i have not looking at file list for years, and few days back want to access a file remotely and the script does not work anymore. most probably because of the new PHP version. So just do a quick fix, and here it's if somebody need it. work with latest abyss and latest PHP 8
<?php
// *********************************************************************
// * Sortable Directory Listing script for Abyss Web Server *
// * Lists Directories first. *
// * by Vesku 29/7/2007 *
// * Works also with virtual directories. *
// * *
// *********************************************************************
// error_reporting(0);
$icons = [
'7z' => 'fas fa-file-archive',
'aac' => 'fas fa-music',
'accdb' => 'fas fa-database',
'ai' => 'fas fa-image',
'aif' => 'fas fa-music',
'apk' => 'fab fa-android',
'app' => 'fas fa-window',
'avi' => 'fas fa-video',
'bak' => 'fas fa-save',
'bat' => 'fas fa-terminal',
'bmp' => 'fas fa-image',
'box' => 'fas fa-archive',
'bz' => 'fas fa-file-archive',
'c' => 'fas fa-code',
'cfg' => 'fas fa-file-alt',
'class' => 'fas fa-code',
'cmd' => 'fas fa-terminal',
'com' => 'fas fa-window',
'cpp' => 'fas fa-code',
'css' => 'fab fab fa-css3',
'csv' => 'fas fa-file-csv',
'db' => 'fas fa-database',
'dbf' => 'fas fa-database',
'deb' => 'fas fa-archive',
'doc' => 'fas fa-file-word',
'docx' => 'fas fa-file-word',
'drw' => 'fas fa-image',
'email' => 'fas fa-envelope',
'eot' => 'fas fa-font-case',
'eps' => 'fas fa-image',
'erb' => 'fas fa-code',
'exe' => 'fab fa-windows',
'flac' => 'fas fa-music',
'flv' => 'fas fa-video',
'gam' => 'fas fa-gamepad',
'gif' => 'fas fa-image',
'gz' => 'fas fa-file-archive',
'htm' => 'fab fa-html5',
'html' => 'fab fa-html5',
'ico' => 'fas fa-image',
'ini' => 'fas fa-file-alt',
'iso' => 'fas fa-compact-disc',
'jar' => 'fas fa-window',
'java' => 'fab fa-java',
'jpeg' => 'fas fa-image',
'jpg' => 'fas fa-image',
'js' => 'fab fa-js',
'json' => 'fas fa-file-alt',
'lock' => 'fas fa-lock',
'log' => 'fas fa-file-alt',
'mail' => 'fas fa-envelope',
'md' => 'fab fa-markdown',
'mdb' => 'fas fa-database',
'mid' => 'fas fa-music',
'midi' => 'fas fa-music',
'mkv' => 'fas fa-video',
'mov' => 'fas fa-video',
'mp3' => 'fas fa-music',
'mp4' => 'fas fa-video',
'mpa' => 'fas fa-music',
'mpg' => 'fas fa-video',
'msg' => 'fas fa-envelope',
'msi' => 'fas fa-window',
'nes' => 'fas fa-gamepad',
'odt' => 'fas fa-file-alt',
'ogg' => 'fas fa-music',
'ogv' => 'fas fa-video',
'otf' => 'fas fa-font-case',
'pdb' => 'fas fa-database',
'pdf' => 'fas fa-file-pdf',
'php' => 'fab fa-php',
'phtml' => 'fab fa-html5',
'pl' => 'fas fa-code',
'png' => 'fas fa-image',
'ppt' => 'fas fa-file-powerpoint',
'pptx' => 'fas fa-file-powerpoint',
'ps' => 'fas fa-image',
'psd' => 'fas fa-image',
'py' => 'fab fa-python',
'rar' => 'fas fa-file-archive',
'rb' => 'fas fa-code',
'rom' => 'fas fa-gamepad',
'rpm' => 'fas fa-archive',
'rtf' => 'fas fa-file-alt',
'sav' => 'fas fa-save',
'sh' => 'fas fa-terminal',
'sql' => 'fas fa-database',
'svg' => 'fas fa-image',
'swf' => 'fas fa-video',
'tar' => 'fas fa-file-archive',
'tga' => 'fas fa-image',
'tif' => 'fas fa-image',
'tiff' => 'fas fa-image',
'ttf' => 'fas fa-font-case',
'twig' => 'fab fa-php',
'txt' => 'fas fa-file-alt',
'vb' => 'fas fa-window',
'wav' => 'fas fa-music',
'webm' => 'fas fa-video',
'wma' => 'fas fa-music',
'wmv' => 'fas fa-video',
'woff' => 'fas fa-font-case',
'xhtml' => 'fas fa-code',
'xls' => 'fas fa-file-excel',
'xlsx' => 'fas fa-file-excel',
'xml' => 'fas fa-code',
'xz' => 'fas fa-file-archive',
'yaml' => 'fas fa-file-alt',
'zip' => 'fas fa-file-archive',
'ffs_db' => 'fa-solid fa-rotate'
];
function sizeformat($size)
{
if ($size < 1024) {
return $size . " bytes";
} elseif ($size < 1024 * 1024) {
$size = round($size / 1024, 1);
return $size . " KB";
} elseif ($size < 1024 * 1024 * 1024) {
$size = round($size / (1024 * 1024), 1);
return $size . " MB";
} else {
$size = round($size / (1024 * 1024 * 1024), 1);
return $size . " GB";
}
}
function dateformat($date)
{
$separate = explode(" ", $date);
$separate_date = explode("-", $separate[0]);
$separate_time = explode(":", $separate[1]);
$year = $separate_date[0];
$month = $separate_date[1];
$day = $separate_date[2];
$hour = $separate_time[0] + 8; //+timezone
$minute = $separate_time[1];
$second = $separate_time[2];
$date = mktime($hour, $minute, $second, $month, $day, $year);
$date = date("Y-m-d h:i:s", $date);
return $date;
}
// Reading Abyss dirlist
$dotdot = false;
$lines = explode("\n", $_POST["files"]);
for ($i = 0; $i < count($lines); $i++) {
$array = explode("\t", $lines[$i]);
if ($array[1] == "../") {
$dotdot = "1";
$dotdotdate = $array[3];
}
$id[] = $i;
$name[] = $array[0];
$url[] = $array[1];
$size[] = $array[2];
$date[] = $array[3];
$type[] = $array[4];
if ($type[$i] == "") {
$type[$i] = "Directory";
}
}
$dir = [$name, $url, $size, $date, $type, $id];
// Sorting section
$nameth = "S=N&O=A";
$sizeth = "S=S&O=A";
$dateth = "S=D&O=A";
$mimeth = "S=T&O=A";
if (isset($_GET["S"])) {
switch ($_GET["S"]) {
case "N":
switch ($_GET["O"]) {
case "A":
array_multisort(
$dir[5],
SORT_REGULAR,
SORT_ASC,
$dir[1],
$dir[0],
$dir[4],
$dir[3],
$dir[2]
);
$nameth = "S=N&O=D";
break;
case "D":
array_multisort(
$dir[5],
SORT_REGULAR,
SORT_DESC,
$dir[1],
$dir[0],
$dir[4],
$dir[3],
$dir[2]
);
break;
}
break;
case "S":
switch ($_GET["O"]) {
case "A":
array_multisort(
$dir[2],
SORT_NUMERIC,
SORT_ASC,
$dir[5],
$dir[1],
$dir[0],
$dir[4],
$dir[3]
);
$sizeth = "S=S&O=D";
break;
case "D":
array_multisort(
$dir[2],
SORT_NUMERIC,
SORT_DESC,
$dir[5],
$dir[1],
$dir[0],
$dir[4],
$dir[3]
);
break;
}
break;
case "D":
switch ($_GET["O"]) {
case "A":
array_multisort(
$dir[3],
SORT_REGULAR,
SORT_ASC,
$dir[5],
$dir[1],
$dir[0],
$dir[4],
$dir[2]
);
$dateth = "S=D&O=D";
break;
case "D":
array_multisort(
$dir[3],
SORT_REGULAR,
SORT_DESC,
$dir[5],
$dir[1],
$dir[0],
$dir[4],
$dir[2]
);
break;
}
break;
case "T":
switch ($_GET["O"]) {
case "A":
array_multisort(
$dir[4],
SORT_REGULAR,
SORT_ASC,
$dir[5],
$dir[1],
$dir[0],
$dir[3],
$dir[2]
);
$mimeth = "S=T&O=D";
break;
case "D":
array_multisort(
$dir[4],
SORT_REGULAR,
SORT_DESC,
$dir[5],
$dir[1],
$dir[0],
$dir[3],
$dir[2]
);
break;
}
break;
default:
$nameth = "S=N&O=D";
break;
}
}
// HTML section
?>
<!DOCTYPE html>
<HTML>
<HEAD>
<META HTTP-EQUIV='Content-Type' CONTENT='text/html; charset=utf-8'>
<TITLE>Index of <?php echo rawurldecode($_POST["path"]); ?></TITLE>
<script src="https://kit.fontawesome.com/9e977409e4.js" crossorigin="anonymous"></script>
<style type="text/css">
TABLE {font-family: monospace;
font-size: smaller;}
TD {padding-right: 1em;}
TD {padding-top: 0.5em;}
<!--
BODY {
FONT-SIZE: small; COLOR: #000000; FONT-FAMILY: "trebuchet ms", Verdana, Arial, Helvetica, sans-serif; BACKGROUND-COLOR: #FFFFFF
}
H1 {
FONT-SIZE: large;
}
A:hover {
COLOR: #ff9900; TEXT-DECORATION: underline;
}
.footer {
TEXT-ALIGN: center; FONT-SIZE: smaller;
}
.footer IMG {
BORDER: 1px solid #888;
}
-->
</style>
</HEAD>
<BODY><H2>Index of <?php echo rawurldecode($_POST["path"]); ?></H2>
<HR>
<TABLE BORDER="0" class="listing">
<?php
echo "<TR><TH><a href=\"?$nameth\">Name</a></TH><TH><a href=\"?$sizeth\">Size</a></TH><TH><a href=\"?$dateth\">Date</a></TH><TH><a href=\"?$mimeth\">MIME Type</a></TH></TR>";
/*
echo "<PRE>";
print_r($dir);
echo "</PRE>";
*/
$max_length = 20; // file name length
// Printing dotdotdir
if ($dotdot == "1") {
echo '<TR><TD><span class="fa-solid fa-arrow-up-from-bracket"></span> <A HREF="../">[Parent Directory]</A></TD><TD NOWRAP ALIGN="RIGHT"><DIR></TD><TD NOWRAP>';
echo dateformat($dotdotdate) . "</TD><TD NOWRAP>Directory</TD></TR>" . "\n";
}
// Printing Directories
for ($i = 0; $i < count($lines); $i++) {
if ($dir[1][$i] != "../") {
if ($dir[4][$i] == "Directory") {
if (str_replace("/", "", $dir[0][$i])[0] == '$') {
// continue;
}
echo '<TR><TD>' .
"<span class=\"fa-solid fa-folder\"></span> " .
'<A HREF="' .
$dir[1][$i];
echo '"';
if (strlen($dir[1][$i]) > $max_length) {
echo ' title=" ' . str_replace("/", "", $dir[0][$i]) . '"';
}
echo '>';
echo '[';
if (strlen($dir[1][$i]) > $max_length) {
echo substr(str_replace("/", "", $dir[0][$i]), 0, $max_length) . "....";
} else {
echo str_replace("/", "", $dir[0][$i]);
}
echo ']</A></TD><TD NOWRAP ALIGN="RIGHT">';
echo "<DIR>";
echo "</TD><TD NOWRAP>" .
dateformat($dir[3][$i]) .
"</TD><TD NOWRAP>";
echo $dir[4][$i];
echo "</TD></TR>" . "\n";
}
}
}
// Printing Files
for ($i = 0; $i < count($lines); $i++) {
if ($dir[4][$i] != "Directory") {
$ext_arr = explode('.', $dir[1][$i]);
$icon = $icons[strtolower($ext_arr[count($ext_arr) - 1])] ?? 'fa-file';
echo '<TR><TD>' .
"<span class=\"fa-solid {$icon}\"></span> " .
'<A HREF="';
echo $dir[1][$i];
echo '"';
if (strlen($dir[0][$i]) > $max_length) {
echo ' title=" ' . $dir[0][$i] . '"';
}
echo '>';
if (strlen($dir[0][$i]) > $max_length) {
echo substr($dir[0][$i], 0, $max_length) . "....";
} else {
echo $dir[0][$i];
}
echo '</A></TD><TD NOWRAP ALIGN="RIGHT">';
echo sizeformat($dir[2][$i]);
echo "</TD><TD NOWRAP>" . dateformat($dir[3][$i]) . "</TD><TD NOWRAP>";
echo $dir[4][$i];
echo "</TD></TR>" . "\n";
}
}
?>
</TABLE>
<br><HR>
<CENTER>
<P CLASS="footer">
Abyss Web Server -
Copyright ?? 2001-2021 <A HREF="http://www.aprelium.com" >Aprelium</A> - All rights reserved
</P>
<P CLASS="footer">
<A HREF="http://www.aprelium.com" ><IMG SRC="/pwrabyss.gif" ALT="Powered by Abyss Web Server" TITLE="Powered by Abyss Web Server" BORDER="0" WIDTH="88" HEIGHT="31"></A>
</P>
</CENTER>
</BODY>
</HTML>