新增到第一页和到最后一页

This commit is contained in:
2024-10-11 14:45:34 +08:00
parent 74cd879ce2
commit 3f95886aa5

View File

@@ -1,16 +1,16 @@
<?php $show_title="$MSG_PROBLEMS - $OJ_NAME"; ?> <?php $show_title = "$MSG_PROBLEMS - $OJ_NAME"; ?>
<?php include("template/$OJ_TEMPLATE/header.php");?> <?php include("template/$OJ_TEMPLATE/header.php"); ?>
<div class="padding"> <div class="padding">
<div class="ui grid" style="margin-bottom: 10px; "> <div class="ui grid" style="margin-bottom: 10px; ">
<div class="row" style="white-space: nowrap; "> <div class="row" style="white-space: nowrap; ">
<div class="seven wide column"> <div class="seven wide column">
<form action="" method="get"> <form action="" method="get">
<div class="ui search" style="width: 280px; height: 28px; margin-top: -5.3px;float:left "> <div class="ui search" style="width: 280px; height: 28px; margin-top: -5.3px;float:left ">
<div class="ui left icon input" style="width: 100%; "> <div class="ui left icon input" style="width: 100%; ">
<input class="prompt" style="width: 100%; " type="text" placeholder=" <?php echo $MSG_TITLE;?> …" name="search" <input class="prompt" style="width: 100%; " type="text" placeholder=" <?php echo $MSG_TITLE; ?> …"
value="<?php if(isset($_GET['search']))echo htmlentities($_GET['search'],ENT_QUOTES,'UTF-8') ?>" name="search" value="<?php if (isset($_GET['search']))
> echo htmlentities($_GET['search'], ENT_QUOTES, 'UTF-8') ?>">
<i class="search icon"></i> <i class="search icon"></i>
</div> </div>
@@ -28,183 +28,213 @@
</div> </div>
</form> </form>
<!-- 管理员用来显示指定用户的对错情况 --> <!-- 管理员用来显示指定用户的对错情况 -->
<?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;float:left "> <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 left icon input" style="width: 100%; ">
<input class="prompt" style="width: 100%; " type="text" placeholder="用户ID" name="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']))
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') ?>">
>
<i class="search icon"></i> <i class="search icon"></i>
</div>
<div class="results" style="width: 100%; "></div>
</div> </div>
<div class="results" style="width: 100%; "></div> </form>
</div> <?php endif; ?>
</form>
</div> </div>
<div class="nine wide right aligned column"> <div class="nine wide right aligned column">
<div class="ui toggle checkbox" id="show_tag"> <div class="ui toggle checkbox" id="show_tag">
<style id="show_tag_style"></style> <style id="show_tag_style"></style>
<script> <script>
if (localStorage.getItem('show_tag') != '0') { if (localStorage.getItem('show_tag') != '0') {
document.write('<input type="checkbox" checked>'); document.write('<input type="checkbox" checked>');
document.getElementById('show_tag_style').innerHTML = '.show_tag_controled { white-space: nowrap; overflow: hidden; }'; document.getElementById('show_tag_style').innerHTML = '.show_tag_controled { white-space: nowrap; overflow: hidden; }';
} else { } else {
document.write('<input type="checkbox">'); document.write('<input type="checkbox">');
document.getElementById('show_tag_style').innerHTML = '.show_tag_controled { width: 0; white-space: nowrap; overflow: hidden; }'; document.getElementById('show_tag_style').innerHTML = '.show_tag_controled { width: 0; white-space: nowrap; overflow: hidden; }';
} }
</script> </script>
<script> <script>
$(function () { $(function () {
$('#show_tag').checkbox('setting', 'onChange', function () { $('#show_tag').checkbox('setting', 'onChange', function () {
let checked = $('#show_tag').checkbox('is checked'); let checked = $('#show_tag').checkbox('is checked');
localStorage.setItem('show_tag', checked ? '1' : '0'); localStorage.setItem('show_tag', checked ? '1' : '0');
if (checked) { if (checked) {
document.getElementById('show_tag_style').innerHTML = '.show_tag_controled { white-space: nowrap; overflow: hidden; }'; document.getElementById('show_tag_style').innerHTML = '.show_tag_controled { white-space: nowrap; overflow: hidden; }';
} else { } else {
document.getElementById('show_tag_style').innerHTML = '.show_tag_controled { width: 0; white-space: nowrap; overflow: hidden; }'; document.getElementById('show_tag_style').innerHTML = '.show_tag_controled { width: 0; white-space: nowrap; overflow: hidden; }';
} }
});
}); });
});
</script> </script>
<label><?php echo $MSG_SHOW_TAGS;?></label> <label><?php echo $MSG_SHOW_TAGS; ?></label>
</div> </div>
<div style="margin-left: 10px; display: inline-block; "> <div style="margin-left: 10px; display: inline-block; ">
<a style="margin-left: 10px; " href="category.php" class="ui labeled icon mini green button"><i class="plus icon"></i> <?php echo $MSG_SHOW_ALL_TAGS;?></a> <a style="margin-left: 10px; " href="category.php" class="ui labeled icon mini green button"><i
class="plus icon"></i> <?php echo $MSG_SHOW_ALL_TAGS; ?></a>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<?php if (!isset($_GET['list'])){ ?> <?php if (!isset($_GET['list'])) { ?>
<div style="margin-bottom: 30px; "> <div style="margin-bottom: 30px; ">
<?php <?php
if(!isset($page)) $page=1; if (!isset($page))
$page=intval($page); $page = 1;
$section=8; $page = intval($page);
$start=$page>$section?$page-$section:1; $section = 8;
$end=$page+$section>$view_total_page?$view_total_page:$page+$section; $start = $page > $section ? $page - $section : 1;
?> $end = $page + $section > $view_total_page ? $view_total_page : $page + $section;
<div style="text-align: center; "> function get_href($page, $postfix, $query_user_id)
<div class="ui pagination menu" style="box-shadow: none; "> {
<a class="<?php if($page==1) echo "disabled "; ?>icon item" href="<?php if($page<>1) echo "problemset.php?page=".($page-1).htmlentities($postfix,ENT_QUOTES,'UTF-8'); ?>" id="page_prev"> return "problemset.php?page=" . $page .
<i class="left chevron icon"></i> htmlentities($postfix, ENT_QUOTES, 'UTF-8') .
</a> "&query_user_id=" . $query_user_id;
<?php
for ($i=$start;$i<=$end;$i++){
echo "<a class=\"".($page==$i?"active ":"")."item\" href=\"problemset.php?page=".$i.htmlentities($postfix,ENT_QUOTES,'UTF-8')."\">".$i."</a>";
} }
?> ?>
<a class="<?php if($page==$view_total_page) echo "disabled "; ?> icon item" href="<?php if($page<>$view_total_page) echo "problemset.php?page=".($page+1).htmlentities($postfix,ENT_QUOTES,'UTF-8'); ?>" id="page_next"> <div style="text-align: center; ">
<i class="right chevron icon"></i> <div class="ui pagination menu" style="box-shadow: none; ">
</a> <a class="<?php if ($page == 1)
</div> echo "disabled "; ?>icon item" href="<?php if ($page <> 1)
</div> echo get_href(1, $postfix, $query_user_id); ?>" id="page_first">
</div> <i class="angle double left icon"></i>
<?php } ?> </a>
<a class="<?php if ($page == 1)
echo "disabled "; ?>icon item" href="<?php if ($page <> 1)
echo get_href($page - 1, $postfix, $query_user_id); ?>" id="page_prev">
<i class="left chevron icon"></i>
</a>
<?php
for ($i = $start; $i <= $end; $i++) {
echo "<a class=\"" . ($page == $i ? "active " : "") . "item\" href=\"" . get_href($i, $postfix, $query_user_id) . "\">" . $i . "</a>";
}
?>
<a class="<?php if ($page == $view_total_page)
echo "disabled "; ?> icon item" href="<?php if ($page <> $view_total_page)
echo get_href($page + 1, $postfix, $query_user_id); ?>" id="page_next">
<i class="right chevron icon"></i>
</a>
<a class="<?php if ($page == $view_total_page)
echo "disabled "; ?> icon item" href="<?php if ($page <> $view_total_page)
echo get_href($view_total_page, $postfix, $query_user_id); ?>" id="page_last">
<i class="angle double right icon"></i>
</a>
</div>
</div>
</div>
<?php } ?>
<table class="ui very basic center aligned table"> <table class="ui very basic center aligned table">
<thead> <thead>
<tr> <tr>
<?php if (isset($_SESSION[$OJ_NAME.'_'.'user_id'])){?> <?php if (isset($_SESSION[$OJ_NAME . '_' . 'user_id'])) { ?>
<th class="one wide"><?php echo $MSG_STATUS?></th> <th class="one wide"><?php echo $MSG_STATUS ?></th>
<?php } ?> <?php } ?>
<th class="one wide"><?php echo $MSG_PROBLEM_ID?></th> <th class="one wide"><?php echo $MSG_PROBLEM_ID ?></th>
<th class="left aligned"><?php echo $MSG_TITLE?></th> <th class="left aligned"><?php echo $MSG_TITLE ?></th>
<th class="one wide"><?php echo $MSG_SOVLED."/".$MSG_SUBMIT?></th> <th class="one wide"><?php echo $MSG_SOVLED . "/" . $MSG_SUBMIT ?></th>
<th class="one wide"><?php echo $MSG_PASS_RATE?></th> <th class="one wide"><?php echo $MSG_PASS_RATE ?></th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<?php <?php
$color=array("blue","teal","orange","pink","olive","red","yellow","green","purple"); $color = array("blue", "teal", "orange", "pink", "olive", "red", "yellow", "green", "purple");
$tcolor=0; $tcolor = 0;
$i=0; $i = 0;
foreach ($result as $row){ foreach ($result as $row) {
echo "<tr>"; echo "<tr>";
if (isset($_SESSION[$OJ_NAME.'_'.'user_id'])){ if (isset($_SESSION[$OJ_NAME . '_' . 'user_id'])) {
if (isset($sub_arr[$row['problem_id']])){ if (isset($sub_arr[$row['problem_id']])) {
if (isset($acc_arr[$row['problem_id']])) if (isset($acc_arr[$row['problem_id']]))
echo "<td><span class=\"status accepted\"><i class=\"checkmark icon\"></i></span></td>"; echo "<td><span class=\"status accepted\"><i class=\"checkmark icon\"></i></span></td>";
else else
echo "<td><span class=\"status wrong_answer\"><i class=\"remove icon\"></i></span></td>"; echo "<td><span class=\"status wrong_answer\"><i class=\"remove icon\"></i></span></td>";
}else{ } else {
echo "<td><span class=\"status\"><i class=\"icon\"></i></span></td>"; echo "<td><span class=\"status\"><i class=\"icon\"></i></span></td>";
}
}
echo "<td><b>".$row['problem_id']."</b></td>";
echo "<td class=\"left aligned\">";
echo "<a style=\"vertical-align: middle; \" href=\"problem.php?id=".$row['problem_id']."\">";
echo $row['title'];
echo "</a>";
if($row['defunct']=='Y')
{echo "<a href=admin/problem_df_change.php?id=".$row['problem_id']."&getkey=".$_SESSION[$OJ_NAME.'_'.'getkey'].">".("<span class=\"ui tiny red label\">未公开</span>")."</a>";}
echo "<div class=\"show_tag_controled\" style=\"float: right; \">";
//echo "<span class=\"ui header\">";
echo $view_problemset[$i][3];
//echo "</span></div>";
echo "</div>";
echo "</td>";
echo "<td><a href=\"status.php?problem_id=".$row['problem_id']."&jresult=4\">".$row['accepted']."/".$row['submit']."</a></td>";
// echo "<td><a href='status.php?problem_id=".$row['problem_id']."'>".$row['submit']."</a></td>";
if ($row['submit'] == 0) {
echo '<td><div class="progress" style="margin-bottom:-20px; "><div class="progress-bar progress-bar-danger" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width:0%;">0.000%</div></div></td>';
} else {
$percentage = round(100 * $row['accepted'] / $row['submit'], 3);
echo '<td><div class="progress" style="margin-bottom:-20px;"><div class="progress-bar progress-bar-success progress-bar-striped" role="progressbar" aria-valuenow="'.$percentage.'" aria-valuemin="0" aria-valuemax="100" style="width:'.$percentage.'%;">'.$percentage.'%</div></div></td>';
}
echo "</tr>";
$i++;
} }
?> }
echo "<td><b>" . $row['problem_id'] . "</b></td>";
echo "<td class=\"left aligned\">";
echo "<a style=\"vertical-align: middle; \" href=\"problem.php?id=" . $row['problem_id'] . "\">";
echo $row['title'];
echo "</a>";
if ($row['defunct'] == 'Y') {
echo "<a href=admin/problem_df_change.php?id=" . $row['problem_id'] . "&getkey=" . $_SESSION[$OJ_NAME . '_' . 'getkey'] . ">" . ("<span class=\"ui tiny red label\">未公开</span>") . "</a>";
}
echo "<div class=\"show_tag_controled\" style=\"float: right; \">";
//echo "<span class=\"ui header\">";
echo $view_problemset[$i][3];
//echo "</span></div>";
echo "</div>";
echo "</td>";
echo "<td><a href=\"status.php?problem_id=" . $row['problem_id'] . "&jresult=4\">" . $row['accepted'] . "/" . $row['submit'] . "</a></td>";
// echo "<td><a href='status.php?problem_id=".$row['problem_id']."'>".$row['submit']."</a></td>";
if ($row['submit'] == 0) {
echo '<td><div class="progress" style="margin-bottom:-20px; "><div class="progress-bar progress-bar-danger" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width:0%;">0.000%</div></div></td>';
} else {
$percentage = round(100 * $row['accepted'] / $row['submit'], 3);
echo '<td><div class="progress" style="margin-bottom:-20px;"><div class="progress-bar progress-bar-success progress-bar-striped" role="progressbar" aria-valuenow="' . $percentage . '" aria-valuemin="0" aria-valuemax="100" style="width:' . $percentage . '%;">' . $percentage . '%</div></div></td>';
}
echo "</tr>";
$i++;
}
?>
</tbody> </tbody>
</table><br> </table><br>
<?php if (!isset($_GET['list'])){ ?> <?php if (!isset($_GET['list'])) { ?>
<div style="margin-bottom: 30px; "> <div style="margin-bottom: 30px; ">
<?php
if(!isset($page)) $page=1;
$page=intval($page);
$section=8;
$start=$page>$section?$page-$section:1;
$end=$page+$section>$view_total_page?$view_total_page:$page+$section;
?>
<div style="text-align: center; ">
<div class="ui pagination menu" style="box-shadow: none; ">
<a class="<?php if($page==1) echo "disabled "; ?>icon item" href="<?php if($page<>1) echo "problemset.php?page=".($page-1).htmlentities($postfix,ENT_QUOTES,'UTF-8'); ?>" id="page_prev">
<i class="left chevron icon"></i>
</a>
<?php
for ($i=$start;$i<=$end;$i++){
echo "<a class=\"".($page==$i?"active ":"")."item\" href=\"problemset.php?page=".$i.htmlentities($postfix,ENT_QUOTES,'UTF-8')."\">".$i."</a>";
}
?>
<a class="<?php if($page==$view_total_page) echo "disabled "; ?> icon item" href="<?php if($page<>$view_total_page) echo "problemset.php?page=".($page+1).htmlentities($postfix,ENT_QUOTES,'UTF-8'); ?>" id="page_next">
<i class="right chevron icon"></i>
</a>
</div>
</div>
<?php } ?>
<script type="text/javascript" src="include/jquery.tablesorter.js"></script>
</div> <?php
<?php include("template/$OJ_TEMPLATE/footer.php");?> if (!isset($page))
$page = 1;
$page = intval($page);
$section = 8;
$start = $page > $section ? $page - $section : 1;
$end = $page + $section > $view_total_page ? $view_total_page : $page + $section;
?>
<div style="text-align: center; ">
<div class="ui pagination menu" style="box-shadow: none; ">
<a class="<?php if ($page == 1)
echo "disabled "; ?>icon item" href="<?php if ($page <> 1)
echo "problemset.php?page=" . ($page - 1) . htmlentities($postfix, ENT_QUOTES, 'UTF-8'); ?>"
id="page_prev">
<i class="left chevron icon"></i>
</a>
<?php
for ($i = $start; $i <= $end; $i++) {
echo "<a class=\"" . ($page == $i ? "active " : "") . "item\" href=\"problemset.php?page=" . $i . htmlentities($postfix, ENT_QUOTES, 'UTF-8') . "\">" . $i . "</a>";
}
?>
<a class="<?php if ($page == $view_total_page)
echo "disabled "; ?> icon item" href="<?php if ($page <> $view_total_page)
echo "problemset.php?page=" . ($page + 1) . htmlentities($postfix, ENT_QUOTES, 'UTF-8'); ?>"
id="page_next">
<i class="right chevron icon"></i>
</a>
</div>
</div>
<?php } ?>
<script type="text/javascript" src="include/jquery.tablesorter.js"></script>
</div>
<?php include("template/$OJ_TEMPLATE/footer.php"); ?>