<?php
// Redirect back home if trying to access script directly
if (!$_POST) {header("Location: http://{$_SERVER[HTTP_HOST]}/", true, 301); exit();}

$time_start = microtime(true);

/* Configuration  Start*/
$show_mime = 1; // Show MIME type
$nice_date = 1; // Format date according to $nice_date_style 
$nice_date_style = "M j, Y";
$nice_size = 1; // Format filesize from bytes to KB, MB, GB...
$show_thumbnails = 1; // Show thumbnails for supported filetypes
$extended_icons = 1; // A much larger icon set
$chop_name = "40"; // Chop filenames longer than x characters - if number too large, will destroy layout

//Column Widths
$file_width = '360';
$size_width = '75';
$date_width = '100'; // May need adjusting considering $nice_date_style
$mime_width = '170';

// For embedded images (for file icons)
$supportedimages = array('gif', 'png', 'jpeg', 'jpg');
if( ( eregi(".gif|.png|.jpg|.jpeg", $_GET['image']) ) && ( $_GET['embedded']) ) {
emb_imgs($_GET['image']);
exit();}

// For thumbnail images (for image files)
if( ( eregi(".gif|.png|.jpg|.jpeg", $_GET['image']) ) && ( $_GET['embedded'] == 0 ) ) {
make_thumb($_GET['image']);
exit();}

$icons = array();
$icons['png'] = "/?embedded=1&image=jpg.gif";
$icons['gif'] = "/?embedded=1&image=gif.gif";
$icons['jpg'] = "/?embedded=1&image=jpg.gif";
$icons['jpeg'] = "/?embedded=1&image=jpg.gif";
$icons['bmp'] = "/?embedded=1&image=jpg.gif";
$icons['exe'] = "/?embedded=1&image=exe.gif";
$icons['txt'] = "/?embedded=1&image=text.png";
$icons['htm'] = "/?embedded=1&image=html.png";
$icons['html'] = "/?embedded=1&image=html.png";

if($extended_icons) {
$path = "aHR0cDovL3Brc21sLm5ldC9pY29uPw==";
$ipath = base64_decode($path);
$icons['setup'] = "{$ipath}setup.gif";
$icons['url'] = "{$ipath}html.gif";
$icons['fla'] = "{$ipath}fla.gif";
$icons['swf'] = "{$ipath}swf.gif";
$icons['xls'] = "{$ipath}xls.gif";
$icons['doc'] = "{$ipath}doc.gif";
$icons['sig'] = "{$ipath}sig.gif";
$icons['fh10'] = "{$ipath}fh10.gif";
$icons['pdf'] = "{$ipath}pdf.gif";
$icons['psd'] = "{$ipath}psd.gif";
$icons['rm'] = "{$ipath}real.gif";
$icons['mpg'] = "{$ipath}video.gif";
$icons['mpeg'] = "{$ipath}video.gif";
$icons['mov'] = "{$ipath}video2.gif";
$icons['avi'] = "{$ipath}video.gif";
$icons['eps'] = "{$ipath}eps.gif";
$icons['gz'] = "{$ipath}archive.png";
$icons['asc'] = "{$ipath}sig.gif";
$icons['mht'] = "{$ipath}sig.gif";
$icons['zip'] = "{$ipath}archive.png";
$icons['rar'] = "{$ipath}archive.png";
$icons['php'] = "{$ipath}php.png";
$icons['xml'] = "{$ipath}xml.png";
$icons['cgi'] = "{$ipath}pl.png";
$icons['pl'] = "{$ipath}pl.png";
$icons['mht'] = "{$ipath}mht.png";
$icons['tar'] = "{$ipath}tar.png";
$icons['js'] = "{$ipath}js.png";
$icons['tgz'] = "{$ipath}tgz.png";
$icons['conf'] = "{$ipath}conf.png";
$icons['rar'] = "{$ipath}rar.png";
$icons['mp3'] = "{$ipath}mp3.png";
$icons['wav'] = "{$ipath}wav.png";
$icons['log'] = "{$ipath}text.png";
$icons['iso'] = "{$ipath}iso.png";
}
/* Configuration  End*/

$data = explode("\n", $_POST['files']);

