show only dir with *.cfg
This commit is contained in:
parent
0ca0c3cb83
commit
a889a55738
23
index.php
23
index.php
@ -18,23 +18,30 @@ ul {
|
|||||||
|
|
||||||
function recursive_ls($path) {
|
function recursive_ls($path) {
|
||||||
global $basedir;
|
global $basedir;
|
||||||
echo "<ul>\n";
|
$strdir = "";
|
||||||
foreach (scandir($path) as $filename) {
|
foreach (scandir($path) as $filename) {
|
||||||
if (substr($filename, 0, 1) != '.') {
|
if (substr($filename, 0, 1) != '.') {
|
||||||
$fullpath = $path ."/". $filename;
|
$fullpath = $path ."/". $filename;
|
||||||
if (is_dir($fullpath)) {
|
if (is_dir($fullpath)) {
|
||||||
echo "<li>\n<details>\n<summary>", $filename, "</summary>\n";
|
$str = "";
|
||||||
recursive_ls($fullpath);
|
$cfgPaths = glob($fullpath . '/*.cfg');
|
||||||
echo "</details>\n</li>\n";
|
if (count($cfgPaths)) {
|
||||||
} elseif (substr($filename, -4) == ".cfg") {
|
$str .= "<ul>\n";
|
||||||
echo "<li><a href='vlans.php?switch=", str_replace($basedir.'/', "", $fullpath), "'>$filename</a></li>\n";
|
foreach ( as $conf) {
|
||||||
|
$str .= "<li><a href='vlans.php?switch=" . str_replace($basedir.'/', "", $conf) . "'>" . basename($conf) . "</a></li>\n";
|
||||||
|
}
|
||||||
|
$str .= "</ul>\n";
|
||||||
|
}
|
||||||
|
$str = recursive_ls($fullpath) . $str;
|
||||||
|
if ($str != "") $strdir .= "<li>\n<details>\n<summary>" . $filename . "</summary>\n" . $str . "</details>\n</li>\n";;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
echo "</ul>\n";
|
if ($strdir != "") $strdir = "<ul>\n" . $strdir . "</ul>\n";
|
||||||
|
return $strdir;
|
||||||
}
|
}
|
||||||
|
|
||||||
recursive_ls($basedir);
|
echo recursive_ls($basedir);
|
||||||
?>
|
?>
|
||||||
</main>
|
</main>
|
||||||
</body>
|
</body>
|
||||||
|
45
test.php
Normal file
45
test.php
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
<!DOCTYPE HTML>
|
||||||
|
<html lang='fr'>
|
||||||
|
<head>
|
||||||
|
<title>Tableau des VLANs</title>
|
||||||
|
<style>
|
||||||
|
ul {
|
||||||
|
list-style: none;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header>
|
||||||
|
<h1>Tableau des VLANs</h1>
|
||||||
|
</header>
|
||||||
|
<main>
|
||||||
|
<?php
|
||||||
|
$basedir = __DIR__ . "/confs";
|
||||||
|
|
||||||
|
function recursive_ls($path) {
|
||||||
|
global $basedir;
|
||||||
|
foreach (scandir($path) as $filename) {
|
||||||
|
if (substr($filename, 0, 1) != '.') {
|
||||||
|
$fullpath = $path ."/". $filename;
|
||||||
|
if (is_dir($fullpath)) {
|
||||||
|
$confs = $files = glob($fullpath . '/*.cfg');
|
||||||
|
if (count($confs)) {
|
||||||
|
echo "<li>\n<details>\n<summary>", str_replace($basedir.'/', "", $fullpath), "</summary>\n<ul>\n";
|
||||||
|
foreach ($confs as $conf) {
|
||||||
|
echo "<li><a href='vlans.php?switch=", str_replace($basedir.'/', "", $conf), "'>" . basename($conf) . "</a></li>\n";
|
||||||
|
}
|
||||||
|
echo "</ul>\n</details>\n</li>\n";
|
||||||
|
}
|
||||||
|
recursive_ls($fullpath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "<ul>\n";
|
||||||
|
recursive_ls($basedir);
|
||||||
|
echo "</ul>\n";
|
||||||
|
?>
|
||||||
|
</main>
|
||||||
|
</body>
|
||||||
|
</html>
|
Loading…
x
Reference in New Issue
Block a user