Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function searchdir($directory)
- {
- // create an array to hold directory list
- $results = array();
- // create a handler for the directory
- $handler = opendir($directory);
- // keep going until all files in directory have been read
- while ($file = readdir($handler)) {
- // if $file isn't this directory or its parent,
- // add it to the results array
- if ($file != '.' && $file != '..')
- $results[] = $file;
- }
- // tidy up: close the handler
- closedir($handler);
- // done!
- return $results;
- }
- // Directory Scanner Function. Recursively acquires folders and files from the specified directory
- function index($directory) {
- $result = null;
- $scan = searchdir($directory);
- foreach ($scan as $key=>$value) {
- // Custom list of files to ignore
- if($value != "." && $value != ".." && $value != "index.php" && $value != ".DS_Store" && $value != ".svn" && $value != "thumbs.db" && $value != "thumb.jpg") {
- if (is_dir($directory.'/'.$value))
- $result[$value] = index($directory.'/'.$value);
- else
- //FIXME Recode regular expression
- //$result[$value] = str_replace('_',' ',preg_replace('', '', $value));
- $result[$value] = str_replace('_',' ',$value);
- }
- }
- return $result;
- }
- ?>
Add Comment
Please, Sign In to add comment