From 3b3c5e21a6010a8307426b4536509294534bbfdb Mon Sep 17 00:00:00 2001 From: Denis Ovsienko Date: Sat, 25 Dec 2010 12:53:04 +0000 Subject: [PATCH] r4068 mkA(): new helper function render8021QReport(): initial implementation --- inc/functions.php | 23 +++++++++++++++++ inc/interface.php | 64 ++++++++++++++++++++++++++++++++++++++++++++++ inc/navigation.php | 2 ++ 3 files changed, 89 insertions(+) diff --git a/inc/functions.php b/inc/functions.php index 6fa9fb46..7d20d32b 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -2126,6 +2126,29 @@ function ip_long2quad ($quad) return long2ip($quad); } +function mkA ($text, $nextpage, $bypass = NULL, $nexttab = NULL) +{ + global $page, $tab; + if (!mb_strlen ($text)) + throw new InvalidArgException ('text', $text); + if (!array_key_exists ($nextpage, $page)) + throw new InvalidArgException ('nextpage', $nextpage); + $args = array ('page' => $nextpage); + if ($nexttab !== NULL) + { + if (!array_key_exists ($nexttab, $tab[$nextpage])) + throw new InvalidArgException ('nexttab', $nexttab); + $args['tab'] = $nexttab; + } + if (array_key_exists ('bypass', $page[$nextpage])) + { + if ($bypass === NULL) + throw new InvalidArgException ('bypass', $bypass); + $args[$page[$nextpage]['bypass']] = $bypass; + } + return '' . $text . ''; +} + function makeHref($params = array()) { $ret = 'index.php?'; diff --git a/inc/interface.php b/inc/interface.php index b5e360d1..1fda7946 100644 --- a/inc/interface.php +++ b/inc/interface.php @@ -4602,6 +4602,70 @@ function renderPortsReport () renderReports ($tmp); } +function render8021QReport () +{ + if (!count ($domains = getVLANDomainOptions())) + { + echo '

(no VLAN configuration exists)

'; + return; + } + $vlanstats = array(); + for ($i = VLAN_MIN_ID; $i <= VLAN_MAX_ID; $i++) + $vlanstats[$i] = array(); + $header = ' '; + foreach ($domains as $domain_id => $domain_name) + { + foreach (getDomainVLANs ($domain_id) as $vlan_id => $vlan_info) + $vlanstats[$vlan_id][$domain_id] = $vlan_info; + $header .= '' . mkA ($domain_name, 'vlandomain', $domain_id) . ''; + } + $header .= ''; + $output = $available = array(); + for ($i = VLAN_MIN_ID; $i <= VLAN_MAX_ID; $i++) + if (!count ($vlanstats[$i])) + $available[] = $i; + else + $output[$i] = FALSE; + foreach (listToRanges ($available) as $span) + { + if ($span['to'] - $span['from'] < 4) + for ($i = $span['from']; $i <= $span['to']; $i++) + $output[$i] = FALSE; + else + { + $output[$span['from']] = TRUE; + $output[$span['to']] = FALSE; + } + } + ksort ($output, SORT_NUMERIC); + $header_delay = 0; + startPortlet ('VLAN existence per domain'); + echo ''; + foreach ($output as $vlan_id => $tbc) + { + if (--$header_delay <= 0) + { + echo $header; + $header_delay = 50; + } + echo ''; + foreach (array_keys ($domains) as $domain_id) + { + echo ''; + } + echo ''; + if ($tbc) + echo ''; + } + echo '
' . $vlan_id . ''; + if (array_key_exists ($domain_id, $vlanstats[$vlan_id])) + echo mkA ('∃', 'vlan', "${domain_id}-${vlan_id}"); + else + echo ' '; + echo '
... 
'; + finishPortlet(); +} + function renderReports ($what) { if (!count ($what)) diff --git a/inc/navigation.php b/inc/navigation.php index e4a2154f..7afd9a8c 100644 --- a/inc/navigation.php +++ b/inc/navigation.php @@ -507,6 +507,7 @@ $tab['reports']['rackcode'] = 'RackCode'; $tab['reports']['ipv4'] = 'IPv4'; $tab['reports']['ipv6'] = 'IPv6'; $tab['reports']['ports'] = 'Ports'; +$tab['reports']['8021q'] = '802.1Q'; $tab['reports']['local'] = getConfigVar ('enterprise'); $trigger['reports']['local'] = 'trigger_localreports'; $tabhandler['reports']['default'] = 'renderSystemReports'; @@ -514,6 +515,7 @@ $tabhandler['reports']['rackcode'] = 'renderRackCodeReports'; $tabhandler['reports']['ipv4'] = 'renderIPv4Reports'; $tabhandler['reports']['ipv6'] = 'renderIPv6Reports'; $tabhandler['reports']['ports'] = 'renderPortsReport'; +$tabhandler['reports']['8021q'] = 'render8021QReport'; $tabhandler['reports']['local'] = 'renderLocalReports'; $page['files']['title'] = 'Files'; -- 2.17.1