show only dir with *.cfg
This commit is contained in:
parent
0ca0c3cb83
commit
a889a55738
29
index.php
29
index.php
@ -3,9 +3,9 @@
|
||||
<head>
|
||||
<title>Tableau des VLANs</title>
|
||||
<style>
|
||||
ul {
|
||||
list-style: none;
|
||||
}
|
||||
ul {
|
||||
list-style: none;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
@ -18,23 +18,30 @@ ul {
|
||||
|
||||
function recursive_ls($path) {
|
||||
global $basedir;
|
||||
echo "<ul>\n";
|
||||
$strdir = "";
|
||||
foreach (scandir($path) as $filename) {
|
||||
if (substr($filename, 0, 1) != '.') {
|
||||
$fullpath = $path ."/". $filename;
|
||||
if (is_dir($fullpath)) {
|
||||
echo "<li>\n<details>\n<summary>", $filename, "</summary>\n";
|
||||
recursive_ls($fullpath);
|
||||
echo "</details>\n</li>\n";
|
||||
} elseif (substr($filename, -4) == ".cfg") {
|
||||
echo "<li><a href='vlans.php?switch=", str_replace($basedir.'/', "", $fullpath), "'>$filename</a></li>\n";
|
||||
$str = "";
|
||||
$cfgPaths = glob($fullpath . '/*.cfg');
|
||||
if (count($cfgPaths)) {
|
||||
$str .= "<ul>\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>
|
||||
</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