修改私有比赛不再显示在不属于这个比赛的用户那里
This commit is contained in:
@@ -13,7 +13,8 @@ require_once('./include/const.inc.php');
|
|||||||
require_once('./include/setlang.php');
|
require_once('./include/setlang.php');
|
||||||
$view_title = $MSG_CONTEST;
|
$view_title = $MSG_CONTEST;
|
||||||
|
|
||||||
function formatTimeLength($length) {
|
function formatTimeLength($length)
|
||||||
|
{
|
||||||
$hour = 0;
|
$hour = 0;
|
||||||
$minute = 0;
|
$minute = 0;
|
||||||
$second = 0;
|
$second = 0;
|
||||||
@@ -25,8 +26,8 @@ function formatTimeLength($length) {
|
|||||||
$second = $length % 60;
|
$second = $length % 60;
|
||||||
|
|
||||||
if ($second > 0 && $second < 10) {
|
if ($second > 0 && $second < 10) {
|
||||||
$result = '0'.$second.' '.$MSG_SECONDS;}
|
$result = '0' . $second . ' ' . $MSG_SECONDS;
|
||||||
else if ($second>0) {
|
} else if ($second > 0) {
|
||||||
$result = $second . ' ' . $MSG_SECONDS;
|
$result = $second . ' ' . $MSG_SECONDS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -38,12 +39,11 @@ function formatTimeLength($length) {
|
|||||||
if ($result != '') {
|
if ($result != '') {
|
||||||
$result = '00' . ' ' . $MSG_MINUTES . ' ' . $result;
|
$result = '00' . ' ' . $MSG_MINUTES . ' ' . $result;
|
||||||
}
|
}
|
||||||
}
|
} else if ($minute > 0 && $minute < 10) {
|
||||||
else if ($minute>0 && $minute<10) {
|
|
||||||
if ($result != '') {
|
if ($result != '') {
|
||||||
$result = '0'.$minute.' '.$MSG_MINUTES.' '.$result;}
|
$result = '0' . $minute . ' ' . $MSG_MINUTES . ' ' . $result;
|
||||||
}
|
}
|
||||||
else {
|
} else {
|
||||||
$result = $minute . ' ' . $MSG_MINUTES . ' ' . $result;
|
$result = $minute . ' ' . $MSG_MINUTES . ' ' . $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -56,28 +56,23 @@ function formatTimeLength($length) {
|
|||||||
if ($result != '') {
|
if ($result != '') {
|
||||||
$result = '00' . ' ' . $MSG_HOURS . ' ' . $result;
|
$result = '00' . ' ' . $MSG_HOURS . ' ' . $result;
|
||||||
}
|
}
|
||||||
}
|
} else if ($hour > 0 && $hour < 10) {
|
||||||
else if ($hour>0 && $hour<10) {
|
|
||||||
if ($result != '') {
|
if ($result != '') {
|
||||||
$result = '0' . $hour . ' ' . $MSG_HOURS . ' ' . $result;
|
$result = '0' . $hour . ' ' . $MSG_HOURS . ' ' . $result;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
$result = $hour . ' ' . $MSG_HOURS . ' ' . $result;
|
$result = $hour . ' ' . $MSG_HOURS . ' ' . $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
$length = floor($length / 24);
|
$length = floor($length / 24);
|
||||||
$result = $length . $MSG_DAYS . ' ' . $result;
|
$result = $length . $MSG_DAYS . ' ' . $result;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
$result = $length . ' ' . $MSG_HOURS . ' ' . $result;
|
$result = $length . ' ' . $MSG_HOURS . ' ' . $result;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
$result = $length . ' ' . $MSG_MINUTES . ' ' . $result;
|
$result = $length . ' ' . $MSG_MINUTES . ' ' . $result;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
$result = $length . ' ' . $MSG_SECONDS;
|
$result = $length . ' ' . $MSG_SECONDS;
|
||||||
}
|
}
|
||||||
return $result;
|
return $result;
|
||||||
@@ -93,21 +88,24 @@ if (isset($_GET['cid'])) {
|
|||||||
//$result = pdo_query($sql,$cid,$cid,$cid);
|
//$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";
|
$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);
|
$result = mysql_query_cache($sql);
|
||||||
$view_problemset = Array();
|
$view_problemset = array();
|
||||||
|
|
||||||
$cnt = 0;
|
$cnt = 0;
|
||||||
$noip = (time() < $end_time) && (stripos($view_title, $OJ_NOIP_KEYWORD) !== false);
|
$noip = (time() < $end_time) && (stripos($view_title, $OJ_NOIP_KEYWORD) !== false);
|
||||||
if(isset($_SESSION[$OJ_NAME.'_'."administrator"])||
|
if (
|
||||||
|
isset($_SESSION[$OJ_NAME . '_' . "administrator"]) ||
|
||||||
isset($_SESSION[$OJ_NAME . '_' . "m$cid"]) ||
|
isset($_SESSION[$OJ_NAME . '_' . "m$cid"]) ||
|
||||||
isset($_SESSION[$OJ_NAME . '_' . "source_browser"]) ||
|
isset($_SESSION[$OJ_NAME . '_' . "source_browser"]) ||
|
||||||
isset($_SESSION[$OJ_NAME . '_' . "contest_creator"])
|
isset($_SESSION[$OJ_NAME . '_' . "contest_creator"])
|
||||||
) $noip=false;
|
)
|
||||||
|
$noip = false;
|
||||||
foreach ($result as $row) {
|
foreach ($result as $row) {
|
||||||
$view_problemset[$cnt][0] = "";
|
$view_problemset[$cnt][0] = "";
|
||||||
if (isset($_SESSION[$OJ_NAME . '_' . 'user_id'])) {
|
if (isset($_SESSION[$OJ_NAME . '_' . 'user_id'])) {
|
||||||
$ac = check_ac($cid, $cnt, $noip);
|
$ac = check_ac($cid, $cnt, $noip);
|
||||||
$sub = "";
|
$sub = "";
|
||||||
if($ac!="") $sub="?";
|
if ($ac != "")
|
||||||
|
$sub = "?";
|
||||||
if ($noip)
|
if ($noip)
|
||||||
$view_problemset[$cnt][0] = "$sub";
|
$view_problemset[$cnt][0] = "$sub";
|
||||||
else
|
else
|
||||||
@@ -120,8 +118,7 @@ if (isset($_GET['cid'])) {
|
|||||||
if ($now < $end_time) { //during contest/exam time
|
if ($now < $end_time) { //during contest/exam time
|
||||||
$view_problemset[$cnt][1] = "<a href='problem.php?cid=$cid&pid=$cnt'>" . $PID[$cnt] . "</a>";
|
$view_problemset[$cnt][1] = "<a href='problem.php?cid=$cid&pid=$cnt'>" . $PID[$cnt] . "</a>";
|
||||||
$view_problemset[$cnt][2] = "<a href='problem.php?cid=$cid&pid=$cnt'>" . $row['title'] . "</a>";
|
$view_problemset[$cnt][2] = "<a href='problem.php?cid=$cid&pid=$cnt'>" . $row['title'] . "</a>";
|
||||||
}
|
} else { //over contest time
|
||||||
else { //over contest time
|
|
||||||
//check the problem will be use remained contest/exam
|
//check the problem will be use remained contest/exam
|
||||||
$tpid = intval($row['problem_id']);
|
$tpid = intval($row['problem_id']);
|
||||||
$sql = "SELECT `problem_id` FROM `problem` WHERE `problem_id`=? AND `problem_id` IN (
|
$sql = "SELECT `problem_id` FROM `problem` WHERE `problem_id`=? AND `problem_id` IN (
|
||||||
@@ -136,8 +133,7 @@ if (isset($_GET['cid'])) {
|
|||||||
//if the problem will be use remained contes/exam don't show to other teachers and students
|
//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][1] = $PID[$cnt]; //hide the title after contest
|
||||||
$view_problemset[$cnt][2] = '--using in another private contest--';
|
$view_problemset[$cnt][2] = '--using in another private contest--';
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
$view_problemset[$cnt][1] = "<a href='problem.php?id=" . $row['problem_id'] . "'>" . $PID[$cnt] . "</a>";
|
$view_problemset[$cnt][1] = "<a href='problem.php?id=" . $row['problem_id'] . "'>" . $PID[$cnt] . "</a>";
|
||||||
if ($contest_ok)
|
if ($contest_ok)
|
||||||
$view_problemset[$cnt][2] = "<a href='problem.php?cid=$cid&pid=$cnt'>" . $row['title'] . "</a>";
|
$view_problemset[$cnt][2] = "<a href='problem.php?cid=$cid&pid=$cnt'>" . $row['title'] . "</a>";
|
||||||
@@ -156,8 +152,7 @@ if (isset($_GET['cid'])) {
|
|||||||
$view_problemset[$cnt][4] = $row['submit'];
|
$view_problemset[$cnt][4] = $row['submit'];
|
||||||
$cnt++;
|
$cnt++;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
$page = 1;
|
$page = 1;
|
||||||
if (isset($_GET['page']))
|
if (isset($_GET['page']))
|
||||||
$page = intval($_GET['page']);
|
$page = intval($_GET['page']);
|
||||||
@@ -174,7 +169,8 @@ else {
|
|||||||
$keyword = "";
|
$keyword = "";
|
||||||
|
|
||||||
if (isset($_POST['keyword'])) {
|
if (isset($_POST['keyword'])) {
|
||||||
$keyword = "%".$_POST['keyword']."%";}
|
$keyword = "%" . $_POST['keyword'] . "%";
|
||||||
|
}
|
||||||
|
|
||||||
//echo "$keyword";
|
//echo "$keyword";
|
||||||
$mycontests = "";
|
$mycontests = "";
|
||||||
@@ -209,7 +205,8 @@ else {
|
|||||||
foreach ($result as $row) {
|
foreach ($result as $row) {
|
||||||
$_SESSION[$OJ_NAME . '_c' . $row['contest_id']] = true;
|
$_SESSION[$OJ_NAME . '_c' . $row['contest_id']] = true;
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($_SESSION as $key => $value) {
|
foreach ($_SESSION as $key => $value) {
|
||||||
@@ -224,7 +221,8 @@ else {
|
|||||||
if (strlen($mycontests) > 0)
|
if (strlen($mycontests) > 0)
|
||||||
$mycontests = substr($mycontests, 1);
|
$mycontests = substr($mycontests, 1);
|
||||||
if (isset($_GET['my']) && $mycontests != "")
|
if (isset($_GET['my']) && $mycontests != "")
|
||||||
if(isset($_GET['my'])) $wheremy=" and( contest_id in ($mycontests) or user_id='".$_SESSION[$OJ_NAME.'_user_id']."')";
|
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";
|
||||||
@@ -234,15 +232,14 @@ else {
|
|||||||
$sql .= " limit " . strval($pstart) . "," . strval($pend);
|
$sql .= " limit " . strval($pstart) . "," . strval($pend);
|
||||||
|
|
||||||
$result = pdo_query($sql, $keyword);
|
$result = pdo_query($sql, $keyword);
|
||||||
}
|
} else {
|
||||||
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 = "SELECT * FROM contest WHERE contest.defunct='N' $wheremy ORDER BY contest_id DESC";
|
|
||||||
$sql .= " limit " . strval($pstart) . "," . strval($pend);
|
$sql .= " limit " . strval($pstart) . "," . strval($pend);
|
||||||
//echo $sql;
|
//echo $sql;
|
||||||
$result = mysql_query_cache($sql);
|
$result = mysql_query_cache($sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
$view_contest = Array();
|
$view_contest = array();
|
||||||
$i = 0;
|
$i = 0;
|
||||||
|
|
||||||
foreach ($result as $row) {
|
foreach ($result as $row) {
|
||||||
@@ -263,13 +260,11 @@ else {
|
|||||||
//past
|
//past
|
||||||
$view_contest[$i][2] = "<span class=text-muted>$MSG_Ended</span>" . " " . "<span class=text-muted>" . $row['end_time'] . "</span>";
|
$view_contest[$i][2] = "<span class=text-muted>$MSG_Ended</span>" . " " . "<span class=text-muted>" . $row['end_time'] . "</span>";
|
||||||
|
|
||||||
}
|
} else if ($now < $start_time) {
|
||||||
else if ($now<$start_time) {
|
|
||||||
//pending
|
//pending
|
||||||
$view_contest[$i][2] = "<span class=text-success>$MSG_Start</span>" . " " . $row['start_time'] . " ";
|
$view_contest[$i][2] = "<span class=text-success>$MSG_Start</span>" . " " . $row['start_time'] . " ";
|
||||||
$view_contest[$i][2] .= "<span class=text-success>$MSG_TotalTime</span>" . " " . formatTimeLength($length);
|
$view_contest[$i][2] .= "<span class=text-success>$MSG_TotalTime</span>" . " " . formatTimeLength($length);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
//running
|
//running
|
||||||
$view_contest[$i][2] = "<span class=text-danger>$MSG_Running</span>" . " " . $row['start_time'] . " ";
|
$view_contest[$i][2] = "<span class=text-danger>$MSG_Running</span>" . " " . $row['start_time'] . " ";
|
||||||
$view_contest[$i][2] .= "<span class=text-danger>$MSG_LeftTime</span>" . " " . formatTimeLength($left) . "</span>";
|
$view_contest[$i][2] .= "<span class=text-danger>$MSG_LeftTime</span>" . " " . formatTimeLength($left) . "</span>";
|
||||||
|
|||||||
@@ -31,7 +31,7 @@
|
|||||||
<?php if (isset($_SESSION[$OJ_NAME . '_' . 'administrator'])): ?>
|
<?php if (isset($_SESSION[$OJ_NAME . '_' . 'administrator'])): ?>
|
||||||
<form action="" method="get">
|
<form action="" method="get">
|
||||||
<div class="ui search" style="width: 280px; height: 28px; margin-top: -5.3px;">
|
<div class="ui search" style="width: 280px; height: 28px; margin-top: -5.3px;">
|
||||||
<div class="ui left icon input" style="width: 100%; ">
|
<div class="ui icon input" style="width: 100%; ">
|
||||||
<input class="prompt" style="width: 100%; " type="text" placeholder="用户ID" name="query_user_id" value="<?php if (isset($_GET['query_user_id']))
|
<input class="prompt" style="width: 100%; " type="text" placeholder="用户ID" name="query_user_id" value="<?php if (isset($_GET['query_user_id']))
|
||||||
echo htmlentities($_GET['query_user_id'], ENT_QUOTES, 'UTF-8') ?>">
|
echo htmlentities($_GET['query_user_id'], ENT_QUOTES, 'UTF-8') ?>">
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user