LEPTON CMS 7.2.0
feel free to keep it strictly simple...
Loading...
Searching...
No Matches
function.directory_list.php
Go to the documentation of this file.
1<?php
2
18// include secure.php to protect this file and the whole CMS!
19if(!defined("SEC_FILE")){define("SEC_FILE",'/framework/secure.php' );}
20if (defined('LEPTON_PATH')) {
21 include LEPTON_PATH.SEC_FILE;
22} else {
23 $oneback = "../";
24 $root = $oneback;
25 $level = 1;
26 while (($level < 10) && (!file_exists($root.SEC_FILE))) {
27 $root .= $oneback;
28 $level += 1;
29 }
30 if (file_exists($root.SEC_FILE)) {
31 include $root.SEC_FILE;
32 } else {
33 trigger_error(sprintf("[ <b>%s</b> ] Can't include secure.php!", $_SERVER['SCRIPT_NAME']), E_USER_ERROR);
34 }
35}
36// end include secure file
37
38
68function directory_list(string $directory, bool $show_hidden = false, int $recursion_deep = 0, array &$aList = [], string &$ignore = "")
69{
70 if (is_dir($directory))
71 {
72 // Open the directory
73 $dir = dir( $directory );
74 if (!is_null($dir))
75 {
76 while (false !== ($entry = $dir->read()))
77 {
78 // Skip hidden files
79 if ($entry[0] == '.' && $show_hidden === false)
80 {
81 continue;
82 }
83
84 $temp_dir = $directory."/".$entry;
85 if (is_dir($temp_dir))
86 {
87 // Add dir and contents to list
88 $aList[] = str_replace( $ignore, "", $temp_dir );
89 directory_list($temp_dir, $show_hidden, $recursion_deep + 1, $aList, $ignore);
90 }
91 }
92 $dir->close();
93 }
94 }
95 if ($recursion_deep == 0)
96 {
97 natcasesort( $aList );
98 }
99 return $aList;
100}
directory_list(string $directory, bool $show_hidden=false, int $recursion_deep=0, array &$aList=[], string &$ignore="")