;window.location = window.location.origin + window.location.pathname + (window.location.search.length ? window.location.search + "&" : "?") + "_=" + (+new Date()) + window.location.hash;'); if (!isSuperUser($myUser)) { become403Page(); } $cur_tab = isset($_GET['tab']) ? $_GET['tab'] : 'index'; $tabs_info = [ 'index' => [ '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", ], 'image_hosting' => [ 'name' => '图床管理', 'url' => "/super_manage/image_hosting", ], ]; if (!isset($tabs_info[$cur_tab])) { become404Page(); } if ($cur_tab == 'index') { // ========== 公告 ========== if (isset($_POST['submit-delete_announcement']) && $_POST['submit-delete_announcement'] == 'delete_announcement') { crsf_defend(); $blog_id = $_POST['blog_id']; if (!validateUInt($blog_id)) { die('' . SCRIPT_REFRESH_AS_GET); } DB::delete("DELETE FROM important_blogs WHERE blog_id = {$blog_id}"); die('' . SCRIPT_REFRESH_AS_GET); } $announcements = DB::selectAll("SELECT blogs.id as id, blogs.title as title, blogs.poster as poster, user_info.realname as realname, blogs.post_time as post_time, important_blogs.level as level, blogs.is_hidden as is_hidden FROM important_blogs INNER JOIN 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', 'text', '博客 ID', '', function($id, &$vdata) { if (!validateUInt($id)) { return '博客 ID 无效'; } if (!queryBlog($id)) { return '博客不存在'; } $vdata['blog_id'] = $id; return ''; }, null ); $add_announcement_form->addInput('blog_level', 'text', '置顶级别', '0', function ($x, &$vdata) { if (!validateUInt($x)) { return '数字不合法'; } if ($x > 3) { return '该级别不存在'; } $vdata['level'] = $x; return ''; }, null ); $add_announcement_form->handle = function(&$vdata) { $blog_id = $vdata['blog_id']; $blog_level = $vdata['level']; if (DB::selectFirst("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 (blog_id, level) values ({$blog_id}, {$blog_level})"); } }; $add_announcement_form->submit_button_config['align'] = 'compressed'; $add_announcement_form->submit_button_config['text'] = '提交'; $add_announcement_form->succ_href = '/super_manage/index#announcements'; $add_announcement_form->runAtServer(); // ========== 倒计时 ========== if (isset($_POST['submit-delete_countdown']) && $_POST['submit-delete_countdown'] == 'delete_countdown') { crsf_defend(); $countdown_id = $_POST['countdown_id']; if (!validateUInt($countdown_id)) { die('' . SCRIPT_REFRESH_AS_GET); } DB::delete("DELETE FROM countdowns WHERE id = {$countdown_id}"); die('' . SCRIPT_REFRESH_AS_GET); } $countdowns = DB::selectAll("SELECT id, title, endtime FROM countdowns ORDER BY endtime ASC"); $add_countdown_form = new UOJForm('add_countdown'); $add_countdown_form->addInput('countdown_title', 'text', '标题', '', function($title, &$vdata) { if ($title == '') { return '标题不能为空'; } $vdata['title'] = $title; return ''; }, null ); $add_countdown_form->addInput('countdown_endtime', 'text', '结束时间', date("Y-m-d H:i:s"), function($endtime, &$vdata) { try { $vdata['endtime'] = new DateTime($endtime); } catch (Exception $e) { return '无效时间格式'; } return ''; }, null ); $add_countdown_form->handle = function(&$vdata) { $esc_title = DB::escape($vdata['title']); $esc_endtime = DB::escape($vdata['endtime']->format('Y-m-d H:i:s')); DB::insert("INSERT INTO countdowns (title, endtime) VALUES ('{$esc_title}', '{$esc_endtime}')"); }; $add_countdown_form->submit_button_config['align'] = 'compressed'; $add_countdown_form->submit_button_config['text'] = '添加'; $add_countdown_form->succ_href = '/super_manage/index#countdowns'; $add_countdown_form->runAtServer(); // ========== 常用链接 ========== if (isset($_POST['submit-delete_link']) && $_POST['submit-delete_link'] == 'delete_link') { crsf_defend(); $item_id = $_POST['item_id']; if (!validateUInt($item_id)) { die('' . SCRIPT_REFRESH_AS_GET); } DB::delete("DELETE FROM links WHERE id = {$item_id}"); die('' . SCRIPT_REFRESH_AS_GET); } $links = DB::selectAll("SELECT `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', 'text', '标题', '', function($title, &$vdata) { if ($title == '') { return '标题不能为空'; } $vdata['title'] = $title; return ''; }, null ); $add_link_form->addInput('link_url', 'text', '链接', '', function($url, &$vdata) { if (!validateURL($url)) { return '链接不合法'; } $vdata['url'] = $url; return ''; }, null ); $add_link_form->addInput('link_level', 'text', '权重', '10', function($level, &$vdata) { if (!validateUInt($level)) { return '数字不合法'; } $vdata['level'] = $level; return ''; }, null ); $add_link_form->handle = function(&$vdata) { $esc_title = DB::escape($vdata['title']); $esc_url = DB::escape($vdata['url']); $level = $vdata['level']; DB::insert("INSERT INTO friend_links (title, url, level) VALUES ('{$esc_title}', '{$esc_url}', {$level})"); }; $add_link_form->submit_button_config['align'] = 'compressed'; $add_link_form->submit_button_config['text'] = '添加'; $add_link_form->succ_href = '/super_manage/index#links'; $add_link_form->runAtServer(); } elseif ($cur_tab == 'users') { // } ?>

$tab): ?>
添加/修改公告
printHTML(); ?>
添加倒计时
printHTML(); ?>
1
2