-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfiles.php
More file actions
106 lines (101 loc) · 2.74 KB
/
files.php
File metadata and controls
106 lines (101 loc) · 2.74 KB
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
<!DOCTYPE html>
<?php
require_once __DIR__ . '/vendor/owasp/csrf-protector-php/libs/csrf/csrfprotector.php';
csrfProtector::init();
require('config/config.php');
require('func/filesize.php');
$admin = isset($_GET['admin']);
$pick = isset($_GET['pick']);
if ($admin) {
$sth = $G["db"]->prepare('SELECT * FROM `file`');
} else {
$sth = $G["db"]->prepare('SELECT * FROM `file` WHERE `inuse` = 1');
}
$sth->execute();
$filelist = $sth->fetchAll(PDO::FETCH_ASSOC);
?>
<html lang="zh-Hant-TW">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<?php
require __DIR__ . '/commonhead.php';
?>
<title><?=$C["titlename"]?>/<?=($admin?"管理":"查詢")?>檔案</title>
<style type="text/css">
body {
padding-top: 4.5rem;
}
</style>
</head>
<body>
<?php
require("header.php");
$showform = true;
if ($admin && !$U["islogin"]) {
?>
<div class="alert alert-danger alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
此功能需要驗證帳號,請<a href="<?=$C["path"]?>/login/">登入</a>
</div>
<?php
$showform = false;
}
if ($showform) {
?>
<div class="container">
<h2>檔案<?=($admin?"管理":"查詢")?><?php if($admin){ ?> <a class="btn btn-sm btn-primary" href="<?=$C["path"]?>/newfile/" role="button"><i class="fa fa-upload" aria-hidden="true"></i> 上傳</a><?php }?></h2>
<div class="table-responsive">
<table class="table">
<th>名稱</th>
<th>副檔名</th>
<th>檔案大小</th>
<th>動作</th>
<?php
foreach ($filelist as $file) {
?>
<tr>
<td><?=htmlentities($file['name'])?></td>
<td><?=htmlentities($file['extension'])?></td>
<td style="white-space: nowrap"><?php
if (file_exists("file/".$file["filename"])) {
echo FormateFileSize(filesize(__DIR__."/file/".$file['filename']));
} else {
echo "檔案遺失";
}
?></td>
<td>
<?php
if ($pick) {
?>
<button class="btn btn-sm btn-info" onclick="window.opener.morefile('<?=$file['id']?>');window.close();"><i class="fa fa-check" aria-hidden="true"></i> 選取</button>
<?php
}
?>
<a class="btn btn-sm btn-success" href="<?=$C["path"]?>/file/<?=$file['id']?>/" role="button"><i class="fa fa-eye" aria-hidden="true"></i> 查看</a>
<?php
if ($admin) {
?>
<a class="btn btn-sm btn-primary" href="<?=$C["path"]?>/editfile/<?=$file['id']?>/" role="button"><i class="fa fa-pencil" aria-hidden="true"></i> 管理</a>
<?php
}
?>
</td>
</tr>
<?php
}
?>
</table>
</div>
</div>
<?php
}
require("footer.php");
?>
<script type="text/javascript">
$(function () {
$('[data-toggle="tooltip"]').tooltip()
})
</script>
</body>
</html>