52 lines
1.4 KiB
PHP
52 lines
1.4 KiB
PHP
<?php
|
|
|
|
// 密码验证接口
|
|
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action']) && $_POST['action'] === 'login') {
|
|
$password = $_POST['password'] ?? '';
|
|
// 使用 SHA256 + 固定盐值
|
|
$inputHash = hash('sha256', $password . 'your_secret_salt_12345');
|
|
$correctHash = hash('sha256', 'JLUnaga2026' . 'your_secret_salt_12345');
|
|
|
|
if ($inputHash === $correctHash) {
|
|
echo json_encode(['success' => true]);
|
|
} else {
|
|
echo json_encode(['success' => false]);
|
|
}
|
|
exit;
|
|
}
|
|
|
|
// 后面的代码不变...
|
|
|
|
header('Content-Type: application/json');
|
|
header('Access-Control-Allow-Origin: *');
|
|
header('Access-Control-Allow-Methods: GET, POST');
|
|
header('Access-Control-Allow-Headers: Content-Type');
|
|
|
|
$dataFile = 'dataurl.json';
|
|
|
|
// 确保文件存在
|
|
if (!file_exists($dataFile)) {
|
|
file_put_contents($dataFile, '[]');
|
|
}
|
|
|
|
$method = $_SERVER['REQUEST_METHOD'];
|
|
|
|
if ($method === 'GET') {
|
|
// 读取数据
|
|
$data = file_get_contents($dataFile);
|
|
echo $data;
|
|
|
|
} elseif ($method === 'POST') {
|
|
// 保存数据
|
|
$input = file_get_contents('php://input');
|
|
$data = json_decode($input, true);
|
|
|
|
if ($data !== null) {
|
|
file_put_contents($dataFile, json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE));
|
|
echo json_encode(['success' => true]);
|
|
} else {
|
|
http_response_code(400);
|
|
echo json_encode(['success' => false, 'error' => 'Invalid JSON']);
|
|
}
|
|
}
|
|
?>
|