S2OJ/web/app/controllers/blogs.php

45 lines
1.4 KiB
PHP
Raw Normal View History

2016-07-18 16:39:37 +00:00
<?php
requirePHPLib('form');
2022-03-17 04:00:03 +00:00
if (!Auth::check()) {
2022-04-02 10:01:26 +00:00
become403Page(UOJLocale::get('need login'));
2022-03-17 04:00:03 +00:00
}
2022-04-03 10:18:17 +00:00
if (!isNormalUser($myUser)) {
become403Page();
}
2016-07-18 16:39:37 +00:00
function echoBlogCell($blog) {
echo '<tr>';
2022-03-17 03:30:38 +00:00
if ($blog['is_hidden']) {
echo '<td><span class="text-danger">[已隐藏]</span>' . getBlogLink($blog['id']) . '</td>';
} else {
echo '<td>' . getBlogLink($blog['id']) . '</td>';
}
2016-07-18 16:39:37 +00:00
echo '<td>' . getUserLink($blog['poster']) . '</td>';
echo '<td>' . $blog['post_time'] . '</td>';
echo '</tr>';
}
$header = <<<EOD
<tr>
<th width="60%">标题</th>
<th width="20%">发表者</th>
<th width="20%">发表日期</th>
</tr>
EOD;
$config = array();
$config['table_classes'] = array('table', 'table-hover');
?>
<?php echoUOJPageHeader(UOJLocale::get('blogs')) ?>
<?php if (Auth::check()): ?>
<div class="float-right">
<div class="btn-group">
<a href="<?= HTML::blog_url(Auth::id(), '/') ?>" class="btn btn-secondary btn-sm">我的博客首页</a>
<a href="<?= HTML::blog_url(Auth::id(), '/post/new/write')?>" class="btn btn-primary btn-sm"><span class="glyphicon glyphicon-edit"></span> 写新博客</a>
</div>
2016-07-18 16:39:37 +00:00
</div>
<?php endif ?>
<h3>博客总览</h3>
<?php echoLongTable(array('id', 'poster', 'title', 'post_time', 'zan', 'is_hidden'), 'blogs', isSuperUser($myUser) ? "1" : "is_hidden = 0 or poster = '{$myUser['username']}'", 'order by post_time desc', $header, 'echoBlogCell', $config); ?>
2016-07-18 16:39:37 +00:00
<?php echoUOJPageFooter() ?>