From 0464c77ffbe062510e07b312443d2c64efbacda3 Mon Sep 17 00:00:00 2001
From: klarkxy <278370456@qq.com>
Date: Fri, 11 Oct 2024 15:03:36 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=A7=81=E6=9C=89=E6=AF=94?=
=?UTF-8?q?=E8=B5=9B=E4=B8=8D=E5=86=8D=E6=98=BE=E7=A4=BA=E5=9C=A8=E4=B8=8D?=
=?UTF-8?q?=E5=B1=9E=E4=BA=8E=E8=BF=99=E4=B8=AA=E6=AF=94=E8=B5=9B=E7=9A=84?=
=?UTF-8?q?=E7=94=A8=E6=88=B7=E9=82=A3=E9=87=8C?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
web/contest.php | 327 +++++++++++++++---------------
web/template/syzoj/problemset.php | 2 +-
2 files changed, 162 insertions(+), 167 deletions(-)
diff --git a/web/contest.php b/web/contest.php
index 8da030e..e5b4564 100644
--- a/web/contest.php
+++ b/web/contest.php
@@ -1,8 +1,8 @@
- =60) {
- $second = $length%60;
-
- if ($second>0 && $second<10) {
- $result = '0'.$second.' '.$MSG_SECONDS;}
- else if ($second>0) {
- $result = $second.' '.$MSG_SECONDS;
- }
+ if ($length >= 60) {
+ $second = $length % 60;
- $length = floor($length/60);
- if ($length >= 60) {
- $minute = $length%60;
-
- if ($minute==0) {
- if ($result != '') {
- $result = '00'.' '.$MSG_MINUTES.' '.$result;
- }
- }
- else if ($minute>0 && $minute<10) {
- if ($result != '') {
- $result = '0'.$minute.' '.$MSG_MINUTES.' '.$result;}
+ if ($second > 0 && $second < 10) {
+ $result = '0' . $second . ' ' . $MSG_SECONDS;
+ } else if ($second > 0) {
+ $result = $second . ' ' . $MSG_SECONDS;
+ }
+
+ $length = floor($length / 60);
+ if ($length >= 60) {
+ $minute = $length % 60;
+
+ if ($minute == 0) {
+ if ($result != '') {
+ $result = '00' . ' ' . $MSG_MINUTES . ' ' . $result;
}
- else {
- $result = $minute.' '.$MSG_MINUTES.' '.$result;
+ } else if ($minute > 0 && $minute < 10) {
+ if ($result != '') {
+ $result = '0' . $minute . ' ' . $MSG_MINUTES . ' ' . $result;
}
-
- $length = floor($length/60);
+ } else {
+ $result = $minute . ' ' . $MSG_MINUTES . ' ' . $result;
+ }
- if ($length >= 24) {
- $hour = $length%24;
+ $length = floor($length / 60);
- if ($hour==0) {
+ if ($length >= 24) {
+ $hour = $length % 24;
+
+ if ($hour == 0) {
if ($result != '') {
- $result = '00'.' '.$MSG_HOURS.' '.$result;
+ $result = '00' . ' ' . $MSG_HOURS . ' ' . $result;
}
- }
- else if ($hour>0 && $hour<10) {
- if($result != '') {
- $result = '0'.$hour.' '.$MSG_HOURS.' '.$result;
+ } else if ($hour > 0 && $hour < 10) {
+ if ($result != '') {
+ $result = '0' . $hour . ' ' . $MSG_HOURS . ' ' . $result;
}
- }
- else {
- $result = $hour.' '.$MSG_HOURS.' '.$result;
+ } else {
+ $result = $hour . ' ' . $MSG_HOURS . ' ' . $result;
}
$length = floor($length / 24);
- $result = $length .$MSG_DAYS.' '.$result;
- }
- else {
- $result = $length.' '.$MSG_HOURS.' '.$result;
+ $result = $length . $MSG_DAYS . ' ' . $result;
+ } else {
+ $result = $length . ' ' . $MSG_HOURS . ' ' . $result;
}
+ } else {
+ $result = $length . ' ' . $MSG_MINUTES . ' ' . $result;
}
- else {
- $result = $length.' '.$MSG_MINUTES.' '.$result;
- }
- }
- else {
- $result = $length.' '.$MSG_SECONDS;
+ } else {
+ $result = $length . ' ' . $MSG_SECONDS;
}
return $result;
}
$now = time();
if (isset($_GET['cid'])) {
-
- require_once("contest-check.php");
-
+
+ require_once("contest-check.php");
+
//$sql = "SELECT * FROM (SELECT `problem`.`title` AS `title`,`problem`.`problem_id` AS `pid`,source AS source, contest_problem.num as pnum FROM `contest_problem`,`problem` WHERE `contest_problem`.`problem_id`=`problem`.`problem_id` AND `contest_problem`.`contest_id`=? ORDER BY `contest_problem`.`num`) problem LEFT JOIN (SELECT problem_id pid1,count(distinct(user_id)) accepted FROM solution WHERE result=4 AND contest_id=? GROUP BY pid1) p1 ON problem.pid=p1.pid1 LEFT JOIN (SELECT problem_id pid2,count(1) submit FROM solution WHERE contest_id=? GROUP BY pid2) p2 ON problem.pid=p2.pid2 ORDER BY pnum";//AND `problem`.`defunct`='N'
//$result = pdo_query($sql,$cid,$cid,$cid);
$sql = "select p.title,p.problem_id,p.source,cp.num as pnum,cp.c_accepted accepted,cp.c_submit submit from problem p inner join contest_problem cp on p.problem_id = cp.problem_id and cp.contest_id=$cid order by cp.num";
$result = mysql_query_cache($sql);
- $view_problemset = Array();
+ $view_problemset = array();
$cnt = 0;
- $noip = (time()<$end_time) && (stripos($view_title,$OJ_NOIP_KEYWORD)!==false);
- if(isset($_SESSION[$OJ_NAME.'_'."administrator"])||
- isset($_SESSION[$OJ_NAME.'_'."m$cid"])||
- isset($_SESSION[$OJ_NAME.'_'."source_browser"])||
- isset($_SESSION[$OJ_NAME.'_'."contest_creator"])
- ) $noip=false;
- foreach($result as $row) {
+ $noip = (time() < $end_time) && (stripos($view_title, $OJ_NOIP_KEYWORD) !== false);
+ if (
+ isset($_SESSION[$OJ_NAME . '_' . "administrator"]) ||
+ isset($_SESSION[$OJ_NAME . '_' . "m$cid"]) ||
+ isset($_SESSION[$OJ_NAME . '_' . "source_browser"]) ||
+ isset($_SESSION[$OJ_NAME . '_' . "contest_creator"])
+ )
+ $noip = false;
+ foreach ($result as $row) {
$view_problemset[$cnt][0] = "";
- if (isset($_SESSION[$OJ_NAME.'_'.'user_id'])){
- $ac=check_ac($cid,$cnt,$noip);
- $sub="";
- if($ac!="") $sub="?";
- if($noip)
- $view_problemset[$cnt][0] = "$sub";
- else
- $view_problemset[$cnt][0] = "$ac" ;
+ if (isset($_SESSION[$OJ_NAME . '_' . 'user_id'])) {
+ $ac = check_ac($cid, $cnt, $noip);
+ $sub = "";
+ if ($ac != "")
+ $sub = "?";
+ if ($noip)
+ $view_problemset[$cnt][0] = "$sub";
+ else
+ $view_problemset[$cnt][0] = "$ac";
- }else
+ } else
$view_problemset[$cnt][0] = "";
- if($now < $end_time) { //during contest/exam time
- $view_problemset[$cnt][1] = "".$PID[$cnt]."";
- $view_problemset[$cnt][2] = "".$row['title']."";
- }
- else { //over contest time
+ if ($now < $end_time) { //during contest/exam time
+ $view_problemset[$cnt][1] = "" . $PID[$cnt] . "";
+ $view_problemset[$cnt][2] = "" . $row['title'] . "";
+ } else { //over contest time
//check the problem will be use remained contest/exam
$tpid = intval($row['problem_id']);
$sql = "SELECT `problem_id` FROM `problem` WHERE `problem_id`=? AND `problem_id` IN (
@@ -132,15 +129,14 @@ if (isset($_GET['cid'])) {
$tresult = pdo_query($sql, $tpid);
- if (intval($tresult) != 0 && !isset($_SESSION[$OJ_NAME.'_'."m$cid"]) ) {
+ if (intval($tresult) != 0 && !isset($_SESSION[$OJ_NAME . '_' . "m$cid"])) {
//if the problem will be use remained contes/exam don't show to other teachers and students
$view_problemset[$cnt][1] = $PID[$cnt]; //hide the title after contest
$view_problemset[$cnt][2] = '--using in another private contest--';
- }
- else {
- $view_problemset[$cnt][1] = "".$PID[$cnt]."";
- if($contest_ok)
- $view_problemset[$cnt][2] = "".$row['title']."";
+ } else {
+ $view_problemset[$cnt][1] = "" . $PID[$cnt] . "";
+ if ($contest_ok)
+ $view_problemset[$cnt][2] = "" . $row['title'] . "";
else
$view_problemset[$cnt][2] = $row['title'];
}
@@ -152,147 +148,146 @@ if (isset($_GET['cid'])) {
$view_problemset[$cnt][3] = $row['accepted'];
else
$view_problemset[$cnt][3] = "";
-
- $view_problemset[$cnt][4] = $row['submit'];
- $cnt++;
- }
-}
-else {
+
+ $view_problemset[$cnt][4] = $row['submit'];
+ $cnt++;
+ }
+} else {
$page = 1;
if (isset($_GET['page']))
$page = intval($_GET['page']);
$page_cnt = 25;
- $pstart = $page_cnt*$page-$page_cnt;
+ $pstart = $page_cnt * $page - $page_cnt;
$pend = $page_cnt;
$rows = pdo_query("select count(1) from contest where defunct='N'");
if ($rows)
$total = $rows[0][0];
-
- $view_total_page = intval($total/$page_cnt)+1;
- $keyword = "";
+
+ $view_total_page = intval($total / $page_cnt) + 1;
+ $keyword = "";
if (isset($_POST['keyword'])) {
- $keyword = "%".$_POST['keyword']."%";}
+ $keyword = "%" . $_POST['keyword'] . "%";
+ }
//echo "$keyword";
$mycontests = "";
$wheremy = "";
- if (isset($_SESSION[$OJ_NAME.'_user_id'])) {
+ if (isset($_SESSION[$OJ_NAME . '_user_id'])) {
$sql = "select distinct contest_id from solution where contest_id>0 and user_id=?";
- $result = pdo_query($sql,$_SESSION[$OJ_NAME.'_user_id']);
+ $result = pdo_query($sql, $_SESSION[$OJ_NAME . '_user_id']);
foreach ($result as $row) {
- $mycontests .= ",".$row[0];
- }
+ $mycontests .= "," . $row[0];
+ }
- $len = mb_strlen($OJ_NAME.'_');
- $user_id = $_SESSION[ $OJ_NAME . '_' . 'user_id' ];
+ $len = mb_strlen($OJ_NAME . '_');
+ $user_id = $_SESSION[$OJ_NAME . '_' . 'user_id'];
- if($user_id){
- // 已登录的
- $sql = "SELECT * FROM `privilege` WHERE `user_id`=?";
- $result = pdo_query( $sql, $user_id );
+ if ($user_id) {
+ // 已登录的
+ $sql = "SELECT * FROM `privilege` WHERE `user_id`=?";
+ $result = pdo_query($sql, $user_id);
- // 刷新各种权限
- foreach ( $result as $row ){
- if(isset($row[ 'valuestr' ])){
- $_SESSION[ $OJ_NAME . '_' . $row[ 'rightstr' ] ] = $row[ 'valuestr' ];
- }else {
- $_SESSION[ $OJ_NAME . '_' . $row[ 'rightstr' ] ] = true;
- }
- }
- if(isset($_SESSION[ $OJ_NAME . '_vip' ])) { // VIP mark can access all [VIP] marked contest
- $sql="select contest_id from contest where title like '%[VIP]%'";
- $result=pdo_query($sql);
- foreach ($result as $row){
- $_SESSION[ $OJ_NAME . '_c' .$row['contest_id'] ] = true;
- }
- };
- }
+ // 刷新各种权限
+ foreach ($result as $row) {
+ if (isset($row['valuestr'])) {
+ $_SESSION[$OJ_NAME . '_' . $row['rightstr']] = $row['valuestr'];
+ } else {
+ $_SESSION[$OJ_NAME . '_' . $row['rightstr']] = true;
+ }
+ }
+ if (isset($_SESSION[$OJ_NAME . '_vip'])) { // VIP mark can access all [VIP] marked contest
+ $sql = "select contest_id from contest where title like '%[VIP]%'";
+ $result = pdo_query($sql);
+ foreach ($result as $row) {
+ $_SESSION[$OJ_NAME . '_c' . $row['contest_id']] = true;
+ }
+ }
+ ;
+ }
foreach ($_SESSION as $key => $value) {
- if ((mb_substr($key,$len,1)=='m' || mb_substr($key,$len,1)=='c') && intval(mb_substr($key,$len+1))>0) {
- //echo substr($key,1)."
";
- $mycontests .= ",".intval(mb_substr($key,$len+1));
+ if ((mb_substr($key, $len, 1) == 'm' || mb_substr($key, $len, 1) == 'c') && intval(mb_substr($key, $len + 1)) > 0) {
+ //echo substr($key,1)."
";
+ $mycontests .= "," . intval(mb_substr($key, $len + 1));
}
}
//echo "=====>$mycontests<====";
- if (strlen($mycontests)>0)
- $mycontests=substr($mycontests,1);
- if (isset($_GET['my'])&&$mycontests!="")
- if(isset($_GET['my'])) $wheremy=" and( contest_id in ($mycontests) or user_id='".$_SESSION[$OJ_NAME.'_user_id']."')";
+ if (strlen($mycontests) > 0)
+ $mycontests = substr($mycontests, 1);
+ if (isset($_GET['my']) && $mycontests != "")
+ if (isset($_GET['my']))
+ $wheremy = " and( contest_id in ($mycontests) or user_id='" . $_SESSION[$OJ_NAME . '_user_id'] . "')";
}
- $sql = "SELECT * FROM `contest` WHERE `defunct`='N' ORDER BY `contest_id` DESC LIMIT 1000";
+ $sql = "SELECT * FROM `contest` WHERE `defunct`='N' ORDER BY `contest_id` DESC LIMIT 1000";
if ($keyword) {
$sql = "SELECT * FROM contest WHERE contest.defunct='N' AND contest.title LIKE ? $wheremy ORDER BY contest_id DESC";
- $sql .= " limit ".strval($pstart).",".strval($pend);
+ $sql .= " limit " . strval($pstart) . "," . strval($pend);
- $result = pdo_query($sql,$keyword);
- }
- else {
- $sql = "SELECT * FROM contest WHERE contest.defunct='N' $wheremy ORDER BY contest_id DESC";
- $sql .= " limit ".strval($pstart).",".strval($pend);
+ $result = pdo_query($sql, $keyword);
+ } else {
+ $sql = "SELECT * FROM contest WHERE contest.defunct='N' and ( `private` =0 or `contest_id` in (select `contest_id` from `testusers` where `user_id`=? )) ORDER BY contest_id DESC";
+ $sql .= " limit " . strval($pstart) . "," . strval($pend);
//echo $sql;
$result = mysql_query_cache($sql);
}
- $view_contest = Array();
+ $view_contest = array();
$i = 0;
foreach ($result as $row) {
$view_contest[$i][0] = $row['contest_id'];
- if (trim($row['title'])=="")
- $row['title'] = $MSG_CONTEST.$row['contest_id'];
+ if (trim($row['title']) == "")
+ $row['title'] = $MSG_CONTEST . $row['contest_id'];
- $view_contest[$i][1] = "".$row['title']."";
+ $view_contest[$i][1] = "" . $row['title'] . "";
$start_time = strtotime($row['start_time']);
$end_time = strtotime($row['end_time']);
$now = time();
- $length = $end_time-$start_time;
- $left = $end_time-$now;
+ $length = $end_time - $start_time;
+ $left = $end_time - $now;
- if ($end_time<=$now) {
+ if ($end_time <= $now) {
//past
- $view_contest[$i][2] = "$MSG_Ended"." "."".$row['end_time']."";
+ $view_contest[$i][2] = "$MSG_Ended" . " " . "" . $row['end_time'] . "";
- }
- else if ($now<$start_time) {
+ } else if ($now < $start_time) {
//pending
- $view_contest[$i][2] = "$MSG_Start"." ".$row['start_time']." ";
- $view_contest[$i][2] .= "$MSG_TotalTime"." ".formatTimeLength($length);
- }
- else {
+ $view_contest[$i][2] = "$MSG_Start" . " " . $row['start_time'] . " ";
+ $view_contest[$i][2] .= "$MSG_TotalTime" . " " . formatTimeLength($length);
+ } else {
//running
- $view_contest[$i][2] = "$MSG_Running"." ".$row['start_time']." ";
- $view_contest[$i][2] .= "$MSG_LeftTime"." ".formatTimeLength($left)."";
- }
+ $view_contest[$i][2] = "$MSG_Running" . " " . $row['start_time'] . " ";
+ $view_contest[$i][2] .= "$MSG_LeftTime" . " " . formatTimeLength($left) . "";
+ }
- $private = intval($row['private']);
- if ($private==0)
- $view_contest[$i][4] = "$MSG_Public";
- else
- $view_contest[$i][5] = "$MSG_Private";
+ $private = intval($row['private']);
+ if ($private == 0)
+ $view_contest[$i][4] = "$MSG_Public";
+ else
+ $view_contest[$i][5] = "$MSG_Private";
- $view_contest[$i][6] = $row['user_id'];
+ $view_contest[$i][6] = $row['user_id'];
- $i++;
- }
+ $i++;
+ }
}
/////////////////////////Template
if (isset($_GET['cid']))
- require("template/".$OJ_TEMPLATE."/contest.php");
+ require("template/" . $OJ_TEMPLATE . "/contest.php");
else
- require("template/".$OJ_TEMPLATE."/contestset.php");
+ require("template/" . $OJ_TEMPLATE . "/contestset.php");
/////////////////////////Common foot
if (file_exists('./include/cache_end.php'))
require_once('./include/cache_end.php');
-?>
+?>
\ No newline at end of file
diff --git a/web/template/syzoj/problemset.php b/web/template/syzoj/problemset.php
index 0645479..90df204 100644
--- a/web/template/syzoj/problemset.php
+++ b/web/template/syzoj/problemset.php
@@ -31,7 +31,7 @@