Update things

This commit is contained in:
Skylar Ittner 2019-01-01 13:31:59 -07:00
parent 949632abbe
commit c5f9b01554
2 changed files with 140 additions and 121 deletions

View File

@ -1,4 +1,4 @@
Copyright 2018 Netsyms Technologies Copyright 2018-2019 Netsyms Technologies
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

259
index.php
View File

@ -4,7 +4,7 @@ Nice Dirlist
https://source.netsyms.com/Netsyms/NiceDirlist https://source.netsyms.com/Netsyms/NiceDirlist
Copyright 2018 Netsyms Technologies Copyright 2018-2019 Netsyms Technologies
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met: modification, are permitted provided that the following conditions are met:
@ -58,15 +58,10 @@ $MIRRORBASE = [
]; ];
*/ */
// Bootstrap and optional CSS // Bootstrap, FontAwesome, and optional CSS
$STYLESHEETS = [ $STYLESHEETS = [
"https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" "https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css",
]; "https://use.fontawesome.com/releases/v5.6.3/css/all.css"
// FontAwesome 5 locations
$FONTAWESOME = [
"https://use.fontawesome.com/releases/v5.0.9/js/solid.js",
"https://use.fontawesome.com/releases/v5.0.9/js/brands.js",
"https://use.fontawesome.com/releases/v5.0.9/js/fontawesome.js"
]; ];
// Mimetype to FontAwesome conversion table // Mimetype to FontAwesome conversion table
$MIMEICONS = [ $MIMEICONS = [
@ -76,7 +71,7 @@ $MIMEICONS = [
// Text/Code // Text/Code
"text/html" => "fab fa-html5", "text/html" => "fab fa-html5",
"text/css" => "fab fa-css3", "text/css" => "fab fa-css3",
"text/csv" => "fas fa-table", "text/csv" => "fas fa-file-csv",
"application/ecmascript" => "fas fa-code", "application/ecmascript" => "fas fa-code",
"text/calendar" => "fas fa-calendar", "text/calendar" => "fas fa-calendar",
"application/javascript" => "fab fa-js", "application/javascript" => "fab fa-js",
@ -91,7 +86,12 @@ $MIMEICONS = [
"text/checksum" => "fas fa-file-medical-alt", "text/checksum" => "fas fa-file-medical-alt",
"text/config" => "fas fa-list", "text/config" => "fas fa-list",
"text/other" => "fas fa-file-alt", "text/other" => "fas fa-file-alt",
// Archives and disk images "text/x-java-source" => "fab fa-java",
"application/x-python-code" => "fab fa-python",
"text/x-vcard" => "fas fa-address-card",
"text/x-c" => "fas fa-code",
"text/x-asm" => "fas fa-microchip",
// Archives, disk images, and executables
"application/x-iso9660-image" => "fas fa-hdd", "application/x-iso9660-image" => "fas fa-hdd",
"application/x-gzip" => "fas fa-file-archive", "application/x-gzip" => "fas fa-file-archive",
"application/zip" => "fas fa-file-archive", "application/zip" => "fas fa-file-archive",
@ -100,11 +100,15 @@ $MIMEICONS = [
"application/x-7z-compressed" => "fas fa-file-archive", "application/x-7z-compressed" => "fas fa-file-archive",
"application/x-msi" => "fab fa-windows", "application/x-msi" => "fab fa-windows",
"application/x-msdownload" => "fab fa-windows", "application/x-msdownload" => "fab fa-windows",
"application/java-archive" => "fas fa-coffee", "application/java-archive" => "fab fa-java",
"application/x-java-jnlp-file" => "fab fa-java",
"application/x-rar-compressed" => "fas fa-file-archive", "application/x-rar-compressed" => "fas fa-file-archive",
"application/x-tar" => "fas fa-file-archive", "application/x-tar" => "fas fa-file-archive",
"application/x-apple-diskimage" => "fab fa-apple", "application/x-apple-diskimage" => "fab fa-apple",
"application/imgfile" => "fas fa-hdd", "application/imgfile" => "fas fa-hdd",
"application/x-debian-package" => "fab fa-linux",
"application/x-appimage" => "fab fa-linux",
"application/x-msdownload" => "fab fa-windows",
// Fonts // Fonts
"application/vnd.ms-fontobject" => "fas fa-font", "application/vnd.ms-fontobject" => "fas fa-font",
"application/x-font-ttf" => "fas fa-font", "application/x-font-ttf" => "fas fa-font",
@ -124,6 +128,7 @@ $MIMEICONS = [
"image/tiff" => "fas fa-image", "image/tiff" => "fas fa-image",
"image/webp" => "fas fa-image", "image/webp" => "fas fa-image",
"image/other" => "fas fa-image", "image/other" => "fas fa-image",
"application/postscript" => "fas fa-file-image",
// Audio // Audio
"audio/acc" => "fas fa-file-audio", "audio/acc" => "fas fa-file-audio",
"audio/ogg" => "fas fa-file-audio", "audio/ogg" => "fas fa-file-audio",
@ -133,6 +138,8 @@ $MIMEICONS = [
"audio/3gpp" => "fas fa-file-audio", "audio/3gpp" => "fas fa-file-audio",
"audio/3gpp2" => "fas fa-file-audio", "audio/3gpp2" => "fas fa-file-audio",
"audio/other" => "fas fa-file-audio", "audio/other" => "fas fa-file-audio",
"audio/mpeg" => "fas fa-file-audio",
"application/vnd.apple.mpegurl" => "fas fa-podcast",
// Video // Video
"application/x-shockwave-flash" => "fas fa-video-slash", "application/x-shockwave-flash" => "fas fa-video-slash",
"video/mpeg" => "fas fa-file-video", "video/mpeg" => "fas fa-file-video",
@ -141,6 +148,7 @@ $MIMEICONS = [
"video/3gpp" => "fas fa-file-video", "video/3gpp" => "fas fa-file-video",
"video/3gpp2" => "fas fa-file-video", "video/3gpp2" => "fas fa-file-video",
"video/other" => "fas fa-file-video", "video/other" => "fas fa-file-video",
"video/x-matroska" => "fas fa-file-video",
// Office files // Office files
"application/x-abiword" => "fas fa-file-word", "application/x-abiword" => "fas fa-file-word",
"application/msword" => "fas fa-file-word", "application/msword" => "fas fa-file-word",
@ -152,12 +160,24 @@ $MIMEICONS = [
"application/vnd.oasis.opendocument.text" => "fas fa-file-word", "application/vnd.oasis.opendocument.text" => "fas fa-file-word",
"application/pdf" => "fas fa-file-pdf", "application/pdf" => "fas fa-file-pdf",
"application/rtf" => "fas fa-file", "application/rtf" => "fas fa-file",
"application/x-gnumeric" => "fas fa-file-excel",
// Other // Other
"application/vnd.amazon.ebook" => "fas fa-book", "application/vnd.amazon.ebook" => "fas fa-book",
"application/epub+zip" => "fas fa-book", "application/epub+zip" => "fas fa-book",
"application/x-mobipocket-ebook" => "fas fa-book",
"application/ogg" => "fas fa-play", "application/ogg" => "fas fa-play",
"application/x-sql" => "fas fa-database", "application/x-sql" => "fas fa-database",
"application/odb" => "fas fa-database", "application/odb" => "fas fa-database",
"application/gpx+xml" => "fas fa-compass",
"application/java-serialized-object" => "fab fa-java",
"application/java-vm" => "fab fa-java",
"application/x-ms-shortcut" => "fas fa-external-link-alt",
"application/x-bittorrent" => "fas fa-share-alt",
"application/x-pkcs12" => "fas fa-certificate",
"application/pgp-encrypted" => "fas fa-lock",
"application/pgp-signature" => "fas fa-file-signature",
"model/mesh" => "fas fa-cube",
"model/vnd.dwf" => "fas fa-cube",
]; ];
// File extension to mimetype conversion // File extension to mimetype conversion
$EXT2MIME = [ $EXT2MIME = [
@ -180,6 +200,8 @@ $EXT2MIME = [
"img" => "application/imgfile", "img" => "application/imgfile",
"ini" => "text/config", "ini" => "text/config",
"yml" => "text/config", "yml" => "text/config",
"py" => "application/x-python-code",
"appimage" => "application/x-appimage",
// From Apache: http://svn.apache.org/viewvc?view=revision&revision=1810122 // From Apache: http://svn.apache.org/viewvc?view=revision&revision=1810122
"ez" => "application/andrew-inset", "ez" => "application/andrew-inset",
"aw" => "application/applixware", "aw" => "application/applixware",
@ -1223,116 +1245,113 @@ word-break: break-all;
} }
} }
</style> </style>
<?php
foreach ($FONTAWESOME as $fa) {
echo "<script src=\"$fa\"></script>\n";
}
?>
<div class="container"> <div class="container">
<div class="card">
<div class="card-body">
<div class="row">
<div class="col-12 col-md-4 col-lg-2" style="text-align: center;">
<img src="<?php echo $SITEICON; ?>" class="site-icon" />
</div>
<div class="col-12 col-md-8 col-lg-10">
<div class="d-flex flex-column justify-content-center" style="height: 100%;">
<h1 class="display-4"><?php echo $H1; ?></h1>
<h2 class="display-5"><?php echo $H2; ?></h2>
</div>
</div>
</div>
</div>
</div>
<div class="row mt-4"> <div class="card">
<div class="card-body">
<div class="row">
<div class="col-12 col-md-4 col-lg-2" style="text-align: center;">
<img src="<?php echo $SITEICON; ?>" class="site-icon" />
</div>
<div class="col-12 col-md-8 col-lg-10">
<div class="d-flex flex-column justify-content-center" style="height: 100%;">
<h1 class="display-4"><?php echo $H1; ?></h1>
<h2 class="display-5"><?php echo $H2; ?></h2>
</div>
</div>
</div>
</div>
</div>
<div class="col-12"> <div class="row mt-4">
<div class="card"> <div class="col-12">
<div class="card-header d-flex"> <div class="card">
<span class="mr-auto">
<nav aria-label="breadcrumb"> <div class="card-header d-flex">
<ol class="breadcrumb m-0"> <span class="mr-auto">
<?php <nav aria-label="breadcrumb">
$pathparts = explode("/", $path); <ol class="breadcrumb m-0">
$pstr = ""; <?php
for ($i = 0; $i < count($pathparts)-1; $i++) { $pathparts = explode("/", $path);
$p = $pathparts[$i]; $pstr = "";
$pstr .= $p . "/"; for ($i = 0; $i < count($pathparts)-1; $i++) {
if ($i == 0) { $p = $pathparts[$i];
$p = "<span class=\"fas fa-home\"></span>"; $pstr .= $p . "/";
} if ($i == 0) {
if ($i+1 == count($pathparts)-1) { $p = "<span class=\"fas fa-home\"></span>";
echo "\t<li aria-current=\"page\" class=\"breadcrumb-item active\">$p</li>"; }
} else { if ($i+1 == count($pathparts)-1) {
echo "\t<li class=\"breadcrumb-item\"><a href=\"$pstr\">$p</a></li>"; echo "\t<li aria-current=\"page\" class=\"breadcrumb-item active\">$p</li>";
} } else {
echo "\n"; echo "\t<li class=\"breadcrumb-item\"><a href=\"$pstr\">$p</a></li>";
} }
?> echo "\n";
</ol> }
</nav> ?>
</span> </ol>
</div> </nav>
<div class="card-body"> </span>
<ul class="list-group"> </div>
<?php
$files = scandir($dir); <div class="card-body">
foreach ($files as $f) { <ul class="list-group">
if (strpos($f, '.') !== 0 && !in_array($f, $IGNORE)) { <?php
echo "<li class=\"list-group-item d-flex\">\n"; $files = scandir($dir);
echo "\t<a href=\"$path$f\">"; foreach ($files as $f) {
if (is_dir($dir . "/" . $f)) { if (strpos($f, '.') !== 0 && !in_array($f, $IGNORE)) {
echo "<span class=\"fas fa-folder fa-fw\"></span> "; echo "<li class=\"list-group-item d-flex\">\n";
} else { echo "\t<a href=\"$path$f\">";
$icon = "fas fa-file"; if (is_dir($dir . "/" . $f)) {
$extension = pathinfo("$dir/$f")['extension']; echo "<span class=\"fas fa-folder fa-fw\"></span> ";
// If we don't have an extension, try using the whole filename } else {
if ($extension == "") { $icon = "fas fa-file";
$extension = $f; $extension = strtolower(pathinfo("$dir/$f")['extension']);
} // If we don't have an extension, try using the whole filename
$mimetype = "application/octet-stream"; if ($extension == "") {
// Lookup mimetype from extension $extension = $f;
if (array_key_exists($extension, $EXT2MIME)) { }
$mimetype = $EXT2MIME[$extension]; $mimetype = "application/octet-stream";
} // Lookup mimetype from extension
// Lookup icon from mimetype if (array_key_exists($extension, $EXT2MIME)) {
if (array_key_exists($mimetype, $MIMEICONS)) { $mimetype = $EXT2MIME[$extension];
$icon = $MIMEICONS[$mimetype]; }
} else { // Allow broad generic <format>/other icons // Lookup icon from mimetype
$mimefirst = explode("/", $mimetype, 2)[0]; if (array_key_exists($mimetype, $MIMEICONS)) {
if (array_key_exists($mimefirst."/other", $MIMEICONS)) { $icon = $MIMEICONS[$mimetype];
$icon = $MIMEICONS[$mimetype]; } else { // Allow broad generic <format>/other icons
} $mimefirst = explode("/", $mimetype, 2)[0];
} if (array_key_exists($mimefirst."/other", $MIMEICONS)) {
echo "<span class=\"$icon fa-fw\"></span> "; $icon = $MIMEICONS[$mimetype];
} }
echo $f . "</a>\n"; }
if (count($MIRRORBASE) > 0 && !is_dir($dir . "/" . $f)) { echo "<span class=\"$icon fa-fw\"></span> ";
echo "<span class=\"d-inline-flex justify-content-end " }
. "align-items-center flex-wrap ml-auto\">\n"; echo $f . "</a>\n";
echo "\t<a href=\"$path$f\" class=\"my-1 btn btn-outline-default btn-sm\">" if (count($MIRRORBASE) > 0 && !is_dir($dir . "/" . $f)) {
. "<span class=\"fas fa-cloud-download-alt\"></span>" echo "<span class=\"d-inline-flex justify-content-end "
. " Main</a>\n"; . "align-items-center flex-wrap ml-auto\">\n";
foreach ($MIRRORBASE as $mirror) { echo "\t<a href=\"$path$f\" class=\"my-1 btn btn-outline-default btn-sm\">"
$name = $mirror["name"]; . "<span class=\"fas fa-cloud-download-alt\"></span>"
$base = $mirror["base"]; . " Main</a>\n";
echo "\t<a href=\"$base$path$f\"" foreach ($MIRRORBASE as $mirror) {
. " class=\"ml-2 my-1 btn btn-outline-default btn-sm\">" $name = $mirror["name"];
. "<span class=\"fas fa-cloud-download-alt\"></span>" $base = $mirror["base"];
. " $name</a>\n"; echo "\t<a href=\"$base$path$f\""
} . " class=\"ml-2 my-1 btn btn-outline-default btn-sm\">"
echo "</span>"; . "<span class=\"fas fa-cloud-download-alt\"></span>"
} . " $name</a>\n";
echo "</li>\n\n"; }
} echo "</span>";
} }
?> echo "</li>\n\n";
</ul> }
</div> }
</div> ?>
</div> </ul>
</div>
</div>
</div>
</div>
</div>
</div> </div>