Functions
WebDev/*nix assorted functions & hacks
Search
find all
Array
-
Bash
-
Classes
-
Config
-
DateTime
-
Debug
-
dotjs
-
File
-
foooo
-
Git
-
HTML
-
Images
-
Javascript
-
Linux
-
Math
-
Misc
-
MySQL
-
OS X
-
Reading
-
Redis
-
Shell scripts
-
snippets
-
SQL
-
Strings
-
TextMate
-
Web
-
\(^o^)/ Fun!
-
_Misc hacks
-
_Pages
File
clean_filename($filename)
duplicate_name($name, etc)
fetch_dirlist($path='', $exts='')
file_ext($file)
file_label($file, $label)
fsize($x)
resize_image($image, $sizes)
7
found
auth
Name:
Category: File
Body:
# Should be updated to return more metadata (optionally?) #________________________________________, # fetch_dirlist($path = '', $exts = '') / function fetch_dirlist($path = '', $exts = '') { $dir = $_SERVER['DOCUMENT_ROOT'] .'/'. trim($path, '/') .'/'; $d = dir($dir); $files = array(); while (($entry = $d->read()) !== false) { # the error supression is for links to 'outside' which are not allowed under open_basedir if ( (substr($entry, 0, 1) != '.') && (in_array(@filetype($dir.$entry), array('dir', 'file'))) ) { $files[$entry] = $entry; } } if (is_array($exts)) { foreach($files as $file) { $ext = ((strpos($entry, '.') !== false)?substr($entry, strrpos($entry, '.') + 1):''); if (! in_array($ext, $exts)) { unset($files[$entry]); } } } return $files; }
Footer