diff --git a/configure b/configure index 28a118954..38891d583 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.11. +# Generated by GNU Autoconf 2.69 for openlitespeed 1.6.12. # # Report bugs to . # @@ -590,8 +590,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='openlitespeed' PACKAGE_TARNAME='openlitespeed' -PACKAGE_VERSION='1.6.11' -PACKAGE_STRING='openlitespeed 1.6.11' +PACKAGE_VERSION='1.6.12' +PACKAGE_STRING='openlitespeed 1.6.12' 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.11 to adapt to many kinds of systems. +\`configure' configures openlitespeed 1.6.12 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.11:";; + short | recursive ) echo "Configuration of openlitespeed 1.6.12:";; 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.11 +openlitespeed configure 1.6.12 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.11, which was +It was created by openlitespeed $as_me 1.6.12, 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.11' + VERSION='1.6.12' # 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.11, which was +This file was extended by openlitespeed $as_me 1.6.12, 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.11 +openlitespeed config.status 1.6.12 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff --git a/configure.ac b/configure.ac index 82d650d7d..ff5839e5f 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.11],[info@litespeedtech.com],[openlitespeed],[http://www.litespeedtech.com/]) +AC_INIT([openlitespeed],[1.6.12],[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 99c026bde..9e7398a30 100644 --- a/dist/VERSION +++ b/dist/VERSION @@ -1 +1 @@ -1.6.11 +1.6.12 diff --git a/dist/add-ons/webcachemgr/VERSION b/dist/add-ons/webcachemgr/VERSION index 096015870..35d51f33b 100644 --- a/dist/add-ons/webcachemgr/VERSION +++ b/dist/add-ons/webcachemgr/VERSION @@ -1 +1 @@ -1.11 +1.12 \ No newline at end of file diff --git a/dist/add-ons/webcachemgr/bootstrap.php b/dist/add-ons/webcachemgr/bootstrap.php index 564f67e07..747107593 100644 --- a/dist/add-ons/webcachemgr/bootstrap.php +++ b/dist/add-ons/webcachemgr/bootstrap.php @@ -1,6 +1,6 @@ phpOptions = '-d disable_functions=ini_set -d opcache.enable=0 ' - . '-d max_execution_time=' . self::PHP_TIMEOUT . ' -d memory_limit=512M ' + . '-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='; @@ -136,8 +136,8 @@ protected function __construct() * Use getClassInstance() with a fully qualified class name as a parameter * instead. * - * Sets self::$instance with a new $className instance if it has not been - * set already. An exception will be thrown if self::$instance has already + * Sets static::$instance with a new $className instance if it has not been + * set already. An exception will be thrown if static::$instance has already * been set to a different class name than the one provided. * * @deprecated @@ -147,7 +147,7 @@ protected function __construct() */ public static function initByClassName( $className ) { - if ( self::$instance == null ) { + if ( static::$instance == null ) { if ( $className == 'custom' ) { $lsws_home = realpath(__DIR__ . '/../../../../'); @@ -173,7 +173,7 @@ public static function initByClassName( $className ) } try{ - self::$instance = new $className(); + static::$instance = new $className(); } catch ( \Exception $e ){ throw new LSCMException( @@ -181,7 +181,7 @@ public static function initByClassName( $className ) } } else { - $instanceClassName = '\\' . get_class(self::$instance); + $instanceClassName = '\\' . get_class(static::$instance); if ( $instanceClassName != $className ) { throw new LSCMException( @@ -190,7 +190,7 @@ public static function initByClassName( $className ) } } - return self::$instance; + return static::$instance; } /** @@ -204,22 +204,22 @@ public static function initByClassName( $className ) */ public static function init( $name ) { - if ( self::$instance != null ) { + if ( static::$instance != null ) { throw new LSCMException('ControlPanel cannot be initialized twice.'); } switch ($name) { - case self::PANEL_CPANEL: + case static::PANEL_CPANEL: $className = 'CPanel'; break; - case self::PANEL_PLESK: + case static::PANEL_PLESK: $className = 'Plesk'; break; default: throw new LSCMException("Control panel '{$name}' is not supported."); } - return self::initByClassName("\Lsc\Wp\Panel\\{$className}"); + return static::initByClassName("\Lsc\Wp\Panel\\{$className}"); } /** @@ -229,18 +229,18 @@ public static function init( $name ) * * @param string $className Fully qualified class name. * @return ControlPanel - * @throws LSCMException Indirectly thrown by self::initByClassName(). + * @throws LSCMException Indirectly thrown by static::initByClassName(). */ public static function getClassInstance( $className = '' ) { if ( $className != '' ) { - self::initByClassName($className); + static::initByClassName($className); } - elseif ( self::$instance == null ) { + elseif ( static::$instance == null ) { throw new LSCMException('Could not get instance, ControlPanel not initialized. '); } - return self::$instance; + return static::$instance; } /** @@ -251,7 +251,7 @@ public static function getClassInstance( $className = '' ) */ public static function getInstance() { - return self::getClassInstance(); + return static::getClassInstance(); } /** @@ -283,11 +283,11 @@ public function areCacheRootsSet() { $ret = true; - if ( self::NOT_SET == $this->getServerCacheRoot() ) { + if ( static::NOT_SET == $this->getServerCacheRoot() ) { $ret = false; } - if ( self::NOT_SET == $this->getVHCacheRoot() ) { + if ( static::NOT_SET == $this->getVHCacheRoot() ) { $ret = false; } @@ -310,12 +310,12 @@ public function verifyCacheSetup() $restartRequired = false; - if ( self::NOT_SET == $this->getServerCacheRoot() ) { + if ( static::NOT_SET == $this->getServerCacheRoot() ) { $this->setServerCacheRoot(); $restartRequired = true; } - if ( self::NOT_SET == $this->getVHCacheRoot() ) { + if ( static::NOT_SET == $this->getVHCacheRoot() ) { $this->setVHCacheRoot(); $restartRequired = true; } @@ -561,7 +561,7 @@ protected function initCacheRoots() $this->log("Server level cache root is {$svrCacheRoot}.", Logger::L_DEBUG); } else { - $this->serverCacheRoot = self::NOT_SET; + $this->serverCacheRoot = static::NOT_SET; $this->log('Server level cache root is not set.', Logger::L_NOTICE); } @@ -570,7 +570,7 @@ protected function initCacheRoots() $this->log("Virtual Host level cache root is {$vhCacheRoot}.", Logger::L_DEBUG); } else { - $this->vhCacheRoot = self::NOT_SET; + $this->vhCacheRoot = static::NOT_SET; $this->log('Virtual Host level cache root is not set.', Logger::L_INFO); } } @@ -620,7 +620,7 @@ protected function log( $msg, $level ) /** * * @param string $svrCacheRoot - * @throws LSCMException + * @throws LSCMException Thrown directly and indirectly. */ public function setServerCacheRoot( $svrCacheRoot = '' ) { @@ -690,8 +690,7 @@ abstract protected function addVHCacheRootSection( $file_contents, /** * * @param string $vhConf - * @throws LSCMException Indirectly thrown by Util::createBackup() and - * $this->log(). + * @throws LSCMException Thrown directly and indirectly. */ public function writeVHCacheRoot( $vhConf, $vhCacheRoot = 'lscache' ) { @@ -756,7 +755,7 @@ public function applyVHConfChanges() */ protected static function setMinAPIFilePath() { - self::$minAPIFilePath = realpath(__DIR__ . '/../..') . '/MIN_VER'; + static::$minAPIFilePath = realpath(__DIR__ . '/../..') . '/MIN_VER'; } /** @@ -767,20 +766,21 @@ protected static function setMinAPIFilePath() */ protected static function getMinAPIFilePath() { - if ( self::$minAPIFilePath == '' ) { - self::setMinAPIFilePath(); + if ( static::$minAPIFilePath == '' ) { + static::setMinAPIFilePath(); } - return self::$minAPIFilePath; + return static::$minAPIFilePath; } /** * * @since 1.9.7 + * @since 1.12 Changed visibility from protected to public. */ - protected static function populateMinAPIVerFile() + public static function populateMinAPIVerFile() { - $minVerFile = self::getMinAPIFilePath(); + $minVerFile = static::getMinAPIFilePath(); $minVerURL = 'https://www.litespeed.sh/sub/shared/MIN_VER'; $content = Util::get_url_contents($minVerURL); @@ -801,14 +801,14 @@ protected static function populateMinAPIVerFile() */ protected static function getMinAPIVer() { - $minVerFile = self::getMinAPIFilePath(); + $minVerFile = static::getMinAPIFilePath(); clearstatcache(); if ( !file_exists($minVerFile) || (time() - filemtime($minVerFile)) > 86400 ) { - self::populateMinAPIVerFile(); + static::populateMinAPIVerFile(); } $minVer = trim(file_get_contents($minVerFile)); @@ -824,10 +824,10 @@ protected static function getMinAPIVer() */ public static function meetsMinAPIVerRequirement() { - $minAPIVer = self::getMinAPIVer(); + $minAPIVer = static::getMinAPIVer(); if ( $minAPIVer == '' - || version_compare(self::PANEL_API_VERSION, $minAPIVer, '<') ) { + || version_compare(static::PANEL_API_VERSION, $minAPIVer, '<') ) { return false; } @@ -846,6 +846,7 @@ public static function meetsMinAPIVerRequirement() public static function checkPanelAPICompatibility( $panelAPIVer ) { $supportedAPIVers = array ( + '1.12', '1.11', '1.10', '1.9.8', @@ -874,16 +875,16 @@ public static function checkPanelAPICompatibility( $panelAPIVer ) $minSupportedAPIVer = end($supportedAPIVers); if ( version_compare($panelAPIVer, $maxSupportedAPIVer, '>') ) { - return self::PANEL_API_VERSION_TOO_HIGH; + return static::PANEL_API_VERSION_TOO_HIGH; } elseif ( version_compare($panelAPIVer, $minSupportedAPIVer, '<') ) { - return self::PANEL_API_VERSION_TOO_LOW; + return static::PANEL_API_VERSION_TOO_LOW; } elseif ( ! in_array($panelAPIVer, $supportedAPIVers) ) { - return self::PANEL_API_VERSION_UNKNOWN; + return static::PANEL_API_VERSION_UNKNOWN; } else { - return self::PANEL_API_VERSION_SUPPORTED; + return static::PANEL_API_VERSION_SUPPORTED; } } @@ -897,9 +898,9 @@ public static function checkPanelAPICompatibility( $panelAPIVer ) */ public static function isPanelAPICompatible( $panelAPIVer ) { - $apiCompatStatus = self::checkPanelAPICompatibility($panelAPIVer); + $apiCompatStatus = static::checkPanelAPICompatibility($panelAPIVer); - if ( $apiCompatStatus != self::PANEL_API_VERSION_SUPPORTED ) { + if ( $apiCompatStatus != static::PANEL_API_VERSION_SUPPORTED ) { return false; } diff --git a/dist/add-ons/webcachemgr/src/UserCommand.php b/dist/add-ons/webcachemgr/src/UserCommand.php index 56eeb3e9c..268067c27 100644 --- a/dist/add-ons/webcachemgr/src/UserCommand.php +++ b/dist/add-ons/webcachemgr/src/UserCommand.php @@ -10,6 +10,7 @@ namespace Lsc\Wp; +use \Exception; use \Lsc\Wp\Context\Context; use \Lsc\Wp\Context\ContextOption; use \Lsc\Wp\Context\UserCLIContextOption; @@ -46,6 +47,12 @@ class UserCommand const CMD_DASH_ADD_MSG = 'dash_add_msg'; const CMD_DASH_DELETE_MSG = 'dash_delete_msg'; + /** + * @since 1.12 + * @var string + */ + const CMD_GET_QUICCLOUD_API_KEY = 'getQuicCloudApiKey'; + /** * @var bool */ @@ -62,13 +69,14 @@ class UserCommand private $action; /** - * @var mixed[] + * @var string[] */ private $extraArgs; /** * * @param boolean $asUser + * @throws LSCMException Thrown indirectly. */ private function __construct( $asUser = false ) { @@ -286,11 +294,83 @@ protected static function getIssueCmd( $action, WPInstall $wpInstall, $modifier = implode(' ', $extraArgs); $file = __FILE__; - $cmd = "{$su} -c \"cd {$path}/wp-admin && timeout {$timeout} {$phpBin} {$file} " - . "{$action} {$path} {$docRoot} {$serverName} {$env}" + return "{$su} -c \"cd {$path}/wp-admin && timeout {$timeout} {$phpBin} " + . "{$file} {$action} {$path} {$docRoot} {$serverName} {$env}" . (($modifier !== '') ? " {$modifier}\"" : '"'); + } + + /** + * + * @since 1.12 + * + * @param string $action + * @param WPInstall $wpInstall + * @param string[] $extraArgs + * @return null|mixed + * @throws LSCMException Thrown indirectly. + */ + public static function getValueFromWordPress( $action, + WPInstall $wpInstall, $extraArgs = array() ) + { + $ret = null; + + if ( !self::preIssueValidation($action, $wpInstall, $extraArgs) ) { + return $ret; + } - return $cmd; + $cmd = self::getIssueCmd($action, $wpInstall, $extraArgs); + + exec($cmd, $output, $return_var); + + Logger::debug("getValueFromWordPress command " + . "{$action}={$return_var} {$wpInstall}\n{$cmd}"); + Logger::debug('output = ' . var_export($output, true)); + + $debug = $upgrade = $err = ''; + $curr = &$err; + + foreach ( $output as $line ) { + + /** + * If this line is not present in output, did not return normally. + * This line will appear after any [UPGRADE] output. + */ + if ( strpos($line, 'LS UserCommand Output Start') !== false ) { + continue; + } + elseif ( strpos($line, '[RESULT]') !== false ) { + + if ( preg_match('/API_KEY=(.+)/', $line, $m) ) { + $ret = $m[1]; + } + else { + $err .= "Unexpected result line {$line}\n"; + } + } + elseif ( ($pos = strpos($line, '[DEBUG]')) !== false ) { + $debug .= substr($line, $pos + 7) . "\n"; + $curr = &$debug; + } + elseif ( strpos($line, '[UPGRADE]') !== false ) { + //Ignore this output + $curr = &$upgrade; + } + else { + $curr .= "{$line}\n"; + } + } + + $path = $wpInstall->getPath(); + + if ( $debug ) { + Logger::logMsg("{$path} - {$debug}", Logger::L_DEBUG); + } + + if ( $err ) { + Logger::logMsg("{$path} - {$err}", Logger::L_ERROR); + } + + return $ret; } /** @@ -299,12 +379,7 @@ protected static function getIssueCmd( $action, WPInstall $wpInstall, * @param WPInstall $wpInstall * @param string[] $extraArgs * @return boolean - * @throws LSCMException Indirectly thrown by self::preIssueValidation(), - * self::getIssueCmd(), Logger::debug(), - * self::removeLeftoverLscwpFiles(), - * self::handleResultOutput(), Logger::logMsg(), - * $wpInstall->addUserFlagFile(), Logger::error(), - * and self::handleUnexpectedError(). + * @throws LSCMException Thrown indirectly. */ public static function issue( $action, WPInstall $wpInstall, $extraArgs = array() ) @@ -503,10 +578,9 @@ public static function newFromCmdArgs( &$args ) * @param WPInstall $wpInstall * @param string[] $extraArgs Not used at the moment. * @return boolean - * @throws LSCMException Indirectly thrown by $wpInstall->hasValidPath() - * Logger::debug(), $wpInstall->refreshStatus(), - * $wpInstall->addUserFlagFile(), - * and DashNotifier::prepLocalDashPluginFiles(). + * @throws LSCMException Thrown directly and indirectly. + * + * @noinspection PhpUnusedParameterInspection */ private static function preIssueValidation( $action, WPInstall $wpInstall, $extraArgs ) @@ -523,6 +597,7 @@ private static function preIssueValidation( $action, WPInstall $wpInstall, switch ($action) { case self::CMD_MASS_ENABLE: case self::CMD_MASS_DISABLE: + /** @noinspection PhpMissingBreakStatementInspection */ case self::CMD_MASS_UPGRADE: if ( $wpInstall->hasFlagFile() ) { @@ -548,6 +623,7 @@ private static function preIssueValidation( $action, WPInstall $wpInstall, return false; } } + //no default } @@ -586,46 +662,64 @@ private function runAsUser() case self::CMD_STATUS: $ret = $proc->updateStatus(true); break; + case self::CMD_ENABLE: $ret = $proc->enable($this->extraArgs); $this->currInstall->removeNewLscwpFlagFile(); break; + case self::CMD_DIRECT_ENABLE: $ret = $proc->directEnable(); $this->currInstall->removeNewLscwpFlagFile(); break; + case self::CMD_MASS_ENABLE: $ret = $proc->massEnable($this->extraArgs); $this->currInstall->removeNewLscwpFlagFile(); break; + case self::CMD_DISABLE: $ret = $proc->disable($this->extraArgs); break; + case self::CMD_MASS_DISABLE: $ret = $proc->massDisable($this->extraArgs); break; + case self::CMD_UPGRADE: $ret = $proc->upgrade($this->extraArgs); break; + case self::CMD_MASS_UPGRADE: $ret = $proc->massUpgrade($this->extraArgs); break; + case self::CMD_UPDATE_TRANSLATION: $proc->updateTranslationFiles(); $ret = self::EXIT_SUCC; break; + case self::CMD_DASH_NOTIFY: $ret = $proc->dashNotify($this->extraArgs); break; + case self::CMD_MASS_DASH_NOTIFY: $ret = $proc->massDashNotify($this->extraArgs); break; + case self::CMD_DASH_DISABLE: $ret = $proc->dashDisable($this->extraArgs); break; + case self::CMD_MASS_DASH_DISABLE: $ret = $proc->massDashDisable($this->extraArgs); break; + + case self::CMD_GET_QUICCLOUD_API_KEY: + $proc->getQuicCloudAPIKey(true); + $ret = self::EXIT_SUCC; + break; + //no default } } @@ -651,7 +745,7 @@ private function runAsUser() echo "[LOG][{$lvl}] {$msg}\n"; } } - catch ( \Exception $e ) + catch ( Exception $e ) { $ret = UserCommand::EXIT_ERROR; @@ -689,7 +783,8 @@ private static function isSupportedIssueCmd( $action ) self::CMD_DASH_NOTIFY, self::CMD_MASS_DASH_NOTIFY, self::CMD_DASH_DISABLE, - self::CMD_MASS_DASH_DISABLE + self::CMD_MASS_DASH_DISABLE, + self::CMD_GET_QUICCLOUD_API_KEY ); return in_array($action, $supported); @@ -720,6 +815,7 @@ private function initArgs( $args ) /** * * @return UserCommand + * @throws LSCMException Thrown indirectly. */ private static function getUserCommand() { @@ -747,6 +843,10 @@ private static function getUserCommand() return $instance; } + /** + * + * @throws LSCMException Thrown indirectly. + */ public static function run() { if ( $cmd = self::getUserCommand() ) { @@ -764,5 +864,7 @@ public static function run() /** * This should only be invoked from command line. + * + * @noinspection PhpUnhandledExceptionInspection */ UserCommand::run(); diff --git a/dist/add-ons/webcachemgr/src/Util.php b/dist/add-ons/webcachemgr/src/Util.php index 97a03b9dc..790bd0e94 100644 --- a/dist/add-ons/webcachemgr/src/Util.php +++ b/dist/add-ons/webcachemgr/src/Util.php @@ -303,9 +303,7 @@ private static function getBackupSuffix( $filepath, $bak = '_lscachebak_orig' ) * * @param string $filepath * @return boolean - * @throws LSCMException Indirectly thrown by Logger::debug(), - * Logger::verbose(), self::matchFileSettings(), and - * Logger::info(). + * @throws LSCMException Thrown indirectly. */ public static function createBackup( $filepath ) { diff --git a/dist/add-ons/webcachemgr/src/WPCaller.php b/dist/add-ons/webcachemgr/src/WPCaller.php index d08565d11..557bf7330 100644 --- a/dist/add-ons/webcachemgr/src/WPCaller.php +++ b/dist/add-ons/webcachemgr/src/WPCaller.php @@ -1,6 +1,6 @@ ') ) { - require_once "{$dir}/litespeed-cache-admin.class.php"; + if ( version_compare($lscwpVer, '3.0', '>=') ) { + require_once "${dir}/src/admin.cls.php"; + } + elseif ( version_compare($lscwpVer, '1.1.2.2', '>') ) { + require_once "{$dir}/admin/litespeed-cache-admin.class.php"; } else { - require_once "{$dir}/class-litespeed-cache-admin.php"; + require_once "{$dir}/admin/class-litespeed-cache-admin.php"; } if ( version_compare($lscwpVer, '1.1.0', '<') && version_compare($lscwpVer, '1.0.6', '>') ) { - require_once "{$dir}/class-litespeed-cache-admin-rules.php"; + require_once "{$dir}/admin/class-litespeed-cache-admin-rules.php"; } } @@ -698,9 +700,7 @@ private function includeDisableRequiredFiles( $lscwpVer ) private function performDisable( $uninstall ) { $this->includeDisableRequiredFiles($this->getPluginVersionFromFile()); - $status = $this->disable_lscwp($uninstall); - - return $status; + return $this->disable_lscwp($uninstall); } /** @@ -1136,6 +1136,28 @@ public function massDashDisable( $extraArgs ) return $ret; } + /** + * + * @since 1.12 + * + * @param bool $setOutputResult + * @return string + */ + public function getQuicCloudAPIKey( $setOutputResult = false ) + { + $key = apply_filters('litespeed_conf', 'api_key'); + + if ( $key == 'api_key' || $key == null ) { + $key = ''; + } + + if ( $setOutputResult ) { + $this->outputResult('API_KEY', $key); + } + + return $key; + } + /** * Set global server and environment variables. * @@ -1213,6 +1235,10 @@ private function isMultisite() return $isMultiSite; } + /** + * + * @throws LSCMException Thrown directly and indirectly. + */ private function initWp() { /** @@ -1241,6 +1267,7 @@ private function initWp() */ include_once "{$wpPath}/wp-includes/version.php"; + /** @noinspection PhpUndefinedVariableInspection */ if ( version_compare($wp_version, '4.0', '<') ) { throw new LSCMException("Detected WordPress version as {$wp_version}. " . 'Version 4.0 required at minimum.'); diff --git a/dist/add-ons/webcachemgr/src/WPInstall.php b/dist/add-ons/webcachemgr/src/WPInstall.php index 3b2d63865..7ac5d76c6 100644 --- a/dist/add-ons/webcachemgr/src/WPInstall.php +++ b/dist/add-ons/webcachemgr/src/WPInstall.php @@ -383,9 +383,7 @@ public function getWpConfigFile() * * @param string $url * @return boolean - * @throws LSCMException Indirectly thrown by - * ControlPanel::getClassInstance(), - * $this->addUserFlagFile(), and Logger::error(). + * @throws LSCMException Thrown indirectly. */ public function populateDataFromUrl( $url ) { diff --git a/dist/add-ons/webcachemgr/src/WPInstallStorage.php b/dist/add-ons/webcachemgr/src/WPInstallStorage.php index 95954cdf8..33213505e 100644 --- a/dist/add-ons/webcachemgr/src/WPInstallStorage.php +++ b/dist/add-ons/webcachemgr/src/WPInstallStorage.php @@ -19,17 +19,60 @@ class WPInstallStorage { + /** + * @var string + */ + const CMD_ADD_CUST_WPINSTALLS = 'addCustWPInstalls'; + + /** + * @var string + */ + const CMD_DISCOVER_NEW = 'discoverNew'; + + /** + * @var string + */ + const CMD_FLAG = 'flag'; + + /** + * @var string + */ + const CMD_MASS_UNFLAG = 'mass_unflag'; + + /** + * @var string + */ + const CMD_SCAN = 'scan'; + + /** + * @var string + */ + const CMD_UNFLAG = 'unflag'; + + /** + * @var string + */ const DATA_VERSION = '1.5'; + + /** + * @var int + */ const ERR_NOT_EXIST = 1; + + /** + * @var int + */ const ERR_CORRUPTED = 2; + + /** + * @var int + */ const ERR_VERSION_HIGH = 3; + + /** + * @var int + */ const ERR_VERSION_LOW = 4; - const CMD_SCAN = 'scan'; - const CMD_DISCOVER_NEW = 'discoverNew'; - const CMD_ADD_CUST_WPINSTALLS = 'addCustWPInstalls'; - const CMD_FLAG = 'flag'; - const CMD_UNFLAG = 'unflag'; - const CMD_MASS_UNFLAG = 'mass_unflag'; /** * @var string @@ -65,7 +108,7 @@ class WPInstallStorage * * @param string $dataFile * @param string $custDataFile - * @throws LSCMException Indirectly thrown by $this->init(). + * @throws LSCMException Thrown indirectly. */ public function __construct( $dataFile, $custDataFile = '' ) { @@ -77,8 +120,7 @@ public function __construct( $dataFile, $custDataFile = '' ) /** * * @return int - * @throws LSCMException Indirectly thrown by $this->getDataFileData() and - * Logger::debug(). + * @throws LSCMException Thrown indirectly. */ protected function init() { @@ -113,7 +155,7 @@ protected function init() * * @param string $dataFile * @return WPInstall[] - * @throws LSCMException Indirectly thrown by $this->verifyDataFileVer(). + * @throws LSCMException Thrown indirectly. */ protected function getDataFileData( $dataFile ) { @@ -195,6 +237,8 @@ public function getCount( $nonFatalOnly = false ) /** * * @return null|WPInstall[] + * + * @noinspection PhpUnused */ public function getWPInstalls() { @@ -204,6 +248,8 @@ public function getWPInstalls() /** * * @return null|WPInstall[] + * + * @noinspection PhpUnused */ public function getCustWPInstalls() { @@ -297,7 +343,7 @@ public function addWPInstall( WPInstall $wpInstall ) /** * - * @throws LSCMException Indirectly thrown by $this->saveDataFile(). + * @throws LSCMException Thrown indirectly. */ public function syncToDisk() { @@ -312,7 +358,7 @@ public function syncToDisk() * * @param string $dataFile * @param WPInstall[] $wpInstalls - * @throws LSCMException Indirectly thrown by $this->log(). + * @throws LSCMException Thrown indirectly. */ protected function saveDataFile( $dataFile, $wpInstalls ) { @@ -337,27 +383,12 @@ protected function saveDataFile( $dataFile, $wpInstalls ) $this->log("Data file saved {$dataFile}", Logger::L_DEBUG); } - /** - * Deprecated 06/14/19. Use verifyDataFileVer() instead. - * - * Updates data file to the latest format if possible/needed. - * - * @deprecated - * @param string $dataFileVer - * @return int - */ - protected function checkDataFileVer( $dataFileVer ) - { - return $this->verifyDataFileVer($this->dataFile, $dataFileVer); - } - /** * * @param string $dataFile * @param string $dataFileVer * @return int - * @throws LSCMException Indirectly thrown by Logger::info() and - * $this->updateDataFile(). + * @throws LSCMException Thrown indirectly. */ protected function verifyDataFileVer( $dataFile, $dataFileVer ) { @@ -375,25 +406,12 @@ protected function verifyDataFileVer( $dataFile, $dataFileVer ) return 0; } - /** - * Deprecated 06/14/19. Use updateDataFile() instead. - * - * @deprecated - * @param string $dataFileVersion - * @return boolean - */ - protected function upgradeDataFile( $dataFileVersion ) - { - return $this->updateDataFile($this->dataFile, $dataFileVersion); - } - /** * * @param string $dataFile * @param string $dataFileVer * @return boolean - * @throws LSCMException Indirectly thrown by Logger::info(), - * Util::createBackup(), and Logger::error(). + * @throws LSCMException Thrown indirectly. */ public static function updateDataFile( $dataFile, $dataFileVer ) { @@ -425,8 +443,7 @@ public static function updateDataFile( $dataFile, $dataFileVer ) * * @param string $action * @return string[] - * @throws LSCMException Indirectly thrown by - * ControlPanel::getClassInstance(). + * @throws LSCMException Thrown indirectly. */ protected function prepareActionItems( $action ) { @@ -462,12 +479,7 @@ protected function prepareActionItems( $action ) * @param string $action * @param string $path * @param string[] $extraArgs - * @throws LSCMException Indirectly thrown by $wpInstall->hasValidPath(), - * $wpInstall->addUserFlagFile(), - * $wpInstall->refreshStatus(), - * PluginVersion::getInstance(), and - * PluginVersion::getInstance()->getAllowedVersions(), - * UserCommand::issue(), and $this->syncToDisk(). + * @throws LSCMException Thrown indirectly. */ protected function doWPInstallAction( $action, $path, $extraArgs ) { @@ -580,14 +592,7 @@ protected function doWPInstallAction( $action, $path, $extraArgs ) * @param null|string[] $list * @param string[] $extraArgs * @return string[] - * @throws LSCMException Indirectly thrown by $this->prepareActionItems(), - * $this->log(), Context::getActionTimeout(), - * $this->scan(), $this->addCustomInstallations(), - * $this->doWPInstallAction(), - * PluginVersion::getCurrentVersion(), - * PluginVersion::getInstance(), - * PluginVersion::getInstance()->setActiveVersion(), - * and $this->syncToDisk(). + * @throws LSCMException Thrown indirectly. */ public function doAction( $action, $list, $extraArgs = array() ) { @@ -676,10 +681,8 @@ public function doAction( $action, $list, $extraArgs = array() ) * * @param string $docroot * @param boolean $forceRefresh - * @return null - * @throws LSCMException Indirectly thrown by Context::getScanDepth(), - * $this->log(), and - * $this->wpInstalls[$wp_path]->refreshStatus(). + * @return void + * @throws LSCMException Thrown indirectly. */ protected function scan( $docroot, $forceRefresh = false ) { @@ -734,9 +737,8 @@ protected function scan( $docroot, $forceRefresh = false ) /** * * @param string[] $wpInstallsInfo - * @return null - * @throws LSCMException Indirectly thrown by $this->log() and - * $this->custWpInstalls[$wpPath]->refreshStatus(). + * @return void + * @throws LSCMException Thrown indirectly. */ protected function addCustomInstallations( $wpInstallsInfo ) { @@ -833,18 +835,14 @@ public function getAllCmdMsgs() } } - $msgs = array( 'succ' => $succ, 'fail' => $fail, 'err' => $err ); - - return $msgs; + return array( 'succ' => $succ, 'fail' => $fail, 'err' => $err ); } /** * * @param string $msg * @param int $level - * @throws LSCMException Indirectly thrown by Logger::error(), - * Logger::warn(), Logger::notice(), Logger::info(), - * Logger::verbose(), and Logger::debug(). + * @throws LSCMException Thrown indirectly. */ protected function log( $msg, $level ) { diff --git a/src/config.h.cmake b/src/config.h.cmake index 9784aa420..6b4c092a1 100644 --- a/src/config.h.cmake +++ b/src/config.h.cmake @@ -5,6 +5,6 @@ #define DEFAULT_TMP_DIR "/tmp/lshttpd" #define PID_FILE "/tmp/lshttpd/openlitespeed.pid" -#define PACKAGE_VERSION "1.6.11" +#define PACKAGE_VERSION "1.6.12" #define LS_MODULE_VERSION_INFO "\tmodgzip 1.1\n\tcache 1.62\n\tmodinspector 1.1\n\tuploadprogress 1.1\n\tmod_security 1.3\n" #endif diff --git a/src/main/lshttpdmain.cpp b/src/main/lshttpdmain.cpp index 88bfaf3e6..751aad655 100644 --- a/src/main/lshttpdmain.cpp +++ b/src/main/lshttpdmain.cpp @@ -82,7 +82,7 @@ /*** * Do not change the below format, it will be set correctly while packing the code */ -#define BUILDTIME " (built: Thu Apr 2 14:45:36 UTC 2020)" +#define BUILDTIME " (built: Thu Apr 9 17:38:26 UTC 2020)" #define GlobalServerSessionHooks (LsiApiHooks::getServerSessionHooks()) diff --git a/src/main/plainconf.cpp b/src/main/plainconf.cpp index 36abe7ff3..2c9b38284 100644 --- a/src/main/plainconf.cpp +++ b/src/main/plainconf.cpp @@ -442,7 +442,11 @@ bool plainconf::bErrorLogSetup = false; AutoStr2 plainconf::rootPath = ""; StringList plainconf::errorLogList; GPointerList plainconf::gModuleList; + +#ifdef ENABLE_CONF_HASH StrStrHashMap plainconf::m_confFileHash; +#endif + /*** * We try to make log available even if errorlog is not setup. @@ -546,7 +550,9 @@ void plainconf::init() void plainconf::release() { +#ifdef ENABLE_CONF_HASH m_confFileHash.release_objects(); +#endif } void plainconf::setRootPath(const char *root) @@ -1272,6 +1278,8 @@ void plainconf::loadConfFile(const char *path) size_t nMultiLineModeSignLen = 0; //>0 is mulline mode bool bInHashT = false; char *pBuf = NULL; + +#ifdef ENABLE_CONF_HASH if (m_confFileHash.size() > 0) { StrStrHashMap::iterator it = m_confFileHash.find(path); @@ -1282,7 +1290,7 @@ void plainconf::loadConfFile(const char *path) logToMem(LOG_LEVEL_INFO, "File %s loaded, use memory in hashT, size %d.", path, strlen(pBuf)); } } - +#endif if (!pBuf) { FILE *fp = fopen(path, "r"); @@ -1305,7 +1313,9 @@ void plainconf::loadConfFile(const char *path) fread(pBuf, 1, bufLen, fp); pBuf[bufLen] = 0; fclose(fp); +#ifdef ENABLE_CONF_HASH m_confFileHash.insert_update(path, pBuf); +#endif } char *pBufStart = pBuf; @@ -1318,14 +1328,14 @@ void plainconf::loadConfFile(const char *path) if (!pLineEnd) pLineEnd = pBufEnd; - if (pLineEnd - pBufStart >= MAX_LINE_LENGTH) + if (pLineEnd - pBufStart >= MAX_LINE_LENGTH - 1) { logToMem(LOG_LEVEL_ERR, "Config file %s #%d line is too long!!", path, lineNumber); return ; } - memcpy(sLine, pBufStart, pLineEnd - pBufStart); - sLine[pLineEnd - pBufStart] = 0; + memcpy(sLine, pBufStart, pLineEnd - pBufStart + 1); + sLine[pLineEnd - pBufStart + 1] = 0; //Add a NULL terminate p = sLine; pBufStart = pLineEnd + 1; diff --git a/src/main/plainconf.h b/src/main/plainconf.h index 522c5695d..01983b0e0 100644 --- a/src/main/plainconf.h +++ b/src/main/plainconf.h @@ -18,6 +18,9 @@ #ifndef __PLAINCONF_H__ #define __PLAINCONF_H__ +#define ENABLE_CONF_HASH 1 + + /*Usage of this module * parseFile() to parse a whole file includes "include" and return the root node * of the config tree @@ -119,7 +122,9 @@ class plainconf static AutoStr2 rootPath; static StringList errorLogList; static bool bErrorLogSetup; +#ifdef ENABLE_CONF_HASH static StrStrHashMap m_confFileHash; +#endif }; diff --git a/src/modules/lsrecaptcha/src/ls/lsapi/logger.go b/src/modules/lsrecaptcha/src/ls/lsapi/logger.go index cbf1d1cbd..3613320b0 100644 --- a/src/modules/lsrecaptcha/src/ls/lsapi/logger.go +++ b/src/modules/lsrecaptcha/src/ls/lsapi/logger.go @@ -173,9 +173,6 @@ func (w *fileLogger) Write(output []byte) (int, error) { // Perform the actual act of rotating and reopening file. func (w *fileLogger) rotate() (err error) { - w.lock.Lock() - defer w.lock.Unlock() - // Close existing file if open if w.handle != nil { err = w.handle.Close()