streamkid.net

2007-12-10

php script that creates a structure tree of a directory.

PHP directory script

A php script that creates a file and folder tree listing, in a recursive manner (ie for subfolders also). Filenames are linked to the files, and file size is also displayed. Finally, it is possible to hide certain files and folders, by explicitly defining their names. If a folder is excluded, all files and subfolders are not examined. Unfortunately at tne moment, the exclude list is hardcoded in the script.

Usage^

You can see the script in action here. The script is called as following:

file.php

<?php
	include 'dir-list.php';
	$fstructure = array('');
	ldir('fs_path', 0, $fstructure, 'client_path');
>>

$fstructure is an empty array.
fs_path is the filesystem path to the folder, ie if we are in /home/streamkid, and and want to list public_html, it can be /home/streamkid/public_html/, ./public_html/, or public_html/. Please note the trailing slash.
0 is for internal use.
client_path is the path for the client to access the files, ie in this case /~streamkid.
$ignore is the array containing the excluded file and folder names (hardcoded in the script).

Download^

You can find the php source here.