2009-11-19 20:39:44 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/************************************************************************************
|
|
|
|
************************************************************************************
|
|
|
|
** **
|
|
|
|
** If you can read this text in your browser then you don't have PHP installed. **
|
2017-06-27 14:27:40 +02:00
|
|
|
** Please install PHP 5.6.0 or higher. **
|
2009-11-19 20:39:44 +01:00
|
|
|
** **
|
|
|
|
************************************************************************************
|
|
|
|
************************************************************************************/
|
|
|
|
|
|
|
|
/**
|
2012-04-12 11:15:32 +02:00
|
|
|
* This script bolts on top of SilverStripe to allow access without the use of .htaccess
|
2009-11-19 20:39:44 +01:00
|
|
|
* rewriting rules.
|
|
|
|
*/
|
|
|
|
|
|
|
|
// This is the URL of the script that everything must be viewed with.
|
2017-05-14 11:48:27 +02:00
|
|
|
define('BASE_SCRIPT_URL', 'index.php/');
|
2009-11-19 20:39:44 +01:00
|
|
|
|
|
|
|
$ruLen = strlen($_SERVER['REQUEST_URI']);
|
|
|
|
$snLen = strlen($_SERVER['SCRIPT_NAME']);
|
|
|
|
|
2009-11-19 20:41:35 +01:00
|
|
|
$isIIS = (strpos($_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS') !== false);
|
|
|
|
|
|
|
|
// IIS will populate server variables using one of these two ways
|
2017-05-14 11:48:27 +02:00
|
|
|
if ($isIIS) {
|
|
|
|
if ($_SERVER['REQUEST_URI'] == $_SERVER['SCRIPT_NAME']) {
|
|
|
|
$url = "";
|
2017-04-27 21:33:07 +02:00
|
|
|
} elseif ($ruLen > $snLen && substr($_SERVER['REQUEST_URI'], 0, $snLen + 1) == ($_SERVER['SCRIPT_NAME'] . '/')) {
|
2017-06-27 14:27:40 +02:00
|
|
|
$url = substr($_SERVER['REQUEST_URI'], $snLen + 1);
|
2017-04-27 21:33:07 +02:00
|
|
|
$url = strtok($url, '?');
|
2017-05-14 11:48:27 +02:00
|
|
|
} else {
|
2017-04-27 21:33:07 +02:00
|
|
|
$url = $_SERVER['REQUEST_URI'];
|
|
|
|
if ($url[0] == '/') {
|
|
|
|
$url = substr($url, 1);
|
2017-05-14 11:48:27 +02:00
|
|
|
}
|
2017-04-27 21:33:07 +02:00
|
|
|
$url = strtok($url, '?');
|
2017-05-14 11:48:27 +02:00
|
|
|
}
|
2009-11-19 20:41:35 +01:00
|
|
|
|
|
|
|
// Apache will populate the server variables this way
|
|
|
|
} else {
|
2017-05-14 11:48:27 +02:00
|
|
|
if ($ruLen > $snLen && substr($_SERVER['REQUEST_URI'], 0, $snLen + 1) == ($_SERVER['SCRIPT_NAME'] . '/')) {
|
|
|
|
$url = substr($_SERVER['REQUEST_URI'], $snLen + 1);
|
|
|
|
$url = strtok($url, '?');
|
|
|
|
} else {
|
|
|
|
$url = "";
|
|
|
|
}
|
2009-11-19 20:39:44 +01:00
|
|
|
}
|
|
|
|
|
2009-11-19 20:41:35 +01:00
|
|
|
$_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
|
|
|
|
*/
|
2017-05-14 11:48:27 +02:00
|
|
|
if ($url && file_exists($fileName)) {
|
|
|
|
$fileURL = (dirname($_SERVER['SCRIPT_NAME']) == '/' ? '' : dirname($_SERVER['SCRIPT_NAME'])) . '/' . $url;
|
|
|
|
if (isset($_SERVER['QUERY_STRING'])) {
|
|
|
|
$fileURL .= '?' . $_SERVER['QUERY_STRING'];
|
|
|
|
}
|
|
|
|
header($_SERVER['SERVER_PROTOCOL'] . ' 301 Moved Permanently');
|
|
|
|
header("Location: $fileURL");
|
|
|
|
die();
|
2009-11-19 20:41:35 +01:00
|
|
|
}
|
|
|
|
|
2017-04-27 21:33:07 +02:00
|
|
|
require_once 'framework/main.php';
|