-
Notifications
You must be signed in to change notification settings - Fork 50
/
index.php
143 lines (140 loc) · 5.47 KB
/
index.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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
<?php
if (version_compare(PHP_VERSION, '7.1.0', '<')) {
die('require PHP >= 7.1 !');
}
include("./includes/common.php");
if(isset($_GET['m']) && $_GET['m']=='mine'){
$title = '我的文件 - ' . $conf['title'];
$htext = '我上传的文件';
if($islogin2){
$sql = " uid='{$uid}'";
}else{
if($conf['userlogin']==1){
$htext .= '<span class="text-muted" style="font-size:16px">(根据浏览器缓存记录,<a href="login.php">登录</a>后可永久保留记录)</span>';
}else{
$htext .= '<span class="text-muted" style="font-size:16px">(根据浏览器缓存记录)</span>';
}
if(isset($_SESSION['fileids']) && count($_SESSION['fileids'])>0){
$ids = array_reverse($_SESSION['fileids']);
if(count($ids) > 60){
$ids = array_splice($ids, 0, 60);
}
$ids = implode(',',$ids);
$sql = " id IN ($ids)";
}else{
$sql = " 1=2";
}
}
$link = '&m=mine';
}else{
$title = $conf['title'];
$htext = '文件列表';
$sql = " hide=0";
$link = '';
}
$kw = isset($_GET['kw'])?daddslashes(trim(strip_tags($_GET['kw']))):null;
if($conf['filesearch']==1 && $kw){
$sql.=" AND name LIKE '%{$kw}%'";
$link .= '&kw='.$kw;
}
include SYSTEM_ROOT.'header.php';
?>
<div class="container">
<div class="well bs-component">
<h2><?php echo $htext?>
<?php if($conf['filesearch']==1){?><span class="searchbox">
<form class="form-inline" action="./" method="GET">
<?php if(isset($_GET['m'])){?><input name="m" type="hidden" value="<?php echo htmlspecialchars($_GET['m'])?>"><?php }?>
<input name="kw" class="form-control" type="search" placeholder="请输入搜索关键字" value="<?php echo $kw?>" required="">
<button class="btn btn-default btn-raised btn-sm" type="submit"><i class="fa fa-search" aria-hidden="true"></i> 搜索</button>
</form>
</span><?php }?></h2>
<div class="table-responsive">
<table class="table table-striped table-hover filelist">
<thead>
<tr>
<th>#</th>
<th>操作</th>
<th>文件名</th>
<th>文件大小</th>
<th>文件格式</th>
<th>上传时间</th>
<th>上传者IP</th>
</tr>
</thead>
<tbody>
<?php
$numrows=$DB->getColumn("SELECT count(*) from pre_file WHERE{$sql}");
$pagesize=15;
$pages=ceil($numrows/$pagesize);
$page=isset($_GET['page'])?intval($_GET['page']):1;
$offset=$pagesize*($page - 1);
$rs=$DB->query("SELECT * FROM pre_file WHERE{$sql} ORDER BY id DESC LIMIT $offset,$pagesize");
$i=1;
while($res = $rs->fetch())
{
$fileurl = './down.php/'.$res['hash'].'.'.($res['type']?$res['type']:'file');
$viewurl = './file.php?hash='.$res['hash'];
echo '<tr><td><b>'.$i++.'</b></td><td><a href="'.$fileurl.'">下载</a>|<a href="'.$viewurl.'">查看</a></td><td><i class="fa '.type_to_icon($res['type']).' fa-fw"></i>'.$res['name'].'</td><td>'.size_format($res['size']).'</td><td><font color="blue">'.($res['type']?$res['type']:'未知').'</font></td><td>'.$res['addtime'].'</td><td>'.preg_replace('/\d+$/','*',$res['ip']).'</b></td></tr>';
}
if($numrows == 0) echo '<tr><td colspan="7" align="center">还没上传过任何文件</td></tr>';
?>
</tbody>
</table>
</div>
<div class="row">
<div class="col-md-6"><br>共有 <?php echo $numrows?> 个文件 当前第 <?php echo $page?> 页,共 <?php echo $pages?> 页</div>
<div class="col-md-6"><nav>
<ul class="pagination pagination-sm" style="float:right;">
<?php
$first=1;
$prev=$page-1;
$next=$page+1;
$last=$pages;
if ($page>1)
{
echo '<li><a href="index.php?page='.$first.$link.'">首页</a></li>';
echo '<li><a href="index.php?page='.$prev.$link.'">«</a></li>';
} else {
echo '<li class="disabled"><a>首页</a></li>';
echo '<li class="disabled"><a>«</a></li>';
}
$start=$page-10>1?$page-10:1;
$end=$page+10<$pages?$page+10:$pages;
for ($i=$start;$i<$page;$i++)
echo '<li><a href="index.php?page='.$i.$link.'">'.$i .'</a></li>';
echo '<li class="disabled"><a>'.$page.'</a></li>';
for ($i=$page+1;$i<=$end;$i++)
echo '<li><a href="index.php?page='.$i.$link.'">'.$i .'</a></li>';
echo '';
if ($page<$pages)
{
echo '<li><a href="index.php?page='.$next.$link.'">»</a></li>';
echo '<li><a href="index.php?page='.$last.$link.'">尾页</a></li>';
} else {
echo '<li class="disabled"><a>»</a></li>';
echo '<li class="disabled"><a>尾页</a></li>';
}
?>
</ul>
</nav></div>
</div>
</div>
<?php include SYSTEM_ROOT.'footer.php';?>
<?php if(!empty($conf['gonggao'])){?>
<link href="https://s4.zstatic.net/ajax/libs/snackbarjs/1.1.0/snackbar.min.css" rel="stylesheet">
<script src="https://s4.zstatic.net/ajax/libs/snackbarjs/1.1.0/snackbar.min.js"></script>
<script src="https://s4.zstatic.net/ajax/libs/jquery-cookie/1.4.1/jquery.cookie.min.js"></script>
<script>
$(function() {
if(!$.cookie('gonggao')){
$.snackbar({content: "<?php echo $conf['gonggao']?>", timeout: 10000});
var cookietime = new Date();
cookietime.setTime(cookietime.getTime() + (60*60*1000));
$.cookie('gonggao', false, { expires: cookietime });
}
});
</script>
<?php }?>
</body>
</html>