Reformated with php-cs-fixer

This commit is contained in:
Leo Lu 2020-06-25 20:41:16 +08:00 committed by billchenchina
parent 8ca70fc87c
commit b8f82be3dc
31 changed files with 333 additions and 281 deletions

View File

@ -1,8 +1,7 @@
<?php <?php
requirePHPLib('form'); requirePHPLib('form');
if (!isSuperUser($myUser)) if (!isSuperUser($myUser)) {
{
become403Page(); become403Page();
} }
$time_form = new UOJForm('time'); $time_form = new UOJForm('time');

View File

@ -4,20 +4,16 @@
} }
function handlePost() { function handlePost() {
global $myUser; global $myUser;
if (!isset($_POST['old_password'])) if (!isset($_POST['old_password'])) {
{
return '无效表单'; return '无效表单';
} }
$old_password = $_POST['old_password']; $old_password = $_POST['old_password'];
if (!validatePassword($old_password) || !checkPassword($myUser, $old_password)) if (!validatePassword($old_password) || !checkPassword($myUser, $old_password)) {
{
return "失败:密码错误。"; return "失败:密码错误。";
} }
if ($_POST['ptag']) if ($_POST['ptag']) {
{
$password = $_POST['password']; $password = $_POST['password'];
if (!validatePassword($password)) if (!validatePassword($password)) {
{
return "失败:无效密码。"; return "失败:无效密码。";
} }
$password = getPasswordToStore($password, $myUser['username']); $password = getPasswordToStore($password, $myUser['username']);
@ -25,27 +21,23 @@
} }
$email = $_POST['email']; $email = $_POST['email'];
if (!validateEmail($email)) if (!validateEmail($email)) {
{
return "失败:无效电子邮箱。"; return "失败:无效电子邮箱。";
} }
$esc_email = DB::escape($email); $esc_email = DB::escape($email);
DB::update("update user_info set email = '$esc_email' where username = '{$myUser['username']}'"); DB::update("update user_info set email = '$esc_email' where username = '{$myUser['username']}'");
if ($_POST['Qtag']) if ($_POST['Qtag']) {
{
$qq = $_POST['qq']; $qq = $_POST['qq'];
if (!validateQQ($qq)) if (!validateQQ($qq)) {
{
return "失败无效QQ。"; return "失败无效QQ。";
} }
$esc_qq = DB::escape($qq); $esc_qq = DB::escape($qq);
DB::update("update user_info set qq = '$esc_qq' where username = '{$myUser['username']}'"); DB::update("update user_info set qq = '$esc_qq' where username = '{$myUser['username']}'");
} } else {
else
DB::update("update user_info set QQ = NULL where username = '{$myUser['username']}'"); DB::update("update user_info set QQ = NULL where username = '{$myUser['username']}'");
if ($_POST['sex'] == "U" || $_POST['sex'] == 'M' || $_POST['sex'] == 'F') }
{ if ($_POST['sex'] == "U" || $_POST['sex'] == 'M' || $_POST['sex'] == 'F') {
$sex = $_POST['sex']; $sex = $_POST['sex'];
$esc_sex = DB::escape($sex); $esc_sex = DB::escape($sex);
DB::update("update user_info set sex = '$esc_sex' where username = '{$myUser['username']}'"); DB::update("update user_info set sex = '$esc_sex' where username = '{$myUser['username']}'");

View File

@ -1,13 +1,17 @@
<?php <?php
function validateZan() { function validateZan() {
if (!validateUInt($_POST['id'])) if (!validateUInt($_POST['id'])) {
return false; return false;
if (!validateInt($_POST['delta'])) }
if (!validateInt($_POST['delta'])) {
return false; return false;
if ($_POST['delta'] != 1 && $_POST['delta'] != -1) }
if ($_POST['delta'] != 1 && $_POST['delta'] != -1) {
return false; return false;
if ($_POST['type'] != 'B' && $_POST['type'] != 'BC' && $_POST['type'] != 'P' && $_POST['type'] != 'C') }
if ($_POST['type'] != 'B' && $_POST['type'] != 'BC' && $_POST['type'] != 'P' && $_POST['type'] != 'C') {
return false; return false;
}
return true; return true;
} }
if (!validateZan()) { if (!validateZan()) {

View File

@ -48,8 +48,7 @@
if ($_FILES["problem_data_file"]["error"] > 0) { if ($_FILES["problem_data_file"]["error"] > 0) {
$errmsg = "Error: ".$_FILES["problem_data_file"]["error"]; $errmsg = "Error: ".$_FILES["problem_data_file"]["error"];
becomeMsgPage('<div>' . $errmsg . '</div><a href="/problem/'.$problem['id'].'/manage/data">返回</a>'); becomeMsgPage('<div>' . $errmsg . '</div><a href="/problem/'.$problem['id'].'/manage/data">返回</a>');
} } else {
else{
$zip_mime_types = array('application/zip', 'application/x-zip', 'application/x-zip-compressed'); $zip_mime_types = array('application/zip', 'application/x-zip', 'application/x-zip-compressed');
if (in_array($_FILES["problem_data_file"]["type"], $zip_mime_types)) { if (in_array($_FILES["problem_data_file"]["type"], $zip_mime_types)) {
$up_filename="/tmp/".rand(0,100000000)."data.zip"; $up_filename="/tmp/".rand(0,100000000)."data.zip";
@ -226,7 +225,9 @@ EOD
} }
if (!isset($data_files)) { if (!isset($data_files)) {
$this->data_files = array_filter(scandir($data_dir), function($x){return $x !== '.' && $x !== '..' && $x !== 'problem.conf';}); $this->data_files = array_filter(scandir($data_dir), function($x) {
return $x !== '.' && $x !== '..' && $x !== 'problem.conf';
});
natsort($this->data_files); natsort($this->data_files);
array_unshift($this->data_files, 'problem.conf'); array_unshift($this->data_files, 'problem.conf');
} else { } else {
@ -309,7 +310,9 @@ EOD
global $data_dir; global $data_dir;
global $problem; global $problem;
$allow_files = array_flip(array_filter(scandir($data_dir), function($x){return $x !== '.' && $x !== '..';})); $allow_files = array_flip(array_filter(scandir($data_dir), function($x) {
return $x !== '.' && $x !== '..';
}));
$getDisplaySrcFunc = function($name) use ($allow_files) { $getDisplaySrcFunc = function($name) use ($allow_files) {
return function() use ($name, $allow_files) { return function() use ($name, $allow_files) {

View File

@ -34,10 +34,11 @@
$esc_email = DB::escape($email); $esc_email = DB::escape($email);
$svn_pw = uojRandString(10); $svn_pw = uojRandString(10);
if (!DB::selectCount("SELECT COUNT(*) FROM user_info")) if (!DB::selectCount("SELECT COUNT(*) FROM user_info")) {
DB::query("insert into user_info (username, email, password, svn_password, register_time, usergroup) values ('$username', '$esc_email', '$password', '$svn_pw', now(), 'S')"); DB::query("insert into user_info (username, email, password, svn_password, register_time, usergroup) values ('$username', '$esc_email', '$password', '$svn_pw', now(), 'S')");
else } else {
DB::query("insert into user_info (username, email, password, svn_password, register_time) values ('$username', '$esc_email', '$password', '$svn_pw', now())"); DB::query("insert into user_info (username, email, password, svn_password, register_time) values ('$username', '$esc_email', '$password', '$svn_pw', now())");
}
return "欢迎你!" . $username . ",你已成功注册。"; return "欢迎你!" . $username . ",你已成功注册。";
} }

View File

@ -45,5 +45,4 @@ call_user_func(function() { // to prevent variable scope leak
Route::any("$prefix/post/{id}/delete", '/subdomain/blog/blog_delete.php'); Route::any("$prefix/post/{id}/delete", '/subdomain/blog/blog_delete.php');
} }
); );
}); });

View File

@ -46,16 +46,24 @@
$blog_link_contests = new UOJForm('blog_link_contests'); $blog_link_contests = new UOJForm('blog_link_contests');
$blog_link_contests->addInput('blog_id', 'text', '博客ID', '', $blog_link_contests->addInput('blog_id', 'text', '博客ID', '',
function ($x) { function ($x) {
if (!validateUInt($x)) return 'ID不合法'; if (!validateUInt($x)) {
if (!queryBlog($x)) return '博客不存在'; return 'ID不合法';
}
if (!queryBlog($x)) {
return '博客不存在';
}
return ''; return '';
}, },
null null
); );
$blog_link_contests->addInput('contest_id', 'text', '比赛ID', '', $blog_link_contests->addInput('contest_id', 'text', '比赛ID', '',
function ($x) { function ($x) {
if (!validateUInt($x)) return 'ID不合法'; if (!validateUInt($x)) {
if (!queryContest($x)) return '比赛不存在'; return 'ID不合法';
}
if (!queryContest($x)) {
return '比赛不存在';
}
return ''; return '';
}, },
null null
@ -87,13 +95,14 @@
$config[$n] = $row; $config[$n] = $row;
} }
if ($_POST['op-type'] == 'del') { if ($_POST['op-type'] == 'del') {
for ($i = 0; $i < $n; $i++) for ($i = 0; $i < $n; $i++) {
if ($config[$i][1] == $blog_id) { if ($config[$i][1] == $blog_id) {
$config[$i] = $config[$n - 1]; $config[$i] = $config[$n - 1];
unset($config[$n - 1]); unset($config[$n - 1]);
break; break;
} }
} }
}
$all_config['links'] = $config; $all_config['links'] = $config;
$str = json_encode($all_config); $str = json_encode($all_config);
@ -105,16 +114,24 @@
$blog_link_index = new UOJForm('blog_link_index'); $blog_link_index = new UOJForm('blog_link_index');
$blog_link_index->addInput('blog_id2', 'text', '博客ID', '', $blog_link_index->addInput('blog_id2', 'text', '博客ID', '',
function ($x) { function ($x) {
if (!validateUInt($x)) return 'ID不合法'; if (!validateUInt($x)) {
if (!queryBlog($x)) return '博客不存在'; return 'ID不合法';
}
if (!queryBlog($x)) {
return '博客不存在';
}
return ''; return '';
}, },
null null
); );
$blog_link_index->addInput('blog_level', 'text', '置顶级别(删除不用填)', '0', $blog_link_index->addInput('blog_level', 'text', '置顶级别(删除不用填)', '0',
function ($x) { function ($x) {
if (!validateUInt($x)) return '数字不合法'; if (!validateUInt($x)) {
if ($x > 3) return '该级别不存在'; return '数字不合法';
}
if ($x > 3) {
return '该级别不存在';
}
return ''; return '';
}, },
null null
@ -367,8 +384,7 @@ EOD;
'tail' => 'order by id asc', 'tail' => 'order by id asc',
'page_len' => 5 'page_len' => 5
)); ));
foreach ($submissions_pag->get() as $submission) foreach ($submissions_pag->get() as $submission) {
{
$problem = queryProblemBrief($submission['problem_id']); $problem = queryProblemBrief($submission['problem_id']);
$submission_result = json_decode($submission['result'], true); $submission_result = json_decode($submission['result'], true);
echo '<dl class="dl-horizontal">'; echo '<dl class="dl-horizontal">';

View File

@ -13,8 +13,7 @@
if ($esc_sex == "M") { if ($esc_sex == "M") {
$esc_sex=""; $esc_sex="";
$col_sex="color:blue"; $col_sex="color:blue";
} } elseif ($esc_sex == "F") {
else if($esc_sex == "F") {
$esc_sex=""; $esc_sex="";
$col_sex="color:red"; $col_sex="color:red";
} else { } else {

View File

@ -39,7 +39,9 @@
} }
$ret[$msg['sender']] = array($msg['send_time'], ($msg['read_time'] == null)); $ret[$msg['sender']] = array($msg['send_time'], ($msg['read_time'] == null));
} else { } else {
if (isset($ret[$msg['receiver']])) continue; if (isset($ret[$msg['receiver']])) {
continue;
}
$ret[$msg['receiver']] = array($msg['send_time'], 0); $ret[$msg['receiver']] = array($msg['send_time'], 0);
} }
} }
@ -47,7 +49,9 @@
foreach ($ret as $name => $con) { foreach ($ret as $name => $con) {
$res[] = [$con[0], $con[1], $name]; $res[] = [$con[0], $con[1], $name];
} }
usort($res, function($a, $b) { return -strcmp($a[0], $b[0]); }); usort($res, function($a, $b) {
return -strcmp($a[0], $b[0]);
});
return json_encode($res); return json_encode($res);
} }

