better shutdown and voice-vlan detection
This commit is contained in:
parent
26dc6b3b28
commit
25f0f7cd91
23
style.css
23
style.css
@ -12,7 +12,7 @@ main > table {
|
|||||||
margin: auto;
|
margin: auto;
|
||||||
}
|
}
|
||||||
td {
|
td {
|
||||||
text-align: left
|
text-align: left;
|
||||||
}
|
}
|
||||||
.member {
|
.member {
|
||||||
border-spacing: 0;
|
border-spacing: 0;
|
||||||
@ -42,14 +42,25 @@ td {
|
|||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
border: 4px solid !important;
|
border: 4px solid !important;
|
||||||
border-image-slice: 1 !important;
|
border-image-slice: 1 !important;
|
||||||
border-image-source: linear-gradient(127deg, red, orange, yellow, green, blue, violet) !important;
|
border-image-source: linear-gradient(
|
||||||
|
127deg,
|
||||||
|
red,
|
||||||
|
orange,
|
||||||
|
yellow,
|
||||||
|
green,
|
||||||
|
blue,
|
||||||
|
violet
|
||||||
|
) !important;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
.hybrid {
|
.hybrid {
|
||||||
background-image: linear-gradient(135deg, hsl(calc(var(--k)*var(--tagged)) 100% 60%) 50%, hsl(calc(var(--k)*var(--untagged)) 100% 60%) 50%);
|
background-image: linear-gradient(
|
||||||
|
135deg,
|
||||||
|
hsl(calc(var(--k) * var(--tagged)) 100% 60%) 50%,
|
||||||
|
hsl(calc(var(--k) * var(--untagged)) 100% 60%) 50%
|
||||||
|
);
|
||||||
}
|
}
|
||||||
.shutdown {
|
.shutdown:not([class*="loopback-detection action shutdown"]) {
|
||||||
background-color: lightgray !important;
|
background-color: lightgray !important;
|
||||||
background-image: none !important;
|
background-image: none !important;
|
||||||
color: gray !important;
|
color: gray !important;
|
||||||
@ -61,7 +72,7 @@ td {
|
|||||||
top: 0;
|
top: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
}
|
}
|
||||||
.voice-vlan::after {
|
.voice_vlan::after {
|
||||||
content: "📞";
|
content: "📞";
|
||||||
font-size: 0.7em;
|
font-size: 0.7em;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
65
vlans.php
65
vlans.php
@ -11,28 +11,30 @@ $conf = file_get_contents($path);
|
|||||||
preg_match("/ sysname ([\w-]+)/", $conf, $sysname);
|
preg_match("/ sysname ([\w-]+)/", $conf, $sysname);
|
||||||
preg_match("/ip address ([\d.]+)/", $conf, $address);
|
preg_match("/ip address ([\d.]+)/", $conf, $address);
|
||||||
preg_match_all("/(?<=\n)vlan (?P<pvid>\d+)[\r\n]+(?: name (?P<name>.+)[\r\n]+| description (?P<description>.+)[\r\n]+| .*[\r\n]+)*/", $conf, $vlans, PREG_SET_ORDER);
|
preg_match_all("/(?<=\n)vlan (?P<pvid>\d+)[\r\n]+(?: name (?P<name>.+)[\r\n]+| description (?P<description>.+)[\r\n]+| .*[\r\n]+)*/", $conf, $vlans, PREG_SET_ORDER);
|
||||||
preg_match_all("/(?<=\n)interface [\w-]+(?P<member>\d+)\/0\/(?P<port>\d+)[\r\n]+(?: port hybrid (?:pvid )?vlan (?:(?P<tagged>\d+) tagged|(?P<untagged>\d+)(?: \d+)* untagged)[\r\n]+| port (?:access |trunk |hybrid |pvid |vlan )*(?P<pvid>\d+)[\r\n]+| .*[\r\n]+)*(?<!#)/", $conf, $interfaces, PREG_SET_ORDER);
|
preg_match_all("/(?<=\n)interface [\w-]+(?P<member>\d+)\/0\/(?P<port>\d+)[\r\n]+(?: port hybrid (?:pvid )?vlan (?:(?P<tagged>\d+) tagged|(?P<untagged>\d+)(?: \d+)* untagged)[\r\n]+| port (?:access |trunk |hybrid |pvid |vlan )*(?P<pvid>\d+)[\r\n]+| voice-vlan (?P<voice_vlan>\d+) enable[\r\n]+| .*[\r\n]+)*(?<!#)/", $conf, $interfaces, PREG_SET_ORDER);
|
||||||
$stack = array();
|
$stack = array();
|
||||||
foreach ($interfaces as $interface) {
|
foreach ($interfaces as $interface) {
|
||||||
if (!isset($stack[$interface["member"]])) $stack[$interface["member"]] = array();
|
if (!isset($stack[$interface["member"]])) $stack[$interface["member"]] = array();
|
||||||
$interface["style"] = "";
|
$interface["style"] = "";
|
||||||
if (!empty($interface["pvid"])) $interface["style"] .= "--pvid: ${interface["pvid"]}; ";
|
if (!empty($interface["pvid"])) $interface["style"] .= "--pvid: {$interface["pvid"]}; ";
|
||||||
if (!empty($interface["tagged"])) $interface["style"] .= "--tagged: ${interface["tagged"]}; ";
|
if (!empty($interface["tagged"])) $interface["style"] .= "--tagged: {$interface["tagged"]}; ";
|
||||||
if (!empty($interface["untagged"])) $interface["style"] .= "--untagged: ${interface["untagged"]}; ";
|
if (!empty($interface["untagged"])) $interface["style"] .= "--untagged: {$interface["untagged"]}; ";
|
||||||
$stack[$interface["member"]][$interface["port"]] = $interface;
|
$stack[$interface["member"]][$interface["port"]] = $interface;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* echo ("<!--");
|
echo ("<!--");
|
||||||
var_dump($stack);
|
var_dump($interfaces);
|
||||||
echo ("-->"); */
|
echo ("-->");
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<!DOCTYPE HTML>
|
<!DOCTYPE HTML>
|
||||||
<html lang='fr'>
|
<html lang='fr'>
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<title><?= $sysname[1] ?? "Switch sans nom" ?> - Tableau des VLANs</title>
|
<title><?= $sysname[1] ?? "Switch sans nom" ?> - Tableau des VLANs</title>
|
||||||
<link href="style.css" rel="stylesheet" />
|
<link href="style.css" rel="stylesheet" />
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<header>
|
<header>
|
||||||
<h1>
|
<h1>
|
||||||
@ -42,12 +44,15 @@ echo ("-->"); */
|
|||||||
</header>
|
</header>
|
||||||
<main>
|
<main>
|
||||||
<table>
|
<table>
|
||||||
<caption><h2>Interfaces</h2></caption>
|
<caption>
|
||||||
|
<h2>Interfaces</h2>
|
||||||
|
</caption>
|
||||||
<tbody>
|
<tbody>
|
||||||
<?php
|
<?php
|
||||||
function display_interface($interface, $odd) {
|
function display_interface($interface, $odd)
|
||||||
|
{
|
||||||
if ($interface["port"] % 2 == $odd) {
|
if ($interface["port"] % 2 == $odd) {
|
||||||
echo "<td class='${interface[0]}' title='${interface[0]}' style='${interface["style"]}'>${interface["port"]}</td>\n";
|
echo "<td class='{$interface[0]}" . (isset($interface["voice_vlan"]) ? " voice_vlan" : "") . "' title='{$interface[0]}' style='{$interface["style"]}'>{$interface["port"]}</td>\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,23 +67,46 @@ foreach ($stack as $member => $interfaces) {
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<table class='legend'>
|
<table class='legend'>
|
||||||
<caption><h2>Légende</h2></caption>
|
<caption>
|
||||||
<thead><tr><th>PVID</th><th>Nom</th><th>Description</th></tr></thead>
|
<h2>Légende</h2>
|
||||||
|
</caption>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>PVID</th>
|
||||||
|
<th>Nom</th>
|
||||||
|
<th>Description</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<?php
|
<?php
|
||||||
foreach ($vlans as $vlan) {
|
foreach ($vlans as $vlan) {
|
||||||
if (isset($vlan["pvid"]) and $vlan["pvid"] != 1) {
|
if (isset($vlan["pvid"]) and $vlan["pvid"] != 1) {
|
||||||
$name = $vlan["name"] ?? "";
|
$name = $vlan["name"] ?? "";
|
||||||
$description = $vlan["description"] ?? "";
|
$description = $vlan["description"] ?? "";
|
||||||
echo "<tr title='${vlan[0]}'><td class='interface vlan' style='--pvid: ${vlan["pvid"]}'>${vlan["pvid"]}</td><td>$name</td><td>$description</td></tr>";
|
echo "<tr title='{$vlan[0]}'><td class='interface vlan' style='--pvid: {$vlan["pvid"]}'>{$vlan["pvid"]}</td><td>$name</td><td>$description</td></tr>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
<tr><td class='interface trunk'></td><td colspan='2'>Trunk</td></tr>
|
<tr>
|
||||||
<tr><td class='interface hybrid' style='--tagged:60; --untagged:0'></td><td colspan='2'>Hybride (tagged/untagged)</td></tr>
|
<td class='interface trunk'></td>
|
||||||
<tr><td class='interface poe'></td><td colspan='2'>Power on Ethernet</td></tr>
|
<td colspan='2'>Trunk</td>
|
||||||
<tr><td class='interface voice-vlan'></td><td colspan='2'>Voice-VLAN</td></tr>
|
</tr>
|
||||||
<tr><td class='interface shutdown'></td><td colspan='2'>Interface désactivée</td></tr>
|
<tr>
|
||||||
|
<td class='interface hybrid' style='--tagged:60; --untagged:0'></td>
|
||||||
|
<td colspan='2'>Hybride (tagged/untagged)</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class='interface poe'></td>
|
||||||
|
<td colspan='2'>Power on Ethernet</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class='interface voice_vlan'></td>
|
||||||
|
<td colspan='2'>ToIP (voice-vlan)</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class='interface shutdown'></td>
|
||||||
|
<td colspan='2'>Interface désactivée</td>
|
||||||
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</main>
|
</main>
|
||||||
@ -88,4 +116,5 @@ foreach ($vlans as $vlan) {
|
|||||||
oninput="document.documentElement.style.setProperty('--k', this.value);">
|
oninput="document.documentElement.style.setProperty('--k', this.value);">
|
||||||
</footer>
|
</footer>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
Loading…
x
Reference in New Issue
Block a user