Added feature to hide files and cleaned the PHP a little.
This commit is contained in:
parent
a8053841a4
commit
77de8e47f2
3 changed files with 46 additions and 25 deletions
|
@ -1,8 +1,22 @@
|
|||
<?php
|
||||
function completeScanDir($dir) {
|
||||
if (file_exists("$dir/.hide.txt")) {
|
||||
$hideFile = fopen("$dir/.hide.txt", "r");
|
||||
$filesToHide = fread($hideFile, filesize("$dir/.hide.txt"));
|
||||
fclose($hideFile);
|
||||
$filesToHide = explode("\n", $filesToHide);
|
||||
}
|
||||
|
||||
$result = [];
|
||||
foreach(scandir($dir) as $filename) {
|
||||
if ($filename[0] === '.') continue;
|
||||
if ($filename[0] == '.'){
|
||||
continue;
|
||||
}
|
||||
|
||||
if (isset($filesToHide)) {
|
||||
if (in_array($filename, $filesToHide)) continue;
|
||||
}
|
||||
|
||||
$filePath = $dir . '/' . $filename;
|
||||
|
||||
if (is_dir($filePath)) {
|
||||
|
@ -25,6 +39,10 @@
|
|||
.submenu_$useableName:hover {
|
||||
display: block;
|
||||
background-color: $randomColor, 0.2);
|
||||
}
|
||||
|
||||
.label_$useableName {
|
||||
background-color: $randomColor, 0.2);
|
||||
}\n\n";
|
||||
|
||||
generateCSSCode($filename);
|
||||
|
@ -34,36 +52,39 @@
|
|||
|
||||
function generateSubmenusHTML($directory, $indentation) {
|
||||
foreach ($directory as $path => $filename) {
|
||||
$useableName = str_replace("/", "_", $path); // CSS classes cant contain slashes
|
||||
if ($filename !== "README.txt") {
|
||||
$useableName = str_replace("/", "_", $path); // CSS classes cant contain slashes
|
||||
|
||||
if (is_array($filename)) {
|
||||
$folderName = end(explode("/", $path));
|
||||
echo " $indentation<label for='input_$useableName' class='inout hcb-label label_$useableName'>$folderName</label>
|
||||
$indentation<input type='checkbox' id='input_$useableName' class='hacked-checkbox'>
|
||||
$indentation<div class='glass inset submenu submenu_$useableName' id='submenu_$useableName'>\n";
|
||||
if (is_array($filename)) {
|
||||
$pathFragments = explode("/", $path); // i wanted to just use end(explode("/", $path)) but PHP doesnt like it.
|
||||
$folderName = end($pathFragments);
|
||||
echo " $indentation<label for='input_$useableName' class='inout hcb-label label_$useableName'>$folderName</label>
|
||||
$indentation<input type='checkbox' id='input_$useableName' class='hacked-checkbox'>
|
||||
$indentation<div class='glass inset submenu submenu_$useableName' id='submenu_$useableName'>\n";
|
||||
|
||||
if (file_exists("$path/README.txt")) { // show description text if there is a README.txt
|
||||
echo " $indentation<p class='tiny-text'>Beschreibung:</p>\n";
|
||||
if (file_exists("$path/README.txt")) { // show description text if there is a README.txt
|
||||
echo " $indentation<p class='tiny-text'>Beschreibung:</p>\n";
|
||||
|
||||
$readmeFile = fopen("$path/README.txt", "r");
|
||||
$readmeContent = fread($readmeFile, filesize("$path/README.txt"));
|
||||
echo " $indentation<pre class='heading-text fat-text'>
|
||||
$readmeFile = fopen("$path/README.txt", "r");
|
||||
$readmeContent = fread($readmeFile, filesize("$path/README.txt"));
|
||||
echo " $indentation<pre class='heading-text fat-text'>
|
||||
$readmeContent
|
||||
$indentation</pre>
|
||||
$indentation<hr>\n";
|
||||
fclose($readmeFile);
|
||||
}
|
||||
$indentation</pre>
|
||||
$indentation<hr>\n";
|
||||
fclose($readmeFile);
|
||||
}
|
||||
|
||||
generateSubmenusHTML($filename, "$indentation ");
|
||||
echo " $indentation</div>
|
||||
$indentation<br>\n";
|
||||
generateSubmenusHTML($filename, "$indentation ");
|
||||
echo " $indentation</div>
|
||||
$indentation<br>\n";
|
||||
|
||||
} else {
|
||||
if ($filename !== "README.txt") {
|
||||
echo " $indentation<a href='$path' class='file-link'>$filename</a>\n";
|
||||
} else {
|
||||
if ($filename !== "README.txt") {
|
||||
echo " $indentation<a href='$path' class='file-link'>$filename</a>\n";
|
||||
}
|
||||
}
|
||||
echo " $indentation<br>\n";
|
||||
}
|
||||
echo " $indentation<br>\n";
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -131,7 +131,7 @@ echo " </style>";
|
|||
Evtl. könnt ihr hier etwas brauchbares finden.
|
||||
</p>
|
||||
<div class="glass inset">
|
||||
<br>
|
||||
<br>
|
||||
|
||||
<?= generateSubmenusHTML(completeScanDir("files"), " ") ?>
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ label {
|
|||
}
|
||||
|
||||
hr {
|
||||
margin: 0px 16px 0px 0px;
|
||||
margin: 0px 16px 16px 0px;
|
||||
border: 1px solid rgba(255, 255, 255, 0.5);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue