From b655cebf3c6fba25c4403841c4465ff11379d1ce Mon Sep 17 00:00:00 2001 From: david Date: Tue, 24 Nov 2020 16:22:00 -0500 Subject: [PATCH] Check in 1.6.18 --- LSQUICCOMMIT | 2 +- configure | 20 +- configure.ac | 2 +- dist/VERSION | 2 +- dist/add-ons/webcachemgr/VERSION | 2 +- .../add-ons/webcachemgr/src/CliController.php | 98 +++++---- .../webcachemgr/src/Context/Context.php | 62 +++--- .../src/Context/RootCLIContextOption.php | 2 +- dist/add-ons/webcachemgr/src/DashNotifier.php | 8 +- dist/add-ons/webcachemgr/src/LogEntry.php | 3 +- dist/add-ons/webcachemgr/src/Logger.php | 30 ++- .../webcachemgr/src/Panel/ControlPanel.php | 89 ++++---- .../add-ons/webcachemgr/src/PluginVersion.php | 204 +++++++++++++----- dist/add-ons/webcachemgr/src/UserCommand.php | 90 ++++---- dist/add-ons/webcachemgr/src/Util.php | 32 ++- .../src/View/Model/VersionManageViewModel.php | 68 +++++- .../src/View/Tpl/VersionManage.tpl | 9 +- dist/add-ons/webcachemgr/src/WPCaller.php | 182 +++++++++------- dist/admin/html.open/index.php | 9 +- dist/admin/html.open/lib/CData.php | 4 + dist/admin/html.open/lib/DMsg.php | 10 +- .../lib/util/build_php/BuildConfig.php | 4 +- dist/admin/html.open/res/lang/en-US_msg.php | 6 +- dist/admin/html.open/view/inc/header.php | 9 +- dist/admin/html.open/view/inc/scripts.php | 9 +- dist/install.sh | 15 ++ src/config.h.cmake | 4 +- src/extensions/extworkerconfig.h | 12 +- src/extensions/registry/extappregistry.cpp | 2 +- src/http/httpsession.cpp | 13 +- src/http/httpvhost.cpp | 8 +- src/http/pipeappender.cpp | 16 +- src/http/staticfilecachedata.cpp | 12 ++ src/main/httpserver.cpp | 19 +- src/main/lshttpdmain.cpp | 2 +- src/modules/cache/cache.cpp | 8 +- src/modules/modsecurity-ls/mod_security.cpp | 4 +- src/sslpp/sslcontext.cpp | 2 +- 38 files changed, 683 insertions(+), 390 deletions(-) diff --git a/LSQUICCOMMIT b/LSQUICCOMMIT index 03eb7acb4..040497a95 100644 --- a/LSQUICCOMMIT +++ b/LSQUICCOMMIT @@ -1 +1 @@ -6eec0a76f7edc4e7c6e6d32305484065f2fa7478 +e02bc3157d0de31249300437fa86dd7da1a088f6 diff --git a/configure b/configure index d9c2e85ed..c928e913d 100755 --- a/configure +++ b/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for openlitespeed 1.6.17. +# Generated by GNU Autoconf 2.69 for openlitespeed 1.6.18. # # Report bugs to . # @@ -590,8 +590,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='openlitespeed' PACKAGE_TARNAME='openlitespeed' -PACKAGE_VERSION='1.6.17' -PACKAGE_STRING='openlitespeed 1.6.17' +PACKAGE_VERSION='1.6.18' +PACKAGE_STRING='openlitespeed 1.6.18' PACKAGE_BUGREPORT='info@litespeedtech.com' PACKAGE_URL='http://www.litespeedtech.com/' @@ -1409,7 +1409,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures openlitespeed 1.6.17 to adapt to many kinds of systems. +\`configure' configures openlitespeed 1.6.18 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1480,7 +1480,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of openlitespeed 1.6.17:";; + short | recursive ) echo "Configuration of openlitespeed 1.6.18:";; esac cat <<\_ACEOF @@ -1641,7 +1641,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -openlitespeed configure 1.6.17 +openlitespeed configure 1.6.18 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -2315,7 +2315,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by openlitespeed $as_me 1.6.17, which was +It was created by openlitespeed $as_me 1.6.18, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -3181,7 +3181,7 @@ fi # Define the identity of the package. PACKAGE='openlitespeed' - VERSION='1.6.17' + VERSION='1.6.18' # Some tools Automake needs. @@ -19624,7 +19624,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by openlitespeed $as_me 1.6.17, which was +This file was extended by openlitespeed $as_me 1.6.18, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -19691,7 +19691,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -openlitespeed config.status 1.6.17 +openlitespeed config.status 1.6.18 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff --git a/configure.ac b/configure.ac index 014765bf0..55d7c1a5a 100644 --- a/configure.ac +++ b/configure.ac @@ -7,7 +7,7 @@ m4_include(ax_check_libudns.m4) m4_include(ax_check_ip2location.m4) dnl Process this file with autoconf to produce a configure script. -AC_INIT([openlitespeed],[1.6.17],[info@litespeedtech.com],[openlitespeed],[http://www.litespeedtech.com/]) +AC_INIT([openlitespeed],[1.6.18],[info@litespeedtech.com],[openlitespeed],[http://www.litespeedtech.com/]) AM_INIT_AUTOMAKE([1.0 foreign no-define subdir-objects]) diff --git a/dist/VERSION b/dist/VERSION index 5f3f7155d..7a9d7939e 100644 --- a/dist/VERSION +++ b/dist/VERSION @@ -1 +1 @@ -1.6.17 +1.6.18 diff --git a/dist/add-ons/webcachemgr/VERSION b/dist/add-ons/webcachemgr/VERSION index ac19c875f..564a1f228 100644 --- a/dist/add-ons/webcachemgr/VERSION +++ b/dist/add-ons/webcachemgr/VERSION @@ -1 +1 @@ -1.13.3.1 \ No newline at end of file +1.13.4.1 \ No newline at end of file diff --git a/dist/add-ons/webcachemgr/src/CliController.php b/dist/add-ons/webcachemgr/src/CliController.php index 5b506dfee..2e346bea2 100644 --- a/dist/add-ons/webcachemgr/src/CliController.php +++ b/dist/add-ons/webcachemgr/src/CliController.php @@ -96,7 +96,7 @@ public function __construct() private function checkDataFile( $action, WPInstallStorage $wpInstallStorage) { - if ( $action == 'scan' ) { + if ( $action == WPInstallStorage::CMD_SCAN ) { /** * Always allowed. */ @@ -112,13 +112,13 @@ private function checkDataFile( $action, case WPInstallStorage::ERR_CORRUPTED: case WPInstallStorage::ERR_VERSION_HIGH: $msg = 'Scan data could not be read! Please scan again ' - . '(without the \'-n\' flag) before attempting any ' - . "cache operations.\n"; + . '(without the \'-n\' flag) before attempting any ' + . "cache operations.\n"; break; case WPInstallStorage::ERR_VERSION_LOW: $msg = 'Scan data file format has been changed for this ' - . 'version. Please scan again (without the \'-n\' ' - . "flag) before attempting any cache operations.\n"; + . 'version. Please scan again (without the \'-n\' ' + . "flag) before attempting any cache operations.\n"; break; //no default } @@ -127,9 +127,9 @@ private function checkDataFile( $action, && $wpInstallStorage->getCount() == 0 ) { $msg = 'No WordPress installations discovered in the previous ' - . 'scan. If you have any newly installed WordPress ' - . 'installations, please scan again or add them with' - . "command 'addinstalls'.\n"; + . 'scan. If you have any newly installed WordPress ' + . 'installations, please scan again or add them with command ' + . "'addinstalls'.\n"; } if ( $msg != '' ) { @@ -168,12 +168,12 @@ private function printStatusMsg( WPInstall $wpInstall ) } elseif ( $status & WPInstall::ST_ERR_DOCROOT ) { $msg .= 'Could not match WordPress siteURL to a known control ' - . 'panel docroot.'; + . 'panel docroot.'; } elseif ( $status & WPInstall::ST_ERR_EXECMD ) { $msg .= 'WordPress fatal error encountered during action ' - . 'execution. This is most likely caused by custom code in ' - . 'this WordPress installation.'; + . 'execution. This is most likely caused by custom code in ' + . 'this WordPress installation.'; } elseif ( $status & WPInstall::ST_ERR_EXECMD_DB ) { $msg .= 'Error establishing WordPress database connection.'; @@ -322,15 +322,15 @@ private function handleScanInput( &$args ) { if ( ($key = array_search('-n', $args)) !== false ) { unset($args[$key]); - $this->commands[] = 'discoverNew'; + $this->commands[] = WPInstallStorage::CMD_DISCOVER_NEW; } else { - $this->commands[] = 'scan'; + $this->commands[] = WPInstallStorage::CMD_SCAN; } if ( ($key = array_search('-e', $args)) !== false ) { unset($args[$key]); - $this->commands[] = 'mass_enable'; + $this->commands[] = UserCommand::CMD_MASS_ENABLE; } } @@ -385,7 +385,7 @@ private function handleDashNotifyInput( $cmdType, &$args ) if ( ($key = array_search('-m', $args)) !== false ) { unset($args[$key]); - $this->commands[] = 'mass_dash_notify'; + $this->commands[] = UserCommand::CMD_MASS_DASH_NOTIFY; } else { @@ -410,7 +410,7 @@ private function handleDashNotifyInput( $cmdType, &$args ) throw new LSCMException("Invalid WP Path: {$path}."); } - $this->commands[] = 'dash_notify'; + $this->commands[] = UserCommand::CMD_DASH_NOTIFY; $this->currWpPath = rtrim($path, '/'); unset($args[$key], $args[$key + 1]); @@ -422,7 +422,8 @@ private function handleDashNotifyInput( $cmdType, &$args ) if ( empty($args[$key + 1]) ) { throw new LSCMException( - 'Invalid Command, missing \'-msgfile\' value.'); + 'Invalid Command, missing \'-msgfile\' value.' + ); } $msgFilePath = $args[$key + 1]; @@ -495,7 +496,7 @@ private function handleDashNotifyInput( $cmdType, &$args ) $arg1 = array_shift($args); if ( $arg1 == '-m' ) { - $this->commands[] = 'mass_dash_disable'; + $this->commands[] = UserCommand::CMD_MASS_DASH_DISABLE; } else { $path = $arg1; @@ -512,7 +513,7 @@ private function handleDashNotifyInput( $cmdType, &$args ) throw new LSCMException("Invalid WP Path: {$path}."); } - $this->commands[] = 'dash_disable'; + $this->commands[] = UserCommand::CMD_DASH_DISABLE; $this->currWpPath = rtrim($path, '/'); } } @@ -695,6 +696,7 @@ private function parseCommands( $args ) switch ($cmd) { case 'setcacheroot': + if ( $panelClassName == 'custom' ) { throw new LSCMException( 'Command \'setcacheroot\' cannot be used in the ' @@ -813,12 +815,12 @@ private function doSpecialCommand() case 'update': echo 'Updated LiteSpeed cPanel plugin to current ' - . "version\n\n"; + . "version\n\n"; break; case 'new': echo 'LiteSpeed cPanel plugin installed, auto install ' - . "turned on.\n\n"; + . "turned on.\n\n"; break; //no default @@ -831,27 +833,27 @@ private function doSpecialCommand() CPanel::uninstallCpanelPlugin(); echo 'LiteSpeed cPanel plugin uninstalled successfully, auto ' - . "install turned off.\n\n"; + . "install turned off.\n\n"; break; case 'cpanelPluginAutoInstallStatus': $state = (CPanel::isCpanelPluginAutoInstallOn()) ? 'On' : 'Off'; echo "Auto install is currently {$state} for the LiteSpeed " - . "cPanel plugin.\n"; + . "cPanel plugin.\n"; echo 'Use command \'cpanelplugin -autoinstall {0 | 1}\' to ' - . "turn auto install off/on respectively.\n\n"; + . "turn auto install off/on respectively.\n\n"; break; case 'cpanelPluginAutoInstallOn': if ( CPanel::turnOnCpanelPluginAutoInstall() ) { echo 'Auto install is now On for LiteSpeed cPanel plugin.' - . "\n\n"; + . "\n\n"; } else { echo 'Failed to turn off auto install for LiteSpeed cPanel ' - . "plugin.\n\n"; + . "plugin.\n\n"; } break; @@ -860,11 +862,11 @@ private function doSpecialCommand() if ( CPanel::turnOffCpanelPluginAutoInstall() ) { echo 'Auto install is now Off for LiteSpeed cPanel plugin.' - . "\n\n"; + . "\n\n"; } else { echo 'Failed to turn on auto install for LiteSpeed cPanel ' - . "plugin.\n\n"; + . "plugin.\n\n"; } break; @@ -887,7 +889,7 @@ private function doVersionCommand() $allowedVers = $pluginVerInstance->getAllowedVersions(); echo "Available versions are: \n" . implode("\n",$allowedVers) - . "\n"; + . "\n"; break; case 'latest': @@ -902,7 +904,7 @@ private function doVersionCommand() if ( $latest == $currVer ) { echo "Current version, {$latest}, is already the latest " - . "version.\n"; + . "version.\n"; } else { $pluginVerInstance->setActiveVersion($latest); @@ -932,9 +934,10 @@ private function doWPInstallStorageAction() $lscmDataFiles = Context::getLSCMDataFiles(); - $wpInstallStorage = - new WPInstallStorage($lscmDataFiles['dataFile'], - $lscmDataFiles['custDataFile']); + $wpInstallStorage = new WPInstallStorage( + $lscmDataFiles['dataFile'], + $lscmDataFiles['custDataFile'] + ); if ($this->currWpPath) { $list = array( $this->currWpPath ); @@ -947,17 +950,19 @@ private function doWPInstallStorageAction() switch ( $action ) { - case 'upgrade': - case 'mass_upgrade': + case UserCommand::CMD_UPGRADE: + case UserCommand::CMD_MASS_UPGRADE: $pluginVerInstance = PluginVersion::getInstance(); - $extraArgs[] = implode(',', - $pluginVerInstance->getKnownVersions(true)); + $extraArgs[] = implode( + ',', + $pluginVerInstance->getShortVersions() + ); $extraArgs[] = $pluginVerInstance->getCurrentVersion(); break; - case 'dash_notify': - case 'mass_dash_notify': + case UserCommand::CMD_DASH_NOTIFY: + case UserCommand::CMD_MASS_DASH_NOTIFY: DashNotifier::prepLocalDashPluginFiles(); $slug = ''; @@ -967,11 +972,11 @@ private function doWPInstallStorageAction() } $msgInfoJSON = json_encode( - array( - 'msg' => $this->input['msg'], - 'plugin' => $slug, - 'plugin_name' => '' - ) + array( + 'msg' => $this->input['msg'], + 'plugin' => $slug, + 'plugin_name' => '' + ) ); $extraArgs[] = base64_encode($msgInfoJSON); @@ -987,9 +992,8 @@ private function doWPInstallStorageAction() $wpInstallStorage->doAction($action, $list, $extraArgs); - if ( $action == 'status' ) { - $wpInstall = - $wpInstallStorage->getWPInstall($this->currWpPath); + if ( $action == UserCommand::CMD_STATUS ) { + $wpInstall = $wpInstallStorage->getWPInstall($this->currWpPath); $this->printStatusMsg($wpInstall); } diff --git a/dist/add-ons/webcachemgr/src/Context/Context.php b/dist/add-ons/webcachemgr/src/Context/Context.php index e5e3fd1ef..5dda0141e 100644 --- a/dist/add-ons/webcachemgr/src/Context/Context.php +++ b/dist/add-ons/webcachemgr/src/Context/Context.php @@ -4,7 +4,7 @@ * LiteSpeed Web Server Cache Manager * * @author LiteSpeed Technologies, Inc. (https://www.litespeedtech.com) - * @copyright (c) 2018-2019 + * @copyright (c) 2018-2020 * ******************************************* */ namespace Lsc\Wp\Context; @@ -106,8 +106,11 @@ protected function checkLocalPluginDirInCageFS() $setInMpFile = ! empty($result); if ( ! $setInMpFile ) { - file_put_contents($mpFile, "\n{$localPluginDir}", - FILE_APPEND); + file_put_contents( + $mpFile, + "\n{$localPluginDir}", + FILE_APPEND + ); Logger::notice('Added data dir to cagefs.mp.'); } @@ -128,8 +131,10 @@ protected function checkLocalPluginDirInCageFS() protected function createDataDir() { if ( !file_exists($this->dataDir) && !mkdir($this->dataDir, 0755) ) { - throw new LSCMException("Fail to create data directory {$this->dataDir}.", - LSCMException::E_PERMISSION); + throw new LSCMException( + "Fail to create data directory {$this->dataDir}.", + LSCMException::E_PERMISSION + ); } } @@ -145,15 +150,17 @@ protected function createLocalPluginDir() && !mkdir(Context::LOCAL_PLUGIN_DIR, 0755) ) { throw new LSCMException( - "Fail to create local plugin directory " . Context::LOCAL_PLUGIN_DIR . '.', - LSCMException::E_PERMISSION); + "Fail to create local plugin directory " + . Context::LOCAL_PLUGIN_DIR . '.', + LSCMException::E_PERMISSION + ); } } /** * * @return ContextOption - * @throws LSCMException Indirectly thrown by self::me(). + * @throws LSCMException Thrown indirectly. */ public static function getOption() { @@ -176,8 +183,10 @@ public static function initialize( ContextOption $contextOption, /** * Do not allow, must initialize first. */ - throw new LSCMException('Context cannot be initialized twice.', - LSCMException::E_PROGRAM); + throw new LSCMException( + 'Context cannot be initialized twice.', + LSCMException::E_PROGRAM + ); } self::$instance = new self($contextOption); @@ -206,7 +215,7 @@ public static function initialize( ContextOption $contextOption, protected function hasInsufficentPermissions() { $expectedPermissions = - self::$instance->options->getExpectedPermissions(); + self::$instance->options->getExpectedPermissions(); return (self::$instance->isRoot < $expectedPermissions); } @@ -223,13 +232,17 @@ protected static function me( $checkPerms = false ) /** * Do not allow, must initialize first. */ - throw new LSCMException('Uninitialized context.', - LSCMException::E_NON_FATAL); + throw new LSCMException( + 'Uninitialized context.', + LSCMException::E_NON_FATAL + ); } if ( $checkPerms && self::$instance->hasInsufficentPermissions() ) { - throw new LSCMException('Access denied: Insufficient permissions.', - LSCMException::E_NON_FATAL); + throw new LSCMException( + 'Access denied: Insufficient permissions.', + LSCMException::E_NON_FATAL + ); } return self::$instance; @@ -262,8 +275,7 @@ public static function getLSCMDataFile() /** * * @return string[] - * @throws LSCMException Indirectly thrown by self::me() and - * Logger::debug(). + * @throws LSCMException Thrown indirectly. */ public static function getLSCMDataFiles() { @@ -278,7 +290,10 @@ public static function getLSCMDataFiles() throw new LSCMException($msg); } - return array( 'dataFile' => $dataFile, 'custDataFile' => $custDataFile ); + return array( + 'dataFile' => $dataFile, + 'custDataFile' => $custDataFile + ); } /** @@ -293,18 +308,17 @@ public static function isRoot() /** * * @return boolean - * @throws LSCMException Indirectly thrown by self::me(). + * @throws LSCMException Thrown indirectly. */ public static function isPrivileged() { - $rootCapable = self::me()->isRoot > ContextOption::IS_NOT_ROOT; - return $rootCapable; + return (self::me()->isRoot > ContextOption::IS_NOT_ROOT); } /** * * @return int - * @throws LSCMException Indirectly thrown by self::me(). + * @throws LSCMException Thrown indirectly. */ public static function getScanDepth() { @@ -314,7 +328,7 @@ public static function getScanDepth() /** * * @return int - * @throws LSCMException Indirectly thrown by self::me(). + * @throws LSCMException Thrown indirectly. */ public static function getActionTimeout() { @@ -333,7 +347,7 @@ public static function getActionTimeout() /** * * @return string - * @throws LSCMException Indirectly thrown by self::me(). + * @throws LSCMException Thrown indirectly. */ public static function getFlagFileContent() { diff --git a/dist/add-ons/webcachemgr/src/Context/RootCLIContextOption.php b/dist/add-ons/webcachemgr/src/Context/RootCLIContextOption.php index 2e92a0597..7d37ddc0f 100644 --- a/dist/add-ons/webcachemgr/src/Context/RootCLIContextOption.php +++ b/dist/add-ons/webcachemgr/src/Context/RootCLIContextOption.php @@ -1,6 +1,6 @@ p_log(). + * @throws LSCMException Thrown indirectly. */ public static function logMsg( $msg, $lvl ) { @@ -553,7 +552,7 @@ public static function logMsg( $msg, $lvl ) * Calls logMsg() with message level static::L_ERROR. * * @param string $msg - * @throws LSCMException Indirectly thrown by static::logMsg(). + * @throws LSCMException Thrown indirectly. */ public static function error( $msg ) { @@ -564,7 +563,7 @@ public static function error( $msg ) * Calls logMsg() with message level static::L_WARN. * * @param string $msg - * @throws LSCMException Indirectly thrown by static::logMsg(). + * @throws LSCMException Thrown indirectly. */ public static function warn( $msg ) { @@ -575,7 +574,7 @@ public static function warn( $msg ) * Calls logMsg() with message level static::L_NOTICE. * * @param string $msg - * @throws LSCMException Indirectly thrown by static::logMsg(). + * @throws LSCMException Thrown indirectly. */ public static function notice( $msg ) { @@ -586,7 +585,7 @@ public static function notice( $msg ) * Calls logMsg() with message level static::L_INFO. * * @param string $msg - * @throws LSCMException Indirectly thrown by static::logMsg(). + * @throws LSCMException Thrown indirectly. */ public static function info( $msg ) { @@ -597,7 +596,7 @@ public static function info( $msg ) * Calls logMsg() with message level static::L_VERBOSE. * * @param string $msg - * @throws LSCMException Indirectly thrown by static::logMsg(). + * @throws LSCMException Thrown indirectly. */ public static function verbose( $msg ) { @@ -608,7 +607,7 @@ public static function verbose( $msg ) * Calls logMsg() with message level static::L_DEBUG. * * @param string $msg - * @throws LSCMException Indirectly thrown by static::logMsg(). + * @throws LSCMException Thrown indirectly. */ public static function debug( $msg ) { @@ -635,8 +634,7 @@ protected static function me() * * @param string $msg * @param int $lvl - * @throws LSCMException Indirectly thrown by $this->writeToFile and - * $this->echoEntries(). + * @throws LSCMException Thrown indirectly. */ protected function log( $msg, $lvl ) { @@ -658,7 +656,7 @@ protected function log( $msg, $lvl ) * @param LogEntry[]|object[] $entries Array of objects that implement * all LogEntry class public * functions. - * @throws LSCMException Indirectly thrown by $e->getOutput(). + * @throws LSCMException Thrown indirectly. */ protected function writeToFile( $entries ) { @@ -685,7 +683,7 @@ protected function writeToFile( $entries ) * @param LogEntry[]|object[] $entries Array of objects that implement * all LogEntry class public * functions. - * @throws LSCMException Indirectly thrown by $entry->getOutput(). + * @throws LSCMException Thrown indirectly. */ protected function echoEntries( $entries ) { diff --git a/dist/add-ons/webcachemgr/src/Panel/ControlPanel.php b/dist/add-ons/webcachemgr/src/Panel/ControlPanel.php index 650faa65a..dee20c007 100644 --- a/dist/add-ons/webcachemgr/src/Panel/ControlPanel.php +++ b/dist/add-ons/webcachemgr/src/Panel/ControlPanel.php @@ -34,7 +34,7 @@ abstract class ControlPanel /** * @var string */ - const PANEL_API_VERSION = '1.13.3.1'; + const PANEL_API_VERSION = '1.13.4.1'; /** * @since 1.9 @@ -63,7 +63,7 @@ abstract class ControlPanel /** * @var int */ - const PHP_TIMEOUT = 10; + const PHP_TIMEOUT = 30; /** * @var string @@ -146,10 +146,10 @@ protected function init2() * 'ob_gzhandler' etc. */ $this->phpOptions = '-d disable_functions=ini_set -d opcache.enable=0 ' - . '-d max_execution_time=' . static::PHP_TIMEOUT - . ' -d memory_limit=512M -d register_argc_argv=1 ' - . '-d zlib.output_compression=0 -d output_handler= ' - . '-d safe_mode=0 -d open_basedir='; + . '-d max_execution_time=' . static::PHP_TIMEOUT + . ' -d memory_limit=512M -d register_argc_argv=1 ' + . '-d zlib.output_compression=0 -d output_handler= ' + . '-d safe_mode=0 -d open_basedir='; $this->initConfPaths(); } @@ -182,7 +182,8 @@ public static function initByClassName( $className ) || ! include_once $customPanelFile ) { throw new LSCMException( - "Unable to include file {$customPanelFile}"); + "Unable to include file {$customPanelFile}" + ); } $className = '\Lsc\Wp\Panel\CustomPanel'; @@ -193,9 +194,10 @@ public static function initByClassName( $className ) ); if ( ! $isSubClass ) { - $msg = 'Class CustomPanel must extend class ' - . '\Lsc\Wp\Panel\CustomPanelBase'; - throw new LSCMException($msg); + throw new LSCMException( + 'Class CustomPanel must extend class ' + . '\Lsc\Wp\Panel\CustomPanelBase' + ); } } @@ -204,7 +206,8 @@ public static function initByClassName( $className ) } catch ( \Exception $e ){ throw new LSCMException( - "Could not create object with class name {$className}"); + "Could not create object with class name {$className}" + ); } } else { @@ -262,7 +265,7 @@ public static function init( $name ) * * @param string $className Fully qualified class name. * @return ControlPanel Object that extends ControlPanel abstract class. - * @throws LSCMException Indirectly thrown by static::initByClassName(). + * @throws LSCMException Thrown directly and indirectly. */ public static function getClassInstance( $className = '' ) { @@ -337,11 +340,12 @@ public function areCacheRootsSet() public function verifyCacheSetup() { if ( !$this->isCacheEnabled() ) { - $msg = 'LSCache is not included in the current LiteSpeed license. ' + throw new LSCMException( + 'LSCache is not included in the current LiteSpeed license. ' . 'Please purchase the LSCache add-on or upgrade to a ' - . 'license type that includes LSCache and try again.'; - - throw new LSCMException($msg, LSCMException::E_PERMISSION); + . 'license type that includes LSCache and try again.', + LSCMException::E_PERMISSION + ); } $restartRequired = false; @@ -364,16 +368,17 @@ public function verifyCacheSetup() /** * * @param string $vhCacheRoot - * @throws LSCMException Indirectly thrown by $this->log() and - * $this->writeVHCacheRoot(). + * @throws LSCMException Thrown indirectly. */ public function setVHCacheRoot( $vhCacheRoot = 'lscache' ) { $this->log('Attempting to set VH cache root...', Logger::L_VERBOSE); if ( !file_exists($this->apacheVHConf) ) { - $this->createVHConfAndSetCacheRoot($this->apacheVHConf, - $vhCacheRoot); + $this->createVHConfAndSetCacheRoot( + $this->apacheVHConf, + $vhCacheRoot + ); } else { $this->writeVHCacheRoot($this->apacheVHConf, $vhCacheRoot); @@ -412,15 +417,18 @@ public function isCacheEnabled() $statusFile = '/tmp/lshttpd/.status'; if ( !file_exists($statusFile) ) { - $msg = 'Cannot determine LSCache availability. Please start/switch ' - . 'to LiteSpeed Web Server before trying again.'; - - throw new LSCMException($msg, LSCMException::E_PERMISSION); + throw new LSCMException( + 'Cannot determine LSCache availability. Please start/switch ' + . 'to LiteSpeed Web Server before trying again.', + LSCMException::E_PERMISSION + ); } if ( ($f = fopen($statusFile, 'r')) === false ) { - throw new LSCMException('Cannot determine LSCache availability.', - LSCMException::E_PERMISSION); + throw new LSCMException( + 'Cannot determine LSCache availability.', + LSCMException::E_PERMISSION + ); } fseek($f, -128, SEEK_END); @@ -588,9 +596,9 @@ public function getLSWSCacheRootSetting() if ( file_exists($serverConf) ) { $file_content = file_get_contents($serverConf); - if ( preg_match('!(.+)!i', - $file_content, $matches) ) { + $pattern = '!(.+)!i'; + if ( preg_match($pattern, $file_content, $matches) ) { $svrCacheRoot = trim($matches[1]); } } @@ -725,7 +733,9 @@ public function setServerCacheRoot( $svrCacheRoot = '' ) else { $file_contents = file($this->apacheConf); - if ( preg_grep('/^\s*/im', $file_contents) ) { + $pattern = '/^\s*/im'; + + if ( preg_grep($pattern, $file_contents) ) { if ( preg_grep('/^\s*CacheRoot +/im', $file_contents) ) { $file_contents = preg_replace( @@ -802,8 +812,11 @@ public function writeVHCacheRoot( $vhConf, $vhCacheRoot = 'lscache' ) if ( preg_grep('/^\s*/im', $file_contents) ) { if ( preg_grep('/^\s*CacheRoot +/im', $file_contents) ) { - $modified_contents = preg_replace('/^\s*CacheRoot +.+/im', - "CacheRoot {$vhCacheRoot}", $file_contents); + $modified_contents = preg_replace( + '/^\s*CacheRoot +.+/im', + "CacheRoot {$vhCacheRoot}", + $file_contents + ); } else { $modified_contents = preg_replace( @@ -815,12 +828,14 @@ public function writeVHCacheRoot( $vhConf, $vhCacheRoot = 'lscache' ) } else { $modified_contents = - $this->addVHCacheRootSection($file_contents, $vhCacheRoot); + $this->addVHCacheRootSection($file_contents, $vhCacheRoot); } if ( file_put_contents($vhConf, $modified_contents) === false ) { - throw new LSCMException("Failed to write to file {$vhConf}.", - LSCMException::E_PERMISSION); + throw new LSCMException( + "Failed to write to file {$vhConf}.", + LSCMException::E_PERMISSION + ); } $this->log("Updated file {$vhConf}.", Logger::L_DEBUG); @@ -905,9 +920,7 @@ protected static function getMinAPIVer() static::populateMinAPIVerFile(); } - $minVer = trim(file_get_contents($minVerFile)); - - return $minVer; + return trim(file_get_contents($minVerFile)); } /** @@ -940,6 +953,8 @@ public static function meetsMinAPIVerRequirement() public static function checkPanelAPICompatibility( $panelAPIVer ) { $supportedAPIVers = array ( + '1.13.4.1', + '1.13.4', '1.13.3.1', '1.13.3', '1.13.2.2', diff --git a/dist/add-ons/webcachemgr/src/PluginVersion.php b/dist/add-ons/webcachemgr/src/PluginVersion.php index 9810769ee..a6778253e 100644 --- a/dist/add-ons/webcachemgr/src/PluginVersion.php +++ b/dist/add-ons/webcachemgr/src/PluginVersion.php @@ -4,7 +4,7 @@ * LiteSpeed Web Server Cache Manager * * @author LiteSpeed Technologies, Inc. (https://www.litespeedtech.com) - * @copyright (c) 2018-2019 + * @copyright (c) 2018-2020 * ******************************************* */ @@ -28,10 +28,17 @@ class PluginVersion const VER_MD5 = 'lscwp_md5'; /** + * @deprecated 4.1.3 Will be removed in favor of $this->shortVersions. * @var string[] */ protected $knownVersions = array(); + /** + * @since 4.1.3 + * @var string[] + */ + protected $shortVersions = array(); + /** * @var string[] */ @@ -59,7 +66,7 @@ class PluginVersion /** * - * @throws LSCMException Indirectly thrown by $this->init(). + * @throws LSCMException Thrown indirectly. */ protected function __construct() { @@ -67,7 +74,7 @@ protected function __construct() } /** - * @throws LSCMException Indirectly thrown by Context::isPrivileged(). + * @throws LSCMException Thrown indirectly. */ protected function init() { @@ -81,7 +88,7 @@ protected function init() /** * * @return PluginVersion - * @throws LSCMException Indirectly thrown by Context::getOption(). + * @throws LSCMException Thrown indirectly. */ public static function getInstance() { @@ -95,10 +102,15 @@ public static function getInstance() } /** + * + * @deprecated 4.1.3 Use "$formatted = true" equivalent function + * $this->getShortVersions() instead. Un-formatted + * version of this list will no longer be available once + * this function is removed. * * @param bool $formatted * @return string[] - * @throws LSCMException Indirectly thrown by $this->setKnownVersions(). + * @throws LSCMException Thrown indirectly. */ public function getKnownVersions( $formatted = false ) { @@ -134,7 +146,7 @@ public function getKnownVersions( $formatted = false ) /** * * @return string[] - * @throws LSCMException Indirectly thrown by $this->setAllowedVersions(). + * @throws LSCMException Thrown indirectly. */ public function getAllowedVersions() { @@ -145,10 +157,26 @@ public function getAllowedVersions() return $this->allowedVersions; } + /** + * + * @since 4.1.3 + * + * @return string[] + * @throws LSCMException Thrown indirectly. + */ + public function getShortVersions() + { + if ( empty($this->shortVersions) ) { + $this->setShortVersions(); + } + + return $this->shortVersions; + } + /** * * @return string - * @throws LSCMException Indirectly thrown by $this->getAllowedVersions(). + * @throws LSCMException Thrown indirectly. */ public function getLatestVersion() { @@ -161,8 +189,7 @@ public function getLatestVersion() /** * * @return string - * @throws LSCMException Indirectly thrown by self::getInstance() and - * $instance->setCurrentVersion(). + * @throws LSCMException Thrown indirectly. */ public static function getCurrentVersion() { @@ -186,7 +213,7 @@ protected function createDownloadDir() protected function setVersionFiles() { - $this->versionFile = Context::LOCAL_PLUGIN_DIR . '/lscwp_versions'; + $this->versionFile = Context::LOCAL_PLUGIN_DIR . '/lscwp_versions_v2'; $this->activeFile = Context::LOCAL_PLUGIN_DIR . '/lscwp_active_version'; } @@ -217,8 +244,8 @@ protected function checkOldVersionFiles() } /** - * @throws LSCMException Indirectly thrown by - * $this->checkOldVersionFiles() and Logger::debug(). + * + * @throws LSCMException Thrown indirectly. */ public function setCurrentVersion() { @@ -234,6 +261,7 @@ public function setCurrentVersion() } if ( $activeVersion == '' ) { + try { $latestVer = self::getLatestVersion(); $activeVersion = $latestVer; @@ -255,7 +283,8 @@ public function setCurrentVersion() private function getActiveVersion() { if ( file_exists($this->activeFile) - && ($content = file_get_contents($this->activeFile)) ) { + && ($content = file_get_contents($this->activeFile)) ) { + return trim($content); } @@ -263,30 +292,68 @@ private function getActiveVersion() } /** + * + * @deprecated 4.1.3 This function will be removed in favor of + * pre-formatted $this->setShortVersions(). * * @throws LSCMException */ protected function setKnownVersions() { if ( !file_exists($this->versionFile) ) { - throw new LSCMException('Cannot find LSCWP version list.', - LSCMException::E_NON_FATAL); + throw new LSCMException( + 'Cannot find LSCWP version list.', + LSCMException::E_NON_FATAL + ); } $content = trim(file_get_contents($this->versionFile)); - $this->knownVersions = explode("\n", $content); + + preg_match('/old\s{(.*)}/sU', $content, $m); + + $this->knownVersions = explode("\n", trim($m[1])); } /** * - * @throws LSCMException Indirectly thrown by $this->getKnownVersions(). + * @throws LSCMException */ protected function setAllowedVersions() { - $knownVers = $this->getKnownVersions(); + if ( !file_exists($this->versionFile) ) { + throw new LSCMException( + 'Cannot find LSCWP version list.', + LSCMException::E_NON_FATAL + ); + } + + $content = trim(file_get_contents($this->versionFile)); + + preg_match('/allowed\s{(.*)}/sU', $content, $m); + + $this->allowedVersions = explode("\n", trim($m[1])); + } + + /** + * + * @since 4.1.3 + * + * @throws LSCMException + */ + protected function setShortVersions() + { + if ( !file_exists($this->versionFile) ) { + throw new LSCMException( + 'Cannot find LSCWP version list.', + LSCMException::E_NON_FATAL + ); + } - $this->allowedVersions = array_filter($knownVers, - array( $this, 'filterVerList' )); + $content = trim(file_get_contents($this->versionFile)); + + preg_match('/short\s{(.*)}/sU', $content, $m); + + $this->shortVersions = explode("\n", trim($m[1])); } /** @@ -294,9 +361,7 @@ protected function setAllowedVersions() * @param string $version Valid LSCWP version. * @param boolean $init True when trying to set initial active * version. - * @throws LSCMException Indirectly thrown by $this->getAllowedVersions(), - * Logger::error(), $this->downloadVersion(), - * and Logger::notice(). + * @throws LSCMException Thrown indirectly. */ public function setActiveVersion( $version, $init = false ) { @@ -320,8 +385,9 @@ public function setActiveVersion( $version, $init = false ) } Logger::error( - "Version {$badVer} not in allowed list, reset active " - . "version to {$version}."); + "Version {$badVer} not in allowed list, reset active " + . "version to {$version}." + ); } if ( $version != $this->getActiveVersion() ) { @@ -339,13 +405,13 @@ public function setActiveVersion( $version, $init = false ) /** * * @param boolean $isforced - * @throws LSCMException Indirectly thrown by Logger::info(). + * @throws LSCMException Thrown indirectly. */ protected function refreshVersionList( $isforced = false ) { clearstatcache(); $versionsUrl = - 'https://www.litespeedtech.com/packages/lswpcache/version_list'; + 'https://www.litespeedtech.com/packages/lswpcache/version_list_v2'; if ( $isforced || !file_exists($this->versionFile) || (time() - filemtime($this->versionFile)) > 86400 ) { @@ -367,6 +433,8 @@ protected function refreshVersionList( $isforced = false ) /** * Filter out any versionList versions that do not meet specific criteria. * + * @deprecated 4.1.3 No longer used. + * * @param string $ver Version string. * @return boolean */ @@ -404,8 +472,10 @@ public static function prepareUserInstall( $pluginDir, $version = '' ) } if ( !$instance->hasDownloadedVersion($version) ) { - throw new LSCMException("Source Package not available for version {$version}.", - LSCMException::E_NON_FATAL); + throw new LSCMException( + "Source Package not available for version {$version}.", + LSCMException::E_NON_FATAL + ); } $pluginSrc = @@ -413,21 +483,25 @@ public static function prepareUserInstall( $pluginDir, $version = '' ) exec("/bin/cp -rf {$pluginSrc} {$pluginDir}"); if ( !file_exists($lscwp_plugin) ) { - throw new LSCMException("Failed to copy plugin files to {$pluginDir}.", - LSCMException::E_NON_FATAL); + throw new LSCMException( + "Failed to copy plugin files to {$pluginDir}.", + LSCMException::E_NON_FATAL + ); } $customIni = Context::LOCAL_PLUGIN_DIR . '/' - . self::LSCWP_DEFAULTS_INI_FILE_NAME; + . self::LSCWP_DEFAULTS_INI_FILE_NAME; $defaultIni = "{$pluginDir}/litespeed-cache/data/" - . self::LSCWP_DEFAULTS_INI_FILE_NAME; + . self::LSCWP_DEFAULTS_INI_FILE_NAME; if ( file_exists($customIni) ) { copy($customIni, $defaultIni); } - Logger::debug('Copied LSCache for WordPress plugin files into plugins directory ' - . $pluginDir); + Logger::debug( + 'Copied LSCache for WordPress plugin files into plugins directory ' + . $pluginDir + ); return true; } @@ -469,28 +543,36 @@ protected function wgetPlugin( $version, $dir, $saveMD5 = false ) $localZipFile = "{$dir}/{$zipFile}"; $url = "https://downloads.wordpress.org/plugin/{$zipFile}"; - $wget_command = "wget -q --tries=1 --no-check-certificate {$url} -P {$dir}"; + $wget_command = + "wget -q --tries=1 --no-check-certificate {$url} -P {$dir}"; exec($wget_command, $output, $return_var); if ( $return_var !== 0 ) { - throw new LSCMException("Failed to download LSCWP v{$version} with wget " - . "exit status {$return_var}.", LSCMException::E_NON_FATAL); + throw new LSCMException( + "Failed to download LSCWP v{$version} with wget " + . "exit status {$return_var}.", + LSCMException::E_NON_FATAL + ); } $extracted = Util::unzipFile($localZipFile, $dir); unlink($localZipFile); if ( !$extracted ) { - throw new LSCMException("Unable to unzip {$localZipFile}", - LSCMException::E_NON_FATAL); + throw new LSCMException( + "Unable to unzip {$localZipFile}", + LSCMException::E_NON_FATAL + ); } $testfile = "{$plugin}/" . self::PLUGIN_NAME . '.php'; if ( !file_exists($testfile) ) { - throw new LSCMException("Unable to download LSCWP v{$version}.", - LSCMException::E_NON_FATAL); + throw new LSCMException( + "Unable to download LSCWP v{$version}.", + LSCMException::E_NON_FATAL + ); } if ( $saveMD5 ) { @@ -511,8 +593,10 @@ protected function downloadVersion( $version ) if ( !file_exists($dir) ) { if ( !mkdir($dir, 0755, true) ) { - throw new LSCMException("Failed to create download dir {$dir}.", - LSCMException::E_NON_FATAL); + throw new LSCMException( + "Failed to create download dir {$dir}.", + LSCMException::E_NON_FATAL + ); } } else { @@ -527,14 +611,16 @@ protected function downloadVersion( $version ) * @param string $locale * @param string $pluginVer * @return boolean - * @throws LSCMException Indirectly thrown by Logger::info() and - * Util::unzipFile(). + * @throws LSCMException Thrown indirectly. */ public static function retrieveTranslation( $locale, $pluginVer ) { - Logger::info("Downloading LSCache for WordPress {$locale} translation..."); + Logger::info( + "Downloading LSCache for WordPress {$locale} translation..." + ); - $translationDir = Context::LOCAL_PLUGIN_DIR . "/{$pluginVer}/translations"; + $translationDir = + Context::LOCAL_PLUGIN_DIR . "/{$pluginVer}/translations"; $zipFile = "{$locale}.zip"; $localZipFile = "{$translationDir}/{$zipFile}"; @@ -542,8 +628,10 @@ public static function retrieveTranslation( $locale, $pluginVer ) mkdir($translationDir, 0755); } - touch("$translationDir/" . self::TRANSLATION_CHECK_FLAG_BASE - . "_{$locale}"); + touch( + "$translationDir/" . self::TRANSLATION_CHECK_FLAG_BASE + . "_{$locale}" + ); /** * downloads.wordpress.org looks to always return a '200 OK' status, @@ -551,10 +639,10 @@ public static function retrieveTranslation( $locale, $pluginVer ) * checked through user failure to unzip through WP func unzip_file() * as we do not assume that root has the ability to unzip. */ - $url = "https://downloads.wordpress.org/translation/plugin/litespeed-cache/" - . "{$pluginVer}/{$locale}.zip"; - $wget_command = - "wget -q --tries=1 --no-check-certificate {$url} -P {$translationDir}"; + $url = 'https://downloads.wordpress.org/translation/plugin/' + . "litespeed-cache/{$pluginVer}/{$locale}.zip"; + $wget_command = 'wget -q --tries=1 --no-check-certificate ' + . "{$url} -P {$translationDir}"; exec($wget_command, $output, $return_var); @@ -574,14 +662,16 @@ public static function retrieveTranslation( $locale, $pluginVer ) * * @param string $locale * @param string $pluginVer - * @throws LSCMException Indirectly thrown by Logger::info(). + * @throws LSCMException Thrown indirectly. */ public static function removeTranslationZip( $locale, $pluginVer ) { Logger::info("Removing LSCache for WordPress {$locale} translation..."); - $zipFile = realpath(Context::LOCAL_PLUGIN_DIR - . "/{$pluginVer}/translations/{$locale}.zip"); + $zipFile = realpath( + Context::LOCAL_PLUGIN_DIR + . "/{$pluginVer}/translations/{$locale}.zip" + ); $realPathStart = substr($zipFile, 0, strlen(Context::LOCAL_PLUGIN_DIR)); diff --git a/dist/add-ons/webcachemgr/src/UserCommand.php b/dist/add-ons/webcachemgr/src/UserCommand.php index 268067c27..7b867938b 100644 --- a/dist/add-ons/webcachemgr/src/UserCommand.php +++ b/dist/add-ons/webcachemgr/src/UserCommand.php @@ -98,7 +98,7 @@ private function __construct( $asUser = false ) * @param int $lines Number of $output lines read into the * error msg. * @return string Message to be displayed instead. - * @throws LSCMException Indirectly thrown by Logger::error(). + * @throws LSCMException Thrown indirectly. */ private static function handleUnexpectedError( $wpInstall, &$err, $lines ) { @@ -111,8 +111,10 @@ private static function handleUnexpectedError( $wpInstall, &$err, $lines ) */ if ( $lines < 500 ) { $match = false; + $commonErrs = array( - WPInstall::ST_ERR_EXECMD_DB => 'Error establishing a database connection' + WPInstall::ST_ERR_EXECMD_DB => + 'Error establishing a database connection' ); foreach ( $commonErrs as $statusBit => $commonErr ) { @@ -131,7 +133,7 @@ private static function handleUnexpectedError( $wpInstall, &$err, $lines ) if ( !$match ) { Logger::error("{$path} - {$err}"); return "{$msg} See " . ContextOption::LOG_FILE_NAME - . " for more information."; + . " for more information."; } } @@ -145,10 +147,7 @@ private static function handleUnexpectedError( $wpInstall, &$err, $lines ) * * @param WPInstall $wpInstall * @param string $output - * @throws LSCMException Indirectly thrown by - * PluginVersion::retrieveTranslation(), - * self::getIssueCmd(), Logger::debug(), and - * PluginVersion::removeTranslationZip(). + * @throws LSCMException Thrown indirectly. */ private static function handleGetTranslationOutput( WPInstall $wpInstall, $output ) @@ -165,8 +164,9 @@ private static function handleGetTranslationOutput( WPInstall $wpInstall, exec($subCmd, $subOutput, $subReturn_var); Logger::debug( - "Issue sub command {$subAction}={$subReturn_var} {$wpInstall}\n" - . "{$subCmd}"); + 'Issue sub command ' + . "{$subAction}={$subReturn_var} {$wpInstall}\n{$subCmd}" + ); Logger::debug('sub output = ' . var_export($subOutput, true)); foreach ( $subOutput as $subLine ) { @@ -178,8 +178,10 @@ private static function handleGetTranslationOutput( WPInstall $wpInstall, $locale = $translationInfo[0]; $lscwpVer = $translationInfo[1]; - PluginVersion::removeTranslationZip($locale, - $lscwpVer); + PluginVersion::removeTranslationZip( + $locale, + $lscwpVer + ); } } } @@ -195,9 +197,7 @@ private static function handleGetTranslationOutput( WPInstall $wpInstall, * @param int $cmdStatus * @param string $err * @return boolean - * @throws LSCMException Indirectly thrown by - * $wpInstall->populateDataFromUrl() and - * self::handleGetTranslationOutput(). + * @throws LSCMException Thrown indirectly. */ private static function handleResultOutput( WPInstall $wpInstall, $line, &$retStatus, &$cmdStatus, &$err ) @@ -242,8 +242,7 @@ private static function handleResultOutput( WPInstall $wpInstall, $line, * @since 1.9 * * @param WPInstall $wpInstall - * @throws LSCMException Indirectly thrown by self::getIssueCmd() and - * Logger::debug(). + * @throws LSCMException Thrown indirectly. */ private static function removeLeftoverLscwpFiles( $wpInstall ) { @@ -252,9 +251,10 @@ private static function removeLeftoverLscwpFiles( $wpInstall ) exec($subCmd, $subOutput, $subReturn_var); - Logger::debug("Issue sub command " - . "{$subAction}={$subReturn_var} {$wpInstall}\n" - . "{$subCmd}"); + Logger::debug( + "Issue sub command " + . "{$subAction}={$subReturn_var} {$wpInstall}\n{$subCmd}" + ); Logger::debug('sub output = ' . var_export($subOutput, true)); $wpInstall->removeNewLscwpFlagFile(); @@ -266,9 +266,7 @@ private static function removeLeftoverLscwpFiles( $wpInstall ) * @param WPInstall $wpInstall * @param mixed[] $extraArgs * @return string - * @throws LSCMException Indirectly thrown by - * $wpInstall->getPhpBinary() and - * Context::getOption(). + * @throws LSCMException Thrown indirectly. */ protected static function getIssueCmd( $action, WPInstall $wpInstall, $extraArgs = array() ) @@ -295,8 +293,8 @@ protected static function getIssueCmd( $action, WPInstall $wpInstall, $file = __FILE__; return "{$su} -c \"cd {$path}/wp-admin && timeout {$timeout} {$phpBin} " - . "{$file} {$action} {$path} {$docRoot} {$serverName} {$env}" - . (($modifier !== '') ? " {$modifier}\"" : '"'); + . "{$file} {$action} {$path} {$docRoot} {$serverName} {$env}" + . (($modifier !== '') ? " {$modifier}\"" : '"'); } /** @@ -322,8 +320,10 @@ public static function getValueFromWordPress( $action, exec($cmd, $output, $return_var); - Logger::debug("getValueFromWordPress command " - . "{$action}={$return_var} {$wpInstall}\n{$cmd}"); + Logger::debug( + "getValueFromWordPress command " + . "{$action}={$return_var} {$wpInstall}\n{$cmd}" + ); Logger::debug('output = ' . var_export($output, true)); $debug = $upgrade = $err = ''; @@ -393,7 +393,8 @@ public static function issue( $action, WPInstall $wpInstall, exec($cmd, $output, $return_var); Logger::debug( - "Issue command {$action}={$return_var} {$wpInstall}\n{$cmd}"); + "Issue command {$action}={$return_var} {$wpInstall}\n{$cmd}" + ); Logger::debug('output = ' . var_export($output, true)); if ( $wpInstall->hasNewLscwpFlagFile() ) { @@ -430,8 +431,15 @@ public static function issue( $action, WPInstall $wpInstall, } elseif ( strpos($line, '[RESULT]') !== false ) { - if ( !self::handleResultOutput($wpInstall, $line, $retStatus, - $cmdStatus, $err) ) { + $ret = self::handleResultOutput( + $wpInstall, + $line, + $retStatus, + $cmdStatus, + $err + ); + + if ( !$ret ) { /** * Problem handling RESULT output, ignore other output. @@ -518,8 +526,11 @@ public static function issue( $action, WPInstall $wpInstall, Logger::error("{$wpInstall->getPath()} - {$err}"); } else { - $msg = self::handleUnexpectedError($wpInstall, $err, - $unexpectedLines); + $msg = self::handleUnexpectedError( + $wpInstall, + $err, + $unexpectedLines + ); } } @@ -586,8 +597,10 @@ private static function preIssueValidation( $action, WPInstall $wpInstall, $extraArgs ) { if ( !self::isSupportedIssueCmd($action) ) { - throw new LSCMException("Illegal action {$action}.", - LSCMException::E_PROGRAM); + throw new LSCMException( + "Illegal action {$action}.", + LSCMException::E_PROGRAM + ); } if ( !$wpInstall->hasValidPath() ) { @@ -602,8 +615,8 @@ private static function preIssueValidation( $action, WPInstall $wpInstall, if ( $wpInstall->hasFlagFile() ) { Logger::debug( - 'Bypass mass operation for flagged install ' - . $wpInstall); + "Bypass mass operation for flagged install {$wpInstall}" + ); return false; } @@ -617,9 +630,10 @@ private static function preIssueValidation( $action, WPInstall $wpInstall, if ( $wpInstall->hasFatalError() ) { $wpInstall->addUserFlagFile(false); - $msg = 'Bypassed mass operation for error install and ' - . "flagged {$wpInstall}"; - Logger::debug($msg); + Logger::debug( + 'Bypassed mass operation for error install and ' + . "flagged {$wpInstall}" + ); return false; } } diff --git a/dist/add-ons/webcachemgr/src/Util.php b/dist/add-ons/webcachemgr/src/Util.php index 6954f9057..1465a89ae 100644 --- a/dist/add-ons/webcachemgr/src/Util.php +++ b/dist/add-ons/webcachemgr/src/Util.php @@ -260,7 +260,7 @@ public static function DirectoryMd5( $dir ) * @param string $file * @param string $backup * @return boolean - * @throws LSCMException Indrectly thrown by Logger::debug(). + * @throws LSCMException Thrown indirectly. */ private static function matchFileSettings( $file, $backup ) { @@ -283,7 +283,8 @@ private static function matchFileSettings( $file, $backup ) return true; } - private static function getBackupSuffix( $filepath, $bak = '_lscachebak_orig' ) + private static function getBackupSuffix( $filepath, + $bak = '_lscachebak_orig' ) { $i = 1; @@ -311,7 +312,9 @@ public static function createBackup( $filepath ) $backup = $filepath . $bak; if ( !copy($filepath, $backup) ) { - Logger::debug("Could not backup file {$filepath} to location {$backup}"); + Logger::debug( + "Could not backup file {$filepath} to location {$backup}" + ); return false; } @@ -319,13 +322,17 @@ public static function createBackup( $filepath ) Logger::verbose("Created file{$backup}"); if ( !self::matchFileSettings($filepath, $backup) ) { - Logger::debug("Could not backup file {$filepath} to location {$backup}"); + Logger::debug( + "Could not backup file {$filepath} to location {$backup}" + ); return false; } Logger::debug('Matched owner/group setting for both files'); - Logger::info("Successfully backed up file {$filepath} to location {$backup}"); + Logger::info( + "Successfully backed up file {$filepath} to location {$backup}" + ); return true; } @@ -334,7 +341,7 @@ public static function createBackup( $filepath ) * @param string $zipFile * @param string $dest * @return boolean - * @throws LSCMException Indirectly thrown by Logger::debug(). + * @throws LSCMException Thrown indirectly. */ public static function unzipFile( $zipFile, $dest ) { @@ -355,7 +362,11 @@ public static function unzipFile( $zipFile, $dest ) $output = array(); - exec("unzip {$zipFile} -d {$dest} > /dev/null 2>&1", $output, $return_var); + exec( + "unzip {$zipFile} -d {$dest} > /dev/null 2>&1", + $output, + $return_var + ); if ( $return_var == 0 ) { return true; @@ -410,8 +421,11 @@ public static function ensureVHCacheRootInCage( $vhCacheRoot ) if ( !preg_grep('!^\s*' . $escVHCacheRoot . '!im', $file_contents) ) { $remount = true; - file_put_contents($cageFsFile, "\n{$vhCacheRoot}", - FILE_APPEND); + file_put_contents( + $cageFsFile, + "\n{$vhCacheRoot}", + FILE_APPEND + ); } } diff --git a/dist/add-ons/webcachemgr/src/View/Model/VersionManageViewModel.php b/dist/add-ons/webcachemgr/src/View/Model/VersionManageViewModel.php index 41960f830..c10afa878 100644 --- a/dist/add-ons/webcachemgr/src/View/Model/VersionManageViewModel.php +++ b/dist/add-ons/webcachemgr/src/View/Model/VersionManageViewModel.php @@ -1,9 +1,9 @@ init(); } + /** + * + * @throws LSCMException Thrown indirectly. + */ protected function init() { $this->setIconPath(); @@ -97,7 +145,9 @@ protected function setActiveVerData() } catch ( LSCMException $e ) { - Logger::debug($e->getMessage() . ' Could not get active LSCWP version.'); + Logger::debug( + $e->getMessage() . ' Could not get active LSCWP version.' + ); $currVer = false; } @@ -114,7 +164,7 @@ protected function setStateData() } else { $this->tplData[self::FLD_STATE] = - self::ST_NO_INSTALLS_DISCOVERED; + self::ST_NO_NON_ERROR_INSTALLS_DISCOVERED; } } else { @@ -122,18 +172,24 @@ protected function setStateData() } } + /** + * + * @throws LSCMException Thrown indirectly. + */ protected function setVerListData() { $vermgr = PluginVersion::getInstance(); try { - $verList = $vermgr->getKnownVersions(true); + $verList = $vermgr->getShortVersions(); $allowedList = $vermgr->getAllowedVersions(); } catch ( LSCMException $e ) { - Logger::debug($e->getMessage() . ' Could not retrieve version list.'); + Logger::debug( + $e->getMessage() . ' Could not retrieve version list.' + ); $verList = $allowedList = array(); } diff --git a/dist/add-ons/webcachemgr/src/View/Tpl/VersionManage.tpl b/dist/add-ons/webcachemgr/src/View/Tpl/VersionManage.tpl index 635d92964..59bd5f528 100644 --- a/dist/add-ons/webcachemgr/src/View/Tpl/VersionManage.tpl +++ b/dist/add-ons/webcachemgr/src/View/Tpl/VersionManage.tpl @@ -114,13 +114,14 @@ if ( $state == ViewModel::ST_SCAN_NEEDED ):

