Conditions | 9 |
Paths | 7 |
Total Lines | 24 |
Code Lines | 16 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
10 | function read_dir($dir, $ext = null) |
||
11 | { |
||
12 | $list = []; |
||
13 | $dir .= '/'; |
||
14 | if (($res = opendir($dir)) === false) { |
||
15 | exit(1); |
||
16 | } |
||
17 | while (($name = readdir($res)) !== false) { |
||
18 | if ($name == '.' || $name == '..') { |
||
19 | continue; |
||
20 | } |
||
21 | $name = $dir . $name; |
||
22 | if (is_dir($name)) { |
||
23 | $list = array_merge($list, read_dir($name, $ext)); |
||
24 | } elseif (is_file($name)) { |
||
25 | if (!is_null($ext) && substr(strrchr($name, '.'), 1) != $ext) { |
||
26 | continue; |
||
27 | } |
||
28 | $list[] = $name; |
||
29 | } |
||
30 | } |
||
31 | |||
32 | return $list; |
||
33 | } |
||
34 | |||
60 | exit($exit); |