[ 'name' => '首页管理', 'url' => "/super_manage/index", ], 'users' => [ 'name' => '用户管理', 'url' => "/super_manage/users", ], 'submissions' => [ 'name' => '提交记录', 'url' => "/super_manage/submissions", ], 'custom_test' => [ 'name' => '自定义测试', 'url' => "/super_manage/custom_test", ], 'judger' => [ 'name' => '评测机管理', 'url' => "/super_manage/judger", ], 'image_hosting' => [ 'name' => '图床管理', 'url' => "/super_manage/image_hosting", ], ]; if (!isset($tabs_info[$cur_tab])) { become404Page(); } if ($cur_tab == 'index') { // ========== 公告 ========== if (UOJRequest::post('submit-delete_announcement') === 'delete_announcement') { crsf_defend(); $blog_id = UOJRequest::post('blog_id'); if (!validateUInt($blog_id)) { dieWithAlert('移除失败:博客 ID 无效'); } DB::delete([ "delete from important_blogs", "where", [ "blog_id" => $blog_id, ] ]); dieWithAlert('移除成功!'); } $announcements = DB::selectAll([ "select", DB::fields([ "id" => "blogs.id", "title" => "blogs.title", "poster" => "blogs.poster", "realname" => "user_info.realname", "post_time" => "blogs.post_time", "level" => "important_blogs.level", "is_hidden" => "blogs.is_hidden", ]), "from blogs", "inner join important_blogs on important_blogs.blog_id = blogs.id", "inner join user_info on blogs.poster = user_info.username", "order by level desc, important_blogs.blog_id desc", ]); $add_announcement_form = new UOJForm('add_announcement'); $add_announcement_form->addInput('blog_id', [ 'div_class' => 'col-auto', 'label' => '博客 ID', 'validator_php' => function ($id, &$vdata) { if (!validateUInt($id)) { return '博客 ID 无效'; } if (!queryBlog($id)) { return '博客不存在'; } $vdata['blog_id'] = $id; return ''; }, ]); $add_announcement_form->addInput('blog_level', [ 'div_class' => 'col-auto', 'label' => '置顶级别', 'default_value' => '0', 'validator_php' => function ($x, &$vdata) { if (!validateUInt($x)) { return '数字不合法'; } if ($x > 3) { return '该级别不存在'; } $vdata['level'] = $x; return ''; }, ]); $add_announcement_form->handle = function (&$vdata) { $blog_id = $vdata['blog_id']; $blog_level = $vdata['level']; if (DB::selectExists([ "select * from important_blogs", "where", [ "blog_id" => $blog_id, ] ])) { DB::update([ "update important_blogs", "set", [ "level" => $blog_level, ], "where", [ "blog_id" => $blog_id, ] ]); } else { DB::insert([ "insert into important_blogs", DB::bracketed_fields(["blog_id", "level"]), "values", DB::tuple([$blog_id, $blog_level]), ]); } }; $add_announcement_form->config['form']['class'] = 'row gy-2 gx-3 align-items-end'; $add_announcement_form->config['submit_container']['class'] = 'col-auto'; $add_announcement_form->config['submit_button']['text'] = '提交'; $add_announcement_form->succ_href = '/super_manage/index#announcements'; $add_announcement_form->runAtServer(); // ========== 倒计时 ========== if (UOJRequest::post('submit-delete_countdown') === 'delete_countdown') { crsf_defend(); $countdown_id = UOJRequest::post('countdown_id'); if (!validateUInt($countdown_id)) { dieWithAlert('删除失败:倒计时 ID 无效'); } DB::delete([ "delete from countdowns", "where", [ "id" => $countdown_id, ] ]); dieWithAlert('删除成功!'); } $countdowns = DB::selectAll([ "select", DB::fields(["id", "title", "end_time"]), "from countdowns", "order by end_time asc", ]); $add_countdown_form = new UOJForm('add_countdown'); $add_countdown_form->addInput('countdown_title', [ 'div_class' => 'col-auto', 'label' => '标题', 'validator_php' => function ($title, &$vdata) { if ($title == '') { return '标题不能为空'; } $vdata['title'] = $title; return ''; }, ]); $add_countdown_form->addInput('countdown_end_time', [ 'div_class' => 'col-auto', 'label' => '结束时间', 'default_value' => UOJTime::$time_now_str, 'validator_php' => function ($end_time, &$vdata) { try { $vdata['end_time'] = new DateTime($end_time); } catch (Exception $e) { return '无效时间格式'; } return ''; }, ]); $add_countdown_form->handle = function (&$vdata) { DB::insert([ "insert into countdowns", DB::bracketed_fields(["title", "end_time"]), "values", DB::tuple([$vdata['title'], $vdata['end_time']->format('Y-m-d H:i:s')]), ]); }; $add_countdown_form->config['form']['class'] = 'row gy-2 gx-3 align-items-end'; $add_countdown_form->config['submit_container']['class'] = 'col-auto'; $add_countdown_form->config['submit_button']['text'] = '添加'; $add_countdown_form->succ_href = '/super_manage/index#countdowns'; $add_countdown_form->runAtServer(); // ========== 常用链接 ========== if (UOJRequest::post('submit-delete_link') === 'delete_link') { crsf_defend(); $link_id = UOJRequest::post('link_id'); if (!validateUInt($link_id)) { dieWithAlert('删除失败:ID 无效'); } DB::delete([ "delete from friend_links", "where", [ "id" => $link_id, ] ]); dieWithAlert('删除成功!'); } $links = DB::selectAll([ "select", DB::fields(["id", "title", "url", "level"]), "from friend_links", "order by level desc, id asc", ]); $add_link_form = new UOJForm('add_link'); $add_link_form->addInput('link_title', [ 'div_class' => 'col-auto', 'label' => '标题', 'validator_php' => function ($title, &$vdata) { if ($title == '') { return '标题不能为空'; } $vdata['title'] = $title; return ''; }, ]); $add_link_form->addInput('link_url', [ 'div_class' => 'col-auto', 'label' => '链接', 'validator_php' => function ($url, &$vdata) { if (!validateURL($url)) { return '链接不合法'; } $vdata['url'] = $url; return ''; }, ]); $add_link_form->addInput('link_level', [ 'div_class' => 'col-auto', 'label' => '权重', 'default_value' => '10', 'validator_php' => function ($level, &$vdata) { if (!validateUInt($level)) { return '数字不合法'; } $vdata['level'] = $level; return ''; }, ]); $add_link_form->handle = function (&$vdata) { DB::insert([ "insert into friend_links", DB::bracketed_fields(["title", "url", "level"]), "values", DB::tuple([$vdata['title'], $vdata['url'], $vdata['level']]), ]); }; $add_link_form->config['form']['class'] = 'row gy-2 gx-3 align-items-end'; $add_link_form->config['submit_container']['class'] = 'col-auto'; $add_link_form->config['submit_button']['text'] = '添加'; $add_link_form->succ_href = '/super_manage/index#links'; $add_link_form->runAtServer(); } elseif ($cur_tab == 'users') { $user_list_cond = []; if (isset($_GET['username']) && $_GET['username'] != "") { $user_list_cond[] = "username like '%" . DB::escape($_GET['username']) . "%'"; } if (isset($_GET['usergroup']) && $_GET['usergroup'] != "") { $user_list_cond[] = "usergroup = '" . DB::escape($_GET['usergroup']) . "'"; } if ($user_list_cond) { $user_list_cond = implode(' and ', $user_list_cond); } else { $user_list_cond = '1'; } $register_form = new UOJForm('register'); $register_form->addInput('new_username', [ 'label' => '用户名', 'validator_php' => function ($username, &$vdata) { if (!validateUsername($username)) { return '用户名不合法'; } if (UOJUser::query($username)) { return '该用户已存在'; } $vdata['username'] = $username; return ''; }, ]); $register_form->addInput('new_password', [ 'div_class' => 'mt-3', 'type' => 'password', 'label' => '密码', 'validator_php' => function ($password, &$vdata) { $vdata['password'] = $password; return ''; }, 'validator_js' => 'validatePassword', ]); $register_form->addInput('new_email', [ 'div_class' => 'mt-3', 'label' => '电子邮件', 'help' => '选填项。填写电子邮件后用户可自主进行密码重置。', 'validator_php' => function ($email, &$vdata) { if (!validateEmail($email)) { return '邮件地址不合法'; } $vdata['email'] = $email; return ''; }, ]); $register_form->addInput('new_realname', [ 'div_class' => 'mt-3', 'label' => '真实姓名', 'help' => '选填项。', 'validator_php' => function ($realname, &$vdata) { $vdata['realname'] = $realname; return ''; }, ]); $register_form->addInput('new_school', [ 'div_class' => 'mt-3', 'label' => '学校名称', 'help' => '选填项。常用名称:石家庄市第二中学石家庄二中实验学校。', 'validator_php' => function ($school, &$vdata) { $vdata['school'] = $school; return ''; }, ]); $register_form->handle = function (&$vdata) { $user = [ 'username' => $vdata['username'], 'realname' => $vdata['realname'], 'school' => $vdata['school'], 'email' => $vdata['email'], 'password' => hash_hmac('md5', $vdata['password'], getPasswordClientSalt()), ]; UOJUser::register($user, ['check_email' => false]); dieWithJsonData(['status' => 'success', 'message' => '']); }; $register_form->setAjaxSubmit(<<runAtServer(); $register_tmp_user_form = new UOJForm('register_tmp_user'); $register_tmp_user_form->addInput('new_tmp_username', [ 'label' => '用户名', 'validator_php' => function ($username, &$vdata) { if (!validateUsername($username)) { return '用户名不合法'; } if (UOJUser::query($username)) { return '该用户已存在'; } $vdata['username'] = $username; return ''; }, ]); $register_tmp_user_form->addInput('new_tmp_password', [ 'div_class' => 'mt-3', 'type' => 'password', 'label' => '密码', 'validator_php' => function ($password, &$vdata) { $vdata['password'] = $password; return ''; }, 'validator_js' => 'validatePassword', ]); $register_tmp_user_form->addInput('new_tmp_email', [ 'div_class' => 'mt-3', 'label' => '电子邮件', 'help' => '选填项。', 'validator_php' => function ($email, &$vdata) { if ($email && !validateEmail($email)) { return '邮件地址不合法'; } $vdata['email'] = $email; return ''; }, ]); $register_tmp_user_form->addInput('new_tmp_realname', [ 'div_class' => 'mt-3', 'label' => '真实姓名', 'help' => '选填项。', 'validator_php' => function ($realname, &$vdata) { $vdata['realname'] = $realname; return ''; }, ]); $register_tmp_user_form->addInput('new_tmp_school', [ 'div_class' => 'mt-3', 'label' => '学校名称', 'help' => '选填项。', 'validator_php' => function ($school, &$vdata) { $vdata['school'] = $school; return ''; }, ]); $register_tmp_user_form->addInput('new_tmp_expiration_time', [ 'div_class' => 'mt-3', 'label' => '过期时间', 'help' => '选填项。默认过期时间为 7 天后。', 'default_value' => UOJTime::time2str((new DateTime())->add(new DateInterval('P7D'))->setTime(0, 0, 0)), 'validator_php' => function ($expiration_time, &$vdata) { try { $vdata['expiration_time'] = new DateTime($expiration_time); } catch (Exception $e) { return '无效时间格式'; } return ''; }, ]); $register_tmp_user_form->handle = function (&$vdata) { $user = [ 'username' => $vdata['username'], 'realname' => $vdata['realname'], 'school' => $vdata['school'], 'email' => $vdata['email'], 'expiration_time' => $vdata['expiration_time']->format('Y-m-d H:i:s'), 'password' => hash_hmac('md5', $vdata['password'], getPasswordClientSalt()), ]; UOJUser::registerTmpAccount($user, ['check_email' => false]); dieWithJsonData(['status' => 'success', 'message' => '']); }; $register_tmp_user_form->setAjaxSubmit(<<runAtServer(); $change_password_form = new UOJForm('change_password'); $change_password_form->addInput('p_username', [ 'label' => '用户名', 'validator_php' => function ($username, &$vdata) { if (!validateUsername($username)) { return '用户名不合法'; } if (!UOJUser::query($username)) { return '用户不存在'; } $vdata['username'] = $username; return ''; }, ]); $change_password_form->addInput('p_password', [ 'div_class' => 'mt-3', 'type' => 'password', 'label' => '密码', 'validator_php' => function ($password, &$vdata) { $vdata['password'] = $password; return ''; }, 'validator_js' => 'validatePassword', ]); $change_password_form->handle = function (&$vdata) { $password = hash_hmac('md5', $vdata['password'], getPasswordClientSalt()); DB::update([ "update user_info", "set", [ "password" => getPasswordToStore($password, $vdata['username']), ], "where", [ "username" => $vdata['username'], ], ]); dieWithJsonData(['status' => 'success', 'message' => '用户 ' . $vdata['username'] . ' 的密码已经被成功重置。']); }; $change_password_form->config['submit_button']['class'] = 'btn btn-secondary'; $change_password_form->config['submit_button']['text'] = '重置密码'; $change_password_form->config['confirm']['smart'] = true; $change_password_form->setAjaxSubmit(<<runAtServer(); $change_usergroup_form = new UOJForm('change_usergroup'); $change_usergroup_form->addInput('username', [ 'label' => '用户名', 'validator_php' => function ($username, &$vdata) { if (!validateUsername($username)) { return '用户名不合法'; } if (!UOJUser::query($username)) { return '用户不存在'; } $vdata['username'] = $username; return ''; }, ]); $change_usergroup_form->addSelect('op_type', [ 'div_class' => 'mt-3', 'label' => '操作类型', 'options' => [ 'banneduser' => '设为封禁用户', 'tempuser' => '设为临时用户', 'normaluser' => '设为普通用户', 'superuser' => '设为超级用户', ], ]); $change_usergroup_form->handle = function ($vdata) { $username = $vdata['username']; $usergroup = ''; switch ($_POST['op_type']) { case 'banneduser': DB::update([ "update user_info", "set", [ "usergroup" => "B", "usertype" => "banned", "expiration_time" => null, ], "where", [ "username" => $username, ], ]); $usergroup = '被封禁的用户,该用户将无法再次登录系统'; break; case 'tempuser': DB::update([ "update user_info", "set", [ "usergroup" => "T", "usertype" => "student", "expiration_time" => DB::now(), ], "where", [ "username" => $username, ], ]); $usergroup = '临时用户,请前往个人信息编辑页面修改过期时间'; break; case 'normaluser': DB::update([ "update user_info", "set", [ "usergroup" => "U", "usertype" => "student", "expiration_time" => null, ], "where", [ "username" => $username, ], ]); $usergroup = '普通用户'; break; case 'superuser': DB::update([ "update user_info", "set", [ "usergroup" => "S", "usertype" => "student", "expiration_time" => null, ], "where", [ "username" => $username, ], ]); $usergroup = '超级用户'; break; } dieWithJsonData(['status' => 'success', 'message' => '用户 ' . $username . ' 现在是 ' . $usergroup . '。']); }; $change_usergroup_form->setAjaxSubmit(<<runAtServer(); $users_default_permissions = UOJContext::getMeta('users_default_permissions'); $update_users_default_permissions_form = new UOJForm('update_users_default_permissions'); $update_users_default_permissions_form->appendHTML(HTML::tag('h3', ['class' => 'h5'], '题目')); $update_users_default_permissions_form->addCheckbox('problems__view', [ 'checked' => $users_default_permissions['problems']['view'], 'label' => '查看题目', 'role' => 'switch', 'help' => '', ]); $update_users_default_permissions_form->addCheckbox('problems__download_testdata', [ 'checked' => $users_default_permissions['problems']['download_testdata'], 'label' => '下载测试数据', 'role' => 'switch', 'help' => '请谨慎开启此权限,以防数据泄露。', ]); $update_users_default_permissions_form->addCheckbox('problems__create', [ 'checked' => $users_default_permissions['problems']['create'], 'label' => '新建题目', 'role' => 'switch', 'help' => '', 'disabled' => true, ]); $update_users_default_permissions_form->addCheckbox('problems__manage', [ 'checked' => $users_default_permissions['problems']['manage'], 'label' => '管理题目', 'role' => 'switch', 'help' => '', 'disabled' => true, ]); $update_users_default_permissions_form->appendHTML(HTML::tag('h3', ['class' => 'h5 mt-3'], '比赛')); $update_users_default_permissions_form->addCheckbox('contests__view', [ 'checked' => $users_default_permissions['contests']['view'], 'label' => '查看比赛', 'role' => 'switch', 'help' => '若用户不具有此权限,则只显示已报名过的比赛列表及详情。', ]); $update_users_default_permissions_form->addCheckbox('contests__register', [ 'checked' => $users_default_permissions['contests']['register'], 'label' => '报名比赛', 'role' => 'switch', 'help' => '', ]); $update_users_default_permissions_form->addCheckbox('contests__create', [ 'checked' => $users_default_permissions['contests']['create'], 'label' => '新建比赛', 'role' => 'switch', 'help' => '', 'disabled' => true, ]); $update_users_default_permissions_form->addCheckbox('contests__start_final_test', [ 'checked' => $users_default_permissions['contests']['start_final_test'], 'label' => '开始比赛最终测试', 'role' => 'switch', 'help' => '', 'disabled' => true, ]); $update_users_default_permissions_form->addCheckbox('contests__manage', [ 'checked' => $users_default_permissions['contests']['manage'], 'label' => '管理比赛', 'role' => 'switch', 'help' => '', 'disabled' => true, ]); $update_users_default_permissions_form->appendHTML(HTML::tag('h3', ['class' => 'h5 mt-3'], '题单')); $update_users_default_permissions_form->addCheckbox('lists__view', [ 'checked' => $users_default_permissions['lists']['view'], 'label' => '查看题单', 'role' => 'switch', 'help' => '', ]); $update_users_default_permissions_form->addCheckbox('lists__create', [ 'checked' => $users_default_permissions['lists']['create'], 'label' => '新建题单', 'role' => 'switch', 'help' => '', 'disabled' => true, ]); $update_users_default_permissions_form->addCheckbox('lists__manage', [ 'checked' => $users_default_permissions['lists']['manage'], 'label' => '管理题单', 'role' => 'switch', 'help' => '', 'disabled' => true, ]); $update_users_default_permissions_form->appendHTML(HTML::tag('h3', ['class' => 'h5 mt-3'], '小组')); $update_users_default_permissions_form->addCheckbox('groups__view', [ 'checked' => $users_default_permissions['groups']['view'], 'label' => '查看小组', 'role' => 'switch', 'help' => '', ]); $update_users_default_permissions_form->addCheckbox('groups__create', [ 'checked' => $users_default_permissions['groups']['create'], 'label' => '新建小组', 'role' => 'switch', 'help' => '', 'disabled' => true, ]); $update_users_default_permissions_form->addCheckbox('groups__manage', [ 'checked' => $users_default_permissions['groups']['manage'], 'label' => '管理小组', 'role' => 'switch', 'help' => '', 'disabled' => true, ]); $update_users_default_permissions_form->appendHTML(HTML::tag('h3', ['class' => 'h5 mt-3'], '博客')); $update_users_default_permissions_form->addCheckbox('blogs__view', [ 'checked' => $users_default_permissions['blogs']['view'], 'label' => '查看博客', 'role' => 'switch', 'help' => '', ]); $update_users_default_permissions_form->addCheckbox('blogs__create', [ 'checked' => $users_default_permissions['blogs']['create'], 'label' => '新建博客', 'role' => 'switch', 'help' => '', ]); $update_users_default_permissions_form->addCheckbox('blogs__manage', [ 'checked' => $users_default_permissions['blogs']['manage'], 'label' => '管理博客', 'role' => 'switch', 'help' => '', 'disabled' => true, ]); $update_users_default_permissions_form->appendHTML(HTML::tag('h3', ['class' => 'h5 mt-3'], '用户')); $update_users_default_permissions_form->addCheckbox('users__view', [ 'checked' => $users_default_permissions['users']['view'], 'label' => '查看用户', 'role' => 'switch', 'help' => '若用户不具有此权限,则不能查看他人的个人资料。', ]); $update_users_default_permissions_form->addCheckbox('users__upload_image', [ 'checked' => $users_default_permissions['users']['upload_image'], 'label' => '上传图片', 'role' => 'switch', 'help' => '若用户不具有此权限,则不能使用图床功能。', ]); $update_users_default_permissions_form->setAjaxSubmit(<<config['confirm']['text'] = '你确定要修改所有用户的默认权限吗?'; $update_users_default_permissions_form->handle = function () { $new_permissions = [ 'problems' => [ 'view' => isset($_POST['problems__view']), 'download_testdata' => isset($_POST['problems__download_testdata']), 'create' => false, // isset($_POST['problems__create']), 'manage' => false, // isset($_POST['problems__manage']), ], 'contests' => [ 'view' => isset($_POST['contests__view']), 'register' => isset($_POST['contests__register']), 'create' => false, // isset($_POST['contests__create']), 'start_final_test' => false, // isset($_POST['contests__start_final_test']), 'manage' => false, // isset($_POST['contests__manage']), ], 'lists' => [ 'view' => isset($_POST['lists__view']), 'create' => false, // isset($_POST['lists__create']), 'manage' => false, // isset($_POST['lists__manage']), ], 'groups' => [ 'view' => isset($_POST['groups__view']), 'create' => false, // isset($_POST['groups__create']), 'manage' => false, // isset($_POST['groups__manage']), ], 'blogs' => [ 'view' => isset($_POST['blogs__view']), 'create' => isset($_POST['blogs__create']), 'manage' => false, // isset($_POST['blogs__manage']), ], 'users' => [ 'view' => isset($_POST['users__view']), 'upload_image' => isset($_POST['users__upload_image']), ], ]; UOJContext::setMeta('users_default_permissions', $new_permissions); dieWithJsonData(['status' => 'success', 'message' => '']); }; $update_users_default_permissions_form->runAtServer(); } elseif ($cur_tab == 'submissions') { } elseif ($cur_tab == 'custom_test') { requireLib('hljs'); $submissions_pag = new Paginator([ 'col_names' => ['*'], 'table_name' => 'custom_test_submissions', 'cond' => '1', 'tail' => 'order by id desc', 'page_len' => 10 ]); $custom_test_deleter = new UOJForm('custom_test_deleter'); $custom_test_deleter->addInput('last', [ 'div_class' => 'col-auto', 'label' => '删除末尾记录', 'default_value' => '5', 'validator_php' => function ($x, &$vdata) { if (!validateUInt($x)) { return '不合法'; } $vdata['last'] = $x; return ''; }, ]); $custom_test_deleter->handle = function (&$vdata) { $all = DB::selectAll("select * from custom_test_submissions order by id asc limit {$vdata['last']}"); foreach ($all as $submission) { $content = json_decode($submission['content'], true); unlink(UOJContext::storagePath() . $content['file_name']); } DB::delete("delete from custom_test_submissions order by id asc limit {$vdata['last']}"); }; $custom_test_deleter->config['form']['class'] = 'row gy-2 gx-3 align-items-end'; $custom_test_deleter->config['submit_container']['class'] = 'col-auto'; $custom_test_deleter->runAtServer(); } elseif ($cur_tab == 'judger') { $judger_adder = new UOJBs4Form('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->submit_button_config['align'] = 'compressed'; $judger_adder->runAtServer(); $judger_deleter = new UOJBs4Form('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->submit_button_config['align'] = 'compressed'; $judger_deleter->runAtServer(); } elseif ($cur_tab == 'image_hosting') { if (isset($_POST['submit-delete_image']) && $_POST['submit-delete_image'] == 'delete_image') { crsf_defend(); $image_id = $_POST['image_id']; if (!validateUInt($image_id)) { dieWithAlert('删除失败:图片 ID 无效'); } if (!($image = DB::selectFirst("SELECT * from users_images where id = $image_id"))) { dieWithAlert('删除失败:图片不存在'); } unlink(UOJContext::storagePath() . $result['path']); DB::delete("DELETE FROM users_images WHERE id = $image_id"); dieWithAlert('删除成功!'); } $change_user_image_total_size_limit_form = new UOJBs4Form('change_user_image_total_size_limit'); $change_user_image_total_size_limit_form->submit_button_config['align'] = 'compressed'; $change_user_image_total_size_limit_form->addInput( 'change_user_image_total_size_limit_username', 'text', '用户名', '', function ($x, &$vdata) { if (!validateUsername($x)) { return '用户名不合法'; } if (!UOJUser::query($x)) { return '用户不存在'; } $vdata['username'] = $x; return ''; }, null ); $change_user_image_total_size_limit_form->addInput( 'change_user_image_total_size_limit_limit', 'text', '存储限制(单位:Byte)', '104857600', function ($x, &$vdata) { if (!validateUInt($x, 10)) { return '限制不合法'; } if (intval($x) > 2147483648) { return '限制不能大于 2 GB'; } $vdata['limit'] = $x; return ''; }, null ); $change_user_image_total_size_limit_form->handle = function (&$vdata) { DB::update([ "update user_info", "set", [ 'extra' => DB::json_set( 'extra', '$.image_hosting.total_size_limit', $vdata['limit'], ), ], "where", ["username" => $vdata['username']] ]); }; $change_user_image_total_size_limit_form->runAtServer(); } ?>

添加/修改公告
printHTML(); ?>
添加倒计时
printHTML(); ?>
用户名 学校 用户类别 注册时间 过期时间 操作 EOD, function ($row) { echo ''; echo '', UOJUser::getLink($row), ''; echo '', HTML::escape($row['school']), ''; echo ''; switch ($row['usergroup']) { case 'S': echo UOJLocale::get('user::super user'); break; case 'B': echo UOJLocale::get('user::banned user'); break; case 'T': echo UOJLocale::get('user::tmp user'); break; default: echo UOJLocale::get('user::normal user'); break; } echo ', ', HTML::tag('small', ['class' => 'text-muted'], UOJLocale::get('user::' . $row['usertype']) ?: HTML::escape($row['usertype'])); echo ''; echo '', $row['register_time'], ''; echo '', $row['expiration_time'], ''; echo '', '编辑', ''; echo ''; }, [ 'page_len' => 20, 'div_classes' => ['table-responsive'], 'table_classes' => ['table', 'align-middle'], ], ); ?>
printHTML() ?>
注意事项
  • 用户名推荐格式为年级 + 姓名全拼,如 2022 级的张三同学可以设置为 2022zhangsan。对于外校学生,推荐格式为学校名称缩写 + 姓名拼音首字母,如山大附中的赵锦熙同学可以设置为 sdfzzjx)。
  • 请提醒用户及时修改初始密码,以免账号被盗导致教学资源流出。请勿设置过于简单的初始密码。
  • 我们推荐在创建账号时输入号主的电子邮件地址以便后期发生忘记密码等情况时进行验证。
  • 创建账号后可以在「修改个人信息」页面中的「特权」选项卡为用户分配权限。特别地,如果该用户是外校学生,那么您可能需要禁用其 所有权限,并为其手动报名比赛。
  • 对于外校学生,更推荐分发 临时账号