- +

- No WordPress installations discovered in the previous scan - (Installations with a Cache Status of "Error" are not counted). If you have - any newly installed WordPress installations, please go to + No WordPress installations with a non-error status discovered in the + previous scan (Installations with a Cache Status of "Error" are not + counted). If you have any newly installed WordPress installations, please go + to Manage Cache Installations diff --git a/dist/add-ons/webcachemgr/src/WPCaller.php b/dist/add-ons/webcachemgr/src/WPCaller.php index e1890ef6b..ac316e955 100644 --- a/dist/add-ons/webcachemgr/src/WPCaller.php +++ b/dist/add-ons/webcachemgr/src/WPCaller.php @@ -242,7 +242,7 @@ private function getSiteURL() * Get siteurl value from DB directly. */ $query = "SELECT option_value FROM {$table_prefix}options " - . "WHERE option_name = 'siteurl'"; + . "WHERE option_name = 'siteurl'"; $siteURL = $wpdb->get_var($query); } @@ -294,7 +294,7 @@ private function checkStatus( WPInstall $install ) . '/wp-content/advanced-cache.php'; if ( (version_compare($this->installedLscwpVer, '3.0.4', '>=') && !file_exists($advCacheFile)) - || (defined('LSCACHE_ADV_CACHE') && LSCACHE_ADV_CACHE === true) ) { + || (defined('LSCACHE_ADV_CACHE') && LSCACHE_ADV_CACHE === true) ) { $status |= WPInstall::ST_LSC_ADVCACHE_DEFINED; } @@ -421,18 +421,20 @@ private function canEnable( $isMassAction, $isNewInstall ) } $thirdPartyCachePluginSlug = - $this->checkForKnownNonAdvCachePlugins(); + $this->checkForKnownNonAdvCachePlugins(); if ( $thirdPartyCachePluginSlug != '' ) { $this->currInstall->addUserFlagFile(); - $msg = 'Cannot Enable LSCWP - Detected another active cache ' - . "plugin \"{$thirdPartyCachePluginSlug}\". Flag set."; - Logger::uiError($msg); + Logger::uiError( + 'Cannot Enable LSCWP - Detected another active cache ' + . "plugin \"{$thirdPartyCachePluginSlug}\". Flag set." + ); - $msg = 'Ignore - Detected another active cache plugin ' - . "\"{$thirdPartyCachePluginSlug}\". Flagged."; - Logger::notice($msg); + Logger::notice( + 'Ignore - Detected another active cache plugin ' + . "\"{$thirdPartyCachePluginSlug}\". Flagged." + ); return false; } @@ -448,11 +450,11 @@ private function canEnable( $isMassAction, $isNewInstall ) else { $this->currInstall->addUserFlagFile(); - $msg = 'LSCWP Already Enabled But Not Caching - Detected ' - . 'another active cache plugin. Please visit the ' - . 'WordPress Dashboard for further instructions.'; - - Logger::uiError($msg); + Logger::uiError( + 'LSCWP Already Enabled But Not Caching - Detected another ' + . 'active cache plugin. Please visit the WordPress ' + . 'Dashboard for further instructions.' + ); Logger::notice( 'Ignore - Existing install but advanced cache not set' ); @@ -515,16 +517,18 @@ private function directEnableNewInstall() unlink($lscwpZip); if ( $unzipRet !== true ) { - throw new LSCMException("Unable to extract downloaded LSCWP files.", - LSCMException::E_NON_FATAL); + throw new LSCMException( + "Unable to extract downloaded LSCWP files.", + LSCMException::E_NON_FATAL + ); } $this->currInstall->addNewLscwpFlagFile(); $customIni = Context::LOCAL_PLUGIN_DIR . '/' - . PluginVersion::LSCWP_DEFAULTS_INI_FILE_NAME; + . PluginVersion::LSCWP_DEFAULTS_INI_FILE_NAME; $defaultIni = "{$pluginDir}/litespeed-cache/data/" - . PluginVersion::LSCWP_DEFAULTS_INI_FILE_NAME; + . PluginVersion::LSCWP_DEFAULTS_INI_FILE_NAME; if ( file_exists($customIni) ) { copy($customIni, $defaultIni); @@ -556,9 +560,11 @@ private function downloadLscwpZip( $lscwpZip ) { /** @noinspection PhpUndefinedConstantInspection */ $pluginDir = WP_PLUGIN_DIR; - $url = 'https://downloads.wordpress.org/plugin/litespeed-cache.latest-stable.zip'; + $url = 'https://downloads.wordpress.org/plugin/' + . 'litespeed-cache.latest-stable.zip'; - $wget_command = "wget -q --tries=1 --no-check-certificate {$url} -P {$pluginDir}"; + $wget_command = + "wget -q --tries=1 --no-check-certificate {$url} -P {$pluginDir}"; exec($wget_command, $output, $return_var); if ( $return_var === 0 && file_exists($lscwpZip) ) { @@ -570,7 +576,8 @@ private function downloadLscwpZip( $lscwpZip ) /** * Fall back to curl incase wget is disabled for user. */ - $curl_command = "cd {$pluginDir} && curl -O -s --retry 1 --insecure {$url}"; + $curl_command = + "cd {$pluginDir} && curl -O -s --retry 1 --insecure {$url}"; exec($curl_command, $output, $return_var); if ( $return_var === 0 && file_exists($lscwpZip) ) { @@ -597,7 +604,7 @@ public function enable( $extraArgs, $massOp = false ) { /** @noinspection PhpUndefinedConstantInspection */ $isNewInstall = - PluginVersion::getInstance()->prepareUserInstall(WP_PLUGIN_DIR); + PluginVersion::getInstance()->prepareUserInstall(WP_PLUGIN_DIR); if ( $isNewInstall ) { $this->installedLscwpVer = $this->getPluginVersionFromFile(); @@ -658,7 +665,9 @@ private function canDisable( $isMassAction ) if ( $status & WPInstall::ST_PLUGIN_INACTIVE ) { Logger::notice('Ignore - Already disabled'); - Logger::uiSuccess('LiteSpeed Cache Already Disabled - No Action Taken'); + Logger::uiSuccess( + 'LiteSpeed Cache Already Disabled - No Action Taken' + ); return false; } @@ -668,13 +677,15 @@ private function canDisable( $isMassAction ) if ( !($status & WPInstall::ST_LSC_ADVCACHE_DEFINED) ) { $this->currInstall->addUserFlagFile(); - $msg = 'LSCWP Detected As Manually Enabled But Not Caching - Flag Set. If ' - . 'desired, this installation can be disabled from the ' - . 'Manage Cache Installations screen.'; - - Logger::uiSuccess($msg); + Logger::uiSuccess( + 'LSCWP Detected As Manually Enabled But Not Caching - Flag ' + . 'Set. If desired, this installation can be disabled ' + . 'from the Manage Cache Installations screen.' + ); Logger::notice( - 'Ignore for mass disable - Installed manually as advanced cache not set.'); + 'Ignore for mass disable - Installed manually as advanced ' + . 'cache not set.' + ); return false; } @@ -683,9 +694,10 @@ private function canDisable( $isMassAction ) if ( is_plugin_active_for_network(self::LSCWP_PLUGIN) ) { $this->currInstall->addUserFlagFile(); - $msg = 'LiteSpeed Cache Detected As Network Activated - ' - . 'Flag Set & No Action Taken'; - Logger::uiSuccess($msg); + Logger::uiSuccess( + 'LiteSpeed Cache Detected As Network Activated - Flag Set ' + . '& No Action Taken' + ); return false; } @@ -803,26 +815,30 @@ private function canUpgrade( $fromVersions, $toVersion, $massOp ) return false; } - $match = false; + foreach ( $fromVersions as $fromVer ) { + + $fromVerParts = explode('.', $fromVer); + $installedVerParts = explode('.', $this->installedLscwpVer); - foreach ( $fromVersions as $ver ) { + $i = 0; + $stop = sizeof($fromVerParts); - if ( strpos($ver, '.x') !== false ) { - $ver1 = explode('.', $ver); - $ver2 = explode('.', $this->installedLscwpVer); + while (true) { + + if ( $i == $stop || $fromVerParts[$i] == 'x' ) { + return true; + } + elseif ( !isset($installedVerParts[$i]) + || $installedVerParts[$i] != $fromVerParts[$i] ) { - if ( $ver1[0] === $ver2[0] && $ver1[1] === $ver2[1] ) { - $match = true; break; } - } - elseif ( $ver === $this->installedLscwpVer ) { - $match = true; - break; + + $i++; } } - return $match; + return false; } /** @@ -945,11 +961,12 @@ private function enable_lscwp() if ( !($status & WPInstall::ST_LSC_ADVCACHE_DEFINED) ) { $status = $this->performDisable(true); - $msg = 'Detected another active cache plugin. Please deactivate ' - . 'the detected plugin and try again. You may also try ' + Logger::uiError( + 'Detected another active cache plugin. Please deactivate the ' + . 'detected plugin and try again. You may also try ' . 'manually installing through the WordPress Dashboard and ' - . 'following the instructions given.'; - Logger::uiError($msg); + . 'following the instructions given.' + ); $this->massIncr = 'FAIL'; } @@ -968,9 +985,10 @@ private function enable_lscwp() $this->currInstall->addUserFlagFile(); $status = $this->currInstall->getStatus(); - $msg = 'LSCWP Enabled But Not Caching - Please visit the ' - . 'WordPress Dashboard for further instructions.'; - Logger::uiError($msg); + Logger::uiError( + 'LSCWP Enabled But Not Caching - Please visit the ' + . 'WordPress Dashboard for further instructions.' + ); $this->massIncr = 'SUCC'; } @@ -1039,17 +1057,19 @@ private function upgrade_lscwp( $ver, $runHooks = true ) * @noinspection PhpUndefinedMethodInspection * @noinspection PhpUndefinedConstantInspection */ - $upgrader->run(array( - 'package' => $lscwpPackageURL, - 'destination' => WP_PLUGIN_DIR, - 'clear_destination' => true, - 'clear_working' => true, - 'hook_extra' => array( - 'plugin' => $this->pluginEntry, - 'type' => 'plugin', - 'action' => 'update', + $upgrader->run( + array( + 'package' => $lscwpPackageURL, + 'destination' => WP_PLUGIN_DIR, + 'clear_destination' => true, + 'clear_working' => true, + 'hook_extra' => array( + 'plugin' => $this->pluginEntry, + 'type' => 'plugin', + 'action' => 'update', + ) ) - )); + ); /** * Start new messages on a new line @@ -1080,8 +1100,10 @@ private function upgrade_lscwp( $ver, $runHooks = true ) * @noinspection PhpUndefinedFunctionInspection */ if ( !$upgrader->result || is_wp_error($upgrader->result) ) { - throw new LSCMException("Failed to upgrade to v{$ver}.", - LSCMException::E_NON_FATAL); + throw new LSCMException( + "Failed to upgrade to v{$ver}.", + LSCMException::E_NON_FATAL + ); } $this->updateTranslationFiles(); @@ -1127,7 +1149,7 @@ public function updateTranslationFiles() } $localTranslationDir = Context::LOCAL_PLUGIN_DIR - . "/{$this->installedLscwpVer}/translations"; + . "/{$this->installedLscwpVer}/translations"; $moFileName = "litespeed-cache-{$locale}.mo"; $poFileName = "litespeed-cache-{$locale}.po"; @@ -1135,7 +1157,7 @@ public function updateTranslationFiles() $localPoFile = "{$localTranslationDir}/{$poFileName}"; $zipFile = "{$localTranslationDir}/{$locale}.zip"; $translationFlag = "{$localTranslationDir}/" - . PluginVersion::TRANSLATION_CHECK_FLAG_BASE . "_{$locale}"; + . PluginVersion::TRANSLATION_CHECK_FLAG_BASE . "_{$locale}"; $langDir = $this->currInstall->getPath() . '/wp-content/languages/plugins'; @@ -1157,8 +1179,10 @@ public function updateTranslationFiles() /** @noinspection PhpUndefinedFunctionInspection */ if ( unzip_file($zipFile, $langDir) !== true ) { - $this->outputResult('BAD_TRANSLATION', - "{$locale} {$this->installedLscwpVer}"); + $this->outputResult( + 'BAD_TRANSLATION', + "{$locale} {$this->installedLscwpVer}" + ); } } elseif ( !file_exists($translationFlag) || @@ -1174,7 +1198,7 @@ public function updateTranslationFiles() private function includeLSCWPAdvancedCacheFile() { $advCacheFile = $this->currInstall->getPath() - . '/wp-content/advanced-cache.php'; + . '/wp-content/advanced-cache.php'; if ( file_exists($advCacheFile) ) { $content = file_get_contents($advCacheFile); @@ -1372,7 +1396,7 @@ private function isMultisite() $pattern5 = '/define\(\s*[\'"]SUNRISE[\'"]\s*,[^;]*;/'; $config_content = - file_get_contents($this->currInstall->getWpConfigFile()); + file_get_contents($this->currInstall->getWpConfigFile()); if ( preg_match($pattern1, $config_content, $m1) && preg_match($pattern2, $m1[0]) ) { @@ -1388,20 +1412,24 @@ private function isMultisite() if ( $isMultiSite ) { - if ( !preg_match('/define\(\s*[\'"]DOMAIN_CURRENT_SITE[\'"]\s*,\s*[\'"](.+)[\'"]\s*\)\s*;/', - $config_content, $m2) ) { + $domainPattern = '/define\(\s*[\'"]DOMAIN_CURRENT_SITE[\'"]\s*,' + . '\s*[\'"](.+)[\'"]\s*\)\s*;/'; + if ( !preg_match($domainPattern, $config_content, $m2) ) { throw new LSCMException( - 'Cannot find DOMAIN_CURRENT_SITE with MULTISITE defined.'); + 'Cannot find DOMAIN_CURRENT_SITE with MULTISITE defined.' + ); } $this->currInstall->setServerName($m2[1]); - if ( !preg_match('/define\(\s*[\'"]PATH_CURRENT_SITE[\'"]\s*,\s*[\'"](.+)[\'"]\s*\)\s*;/', - $config_content, $m3) ) { + $pathPattern = '/define\(\s*[\'"]PATH_CURRENT_SITE[\'"]\s*,' + . '\s*[\'"](.+)[\'"]\s*\)\s*;/'; + if ( !preg_match($pathPattern, $config_content, $m3) ) { throw new LSCMException( - 'Cannot find PATH_CURRENT_SITE with MULTISITE defined.'); + 'Cannot find PATH_CURRENT_SITE with MULTISITE defined.' + ); } $this->setEnvVar('REQUEST_URI', $m3[1]); @@ -1581,7 +1609,9 @@ private function initWp() $file = $wpPath . $file; if ( !file_exists($file) ) { - throw new LSCMException("Could not include missing file {$file}."); + throw new LSCMException( + "Could not include missing file {$file}." + ); } /** @noinspection PhpIncludeInspection */ diff --git a/dist/admin/html.open/index.php b/dist/admin/html.open/index.php index 4443d3b7e..6cd92a74e 100644 --- a/dist/admin/html.open/index.php +++ b/dist/admin/html.open/index.php @@ -21,7 +21,7 @@ - +

@@ -44,11 +44,11 @@ @@ -63,5 +63,4 @@ ?> - - + \ No newline at end of file diff --git a/dist/admin/html.open/lib/CData.php b/dist/admin/html.open/lib/CData.php index d4928b0cc..f7f06569e 100644 --- a/dist/admin/html.open/lib/CData.php +++ b/dist/admin/html.open/lib/CData.php @@ -972,6 +972,10 @@ private function write_file($filepath, $buf) } fclose($fd); + if (file_exists($filepath)) { + $this->copy_permission($filepath, "{$filepath}.new"); + } + @unlink("{$filepath}.bak"); if (file_exists($filepath) && !rename($filepath, "{$filepath}.bak")) { error_log("failed to rename {$filepath} to {$filepath}.bak"); diff --git a/dist/admin/html.open/lib/DMsg.php b/dist/admin/html.open/lib/DMsg.php index b1f52b0c7..151e414a2 100644 --- a/dist/admin/html.open/lib/DMsg.php +++ b/dist/admin/html.open/lib/DMsg.php @@ -10,11 +10,11 @@ class DMsg const LANG_JAPANES = 'japanes'; const _COOKIE_LANG_ = 'litespeed_admin_lang'; - private static $_supported = array( - self::LANG_ENGLISH => array('English', 'en-US'), - self::LANG_CHINESE => array('中文', 'zh-CN'), - self::LANG_JAPANES => array('日本語', 'ja-JP') - ); + private static $_supported = [ + self::LANG_ENGLISH => ['English', 'en-US'], + self::LANG_CHINESE => ['中文', 'zh-CN'], + self::LANG_JAPANES => ['日本語', 'ja-JP'], + ]; private static $_curlang = ''; private static $_curtips = ''; diff --git a/dist/admin/html.open/lib/util/build_php/BuildConfig.php b/dist/admin/html.open/lib/util/build_php/BuildConfig.php index ec2b57636..8726443a8 100644 --- a/dist/admin/html.open/lib/util/build_php/BuildConfig.php +++ b/dist/admin/html.open/lib/util/build_php/BuildConfig.php @@ -25,8 +25,8 @@ public static function GetVersion($field) case self::PHP_VERSION: return array( - '7.4.11', - '7.3.23', + '7.4.12', + '7.3.24', '7.2.34', '7.1.33', '7.0.33', diff --git a/dist/admin/html.open/res/lang/en-US_msg.php b/dist/admin/html.open/res/lang/en-US_msg.php index 08abb2e64..a8b6ec521 100644 --- a/dist/admin/html.open/res/lang/en-US_msg.php +++ b/dist/admin/html.open/res/lang/en-US_msg.php @@ -83,6 +83,7 @@ $_gmsg['note_configmodified'] = 'Configuration has been modified. To apply changes, please perform a graceful restart.'; $_gmsg['note_confirm_delete'] = 'Are you sure you want to delete this entry? This will be permanently removed from the configuration file.'; $_gmsg['note_confirm_instantiate'] = 'Are you sure you want to instantiate this virtual host? This will create a dedicated configuration file for this virtual host.'; +$_gmsg['note_confirm_logout'] = 'Logout'; $_gmsg['note_copyrightreserved'] = 'All Rights Reserved.'; $_gmsg['note_curbranch'] = 'current branch'; $_gmsg['note_curver'] = 'Current Version'; @@ -90,6 +91,7 @@ $_gmsg['note_entfeature'] = 'This feature is available in Enterprise Edition'; $_gmsg['note_example'] = 'Example'; $_gmsg['note_fullscreen'] = 'Full Screen'; +$_gmsg['note_home'] = 'Home'; $_gmsg['note_inputerr'] = 'Input error detected. Please resolve the error(s).'; $_gmsg['note_loadavg'] = 'System Load Avg'; $_gmsg['note_logout'] = 'You can improve your security further after logging out by closing this opened browser'; @@ -113,6 +115,8 @@ $_gmsg['err_invalidvalat'] = 'Invalid value at'; $_gmsg['err_loggedoff'] = 'You have logged off.'; $_gmsg['err_login'] = 'Invalid credentials.'; +$_gmsg['err_menuanchornotexist'] = 'Error - menu anchor does not exist'; +$_gmsg['err_page_404'] = 'Error 404! Page not found.'; $_gmsg['err_parentdirnotexist'] = 'Parent directory does not exist'; $_gmsg['err_requireabspath'] = 'Require absolute path'; $_gmsg['err_sessiontimeout'] = 'Your session has timed out.'; @@ -775,5 +779,3 @@ 2. change the listener port from default value 7080; 3. do not use simple password; 4. use https for admin console.'; - - diff --git a/dist/admin/html.open/view/inc/header.php b/dist/admin/html.open/view/inc/header.php index a143659ba..0d94bb497 100644 --- a/dist/admin/html.open/view/inc/header.php +++ b/dist/admin/html.open/view/inc/header.php @@ -25,22 +25,19 @@ - + - + - + -