31 lines
971 B
PHP
31 lines
971 B
PHP
<?php
|
|
include('config.php');
|
|
|
|
// 安全地获取API名称
|
|
$api = isset($_GET['api']) ? $_GET['api'] : '';
|
|
|
|
// 白名单验证
|
|
$allowedApis = ['pic', 'favicon', 'bj', 'fox', 'total-pic', 'announcements'];
|
|
|
|
if (empty($api)) {
|
|
include('includes/home.php');
|
|
} elseif (in_array($api, $allowedApis)) {
|
|
if ($api === 'pic') {
|
|
include('includes/pic-header.php');
|
|
include('includes/pic-table-default.php');
|
|
include('includes/pic-push.php');
|
|
} elseif (in_array($api, ['favicon', 'bj', 'fox'])) {
|
|
include('includes/pic-header.php');
|
|
include('includes/pic-table-others.php');
|
|
include('includes/pic-push.php');
|
|
} else { // 'total-pic' or 'announcements'
|
|
header('Content-Type: application/json');
|
|
include ('includes/' . $api . '.php');
|
|
}
|
|
} else {
|
|
http_response_code(404);
|
|
header('Content-Type: application/json');
|
|
echo json_encode(['code' => 404,'messages' => 'Not Found']);
|
|
exit;
|
|
}
|
|
?>
|