printHTML() ?>
注意事项
  • 用户名推荐格式为年级 + 姓名全拼,如 2022 级的张三同学可以设置为 2022zhangsan。对于外校学生,推荐格式为学校名称缩写 + 姓名拼音首字母,如山大附中的赵锦熙同学可以设置为 sdfzzjx)。
  • 请提醒用户及时修改初始密码,以免账号被盗导致教学资源流出。请勿设置过于简单的初始密码。
  • 我们推荐在创建账号时输入号主的电子邮件地址以便后期发生忘记密码等情况时进行验证。
  • 临时账号不具有任何权限,只能查看、参加已经用户报名了的比赛。创建账号后可以在「修改个人信息」页面中的「特权」选项卡为用户分配权限。特别地,如果该用户是外校学生,那么您可能需要禁用其 所有权限,并为其手动报名比赛。
printHTML() ?>
注意事项
  • 在为用户重置密码前请核对对方身份以免被骗。
  • 请勿设置过于简单的密码。
  • 请提醒用户在登录后及时修改初始密码。
printHTML() ?>
注意事项
  • 用户被封禁后将不能再次登录系统。
  • 将用户修改为临时用户后,请前往个人信息编辑页面修改过期时间。
  • 将当前用户移除管理权限后将无法再次访问本页面。
  • 在修改用户类别前请仔细核对用户名以免产生不必要的麻烦。
  • 如需为用户设置题目上传者、题目管理员等权限,请前往对应用户的个人资料编辑页面,点击「特权」选项卡修改。
