P L I P
         P R O J E C T S                     C O N T A C T                       A B O U T            

Lil' Directory listing PHP app: ASCII

Call this with an intial depth of zero:

getFileListing("/home/mrjones/plip/download/sales",0);

<?php

function getFileListing($path,$depth){

    if (
$dir = @opendir($path)) {
        while(
$file readdir($dir)) {
            
            if ((
$file!=".")&&($file!="..")){
            
                
// unset spacing
                
$depthSpacing="";

                
// figure how many spaces to print per depth
                
$i 1;
                while (
$i <= $depth) {
                    
$depthSpacing .="\t";
                    
$i++;
                }

                
// print current itteration
                
print $depthSpacing.$file."\n";
                
                
// check if it's a directory
                
if (is_dir($path."/".$file)){
                    
getFileListing($path."/".$file$depth+1);
                }
            }
        }
        
closedir($dir);
    }
    else {
        print 
"error - could not @opendir(".$path.")";
        return 
0;
    }

    return 
1;
}

?>

© p l i p . c o m - w e b m a s t e r