View File

@ -35,11 +35,13 @@ function calcRating($standings, $K = 400) {
$weight[$i] = pow(7, $rating[$i] / $DELTA); $weight[$i] = pow(7, $rating[$i] / $DELTA);
} }
$exp = array_fill(0, $n, 0); $exp = array_fill(0, $n, 0);
for ($i = 0; $i < $n; ++$i) for ($i = 0; $i < $n; ++$i) {
for ($j = 0; $j < $n; ++$j) for ($j = 0; $j < $n; ++$j) {
if ($j != $i) { if ($j != $i) {
$exp[$i] += $weight[$i] / ($weight[$i] + $weight[$j]); $exp[$i] += $weight[$i] / ($weight[$i] + $weight[$j]);
} }
}
}
$new_rating = array(); $new_rating = array();
for ($i = 0; $i < $n; $i++) { for ($i = 0; $i < $n; $i++) {

View File

@ -178,7 +178,9 @@
throw new UOJProblemConfException("syntax error"); throw new UOJProblemConfException("syntax error");
} }
$this->allow_files = array_flip(array_filter(scandir($this->upload_dir), function($x){return $x !== '.' && $x !== '..';})); $this->allow_files = array_flip(array_filter(scandir($this->upload_dir), function($x) {
return $x !== '.' && $x !== '..';
}));
$zip_file = new ZipArchive(); $zip_file = new ZipArchive();
if ($zip_file->open("{$this->prepare_dir}/download.zip", ZipArchive::CREATE) !== true) { if ($zip_file->open("{$this->prepare_dir}/download.zip", ZipArchive::CREATE) !== true) {

View File

@ -21,7 +21,8 @@
public function __construct($form_name) { public function __construct($form_name) {
$this->form_name = $form_name; $this->form_name = $form_name;
$this->succ_href = $_SERVER['REQUEST_URI']; $this->succ_href = $_SERVER['REQUEST_URI'];
$this->handle = function(&$vdata){}; $this->handle = function(&$vdata) {
};
$this->run_at_server_handler["check-{$this->form_name}"] = function() { $this->run_at_server_handler["check-{$this->form_name}"] = function() {
die(json_encode($this->validateAtServer())); die(json_encode($this->validateAtServer()));
@ -724,7 +725,9 @@ EOD;
function newZipSubmissionForm($form_name, $requirement, $zip_file_name_gen, $handle) { function newZipSubmissionForm($form_name, $requirement, $zip_file_name_gen, $handle) {
$form = new UOJForm($form_name); $form = new UOJForm($form_name);
$name = "zip_ans_{$form_name}"; $name = "zip_ans_{$form_name}";
$text = UOJLocale::get('problems::zip file upload introduction', join(array_map(function($req){return $req['file_name'];}, $requirement), ', ')); $text = UOJLocale::get('problems::zip file upload introduction', join(array_map(function($req) {
return $req['file_name'];
}, $requirement), ', '));
$browse_text = UOJLocale::get('browse'); $browse_text = UOJLocale::get('browse');
$html = <<<EOD $html = <<<EOD
<div id="div-{$name}"> <div id="div-{$name}">

View File

@ -121,8 +121,9 @@ function getLongTablePageRawUri($page) {
parse_str($query_string, $param); parse_str($query_string, $param);
$param['page'] = $page; $param['page'] = $page;
if ($page == 1) if ($page == 1) {
unset($param['page']); unset($param['page']);
}
if ($param) { if ($param) {
return $path . '?' . http_build_query($param); return $path . '?' . http_build_query($param);
@ -249,10 +250,12 @@ function echoSubmission($submission, $config, $user) {
} }
echo '</td>'; echo '</td>';
} }
if (!isset($config['used_time_hidden'])) if (!isset($config['used_time_hidden'])) {
echo '<td>', $used_time_str, '</td>'; echo '<td>', $used_time_str, '</td>';
if (!isset($config['used_memory_hidden'])) }
if (!isset($config['used_memory_hidden'])) {
echo '<td>', $used_memory_str, '</td>'; echo '<td>', $used_memory_str, '</td>';
}
echo '<td>', '<a href="/submission/', $submission['id'], '">', $submission['language'], '</a>', '</td>'; echo '<td>', '<a href="/submission/', $submission['id'], '">', $submission['language'], '</a>', '</td>';
@ -263,10 +266,12 @@ function echoSubmission($submission, $config, $user) {
} }
echo '<td>', $size_str, '</td>'; echo '<td>', $size_str, '</td>';
if (!isset($config['submit_time_hidden'])) if (!isset($config['submit_time_hidden'])) {
echo '<td><small>', $submission['submit_time'], '</small></td>'; echo '<td><small>', $submission['submit_time'], '</small></td>';
if (!isset($config['judge_time_hidden'])) }
if (!isset($config['judge_time_hidden'])) {
echo '<td><small>', $submission['judge_time'], '</small></td>'; echo '<td><small>', $submission['judge_time'], '</small></td>';
}
echo '</tr>'; echo '</tr>';
if ($show_status_details) { if ($show_status_details) {
echo '<tr id="', "status_details_{$submission['id']}", '" class="info">'; echo '<tr id="', "status_details_{$submission['id']}", '" class="info">';
@ -282,24 +287,32 @@ function echoSubmissionsListOnlyOne($submission, $config, $user) {
echo '<table class="table table-bordered table-text-center">'; echo '<table class="table table-bordered table-text-center">';
echo '<thead>'; echo '<thead>';
echo '<tr>'; echo '<tr>';
if (!isset($config['id_hidden'])) if (!isset($config['id_hidden'])) {
echo '<th>ID</th>'; echo '<th>ID</th>';
if (!isset($config['problem_hidden'])) }
if (!isset($config['problem_hidden'])) {
echo '<th>'.UOJLocale::get('problems::problem').'</th>'; echo '<th>'.UOJLocale::get('problems::problem').'</th>';
if (!isset($config['submitter_hidden'])) }
if (!isset($config['submitter_hidden'])) {
echo '<th>'.UOJLocale::get('problems::submitter').'</th>'; echo '<th>'.UOJLocale::get('problems::submitter').'</th>';
if (!isset($config['result_hidden'])) }
if (!isset($config['result_hidden'])) {
echo '<th>'.UOJLocale::get('problems::result').'</th>'; echo '<th>'.UOJLocale::get('problems::result').'</th>';
if (!isset($config['used_time_hidden'])) }
if (!isset($config['used_time_hidden'])) {
echo '<th>'.UOJLocale::get('problems::used time').'</th>'; echo '<th>'.UOJLocale::get('problems::used time').'</th>';
if (!isset($config['used_memory_hidden'])) }
if (!isset($config['used_memory_hidden'])) {
echo '<th>'.UOJLocale::get('problems::used memory').'</th>'; echo '<th>'.UOJLocale::get('problems::used memory').'</th>';
}
echo '<th>'.UOJLocale::get('problems::language').'</th>'; echo '<th>'.UOJLocale::get('problems::language').'</th>';
echo '<th>'.UOJLocale::get('problems::file size').'</th>'; echo '<th>'.UOJLocale::get('problems::file size').'</th>';
if (!isset($config['submit_time_hidden'])) if (!isset($config['submit_time_hidden'])) {
echo '<th>'.UOJLocale::get('problems::submit time').'</th>'; echo '<th>'.UOJLocale::get('problems::submit time').'</th>';
if (!isset($config['judge_time_hidden'])) }
if (!isset($config['judge_time_hidden'])) {
echo '<th>'.UOJLocale::get('problems::judge time').'</th>'; echo '<th>'.UOJLocale::get('problems::judge time').'</th>';
}
echo '</tr>'; echo '</tr>';
echo '</thead>'; echo '</thead>';
echo '<tbody>'; echo '<tbody>';
@ -429,8 +442,7 @@ function echoSubmissionContent($submission, $requirement) {
echo '</div>'; echo '</div>';
echo '<div class="card-footer">'.$footer_text.'</div>'; echo '<div class="card-footer">'.$footer_text.'</div>';
echo '</div>'; echo '</div>';
} } elseif ($req['type'] == "text") {
else if ($req['type'] == "text") {
$file_content = $zip_file->getFromName("{$req['file_name']}", 504); $file_content = $zip_file->getFromName("{$req['file_name']}", 504);
$file_content = strOmit($file_content, 500); $file_content = strOmit($file_content, 500);
$file_content = uojTextEncode($file_content, array('allow_CR' => true, 'html_escape' => true)); $file_content = uojTextEncode($file_content, array('allow_CR' => true, 'html_escape' => true));
@ -476,8 +488,7 @@ class JudgementDetailsPrinter {
echo '<div id="', $this->name, '_details_accordion">'; echo '<div id="', $this->name, '_details_accordion">';
if ($this->styler->show_small_tip) { if ($this->styler->show_small_tip) {
echo '<div class="text-right text-muted">', '小提示:点击横条可展开更详细的信息', '</div>'; echo '<div class="text-right text-muted">', '小提示:点击横条可展开更详细的信息', '</div>';
} } elseif ($this->styler->ioi_contest_is_running) {
elseif ($this->styler->ioi_contest_is_running) {
echo '<div class="text-right text-muted">', 'IOI赛制比赛中不支持显示详细信息', '</div>'; echo '<div class="text-right text-muted">', 'IOI赛制比赛中不支持显示详细信息', '</div>';
} }
$this->_print_c($node); $this->_print_c($node);
@ -774,10 +785,12 @@ function echoHackDetails($hack_details, $name) {
function echoHack($hack, $config, $user) { function echoHack($hack, $config, $user) {
$problem = queryProblemBrief($hack['problem_id']); $problem = queryProblemBrief($hack['problem_id']);
echo '<tr>'; echo '<tr>';
if (!isset($config['id_hidden'])) if (!isset($config['id_hidden'])) {
echo '<td><a href="/hack/', $hack['id'], '">#', $hack['id'], '</a></td>'; echo '<td><a href="/hack/', $hack['id'], '">#', $hack['id'], '</a></td>';
if (!isset($config['submission_hidden'])) }
if (!isset($config['submission_hidden'])) {
echo '<td><a href="/submission/', $hack['submission_id'], '">#', $hack['submission_id'], '</a></td>'; echo '<td><a href="/submission/', $hack['submission_id'], '">#', $hack['submission_id'], '</a></td>';
}
if (!isset($config['problem_hidden'])) { if (!isset($config['problem_hidden'])) {
if ($hack['contest_id']) { if ($hack['contest_id']) {
echo '<td>', getContestProblemLink($problem, $hack['contest_id'], '!id_and_title'), '</td>'; echo '<td>', getContestProblemLink($problem, $hack['contest_id'], '!id_and_title'), '</td>';
@ -785,12 +798,13 @@ function echoHack($hack, $config, $user) {
echo '<td>', getProblemLink($problem, '!id_and_title'), '</td>'; echo '<td>', getProblemLink($problem, '!id_and_title'), '</td>';
} }
} }
if (!isset($config['hacker_hidden'])) if (!isset($config['hacker_hidden'])) {
echo '<td>', getUserLink($hack['hacker']), '</td>'; echo '<td>', getUserLink($hack['hacker']), '</td>';
if (!isset($config['owner_hidden'])) }
if (!isset($config['owner_hidden'])) {
echo '<td>', getUserLink($hack['owner']), '</td>'; echo '<td>', getUserLink($hack['owner']), '</td>';
if (!isset($config['result_hidden'])) }
{ if (!isset($config['result_hidden'])) {
if ($hack['judge_time'] == null) { if ($hack['judge_time'] == null) {
echo '<td><a href="/hack/', $hack['id'], '">Waiting</a></td>'; echo '<td><a href="/hack/', $hack['id'], '">Waiting</a></td>';
} elseif ($hack['success'] == null) { } elseif ($hack['success'] == null) {
@ -800,13 +814,15 @@ function echoHack($hack, $config, $user) {
} else { } else {
echo '<td><a href="/hack/', $hack['id'], '" class="uoj-status" data-success="0"><strong>Failed.</strong></a></td>'; echo '<td><a href="/hack/', $hack['id'], '" class="uoj-status" data-success="0"><strong>Failed.</strong></a></td>';
} }
} } else {
else
echo '<td>Hidden</td>'; echo '<td>Hidden</td>';
if (!isset($config['submit_time_hidden'])) }
if (!isset($config['submit_time_hidden'])) {
echo '<td>', $hack['submit_time'], '</td>'; echo '<td>', $hack['submit_time'], '</td>';
if (!isset($config['judge_time_hidden'])) }
if (!isset($config['judge_time_hidden'])) {
echo '<td>', $hack['judge_time'], '</td>'; echo '<td>', $hack['judge_time'], '</td>';
}
echo '</tr>'; echo '</tr>';
} }
function echoHackListOnlyOne($hack, $config, $user) { function echoHackListOnlyOne($hack, $config, $user) {
@ -814,22 +830,30 @@ function echoHackListOnlyOne($hack, $config, $user) {
echo '<table class="table table-bordered table-text-center">'; echo '<table class="table table-bordered table-text-center">';
echo '<thead>'; echo '<thead>';
echo '<tr>'; echo '<tr>';
if (!isset($config['id_hidden'])) if (!isset($config['id_hidden'])) {
echo '<th>ID</th>'; echo '<th>ID</th>';
if (!isset($config['submission_id_hidden'])) }
if (!isset($config['submission_id_hidden'])) {
echo '<th>'.UOJLocale::get('problems::submission id').'</th>'; echo '<th>'.UOJLocale::get('problems::submission id').'</th>';
if (!isset($config['problem_hidden'])) }
if (!isset($config['problem_hidden'])) {
echo '<th>'.UOJLocale::get('problems::problem').'</th>'; echo '<th>'.UOJLocale::get('problems::problem').'</th>';
if (!isset($config['hacker_hidden'])) }
if (!isset($config['hacker_hidden'])) {
echo '<th>'.UOJLocale::get('problems::hacker').'</th>'; echo '<th>'.UOJLocale::get('problems::hacker').'</th>';
if (!isset($config['owner_hidden'])) }
if (!isset($config['owner_hidden'])) {
echo '<th>'.UOJLocale::get('problems::owner').'</th>'; echo '<th>'.UOJLocale::get('problems::owner').'</th>';
if (!isset($config['result_hidden'])) }
if (!isset($config['result_hidden'])) {
echo '<th>'.UOJLocale::get('problems::result').'</th>'; echo '<th>'.UOJLocale::get('problems::result').'</th>';
if (!isset($config['submit_time_hidden'])) }
if (!isset($config['submit_time_hidden'])) {
echo '<th>'.UOJLocale::get('problems::submit time').'</th>'; echo '<th>'.UOJLocale::get('problems::submit time').'</th>';
if (!isset($config['judge_time_hidden'])) }
if (!isset($config['judge_time_hidden'])) {
echo '<th>'.UOJLocale::get('problems::judge time').'</th>'; echo '<th>'.UOJLocale::get('problems::judge time').'</th>';
}
echo '</tr>'; echo '</tr>';
echo '</thead>'; echo '</thead>';
echo '<tbody>'; echo '<tbody>';

View File

@ -10,12 +10,15 @@ function hasProblemPermission($user, $problem) {
return DB::selectFirst("select * from problems_permissions where username = '{$user['username']}' and problem_id = {$problem['id']}") != null; return DB::selectFirst("select * from problems_permissions where username = '{$user['username']}' and problem_id = {$problem['id']}") != null;
} }
function hasViewPermission($str,$user,$problem,$submission) { function hasViewPermission($str,$user,$problem,$submission) {
if($str=='ALL') if ($str=='ALL') {
return true; return true;
if($str=='ALL_AFTER_AC') }
if ($str=='ALL_AFTER_AC') {
return hasAC($user,$problem); return hasAC($user,$problem);
if($str=='SELF') }
if ($str=='SELF') {
return $submission['submitter']==$user['username']; return $submission['submitter']==$user['username'];
}
return false; return false;
} }

View File

@ -47,8 +47,9 @@ class Paginator {
parse_str($query_string, $param); parse_str($query_string, $param);
$param['page'] = $page; $param['page'] = $page;
if ($page == 1) if ($page == 1) {
unset($param['page']); unset($param['page']);
}
if ($param) { if ($param) {
return $path . '?' . http_build_query($param); return $path . '?' . http_build_query($param);