printHTML() ?>
注意事项
  • 此处修改的是 所有用户 的默认权限。
  • 如果某用户的 A 权限启闭状态与为该用户修改 A 权限时的默认权限状态不同,则在此处修改用户默认权限后该用户的 A 权限状态不会受到影响。
  • 对于每一个权限分类,若用户不具有新建项目权限,则只能对现有内容进行管理。
  • 如需为单个用户设置增加/移除特定权限,请前往对应用户的个人资料编辑页面,点击「特权」选项卡修改。
  • 出于安全考虑,部分权限不能被设置为默认权限。
  • 关于各项权限的详细解释,请查看 权限管理 文档。

测评失败的提交记录

'', 'table_config' => [ 'div_classes' => ['card', 'mb-3', 'table-responsive'], 'table_classes' => ['table', 'uoj-table', 'mb-0', 'text-center'] ] ], $myUser ); ?>
get() as $submission) : ?> isEmpty()) : ?>
ID 题目 ID 提交者 提交时间 测评时间
# #
pagination() ?>
删除末尾的 n 条记录
printHTML() ?>

评测机列表

评测机名称 密码 IP EOD, function ($row) { echo << {$row['judger_name']} {$row['password']} {$row['ip']} EOD; }, [ 'page_len' => 10, 'div_classes' => ['card', 'mb-3', 'table-responsive'], 'table_classes' => ['table', 'uoj-table', 'mb-0'], ] ); ?>
添加评测机
printHTML(); ?>
删除评测机
printHTML(); ?>
上传者 预览 文件大小 上传时间 操作 EOD, function ($row) { $user_link = UOJUser::getLink($row['uploader']); if ($row['size'] < 1024 * 512) { $size = strval(round($row['size'] * 1.0 / 1024, 1)) . ' KB'; } else { $size = strval(round($row['size'] * 1.0 / 1024 / 1024, 1)) . ' MB'; } $token = crsf_token(); echo << $user_link $size {$row['upload_time']}
EOD; }, [ 'page_len' => 20, 'div_classes' => ['card', 'mb-3', 'table-responsive'], 'table_classes' => ['table', 'uoj-table', 'mb-0'], ] ); ?>
修改用户图床空间上限
printHTML() ?>