-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrouter.php
34 lines (31 loc) · 944 Bytes
/
router.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php
/*
* This file is part of the WordPress Standard project.
*
* Copyright (c) 2015-present LIN3S <info@lin3s.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
$root = $_SERVER['DOCUMENT_ROOT'];
chdir($root);
$path = '/' . ltrim(parse_url($_SERVER['REQUEST_URI'])['path'], '/');
set_include_path(get_include_path() . ':' . __DIR__);
if ($path === '/wp-admin/') {
header('Location: /core/wp-admin/');
die;
}
if (file_exists($root . $path) && $path !== '/') {
if (is_dir($root . $path) && substr($path, strlen($path) - 1, 1) !== '/') {
$path = rtrim($path, '/') . '/core/index.php';
}
if (strpos($path, '.php') === false) {
return false;
} else {
chdir(dirname($root . $path));
require_once $root . $path;
}
} else {
include_once $root . '/core/index.php';
}