Web Hosting Talk







View Full Version : File and folder tree (PHP)


sasha
11-25-2005, 01:43 PM
Just spent couple hours making a script to reccusivly list files and folders and sort them in some natural way. I need this for a project I am working on but I though to share this part with you. It is not pretty and it will be modified a lot for intergration with the project in question but someone might find use for it.

http://tnt.goldnet.ca/tree.php
source
http://tnt.goldnet.ca/tree.phps

siLentBASE
11-26-2005, 11:46 AM
Nice, I like it. I was expecting a simple text list with indentions but the whole collapsabe and expandable folders thing is really cool. Nice work.

sasha
11-29-2005, 11:57 AM
I made some changes to is and couple fixes. Now it supports different icons for different file types

http://tnt.goldnet.ca/tree2.php
source:
http://tnt.goldnet.ca/tree2.phps

malenski
11-29-2005, 01:07 PM
Neat

You should stick it up on phpclasses.org

Can it handle files and directories with single and double quotes in the name?

sasha
11-29-2005, 01:21 PM
yeah, spaces and quotes should work. There are few lines of html embeded in there which i dislike. If i find a way to get rid of that i might post it someplace else then here.

malenski
11-29-2005, 01:47 PM
There is an instance when double quotes do not work.

view source -> http://malenski.com/foo.php

Your setting title to name of file when filename is longer then given max length.

Your not escaping the double quotes in this instance.

You can stick in a htmlentities at line 199 to solve this.
$link_title = $link_name;
becomes
$link_title = htmlentities($link_name);