From 3b68e6c50361b54f43289de884dc9ecaf79e2e7f Mon Sep 17 00:00:00 2001
From: Baoshuo
Date: Wed, 21 Sep 2022 18:12:58 +0800
Subject: [PATCH] feat: move blog_link_contests to contest_manage.php
---
web/app/controllers/contest_manage.php | 63 ++++++++++++++++++++++
web/app/controllers/super_manage.php | 73 --------------------------
2 files changed, 63 insertions(+), 73 deletions(-)
diff --git a/web/app/controllers/contest_manage.php b/web/app/controllers/contest_manage.php
index 94df58f..f9587ca 100644
--- a/web/app/controllers/contest_manage.php
+++ b/web/app/controllers/contest_manage.php
@@ -168,6 +168,65 @@
$time_form->runAtServer();
$managers_form->runAtServer();
$problems_form->runAtServer();
+
+ $blog_link_contests = new UOJForm('blog_link_contests');
+ $blog_link_contests->addInput('blog_link_contests__blog_id', 'text', '博客ID', '',
+ function ($x) {
+ if (!validateUInt($x)) {
+ return 'ID不合法';
+ }
+ if (!queryBlog($x)) {
+ return '博客不存在';
+ }
+ return '';
+ },
+ null
+ );
+ $blog_link_contests->addInput('blog_link_contests__title', 'text', '标题', '',
+ function ($x) {
+ return '';
+ },
+ null
+ );
+ $options = array(
+ 'add' => '添加',
+ 'del' => '删除'
+ );
+ $blog_link_contests->addSelect('blog_link_contests__op-type', $options, '操作类型', '');
+ $blog_link_contests->handle = function() {
+ global $contest;
+
+ $blog_id = $_POST['blog_link_contests__blog_id'];
+ $contest_id = $contest['id'];
+ $str = DB::selectFirst("select * from contests where id='${contest_id}'");
+ $all_config = json_decode($str['extra_config'], true);
+ $config = $all_config['links'];
+
+ $n = count($config);
+
+ if ($_POST['blog_link_contests__op-type'] == 'add') {
+ $row = array();
+ $row[0] = $_POST['blog_link_contests__title'];
+ $row[1] = $blog_id;
+ $config[$n] = $row;
+ }
+ if ($_POST['blog_link_contests__op-type'] == 'del') {
+ for ($i = 0; $i < $n; $i++) {
+ if ($config[$i][1] == $blog_id) {
+ $config[$i] = $config[$n - 1];
+ unset($config[$n - 1]);
+ break;
+ }
+ }
+ }
+
+ $all_config['links'] = $config;
+ $str = json_encode($all_config);
+ $str = DB::escape($str);
+ DB::query("update contests set extra_config='${str}' where id='${contest_id}'");
+ };
+ $blog_link_contests->runAtServer();
+
?>
=$contest['name']?> 管理
@@ -175,6 +234,7 @@
命令格式:命令一行一个,+233表示把题号为233的试题加入比赛,-233表示把题号为233的试题从比赛中移除
printHTML(); ?> +