mirror of
https://github.com/renbaoshuo/S2OJ.git
synced 2024-11-08 13:38:41 +00:00
Reformated with php-cs-fixer
This commit is contained in:
parent
8ca70fc87c
commit
b8f82be3dc
@ -11,7 +11,7 @@ $handlers = [
|
||||
if (func_num_args() != 1) {
|
||||
die("php cli.php upgrade:up <name>\n");
|
||||
}
|
||||
Upgrader::transaction(function() use($name) {
|
||||
Upgrader::transaction(function() use ($name) {
|
||||
Upgrader::up($name);
|
||||
});
|
||||
die("finished!\n");
|
||||
@ -20,7 +20,7 @@ $handlers = [
|
||||
if (func_num_args() != 1) {
|
||||
die("php cli.php upgrade:down <name>\n");
|
||||
}
|
||||
Upgrader::transaction(function() use($name) {
|
||||
Upgrader::transaction(function() use ($name) {
|
||||
Upgrader::down($name);
|
||||
});
|
||||
die("finished!\n");
|
||||
@ -29,7 +29,7 @@ $handlers = [
|
||||
if (func_num_args() != 1) {
|
||||
die("php cli.php upgrade:refresh <name>\n");
|
||||
}
|
||||
Upgrader::transaction(function() use($name) {
|
||||
Upgrader::transaction(function() use ($name) {
|
||||
Upgrader::refresh($name);
|
||||
});
|
||||
die("finished!\n");
|
||||
@ -38,7 +38,7 @@ $handlers = [
|
||||
if (func_num_args() != 1) {
|
||||
die("php cli.php upgrade:remove <name>\n");
|
||||
}
|
||||
Upgrader::transaction(function() use($name) {
|
||||
Upgrader::transaction(function() use ($name) {
|
||||
Upgrader::remove($name);
|
||||
});
|
||||
die("finished!\n");
|
||||
|
@ -1,8 +1,7 @@
|
||||
<?php
|
||||
requirePHPLib('form');
|
||||
|
||||
if (!isSuperUser($myUser))
|
||||
{
|
||||
if (!isSuperUser($myUser)) {
|
||||
become403Page();
|
||||
}
|
||||
$time_form = new UOJForm('time');
|
||||
|
@ -4,20 +4,16 @@
|
||||
}
|
||||
function handlePost() {
|
||||
global $myUser;
|
||||
if (!isset($_POST['old_password']))
|
||||
{
|
||||
if (!isset($_POST['old_password'])) {
|
||||
return '无效表单';
|
||||
}
|
||||
$old_password = $_POST['old_password'];
|
||||
if (!validatePassword($old_password) || !checkPassword($myUser, $old_password))
|
||||
{
|
||||
if (!validatePassword($old_password) || !checkPassword($myUser, $old_password)) {
|
||||
return "失败:密码错误。";
|
||||
}
|
||||
if ($_POST['ptag'])
|
||||
{
|
||||
if ($_POST['ptag']) {
|
||||
$password = $_POST['password'];
|
||||
if (!validatePassword($password))
|
||||
{
|
||||
if (!validatePassword($password)) {
|
||||
return "失败:无效密码。";
|
||||
}
|
||||
$password = getPasswordToStore($password, $myUser['username']);
|
||||
@ -25,27 +21,23 @@
|
||||
}
|
||||
|
||||
$email = $_POST['email'];
|
||||
if (!validateEmail($email))
|
||||
{
|
||||
if (!validateEmail($email)) {
|
||||
return "失败:无效电子邮箱。";
|
||||
}
|
||||
$esc_email = DB::escape($email);
|
||||
DB::update("update user_info set email = '$esc_email' where username = '{$myUser['username']}'");
|
||||
|
||||
if ($_POST['Qtag'])
|
||||
{
|
||||
if ($_POST['Qtag']) {
|
||||
$qq = $_POST['qq'];
|
||||
if (!validateQQ($qq))
|
||||
{
|
||||
if (!validateQQ($qq)) {
|
||||
return "失败:无效QQ。";
|
||||
}
|
||||
$esc_qq = DB::escape($qq);
|
||||
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']}'");
|
||||
if ($_POST['sex'] == "U" || $_POST['sex'] == 'M' || $_POST['sex'] == 'F')
|
||||
{
|
||||
}
|
||||
if ($_POST['sex'] == "U" || $_POST['sex'] == 'M' || $_POST['sex'] == 'F') {
|
||||
$sex = $_POST['sex'];
|
||||
$esc_sex = DB::escape($sex);
|
||||
DB::update("update user_info set sex = '$esc_sex' where username = '{$myUser['username']}'");
|
||||
|
@ -1,13 +1,17 @@
|
||||
<?php
|
||||
function validateZan() {
|
||||
if (!validateUInt($_POST['id']))
|
||||
if (!validateUInt($_POST['id'])) {
|
||||
return false;
|
||||
if (!validateInt($_POST['delta']))
|
||||
}
|
||||
if (!validateInt($_POST['delta'])) {
|
||||
return false;
|
||||
if ($_POST['delta'] != 1 && $_POST['delta'] != -1)
|
||||
}
|
||||
if ($_POST['delta'] != 1 && $_POST['delta'] != -1) {
|
||||
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 true;
|
||||
}
|
||||
if (!validateZan()) {
|
||||
@ -46,7 +50,7 @@
|
||||
$cur += $delta;
|
||||
if ($cur == 0) {
|
||||
DB::query("delete from click_zans where username = '{$myUser['username']}' and type = '$type' and target_id = $id");
|
||||
} else if ($cur != $delta) {
|
||||
} elseif ($cur != $delta) {
|
||||
DB::query("update click_zans set val = '$cur' where username = '{$myUser['username']}' and type = '$type' and target_id = $id");
|
||||
} else {
|
||||
DB::query("insert into click_zans (username, type, target_id, val) values ('{$myUser['username']}', '$type', $id, $cur)");
|
||||
|
@ -497,7 +497,7 @@ EOD;
|
||||
<?php
|
||||
if ($contest['cur_progress'] <= CONTEST_IN_PROGRESS) {
|
||||
echoContestCountdown();
|
||||
} else if ($contest['cur_progress'] <= CONTEST_TESTING) {
|
||||
} elseif ($contest['cur_progress'] <= CONTEST_TESTING) {
|
||||
echoContestJudgeProgress();
|
||||
} else {
|
||||
echoContestFinished();
|
||||
|
@ -61,7 +61,7 @@
|
||||
global $contest;
|
||||
if ($type == '+') {
|
||||
DB::query("insert into contests_permissions (contest_id, username) values (${contest['id']}, '$username')");
|
||||
} else if ($type == '-') {
|
||||
} elseif ($type == '-') {
|
||||
DB::query("delete from contests_permissions where contest_id = ${contest['id']} and username = '$username'");
|
||||
}
|
||||
}
|
||||
@ -92,7 +92,7 @@
|
||||
|
||||
if ($type == '+') {
|
||||
DB::insert("insert into contests_problems (contest_id, problem_id) values ({$contest['id']}, '$problem_id')");
|
||||
} else if ($type == '-') {
|
||||
} elseif ($type == '-') {
|
||||
DB::delete("delete from contests_problems where contest_id = {$contest['id']} and problem_id = '$problem_id'");
|
||||
}
|
||||
|
||||
|
@ -5,29 +5,29 @@
|
||||
$q_submission_id = isset($_GET['submission_id']) && validateUInt($_GET['submission_id']) ? $_GET['submission_id'] : null;
|
||||
$q_hacker = isset($_GET['hacker']) && validateUsername($_GET['hacker']) ? $_GET['hacker'] : null;
|
||||
$q_owner = isset($_GET['owner']) && validateUsername($_GET['owner']) ? $_GET['owner'] : null;
|
||||
if($q_problem_id != null) {
|
||||
if ($q_problem_id != null) {
|
||||
$conds[] = "problem_id = $q_problem_id";
|
||||
}
|
||||
if($q_submission_id != null) {
|
||||
if ($q_submission_id != null) {
|
||||
$conds[] = "submission_id = $q_submission_id";
|
||||
}
|
||||
if($q_hacker != null) {
|
||||
if ($q_hacker != null) {
|
||||
$conds[] = "hacker = '$q_hacker'";
|
||||
}
|
||||
if($q_owner != null) {
|
||||
if ($q_owner != null) {
|
||||
$conds[] = "owner = '$q_owner'";
|
||||
}
|
||||
|
||||
$selected_all = ' selected="selected"';
|
||||
$selected_succ ='';
|
||||
$selected_fail ='';
|
||||
if(isset($_GET['status']) && validateUInt($_GET['status'])) {
|
||||
if($_GET['status'] == 1) {
|
||||
if (isset($_GET['status']) && validateUInt($_GET['status'])) {
|
||||
if ($_GET['status'] == 1) {
|
||||
$selected_all = '';
|
||||
$selected_succ =' selected="selected"';
|
||||
$conds[] = 'success = 1';
|
||||
}
|
||||
if($_GET['status'] == 2) {
|
||||
if ($_GET['status'] == 2) {
|
||||
$selected_all = '';
|
||||
$selected_fail = ' selected="selected"';
|
||||
$conds[] = 'success = 0';
|
||||
|
@ -53,7 +53,7 @@
|
||||
if ($custom_test_requirement && $_GET['get'] == 'custom-test-status-details' && Auth::check()) {
|
||||
if ($custom_test_submission == null) {
|
||||
echo json_encode(null);
|
||||
} else if ($custom_test_submission['status'] != 'Judged') {
|
||||
} elseif ($custom_test_submission['status'] != 'Judged') {
|
||||
echo json_encode(array(
|
||||
'judged' => false,
|
||||
'html' => getSubmissionStatusDetails($custom_test_submission)
|
||||
|
@ -44,28 +44,27 @@
|
||||
|
||||
|
||||
//上传数据
|
||||
if($_POST['problem_data_file_submit']=='submit'){
|
||||
if ($_FILES["problem_data_file"]["error"] > 0){
|
||||
if ($_POST['problem_data_file_submit']=='submit') {
|
||||
if ($_FILES["problem_data_file"]["error"] > 0) {
|
||||
$errmsg = "Error: ".$_FILES["problem_data_file"]["error"];
|
||||
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');
|
||||
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";
|
||||
move_uploaded_file($_FILES["problem_data_file"]["tmp_name"], $up_filename);
|
||||
$zip = new ZipArchive;
|
||||
if ($zip->open($up_filename) === TRUE){
|
||||
if ($zip->open($up_filename) === TRUE) {
|
||||
$zip->extractTo("/var/uoj_data/upload/{$problem['id']}");
|
||||
$zip->close();
|
||||
exec("cd /var/uoj_data/upload/{$problem['id']}; if [ `find . -maxdepth 1 -type f`File = File ]; then for sub_dir in `find -maxdepth 1 -type d ! -name .`; do mv -f \$sub_dir/* . && rm -rf \$sub_dir; done; fi");
|
||||
echo "<script>alert('上传成功!')</script>";
|
||||
}else{
|
||||
} else {
|
||||
$errmsg = "解压失败!";
|
||||
becomeMsgPage('<div>' . $errmsg . '</div><a href="/problem/'.$problem['id'].'/manage/data">返回</a>');
|
||||
}
|
||||
unlink($up_filename);
|
||||
}else{
|
||||
} else {
|
||||
$errmsg = "请上传zip格式!";
|
||||
becomeMsgPage('<div>' . $errmsg . '</div><a href="/problem/'.$problem['id'].'/manage/data">返回</a>');
|
||||
}
|
||||
@ -73,28 +72,28 @@
|
||||
}
|
||||
|
||||
//添加配置文件
|
||||
if($_POST['problem_settings_file_submit']=='submit'){
|
||||
if($_POST['use_builtin_checker'] and $_POST['n_tests'] and $_POST['input_pre'] and $_POST['input_suf'] and $_POST['output_pre'] and $_POST['output_suf'] and $_POST['time_limit'] and $_POST['memory_limit']){
|
||||
if ($_POST['problem_settings_file_submit']=='submit') {
|
||||
if ($_POST['use_builtin_checker'] and $_POST['n_tests'] and $_POST['input_pre'] and $_POST['input_suf'] and $_POST['output_pre'] and $_POST['output_suf'] and $_POST['time_limit'] and $_POST['memory_limit']) {
|
||||
$set_filename="/var/uoj_data/upload/{$problem['id']}/problem.conf";
|
||||
$has_legacy=false;
|
||||
if(file_exists($set_filename)){
|
||||
if (file_exists($set_filename)) {
|
||||
$has_legacy=true;
|
||||
unlink($set_filename);
|
||||
}
|
||||
$setfile = fopen($set_filename, "w");
|
||||
fwrite($setfile, "use_builtin_judger on\n");
|
||||
if($_POST['use_builtin_checker'] != 'ownchk'){
|
||||
if ($_POST['use_builtin_checker'] != 'ownchk') {
|
||||
fwrite($setfile, "use_builtin_checker ".$_POST['use_builtin_checker']."\n");
|
||||
}
|
||||
fwrite($setfile, "n_tests ".$_POST['n_tests']."\n");
|
||||
if($_POST['n_ex_tests']){
|
||||
if ($_POST['n_ex_tests']) {
|
||||
fwrite($setfile, "n_ex_tests ".$_POST['n_ex_tests']."\n");
|
||||
}else{
|
||||
} else {
|
||||
fwrite($setfile, "n_ex_tests 0\n");
|
||||
}
|
||||
if($_POST['n_sample_tests']){
|
||||
if ($_POST['n_sample_tests']) {
|
||||
fwrite($setfile, "n_sample_tests ".$_POST['n_sample_tests']."\n");
|
||||
}else{
|
||||
} else {
|
||||
fwrite($setfile, "n_sample_tests 0\n");
|
||||
}
|
||||
fwrite($setfile, "input_pre ".$_POST['input_pre']."\n");
|
||||
@ -104,12 +103,12 @@
|
||||
fwrite($setfile, "time_limit ".$_POST['time_limit']."\n");
|
||||
fwrite($setfile, "memory_limit ".$_POST['memory_limit']."\n");
|
||||
fclose($setfile);
|
||||
if(!$has_legacy){
|
||||
if (!$has_legacy) {
|
||||
echo "<script>alert('添加成功!')</script>";
|
||||
}else{
|
||||
} else {
|
||||
echo "<script>alert('替换成功!')</script>";
|
||||
}
|
||||
}else{
|
||||
} else {
|
||||
$errmsg = "添加配置文件失败,请检查是否所有输入框都已填写!";
|
||||
becomeMsgPage('<div>' . $errmsg . '</div><a href="/problem/'.$problem['id'].'/manage/data">返回</a>');
|
||||
}
|
||||
@ -226,7 +225,9 @@ EOD
|
||||
}
|
||||
|
||||
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);
|
||||
array_unshift($this->data_files, 'problem.conf');
|
||||
} else {
|
||||
@ -309,10 +310,12 @@ EOD
|
||||
global $data_dir;
|
||||
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) {
|
||||
return function() use($name, $allow_files) {
|
||||
$getDisplaySrcFunc = function($name) use ($allow_files) {
|
||||
return function() use ($name, $allow_files) {
|
||||
$src_name = $name . '.cpp';
|
||||
if (isset($allow_files[$src_name])) {
|
||||
echoFilePre($src_name);
|
||||
@ -358,7 +361,7 @@ EOD
|
||||
|
||||
$data_disp = new DataDisplayer($problem_conf, array('problem.conf'));
|
||||
$data_disp->addDisplayer('tests',
|
||||
function($self) use($problem_conf, $allow_files, $n_tests, $n_ex_tests) {
|
||||
function($self) use ($problem_conf, $allow_files, $n_tests, $n_ex_tests) {
|
||||
for ($num = 1; $num <= $n_tests; $num++) {
|
||||
$input_file_name = getUOJProblemInputFileName($problem_conf, $num);
|
||||
$output_file_name = getUOJProblemOutputFileName($problem_conf, $num);
|
||||
@ -388,7 +391,7 @@ EOD
|
||||
}
|
||||
|
||||
$data_disp->addDisplayer('extra tests',
|
||||
function($self) use($problem_conf, $allow_files, $n_tests, $n_ex_tests) {
|
||||
function($self) use ($problem_conf, $allow_files, $n_tests, $n_ex_tests) {
|
||||
for ($num = 1; $num <= $n_ex_tests; $num++) {
|
||||
$input_file_name = getUOJProblemExtraInputFileName($problem_conf, $num);
|
||||
$output_file_name = getUOJProblemExtraOutputFileName($problem_conf, $num);
|
||||
|
@ -19,7 +19,7 @@
|
||||
global $problem;
|
||||
if ($type == '+') {
|
||||
DB::query("insert into problems_permissions (problem_id, username) values (${problem['id']}, '$username')");
|
||||
} else if ($type == '-') {
|
||||
} elseif ($type == '-') {
|
||||
DB::query("delete from problems_permissions where problem_id = ${problem['id']} and username = '$username'");
|
||||
}
|
||||
}
|
||||
|
@ -24,7 +24,7 @@
|
||||
while ($row = DB::fetch($result, MYSQLI_NUM)) {
|
||||
if ($row[0] == 0) {
|
||||
$has_score_0 = true;
|
||||
} else if ($row[0] == 100) {
|
||||
} elseif ($row[0] == 100) {
|
||||
$has_score_100 = true;
|
||||
}
|
||||
$score = $row[0] * 100;
|
||||
|
@ -34,10 +34,11 @@
|
||||
$esc_email = DB::escape($email);
|
||||
|
||||
$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')");
|
||||
else
|
||||
} else {
|
||||
DB::query("insert into user_info (username, email, password, svn_password, register_time) values ('$username', '$esc_email', '$password', '$svn_pw', now())");
|
||||
}
|
||||
|
||||
return "欢迎你!" . $username . ",你已成功注册。";
|
||||
}
|
||||
|
@ -45,5 +45,4 @@ call_user_func(function() { // to prevent variable scope leak
|
||||
Route::any("$prefix/post/{id}/delete", '/subdomain/blog/blog_delete.php');
|
||||
}
|
||||
);
|
||||
|
||||
});
|
||||
|
@ -6,10 +6,10 @@
|
||||
$q_min_score = isset($_GET['min_score']) && validateUInt($_GET['min_score']) ? $_GET['min_score'] : null;
|
||||
$q_max_score = isset($_GET['max_score']) && validateUInt($_GET['max_score']) ? $_GET['max_score'] : null;
|
||||
$q_language = isset($_GET['language']) ? $_GET['language'] : null;
|
||||
if($q_problem_id != null) {
|
||||
if ($q_problem_id != null) {
|
||||
$conds[] = "problem_id = $q_problem_id";
|
||||
}
|
||||
if($q_submitter != null) {
|
||||
if ($q_submitter != null) {
|
||||
$conds[] = "submitter = '$q_submitter'";
|
||||
}
|
||||
if ($q_min_score != null) {
|
||||
|
@ -46,16 +46,24 @@
|
||||
$blog_link_contests = new UOJForm('blog_link_contests');
|
||||
$blog_link_contests->addInput('blog_id', 'text', '博客ID', '',
|
||||
function ($x) {
|
||||
if (!validateUInt($x)) return 'ID不合法';
|
||||
if (!queryBlog($x)) return '博客不存在';
|
||||
if (!validateUInt($x)) {
|
||||
return 'ID不合法';
|
||||
}
|
||||
if (!queryBlog($x)) {
|
||||
return '博客不存在';
|
||||
}
|
||||
return '';
|
||||
},
|
||||
null
|
||||
);
|
||||
$blog_link_contests->addInput('contest_id', 'text', '比赛ID', '',
|
||||
function ($x) {
|
||||
if (!validateUInt($x)) return 'ID不合法';
|
||||
if (!queryContest($x)) return '比赛不存在';
|
||||
if (!validateUInt($x)) {
|
||||
return 'ID不合法';
|
||||
}
|
||||
if (!queryContest($x)) {
|
||||
return '比赛不存在';
|
||||
}
|
||||
return '';
|
||||
},
|
||||
null
|
||||
@ -87,13 +95,14 @@
|
||||
$config[$n] = $row;
|
||||
}
|
||||
if ($_POST['op-type'] == 'del') {
|
||||
for ($i = 0; $i < $n; $i++)
|
||||
for ($i = 0; $i < $n; $i++) {
|
||||
if ($config[$i][1] == $blog_id) {
|
||||
$config[$i] = $config[$n - 1];
|
||||
unset($config[$n - 1]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$all_config['links'] = $config;
|
||||
$str = json_encode($all_config);
|
||||
@ -105,16 +114,24 @@
|
||||
$blog_link_index = new UOJForm('blog_link_index');
|
||||
$blog_link_index->addInput('blog_id2', 'text', '博客ID', '',
|
||||
function ($x) {
|
||||
if (!validateUInt($x)) return 'ID不合法';
|
||||
if (!queryBlog($x)) return '博客不存在';
|
||||
if (!validateUInt($x)) {
|
||||
return 'ID不合法';
|
||||
}
|
||||
if (!queryBlog($x)) {
|
||||
return '博客不存在';
|
||||
}
|
||||
return '';
|
||||
},
|
||||
null
|
||||
);
|
||||
$blog_link_index->addInput('blog_level', 'text', '置顶级别(删除不用填)', '0',
|
||||
function ($x) {
|
||||
if (!validateUInt($x)) return '数字不合法';
|
||||
if ($x > 3) return '该级别不存在';
|
||||
if (!validateUInt($x)) {
|
||||
return '数字不合法';
|
||||
}
|
||||
if ($x > 3) {
|
||||
return '该级别不存在';
|
||||
}
|
||||
return '';
|
||||
},
|
||||
null
|
||||
@ -215,7 +232,7 @@
|
||||
if (!validateUsername($x)) {
|
||||
return '不合法';
|
||||
}
|
||||
if(DB::selectCount("select count(*) from judger_info where judger_name='$x'")!=0) {
|
||||
if (DB::selectCount("select count(*) from judger_info where judger_name='$x'")!=0) {
|
||||
return '不合法';
|
||||
}
|
||||
$vdata['name'] = $x;
|
||||
@ -235,7 +252,7 @@
|
||||
if (!validateUsername($x)) {
|
||||
return '不合法';
|
||||
}
|
||||
if(DB::selectCount("select count(*) from judger_info where judger_name='$x'")!=1) {
|
||||
if (DB::selectCount("select count(*) from judger_info where judger_name='$x'")!=1) {
|
||||
return '不合法';
|
||||
}
|
||||
$vdata['name'] = $x;
|
||||
@ -367,8 +384,7 @@ EOD;
|
||||
'tail' => 'order by id asc',
|
||||
'page_len' => 5
|
||||
));
|
||||
foreach ($submissions_pag->get() as $submission)
|
||||
{
|
||||
foreach ($submissions_pag->get() as $submission) {
|
||||
$problem = queryProblemBrief($submission['problem_id']);
|
||||
$submission_result = json_decode($submission['result'], true);
|
||||
echo '<dl class="dl-horizontal">';
|
||||
|
@ -10,11 +10,10 @@
|
||||
$esc_qq = HTML::escape($user['qq'] != 0 ? $user['qq'] : 'Unfilled');
|
||||
$esc_sex = HTML::escape($user['sex']);
|
||||
$col_sex="color:blue";
|
||||
if($esc_sex == "M") {
|
||||
if ($esc_sex == "M") {
|
||||
$esc_sex="♂";
|
||||
$col_sex="color:blue";
|
||||
}
|
||||
else if($esc_sex == "F") {
|
||||
} elseif ($esc_sex == "F") {
|
||||
$esc_sex="♀";
|
||||
$col_sex="color:red";
|
||||
} else {
|
||||
|
@ -39,7 +39,9 @@
|
||||
}
|
||||
$ret[$msg['sender']] = array($msg['send_time'], ($msg['read_time'] == null));
|
||||
} else {
|
||||
if (isset($ret[$msg['receiver']])) continue;
|
||||
if (isset($ret[$msg['receiver']])) {
|
||||
continue;
|
||||
}
|
||||
$ret[$msg['receiver']] = array($msg['send_time'], 0);
|
||||
}
|
||||
}
|
||||
@ -47,7 +49,9 @@
|
||||
foreach ($ret as $name => $con) {
|
||||
$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);
|
||||
}
|
||||
|
||||
|
@ -35,11 +35,13 @@ function calcRating($standings, $K = 400) {
|
||||
$weight[$i] = pow(7, $rating[$i] / $DELTA);
|
||||
}
|
||||
$exp = array_fill(0, $n, 0);
|
||||
for ($i = 0; $i < $n; ++$i)
|
||||
for ($j = 0; $j < $n; ++$j)
|
||||
for ($i = 0; $i < $n; ++$i) {
|
||||
for ($j = 0; $j < $n; ++$j) {
|
||||
if ($j != $i) {
|
||||
$exp[$i] += $weight[$i] / ($weight[$i] + $weight[$j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$new_rating = array();
|
||||
for ($i = 0; $i < $n; $i++) {
|
||||
@ -105,14 +107,14 @@ function genMoreContestInfo(&$contest) {
|
||||
if ($contest['status'] == 'unfinished') {
|
||||
if (UOJTime::$time_now < $contest['start_time']) {
|
||||
$contest['cur_progress'] = CONTEST_NOT_STARTED;
|
||||
} else if (UOJTime::$time_now < $contest['end_time']) {
|
||||
} elseif (UOJTime::$time_now < $contest['end_time']) {
|
||||
$contest['cur_progress'] = CONTEST_IN_PROGRESS;
|
||||
} else {
|
||||
$contest['cur_progress'] = CONTEST_PENDING_FINAL_TEST;
|
||||
}
|
||||
} else if ($contest['status'] == 'testing') {
|
||||
} elseif ($contest['status'] == 'testing') {
|
||||
$contest['cur_progress'] = CONTEST_TESTING;
|
||||
} else if ($contest['status'] == 'finished') {
|
||||
} elseif ($contest['status'] == 'finished') {
|
||||
$contest['cur_progress'] = CONTEST_FINISHED;
|
||||
}
|
||||
$contest['extra_config'] = json_decode($contest['extra_config'], true);
|
||||
@ -220,7 +222,7 @@ function calcStandings($contest, $contest_data, &$score, &$standings, $update_co
|
||||
usort($standings, function($lhs, $rhs) {
|
||||
if ($lhs[0] != $rhs[0]) {
|
||||
return $rhs[0] - $lhs[0];
|
||||
} else if ($lhs[1] != $rhs[1]) {
|
||||
} elseif ($lhs[1] != $rhs[1]) {
|
||||
return $lhs[1] - $rhs[1];
|
||||
} else {
|
||||
return strcmp($lhs[2][0], $rhs[2][0]);
|
||||
|
@ -178,7 +178,9 @@
|
||||
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();
|
||||
if ($zip_file->open("{$this->prepare_dir}/download.zip", ZipArchive::CREATE) !== true) {
|
||||
|
@ -21,7 +21,8 @@
|
||||
public function __construct($form_name) {
|
||||
$this->form_name = $form_name;
|
||||
$this->succ_href = $_SERVER['REQUEST_URI'];
|
||||
$this->handle = function(&$vdata){};
|
||||
$this->handle = function(&$vdata) {
|
||||
};
|
||||
|
||||
$this->run_at_server_handler["check-{$this->form_name}"] = function() {
|
||||
die(json_encode($this->validateAtServer()));
|
||||
@ -244,7 +245,7 @@ EOD;
|
||||
$name = $editor->name;
|
||||
|
||||
$this->addVInput("{$name}_title", 'text', '标题', $editor->cur_data['title'],
|
||||
function ($title) use($editor) {
|
||||
function ($title) use ($editor) {
|
||||
return $editor->validateTitle();
|
||||
},
|
||||
null
|
||||
@ -253,7 +254,7 @@ EOD;
|
||||
$content_md_html = HTML::div_vtextarea("{$name}_content_md", '内容', $editor->cur_data['content_md']);
|
||||
|
||||
$this->add("{$name}_content_md", $content_md_html,
|
||||
function ($content_md) use($editor) {
|
||||
function ($content_md) use ($editor) {
|
||||
return $editor->validateContentMd();
|
||||
},
|
||||
'always_ok'
|
||||
@ -264,7 +265,7 @@ EOD;
|
||||
EOD
|
||||
);
|
||||
|
||||
$this->run_at_server_handler["save-{$name}"] = function() use($name, $editor) {
|
||||
$this->run_at_server_handler["save-{$name}"] = function() use ($name, $editor) {
|
||||
if ($this->no_submit) {
|
||||
become404Page();
|
||||
}
|
||||
@ -311,7 +312,7 @@ EOD;
|
||||
|
||||
public function addSourceCodeInput($name, $text, $languages) {
|
||||
$this->add("{$name}_upload_type", '',
|
||||
function($type, &$vdata) use($name) {
|
||||
function($type, &$vdata) use ($name) {
|
||||
if ($type == 'editor') {
|
||||
if (!isset($_POST["{$name}_editor"])) {
|
||||
return '你在干啥……怎么什么都没交过来……?';
|
||||
@ -362,7 +363,7 @@ EOD
|
||||
}
|
||||
public function addTextFileInput($name, $text) {
|
||||
$this->add("{$name}_upload_type", '',
|
||||
function($type, &$vdata) use($name) {
|
||||
function($type, &$vdata) use ($name) {
|
||||
if ($type == 'editor') {
|
||||
if (!isset($_POST["{$name}_editor"])) {
|
||||
return '你在干啥……怎么什么都没交过来……?';
|
||||
@ -616,7 +617,7 @@ EOD;
|
||||
$form = new UOJForm($form_name);
|
||||
$form->addTextArea(
|
||||
$form_name . '_cmds', '命令', '',
|
||||
function($str, &$vdata) use($validate) {
|
||||
function($str, &$vdata) use ($validate) {
|
||||
$cmds = array();
|
||||
foreach (explode("\n", $str) as $line_id => $raw_line) {
|
||||
$line = trim($raw_line);
|
||||
@ -639,13 +640,13 @@ EOD;
|
||||
null
|
||||
);
|
||||
if (!isset($final)) {
|
||||
$form->handle = function(&$vdata) use($handle) {
|
||||
$form->handle = function(&$vdata) use ($handle) {
|
||||
foreach ($vdata['cmds'] as $cmd) {
|
||||
$handle($cmd['type'], $cmd['obj']);
|
||||
}
|
||||
};
|
||||
} else {
|
||||
$form->handle = function(&$vdata) use($handle, $final) {
|
||||
$form->handle = function(&$vdata) use ($handle, $final) {
|
||||
foreach ($vdata['cmds'] as $cmd) {
|
||||
$handle($cmd['type'], $cmd['obj']);
|
||||
}
|
||||
@ -666,7 +667,7 @@ EOD;
|
||||
}
|
||||
}
|
||||
|
||||
$form->handle = function(&$vdata) use($form_name, $requirement, $zip_file_name_gen, $handle) {
|
||||
$form->handle = function(&$vdata) use ($form_name, $requirement, $zip_file_name_gen, $handle) {
|
||||
global $myUser;
|
||||
|
||||
if ($myUser == null) {
|
||||
@ -724,7 +725,9 @@ EOD;
|
||||
function newZipSubmissionForm($form_name, $requirement, $zip_file_name_gen, $handle) {
|
||||
$form = new UOJForm($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');
|
||||
$html = <<<EOD
|
||||
<div id="div-{$name}">
|
||||
@ -744,7 +747,7 @@ EOD;
|
||||
$form->is_big = true;
|
||||
$form->has_file = true;
|
||||
|
||||
$form->handle = function() use($name, $requirement, $zip_file_name_gen, $handle) {
|
||||
$form->handle = function() use ($name, $requirement, $zip_file_name_gen, $handle) {
|
||||
global $myUser;
|
||||
|
||||
if ($myUser == null) {
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
function uojHandleAtSign($str, $uri) {
|
||||
$referrers = array();
|
||||
$res = preg_replace_callback('/@(@|[a-zA-Z0-9_]{1,20})/', function($matches) use(&$referrers) {
|
||||
$res = preg_replace_callback('/@(@|[a-zA-Z0-9_]{1,20})/', function($matches) use (&$referrers) {
|
||||
if ($matches[1] === '@') {
|
||||
return '@';
|
||||
} else {
|
||||
@ -89,7 +89,7 @@ function getUserLink($username, $rating = null) {
|
||||
function getProblemLink($problem, $problem_title = '!title_only') {
|
||||
if ($problem_title == '!title_only') {
|
||||
$problem_title = $problem['title'];
|
||||
} else if ($problem_title == '!id_and_title') {
|
||||
} elseif ($problem_title == '!id_and_title') {
|
||||
$problem_title = "#${problem['id']}. ${problem['title']}";
|
||||
}
|
||||
return '<a href="/problem/'.$problem['id'].'">'.$problem_title.'</a>';
|
||||
@ -97,7 +97,7 @@ function getProblemLink($problem, $problem_title = '!title_only') {
|
||||
function getContestProblemLink($problem, $contest_id, $problem_title = '!title_only') {
|
||||
if ($problem_title == '!title_only') {
|
||||
$problem_title = $problem['title'];
|
||||
} else if ($problem_title == '!id_and_title') {
|
||||
} elseif ($problem_title == '!id_and_title') {
|
||||
$problem_title = "#{$problem['id']}. {$problem['title']}";
|
||||
}
|
||||
return '<a href="/contest/'.$contest_id.'/problem/'.$problem['id'].'">'.$problem_title.'</a>';
|
||||
@ -121,15 +121,16 @@ function getLongTablePageRawUri($page) {
|
||||
parse_str($query_string, $param);
|
||||
|
||||
$param['page'] = $page;
|
||||
if ($page == 1)
|
||||
if ($page == 1) {
|
||||
unset($param['page']);
|
||||
}
|
||||
|
||||
if ($param) {
|
||||
return $path . '?' . http_build_query($param);
|
||||
} else {
|
||||
return $path;
|
||||
}
|
||||
}
|
||||
}
|
||||
function getLongTablePageUri($page) {
|
||||
return HTML::escape(getLongTablePageRawUri($page));
|
||||
}
|
||||
@ -249,10 +250,12 @@ function echoSubmission($submission, $config, $user) {
|
||||
}
|
||||
echo '</td>';
|
||||
}
|
||||
if (!isset($config['used_time_hidden']))
|
||||
if (!isset($config['used_time_hidden'])) {
|
||||
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>', '<a href="/submission/', $submission['id'], '">', $submission['language'], '</a>', '</td>';
|
||||
|
||||
@ -263,10 +266,12 @@ function echoSubmission($submission, $config, $user) {
|
||||
}
|
||||
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>';
|
||||
if (!isset($config['judge_time_hidden']))
|
||||
}
|
||||
if (!isset($config['judge_time_hidden'])) {
|
||||
echo '<td><small>', $submission['judge_time'], '</small></td>';
|
||||
}
|
||||
echo '</tr>';
|
||||
if ($show_status_details) {
|
||||
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 '<thead>';
|
||||
echo '<tr>';
|
||||
if (!isset($config['id_hidden']))
|
||||
if (!isset($config['id_hidden'])) {
|
||||
echo '<th>ID</th>';
|
||||
if (!isset($config['problem_hidden']))
|
||||
}
|
||||
if (!isset($config['problem_hidden'])) {
|
||||
echo '<th>'.UOJLocale::get('problems::problem').'</th>';
|
||||
if (!isset($config['submitter_hidden']))
|
||||
}
|
||||
if (!isset($config['submitter_hidden'])) {
|
||||
echo '<th>'.UOJLocale::get('problems::submitter').'</th>';
|
||||
if (!isset($config['result_hidden']))
|
||||
}
|
||||
if (!isset($config['result_hidden'])) {
|
||||
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>';
|
||||
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::language').'</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>';
|
||||
if (!isset($config['judge_time_hidden']))
|
||||
}
|
||||
if (!isset($config['judge_time_hidden'])) {
|
||||
echo '<th>'.UOJLocale::get('problems::judge time').'</th>';
|
||||
}
|
||||
echo '</tr>';
|
||||
echo '</thead>';
|
||||
echo '<tbody>';
|
||||
@ -375,7 +388,7 @@ function echoSubmissionsList($cond, $tail, $config, $user) {
|
||||
$table_config = isset($config['table_config']) ? $config['table_config'] : null;
|
||||
|
||||
echoLongTable($col_names, $table_name, $cond, $tail, $header_row,
|
||||
function($submission) use($config, $user) {
|
||||
function($submission) use ($config, $user) {
|
||||
echoSubmission($submission, $config, $user);
|
||||
}, $table_config);
|
||||
}
|
||||
@ -429,8 +442,7 @@ function echoSubmissionContent($submission, $requirement) {
|
||||
echo '</div>';
|
||||
echo '<div class="card-footer">'.$footer_text.'</div>';
|
||||
echo '</div>';
|
||||
}
|
||||
else if ($req['type'] == "text") {
|
||||
} elseif ($req['type'] == "text") {
|
||||
$file_content = $zip_file->getFromName("{$req['file_name']}", 504);
|
||||
$file_content = strOmit($file_content, 500);
|
||||
$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">';
|
||||
if ($this->styler->show_small_tip) {
|
||||
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>';
|
||||
}
|
||||
$this->_print_c($node);
|
||||
@ -774,10 +785,12 @@ function echoHackDetails($hack_details, $name) {
|
||||
function echoHack($hack, $config, $user) {
|
||||
$problem = queryProblemBrief($hack['problem_id']);
|
||||
echo '<tr>';
|
||||
if (!isset($config['id_hidden']))
|
||||
if (!isset($config['id_hidden'])) {
|
||||
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>';
|
||||
}
|
||||
if (!isset($config['problem_hidden'])) {
|
||||
if ($hack['contest_id']) {
|
||||
echo '<td>', getContestProblemLink($problem, $hack['contest_id'], '!id_and_title'), '</td>';
|
||||
@ -785,13 +798,14 @@ function echoHack($hack, $config, $user) {
|
||||
echo '<td>', getProblemLink($problem, '!id_and_title'), '</td>';
|
||||
}
|
||||
}
|
||||
if (!isset($config['hacker_hidden']))
|
||||
if (!isset($config['hacker_hidden'])) {
|
||||
echo '<td>', getUserLink($hack['hacker']), '</td>';
|
||||
if (!isset($config['owner_hidden']))
|
||||
}
|
||||
if (!isset($config['owner_hidden'])) {
|
||||
echo '<td>', getUserLink($hack['owner']), '</td>';
|
||||
if (!isset($config['result_hidden']))
|
||||
{
|
||||
if($hack['judge_time'] == null) {
|
||||
}
|
||||
if (!isset($config['result_hidden'])) {
|
||||
if ($hack['judge_time'] == null) {
|
||||
echo '<td><a href="/hack/', $hack['id'], '">Waiting</a></td>';
|
||||
} elseif ($hack['success'] == null) {
|
||||
echo '<td><a href="/hack/', $hack['id'], '">Judging</a></td>';
|
||||
@ -800,13 +814,15 @@ function echoHack($hack, $config, $user) {
|
||||
} else {
|
||||
echo '<td><a href="/hack/', $hack['id'], '" class="uoj-status" data-success="0"><strong>Failed.</strong></a></td>';
|
||||
}
|
||||
}
|
||||
else
|
||||
} else {
|
||||
echo '<td>Hidden</td>';
|
||||
if (!isset($config['submit_time_hidden']))
|
||||
}
|
||||
if (!isset($config['submit_time_hidden'])) {
|
||||
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 '</tr>';
|
||||
}
|
||||
function echoHackListOnlyOne($hack, $config, $user) {
|
||||
@ -814,22 +830,30 @@ function echoHackListOnlyOne($hack, $config, $user) {
|
||||
echo '<table class="table table-bordered table-text-center">';
|
||||
echo '<thead>';
|
||||
echo '<tr>';
|
||||
if (!isset($config['id_hidden']))
|
||||
if (!isset($config['id_hidden'])) {
|
||||
echo '<th>ID</th>';
|
||||
if (!isset($config['submission_id_hidden']))
|
||||
}
|
||||
if (!isset($config['submission_id_hidden'])) {
|
||||
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>';
|
||||
if (!isset($config['hacker_hidden']))
|
||||
}
|
||||
if (!isset($config['hacker_hidden'])) {
|
||||
echo '<th>'.UOJLocale::get('problems::hacker').'</th>';
|
||||
if (!isset($config['owner_hidden']))
|
||||
}
|
||||
if (!isset($config['owner_hidden'])) {
|
||||
echo '<th>'.UOJLocale::get('problems::owner').'</th>';
|
||||
if (!isset($config['result_hidden']))
|
||||
}
|
||||
if (!isset($config['result_hidden'])) {
|
||||
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>';
|
||||
if (!isset($config['judge_time_hidden']))
|
||||
}
|
||||
if (!isset($config['judge_time_hidden'])) {
|
||||
echo '<th>'.UOJLocale::get('problems::judge time').'</th>';
|
||||
}
|
||||
echo '</tr>';
|
||||
echo '</thead>';
|
||||
echo '<tbody>';
|
||||
@ -891,7 +915,7 @@ function echoHacksList($cond, $tail, $config, $user) {
|
||||
}
|
||||
|
||||
echoLongTable($col_names, 'hacks', $cond, $tail, $header_row,
|
||||
function($hacks) use($config, $user) {
|
||||
function($hacks) use ($config, $user) {
|
||||
echoHack($hacks, $config, $user);
|
||||
}, null);
|
||||
}
|
||||
@ -935,10 +959,10 @@ function echoRanklist($config = array()) {
|
||||
$header_row .= '</tr>';
|
||||
|
||||
$users = array();
|
||||
$print_row = function($user, $now_cnt) use(&$users) {
|
||||
$print_row = function($user, $now_cnt) use (&$users) {
|
||||
if (!$users) {
|
||||
$rank = DB::selectCount("select count(*) from user_info where rating > {$user['rating']}") + 1;
|
||||
} else if ($user['rating'] == $users[count($users) - 1]['rating']) {
|
||||
} elseif ($user['rating'] == $users[count($users) - 1]['rating']) {
|
||||
$rank = $users[count($users) - 1]['rank'];
|
||||
} else {
|
||||
$rank = $now_cnt;
|
||||
|
@ -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;
|
||||
}
|
||||
function hasViewPermission($str,$user,$problem,$submission) {
|
||||
if($str=='ALL')
|
||||
if ($str=='ALL') {
|
||||
return true;
|
||||
if($str=='ALL_AFTER_AC')
|
||||
}
|
||||
if ($str=='ALL_AFTER_AC') {
|
||||
return hasAC($user,$problem);
|
||||
if($str=='SELF')
|
||||
}
|
||||
if ($str=='SELF') {
|
||||
return $submission['submitter']==$user['username'];
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -31,7 +34,7 @@ function hasContestPermission($user, $contest) {
|
||||
|
||||
function hasRegistered($user, $contest) {
|
||||
return DB::selectFirst("select * from contests_registrants where username = '${user['username']}' and contest_id = ${contest['id']}") != null;
|
||||
}
|
||||
}
|
||||
function hasAC($user, $problem) {
|
||||
return DB::selectFirst("select * from best_ac_submissions where submitter = '${user['username']}' and problem_id = ${problem['id']}") != null;
|
||||
}
|
||||
@ -122,7 +125,7 @@ function isContestProblemVisibleToUser($problem, $contest, $user) {
|
||||
function isSubmissionVisibleToUser($submission, $problem, $user) {
|
||||
if (isSuperUser($user)) {
|
||||
return true;
|
||||
} else if (!$submission['is_hidden']) {
|
||||
} elseif (!$submission['is_hidden']) {
|
||||
return true;
|
||||
} else {
|
||||
return hasProblemPermission($user, $problem);
|
||||
|
@ -19,7 +19,7 @@ function crsf_token() {
|
||||
function crsf_check() {
|
||||
if (isset($_POST['_token'])) {
|
||||
$_token = $_POST['_token'];
|
||||
} else if (isset($_GET['_token'])) {
|
||||
} elseif (isset($_GET['_token'])) {
|
||||
$_token = $_GET['_token'];
|
||||
} else {
|
||||
return false;
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
function mergeConfig(&$config, $default_config) {
|
||||
foreach($default_config as $key => $val) {
|
||||
foreach ($default_config as $key => $val) {
|
||||
if (!isset($config[$key])) {
|
||||
$config[$key] = $val;
|
||||
} elseif (is_array($config[$key])) {
|
||||
@ -69,11 +69,11 @@ function uojTextEncode($str, $config = array()) {
|
||||
if ($config['html_escape']) {
|
||||
if ($c == '&') {
|
||||
$res .= '&';
|
||||
} else if ($c == '"') {
|
||||
} elseif ($c == '"') {
|
||||
$res .= '"';
|
||||
} else if ($c == '<') {
|
||||
} elseif ($c == '<') {
|
||||
$res .= '<';
|
||||
} else if ($c == '>') {
|
||||
} elseif ($c == '>') {
|
||||
$res .= '>';
|
||||
} else {
|
||||
$res .= $c;
|
||||
|
@ -131,7 +131,7 @@ class HTML {
|
||||
$r = array();
|
||||
foreach ((array)$q as $k => $v) {
|
||||
if ($array_name !== null) {
|
||||
if(is_numeric($k)) {
|
||||
if (is_numeric($k)) {
|
||||
$k = $array_name."[]";
|
||||
} else {
|
||||
$k = $array_name."[$k]";
|
||||
|
@ -25,7 +25,7 @@ class Paginator {
|
||||
$this->cur_page = validateUInt($_GET['page']) ? (int)$_GET['page'] : 1;
|
||||
if ($this->cur_page < 1) {
|
||||
$this->cur_page = 1;
|
||||
} else if ($this->cur_page > $this->n_pages) {
|
||||
} elseif ($this->cur_page > $this->n_pages) {
|
||||
$this->cur_page = $this->n_pages;
|
||||
}
|
||||
$this->cur_start = ($this->cur_page - 1) * $this->page_len;
|
||||
@ -47,8 +47,9 @@ class Paginator {
|
||||
parse_str($query_string, $param);
|
||||
|
||||
$param['page'] = $page;
|
||||
if ($page == 1)
|
||||
if ($page == 1) {
|
||||
unset($param['page']);
|
||||
}
|
||||
|
||||
if ($param) {
|
||||
return $path . '?' . http_build_query($param);
|
||||
|
@ -113,7 +113,7 @@ class UOJBlogEditor {
|
||||
} else {
|
||||
$this->post_data['content'] = $purifier->purify($this->post_data['content']);
|
||||
}
|
||||
} else if ($this->type == 'slide') {
|
||||
} elseif ($this->type == 'slide') {
|
||||
$content_array = yaml_parse($this->post_data['content_md']);
|
||||
if ($content_array === false || !is_array($content_array)) {
|
||||
die(json_encode(array('content_md' => '不合法的 YAML 格式')));
|
||||
@ -150,7 +150,7 @@ EOD
|
||||
die(json_encode(array('content_md' => '未知错误')));
|
||||
}
|
||||
|
||||
$marked = function($md) use($v8, $purifier) {
|
||||
$marked = function($md) use ($v8, $purifier) {
|
||||
try {
|
||||
$v8->md = $md;
|
||||
return $purifier->purify($v8->executeString('marked(PHP.md)'));
|
||||
@ -206,7 +206,7 @@ EOD
|
||||
echo $this->post_data['content'];
|
||||
echo '</article>';
|
||||
echoUOJPageFooter(array('ShowPageFooter' => false));
|
||||
} else if ($this->type == 'slide') {
|
||||
} elseif ($this->type == 'slide') {
|
||||
uojIncludeView('slide', array_merge(
|
||||
UOJContext::pageConfig(),
|
||||
array(
|
||||
|
@ -8,7 +8,7 @@ class UOJContext {
|
||||
return array(
|
||||
'PageNav' => 'main-nav'
|
||||
);
|
||||
} else if (self::$data['type'] == 'blog') {
|
||||
} elseif (self::$data['type'] == 'blog') {
|
||||
return array(
|
||||
'PageNav' => 'blog-nav',
|
||||
'PageMainTitle' => UOJContext::$data['user']['username'] . '的博客',
|
||||
@ -55,7 +55,7 @@ class UOJContext {
|
||||
public static function httpHost() {
|
||||
if (isset($_SERVER['HTTP_X_FORWARDED_HOST'])) {
|
||||
return $_SERVER['HTTP_X_FORWARDED_HOST'];
|
||||
} else if (isset($_SERVER['HTTP_HOST'])) {
|
||||
} elseif (isset($_SERVER['HTTP_HOST'])) {
|
||||
return $_SERVER['HTTP_HOST'];
|
||||
} else {
|
||||
return $_SERVER['SERVER_NAME'].($_SERVER['SERVER_PORT'] == '80' ? '' : ':'.$_SERVER['SERVER_PORT']);
|
||||
|
Loading…
Reference in New Issue
Block a user