Created
January 28, 2015 16:39
-
-
Save CarsonF/ea480de052dd28ab48e6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if (!isResource()) { | |
return false; | |
} | |
require_once __DIR__ . '/index.php'; | |
function isResource() { | |
$path = $_SERVER['SCRIPT_NAME']; | |
$parts = explode('.', $path); | |
if (empty($parts)) { | |
return true; | |
} | |
$type = end($parts); | |
if ($type === 'php') { | |
return true; | |
} | |
if (in_array($type, ['yml', 'db', 'twig', 'md'])) { | |
// Fix PHP built-in server | |
$_SERVER['SCRIPT_FILENAME'] = __FILE__; | |
$_SERVER['SCRIPT_NAME'] = '/index.php'; | |
$_SERVER['PHP_SELF'] = '/index.php'; | |
return true; | |
} | |
if ($type === 'map') { | |
return false; | |
} | |
if (!file_exists(__DIR__ . $path)) { | |
return true; | |
} | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment