|
<?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 (strpos($_SERVER['REQUEST_URI'], '/api.php') === 0 ||
|
|
strpos($_SERVER['REQUEST_URI'], '/file_api.php') === 0 ||
|
|
strpos($_SERVER['REQUEST_URI'], '/upload.php') === 0) {
|
|
header('Content-Type: application/json');
|
|
}
|
|
|
|
|
|
if (preg_match('/^\/([a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12})$/', $_SERVER['REQUEST_URI'], $matches)) {
|
|
$_GET['id'] = $matches[1];
|
|
require __DIR__ . '/index.php';
|
|
return true;
|
|
}
|
|
|
|
|
|
if (preg_match('/\.(css|js|png|jpg|jpeg|gif|ico|webp)$/', $_SERVER['REQUEST_URI'])) {
|
|
return false;
|
|
}
|
|
|
|
|
|
if (strpos($_SERVER['REQUEST_URI'], '/api.php') === 0) {
|
|
ob_start();
|
|
require __DIR__ . '/api.php';
|
|
$output = ob_get_clean();
|
|
if (json_decode($output) === null) {
|
|
|
|
echo json_encode(['status' => 'error', 'message' => 'Invalid response']);
|
|
} else {
|
|
echo $output;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
if (strpos($_SERVER['REQUEST_URI'], '/file_api.php') === 0) {
|
|
ob_start();
|
|
require __DIR__ . '/file_api.php';
|
|
$output = ob_get_clean();
|
|
if (json_decode($output) === null && !headers_sent()) {
|
|
|
|
echo json_encode(['status' => 'error', 'message' => 'Invalid response']);
|
|
} else {
|
|
echo $output;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
if (strpos($_SERVER['REQUEST_URI'], '/upload.php') === 0) {
|
|
ob_start();
|
|
require __DIR__ . '/upload.php';
|
|
$output = ob_get_clean();
|
|
if (json_decode($output) === null) {
|
|
|
|
echo json_encode(['status' => 'error', 'message' => 'Invalid response']);
|
|
} else {
|
|
echo $output;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
|
|
require __DIR__ . '/index.php';
|
|
return true;
|
|
|