温泉授权系统自动更换设备码接口

文件里的东西可以自行󠄐󠄹󠅀󠄪󠄡󠄨󠄞󠄢󠄢󠄤󠄐󠄹󠅀󠄪󠄡󠄨󠄞󠄢󠄢󠄤󠄞󠄢󠄡󠄢󠄞󠄡󠄩󠄬󠅒󠅢󠄟󠄮󠄐󠅅󠄹󠄴󠄪󠄾󠅟󠅤󠄐󠄼󠅟󠅗󠅙󠅞󠄬󠅒󠅢󠄟󠄮󠅄󠅙󠅝󠅕󠄪󠄡󠄧󠄤󠄣󠄧󠄢󠄡󠄣󠄣󠄡󠄬󠅒󠅢󠄟󠄮󠇕󠅸󠆍󠇗󠆖󠆫󠇕󠅽󠆊󠇕󠆞󠆒󠄐󠇗󠅹󠅸󠇖󠆍󠅳󠇖󠅹󠅰󠇖󠆌󠅹󠄬󠅒󠅢󠄟󠄮󠄞󠄢󠄡󠄢󠄞󠄡󠄩󠄬󠅒󠅢󠄟󠄮󠄐󠅅󠄹󠄴󠄪󠄾󠅟󠅤󠄐󠄼󠅟󠅗󠅙󠅞󠄬󠅒󠅢󠄟󠄮󠅄󠅙󠅝󠅕󠄪󠄡󠄧󠄤󠄣󠄧󠄢󠄡󠄣󠄣󠄡󠄬󠅒󠅢󠄟󠄮󠇕󠅸󠆍󠇗󠆖󠆫󠇕󠅽󠆊󠇕󠆞󠆒󠄐󠇗󠅹󠅸󠇖󠆍󠅳󠇖󠅹󠅰󠇖󠆌󠅹󠄬󠅒󠅢󠄟󠄮更改,请󠄐󠄹󠅀󠄪󠄡󠄨󠄞󠄢󠄢󠄤󠄞󠄢󠄡󠄢󠄞󠄡󠄩󠄬󠅒󠅢󠄟󠄮󠄐󠅅󠄹󠄴󠄪󠄾󠅟󠅤󠄐󠄼󠅟󠅗󠅙󠅞󠄬󠅒󠅢󠄟󠄮󠅄󠅙󠅝󠅕󠄪󠄡󠄧󠄤󠄣󠄧󠄢󠄡󠄣󠄣󠄡󠄬󠅒󠅢󠄟󠄮󠇕󠅸󠆍󠇗󠆖󠆫󠇕󠅽󠆊󠇕󠆞󠆒󠄐󠇗󠅹󠅸󠇖󠆍󠅳󠇖󠅹󠅰󠇖󠆌󠅹󠄬󠅒󠅢󠄟󠄮求格式:https://域名/文件名.php?old_mac=旧机器码&new_mac=新机器码,Json󠄐󠄹󠅀󠄪󠄡󠄨󠄞󠄢󠄢󠄤󠄞󠄢󠄡󠄢󠄞󠄡󠄩󠄬󠅒󠅢󠄟󠄮󠄐󠅅󠄹󠄴󠄪󠄾󠅟󠅤󠄐󠄼󠅟󠅗󠅙󠅞󠄬󠅒󠅢󠄐󠄹󠅀󠄪󠄡󠄨󠄞󠄢󠄢󠄤󠄞󠄢󠄡󠄢󠄞󠄡󠄩󠄬󠅒󠅢󠄟󠄮󠄐󠅅󠄹󠄴󠄪󠄾󠅟󠅤󠄐󠄼󠅟󠅗󠅙󠅞󠄬󠅒󠅢󠄟󠄮󠅄󠅙󠅝󠅕󠄪󠄡󠄧󠄤󠄣󠄧󠄢󠄡󠄣󠄣󠄡󠄬󠅒󠅢󠄟󠄮󠇕󠅸󠆍󠇗󠆖󠆫󠇕󠅽󠆊󠇕󠆞󠆒󠄐󠇗󠅹󠅸󠇖󠆍󠅳󠇖󠅹󠅰󠇖󠆌󠅹󠄬󠅒󠅢󠄟󠄮󠄟󠄮󠅄󠅙󠅝󠅕󠄪󠄡󠄧󠄤󠄣󠄧󠄢󠄡󠄣󠄣󠄡󠄬󠅒󠅢󠄟󠄮󠇕󠅸󠆍󠇗󠆖󠆫󠇕󠅽󠆊󠇕󠆞󠆒󠄐󠇗󠅹󠅸󠇖󠆍󠅳󠇖󠅹󠅰󠇖󠆌󠅹󠄬󠅒󠅢󠄟󠄮 格式。

代码部分

<?php
// 数据库连接配置
$db_host = 'localhost';
$db_user = 'root';
$db_pass = 'password';
$db_name = 'name';
$conn = new mysqli($db_host, $db_user, $db_pass, $db_name);

if ($conn->connect_error) {
    die("数据库连接失败: " . $conn->connect_error);
}

// 获取参数
$old_mac = isset($_GET['old_mac']) ? $_GET['old_mac'] : '';
$new_mac = isset($_GET['new_mac']) ? $_GET['new_mac'] : '';

// 验证参数
if (empty($old_mac) || empty($new_mac)) {
    echo json_encode(['code' => 400, 'message' => '参数不完整']);
    exit;
}

// 检查旧机器码是否存在
$sql = "SELECT * FROM sq_fidkey WHERE user LIKE ? AND status = 1";
$stmt = $conn->prepare($sql);
$search_term = '%"mac":"' . $old_mac . '"%';
$stmt->bind_param("s", $search_term);
$stmt->execute();
$result = $stmt->get_result();

if ($result->num_rows === 0) {
    echo json_encode(['code' => 404, 'message' => '未找到对应的授权记录']);
    exit;
}

// 更新机器码
$row = $result->fetch_assoc();
$user_data = json_decode($row['user'], true);
$user_data['mac'] = $new_mac;
$new_user_data = json_encode($user_data);

$update_sql = "UPDATE sq_fidkey SET user = ? WHERE ID = ?";
$update_stmt = $conn->prepare($update_sql);
$update_stmt->bind_param("si", $new_user_data, $row['ID']);

if ($update_stmt->execute()) {
    echo json_encode(['code' => 200, 'message' => '机器码更换成功']);
} else {
    echo json_encode(['code' => 500, 'message' => '机器码更换失败']);
}

$conn->close();
?>

 

请登录后发表评论

    没有回复内容