From b6b9faddc8cda3f1dfb2cd1f3d548328660eb445 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=B5=A9=E6=96=8C?= Date: Wed, 4 Oct 2023 10:26:45 +0800 Subject: [PATCH] Update problemset.php --- trunk/web/problemset.php | 191 ++++++++++++++++++++------------------- 1 file changed, 97 insertions(+), 94 deletions(-) diff --git a/trunk/web/problemset.php b/trunk/web/problemset.php index 9b54829859e..8717c050261 100644 --- a/trunk/web/problemset.php +++ b/trunk/web/problemset.php @@ -1,6 +1,6 @@ - '$now' OR c.private =1)" . // original style , hidden all private contest problems - ") ORDER BY `problem_id` - "; + $now = strftime("%Y-%m-%d %H:%M",time()); + $filter_sql.=" and `defunct`='N' AND `problem_id` NOT IN ( + SELECT `problem_id` + FROM contest c + INNER JOIN `contest_problem` cp ON c.`contest_id` = cp.`contest_id` ". + " AND (c.`defunct` = 'N' AND '$now' '$now' OR c.private =1)" . // original style , hidden all private contest problems + ") ORDER BY `problem_id` + "; } // End Page Setting -pdo_query("SET sort_buffer_size = 1024*1024"); // Out of sort memory, consider increasing server sort buffer size -//echo htmlentities( $sql); - $sql = "SELECT * FROM (SELECT @ROWNUM := @ROWNUM + 1 AS ROWNUM, `problem_id`,`title`,`source`,`submit`,`accepted`,defunct FROM (select * from `problem` order by problem_id) problem, (SELECT @ROWNUM := 0) TEMP ORDER BY `problem_id`) A WHERE $filter_sql $limit_sql "; + pdo_query("SET sort_buffer_size = 1024*1024"); // Out of sort memory, consider increasing server sort buffer size + $sql = "SELECT `problem_id`,`title`,`source`,`submit`,`accepted`,defunct FROM problem A WHERE $filter_sql $order_by $limit_sql "; $count_sql= "SELECT count(1) from problem where $filter_sql "; + //echo htmlentities( $sql); if (isset($_GET['search']) && trim($_GET['search'])!="") { - $total = pdo_query($count_sql,$search,$search); - $cnt = $total[0][0] / $page_cnt; - $result = pdo_query($sql,$search,$search); + $total = pdo_query($count_sql,$search,$search); + $cnt = $total[0][0] / $page_cnt; + $result = pdo_query($sql,$search,$search); } else { - $total = mysql_query_cache($count_sql); - $cnt = $total[0][0] / $page_cnt; - $result = mysql_query_cache($sql); + $total = mysql_query_cache($count_sql); + $cnt = $total[0][0] / $page_cnt; + $result = mysql_query_cache($sql); } echo ""; @@ -123,54 +126,54 @@ $view_problemset = Array(); $i = 0; foreach ($result as $row) { - $view_problemset[$i] = Array(); - - if (isset($sub_arr[$row['problem_id']])) { - if (isset($acc_arr[$row['problem_id']])) - $view_problemset[$i][0] = "
Y
"; - else - $view_problemset[$i][0] = "
N
"; - } - else { - $view_problemset[$i][0] = "
"; - } - - $category = array(); - $cate = explode(" ",$row['source']); - foreach($cate as $cat){ + $view_problemset[$i] = Array(); + + if (isset($sub_arr[$row['problem_id']])) { + if (isset($acc_arr[$row['problem_id']])) + $view_problemset[$i][0] = "
Y
"; + else + $view_problemset[$i][0] = "
N
"; + } + else { + $view_problemset[$i][0] = "
"; + } + + $category = array(); + $cate = explode(" ",$row['source']); + foreach($cate as $cat){ $cat=trim($cat); if(mb_ereg("^http",$cat)){ $cat=get_domain($cat); } array_push($category,trim($cat)); } - $view_problemset[$i][1] = "
".$row['problem_id']."
"; - $view_problemset[$i][2] = "";; - $view_problemset[$i][3] = "
"; + $view_problemset[$i][1] = "
".$row['problem_id']."
"; + $view_problemset[$i][2] = "";; + $view_problemset[$i][3] = "
"; - foreach ($category as $cat) { - if(trim($cat)==""||trim($cat)==" ") - continue; + foreach ($category as $cat) { + if(trim($cat)==""||trim($cat)==" ") + continue; - $hash_num = hexdec(substr(md5($cat),0,7)); - $label_theme = $color_theme[$hash_num%count($color_theme)]; + $hash_num = hexdec(substr(md5($cat),0,7)); + $label_theme = $color_theme[$hash_num%count($color_theme)]; - if ($label_theme=="") - $label_theme = "default"; + if ($label_theme=="") + $label_theme = "default"; - $view_problemset[$i][3] .= "".mb_substr($cat,0,10,'utf8')." "; - } + $view_problemset[$i][3] .= "".mb_substr($cat,0,10,'utf8')." "; + } - $view_problemset[$i][3] .= "
"; - $view_problemset[$i][4] = ""; - $view_problemset[$i][5] = ""; - $i++; + $view_problemset[$i][3] .= "
"; + $view_problemset[$i][4] = ""; + $view_problemset[$i][5] = ""; + $i++; } if(isset($_GET['ajax'])){ - require("template/bs3/problemset.php"); + require("template/bs3/problemset.php"); }else{ - require("template/".$OJ_TEMPLATE."/problemset.php"); + require("template/".$OJ_TEMPLATE."/problemset.php"); } if(file_exists('./include/cache_end.php')) - require_once('./include/cache_end.php'); + require_once('./include/cache_end.php'); ?>