<?php
    require_once 'global.php';
    checkAdminLogin();      //检测当前系统是否登录
?>
<?php
$token=file_get_contents('config/ai_login_token.txt');
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>AI平台Token提交</title>
<script src="js/jquery.min.js"></script>
<script>
$(document).ready(function(){
    $('#submitBtn').click(function(){
        var token = $('#Token').val();
        
        // 弹出确认框
        if(confirm("确定要提交吗？")) {
            // 使用Ajax提交数据
            $.ajax({
                type: 'POST',
                url: 'submit_set_token.php',
                data: {token: token},
                success: function(response) {
                    if(response.trim() === 'success') {
                        alert('写入成功');
                    } else {
                        alert('写入失败');
                    }
                },
                error: function() {
                    alert('写入失败，请重试');
                }
            });
        }
    });
});
</script>
</head>
<body>
    AI平台用户Token:<br>
    <textarea id="Token" name="Token" style="width:100%;height:100px;"><?=$token?></textarea><br>
    <center><button id="submitBtn" style="padding:10px 20px;background-color:green;color:#fff;margin:0 auto;">保存Token</button></center>
</body>
</html>
