|
<?php |
|
|
|
date_default_timezone_set('Asia/Shanghai'); |
|
|
|
|
|
ini_set('display_errors', 'Off'); |
|
error_reporting(E_ALL); |
|
ini_set('log_errors', 'On'); |
|
ini_set('error_log', '/dev/stderr'); |
|
|
|
|
|
if (in_array(basename($_SERVER['REQUEST_URI']), [ |
|
'delete.php', |
|
'images.php', |
|
'videos.php', |
|
'upload.php', |
|
'random-image.php' // 新增的路由 |
|
])) { |
|
header('Content-Type: application/json'); |
|
} |
|
|
|
|
|
if (preg_match('/\.(css|js|png|jpg|jpeg|gif|ico|webp|mp4)$/', $_SERVER['REQUEST_URI'])) { |
|
return false; |
|
} |
|
|
|
|
|
$path = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH); |
|
$file = ltrim($path, '/'); |
|
|
|
|
|
$apiRoutes = [ |
|
'delete.php' => 'delete.php', |
|
'images.php' => 'images.php', |
|
'img.php' => 'img.php', |
|
'upload.php' => 'upload.php', |
|
'videos.php' => 'videos.php', |
|
'adminer.php' => 'adminer.php' |
|
]; |
|
|
|
|
|
if (isset($apiRoutes[$file])) { |
|
require __DIR__ . '/' . $apiRoutes[$file]; |
|
return true; |
|
} |
|
|
|
|
|
if ($file === '' || $file === 'index.html') { |
|
require __DIR__ . '/index.html'; |
|
return true; |
|
} |
|
|
|
|
|
if (file_exists(__DIR__ . '/' . $file) && preg_match('/\.php$/', $file)) { |
|
require __DIR__ . '/' . $file; |
|
return true; |
|
} |
|
|
|
|
|
require __DIR__ . '/index.html'; |
|
return true; |
|
|