Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## Original
- <?php
- if(isset($_FILE_TO_URL_MAPPING)) {
- $fullPath = $testPath = $_SERVER['SCRIPT_FILENAME'];
- while($testPath && $testPath != "/") {
- if(isset($_FILE_TO_URL_MAPPING[$testPath])) {
- $url = $_FILE_TO_URL_MAPPING[$testPath] . substr($fullPath,strlen($testPath));
- $_SERVER['HTTP_HOST'] = parse_url($url, PHP_URL_HOST);
- $_SERVER['SCRIPT_NAME'] = $_SERVER['PHP_SELF'] = parse_url($url, PHP_URL_PATH);
- $_SERVER['REQUEST_PORT'] = parse_url($url, PHP_URL_PORT);
- break;
- }
- $testPath = dirname($testPath);
- }
- }
- ## Fixed version
- <?php
- if(isset($_FILE_TO_URL_MAPPING)) {
- $fullPath = $testPath = $_SERVER['SCRIPT_FILENAME'];
- while($testPath && $testPath != dirname($testPath)) {
- if(isset($_FILE_TO_URL_MAPPING[$testPath])) {
- $url = $_FILE_TO_URL_MAPPING[$testPath] . substr($fullPath,strlen($testPath));
- $_SERVER['HTTP_HOST'] = parse_url($url, PHP_URL_HOST);
- $_SERVER['SCRIPT_NAME'] = $_SERVER['PHP_SELF'] = parse_url($url, PHP_URL_PATH);
- $_SERVER['REQUEST_PORT'] = parse_url($url, PHP_URL_PORT);
- break;
- }
- $testPath = dirname($testPath);
- }
- if ( !isset($url) ) {
- die("Cannot map to URL. Please check global \$_FILE_TO_URL_MAPPING is set correctly (in particular the slashes)");
- }
- }
Add Comment
Please, Sign In to add comment