From 432ffb8e5bcd330a0c116fd95bb15bb54e3121b5 Mon Sep 17 00:00:00 2001 From: MKStoler Date: Wed, 29 Jan 2025 22:30:31 +0800 Subject: [PATCH] =?UTF-8?q?init:=20=E5=88=9D=E5=A7=8B=E5=8C=96=E4=BB=93?= =?UTF-8?q?=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .htaccess | 3 + admin/delete.php | 16 +++++ admin/edit.php | 166 ++++++++++++++++++++++++++++++++++++++++++++ admin/index.php | 139 +++++++++++++++++++++++++++++++++++++ admin/login.php | 104 +++++++++++++++++++++++++++ configs/111111.json | 12 ++++ get_config.php | 18 +++++ includes/auth.php | 23 ++++++ includes/users.json | 4 ++ index.php | 129 ++++++++++++++++++++++++++++++++++ 10 files changed, 614 insertions(+) create mode 100644 .htaccess create mode 100644 admin/delete.php create mode 100644 admin/edit.php create mode 100644 admin/index.php create mode 100644 admin/login.php create mode 100644 configs/111111.json create mode 100644 get_config.php create mode 100644 includes/auth.php create mode 100644 includes/users.json create mode 100644 index.php diff --git a/.htaccess b/.htaccess new file mode 100644 index 0000000..e52e474 --- /dev/null +++ b/.htaccess @@ -0,0 +1,3 @@ + + Deny from all + \ No newline at end of file diff --git a/admin/delete.php b/admin/delete.php new file mode 100644 index 0000000..08335e5 --- /dev/null +++ b/admin/delete.php @@ -0,0 +1,16 @@ + diff --git a/admin/edit.php b/admin/edit.php new file mode 100644 index 0000000..889159e --- /dev/null +++ b/admin/edit.php @@ -0,0 +1,166 @@ + '', 'message' => '', 'examInfos' => []]; + +// 保存逻辑 +if ($_SERVER['REQUEST_METHOD'] === 'POST') { + $id = preg_replace('/[^a-zA-Z0-9]/', '', $_POST['id']); + + $newConfig = [ + 'examName' => $_POST['examName'], + 'message' => $_POST['message'], + 'room' => ' ', + 'examInfos' => [] + ]; + + foreach ($_POST['subject'] as $index => $subject) { + $newConfig['examInfos'][] = [ + 'name' => $subject, + 'start' => $_POST['start'][$index], + 'end' => $_POST['end'][$index] + ]; + } + + file_put_contents("../configs/{$id}.json", json_encode($newConfig, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT)); + header('Location: index.php'); + exit; +} + +// 加载现有配置 +if (!empty($id) && file_exists("../configs/{$id}.json")) { + $config = json_decode(file_get_contents("../configs/{$id}.json"), true); +} +?> + + + + 编辑配置 + + + + +
+
+
+ + +
+
+ + +
+
+ + +
+ +

考试科目安排

+
+ +
+
+ + +
+
+ + +
+
+ + +
+ +
+ +
+ +
+ +
+
+ + \ No newline at end of file diff --git a/admin/index.php b/admin/index.php new file mode 100644 index 0000000..0b3819f --- /dev/null +++ b/admin/index.php @@ -0,0 +1,139 @@ + $id, + 'mtime' => date("Y-m-d H:i:s", filemtime("../configs/$file")), + 'size' => filesize("../configs/$file") + ]; + } +} + +// 按创建时间排序 +uksort($configs, function($a, $b) { + return filemtime("../configs/$b.json") - filemtime("../configs/$a.json"); +}); +?> + + + + 配置管理后台 + + + +
+

考试配置管理 当前用户:

+ 退出登录 +
+ +
+ 新建配置 +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
配置ID最后修改时间文件大小操作
暂无配置文件
KB + 编辑 + 删除 + 预览 +
+ + + + \ No newline at end of file diff --git a/admin/login.php b/admin/login.php new file mode 100644 index 0000000..827e0a4 --- /dev/null +++ b/admin/login.php @@ -0,0 +1,104 @@ + + + + + 登录 + + + +
+

登录

+ +
+ +
+
+ + +
+
+ + +
+ +
+
+ + \ No newline at end of file diff --git a/configs/111111.json b/configs/111111.json new file mode 100644 index 0000000..2c4d770 --- /dev/null +++ b/configs/111111.json @@ -0,0 +1,12 @@ +{ + "examName": "1111", + "message": "1111", + "room": " ", + "examInfos": [ + { + "name": "1111", + "start": "2025-01-29T00:00", + "end": "2025-01-29T22:15" + } + ] +} \ No newline at end of file diff --git a/get_config.php b/get_config.php new file mode 100644 index 0000000..ab65948 --- /dev/null +++ b/get_config.php @@ -0,0 +1,18 @@ + '缺少ID参数'])); +} + +$id = preg_replace('/[^a-zA-Z0-9]/', '', $_GET['id']); +$file = "configs/{$id}.json"; + +if (!file_exists($file)) { + http_response_code(404); + die(json_encode(['error' => '配置不存在'])); +} + +echo file_get_contents($file); +?> \ No newline at end of file diff --git a/includes/auth.php b/includes/auth.php new file mode 100644 index 0000000..6a893a9 --- /dev/null +++ b/includes/auth.php @@ -0,0 +1,23 @@ + \ No newline at end of file diff --git a/includes/users.json b/includes/users.json new file mode 100644 index 0000000..7456dd4 --- /dev/null +++ b/includes/users.json @@ -0,0 +1,4 @@ +[{ + "username": "admin", + "password": "21232f297a57a5a743894a0e4a801fc3" +}] \ No newline at end of file diff --git a/index.php b/index.php new file mode 100644 index 0000000..a7d26e3 --- /dev/null +++ b/index.php @@ -0,0 +1,129 @@ + + + + + 考试看板配置查询 + + + +
+

考试看板配置查询

+
+ + + +
+ +
+ +
+

管理员请前往 管理后台

+
+ + + + \ No newline at end of file