S2OJ/web/app/controllers/index.php

205 lines
6.3 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-23 13:00:17 +00:00
2022-09-24 02:18:55 +00:00
if (!isset($_COOKIE['bootstrap4'])) {
2022-09-24 00:26:39 +00:00
$REQUIRE_LIB['bootstrap5'] = '';
}
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">
2022-09-26 23:57:01 +00:00
<div class="col-lg-9">
2022-04-03 11:33:50 +00:00
<div class="card card-default">
<div class="card-body">
2022-09-23 13:00:17 +00:00
<?php if (isset($REQUIRE_LIB['bootstrap5'])): ?>
<h4 class="card-title">
<?= UOJLocale::get('announcements') ?>
</h4>
<?php endif ?>
<table class="table table-sm">
2016-07-18 16:39:37 +00:00
<thead>
<tr>
2022-09-23 13:00:17 +00:00
<th style="width:60%">
<?php if (!isset($REQUIRE_LIB['bootstrap5'])): ?>
<?= UOJLocale::get('announcements') ?>
<?php endif ?>
</th>
2016-07-18 16:39:37 +00:00
<th style="width:20%"></th>
<th style="width:20%"></th>
</tr>
</thead>
2022-09-23 13:00:17 +00:00
<tbody>
<?php $now_cnt = 0; ?>
<?php foreach ($blogs as $blog): ?>
<?php
$now_cnt++;
$new_tag = '';
if ((time() - strtotime($blog['post_time'])) / 3600 / 24 <= 7) {
$new_tag = '<sup style="color:red">&nbsp;new</sup>';
}
?>
<tr>
<td>
<a href="/blogs/<?= $blog['id'] ?>"
<?php if (isset($REQUIRE_LIB['bootstrap5'])): ?>
class="text-decoration-none"
<?php endif ?>
><?= $blog['title'] ?></a>
<?= $new_tag ?>
</td>
<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 ?>
<?php if (!isset($REQUIRE_LIB['bootstrap5'])): ?>
<tr><td class="text-right" colspan="233"><a href="/announcements"><?= UOJLocale::get('all the announcements') ?></a></td></tr>
<?php endif ?>
2016-07-18 16:39:37 +00:00
</tbody>
</table>
2022-09-23 13:00:17 +00:00
<?php if (isset($REQUIRE_LIB['bootstrap5'])): ?>
<div class="text-end">
<a class="text-decoration-none" href="/announcements"><?= UOJLocale::get('all the announcements') ?></a>
</div>
<?php endif ?>
2016-07-18 16:39:37 +00:00
</div>
</div>
2022-09-23 22:58:20 +00:00
<?php if (Auth::check()): ?>
<?php if (isNormalUser($myUser)): ?>
2022-09-24 00:33:36 +00:00
<div class="mt-4
<?php if (isset($REQUIRE_LIB['bootstrap5'])): ?>
card
<?php endif ?>
">
<?php if (isset($REQUIRE_LIB['bootstrap5'])): ?>
2022-09-23 22:58:20 +00:00
<div class="card-body">
<h4 class="card-title"><?= UOJLocale::get('top solver') ?></h4>
2022-09-24 00:33:36 +00:00
<?php else: ?>
<h3><?= UOJLocale::get('top solver') ?></h3>
<?php endif ?>
2022-09-23 22:58:20 +00:00
<?php echoRanklist(array(
'echo_full' => true,
'top10' => true,
'by_accepted' => true,
2022-09-24 00:33:36 +00:00
'table_classes' => isset($REQUIRE_LIB['bootstrap5'])
? array('table', 'text-center')
: array('table', 'table-bordered', 'table-hover', 'table-striped', 'table-text-center'),
2022-09-23 22:58:20 +00:00
)) ?>
<div class="text-center">
<a href="/solverlist"
<?php if (isset($REQUIRE_LIB['bootstrap5'])): ?>
class="text-decoration-none"
<?php endif ?>
><?= UOJLocale::get('view all') ?></a>
</div>
2022-09-24 00:33:36 +00:00
<?php if (isset($REQUIRE_LIB['bootstrap5'])): ?>
2022-04-03 11:33:50 +00:00
</div>
2022-09-24 00:33:36 +00:00
<?php endif ?>
2022-04-03 11:33:50 +00:00
</div>
2022-09-23 22:58:20 +00:00
<?php endif ?>
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-09-23 14:10:57 +00:00
<div class="col">
2022-09-26 10:56:38 +00:00
<div class="d-none d-md-block mb-4">
2022-04-03 11:33:50 +00:00
<img class="media-object img-thumbnail" src="/images/logo.png" alt="Logo" />
</div>
2022-09-26 10:56:38 +00:00
<div class="card card-default mb-2">
2022-09-23 13:00:17 +00:00
<?php if (isset($REQUIRE_LIB['bootstrap5'])): ?>
2022-09-23 22:58:20 +00:00
<div class="card-header bg-white">
<b><?= UOJLocale::get('countdowns') ?></b>
2022-09-23 13:00:17 +00:00
</div>
<?php endif ?>
2022-04-03 11:33:50 +00:00
<div class="card-body">
2022-09-23 13:00:17 +00:00
<?php if (!isset($REQUIRE_LIB['bootstrap5'])): ?>
<h4 class="card-title" style="font-size: 1.25rem">
2022-09-24 11:13:16 +00:00
<?= UOJLocale::get('countdowns') ?>
</h4>
2022-09-23 13:00:17 +00:00
<?php endif ?>
2022-09-23 13:51:36 +00:00
<ul class="
<?php if (isset($REQUIRE_LIB['bootstrap5'])): ?>
list-unstyled
<?php else: ?>
pl-4
<?php endif ?> 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): ?>
<?= UOJLocale::get('x days until countdown title', $countdown['title'], $diff) ?>
2022-04-03 11:33:50 +00:00
<?php else: ?>
<?= UOJLocale::get("countdown title has begun", $countdown['title']) ?>
2022-04-03 11:33:50 +00:00
<?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-09-23 13:00:17 +00:00
<?php if (count($countdowns) == 0): ?>
<div class="text-center">
<?= UOJLocale::get('none') ?>
</div>
2022-09-23 13:00:17 +00:00
<?php endif ?>
2022-04-03 11:33:50 +00:00
</div>
2022-03-21 02:51:31 +00:00
</div>
2022-09-26 10:56:38 +00:00
<?php if (Auth::check()): ?>
2022-09-26 13:11:38 +00:00
<?php if (isset($REQUIRE_LIB['bootstrap5'])): ?>
<?php uojIncludeView('sidebar') ?>
<?php endif ?>
2022-09-26 10:56:38 +00:00
<?php endif ?>
<div class="card card-default mb-2">
2022-09-23 13:00:17 +00:00
<?php if (isset($REQUIRE_LIB['bootstrap5'])): ?>
2022-09-23 22:58:20 +00:00
<div class="card-header bg-white">
<b><?= UOJLocale::get('friend links') ?></b>
2022-09-23 13:00:17 +00:00
</div>
<?php endif ?>
2022-04-03 13:27:40 +00:00
<div class="card-body">
2022-09-23 13:00:17 +00:00
<?php if (!isset($REQUIRE_LIB['bootstrap5'])): ?>
<h4 class="card-title" style="font-size: 1.25rem">
<?= UOJLocale::get('friend links') ?>
</h4>
2022-09-23 13:00:17 +00:00
<?php endif ?>
2022-09-23 13:51:36 +00:00
<ul class="
<?php if (isset($REQUIRE_LIB['bootstrap5'])): ?>
ps-3
<?php else: ?>
pl-4
<?php endif ?>
mb-0">
2022-09-21 03:33:42 +00:00
<?php foreach ($friend_links as $friend_link): ?>
<li>
2022-09-23 13:51:36 +00:00
<a
<?php if (isset($REQUIRE_LIB['bootstrap5'])): ?>
class="text-decoration-none"
<?php endif ?>
href="<?= $friend_link['url'] ?>" target="_blank"><?= $friend_link['title'] ?></a>
2022-09-21 03:33:42 +00:00
</li>
<?php endforeach ?>
2022-04-03 13:27:40 +00:00
</ul>
2022-09-23 13:00:17 +00:00
<?php if (count($friend_links) == 0): ?>
<div class="text-center">
<?= UOJLocale::get('none') ?>
</div>
2022-09-23 13:00:17 +00:00
<?php endif ?>
2022-04-03 13:27:40 +00:00
</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() ?>