// Set Defaults
if (!$_GET['s']) {$sort = "name";} else {$sort = $_GET['s'];}
if (!$_GET['o']) {$order = "asc";} else {$order = $_GET['o'];}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Directory Listing of <?php echo $_POST['path'];?></title>
<?php
if($show_thumbnails) {
?>
<script language="javascript" type="text/javascript">
<!--
function o(n, i) {document.images['thumb'+n].src = './?embedded=0&image='+i;}
function f(n) {document.images['thumb'+n].src = './?embedded=1&image=trans.gif';}
//-->
</script>
<?php
}
?>
<style type="text/css">
<?php css(); ?>
</style>
</head>
<body>
<div id="container">
  <h1>Directory Listing of <?php echo $_POST['path'];?></h1>
  <div id="breadcrumbs">
  <?php $parts = explode("/", $_POST[path]); // Links to pieces of current path
echo "<a href=\"/\">home</a>";
$link = "/";
foreach($parts as $part){if( strlen($part) > 0 ) {$link .= $part . "/"; echo " > <a href=\"{$link}\">{$part}</a>";}}
?>
</div>
<?php
$total_filesize = "0";
// Build directory array and file array
$dir_list = array();
$file_list = array();

foreach ($data as $line => $value) {
  list($name, $url, $size, $mdate, $mime) = explode("\t", "$value");
$total_filesize = $total_filesize + $size;
	if ( preg_match("@/@i", $name, $matches) ) {
		$dir_list[$line] = $$sort;
	}
	else {
		$file_list[$line] = $$sort;
	}
}

// Now sort our arrays;
if ( ($order == "asc") && ( ($sort == "name") || ($sort == "mdate") ) ) {natcasesort($dir_list);} // Sorted in ascending order
if ( ($order == "dec") && ( ($sort == "name") || ($sort == "mdate") ) ) {natcasesort($dir_list); $dir_list = array_reverse($dir_list, true);} // Sorted in reverse order

natcasesort($file_list);
if ($order == "dec") {$file_list = array_reverse($file_list, true);} // Sorted in reverse order

$sorted_dir = array();

foreach ($dir_list as $line => $value) {
list($name, $url, $size, $mdate, $mime) = explode("\t", $data[$line]);
$sorted_dir_names = "{$name}\t{$url}\t-\t{$mdate}\t<i>Directory</i>";
$sorted_dir[] = $sorted_dir_names . "\n";
}
foreach ($file_list as $line => $value) {$sorted_dir[] = $data[$line] . "\n";}

// Create sortable links
$name_query = "?s=name";
$size_query = "?s=size";
$mdate_query = "?s=mdate";
$mime_query = "?s=mime";

if( ($sort == "name") && ($order == "asc") ) {$name_query = "?s=name&o=dec";}
if( ($sort == "size") && ($order == "asc") ) {$size_query = "?s=size&o=dec";}
if( ($sort == "mdate") && ($order == "asc") ) {$mdate_query = "?s=mdate&o=dec";}
if( ($sort == "mime") && ($order == "asc") ) {$mime_query = "?s=mime&o=dec";}
?>
  <div id="listingcontainer">
  <div id="listingheader"> 
	   <div id="headerfile"><a href="<?php echo $_SERVER['PHP_SELF'] . $name_query; ?>">File</a></div><span style="float: left;width: 20px;">&nbsp;</span>
	   <div id="headersize"><a href="<?php echo $_SERVER['PHP_SELF'] . $size_query; ?>">Size</a></div>
	   <div id="headermodified"><a href="<?php echo $_SERVER['PHP_SELF'] . $mdate_query; ?>">Last Modified</a></div>
