|
| |
1 |
|
<?php |
|
| |
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 |
|
if (!function_exists('scandir')) |
|
| |
35 |
|
{ |
|
| |
36 |
|
function scandir ($directory, $sorting_order = 0) |
|
| |
37 |
|
{ |
|
| |
38 |
|
if (!is_string($directory)) { |
|
| |
39 |
|
trigger_error('scandir() expects parameter 1 to be string, ' . gettype($directory) . ' given', E_USER_WARNING); |
|
| |
40 |
|
return null; |
|
| |
41 |
|
} |
|
| |
42 |
|
|
|
| |
43 |
|
if (!is_int($sorting_order)) { |
|
| |
44 |
|
trigger_error('scandir() expects parameter 2 to be long, ' . gettype($sorting_order) . ' given', E_USER_WARNING); |
|
| |
45 |
|
return null; |
|
| |
46 |
|
} |
|
| |
47 |
|
|
|
| |
48 |
|
if (!is_dir($directory) || (false === $fh = @opendir($directory))) { |
|
| |
49 |
|
trigger_error('scandir() failed to open dir: Invalid argument', E_USER_WARNING); |
|
| |
50 |
|
return false; |
|
| |
51 |
|
} |
|
| |
52 |
|
|
|
| |
53 |
|
$files = array (); |
|
| |
54 |
|
while (false !== ($filename = readdir($fh))) { |
|
| |
55 |
|
$files[] = $filename; |
|
| |
56 |
|
} |
|
| |
57 |
|
|
|
| |
58 |
|
closedir($fh); |
|
| |
59 |
|
|
|
| |
60 |
|
if ($sorting_order == 1) { |
|
| |
61 |
|
rsort($files); |
|
| |
62 |
|
} else { |
|
| |
63 |
|
sort($files); |
|
| |
64 |
|
} |
|
| |
65 |
|
|
|
| |
66 |
|
return $files; |
|
| |
67 |
|
} |
|
| |
68 |
|
} |
|
| |
69 |
|
|
|
| |
70 |
|
?> |