ez-api/core/router.php

25 lines
674 B
PHP
Raw Normal View History

2024-10-29 13:13:37 +08:00
<?php
2024-10-30 12:59:20 +08:00
// 管理界面路由
if ($api_class == 'admin') {
if ($_SESSION['user_id'] == 'admin') {
// 处理管理员请求
// ...
} else {
2024-11-01 13:02:42 +08:00
http_response_code(401)
2024-10-30 12:59:20 +08:00
echo json_encode(['error' => 'Unauthorized', 'code' => 401]);
exit;
}
2024-10-29 13:13:37 +08:00
}
2024-10-30 12:59:20 +08:00
// 非管理需登陆界面路由
elseif ($api_class != 'admin') {
if (isset($_SESSION['user_id']) && !empty($_SESSION['user_id'])) {
// 处理已登录用户请求
// ...
} else {
2024-11-01 13:02:42 +08:00
http_response_code(401)
2024-10-30 12:59:20 +08:00
echo json_encode(['error' => 'Unauthorized', 'code' => 401]);
exit;
}
} else {
echo json_encode(['error' => 'unknown error']);
}