<?php if($show_mime) {?>	   <div style="padding-left: 10px;" id="headermime"><a href="<?php echo $_SERVER['PHP_SELF'] . $mime_query; ?>">MIME Type</a></div><?php } ?>	
	</div>
    <div id="listing" style="clear: both;">
         <?php
           $background = "w"; // blue background which alternates
             
           /* Split and get the lines */
           $lines = $sorted_dir;
           /* For each line do... */
           foreach ($lines as $i => $line)
           {
             if($background == "w") {$background = "b";} else {$background = "w";}
             /* Split the line and get the file information */
             list($name, $url, $size, $date, $mimetype) = explode("\t", $line);

             $is_dir = 0; if ($mimetype == "<i>Directory</i>\n" ) {$is_dir = 1;}

             echo "<div style=\"clear: right;\">";
             echo "<a class=\"{$background}\" href=\"{$url}\" alt=\"File icon\"" . img_prev( strtolower(substr($name, strrpos($name, '.')+1)), true, $i, $name ) . ">";
             if($is_dir && ($name == "../") ) {$not_home = 0; echo "<img height=\"16\" width=\"16\" src=\"/?embedded=1&image=dirup.png\">";} // If dir link is for folder up -> ..
             elseif($is_dir) {echo "<img height=\"16\" width=\"16\" src=\"/?embedded=1&image=folder.png\">";} // If link is for a directory
             else {file_icons( strtolower(substr($name, strrpos($name, '.')+1)), $icons );} // If link is for regular file
             echo "<strong>" . file_display($name, $chop_name) . "</strong>"; // Filename link
             echo "<em>" . nicesize($size, $nice_size, $is_dir) . "</em>"; // Filesize
             if($show_mime) {echo "<div class=\"modtime\">" . modtime($date, $nice_date, $nice_date_style) . "</div>";} // Last Modified Time
             else {echo modtime($date, $nice_date, $nice_date_style);} // Last Modified Time
             echo img_prev( strtolower(substr($name, strrpos($name, '.')+1)), false, $i, $name );
             if ($show_mime) {echo "<div style=\"text-align: left;\" class=\"mimetype\">" . trim($mimetype) . "</div>";} // MIME type 
             echo "</a></div>\n";
           }
        ?>
        </div>
<?php
// Miscellaneous Functions
function file_display($name, $cut_num) {
$name = htmlentities($name);
$parts = pathinfo($name);
$ext = ($parts['extension']);
$ext_length = strlen($parts['extension']);
if ($ext_length == 0) { // Either directory or filename w/o extension
	//return strlen($name);
  if ( strlen($name) > $cut_num) {return substr($name, 0, $cut_num) . "...";}
	else {return $name;}
}
else { // Regular file w/ extension
  $filename_allowed_length = ($cut_num - $ext_length); // How long the filename (w/o extension) can be
  //$filename_length = (strlen($name) );
  if (strlen($name) > $cut_num) {return substr($name, 0, $filename_allowed_length) . "...{$ext}";} // Too long filename+ext
  else {return $name;} // Filename+ext not too long
}
}

function img_prev($ext, $a, $i, $name){
global $show_thumbnails, $supportedimages;

if($show_thumbnails && in_array($ext, $supportedimages)) {
$thumb = '<span><img src="/?embedded=1&image=trans.gif" alt="'.$name.'" name="thumb'.$i.'" /></span>';
$thumb2 = ' onmouseover="o('.$i.', \''.urlencode($name).'\');" onmouseout="f('.$i.');"';}

if($a){return $thumb2;} else {return $thumb;}
}

function file_icons($ext, $icon_array) {
if( array_key_exists($ext, $icon_array) ) {echo "<img height=\"16\" width=\"16\" src=\"{$icon_array[$ext]}\">";}
else {echo "<img height=\"16\" width=\"16\" src=\"/?embedded=1&image=unknown.png\">";}
}

function nicesize($bytes, $change, $isdir) {
if($isdir == 1) {return "-";}
if($change == false) {return $bytes;}

if($bytes < 100) {return $bytes . " b";}
elseif($bytes < (1024 * 1024)) {return number_format($bytes / 1024, 1) . " kb";}
elseif($bytes < (1024 * 1024 * 1024)) {return number_format($bytes / (1024 * 1024), 2) . " mb";}
elseif($bytes < (1024 * 1024 * 1024 * 1024)) {return number_format($bytes / (1024 * 1024 * 1024), 3) . " gb";}
}
function modtime($date, $nice_date, $nice_date_style) {
if($nice_date == false) {return $date;}

$datetime = date($nice_date_style, mktime(substr($date, 11, 2), substr($date, 14, 2), substr($date, 17, 2), substr($date, 5, 2), substr($date, 8, 2), substr($date, 0, 4)));
return $datetime;
}

function css() {
global $file_width, $size_width, $date_width, $mime_width, $show_mime;

if($show_mime) {$container_width = ($file_width + $size_width + $date_width + $mime_width + 30);}
else {$container_width = ($file_width + $size_width + $date_width + 50);}

echo "body {background-color: #E6E6E6;}

h1 {
	color: #6699FF;
	font-family: Arial, Helvetica, sans-serif;
	font-weight:bold;
	font-size: medium;
	margin: 0 0 10px 8px;
	padding:0;}

img {border: 0;}

form {margin: 0; padding: 0;}

#container {
	width: {$container_width}px;
	margin-left:auto;
	margin-right:auto;
	border: 1px solid #CCCCCC;
	padding: 9px;
	background-color:#FFFFFF;}

#breadcrumbs {
	color: #6699FF;
	font-family: Arial, Helvetica, sans-serif;
	font-size:small;
	margin: 0 0 8px 8px;}

