change url
This commit is contained in:
parent
5a63ac033e
commit
d9415c7fa6
4
config.php
Normal file
4
config.php
Normal file
@ -0,0 +1,4 @@
|
||||
<?php
|
||||
|
||||
$basedir = __DIR__ . "/confs";
|
||||
$locale = "fr_FR.UTF-8";
|
72
index.php
72
index.php
@ -1,3 +1,14 @@
|
||||
<?php
|
||||
|
||||
require_once "config.php";
|
||||
|
||||
setlocale(LC_CTYPE, $locale);
|
||||
|
||||
if ($_SERVER["QUERY_STRING"] != "") {
|
||||
include "show.php";
|
||||
exit;
|
||||
}
|
||||
?>
|
||||
<!DOCTYPE HTML>
|
||||
<html lang='fr'>
|
||||
|
||||
@ -11,42 +22,39 @@
|
||||
<h1>Schémas des VLANs</h1>
|
||||
<div class="file-list">
|
||||
<ul>
|
||||
<?php
|
||||
$basedir = __DIR__ . "/confs";
|
||||
<?php
|
||||
function recursive_ls($path) {
|
||||
global $basedir;
|
||||
|
||||
function recursive_ls($path)
|
||||
{
|
||||
global $basedir;
|
||||
if (substr(basename($path), 0, 1) == '.') {
|
||||
return "";
|
||||
}
|
||||
|
||||
if (substr(basename($path), 0, 1) == '.') {
|
||||
return "";
|
||||
}
|
||||
|
||||
if (is_dir($path)) {
|
||||
$str = "";
|
||||
foreach (scandir($path) as $filename) {
|
||||
$str .= recursive_ls("$path/$filename");
|
||||
}
|
||||
if ($str == "") {
|
||||
return "";
|
||||
} else {
|
||||
if ($path == $basedir) {
|
||||
return "<ul>\n$str\n</ul>\n";
|
||||
} else {
|
||||
return "<li>\n<details>\n<summary>" . basename($path) . "</summary>\n<ul>\n" . $str . "</ul>\n</details>\n</li>\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (substr($path, -4) == ".cfg") {
|
||||
return "<li><a href='show.php?switch=" . str_replace("$basedir/", "", $path) . "' target='_blank'>" . basename($path) . "</a></li>\n";
|
||||
}
|
||||
|
||||
return "";
|
||||
if (is_dir($path)) {
|
||||
$str = "";
|
||||
foreach (scandir($path) as $filename) {
|
||||
$str .= recursive_ls("$path/$filename");
|
||||
}
|
||||
if ($str == "") {
|
||||
return "";
|
||||
} else {
|
||||
if ($path == $basedir) {
|
||||
return "<ul>\n$str\n</ul>\n";
|
||||
} else {
|
||||
return "<li>\n<details>\n<summary>" . basename($path) . "</summary>\n<ul>\n" . $str . "</ul>\n</details>\n</li>\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
echo recursive_ls($basedir);
|
||||
?>
|
||||
if (substr($path, -4) == ".cfg") {
|
||||
return "<li><a href='?" . str_replace("$basedir/", "", $path) . "' target='_blank'>" . basename($path) . "</a></li>\n";
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
echo recursive_ls($basedir);
|
||||
?>
|
||||
</ul>
|
||||
</div>
|
||||
</body>
|
||||
|
9
show.php
9
show.php
@ -1,10 +1,9 @@
|
||||
<?php
|
||||
setlocale(LC_CTYPE, "fr_FR.UTF-8");
|
||||
|
||||
$basedir = __DIR__ . "/confs/";
|
||||
$path = escapeshellcmd(realpath($basedir . $_GET["switch"]));
|
||||
if (substr($path, -4) != ".cfg") {
|
||||
http_response_code(404);
|
||||
$path = realpath($basedir . DIRECTORY_SEPARATOR . ltrim(urldecode($_SERVER["QUERY_STRING"]), '/'));
|
||||
|
||||
if (strpos($path, $basedir) !== 0 || substr($path, -4) != ".cfg") {
|
||||
http_response_code(403);
|
||||
die();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user