-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimagelist.php
44 lines (32 loc) · 990 Bytes
/
imagelist.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
<?php
$id = sprintf("%05d",$_GET['id']);
$delimiter = PHP_EOL;
$output = 'var tinyMCEImageList = new Array(';
$directory = dirname(__FILE__).DIRECTORY_SEPARATOR."library".DIRECTORY_SEPARATOR."supplement";
if (is_dir($directory)) {
$direc = opendir($directory);
while ($file = readdir($direc)) {
if (is_file($directory.DIRECTORY_SEPARATOR.$file) && preg_match('/^'.$id.'.*/i', $file)) {
$isimage = null;
$image_array = array();
$image_array = @getimagesize('library/supplement/'.$file);
$image_mime = $image_array['mime'];
if($image_mime == 'image/jpeg' || $image_mime == 'image/gif' || $image_mime == 'image/png') $isimage = true;
if($isimage) {
$output .= $delimiter
. '["'
. utf8_encode(substr($file,5))
. '", "'
. utf8_encode("library/supplement/$file")
. '"],';
}
}
}
$output = substr($output, 0, -1);
$output .= $delimiter;
closedir($direc);
}
$output .= ');';
header('Content-type: text/javascript');
echo $output;
?>