forked from lincanbin/Carbon-Forum
-
Notifications
You must be signed in to change notification settings - Fork 0
/
upload_list.php
46 lines (42 loc) · 1.32 KB
/
upload_list.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
<?php
include(dirname(__FILE__) . '/common.php');
include(dirname(__FILE__) . '/includes/Uploader.class.php');
SetStyle('api', 'API');
//header("Content-Type: text/html; charset=utf-8");
Auth(1, 0, true);
$Size = isset($_GET['size']) ? intval($_GET['size']) : 20;
$Page = isset($_GET['start']) ? (intval($_GET['start']) / $Size) : 1;
/* 判断类型 */
switch ($_GET['action']) {
/* 列出文件 */
case 'listfile':
$SQL = 'SELECT FilePath as url, Created as mtime FROM ' . $Prefix . 'upload WHERE UserName=:UserName ORDER BY Created DESC LIMIT ' . $Page * $Size . ',' . $Size;
break;
/* 列出图片 */
case 'listimage':
$SQL = 'SELECT FilePath as url, Created as mtime FROM ' . $Prefix . 'upload WHERE UserName=:UserName and FileType like "image/%" ORDER BY Created DESC LIMIT ' . $Page * $Size . ',' . $Size;
break;
default:
AlertMsg('Bad Request', 'Bad Request');
break;
}
$files = $DB->query($SQL, array(
'UserName' => $CurUserName
));
if (!count($files)) {
$result = json_encode(array(
"state" => "no match file",
"list" => array(),
"start" => $Page * $Size,
"total" => count($files)
));
} else {
/* 返回数据 */
$result = json_encode(array(
"state" => "SUCCESS",
"list" => $files,
"start" => $Page * $Size,
"total" => count($files)
));
}
return $result;