all interface config in class
This commit is contained in:
parent
35d492c0de
commit
c1eccd205c
18
vlans.php
18
vlans.php
@ -11,17 +11,21 @@ $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[\r\n]+| port hybrid vlan (?P<untagged>\d+)(?: \d+)* untagged[\r\n]+| port (?P<linktype>(?:access |trunk |hybrid |pvid |vlan )*)(?P<pvid>\d+)[\r\n]+| (?P<poe>poe) enable[\r\n]+| (?P<shutdown>shutdown)[\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]+| .*[\r\n]+)*(?<!#)/", $conf, $interfaces, PREG_SET_ORDER);
|
||||||
$stack = array();
|
$stack = array();
|
||||||
foreach ($interfaces as $interface) {
|
foreach ($interfaces as $interface) {
|
||||||
if (!isset($stack[$interface["member"]])) {
|
if (!isset($stack[$interface["member"]])) $stack[$interface["member"]] = array();
|
||||||
$stack[$interface["member"]] = array();
|
$interface["style"] = "";
|
||||||
}
|
if ($interface["pvid"]) $interface["style"] .= "--pvid: ${interface["pvid"]}; ";
|
||||||
|
if ($interface["tagged"]) $interface["style"] .= "--tagged: ${interface["tagged"]}; ";
|
||||||
|
if ($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($stack);
|
||||||
echo ("-->");
|
echo ("-->"); */
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<!DOCTYPE HTML>
|
<!DOCTYPE HTML>
|
||||||
<html lang='fr'>
|
<html lang='fr'>
|
||||||
@ -43,7 +47,7 @@ echo ("-->");
|
|||||||
<?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 ${interface["shutdown"]} ${interface["linktype"]} ${interface["poe"]}' title='${interface[0]}' style='--pvid: ${interface["pvid"]}; --tagged: ${interface["tagged"]}; --untagged: ${interface["untagged"]};'>${interface["port"]}</td>\n";
|
echo "<td class='${interface[0]}' title='${interface[0]}' style='${interface["style"]}'>${interface["port"]}</td>\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user