little changes

This commit is contained in:
Adrien MALINGREY 2025-05-22 13:58:14 +02:00
parent abc3d30473
commit 0a4921646e
3 changed files with 11 additions and 11 deletions

0
custom.css Normal file
View File

View File

@ -5,7 +5,7 @@ require_once "config.php";
setlocale(LC_CTYPE, $locale); setlocale(LC_CTYPE, $locale);
if ($_SERVER["QUERY_STRING"] != "") { if ($_SERVER["QUERY_STRING"] != "") {
include "show.php"; include "switch.php";
exit; exit;
} }
?> ?>

View File

@ -20,18 +20,18 @@ if ($conf === false) {
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);
$startPattern = "(?<=\n)"; $startPattern = "(?<=[\r\n])";
$NL = "[\r\n]+"; $NL = "(?:[\r\n]+)";
$vlanPvidPattern = "vlan (?P<pvid>\d+)$NL"; $vlanPvidPattern = "vlan (?P<pvid>\d+)$NL";
$vlanNamePattern = " name (?P<name>.+)$NL"; $vlanNamePattern = "$startPattern name (?P<name>.+)$NL";
$vlanDescriptionPattern = " description (?P<description>.+)$NL"; $vlanDescriptionPattern = "$startPattern description (?P<description>.+)$NL";
$otherPattern = " .*$NL"; $otherPattern = "$startPattern .*$NL";
$endPattern = "(?<!#)"; $endPattern = "(?<!#)";
preg_match_all("/$startPattern$vlanPvidPattern(?:$vlanNamePattern|$vlanDescriptionPattern|$otherPattern)*$endPattern/", $conf, $vlans, PREG_SET_ORDER); preg_match_all("/$startPattern$vlanPvidPattern(?:$vlanNamePattern|$vlanDescriptionPattern|$otherPattern)*$endPattern/", $conf, $vlans, PREG_SET_ORDER);
$interfaceAddressPattern = "interface [\w-]+(?P<member>\d+)\/0\/(?P<port>\d+)$NL"; $interfaceAddressPattern = "interface [\w-]+(?P<member>\d+)\/0\/(?P<port>\d+)$NL";
$pvidPattern = " port (?:access|trunk pvid|hybrid pvid) vlan (?P<pvid>\d+)$NL"; $pvidPattern = "$startPattern port (?:access|trunk pvid|hybrid pvid) vlan (?P<pvid>\d+)$NL";
$portHybridPattern = " port hybrid vlan (?:(?P<tagged>\d+)(?: (?:to|\d+))* tagged|(?P<untagged>\d+)(?: \d+)* untagged)$NL"; $portHybridPattern = "$startPattern port hybrid vlan (?:(?P<tagged>\d+)(?: (?:to|\d+))* tagged|(?P<untagged>\d+)(?: \d+)* untagged)$NL";
$voiceVlanPattern = " voice-vlan (?P<voice_vlan>\d+) enable$NL"; $voiceVlanPattern = "$startPattern voice-vlan (?P<voice_vlan>\d+) enable$NL";
preg_match_all("/$startPattern$interfaceAddressPattern(?:$pvidPattern|$portHybridPattern|$voiceVlanPattern|$otherPattern)*$endPattern/", $conf, $interfaces, PREG_SET_ORDER); preg_match_all("/$startPattern$interfaceAddressPattern(?:$pvidPattern|$portHybridPattern|$voiceVlanPattern|$otherPattern)*$endPattern/", $conf, $interfaces, PREG_SET_ORDER);
$stack = array(); $stack = array();
@ -50,8 +50,9 @@ foreach ($interfaces as $interface) {
<head> <head>
<title><?= $sysname[1] ?? "Switch sans nom" ?> - Schéma des VLANs</title> <title><?= $sysname[1] ?? "Switch sans nom" ?> - Schéma des VLANs</title>
<link href="style.css" rel="stylesheet" />
<link rel="icon" type="image/svg" href="favicon.svg"> <link rel="icon" type="image/svg" href="favicon.svg">
<link href="style.css" rel="stylesheet" />
<link href="custom.css" rel="stylesheet" />
<style id="customColors"></style> <style id="customColors"></style>
</head> </head>
@ -146,7 +147,6 @@ foreach ($interfaces as $interface) {
customColors.sheet.insertRule(`[style*="--pvid: ${pvid};"] { --pvid-color: ${color} }`) customColors.sheet.insertRule(`[style*="--pvid: ${pvid};"] { --pvid-color: ${color} }`)
customColors.sheet.insertRule(`[style*="--tagged: ${pvid};"] { --tagged-color: ${color} }`) customColors.sheet.insertRule(`[style*="--tagged: ${pvid};"] { --tagged-color: ${color} }`)
customColors.sheet.insertRule(`[style*="--untagged: ${pvid};"] { --untagged-color: ${color} }`) customColors.sheet.insertRule(`[style*="--untagged: ${pvid};"] { --untagged-color: ${color} }`)
console.log(customColors.sheet.cssRules)
} }
</script> </script>
</body> </body>