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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,4 +1,8 @@
<?php
if (!Auth::check()) {
becomeMsgPage(UOJLocale::get('need login'));
}
become404Page();
?>
<?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 if (UOJContext::user()['username'] != 'vfleaking'): ?>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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