8) $hardness = 0; } if (isset($_GET['search']) && trim($_GET['search']) != "") { $search = "%" . ($_GET['search']) . "%"; $filter_sql = " ( title like ? or source like ?)"; $filter_params[] = $search; $filter_params[] = $search; $limit_sql = " LIMIT " . ($page - 1) * $page_cnt . "," . $page_cnt; $postfix = "&search=" . urlencode($_GET['search']); } else if (isset($_GET['list']) && trim($_GET['list'] != "")) { $plist = explode(",", $_GET['list']); $pids = "0"; foreach ($plist as $pid) { $pid = intval($pid); $pids .= ",$pid"; } $filter_sql = " problem_id in ($pids) "; $order_by = "order by FIELD(problem_id,$pids)"; // 如果希望按难度顺序改成 order by accepted desc ; //$limit_sql = " LIMIT ".($page-1)*$page_cnt.",".$page_cnt; $limit_sql = ""; // list 不翻页 } else { $filter_sql = " 1"; $limit_sql = " LIMIT " . ($page - 1) * $page_cnt . "," . $page_cnt; } if ($hardness > 0) { $filter_sql .= " and hardness=?"; $filter_params[] = $hardness; $postfix .= "&hardness=" . $hardness; } //all submit //all acc $sub_arr = array(); $acc_arr = array(); if (isset($_SESSION[$OJ_NAME . '_' . 'user_id'])) { $user_id = $_SESSION[$OJ_NAME . '_' . 'user_id']; // 管理员可以选择看谁的对错信息 if (isset($_SESSION[$OJ_NAME . '_' . 'administrator']) && isset($_GET['query_user_id'])) { $user_id = $_GET['query_user_id']; } // 增加筛选题目的时候也要看学生的对错信息 $sql = "SELECT problem_id, MIN(result) AS result FROM solution WHERE user_id=? and result>=4 GROUP BY problem_id "; $result = pdo_query($sql, $user_id); foreach ($result as $row) { $sub_arr[$row['problem_id']] = true; if ($row['result'] == 4) $acc_arr[$row['problem_id']] = true; } } // Problem Page Navigator //if($OJ_SAE) $first=1; if (isset($_SESSION[$OJ_NAME . '_' . 'administrator'])) { //all problems //$limit = $limit_sql; } else if ($OJ_FREE_PRACTICE) { // open free practice without limit of contest using $filter_sql .= " and defunct='N' "; } else { //page problems (not include in contests period) $now = date('Y-m-d H:i', 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 ") "; } // End Page Setting 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 (count($filter_params) > 0) { $total = pdo_query($count_sql, ...$filter_params); $cnt = $total[0][0] / $page_cnt; $result = pdo_query($sql, ...$filter_params); } else { $total = mysql_query_cache($count_sql); $cnt = $total[0][0] / $page_cnt; $result = mysql_query_cache($sql); } echo ""; $view_total_page = ceil($cnt * 1.0); $cnt = 0; $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) { $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] = "
" . $row['title'] . "
"; ; $view_problemset[$i][3] = "
"; 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)]; if ($label_theme == "") $label_theme = "default"; $view_problemset[$i][3] .= "" . mb_substr($cat, 0, 10, 'utf8') . " "; } $view_problemset[$i][3] .= "
"; $view_problemset[$i][4] = "
" . $row['accepted'] . "
"; $view_problemset[$i][5] = "
" . $row['submit'] . "
"; $i++; } if (isset($_GET['ajax'])) { require("template/" . $OJ_TEMPLATE . "/problemset.php"); } else { require("template/" . $OJ_TEMPLATE . "/problemset.php"); } if (file_exists('./include/cache_end.php')) require_once('./include/cache_end.php'); ?>