Contents of public folder

You are here : Public folder/'.$subdir.'

'; } else { $subdirs = explode("/", $subdir); $parentdirs = ""; echo '

You are here : Public folder/'; foreach ($subdirs as $value) { echo ''.$value.'/'; $parentdirs .= $value.'/'; } echo '

'; } } Else { $dir=opendir('.'); //if you want to track the contents of another folder, replace the above line with //something like $dir=opendir('./MyFolder/'); } $oneOrMoreDir = false; $dirList = ""; $oneOrMoreFile = false; $fileList = ""; echo "

The following folders and files contain useful things. Help yourselves.

"; while (false !== ($file = readdir($dir))){ if($file !='.' && $file != '..' && $file != 'index.php' && $file != 'index.htm' && $file != 'index.html' && $file !='.htaccess'){ //each directory listing contains: //an entry with one dot (for current directory), //an entry two dots (for parent directory), //files... //This script is probably named 'index.php' so it's better to skip index files altogether. //For security reason, '.htaccess' files also need not to be displayed. if (!strrchr($file, ".")) { //is_file or is_dir wouldn't work with my host, so I resorted to tracking dots. $oneOrMoreDir = true; If (isset($subdir)) { $dirList .= '
  • '.$file.'
  • '; } else { $dirList .= '
  • '.$file.'
  • '; } } Else { $oneOrMoreFile = True; If (isset($subdir)) { $fileList .= '
  • '.$file.' ('.number_format((@filesize($subdir.'/'.$file)/1024), 2, '.', ' ').' kb)
  • '; } else { $fileList .= '
  • '.$file.' ('.number_format((@filesize($file)/1024), 2, '.', ' ').' kb)
  • '; //filesize works but reports a warning, though I couldn't find out why. The '@' in front gets us rid rid of it. } } } } if ($oneOrMoreDir == true) { echo '

    Folders:

    '; } if ($oneOrMoreFile == true) { echo '

    Files:

    '; } closedir($dir); clearstatcache(); //Directory-related functions use a lot of server memory, we need to release it at the end of the script. ?>

    Script created by Goulven CHAMPENOIS.