PHP Directory Listing
Last update: 2012-05-27
Synopsis
PHP Directory Listing is a simple PHP script that will do just that, list a directory (and in a clean and simple fashion).
To use it, just unpack and put the contents of the php-directory-listing-<VERSION> folder either directly into the directory you want listed, or somewhere completely different and link index.php from there. In that latter case, the $url variable at the beginning of index.php will have to be set to the full URL which it can be found under.
Note: This project remains mostly "as is"; it does for me what I need it to do and new features or bug fixes will only be done if somebody asks for it, or on occasion if I feel like it. You're of course free to work on it yourself as well, and I'll happily incorporate any changes sent my way. If you're looking for a more featureful directory listing, you might want to take a look at Eugen Wirz' pdirl - he even includes a ready-made .htaccess file, which I figure might come in handy for all those running Apache.
License
This is Free Software licensed under either the GNU
General Public License, version 2.0 or the CreativeCommons BY-SA License, version 3.0.
Looks
There's two demos: the minimal and the gallery-style user interfaces.
Download
Get the latest version. Or clone me on GitHub!
Changes
- 0.3.6:
- Adding controls bar at page bottom.
- Adding background music player to controls bar.
- Moving previous/next buttons to controls bar.
- Adding slideshow start/stop buttons and close button to controls bar.
- Introducing config.ini file (can be both global or local) for configuring the gallery view and some other settings.
- Refactored some more to improve code understandability.
- Made Google Analytics configurable through config.ini.
- Some minor cosmetic improvements.
- Fixed bugs pertaining to clearer separation between the two user interface variants.
- Wrote INSTALL file to help people setting up PHP Directory Listing on their servers.
- 0.3.5:
- If there is a file "README.txt" present, its content will be shown inside a <pre>-Tag below the directory content.
- Integrated jQuery Fancybox to show PNGs, JPGs and GIFs when they're clicked.
- Removing trailing slash from folder names as it messed up the layout sometimes (and they're not really necessary since folders have their own icon anyway).
- 0.3.4:
- Properly escaping content of HTML files.
- New variable $url in index.php which you can set to where PHP Directory Listing is installed. Then using it for a certain directory becomes as easy as simpling softlinking index.php into that directory.
- Changed empty file marker "[empty file]" into an m-dash to maintain language agnosticism.
- Fixing link size limitation for directories.
- Making filetype detection case-insensitive.
- Changed the Thumbnail class to always produce JPEGs, which seems to be more compatible with certain server setups.
- Replacing urlencode() with rawurlencode() in some places for RFC 1738 compliancy. Trying very hard to always be XHTML 1.0 Strict compliant with this, so if you still find cases where this is not true because of unforeseen filenames, please do mention!
- Fixing sorting to have directories come on top again.
- Caching PDF thumbnails like is done for all other thumbnails. Their generation is still monkey-patched into DirectoryListing.class.php, though.
- Added some filetypes to the list of text files that can be previewed.
- Showing the current folder in <title> now, thanks to some DAMN fine regular expression there which shows just how powerful the internets can be as a form of contemporary communication. Yeah, baby.
- 0.3.3:
- Applied Thomas Teisberg's patch which handles empty files gracefully instead of showing a Warning. (Thanks a lot, Thomas!)
- 0.3.2:
- Made the script XHTML 1.0 Strict compliant
- Changed layout to be more CSS based (if anybody knows how to get those awful tables out of there, please help!)
- Added some new icons. I'm always grateful for new icons, as there are a lot of file types out there...
- Implented personal request from Switzerland (PDF thumbnail creation). Please note that you will have both GhostScript and ImageMagick installed in your webserver's PATH for this to work.
- 0.3.1: Fixed the handling of arrays to comply with PHP5.
- 0.3.0: Merged Andreas Aronsson's changes. ASP files are now supported and directories get a slash appended.
- 0.2.1: Removed .phps from the list of text files to preview. The php open tag does ungood things.
- 0.2.0: Initial release.
(Version 0.1 did not have any of the features like thumbnail creation or
the column view with tiles which are the reason why I would like to make
this available to the public and is thus not provided for download).
Known Issues/Limitations
- I'm currently using the Tango Project's icon library, but there's
quite a few of the MIME icons missing (namely so far: dm_69, bib, dvi, pk3, deb, bsp, map). If you're good at graphics and help them out, you're supporting many more projects
than just this little script!
- There's this wierd bug: some icons don't show up, even if they're there and can be read by opening them in Nautilus or Eog or what have you. Doesn't matter if they're files or symlinks - PHP's is_file() and is_symlink() agree. They say 0 instead of 1. An example is odt.png.
- Even though the script requires GDLIB, GhostScript and ImageMagick, it doesn't check for them or produce proper warning messages if they are not configured correctly. Instead it just messes up.
- PDF thumbnail generation is awfully slow (luckily, thumbnails are cached). Also, it's monkey-patched into DirectoryListing.class.php instead of being part of Thumbnail.class.php as it should.
Contact
I am user "sixtyfive" on free(code) and github.