<?php
// CONFIG SECTION
$conf = "c:/program files/abyss/abyss.conf"; //filesystem path to your abyss conf file
$bytes = FALSE; // TRUE will show exact bytes in listing, FALSE will show KB, MB, GB, etc.
$truncate = TRUE; // Truncate long filenames
$trunc = 40; // If truncate is TRUE, where to truncate filename at
// END CONFIG SECTION - Only edit below if you know what you're doing
?>
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
<TITLE>Index of
<?php echo $_POST['path']; ?></TITLE>
<STYLE type="text/css">
td.pr {PADDING-RIGHT: 1em;}
</STYLE>
</HEAD>
<BODY>
<H1>Index of
<?php echo $_POST['path']; ?></H1>
<?php
$dir_array =
explode("/",
$_POST['path']);
?>
<HR>
<TABLE style="FONT-SIZE: smaller; FONT-FAMILY: monospace" border=0>
<THEAD>
<TH>Name</TH>
<TH>Size</TH>
<TH>Date</TH>
<TH>MIME Type</TH>
</TR>
<?php
// Grab virtual dir's
//XML Data
$xmlObj = new XmlToArray($xml_data);
$arrayData = $xmlObj->createArray();
$return = ""; // Have to create this now for the globalization to work right
$id = ($_SERVER['INSTANCE_ID'] - 1);
$aliases = $arrayData['root']['server'][0]['host'][$id]['aliases'][0]['alias'];
foreach ($aliases as $key => $value){
if ('/' ==
substr($value['virtual'],
strlen($value['virtual'])-1)){ $value['virtual'] =
substr_replace($value['virtual'],
'',
strlen($value['virtual'])-1);
} // strip trailing slash $split =
explode("/",
$value['virtual']);
$up_one = $split;
$hier .= "/"; // add trailing slash so it might match post[path]
$return .=
$split[(count($split) -
1)].
"/\t".
//NAME "0"."\t". //SIZE
"-"."\t". //DATE
"<I>Alias Directory</I>"."\n"; //MIME
}
}
// End virtual dir processing
$_POST['files'] = $return.$_POST['files']; //adds aliases to internal file list
$lines =
explode("\n",
$_POST['files']);
foreach ($lines as $line)
{
/* Split the line and get the file information */
list($name,
$url,
$size,
$date,
$mimetype) =
explode("\t",
$line);
if ($mimetype == "") {$mimetype = "Directory";}
if ($size == "0") {$size = "-";} elseif($bytes == FALSE){$size = niceSize($size);}
if ($truncate == TRUE){$name = shortName($name, $trunc);}
"<TD class=\"pr\"><A HREF=\"$url\">".
htmlentities($name).
"</A></TD>".
"<TD class=\"pr\" noWrap align=right>$size</TD>".
"<TD class=\"pr\" noWrap>$date</TD>".
"<TD>$mimetype</TD>".
"</TR>\n";
}
?>
</TABLE>
<HR>
</BODY>
</HTML>
<?php
function niceSize($bytes){
if($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 shortName($name, $trunc){
if(strlen($name) <
$trunc){return $name;
} $return =
substr($name,
0,
$trunc) .
"...";
}
return $return;
}
}
?>
<?php // This class below translates the abyss.conf XML into an array
/**
* Author : MA Razzaque Rupom (rupom_315@yahoo.com, rupom.bd@gmail.com)
* Version : 1.0
* Date : 02 March, 2006
* Purpose : Creating Hierarchical Array from XML Data
* Released : Under GPL
*/
//require_once "class.xmltoarray.php";
//***************************************************************************
class XmlToArray
{
var $xml='';
/**
* Default Constructor
* @param $xml = xml data
* @return none
*/
function XmlToArray($xml)
{
$this->xml = $xml;
}
/**
* _struct_to_array($values, &$i)
*
* This is adds the contents of the return xml into the array for easier processing.
* Recursive, Static
*
* @access private
* @param array $values this is the xml data in an array
* @param int $i this is the current location in the array
* @return Array
*/
function _struct_to_array($values, &$i)
{
while ($i++ <
count($values)) { switch ($values[$i]['type']) {
case 'cdata':
break;
case 'complete':
$name = $values[$i]['tag'];
$child[$name]= ($values[$i]['value'])?($values[$i]['value']):'';
if(isset($values[$i]['attributes'])) { $child[$name] = $values[$i]['attributes'];
}
}
break;
case 'open':
$name = $values[$i]['tag'];
$size =
isset($child[$name]) ?
sizeof($child[$name]) :
0;
$child[$name][$size] = $this->_struct_to_array($values, $i);
break;
case 'close':
return $child;
break;
}
}
return $child;
}//_struct_to_array
/**
* createArray($data)
*
* This is adds the contents of the return xml into the array for easier processing.
*
* @access public
* @param string $data this is the string of the xml data
* @return Array
*/
function createArray()
{
$xml = $this->xml;
$i = 0;
$name = $values[$i]['tag'];
$array[$name] =
isset($values[$i]['attributes']) ?
$values[$i]['attributes'] :
'';
$array[$name] = $this->_struct_to_array($values, $i);
return $array;
}//createArray
}//XmlToArray
//***************************************************************************
?>