Added feature to hide files and cleaned the PHP a little.

This commit is contained in:
The Wobbler 2024-10-27 14:51:58 +01:00
parent a8053841a4
commit 77de8e47f2
3 changed files with 46 additions and 25 deletions

View file

@ -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,10 +52,12 @@
function generateSubmenusHTML($directory, $indentation) {
foreach ($directory as $path => $filename) {
if ($filename !== "README.txt") {
$useableName = str_replace("/", "_", $path); // CSS classes cant contain slashes
if (is_array($filename)) {
$folderName = end(explode("/", $path));
$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";
@ -66,4 +86,5 @@ $readmeContent
echo " $indentation<br>\n";
}
}
}
?>

View file

@ -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);
}