From d0fcca4eadf972016c75f893cf419e5833a15f3f Mon Sep 17 00:00:00 2001
From: klarkxy <278370456@qq.com>
Date: Sat, 12 Oct 2024 15:00:37 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=A7=81=E6=9C=89=E5=88=97?=
=?UTF-8?q?=E8=A1=A8=E6=9C=AA=E7=94=9F=E6=95=88=E7=9A=84BUG?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
web/admin/contest_edit.php | 415 +++++++++++++++++++------------------
1 file changed, 210 insertions(+), 205 deletions(-)
diff --git a/web/admin/contest_edit.php b/web/admin/contest_edit.php
index 38023b3..aaabe0b 100644
--- a/web/admin/contest_edit.php
+++ b/web/admin/contest_edit.php
@@ -1,4 +1,5 @@
+
@@ -8,260 +9,264 @@
-Please Login First!";
- exit(1);
- }
- echo ""."Edit-".$MSG_CONTEST."
";
- include_once("kindeditor.php") ;
+require_once("admin-header.php");
+if (!(isset($_SESSION[$OJ_NAME . '_' . 'administrator']) || isset($_SESSION[$OJ_NAME . '_' . 'contest_creator']))) {
+ echo "Please Login First!";
+ exit(1);
+}
+echo "" . "Edit-" . $MSG_CONTEST . "
";
+include_once("kindeditor.php");
?>
-
-
+ ", "", $description);
- $description = str_replace("", "
", $description);
- $description = str_replace(",", ",", $description);
+ $description = str_replace("", "", $description);
+ $description = str_replace("
", "
", $description);
+ $description = str_replace(",", ",", $description);
- $sql = "UPDATE `contest` SET `title`=?,`description`=?,`start_time`=?,`end_time`=?,`private`=?,`langmask`=?,`password`=? WHERE `contest_id`=?";
- //echo $sql;
- pdo_query($sql,$title,$description,$starttime,$endtime,$private,$langmask,$password,$cid);
+ $sql = "UPDATE `contest` SET `title`=?,`description`=?,`start_time`=?,`end_time`=?,`private`=?,`langmask`=?,`password`=? WHERE `contest_id`=?";
+ //echo $sql;
+ pdo_query($sql, $title, $description, $starttime, $endtime, $private, $langmask, $password, $cid);
- $sql = "DELETE FROM `contest_problem` WHERE `contest_id`=?";
- pdo_query($sql,$cid);
- $plist=trim($_POST['cproblem']);
- $pieces = explode(',', $plist);
+ $sql = "DELETE FROM `contest_problem` WHERE `contest_id`=?";
+ pdo_query($sql, $cid);
+ $plist = trim($_POST['cproblem']);
+ $pieces = explode(',', $plist);
- if(count($pieces)>0 && strlen($pieces[0])>0){
- $sql_1 = "INSERT INTO `contest_problem`(`contest_id`,`problem_id`,`num`) VALUES (?,?,?)";
-
- $plist="";
- pdo_query("update solution set num=-1 where contest_id=?",$cid);
- $num=0;
- for($i=0; $i 0) {
- if($plist) $plist.=",";
- $plist.=intval($pieces[$i]);
- pdo_query($sql_1,$cid,$pieces[$i],$num);
- $sql="UPDATE `contest_problem` SET `c_accepted`=(SELECT count(1) FROM `solution` WHERE `problem_id`=? and contest_id=? AND `result`=4) WHERE `problem_id`=? and contest_id=?";
- pdo_query($sql,$pid,$cid,$pid,$cid);
- $sql="UPDATE `contest_problem` SET `c_submit`=(SELECT count(1) FROM `solution` WHERE `problem_id`=? and contest_id=?) WHERE `problem_id`=? and contest_id=?";
- pdo_query($sql,$pid,$cid,$pid,$cid);
- $sql_2 = "update solution set num=? where contest_id=? and problem_id=?;";
- pdo_query($sql_2,$num,$cid,$pid);
- $num++;
- }else{
- print("Problem not exists:".$pieces[$i]."
\n");
+ if (count($pieces) > 0 && strlen($pieces[0]) > 0) {
+ $sql_1 = "INSERT INTO `contest_problem`(`contest_id`,`problem_id`,`num`) VALUES (?,?,?)";
+
+ $plist = "";
+ pdo_query("update solution set num=-1 where contest_id=?", $cid);
+ $num = 0;
+ for ($i = 0; $i < count($pieces); $i++) {
+ $sql = "select problem_id from problem where problem_id=?";
+ $pid = intval($pieces[$i]);
+ $has = pdo_query($sql, $pid);
+ if (count($has) > 0) {
+ if ($plist)
+ $plist .= ",";
+ $plist .= intval($pieces[$i]);
+ pdo_query($sql_1, $cid, $pieces[$i], $num);
+ $sql = "UPDATE `contest_problem` SET `c_accepted`=(SELECT count(1) FROM `solution` WHERE `problem_id`=? and contest_id=? AND `result`=4) WHERE `problem_id`=? and contest_id=?";
+ pdo_query($sql, $pid, $cid, $pid, $cid);
+ $sql = "UPDATE `contest_problem` SET `c_submit`=(SELECT count(1) FROM `solution` WHERE `problem_id`=? and contest_id=?) WHERE `problem_id`=? and contest_id=?";
+ pdo_query($sql, $pid, $cid, $pid, $cid);
+ $sql_2 = "update solution set num=? where contest_id=? and problem_id=?;";
+ pdo_query($sql_2, $num, $cid, $pid);
+ $num++;
+ } else {
+ print ("Problem not exists:" . $pieces[$i] . "
\n");
+ }
+ }
+
+ $sql = "update `problem` set defunct='N' where `problem_id` in ($plist)";
+ pdo_query($sql);
+ }
+
+ $sql = "DELETE FROM `testusers` WHERE `contest_id`=?";
+ pdo_query($sql, $cid);
+ $pieces = explode("\n", trim($_POST['ulist']));
+ $pieces = array_unique($pieces);
+ if (count($pieces) > 0 && strlen($pieces[0]) > 0) {
+ $sql_1 = "INSERT INTO `testusers`(`user_id`,`contest_id`) VALUES (?,?)";
+ for ($i = 0; $i < count($pieces); $i++) {
+ pdo_query($sql_1, trim($pieces[$i]), $cid);
}
}
- $sql = "update `problem` set defunct='N' where `problem_id` in ($plist)";
- pdo_query($sql) ;
- }
+ echo "";
+ exit();
+ } else {
+ $cid = intval($_GET['cid']);
+ $sql = "SELECT * FROM `contest` WHERE `contest_id`=?";
+ $result = pdo_query($sql, $cid);
- $sql = "DELETE FROM `privilege` WHERE `rightstr`=?";
- pdo_query($sql,"c$cid");
- $pieces = explode("\n", trim($_POST['ulist']));
- $pieces = array_unique($pieces);
- if(count($pieces)>0 && strlen($pieces[0])>0){
- $sql_1 = "INSERT INTO `privilege`(`user_id`,`rightstr`) VALUES (?,?)";
- for($i=0; $i
- echo "";
- exit();
-}else{
- $cid = intval($_GET['cid']);
- $sql = "SELECT * FROM `contest` WHERE `contest_id`=?";
- $result = pdo_query($sql,$cid);
-
- if(count($result)!=1){
- echo "No such Contest!";
- exit(0);
- }
-
- $row = $result[0];
- $starttime = $row['start_time'];
- $endtime = $row['end_time'];
- $private = $row['private'];
- $password = $row['password'];
- $langmask = $row['langmask'];
- $description = $row['description'];
- $title = htmlentities($row['title'],ENT_QUOTES,"UTF-8");
-
- $plist = "";
- $sql = "SELECT `problem_id` FROM `contest_problem` WHERE `contest_id`=? ORDER BY `num`";
- $result=pdo_query($sql,$cid);
-
- foreach($result as $row){
- if($plist) $plist .= ",";
- $plist.=$row[0];
- }
-
- $ulist = "";
- $sql = "SELECT `user_id` FROM `privilege` WHERE `rightstr`=? order by user_id";
- $result = pdo_query($sql,"c$cid");
-
- foreach($result as $row){
- if($ulist) $ulist .= "\n";
- $ulist .= $row[0];
- }
-}
-?>
-
-