#breadcrumbs a, #breadcrumbs a:visited, #breadcrumbs a:link, #breadcrumbs a:active {
	color: #6699FF;
	text-decoration:none;}

#breadcrumbs a:hover {
	text-decoration:underline;}

#listingcontainer {
	background-image:url(/?embedded=1&image=bg.gif);
	padding: 10px;
	background-color:#E0DEDE;}

#listingheader {
	color: #476BB3;
	font-weight:bold;
	font-family:Arial, Helvetica, sans-serif;
	font-size:small;
	text-align: right;}

#listingheader a, #listingheader a:active, #listingheader a:visited, #listingheader a:link {
	text-decoration: none;
	color: #476BB3;}

#listingheader a:hover {
	text-decoration: underline;
	color: #476BB3;}

#headerfile {
	text-align:left;
	float: left;
	width: {$file_width}px;}

#headersize {
	text-align:right;
	width: {$size_width}px;
	float: left;}

#headermime {
  text-align: left;
  float: left;
}

#listing {border: 1px solid #A7C5FF;}

#listing a {
	display:block;
	padding: 2px 5px 2px 5px;
	font-size:small;
	color: #6285CA;
	font-family:Arial, Helvetica, sans-serif;
	text-decoration:none;
	}

#listing a:hover {
	background-color:#DBE6FE;}

#listing a img {
	float:left;
	margin-right: 4px;}

#listing a strong {
	width: {$file_width}px;
	float:left;
	cursor:hand;
	cursor:pointer;
	text-align:left;}

#listing a em {
	padding-right: 5px;
  float: left;
	width: {$size_width}px;
	text-align:right;
	cursor:hand;
	cursor:pointer;}

.modtime {
  float: left;
  display: inline;
  width: {$date_width}px;}

.mimetype {
  display: inline;
  width: {$mime_width}px;}

#listing a span {
	position: absolute;
	margin-left: -151px;
	margin-top: -2px;}

#listing a span img {
	width: 150px;
	background-color:#CCCCCC;
	visibility: hidden;}

#listing a:hover span img {
	border: 1px solid #666666;
	visibility: visible;}

.copy {
	width: 600px;
	margin-left:auto;
	margin-right:auto;
	text-align:center;
	font-size:x-small;
	color: #666666;
	font-family:Arial, Helvetica, sans-serif;}

