feat: 添加旺铺授权系统初始文件
添加url.txt、index.php和auth.json三个初始文件 index.php实现跨域请求处理和授权信息读取 auth.json包含3000+旺铺授权数据
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
// 设置响应头,允许所有来源的跨域请求
|
||||
header('Access-Control-Allow-Origin: *');
|
||||
header('Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS');
|
||||
header('Access-Control-Allow-Headers: Content-Type, Authorization');
|
||||
header('Content-Type: application/json');
|
||||
|
||||
// 处理OPTIONS预检请求
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'OPTIONS') {
|
||||
exit(0);
|
||||
}
|
||||
|
||||
// 定义文件路径
|
||||
$urlFilePath = 'c:\\Users\\吴展鹏\\wangpu_auth\\url.txt';
|
||||
$authFilePath = 'c:\\Users\\吴展鹏\\wangpu_auth\\auth.json';
|
||||
|
||||
// 读取并返回auth.json文件的内容
|
||||
if (file_exists($authFilePath)) {
|
||||
// 读取JSON文件内容
|
||||
$jsonContent = file_get_contents($authFilePath);
|
||||
|
||||
// 验证JSON格式是否正确
|
||||
if ($jsonContent && json_decode($jsonContent) !== null) {
|
||||
// 直接输出JSON内容
|
||||
echo $jsonContent;
|
||||
exit;
|
||||
} else {
|
||||
// JSON格式错误时的响应
|
||||
$errorResponse = array(
|
||||
'status' => 'error',
|
||||
'message' => 'JSON文件格式错误或内容为空'
|
||||
);
|
||||
echo json_encode($errorResponse, JSON_UNESCAPED_UNICODE);
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
// 文件不存在时的响应
|
||||
$errorResponse = array(
|
||||
'status' => 'error',
|
||||
'message' => 'auth.json文件不存在'
|
||||
);
|
||||
echo json_encode($errorResponse, JSON_UNESCAPED_UNICODE);
|
||||
exit;
|
||||
}
|
||||
|
||||
// 终止脚本执行
|
||||
exit;
|
||||
?>
|
||||
Reference in New Issue
Block a user