mirror of
https://github.com/renbaoshuo/S2OJ.git
synced 2024-11-23 20:58:42 +00:00
Compare commits
4 Commits
c4792a3b30
...
b7a0ee7fda
Author | SHA1 | Date | |
---|---|---|---|
b7a0ee7fda | |||
f57fa8a895 | |||
6112612d88 | |||
a09e3a21e7 |
@ -409,6 +409,30 @@ LOCK TABLES `custom_test_submissions` WRITE;
|
|||||||
/*!40000 ALTER TABLE `custom_test_submissions` ENABLE KEYS */;
|
/*!40000 ALTER TABLE `custom_test_submissions` ENABLE KEYS */;
|
||||||
UNLOCK TABLES;
|
UNLOCK TABLES;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Table structure for table `friend_links`
|
||||||
|
--
|
||||||
|
|
||||||
|
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||||
|
/*!40101 SET character_set_client = utf8mb4 */;
|
||||||
|
CREATE TABLE `friend_links` (
|
||||||
|
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||||
|
`title` varchar(40) NOT NULL,
|
||||||
|
`url` varchar(100) NOT NULL,
|
||||||
|
`level` int(10) NOT NULL DEFAULT 10,
|
||||||
|
PRIMARY KEY (`id`)
|
||||||
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;
|
||||||
|
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Dumping data for table `friend_links`
|
||||||
|
--
|
||||||
|
|
||||||
|
LOCK TABLES `friend_links` WRITE;
|
||||||
|
/*!40000 ALTER TABLE `friend_links` DISABLE KEYS */;
|
||||||
|
/*!40000 ALTER TABLE `friend_links` ENABLE KEYS */;
|
||||||
|
UNLOCK TABLES;
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Table structure for table `groups`
|
-- Table structure for table `groups`
|
||||||
--
|
--
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?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");
|
$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");
|
||||||
$countdowns = DB::selectAll("select * from countdowns order by endtime asc limit 5")
|
$countdowns = DB::selectAll("select * from countdowns order by endtime asc");
|
||||||
|
$friend_links = DB::selectAll("select * from friend_links order by level desc, id asc");
|
||||||
?>
|
?>
|
||||||
<?php echoUOJPageHeader(UOJConfig::$data['profile']['oj-name-short']) ?>
|
<?php echoUOJPageHeader(UOJConfig::$data['profile']['oj-name-short']) ?>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
@ -47,6 +48,12 @@
|
|||||||
<a href="/solverlist"><?= UOJLocale::get('view all') ?></a>
|
<a href="/solverlist"><?= UOJLocale::get('view all') ?></a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<?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>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-xs-6 col-sm-4 col-md-3">
|
<div class="col-xs-6 col-sm-4 col-md-3">
|
||||||
@ -56,34 +63,33 @@
|
|||||||
<div class="card card-default mt-4">
|
<div class="card card-default mt-4">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<h3 class="card-title" style="font-size: 1.25rem">倒计时</h3>
|
<h3 class="card-title" style="font-size: 1.25rem">倒计时</h3>
|
||||||
<div>
|
<ul class="pl-4 mb-0">
|
||||||
<?php foreach ($countdowns as $countdown): ?>
|
<?php foreach ($countdowns as $countdown): ?>
|
||||||
<?php
|
<?php
|
||||||
$enddate = strtotime($countdown['endtime']);
|
$enddate = strtotime($countdown['endtime']);
|
||||||
$nowdate = time();
|
$nowdate = time();
|
||||||
$diff = floor(($enddate - $nowdate) / (24 * 60 * 60));
|
$diff = floor(($enddate - $nowdate) / (24 * 60 * 60));
|
||||||
?>
|
?>
|
||||||
<p class="card-text">
|
<li>
|
||||||
<?php if ($diff > 0): ?>
|
<?php if ($diff > 0): ?>
|
||||||
距离 <b><?= $countdown['title'] ?></b> 还有 <b><?= $diff ?></b> 天。
|
距离 <b><?= $countdown['title'] ?></b> 还有 <b><?= $diff ?></b> 天。
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
<b><?= $countdown['title'] ?></b> 已开始。
|
<b><?= $countdown['title'] ?></b> 已开始。
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
</p>
|
</li>
|
||||||
<?php endforeach ?>
|
<?php endforeach ?>
|
||||||
</div>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="card card-default mt-4">
|
<div class="card card-default mt-4">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<h3 class="card-title" style="font-size: 1.25rem">友情链接</h3>
|
<h3 class="card-title" style="font-size: 1.25rem">友情链接</h3>
|
||||||
<ul class="pl-4">
|
<ul class="pl-4 mb-0">
|
||||||
<li>
|
<?php foreach ($friend_links as $friend_link): ?>
|
||||||
<a href="http://www.sjzez.com">石家庄二中</a>
|
<li>
|
||||||
</li>
|
<a href="<?= $friend_link['url'] ?>" target="_blank"><?= $friend_link['title'] ?></a>
|
||||||
<li>
|
</li>
|
||||||
<a href="http://www.sjzezsyxx.com">石家庄二中实验学校</a>
|
<?php endforeach ?>
|
||||||
</li>
|
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -339,25 +339,32 @@
|
|||||||
$countdown_adder->handle = function() {
|
$countdown_adder->handle = function() {
|
||||||
$new_countdown_title = $_POST['new_countdown_title'];
|
$new_countdown_title = $_POST['new_countdown_title'];
|
||||||
$new_countdown_endtime = $_POST['new_countdown_endtime'];
|
$new_countdown_endtime = $_POST['new_countdown_endtime'];
|
||||||
$new_countdown_title = DB::escape($new_countdown_title);
|
$esc_countdown_title = DB::escape($new_countdown_title);
|
||||||
|
|
||||||
DB::query("insert into countdowns (title, endtime) values ('$new_countdown_title', '$new_countdown_endtime')");
|
DB::query("insert into countdowns (title, endtime) values ('$esc_countdown_title', '$new_countdown_endtime')");
|
||||||
};
|
};
|
||||||
$countdown_adder->runAtServer();
|
$countdown_adder->runAtServer();
|
||||||
|
|
||||||
$countdown_deleter = new UOJForm('delete_countdown');
|
$countdown_deleter = new UOJForm('delete_countdown');
|
||||||
$countdown_deleter->submit_button_config['align'] = 'compressed';
|
$countdown_deleter->submit_button_config['align'] = 'compressed';
|
||||||
$countdown_deleter->addInput('delete_countdown_id', 'text', 'ID', '',
|
$countdown_deleter->addInput('delete_countdown_id', 'text', 'ID', '',
|
||||||
function ($delete_countdown_id) {
|
function ($x) {
|
||||||
|
if (!validateUInt($x)) {
|
||||||
|
return 'ID不合法';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!DB::selectFirst("select * from countdowns where id = $x")) {
|
||||||
|
return '倒计时不存在';
|
||||||
|
}
|
||||||
|
|
||||||
return '';
|
return '';
|
||||||
},
|
},
|
||||||
null
|
null
|
||||||
);
|
);
|
||||||
$countdown_deleter->handle = function() {
|
$countdown_deleter->handle = function() {
|
||||||
$delete_countdown_id = $_POST['delete_countdown_id'];
|
$delete_countdown_id = $_POST['delete_countdown_id'];
|
||||||
$delete_countdown_id = DB::escape($delete_countdown_id);
|
|
||||||
|
|
||||||
DB::query("delete from countdowns where id = '$delete_countdown_id'");
|
DB::query("delete from countdowns where id = $delete_countdown_id");
|
||||||
};
|
};
|
||||||
$countdown_deleter->runAtServer();
|
$countdown_deleter->runAtServer();
|
||||||
|
|
||||||
@ -378,6 +385,87 @@ EOD;
|
|||||||
EOD;
|
EOD;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
$friend_link_adder = new UOJForm('new_friend_link');
|
||||||
|
$friend_link_adder->submit_button_config['align'] = 'compressed';
|
||||||
|
$friend_link_adder->addInput('new_friend_link_title', 'text', '名称', '',
|
||||||
|
function ($str) {
|
||||||
|
return '';
|
||||||
|
},
|
||||||
|
null
|
||||||
|
);
|
||||||
|
$friend_link_adder->addInput('new_friend_link_url', 'text', '链接', '',
|
||||||
|
function($str) {
|
||||||
|
if (!validateURL($str)) {
|
||||||
|
return '链接不合法';
|
||||||
|
}
|
||||||
|
|
||||||
|
return '';
|
||||||
|
},
|
||||||
|
null
|
||||||
|
);
|
||||||
|
$friend_link_adder->addInput('new_friend_link_level', 'text', '权重', '10',
|
||||||
|
function($str) {
|
||||||
|
if (!validateUInt($str)) {
|
||||||
|
return '权重必须是数字';
|
||||||
|
}
|
||||||
|
|
||||||
|
return '';
|
||||||
|
},
|
||||||
|
null
|
||||||
|
);
|
||||||
|
$friend_link_adder->handle = function() {
|
||||||
|
$new_friend_link_title = $_POST['new_friend_link_title'];
|
||||||
|
$new_friend_link_url = $_POST['new_friend_link_url'];
|
||||||
|
$new_friend_link_level = $_POST['new_friend_link_level'];
|
||||||
|
$esc_new_friend_link_title = DB::escape($new_friend_link_title);
|
||||||
|
$esc_new_friend_link_url = DB::escape($new_friend_link_url);
|
||||||
|
|
||||||
|
DB::query("insert into friend_links (title, url, level) values ('$esc_new_friend_link_title', '$esc_new_friend_link_url', $new_friend_link_level)");
|
||||||
|
};
|
||||||
|
$friend_link_adder->runAtServer();
|
||||||
|
|
||||||
|
$friend_link_deleter = new UOJForm('delete_friend_link');
|
||||||
|
$friend_link_deleter->submit_button_config['align'] = 'compressed';
|
||||||
|
$friend_link_deleter->addInput('delete_friend_link_id', 'text', 'ID', '',
|
||||||
|
function ($id) {
|
||||||
|
if (!validateUInt($id)) {
|
||||||
|
return 'ID不合法';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!DB::selectFirst("select * from friend_links where id = $id")) {
|
||||||
|
return 'ID不存在';
|
||||||
|
}
|
||||||
|
|
||||||
|
return '';
|
||||||
|
},
|
||||||
|
null
|
||||||
|
);
|
||||||
|
$friend_link_deleter->handle = function() {
|
||||||
|
$delete_friend_link_id = $_POST['delete_friend_link_id'];
|
||||||
|
|
||||||
|
DB::query("delete from friend_links where id = $delete_friend_link_id");
|
||||||
|
};
|
||||||
|
$friend_link_deleter->runAtServer();
|
||||||
|
|
||||||
|
$friend_links_header_row = <<<EOD
|
||||||
|
<tr>
|
||||||
|
<th>ID</th>
|
||||||
|
<th>名称</th>
|
||||||
|
<th>链接</th>
|
||||||
|
<th>置顶等级</th>
|
||||||
|
</tr>
|
||||||
|
EOD;
|
||||||
|
$friend_links_print_row = function($row) {
|
||||||
|
echo <<<EOD
|
||||||
|
<tr>
|
||||||
|
<td>{$row['id']}</td>
|
||||||
|
<td>{$row['title']}</td>
|
||||||
|
<td>{$row['url']}</td>
|
||||||
|
<td>{$row['level']}</td>
|
||||||
|
</tr>
|
||||||
|
EOD;
|
||||||
|
};
|
||||||
|
|
||||||
$contest_submissions_deleter = new UOJForm('contest_submissions');
|
$contest_submissions_deleter = new UOJForm('contest_submissions');
|
||||||
$contest_submissions_deleter->addInput('contest_id', 'text', '比赛ID', '',
|
$contest_submissions_deleter->addInput('contest_id', 'text', '比赛ID', '',
|
||||||
function ($x) {
|
function ($x) {
|
||||||
@ -618,12 +706,19 @@ EOD;
|
|||||||
</div>
|
</div>
|
||||||
<?php elseif ($cur_tab === 'index'): ?>
|
<?php elseif ($cur_tab === 'index'): ?>
|
||||||
<div>
|
<div>
|
||||||
<h4>倒计时管理</h4>
|
<h4>倒计时</h4>
|
||||||
<?php echoLongTable(array('id', 'title', 'endtime'), 'countdowns', '1', 'order by endtime asc', $countdowns_header_row, $countdowns_print_row, $userlist_config) ?>
|
<?php echoLongTable(array('id', 'title', 'endtime'), 'countdowns', '1', 'order by endtime asc', $countdowns_header_row, $countdowns_print_row, $userlist_config) ?>
|
||||||
<h5>添加倒计时</h5>
|
<h5>添加倒计时</h5>
|
||||||
<?php $countdown_adder->printHTML(); ?>
|
<?php $countdown_adder->printHTML(); ?>
|
||||||
<h5>删除倒计时</h5>
|
<h5>删除倒计时</h5>
|
||||||
<?php $countdown_deleter->printHTML(); ?>
|
<?php $countdown_deleter->printHTML(); ?>
|
||||||
|
|
||||||
|
<h4>友情链接</h4>
|
||||||
|
<?php echoLongTable(array('id', 'title', 'url', 'level'), 'friend_links', '1', 'order by level desc, id asc', $friend_links_header_row, $friend_links_print_row, $userlist_config) ?>
|
||||||
|
<h5>添加友情链接</h5>
|
||||||
|
<?php $friend_link_adder->printHTML(); ?>
|
||||||
|
<h5>删除友情链接</h5>
|
||||||
|
<?php $friend_link_deleter->printHTML(); ?>
|
||||||
</div>
|
</div>
|
||||||
<?php elseif ($cur_tab === 'submissions'): ?>
|
<?php elseif ($cur_tab === 'submissions'): ?>
|
||||||
<div>
|
<div>
|
||||||
|
@ -47,3 +47,7 @@ function validateUploadedFile($name) {
|
|||||||
function validateIP($ip) {
|
function validateIP($ip) {
|
||||||
return filter_var($ip, FILTER_VALIDATE_IP) !== false;
|
return filter_var($ip, FILTER_VALIDATE_IP) !== false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function validateURL($url) {
|
||||||
|
return filter_var($url, FILTER_VALIDATE_URL) !== false;
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user