Location: PHPKode > projects > Wexplorer > weXplorer/list.php
<?php
/*
 * Created on 17 août 2005
 * @author Matthias Cullmann
 */

require_once('config.inc.php');
require_once('mime.php');
require_once(ACCESS_MANAGER.'.php');
 ob_start();
function readableSize($bytes){
	$factor = pow(1024, 4);
	if($bytes > $factor)
		return (sprintf("%01.3f TB", $bytes/$factor));
	$factor = $factor/1024;
	if($bytes > $factor)
		return (sprintf("%01.2f GB", $bytes/$factor));
	$factor = $factor/1024;
	if($bytes > $factor)
		return (sprintf("%01.1f MB", $bytes/$factor));
	$factor = $factor/1024;
	if($bytes > $factor)
		return (sprintf("%01.0f KB", $bytes/$factor));
	return "$bytes B";
}
?>
<table cellpadding='0' cellspacing='0' width ="100%" id="t1" class="sortable">
  <tbody>
  <tr>
<?php
if(SHOW_ICONS) echo "
    <th sorttype='nosort'>&nbsp;</th>";
?>
    <th>Name</th>
    <th sorttype="ts_sort_bytesize">Size</th>
    <th>Extension</th>
    <th>Date</th>
  </tr>
<?php
chdir(expandPath($_GET['folder']));
$d = dir('.');
$counter = 0;
$totalsize = 0;
  $ftmp = ROOT_URL."/".DISPATCHER.preg_replace("/^(\.){0,1}\//",'',$_GET['folder']);
while (false !== ($entry = $d->read())) {
  if($entry !='.' && $entry !='..' && $entry !=MESSAGE_FILE && !is_dir($entry) && 
  	(IGNORE_FILES =='' || preg_match(IGNORE_FILES, $entry) < 1 )
  ){
  $counter++;
  if(ob_get_level()==2)
  	ob_end_flush ();
  $size = @filesize($entry);
  if($size===false)
  	$size = "?";
  else {
  	$totalsize += $size;
  	$size = readableSize($size);
  }
  $path_parts = pathinfo($entry);
  if(isset($path_parts['extension']))
  	$ext = $path_parts['extension'];
  else 
  	$ext = "";
  $icon ="";
  if(SHOW_ICONS) {
	  $loxext = strtolower($ext);
	  if(file_exists(ROOT_DIR."/icons/$loxext.png"))
	  	$icon = "<img border='0' src='".ROOT_URL."/icons/$loxext.png'/>";
	  else if($loxext =='zip' || $loxext =='gz' || $loxext =='z')
	  	$icon = "<img border='0' src='".ROOT_URL."/icons/compressed.png'/>";	 
	  else if($loxext =='css' || $loxext =='README' || $loxext =='ini' || $loxext =='txt' || $loxext =='ksh' || $loxext =='reg' )
	  	$icon = "<img border='0' src='".ROOT_URL."/icons/text.png'/>";	 
	  else if($loxext =='html' || $loxext =='htm' )
	  	$icon = "<img border='0' src='".ROOT_URL."/icons/web.png'/>";	 
	  else if($loxext =='png' || $loxext =='jpg' || $loxext =='gif' || $loxext =='jpeg')
	  	$icon = "<img border='0' src='".ROOT_URL."/icons/image.png'/>";	 
	  else if($loxext =='exe' || $loxext =='cmd' || $loxext =='bat' || $loxext =='msi')
	  	$icon = "<img border='0' src='".ROOT_URL."/icons/binary.png'/>";	 
	  else 
	  	$icon = "<img border='0' src='".ROOT_URL."/icons/unknown.png'/>";
  	  $icon = "<td>$icon</td>";
  }	 
  $time =  @filemtime($entry);
  $new = "";
  if(isLogged() && lastLogin()&& lastLogin() < $time)
  	$new = "<img src='".ROOT_URL."/images/new.gif'/ >";
   if($time===false)
  	$time = "?";
  else 
  	$time = date("Y/m/d H:i:s", $time); 
	  if (isInline($entry) && authorized($_GET['folder']."/".$entry))
	 	 $filelink = "<a href='".$ftmp."/$entry' onclick='javascript:popupUrl(this.href,\"force_viewer\");return false;' >$entry</a>";
	  else 
	  	$filelink = "<a href='".$ftmp."/$entry'>$entry</a>";
  echo "
	<tr style='background-color:#FFFFFF;' onmouseover='spook(this)' onmouseout='deSpook(this)' onclick='this.style.backgroundColor=\"DDDDDD\";this.spookProtected = !this.spookProtected;deSpook(this);'>
		$icon		
		<td class='filelistentry'><a name='$entry'>$filelink</a> $new</td>
		<td class='filelistentry'><nobr>$size<nobr></td>
		<td class='filelistentry'><nobr>$ext</nobr></td>
		<td class='filelistentry'><nobr>$time</nobr></td>
	</tr>";
  }
}
echo "</tbody></table>";
  echo "<table cellpadding='0' cellspacing='0' width ='100%' ><tr>
		<td class='statusbar'>Total: ".readableSize($totalsize)." in $counter files</td>
</tr></table>";
if(ob_get_level()==2){
	ob_end_clean ();
echo "<table cellpadding='0' cellspacing='0' width ='100%' class='sortable'><tr><td class='statusbar'>";
echo "There are no files in this directory";
echo "</td></tr></table>";
}

?>


Return current item: Wexplorer