-
Notifications
You must be signed in to change notification settings - Fork 24
/
popular-keyword.php
107 lines (79 loc) · 2.99 KB
/
popular-keyword.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<DOCTYPE html>
<html lang="zh-CN">
<?php
require_once('header.php');
$page = isset($_GET['page']) ? $_GET['page'] : 1;
$page = max($page, 1);
$result = get_popular_kws(($page - 1) * $PAGE_SIZE, $PAGE_SIZE, $cnt);
?>
<head>
<meta charset="utf-8">
<title>搜索关键字热度排行 - KOTOMI RSS</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" rel="stylesheet">
<link href="css/index.css" rel="stylesheet">
</head>
<body>
<?php require_once('nav.tpl.php'); ?>
<div class="container-fluid">
<div class="row">
<div class="col-sm-12 text-center head-title">
KOTOMI RSS
</div>
</div>
</div>
<?php require_once('search.tpl.php');?>
<div class="container-fluid text-primary text-center text-large" style="font-size: 1.2em; margin-top: 1em;">
搜索关键字热度排行
</div>
<div class="container-fluid">
<table class="table table-hover table-bordered popular-kw-list">
<tr class="info">
<th>搜索关键字</th>
<th style="width: 10em;"><abbr title="根据近期搜索次数计算而得">热度</abbr></th>
<th>最后一次被搜索的时间</th>
</tr>
<?php
foreach ($result as $res) {
$popularity = '未知';
if ($res['popularity2'] >= 0) {
$popularity = sprintf('%0.3f', round($res['popularity2'], 3));
}
?>
<tr>
<td>
<a href="/?page=1&kw=<?php echo urlencode($res['kw']);?>"><?php echo htmlspecialchars($res['kw']);?></a>
</td>
<td class="popularity"><?php echo $popularity;?></td>
<td><?php echo date('Y-m-d H:i:s', $res['pmtime']);?></td>
</tr>
<?php } ?>
</table>
</div>
<div class="container-fluid">
<nav style="text-align: center;">
<ul class="pagination">
<?php
$pages = array();
$page_count = max(1, ceil($cnt / $PAGE_SIZE));
/// 显示前后 4 页
for ($i = $page; $i >= 1 && $i >= $page - 4; $i--) {
$pages[] = $i;
}
for ($i = $page; $i <= $page_count && $i <= $page + 4; $i++) {
$pages[] = $i;
}
$pages = array_unique($pages);
sort($pages);
?>
<li><a href="?page=1">首页</a></li>
<?php foreach ($pages as $i) { ?>
<li <?php if ($i == $page) { ?>class="active"<?php } ?>><a href="?page=<?php echo $i;?>"><?php echo $i;?></a></li>
<?php } ?>
<li><a href="?page=<?php echo $page_count;?>">末页</a></li>
</ul>
</nav>
</div>
<?php require('footer.tpl.php'); ?>
</body>
</html>