feat(web): force login

This commit is contained in:
Baoshuo Ren 2022-03-17 12:00:03 +08:00
parent 9a41bf1872
commit 2e7da82db9
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A
39 changed files with 157 additions and 22 deletions

View File

@ -1,4 +1,8 @@
<?php <?php
if (!Auth::check()) {
becomeMsgPage(UOJLocale::get('need login'));
}
requirePHPLib('form'); requirePHPLib('form');
if (!isSuperUser($myUser)) { if (!isSuperUser($myUser)) {
@ -52,4 +56,4 @@
$time_form->printHTML(); $time_form->printHTML();
?> ?>
</div> </div>
<?php echoUOJPageFooter() ?> <?php echoUOJPageFooter() ?>

View File

@ -1,4 +1,8 @@
<?php <?php
if (!Auth::check()) {
becomeMsgPage(UOJLocale::get('need login'));
}
requirePHPLib('form'); requirePHPLib('form');
function echoBlogCell($blog) { function echoBlogCell($blog) {

View File

@ -1,4 +1,8 @@
<?php <?php
if (!Auth::check()) {
becomeMsgPage(UOJLocale::get('need login'));
}
if (!validateUInt($_GET['id']) || !($blog = queryBlog($_GET['id']))) { if (!validateUInt($_GET['id']) || !($blog = queryBlog($_GET['id']))) {
become404Page(); become404Page();
} }

View File

@ -1,5 +1,9 @@
<?php <?php
requirePHPLib('form'); requirePHPLib('form');
if (!Auth::check()) {
becomeMsgPage(UOJLocale::get('need login'));
}
function echoBlogCell($blog) { function echoBlogCell($blog) {
echo '<tr>'; echo '<tr>';

View File

@ -1,5 +1,9 @@
<?php <?php
requirePHPLib('form'); requirePHPLib('form');
if (!Auth::check()) {
becomeMsgPage(UOJLocale::get('need login'));
}
if (!validateUInt($_GET['id']) || !($contest = queryContest($_GET['id']))) { if (!validateUInt($_GET['id']) || !($contest = queryContest($_GET['id']))) {
become404Page(); become404Page();

View File

@ -1,6 +1,10 @@
<?php <?php
requirePHPLib('form'); requirePHPLib('form');
if (!Auth::check()) {
becomeMsgPage(UOJLocale::get('need login'));
}
if (!validateUInt($_GET['id']) || !($contest = queryContest($_GET['id']))) { if (!validateUInt($_GET['id']) || !($contest = queryContest($_GET['id']))) {
become404Page(); become404Page();
} }

View File

@ -1,6 +1,10 @@
<?php <?php
requirePHPLib('form'); requirePHPLib('form');
if (!Auth::check()) {
becomeMsgPage(UOJLocale::get('need login'));
}
if (!validateUInt($_GET['id']) || !($contest = queryContest($_GET['id']))) { if (!validateUInt($_GET['id']) || !($contest = queryContest($_GET['id']))) {
become404Page(); become404Page();
} }

View File

@ -1,11 +1,12 @@
<?php <?php
requirePHPLib('form'); requirePHPLib('form');
if (!validateUInt($_GET['id']) || !($contest = queryContest($_GET['id']))) { if (!validateUInt($_GET['id']) || !($contest = queryContest($_GET['id']))) {
become404Page(); become404Page();
} }
genMoreContestInfo($contest); genMoreContestInfo($contest);
if ($myUser == null) { if (!Auth::check()) {
redirectToLogin(); redirectToLogin();
} elseif (hasContestPermission($myUser, $contest) || hasRegistered($myUser, $contest) || $contest['cur_progress'] != CONTEST_NOT_STARTED) { } elseif (hasContestPermission($myUser, $contest) || hasRegistered($myUser, $contest) || $contest['cur_progress'] != CONTEST_NOT_STARTED) {
redirectTo('/contests'); redirectTo('/contests');

View File

@ -1,6 +1,10 @@
<?php <?php
requirePHPLib('form'); requirePHPLib('form');
if (!Auth::check()) {
becomeMsgPage(UOJLocale::get('need login'));
}
$upcoming_contest_name = null; $upcoming_contest_name = null;
$upcoming_contest_href = null; $upcoming_contest_href = null;
$rest_second = 1000000; $rest_second = 1000000;

View File

@ -1,5 +1,10 @@
<?php <?php
requirePHPLib('judger'); requirePHPLib('judger');
if (!Auth::check()) {
becomeMsgPage(UOJLocale::get('need login'));
}
switch ($_GET['type']) { switch ($_GET['type']) {
case 'problem': case 'problem':
if (!validateUInt($_GET['id']) || !($problem = queryProblemBrief($_GET['id']))) { if (!validateUInt($_GET['id']) || !($problem = queryProblemBrief($_GET['id']))) {
@ -44,4 +49,4 @@
header("X-Sendfile: $file_name"); header("X-Sendfile: $file_name");
header("Content-type: $mimetype"); header("Content-type: $mimetype");
header("Content-Disposition: attachment; filename=$download_name"); header("Content-Disposition: attachment; filename=$download_name");
?> ?>

View File

@ -1,7 +1,12 @@
<?php <?php
requireLib('shjs'); requireLib('shjs');
requireLib('mathjax'); requireLib('mathjax');
echoUOJPageHeader(UOJLocale::get('help'))
if (!Auth::check()) {
becomeMsgPage(UOJLocale::get('need login'));
}
echoUOJPageHeader(UOJLocale::get('help'));
?> ?>
<article> <article>
<header> <header>

View File

@ -1,6 +1,10 @@
<?php <?php
requirePHPLib('form'); requirePHPLib('form');
if (!Auth::check()) {
becomeMsgPage(UOJLocale::get('need login'));
}
if (!validateUInt($_GET['id']) || !($hack = queryHack($_GET['id']))) { if (!validateUInt($_GET['id']) || !($hack = queryHack($_GET['id']))) {
become404Page(); become404Page();
} }

View File

@ -1,4 +1,8 @@
<?php <?php
if (!Auth::check()) {
becomeMsgPage(UOJLocale::get('need login'));
}
$conds = array(); $conds = array();
$q_problem_id = isset($_GET['problem_id']) && validateUInt($_GET['problem_id']) ? $_GET['problem_id'] : null; $q_problem_id = isset($_GET['problem_id']) && validateUInt($_GET['problem_id']) ? $_GET['problem_id'] : null;

View File

@ -1,5 +1,9 @@
<?php <?php
if (!Auth::check()) {
becomeMsgPage(UOJLocale::get('need login'));
}
$REQUIRE_LIB['shjs'] = ""; $REQUIRE_LIB['shjs'] = "";
$REQUIRE_LIB['dracula'] = ""; $REQUIRE_LIB['dracula'] = "";
$REQUIRE_LIB['base64'] = ""; $REQUIRE_LIB['base64'] = "";
@ -129,4 +133,4 @@ echoUOJPageHeader("图可视化");
</script> </script>
<?php <?php
echoUOJPageFooter(); echoUOJPageFooter();

View File

@ -2,8 +2,8 @@
requirePHPLib('form'); requirePHPLib('form');
requirePHPLib('judger'); requirePHPLib('judger');
if ($myUser == null) { if (!Auth::check()) {
becomeMsgPage("请先登录!"); becomeMsgPage(UOJLocale::get('need login'));
} }
@ -34,4 +34,4 @@ $paste_form->succ_href = '/paste';
$paste_form->runAtServer(); $paste_form->runAtServer();
echoUOJPageHeader("Paste!"); echoUOJPageHeader("Paste!");
$paste_form->printHTML(); $paste_form->printHTML();
echoUOJPageFooter(); echoUOJPageFooter();

View File

@ -1,5 +1,9 @@
<?php <?php
if (!Auth::check()) {
becomeMsgPage(UOJLocale::get('need login'));
}
$paste_id = $_GET['rand_str_id']; $paste_id = $_GET['rand_str_id'];
$paste = DB::selectFirst("select * from pastes where `index` = '".DB::escape($paste_id)."'"); $paste = DB::selectFirst("select * from pastes where `index` = '".DB::escape($paste_id)."'");
@ -9,4 +13,4 @@ if (!$paste) {
$REQUIRE_LIB['shjs'] = ""; $REQUIRE_LIB['shjs'] = "";
echoUOJPageHeader("Paste!"); echoUOJPageHeader("Paste!");
echoPasteContent($paste); echoPasteContent($paste);
echoUOJPageFooter(); echoUOJPageFooter();

View File

@ -1,7 +1,11 @@
<?php <?php
requirePHPLib('form'); requirePHPLib('form');
requirePHPLib('judger'); requirePHPLib('judger');
if (!Auth::check()) {
becomeMsgPage(UOJLocale::get('need login'));
}
if (!validateUInt($_GET['id']) || !($problem = queryProblemBrief($_GET['id']))) { if (!validateUInt($_GET['id']) || !($problem = queryProblemBrief($_GET['id']))) {
become404Page(); become404Page();
} }

View File

@ -2,6 +2,10 @@
requirePHPLib('form'); requirePHPLib('form');
requirePHPLib('judger'); requirePHPLib('judger');
requirePHPLib('data'); requirePHPLib('data');
if (!Auth::check()) {
becomeMsgPage(UOJLocale::get('need login'));
}
if (!validateUInt($_GET['id']) || !($problem = queryProblemBrief($_GET['id']))) { if (!validateUInt($_GET['id']) || !($problem = queryProblemBrief($_GET['id']))) {
become404Page(); become404Page();

View File

@ -1,5 +1,9 @@
<?php <?php
requirePHPLib('form'); requirePHPLib('form');
if (!Auth::check()) {
becomeMsgPage(UOJLocale::get('need login'));
}
if (!validateUInt($_GET['id']) || !($problem = queryProblemBrief($_GET['id']))) { if (!validateUInt($_GET['id']) || !($problem = queryProblemBrief($_GET['id']))) {
become404Page(); become404Page();

View File

@ -2,6 +2,10 @@
requirePHPLib('form'); requirePHPLib('form');
requirePHPLib('judger'); requirePHPLib('judger');
requirePHPLib('data'); requirePHPLib('data');
if (!Auth::check()) {
becomeMsgPage(UOJLocale::get('need login'));
}
if (isSuperUser($myUser)) { if (isSuperUser($myUser)) {
$new_problem_form = new UOJForm('new_problem'); $new_problem_form = new UOJForm('new_problem');

View File

@ -1,6 +1,10 @@
<?php <?php
requirePHPLib('form'); requirePHPLib('form');
if (!Auth::check()) {
becomeMsgPage(UOJLocale::get('need login'));
}
if (!validateUInt($_GET['id']) || !($problem = queryProblemBrief($_GET['id']))) { if (!validateUInt($_GET['id']) || !($problem = queryProblemBrief($_GET['id']))) {
become404Page(); become404Page();
} }

View File

@ -1,4 +1,8 @@
<?php <?php
if (!Auth::check()) {
becomeMsgPage(UOJLocale::get('need login'));
}
if (!validateUInt($_GET['id']) || !($problem = queryProblemBrief($_GET['id']))) { if (!validateUInt($_GET['id']) || !($problem = queryProblemBrief($_GET['id']))) {
become404Page(); become404Page();
} }

View File

@ -1,4 +1,8 @@
<?php <?php
if (!Auth::check()) {
becomeMsgPage(UOJLocale::get('need login'));
}
become404Page(); become404Page();
?> ?>
<?php echoUOJPageHeader('比赛排行榜') ?> <?php echoUOJPageHeader('比赛排行榜') ?>

View File

@ -1,4 +1,10 @@
<?php requirePHPLib('form') ?> <?php
requirePHPLib('form');
if (!Auth::check()) {
becomeMsgPage(UOJLocale::get('need login'));
}
?>
<?php echoUOJPageHeader('关于我') ?> <?php echoUOJPageHeader('关于我') ?>
<?php if (UOJContext::user()['username'] != 'vfleaking'): ?> <?php if (UOJContext::user()['username'] != 'vfleaking'): ?>

View File

@ -1,5 +1,9 @@
<?php <?php
requirePHPLib('form'); requirePHPLib('form');
if (!Auth::check()) {
becomeMsgPage(UOJLocale::get('need login'));
}
$blogs_cond = "poster = '".UOJContext::userid()."' and is_draft = false"; $blogs_cond = "poster = '".UOJContext::userid()."' and is_draft = false";
if (!UOJContext::hasBlogPermission()) { if (!UOJContext::hasBlogPermission()) {

View File

@ -1,6 +1,10 @@
<?php <?php
requirePHPLib('form'); requirePHPLib('form');
if (!Auth::check()) {
becomeMsgPage(UOJLocale::get('need login'));
}
if (!isset($_GET['id']) || !validateUInt($_GET['id']) || !($blog = queryBlog($_GET['id'])) || !UOJContext::isHis($blog)) { if (!isset($_GET['id']) || !validateUInt($_GET['id']) || !($blog = queryBlog($_GET['id'])) || !UOJContext::isHis($blog)) {
become404Page(); become404Page();
} }

View File

@ -1,5 +1,9 @@
<?php <?php
requirePHPLib('form'); requirePHPLib('form');
if (!Auth::check()) {
becomeMsgPage(UOJLocale::get('need login'));
}
if (!UOJContext::hasBlogPermission()) { if (!UOJContext::hasBlogPermission()) {
become403Page(); become403Page();

View File

@ -1,6 +1,10 @@
<?php <?php
requirePHPLib('form'); requirePHPLib('form');
if (!Auth::check()) {
becomeMsgPage(UOJLocale::get('need login'));
}
if (!UOJContext::hasBlogPermission()) { if (!UOJContext::hasBlogPermission()) {
become403Page(); become403Page();
} }

View File

@ -1,4 +1,8 @@
<?php <?php
if (!Auth::check()) {
becomeMsgPage(UOJLocale::get('need login'));
}
$blogs_pag = new Paginator(array( $blogs_pag = new Paginator(array(
'col_names' => array('*'), 'col_names' => array('*'),
'table_name' => 'blogs', 'table_name' => 'blogs',

View File

@ -1,5 +1,9 @@
<?php <?php
requirePHPLib('form'); requirePHPLib('form');
if (!Auth::check()) {
becomeMsgPage(UOJLocale::get('need login'));
}
if (!isset($_GET['id']) || !validateUInt($_GET['id']) || !($blog = queryBlog($_GET['id'])) || !UOJContext::isHisSlide($blog)) { if (!isset($_GET['id']) || !validateUInt($_GET['id']) || !($blog = queryBlog($_GET['id'])) || !UOJContext::isHisSlide($blog)) {
become404Page(); become404Page();

View File

@ -1,5 +1,9 @@
<?php <?php
requirePHPLib('form'); requirePHPLib('form');
if (!Auth::check()) {
becomeMsgPage(UOJLocale::get('need login'));
}
if (!UOJContext::hasBlogPermission()) { if (!UOJContext::hasBlogPermission()) {
become403Page(); become403Page();

View File

@ -1,6 +1,10 @@
<?php <?php
requirePHPLib('form'); requirePHPLib('form');
requirePHPLib('judger'); requirePHPLib('judger');
if (!Auth::check()) {
becomeMsgPage(UOJLocale::get('need login'));
}
if (!validateUInt($_GET['id']) || !($submission = querySubmission($_GET['id']))) { if (!validateUInt($_GET['id']) || !($submission = querySubmission($_GET['id']))) {
become404Page(); become404Page();

View File

@ -1,7 +1,7 @@
<?php <?php
if (!Auth::check()) { if (!Auth::check()) {
become403Page(); becomeMsgPage(UOJLocale::get('need login'));
} }
if (!is_array($_GET['get'])) { if (!is_array($_GET['get'])) {

View File

@ -1,4 +1,8 @@
<?php <?php
if (!Auth::check()) {
becomeMsgPage(UOJLocale::get('need login'));
}
$conds = array(); $conds = array();
$q_problem_id = isset($_GET['problem_id']) && validateUInt($_GET['problem_id']) ? $_GET['problem_id'] : null; $q_problem_id = isset($_GET['problem_id']) && validateUInt($_GET['problem_id']) ? $_GET['problem_id'] : null;

View File

@ -1,4 +1,8 @@
<?php <?php
if (!Auth::check()) {
becomeMsgPage(UOJLocale::get('need login'));
}
$username = $_GET['username']; $username = $_GET['username'];
?> ?>
<?php if (validateUsername($username) && ($user = queryUser($username))): ?> <?php if (validateUsername($username) && ($user = queryUser($username))): ?>

View File

@ -1,5 +1,5 @@
<?php <?php
if ($myUser == null) { if (!Auth::check()) {
redirectToLogin(); redirectToLogin();
} }

View File

@ -1,5 +1,5 @@
<?php <?php
if ($myUser == null) { if (!Auth::check()) {
redirectToLogin(); redirectToLogin();
} }

View File

@ -4,6 +4,7 @@ return [
'login' => 'Login', 'login' => 'Login',
'register' => 'Register', 'register' => 'Register',
'logout' => 'Logout', 'logout' => 'Logout',
'need login' => 'You need to login first',
'my profile' => 'My Profile', 'my profile' => 'My Profile',
'private message' => 'Private Message', 'private message' => 'Private Message',
'system message' => 'System Message', 'system message' => 'System Message',

View File

@ -4,6 +4,7 @@ return [
'login' => '登录', 'login' => '登录',
'register' => '注册', 'register' => '注册',
'logout' => '登出', 'logout' => '登出',
'need login' => '您需要登录后才能继续',
'my profile' => '个人信息', 'my profile' => '个人信息',
'private message' => '私信', 'private message' => '私信',
'system message' => '系统消息', 'system message' => '系统消息',