Looking for a php script that list content of a folder + size + date.


Hi !


A script like the one who produces that :


http://openpandora.org/firmware/
That page you linked is generated from the Apache webserver when directory browsing is enabled for that directory via a .htaccess file or globally for every directory on the server with the apache config file..


but I take it you need something similar, but without messing with Apache.


This was something I threw together quickly to look at log files in a directory and created html links to them.. It may not be exactly what you want, there is no styling or ability to navigate subdirectories, this was part of an old project.. but may get you started a good source of info is http://php.net:


Although perhaps checking if you can enable directory browsing on the directory you want listed may be a better solution as this is fairly crude..



Code:
<?php

function ListFiles($directory,$order) {


$filearray = array ();

if ($dirh = opendir($directory)) {

  while (($files = readdir($dirh)) !== FALSE) {

   if ($files != "." and $files != "..") {

	array_push($filearray,"<li><a target=\"_blank\" href=\"$directory/$files\">$files</a></li>\n");

   }


  }}

natsort($filearray);

if ($order == '' or $order == 'ASC') {


  return  $filearray;


} elseif ($order == 'DESC') {


  return array_reverse($filearray);

}

}

// usage, directory name and order ASC or DESC


$filelist = ListFiles('logs','DESC');

echo "<div class='filelist'>\n";

foreach ($filelist as $x) {

echo $x;

}

echo "</div>";

?>
 
Last edited by a moderator:
Produce an error... Warning: opendir(logs) [function.opendir]: failed to open dir: No such file or directory in...


Indeed, i need to be able to browse sub directories.


Thx.


---EDIT :


Found this one, but it doesn't show folders :/


http://www.celerondude.com/php-indexer


---EDIT :


Mmm seems it shows folders...
 
Last edited by a moderator:
Well it does need to have a directory called logs to work, just change the function call with your directory..



Code:
$filelist = ListFiles('YOUR_DIRECTORY_PATH','DESC');
..Like I said it was some quick code just to show the files in one directory.. I thought I had it navigating into directories at one point, but couldn't find that code...


Found this on a google search..


http://www.evoluted....-listing-script
 
Last edited by a moderator:
Back
Top