Page 1 of 1

Help needed

Posted: Thu Aug 19, 2010 6:04 am
by ute
Hi
I need someone to write me a script that reads the contents of a folder and its subfolders and then write the content into a html file as a list of links.

I would need it asap.
If someone is interested please give me a quotation.

Thanks

Ute

Re: Help needed

Posted: Thu Aug 19, 2010 10:15 am
by MindOverBody
Here it is, play a bit, and adjust it to your needs

Code: Select all

function getDirTree( $RootPath, $Position ){ 
	if ( ( $directoryHandle = opendir( $RootPath ) ) == true ) {  
              $Position += 15;
              while ( ( $file = readdir( $directoryHandle ) ) !== false ) {
                   if ( is_dir( $RootPath . "/" . $file ) && ( $file == '.' || $file == '..' ) !== true ){   
		        echo "<div style='margin-left: " . $Position . "px; '> ยป <a href='" . $RootPath . "/" . $file . "'>" . $file . "</a></div>";
			getDirTree( $RootPath . "/" . $file, $Position );  
                   }
              }		
        
	}
}

// First parameter: Starting position
// Second parameter: Tree item left margin (in pixels)
getDirTree( dirname(__file__), -15 );