diff --git a/web/app/cli.php b/web/app/cli.php index b060d3a..cd1d9c7 100644 --- a/web/app/cli.php +++ b/web/app/cli.php @@ -11,7 +11,7 @@ $handlers = [ if (func_num_args() != 1) { die("php cli.php upgrade:up \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 \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 \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 \n"); } - Upgrader::transaction(function() use($name) { + Upgrader::transaction(function() use ($name) { Upgrader::remove($name); }); die("finished!\n"); diff --git a/web/app/controllers/add_contest.php b/web/app/controllers/add_contest.php index 381ab70..9f98ee4 100644 --- a/web/app/controllers/add_contest.php +++ b/web/app/controllers/add_contest.php @@ -1,8 +1,7 @@ addHidden('rid', '0', function($id) { - global $contest; + global $contest; if (!validateUInt($id)) { return '无效ID'; } $q = DB::selectFirst("select * from contests_asks where id = $id"); if ($q['contest_id'] != $contest['id']) { - return '无效ID'; + return '无效ID'; } return ''; }, @@ -247,15 +247,15 @@ EOD; ], '回复类型', 'private'); $reply_question->addVTextArea('rcontent', '回复', '', function($content) { - if (!Auth::check()) { - return '您尚未登录'; - } - switch ($_POST['rtype']) { + if (!Auth::check()) { + return '您尚未登录'; + } + switch ($_POST['rtype']) { case 'public': case 'private': if (strlen($content) == 0) { - return '回复不能为空'; - } + return '回复不能为空'; + } break; } return ''; @@ -406,10 +406,10 @@ EOD; function echoContestCountdown() { global $contest; - $rest_second = $contest['end_time']->getTimestamp() - UOJTime::$time_now->getTimestamp(); - $time_str = UOJTime::$time_now_str; - $contest_ends_in = UOJLocale::get('contests::contest ends in'); - echo <<getTimestamp() - UOJTime::$time_now->getTimestamp(); + $time_str = UOJTime::$time_now_str; + $contest_ends_in = UOJLocale::get('contests::contest ends in'); + echo <<

$contest_ends_in

@@ -497,7 +497,7 @@ EOD; addAddress($user['email'], $user['username']); $mailer->Subject = $oj_name_short."密码找回"; $mailer->msgHTML($html); - if (!$mailer->send()) { + if (!$mailer->send()) { error_log($mailer->ErrorInfo); becomeMsgPage('

邮件发送失败,请重试

'); } else { diff --git a/web/app/controllers/hack_list.php b/web/app/controllers/hack_list.php index d6ca67a..2d343b3 100644 --- a/web/app/controllers/hack_list.php +++ b/web/app/controllers/hack_list.php @@ -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'; diff --git a/web/app/controllers/problem.php b/web/app/controllers/problem.php index 41e116e..525efce 100644 --- a/web/app/controllers/problem.php +++ b/web/app/controllers/problem.php @@ -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) @@ -114,7 +114,7 @@ } else { DB::query("insert into submissions (problem_id, submit_time, submitter, content, language, tot_size, status, result, is_hidden) values (${problem['id']}, now(), '${myUser['username']}', '$esc_content', '$esc_language', $tot_size, '${result['status']}', '$result_json', {$problem['is_hidden']})"); } - } + } function handleCustomTestUpload($zip_file_name, $content, $tot_size) { global $problem, $contest, $myUser; @@ -139,7 +139,7 @@ $result_json = json_encode($result); DB::insert("insert into custom_test_submissions (problem_id, submit_time, submitter, content, status, result) values ({$problem['id']}, now(), '{$myUser['username']}', '$esc_content', '{$result['status']}', '$result_json')"); - } + } if ($can_use_zip_upload) { $zip_answer_form = newZipSubmissionForm('zip_answer', diff --git a/web/app/controllers/problem_data_manage.php b/web/app/controllers/problem_data_manage.php index 7127d56..138ae69 100644 --- a/web/app/controllers/problem_data_manage.php +++ b/web/app/controllers/problem_data_manage.php @@ -44,72 +44,71 @@ //上传数据 - if($_POST['problem_data_file_submit']=='submit'){ - if ($_FILES["problem_data_file"]["error"] > 0){ - $errmsg = "Error: ".$_FILES["problem_data_file"]["error"]; + if ($_POST['problem_data_file_submit']=='submit') { + if ($_FILES["problem_data_file"]["error"] > 0) { + $errmsg = "Error: ".$_FILES["problem_data_file"]["error"]; becomeMsgPage('
' . $errmsg . '
返回'); - } - 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 ""; - }else{ + } else { $errmsg = "解压失败!"; becomeMsgPage('
' . $errmsg . '
返回'); } unlink($up_filename); - }else{ + } else { $errmsg = "请上传zip格式!"; becomeMsgPage('
' . $errmsg . '
返回'); } - } + } } //添加配置文件 - 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)){ - $has_legacy=true; - unlink($set_filename); - } - $setfile = fopen($set_filename, "w"); - fwrite($setfile, "use_builtin_judger on\n"); - 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']){ - fwrite($setfile, "n_ex_tests ".$_POST['n_ex_tests']."\n"); - }else{ - fwrite($setfile, "n_ex_tests 0\n"); - } - if($_POST['n_sample_tests']){ - fwrite($setfile, "n_sample_tests ".$_POST['n_sample_tests']."\n"); - }else{ - fwrite($setfile, "n_sample_tests 0\n"); - } - fwrite($setfile, "input_pre ".$_POST['input_pre']."\n"); - fwrite($setfile, "input_suf ".$_POST['input_suf']."\n"); - fwrite($setfile, "output_pre ".$_POST['output_pre']."\n"); - fwrite($setfile, "output_suf ".$_POST['output_suf']."\n"); - fwrite($setfile, "time_limit ".$_POST['time_limit']."\n"); - fwrite($setfile, "memory_limit ".$_POST['memory_limit']."\n"); - fclose($setfile); - if(!$has_legacy){ - echo ""; - }else{ - echo ""; - } - }else{ + 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)) { + $has_legacy=true; + unlink($set_filename); + } + $setfile = fopen($set_filename, "w"); + fwrite($setfile, "use_builtin_judger on\n"); + 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']) { + fwrite($setfile, "n_ex_tests ".$_POST['n_ex_tests']."\n"); + } else { + fwrite($setfile, "n_ex_tests 0\n"); + } + if ($_POST['n_sample_tests']) { + fwrite($setfile, "n_sample_tests ".$_POST['n_sample_tests']."\n"); + } else { + fwrite($setfile, "n_sample_tests 0\n"); + } + fwrite($setfile, "input_pre ".$_POST['input_pre']."\n"); + fwrite($setfile, "input_suf ".$_POST['input_suf']."\n"); + fwrite($setfile, "output_pre ".$_POST['output_pre']."\n"); + fwrite($setfile, "output_suf ".$_POST['output_suf']."\n"); + fwrite($setfile, "time_limit ".$_POST['time_limit']."\n"); + fwrite($setfile, "memory_limit ".$_POST['memory_limit']."\n"); + fclose($setfile); + if (!$has_legacy) { + echo ""; + } else { + echo ""; + } + } else { $errmsg = "添加配置文件失败,请检查是否所有输入框都已填写!"; becomeMsgPage('
' . $errmsg . '
返回'); } @@ -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); @@ -584,9 +587,9 @@ EOD $esc_content = DB::escape(json_encode($content)); $esc_language = DB::escape('C++'); - $result = array(); - $result['status'] = "Waiting"; - $result_json = json_encode($result); + $result = array(); + $result['status'] = "Waiting"; + $result_json = json_encode($result); $is_hidden = $problem['is_hidden'] ? 1 : 0; DB::insert("insert into submissions (problem_id, submit_time, submitter, content, language, tot_size, status, result, is_hidden) values ({$problem['id']}, now(), '{$user_std['username']}', '$esc_content', '$esc_language', $tot_size, '{$result['status']}', '$result_json', $is_hidden)"); diff --git a/web/app/controllers/problem_managers_manage.php b/web/app/controllers/problem_managers_manage.php index 6eb2828..786d91f 100644 --- a/web/app/controllers/problem_managers_manage.php +++ b/web/app/controllers/problem_managers_manage.php @@ -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'"); } } diff --git a/web/app/controllers/problem_set.php b/web/app/controllers/problem_set.php index 210acbf..3c0a162 100644 --- a/web/app/controllers/problem_set.php +++ b/web/app/controllers/problem_set.php @@ -71,8 +71,8 @@ EOD; if ($search_tag) { $cond[] = "'".DB::escape($search_tag)."' in (select tag from problems_tags where problems_tags.problem_id = problems.id)"; } - if (isset($_GET["search"])) { - $cond[]="title like '%".DB::escape($_GET["search"])."%' or id like '%".DB::escape($_GET["search"])."%'"; + if (isset($_GET["search"])) { + $cond[]="title like '%".DB::escape($_GET["search"])."%' or id like '%".DB::escape($_GET["search"])."%'"; } if ($cond) { diff --git a/web/app/controllers/problem_statistics.php b/web/app/controllers/problem_statistics.php index b6acce9..b97f1d7 100644 --- a/web/app/controllers/problem_statistics.php +++ b/web/app/controllers/problem_statistics.php @@ -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; diff --git a/web/app/controllers/register.php b/web/app/controllers/register.php index cd64bd5..315dec0 100644 --- a/web/app/controllers/register.php +++ b/web/app/controllers/register.php @@ -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 . ",你已成功注册。"; } diff --git a/web/app/controllers/reset_pw.php b/web/app/controllers/reset_pw.php index 48c79b3..4bf64de 100644 --- a/web/app/controllers/reset_pw.php +++ b/web/app/controllers/reset_pw.php @@ -18,7 +18,7 @@ $user = queryUser($username); if ($user == null) { return '不明错误'; - } + } if ($check_code !== md5($user['username'] . '+' . $user['password'])) { return '不明错误'; } diff --git a/web/app/controllers/subdomain/blog/route.php b/web/app/controllers/subdomain/blog/route.php index 82ace32..461e2ff 100644 --- a/web/app/controllers/subdomain/blog/route.php +++ b/web/app/controllers/subdomain/blog/route.php @@ -45,5 +45,4 @@ call_user_func(function() { // to prevent variable scope leak Route::any("$prefix/post/{id}/delete", '/subdomain/blog/blog_delete.php'); } ); - }); diff --git a/web/app/controllers/submissions_list.php b/web/app/controllers/submissions_list.php index ef93189..a04b2a1 100644 --- a/web/app/controllers/submissions_list.php +++ b/web/app/controllers/submissions_list.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) { diff --git a/web/app/controllers/super_manage.php b/web/app/controllers/super_manage.php index ee9f0d2..8c91513 100644 --- a/web/app/controllers/super_manage.php +++ b/web/app/controllers/super_manage.php @@ -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,12 +95,13 @@ $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; @@ -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 '
'; diff --git a/web/app/controllers/user_info.php b/web/app/controllers/user_info.php index f76c236..a5ab50c 100644 --- a/web/app/controllers/user_info.php +++ b/web/app/controllers/user_info.php @@ -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 { diff --git a/web/app/controllers/user_msg.php b/web/app/controllers/user_msg.php index bcea8e9..070ae32 100644 --- a/web/app/controllers/user_msg.php +++ b/web/app/controllers/user_msg.php @@ -4,51 +4,55 @@ } function handleMsgPost() { - global $myUser; - if (!isset($_POST['receiver'])) { - return 'fail'; - } - if (!isset($_POST['message'])) { - return 'fail'; - } - if (0 > strlen($_POST['message']) || strlen($_POST['message']) > 65535) { - return 'fail'; - } - $receiver = $_POST['receiver']; - $esc_message = DB::escape($_POST['message']); - $sender = $myUser['username']; + global $myUser; + if (!isset($_POST['receiver'])) { + return 'fail'; + } + if (!isset($_POST['message'])) { + return 'fail'; + } + if (0 > strlen($_POST['message']) || strlen($_POST['message']) > 65535) { + return 'fail'; + } + $receiver = $_POST['receiver']; + $esc_message = DB::escape($_POST['message']); + $sender = $myUser['username']; - if (!validateUsername($receiver) || !queryUser($receiver)) { - return 'fail'; - } + if (!validateUsername($receiver) || !queryUser($receiver)) { + return 'fail'; + } - DB::query("insert into user_msg (sender, receiver, message, send_time) values ('$sender', '$receiver', '$esc_message', now())"); - return "ok"; + DB::query("insert into user_msg (sender, receiver, message, send_time) values ('$sender', '$receiver', '$esc_message', now())"); + return "ok"; } function getConversations() { - global $myUser; - $username = $myUser['username']; - $result = DB::query( "select * from user_msg where sender = '$username' or receiver = '$username' order by send_time DESC" ); - $ret = array(); - while ($msg = DB::fetch($result)) { - if ($msg['sender'] !== $username) { - if (isset($ret[$msg['sender']])) { - $ret[$msg['sender']][1] |= ($msg['read_time'] == null); - continue; - } - $ret[$msg['sender']] = array($msg['send_time'], ($msg['read_time'] == null)); - } else { - if (isset($ret[$msg['receiver']])) continue; - $ret[$msg['receiver']] = array($msg['send_time'], 0); - } + global $myUser; + $username = $myUser['username']; + $result = DB::query( "select * from user_msg where sender = '$username' or receiver = '$username' order by send_time DESC" ); + $ret = array(); + while ($msg = DB::fetch($result)) { + if ($msg['sender'] !== $username) { + if (isset($ret[$msg['sender']])) { + $ret[$msg['sender']][1] |= ($msg['read_time'] == null); + continue; + } + $ret[$msg['sender']] = array($msg['send_time'], ($msg['read_time'] == null)); + } else { + if (isset($ret[$msg['receiver']])) { + continue; + } + $ret[$msg['receiver']] = array($msg['send_time'], 0); } - $res = []; - foreach ($ret as $name => $con) { - $res[] = [$con[0], $con[1], $name]; - } - usort($res, function($a, $b) { return -strcmp($a[0], $b[0]); }); - return json_encode($res); + } + $res = []; + foreach ($ret as $name => $con) { + $res[] = [$con[0], $con[1], $name]; + } + usort($res, function($a, $b) { + return -strcmp($a[0], $b[0]); + }); + return json_encode($res); } function getHistory() { @@ -95,11 +99,11 @@ EOD; */ if (isset($_POST['user_msg'])) { - die(handleMsgPost()); + die(handleMsgPost()); } elseif (isset($_GET['getConversations'])) { - die(getConversations()); + die(getConversations()); } elseif (isset($_GET['getHistory'])) { - die(getHistory()); + die(getHistory()); } ?> diff --git a/web/app/libs/uoj-contest-lib.php b/web/app/libs/uoj-contest-lib.php index 0e42bdb..bac6f04 100644 --- a/web/app/libs/uoj-contest-lib.php +++ b/web/app/libs/uoj-contest-lib.php @@ -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); @@ -190,7 +192,7 @@ function calcStandings($contest, $contest_data, &$score, &$standings, $update_co foreach ($contest_data['people'] as $person) { $score[$person[0]] = array(); } - foreach ($contest_data['data'] as $submission) { + foreach ($contest_data['data'] as $submission) { $penalty = (new DateTime($submission[1]))->getTimestamp() - $contest['start_time']->getTimestamp(); if ($contest['extra_config']['standings_version'] >= 2) { if ($submission[4] == 0) { @@ -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]); diff --git a/web/app/libs/uoj-data-lib.php b/web/app/libs/uoj-data-lib.php index 93ab34c..923c479 100644 --- a/web/app/libs/uoj-data-lib.php +++ b/web/app/libs/uoj-data-lib.php @@ -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) { diff --git a/web/app/libs/uoj-form-lib.php b/web/app/libs/uoj-form-lib.php index 7a96b5f..cf2b0d0 100644 --- a/web/app/libs/uoj-form-lib.php +++ b/web/app/libs/uoj-form-lib.php @@ -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())); @@ -53,7 +54,7 @@ $esc_err = htmlspecialchars($err); $err_str .= "$name: $esc_err
"; } - becomeMsgPage($err_str); + becomeMsgPage($err_str); } $fun = $this->handle; $fun($this->vdata); @@ -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']); } @@ -662,11 +663,11 @@ EOD; $languages = isset($req['languages']) ? $req['languages'] : $GLOBALS['uojSupportedLanguages']; $form->addSourceCodeInput("{$form_name}_{$req['name']}", UOJLocale::get('problems::source code').':'.$req['name'], $languages); } elseif ($req['type'] == "text") { - $form->addTextFileInput("{$form_name}_{$req['name']}", UOJLocale::get('problems::text file').':'.$req['file_name']); + $form->addTextFileInput("{$form_name}_{$req['name']}", UOJLocale::get('problems::text file').':'.$req['file_name']); } } - $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 = << @@ -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) { @@ -791,7 +794,7 @@ EOD; } foreach ($requirement as $req) { - $zip_file->addFromString($req['file_name'], $zip_content[$req['name']]); + $zip_file->addFromString($req['file_name'], $zip_content[$req['name']]); } $zip_file->close(); diff --git a/web/app/libs/uoj-html-lib.php b/web/app/libs/uoj-html-lib.php index 53a1688..b46d987 100644 --- a/web/app/libs/uoj-html-lib.php +++ b/web/app/libs/uoj-html-lib.php @@ -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 ''.$problem_title.''; @@ -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 ''.$problem_title.''; @@ -116,20 +116,21 @@ function getClickZanBlock($type, $id, $cnt, $val = null) { function getLongTablePageRawUri($page) { - $path = strtok(UOJContext::requestURI(), '?'); - $query_string = strtok('?'); - parse_str($query_string, $param); + $path = strtok(UOJContext::requestURI(), '?'); + $query_string = strtok('?'); + parse_str($query_string, $param); - $param['page'] = $page; - if ($page == 1) - unset($param['page']); - - if ($param) { - return $path . '?' . http_build_query($param); - } else { - return $path; - } + $param['page'] = $page; + 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)); } @@ -190,7 +191,7 @@ function getSubmissionStatusDetails($submission) { if ($submission['status_details'] !== '') { $status_img = $fly; $status_text = HTML::escape($submission['status_details']); - } else { + } else { $status_img = $think; $status_text = $out_status; } @@ -249,10 +250,12 @@ function echoSubmission($submission, $config, $user) { } echo ''; } - if (!isset($config['used_time_hidden'])) + if (!isset($config['used_time_hidden'])) { echo '', $used_time_str, ''; - if (!isset($config['used_memory_hidden'])) + } + if (!isset($config['used_memory_hidden'])) { echo '', $used_memory_str, ''; + } echo '', '', $submission['language'], '', ''; @@ -263,10 +266,12 @@ function echoSubmission($submission, $config, $user) { } echo '', $size_str, ''; - if (!isset($config['submit_time_hidden'])) + if (!isset($config['submit_time_hidden'])) { echo '', $submission['submit_time'], ''; - if (!isset($config['judge_time_hidden'])) + } + if (!isset($config['judge_time_hidden'])) { echo '', $submission['judge_time'], ''; + } echo ''; if ($show_status_details) { echo ''; @@ -282,24 +287,32 @@ function echoSubmissionsListOnlyOne($submission, $config, $user) { echo ''; echo ''; echo ''; - if (!isset($config['id_hidden'])) + if (!isset($config['id_hidden'])) { echo ''; - if (!isset($config['problem_hidden'])) + } + if (!isset($config['problem_hidden'])) { echo ''; - if (!isset($config['submitter_hidden'])) + } + if (!isset($config['submitter_hidden'])) { echo ''; - if (!isset($config['result_hidden'])) + } + if (!isset($config['result_hidden'])) { echo ''; - if (!isset($config['used_time_hidden'])) + } + if (!isset($config['used_time_hidden'])) { echo ''; - if (!isset($config['used_memory_hidden'])) + } + if (!isset($config['used_memory_hidden'])) { echo ''; + } echo ''; echo ''; - if (!isset($config['submit_time_hidden'])) + if (!isset($config['submit_time_hidden'])) { echo ''; - if (!isset($config['judge_time_hidden'])) + } + if (!isset($config['judge_time_hidden'])) { echo ''; + } echo ''; echo ''; echo ''; @@ -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 ''; echo ''; echo ''; - } - 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 '
'; if ($this->styler->show_small_tip) { echo '
', '小提示:点击横条可展开更详细的信息', '
'; - } - elseif ($this->styler->ioi_contest_is_running) { + } elseif ($this->styler->ioi_contest_is_running) { echo '
', 'IOI赛制比赛中不支持显示详细信息', '
'; } $this->_print_c($node); @@ -774,10 +785,12 @@ function echoHackDetails($hack_details, $name) { function echoHack($hack, $config, $user) { $problem = queryProblemBrief($hack['problem_id']); echo '
'; - if (!isset($config['id_hidden'])) + if (!isset($config['id_hidden'])) { echo ''; - if (!isset($config['submission_hidden'])) + } + if (!isset($config['submission_hidden'])) { echo ''; + } if (!isset($config['problem_hidden'])) { if ($hack['contest_id']) { echo ''; @@ -785,13 +798,14 @@ function echoHack($hack, $config, $user) { echo ''; } } - if (!isset($config['hacker_hidden'])) + if (!isset($config['hacker_hidden'])) { echo ''; - if (!isset($config['owner_hidden'])) + } + if (!isset($config['owner_hidden'])) { echo ''; - if (!isset($config['result_hidden'])) - { - if($hack['judge_time'] == null) { + } + if (!isset($config['result_hidden'])) { + if ($hack['judge_time'] == null) { echo ''; } elseif ($hack['success'] == null) { echo ''; @@ -800,13 +814,15 @@ function echoHack($hack, $config, $user) { } else { echo ''; } - } - else + } else { echo ''; - if (!isset($config['submit_time_hidden'])) + } + if (!isset($config['submit_time_hidden'])) { echo ''; - if (!isset($config['judge_time_hidden'])) + } + if (!isset($config['judge_time_hidden'])) { echo ''; + } echo ''; } function echoHackListOnlyOne($hack, $config, $user) { @@ -814,22 +830,30 @@ function echoHackListOnlyOne($hack, $config, $user) { echo '
ID'.UOJLocale::get('problems::problem').''.UOJLocale::get('problems::submitter').''.UOJLocale::get('problems::result').''.UOJLocale::get('problems::used time').''.UOJLocale::get('problems::used memory').''.UOJLocale::get('problems::language').''.UOJLocale::get('problems::file size').''.UOJLocale::get('problems::submit time').''.UOJLocale::get('problems::judge time').'
#', $hack['id'], '#', $hack['submission_id'], '', getContestProblemLink($problem, $hack['contest_id'], '!id_and_title'), '', getProblemLink($problem, '!id_and_title'), '', getUserLink($hack['hacker']), '', getUserLink($hack['owner']), 'WaitingJudgingFailed.Hidden', $hack['submit_time'], '', $hack['judge_time'], '
'; echo ''; echo ''; - if (!isset($config['id_hidden'])) + if (!isset($config['id_hidden'])) { echo ''; - if (!isset($config['submission_id_hidden'])) + } + if (!isset($config['submission_id_hidden'])) { echo ''; - if (!isset($config['problem_hidden'])) + } + if (!isset($config['problem_hidden'])) { echo ''; - if (!isset($config['hacker_hidden'])) + } + if (!isset($config['hacker_hidden'])) { echo ''; - if (!isset($config['owner_hidden'])) + } + if (!isset($config['owner_hidden'])) { echo ''; - if (!isset($config['result_hidden'])) + } + if (!isset($config['result_hidden'])) { echo ''; - if (!isset($config['submit_time_hidden'])) + } + if (!isset($config['submit_time_hidden'])) { echo ''; - if (!isset($config['judge_time_hidden'])) + } + if (!isset($config['judge_time_hidden'])) { echo ''; + } echo ''; echo ''; echo ''; @@ -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 .= ''; $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; diff --git a/web/app/libs/uoj-query-lib.php b/web/app/libs/uoj-query-lib.php index 73b3b89..4907ba1 100644 --- a/web/app/libs/uoj-query-lib.php +++ b/web/app/libs/uoj-query-lib.php @@ -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); diff --git a/web/app/libs/uoj-security-lib.php b/web/app/libs/uoj-security-lib.php index c174486..e095c70 100644 --- a/web/app/libs/uoj-security-lib.php +++ b/web/app/libs/uoj-security-lib.php @@ -4,7 +4,7 @@ function getPasswordToStore($password, $username) { return md5($username . $password); } function checkPassword($user, $password) { - return $user['password'] == md5($user['username'] . $password); + return $user['password'] == md5($user['username'] . $password); } function getPasswordClientSalt() { return UOJConfig::$data['security']['user']['client_salt']; @@ -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; diff --git a/web/app/libs/uoj-utility-lib.php b/web/app/libs/uoj-utility-lib.php index 211a8cd..675d310 100644 --- a/web/app/libs/uoj-utility-lib.php +++ b/web/app/libs/uoj-utility-lib.php @@ -1,7 +1,7 @@ $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; @@ -108,11 +108,11 @@ function uojTextEncode($str, $config = array()) { } } -function base64url_encode($data) { - return rtrim(strtr(base64_encode($data), '+/', '-_'), '='); +function base64url_encode($data) { + return rtrim(strtr(base64_encode($data), '+/', '-_'), '='); } -function base64url_decode($data) { - return base64_decode(str_pad(strtr($data, '-_', '+/'), strlen($data) % 4, '=', STR_PAD_RIGHT)); +function base64url_decode($data) { + return base64_decode(str_pad(strtr($data, '-_', '+/'), strlen($data) % 4, '=', STR_PAD_RIGHT)); } function blog_name_encode($name) { diff --git a/web/app/models/HTML.php b/web/app/models/HTML.php index 215faa1..509e08c 100644 --- a/web/app/models/HTML.php +++ b/web/app/models/HTML.php @@ -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]"; diff --git a/web/app/models/Paginator.php b/web/app/models/Paginator.php index 85a4cca..ed92695 100644 --- a/web/app/models/Paginator.php +++ b/web/app/models/Paginator.php @@ -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); diff --git a/web/app/models/UOJBlogEditor.php b/web/app/models/UOJBlogEditor.php index cb69583..0391629 100644 --- a/web/app/models/UOJBlogEditor.php +++ b/web/app/models/UOJBlogEditor.php @@ -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 ''; echoUOJPageFooter(array('ShowPageFooter' => false)); - } else if ($this->type == 'slide') { + } elseif ($this->type == 'slide') { uojIncludeView('slide', array_merge( UOJContext::pageConfig(), array( diff --git a/web/app/models/UOJContext.php b/web/app/models/UOJContext.php index 845858d..769a719 100644 --- a/web/app/models/UOJContext.php +++ b/web/app/models/UOJContext.php @@ -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']);
ID'.UOJLocale::get('problems::submission id').''.UOJLocale::get('problems::problem').''.UOJLocale::get('problems::hacker').''.UOJLocale::get('problems::owner').''.UOJLocale::get('problems::result').''.UOJLocale::get('problems::submit time').''.UOJLocale::get('problems::judge time').'