芝麻web文件管理V1.00
编辑当前文件:/home/paymbalq/www/wp-content/plugins/w3-total-cache/Util_Activation.php
', addslashes( $reactivate_url ) ); self::_error( sprintf( // Translators: 1 error message, 2 reactivate button. __( '%1$s
then %2$s.', 'w3-total-cache' ), $e->getMessage(), $reactivate_button ) ); } /** * W3 writable error * * @param string $path Path. * @param string[] $chmod_dirs Directories that should be chmod 777 inorder to write. * * @throws \Exception Exception. * * @return void */ public static function throw_on_write_error( $path, $chmod_dirs = array() ) { $chmods = ''; if ( $chmod_dirs ) { $chmods = '
'; foreach ( $chmod_dirs as $dir ) { $chmods .= sprintf( // Translators: 1 opening HTML li tag followed by opening HTML strong tag, 2 directory name // Translators: 3 closing HTML strong tag followed by closing HTML li tag. __( '%1$schmod 777 %2$s%3$s', 'w3-total-cache' ), '
', $dir, '
' ); } } else { $chmods = sprintf( '
chmod 777 %s
', file_exists( $path ) ? $path : dirname( $path ) ); } if ( Util_File::check_open_basedir( $path ) ) { $error = sprintf( // Translators: 1 opening HTML strong tag, 2 file path, 3 closing HTML strong tag // Translators: 4 HTML line break, 5 chmod values. __( '%1$s%2$s%3$s could not be created, please run following command:%4$s%5$s', 'w3-total-cache' ), '
', $path, '
', '
', $chmods ); } else { $error = sprintf( // Translators: 1 opening HTML strong tag, 2 file path, 3 closing HTML strong tag // Translators: 4 HTML line break followed by opening HTML strong tag, 5 open basedir value. __( '%1$s%2$s%3$s could not be created, %1$sopen_basedir%3$s restriction in effect, please check your php.ini settings:%4$sopen_basedir = "%5$s"%3$s', 'w3-total-cache' ), '
', $path, '
', '
', ini_get( 'open_basedir' ) ); } throw new \Exception( \esc_html( $error ) ); } /** * Creates maintenance mode file * * @param unknown $time Time. * * @return void */ public static function enable_maintenance_mode( $time = null ) { if ( is_null( $time ) ) { $time = 'time()'; } Util_WpFile::write_to_file( Util_Environment::site_path() . '/.maintenance', "" ); } /** * Deletes maintenance mode file * * @return void */ public static function disable_maintenance_mode() { Util_WpFile::delete_file( Util_Environment::site_path() . '/.maintenance' ); } /** * Used to display Util_Environment_Exceptions in UI * * @param Util_Environment_Exceptions $exs Environment exceptions. * * @return array(before_errors = [], required_changes =>, later_errors => []) */ public static function parse_environment_exceptions( $exs ) { $exceptions = $exs->exceptions(); $commands = ''; $required_changes = ''; $before_errors = array(); $later_errors = array(); $operation_error_already_shown = false; foreach ( $exceptions as $ex ) { if ( $ex instanceof Util_WpFile_FilesystemOperationException ) { if ( ! $operation_error_already_shown ) { $m = $ex->getMessage(); if ( strlen( $m ) > 0 ) { $before_errors[] = $m; // if multiple operations failed when they tried to fix environment - show only first // otherwise can duplication information about absense of permissions. $operation_error_already_shown = true; } if ( $ex instanceof Util_WpFile_FilesystemWriteException ) { $required_changes .= sprintf( // Translators: 1 opening HTML strong tag, 2 file path, 3 closing HTML strong tag // Translators: 4 opening HTML textarea tag, 5 textarea content, 6 closing HTML textarea tag followed by line break. __( 'Create the %1$s%2$s%3$s file and paste the following text into it: %4$s%5$s%6$s', 'w3-total-cache' ), '
', $ex->filename(), '
', '
', esc_textarea( $ex->file_contents() ), '</textarea>
' ); } elseif ( $ex instanceof Util_WpFile_FilesystemModifyException ) { $modification_content = $ex->file_contents(); if ( strlen( $modification_content ) > 0 ) { $modification_content = '
' . esc_textarea( $modification_content ) . '</textarea>'; } $required_changes .= $ex->modification_description() . $modification_content . '
'; } elseif ( $ex instanceof Util_WpFile_FilesystemCopyException ) { $commands .= 'cp ' . $ex->source_filename() . ' ' . $ex->destination_filename() . '
'; } elseif ( $ex instanceof Util_WpFile_FilesystemMkdirException ) { $commands .= 'mkdir ' . $ex->folder() . '
'; $commands .= 'chmod 777 ' . $ex->folder() . '
'; } elseif ( $ex instanceof Util_WpFile_FilesystemRmException ) { $commands .= 'rm ' . $ex->filename() . '
'; } elseif ( $ex instanceof Util_WpFile_FilesystemRmdirException ) { $commands .= 'rm -rf ' . $ex->folder() . '
'; } elseif ( $ex instanceof Util_WpFile_FilesystemChmodException ) { $commands .= 'chmod 777 ' . $ex->filename() . '
'; } } } elseif ( $ex instanceof Util_Environment_Exception ) { $t = $ex->technical_message(); if ( strlen( $t ) > 0 ) { $t = '
' . __( 'Technical info', 'w3-total-cache' ) . '
' . $t . '
'; } $later_errors[] = $ex->getMessage() . $t; } else { // unknown command. $later_errors[] = $ex->getMessage(); } } if ( strlen( $commands ) > 0 ) { $required_changes .= __( 'Execute next commands in a shell:', 'w3-total-cache' ) . '
' . $commands . '
'; } return array( 'before_errors' => $before_errors, 'required_changes' => $required_changes, 'later_errors' => $later_errors, ); } /** * Deactivate plugin * * @return string[] error messages */ public static function deactivate_plugin() { $errors = array(); try { $environment = Dispatcher::component( 'Root_Environment' ); $environment->fix_after_deactivation(); deactivate_plugins( plugin_basename( W3TC_FILE ) ); } catch ( SelfTestExceptions $exs ) { $r = self::parse_environment_exceptions( $exs ); foreach ( $r['before_errors'] as $e ) { $errors[] = $e; } if ( strlen( $r['required_changes'] ) > 0 ) { $changes_style = 'border: 1px solid black; background: white; margin: 10px 30px 10px 30px; padding: 10px; display: none'; $ftp_style = 'border: 1px solid black; background: white; margin: 10px 30px 10px 30px; padding: 10px; display: none'; $ftp_form = str_replace( 'class="wrap"', '', $exs->credentials_form() ); $ftp_form = str_replace( '
', '', $ftp_form ); $ftp_form = str_replace( '
', '', $ftp_form ); $ftp_form = str_replace( 'id="upgrade" class="button"', 'id="upgrade" class="button w3tc-button-save"', $ftp_form ); $error = sprintf( '%s
%s
%s
%s
%s
', __( '
W3 Total Cache Error:
Files and directories could not be automatically deleted.', 'w3-total-cache' ), __( 'Please execute commands manually', 'w3-total-cache' ), __( 'or use FTP form to allow
W3 Total Cache
make it automatically.', 'w3-total-cache' ), Util_Ui::button( __( 'View required changes', 'w3-total-cache' ), '', 'w3tc-show-required-changes' ), Util_Ui::button( __( 'Update via FTP', 'w3-total-cache' ), '', 'w3tc-show-ftp-form' ) ) . '
' . $r['required_changes'] . '
' . '
' . $ftp_form . '
'; $errors[] = $error; } return $errors; } } }