Update things

master
Skylar Ittner 5 years ago
parent 949632abbe
commit c5f9b01554

@ -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:

@ -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="col-12"> <div class="card">
<div class="card"> <div class="card-body">
<div class="card-header d-flex"> <div class="row">
<span class="mr-auto"> <div class="col-12 col-md-4 col-lg-2" style="text-align: center;">
<nav aria-label="breadcrumb"> <img src="<?php echo $SITEICON; ?>" class="site-icon" />
<ol class="breadcrumb m-0"> </div>
<?php <div class="col-12 col-md-8 col-lg-10">
$pathparts = explode("/", $path); <div class="d-flex flex-column justify-content-center" style="height: 100%;">
$pstr = ""; <h1 class="display-4"><?php echo $H1; ?></h1>
for ($i = 0; $i < count($pathparts)-1; $i++) { <h2 class="display-5"><?php echo $H2; ?></h2>
$p = $pathparts[$i]; </div>
$pstr .= $p . "/"; </div>
if ($i == 0) { </div>
$p = "<span class=\"fas fa-home\"></span>"; </div>
} </div>
if ($i+1 == count($pathparts)-1) {
echo "\t<li aria-current=\"page\" class=\"breadcrumb-item active\">$p</li>";
} else {
echo "\t<li class=\"breadcrumb-item\"><a href=\"$pstr\">$p</a></li>";
}
echo "\n";
}
?>
</ol>
</nav>
</span>
</div>
<div class="card-body">
<ul class="list-group">
<?php
$files = scandir($dir);
foreach ($files as $f) {
if (strpos($f, '.') !== 0 && !in_array($f, $IGNORE)) {
echo "<li class=\"list-group-item d-flex\">\n";
echo "\t<a href=\"$path$f\">";
if (is_dir($dir . "/" . $f)) {
echo "<span class=\"fas fa-folder fa-fw\"></span> ";
} else {
$icon = "fas fa-file";
$extension = pathinfo("$dir/$f")['extension'];
// If we don't have an extension, try using the whole filename
if ($extension == "") {
$extension = $f;
}
$mimetype = "application/octet-stream";
// Lookup mimetype from extension
if (array_key_exists($extension, $EXT2MIME)) {
$mimetype = $EXT2MIME[$extension];
}
// Lookup icon from mimetype
if (array_key_exists($mimetype, $MIMEICONS)) {
$icon = $MIMEICONS[$mimetype];
} else { // Allow broad generic <format>/other icons
$mimefirst = explode("/", $mimetype, 2)[0];
if (array_key_exists($mimefirst."/other", $MIMEICONS)) {
$icon = $MIMEICONS[$mimetype];
}
}
echo "<span class=\"$icon fa-fw\"></span> ";
}
echo $f . "</a>\n";
if (count($MIRRORBASE) > 0 && !is_dir($dir . "/" . $f)) {
echo "<span class=\"d-inline-flex justify-content-end "
. "align-items-center flex-wrap ml-auto\">\n";
echo "\t<a href=\"$path$f\" class=\"my-1 btn btn-outline-default btn-sm\">"
. "<span class=\"fas fa-cloud-download-alt\"></span>"
. " Main</a>\n";
foreach ($MIRRORBASE as $mirror) {
$name = $mirror["name"];
$base = $mirror["base"];
echo "\t<a href=\"$base$path$f\""
. " class=\"ml-2 my-1 btn btn-outline-default btn-sm\">"
. "<span class=\"fas fa-cloud-download-alt\"></span>"
. " $name</a>\n";
}
echo "</span>";
}
echo "</li>\n\n";
}
}
?>
</ul>
</div>
</div>
</div>
</div> <div class="row mt-4">
<div class="col-12">
<div class="card">
<div class="card-header d-flex">
<span class="mr-auto">
<nav aria-label="breadcrumb">
<ol class="breadcrumb m-0">
<?php
$pathparts = explode("/", $path);
$pstr = "";
for ($i = 0; $i < count($pathparts)-1; $i++) {
$p = $pathparts[$i];
$pstr .= $p . "/";
if ($i == 0) {
$p = "<span class=\"fas fa-home\"></span>";
}
if ($i+1 == count($pathparts)-1) {
echo "\t<li aria-current=\"page\" class=\"breadcrumb-item active\">$p</li>";
} else {
echo "\t<li class=\"breadcrumb-item\"><a href=\"$pstr\">$p</a></li>";
}
echo "\n";
}
?>
</ol>
</nav>
</span>
</div>
<div class="card-body">
<ul class="list-group">
<?php
$files = scandir($dir);
foreach ($files as $f) {
if (strpos($f, '.') !== 0 && !in_array($f, $IGNORE)) {
echo "<li class=\"list-group-item d-flex\">\n";
echo "\t<a href=\"$path$f\">";
if (is_dir($dir . "/" . $f)) {
echo "<span class=\"fas fa-folder fa-fw\"></span> ";
} else {
$icon = "fas fa-file";
$extension = strtolower(pathinfo("$dir/$f")['extension']);
// If we don't have an extension, try using the whole filename
if ($extension == "") {
$extension = $f;
}
$mimetype = "application/octet-stream";
// Lookup mimetype from extension
if (array_key_exists($extension, $EXT2MIME)) {
$mimetype = $EXT2MIME[$extension];
}
// Lookup icon from mimetype
if (array_key_exists($mimetype, $MIMEICONS)) {
$icon = $MIMEICONS[$mimetype];
} else { // Allow broad generic <format>/other icons
$mimefirst = explode("/", $mimetype, 2)[0];
if (array_key_exists($mimefirst."/other", $MIMEICONS)) {
$icon = $MIMEICONS[$mimetype];
}
}
echo "<span class=\"$icon fa-fw\"></span> ";
}
echo $f . "</a>\n";
if (count($MIRRORBASE) > 0 && !is_dir($dir . "/" . $f)) {
echo "<span class=\"d-inline-flex justify-content-end "
. "align-items-center flex-wrap ml-auto\">\n";
echo "\t<a href=\"$path$f\" class=\"my-1 btn btn-outline-default btn-sm\">"
. "<span class=\"fas fa-cloud-download-alt\"></span>"
. " Main</a>\n";
foreach ($MIRRORBASE as $mirror) {
$name = $mirror["name"];
$base = $mirror["base"];
echo "\t<a href=\"$base$path$f\""
. " class=\"ml-2 my-1 btn btn-outline-default btn-sm\">"
. "<span class=\"fas fa-cloud-download-alt\"></span>"
. " $name</a>\n";
}
echo "</span>";
}
echo "</li>\n\n";
}
}
?>
</ul>
</div>
</div>
</div>
</div>
</div> </div>

Loading…
Cancel
Save