function process_reply($guests, $guest) { $reply = $_REQUEST["reply"]; $heads = $_REQUEST["heads"]; $comments = $_REQUEST["comments"]; if ($reply == "N") { $heads = 0; } else { if ($heads < 1) { $heads = 1; } else { if ($heads > 50) { $heads = 50; } } } rowid_set_values($guests, $guest, array("reply" => $reply, "heads" => $heads, "comments" => $comments)); get_reply($guests, $guest); return 0; }
$endTime = $_GET['endtime']; $conn = new mysqli($mysqlServer, $mysqlUser, $mysqlPass, $mysqlDbName); if ($conn->connect_error) { die('数据库连接错误:' . $conn->connect_error); } //清空表 $sql = "TRUNCATE TABLE smsreply"; $conn->query($sql); //查询回复短信并保存 $sql = "SELECT * FROM user"; $result = $conn->query($sql); if ($result->num_rows > 0) { while ($row = $result->fetch_assoc()) { $phone = $row['phone']; $name = $row['name']; $replyResultJson = get_reply($apiKey, $replyUrl, $startTime, $endTime, $phone); $replyResult = json_decode($replyResultJson, 'ture'); $replyText = $replyResult['sms_reply']['0']['text']; $replyText = inputProcess($replyText); $replyTime = $replyResult['sms_reply']['0']['reply_time']; $sql = "INSERT INTO smsreply (phone,name,text,time) VALUES ('{$phone}','{$name}','{$replyText}','{$replyTime}')"; $conn->query($sql); } } $conn->close(); header('Location: smsReply.php'); } ?> <!DOCTYPE html> <html lang="zh-cn">