Plugin Directory

Changeset 3404361


Ignore:
Timestamp:
11/27/2025 08:32:56 PM (3 months ago)
Author:
awesomefootnotes
Message:

Adding the first version of my plugin

Location:
0-day-analytics
Files:
10 edited
1 copied

Legend:

Unmodified
Added
Removed
  • 0-day-analytics/tags/4.2.1/advanced-analytics.php

    r3398360 r3404361  
    1111 * Plugin Name:     0 Day Analytics
    1212 * Description:     Take full control of error log, crons, transients, plugins, requests, mails and DB tables.
    13  * Version:         4.2.0
     13 * Version:         4.2.1
    1414 * Author:          Stoil Dobrev
    1515 * Author URI:      https://github.com/sdobreff/
     
    3737// Constants.
    3838if ( ! defined( 'ADVAN_VERSION' ) ) {
    39     define( 'ADVAN_VERSION', '4.2.0' );
     39    define( 'ADVAN_VERSION', '4.2.1' );
    4040    define( 'ADVAN_TEXTDOMAIN', '0-day-analytics' );
    4141    define( 'ADVAN_NAME', '0 Day Analytics' );
  • 0-day-analytics/tags/4.2.1/classes/vendor/helpers/class-config-transformer.php

    r3384847 r3404361  
    204204            }
    205205
     206            $anchor_default = self::is_wp_engine() ? "# That's It. Pencils down" : "/* That's all, stop editing!";
     207
    206208            $defaults = array(
    207209                '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).
    209211                'separator' => PHP_EOL, // Separator between config definition and anchor string.
    210212                'placement' => 'before', // Config placement direction (insert before or after).
     
    359361
    360362            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;
    361390        }
    362391
  • 0-day-analytics/tags/4.2.1/classes/vendor/helpers/class-settings.php

    r3398360 r3404361  
    160160
    161161            \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' ) );
    162165
    163166            /* Crons start */
     
    238241                    });
    239242                </script>
    240             <?php }
     243                <?php
     244            }
    241245
    242246            // $hook is string value given add_menu_page function.
     
    15081512                            'title' => esc_html__( '0 day', '0-day-analytics' ),
    15091513                            '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                            ),
    15111518                        )
    15121519                    );
     
    17401747            if ( ! $import && ! is_a( Config_Transformer::init(), '\WP_Error' ) ) {
    17411748
     1749                // Collect wp-config transformer errors during this save flow so we can show them as an admin notice.
     1750                $config_errors = array();
     1751
    17421752                $wp_debug_enable = ( array_key_exists( 'wp_debug_enable', $post_array ) ) ? filter_var( $post_array['wp_debug_enable'], FILTER_VALIDATE_BOOLEAN ) : false;
    17431753
    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                }
    17451762
    17461763                $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;
    17471764
    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                }
    17491773
    17501774                $wp_script_debug = ( array_key_exists( 'wp_script_debug', $post_array ) ) ? filter_var( $post_array['wp_script_debug'], FILTER_VALIDATE_BOOLEAN ) : false;
    17511775
    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                }
    17531784
    17541785                $wp_save_queries = ( array_key_exists( 'wp_save_queries', $post_array ) ) ? filter_var( $post_array['wp_save_queries'], FILTER_VALIDATE_BOOLEAN ) : false;
    17551786
    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                }
    17571795
    17581796                $wp_environment_type = ( array_key_exists( 'wp_environment_type', $post_array ) ) ? \sanitize_text_field( \wp_unslash( $post_array['wp_environment_type'] ) ) : false;
     
    17621800                }
    17631801
    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                }
    17651810
    17661811                $wp_development_mode = ( array_key_exists( 'wp_development_mode', $post_array ) ) ? \sanitize_text_field( \wp_unslash( $post_array['wp_development_mode'] ) ) : false;
     
    17701815                }
    17711816
    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                }
    17731825
    17741826                $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;
    17751827
    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                }
    17771836
    17781837                if ( $wp_debug_log_enable ) {
     
    17861845                        // Allow only paths inside WP_CONTENT_DIR to mitigate arbitrary path writes.
    17871846                        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                            }
    17891855                        }
    17901856                    }
     
    17931859                        $file_name = \WP_CONTENT_DIR . \DIRECTORY_SEPARATOR . 'debug_' . File_Helper::generate_random_file_name() . '.log';
    17941860
    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                        }
    17961869                    }
    17971870
     
    18031876                $wp_cron_disable = ( array_key_exists( 'wp_cron_disable', $post_array ) ) ? filter_var( $post_array['wp_cron_disable'], FILTER_VALIDATE_BOOLEAN ) : false;
    18041877
    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                }
    18061886
    18071887                $block_external_requests = ( array_key_exists( 'block_external_requests', $post_array ) ) ? filter_var( $post_array['block_external_requests'], FILTER_VALIDATE_BOOLEAN ) : false;
    18081888
    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                }
    18101897
    18111898                @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                }
    18121908            }
    18131909
     
    18811977                }
    18821978                $segments = explode( '.', $path );
    1883                 $ref     =& $data;
     1979                $ref      =& $data;
    18841980                $found    = true;
    18851981                foreach ( $segments as $seg ) {
     
    18961992            }
    18971993        }
    1898 
    18991994
    19001995        /**
     
    19302025
    19312026        /**
     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        /**
    19322093         * Sets severity as enabled
    19332094         *
  • 0-day-analytics/tags/4.2.1/classes/vendor/helpers/class-system-analytics.php

    r3398360 r3404361  
    297297                $data    = @file( '/proc/meminfo' );
    298298                $meminfo = array();
     299
     300                if ( false === $data ) {
     301                    return null;
     302                }
     303
    299304                foreach ( $data as $line ) {
    300305                    list($key, $val) = explode( ':', $line );
  • 0-day-analytics/tags/4.2.1/readme.txt

    r3398360 r3404361  
    44Tested up to: 6.8
    55Requires PHP: 7.4
    6 Stable tag: 4.2.0
     6Stable tag: 4.2.1
    77License: GPLv3 or later
    88License URI: http://www.gnu.org/licenses/gpl-3.0.txt
     
    114114== Changelog ==
    115115
     116= 4.2.1 =
     117Small maintenance update - improved env compatibility, code fixes and optimizations.
     118
    116119= 4.2.0 =
    117120New filters introduced. Code optimizations and bug fixes. File editor extending.
  • 0-day-analytics/trunk/advanced-analytics.php

    r3398360 r3404361  
    1111 * Plugin Name:     0 Day Analytics
    1212 * Description:     Take full control of error log, crons, transients, plugins, requests, mails and DB tables.
    13  * Version:         4.2.0
     13 * Version:         4.2.1
    1414 * Author:          Stoil Dobrev
    1515 * Author URI:      https://github.com/sdobreff/
     
    3737// Constants.
    3838if ( ! defined( 'ADVAN_VERSION' ) ) {
    39     define( 'ADVAN_VERSION', '4.2.0' );
     39    define( 'ADVAN_VERSION', '4.2.1' );
    4040    define( 'ADVAN_TEXTDOMAIN', '0-day-analytics' );
    4141    define( 'ADVAN_NAME', '0 Day Analytics' );
  • 0-day-analytics/trunk/classes/vendor/helpers/class-config-transformer.php

    r3384847 r3404361  
    204204            }
    205205
     206            $anchor_default = self::is_wp_engine() ? "# That's It. Pencils down" : "/* That's all, stop editing!";
     207
    206208            $defaults = array(
    207209                '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).
    209211                'separator' => PHP_EOL, // Separator between config definition and anchor string.
    210212                'placement' => 'before', // Config placement direction (insert before or after).
     
    359361
    360362            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;
    361390        }
    362391
  • 0-day-analytics/trunk/classes/vendor/helpers/class-settings.php

    r3398360 r3404361  
    160160
    161161            \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' ) );
    162165
    163166            /* Crons start */
     
    238241                    });
    239242                </script>
    240             <?php }
     243                <?php
     244            }
    241245
    242246            // $hook is string value given add_menu_page function.
     
    15081512                            'title' => esc_html__( '0 day', '0-day-analytics' ),
    15091513                            '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                            ),
    15111518                        )
    15121519                    );
     
    17401747            if ( ! $import && ! is_a( Config_Transformer::init(), '\WP_Error' ) ) {
    17411748
     1749                // Collect wp-config transformer errors during this save flow so we can show them as an admin notice.
     1750                $config_errors = array();
     1751
    17421752                $wp_debug_enable = ( array_key_exists( 'wp_debug_enable', $post_array ) ) ? filter_var( $post_array['wp_debug_enable'], FILTER_VALIDATE_BOOLEAN ) : false;
    17431753
    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                }
    17451762
    17461763                $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;
    17471764
    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                }
    17491773
    17501774                $wp_script_debug = ( array_key_exists( 'wp_script_debug', $post_array ) ) ? filter_var( $post_array['wp_script_debug'], FILTER_VALIDATE_BOOLEAN ) : false;
    17511775
    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                }
    17531784
    17541785                $wp_save_queries = ( array_key_exists( 'wp_save_queries', $post_array ) ) ? filter_var( $post_array['wp_save_queries'], FILTER_VALIDATE_BOOLEAN ) : false;
    17551786
    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                }
    17571795
    17581796                $wp_environment_type = ( array_key_exists( 'wp_environment_type', $post_array ) ) ? \sanitize_text_field( \wp_unslash( $post_array['wp_environment_type'] ) ) : false;
     
    17621800                }
    17631801
    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                }
    17651810
    17661811                $wp_development_mode = ( array_key_exists( 'wp_development_mode', $post_array ) ) ? \sanitize_text_field( \wp_unslash( $post_array['wp_development_mode'] ) ) : false;
     
    17701815                }
    17711816
    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                }
    17731825
    17741826                $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;
    17751827
    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                }
    17771836
    17781837                if ( $wp_debug_log_enable ) {
     
    17861845                        // Allow only paths inside WP_CONTENT_DIR to mitigate arbitrary path writes.
    17871846                        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                            }
    17891855                        }
    17901856                    }
     
    17931859                        $file_name = \WP_CONTENT_DIR . \DIRECTORY_SEPARATOR . 'debug_' . File_Helper::generate_random_file_name() . '.log';
    17941860
    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                        }
    17961869                    }
    17971870
     
    18031876                $wp_cron_disable = ( array_key_exists( 'wp_cron_disable', $post_array ) ) ? filter_var( $post_array['wp_cron_disable'], FILTER_VALIDATE_BOOLEAN ) : false;
    18041877
    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                }
    18061886
    18071887                $block_external_requests = ( array_key_exists( 'block_external_requests', $post_array ) ) ? filter_var( $post_array['block_external_requests'], FILTER_VALIDATE_BOOLEAN ) : false;
    18081888
    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                }
    18101897
    18111898                @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                }
    18121908            }
    18131909
     
    18811977                }
    18821978                $segments = explode( '.', $path );
    1883                 $ref     =& $data;
     1979                $ref      =& $data;
    18841980                $found    = true;
    18851981                foreach ( $segments as $seg ) {
     
    18961992            }
    18971993        }
    1898 
    18991994
    19001995        /**
     
    19302025
    19312026        /**
     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        /**
    19322093         * Sets severity as enabled
    19332094         *
  • 0-day-analytics/trunk/classes/vendor/helpers/class-system-analytics.php

    r3398360 r3404361  
    297297                $data    = @file( '/proc/meminfo' );
    298298                $meminfo = array();
     299
     300                if ( false === $data ) {
     301                    return null;
     302                }
     303
    299304                foreach ( $data as $line ) {
    300305                    list($key, $val) = explode( ':', $line );
  • 0-day-analytics/trunk/readme.txt

    r3398360 r3404361  
    44Tested up to: 6.8
    55Requires PHP: 7.4
    6 Stable tag: 4.2.0
     6Stable tag: 4.2.1
    77License: GPLv3 or later
    88License URI: http://www.gnu.org/licenses/gpl-3.0.txt
     
    114114== Changelog ==
    115115
     116= 4.2.1 =
     117Small maintenance update - improved env compatibility, code fixes and optimizations.
     118
    116119= 4.2.0 =
    117120New filters introduced. Code optimizations and bug fixes. File editor extending.
Note: See TracChangeset for help on using the changeset viewer.