1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- <?php
- $url = parse_url($_SERVER['REQUEST_URI']);
- if (file_exists(__DIR__ . $url['path'])) {
-
- return FALSE;
- }
- $path = $url['path'];
- $script = 'index.php';
- if (strpos($path, '.php') !== FALSE) {
-
-
- do {
- $path = dirname($path);
- if (preg_match('/\.php$/', $path) && is_file(__DIR__ . $path)) {
-
-
- $script = ltrim($path, '/');
- break;
- }
- } while ($path !== '/' && $path !== '.');
- }
- $index_file_absolute = $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . $script;
- $index_file_relative = DIRECTORY_SEPARATOR . $script;
- $_SERVER['SCRIPT_FILENAME'] = $index_file_absolute;
- $_SERVER['SCRIPT_NAME'] = $index_file_relative;
- $_SERVER['PHP_SELF'] = $index_file_relative;
- require $_SERVER['SCRIPT_FILENAME'];
|