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