From 872678aecd9e9d32e4f954de6d239a38095f59f5 Mon Sep 17 00:00:00 2001 From: Cameron Date: Wed, 1 Apr 2015 02:09:25 -0700 Subject: [PATCH] Issue #937 Allow for e_MOD_REWRITE in e107_config.php on servers which don't have the mod_env module. (needed for .htaccess detection to function.) --- e107.htaccess | 4 +++- e107_admin/eurl.php | 29 ++++++++++++++++++++--------- e107_handlers/e107_class.php | 6 ++++-- 3 files changed, 27 insertions(+), 12 deletions(-) diff --git a/e107.htaccess b/e107.htaccess index 9ed7256db..cf5f8a3a6 100644 --- a/e107.htaccess +++ b/e107.htaccess @@ -39,7 +39,9 @@ -SetEnv HTTP_MOD_REWRITE On + + SetEnv HTTP_MOD_REWRITE On + ### enable rewrites Options +FollowSymLinks diff --git a/e107_admin/eurl.php b/e107_admin/eurl.php index 6d7e13911..052842d53 100644 --- a/e107_admin/eurl.php +++ b/e107_admin/eurl.php @@ -65,11 +65,26 @@ class eurl_admin_ui extends e_admin_controller_ui { - $htaccess = file_get_contents(e_BASE.".htaccess"); + $htaccess = file_exists(e_BASE.".htaccess"); - if(strpos($htaccess, 'SetEnv HTTP_MOD_REWRITE On')===false) + if(function_exists('apache_get_modules')) { - e107::getMessage()->addWarning("Mod-rewrite is disabled. Please add the following to your .htaccess file after the line \"Rewrite Engine On\":
SetEnv HTTP_MOD_REWRITE On
"); + $modules = apache_get_modules(); + $modRewrite = in_array('mod_rewrite', $modules ); + } + else + { + $modRewrite = false; + } + + if($modRewrite === false) + { + e107::getMessage()->addInfo("Apache mod_rewrite was not found on this server and is required to use this feature. "); + } + + if($htaccess && $modRewrite && !deftrue('e_MOD_REWRITE')) + { + e107::getMessage()->addInfo("Mod-rewrite is disabled. To enable, please add the following line to your e107_config.php file:
define('e_MOD_REWRITE',true);
"); } if(is_array($_POST['rebuild'])) @@ -155,7 +170,8 @@ class eurl_admin_ui extends e_admin_controller_ui $this->addTitle(LAN_EURL_NAME_HELP); return LAN_EURL_UC; } - + + //TODO Checkbox for each plugin to enable/disable public function simplePage() { // $this->addTitle("Simple Redirects"); @@ -167,11 +183,6 @@ class eurl_admin_ui extends e_admin_controller_ui } - - - - - $text = ""; foreach($eUrl as $plug=>$val) diff --git a/e107_handlers/e107_class.php b/e107_handlers/e107_class.php index 5672eb8d3..7908c7824 100644 --- a/e107_handlers/e107_class.php +++ b/e107_handlers/e107_class.php @@ -3006,8 +3006,10 @@ class e107 define('CHARSET', 'utf-8'); // set CHARSET for backward compatibility - define('e_MOD_REWRITE', (getenv('HTTP_MOD_REWRITE')=='On' ? true : false)); - + if(!defined('e_MOD_REWRITE')) // Allow e107_config.php to override. + { + define('e_MOD_REWRITE', (getenv('HTTP_MOD_REWRITE')=='On' ? true : false)); + } // Define the domain name and subdomain name. if(is_numeric(str_replace(".","",$_SERVER['HTTP_HOST']))) {