\ No newline at end of file
+
diff --git a/web/OJ/admin/more_settings.php b/web/OJ/admin/more_settings.php
new file mode 100644
index 00000000..bed8fbd6
--- /dev/null
+++ b/web/OJ/admin/more_settings.php
@@ -0,0 +1,86 @@
+
+
+ strtotime($end_date)) {
+ echo "时间不合法";
+ exit(1);
+ }
+
+ $sql = "UPDATE more_settings SET start_time = '$start_date', end_time = '$end_date'";
+ $mysqli->query($sql);
+}
+if (isset($_POST['update_ai_module'])) {
+ $ai_module = isset($_POST['ai_module']) ? 1 : 0;
+ $sql = "UPDATE more_settings SET ai_model = $ai_module";
+ $mysqli->query($sql);
+}
+?>
+
+query($sql);
+$row = $res->fetch_assoc();
+
+$start_date = date("Y-m-d", strtotime($row['start_time']));
+$end_date = date("Y-m-d", strtotime($row['end_time']));
+$ai_module = $row['ai_model'];
+?>
+
+
+
+
diff --git a/web/OJ/admin/privilege_distribution.php b/web/OJ/admin/privilege_distribution.php
index af88475e..3560521f 100644
--- a/web/OJ/admin/privilege_distribution.php
+++ b/web/OJ/admin/privilege_distribution.php
@@ -240,7 +240,7 @@
manage_tag
- set_dailydetails
+ set_more_settings
@@ -253,4 +253,4 @@
?>
\ No newline at end of file
+
diff --git a/web/OJ/admin/set_dailydetails.php b/web/OJ/admin/set_dailydetails.php
deleted file mode 100644
index a56b4b73..00000000
--- a/web/OJ/admin/set_dailydetails.php
+++ /dev/null
@@ -1,174 +0,0 @@
-
-
- strtotime($end_date)){
- echo "时间不合法";
- exit(1);
- }
-
- $sql = "UPDATE dailydetails SET start_time = '$start_date', end_time = '$end_date'";
- $mysqli->query($sql);
-}
-?>
-
-query($sql);
- $row = $res->fetch_assoc();
-
- $start_date = new DateTime($row['start_time']);
- $end_date = new DateTime($row['end_time']);
-
- $select_start_year = $start_date->format('Y');
- $select_start_month = $start_date->format('m');
- $select_start_day = $start_date->format('d');
-
- $select_end_year = $end_date->format('Y');
- $select_end_month = $end_date->format('m');
- $select_end_day = $end_date->format('d');
-?>
-
-
-
-
-
-
\ No newline at end of file
diff --git a/web/OJ/chat-test.php b/web/OJ/chat-test.php
new file mode 100644
index 00000000..8e983bf2
--- /dev/null
+++ b/web/OJ/chat-test.php
@@ -0,0 +1,43 @@
+
" . PHP_EOL;
+// $endpoint = 'http://172.22.233.71:8081/OJ/chat.php';
+// $numberOfRequests = 20; // Number of concurrent requests
+// $question = '写个C语言的累加程序';
+
+// $multiHandle = curl_multi_init();
+// $curlHandles = [];
+
+// for ($i = 0; $i < $numberOfRequests; $i++) {
+// $curlHandles[$i] = curl_init();
+// curl_setopt($curlHandles[$i], CURLOPT_URL, $endpoint . '?q=' . urlencode($question));
+// curl_setopt($curlHandles[$i], CURLOPT_RETURNTRANSFER, true);
+// curl_setopt($curlHandles[$i], CURLOPT_HTTPHEADER, [
+// 'Accept: text/event-stream',
+// 'Accept-Language: zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,zh-TW;q=0.6,en-US;q=0.5',
+// 'Cache-Control: no-cache',
+// 'Connection: keep-alive',
+// 'Pragma: no-cache',
+// 'Referer: http://172.22.233.71:8081/OJ/',
+// 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36 Edg/131.0.0.0'
+// ]);
+// curl_setopt($curlHandles[$i], CURLOPT_COOKIE, 'PHPSESSID=v252sdchi5438pmte0gt8p2oi7');
+// curl_setopt($curlHandles[$i], CURLOPT_SSL_VERIFYPEER, false); // --insecure option
+// curl_multi_add_handle($multiHandle, $curlHandles[$i]);
+// }
+
+// $running = null;
+// do {
+// curl_multi_exec($multiHandle, $running);
+// curl_multi_select($multiHandle);
+// } while ($running > 0);
+
+// foreach ($curlHandles as $index => $handle) {
+// $response = curl_multi_getcontent($handle);
+// echo "Request " . ($index + 1) . ": Response length - " . strlen($response) . " characters
";
+// $info = curl_getinfo($handle);
+// echo "Request " . ($index + 1) . ": Time taken - " . $info['total_time'] . " seconds
";
+// curl_multi_remove_handle($multiHandle, $handle);
+// curl_close($handle);
+// }
+
+// curl_multi_close($multiHandle);
diff --git a/web/OJ/chat.php b/web/OJ/chat.php
index 0b4b3270..8f33e8f5 100644
--- a/web/OJ/chat.php
+++ b/web/OJ/chat.php
@@ -27,7 +27,16 @@
exit();
}
-// TODO:查询是否禁用AI功能
+// 查询是否禁用AI功能
+$sql = "SELECT * FROM more_settings";
+$res = $mysqli->query($sql);
+$row = $res->fetch_assoc();
+$ai_module = $row['ai_model'];
+if ($ai_module == 0) {
+ echo "data: " . json_encode(["code" => "498", "error" => "AI module is disabled"]) . "\n\n";
+ flush();
+ exit();
+}
// 查询当前用户是否正处于AI对话中
@@ -35,7 +44,7 @@
if (isset($_SESSION['last_chat_time'])) {
$lastChatTime = $_SESSION['last_chat_time'];
if (($currentTime - $lastChatTime) < 5) {
- echo "data: " . json_encode(["code" => "498", "error" => "In Conversation now"]) . "\n\n";
+ echo "data: " . json_encode(["code" => "497", "error" => "In Conversation now"]) . "\n\n";
flush();
exit();
}
@@ -63,7 +72,7 @@
// api 和 模型选择
$chat = new OllamaChat(
"http://$AI_HOST:11434/api/generate",
- "$AI_MODEL"
+ rand(1, 100) <= 50 ? "$AI_MODEL1" : "$AI_MODEL2"
);
$DOCUMENT_ROOT = $_SERVER['DOCUMENT_ROOT'];
diff --git a/web/OJ/daily_detail.php b/web/OJ/daily_detail.php
index 4e0f1672..9610f005 100644
--- a/web/OJ/daily_detail.php
+++ b/web/OJ/daily_detail.php
@@ -5,7 +5,7 @@
$current_year = date("Y");
-$sql = "SELECT * FROM dailydetails";
+$sql = "SELECT * FROM more_settings";
$res = $mysqli->query($sql);
$row = $res->fetch_assoc();
diff --git a/web/OJ/plugins/hznuojai/chat.js b/web/OJ/plugins/hznuojai/chat.js
index 6dfff766..db80eb07 100644
--- a/web/OJ/plugins/hznuojai/chat.js
+++ b/web/OJ/plugins/hznuojai/chat.js
@@ -154,14 +154,14 @@ class ChatCore {
if (result.time && result.content) {
this.answerWords.push(result.content);
this.contentIdx += 1;
- } else if (result.code === "499") {
+ } else if (["499", "498", "497"].includes(result.code)) {
console.error(result.error);
- this.patchMd(this.answers[this.qaIdx], '请登录后再使用 AI 功能');
- this.isStop = true;
- this.eventSource.close();
- } else if (result.code === "498") {
- console.error(result.error);
- this.patchMd(this.answers[this.qaIdx], '请不要频繁发起对话');
+ const messages = {
+ "499": '请登录后再使用 AI 功能',
+ "498": 'AI 服务正在维护中ing 请稍后再试',
+ "497": '请不要频繁发起对话'
+ };
+ this.patchMd(this.answers[this.qaIdx], messages[result.code]);
this.isStop = true;
this.eventSource.close();
}
diff --git a/web/OJ/student_daily_detail.php b/web/OJ/student_daily_detail.php
index 1e2fe400..fd901b90 100644
--- a/web/OJ/student_daily_detail.php
+++ b/web/OJ/student_daily_detail.php
@@ -2,7 +2,7 @@
query($sql);
$row = $res->fetch_assoc();
$start_date_db = date("Y-m-d", strtotime($row['start_time']));
@@ -21,8 +21,8 @@
?>
$MSG_Login";
require("template/" . $OJ_TEMPLATE . "/error.php");
exit(0);
diff --git a/web/OJ/template/hznu/daily_detail.php b/web/OJ/template/hznu/daily_detail.php
index 387cf652..c54f383c 100644
--- a/web/OJ/template/hznu/daily_detail.php
+++ b/web/OJ/template/hznu/daily_detail.php
@@ -4,7 +4,7 @@
?>
查看班级学生每日详情