Changeset 3404361
- Timestamp:
- 11/27/2025 08:32:56 PM (3 months ago)
- Location:
- 0-day-analytics
- Files:
-
- 10 edited
- 1 copied
-
tags/4.2.1 (copied) (copied from 0-day-analytics/trunk)
-
tags/4.2.1/advanced-analytics.php (modified) (2 diffs)
-
tags/4.2.1/classes/vendor/helpers/class-config-transformer.php (modified) (2 diffs)
-
tags/4.2.1/classes/vendor/helpers/class-settings.php (modified) (12 diffs)
-
tags/4.2.1/classes/vendor/helpers/class-system-analytics.php (modified) (1 diff)
-
tags/4.2.1/readme.txt (modified) (2 diffs)
-
trunk/advanced-analytics.php (modified) (2 diffs)
-
trunk/classes/vendor/helpers/class-config-transformer.php (modified) (2 diffs)
-
trunk/classes/vendor/helpers/class-settings.php (modified) (12 diffs)
-
trunk/classes/vendor/helpers/class-system-analytics.php (modified) (1 diff)
-
trunk/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
0-day-analytics/tags/4.2.1/advanced-analytics.php
r3398360 r3404361 11 11 * Plugin Name: 0 Day Analytics 12 12 * Description: Take full control of error log, crons, transients, plugins, requests, mails and DB tables. 13 * Version: 4.2. 013 * Version: 4.2.1 14 14 * Author: Stoil Dobrev 15 15 * Author URI: https://github.com/sdobreff/ … … 37 37 // Constants. 38 38 if ( ! defined( 'ADVAN_VERSION' ) ) { 39 define( 'ADVAN_VERSION', '4.2. 0' );39 define( 'ADVAN_VERSION', '4.2.1' ); 40 40 define( 'ADVAN_TEXTDOMAIN', '0-day-analytics' ); 41 41 define( 'ADVAN_NAME', '0 Day Analytics' ); -
0-day-analytics/tags/4.2.1/classes/vendor/helpers/class-config-transformer.php
r3384847 r3404361 204 204 } 205 205 206 $anchor_default = self::is_wp_engine() ? "# That's It. Pencils down" : "/* That's all, stop editing!"; 207 206 208 $defaults = array( 207 209 'raw' => false, // Display value in raw format without quotes. 208 'anchor' => "/* That's all, stop editing!", // Config placement anchor string.210 'anchor' => $anchor_default, // Config placement anchor string (may vary by host). 209 211 'separator' => PHP_EOL, // Separator between config definition and anchor string. 210 212 'placement' => 'before', // Config placement direction (insert before or after). … … 359 361 360 362 return sprintf( $placeholder, $name, $value ); 363 } 364 365 /** 366 * Detect if the current environment is WP Engine. 367 * 368 * Uses a few heuristics: known WP Engine constants, environment variables, 369 * or the `$_SERVER['SERVER_SOFTWARE']` string. 370 371 * @return bool True if WP Engine is detected, false otherwise. 372 * 373 * @since 1.2.0 374 */ 375 protected static function is_wp_engine() { 376 if ( defined( 'WPENGINE' ) || defined( 'WPE_APIKEY' ) || defined( 'WPE_CLUSTER' ) ) { 377 return true; 378 } 379 380 if ( getenv( 'WPENGINE' ) || getenv( 'WPE_APIKEY' ) || getenv( 'IS_WPE' ) ) { 381 return true; 382 } 383 384 $server_software = $_SERVER['SERVER_SOFTWARE'] ?? ''; 385 if ( $server_software && false !== stripos( $server_software, 'wp engine' ) ) { 386 return true; 387 } 388 389 return false; 361 390 } 362 391 -
0-day-analytics/tags/4.2.1/classes/vendor/helpers/class-settings.php
r3398360 r3404361 160 160 161 161 \add_action( 'admin_enqueue_scripts', array( __CLASS__, 'load_custom_wp_admin_style' ) ); 162 163 // Show any stored wp-config transformer errors after a settings save. 164 \add_action( 'admin_notices', array( __CLASS__, 'show_config_transformer_errors' ) ); 162 165 163 166 /* Crons start */ … … 238 241 }); 239 242 </script> 240 <?php } 243 <?php 244 } 241 245 242 246 // $hook is string value given add_menu_page function. … … 1508 1512 'title' => esc_html__( '0 day', '0-day-analytics' ), 1509 1513 'href' => add_query_arg( 'page', Logs_List::MENU_SLUG, network_admin_url( 'admin.php' ) ), 1510 'meta' => array( 'class' => 'aadvan-live-notif-item', 'aria-label' => esc_attr__( 'Analytics notifications', '0-day-analytics' ) ), 1514 'meta' => array( 1515 'class' => 'aadvan-live-notif-item', 1516 'aria-label' => esc_attr__( 'Analytics notifications', '0-day-analytics' ), 1517 ), 1511 1518 ) 1512 1519 ); … … 1740 1747 if ( ! $import && ! is_a( Config_Transformer::init(), '\WP_Error' ) ) { 1741 1748 1749 // Collect wp-config transformer errors during this save flow so we can show them as an admin notice. 1750 $config_errors = array(); 1751 1742 1752 $wp_debug_enable = ( array_key_exists( 'wp_debug_enable', $post_array ) ) ? filter_var( $post_array['wp_debug_enable'], FILTER_VALIDATE_BOOLEAN ) : false; 1743 1753 1744 Config_Transformer::update( 'constant', 'WP_DEBUG', $wp_debug_enable, self::$config_args ); 1754 try { 1755 Config_Transformer::update( 'constant', 'WP_DEBUG', $wp_debug_enable, self::$config_args ); 1756 } catch ( \Throwable $e ) { 1757 $config_errors[] = array( 1758 'context' => self::build_config_error_context( 'update', 'WP_DEBUG', $wp_debug_enable ), 1759 'message' => $e->getMessage(), 1760 ); 1761 } 1745 1762 1746 1763 $wp_debug_display_enable = ( array_key_exists( 'wp_debug_display_enable', $post_array ) ) ? filter_var( $post_array['wp_debug_display_enable'], FILTER_VALIDATE_BOOLEAN ) : false; 1747 1764 1748 Config_Transformer::update( 'constant', 'WP_DEBUG_DISPLAY', $wp_debug_display_enable, self::$config_args ); 1765 try { 1766 Config_Transformer::update( 'constant', 'WP_DEBUG_DISPLAY', $wp_debug_display_enable, self::$config_args ); 1767 } catch ( \Throwable $e ) { 1768 $config_errors[] = array( 1769 'context' => self::build_config_error_context( 'update', 'WP_DEBUG_DISPLAY', $wp_debug_display_enable ), 1770 'message' => $e->getMessage(), 1771 ); 1772 } 1749 1773 1750 1774 $wp_script_debug = ( array_key_exists( 'wp_script_debug', $post_array ) ) ? filter_var( $post_array['wp_script_debug'], FILTER_VALIDATE_BOOLEAN ) : false; 1751 1775 1752 Config_Transformer::update( 'constant', 'SCRIPT_DEBUG', $wp_script_debug, self::$config_args ); 1776 try { 1777 Config_Transformer::update( 'constant', 'SCRIPT_DEBUG', $wp_script_debug, self::$config_args ); 1778 } catch ( \Throwable $e ) { 1779 $config_errors[] = array( 1780 'context' => self::build_config_error_context( 'update', 'SCRIPT_DEBUG', $wp_script_debug ), 1781 'message' => $e->getMessage(), 1782 ); 1783 } 1753 1784 1754 1785 $wp_save_queries = ( array_key_exists( 'wp_save_queries', $post_array ) ) ? filter_var( $post_array['wp_save_queries'], FILTER_VALIDATE_BOOLEAN ) : false; 1755 1786 1756 Config_Transformer::update( 'constant', 'SAVEQUERIES', $wp_save_queries, self::$config_args ); 1787 try { 1788 Config_Transformer::update( 'constant', 'SAVEQUERIES', $wp_save_queries, self::$config_args ); 1789 } catch ( \Throwable $e ) { 1790 $config_errors[] = array( 1791 'context' => self::build_config_error_context( 'update', 'SAVEQUERIES', $wp_save_queries ), 1792 'message' => $e->getMessage(), 1793 ); 1794 } 1757 1795 1758 1796 $wp_environment_type = ( array_key_exists( 'wp_environment_type', $post_array ) ) ? \sanitize_text_field( \wp_unslash( $post_array['wp_environment_type'] ) ) : false; … … 1762 1800 } 1763 1801 1764 Config_Transformer::update( 'constant', 'WP_ENVIRONMENT_TYPE', $wp_environment_type, self::$config_args ); 1802 try { 1803 Config_Transformer::update( 'constant', 'WP_ENVIRONMENT_TYPE', $wp_environment_type, self::$config_args ); 1804 } catch ( \Throwable $e ) { 1805 $config_errors[] = array( 1806 'context' => self::build_config_error_context( 'update', 'WP_ENVIRONMENT_TYPE', $wp_environment_type ), 1807 'message' => $e->getMessage(), 1808 ); 1809 } 1765 1810 1766 1811 $wp_development_mode = ( array_key_exists( 'wp_development_mode', $post_array ) ) ? \sanitize_text_field( \wp_unslash( $post_array['wp_development_mode'] ) ) : false; … … 1770 1815 } 1771 1816 1772 Config_Transformer::update( 'constant', 'WP_DEVELOPMENT_MODE', $wp_development_mode, self::$config_args ); 1817 try { 1818 Config_Transformer::update( 'constant', 'WP_DEVELOPMENT_MODE', $wp_development_mode, self::$config_args ); 1819 } catch ( \Throwable $e ) { 1820 $config_errors[] = array( 1821 'context' => self::build_config_error_context( 'update', 'WP_DEVELOPMENT_MODE', $wp_development_mode ), 1822 'message' => $e->getMessage(), 1823 ); 1824 } 1773 1825 1774 1826 $wp_debug_log_enable = ( array_key_exists( 'wp_debug_log_enable', $post_array ) ) ? filter_var( $post_array['wp_debug_log_enable'], FILTER_VALIDATE_BOOLEAN ) : false; 1775 1827 1776 Config_Transformer::update( 'constant', 'WP_DEBUG_LOG', $wp_debug_log_enable, self::$config_args ); 1828 try { 1829 Config_Transformer::update( 'constant', 'WP_DEBUG_LOG', $wp_debug_log_enable, self::$config_args ); 1830 } catch ( \Throwable $e ) { 1831 $config_errors[] = array( 1832 'context' => self::build_config_error_context( 'update', 'WP_DEBUG_LOG', $wp_debug_log_enable ), 1833 'message' => $e->getMessage(), 1834 ); 1835 } 1777 1836 1778 1837 if ( $wp_debug_log_enable ) { … … 1786 1845 // Allow only paths inside WP_CONTENT_DIR to mitigate arbitrary path writes. 1787 1846 if ( 0 === strpos( $candidate, $content_root ) && \is_writable( \dirname( $candidate ) ) ) { 1788 Config_Transformer::update( 'constant', 'WP_DEBUG_LOG', $candidate, self::$config_args ); 1847 try { 1848 Config_Transformer::update( 'constant', 'WP_DEBUG_LOG', $candidate, self::$config_args ); 1849 } catch ( \Throwable $e ) { 1850 $config_errors[] = array( 1851 'context' => self::build_config_error_context( 'update', 'WP_DEBUG_LOG', $candidate ), 1852 'message' => $e->getMessage(), 1853 ); 1854 } 1789 1855 } 1790 1856 } … … 1793 1859 $file_name = \WP_CONTENT_DIR . \DIRECTORY_SEPARATOR . 'debug_' . File_Helper::generate_random_file_name() . '.log'; 1794 1860 1795 Config_Transformer::update( 'constant', 'WP_DEBUG_LOG', $file_name, self::$config_args ); 1861 try { 1862 Config_Transformer::update( 'constant', 'WP_DEBUG_LOG', $file_name, self::$config_args ); 1863 } catch ( \Throwable $e ) { 1864 $config_errors[] = array( 1865 'context' => self::build_config_error_context( 'update', 'WP_DEBUG_LOG', $file_name ), 1866 'message' => $e->getMessage(), 1867 ); 1868 } 1796 1869 } 1797 1870 … … 1803 1876 $wp_cron_disable = ( array_key_exists( 'wp_cron_disable', $post_array ) ) ? filter_var( $post_array['wp_cron_disable'], FILTER_VALIDATE_BOOLEAN ) : false; 1804 1877 1805 Config_Transformer::update( 'constant', 'DISABLE_WP_CRON', $wp_cron_disable, self::$config_args ); 1878 try { 1879 Config_Transformer::update( 'constant', 'DISABLE_WP_CRON', $wp_cron_disable, self::$config_args ); 1880 } catch ( \Throwable $e ) { 1881 $config_errors[] = array( 1882 'context' => self::build_config_error_context( 'update', 'DISABLE_WP_CRON', $wp_cron_disable ), 1883 'message' => $e->getMessage(), 1884 ); 1885 } 1806 1886 1807 1887 $block_external_requests = ( array_key_exists( 'block_external_requests', $post_array ) ) ? filter_var( $post_array['block_external_requests'], FILTER_VALIDATE_BOOLEAN ) : false; 1808 1888 1809 Config_Transformer::update( 'constant', 'WP_HTTP_BLOCK_EXTERNAL', $block_external_requests, self::$config_args ); 1889 try { 1890 Config_Transformer::update( 'constant', 'WP_HTTP_BLOCK_EXTERNAL', $block_external_requests, self::$config_args ); 1891 } catch ( \Throwable $e ) { 1892 $config_errors[] = array( 1893 'context' => self::build_config_error_context( 'update', 'WP_HTTP_BLOCK_EXTERNAL', $block_external_requests ), 1894 'message' => $e->getMessage(), 1895 ); 1896 } 1810 1897 1811 1898 @clearstatcache( false, File_Helper::get_wp_config_file_path() ); 1899 1900 if ( ! empty( $config_errors ) ) { 1901 // Persist messages across the redirect so admin_notices can display them. 1902 try { 1903 \update_option( 'advan_config_transformer_errors', $config_errors ); 1904 } catch ( \Throwable $e ) { 1905 // Ignore failures updating the option. 1906 } 1907 } 1812 1908 } 1813 1909 … … 1881 1977 } 1882 1978 $segments = explode( '.', $path ); 1883 $ref =& $data;1979 $ref =& $data; 1884 1980 $found = true; 1885 1981 foreach ( $segments as $seg ) { … … 1896 1992 } 1897 1993 } 1898 1899 1994 1900 1995 /** … … 1930 2025 1931 2026 /** 2027 * Show stored Config_Transformer errors as an admin notice. 2028 2029 /** 2030 * Build a short context string for a wp-config operation. 2031 * 2032 * @param string $action Action performed (e.g. 'update'). 2033 * @param string $name Config name (constant or variable). 2034 * @param mixed $value Optional value attempted to set. 2035 * 2036 * @return string 2037 */ 2038 protected static function build_config_error_context( $action, $name, $value = null ) { 2039 $ctx = ucfirst( (string) $action ) . ' ' . (string) $name; 2040 if ( null !== $value ) { 2041 if ( is_bool( $value ) ) { 2042 $val = $value ? 'true' : 'false'; 2043 } elseif ( is_scalar( $value ) ) { 2044 $val = (string) $value; 2045 } else { 2046 $val = json_encode( $value ); 2047 } 2048 $ctx .= ' (value: ' . $val . ')'; 2049 } 2050 return $ctx; 2051 } 2052 2053 /** 2054 * 2055 * Reads persisted errors from the options table, displays them, and 2056 * then removes the stored errors so the notice is shown only once. 2057 * 2058 * @return void 2059 * 2060 * @since 1.2.0 2061 */ 2062 public static function show_config_transformer_errors() { 2063 if ( ! \is_admin() ) { 2064 return; 2065 } 2066 2067 if ( ! \current_user_can( 'manage_options' ) ) { 2068 return; 2069 } 2070 2071 $errors = \get_option( 'advan_config_transformer_errors', array() ); 2072 if ( empty( $errors ) || ! is_array( $errors ) ) { 2073 return; 2074 } 2075 2076 // Remove stored option so notice is not shown again. 2077 \delete_option( 'advan_config_transformer_errors' ); 2078 2079 echo '<div class="notice notice-error is-dismissible"><p><strong>' . \esc_html__( 'wp-config.php update warnings', '0-day-analytics' ) . '</strong></p><ul>'; 2080 foreach ( $errors as $err ) { 2081 if ( is_array( $err ) ) { 2082 $context = isset( $err['context'] ) ? $err['context'] : ''; 2083 $message = isset( $err['message'] ) ? $err['message'] : ''; 2084 echo '<li><strong>' . \esc_html( (string) $context ) . ':</strong> ' . \esc_html( (string) $message ) . '</li>'; 2085 } else { 2086 echo '<li>' . \esc_html( (string) $err ) . '</li>'; 2087 } 2088 } 2089 echo '</ul></div>'; 2090 } 2091 2092 /** 1932 2093 * Sets severity as enabled 1933 2094 * -
0-day-analytics/tags/4.2.1/classes/vendor/helpers/class-system-analytics.php
r3398360 r3404361 297 297 $data = @file( '/proc/meminfo' ); 298 298 $meminfo = array(); 299 300 if ( false === $data ) { 301 return null; 302 } 303 299 304 foreach ( $data as $line ) { 300 305 list($key, $val) = explode( ':', $line ); -
0-day-analytics/tags/4.2.1/readme.txt
r3398360 r3404361 4 4 Tested up to: 6.8 5 5 Requires PHP: 7.4 6 Stable tag: 4.2. 06 Stable tag: 4.2.1 7 7 License: GPLv3 or later 8 8 License URI: http://www.gnu.org/licenses/gpl-3.0.txt … … 114 114 == Changelog == 115 115 116 = 4.2.1 = 117 Small maintenance update - improved env compatibility, code fixes and optimizations. 118 116 119 = 4.2.0 = 117 120 New filters introduced. Code optimizations and bug fixes. File editor extending. -
0-day-analytics/trunk/advanced-analytics.php
r3398360 r3404361 11 11 * Plugin Name: 0 Day Analytics 12 12 * Description: Take full control of error log, crons, transients, plugins, requests, mails and DB tables. 13 * Version: 4.2. 013 * Version: 4.2.1 14 14 * Author: Stoil Dobrev 15 15 * Author URI: https://github.com/sdobreff/ … … 37 37 // Constants. 38 38 if ( ! defined( 'ADVAN_VERSION' ) ) { 39 define( 'ADVAN_VERSION', '4.2. 0' );39 define( 'ADVAN_VERSION', '4.2.1' ); 40 40 define( 'ADVAN_TEXTDOMAIN', '0-day-analytics' ); 41 41 define( 'ADVAN_NAME', '0 Day Analytics' ); -
0-day-analytics/trunk/classes/vendor/helpers/class-config-transformer.php
r3384847 r3404361 204 204 } 205 205 206 $anchor_default = self::is_wp_engine() ? "# That's It. Pencils down" : "/* That's all, stop editing!"; 207 206 208 $defaults = array( 207 209 'raw' => false, // Display value in raw format without quotes. 208 'anchor' => "/* That's all, stop editing!", // Config placement anchor string.210 'anchor' => $anchor_default, // Config placement anchor string (may vary by host). 209 211 'separator' => PHP_EOL, // Separator between config definition and anchor string. 210 212 'placement' => 'before', // Config placement direction (insert before or after). … … 359 361 360 362 return sprintf( $placeholder, $name, $value ); 363 } 364 365 /** 366 * Detect if the current environment is WP Engine. 367 * 368 * Uses a few heuristics: known WP Engine constants, environment variables, 369 * or the `$_SERVER['SERVER_SOFTWARE']` string. 370 371 * @return bool True if WP Engine is detected, false otherwise. 372 * 373 * @since 1.2.0 374 */ 375 protected static function is_wp_engine() { 376 if ( defined( 'WPENGINE' ) || defined( 'WPE_APIKEY' ) || defined( 'WPE_CLUSTER' ) ) { 377 return true; 378 } 379 380 if ( getenv( 'WPENGINE' ) || getenv( 'WPE_APIKEY' ) || getenv( 'IS_WPE' ) ) { 381 return true; 382 } 383 384 $server_software = $_SERVER['SERVER_SOFTWARE'] ?? ''; 385 if ( $server_software && false !== stripos( $server_software, 'wp engine' ) ) { 386 return true; 387 } 388 389 return false; 361 390 } 362 391 -
0-day-analytics/trunk/classes/vendor/helpers/class-settings.php
r3398360 r3404361 160 160 161 161 \add_action( 'admin_enqueue_scripts', array( __CLASS__, 'load_custom_wp_admin_style' ) ); 162 163 // Show any stored wp-config transformer errors after a settings save. 164 \add_action( 'admin_notices', array( __CLASS__, 'show_config_transformer_errors' ) ); 162 165 163 166 /* Crons start */ … … 238 241 }); 239 242 </script> 240 <?php } 243 <?php 244 } 241 245 242 246 // $hook is string value given add_menu_page function. … … 1508 1512 'title' => esc_html__( '0 day', '0-day-analytics' ), 1509 1513 'href' => add_query_arg( 'page', Logs_List::MENU_SLUG, network_admin_url( 'admin.php' ) ), 1510 'meta' => array( 'class' => 'aadvan-live-notif-item', 'aria-label' => esc_attr__( 'Analytics notifications', '0-day-analytics' ) ), 1514 'meta' => array( 1515 'class' => 'aadvan-live-notif-item', 1516 'aria-label' => esc_attr__( 'Analytics notifications', '0-day-analytics' ), 1517 ), 1511 1518 ) 1512 1519 ); … … 1740 1747 if ( ! $import && ! is_a( Config_Transformer::init(), '\WP_Error' ) ) { 1741 1748 1749 // Collect wp-config transformer errors during this save flow so we can show them as an admin notice. 1750 $config_errors = array(); 1751 1742 1752 $wp_debug_enable = ( array_key_exists( 'wp_debug_enable', $post_array ) ) ? filter_var( $post_array['wp_debug_enable'], FILTER_VALIDATE_BOOLEAN ) : false; 1743 1753 1744 Config_Transformer::update( 'constant', 'WP_DEBUG', $wp_debug_enable, self::$config_args ); 1754 try { 1755 Config_Transformer::update( 'constant', 'WP_DEBUG', $wp_debug_enable, self::$config_args ); 1756 } catch ( \Throwable $e ) { 1757 $config_errors[] = array( 1758 'context' => self::build_config_error_context( 'update', 'WP_DEBUG', $wp_debug_enable ), 1759 'message' => $e->getMessage(), 1760 ); 1761 } 1745 1762 1746 1763 $wp_debug_display_enable = ( array_key_exists( 'wp_debug_display_enable', $post_array ) ) ? filter_var( $post_array['wp_debug_display_enable'], FILTER_VALIDATE_BOOLEAN ) : false; 1747 1764 1748 Config_Transformer::update( 'constant', 'WP_DEBUG_DISPLAY', $wp_debug_display_enable, self::$config_args ); 1765 try { 1766 Config_Transformer::update( 'constant', 'WP_DEBUG_DISPLAY', $wp_debug_display_enable, self::$config_args ); 1767 } catch ( \Throwable $e ) { 1768 $config_errors[] = array( 1769 'context' => self::build_config_error_context( 'update', 'WP_DEBUG_DISPLAY', $wp_debug_display_enable ), 1770 'message' => $e->getMessage(), 1771 ); 1772 } 1749 1773 1750 1774 $wp_script_debug = ( array_key_exists( 'wp_script_debug', $post_array ) ) ? filter_var( $post_array['wp_script_debug'], FILTER_VALIDATE_BOOLEAN ) : false; 1751 1775 1752 Config_Transformer::update( 'constant', 'SCRIPT_DEBUG', $wp_script_debug, self::$config_args ); 1776 try { 1777 Config_Transformer::update( 'constant', 'SCRIPT_DEBUG', $wp_script_debug, self::$config_args ); 1778 } catch ( \Throwable $e ) { 1779 $config_errors[] = array( 1780 'context' => self::build_config_error_context( 'update', 'SCRIPT_DEBUG', $wp_script_debug ), 1781 'message' => $e->getMessage(), 1782 ); 1783 } 1753 1784 1754 1785 $wp_save_queries = ( array_key_exists( 'wp_save_queries', $post_array ) ) ? filter_var( $post_array['wp_save_queries'], FILTER_VALIDATE_BOOLEAN ) : false; 1755 1786 1756 Config_Transformer::update( 'constant', 'SAVEQUERIES', $wp_save_queries, self::$config_args ); 1787 try { 1788 Config_Transformer::update( 'constant', 'SAVEQUERIES', $wp_save_queries, self::$config_args ); 1789 } catch ( \Throwable $e ) { 1790 $config_errors[] = array( 1791 'context' => self::build_config_error_context( 'update', 'SAVEQUERIES', $wp_save_queries ), 1792 'message' => $e->getMessage(), 1793 ); 1794 } 1757 1795 1758 1796 $wp_environment_type = ( array_key_exists( 'wp_environment_type', $post_array ) ) ? \sanitize_text_field( \wp_unslash( $post_array['wp_environment_type'] ) ) : false; … … 1762 1800 } 1763 1801 1764 Config_Transformer::update( 'constant', 'WP_ENVIRONMENT_TYPE', $wp_environment_type, self::$config_args ); 1802 try { 1803 Config_Transformer::update( 'constant', 'WP_ENVIRONMENT_TYPE', $wp_environment_type, self::$config_args ); 1804 } catch ( \Throwable $e ) { 1805 $config_errors[] = array( 1806 'context' => self::build_config_error_context( 'update', 'WP_ENVIRONMENT_TYPE', $wp_environment_type ), 1807 'message' => $e->getMessage(), 1808 ); 1809 } 1765 1810 1766 1811 $wp_development_mode = ( array_key_exists( 'wp_development_mode', $post_array ) ) ? \sanitize_text_field( \wp_unslash( $post_array['wp_development_mode'] ) ) : false; … … 1770 1815 } 1771 1816 1772 Config_Transformer::update( 'constant', 'WP_DEVELOPMENT_MODE', $wp_development_mode, self::$config_args ); 1817 try { 1818 Config_Transformer::update( 'constant', 'WP_DEVELOPMENT_MODE', $wp_development_mode, self::$config_args ); 1819 } catch ( \Throwable $e ) { 1820 $config_errors[] = array( 1821 'context' => self::build_config_error_context( 'update', 'WP_DEVELOPMENT_MODE', $wp_development_mode ), 1822 'message' => $e->getMessage(), 1823 ); 1824 } 1773 1825 1774 1826 $wp_debug_log_enable = ( array_key_exists( 'wp_debug_log_enable', $post_array ) ) ? filter_var( $post_array['wp_debug_log_enable'], FILTER_VALIDATE_BOOLEAN ) : false; 1775 1827 1776 Config_Transformer::update( 'constant', 'WP_DEBUG_LOG', $wp_debug_log_enable, self::$config_args ); 1828 try { 1829 Config_Transformer::update( 'constant', 'WP_DEBUG_LOG', $wp_debug_log_enable, self::$config_args ); 1830 } catch ( \Throwable $e ) { 1831 $config_errors[] = array( 1832 'context' => self::build_config_error_context( 'update', 'WP_DEBUG_LOG', $wp_debug_log_enable ), 1833 'message' => $e->getMessage(), 1834 ); 1835 } 1777 1836 1778 1837 if ( $wp_debug_log_enable ) { … … 1786 1845 // Allow only paths inside WP_CONTENT_DIR to mitigate arbitrary path writes. 1787 1846 if ( 0 === strpos( $candidate, $content_root ) && \is_writable( \dirname( $candidate ) ) ) { 1788 Config_Transformer::update( 'constant', 'WP_DEBUG_LOG', $candidate, self::$config_args ); 1847 try { 1848 Config_Transformer::update( 'constant', 'WP_DEBUG_LOG', $candidate, self::$config_args ); 1849 } catch ( \Throwable $e ) { 1850 $config_errors[] = array( 1851 'context' => self::build_config_error_context( 'update', 'WP_DEBUG_LOG', $candidate ), 1852 'message' => $e->getMessage(), 1853 ); 1854 } 1789 1855 } 1790 1856 } … … 1793 1859 $file_name = \WP_CONTENT_DIR . \DIRECTORY_SEPARATOR . 'debug_' . File_Helper::generate_random_file_name() . '.log'; 1794 1860 1795 Config_Transformer::update( 'constant', 'WP_DEBUG_LOG', $file_name, self::$config_args ); 1861 try { 1862 Config_Transformer::update( 'constant', 'WP_DEBUG_LOG', $file_name, self::$config_args ); 1863 } catch ( \Throwable $e ) { 1864 $config_errors[] = array( 1865 'context' => self::build_config_error_context( 'update', 'WP_DEBUG_LOG', $file_name ), 1866 'message' => $e->getMessage(), 1867 ); 1868 } 1796 1869 } 1797 1870 … … 1803 1876 $wp_cron_disable = ( array_key_exists( 'wp_cron_disable', $post_array ) ) ? filter_var( $post_array['wp_cron_disable'], FILTER_VALIDATE_BOOLEAN ) : false; 1804 1877 1805 Config_Transformer::update( 'constant', 'DISABLE_WP_CRON', $wp_cron_disable, self::$config_args ); 1878 try { 1879 Config_Transformer::update( 'constant', 'DISABLE_WP_CRON', $wp_cron_disable, self::$config_args ); 1880 } catch ( \Throwable $e ) { 1881 $config_errors[] = array( 1882 'context' => self::build_config_error_context( 'update', 'DISABLE_WP_CRON', $wp_cron_disable ), 1883 'message' => $e->getMessage(), 1884 ); 1885 } 1806 1886 1807 1887 $block_external_requests = ( array_key_exists( 'block_external_requests', $post_array ) ) ? filter_var( $post_array['block_external_requests'], FILTER_VALIDATE_BOOLEAN ) : false; 1808 1888 1809 Config_Transformer::update( 'constant', 'WP_HTTP_BLOCK_EXTERNAL', $block_external_requests, self::$config_args ); 1889 try { 1890 Config_Transformer::update( 'constant', 'WP_HTTP_BLOCK_EXTERNAL', $block_external_requests, self::$config_args ); 1891 } catch ( \Throwable $e ) { 1892 $config_errors[] = array( 1893 'context' => self::build_config_error_context( 'update', 'WP_HTTP_BLOCK_EXTERNAL', $block_external_requests ), 1894 'message' => $e->getMessage(), 1895 ); 1896 } 1810 1897 1811 1898 @clearstatcache( false, File_Helper::get_wp_config_file_path() ); 1899 1900 if ( ! empty( $config_errors ) ) { 1901 // Persist messages across the redirect so admin_notices can display them. 1902 try { 1903 \update_option( 'advan_config_transformer_errors', $config_errors ); 1904 } catch ( \Throwable $e ) { 1905 // Ignore failures updating the option. 1906 } 1907 } 1812 1908 } 1813 1909 … … 1881 1977 } 1882 1978 $segments = explode( '.', $path ); 1883 $ref =& $data;1979 $ref =& $data; 1884 1980 $found = true; 1885 1981 foreach ( $segments as $seg ) { … … 1896 1992 } 1897 1993 } 1898 1899 1994 1900 1995 /** … … 1930 2025 1931 2026 /** 2027 * Show stored Config_Transformer errors as an admin notice. 2028 2029 /** 2030 * Build a short context string for a wp-config operation. 2031 * 2032 * @param string $action Action performed (e.g. 'update'). 2033 * @param string $name Config name (constant or variable). 2034 * @param mixed $value Optional value attempted to set. 2035 * 2036 * @return string 2037 */ 2038 protected static function build_config_error_context( $action, $name, $value = null ) { 2039 $ctx = ucfirst( (string) $action ) . ' ' . (string) $name; 2040 if ( null !== $value ) { 2041 if ( is_bool( $value ) ) { 2042 $val = $value ? 'true' : 'false'; 2043 } elseif ( is_scalar( $value ) ) { 2044 $val = (string) $value; 2045 } else { 2046 $val = json_encode( $value ); 2047 } 2048 $ctx .= ' (value: ' . $val . ')'; 2049 } 2050 return $ctx; 2051 } 2052 2053 /** 2054 * 2055 * Reads persisted errors from the options table, displays them, and 2056 * then removes the stored errors so the notice is shown only once. 2057 * 2058 * @return void 2059 * 2060 * @since 1.2.0 2061 */ 2062 public static function show_config_transformer_errors() { 2063 if ( ! \is_admin() ) { 2064 return; 2065 } 2066 2067 if ( ! \current_user_can( 'manage_options' ) ) { 2068 return; 2069 } 2070 2071 $errors = \get_option( 'advan_config_transformer_errors', array() ); 2072 if ( empty( $errors ) || ! is_array( $errors ) ) { 2073 return; 2074 } 2075 2076 // Remove stored option so notice is not shown again. 2077 \delete_option( 'advan_config_transformer_errors' ); 2078 2079 echo '<div class="notice notice-error is-dismissible"><p><strong>' . \esc_html__( 'wp-config.php update warnings', '0-day-analytics' ) . '</strong></p><ul>'; 2080 foreach ( $errors as $err ) { 2081 if ( is_array( $err ) ) { 2082 $context = isset( $err['context'] ) ? $err['context'] : ''; 2083 $message = isset( $err['message'] ) ? $err['message'] : ''; 2084 echo '<li><strong>' . \esc_html( (string) $context ) . ':</strong> ' . \esc_html( (string) $message ) . '</li>'; 2085 } else { 2086 echo '<li>' . \esc_html( (string) $err ) . '</li>'; 2087 } 2088 } 2089 echo '</ul></div>'; 2090 } 2091 2092 /** 1932 2093 * Sets severity as enabled 1933 2094 * -
0-day-analytics/trunk/classes/vendor/helpers/class-system-analytics.php
r3398360 r3404361 297 297 $data = @file( '/proc/meminfo' ); 298 298 $meminfo = array(); 299 300 if ( false === $data ) { 301 return null; 302 } 303 299 304 foreach ( $data as $line ) { 300 305 list($key, $val) = explode( ':', $line ); -
0-day-analytics/trunk/readme.txt
r3398360 r3404361 4 4 Tested up to: 6.8 5 5 Requires PHP: 7.4 6 Stable tag: 4.2. 06 Stable tag: 4.2.1 7 7 License: GPLv3 or later 8 8 License URI: http://www.gnu.org/licenses/gpl-3.0.txt … … 114 114 == Changelog == 115 115 116 = 4.2.1 = 117 Small maintenance update - improved env compatibility, code fixes and optimizations. 118 116 119 = 4.2.0 = 117 120 New filters introduced. Code optimizations and bug fixes. File editor extending.
Note: See TracChangeset
for help on using the changeset viewer.