芝麻web文件管理V1.00
编辑当前文件:/home/paymbalq/public_html/wp-content/plugins/w3-total-cache/Minify_Core.php
get_array( 'minify.cache.files' ); $external_regexp = $c->get_boolean( 'minify.cache.files_regexp' ); foreach ( $external as $ext ) { if ( empty( $ext ) ) { continue; } if ( ! $external_regexp && preg_match( '~^' . Util_Environment::get_url_regexp( $ext ) . '~', $file ) && ! $verified ) { $verified = true; } if ( $external_regexp && preg_match( '~' . $ext . '~', $file ) && ! $verified ) { $verified = true; } } if ( ! $verified ) { self::debug_error( sprintf( 'Remote file not in external files/libraries list: "%s"', $file ) ); } } elseif ( /* no ".." */ strpos( $file, '..' ) !== false || /* no "//" */ strpos( $file, '//' ) !== false || /* no "\" */ ( strpos( $file, '\\' ) !== false && 'WIN' !== strtoupper( substr( PHP_OS, 0, 3 ) ) ) || /* no "./" */ preg_match( '/(?:^|[^\\.])\\.\\//', $file ) || /* no unwanted chars */ ! preg_match( '/^[a-zA-Z0-9_.\\/-]|[\\\\]+$/', $file ) ) { $verified = false; self::debug_error( sprintf( 'File path invalid: "%s"', $file ) ); } else { $verified = true; } if ( $verified ) { $urls[] = $file; } } return $urls; } /** * Retrieves the URL for a minified file. * * @param string $minify_filename The filename of the minified file. * * @return string The URL of the minified file. */ public static function minified_url( $minify_filename ) { $path = Util_Environment::cache_blog_minify_dir(); $filename = $path . '/' . $minify_filename; $c = Dispatcher::config(); if ( Util_Rule::can_check_rules() && $c->get_boolean( 'minify.rewrite' ) ) { return Util_Environment::filename_to_url( $filename ); } return home_url( '?w3tc_minify=' . $minify_filename ); } /** * Logs an error message for debugging. * * @param string $error The error message to log. * * @return void */ public static function debug_error( $error ) { $c = Dispatcher::config(); $debug = $c->get_boolean( 'minify.debug' ); if ( $debug ) { self::log( $error ); echo "\r\n/* " . esc_html( $error ) . " */\r\n"; } } /** * Logs a message to the minify log file. * * @param string $msg The message to log. * * @return bool True if the message was successfully written, false otherwise. */ public static function log( $msg ) { $data = sprintf( "[%s] [%s] [%s] %s\n", gmdate( 'r' ), isset( $_SERVER['REQUEST_URI'] ) ? esc_url_raw( wp_unslash( $_SERVER['REQUEST_URI'] ) ) : '', ! empty( $_SERVER['HTTP_REFERER'] ) ? sanitize_text_field( wp_unslash( $_SERVER['HTTP_REFERER'] ) ) : '-', $msg ); $data = strtr( $data, '<>', '..' ); $filename = Util_Debug::log_filename( 'minify' ); return @file_put_contents( $filename, $data, FILE_APPEND ); } /** * Retrieves the cache configuration for usage statistics based on the minify engine. * * phpcs:disable WordPress.NamingConventions.ValidVariableName.VariableNotSnakeCase * * @return array The cache configuration for the minify engine. */ public function get_usage_statistics_cache_config() { $c = Dispatcher::config(); $engine = $c->get_string( 'minify.engine' ); switch ( $engine ) { case 'memcached': $engineConfig = array( 'servers' => $c->get_array( 'minify.memcached.servers' ), 'persistent' => $c->get_boolean( 'minify.memcached.persistent' ), 'aws_autodiscovery' => $c->get_boolean( 'minify.memcached.aws_autodiscovery' ), 'username' => $c->get_string( 'minify.memcached.username' ), 'password' => $c->get_string( 'minify.memcached.password' ), ); break; case 'redis': $engineConfig = array( 'servers' => $c->get_array( 'minify.redis.servers' ), 'verify_tls_certificates' => $c->get_boolean( 'minify.redis.verify_tls_certificates' ), 'persistent' => $c->get_boolean( 'minify.redis.persistent' ), 'timeout' => $c->get_integer( 'minify.redis.timeout' ), 'retry_interval' => $c->get_integer( 'minify.redis.retry_interval' ), 'read_timeout' => $c->get_integer( 'minify.redis.read_timeout' ), 'dbid' => $c->get_integer( 'minify.redis.dbid' ), 'password' => $c->get_string( 'minify.redis.password' ), ); break; default: $engineConfig = array(); } $engineConfig['engine'] = $engine; return $engineConfig; } }