From 6791bd7ad452fb7449ada07acb607f26c948b734 Mon Sep 17 00:00:00 2001 From: Davide Liessi Date: Tue, 31 Mar 2020 00:10:54 +0200 Subject: [PATCH 1/2] test for apache_get_modules before using it --- admin/vfront.info.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/admin/vfront.info.php b/admin/vfront.info.php index 919c727..9707ba5 100644 --- a/admin/vfront.info.php +++ b/admin/vfront.info.php @@ -295,11 +295,16 @@ // IMPOSTAZIONI IMPORTANTI --------------------------------------------------------------------------------------------------- $OUT.="

"._("Apache Modules")."

"; -$modules_apache=(array) @apache_get_modules(); - -$flog.="ApacheLoadedModules: ".implode(",",$modules_apache)."\n"; +if(function_exists('apache_get_modules')){ + $modules_apache=(array) @apache_get_modules(); + $flog.="ApacheLoadedModules: ".implode(",",$modules_apache)."\n"; + $apache_mod_rewrite=(in_array("mod_rewrite", $modules_apache)) ? ""._("YES")."" : ""._("NO").""; +} +else{ + $flog.="ApacheLoadedModules: apache_get_modules() not available\n"; + $apache_mod_rewrite="??? ("._('This information is not available, since it seems to be using PHP as CGI').")"; +} -$apache_mod_rewrite=(in_array("mod_rewrite", $modules_apache)) ? ""._("YES")."" : ""._("NO").""; $OUT.=""._("Mod_rewrite:")." $apache_mod_rewrite\n"; $OUT.="
"._("VFront requires the use of mod_rewrite for different functions, such as generating reports")."

\n"; From 444a05997b1dcd53ae8bb2d898c984c98922840a Mon Sep 17 00:00:00 2001 From: Davide Liessi Date: Tue, 31 Mar 2020 01:30:30 +0200 Subject: [PATCH 2/2] test for mod_rewrite even when PHP is run as CGI --- _install/index.php | 10 +++++----- admin/vfront.info.php | 10 +++++++++- inc/func.mod_rewrite.php | 8 ++++++++ inc/mod_rewrite/.htaccess | 4 ++++ inc/mod_rewrite/test.php | 2 ++ 5 files changed, 28 insertions(+), 6 deletions(-) create mode 100644 inc/func.mod_rewrite.php create mode 100644 inc/mod_rewrite/.htaccess create mode 100644 inc/mod_rewrite/test.php diff --git a/_install/index.php b/_install/index.php index 64ea67d..c67e48c 100644 --- a/_install/index.php +++ b/_install/index.php @@ -307,17 +307,17 @@ function step1(){ $php_modules = (array) @apache_get_modules(); $l_modrewrite=(in_array('mod_rewrite',$php_modules)) ? 1:0; - $class_alert['modrewrite']= ($l_modrewrite) ? 'install-ok' : 'install-alert'; - $alert_rewrite_na=''; } // caso CGI else{ $php_modules= array(); - $l_modrewrite='na'; - $class_alert['modrewrite']= 'install-na'; - $alert_rewrite_na=_('This information is not available, since it seems to be using PHP as CGI'); + require_once("../inc/func.mod_rewrite.php"); + $doc_root="http://".$_SERVER['HTTP_HOST'].str_replace("/_install/index.php",'',$_SERVER['PHP_SELF']); + $l_modrewrite=(check_mod_rewrite($doc_root)) ? 1:0; } + $class_alert['modrewrite']= ($l_modrewrite) ? 'install-ok' : 'install-alert'; + $alert_rewrite_na=''; $l_mysqli=(in_array('mysqli',$ext)) ? 1:0; $l_mysql_old=(in_array('mysql',$ext)) ? 1:0; diff --git a/admin/vfront.info.php b/admin/vfront.info.php index 9707ba5..f376282 100644 --- a/admin/vfront.info.php +++ b/admin/vfront.info.php @@ -302,7 +302,15 @@ } else{ $flog.="ApacheLoadedModules: apache_get_modules() not available\n"; - $apache_mod_rewrite="??? ("._('This information is not available, since it seems to be using PHP as CGI').")"; + require_once("../inc/func.mod_rewrite.php"); + if (check_mod_rewrite(FRONT_DOCROOT)) { + $flog.="mod_rewrite test succeeded\n"; + $apache_mod_rewrite=""._("YES").""; + } + else{ + $flog.="mod_rewrite test failed\n"; + $apache_mod_rewrite=""._("NO").""; + } } $OUT.=""._("Mod_rewrite:")." $apache_mod_rewrite\n"; diff --git a/inc/func.mod_rewrite.php b/inc/func.mod_rewrite.php new file mode 100644 index 0000000..9afbd51 --- /dev/null +++ b/inc/func.mod_rewrite.php @@ -0,0 +1,8 @@ + diff --git a/inc/mod_rewrite/.htaccess b/inc/mod_rewrite/.htaccess new file mode 100644 index 0000000..3805d14 --- /dev/null +++ b/inc/mod_rewrite/.htaccess @@ -0,0 +1,4 @@ + +RewriteEngine On +RewriteRule ^test$ test.php + diff --git a/inc/mod_rewrite/test.php b/inc/mod_rewrite/test.php new file mode 100644 index 0000000..0de2a9d --- /dev/null +++ b/inc/mod_rewrite/test.php @@ -0,0 +1,2 @@ +