@@ -812,6 +812,7 @@ function get_system_timezone() {
812812 if (!$ timezone && is_link ('/etc/localtime ' )) {
813813 $ timezone = readlink ('/etc/localtime ' );
814814 $ timezone = str_replace ('/usr/share/zoneinfo/ ' , '' , $ timezone );
815+ $ timezone = str_replace ('.. ' , '' , $ timezone );
815816 if (substr ($ timezone , 0 , 6 ) === 'posix/ ' ) $ timezone = substr ($ timezone , 6 );
816817 } elseif (!$ timezone ) {
817818 $ hash = md5_file ('/etc/localtime ' );
@@ -829,29 +830,55 @@ function get_system_timezone() {
829830}
830831
831832function getapacheversion ($ get_minor = false ) {
832- global $ app ;
833-
834- $ cmd = '' ;
835- if (is_installed ('apache2ctl ' )) $ cmd = 'apache2ctl -v ' ;
836- elseif (is_installed ('apachectl ' )) $ cmd = 'apachectl -v ' ;
837- else {
838- $ app ->log ("Could not check apache version, apachectl not found. " , LOGLEVEL_WARN );
839- return '2.2 ' ;
840- }
841-
842- exec ($ cmd , $ output , $ return_var );
843- if ($ return_var != 0 || !$ output [0 ]) {
844- $ app ->log ("Could not check apache version, apachectl did not return any data. " , LOGLEVEL_WARN );
845- return '2.2 ' ;
846- }
847-
848- if (preg_match ('/version:\s*Apache\/(\d+)(\.(\d+)(\.(\d+))*)?(\D|$)/i ' , $ output [0 ], $ matches )) {
849- return $ matches [1 ] . (isset ($ matches [3 ]) ? '. ' . $ matches [3 ] : '' ) . (isset ($ matches [5 ]) && $ get_minor == true ? '. ' . $ matches [5 ] : '' );
850- } else {
851- $ app ->log ("Could not check apache version, did not find version string in apachectl output. " , LOGLEVEL_WARN );
852- return '2.2 ' ;
853- }
833+ global $ app ;
834+
835+ $ cmd = '' ;
836+ if (is_installed ('apache2ctl ' )) $ cmd = 'apache2ctl -v ' ;
837+ elseif (is_installed ('apachectl ' )) $ cmd = 'apachectl -v ' ;
838+ else {
839+ $ app ->log ("Could not check apache version, apachectl not found. " , LOGLEVEL_WARN );
840+ return '2.2 ' ;
841+ }
842+
843+ exec ($ cmd , $ output , $ return_var );
844+ if ($ return_var != 0 || !$ output [0 ]) {
845+ $ app ->log ("Could not check apache version, apachectl did not return any data. " , LOGLEVEL_WARN );
846+ return '2.2 ' ;
847+ }
848+
849+ if (preg_match ('/version:\s*Apache\/(\d+)(\.(\d+)(\.(\d+))*)?(\D|$)/i ' , $ output [0 ], $ matches )) {
850+ return $ matches [1 ] . (isset ($ matches [3 ]) ? '. ' . $ matches [3 ] : '' ) . (isset ($ matches [5 ]) && $ get_minor == true ? '. ' . $ matches [5 ] : '' );
851+ } else {
852+ $ app ->log ("Could not check apache version, did not find version string in apachectl output. " , LOGLEVEL_WARN );
853+ return '2.2 ' ;
854854 }
855+ }
855856
857+ function getapachemodules () {
858+ global $ app ;
859+
860+ $ cmd = '' ;
861+ if (is_installed ('apache2ctl ' )) $ cmd = 'apache2ctl -t -D DUMP_MODULES ' ;
862+ elseif (is_installed ('apachectl ' )) $ cmd = 'apachectl -t -D DUMP_MODULES ' ;
863+ else {
864+ $ app ->log ("Could not check apache modules, apachectl not found. " , LOGLEVEL_WARN );
865+ return array ();
866+ }
867+
868+ exec ($ cmd , $ output , $ return_var );
869+ if ($ return_var != 0 || !$ output [0 ]) {
870+ $ app ->log ("Could not check apache modules, apachectl did not return any data. " , LOGLEVEL_WARN );
871+ return array ();
872+ }
873+
874+ $ modules = array ();
875+ for ($ i = 0 ; $ i < count ($ output ); $ i ++) {
876+ if (preg_match ('/^\s*(\w+)\s+\((shared|static)\)\s*$/ ' , $ output [$ i ], $ matches )) {
877+ $ modules [] = $ matches [1 ];
878+ }
879+ }
880+
881+ return $ modules ;
882+ }
856883
857884?>
0 commit comments