From 351d4d872dacc9becd9d439bae03fd6d7fafd0e2 Mon Sep 17 00:00:00 2001 From: david Date: Thu, 25 Jun 2020 17:26:58 -0400 Subject: [PATCH] Check in 1.7.2 --- CMakeLists.txt | 6 +- LSQUICCOMMIT | 2 +- build.sh | 44 +- configure | 23 +- configure.ac | 3 +- dist/Example/html/upload.html | 4 +- dist/Example/html/upload.php | 178 +- dist/VERSION | 2 +- dist/add-ons/webcachemgr/VERSION | 2 +- dist/add-ons/webcachemgr/src/Panel/CPanel.php | 83 +- .../webcachemgr/src/Panel/ControlPanel.php | 164 +- .../webcachemgr/src/Panel/DirectAdmin.php | 36 +- dist/add-ons/webcachemgr/src/Panel/Plesk.php | 50 +- dist/add-ons/webcachemgr/src/Util.php | 1 + dist/add-ons/webcachemgr/src/WPCaller.php | 340 +- .../webcachemgr/src/WPInstallStorage.php | 8 +- dist/admin/html.open/index.php | 2 +- dist/admin/html.open/lib/DMsg.php | 2 +- dist/admin/html.open/lib/DTbl.php | 1 + dist/admin/html.open/lib/DTblDefBase.php | 27 +- dist/admin/html.open/lib/ows/DPageDef.php | 10 +- dist/admin/html.open/lib/ows/DTblDef.php | 35 +- .../lib/util/build_php/BuildConfig.php | 6 +- dist/admin/html.open/login.php | 2 +- dist/admin/html.open/res/lang/en-US_msg.php | 5 +- dist/admin/html.open/res/lang/en-US_tips.php | 18 +- dist/admin/html.open/res/lang/ja-JP_tips.php | 10 + dist/admin/html.open/res/lang/zh-CN_tips.php | 14 +- dist/admin/html.open/view/inc/configui.php | 2 +- dist/conf/httpd_config.conf.in | 2 +- dist/docs/AdminGeneral_Help.html | 2 +- dist/docs/AdminListeners_General_Help.html | 2 +- dist/docs/AdminListeners_SSL_Help.html | 2 +- dist/docs/AdminSecurity_Help.html | 2 +- dist/docs/App_Server_Context.html | 2 +- dist/docs/App_Server_Help.html | 2 +- dist/docs/CGI_Context.html | 2 +- dist/docs/CompilePHP_Help.html | 2 +- dist/docs/Context_Help.html | 2 +- dist/docs/ExtApp_Help.html | 2 +- dist/docs/External_FCGI.html | 2 +- dist/docs/External_FCGI_Auth.html | 2 +- dist/docs/External_LB.html | 2 +- dist/docs/External_LSAPI.html | 2 +- dist/docs/External_PL.html | 2 +- dist/docs/External_Servlet.html | 2 +- dist/docs/External_WS.html | 2 +- dist/docs/FCGI_Context.html | 2 +- dist/docs/Java_Web_App_Context.html | 2 +- dist/docs/LB_Context.html | 2 +- dist/docs/LSAPI_Context.html | 2 +- dist/docs/Listeners_General_Help.html | 2 +- dist/docs/Listeners_SSL_Help.html | 2 +- dist/docs/Module_Context.html | 2 +- dist/docs/Module_Help.html | 2 +- dist/docs/Proxy_Context.html | 2 +- dist/docs/Redirect_Context.html | 2 +- dist/docs/Rewrite_Help.html | 2 +- dist/docs/ScriptHandler_Help.html | 2 +- dist/docs/ServGeneral_Help.html | 4 +- dist/docs/ServLog_Help.html | 2 +- dist/docs/ServSecurity_Help.html | 6 +- dist/docs/ServTuning_Help.html | 15 +- dist/docs/ServerStat_Help.html | 4 +- dist/docs/Servlet_Context.html | 2 +- dist/docs/Static_Context.html | 2 +- dist/docs/Templates_Help.html | 2 +- dist/docs/VHGeneral_Help.html | 2 +- dist/docs/VHSSL_Help.html | 2 +- dist/docs/VHSecurity_Help.html | 5 +- dist/docs/VHWebSocket_Help.html | 2 +- dist/docs/VirtualHosts_Help.html | 2 +- dist/docs/admin.html | 2 +- dist/docs/config.html | 2 +- dist/docs/css/hdoc.css | 2 +- dist/docs/index.html | 4 +- dist/docs/install.html | 2 +- dist/docs/intro.html | 2 +- dist/docs/ja-JP/ServSecurity_Help.html | 4 + dist/docs/ja-JP/ServTuning_Help.html | 3 +- dist/docs/ja-JP/VHSecurity_Help.html | 3 + dist/docs/license.html | 2 +- dist/docs/security.html | 2 +- dist/docs/webconsole.html | 2 +- dist/docs/zh-CN/AdminGeneral_Help.html | 2 +- .../zh-CN/AdminListeners_General_Help.html | 2 +- dist/docs/zh-CN/AdminListeners_SSL_Help.html | 2 +- dist/docs/zh-CN/AdminSecurity_Help.html | 2 +- dist/docs/zh-CN/App_Server_Context.html | 2 +- dist/docs/zh-CN/App_Server_Help.html | 2 +- dist/docs/zh-CN/CGI_Context.html | 2 +- dist/docs/zh-CN/CompilePHP_Help.html | 2 +- dist/docs/zh-CN/Context_Help.html | 2 +- dist/docs/zh-CN/ExtApp_Help.html | 2 +- dist/docs/zh-CN/External_FCGI.html | 2 +- dist/docs/zh-CN/External_FCGI_Auth.html | 2 +- dist/docs/zh-CN/External_LB.html | 2 +- dist/docs/zh-CN/External_LSAPI.html | 2 +- dist/docs/zh-CN/External_PL.html | 2 +- dist/docs/zh-CN/External_Servlet.html | 2 +- dist/docs/zh-CN/External_WS.html | 2 +- dist/docs/zh-CN/FCGI_Context.html | 2 +- dist/docs/zh-CN/Java_Web_App_Context.html | 2 +- dist/docs/zh-CN/LB_Context.html | 2 +- dist/docs/zh-CN/LSAPI_Context.html | 2 +- dist/docs/zh-CN/Listeners_General_Help.html | 2 +- dist/docs/zh-CN/Listeners_SSL_Help.html | 2 +- dist/docs/zh-CN/Module_Context.html | 2 +- dist/docs/zh-CN/Module_Help.html | 2 +- dist/docs/zh-CN/Proxy_Context.html | 2 +- dist/docs/zh-CN/Redirect_Context.html | 2 +- dist/docs/zh-CN/Rewrite_Help.html | 2 +- dist/docs/zh-CN/ScriptHandler_Help.html | 2 +- dist/docs/zh-CN/ServGeneral_Help.html | 2 +- dist/docs/zh-CN/ServLog_Help.html | 2 +- dist/docs/zh-CN/ServSecurity_Help.html | 6 +- dist/docs/zh-CN/ServTuning_Help.html | 11 +- dist/docs/zh-CN/ServerStat_Help.html | 4 +- dist/docs/zh-CN/Servlet_Context.html | 2 +- dist/docs/zh-CN/Static_Context.html | 2 +- dist/docs/zh-CN/Templates_Help.html | 2 +- dist/docs/zh-CN/VHGeneral_Help.html | 2 +- dist/docs/zh-CN/VHSSL_Help.html | 2 +- dist/docs/zh-CN/VHSecurity_Help.html | 5 +- dist/docs/zh-CN/VHWebSocket_Help.html | 2 +- dist/docs/zh-CN/VirtualHosts_Help.html | 2 +- dist/docs/zh-CN/admin.html | 2 +- dist/docs/zh-CN/config.html | 2 +- dist/docs/zh-CN/index.html | 4 +- dist/docs/zh-CN/install.html | 2 +- dist/docs/zh-CN/intro.html | 2 +- dist/docs/zh-CN/license.html | 2 +- dist/docs/zh-CN/security.html | 2 +- dist/docs/zh-CN/webconsole.html | 2 +- dist/fcgi-bin/RackRunner.rb | 16 +- dist/functions.sh | 29 +- dist/lsrecaptcha/_recaptcha.shtml | 5 +- include/ls.h | 32 +- include/lsdef.h | 1 - include/lsr/ls_atomic.h | 104 +- include/lsr/ls_evtcb.h | 121 +- include/lsr/ls_lock.h | 88 +- src/CMakeLists.txt | 4 +- src/Makefile.am | 10 +- src/Makefile.in | 33 +- src/adns/adns.cpp | 40 +- src/adns/adns.h | 21 +- src/config.h.cmake | 2 +- src/edio/CMakeLists.txt | 25 - src/edio/aiooutputstream.cpp | 133 +- src/edio/aiooutputstream.h | 83 +- src/edio/ediostream.h | 30 +- src/edio/epoll.cpp | 4 +- src/edio/eventnotifier.h | 2 + src/edio/evtcbque.cpp | 671 +- src/edio/evtcbque.h | 120 +- src/edio/flowcontrol.h | 26 +- src/edio/multiplexerfactory.cpp | 18 + src/edio/multiplexerfactory.h | 2 + src/edio/streamstat.h | 98 + src/extensions/CMakeLists.txt | 26 - src/extensions/cgi/cgidworker.cpp | 2 +- src/extensions/extworkerconfig.cpp | 3 + src/extensions/jk/jconn.cpp | 3 +- src/extensions/localworker.cpp | 6 +- src/extensions/lsapi/lsapiconn.cpp | 2 +- src/extensions/proxy/proxyconn.cpp | 2 +- src/h2/CMakeLists.txt | 17 + src/h2/Makefile.am | 12 + src/h2/Makefile.in | 703 + src/h2/h2connbase.cpp | 1849 + src/{spdy/h2connection.h => h2/h2connbase.h} | 304 +- src/h2/h2connection.cpp | 602 + src/h2/h2connection.h | 117 + src/{spdy => h2}/h2protocol.cpp | 4 +- src/{spdy => h2}/h2protocol.h | 12 +- src/h2/h2stream.cpp | 167 + src/h2/h2stream.h | 70 + src/h2/h2streambase.cpp | 592 + src/{spdy/h2stream.h => h2/h2streambase.h} | 92 +- src/{spdy => h2}/h2streampool.cpp | 2 +- src/{spdy => h2}/h2streampool.h | 2 +- src/h2/lsxpack_error_code.h | 48 + src/h2/ssledstream.cpp | 460 + src/h2/ssledstream.h | 145 + src/h2/unpackedheaders.cpp | 1553 + src/h2/unpackedheaders.h | 258 + src/http/CMakeLists.txt | 6 - src/http/Makefile.am | 2 - src/http/Makefile.in | 1 - src/http/accesslog.cpp | 55 +- src/http/hiohandlerfactory.cpp | 2 +- src/http/hiostream.cpp | 14 +- src/http/hiostream.h | 233 +- src/http/httpcgitool.cpp | 59 +- src/http/httpcgitool.h | 16 +- src/http/httpextconnector.cpp | 6 +- src/http/httpheader.cpp | 2 +- src/http/httpheader.h | 20 +- src/http/httplistener.cpp | 3 +- src/http/httplistener.h | 18 +- src/http/httplog.cpp | 44 +- src/http/httprange.cpp | 8 +- src/http/httpreq.cpp | 243 +- src/http/httpreq.h | 12 +- src/http/httpresp.cpp | 4 +- src/http/httpresp.h | 12 +- src/http/httprespheaders.cpp | 1620 +- src/http/httprespheaders.h | 370 +- src/http/httpsession.cpp | 129 +- src/http/httpsession.h | 18 +- src/http/httpstatuscode.h | 4 +- src/http/httpstatusline.cpp | 5 +- src/http/httpvhost.cpp | 14 +- src/http/httpvhostlist.cpp | 16 +- src/http/reqstats.cpp | 11 + src/http/reqstats.h | 40 +- src/http/requestvars.cpp | 13 +- src/http/rewriteengine.cpp | 3 +- src/http/staticfilehandler.cpp | 10 +- src/http/subrequest.cpp | 2 +- src/log4cxx/appendermanager.cpp | 3 +- src/log4cxx/fileappender.cpp | 11 +- src/log4cxx/fileappender.h | 8 +- src/log4cxx/logrotate.cpp | 8 +- src/log4cxx/logsession.h | 4 +- src/log4cxx/patternlayout.cpp | 4 + src/lsiapi/internal.h | 2 +- src/lsiapi/lsiapihooks.h | 8 +- src/lsiapi/lsiapilib.cpp | 11 +- src/lsr/CMakeLists.txt | 2 - src/lsr/ls_lfqueue.c | 14 +- src/lsr/ls_lock.c | 2 +- src/lsr/ls_offload.h | 30 +- src/main/httpserver.cpp | 102 +- src/main/lshttpdmain.cpp | 21 +- src/main/plainconf.cpp | 3 + src/modules/CMakeLists.txt | 2 +- src/modules/cache/cache.cpp | 104 +- src/modules/cache/dirhashcachestore.cpp | 46 +- src/modules/js/CMakeLists.txt | 7 +- src/modules/lua/CMakeLists.txt | 7 +- src/modules/pagespeed/pagespeed.cpp | 6 +- src/quic/quicengine.cpp | 170 +- src/quic/quicshm.cpp | 4 +- src/quic/quicstream.cpp | 145 +- src/quic/quicstream.h | 49 +- src/quic/udplistener.h | 24 +- src/shm/ls_shmhashstat.cpp | 23 + src/shm/lsshmhash.cpp | 51 +- src/shm/lsshmhash.h | 6 +- src/shm/lsshmpool.cpp | 14 + src/shm/lsshmtidmgr.cpp | 226 +- src/shm/lsshmtidmgr.h | 34 +- src/socket/CMakeLists.txt | 25 +- src/socket/Makefile.am | 2 +- src/socket/Makefile.in | 12 +- src/{lsr => socket}/reuseport.cpp | 2 +- {include/lsr => src/socket}/reuseport.h | 0 src/spdy/CMakeLists.txt | 6 - src/spdy/Makefile.am | 5 +- src/spdy/Makefile.in | 65 +- src/spdy/h2connection.cpp | 2170 - src/spdy/h2stream.cpp | 598 - src/spdy/lshpack.c | 72324 ---------------- src/spdy/lshpack.h | 279 - src/spdy/spdyconnection.cpp | 2 +- src/spdy/unpackedheaders.cpp | 431 - src/spdy/unpackedheaders.h | 124 - src/sslpp/ls_fdbuf_bio.c | 94 +- src/sslpp/ls_fdbuf_bio.h | 18 +- src/sslpp/sslconnection.cpp | 17 +- src/sslpp/sslconnection.h | 6 +- src/sslpp/sslcontext.cpp | 17 +- src/sslpp/sslcontext.h | 5 +- src/sslpp/sslcontextconfig.h | 4 + src/sslpp/sslutil.cpp | 76 +- src/sslpp/sslutil.h | 3 + src/thread/CMakeLists.txt | 1 + src/thread/Makefile.am | 12 + src/thread/Makefile.in | 649 + src/{lsr => thread}/offloader.cpp | 54 +- src/thread/workcrew.cpp | 115 +- src/thread/workcrew.h | 28 +- src/util/autobuf.h | 22 +- src/util/datetime.cpp | 3 +- src/util/datetime.h | 7 +- src/util/dlinkqueue.h | 14 + src/util/httpfetch.cpp | 66 +- src/util/httpfetch.h | 12 +- src/util/iovec.h | 5 + src/util/loopbuf.h | 4 + src/util/objarray.h | 75 +- src/util/vmembuf.cpp | 26 +- test/CMakeLists.txt | 2 +- test/http/httpheadertest.cpp | 21 +- test/http/httpreqtest.cpp | 8 +- test/http/statusurlmaptest.cpp | 6 +- test/util/httpfetchtest.cpp | 1 + test/util/objarraytest.cpp | 56 +- 300 files changed, 12694 insertions(+), 79055 deletions(-) create mode 100644 src/edio/streamstat.h create mode 100644 src/h2/CMakeLists.txt create mode 100755 src/h2/Makefile.am create mode 100644 src/h2/Makefile.in create mode 100644 src/h2/h2connbase.cpp rename src/{spdy/h2connection.h => h2/h2connbase.h} (58%) create mode 100644 src/h2/h2connection.cpp create mode 100644 src/h2/h2connection.h rename src/{spdy => h2}/h2protocol.cpp (95%) rename src/{spdy => h2}/h2protocol.h (95%) create mode 100644 src/h2/h2stream.cpp create mode 100644 src/h2/h2stream.h create mode 100644 src/h2/h2streambase.cpp rename src/{spdy/h2stream.h => h2/h2streambase.h} (61%) rename src/{spdy => h2}/h2streampool.cpp (96%) rename src/{spdy => h2}/h2streampool.h (96%) create mode 100644 src/h2/lsxpack_error_code.h create mode 100644 src/h2/ssledstream.cpp create mode 100644 src/h2/ssledstream.h create mode 100644 src/h2/unpackedheaders.cpp create mode 100644 src/h2/unpackedheaders.h rename src/{lsr => socket}/reuseport.cpp (97%) rename {include/lsr => src/socket}/reuseport.h (100%) delete mode 100644 src/spdy/h2connection.cpp delete mode 100644 src/spdy/h2stream.cpp delete mode 100644 src/spdy/lshpack.c delete mode 100644 src/spdy/lshpack.h delete mode 100644 src/spdy/unpackedheaders.cpp delete mode 100644 src/spdy/unpackedheaders.h create mode 100644 src/thread/Makefile.am create mode 100644 src/thread/Makefile.in rename src/{lsr => thread}/offloader.cpp (65%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9bd1a8187..1ac98ade1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,7 +14,7 @@ SET(CMAKE_INCLUDE_CURRENT_DIR ON) SET(LSQUIC_SERVER_MODE 1) -include_directories( BEFORE include ${PROJECT_SOURCE_DIR}/../thirdparty/include/) +include_directories( BEFORE include src/lshpack src/liblsquic/ls-qpack ${PROJECT_SOURCE_DIR}/../thirdparty/include/) link_directories( ${PROJECT_SOURCE_DIR}/../thirdparty/lib/) SET (CMAKE_C_COMPILER "/usr/bin/clang") @@ -55,7 +55,7 @@ add_definitions(-DPOOL_TESTING) #add_definitions(-DLS_WORKCREW_DEBUG) add_definitions(-D_GLIBCXX_USE_CXX11_ABI=0) -#Add definition for QUIC +#Add definition for QUIC add_definitions(-DH3_ALPN="\\x05h3-25\\x05h3-27") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${MY_CMAKE_WARNING_FLAG} ${MY_CMAKE_TSAN_FLAG} ${MY_CMAKE_ASAN_FLAG}") @@ -67,7 +67,7 @@ find_package(Git QUIET) if (GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git") option(GIT_SUBMODULE "Check submodules during build" ON) if (GIT_SUBMODULE) - execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive + execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive --force WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} RESULT_VARIABLE GIT_SUBMOD_RESULT) if(NOT GIT_SUBMOD_RESULT EQUAL "0") diff --git a/LSQUICCOMMIT b/LSQUICCOMMIT index 688ff144d..0858f2901 100644 --- a/LSQUICCOMMIT +++ b/LSQUICCOMMIT @@ -1 +1 @@ -f4bfba069bd281258ce72183fd9d274168e9050c +307ca7fe5089bb86d38bb5408ffee6cc8fa7e08f diff --git a/build.sh b/build.sh index ee73e303d..00443541e 100755 --- a/build.sh +++ b/build.sh @@ -140,6 +140,9 @@ preparelibquic() rm -rf src/liblsquic mv lsquic/src/liblsquic src/ + rm -rf src/lshpack + mv lsquic/src/lshpack src/ + rm include/lsquic.h mv lsquic/include/lsquic.h include/ rm include/lsquic_types.h @@ -232,6 +235,11 @@ prepareLinux() cat /etc/lsb-release | grep "DISTRIB_RELEASE=18." >/dev/null if [ $? = 0 ] ; then OSTYPE=UBUNTU18 + else + cat /etc/lsb-release | grep "DISTRIB_RELEASE=20." >/dev/null + if [ $? = 0 ] ; then + OSTYPE=UBUNTU20 + fi fi fi fi @@ -259,7 +267,7 @@ prepareLinux() #other debian OS, we still can if [ "${OSTYPE}" = "unknowlinux" ] ; then - echo It seems you are not using ubuntu 14,16,18 and Debian 7/8/9/10. + echo It seems you are not using ubuntu 14,16,18,20 and Debian 7/8/9/10. echo But we still can try to go further. fi @@ -478,6 +486,34 @@ freebsdFix() touch ./needreboot.txt fi fi +} + + +fixPagespeed() +{ +PSOLVERSION=1.11.33.4 +cat << EOF > ../thirdparty/psol-$PSOLVERSION/include/pagespeed/kernel/base/scoped_ptr.h +/** +* Due the compiling issue, this file was updated from the original file. +*/ +#ifndef PAGESPEED_KERNEL_BASE_SCOPED_PTR_H_ +#define PAGESPEED_KERNEL_BASE_SCOPED_PTR_H_ +#include "base/memory/scoped_ptr.h" + +namespace net_instaweb { +template class scoped_array : public scoped_ptr { +public: + scoped_array() : scoped_ptr() {} + explicit scoped_array(T* t) : scoped_ptr(t) {} +}; +} +#endif + +EOF + + + + } cd `dirname "$0"` @@ -510,8 +546,8 @@ if [ "${ISLINUX}" != "yes" ] ; then sed -i -e "s/psol/ /g" ./build_ols.sh fi -./build_ols.sh +./build_ols.sh cd ${CURDIR} @@ -525,6 +561,10 @@ cp ../thirdparty/src/brotli/out/*.a ../thirdparty/lib64/ cp ../thirdparty/src//libxml2/.libs/*.a ../thirdparty/lib64/ cp ../thirdparty/src/libmaxminddb/include/* ../thirdparty/include/ +if [ "${ISLINUX}" = "yes" ] ; then + fixPagespeed +fi + #special case modsecurity cd src/modules/modsecurity-ls ln -sf ../../../../thirdparty/src/ModSecurity . diff --git a/configure b/configure index baf8a3328..39c07bc7e 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.7.1. +# Generated by GNU Autoconf 2.69 for openlitespeed 1.7.2. # # Report bugs to . # @@ -590,8 +590,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='openlitespeed' PACKAGE_TARNAME='openlitespeed' -PACKAGE_VERSION='1.7.1' -PACKAGE_STRING='openlitespeed 1.7.1' +PACKAGE_VERSION='1.7.2' +PACKAGE_STRING='openlitespeed 1.7.2' 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.7.1 to adapt to many kinds of systems. +\`configure' configures openlitespeed 1.7.2 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.7.1:";; + short | recursive ) echo "Configuration of openlitespeed 1.7.2:";; 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.7.1 +openlitespeed configure 1.7.2 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.7.1, which was +It was created by openlitespeed $as_me 1.7.2, 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.7.1' + VERSION='1.7.2' # Some tools Automake needs. @@ -19066,7 +19066,7 @@ cat >>confdefs.h <<_ACEOF _ACEOF -ac_config_files="$ac_config_files Makefile src/Makefile src/edio/Makefile src/extensions/Makefile src/http/Makefile src/spdy/Makefile src/log4cxx/Makefile src/main/Makefile src/socket/Makefile src/sslpp/Makefile src/ssi/Makefile src/lsiapi/Makefile src/modules/Makefile src/shm/Makefile src/adns/Makefile src/quic/Makefile src/liblsquic/Makefile src/modules/modinspector/Makefile src/modules/modreqparser/Makefile src/modules/uploadprogress/Makefile" +ac_config_files="$ac_config_files Makefile src/Makefile src/edio/Makefile src/extensions/Makefile src/http/Makefile src/spdy/Makefile src/h2/Makefile src/log4cxx/Makefile src/main/Makefile src/socket/Makefile src/sslpp/Makefile src/ssi/Makefile src/lsiapi/Makefile src/modules/Makefile src/shm/Makefile src/adns/Makefile src/quic/Makefile src/liblsquic/Makefile src/modules/modinspector/Makefile src/modules/modreqparser/Makefile src/modules/uploadprogress/Makefile" if test x$need_lua = xyes ; then @@ -19623,7 +19623,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.7.1, which was +This file was extended by openlitespeed $as_me 1.7.2, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -19690,7 +19690,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.7.1 +openlitespeed config.status 1.7.2 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" @@ -20209,6 +20209,7 @@ do "src/extensions/Makefile") CONFIG_FILES="$CONFIG_FILES src/extensions/Makefile" ;; "src/http/Makefile") CONFIG_FILES="$CONFIG_FILES src/http/Makefile" ;; "src/spdy/Makefile") CONFIG_FILES="$CONFIG_FILES src/spdy/Makefile" ;; + "src/h2/Makefile") CONFIG_FILES="$CONFIG_FILES src/h2/Makefile" ;; "src/log4cxx/Makefile") CONFIG_FILES="$CONFIG_FILES src/log4cxx/Makefile" ;; "src/main/Makefile") CONFIG_FILES="$CONFIG_FILES src/main/Makefile" ;; "src/socket/Makefile") CONFIG_FILES="$CONFIG_FILES src/socket/Makefile" ;; diff --git a/configure.ac b/configure.ac index 9525943b9..d00aa7b2c 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.7.1],[info@litespeedtech.com],[openlitespeed],[http://www.litespeedtech.com/]) +AC_INIT([openlitespeed],[1.7.2],[info@litespeedtech.com],[openlitespeed],[http://www.litespeedtech.com/]) AM_INIT_AUTOMAKE([1.0 foreign no-define subdir-objects]) AC_CONFIG_HEADERS(src/config.h:src/config.h.in) @@ -486,6 +486,7 @@ AC_CONFIG_FILES(Makefile src/extensions/Makefile src/http/Makefile src/spdy/Makefile + src/h2/Makefile src/log4cxx/Makefile src/main/Makefile src/socket/Makefile diff --git a/dist/Example/html/upload.html b/dist/Example/html/upload.html index 1da68b59f..651885f20 100644 --- a/dist/Example/html/upload.html +++ b/dist/Example/html/upload.html @@ -185,8 +185,8 @@
To enable optional module uploadprogress
- - + +

diff --git a/dist/Example/html/upload.php b/dist/Example/html/upload.php index 6162d8ab5..f4e4a2f3b 100644 --- a/dist/Example/html/upload.php +++ b/dist/Example/html/upload.php @@ -1,84 +1,94 @@ - - - - - -file is empty, not stored.

\n"; - } else { - rename($src, $dest); - echo "

Moved: " . $src . " ====> " . $dest . "
"; - echo "MD5 : " . md5_file($dest). "
"; - echo "Size : " . filesize($dest). " bytes

\n"; - } -} - -function disaplyParsedFile($filekey) -{ - echo "

File : " . $filekey . "
"; - echo "Name : " . $_POST["{$filekey}_name"] . "
"; - echo "Type : " . $_POST["{$filekey}_content-type"] . "
"; - echo "Path : " . $_POST["{$filekey}_path"] . "
"; - echo "MD5 : " . $_POST["{$filekey}_md5"] . "
"; - echo "Size : " . $_POST["{$filekey}_size"] . " Bytes

\n"; -} - -function displayNoParsedFile($filekey) -{ - echo "

File : " . $filekey . "
"; - echo "Name : " . $_FILES["{$filekey}"]['name'] . "
"; - echo "Type : " . $_FILES["{$filekey}"]['type'] . "
"; - echo "Path : " . $_FILES["{$filekey}"]['tmp_name'] . "
"; - echo "Size : " . $_FILES["{$filekey}"]['size'] . "

\n"; -} - - - - -if(empty($_FILES["file1"])) -{ - echo "

Request body updated by Parser

\n"; - - for ($i = 1; $i <= 2; $i++) { - disaplyParsedFile("file{$i}"); - $moved_to_path = '/tmp/uploadfile_' . $_POST["file{$i}_name"]; - moveAndShow($_POST["file{$i}_path"], $moved_to_path); - } - -} else { - echo "

No Parser used

\n"; - for ($i = 1; $i <= 2; $i++) { - displayNoParsedFile("file{$i}"); - $moved_to_path = '/tmp/uploadfile_' . $_FILES["file{$i}"]["name"]; - moveAndShow($_FILES["file{$i}"]["tmp_name"], $moved_to_path); - } -} -?> - - + + + + + +file is empty, not stored.

\n"; + } else { + $fileType = strtolower(pathinfo($dest,PATHINFO_EXTENSION)); + $check = getimagesize($src); + if($check == false) { + echo "

file is not jpg file, not stored.

\n"; + } else { + if($fileType != "jpg") { + echo "

file type is not jpg, not stored.

\n"; + } else { + rename($src, $dest); + echo "

Moved: " . $src . " ====> " . $dest . "
"; + echo "MD5 : " . md5_file($dest). "
"; + echo "Size : " . filesize($dest). " bytes

\n"; + } + } + } +} + +function disaplyParsedFile($filekey) +{ + echo "

File : " . $filekey . "
"; + echo "Name : " . $_POST["{$filekey}_name"] . "
"; + echo "Type : " . $_POST["{$filekey}_content-type"] . "
"; + echo "Path : " . $_POST["{$filekey}_path"] . "
"; + echo "MD5 : " . $_POST["{$filekey}_md5"] . "
"; + echo "Size : " . $_POST["{$filekey}_size"] . " Bytes

\n"; +} + +function displayNoParsedFile($filekey) +{ + echo "

File : " . $filekey . "
"; + echo "Name : " . $_FILES["{$filekey}"]['name'] . "
"; + echo "Type : " . $_FILES["{$filekey}"]['type'] . "
"; + echo "Path : " . $_FILES["{$filekey}"]['tmp_name'] . "
"; + echo "Size : " . $_FILES["{$filekey}"]['size'] . "

\n"; +} + + + + +if(empty($_FILES["file1"])) +{ + echo "

Request body updated by Parser

\n"; + + for ($i = 1; $i <= 2; $i++) { + disaplyParsedFile("file{$i}"); + $moved_to_path = '/tmp/uploadfile_' . $_POST["file{$i}_name"]; + moveAndShow($_POST["file{$i}_path"], $moved_to_path); + } + +} else { + echo "

No Parser used

\n"; + for ($i = 1; $i <= 2; $i++) { + displayNoParsedFile("file{$i}"); + $moved_to_path = '/tmp/uploadfile_' . $_FILES["file{$i}"]["name"]; + moveAndShow($_FILES["file{$i}"]["tmp_name"], $moved_to_path); + } +} +?> + + diff --git a/dist/VERSION b/dist/VERSION index 943f9cbc4..f8a696c8d 100644 --- a/dist/VERSION +++ b/dist/VERSION @@ -1 +1 @@ -1.7.1 +1.7.2 diff --git a/dist/add-ons/webcachemgr/VERSION b/dist/add-ons/webcachemgr/VERSION index 35d51f33b..da38e07b3 100644 --- a/dist/add-ons/webcachemgr/VERSION +++ b/dist/add-ons/webcachemgr/VERSION @@ -1 +1 @@ -1.12 \ No newline at end of file +1.13.1 \ No newline at end of file diff --git a/dist/add-ons/webcachemgr/src/Panel/CPanel.php b/dist/add-ons/webcachemgr/src/Panel/CPanel.php index e06808d32..a1656669e 100644 --- a/dist/add-ons/webcachemgr/src/Panel/CPanel.php +++ b/dist/add-ons/webcachemgr/src/Panel/CPanel.php @@ -1,6 +1,6 @@ isEA4 ) { - $this->apacheConf = '/etc/apache2/conf.d/includes/pre_main_global.conf'; - $this->apacheVHConf = '/etc/apache2/conf.d/userdata/lscache_vhosts.conf'; + $this->apacheConf = + '/etc/apache2/conf.d/includes/pre_main_global.conf'; + $this->apacheVHConf = + '/etc/apache2/conf.d/userdata/lscache_vhosts.conf'; } else { - $this->apacheConf = '/usr/local/apache/conf/includes/pre_main_global.conf'; - $this->apacheVHConf = '/usr/local/apache/conf/userdata/lscache_vhosts.conf'; + $this->apacheConf = + '/usr/local/apache/conf/includes/pre_main_global.conf'; + $this->apacheVHConf = + '/usr/local/apache/conf/userdata/lscache_vhosts.conf'; } } @@ -83,23 +83,25 @@ protected function vhCacheRootSearch() /** * - * @param string $file_contents - * @return string + * @param array $file_contents + * @param string $vhCacheRoot + * @return array */ protected function addVHCacheRootSection( $file_contents, $vhCacheRoot = 'lscache' ) { - array_unshift($file_contents, - "\nCacheRoot {$vhCacheRoot}\n\n\n"); - $modified_contents = $file_contents; + array_unshift( + $file_contents, + "\nCacheRoot {$vhCacheRoot}\n\n\n" + ); - return $modified_contents; + return $file_contents; } /** * * @param string $vhConf - * @throws LSCMException + * @throws LSCMException Thrown directly and indirectly. */ public function createVHConfAndSetCacheRoot( $vhConf, $vhCacheRoot = 'lscache' ) @@ -109,13 +111,16 @@ public function createVHConfAndSetCacheRoot( $vhConf, if ( !file_exists($vhConfDir) ) { if ( !mkdir($vhConfDir, 0755) ) { - throw new LSCMException("Failed to create directory {$vhConfDir}."); + throw new LSCMException( + "Failed to create directory {$vhConfDir}." + ); } $this->log("Created directory {$vhConfDir}", Logger::L_DEBUG); } - $content = "\nCacheRoot {$vhCacheRoot}\n"; + $content = + "\nCacheRoot {$vhCacheRoot}\n"; if ( false === file_put_contents($vhConf, $content) ) { throw new LSCMException("Failed to create file {$vhConf}."); @@ -139,8 +144,10 @@ public function applyVHConfChanges() */ protected function prepareDocrootMap() { - $cmd = 'grep -hro --exclude="cache" --exclude="main" ' - . '--exclude="*.cache" "documentroot.*\|serveralias.*\|servername.*" /var/cpanel/userdata/*'; + $cmd = + 'grep -hro --exclude="cache" --exclude="main" --exclude="*.cache" ' + . '"documentroot.*\|serveralias.*\|servername.*" ' + . '/var/cpanel/userdata/*'; exec($cmd, $lines); /** @@ -207,7 +214,9 @@ protected function prepareDocrootMap() $cur = ''; } else { - Logger::debug("Unused line when preparing docroot map: {$line}."); + Logger::debug( + "Unused line when preparing docroot map: {$line}." + ); } } @@ -227,7 +236,8 @@ protected function prepareDocrootMap() $index++; } - $this->docRootMap = array( 'docroots' => $roots, 'names' => $servernames ); + $this->docRootMap = + array( 'docroots' => $roots, 'names' => $servernames ); } /** @@ -249,8 +259,8 @@ public function getPhpBinary( WPInstall $wpInstall ) * cPanel php wrapper should accurately detect the correct binary in * EA4 when EA4 only directive '--ea-reference-dir' is provided. */ - $phpBin = - "/usr/local/bin/php --ea-reference-dir={$wpInstall->getPath()}/wp-admin"; + $phpBin = '/usr/local/bin/php ' + . "--ea-reference-dir={$wpInstall->getPath()}/wp-admin"; } return "{$phpBin} {$this->phpOptions}"; @@ -299,11 +309,16 @@ public static function turnOffCpanelPluginAutoInstall() public function installCpanelPlugin() { if ( !file_exists(self::USER_PLUGIN_INSTALL_SCRIPT) ) { - throw new LSCMException('Unable to find cPanel user-end plugin installation script.' - . ' Please ensure that the LiteSpeed WHM plugin is already installed.'); + throw new LSCMException( + 'Unable to find cPanel user-end plugin installation script.' + . ' Please ensure that the LiteSpeed WHM plugin is already ' + . 'installed.' + ); } - $cpanelPluginDir = '/usr/local/cpanel/base/frontend/paper_lantern/ls_web_cache_manager'; + $cpanelPluginDir = + '/usr/local/cpanel/base/frontend/paper_lantern/' + . 'ls_web_cache_manager'; $cpanelPluginConfFile = "{$cpanelPluginDir}/lswcm.conf"; $cpanelPluginTplDir = "{$cpanelPluginDir}/landing"; $cpanelPluginCustTransDir = "{$cpanelPluginDir}/lang/cust"; @@ -373,8 +388,10 @@ public function installCpanelPlugin() public function uninstallCpanelPlugin() { if ( !file_exists(self::USER_PLUGIN_UNINSTALL_SCRIPT) ) { - throw new LSCMException('Unable to find cPanel user-end plugin uninstallation script.' - . ' Plugin may already be uninstalled.'); + throw new LSCMException( + 'Unable to find cPanel user-end plugin uninstallation script.' + . ' Plugin may already be uninstalled.' + ); } exec(self::USER_PLUGIN_UNINSTALL_SCRIPT); diff --git a/dist/add-ons/webcachemgr/src/Panel/ControlPanel.php b/dist/add-ons/webcachemgr/src/Panel/ControlPanel.php index e2d51bb83..ac24fc353 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.12'; + const PANEL_API_VERSION = '1.13.1'; /** * @since 1.9 @@ -70,6 +70,11 @@ abstract class ControlPanel */ const NOT_SET = '__LSC_NOTSET__'; + /** + * @var string + */ + protected $panelName = ''; + /** * @var string */ @@ -113,10 +118,13 @@ abstract class ControlPanel protected static $minAPIFilePath = ''; /** - * @var null|ControlPanel + * @var null|ControlPanel Object that extends ControlPanel abstract class. */ protected static $instance; + /** + * @throws LSCMException Thrown indirectly. + */ protected function __construct() { /** @@ -124,8 +132,9 @@ protected function __construct() * '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 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(); @@ -142,7 +151,8 @@ protected function __construct() * * @deprecated * @param string $className A fully qualified control panel class name - * @return ControlPanel|null + * @return ControlPanel|null Object that extends ControlPanel abstract + * class. * @throws LSCMException */ public static function initByClassName( $className ) @@ -151,7 +161,8 @@ public static function initByClassName( $className ) if ( $className == 'custom' ) { $lsws_home = realpath(__DIR__ . '/../../../../'); - $customPanelFile = "{$lsws_home}/admin/lscdata/custom/CustomPanel.php"; + $customPanelFile = + "{$lsws_home}/admin/lscdata/custom/CustomPanel.php"; if ( ! file_exists($customPanelFile) || ! include_once $customPanelFile ) { @@ -162,8 +173,10 @@ public static function initByClassName( $className ) $className = '\Lsc\Wp\Panel\CustomPanel'; - $isSubClass = - is_subclass_of($className, '\Lsc\Wp\Panel\CustomPanelBase'); + $isSubClass = is_subclass_of( + $className, + '\Lsc\Wp\Panel\CustomPanelBase' + ); if ( ! $isSubClass ) { $msg = 'Class CustomPanel must extend class ' @@ -185,8 +198,10 @@ public static function initByClassName( $className ) if ( $instanceClassName != $className ) { throw new LSCMException( - "Could not initialize {$className} instance as an instance of another " - . "class ({$instanceClassName}) has already been created."); + "Could not initialize {$className} instance as an instance " + . "of another class ({$instanceClassName}) has already " + . 'been created.' + ); } } @@ -199,13 +214,15 @@ public static function initByClassName( $className ) * @deprecated * * @param string $name - * @return ControlPanel + * @return ControlPanel Object that extends ControlPanel abstract class. * @throws LSCMException */ public static function init( $name ) { if ( static::$instance != null ) { - throw new LSCMException('ControlPanel cannot be initialized twice.'); + throw new LSCMException( + 'ControlPanel cannot be initialized twice.' + ); } switch ($name) { @@ -216,7 +233,9 @@ public static function init( $name ) $className = 'Plesk'; break; default: - throw new LSCMException("Control panel '{$name}' is not supported."); + throw new LSCMException( + "Control panel '{$name}' is not supported." + ); } return static::initByClassName("\Lsc\Wp\Panel\\{$className}"); @@ -228,7 +247,7 @@ public static function init( $name ) * initialized if it has not yet been initialized already. * * @param string $className Fully qualified class name. - * @return ControlPanel + * @return ControlPanel Object that extends ControlPanel abstract class. * @throws LSCMException Indirectly thrown by static::initByClassName(). */ public static function getClassInstance( $className = '' ) @@ -237,7 +256,9 @@ public static function getClassInstance( $className = '' ) static::initByClassName($className); } elseif ( static::$instance == null ) { - throw new LSCMException('Could not get instance, ControlPanel not initialized. '); + throw new LSCMException( + 'Could not get instance, ControlPanel not initialized. ' + ); } return static::$instance; @@ -247,7 +268,7 @@ public static function getClassInstance( $className = '' ) * Deprecated on 02/06/19. Use getClassInstance() instead. * * @deprecated - * @return ControlPanel + * @return ControlPanel Object that extends ControlPanel abstract class. */ public static function getInstance() { @@ -301,9 +322,9 @@ public function areCacheRootsSet() public function verifyCacheSetup() { if ( !$this->isCacheEnabled() ) { - $msg = '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.'; + $msg = '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); } @@ -345,9 +366,14 @@ public function setVHCacheRoot( $vhCacheRoot = 'lscache' ) $this->vhCacheRoot = $vhCacheRoot; - $this->log("Virtual Host cache root set to {$vhCacheRoot}", Logger::L_INFO); + $this->log( + "Virtual Host cache root set to {$vhCacheRoot}", + Logger::L_INFO + ); + + if ( $this->vhCacheRoot[0] == '/' + && !file_exists($this->vhCacheRoot) ) { - if ( $this->vhCacheRoot[0] == '/' && !file_exists($this->vhCacheRoot) ) { /** * 01/29/19: Temporarily create top virtual host cache root * directory to avoid LSWS setting incorrect owner/group and @@ -371,8 +397,8 @@ 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.'; + $msg = 'Cannot determine LSCache availability. Please start/switch ' + . 'to LiteSpeed Web Server before trying again.'; throw new LSCMException($msg, LSCMException::E_PERMISSION); } @@ -386,7 +412,9 @@ public function isCacheEnabled() $line = fread($f, 128); fclose($f); - if ( preg_match('/FEATURES: ([0-9\.]+)/', $line, $m) && ($m[1] & 1) == 1 ) { + if ( preg_match('/FEATURES: ([0-9\.]+)/', $line, $m) + && ($m[1] & 1) == 1 ) { + return true; } @@ -458,6 +486,11 @@ public function getVHCacheRoot() return $this->vhCacheRoot; } + /** + * + * @return void + * @throws LSCMException Thrown in some existing implementations. + */ abstract protected function initConfPaths(); abstract protected function prepareDocrootMap(); @@ -558,7 +591,10 @@ protected function initCacheRoots() if ( $svrCacheRoot ) { $this->serverCacheRoot = $svrCacheRoot; - $this->log("Server level cache root is {$svrCacheRoot}.", Logger::L_DEBUG); + $this->log( + "Server level cache root is {$svrCacheRoot}.", + Logger::L_DEBUG + ); } else { $this->serverCacheRoot = static::NOT_SET; @@ -567,11 +603,17 @@ protected function initCacheRoots() if ( $vhCacheRoot ) { $this->vhCacheRoot = $vhCacheRoot; - $this->log("Virtual Host level cache root is {$vhCacheRoot}.", Logger::L_DEBUG); + $this->log( + "Virtual Host level cache root is {$vhCacheRoot}.", + Logger::L_DEBUG + ); } else { $this->vhCacheRoot = static::NOT_SET; - $this->log('Virtual Host level cache root is not set.', Logger::L_INFO); + $this->log( + 'Virtual Host level cache root is not set.', + Logger::L_INFO + ); } } @@ -633,7 +675,8 @@ public function setServerCacheRoot( $svrCacheRoot = '' ) $cacheroot = $this->defaultSvrCacheRoot; } - $cacheRootLine = "\nCacheRoot {$cacheroot}\n\n\n"; + $cacheRootLine = + "\nCacheRoot {$cacheroot}\n\n\n"; if ( !file_exists($this->apacheConf) ) { file_put_contents($this->apacheConf, $cacheRootLine); @@ -644,11 +687,15 @@ public function setServerCacheRoot( $svrCacheRoot = '' ) else { if ( !is_writable($this->apacheConf) ) { - throw new LSCMException('Apache Config is not writeable. No changes made.'); + throw new LSCMException( + 'Apache Config is not writeable. No changes made.' + ); } if ( !Util::createBackup($this->apacheConf) ) { - throw new LSCMException('Could not backup Apache config. No changes made.'); + throw new LSCMException( + 'Could not backup Apache config. No changes made.' + ); } else { $file_contents = file($this->apacheConf); @@ -656,13 +703,18 @@ public function setServerCacheRoot( $svrCacheRoot = '' ) if ( preg_grep('/^\s*/im', $file_contents) ) { if ( preg_grep('/^\s*CacheRoot +/im', $file_contents) ) { - $file_contents = preg_replace('/^\s*CacheRoot +.+/im', - "CacheRoot {$cacheroot}", $file_contents); + $file_contents = preg_replace( + '/^\s*CacheRoot +.+/im', + "CacheRoot {$cacheroot}", + $file_contents + ); } else { - $file_contents = preg_replace('/^\s*/im', - "\nCacheRoot {$cacheroot}", - $file_contents); + $file_contents = preg_replace( + '/^\s*/im', + "\nCacheRoot {$cacheroot}", + $file_contents + ); } } else { @@ -675,15 +727,27 @@ public function setServerCacheRoot( $svrCacheRoot = '' ) $this->serverCacheRoot = $cacheroot; - $this->log("Server level cache root set to {$cacheroot}", Logger::L_INFO); + $this->log( + "Server level cache root set to {$cacheroot}", + Logger::L_INFO + ); if ( file_exists($cacheroot) ) { exec("/bin/rm -rf {$cacheroot}"); - $this->log('Server level cache root directory removed for proper permission.', - Logger::L_DEBUG); + $this->log( + 'Server level cache root directory removed for proper ' + . 'permission.', + Logger::L_DEBUG + ); } } + /** + * + * @param array $file_contents + * @param string $vhCacheRoot + * @return array + */ abstract protected function addVHCacheRootSection( $file_contents, $vhCacheRoot = 'lscache' ); @@ -696,13 +760,16 @@ public function writeVHCacheRoot( $vhConf, $vhCacheRoot = 'lscache' ) { if ( !is_writable($vhConf) ) { throw new LSCMException( - "Could not write to VH config {$vhConf}. No changes made.", - LSCMException::E_PERMISSION); + "Could not write to VH config {$vhConf}. No changes made.", + LSCMException::E_PERMISSION + ); } if ( !Util::createBackup($vhConf) ) { throw new LSCMException( - "Could not backup Virtual Host config file {$vhConf}. No changes made.", - LSCMException::E_PERMISSION); + "Could not backup Virtual Host config file {$vhConf}. No " + . 'changes made.', + LSCMException::E_PERMISSION + ); } $file_contents = file($vhConf); @@ -714,9 +781,11 @@ public function writeVHCacheRoot( $vhConf, $vhCacheRoot = 'lscache' ) "CacheRoot {$vhCacheRoot}", $file_contents); } else { - $modified_contents = preg_replace('/^\s*/im', - "\nCacheRoot {$vhCacheRoot}", - $file_contents); + $modified_contents = preg_replace( + '/^\s*/im', + "\nCacheRoot {$vhCacheRoot}", + $file_contents + ); } } else { @@ -846,6 +915,11 @@ public static function meetsMinAPIVerRequirement() public static function checkPanelAPICompatibility( $panelAPIVer ) { $supportedAPIVers = array ( + '1.13.1', + '1.13.0.3', + '1.13.0.2', + '1.13.0.1', + '1.13', '1.12', '1.11', '1.10', diff --git a/dist/add-ons/webcachemgr/src/Panel/DirectAdmin.php b/dist/add-ons/webcachemgr/src/Panel/DirectAdmin.php index a179e9134..c1de025a7 100644 --- a/dist/add-ons/webcachemgr/src/Panel/DirectAdmin.php +++ b/dist/add-ons/webcachemgr/src/Panel/DirectAdmin.php @@ -1,9 +1,9 @@ apacheConf = '/etc/httpd/conf/extra/httpd-includes.conf'; - $this->apacheVHConf = - '/usr/local/directadmin/data/templates/custom/cust_httpd.CUSTOM.2.pre'; + $this->apacheVHConf = '/usr/local/directadmin/data/templates/custom/' + . 'cust_httpd.CUSTOM.2.pre'; } /** @@ -88,17 +88,19 @@ public function daVhCacheRootSearch( $confDir ) /** * - * @param string $file_contents - * @return string + * @param array $file_contents + * @param string $vhCacheRoot + * @return array */ protected function addVHCacheRootSection( $file_contents, $vhCacheRoot = 'lscache' ) { - array_unshift($file_contents, - "\nCacheRoot {$vhCacheRoot}\n\n\n"); - $modified_contents = $file_contents; + array_unshift( + $file_contents, + "\nCacheRoot {$vhCacheRoot}\n\n\n" + ); - return $modified_contents; + return $file_contents; } /** @@ -114,13 +116,16 @@ public function createVHConfAndSetCacheRoot( $vhConf, if ( !file_exists($vhConfDir) ) { if ( !mkdir($vhConfDir, 0755) ) { - throw new LSCMException("Failed to create directory {$vhConfDir}."); + throw new LSCMException( + "Failed to create directory {$vhConfDir}." + ); } $this->log("Created directory {$vhConfDir}", Logger::L_DEBUG); } - $content = "\nCacheRoot {$vhCacheRoot}\n"; + $content = + "\nCacheRoot {$vhCacheRoot}\n"; if ( false === file_put_contents($vhConf, $content) ) { throw new LSCMException("Failed to create file {$vhConf}."); @@ -207,7 +212,9 @@ protected function prepareDocrootMap() $curServerName = $curServerAliases = $curDocRoot = ''; } else { - Logger::debug("Unused line when preparing docroot map: {$line}."); + Logger::debug( + "Unused line when preparing docroot map: {$line}." + ); } } @@ -227,7 +234,8 @@ protected function prepareDocrootMap() $index++; } - $this->docRootMap = array( 'docroots' => $roots, 'names' => $servernames ); + $this->docRootMap = + array( 'docroots' => $roots, 'names' => $servernames ); } /** diff --git a/dist/add-ons/webcachemgr/src/Panel/Plesk.php b/dist/add-ons/webcachemgr/src/Panel/Plesk.php index f47f7a589..ccf0e2829 100644 --- a/dist/add-ons/webcachemgr/src/Panel/Plesk.php +++ b/dist/add-ons/webcachemgr/src/Panel/Plesk.php @@ -32,9 +32,17 @@ public function __construct() */ public function getPleskOS() { - $supportedOS = array( 'centos', 'cloudlinux', 'redhat', 'ubuntu', 'debian' ); $cmd = ''; + $supportedOS = array( + 'centos', + 'virtuozzo', + 'cloudlinux', + 'redhat', + 'ubuntu', + 'debian' + ); + if ( is_readable('/etc/os-release') ) { $cmd = 'grep ^ID= /etc/os-release | cut -d"=" -f2 | xargs'; } @@ -57,16 +65,23 @@ public function getPleskOS() } throw new LSCMException( - 'Plesk detected with unsupported OS. (Not CentOS/Cloudlinux/RedHat/Ubuntu/Debian)', - LSCMException::E_UNSUPPORTED); + 'Plesk detected with unsupported OS. ' + . '(Not CentOS/Virtuozzo/Cloudlinux/RedHat/Ubuntu/Debian)', + LSCMException::E_UNSUPPORTED + ); } + /** + * + * @throws LSCMException Thrown indirectly. + */ protected function initConfPaths() { $OS = $this->getPleskOS(); switch ($OS) { case 'centos': + case 'virtuozzo': case 'cloudlinux': case 'redhat': $this->apacheConf = '/etc/httpd/conf.d/lscache.conf'; @@ -79,7 +94,8 @@ protected function initConfPaths() case 'debian': if ( is_dir('/etc/apache2/conf-enabled') ) { - $this->apacheConf = '/etc/apache2/conf-enabled/lscache.conf'; + $this->apacheConf = + '/etc/apache2/conf-enabled/lscache.conf'; } else { /** @@ -93,8 +109,8 @@ protected function initConfPaths() //no default case } - $this->apacheVHConf = - '/usr/local/psa/admin/conf/templates/custom/domain/domainVirtualHost.php'; + $this->apacheVHConf = '/usr/local/psa/admin/conf/templates' + . '/custom/domain/domainVirtualHost.php'; } protected function serverCacheRootSearch() @@ -117,20 +133,28 @@ protected function vhCacheRootSearch() return ''; } + /** + * + * @param array $file_contents + * @param string $vhCacheRoot + * @return array + */ protected function addVHCacheRootSection( $file_contents, $vhCacheRoot = 'lscache' ) { - $modified_contents = preg_replace('!^\s*!im', - "\nCacheRoot {$vhCacheRoot}\n\n", - $file_contents); - - return $modified_contents; + return preg_replace( + '!^\s*!im', + "\nCacheRoot {$vhCacheRoot}\n\n" + . '', + $file_contents + ); } /** + * * @param string $vhConf * @param string $vhCacheRoot - * @throws LSCMException Indirectly thrown by $this->log(). + * @throws LSCMException Thrown indirectly. */ public function createVHConfAndSetCacheRoot( $vhConf, $vhCacheRoot = 'lscache' ) @@ -171,8 +195,6 @@ public function applyVHConfChanges() * * Note: This function is repeated in Plesk plugin files to avoid extra * serialize ops etc. This copy is for cli only. - * - * @return string[][] Array of docroot keys and their server name(s). */ protected function prepareDocrootMap() { diff --git a/dist/add-ons/webcachemgr/src/Util.php b/dist/add-ons/webcachemgr/src/Util.php index 790bd0e94..6954f9057 100644 --- a/dist/add-ons/webcachemgr/src/Util.php +++ b/dist/add-ons/webcachemgr/src/Util.php @@ -426,6 +426,7 @@ public static function ensureVHCacheRootInCage( $vhCacheRoot ) * * @param string $dir Directory path * @param boolean $keepParent Only remove directory contents when true. + * @return boolean */ public static function rrmdir( $dir, $keepParent = false ) { diff --git a/dist/add-ons/webcachemgr/src/WPCaller.php b/dist/add-ons/webcachemgr/src/WPCaller.php index 557bf7330..c905f9870 100644 --- a/dist/add-ons/webcachemgr/src/WPCaller.php +++ b/dist/add-ons/webcachemgr/src/WPCaller.php @@ -41,6 +41,12 @@ class WPCaller */ private $pluginEntry; + /** + * @since 1.13 + * @var null|string + */ + private $installedLscwpVer = null; + /** * @var string[] */ @@ -83,6 +89,14 @@ public static function getInstance( WPInstall $currInstall, return self::$instance; } + /** + * + * @param int $errno Not used at this time. + * @param string $errstr + * @return boolean + * + * @noinspection PhpUnusedParameterInspection + */ public static function warning_handler( $errno, $errstr ) { $strs = array( @@ -178,6 +192,7 @@ public function getDebugMsgs() * @deprecated 1.9 Deprecated 07/30/19. Use * Logger::getUiMsgs(Logger::UI_ERR) to get these messages. * @return string[] + * @throws LSCMException Thrown indirectly. */ public function getErrMsgs() { @@ -190,6 +205,7 @@ public function getErrMsgs() * Logger::getUiMsgs(Logger::UI_SUCC) to get these * messages. * @return string[] + * @throws LSCMException Thrown indirectly. */ public function getSuccMsgs() { @@ -198,17 +214,21 @@ public function getSuccMsgs() /** * + * WP Variables $wpdb, $table_prefix * WP Functions: get_option() * - * @global wpdb $wpdb + * @global \wpdb $wpdb * @global string $table_prefix * @return string + * + * @noinspection PhpFullyQualifiedNameUsageInspection + * @noinspection PhpUndefinedClassInspection */ private function getSiteURL() { - global $wpdb; - global $table_prefix; + global $wpdb, $table_prefix; + /** @noinspection PhpUndefinedFunctionInspection */ $siteURL = get_option('siteurl'); if ( !$siteURL ) { @@ -235,6 +255,7 @@ private function getSiteURL() * * @param WPInstall $install * @return int + * @throws LSCMException Thrown indirectly. */ private function checkStatus( WPInstall $install ) { @@ -255,13 +276,23 @@ private function checkStatus( WPInstall $install ) /** * Check if plugin files exist first, as status in db could be stale if * LSCWP was removed manually. + * + * @noinspection PhpUndefinedFunctionInspection */ if ( file_exists($this->pluginEntry) && is_plugin_active(self::LSCWP_PLUGIN) ) { $status |= WPInstall::ST_PLUGIN_ACTIVE; - if ( defined('LSCACHE_ADV_CACHE') && LSCACHE_ADV_CACHE === true ) { + //TODO: Get rid of ST_LSC_ADVCACHE_DEFINED status or replace with + // new "is caching enabled" define check. + + $advCacheFile = $this->currInstall->getPath() + . '/wp-content/advanced-cache.php'; + + if ( (version_compare($this->installedLscwpVer, '3.0.4', '>=') && !file_exists($advCacheFile)) + || (defined('LSCACHE_ADV_CACHE') && LSCACHE_ADV_CACHE === true) ) { + $status |= WPInstall::ST_LSC_ADVCACHE_DEFINED; } else { @@ -293,6 +324,7 @@ private function checkStatus( WPInstall $install ) * * @param boolean $output * @return int + * @throws LSCMException Thrown indirectly. */ public function updateStatus( $output = false ) { @@ -310,12 +342,16 @@ public function updateStatus( $output = false ) return UserCommand::EXIT_SUCC; } + /** + * + * @return int + * @throws LSCMException Thrown indirectly. + */ private function getCurrStatus() { $this->updateStatus(); - $status = $this->currInstall->getStatus(); - return $status; + return $this->currInstall->getStatus(); } /** @@ -338,6 +374,9 @@ private function checkForKnownNonAdvCachePlugins() /** * Check if plugin files exist first, as status in db could be * stale if plugin files were removed manually. + * + * @noinspection PhpUndefinedConstantInspection + * @noinspection PhpUndefinedFunctionInspection */ if ( file_exists(WP_PLUGIN_DIR . "/{$plugin}") && is_plugin_active($plugin) ) { @@ -354,8 +393,10 @@ private function checkForKnownNonAdvCachePlugins() * WP Constants: WP_PLUGIN_DIR * WP Functions: get_option() * - * @param boolean $isMassAction + * @param boolean $isMassAction + * @param boolean $isNewInstall * @return boolean + * @throws LSCMException Thrown indirectly. */ private function canEnable( $isMassAction, $isNewInstall ) { @@ -366,8 +407,12 @@ private function canEnable( $isMassAction, $isNewInstall ) if ( !$isNewInstall && $isMassAction ) { $this->currInstall->addUserFlagFile(); - Logger::uiSuccess('LSCWP Detected As Manually Disabled - Flag Set'); - Logger::notice('Ignore - Previously disabled, flag it from mass operation'); + Logger::uiSuccess( + 'LSCWP Detected As Manually Disabled - Flag Set' + ); + Logger::notice( + 'Ignore - Previously disabled, flag it from mass operation' + ); return false; } @@ -378,8 +423,8 @@ private function canEnable( $isMassAction, $isNewInstall ) if ( $thirdPartyCachePluginSlug != '' ) { $this->currInstall->addUserFlagFile(); - $msg = 'Cannot Enable LSCWP - Detected another active cache plugin' - . " \"{$thirdPartyCachePluginSlug}\". Flag set."; + $msg = 'Cannot Enable LSCWP - Detected another active cache ' + . "plugin \"{$thirdPartyCachePluginSlug}\". Flag set."; Logger::uiError($msg); $msg = 'Ignore - Detected another active cache plugin ' @@ -400,11 +445,14 @@ 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.'; + $msg = 'LSCWP Already Enabled But Not Caching - Detected ' + . 'another active cache plugin. Please visit the ' + . 'WordPress Dashboard for further instructions.'; Logger::uiError($msg); - Logger::notice('Ignore - Existing install but advanced cache not set'); + Logger::notice( + 'Ignore - Existing install but advanced cache not set' + ); } return false; @@ -416,7 +464,7 @@ private function canEnable( $isMassAction, $isNewInstall ) /** * * @return int - * @throws LSCMException + * @throws LSCMException Thrown indirectly. */ public function directEnable() { @@ -439,19 +487,27 @@ public function directEnable() } /** + * + * WP Constants: WP_PLUGIN_DIR + * WP Functions: unzip_file() + * WP Classes: WP_Filesystem * * @return int - * @throws LSCMException + * @throws LSCMException Thrown directly and indirectly. */ private function directEnableNewInstall() { + /** @noinspection PhpUndefinedConstantInspection */ $pluginDir = WP_PLUGIN_DIR; $lscwpZip = "{$pluginDir}/litespeed-cache.latest-stable.zip"; $this->downloadLSCWPZip($lscwpZip); + /** @noinspection PhpUndefinedFunctionInspection */ WP_Filesystem(); + + /** @noinspection PhpUndefinedFunctionInspection */ $unzipRet = unzip_file($lscwpZip, $pluginDir); unlink($lscwpZip); @@ -471,6 +527,8 @@ private function directEnableNewInstall() copy($customIni, $defaultIni); } + $this->installedLscwpVer = $this->getPluginVersionFromFile(); + $status = $this->enable_lscwp(); if ( $status & WPInstall::ST_PLUGIN_INACTIVE) { @@ -484,6 +542,8 @@ private function directEnableNewInstall() } /** + * + * WP Constants: WP_PLUGIN_DIR * * @param string $lscwpZip * @return null @@ -491,6 +551,7 @@ private function directEnableNewInstall() */ private function downloadLscwpZip( $lscwpZip ) { + /** @noinspection PhpUndefinedConstantInspection */ $pluginDir = WP_PLUGIN_DIR; $url = 'https://downloads.wordpress.org/plugin/litespeed-cache.latest-stable.zip'; @@ -519,17 +580,24 @@ private function downloadLscwpZip( $lscwpZip ) } /** + * + * WP Constants: WP_PLUGIN_DIR * * @param array $extraArgs Not used at this time. * @param boolean $massOp True when called from massEnable(). * @return int + * @throws LSCMException Thrown indirectly. + * + * @noinspection PhpUnusedParameterInspection */ public function enable( $extraArgs, $massOp = false ) { + /** @noinspection PhpUndefinedConstantInspection */ $isNewInstall = PluginVersion::getInstance()->prepareUserInstall(WP_PLUGIN_DIR); if ( $isNewInstall ) { + $this->installedLscwpVer = $this->getPluginVersionFromFile(); $this->currInstall->addNewLscwpFlagFile(); } @@ -544,7 +612,7 @@ public function enable( $extraArgs, $massOp = false ) if ( $isNewInstall ) { - if ( $status &= WPInstall::ST_PLUGIN_INACTIVE ) { + if ( $status & WPInstall::ST_PLUGIN_INACTIVE ) { $this->removeLscwpPluginFiles(); } else { @@ -558,8 +626,9 @@ public function enable( $extraArgs, $massOp = false ) /** * - * @param array $extraArgs + * @param string[] $extraArgs * @return int + * @throws LSCMException Thrown indirectly. */ public function massEnable( $extraArgs ) { @@ -576,8 +645,9 @@ public function massEnable( $extraArgs ) * * WP Functions: is_plugin_active_for_network() * - * @param boolean $isMassAction + * @param boolean $isMassAction * @return boolean + * @throws LSCMException Thrown indirectly. */ private function canDisable( $isMassAction ) { @@ -606,6 +676,7 @@ private function canDisable( $isMassAction ) return false; } + /** @noinspection PhpUndefinedFunctionInspection */ if ( is_plugin_active_for_network(self::LSCWP_PLUGIN) ) { $this->currInstall->addUserFlagFile(); @@ -622,9 +693,12 @@ private function canDisable( $isMassAction ) /** * - * @param array $extraArgs Not used at this time. - * @param boolean $massOp True when called from MassDisable(). + * @param string[] $extraArgs Not used at this time. + * @param boolean $massOp True when called from MassDisable(). * @return int + * @throws LSCMException Thrown indirectly. + * + * @noinspection PhpUnusedParameterInspection */ public function disable( $extraArgs, $massOp = false ) { @@ -651,8 +725,9 @@ public function disable( $extraArgs, $massOp = false ) /** * - * @param array $extraArgs + * @param string[] $extraArgs * @return int + * @throws LSCMException Thrown indirectly. */ public function massDisable( $extraArgs ) { @@ -668,25 +743,27 @@ public function massDisable( $extraArgs ) /** * Includes LSCWP files needed to properly disable the LSCWP plugin. * - * @param string $lscwpVer Current LSCWP version in the WP plugins - * directory. + * @since 1.13 Removed param $lscwpVer. + * + * @noinspection PhpIncludeInspection */ - private function includeDisableRequiredFiles( $lscwpVer ) + private function includeDisableRequiredFiles() { + /** @noinspection PhpUndefinedConstantInspection */ $dir = WP_PLUGIN_DIR . '/litespeed-cache'; - if ( version_compare($lscwpVer, '3.0', '>=') ) { + if ( version_compare($this->installedLscwpVer, '3.0', '>=') ) { require_once "${dir}/src/admin.cls.php"; } - elseif ( version_compare($lscwpVer, '1.1.2.2', '>') ) { + elseif ( version_compare($this->installedLscwpVer, '1.1.2.2', '>') ) { require_once "{$dir}/admin/litespeed-cache-admin.class.php"; } else { require_once "{$dir}/admin/class-litespeed-cache-admin.php"; } - if ( version_compare($lscwpVer, '1.1.0', '<') - && version_compare($lscwpVer, '1.0.6', '>') ) { + if ( version_compare($this->installedLscwpVer, '1.1.0', '<') + && version_compare($this->installedLscwpVer, '1.0.6', '>') ) { require_once "{$dir}/admin/class-litespeed-cache-admin-rules.php"; } @@ -696,10 +773,11 @@ private function includeDisableRequiredFiles( $lscwpVer ) * * @param boolean $uninstall * @return int + * @throws LSCMException Thrown indirectly. */ private function performDisable( $uninstall ) { - $this->includeDisableRequiredFiles($this->getPluginVersionFromFile()); + $this->includeDisableRequiredFiles(); return $this->disable_lscwp($uninstall); } @@ -709,6 +787,8 @@ private function performDisable( $uninstall ) * @param string $toVersion * @param boolean $massOp Not used at this time. * @return boolean + * + * @noinspection PhpUnusedParameterInspection */ private function canUpgrade( $fromVersions, $toVersion, $massOp ) { @@ -716,9 +796,7 @@ private function canUpgrade( $fromVersions, $toVersion, $massOp ) return false; } - $currVersion = $this->getPluginVersionFromFile(); - - if ( $toVersion == $currVersion ) { + if ( $toVersion == $this->installedLscwpVer ) { return false; } @@ -728,14 +806,14 @@ private function canUpgrade( $fromVersions, $toVersion, $massOp ) if ( strpos($ver, '.x') !== false ) { $ver1 = explode('.', $ver); - $ver2 = explode('.', $currVersion); + $ver2 = explode('.', $this->installedLscwpVer); if ( $ver1[0] === $ver2[0] && $ver1[1] === $ver2[1] ) { $match = true; break; } } - elseif ( $ver === $currVersion ) { + elseif ( $ver === $this->installedLscwpVer ) { $match = true; break; } @@ -749,6 +827,7 @@ private function canUpgrade( $fromVersions, $toVersion, $massOp ) * @param string[] $extraArgs * @param boolean $massOp * @return int + * @throws LSCMException Thrown indirectly. */ public function upgrade( $extraArgs, $massOp = false ) { @@ -771,6 +850,7 @@ public function upgrade( $extraArgs, $massOp = false ) * * @param string[] $extraArgs * @return int + * @throws LSCMException Thrown indirectly. */ public function massUpgrade( $extraArgs ) { @@ -791,10 +871,12 @@ public function massUpgrade( $extraArgs ) */ private function deactivate_lscwp( $uninstall ) { + /** @noinspection PhpUndefinedFunctionInspection */ deactivate_plugins(self::LSCWP_PLUGIN); if ( $uninstall ) { //add some msg about having removed plugin files? + /** @noinspection PhpUndefinedFunctionInspection */ delete_plugins(array( self::LSCWP_PLUGIN )); } } @@ -805,20 +887,29 @@ private function deactivate_lscwp( $uninstall ) * WP Variables: $wpdb * WP Functions: switch_to_blog(), restore_current_blog() * - * @global wpdb $wpdb + * @global \wpdb $wpdb * @param boolean $uninstall * @return int + * @throws LSCMException Thrown indirectly. + * + * @noinspection PhpFullyQualifiedNameUsageInspection + * @noinspection PhpUndefinedClassInspection */ private function disable_lscwp( $uninstall ) { + /** @noinspection PhpUndefinedConstantInspection */ if ( MULTISITE ) { global $wpdb; $blogs = $wpdb->get_col("SELECT blog_id FROM {$wpdb->blogs};"); foreach ( $blogs as $id ) { + /** @noinspection PhpUndefinedFunctionInspection */ switch_to_blog($id); + $this->deactivate_lscwp($uninstall); + + /** @noinspection PhpUndefinedFunctionInspection */ restore_current_blog(); } } @@ -835,11 +926,14 @@ private function disable_lscwp( $uninstall ) * WP Functions: activate_plugin() * * @return int + * @throws LSCMException Thrown indirectly. */ private function enable_lscwp() { /** * Should not check directly, can error on success due to object cache. + * + * @noinspection PhpUndefinedFunctionInspection */ activate_plugin(self::LSCWP_PLUGIN, '', false, false); @@ -848,9 +942,10 @@ 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 manually installing through the WordPress ' - . 'Dashboard and following the instructions given.'; + $msg = '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); $this->massIncr = 'FAIL'; @@ -870,8 +965,8 @@ 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.'; + $msg = 'LSCWP Enabled But Not Caching - Please visit the ' + . 'WordPress Dashboard for further instructions.'; Logger::uiError($msg); $this->massIncr = 'SUCC'; @@ -888,6 +983,7 @@ private function enable_lscwp() /** * + * WP Constants: WP_PLUGIN_DIR * WP Functions: add_filter(), remove_filter(), is_wp_error(), * wp_clean_plugins_cache() * WP Classes: Plugin_Upgrader @@ -903,20 +999,43 @@ private function upgrade_lscwp( $ver, $runHooks = true ) */ echo "[UPGRADE]\n"; + /** + * @noinspection PhpUndefinedClassInspection + * @noinspection PhpFullyQualifiedNameUsageInspection + */ $upgrader = new \Plugin_Upgrader; + /** @noinspection PhpUndefinedMethodInspection */ $upgrader->init(); + + /** @noinspection PhpUndefinedMethodInspection */ $upgrader->upgrade_strings(); - $lscwpPackageURL = "https://downloads.wordpress.org/plugin/litespeed-cache.{$ver}.zip"; + $lscwpPackageURL = + "https://downloads.wordpress.org/plugin/litespeed-cache.{$ver}.zip"; if ( $runHooks ) { - add_filter('upgrader_pre_install', - array( $upgrader, 'deactivate_plugin_before_upgrade' ), 10, 2); - add_filter('upgrader_clear_destination', - array( $upgrader, 'delete_old_plugin' ), 10, 4); + /** @noinspection PhpUndefinedFunctionInspection */ + add_filter( + 'upgrader_pre_install', + array( $upgrader, 'deactivate_plugin_before_upgrade' ), + 10, + 2 + ); + + /** @noinspection PhpUndefinedFunctionInspection */ + add_filter( + 'upgrader_clear_destination', + array( $upgrader, 'delete_old_plugin' ), + 10, + 4 + ); } + /** + * @noinspection PhpUndefinedMethodInspection + * @noinspection PhpUndefinedConstantInspection + */ $upgrader->run(array( 'package' => $lscwpPackageURL, 'destination' => WP_PLUGIN_DIR, @@ -938,13 +1057,25 @@ private function upgrade_lscwp( $ver, $runHooks = true ) /** * Cleanup our hooks, in case something else does a upgrade on * this connection. + * + * @noinspection PhpUndefinedFunctionInspection */ - remove_filter('upgrader_pre_install', - array( $upgrader, 'deactivate_plugin_before_upgrade' )); - remove_filter('upgrader_clear_destination', - array( $upgrader, 'delete_old_plugin' )); + remove_filter( + 'upgrader_pre_install', + array( $upgrader, 'deactivate_plugin_before_upgrade' ) + ); + + /** @noinspection PhpUndefinedFunctionInspection */ + remove_filter( + 'upgrader_clear_destination', + array( $upgrader, 'delete_old_plugin' ) + ); } + /** + * @noinspection PhpUndefinedFieldInspection + * @noinspection PhpUndefinedFunctionInspection + */ if ( !$upgrader->result || is_wp_error($upgrader->result) ) { throw new LSCMException("Failed to upgrade to v{$ver}.", LSCMException::E_NON_FATAL); @@ -954,6 +1085,8 @@ private function upgrade_lscwp( $ver, $runHooks = true ) /** * Force refresh of plugin update information + * + * @noinspection PhpUndefinedFunctionInspection */ wp_clean_plugins_cache(true); } @@ -961,17 +1094,16 @@ private function upgrade_lscwp( $ver, $runHooks = true ) /** * Gets LSCWP version from the litespeed-cache.php file. * - * WP Constants: WP_PLUGIN_DIR * WP Functions: get_plugin_data() * * @return string */ private function getPluginVersionFromFile() { + /** @noinspection PhpUndefinedFunctionInspection */ $lscwp_data = get_plugin_data($this->pluginEntry, false, false); - $ver = $lscwp_data['Version']; - return $ver; + return $lscwp_data['Version']; } /** @@ -979,21 +1111,20 @@ private function getPluginVersionFromFile() * languages directory if able. This function will also attempt to inform * the root user when a locales translation should be retrieved or removed. * - * WP Functions: get_locale() + * WP Functions: get_locale(), unzip_file() * WP Classes: WP_Filesystem */ public function updateTranslationFiles() { + /** @noinspection PhpUndefinedFunctionInspection */ $locale = get_locale(); if ( $locale == 'en_US' ) { return; } - $pluginVersion = $this->getPluginVersionFromFile(); - $localTranslationDir = Context::LOCAL_PLUGIN_DIR - . "/{$pluginVersion}/translations"; + . "/{$this->installedLscwpVer}/translations"; $moFileName = "litespeed-cache-{$locale}.mo"; $poFileName = "litespeed-cache-{$locale}.po"; @@ -1003,7 +1134,8 @@ public function updateTranslationFiles() $translationFlag = "{$localTranslationDir}/" . PluginVersion::TRANSLATION_CHECK_FLAG_BASE . "_{$locale}"; - $langDir = $this->currInstall->getPath() . '/wp-content/languages/plugins'; + $langDir = + $this->currInstall->getPath() . '/wp-content/languages/plugins'; if ( !file_exists($langDir) ) { mkdir($langDir, 0755); @@ -1014,17 +1146,25 @@ public function updateTranslationFiles() copy($localPoFile, "{$langDir}/{$poFileName}"); } elseif ( file_exists($zipFile) ) { + /** + * @noinspection PhpUndefinedFunctionInspection + * @noinspection PhpFullyQualifiedNameUsageInspection + */ \WP_Filesystem(); + /** @noinspection PhpUndefinedFunctionInspection */ if ( unzip_file($zipFile, $langDir) !== true ) { $this->outputResult('BAD_TRANSLATION', - "{$locale} {$pluginVersion}"); + "{$locale} {$this->installedLscwpVer}"); } } elseif ( !file_exists($translationFlag) || (time() - filemtime($translationFlag)) > 86400 ) { - $this->outputResult('GET_TRANSLATION', "{$locale} {$pluginVersion}"); + $this->outputResult( + 'GET_TRANSLATION', + "{$locale} {$this->installedLscwpVer}" + ); } return; @@ -1039,6 +1179,7 @@ private function includeLSCWPAdvancedCacheFile() $content = file_get_contents($advCacheFile); if ( strpos($content, 'LSCACHE_ADV_CACHE') !== false ) { + /** @noinspection PhpIncludeInspection */ include_once $advCacheFile; } } @@ -1049,10 +1190,20 @@ public function removeLscwpPluginFiles() $this->currInstall->removePluginFiles(dirname($this->pluginEntry)); } + /** + * @param string[] $extraArgs + * @param boolean $massOp Not used at this time. + * @return int + * @throws LSCMException Thrown indirectly. + * + * @noinspection PhpUnusedParameterInspection + */ public function dashNotify( $extraArgs, $massOp = false ) { $jsonInfo = base64_decode($extraArgs[0]); + $ret = UserCommand::EXIT_FAIL; + if ( DashNotifier::canNotify($this->currInstall->getPath()) ) { DashNotifier::prepareUserInstall(); @@ -1064,7 +1215,6 @@ public function dashNotify( $extraArgs, $massOp = false ) else { Logger::uiError('Failed to Notify'); $this->massIncr = 'FAIL'; - $ret = UserCommand::EXIT_FAIL; } } else { @@ -1076,8 +1226,9 @@ public function dashNotify( $extraArgs, $massOp = false ) /** * - * @param array $extraArgs + * @param string[] $extraArgs * @return int + * @throws LSCMException Thrown indirectly. */ public function massDashNotify( $extraArgs ) { @@ -1090,16 +1241,37 @@ public function massDashNotify( $extraArgs ) return $ret; } + /** + * + * WP Constants: MULTISITE + * WP Variables: $wpdb + * WP Functions: switch_to_blog(), restore_current_blog(), + * is_plugin_active() + * + * @global \wpdb $wpdb + * @param string[] $extraArgs Unused for now. + * @param boolean $massOp + * @return int + * + * @noinspection PhpUndefinedClassInspection + * @noinspection PhpFullyQualifiedNameUsageInspection + * @noinspection PhpUnusedParameterInspection + */ public function dashDisable( $extraArgs, $massOp = false ) { + /** @noinspection PhpUndefinedConstantInspection */ if ( MULTISITE ) { global $wpdb; $blogs = $wpdb->get_col("SELECT blog_id FROM {$wpdb->blogs};"); foreach ( $blogs as $id ) { + /** @noinspection PhpUndefinedFunctionInspection */ switch_to_blog($id); + DashNotifier::deactivate(true); + + /** @noinspection PhpUndefinedFunctionInspection */ restore_current_blog(); } } @@ -1107,6 +1279,7 @@ public function dashDisable( $extraArgs, $massOp = false ) DashNotifier::deactivate(true); } + /** @noinspection PhpUndefinedFunctionInspection */ if ( is_plugin_active(DashNotifier::DASH_PLUGIN) ) { $this->massIncr = 'FAIL'; $ret = UserCommand::EXIT_FAIL; @@ -1137,14 +1310,17 @@ public function massDashDisable( $extraArgs ) } /** + * + * WP Functions: apply_filters(). * * @since 1.12 * - * @param bool $setOutputResult + * @param boolean $setOutputResult * @return string */ public function getQuicCloudAPIKey( $setOutputResult = false ) { + /** @noinspection PhpUndefinedFunctionInspection */ $key = apply_filters('litespeed_conf', 'api_key'); if ( $key == 'api_key' || $key == null ) { @@ -1237,15 +1413,26 @@ private function isMultisite() /** * + * WP Constants: WP_PLUGIN_DIR + * WP Variables: $wpdb, $shortcode_tags + * WP Functions: wp_plugin_directory_constants(), wp_cookie_constants() + * WP Classes: WP_Query + * + * @global \wpdb $wpdb + * @global array $shortcode_tags * @throws LSCMException Thrown directly and indirectly. + * + * @noinspection PhpUndefinedClassInspection + * @noinspection PhpFullyQualifiedNameUsageInspection */ private function initWp() { /** * Declared global variables for use in included files. + * + * @noinspection PhpUnusedLocalVariableInspection */ - global $wpdb; - global $shortcode_tags; + global $wpdb, $shortcode_tags; error_reporting(E_ALL); @@ -1264,13 +1451,17 @@ private function initWp() /** * Set WP version data global variables, including $wp_version. + * + * @noinspection PhpIncludeInspection */ 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.'); + throw new LSCMException( + "Detected WordPress version as {$wp_version}. Version 4.0 ' + . 'required at minimum." + ); } /** @@ -1392,6 +1583,7 @@ private function initWp() throw new LSCMException("Could not include missing file {$file}."); } + /** @noinspection PhpIncludeInspection */ include_once $file; } @@ -1405,6 +1597,7 @@ private function initWp() /** * Define common WP constants and set 'wp_plugin_paths' array. */ + /** @noinspection PhpUndefinedFunctionInspection */ wp_plugin_directory_constants(); /** @@ -1412,20 +1605,31 @@ private function initWp() */ $GLOBALS['wp_plugin_paths'] = array(); + /** @noinspection PhpUndefinedFunctionInspection */ wp_cookie_constants(); /** * Create global wp_query (WordPress) object entry. Needed during * LSCWP uninstall. + * + * @noinspection PhpUndefinedClassInspection + * @noinspection PhpFullyQualifiedNameUsageInspection */ $GLOBALS['wp_the_query'] = new \WP_Query(); $GLOBALS['wp_query'] = $GLOBALS['wp_the_query']; + /** @noinspection PhpUndefinedConstantInspection */ $this->pluginEntry = WP_PLUGIN_DIR . '/' . self::LSCWP_PLUGIN; if ( $this->loadLscwp && file_exists($this->pluginEntry) ) { + /** @noinspection PhpIncludeInspection */ include $this->pluginEntry; - $this->includeLSCWPAdvancedCacheFile(); + + $this->installedLscwpVer = $this->getPluginVersionFromFile(); + + if ( version_compare($this->installedLscwpVer, '3.0.4', '<') ) { + $this->includeLSCWPAdvancedCacheFile(); + } } } diff --git a/dist/add-ons/webcachemgr/src/WPInstallStorage.php b/dist/add-ons/webcachemgr/src/WPInstallStorage.php index 33213505e..bf976f372 100644 --- a/dist/add-ons/webcachemgr/src/WPInstallStorage.php +++ b/dist/add-ons/webcachemgr/src/WPInstallStorage.php @@ -206,15 +206,19 @@ public function getError() */ public function getCount( $nonFatalOnly = false ) { + $count = 0; + if ( !$nonFatalOnly ) { - $count = count($this->wpInstalls); + + if ( $this->wpInstalls != null ) { + $count += count($this->wpInstalls); + } if ( $this->custWpInstalls != null ) { $count += count($this->custWpInstalls); } } else { - $count = 0; foreach ( $this->wpInstalls as $install ) { diff --git a/dist/admin/html.open/index.php b/dist/admin/html.open/index.php index e7bb9904c..4443d3b7e 100644 --- a/dist/admin/html.open/index.php +++ b/dist/admin/html.open/index.php @@ -44,7 +44,7 @@