feat(web): throw 403 when need login

This commit is contained in:
Baoshuo Ren 2022-04-02 18:01:26 +08:00
parent 0af24b52ac
commit 1021dae8c0
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A
32 changed files with 35 additions and 35 deletions

View File

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

View File

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

View File

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

View File

@ -2,7 +2,7 @@
requirePHPLib('form');
if (!Auth::check()) {
becomeMsgPage(UOJLocale::get('need login'));
become403Page(UOJLocale::get('need login'));
}
function echoBlogCell($blog) {

View File

@ -2,7 +2,7 @@
requirePHPLib('form');
if (!Auth::check()) {
becomeMsgPage(UOJLocale::get('need login'));
become403Page(UOJLocale::get('need login'));
}
if (!validateUInt($_GET['id']) || !($contest = queryContest($_GET['id']))) {

View File

@ -2,7 +2,7 @@
requirePHPLib('form');
if (!Auth::check()) {
becomeMsgPage(UOJLocale::get('need login'));
become403Page(UOJLocale::get('need login'));
}
if (!validateUInt($_GET['id']) || !($contest = queryContest($_GET['id']))) {

View File

@ -2,7 +2,7 @@
requirePHPLib('form');
if (!Auth::check()) {
becomeMsgPage(UOJLocale::get('need login'));
become403Page(UOJLocale::get('need login'));
}
if (!validateUInt($_GET['id']) || !($contest = queryContest($_GET['id']))) {

View File

@ -2,7 +2,7 @@
requirePHPLib('form');
if (!Auth::check()) {
becomeMsgPage(UOJLocale::get('need login'));
become403Page(UOJLocale::get('need login'));
}
$upcoming_contest_name = null;

View File

@ -2,7 +2,7 @@
requirePHPLib('judger');
if (!Auth::check()) {
becomeMsgPage(UOJLocale::get('need login'));
become403Page(UOJLocale::get('need login'));
}
switch ($_GET['type']) {

View File

@ -3,7 +3,7 @@
requireLib('mathjax');
if (!Auth::check()) {
becomeMsgPage(UOJLocale::get('need login'));
become403Page(UOJLocale::get('need login'));
}
echoUOJPageHeader(UOJLocale::get('help'));

View File

@ -2,7 +2,7 @@
requirePHPLib('form');
if (!Auth::check()) {
becomeMsgPage(UOJLocale::get('need login'));
become403Page(UOJLocale::get('need login'));
}
if (!validateUInt($_GET['id']) || !($hack = queryHack($_GET['id']))) {

View File

@ -1,6 +1,6 @@
<?php
if (!Auth::check()) {
becomeMsgPage(UOJLocale::get('need login'));
become403Page(UOJLocale::get('need login'));
}
$conds = array();

View File

@ -3,7 +3,7 @@
requirePHPLib('judger');
if (!Auth::check()) {
becomeMsgPage(UOJLocale::get('need login'));
become403Page(UOJLocale::get('need login'));
}
if (!validateUInt($_GET['id']) || !($problem = queryProblemBrief($_GET['id']))) {

View File

@ -4,7 +4,7 @@
requirePHPLib('data');
if (!Auth::check()) {
becomeMsgPage(UOJLocale::get('need login'));
become403Page(UOJLocale::get('need login'));
}
if (!validateUInt($_GET['id']) || !($problem = queryProblemBrief($_GET['id']))) {

View File

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

View File

@ -4,7 +4,7 @@
requirePHPLib('data');
if (!Auth::check()) {
becomeMsgPage(UOJLocale::get('need login'));
become403Page(UOJLocale::get('need login'));
}
if (isSuperUser($myUser) || isProblemManager($myUser) || isProblemUploader($myUser)) {

View File

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

View File

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

View File

@ -1,6 +1,6 @@
<?php
if (!Auth::check()) {
becomeMsgPage(UOJLocale::get('need login'));
become403Page(UOJLocale::get('need login'));
}
if (isset($_GET['type']) && $_GET['type'] == 'accepted') {

View File

@ -2,7 +2,7 @@
requirePHPLib('form');
if (!Auth::check()) {
becomeMsgPage(UOJLocale::get('need login'));
become403Page(UOJLocale::get('need login'));
}
?>
<?php echoUOJPageHeader('关于我') ?>

View File

@ -2,7 +2,7 @@
requirePHPLib('form');
if (!Auth::check()) {
becomeMsgPage(UOJLocale::get('need login'));
become403Page(UOJLocale::get('need login'));
}
$blogs_cond = "poster = '".UOJContext::userid()."'";

View File

@ -2,7 +2,7 @@
requirePHPLib('form');
if (!Auth::check()) {
becomeMsgPage(UOJLocale::get('need login'));
become403Page(UOJLocale::get('need login'));
}
if (!isset($_GET['id']) || !validateUInt($_GET['id']) || !($blog = queryBlog($_GET['id'])) || !UOJContext::isHis($blog)) {

View File

@ -2,7 +2,7 @@
requirePHPLib('form');
if (!Auth::check()) {
becomeMsgPage(UOJLocale::get('need login'));
become403Page(UOJLocale::get('need login'));
}
if (!UOJContext::hasBlogPermission()) {

View File

@ -2,7 +2,7 @@
requirePHPLib('form');
if (!Auth::check()) {
becomeMsgPage(UOJLocale::get('need login'));
become403Page(UOJLocale::get('need login'));
}
if (!UOJContext::hasBlogPermission()) {

View File

@ -1,6 +1,6 @@
<?php
if (!Auth::check()) {
becomeMsgPage(UOJLocale::get('need login'));
become403Page(UOJLocale::get('need login'));
}
$blogs_pag = new Paginator(array(

View File

@ -2,7 +2,7 @@
requirePHPLib('form');
if (!Auth::check()) {
becomeMsgPage(UOJLocale::get('need login'));
become403Page(UOJLocale::get('need login'));
}
if (!isset($_GET['id']) || !validateUInt($_GET['id']) || !($blog = queryBlog($_GET['id'])) || !UOJContext::isHisSlide($blog)) {

View File

@ -2,7 +2,7 @@
requirePHPLib('form');
if (!Auth::check()) {
becomeMsgPage(UOJLocale::get('need login'));
become403Page(UOJLocale::get('need login'));
}
if (!UOJContext::hasBlogPermission()) {

View File

@ -3,7 +3,7 @@
requirePHPLib('judger');
if (!Auth::check()) {
becomeMsgPage(UOJLocale::get('need login'));
become403Page(UOJLocale::get('need login'));
}
if (!validateUInt($_GET['id']) || !($submission = querySubmission($_GET['id']))) {

View File

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

View File

@ -1,6 +1,6 @@
<?php
if (!Auth::check()) {
becomeMsgPage(UOJLocale::get('need login'));
become403Page(UOJLocale::get('need login'));
}
$conds = array();

View File

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

View File

@ -65,13 +65,13 @@ function becomeMsgPage($msg, $title = '消息') {
die();
}
}
function become404Page() {
function become404Page($message = '未找到页面。') {
header($_SERVER['SERVER_PROTOCOL'] . " 404 Not Found", true, 404);
becomeMsgPage('<div class="text-center"><div style="font-size:233px">404</div><p>唔……未找到该页面……你是从哪里点进来的……&gt;_&lt;……</p></div>', '404');
becomeMsgPage('<div class="text-center"><div style="font-size:150px">404</div><p>' . $message . '</p></div>', '404');
}
function become403Page() {
function become403Page($message = '访问被拒绝,您可能需要适当的权限以访问此页面。') {
header($_SERVER['SERVER_PROTOCOL'] . " 403 Forbidden", true, 403);
becomeMsgPage('<div class="text-center"><div style="font-size:233px">403</div><p>禁止入内! T_T</p></div>', '403');
becomeMsgPage('<div class="text-center"><div style="font-size:150px">403</div><p>' . $message . '</p></div>', '403');
}
function getUserLink($username) {