<?php
include("header.php");



	
	echo '

	
	<script>
	function toggle(hop){
		eval("hophop=document.all."+hop);
		if (hophop.style.display=="inline") hophop.style.display="none";
		else hophop.style.display="inline";
		}
	</script><div id="a">';
	recursive_listdir();
	echo "</div>";
	

	
function recursive_listdir($base="documents") {
	global $special_dirs;
    static $filelist = array(); 
    static $dirlist = array(); 
	static $i=0;
	$i++;
	$specials="";
	$folders="";
	$files="";
	
    if(is_dir($base)) { 
       $dh = opendir($base); 
	   echo '<table cellpadding="3" cellspacing="0" border="0"><tr><td style="display:'.(($base!="documents")?"none":"inline").';" id="dir'.$i.'" >
	   <table cellpadding="3" cellspacing="0" border="0">';
	   
	   $my_list=array();
	   while ($file = readdir($dh)) {
			if($file != '..' && $file !='.' && $file !='' && $file !='.htpasswd' && $file !='.htaccess'){ 
				$my_list[$file]=strtolower($file);
				}
			}
			closedir($dh);
			natsort($my_list);
       foreach ($my_list as $dir=>$value) {
			if (isset($special_dirs[strtoupper($dir)])) 
				echo '<a target="_blank" href="'.$base ."/". strtoupper($dir).'"><img align="absmiddle" src="../images/ie.gif" border="0">&nbsp;'.$special_dirs[strtoupper($dir)]."</a><br>\n\r";
           	elseif (is_dir($base ."/". $dir)) { 
            	echo '<tr><td><a href="javascript:void(0);" onClick=\'toggle("dir'.($i+1).'")\'><img align="absmiddle" src="../images/admin/folder.gif" border="0">&nbsp;<b>'.ucfirst($dir)."</b></a><br>";
				recursive_listdir($base ."/". $dir).'</td></tr>'; 
            	}
			elseif(is_file($base ."/". $dir) && $dir !== '.' && $dir !== '..') { 
               	$files.='<tr><td><a target="_blank" href="'.$base ."/". $dir.'"><img align="absmiddle" src="../images/admin/'.file_get_extension($dir).'.gif" border="0">&nbsp;'.ucfirst($dir)."</a> <font color='#AAAAAA'>".(round(filesize($base ."/". $dir)/1024))." Ko</font></td></tr>\n\r";
			    }
			}
			
		echo $files."</table></td></tr></table>\n\r";
    } 
 } 
 
function file_get_extension($file){
	$ext=substr(strrchr($file, "."), 1);
		if ($ext=="doc") return "doc";
	elseif ($ext=="xls") return "xls";
	elseif ($ext=="ppt") return "ppt";
	elseif ($ext=="pps") return "ppt";
	elseif ($ext=="pdf") return "pdf";
	elseif ($ext=="html") return "ie";
	elseif ($ext=="htm") return "ie";
	else return "file";
	}
include("footer.php");
?>