From a74f68782473de131bd0a8ccbabf06cf328af5ff Mon Sep 17 00:00:00 2001 From: Masco Skray Date: Thu, 12 Sep 2019 18:12:01 +0800 Subject: [PATCH] feat(web): add judger management in super_manage You can add or delete judger information at this page. It will give a password to you, then you can use it to set up new judger. --- web/app/controllers/super_manage.php | 71 ++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) diff --git a/web/app/controllers/super_manage.php b/web/app/controllers/super_manage.php index 2ee1bd4..ee9f0d2 100644 --- a/web/app/controllers/super_manage.php +++ b/web/app/controllers/super_manage.php @@ -208,6 +208,62 @@ DB::delete("delete from custom_test_submissions order by id asc limit {$vdata['last']}"); }; $custom_test_deleter->runAtServer(); + + $judger_adder = new UOJForm('judger_adder'); + $judger_adder->addInput('judger_adder_name', 'text', '评测机名称', '', + function ($x, &$vdata) { + if (!validateUsername($x)) { + return '不合法'; + } + if(DB::selectCount("select count(*) from judger_info where judger_name='$x'")!=0) { + return '不合法'; + } + $vdata['name'] = $x; + return ''; + }, + null + ); + $judger_adder->handle = function(&$vdata) { + $password=uojRandString(32); + DB::insert("insert into judger_info (judger_name,password) values('{$vdata['name']}','{$password}')"); + }; + $judger_adder->runAtServer(); + + $judger_deleter = new UOJForm('judger_deleter'); + $judger_deleter->addInput('judger_deleter_name', 'text', '评测机名称', '', + function ($x, &$vdata) { + if (!validateUsername($x)) { + return '不合法'; + } + if(DB::selectCount("select count(*) from judger_info where judger_name='$x'")!=1) { + return '不合法'; + } + $vdata['name'] = $x; + return ''; + }, + null + ); + $judger_deleter->handle = function(&$vdata) { + DB::delete("delete from judger_info where judger_name='{$vdata['name']}'"); + }; + $judger_deleter->runAtServer(); + + $judgerlist_cols = array('judger_name', 'password'); + $judgerlist_config = array(); + $judgerlist_header_row = << + 评测机名称 + 密码 + +EOD; + $judgerlist_print_row = function($row) { + echo << + {$row['judger_name']} + {$row['password']} + +EOD; + }; $banlist_cols = array('username', 'usergroup'); $banlist_config = array(); @@ -251,6 +307,10 @@ EOD; 'search' => array( 'name' => '搜索管理', 'url' => '/super-manage/search' + ), + 'judger' => array( + 'name' => '评测机管理', + 'url' => '/super-manage/judger' ) ); @@ -371,6 +431,17 @@ EOD; 'page_len' => 1000 )) ?> + +
+

添加评测机

+ printHTML(); ?> +
+
+

删除评测机

+ printHTML(); ?> +
+

评测机列表

+