From 3a0a5089110a8a7827fa3a2dc5462b49b5836fc9 Mon Sep 17 00:00:00 2001 From: Sean Harvey Date: Sat, 13 Feb 2010 06:06:30 +0000 Subject: [PATCH] BUGFIX Installer now opens if mod_rewrite is disabled. Using index.php instead of rewriting the URL didn't quite work with the new BASE_URL, so we need to take this case into account as well git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.4@98895 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- core/Core.php | 5 ++++- main.php | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/core/Core.php b/core/Core.php index 39d8632e9..ca042157a 100755 --- a/core/Core.php +++ b/core/Core.php @@ -134,7 +134,10 @@ if(!defined('BASE_URL')) { // If that didn't work, failover to the old syntax. Hopefully this isn't necessary, and maybe // if can be phased out? if(!defined('BASE_URL')) { - define('BASE_URL', rtrim(dirname(dirname($_SERVER['SCRIPT_NAME'])), DIRECTORY_SEPARATOR)); + $dir = strpos($_SERVER['SCRIPT_NAME'], 'index.php') + ? dirname($_SERVER['SCRIPT_NAME']) + : dirname(dirname($_SERVER['SCRIPT_NAME'])); + define('BASE_URL', rtrim($dir, DIRECTORY_SEPARATOR)); } } define('MODULES_DIR', 'modules'); diff --git a/main.php b/main.php index cb7a04645..bfa7b7e6e 100644 --- a/main.php +++ b/main.php @@ -107,7 +107,7 @@ require_once("core/model/DB.php"); // Redirect to the installer if no database is selected if(!isset($databaseConfig) || !isset($databaseConfig['database']) || !$databaseConfig['database']) { $s = (isset($_SERVER['SSL']) || (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off')) ? 's' : ''; - $installURL = "http$s://" . $_SERVER['HTTP_HOST'] . dirname(dirname($_SERVER['SCRIPT_NAME'])) . '/install.php'; + $installURL = "http$s://" . $_SERVER['HTTP_HOST'] . BASE_URL . '/install.php'; // The above dirname() will equate to "\" on Windows when installing directly from http://localhost (not using // a sub-directory), this really messes things up in some browsers. Let's get rid of the backslashes