-
Notifications
You must be signed in to change notification settings - Fork 7
/
file.php
307 lines (297 loc) · 13.3 KB
/
file.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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
<?php
include("./includes/common.php");
$title = '文件查看 - '.$conf['title'];
$is_file=true;
include SYSTEM_ROOT.'header.php';
$csrf_token = md5(mt_rand(0,999).time());
$_SESSION['csrf_token'] = $csrf_token;
$hash = isset($_GET['hash'])?$_GET['hash']:exit("<script language='javascript'>window.location.href='./';</script>");
$pwd = isset($_GET['pwd'])?$_GET['pwd']:null;
$row = $DB->getRow("SELECT * FROM pre_file WHERE hash=:hash", [':hash'=>$hash]);
if(!$row)exit("<script language='javascript'>alert('文件不存在');window.location.href='./';</script>");
$name = $row['name'];
$type = $row['type'];
$downurl = 'down.php/'.$row['hash'].'.'.$type;
if(!empty($row['pwd']))$downurl .= '&'.$row['pwd'];
$viewurl = 'view.php/'.$row['hash'].'.'.$type;
$downurl_all = $siteurl.$downurl;
$viewurl_all = $siteurl.$viewurl;
$thisurl = $siteurl.'file.php?hash='.$row['hash'];
if(!empty($pwd))$thisurl .= '&pwd='.$pwd;
if(isset($_SESSION['fileids']) && in_array($row['id'], $_SESSION['fileids']) && strtotime($row['addtime'])>strtotime("-7 days")){
$is_mine = true;
}
$type_image = explode('|',$conf['type_image']);
$type_audio = explode('|',$conf['type_audio']);
$type_video = explode('|',$conf['type_video']);
if(in_array($type, $type_image)){
$filetype = 1;
$title = '<i class="fa fa-picture-o"></i> 图片查看器';
$htmlcode = htmlspecialchars('<img src="'.$viewurl_all.'"/>');
$ubbcode = '[img]'.$viewurl_all.'[/img]';
$linktitle = '图片链接';
}elseif(in_array($type, $type_audio)){
$filetype = 2;
$title = '<i class="fa fa-music"></i> 音乐播放器';
$htmlcode = htmlspecialchars('<audio id="bgmMusic" src="'.$viewurl_all.'" autoplay="autoplay" loop="loop" preload="auto"></audio>');
$htmlcode2 = htmlspecialchars('<iframe src="'.$siteurl.'player.php?hash='.$hash.'" width="407" scrolling="no"frameborder="0"height="70"></iframe>');
$ubbcode = '[audio=X]'.$viewurl_all.'[/audio]';
$linktitle = '音乐链接';
}elseif(in_array($type, $type_video)){
$filetype = 3;
$title = '<i class="fa fa-video-camera"></i> 视频播放器';
$htmlcode = htmlspecialchars('<video id="movies" src="'.$viewurl_all.'" autobuffer="true" controls="" width="100
%"></video>');
$htmlcode2 = htmlspecialchars('<iframe src="'.$siteurl.'player.php?hash='.$hash.'" width="800" height="500" scrolling="no" frameborder="0"></iframe>');
$ubbcode = '[movie=320*180]'.$viewurl_all.'[/movie]';
$linktitle = '视频链接';
}else{
$filetype = 0;
$title = '<i class="fa fa-file"></i> 文件查看';
$htmlcode = htmlspecialchars('<a href="'.$downurl_all.'" target="_blank">'.$name.'</a>');
$ubbcode = '[url='.$downurl_all.']'.$name.'[/url]';
}
?>
<div class="container">
<div class="row">
<?php
if($row['pwd']!=null && $row['pwd']!=$pwd){ ?>
<meta http-equiv="content-type" content="text/html;charset=utf-8"/>
<title>请输入密码下载文件</title>
<script type="text/javascript">
var pwd=prompt("请输入密码","")
if (pwd!=null && pwd!="")
{
window.location.href="./file.php?hash=<?php echo $row['hash']?>&pwd="+pwd
}
</script>
请刷新页面,或[ <a href="javascript:history.back();">返回上一页</a> ]
<?php
exit;
}
?>
<div class="col-sm-9">
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title"><?php echo $title?></h3>
</div>
<div class="panel-body" align="center">
<?php
if($filetype==1){
echo '<div class="image_view"><a href="'.$viewurl.'" title="点击查看原图"><img alt="loading" src="'.$viewurl.'" class="image"></a></div>';
}elseif($filetype==2){
echo '<div class="view"><div id="aplayer"></div></div>';
}elseif($filetype==3 && $row['block']==0){
echo '<div class="videosamplex"><video id="videoplayer"></video></div>';
}elseif($filetype==3){
echo '<div class="view">
<div class="elseview">
<div class="tubiao"><i class="fa '.type_to_icon($type).'"></i> </div>
</div>
<div class="elsetext"><p>'.$name.'</p><p>视频文件需审核通过后才能在线播放和下载,请等待审核通过!</p></div>
</div>';
}else{
echo '<div class="view">
<div class="elseview">
<div class="tubiao"><i class="fa '.type_to_icon($type).'"></i> </div>
</div>
<div class="elsetext"><p>'.$name.'('.size_format($row['size']).')</p>
<a href="'.$downurl.'" class="btn btn-raised btn-primary btn-lg"><i class="fa fa-download" aria-hidden="true"></i> 下载文件<div class="ripple-container"></div></a>
</div>
</div>';
}
?>
</div>
</div>
<div class="panel panel-default">
<div class="panel-body" style="padding: 0px;">
<ul class="nav nav-tabs" style="margin-bottom: 15px;">
<li class="active"><a href="#link" data-toggle="tab"><i class="fa fa-link" aria-hidden="true"></i> 文件外链</a>
</li>
<li><a href="#code" data-toggle="tab"><i class="fa fa-code" aria-hidden="true"></i> 代码调用</a>
</li>
<li><a href="#info" data-toggle="tab"><i class="fa fa-info-circle" aria-hidden="true"></i> 文件详情</a>
</li>
<li class="<?php echo $is_mine?'':'hide';?>"><a href="#manager" data-toggle="tab"><i class="fa fa-cog" aria-hidden="true"></i> 管理</a>
</li>
</ul>
<div id="myTabContent" class="tab-content" style="padding: 19px;">
<div class="tab-pane fade active in" id="link">
<div class="form-group row <?php echo $filetype==0?'hide':'';?>">
<label for="link1" class="col-md-2 control-label"><?php echo $linktitle?>:</label>
<div class="col-md-10">
<div class="input-group">
<input type="text" class="form-control" id="link1" readonly="readonly" value="<?php echo $viewurl_all?>">
<span class="input-group-btn">
<button class="btn btn-primary btn-raised copy-btn" type="button" data-clipboard-text="<?php echo $viewurl_all?>">复制<div class="ripple-container"></div></button>
</span>
</div>
</div>
</div>
<div class="form-group row">
<label for="link2" class="col-md-2 control-label">下载链接:</label>
<div class="col-md-10">
<div class="input-group">
<input type="text" class="form-control" id="link2" readonly="readonly" value="<?php echo $downurl_all?>">
<span class="input-group-btn">
<button class="btn btn-primary btn-raised copy-btn" type="button" data-clipboard-text="<?php echo $downurl_all?>">复制<div class="ripple-container"></div></button>
</span>
</div>
</div>
</div>
</div>
<div class="tab-pane fade" id="code">
<div class="form-group row <?php echo $filetype<2?'hide':'';?>">
<label for="code1" class="col-md-2 control-label">播放器代码:</label>
<div class="col-md-10">
<div class="input-group">
<input type="text" class="form-control" id="code1" readonly="readonly" value="<?php echo $htmlcode2?>">
<span class="input-group-btn">
<button class="btn btn-primary btn-raised copy-btn" type="button" data-clipboard-text="<?php echo $htmlcode2?>">复制<div class="ripple-container"></div></button>
</span>
</div>
</div>
</div>
<div class="form-group row">
<label for="code2" class="col-md-2 control-label">HTML代码:</label>
<div class="col-md-10">
<div class="input-group">
<input type="text" class="form-control" id="code2" readonly="readonly" value="<?php echo $htmlcode?>">
<span class="input-group-btn">
<button class="btn btn-primary btn-raised copy-btn" type="button" data-clipboard-text="<?php echo $htmlcode?>">复制<div class="ripple-container"></div></button>
</span>
</div>
</div>
</div>
<div class="form-group row">
<label for="code3" class="col-md-2 control-label">UBB代码:</label>
<div class="col-md-10">
<div class="input-group">
<input type="text" class="form-control" id="code3" readonly="readonly" value="<?php echo $ubbcode?>">
<span class="input-group-btn">
<button class="btn btn-primary btn-raised copy-btn" type="button" data-clipboard-text="<?php echo $ubbcode?>">复制<div class="ripple-container"></div></button>
</span>
</div>
</div>
</div>
</div>
<div class="tab-pane fade" id="info">
<div class="row" align="center">
<table class="table table-bordered fileinfo-table">
<tr>
<th width="97">上传者IP:</td><td width="100"><?php echo preg_replace('/\d+$/','*',$row['ip'])?></td>
<th width="100">上传时间:</td><td width="168"><?php echo $row['addtime']?></td>
</tr>
<tr>
<th>下载次数:</td><td><?php echo $row['count']?></td>
<th>文件大小:</td><td><?php echo size_format($row['size']).' ('.$row['size'].' 字节)'?></td>
</tr>
</table>
</div>
</div>
<div class="tab-pane fade" id="manager">
<div class="row" align="center">
<div class="col-md-12">
<input type="hidden" id="hash" name="hash" value="<?php echo $hash?>">
<input type="hidden" id="csrf_token" name="csrf_token" value="<?php echo $csrf_token?>">
<button onclick="delete_confirm()" class="btn btn-raised btn-danger"><i class="fa fa-close" aria-hidden="true"></i> 删除文件</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="col-sm-3">
<div class="panel panel-info">
<div class="panel-heading">
<h3 class="panel-title"><i class="fa fa-exclamation-circle"></i> 提示</h3>
</div>
<div class="panel-body">
<?php echo $conf['gg_file']?>
</div>
</div>
<div class="panel panel-default hidden-xs">
<div class="panel-heading">
<h3 class="panel-title"><i class="fa fa-qrcode"></i> 当前页面二维码</h3>
</div>
<div class="panel-body text-center">
<img alt="二维码" src="//api.qrserver.com/v1/create-qr-code/?size=180x180&margin=10&data=<?php echo urlencode($thisurl);?>">
</div>
</div>
</div>
</div>
</div>
<?php include SYSTEM_ROOT.'footer.php';?>
<?php if($filetype==2){?>
<script type="text/javascript" src="//cdn.staticfile.org/aplayer/1.10.1/APlayer.min.js"></script>
<script type="text/javascript">
var ap1 = new APlayer({
element: document.getElementById('aplayer'),
narrow: false,
autoplay: false,
showlrc: false,
mutex: true,
theme: '#b2dae6',
music: {
title: '<?php echo $name?>',
author: '',
url: '<?php echo $viewurl_all?>',
}
});
</script>
<?php }elseif($filetype==3 && $row['block']==0){?>
<script type="text/javascript" src="assets/js/ckplayer.min.js"></script>
<script type="text/javascript">
var videoObject = {
container: '.videosamplex',
variable: 'player',
mobileCkControls:true,
mobileAutoFull:false,
h5container:'#videoplayer',
flashplayer:false,
video:'<?php echo $viewurl_all?>'
};
var player=new ckplayer(videoObject);
</script>
<?php }?>
<script src="//cdn.staticfile.org/layer/2.3/layer.js"></script>
<script src="//cdn.staticfile.org/clipboard.js/1.7.1/clipboard.min.js"></script>
<script>
function delete_confirm(){
var hash = $("#hash").val();
var csrf_token = $("#csrf_token").val();
var confirmobj = layer.confirm('删除文件后不可恢复,确定删除吗?', {
btn: ['确定','取消'], icon: 0
}, function(){
$.ajax({
type : 'POST',
url : 'ajax.php?act=deleteFile',
data : {hash:hash, csrf_token:csrf_token},
dataType : 'json',
success : function(data) {
if(data.code == 0){
layer.alert('删除成功', {icon:1}, function(){window.location.href="./";});
}else{
layer.alert(data.msg, {icon:2});
}
},
error:function(data){
layer.msg('服务器错误');
return false;
}
});
}, function(){
layer.close(confirmobj);
});
}
$(document).ready(function(){
var clipboard = new Clipboard('.copy-btn');
clipboard.on('success', function (e) {
layer.msg('复制成功!', {icon: 1});
});
clipboard.on('error', function (e) {
layer.msg('复制失败,请长按链接后手动复制', {icon: 2});
});
})
</script>