|
|
@@ -1,15 +1,39 @@
|
|
|
<?php
|
|
|
$blogs = DB::selectAll("select blogs.id, title, poster, post_time from important_blogs, blogs where is_hidden = 0 and important_blogs.blog_id = blogs.id order by level desc, important_blogs.blog_id desc limit 8");
|
|
|
+$activateusers = DB::selectAll("select submitter, count(*) as cnt from submissions where datediff(now(), submit_time) <= 30 group by submitter order by cnt desc limit 12;");
|
|
|
$topusers = DB::selectAll("select username, rating, qq, motto from user_info order by rating desc, username asc limit 12;");
|
|
|
$topblogs = DB::selectAll("select id from blogs order by zan desc limit 10;");
|
|
|
$songs_data = htmlspecialchars(json_encode(DB::selectAll("select * from songs;")), ENT_QUOTES, 'UTF-8');
|
|
|
|
|
|
-$submdata = DB::selectAll("select yearweek(submit_time, 1) as weeknr, date(submit_time - interval weekday(submit_time) day) as weekst, count(*) as cnt from submissions group by weeknr, weekst order by weekst;");
|
|
|
-$submjson = htmlspecialchars(json_encode($submdata), ENT_QUOTES, 'UTF-8');
|
|
|
-requireLib('flot');
|
|
|
+// 服务器数据看板
|
|
|
+$today_submit_num = DB::selectCount("select count(*) from submissions where date(submit_time) = date(now())");
|
|
|
+$today_ac_num = DB::selectCount("select count(*) from submissions where date(submit_time) = date(now()) and score = 100");
|
|
|
+$month_submit_num = DB::selectCount("select count(*) from submissions where year(submit_time) = year(now()) and month(submit_time) = month(now())");
|
|
|
+$month_ac_num = DB::selectCount("select count(*) from submissions where year(submit_time) = year(now()) and month(submit_time) = month(now()) and score = 100");
|
|
|
+$total_submit_num = DB::selectCount("select count(*) from submissions");
|
|
|
+$total_ac_num = DB::selectCount("select count(*) from submissions where score = 100");
|
|
|
+$total_problem_num = DB::selectCount("select count(*) from problems where is_hidden = 0");
|
|
|
+$total_user_num = DB::selectCount("select count(*) from user_info");
|
|
|
+
|
|
|
+// 最近比赛:未结束的按开始时间升序取,不足 5 场时补最近结束的
|
|
|
+$recent_contests = array();
|
|
|
+$result = DB::selectAll("select * from contests where status != 'finished' order by start_time asc, id asc limit 5");
|
|
|
+foreach ($result as $contest) {
|
|
|
+ genMoreContestInfo($contest);
|
|
|
+ $recent_contests[] = $contest;
|
|
|
+}
|
|
|
+if (count($recent_contests) < 5) {
|
|
|
+ $need = 5 - count($recent_contests);
|
|
|
+ $result = DB::selectAll("select * from contests where status = 'finished' order by start_time desc, id desc limit $need");
|
|
|
+ foreach ($result as $contest) {
|
|
|
+ genMoreContestInfo($contest);
|
|
|
+ $recent_contests[] = $contest;
|
|
|
+ }
|
|
|
+}
|
|
|
?>
|
|
|
<?php echoUOJPageHeader(UOJConfig::$data['profile']['oj-name-short']) ?>
|
|
|
<div id="songs-data" data-songs='<?php echo $songs_data; ?>'></div>
|
|
|
+
|
|
|
<div class="row shadow my-4 wyoj-topcard">
|
|
|
<div class="card-body">
|
|
|
<div class="row">
|
|
|
@@ -186,31 +210,123 @@ requireLib('flot');
|
|
|
</div>
|
|
|
</div>
|
|
|
|
|
|
-<!--
|
|
|
-<div class="row shadow my-4 wyoj-topcard" id="recommender-zone">
|
|
|
- <div class="col-12 p-4">
|
|
|
- <h3>服务器信息</h3>
|
|
|
- <div id="submissions-data" data-submissions_data='<?= $submjson ?>'></div>
|
|
|
- <div style="position: relative; width: 100%; padding-top: 20%;">
|
|
|
- <div id="submissions-plot" class="w-100 h-100" style="position: absolute; top: 0; left: 0;"></div>
|
|
|
- </div>
|
|
|
- <div style="position: relative; width: 100%; padding-top: 20%;">
|
|
|
- <div id="storage-plot" class="w-100 h-100" style="position: absolute; top: 0; left: 0;"></div>
|
|
|
+<div class="row shadow my-4 wyoj-topcard">
|
|
|
+ <div class="col-lg-6 p-4">
|
|
|
+ <h3>服务器数据</h3>
|
|
|
+ <div class="row">
|
|
|
+ <div class="col-6 col-lg-3 mb-3">
|
|
|
+ <div class="card h-100 p-3 text-center stat-card">
|
|
|
+ <div class="stat-icon"><span class="glyphicon glyphicon-flash"></span></div>
|
|
|
+ <div class="stat-num"><?= $today_submit_num ?></div>
|
|
|
+ <div class="stat-label">今日提交</div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="col-6 col-lg-3 mb-3">
|
|
|
+ <div class="card h-100 p-3 text-center stat-card">
|
|
|
+ <div class="stat-icon"><span class="glyphicon glyphicon-ok"></span></div>
|
|
|
+ <div class="stat-num"><?= $today_ac_num ?></div>
|
|
|
+ <div class="stat-label">今日通过</div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="col-6 col-lg-3 mb-3">
|
|
|
+ <div class="card h-100 p-3 text-center stat-card">
|
|
|
+ <div class="stat-icon"><span class="glyphicon glyphicon-send"></span></div>
|
|
|
+ <div class="stat-num"><?= $month_submit_num ?></div>
|
|
|
+ <div class="stat-label">本月提交</div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="col-6 col-lg-3 mb-3">
|
|
|
+ <div class="card h-100 p-3 text-center stat-card">
|
|
|
+ <div class="stat-icon"><span class="glyphicon glyphicon-check"></span></div>
|
|
|
+ <div class="stat-num"><?= $month_ac_num ?></div>
|
|
|
+ <div class="stat-label">本月通过</div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="col-6 col-lg-3 mb-3">
|
|
|
+ <div class="card h-100 p-3 text-center stat-card">
|
|
|
+ <div class="stat-icon"><span class="glyphicon glyphicon-tasks"></span></div>
|
|
|
+ <div class="stat-num"><?= $total_submit_num ?></div>
|
|
|
+ <div class="stat-label">总提交</div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="col-6 col-lg-3 mb-3">
|
|
|
+ <div class="card h-100 p-3 text-center stat-card">
|
|
|
+ <div class="stat-icon"><span class="glyphicon glyphicon-star"></span></div>
|
|
|
+ <div class="stat-num"><?= $total_ac_num ?></div>
|
|
|
+ <div class="stat-label">总通过</div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="col-6 col-lg-3 mb-3">
|
|
|
+ <div class="card h-100 p-3 text-center stat-card">
|
|
|
+ <div class="stat-icon"><span class="glyphicon glyphicon-list-alt"></span></div>
|
|
|
+ <div class="stat-num"><?= $total_problem_num ?></div>
|
|
|
+ <div class="stat-label">题目总数</div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="col-6 col-lg-3 mb-3">
|
|
|
+ <div class="card h-100 p-3 text-center stat-card">
|
|
|
+ <div class="stat-icon"><span class="glyphicon glyphicon-user"></span></div>
|
|
|
+ <div class="stat-num"><?= $total_user_num ?></div>
|
|
|
+ <div class="stat-label">注册用户</div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
</div>
|
|
|
+ <div class="col-lg-6 p-4">
|
|
|
+ <h3>最近比赛</h3>
|
|
|
+ <?php if (empty($recent_contests)): ?>
|
|
|
+ <p class="text-muted">暂无比赛</p>
|
|
|
+ <?php else: ?>
|
|
|
+ <table class="table contest-table">
|
|
|
+ <tbody>
|
|
|
+ <?php foreach ($recent_contests as $contest): ?>
|
|
|
+ <tr>
|
|
|
+ <td class="contest-name">
|
|
|
+ <a href="<?= HTML::url('/contest/' . $contest['id']) ?>"><?= $contest['name'] ?></a>
|
|
|
+ <?php if ($contest['cur_progress'] == CONTEST_NOT_STARTED): ?>
|
|
|
+ <span class="badge badge-info">即将开始</span>
|
|
|
+ <span class="contest-countdown" id="recent-contest-countdown-<?= $contest['id'] ?>"></span>
|
|
|
+ <?php elseif ($contest['cur_progress'] == CONTEST_IN_PROGRESS): ?>
|
|
|
+ <span class="badge badge-success">进行中</span>
|
|
|
+ <?php elseif ($contest['cur_progress'] == CONTEST_PENDING_FINAL_TEST): ?>
|
|
|
+ <span class="badge badge-warning">等待出分</span>
|
|
|
+ <?php elseif ($contest['cur_progress'] == CONTEST_TESTING): ?>
|
|
|
+ <span class="badge badge-warning">最终评测中</span>
|
|
|
+ <?php else: ?>
|
|
|
+ <span class="badge badge-secondary">已结束</span>
|
|
|
+ <?php endif ?>
|
|
|
+ </td>
|
|
|
+ <td class="contest-info"><?= $contest['start_time_str'] ?></td>
|
|
|
+ <td class="contest-info"><?= round($contest['last_min'] / 60, 2) ?>h</td>
|
|
|
+ </tr>
|
|
|
+ <?php endforeach ?>
|
|
|
+ </tbody>
|
|
|
+ </table>
|
|
|
+ <?php endif ?>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
--->
|
|
|
-
|
|
|
+<script type="text/javascript">
|
|
|
+<?php foreach ($recent_contests as $contest): ?>
|
|
|
+<?php if ($contest['cur_progress'] == CONTEST_NOT_STARTED): ?>
|
|
|
+$('#recent-contest-countdown-<?= $contest['id'] ?>').countdown(<?= $contest['start_time']->getTimestamp() - UOJTime::$time_now->getTimestamp() ?>);
|
|
|
+<?php endif ?>
|
|
|
+<?php endforeach ?>
|
|
|
+</script>
|
|
|
<div class="row shadow my-4 wyoj-topcard">
|
|
|
<div class="col-12 p-4">
|
|
|
- <h3>博客广场</h3>
|
|
|
+ <h3>活跃排行榜</h3>
|
|
|
</div>
|
|
|
-
|
|
|
- <?php
|
|
|
- foreach ($topblogs as $id) echo echoBlogCard(queryBlog($id['id']));
|
|
|
- ?>
|
|
|
+ <?php foreach($activateusers as $username): ?>
|
|
|
+ <?php $user = queryUser($username['submitter']); ?>
|
|
|
+ <div class="col-md-3 mb-4">
|
|
|
+ <div class="card h-100 p-3 text-center">
|
|
|
+ <img class="uoj-avatar mx-auto mb-2" src=<?= "https://q.qlogo.cn/g?b=qq&nk=" . $user['qq'] . "&s=100" ?> alt="...">
|
|
|
+ <span class="mb-2"><?= getUserLink($user['username']) ?></span>
|
|
|
+ <span class="text-center text-bottom"><?= $user['motto'] ?></span>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <?php endforeach ?>
|
|
|
</div>
|
|
|
-
|
|
|
<div class="row shadow my-4 wyoj-topcard">
|
|
|
<div class="col-12 p-4">
|
|
|
<h3>比赛排行榜</h3>
|
|
|
@@ -225,55 +341,14 @@ requireLib('flot');
|
|
|
</div>
|
|
|
<?php endforeach ?>
|
|
|
</div>
|
|
|
-<script>
|
|
|
-(function() {
|
|
|
- const submissions_data_raw = JSON.parse(document.getElementById('submissions-data').dataset.submissions_data);
|
|
|
- const submissions_data = submissions_data_raw.map(x => [Number(new Date(x['weekst'])), Number(x['cnt'])]);
|
|
|
- console.log(submissions_data);
|
|
|
-
|
|
|
- var dataset = [
|
|
|
- {
|
|
|
- label: "提交数",
|
|
|
- data: submissions_data,
|
|
|
- yaxis: 1,
|
|
|
- lines: { show: true },
|
|
|
- points: { show: true }
|
|
|
- },
|
|
|
- ];
|
|
|
-
|
|
|
- var options1 = {
|
|
|
- yaxes: [
|
|
|
- {
|
|
|
- position: "left",
|
|
|
- min: 0,
|
|
|
- max: 10000,
|
|
|
- axisLabelUseCanvas: true,
|
|
|
- axisLabelFontSizePixels: 12
|
|
|
- },
|
|
|
- {
|
|
|
- position: "right",
|
|
|
- min: 0,
|
|
|
- max: 10000,
|
|
|
- tickDecimals: 0,
|
|
|
- axisLabelUseCanvas: true,
|
|
|
- axisLabelFontSizePixels: 12
|
|
|
- }
|
|
|
- ],
|
|
|
- xais: {
|
|
|
- mode: 'time',
|
|
|
- timeformat: "%Y-%m-%d",
|
|
|
- minTickSize: [1, 'day']
|
|
|
- },
|
|
|
- grid: {
|
|
|
- hoverable: true,
|
|
|
- },
|
|
|
- legend: {
|
|
|
- position: "ne"
|
|
|
- }
|
|
|
- };
|
|
|
- $.plot($("#submissions-plot"), dataset, options1);
|
|
|
-}) ();
|
|
|
-</script>
|
|
|
|
|
|
+<div class="row shadow my-4 wyoj-topcard">
|
|
|
+ <div class="col-12 p-4">
|
|
|
+ <h3>博客广场</h3>
|
|
|
+ </div>
|
|
|
|
|
|
+ <?php
|
|
|
+ foreach ($topblogs as $id) echo echoBlogCard(queryBlog($id['id']));
|
|
|
+ ?>
|
|
|
+</div>
|
|
|
<?php echoUOJPageFooter() ?>
|