Files
Fuxsto-V3/user/admin_end_ticket.php
2025-10-18 14:46:52 +08:00

101 lines
1.9 KiB
PHP

<?php
include './admin_sc.php';
include './email.php';
$a_user = $_GET['user'];
$a_pass = $_GET['pass'];
$ticket = @file_get_contents("./me/".$a_user."/".$a_pass."/ticket.json");
if (!$ticket) {
die("error");
}
$ticket = @file_get_contents("./me/".$a_user."/".$a_pass."/ticket.json");
// 获取当前时间并格式化
$time = date('Y-m-d H:i:s');
$data = json_decode($ticket, true);
$msg = $_POST['msg'];
$name = $_POST['name'];
$data['ticket']['last_reply_time'] = $time;
$data['ticket']['status'] = "已完结";
// 添加新的对话到尾部
$new_conversation_tail = [
"responder" => "Fuxsto Host",
"role" => "admin",
"reply_time" => $time,
"reply_content" => "工单已完结!"
];
array_push($data['ticket']['conversation'], $new_conversation_tail);
// 编码为 JSON 字符串
$main = json_encode($data, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
// 定义要检查的文件路径
$filename = './me/' . $a_user . '/' . $a_pass . '/ticket.json'; // 目录路径
@file_put_contents($filename, $main);
@sendMail($a_user . '@qq.com', '#Fuxsto Host 工单完结', "你的工单已完结!");
echo '结单成功!<br><meta http-equiv="refresh" content="0;url=./admin.php">';
// 原文件路径
$originalFile = $filename;
// 新文件名
$newFileName = $time.'.json';
// 目标目录
$targetDirectory = './me/' . $a_user . '/' . $a_pass . '/tickets/';
// 新文件完整路径
$newFilePath = $targetDirectory . $newFileName;
// 检查目标目录是否存在,如果不存在则创建
if (!is_dir($targetDirectory)) {
if (mkdir($targetDirectory, 0755, true)) {
echo "目标目录创建成功!<br>";
} else {
die("目标目录创建失败!<br>");
}
}
// 首先重命名文件
if (rename($originalFile, $newFilePath)) {
echo "文件重命名并移动成功!";
} else {
echo "文件重命名或移动失败!";
}
?>