S2OJ/web/app/controllers/index.php

101 lines
3.4 KiB
PHP
Raw Normal View History

2016-07-18 16:39:37 +00:00
<?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 5");
2022-09-21 03:33:42 +00:00
$countdowns = DB::selectAll("select * from countdowns order by endtime asc");
$friend_links = DB::selectAll("select * from friend_links order by level desc, id asc");
2022-09-18 04:58:35 +00:00
?>
<?php echoUOJPageHeader(UOJConfig::$data['profile']['oj-name-short']) ?>
2022-04-03 11:33:50 +00:00
<div class="row">
<div class="col-sm-12 col-md-9">
<div class="card card-default">
<div class="card-body">
<table class="table table-sm">
2016-07-18 16:39:37 +00:00
<thead>
<tr>
<th style="width:60%"><?= UOJLocale::get('announcements') ?></th>
<th style="width:20%"></th>
<th style="width:20%"></th>
</tr>
</thead>
2022-04-03 11:33:50 +00:00
<tbody>
2016-07-18 16:39:37 +00:00
<?php $now_cnt = 0; ?>
<?php foreach ($blogs as $blog): ?>
<?php
2022-09-18 04:58:35 +00:00
$now_cnt++;
$new_tag = '';
if ((time() - strtotime($blog['post_time'])) / 3600 / 24 <= 7) {
$new_tag = '<sup style="color:red">&nbsp;new</sup>';
}
2016-07-18 16:39:37 +00:00
?>
<tr>
<td><a href="/blogs/<?= $blog['id'] ?>"><?= $blog['title'] ?></a><?= $new_tag ?></td>
2016-07-18 16:39:37 +00:00
<td>by <?= getUserLink($blog['poster']) ?></td>
<td><small><?= $blog['post_time'] ?></small></td>
</tr>
<?php endforeach ?>
<?php for ($i = $now_cnt + 1; $i <= 5; $i++): ?>
<tr><td colspan="233">&nbsp;</td></tr>
<?php endfor ?>
<tr><td class="text-right" colspan="233"><a href="/announcements"><?= UOJLocale::get('all the announcements') ?></a></td></tr>
</tbody>
</table>
</div>
</div>
2022-04-03 11:33:50 +00:00
<?php if (Auth::check() && isNormalUser($myUser)): ?>
<div class="mt-4">
<h3><?= UOJLocale::get('top solver') ?></h3>
<?php echoRanklist(array('echo_full' => true, 'top10' => true, 'by_accepted' => true)) ?>
<div class="text-center">
<a href="/solverlist"><?= UOJLocale::get('view all') ?></a>
</div>
</div>
2022-09-21 03:27:03 +00:00
<?php else: ?>
<div class="mt-4 card card-default">
<div class="card-body text-center">
<a role="button" class="btn btn-outline-primary" href="<?= HTML::url('/login') ?>">登录</a> 以查看更多内容。
</div>
</div>
2022-04-03 11:33:50 +00:00
<?php endif ?>
2016-07-18 16:39:37 +00:00
</div>
2022-04-03 11:33:50 +00:00
<div class="col-xs-6 col-sm-4 col-md-3">
<div class="d-none d-md-block">
<img class="media-object img-thumbnail" src="/images/logo.png" alt="Logo" />
</div>
<div class="card card-default mt-4">
<div class="card-body">
2022-04-03 13:27:40 +00:00
<h3 class="card-title" style="font-size: 1.25rem">倒计时</h3>
2022-09-21 02:58:45 +00:00
<ul class="pl-4 mb-0">
2022-04-03 11:33:50 +00:00
<?php foreach ($countdowns as $countdown): ?>
<?php
$enddate = strtotime($countdown['endtime']);
2022-09-18 04:58:35 +00:00
$nowdate = time();
$diff = floor(($enddate - $nowdate) / (24 * 60 * 60));
2022-04-03 11:33:50 +00:00
?>
2022-09-21 02:58:45 +00:00
<li>
2022-04-03 11:33:50 +00:00
<?php if ($diff > 0): ?>
距离 <b><?= $countdown['title'] ?></b> 还有 <b><?= $diff ?></b> 天。
<?php else: ?>
<b><?= $countdown['title'] ?></b> 已开始。
<?php endif ?>
2022-09-21 02:58:45 +00:00
</li>
2022-04-03 11:33:50 +00:00
<?php endforeach ?>
2022-09-21 03:33:42 +00:00
</ul>
2022-04-03 11:33:50 +00:00
</div>
2022-03-21 02:51:31 +00:00
</div>
2022-04-03 13:27:40 +00:00
<div class="card card-default mt-4">
<div class="card-body">
<h3 class="card-title" style="font-size: 1.25rem">友情链接</h3>
2022-09-21 02:58:45 +00:00
<ul class="pl-4 mb-0">
2022-09-21 03:33:42 +00:00
<?php foreach ($friend_links as $friend_link): ?>
<li>
<a href="<?= $friend_link['url'] ?>" target="_blank"><?= $friend_link['title'] ?></a>
</li>
<?php endforeach ?>
2022-04-03 13:27:40 +00:00
</ul>
</div>
</div>
2022-03-21 02:51:31 +00:00
</div>
</div>
2022-04-03 11:33:50 +00:00
2022-03-21 02:51:31 +00:00
2016-07-18 16:39:37 +00:00
<?php echoUOJPageFooter() ?>