PHP: ldir
(PHP 4, PHP 5)
ldir - List files and directories inside the specified path.
Description
Mixed ldir(string $directory[, array $hiddentypes[, array $hiddenfiles[, $GET]]])
echos a HTML table with the contents of the directory.
Parameters
directory
The directory to be displayed (Absolute or Relative)
hiddentypes
The filetypes (extensions) to hide i.e. .php Include ".?" to hide dot files/folders.
hiddenfiles
Individual files to hide. (The script hides itself (or anything with the same name [to fix]))
GET
Any additional GET variables to be passed. This allows ldir to be used with more complicated scripts. [Added in Version 1.7.0 onwards]
Return Values
Returns echo'd HTML.
Returns bool true int 2 if there was a minor problem (folder/file permissions)
Returns bool true int 3 if there was a minor problem (cannot retrieve icons)
Returns bool true int 4 if it detects an injection attack (only for admin/logging use)
Returns false if there is any other problem i.e. Directory doesn't exist.
Use === rather than == to determine which error code is produced.
NOTE: File sizes over 2GB maybe incorrect, see PHP Filesize
Example
ob_start(); $types = array(".php",".exe",".?"); $files = array("index.php","README.txt"); .... code .... ldir("/location/to/folder",$types,$files);
Output:
[Folder] /location/to/files Type FileName Size [icon] filename/link filesize
Download
Latest Version: 1.7.7
Download latest here
Download 1.7.6 here
Download 1.7.5 here
Download 1.7.4 here
Download 1.7.3* here
Download 1.7.2* here
Download 1.7.1* here
Download 1.7.0* here
Download 1.6.7* here
Download 1.6.6* here
Download 1.6.5* here
Download 1.6.4 here
Download 1.6.3 here
Download 1.6.2 here
Download 1.4.0 here (Legacy, pre-function version)
*Download Bug Fix 1.7.3-1 0.0.3 here (PHP4 Only)
Licensing
Versions 1.6.6 onwards
- Covered by the GNU GPL v3
Versions Prior to 1.6.6
- No License but deemed as Gratis (like free Beer but not Free Speech) i.e. don't edit the code!
Changelog
Version 1.7.7
- Changed the Update URL.
Version 1.7.6
- Rewrote the PHP4 scandir support so its mildly faster
- Edited the file/folder checkingn system so its less resource hungry
- Added Support for different icon hosts
- Migrated icons to dropbox.
Version 1.7.5
- Removed more legacy CSS that may have been an issue for users with custom CSS
- Capitialised the first character of the visible directory name / download location
- Changed the folder refresh method so it didn't force a cache reload
Version 1.7.4
- Changed strripos and stripos to strpos & stripos to make it PHP4 compatible (again)(See 1.7.3-1)
- Added a class to update text and refresh div so they can be hidden.
- Removed some legacy CSS forcing elements to be blue
Version 1.7.3-1
- Issued Bug-Fix (1.7.3-1 0.0.3) for Versions 1.6.5 - 1.7.3 (PHP4 Only)
- Usage: Just require_once before you require/include ldir.
- KB: Here
Version 1.7.3
- Fixed a bug where file extensions with capital letters weren't displaying the correct filetype image
Version 1.7.2
- Fixed a bug where the anti-injection was killing any access to dot files/folders
- Tweaked the way it handles folders
- Improved the anti-injection code
- Can now handle folders with double dots (i.e. ..folder)
- Allows using ./ in the folder request (i.e. HTTP GET f=folder/./) as it now shouldn't do any harm
- Suppressed warning from filesize() as it was complaining about not being able to stat while inside a double dot folder (will re-asses this later)
- Added the GET variable to the error output
- Function File size is now just under 9KBytes
Version 1.7.1
- Fixed a problem where the redirect wasn't using the passed on GET
Version 1.7.0
- Allows GET variables to be passed.