ENHANCEMENT: Added index.php that will keep SilverStripe functioning even if the .htaccess doesn't work (svn diff) (from r72495)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/phpinstaller/trunk@92240 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
ischommer 2009-11-19 19:39:44 +00:00
parent df8dc5f881
commit c546a1877a
2 changed files with 46 additions and 10 deletions

View File

@ -1,10 +0,0 @@
<html>
<body>
<script>
window.location = 'install.php';
</script>
<noscript>
<a href="install.php">Click here to install</a>
</noscript>
</body>
</html>

46
index.php Normal file
View File

@ -0,0 +1,46 @@
<?php
/************************************************************************************
************************************************************************************
** **
** If you can read this text in your browser then you don't have PHP installed. **
** Please install PHP 5.0 or higher, preferably PHP 5.2. **
** **
************************************************************************************
************************************************************************************/
/**
* This script bolts on top of SilverStripe/Sapphire to allow access without the use of .htaccess
* rewriting rules.
*/
// This is the URL of the script that everything must be viewed with.
define('BASE_SCRIPT_URL','index.php/');
$ruLen = strlen($_SERVER['REQUEST_URI']);
$snLen = strlen($_SERVER['SCRIPT_NAME']);
if($ruLen > $snLen && substr($_SERVER['REQUEST_URI'],0,$snLen+1) == ($_SERVER['SCRIPT_NAME'] . '/')) {
$url = substr($_SERVER['REQUEST_URI'],$snLen+1);
$url = strtok($url, '?');
$_GET['url'] = $_REQUEST['url'] = $url;
$fileName = dirname($_SERVER['SCRIPT_FILENAME']) . '/' . $url;
/**
* This code is a very simple wrapper for sending files
* Very quickly pass through references to files
*/
if(file_exists($fileName)) {
$fileURL = dirname($_SERVER['SCRIPT_NAME']) . '/' . $url;
header($_SERVER['SERVER_PROTOCOL'] . ' 301 Moved Permanently');
header("Location: $fileURL");
die();
}
}
$_SERVER['SCRIPT_FILENAME'] = str_replace('/index.php','/sapphire/main.php', $_SERVER['SCRIPT_FILENAME']);
$_SERVER['SCRIPT_NAME'] = str_replace('/index.php','/sapphire/main.php', $_SERVER['SCRIPT_NAME']);
chdir('sapphire');
require_once('sapphire/main.php');