/
ajax.file.list.php
48 lines (42 loc) · 1.38 KB
/
ajax.file.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
47
<?php
include_once('../../../../../common.php');
if(!$member['mb_no']) {
header("Content-Type: application/json");
echo json_encode([
'success'=>false,
'bf_no'=>0,
'image'=>false,
'path'=> '',
'msg'=> '파일업로드를 위해서는 로그인이 필요합니다.'
]);
exit;
}
$table = $g5['board_file_table'];
$result = sql_query("
select bf_source as name, bf_file, bf_no, bf_filesize as size, bf_width as width, bf_height as height
from {$table} where
`bo_table` = '{$bo_table}' and
(
`wr_id` = {$wr_id} or
(`wr_id` = -1 and `bf_download` = {$member['mb_no']})
)
");
$list = [];
while ($row = sql_fetch_array($result)) {
$row['path'] = '/data/file/'.$bo_table.'/'.$row['bf_file'];
$row['image'] = true;
if(is_file(G5_DATA_PATH.'/file/'.$bo_table.'/'.$row['bf_file'])) {
$row['mime'] = mime_content_type(G5_DATA_PATH.'/file/'.$bo_table.'/'.$row['bf_file']);
if(strpos($row['mime'],'image') === false) {
$ext = pathinfo($row['name'],PATHINFO_EXTENSION);
$row['thumb'] = $board_skin_url.'/img/extensions/'.$ext.'.svg';
$row['image'] = false;
}
}
$list[] = $row;
}
header("Content-Type: application/json");
echo json_encode([
'count'=>sizeof($list),
'list'=>$list
]);