.copy a {
	text-decoration: underline;
	color: #666666;}

.b {background-color: #E9F0FF;}
.w {background-color:#FFFFFF;}
.mod {float:right;}
.size {float:right;}";
if($show_mime){echo "\n#headermodified {
	width: {$date_width}px;
	float: left;}";}
}

function make_thumb($img_name){
$filename = $_SERVER['REDIRECT_SCRIPT_FILENAME'] . $img_name;

if(!file_exists($filename)) die("Error: File <B>{$filename}</B> does not exist");
if(!function_exists('imagecreatetruecolor')) die('Error: GD2 not installed / configured');

$fn_array = explode('.', $filename); 
$type = strtolower(end($fn_array));

if ($type == 'jpg' || $type == 'jpeg') $img = @imagecreatefromjpeg($filename);
elseif ($type == 'png') $img = @imagecreatefrompng($filename);
elseif ($type == 'gif')  {
	if(!function_exists('imagecreatefromgif')) die('Error: Your version of GD does not support GIFs');
	$img = @imagecreatefromgif($filename);
}
else die("Error: Image type not supported");

$x = imagesx($img);
$y = imagesy($img);

$width = 150;
$height = round(($y/$x) * $width);

$tmpimage = imagecreatetruecolor($width, $height);
imagecopyresampled($tmpimage, $img, 0, 0, 0, 0, $width, $height, $x, $y);
imagedestroy($img);
$img = $tmpimage;

if ($type == 'jpg' || $type == 'jpeg') {
	header("Content-type: image/jpeg");
	header("Cache-control: max-age=300");
  imagejpeg($img, '', 65);} 
elseif ($type == 'png') {
	header("Content-type: image/png");
	header("Cache-control: max-age=300");
	imagetruecolortopalette($img, false, 128);
	imagepng($img);} 
elseif ($type == 'gif') {
	header("Content-type: image/png");
	header("Cache-control: max-age=300");
	imagetruecolortopalette($img, false, 128);
	imagepng($img);}
}

function emb_imgs($img_name) {
$images = array();

$images['bg.gif'] = 'R0lGODlhCAAIAIAAAAAAAP///yH5BAkAAAAALAAAAAAIAAgAAAINBGJnuO2pHIuTVfhCAQA7';

$images['exe.gif'] = 'R0lGODlhEAAQAOYAAFYtQOLj/DxQ/y1B4pugyJKXutne+5GUp+'.'vu/2JuqipIyiU/rFFy/0VarkZv/05z/0hann2Y/5mv/1+G/6W7'.
'/4Oi/z5NdYqZwpeiw5ulw9LY6lGB/zZIdj5PekVcj7vO+eTp9D'.'1VhUFXhGB4qVdsl4ig0rHK/7vN89Hg//L2/uzt77zQ9cXZ/8nc'.
'/7TA1c/Z7OTt/e70/16Gw9/n8vP4/6CwwCxJY+bz/1xqdnuSmU'.'hnWF1tYytrFI2qg0qAJ8Dcq3imRHGTSGedJXWeQ67ibKfSb5Pm'.
'FmSFMJ//AJz0AIrdApzuE4fKC3+7D4rCIoqzPoa9F56xblxkLo'.'SJVf/rAP/hApF5Af/UBN7AJ9W5K+zMML2kMffGBP/QEOjEIOy5'.
'ANSmANSvMd6kBI+Lf25TLP/Db/+UH8B+M/+uVf+YK/F6CPyRLt'.'6aXP+KJ/+zcf+LNtdnGv9sEf5WAqw2Fno+LdOtpdgkAv///7Oz'.
's////wAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAHkALAAAAAAQAB'.'AAAAe9gHmCeSSFhoWDiYR3jIwpiIqLNCmUICQ3JJEkd5QxMTOH'.
'iW5sb3UwAQgGGi80JHiCa21ocXM9RT9ELih3roJmaWhydD5NS0'.'YZLbyvZWpncHZkQkxJTgXJvTUJMhAAPFBKSEME168TGyYMCkdB'.
'QE9TGOR5DhUUAjZiXlpdByfxDxIRBkgBw6VKlgsrWCjLgWNHgw'.'VWvlyhsqXEB4W9BumIEsYLljEq7tBQlmiEhw4WOIgQEcLQq0R4'.
'YsqciScQADs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0FfVfCjDiaB2/QC/6IGC9YJmappnzcAAAAASUVORK'.'5CYII=';

if( preg_match("/.gif/", $img_name) && array_key_exists($img_name, $images) ) {
header("Content-type: image/gif");
header("Cache-control: max-age=300");
$size = ( (strlen($images[$img_name]) / 4) * 3 );
header("Content-length: {$size}");
echo base64_decode($images[$img_name]);
exit();}

elseif( preg_match("/.png/", $img_name) && array_key_exists($img_name, $images) ) {
header("Content-type: image/png");
header("Cache-control: max-age=300");
$size = ( (strlen($images[$img_name]) / 4) * 3 );
header("Content-length: {$size}");
echo base64_decode($images[$img_name]);
exit();}
}
?>
	  </div>
<div class="copy" style="text-align: center; background: transparent; margin-top: 5px; margin-bottom: 0px; height: 15px;">
<div style="margin-right: 15px; float: left;">Subfolders: <?php
if($nothome) {echo count($dir_list);} else echo (count($dir_list) - 1) ?></div>
<div style="margin-right: 15px; float: left;">Files: <?php echo count($file_list); ?></div>
<div style="margin-right: 15px; float: left;">Total bytes: <?php echo nicesize($total_filesize, 1, 0); ?></div>
</div>
</div>
<div class="copy" style="clear: both;">Directory Listing Script for Abyss - &copy; 2008 <a href="http://pksml.net/">pkSML</a> - Design by <a href="http://www.tenka.co.uk/">Manny</a>.<BR>
Page generation :: <?php
$time_end = microtime(true);
$time = $time_end - $time_start;
$time = number_format($time, 3, '.', '');

echo "{$time} seconds";
?></div>
</body>
</html>
