From bdc4deb4355c5a81f7bbd6fe2e35e02fe72978f8 Mon Sep 17 00:00:00 2001 From: laf Date: Mon, 1 Jun 2015 23:27:41 +0100 Subject: [PATCH 01/71] Updated to use mac address data --- html/includes/print-map.inc.php | 66 ++++++++++++++++++++++++++++++--- 1 file changed, 60 insertions(+), 6 deletions(-) diff --git a/html/includes/print-map.inc.php b/html/includes/print-map.inc.php index c8fcf1249b..6902db4b19 100644 --- a/html/includes/print-map.inc.php +++ b/html/includes/print-map.inc.php @@ -36,13 +36,66 @@ foreach (dbFetchRows("SELECT DISTINCT least(`devices`.`device_id`, `remote_devic array_push($tmp_ids,$link_devices['remote_device_id']); } -$tmp_ids = implode(',',$tmp_ids); - -$nodes = json_encode($tmp_devices); +$tmp_exp_ids = implode(',',$tmp_ids); + +$port_ids = array(); +foreach (dbFetchRows("SELECT DISTINCT LEAST(`M`.`port_id`, `P`.`port_id`) AS `remote_port_id`, GREATEST(`P`.`port_id`,`M`.`port_id`) AS `local_port_id` FROM `ipv4_mac` AS `M` LEFT JOIN `ports` AS `P` ON `M`.`mac_address` = `P`.`ifPhysAddress` WHERE `P`.`port_id` IS NOT NULL AND `M`.`port_id` IS NOT NULL", array()) as $macs) { + if (!in_array($macs['local_port_id'], $port_ids) && port_permitted($macs['local_port_id'])) { + $port_dev = dbFetchRow("SELECT * FROM `devices` WHERE `device_id`=?", array($macs['local_port_id'])); + $port_det = dbFetchRow("SELECT * FROM `ports` WHERE `port_id`=?", array($macs['local_port_id'])); + if (!in_array($port_dev['device_id'],$tmp_ids)) { + $mac_devices[] = array('id'=>$port_dev['device_id'], 'label'=>$port_dev['hostname'], 'title'=>generate_device_link($port_dev,'',array(),'','','',0),'group'=>$port_dev['location'], 'shape'=>'box'); + array_push($port_ids, $port_dev['device_id']); + $port_data = $port_det; + $from = $port_dev['device_id']; + $port = shorten_interface_type($port_det['ifName']); + $speed = $port_det['ifSpeed']/1000/1000; + if ($speed == 100) { + $width = 3; + } elseif ($speed == 1000) { + $width = 5; + } elseif ($speed == 10000) { + $width = 10; + } elseif ($speed == 40000) { + $width = 15; + } elseif ($speed == 100000) { + $width = 20; + } else { + $width = 1; + } + $link_in_used = ($port_det['ifInOctets_rate'] * 8) / $port_det['ifSpeed'] * 100; + $link_out_used = ($port_det['ifOutOctets_rate'] * 8) / $port_det['ifSpeed'] * 100; + if ($link_in_used > $link_out_used) { + $link_used = $link_in_used; + } else { + $link_used = $link_out_used; + } + $link_used = round($link_used, -1); + if ($link_used > 100) { + $link_used = 100; + } + $link_color = $config['map_legend'][$link_used]; + } + } + if (!in_array($macs['remote_port_id'], $port_ids) && port_permitted($macs['remote_port_id'])) { + $port_dev = dbFetchRow("SELECT * FROM `devices` WHERE `device_id`=?", array($macs['remote_port_id'])); + $port_det = dbFetchRow("SELECT * FROM `ports` WHERE `port_id`=?", array($macs['remote_port_id'])); + if (!in_array($port_dev['device_id'],$tmp_ids)) { + $mac_devices[] = array('id'=>$port_dev['device_id'], 'label'=>$port_dev['hostname'], 'title'=>generate_device_link($port_dev,'',array(),'','','',0),'group'=>$port_dev['location'], 'shape'=>'box'); + array_push($port_ids, $port_dev['device_id']); + $to = $port_dev['device_id']; + $port .= ' > ' . shorten_interface_type($port_det['ifName']); + } + } + $tmp_links[] = array('from'=>$from,'to'=>$to,'label'=>$port,'title'=>generate_port_link($port_data, "",'',0,1),'width'=>$width,'color'=>$link_color); +} + +$node_devices = array_merge($tmp_devices,$mac_devices); +$nodes = json_encode($node_devices); if (is_array($tmp_devices[0])) { $tmp_links = array(); - foreach (dbFetchRows("SELECT local_device_id, remote_device_id, `remote_hostname`,`ports`.*, `remote_port` FROM `links` LEFT JOIN `ports` ON `local_port_id`=`ports`.`port_id` LEFT JOIN `devices` ON `ports`.`device_id`=`devices`.`device_id` WHERE (`local_device_id` IN ($tmp_ids) AND `remote_device_id` IN ($tmp_ids))") as $link_devices) { + foreach (dbFetchRows("SELECT local_device_id, remote_device_id, `remote_hostname`,`ports`.*, `remote_port` FROM `links` LEFT JOIN `ports` ON `local_port_id`=`ports`.`port_id` LEFT JOIN `devices` ON `ports`.`device_id`=`devices`.`device_id` WHERE (`local_device_id` IN ($tmp_exp_ids) AND `remote_device_id` IN ($tmp_exp_ids))") as $link_devices) { foreach ($tmp_devices as $k=>$v) { if ($v['id'] == $link_devices['local_device_id']) { $from = $v['id']; @@ -85,6 +138,8 @@ if (is_array($tmp_devices[0])) { } $edges = json_encode($tmp_links); +} + ?> @@ -147,7 +202,6 @@ network.redraw(); From 988cb3b2407ed533d8f30f890aafb256e6da1994 Mon Sep 17 00:00:00 2001 From: Neil Lathwood Date: Tue, 2 Jun 2015 00:03:06 +0100 Subject: [PATCH 02/71] Last update to get map working for mac addresses --- html/includes/print-map.inc.php | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/html/includes/print-map.inc.php b/html/includes/print-map.inc.php index 6902db4b19..fb1d16f700 100644 --- a/html/includes/print-map.inc.php +++ b/html/includes/print-map.inc.php @@ -16,6 +16,8 @@ $tmp_devices = array(); if (!empty($device['hostname'])) { $sql = ' WHERE `devices`.`hostname`=?'; $sql_array = array($device['hostname']); + $mac_sql = ' AND `D`.`hostname` = ?'; + $mac_array = array($device['hostname']); } else { $sql = ' WHERE 1'; } @@ -39,13 +41,15 @@ foreach (dbFetchRows("SELECT DISTINCT least(`devices`.`device_id`, `remote_devic $tmp_exp_ids = implode(',',$tmp_ids); $port_ids = array(); -foreach (dbFetchRows("SELECT DISTINCT LEAST(`M`.`port_id`, `P`.`port_id`) AS `remote_port_id`, GREATEST(`P`.`port_id`,`M`.`port_id`) AS `local_port_id` FROM `ipv4_mac` AS `M` LEFT JOIN `ports` AS `P` ON `M`.`mac_address` = `P`.`ifPhysAddress` WHERE `P`.`port_id` IS NOT NULL AND `M`.`port_id` IS NOT NULL", array()) as $macs) { +$port_devices = array(); +foreach (dbFetchRows("SELECT DISTINCT LEAST(`M`.`port_id`, `P`.`port_id`) AS `remote_port_id`, GREATEST(`P`.`port_id`,`M`.`port_id`) AS `local_port_id` FROM `ipv4_mac` AS `M` LEFT JOIN `ports` AS `P` ON `M`.`mac_address` = `P`.`ifPhysAddress` LEFT JOIN `devices` AS `D` ON `P`.`device_id`=`D`.`device_id` WHERE `P`.`port_id` IS NOT NULL AND `M`.`port_id` IS NOT NULL $mac_sql", $mac_array) as $macs) { if (!in_array($macs['local_port_id'], $port_ids) && port_permitted($macs['local_port_id'])) { - $port_dev = dbFetchRow("SELECT * FROM `devices` WHERE `device_id`=?", array($macs['local_port_id'])); $port_det = dbFetchRow("SELECT * FROM `ports` WHERE `port_id`=?", array($macs['local_port_id'])); - if (!in_array($port_dev['device_id'],$tmp_ids)) { + $port_dev = dbFetchRow("SELECT * FROM `devices` WHERE `device_id`=?", array($port_det['device_id'])); + if (!in_array($port_dev['device_id'],$tmp_ids) && !in_array($port_dev['device_id'],$port_devices)) { $mac_devices[] = array('id'=>$port_dev['device_id'], 'label'=>$port_dev['hostname'], 'title'=>generate_device_link($port_dev,'',array(),'','','',0),'group'=>$port_dev['location'], 'shape'=>'box'); - array_push($port_ids, $port_dev['device_id']); + array_push($port_ids, $port_det['port_id']); + array_push($port_devices, $port_dev['device_id']); $port_data = $port_det; $from = $port_dev['device_id']; $port = shorten_interface_type($port_det['ifName']); @@ -78,11 +82,12 @@ foreach (dbFetchRows("SELECT DISTINCT LEAST(`M`.`port_id`, `P`.`port_id`) AS `re } } if (!in_array($macs['remote_port_id'], $port_ids) && port_permitted($macs['remote_port_id'])) { - $port_dev = dbFetchRow("SELECT * FROM `devices` WHERE `device_id`=?", array($macs['remote_port_id'])); $port_det = dbFetchRow("SELECT * FROM `ports` WHERE `port_id`=?", array($macs['remote_port_id'])); - if (!in_array($port_dev['device_id'],$tmp_ids)) { + $port_dev = dbFetchRow("SELECT * FROM `devices` WHERE `device_id`=?", array($port_det['device_id'])); + if (!in_array($port_dev['device_id'],$tmp_ids) && !in_array($port_dev['device_id'],$port_devices)) { $mac_devices[] = array('id'=>$port_dev['device_id'], 'label'=>$port_dev['hostname'], 'title'=>generate_device_link($port_dev,'',array(),'','','',0),'group'=>$port_dev['location'], 'shape'=>'box'); - array_push($port_ids, $port_dev['device_id']); + array_push($port_ids, $port_det['port_id']); + array_push($port_devices, $port_dev['device_id']); $to = $port_dev['device_id']; $port .= ' > ' . shorten_interface_type($port_det['ifName']); } @@ -94,7 +99,6 @@ $node_devices = array_merge($tmp_devices,$mac_devices); $nodes = json_encode($node_devices); if (is_array($tmp_devices[0])) { - $tmp_links = array(); foreach (dbFetchRows("SELECT local_device_id, remote_device_id, `remote_hostname`,`ports`.*, `remote_port` FROM `links` LEFT JOIN `ports` ON `local_port_id`=`ports`.`port_id` LEFT JOIN `devices` ON `ports`.`device_id`=`devices`.`device_id` WHERE (`local_device_id` IN ($tmp_exp_ids) AND `remote_device_id` IN ($tmp_exp_ids))") as $link_devices) { foreach ($tmp_devices as $k=>$v) { if ($v['id'] == $link_devices['local_device_id']) { @@ -136,10 +140,9 @@ if (is_array($tmp_devices[0])) { $tmp_links[] = array('from'=>$from,'to'=>$to,'label'=>$port,'title'=>generate_port_link($port_data, "",'',0,1),'width'=>$width,'color'=>$link_color); } - - $edges = json_encode($tmp_links); } +$edges = json_encode($tmp_links); ?> From f0395e453eb4cfcabc431a9a4005d2e47a0cb9cc Mon Sep 17 00:00:00 2001 From: laf Date: Tue, 2 Jun 2015 00:37:34 +0100 Subject: [PATCH 03/71] Final final updates to get better map support --- html/includes/print-map.inc.php | 10 +++++++++- html/includes/print-menubar.php | 8 -------- html/pages/device.inc.php | 4 ---- 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/html/includes/print-map.inc.php b/html/includes/print-map.inc.php index fb1d16f700..bfadc788d2 100644 --- a/html/includes/print-map.inc.php +++ b/html/includes/print-map.inc.php @@ -42,7 +42,7 @@ $tmp_exp_ids = implode(',',$tmp_ids); $port_ids = array(); $port_devices = array(); -foreach (dbFetchRows("SELECT DISTINCT LEAST(`M`.`port_id`, `P`.`port_id`) AS `remote_port_id`, GREATEST(`P`.`port_id`,`M`.`port_id`) AS `local_port_id` FROM `ipv4_mac` AS `M` LEFT JOIN `ports` AS `P` ON `M`.`mac_address` = `P`.`ifPhysAddress` LEFT JOIN `devices` AS `D` ON `P`.`device_id`=`D`.`device_id` WHERE `P`.`port_id` IS NOT NULL AND `M`.`port_id` IS NOT NULL $mac_sql", $mac_array) as $macs) { +foreach (dbFetchRows("SELECT DISTINCT LEAST(`M`.`port_id`, `P`.`port_id`) AS `remote_port_id`, GREATEST(`P`.`port_id`,`M`.`port_id`) AS `local_port_id` FROM `ipv4_mac` AS `M` LEFT JOIN `ports` AS `P` ON `M`.`mac_address` = `P`.`ifPhysAddress` LEFT JOIN `devices` AS `D` ON `P`.`device_id`=`D`.`device_id` WHERE `P`.`port_id` IS NOT NULL AND `M`.`port_id` IS NOT NULL AND `M`.`port_id` != 0 AND `P`.`port_id` != 0 $mac_sql", $mac_array) as $macs) { if (!in_array($macs['local_port_id'], $port_ids) && port_permitted($macs['local_port_id'])) { $port_det = dbFetchRow("SELECT * FROM `ports` WHERE `port_id`=?", array($macs['local_port_id'])); $port_dev = dbFetchRow("SELECT * FROM `devices` WHERE `device_id`=?", array($port_det['device_id'])); @@ -143,6 +143,8 @@ if (is_array($tmp_devices[0])) { } $edges = json_encode($tmp_links); + +if (count($node_devices) > 1 && count($tmp_links) > 0) { ?> @@ -205,6 +207,12 @@ network.redraw(); diff --git a/html/includes/print-menubar.php b/html/includes/print-menubar.php index ca30ad6c32..ab43b2a9eb 100644 --- a/html/includes/print-menubar.php +++ b/html/includes/print-menubar.php @@ -147,17 +147,9 @@ if ($config['show_locations'])
  • Delete Device
  • '); } -if ($links['count'] > 0) { - ?>
  • Network Map Network Map
  • - - diff --git a/html/pages/device.inc.php b/html/pages/device.inc.php index c72daf9bfe..245c29dd3a 100644 --- a/html/pages/device.inc.php +++ b/html/pages/device.inc.php @@ -256,15 +256,11 @@ if (device_permitted($vars['device']) || $check_device == $vars['device']) '); } - if ($_SESSION['userlevel'] >= "5" && dbFetchCell("SELECT COUNT(*) FROM links AS L, ports AS I WHERE I.device_id = '".$device['device_id']."' AND I.port_id = L.local_port_id")) - { - $discovery_links = TRUE; echo('
  • Map
  • '); - } if (@dbFetchCell("SELECT COUNT(*) FROM `packages` WHERE device_id = '".$device['device_id']."'") > '0') { From 841cb803b3fc8f9e244e46973e9c142ff8f47e50 Mon Sep 17 00:00:00 2001 From: laf Date: Tue, 2 Jun 2015 00:50:09 +0100 Subject: [PATCH 04/71] Some tidying up of variables/array --- html/includes/print-map.inc.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/html/includes/print-map.inc.php b/html/includes/print-map.inc.php index bfadc788d2..1e4311351c 100644 --- a/html/includes/print-map.inc.php +++ b/html/includes/print-map.inc.php @@ -42,6 +42,7 @@ $tmp_exp_ids = implode(',',$tmp_ids); $port_ids = array(); $port_devices = array(); +$tmp_links = array(); foreach (dbFetchRows("SELECT DISTINCT LEAST(`M`.`port_id`, `P`.`port_id`) AS `remote_port_id`, GREATEST(`P`.`port_id`,`M`.`port_id`) AS `local_port_id` FROM `ipv4_mac` AS `M` LEFT JOIN `ports` AS `P` ON `M`.`mac_address` = `P`.`ifPhysAddress` LEFT JOIN `devices` AS `D` ON `P`.`device_id`=`D`.`device_id` WHERE `P`.`port_id` IS NOT NULL AND `M`.`port_id` IS NOT NULL AND `M`.`port_id` != 0 AND `P`.`port_id` != 0 $mac_sql", $mac_array) as $macs) { if (!in_array($macs['local_port_id'], $port_ids) && port_permitted($macs['local_port_id'])) { $port_det = dbFetchRow("SELECT * FROM `ports` WHERE `port_id`=?", array($macs['local_port_id'])); @@ -93,6 +94,7 @@ foreach (dbFetchRows("SELECT DISTINCT LEAST(`M`.`port_id`, `P`.`port_id`) AS `re } } $tmp_links[] = array('from'=>$from,'to'=>$to,'label'=>$port,'title'=>generate_port_link($port_data, "",'',0,1),'width'=>$width,'color'=>$link_color); + unset($port); } $node_devices = array_merge($tmp_devices,$mac_devices); From 4bef35c90a4cf69ff9c5f0d7bef193589334e662 Mon Sep 17 00:00:00 2001 From: laf Date: Sat, 27 Jun 2015 17:41:31 +0100 Subject: [PATCH 05/71] Now save the connection value selected and remove when not needed --- html/forms/create-device-group.inc.php | 2 -- html/forms/parse-device-group.inc.php | 6 +++++- includes/device-groups.inc.php | 2 ++ 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/html/forms/create-device-group.inc.php b/html/forms/create-device-group.inc.php index 94c410c9e9..0992f73a12 100644 --- a/html/forms/create-device-group.inc.php +++ b/html/forms/create-device-group.inc.php @@ -23,8 +23,6 @@ $desc = mres($_POST['desc']); if( is_array($pattern) ) { $pattern = implode(" ", $pattern); - $pattern = rtrim($pattern,'&&'); - $pattern = rtrim($pattern,'||'); } elseif( !empty($_POST['pattern']) && !empty($_POST['condition']) && !empty($_POST['value']) ) { $pattern = '%'.$_POST['pattern'].' '.$_POST['condition'].' '; if( is_numeric($_POST['value']) ) { diff --git a/html/forms/parse-device-group.inc.php b/html/forms/parse-device-group.inc.php index 7009459f26..74af38cf63 100644 --- a/html/forms/parse-device-group.inc.php +++ b/html/forms/parse-device-group.inc.php @@ -22,7 +22,11 @@ if(is_numeric($group_id) && $group_id > 0) { $group = dbFetchRow("SELECT * FROM `device_groups` WHERE `id` = ? LIMIT 1",array($group_id)); $group_split = preg_split('/([a-zA-Z0-9_\-\.\=\%\<\>\ \"\'\!\~\(\)\*\/\@]+[&&\|\|]+)/',$group['pattern'], -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); $count = count($group_split) - 1; - $group_split[$count] = $group_split[$count].' &&'; + if (preg_match("/\&\&$/",$group_split[$count]) == 1 || preg_match("/\|\|$/", $group_split[$count]) == 1) { + $group_split[$count] = $group_split[$count]; + } else { + $group_split[$count] = $group_split[$count].' &&'; + } $output = array('name'=>$group['name'],'desc'=>$group['desc'],'pattern'=>$group_split); echo _json_encode($output); } diff --git a/includes/device-groups.inc.php b/includes/device-groups.inc.php index 533b433b56..36835c80ae 100644 --- a/includes/device-groups.inc.php +++ b/includes/device-groups.inc.php @@ -63,6 +63,8 @@ function GenGroupSQL($pattern,$search='') { */ function GetDevicesFromGroup($group_id) { $pattern = dbFetchCell("SELECT pattern FROM device_groups WHERE id = ?",array($group_id)); + $pattern = rtrim($pattern,'&&'); + $pattern = rtrim($pattern,'||'); if( !empty($pattern) ) { return dbFetchRows(GenGroupSQL($pattern)); } From 116a64deb95d6a71c322f4fa1d5da6395165a728 Mon Sep 17 00:00:00 2001 From: laf Date: Sat, 27 Jun 2015 22:52:01 +0100 Subject: [PATCH 06/71] Added basic detection for Mellanox devices --- html/images/os/mellanox.png | Bin 0 -> 1323 bytes includes/definitions.inc.php | 10 ++++++++++ includes/discovery/os/mellanox.inc.php | 7 +++++++ includes/polling/os/mellanox.inc.php | 8 ++++++++ 4 files changed, 25 insertions(+) create mode 100644 html/images/os/mellanox.png create mode 100644 includes/discovery/os/mellanox.inc.php create mode 100644 includes/polling/os/mellanox.inc.php diff --git a/html/images/os/mellanox.png b/html/images/os/mellanox.png new file mode 100644 index 0000000000000000000000000000000000000000..a1b9b4b0eb2c6da64d5f4a738eee97ac947863c3 GIT binary patch literal 1323 zcmc(e|2xwO0LMS14xLbXqA2B(WY1N0aea|x3U!XnMCHtvk(2K`C2BKLhI=;G^+g>C z8z)+&xoxT0WH$LWh7t2^n^|m{jhS)ouekT~yx*_q{qy^I=Lh(oGc(<33IKqauMZTq zPW%6CykR||mH5_m*r2^b(D0-f^!12T6aa}%ibUD_CPc)dV5o@bj1(^FBmfv-11S0u zCsVGe$y{P9=UVW;qcF6c z(bOxEDsXv}uI@3FYDuHflB!!*SM>^oy7W0qEK#(!a&$U9Hn)CqYF0ERzn)nmomTet zO-{?^Kd}0hN(EpWz0EP`BXsuRDa5&<%Y4x2!BZ9NfO|aG@ z*|zzjXT!J7&#KEd^R^NW5KdhkzjauU`m<-zZd_RT3pkEsx?pl&nKfqf&j$NW_Io3j z6zg6;jNHIuQ|OGzm@0snP0qnmJS{9?X$>Yw*Kq2o>}0#bYwUjCy6IHOscXfIrixxr zCTxpPzuWz-qe*8+yfH>48v$dKEk+-LS)8^+krOok41IlAAnJYm~21#_1?nh(n=R3!@WoE_2 z_6Q*Xi?Ph8(Od#fd{2m{THg)10W*KH%V`(9Bzii?w!&y_rF&B>-m=+&=qGg@rk*Z= zdT~fD#(Q}cNc%u-6f2N02A+YMIwpIl@^M>SeBAcEnu)L{xA}$@A_}P0lAVU|qPk%V zq`hmcLBb9J=w-&^$e@Gb2{6gy<#PM({~t Date: Mon, 29 Jun 2015 16:28:58 +0100 Subject: [PATCH 07/71] Updated NX-OS to avoid conflicts elsewhere --- includes/discovery/os/nxos.inc.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/discovery/os/nxos.inc.php b/includes/discovery/os/nxos.inc.php index 989021c932..5e374396a7 100644 --- a/includes/discovery/os/nxos.inc.php +++ b/includes/discovery/os/nxos.inc.php @@ -2,7 +2,7 @@ if (!$os) { - if (strstr($sysDescr, "NX-OS")) { $os = "nxos"; } + if (strstr($sysDescr, "NX-OS(tm)")) { $os = "nxos"; } } -?> \ No newline at end of file +?> From 1a5f98ac149d4d8693f22ba29474988ec543dd1b Mon Sep 17 00:00:00 2001 From: Will Jones Date: Mon, 6 Jul 2015 02:08:19 +0100 Subject: [PATCH 08/71] Create merakimr.inc.php OS detection module for Meraki MR --- includes/discovery/os/merakimr.inc.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 includes/discovery/os/merakimr.inc.php diff --git a/includes/discovery/os/merakimr.inc.php b/includes/discovery/os/merakimr.inc.php new file mode 100644 index 0000000000..a8255a6b35 --- /dev/null +++ b/includes/discovery/os/merakimr.inc.php @@ -0,0 +1,17 @@ + + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. Please see LICENSE.txt at the top level of + * the source code distribution for details. + */ + +if (!$os) { + if (preg_match("/^Meraki MR/", $sysDescr)) { $os = "merakimr"; } +} + +?> From f8b6038c9d0c3d9484f9e582449e7869728a9be5 Mon Sep 17 00:00:00 2001 From: Will Jones Date: Mon, 6 Jul 2015 02:09:40 +0100 Subject: [PATCH 09/71] Create merakims.inc.php OS Detection module for Meraki MS --- includes/discovery/os/merakims.inc.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 includes/discovery/os/merakims.inc.php diff --git a/includes/discovery/os/merakims.inc.php b/includes/discovery/os/merakims.inc.php new file mode 100644 index 0000000000..8635c0e95d --- /dev/null +++ b/includes/discovery/os/merakims.inc.php @@ -0,0 +1,17 @@ + + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. Please see LICENSE.txt at the top level of + * the source code distribution for details. + */ + +if (!$os) { + if (preg_match("/^Meraki MS/", $sysDescr)) { $os = "merakims"; } +} + +?> From be69210591509b880fa7424ae7418a8d7af240f9 Mon Sep 17 00:00:00 2001 From: Will Jones Date: Mon, 6 Jul 2015 02:10:25 +0100 Subject: [PATCH 10/71] Create merakimx.inc.php OS Detection module for Meraki MX --- includes/discovery/os/merakimx.inc.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 includes/discovery/os/merakimx.inc.php diff --git a/includes/discovery/os/merakimx.inc.php b/includes/discovery/os/merakimx.inc.php new file mode 100644 index 0000000000..aa0f87e913 --- /dev/null +++ b/includes/discovery/os/merakimx.inc.php @@ -0,0 +1,17 @@ + + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. Please see LICENSE.txt at the top level of + * the source code distribution for details. + */ + +if (!$os) { + if (preg_match("/^Meraki MX/", $sysDescr)) { $os = "merakimx"; } +} + +?> From f6f4a40c736a193b9e47d9c42461ac44731f1f9b Mon Sep 17 00:00:00 2001 From: Will Jones Date: Mon, 6 Jul 2015 02:13:50 +0100 Subject: [PATCH 11/71] Adding Meraki devices Definitions for Meraki MX. MR and MS hardware. --- includes/definitions.inc.php | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/includes/definitions.inc.php b/includes/definitions.inc.php index 3c551d5712..1140ad6aa3 100644 --- a/includes/definitions.inc.php +++ b/includes/definitions.inc.php @@ -1189,6 +1189,31 @@ foreach ($config['os'] as $this_os => $blah) } } +// Meraki Devices +$os = "merakimx"; +$config['os'][$os]['text'] = "Meraki MX Appliance"; +$config['os'][$os]['type'] = "firewall"; +$config['os'][$os]['icon'] = "meraki"; +$config['os'][$os]['ifname'] = 1; +$config['os'][$os]['over'][0]['graph'] = "device_bits"; +$config['os'][$os]['over'][0]['text'] = "Device Traffic"; + +$os = "merakimr"; +$config['os'][$os]['text'] = "Meraki AP"; +$config['os'][$os]['type'] = "wireless"; +$config['os'][$os]['icon'] = "meraki"; +$config['os'][$os]['ifname'] = 1; +$config['os'][$os]['over'][0]['graph'] = "device_bits"; +$config['os'][$os]['over'][0]['text'] = "Device Traffic"; + +$os = "merakims"; +$config['os'][$os]['text'] = "Meraki Switch"; +$config['os'][$os]['type'] = "network"; +$config['os'][$os]['icon'] = "meraki"; +$config['os'][$os]['ifname'] = 1; +$config['os'][$os]['over'][0]['graph'] = "device_bits"; +$config['os'][$os]['over'][0]['text'] = "Device Traffic"; + // Graph Types include_once($config['install_dir'] . "/includes/load_db_graph_types.inc.php"); From a584c08babf2f92a2853653b0419484feb982dd0 Mon Sep 17 00:00:00 2001 From: dontforget Date: Mon, 6 Jul 2015 17:14:52 +0300 Subject: [PATCH 12/71] fix chkconfig command Defining level is not needed for chkconfig according to official documentation https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Deployment_Guide/sect-System_Monitoring_Tools-Net-SNMP-Running.html --- doc/Installation/Installation-(RHEL-CentOS).md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/Installation/Installation-(RHEL-CentOS).md b/doc/Installation/Installation-(RHEL-CentOS).md index 42f277f181..cf36bb9795 100644 --- a/doc/Installation/Installation-(RHEL-CentOS).md +++ b/doc/Installation/Installation-(RHEL-CentOS).md @@ -7,8 +7,8 @@ NOTE: These instructions assume you are the root user. If you are not, prepend yum install net-snmp mysql-server service snmpd start service mysqld start - chkconfig --levels 235 mysqld on - chkconfig --levels 235 snmpd on + chkconfig mysqld on + chkconfig snmpd on mysql_secure_installation mysql -uroot -p From 5d80beeeb5e3ec513cd8d1558ab8f2e3f51e8d31 Mon Sep 17 00:00:00 2001 From: dontforget Date: Mon, 6 Jul 2015 17:21:48 +0300 Subject: [PATCH 13/71] fix install for epel Install epel release using yum --- doc/Installation/Installation-(RHEL-CentOS).md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/Installation/Installation-(RHEL-CentOS).md b/doc/Installation/Installation-(RHEL-CentOS).md index cf36bb9795..350cc4c717 100644 --- a/doc/Installation/Installation-(RHEL-CentOS).md +++ b/doc/Installation/Installation-(RHEL-CentOS).md @@ -46,7 +46,7 @@ Install necessary software. The packages listed below are an all-inclusive list Note if not using HTTPd (Apache): RHEL requires `httpd` to be installed regardless of of `nginx`'s (or any other web-server's) presence. - rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm + yum install epel-release yum install php php-cli php-gd php-mysql php-snmp php-pear php-curl httpd net-snmp graphviz graphviz-php mysql ImageMagick jwhois nmap mtr rrdtool MySQL-python net-snmp-utils vixie-cron php-mcrypt fping git pear install Net_IPv4-1.3.4 pear install Net_IPv6-1.2.2b2 From e9aa9a2ae967be24f7aef94be2126044551daa13 Mon Sep 17 00:00:00 2001 From: dontforget Date: Mon, 6 Jul 2015 17:26:58 +0300 Subject: [PATCH 14/71] fix nginx and php --- doc/Installation/Installation-(RHEL-CentOS).md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/Installation/Installation-(RHEL-CentOS).md b/doc/Installation/Installation-(RHEL-CentOS).md index 350cc4c717..5968dacbb6 100644 --- a/doc/Installation/Installation-(RHEL-CentOS).md +++ b/doc/Installation/Installation-(RHEL-CentOS).md @@ -87,8 +87,8 @@ If the file `/etc/httpd/conf.d/welcome.conf` exists, you might want to remove th Install necessary extra software and let it start on system boot. yum install nginx php-fpm - chkconfig --levels 235 nginx on - chkconfig --levels 235 php-fpm on + chkconfig nginx on + chkconfig php-fpm on Modify permissions and configuration for `php-fpm` to use nginx credentials. From 016b759858d76ca1db3a5a871f09ba73f64a6f07 Mon Sep 17 00:00:00 2001 From: willjones Date: Mon, 6 Jul 2015 21:17:50 +0100 Subject: [PATCH 15/71] Added Meraki OS discovery and polling --- html/images/os/meraki.png | Bin 0 -> 1664 bytes includes/definitions.inc.php | 25 +++++++++++++++++++++++++ includes/discovery/os/merakimr.inc.php | 17 +++++++++++++++++ includes/discovery/os/merakims.inc.php | 17 +++++++++++++++++ includes/discovery/os/merakimx.inc.php | 17 +++++++++++++++++ includes/polling/os/merakimr.inc.php | 18 ++++++++++++++++++ includes/polling/os/merakims.inc.php | 18 ++++++++++++++++++ includes/polling/os/merakimx.inc.php | 18 ++++++++++++++++++ 8 files changed, 130 insertions(+) create mode 100644 html/images/os/meraki.png create mode 100644 includes/discovery/os/merakimr.inc.php create mode 100644 includes/discovery/os/merakims.inc.php create mode 100644 includes/discovery/os/merakimx.inc.php create mode 100644 includes/polling/os/merakimr.inc.php create mode 100644 includes/polling/os/merakims.inc.php create mode 100644 includes/polling/os/merakimx.inc.php diff --git a/html/images/os/meraki.png b/html/images/os/meraki.png new file mode 100644 index 0000000000000000000000000000000000000000..51b3564f6dc9e20b528d3d7933766b418addb6fa GIT binary patch literal 1664 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz#^NA%Cx&(BWL^T}FfdWk9dNvV1jxdlK~3=B3ERzPNMYDuC(MQ%=Bu~mhw5?F;5kPQ;nS5g2gDap1~ zitr6kaLzAERWQ{v(KAr8<5EyiuqjGOvkG!?gK7uzY?U%fN(!v>^~=l4^~#O)@{7{- z4J|D#^$m>ljf`}GDs+o0^GXscbn}XpA%?)raY-#sF3Kz@$;{7F0GXSZlwVq6tE2?7 z2o50bEXhnm*pycc^%l^B`XCv7Lp=k1xY$-uu4$%|?`(myi^JB2i8yLB{aA6K{@*9Z*Na6&7HV|3F8S{gV8FUGH^67HS+9ht zeUSN*v)xB*e9AuGy89-%tn7OAyEJp_yS<$%6YMPwir=5H{XQrEoaOzU$}Te!q+Pf6 z?%VlVmf^M>eb=OT< z4mI?tURWcR5b(BDA>*;#lMh17CXJSo6&kNa;?`D6AHA9S@#~S3Z45jT{)}Ir06bo^Lkrh&VNsnch-Hi zGfiJauo-<}t@!f5IAfhnqt4;KcYekt8?QTG)A{b8^p;S?Y_W$sibdq_)bOzhZpg}d z$Zt7SnpNB7;DO#-5iD)beh1_;h%sOOk@|pLuF>+o$a+D|M{Wz{Uda4q<9)i8t89r+ zqss4(7yHu-OFt={@+tK^$H^%=SL20&{2Sj$<|WQM)n&V6Uh1DLi^81*g6lz4O*SHYJ@U`CVLx_8I|&q6@0eCTDC6IrMOD zL+wB7jwCacYg&IC*B^=zYA}3mP&H@zgq0_sU!AwYH{Que-|}P1QSKF*c3phGL${Q~ zxfM^DI;ZZf+=8`lN^N34+qk8@fAnRm_l>g*0;Z;qvi2)Pdor-4zgZ9v$s-mOA3QDM z_0o)qbM)<)C#Qw(*W1C;e2gRO>SsB2{gg%PLJwa`J{f+)hwZ_e#}E5O{TG$#$X?0X z|Le7L&7bGO70dT=KbQM$64-mb^U(S&vI*ykBYjO0u2c*6TBdJMUmUP-HG{+3vO~q~ z?OqF~K02uTzqd}_`}n42cc)3rG1@YGj_XYiJ&ixoQZK_=CF{iT>Du2b|E4D-WOpuF zpji0-?0fk}eVdlpSF0>)Gnidf0$m(=wJb!Xw<={bXe)8)obz#-sPJc#^yW+JZI+7n zZTZ}`b&;67h+xDgy#u0BEuNxhC;R!Nx23Q+ZT{eNTmGn?)GyJ8xI}6DE|G9D8n?>?_R+tpJhGXCzsdJb$rpfl%HD^&oG=^ zvtZiO-G7cKXHEPeFgM`2j*;1dBQf2#n%V<{OH5Y&cQ1E&&&9COX3|I3n}@rXrIibR zy4<}(uvdatKX>W;2@V(f8{RM*HnnJ^U5ifeKJB*7w0~>zwfgIVtPB(Xp6%JR?{db9 z1KI8O-Af-fd%6m5o-RH+rznJBfnMnajR!fG#Wl~r^Zn(uGxi{p)$h_QW44bndlPm}S^luCEN|i^zJ|FRf4EtjelDHltuzl*S9rSmxvX $blah) } } +// Meraki +$os = "merakimx"; +$config['os'][$os]['text'] = "Meraki MX Appliance"; +$config['os'][$os]['type'] = "firewall"; +$config['os'][$os]['icon'] = "meraki"; +$config['os'][$os]['ifname'] = 1; +$config['os'][$os]['over'][0]['graph'] = "device_bits"; +$config['os'][$os]['over'][0]['text'] = "Device Traffic"; + +$os = "merakimr"; +$config['os'][$os]['text'] = "Meraki AP"; +$config['os'][$os]['type'] = "wireless"; +$config['os'][$os]['icon'] = "meraki"; +$config['os'][$os]['ifname'] = 1; +$config['os'][$os]['over'][0]['graph'] = "device_bits"; +$config['os'][$os]['over'][0]['text'] = "Device Traffic"; + +$os = "merakims"; +$config['os'][$os]['text'] = "Meraki Switch"; +$config['os'][$os]['type'] = "network"; +$config['os'][$os]['icon'] = "meraki"; +$config['os'][$os]['ifname'] = 1; +$config['os'][$os]['over'][0]['graph'] = "device_bits"; +$config['os'][$os]['over'][0]['text'] = "Device Traffic"; + // Graph Types include_once($config['install_dir'] . "/includes/load_db_graph_types.inc.php"); diff --git a/includes/discovery/os/merakimr.inc.php b/includes/discovery/os/merakimr.inc.php new file mode 100644 index 0000000000..a8255a6b35 --- /dev/null +++ b/includes/discovery/os/merakimr.inc.php @@ -0,0 +1,17 @@ + + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. Please see LICENSE.txt at the top level of + * the source code distribution for details. + */ + +if (!$os) { + if (preg_match("/^Meraki MR/", $sysDescr)) { $os = "merakimr"; } +} + +?> diff --git a/includes/discovery/os/merakims.inc.php b/includes/discovery/os/merakims.inc.php new file mode 100644 index 0000000000..8635c0e95d --- /dev/null +++ b/includes/discovery/os/merakims.inc.php @@ -0,0 +1,17 @@ + + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. Please see LICENSE.txt at the top level of + * the source code distribution for details. + */ + +if (!$os) { + if (preg_match("/^Meraki MS/", $sysDescr)) { $os = "merakims"; } +} + +?> diff --git a/includes/discovery/os/merakimx.inc.php b/includes/discovery/os/merakimx.inc.php new file mode 100644 index 0000000000..aa0f87e913 --- /dev/null +++ b/includes/discovery/os/merakimx.inc.php @@ -0,0 +1,17 @@ + + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. Please see LICENSE.txt at the top level of + * the source code distribution for details. + */ + +if (!$os) { + if (preg_match("/^Meraki MX/", $sysDescr)) { $os = "merakimx"; } +} + +?> diff --git a/includes/polling/os/merakimr.inc.php b/includes/polling/os/merakimr.inc.php new file mode 100644 index 0000000000..2158f6c259 --- /dev/null +++ b/includes/polling/os/merakimr.inc.php @@ -0,0 +1,18 @@ + + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. Please see LICENSE.txt at the top level of + * the source code distribution for details. + */ + +if(empty($hardware)) { + $hardware = snmp_get($device, "sysDescr.0", "-Osqv", "SNMPv2-MIB"); +} + + +?> diff --git a/includes/polling/os/merakims.inc.php b/includes/polling/os/merakims.inc.php new file mode 100644 index 0000000000..1bfdaedc38 --- /dev/null +++ b/includes/polling/os/merakims.inc.php @@ -0,0 +1,18 @@ + + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. Please see LICENSE.txt at the top level of + * the source code distribution for details. + */ + +if(empty($hardware)) { + $hardware = snmp_get($device, "sysDescr.0", "-Osqv", "SNMPv2-MIB"); +} + + +?> diff --git a/includes/polling/os/merakimx.inc.php b/includes/polling/os/merakimx.inc.php new file mode 100644 index 0000000000..217ca3afc9 --- /dev/null +++ b/includes/polling/os/merakimx.inc.php @@ -0,0 +1,18 @@ + + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. Please see LICENSE.txt at the top level of + * the source code distribution for details. + */ + +if(empty($hardware)) { + $hardware = snmp_get($device, "sysDescr.0", "-Osqv", "SNMPv2-MIB"); +} + + +?> From 93c0e8ae9c14ab7ecf2f446aa86b65a40af36aef Mon Sep 17 00:00:00 2001 From: Will Jones Date: Mon, 6 Jul 2015 21:37:18 +0100 Subject: [PATCH 16/71] Delete meraki.png --- html/images/os/meraki.png | Bin 1664 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 html/images/os/meraki.png diff --git a/html/images/os/meraki.png b/html/images/os/meraki.png deleted file mode 100644 index 51b3564f6dc9e20b528d3d7933766b418addb6fa..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1664 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz#^NA%Cx&(BWL^T}FfdWk9dNvV1jxdlK~3=B3ERzPNMYDuC(MQ%=Bu~mhw5?F;5kPQ;nS5g2gDap1~ zitr6kaLzAERWQ{v(KAr8<5EyiuqjGOvkG!?gK7uzY?U%fN(!v>^~=l4^~#O)@{7{- z4J|D#^$m>ljf`}GDs+o0^GXscbn}XpA%?)raY-#sF3Kz@$;{7F0GXSZlwVq6tE2?7 z2o50bEXhnm*pycc^%l^B`XCv7Lp=k1xY$-uu4$%|?`(myi^JB2i8yLB{aA6K{@*9Z*Na6&7HV|3F8S{gV8FUGH^67HS+9ht zeUSN*v)xB*e9AuGy89-%tn7OAyEJp_yS<$%6YMPwir=5H{XQrEoaOzU$}Te!q+Pf6 z?%VlVmf^M>eb=OT< z4mI?tURWcR5b(BDA>*;#lMh17CXJSo6&kNa;?`D6AHA9S@#~S3Z45jT{)}Ir06bo^Lkrh&VNsnch-Hi zGfiJauo-<}t@!f5IAfhnqt4;KcYekt8?QTG)A{b8^p;S?Y_W$sibdq_)bOzhZpg}d z$Zt7SnpNB7;DO#-5iD)beh1_;h%sOOk@|pLuF>+o$a+D|M{Wz{Uda4q<9)i8t89r+ zqss4(7yHu-OFt={@+tK^$H^%=SL20&{2Sj$<|WQM)n&V6Uh1DLi^81*g6lz4O*SHYJ@U`CVLx_8I|&q6@0eCTDC6IrMOD zL+wB7jwCacYg&IC*B^=zYA}3mP&H@zgq0_sU!AwYH{Que-|}P1QSKF*c3phGL${Q~ zxfM^DI;ZZf+=8`lN^N34+qk8@fAnRm_l>g*0;Z;qvi2)Pdor-4zgZ9v$s-mOA3QDM z_0o)qbM)<)C#Qw(*W1C;e2gRO>SsB2{gg%PLJwa`J{f+)hwZ_e#}E5O{TG$#$X?0X z|Le7L&7bGO70dT=KbQM$64-mb^U(S&vI*ykBYjO0u2c*6TBdJMUmUP-HG{+3vO~q~ z?OqF~K02uTzqd}_`}n42cc)3rG1@YGj_XYiJ&ixoQZK_=CF{iT>Du2b|E4D-WOpuF zpji0-?0fk}eVdlpSF0>)Gnidf0$m(=wJb!Xw<={bXe)8)obz#-sPJc#^yW+JZI+7n zZTZ}`b&;67h+xDgy#u0BEuNxhC;R!Nx23Q+ZT{eNTmGn?)GyJ8xI}6DE|G9D8n?>?_R+tpJhGXCzsdJb$rpfl%HD^&oG=^ zvtZiO-G7cKXHEPeFgM`2j*;1dBQf2#n%V<{OH5Y&cQ1E&&&9COX3|I3n}@rXrIibR zy4<}(uvdatKX>W;2@V(f8{RM*HnnJ^U5ifeKJB*7w0~>zwfgIVtPB(Xp6%JR?{db9 z1KI8O-Af-fd%6m5o-RH+rznJBfnMnajR!fG#Wl~r^Zn(uGxi{p)$h_QW44bndlPm}S^luCEN|i^zJ|FRf4EtjelDHltuzl*S9rSmxvX Date: Mon, 6 Jul 2015 21:49:13 +0100 Subject: [PATCH 17/71] Meraki Logo. Source = Meraki Partner Portal --- html/images/os/meraki.png | Bin 0 -> 1664 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 html/images/os/meraki.png diff --git a/html/images/os/meraki.png b/html/images/os/meraki.png new file mode 100644 index 0000000000000000000000000000000000000000..51b3564f6dc9e20b528d3d7933766b418addb6fa GIT binary patch literal 1664 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz#^NA%Cx&(BWL^T}FfdWk9dNvV1jxdlK~3=B3ERzPNMYDuC(MQ%=Bu~mhw5?F;5kPQ;nS5g2gDap1~ zitr6kaLzAERWQ{v(KAr8<5EyiuqjGOvkG!?gK7uzY?U%fN(!v>^~=l4^~#O)@{7{- z4J|D#^$m>ljf`}GDs+o0^GXscbn}XpA%?)raY-#sF3Kz@$;{7F0GXSZlwVq6tE2?7 z2o50bEXhnm*pycc^%l^B`XCv7Lp=k1xY$-uu4$%|?`(myi^JB2i8yLB{aA6K{@*9Z*Na6&7HV|3F8S{gV8FUGH^67HS+9ht zeUSN*v)xB*e9AuGy89-%tn7OAyEJp_yS<$%6YMPwir=5H{XQrEoaOzU$}Te!q+Pf6 z?%VlVmf^M>eb=OT< z4mI?tURWcR5b(BDA>*;#lMh17CXJSo6&kNa;?`D6AHA9S@#~S3Z45jT{)}Ir06bo^Lkrh&VNsnch-Hi zGfiJauo-<}t@!f5IAfhnqt4;KcYekt8?QTG)A{b8^p;S?Y_W$sibdq_)bOzhZpg}d z$Zt7SnpNB7;DO#-5iD)beh1_;h%sOOk@|pLuF>+o$a+D|M{Wz{Uda4q<9)i8t89r+ zqss4(7yHu-OFt={@+tK^$H^%=SL20&{2Sj$<|WQM)n&V6Uh1DLi^81*g6lz4O*SHYJ@U`CVLx_8I|&q6@0eCTDC6IrMOD zL+wB7jwCacYg&IC*B^=zYA}3mP&H@zgq0_sU!AwYH{Que-|}P1QSKF*c3phGL${Q~ zxfM^DI;ZZf+=8`lN^N34+qk8@fAnRm_l>g*0;Z;qvi2)Pdor-4zgZ9v$s-mOA3QDM z_0o)qbM)<)C#Qw(*W1C;e2gRO>SsB2{gg%PLJwa`J{f+)hwZ_e#}E5O{TG$#$X?0X z|Le7L&7bGO70dT=KbQM$64-mb^U(S&vI*ykBYjO0u2c*6TBdJMUmUP-HG{+3vO~q~ z?OqF~K02uTzqd}_`}n42cc)3rG1@YGj_XYiJ&ixoQZK_=CF{iT>Du2b|E4D-WOpuF zpji0-?0fk}eVdlpSF0>)Gnidf0$m(=wJb!Xw<={bXe)8)obz#-sPJc#^yW+JZI+7n zZTZ}`b&;67h+xDgy#u0BEuNxhC;R!Nx23Q+ZT{eNTmGn?)GyJ8xI}6DE|G9D8n?>?_R+tpJhGXCzsdJb$rpfl%HD^&oG=^ zvtZiO-G7cKXHEPeFgM`2j*;1dBQf2#n%V<{OH5Y&cQ1E&&&9COX3|I3n}@rXrIibR zy4<}(uvdatKX>W;2@V(f8{RM*HnnJ^U5ifeKJB*7w0~>zwfgIVtPB(Xp6%JR?{db9 z1KI8O-Af-fd%6m5o-RH+rznJBfnMnajR!fG#Wl~r^Zn(uGxi{p)$h_QW44bndlPm}S^luCEN|i^zJ|FRf4EtjelDHltuzl*S9rSmxvX Date: Tue, 7 Jul 2015 10:04:10 +0100 Subject: [PATCH 18/71] Update definitions.inc.php removed conflict. --- includes/definitions.inc.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/includes/definitions.inc.php b/includes/definitions.inc.php index 16b4dcde02..1140ad6aa3 100644 --- a/includes/definitions.inc.php +++ b/includes/definitions.inc.php @@ -1189,11 +1189,7 @@ foreach ($config['os'] as $this_os => $blah) } } -<<<<<<< HEAD -// Meraki -======= // Meraki Devices ->>>>>>> 8b9323852cb4acdbedecca17c7a1a2fc8a53155f $os = "merakimx"; $config['os'][$os]['text'] = "Meraki MX Appliance"; $config['os'][$os]['type'] = "firewall"; From a35fa43e447f5ac0107979a829240010e7777f51 Mon Sep 17 00:00:00 2001 From: laf Date: Tue, 7 Jul 2015 19:16:36 +0100 Subject: [PATCH 19/71] Added basic detection for Brocade --- includes/definitions.inc.php | 13 ++++++++++++- includes/discovery/os/nos.inc.php | 7 +++++++ includes/polling/os/nos.inc.php | 6 ++++++ 3 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 includes/discovery/os/nos.inc.php create mode 100644 includes/polling/os/nos.inc.php diff --git a/includes/definitions.inc.php b/includes/definitions.inc.php index 3c551d5712..9db59d3c4f 100644 --- a/includes/definitions.inc.php +++ b/includes/definitions.inc.php @@ -408,7 +408,18 @@ $config['os'][$os]['over'][2]['graph'] = "device_mempool"; $config['os'][$os]['over'][2]['text'] = "Memory Usage"; $config['os'][$os]['icon'] = "cisco"; - +// Brocade NOS +$os = "nos"; +$config['os'][$os]['text'] = "Brocade NOS"; +$config['os'][$os]['type'] = "network"; +$config['os'][$os]['ifname'] = 1; +$config['os'][$os]['over'][0]['graph'] = "device_bits"; +$config['os'][$os]['over'][0]['text'] = "Device Traffic"; +$config['os'][$os]['over'][1]['graph'] = "device_processor"; +$config['os'][$os]['over'][1]['text'] = "CPU Usage"; +$config['os'][$os]['over'][2]['graph'] = "device_mempool"; +$config['os'][$os]['over'][2]['text'] = "Memory Usage"; +$config['os'][$os]['icon'] = "brocade"; // Cisco Small Business diff --git a/includes/discovery/os/nos.inc.php b/includes/discovery/os/nos.inc.php new file mode 100644 index 0000000000..de4141cb66 --- /dev/null +++ b/includes/discovery/os/nos.inc.php @@ -0,0 +1,7 @@ + Date: Tue, 7 Jul 2015 19:43:25 +0100 Subject: [PATCH 20/71] Improved the discovery of IP based devices --- includes/discovery/discovery-arp.inc.php | 13 +++---------- includes/discovery/functions.inc.php | 12 +++++++----- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/includes/discovery/discovery-arp.inc.php b/includes/discovery/discovery-arp.inc.php index fce4e2f9a6..230752d9ea 100644 --- a/includes/discovery/discovery-arp.inc.php +++ b/includes/discovery/discovery-arp.inc.php @@ -69,17 +69,10 @@ foreach (dbFetchRows($sql, array($deviceid)) as $entry) } arp_discovery_add_cache($ip); - // Log reverse DNS failures so the administrator can take action. $name = gethostbyaddr($ip); - if ($name != $ip) { // gethostbyaddr returns the original argument on failure - echo("+"); - $names[] = $name; - $ips[$name] = $ip; - } - else { - echo("-"); - log_event("ARP discovery of $ip failed due to absent reverse DNS", $deviceid, 'interface', $if); - } + echo("+"); + $names[] = $name; + $ips[$name] = $ip; } echo("\n"); diff --git a/includes/discovery/functions.inc.php b/includes/discovery/functions.inc.php index f369fac79b..9aa82d274b 100644 --- a/includes/discovery/functions.inc.php +++ b/includes/discovery/functions.inc.php @@ -22,12 +22,14 @@ function discover_new_device($hostname) } if ($debug) { echo("discovering $dst_host\n"); } $ip = gethostbyname($dst_host); - if ($ip == $dst_host) { - if ($debug) { echo("name lookup of $dst_host failed\n"); } - return FALSE; - } else { - if ($debug) { echo("ip lookup result: $ip\n"); } + if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) === FALSE && filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) === FALSE) { + // $ip isn't a valid IP so it must be a name. + if ($ip == $dst_host) { + if ($debug) { echo("name lookup of $dst_host failed\n"); } + return FALSE; + } } + if ($debug) { echo("ip lookup result: $ip\n"); } $dst_host = rtrim($dst_host, '.'); // remove trailing dot From 4c3a6b5ff23f47792433ad3893b2c32350656cab Mon Sep 17 00:00:00 2001 From: laf Date: Tue, 7 Jul 2015 21:04:39 +0100 Subject: [PATCH 21/71] Added using cronic for poller-wrapper, this will now allow email alerts from cron --- cronic | 48 +++++++++++++++++++++++++++++++++++++++++++ librenms.cron | 2 +- librenms.nonroot.cron | 2 +- 3 files changed, 50 insertions(+), 2 deletions(-) create mode 100755 cronic diff --git a/cronic b/cronic new file mode 100755 index 0000000000..8536f29a38 --- /dev/null +++ b/cronic @@ -0,0 +1,48 @@ +#!/bin/bash + +# Cronic v2 - cron job report wrapper +# Copyright 2007 Chuck Houpt. No rights reserved, whatsoever. +# Public Domain CC0: http://creativecommons.org/publicdomain/zero/1.0/ + +set -eu + +OUT=/tmp/cronic.out.$$ +ERR=/tmp/cronic.err.$$ +TRACE=/tmp/cronic.trace.$$ + +set +e +"$@" >$OUT 2>$TRACE +RESULT=$? +set -e + +PATTERN="^${PS4:0:1}\\+${PS4:1}" +if grep -aq "$PATTERN" $TRACE +then + ! grep -av "$PATTERN" $TRACE > $ERR +else + ERR=$TRACE +fi + +if [ $RESULT -ne 0 -o -s "$ERR" ] + then + echo "Cronic detected failure or error output for the command:" + echo "$@" + echo + echo "RESULT CODE: $RESULT" + echo + echo "ERROR OUTPUT:" + cat "$ERR" + echo + echo "STANDARD OUTPUT:" + cat "$OUT" + if [ $TRACE != $ERR ] + then + echo + echo "TRACE-ERROR OUTPUT:" + cat "$TRACE" + fi +fi + +rm -f "$OUT" +rm -f "$ERR" +rm -f "$TRACE" diff --git a/librenms.cron b/librenms.cron index 8ea97492cc..ad03af7f57 100644 --- a/librenms.cron +++ b/librenms.cron @@ -2,6 +2,6 @@ 33 */6 * * * root /opt/librenms/discovery.php -h all >> /dev/null 2>&1 */5 * * * * root /opt/librenms/discovery.php -h new >> /dev/null 2>&1 -*/5 * * * * root /opt/librenms/poller-wrapper.py 16 >> /dev/null 2>&1 +*/5 * * * * root /opt/librenms/cronic /opt/librenms/poller-wrapper.py 16 15 0 * * * root sh /opt/librenms/daily.sh >> /dev/null 2>&1 * * * * * root /opt/librenms/alerts.php >> /dev/null 2>&1 diff --git a/librenms.nonroot.cron b/librenms.nonroot.cron index 7c0fdfc58b..6183ebc18a 100644 --- a/librenms.nonroot.cron +++ b/librenms.nonroot.cron @@ -2,6 +2,6 @@ 33 */6 * * * librenms /opt/librenms/discovery.php -h all >> /dev/null 2>&1 */5 * * * * librenms /opt/librenms/discovery.php -h new >> /dev/null 2>&1 -*/5 * * * * librenms /opt/librenms/poller-wrapper.py 16 >> /dev/null 2>&1 +*/5 * * * * librenms /opt/librenms/cronic /opt/librenms/poller-wrapper.py 16 15 0 * * * librenms sh /opt/librenms/daily.sh >> /dev/null 2>&1 * * * * * librenms /opt/librenms/alerts.php >> /dev/null 2>&1 From b1a052f357d231d797b3fbad6e98cc18abd87eb2 Mon Sep 17 00:00:00 2001 From: laf Date: Tue, 7 Jul 2015 23:18:57 +0100 Subject: [PATCH 22/71] Some permission updates for non-admin users --- html/includes/table/alerts.inc.php | 26 ++++++++++++++++---------- html/pages/search/arp.inc.php | 11 ++++++++++- html/pages/search/packages.inc.php | 13 +++++++++++-- 3 files changed, 37 insertions(+), 13 deletions(-) diff --git a/html/includes/table/alerts.inc.php b/html/includes/table/alerts.inc.php index da2a6d1c6a..799404b1a4 100644 --- a/html/includes/table/alerts.inc.php +++ b/html/includes/table/alerts.inc.php @@ -7,10 +7,18 @@ if (is_numeric($_POST['device_id']) && $_POST['device_id'] > 0) { } if (isset($searchPhrase) && !empty($searchPhrase)) { - $sql .= " AND (`timestamp` LIKE '%$searchPhrase%' OR `rule` LIKE '%$searchPhrase%' OR `name` LIKE '%$searchPhrase%' OR `hostname` LIKE '%$searchPhrase%')"; + $sql_search .= " AND (`timestamp` LIKE '%$searchPhrase%' OR `rule` LIKE '%$searchPhrase%' OR `name` LIKE '%$searchPhrase%' OR `hostname` LIKE '%$searchPhrase%')"; } -$sql = " FROM `alerts` LEFT JOIN `devices` ON `alerts`.`device_id`=`devices`.`device_id` RIGHT JOIN alert_rules ON alerts.rule_id=alert_rules.id WHERE $where AND `state` IN (1,2,3,4) $sql"; +$sql = " FROM `alerts` LEFT JOIN `devices` ON `alerts`.`device_id`=`devices`.`device_id`"; + +if (is_admin() === FALSE && is_read() === FALSE) { + $sql .= " LEFT JOIN `devices_perms` AS `DP` ON `devices`.`device_id` = `DP`.`device_id`"; + $where .= " AND `DP`.`user_id`=?"; + $param[] = $_SESSION['user_id']; +} + +$sql .= " RIGHT JOIN alert_rules ON alerts.rule_id=alert_rules.id WHERE $where AND `state` IN (1,2,3,4) $sql_search"; $count_sql = "SELECT COUNT(`alerts`.`id`) $sql"; $total = dbFetchCell($count_sql,$param); @@ -78,14 +86,12 @@ foreach (dbFetchRows($sql,$param) as $alert) { $severity .= " -"; } - if ($_SESSION['userlevel'] >= '10') { - $ack_ico = 'volume-up'; - $ack_col = 'success'; - if($alert['state'] == 2) { - $ack_ico = 'volume-off'; - $ack_col = 'danger'; - } - } + $ack_ico = 'volume-up'; + $ack_col = 'success'; + if($alert['state'] == 2) { + $ack_ico = 'volume-off'; + $ack_col = 'danger'; + } $hostname = '
    diff --git a/html/pages/search/arp.inc.php b/html/pages/search/arp.inc.php index 5e7df42666..a4dcbd1136 100644 --- a/html/pages/search/arp.inc.php +++ b/html/pages/search/arp.inc.php @@ -30,7 +30,16 @@ var grid = $("#arp-search").bootgrid({ 0) { $count_query = "SELECT COUNT(*) FROM ( "; $full_query = ""; -$query = 'SELECT packages.name FROM packages,devices WHERE packages.device_id = devices.device_id AND packages.name LIKE "%'.mres($_POST['package']).'%" GROUP BY packages.name'; -$where = ''; +$query = 'SELECT packages.name FROM packages,devices '; $param = array(); + +if (is_admin() === FALSE && is_read() === FALSE) { + $query .= " LEFT JOIN `devices_perms` AS `DP` ON `devices`.`device_id` = `DP`.`device_id`"; + $sql_where .= " AND `DP`.`user_id`=?"; + $param[] = $_SESSION['user_id']; +} + +$query .= " WHERE packages.device_id = devices.device_id AND packages.name LIKE '%".mres($_POST['package'])."%' $sql_where GROUP BY packages.name"; + +$where = ''; $ver = ""; $opt = ""; From 3ed8d261a7937010f5bff6f657b2c5fd33beaddd Mon Sep 17 00:00:00 2001 From: laf Date: Tue, 7 Jul 2015 23:26:03 +0100 Subject: [PATCH 23/71] Fixed arp search page user perm queries --- html/includes/table/arp-search.inc.php | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/html/includes/table/arp-search.inc.php b/html/includes/table/arp-search.inc.php index d4a9eaaf84..937553b42b 100644 --- a/html/includes/table/arp-search.inc.php +++ b/html/includes/table/arp-search.inc.php @@ -2,14 +2,22 @@ $param = array(); -$sql = " FROM `ipv4_mac` AS M, `ports` AS P, `devices` AS D WHERE M.port_id = P.port_id AND P.device_id = D.device_id "; +$sql .= " FROM `ipv4_mac` AS M, `ports` AS P, `devices` AS D "; + +if (is_admin() === FALSE && is_read() === FALSE) { + $sql .= " LEFT JOIN `devices_perms` AS `DP` ON `D`.`device_id` = `DP`.`device_id`"; + $where .= " AND `DP`.`user_id`=?"; + $param[] = $_SESSION['user_id']; +} + +$sql .= " WHERE M.port_id = P.port_id AND P.device_id = D.device_id $where "; if (isset($_POST['searchby']) && $_POST['searchby'] == "ip") { $sql .= " AND `ipv4_address` LIKE ?"; - $param = array("%".trim($_POST['address'])."%"); + $param[] = "%".trim($_POST['address'])."%"; } elseif (isset($_POST['searchby']) && $_POST['searchby'] == "mac") { $sql .= " AND `mac_address` LIKE ?"; - $param = array("%".str_replace(array(':', ' ', '-', '.', '0x'),'',mres($_POST['address']))."%"); + $param[] = "%".str_replace(array(':', ' ', '-', '.', '0x'),'',mres($_POST['address']))."%"; } if (is_numeric($_POST['device_id'])) { @@ -41,6 +49,7 @@ if ($rowCount != -1) { $sql = "SELECT *,`P`.`ifDescr` AS `interface` $sql"; +system("echo '$sql' >> /tmp/test"); foreach (dbFetchRows($sql, $param) as $entry) { if (!$ignore) { @@ -70,7 +79,7 @@ foreach (dbFetchRows($sql, $param) as $entry) { $response[] = array('mac_address'=>formatMac($entry['mac_address']), 'ipv4_address'=>$entry['ipv4_address'], 'hostname'=>generate_device_link($entry), - 'interface'=>generate_port_link($entry, makeshortif(fixifname(ifLabel($entry)['label']))) . ' ' . $error_img, + 'interface'=>generate_port_link($entry, makeshortif(fixifname(ifLabel($entry['label'])))) . ' ' . $error_img, 'remote_device'=>$arp_name, 'remote_interface'=>$arp_if); } From fba1e6933af8e026010a3c320b55102391066920 Mon Sep 17 00:00:00 2001 From: laf Date: Tue, 7 Jul 2015 23:28:00 +0100 Subject: [PATCH 24/71] removed debug --- html/includes/table/arp-search.inc.php | 1 - 1 file changed, 1 deletion(-) diff --git a/html/includes/table/arp-search.inc.php b/html/includes/table/arp-search.inc.php index 937553b42b..dd5c6225ea 100644 --- a/html/includes/table/arp-search.inc.php +++ b/html/includes/table/arp-search.inc.php @@ -49,7 +49,6 @@ if ($rowCount != -1) { $sql = "SELECT *,`P`.`ifDescr` AS `interface` $sql"; -system("echo '$sql' >> /tmp/test"); foreach (dbFetchRows($sql, $param) as $entry) { if (!$ignore) { From 9a43454700d9c38591a056b0403ba13b87aa00ca Mon Sep 17 00:00:00 2001 From: laf Date: Tue, 7 Jul 2015 23:34:56 +0100 Subject: [PATCH 25/71] Fixed mac user perm queries --- html/pages/search/mac.inc.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/html/pages/search/mac.inc.php b/html/pages/search/mac.inc.php index 4306a412d0..c040a1e16a 100644 --- a/html/pages/search/mac.inc.php +++ b/html/pages/search/mac.inc.php @@ -26,7 +26,16 @@ var grid = $("#mac-search").bootgrid({ "'); -$result_options = array('10','50','100','250','500','1000','5000'); -foreach($result_options as $option) { + +echo ' + '); -$rulei=1; -$count_query = "SELECT COUNT(id)"; -$full_query = "SELECT *"; -$sql = ''; -$param = array(); -if(isset($device['device_id']) && $device['device_id'] > 0) { - $sql = 'WHERE (device_id=? OR device_id="-1")'; +echo ''; + +$rulei = 1; +$count_query = 'SELECT COUNT(id)'; +$full_query = 'SELECT *'; +$sql = ''; +$param = array(); +if (isset($device['device_id']) && $device['device_id'] > 0) { + $sql = 'WHERE (device_id=? OR device_id="-1")'; $param = array($device['device_id']); } -$query = " FROM alert_rules $sql ORDER BY device_id,id"; -$count_query = $count_query . $query; -$count = dbFetchCell($count_query,$param); -if(!isset($_POST['page_number']) && $_POST['page_number'] < 1) { + +$query = " FROM alert_rules $sql ORDER BY device_id,id"; +$count_query = $count_query.$query; +$count = dbFetchCell($count_query, $param); +if (!isset($_POST['page_number']) && $_POST['page_number'] < 1) { $page_number = 1; -} else { +} +else { $page_number = $_POST['page_number']; } -$start = ($page_number - 1) * $results; -$full_query = $full_query . $query . " LIMIT $start,$results"; -foreach( dbFetchRows($full_query, $param) as $rule ) { - $sub = dbFetchRows("SELECT * FROM alerts WHERE rule_id = ? ORDER BY id DESC LIMIT 1", array($rule['id'])); - $ico = "ok"; - $col = "success"; - $extra = ""; - if( sizeof($sub) == 1 ) { - $sub = $sub[0]; - if( (int) $sub['state'] === 0 ) { - $ico = "ok"; - $col = "success"; - } elseif( (int) $sub['state'] === 1 ) { - $ico = "remove"; - $col = "danger"; - $extra = "danger"; - } elseif( (int) $sub['state'] === 2 ) { - $ico = "time"; - $col = "default"; - $extra = "warning"; - } - } - $alert_checked = ''; - $orig_ico = $ico; - $orig_col = $col; - $orig_class = $extra; - if( $rule['disabled'] ) { - $ico = "pause"; - $col = ""; - $extra = "active"; - } else { - $alert_checked = 'checked'; +$start = (($page_number - 1) * $results); +$full_query = $full_query.$query." LIMIT $start,$results"; + +foreach (dbFetchRows($full_query, $param) as $rule) { + $sub = dbFetchRows('SELECT * FROM alerts WHERE rule_id = ? ORDER BY id DESC LIMIT 1', array($rule['id'])); + $ico = 'ok'; + $col = 'success'; + $extra = ''; + if (sizeof($sub) == 1) { + $sub = $sub[0]; + if ((int) $sub['state'] === 0) { + $ico = 'ok'; + $col = 'success'; } - $rule_extra = json_decode($rule['extra'],TRUE); - echo ""; - echo "#".((int) $rulei++).""; - echo "".$rule['name'].""; - echo ""; - if($rule_extra['invert'] === true) { - echo "Inverted "; + else if ((int) $sub['state'] === 1) { + $ico = 'remove'; + $col = 'danger'; + $extra = 'danger'; } - echo "".htmlentities($rule['rule']).""; - echo "".$rule['severity'].""; - echo " "; - if($rule_extra['mute'] === true) { - echo ""; + else if ((int) $sub['state'] === 2) { + $ico = 'time'; + $col = 'default'; + $extra = 'warning'; } - echo "Max: ".$rule_extra['count']."
    Delay: ".$rule_extra['delay']."
    Interval: ".$rule_extra['interval']."
    "; - echo ""; - if ($_SESSION['userlevel'] >= '10') { - echo ""; - } - echo ""; - echo ""; - if ($_SESSION['userlevel'] >= '10') { - echo " "; - echo ""; - } - echo ""; - echo "\r\n"; + } + + $alert_checked = ''; + $orig_ico = $ico; + $orig_col = $col; + $orig_class = $extra; + if ($rule['disabled']) { + $ico = 'pause'; + $col = ''; + $extra = 'active'; + } + else { + $alert_checked = 'checked'; + } + + $rule_extra = json_decode($rule['extra'], true); + echo ""; + echo '#'.((int) $rulei++).''; + echo ''.$rule['name'].''; + echo ""; + if ($rule_extra['invert'] === true) { + echo 'Inverted '; + } + + echo ''.htmlentities($rule['rule']).''; + echo ''.$rule['severity'].''; + echo " "; + if ($rule_extra['mute'] === true) { + echo ""; + } + + echo 'Max: '.$rule_extra['count'].'
    Delay: '.$rule_extra['delay'].'
    Interval: '.$rule_extra['interval'].'
    '; + echo ''; + if ($_SESSION['userlevel'] >= '10') { + echo ""; + } + + echo ''; + echo ''; + if ($_SESSION['userlevel'] >= '10') { + echo " "; + echo ""; + } + + echo ''; + echo "\r\n"; +}//end foreach + +if (($count % $results) > 0) { + echo ' + '.generate_pagination($count, $results, $page_number).' + '; } -if($count % $results > 0) { - echo(' - '. generate_pagination($count,$results,$page_number) .' - '); -} echo ' - - - -
    '; + + + + '; -if($count < 1) { +if ($count < 1) { if ($_SESSION['userlevel'] >= '10') { echo '
    -
    -
    -

    - -

    -
    -
    -
    '; +
    +
    +

    + +

    +
    +
    + '; } } @@ -180,19 +258,19 @@ $('#ack-alert').click('', function(e) { var alert_id = $(this).data("alert_id"); $.ajax({ type: "POST", - url: "/ajax_form.php", - data: { type: "ack-alert", alert_id: alert_id }, - success: function(msg){ - $("#message").html('
    '+msg+'
    '); - if(msg.indexOf("ERROR:") <= -1) { - setTimeout(function() { - location.reload(1); - }, 1000); - } - }, - error: function(){ - $("#message").html('
    An error occurred acking this alert.
    '); - } + url: "/ajax_form.php", + data: { type: "ack-alert", alert_id: alert_id }, + success: function(msg){ + $("#message").html('
    '+msg+'
    '); + if(msg.indexOf("ERROR:") <= -1) { + setTimeout(function() { + location.reload(1); + }, 1000); + } + }, + error: function(){ + $("#message").html('
    An error occurred acking this alert.
    '); + } }); }); @@ -206,42 +284,42 @@ $('input[name="alert-rule"]').on('switchChange.bootstrapSwitch', function(event var orig_class = $(this).data("orig_class"); $.ajax({ type: 'POST', - url: '/ajax_form.php', - data: { type: "update-alert-rule", alert_id: alert_id, state: state }, - dataType: "html", - success: function(msg) { - if(msg.indexOf("ERROR:") <= -1) { - if(state) { - $('#alert-rule-'+alert_id).removeClass('glyphicon-pause'); - $('#alert-rule-'+alert_id).addClass('glyphicon-'+orig_state); - $('#alert-rule-'+alert_id).removeClass('text-default'); - $('#alert-rule-'+alert_id).addClass('text-'+orig_colour); - $('#row_'+alert_id).removeClass('active'); - $('#row_'+alert_id).addClass(orig_class); + url: '/ajax_form.php', + data: { type: "update-alert-rule", alert_id: alert_id, state: state }, + dataType: "html", + success: function(msg) { + if(msg.indexOf("ERROR:") <= -1) { + if(state) { + $('#alert-rule-'+alert_id).removeClass('glyphicon-pause'); + $('#alert-rule-'+alert_id).addClass('glyphicon-'+orig_state); + $('#alert-rule-'+alert_id).removeClass('text-default'); + $('#alert-rule-'+alert_id).addClass('text-'+orig_colour); + $('#row_'+alert_id).removeClass('active'); + $('#row_'+alert_id).addClass(orig_class); + } else { + $('#alert-rule-'+alert_id).removeClass('glyphicon-'+orig_state); + $('#alert-rule-'+alert_id).addClass('glyphicon-pause'); + $('#alert-rule-'+alert_id).removeClass('text-'+orig_colour); + $('#alert-rule-'+alert_id).addClass('text-default'); + $('#row_'+alert_id).removeClass('warning'); + $('#row_'+alert_id).addClass('active'); + } } else { - $('#alert-rule-'+alert_id).removeClass('glyphicon-'+orig_state); - $('#alert-rule-'+alert_id).addClass('glyphicon-pause'); - $('#alert-rule-'+alert_id).removeClass('text-'+orig_colour); - $('#alert-rule-'+alert_id).addClass('text-default'); - $('#row_'+alert_id).removeClass('warning'); - $('#row_'+alert_id).addClass('active'); + $("#message").html('
    '+msg+'
    '); + $('#'+alert_id).bootstrapSwitch('toggleState',true ); + } + }, + error: function() { + $("#message").html('
    This alert could not be updated.
    '); + $('#'+alert_id).bootstrapSwitch('toggleState',true ); } - } else { - $("#message").html('
    '+msg+'
    '); - $('#'+alert_id).bootstrapSwitch('toggleState',true ); - } - }, - error: function() { - $("#message").html('
    This alert could not be updated.
    '); - $('#'+alert_id).bootstrapSwitch('toggleState',true ); - } }); }); function updateResults(results) { - $('#results_amount').val(results.value); - $('#page_number').val(1); - $('#result_form').submit(); + $('#results_amount').val(results.value); + $('#page_number').val(1); + $('#result_form').submit(); } function changePage(page,e) { diff --git a/html/includes/print-alert-templates.php b/html/includes/print-alert-templates.php index 16a3afdd08..8ad6e8265d 100644 --- a/html/includes/print-alert-templates.php +++ b/html/includes/print-alert-templates.php @@ -1,6 +1,6 @@ @@ -10,17 +10,17 @@ $no_refresh = TRUE;
    0) { +if (isset($_POST['results_amount']) && $_POST['results_amount'] > 0) { $results = $_POST['results']; -} else { +} +else { $results = 50; } @@ -34,37 +34,49 @@ echo '
    '; if ($_SESSION['userlevel'] >= '10') { - echo(''); + echo ''; } echo ' '); -$count_query = "SELECT COUNT(id)"; -$full_query = "SELECT *"; +echo ''; -$query = " FROM `alert_templates`"; +$count_query = 'SELECT COUNT(id)'; +$full_query = 'SELECT *'; -$count_query = $count_query . $query; -$count = dbFetchCell($count_query,$param); -if(!isset($_POST['page_number']) && $_POST['page_number'] < 1) { +$query = ' FROM `alert_templates`'; + +$count_query = $count_query.$query; +$count = dbFetchCell($count_query, $param); +if (!isset($_POST['page_number']) && $_POST['page_number'] < 1) { $page_number = 1; -} else { +} +else { $page_number = $_POST['page_number']; } -$start = ($page_number - 1) * $results; -$full_query = $full_query . $query . " LIMIT $start,$results"; -foreach( dbFetchRows($full_query, $param) as $template ) { +$start = (($page_number - 1) * $results); +$full_query = $full_query.$query." LIMIT $start,$results"; + +foreach (dbFetchRows($full_query, $param) as $template) { echo ' '.$template['name'].' '; @@ -73,14 +85,15 @@ foreach( dbFetchRows($full_query, $param) as $template ) { echo " "; echo ""; } + echo ' '; } -if($count % $results > 0) { - echo(' - '. generate_pagination($count,$results,$page_number) .' - '); +if (($count % $results) > 0) { + echo ' + '.generate_pagination($count, $results, $page_number).' + '; } echo ' diff --git a/html/includes/print-alerts.inc.php b/html/includes/print-alerts.inc.php index dcbab4b3d9..d9758a0f38 100644 --- a/html/includes/print-alerts.inc.php +++ b/html/includes/print-alerts.inc.php @@ -1,49 +1,49 @@ - - ' . $alert_entry['time_logged'] . ' - '); +echo ' + + '.$alert_entry['time_logged'].' + '; if (!isset($alert_entry['device'])) { - $dev = device_by_id_cache($alert_entry['device_id']); - echo(" - " . generate_device_link($dev, shorthost($dev['hostname'])) . " - "); + $dev = device_by_id_cache($alert_entry['device_id']); + echo ' + '.generate_device_link($dev, shorthost($dev['hostname'])).' + '; } -echo("".htmlspecialchars($alert_entry['name']) . ""); +echo ''.htmlspecialchars($alert_entry['name']).''; -if ($alert_state!='') { - if ($alert_state=='0') { - $glyph_icon = 'ok'; +if ($alert_state != '') { + if ($alert_state == '0') { + $glyph_icon = 'ok'; $glyph_color = 'green'; - $text = 'Ok'; + $text = 'Ok'; } - elseif ($alert_state=='1') { - $glyph_icon = 'remove'; + else if ($alert_state == '1') { + $glyph_icon = 'remove'; $glyph_color = 'red'; - $text = 'Alert'; + $text = 'Alert'; } - elseif ($alert_state=='2') { - $glyph_icon = 'info-sign'; + else if ($alert_state == '2') { + $glyph_icon = 'info-sign'; $glyph_color = 'lightgrey'; - $text = 'Ack'; + $text = 'Ack'; } - elseif ($alert_state=='3') { - $glyph_icon = 'arrow-down'; + else if ($alert_state == '3') { + $glyph_icon = 'arrow-down'; $glyph_color = 'orange'; - $text = 'Worse'; + $text = 'Worse'; } - elseif ($alert_state=='4') { - $glyph_icon = 'arrow-up'; + else if ($alert_state == '4') { + $glyph_icon = 'arrow-up'; $glyph_color = 'khaki'; - $text = 'Better'; - } - echo(" $text"); -} + $text = 'Better'; + }//end if + echo " $text"; +}//end if -echo(""); +echo ''; diff --git a/html/includes/print-debug.php b/html/includes/print-debug.php index f35cd05bfe..7fdbbcc6d9 100644 --- a/html/includes/print-debug.php +++ b/html/includes/print-debug.php @@ -1,6 +1,6 @@ @@ -14,25 +14,23 @@ @@ -52,26 +50,25 @@ foreach ($sql_debug as $sql_error) { @@ -97,10 +95,12 @@ if ($_SESSION['userlevel'] >= '10') { if (is_admin() === TRUE || is_read() === TRUE) { $sql = "SELECT `type`,COUNT(`type`) AS total_type FROM `devices` AS D WHERE 1 GROUP BY `type` ORDER BY `type`"; -} else { +} +else { $sql = "SELECT `type`,COUNT(`type`) AS total_type FROM `devices` AS `D`, `devices_perms` AS `P` WHERE `P`.`user_id` = ? AND `P`.`device_id` = `D`.`device_id` GROUP BY `type` ORDER BY `type`"; $param[] = $_SESSION['user_id']; } + foreach (dbFetchRows($sql,$param) as $devtype) { if (empty($devtype['type'])) { $devtype['type'] = 'generic'; @@ -108,9 +108,10 @@ foreach (dbFetchRows($sql,$param) as $devtype) { echo('
  • ' . ucfirst($devtype['type']) . '
  • '); } -require_once('../includes/device-groups.inc.php'); +require_once '../includes/device-groups.inc.php'; + foreach( GetDeviceGroups() as $group ) { - echo '
  • '.ucfirst($group['name']).'
  • '; + echo '
  • '.ucfirst($group['name']).'
  • '; } unset($group); @@ -118,29 +119,24 @@ unset($group); '); if ($_SESSION['userlevel'] >= '10') { -if ($config['show_locations']) -{ - - echo(' + if ($config['show_locations']) { + echo(' - '); -} - echo(' + '); + } + echo('
  • Manage Groups
  • Add Device
  • @@ -155,8 +151,7 @@ if ($config['show_locations'])
  • Alerts ('.$service_alerts.')
  • '); } -if ($_SESSION['userlevel'] >= '10') -{ - echo(' +if ($_SESSION['userlevel'] >= '10') { + echo('
  • Add Service
  • Edit Service
  • @@ -197,36 +190,53 @@ if ($_SESSION['userlevel'] >= '10') 0) -{ - echo('
  • Errored ('.$ports['errored'].')
  • '); +if ($ports['errored'] > 0) { + echo('
  • Errored ('.$ports['errored'].')
  • '); } -if ($ports['ignored'] > 0) -{ - echo('
  • Ignored ('.$ports['ignored'].')
  • '); +if ($ports['ignored'] > 0) { + echo('
  • Ignored ('.$ports['ignored'].')
  • '); } if ($config['enable_billing']) { - echo('
  • Traffic Bills
  • '); $ifbreak = 1; + echo('
  • Traffic Bills
  • '); + $ifbreak = 1; } if ($config['enable_pseudowires']) { - echo('
  • Pseudowires
  • '); $ifbreak = 1; + echo('
  • Pseudowires
  • '); + $ifbreak = 1; } ?> = '5') -{ - echo(' '); - if ($config['int_customers']) { echo('
  • Customers
  • '); $ifbreak = 1; } - if ($config['int_l2tp']) { echo('
  • L2TP
  • '); $ifbreak = 1; } - if ($config['int_transit']) { echo('
  • Transit
  • '); $ifbreak = 1; } - if ($config['int_peering']) { echo('
  • Peering
  • '); $ifbreak = 1; } - if ($config['int_peering'] && $config['int_transit']) { echo('
  • Peering + Transit
  • '); $ifbreak = 1; } - if ($config['int_core']) { echo('
  • Core
  • '); $ifbreak = 1; } +if ($_SESSION['userlevel'] >= '5') { + echo(' '); + if ($config['int_customers']) { + echo('
  • Customers
  • '); + $ifbreak = 1; + } + if ($config['int_l2tp']) { + echo('
  • L2TP
  • '); + $ifbreak = 1; + } + if ($config['int_transit']) { + echo('
  • Transit
  • '); + $ifbreak = 1; + } + if ($config['int_peering']) { + echo('
  • Peering
  • '); + $ifbreak = 1; + } + if ($config['int_peering'] && $config['int_transit']) { + echo('
  • Peering + Transit
  • '); + $ifbreak = 1; + } + if ($config['int_core']) { + echo('
  • Core
  • '); + $ifbreak = 1; + } if (is_array($config['custom_descr']) === FALSE) { $config['custom_descr'] = array($config['custom_descr']); } @@ -239,21 +249,18 @@ if ($_SESSION['userlevel'] >= '5') } if ($ifbreak) { - echo(' '); + echo(' '); } -if (isset($interface_alerts)) -{ - echo('
  • Alerts ('.$interface_alerts.')
  • '); +if (isset($interface_alerts)) { + echo('
  • Alerts ('.$interface_alerts.')
  • '); } $deleted_ports = 0; -foreach (dbFetchRows("SELECT * FROM `ports` AS P, `devices` as D WHERE P.`deleted` = '1' AND D.device_id = P.device_id") as $interface) -{ - if (port_permitted($interface['port_id'], $interface['device_id'])) - { - $deleted_ports++; - } +foreach (dbFetchRows("SELECT * FROM `ports` AS P, `devices` as D WHERE P.`deleted` = '1' AND D.device_id = P.device_id") as $interface) { + if (port_permitted($interface['port_id'], $interface['device_id'])) { + $deleted_ports++; + } } ?> @@ -261,7 +268,9 @@ foreach (dbFetchRows("SELECT * FROM `ports` AS P, `devices` as D WHERE P.`delete
  • Disabled
  • Deleted ('.$deleted_ports.')'); } +if ($deleted_ports) { + echo('
  • Deleted ('.$deleted_ports.')
  • '); +} ?> @@ -270,9 +279,8 @@ if ($deleted_ports) { echo('
  • Processor
  • Storage
  • '); +if ($menu_sensors) { + $sep = 0; + echo(' '); } $icons = array('fanspeed'=>'tachometer','humidity'=>'tint','temperature'=>'fire','current'=>'bolt','frequency'=>'line-chart','power'=>'power-off','voltage'=>'bolt','charge'=>'plus-square','dbm'=>'sun-o', 'load'=>'spinner','state'=>'bullseye'); -foreach (array('fanspeed','humidity','temperature') as $item) -{ - if (isset($menu_sensors[$item])) - { +foreach (array('fanspeed','humidity','temperature') as $item) { + if (isset($menu_sensors[$item])) { + echo('
  • '.nicecase($item).'
  • '); + unset($menu_sensors[$item]);$sep++; + } +} + +if ($sep && array_keys($menu_sensors)) { + echo(' '); + $sep = 0; +} + +foreach (array('current','frequency','power','voltage') as $item) { + if (isset($menu_sensors[$item])) { + echo('
  • '.nicecase($item).'
  • '); + unset($menu_sensors[$item]);$sep++; + } +} + +if ($sep && array_keys($menu_sensors)) { + echo(' '); + $sep = 0; +} + +foreach (array_keys($menu_sensors) as $item) { echo('
  • '.nicecase($item).'
  • '); unset($menu_sensors[$item]);$sep++; - } -} - -if ($sep && array_keys($menu_sensors)) -{ - echo(' '); - $sep = 0; -} - -foreach (array('current','frequency','power','voltage') as $item) -{ - if (isset($menu_sensors[$item])) - { - echo('
  • '.nicecase($item).'
  • '); - unset($menu_sensors[$item]);$sep++; - } -} - -if ($sep && array_keys($menu_sensors)) -{ - echo(' '); - $sep = 0; -} - -foreach (array_keys($menu_sensors) as $item) -{ - echo('
  • '.nicecase($item).'
  • '); - unset($menu_sensors[$item]);$sep++; } ?> @@ -337,27 +337,24 @@ foreach (array_keys($menu_sensors) as $item) $app_count = dbFetchCell("SELECT COUNT(`app_id`) FROM `applications`"); -if ($_SESSION['userlevel'] >= '5' && ($app_count) > "0") -{ +if ($_SESSION['userlevel'] >= '5' && ($app_count) > "0") { ?> + = '5' && ($routing_count['bgp']+$routing_count['ospf']+$routing_count['cef']+$routing_count['vrf']) > "0") -{ +if ($_SESSION['userlevel'] >= '5' && ($routing_count['bgp']+$routing_count['ospf']+$routing_count['cef']+$routing_count['vrf']) > "0") { ?> @@ -440,16 +427,11 @@ if ( dbFetchCell("SELECT 1 from `packages` LIMIT 1") ) { = '10') -{ - if (dbFetchCell("SELECT COUNT(*) from `plugins` WHERE plugin_active = '1'") > 0) { - echo(' - - '); - } - echo(' -
  • Plugin Admin
  • - '); +if ($_SESSION['userlevel'] >= '10') { + if (dbFetchCell("SELECT COUNT(*) from `plugins` WHERE plugin_active = '1'") > 0) { + echo(''); + } + echo('
  • Plugin Admin
  • '); } ?> @@ -457,9 +439,8 @@ if ($_SESSION['userlevel'] >= '10') @@ -476,50 +457,42 @@ if(is_file("includes/print-menubar-custom.inc.php"))
    -"); \ No newline at end of file +"; diff --git a/html/includes/print-service-edit.inc.php b/html/includes/print-service-edit.inc.php index 0954649d6d..d0ad23a569 100644 --- a/html/includes/print-service-edit.inc.php +++ b/html/includes/print-service-edit.inc.php @@ -1,35 +1,33 @@ Edit Service
    - - + +
    - +
    - +
    - +
    -
    "); - -} \ No newline at end of file +"; +}//end if diff --git a/html/includes/print-syslog.inc.php b/html/includes/print-syslog.inc.php index 09467dd7c4..1a7564920d 100644 --- a/html/includes/print-syslog.inc.php +++ b/html/includes/print-syslog.inc.php @@ -1,23 +1,18 @@ "); +if (device_permitted($entry['device_id'])) { + echo ''; - // Stop shortening hostname. Issue #61 - //$entry['hostname'] = shorthost($entry['hostname'], 20); - - if ($vars['page'] != "device") - { - echo("" . $entry['date'] . ""); - echo("".generate_device_link($entry).""); - echo("" . $entry['program'] . " : " . htmlspecialchars($entry['msg']) . ""); - } else { - echo("" . $entry['date'] . "   " . $entry['program'] . "   " . htmlspecialchars($entry['msg']) . ""); - } - - echo(""); + // Stop shortening hostname. Issue #61 + // $entry['hostname'] = shorthost($entry['hostname'], 20); + if ($vars['page'] != 'device') { + echo ''.$entry['date'].''; + echo ''.generate_device_link($entry).''; + echo ''.$entry['program'].' : '.htmlspecialchars($entry['msg']).''; + } + else { + echo ''.$entry['date'].'   '.$entry['program'].'   '.htmlspecialchars($entry['msg']).''; + } + echo ''; } - -?> diff --git a/html/includes/reports/alert-log.pdf.inc.php b/html/includes/reports/alert-log.pdf.inc.php index 5ee0e91ea1..d293b474b9 100644 --- a/html/includes/reports/alert-log.pdf.inc.php +++ b/html/includes/reports/alert-log.pdf.inc.php @@ -1,65 +1,83 @@ AddPage('L'); +$where = '1'; +if (is_numeric($_GET['device_id'])) { + $where .= ' AND E.device_id = ?'; + $param[] = $_GET['device_id']; +} - $where = "1"; - if (is_numeric($_GET['device_id'])) { - $where .= ' AND E.device_id = ?'; - $param[] = $_GET['device_id']; - } - if ($_GET['string']) { - $where .= " AND R.rule LIKE ?"; - $param[] = "%".$_GET['string']."%"; - } +if ($_GET['string']) { + $where .= ' AND R.rule LIKE ?'; + $param[] = '%'.$_GET['string'].'%'; +} - if ($_SESSION['userlevel'] >= '5') { - $query = " FROM `alert_log` AS E LEFT JOIN devices AS D ON E.device_id=D.device_id RIGHT JOIN alert_rules AS R ON E.rule_id=R.id WHERE $where ORDER BY `humandate` DESC"; - } else { - $query = " FROM `alert_log` AS E LEFT JOIN devices AS D ON E.device_id=D.device_id RIGHT JOIN alert_rules AS R ON E.rule_id=R.id RIGHT JOIN devices_perms AS P ON E.device_id = P.device_id WHERE $where AND P.user_id = ? ORDER BY `humandate` DESC"; - $param[] = $_SESSION['user_id']; - } +if ($_SESSION['userlevel'] >= '5') { + $query = " FROM `alert_log` AS E LEFT JOIN devices AS D ON E.device_id=D.device_id RIGHT JOIN alert_rules AS R ON E.rule_id=R.id WHERE $where ORDER BY `humandate` DESC"; +} +else { + $query = " FROM `alert_log` AS E LEFT JOIN devices AS D ON E.device_id=D.device_id RIGHT JOIN alert_rules AS R ON E.rule_id=R.id RIGHT JOIN devices_perms AS P ON E.device_id = P.device_id WHERE $where AND P.user_id = ? ORDER BY `humandate` DESC"; + $param[] = $_SESSION['user_id']; +} - if (isset($_GET['start']) && is_numeric($_GET['start'])) { - $start = mres($_GET['start']); - } else { - $start = 0; - } +if (isset($_GET['start']) && is_numeric($_GET['start'])) { + $start = mres($_GET['start']); +} +else { + $start = 0; +} - if (isset($_GET['results']) && is_numeric($_GET['results'])) { - $numresults = mres($_GET['results']); - } else { - $numresults = 250; - } +if (isset($_GET['results']) && is_numeric($_GET['results'])) { + $numresults = mres($_GET['results']); +} +else { + $numresults = 250; +} - $full_query = "SELECT D.device_id,name,state,time_logged,DATE_FORMAT(time_logged, '".$config['dateformat']['mysql']['compact']."') as humandate $query LIMIT $start,$numresults"; +$full_query = "SELECT D.device_id,name,state,time_logged,DATE_FORMAT(time_logged, '".$config['dateformat']['mysql']['compact']."') as humandate $query LIMIT $start,$numresults"; - foreach (dbFetchRows($full_query, $param) as $alert_entry) { - $hostname = gethostbyid(mres($alert_entry['device_id'])); - $alert_state = $alert_entry['state']; +foreach (dbFetchRows($full_query, $param) as $alert_entry) { + $hostname = gethostbyid(mres($alert_entry['device_id'])); + $alert_state = $alert_entry['state']; - if ($alert_state!='') { - if ($alert_state=='0') { - $glyph_color = 'green'; - $text = 'Ok'; - } elseif ($alert_state=='1') { - $glyph_color = 'red'; - $text = 'Alert'; - } elseif ($alert_state=='2') { - $glyph_color = 'lightgrey'; - $text = 'Ack'; - } elseif ($alert_state=='3') { - $glyph_color = 'orange'; - $text = 'Worse'; - } elseif ($alert_state=='4') { - $glyph_color = 'khaki'; - $text = 'Better'; - } - $data[] = array($alert_entry['time_logged'],$hostname,htmlspecialchars($alert_entry['name']),$text); + if ($alert_state != '') { + if ($alert_state == '0') { + $glyph_color = 'green'; + $text = 'Ok'; + } + else if ($alert_state == '1') { + $glyph_color = 'red'; + $text = 'Alert'; + } + else if ($alert_state == '2') { + $glyph_color = 'lightgrey'; + $text = 'Ack'; + } + else if ($alert_state == '3') { + $glyph_color = 'orange'; + $text = 'Worse'; + } + else if ($alert_state == '4') { + $glyph_color = 'khaki'; + $text = 'Better'; } - } -$header = array('Datetime', 'Device', 'Log', 'Status'); + $data[] = array( + $alert_entry['time_logged'], + $hostname, + htmlspecialchars($alert_entry['name']), + $text, + ); + }//end if +}//end foreach + +$header = array( + 'Datetime', + 'Device', + 'Log', + 'Status', +); $table = << @@ -74,17 +92,19 @@ EOD; foreach ($data as $log) { if ($log[3] == 'Alert') { $tr_col = '#d39392'; - } else { + } + else { $tr_col = '#bbd392'; } + $table .= ' - + '.$log[0].' '.$log[1].' '.$log[2].' '.$log[3].' - - '; + + '; } $table .= << $value) -{ - if ($value != "") - { - switch ($var) - { - case 'hostname': - $where .= " AND D.hostname LIKE ?"; - $param[] = "%".$value."%"; - break; - case 'location': - $where .= " AND D.location LIKE ?"; - $param[] = "%".$value."%"; - break; - case 'device_id': - $where .= " AND D.device_id = ?"; - $param[] = $value; - break; - case 'deleted': - case 'ignore': - if ($value == 1) - { - $where .= " AND (I.ignore = 1 OR D.ignore = 1) AND I.deleted = 0"; - } - break; - case 'disable': - case 'ifSpeed': - if (is_numeric($value)) - { - $where .= " AND I.$var = ?"; - $param[] = $value; - } - break; - case 'ifType': - $where .= " AND I.$var = ?"; - $param[] = $value; - break; - case 'ifAlias': - case 'port_descr_type': - $where .= " AND I.$var LIKE ?"; - $param[] = "%".$value."%"; - break; - case 'errors': - if ($value == 1) - { - $where .= " AND (I.`ifInErrors_delta` > '0' OR I.`ifOutErrors_delta` > '0')"; - } - break; - case 'state': - if ($value == "down") - { - $where .= "AND I.ifAdminStatus = ? AND I.ifOperStatus = ?"; - $param[] = "up"; - $param[] = "down"; - } elseif($value == "up") { - $where .= "AND I.ifAdminStatus = ? AND I.ifOperStatus = ? AND I.ignore = '0' AND D.ignore='0' AND I.deleted='0'"; - $param[] = "up"; - $param[] = "up"; - } elseif($value == "admindown") { - $where .= "AND I.ifAdminStatus = ? AND D.ignore = 0"; - $param[] = "down"; - } - break; - } - } -} +foreach ($vars as $var => $value) { + if ($value != '') { + switch ($var) { + case 'hostname': + $where .= ' AND D.hostname LIKE ?'; + $param[] = '%'.$value.'%'; + break; -$query = "SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id ".$where." ".$query_sort; + case 'location': + $where .= ' AND D.location LIKE ?'; + $param[] = '%'.$value.'%'; + break; + + case 'device_id': + $where .= ' AND D.device_id = ?'; + $param[] = $value; + break; + + case 'deleted': + case 'ignore': + if ($value == 1) { + $where .= ' AND (I.ignore = 1 OR D.ignore = 1) AND I.deleted = 0'; + } + break; + + case 'disable': + case 'ifSpeed': + if (is_numeric($value)) { + $where .= " AND I.$var = ?"; + $param[] = $value; + } + break; + + case 'ifType': + $where .= " AND I.$var = ?"; + $param[] = $value; + break; + + case 'ifAlias': + case 'port_descr_type': + $where .= " AND I.$var LIKE ?"; + $param[] = '%'.$value.'%'; + break; + + case 'errors': + if ($value == 1) { + $where .= " AND (I.`ifInErrors_delta` > '0' OR I.`ifOutErrors_delta` > '0')"; + } + break; + + case 'state': + if ($value == 'down') { + $where .= 'AND I.ifAdminStatus = ? AND I.ifOperStatus = ?'; + $param[] = 'up'; + $param[] = 'down'; + } + else if ($value == 'up') { + $where .= "AND I.ifAdminStatus = ? AND I.ifOperStatus = ? AND I.ignore = '0' AND D.ignore='0' AND I.deleted='0'"; + $param[] = 'up'; + $param[] = 'up'; + } + else if ($value == 'admindown') { + $where .= 'AND I.ifAdminStatus = ? AND D.ignore = 0'; + $param[] = 'down'; + } + break; + }//end switch + }//end if +}//end foreach + +$query = 'SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id '.$where.' '.$query_sort; $row = 1; -list($format, $subformat) = explode("_", $vars['format']); +list($format, $subformat) = explode('_', $vars['format']); $ports = dbFetchRows($query, $param); -switch ($vars['sort']) -{ - case 'traffic': +switch ($vars['sort']) { +case 'traffic': $ports = array_sort($ports, 'ifOctets_rate', SORT_DESC); break; - case 'traffic_in': + +case 'traffic_in': $ports = array_sort($ports, 'ifInOctets_rate', SORT_DESC); break; - case 'traffic_out': + +case 'traffic_out': $ports = array_sort($ports, 'ifOutOctets_rate', SORT_DESC); break; - case 'packets': + +case 'packets': $ports = array_sort($ports, 'ifUcastPkts_rate', SORT_DESC); break; - case 'packets_in': + +case 'packets_in': $ports = array_sort($ports, 'ifInUcastOctets_rate', SORT_DESC); break; - case 'packets_out': + +case 'packets_out': $ports = array_sort($ports, 'ifOutUcastOctets_rate', SORT_DESC); break; - case 'errors': + +case 'errors': $ports = array_sort($ports, 'ifErrors_rate', SORT_DESC); break; - case 'speed': + +case 'speed': $ports = array_sort($ports, 'ifSpeed', SORT_DESC); break; - case 'port': + +case 'port': $ports = array_sort($ports, 'ifDescr', SORT_ASC); break; - case 'media': + +case 'media': $ports = array_sort($ports, 'ifType', SORT_ASC); break; - case 'descr': + +case 'descr': $ports = array_sort($ports, 'ifAlias', SORT_ASC); break; - case 'device': - default: - $ports = array_sort($ports, 'hostname', SORT_ASC); -} -$csv[] = array('Device','Port','Speed','Down','Up','Media','Description'); -foreach( $ports as $port ) { - if( port_permitted($port['port_id'], $port['device_id']) ) { - $speed = humanspeed($port['ifSpeed']); - $type = humanmedia($port['ifType']); - $port['in_rate'] = formatRates($port['ifInOctets_rate'] * 8); - $port['out_rate'] = formatRates($port['ifOutOctets_rate'] * 8); - $port = ifLabel($port, $device); - $csv[] = array($port['hostname'],fixIfName($port['label']),$speed,$port['in_rate'],$port['out_rate'],$type,$port['ifAlias']); - } +case 'device': +default: + $ports = array_sort($ports, 'hostname', SORT_ASC); +}//end switch + +$csv[] = array( + 'Device', + 'Port', + 'Speed', + 'Down', + 'Up', + 'Media', + 'Description', +); +foreach ($ports as $port) { + if (port_permitted($port['port_id'], $port['device_id'])) { + $speed = humanspeed($port['ifSpeed']); + $type = humanmedia($port['ifType']); + $port['in_rate'] = formatRates(($port['ifInOctets_rate'] * 8)); + $port['out_rate'] = formatRates(($port['ifOutOctets_rate'] * 8)); + $port = ifLabel($port, $device); + $csv[] = array( + $port['hostname'], + fixIfName($port['label']), + $speed, + $port['in_rate'], + $port['out_rate'], + $type, + $port['ifAlias'], + ); + } } -?> diff --git a/html/includes/service-add.inc.php b/html/includes/service-add.inc.php index 3bc9eca630..cf1433b274 100644 --- a/html/includes/service-add.inc.php +++ b/html/includes/service-add.inc.php @@ -5,6 +5,6 @@ $updated = '1'; $service_id = add_service(mres($_POST['device']), mres($_POST['type']), mres($_POST['descr']), mres($_POST['ip']), mres($_POST['params'])); if ($service_id) { - $message .= $message_break . "Service added (".$service_id.")!"; - $message_break .= "
    "; -} \ No newline at end of file + $message .= $message_break.'Service added ('.$service_id.')!'; + $message_break .= '
    '; +} diff --git a/html/includes/table/address-search.inc.php b/html/includes/table/address-search.inc.php index a50d06afc7..25eb75360e 100644 --- a/html/includes/table/address-search.inc.php +++ b/html/includes/table/address-search.inc.php @@ -2,56 +2,64 @@ $param = array(); -if (is_admin() === FALSE && is_read() === FALSE) { - $perms_sql .= " LEFT JOIN `devices_perms` AS `DP` ON `D`.`device_id` = `DP`.`device_id`"; - $where .= " AND `DP`.`user_id`=?"; - $param[] = array($_SESSION['user_id']); +if (is_admin() === false && is_read() === false) { + $perms_sql .= ' LEFT JOIN `devices_perms` AS `DP` ON `D`.`device_id` = `DP`.`device_id`'; + $where .= ' AND `DP`.`user_id`=?'; + $param[] = array($_SESSION['user_id']); } -list($address,$prefix) = explode("/", $_POST['address']); +list($address,$prefix) = explode('/', $_POST['address']); if ($_POST['search_type'] == 'ipv4') { - $sql = " FROM `ipv4_addresses` AS A, `ports` AS I, `ipv4_networks` AS N, `devices` AS D"; + $sql = ' FROM `ipv4_addresses` AS A, `ports` AS I, `ipv4_networks` AS N, `devices` AS D'; $sql .= $perms_sql; $sql .= " WHERE I.port_id = A.port_id AND I.device_id = D.device_id AND N.ipv4_network_id = A.ipv4_network_id $where "; if (!empty($address)) { $sql .= " AND ipv4_address LIKE '%".$address."%'"; } + if (!empty($prefix)) { - $sql .= " AND ipv4_prefixlen='?'"; + $sql .= " AND ipv4_prefixlen='?'"; $param[] = array($prefix); } -} elseif ($_POST['search_type'] == 'ipv6') { - $sql = " FROM `ipv6_addresses` AS A, `ports` AS I, `ipv6_networks` AS N, `devices` AS D"; +} +else if ($_POST['search_type'] == 'ipv6') { + $sql = ' FROM `ipv6_addresses` AS A, `ports` AS I, `ipv6_networks` AS N, `devices` AS D'; $sql .= $perms_sql; $sql .= " WHERE I.port_id = A.port_id AND I.device_id = D.device_id AND N.ipv6_network_id = A.ipv6_network_id $where "; if (!empty($address)) { $sql .= " AND (ipv6_address LIKE '%".$address."%' OR ipv6_compressed LIKE '%".$address."%')"; } + if (!empty($prefix)) { $sql .= " AND ipv6_prefixlen = '$prefix'"; } -} elseif ($_POST['search_type'] == 'mac') { - $sql = " FROM `ports` AS I, `devices` AS D"; - $sql .= $perms_sql; - $sql .= " WHERE I.device_id = D.device_id AND `ifPhysAddress` LIKE '%".str_replace(array(':', ' ', '-', '.', '0x'),'',mres($_POST['address']))."%' $where "; } +else if ($_POST['search_type'] == 'mac') { + $sql = ' FROM `ports` AS I, `devices` AS D'; + $sql .= $perms_sql; + $sql .= " WHERE I.device_id = D.device_id AND `ifPhysAddress` LIKE '%".str_replace(array(':', ' ', '-', '.', '0x'), '', mres($_POST['address']))."%' $where "; +}//end if if (is_numeric($_POST['device_id'])) { - $sql .= " AND I.device_id = ?"; + $sql .= ' AND I.device_id = ?'; $param[] = array($_POST['device_id']); } + if ($_POST['interface']) { - $sql .= " AND I.ifDescr LIKE '?'"; + $sql .= " AND I.ifDescr LIKE '?'"; $param[] = array($_POST['interface']); } if ($_POST['search_type'] == 'ipv4') { $count_sql = "SELECT COUNT(`ipv4_address_id`) $sql"; -} elseif ($_POST['search_type'] == 'ipv6') { - $count_sql = "SELECT COUNT(`ipv6_address_id`) $sql"; -} elseif ($_POST['search_type'] == 'mac') { - $count_sql = "SELECT COUNT(`port_id`) $sql"; } -$total = dbFetchCell($count_sql,$param); +else if ($_POST['search_type'] == 'ipv6') { + $count_sql = "SELECT COUNT(`ipv6_address_id`) $sql"; +} +else if ($_POST['search_type'] == 'mac') { + $count_sql = "SELECT COUNT(`port_id`) $sql"; +} + +$total = dbFetchCell($count_sql, $param); if (empty($total)) { $total = 0; } @@ -63,7 +71,7 @@ if (!isset($sort) || empty($sort)) { $sql .= " ORDER BY $sort"; if (isset($current)) { - $limit_low = ($current * $rowCount) - ($rowCount); + $limit_low = (($current * $rowCount) - ($rowCount)); $limit_high = $rowCount; } @@ -75,31 +83,42 @@ $sql = "SELECT *,`I`.`ifDescr` AS `interface` $sql"; foreach (dbFetchRows($sql, $param) as $interface) { $speed = humanspeed($interface['ifSpeed']); - $type = humanmedia($interface['ifType']); + $type = humanmedia($interface['ifType']); if ($_POST['search_type'] == 'ipv6') { - list($prefix, $length) = explode("/", $interface['ipv6_network']); - $address = Net_IPv6::compress($interface['ipv6_address']) . '/'.$length; - } elseif ($_POST['search_type'] == 'mac') { + list($prefix, $length) = explode('/', $interface['ipv6_network']); + $address = Net_IPv6::compress($interface['ipv6_address']).'/'.$length; + } + else if ($_POST['search_type'] == 'mac') { $address = formatMac($interface['ifPhysAddress']); - } else { - list($prefix, $length) = explode("/", $interface['ipv4_network']); - $address = $interface['ipv4_address'] . '/' .$length; + } + else { + list($prefix, $length) = explode('/', $interface['ipv4_network']); + $address = $interface['ipv4_address'].'/'.$length; } if ($interface['in_errors'] > 0 || $interface['out_errors'] > 0) { - $error_img = generate_port_link($interface,"Interface Errors",errors); - } else { - $error_img = ""; + $error_img = generate_port_link($interface, "Interface Errors", errors); } - if (port_permitted($interface['port_id'])) { - $interface = ifLabel ($interface, $interface); - $response[] = array('hostname'=>generate_device_link($interface), - 'interface'=>generate_port_link($interface) . ' ' . $error_img, - 'address'=>$address, - 'description'=>$interface['ifAlias']); + else { + $error_img = ''; } -} -$output = array('current'=>$current,'rowCount'=>$rowCount,'rows'=>$response,'total'=>$total); + if (port_permitted($interface['port_id'])) { + $interface = ifLabel($interface, $interface); + $response[] = array( + 'hostname' => generate_device_link($interface), + 'interface' => generate_port_link($interface).' '.$error_img, + 'address' => $address, + 'description' => $interface['ifAlias'], + ); + } +}//end foreach + +$output = array( + 'current' => $current, + 'rowCount' => $rowCount, + 'rows' => $response, + 'total' => $total, +); echo _json_encode($output); diff --git a/html/includes/table/alert-schedule.inc.php b/html/includes/table/alert-schedule.inc.php index 635e67be92..5d2bfa9b89 100644 --- a/html/includes/table/alert-schedule.inc.php +++ b/html/includes/table/alert-schedule.inc.php @@ -16,8 +16,9 @@ $where = 1; if ($_SESSION['userlevel'] >= '5') { $sql = " FROM `alert_schedule` AS S WHERE $where"; -} else { - $sql = " FROM `alert_schedule` AS S WHERE $where"; +} +else { + $sql = " FROM `alert_schedule` AS S WHERE $where"; $param[] = $_SESSION['user_id']; } @@ -26,7 +27,7 @@ if (isset($searchPhrase) && !empty($searchPhrase)) { } $count_sql = "SELECT COUNT(`id`) $sql"; -$total = dbFetchCell($count_sql,$param); +$total = dbFetchCell($count_sql, $param); if (empty($total)) { $total = 0; } @@ -38,7 +39,7 @@ if (!isset($sort) || empty($sort)) { $sql .= " ORDER BY $sort"; if (isset($current)) { - $limit_low = ($current * $rowCount) - ($rowCount); + $limit_low = (($current * $rowCount) - ($rowCount)); $limit_high = $rowCount; } @@ -48,20 +49,29 @@ if ($rowCount != -1) { $sql = "SELECT `S`.`schedule_id`, DATE_FORMAT(`S`.`start`, '".$config['dateformat']['mysql']['compact']."') AS `start`, DATE_FORMAT(`S`.`end`, '".$config['dateformat']['mysql']['compact']."') AS `end`, `S`.`title` $sql"; -foreach (dbFetchRows($sql,$param) as $schedule) { +foreach (dbFetchRows($sql, $param) as $schedule) { $status = 0; if ($schedule['end'] < date('dS M Y H:i::s')) { $status = 1; } + if (date('dS M Y H:i::s') >= $schedule['start'] && date('dS M Y H:i::s') < $schedule['end']) { $status = 2; } - $response[] = array('title'=>$schedule['title'], - 'start'=>$schedule['start'], - 'end'=>$schedule['end'], - 'id'=>$schedule['schedule_id'], - 'status'=>$status); + + $response[] = array( + 'title' => $schedule['title'], + 'start' => $schedule['start'], + 'end' => $schedule['end'], + 'id' => $schedule['schedule_id'], + 'status' => $status, + ); } -$output = array('current'=>$current,'rowCount'=>$rowCount,'rows'=>$response,'total'=>$total); +$output = array( + 'current' => $current, + 'rowCount' => $rowCount, + 'rows' => $response, + 'total' => $total, +); echo _json_encode($output); diff --git a/html/includes/table/alertlog.inc.php b/html/includes/table/alertlog.inc.php index 0c8e515e62..8b4d94d3e2 100644 --- a/html/includes/table/alertlog.inc.php +++ b/html/includes/table/alertlog.inc.php @@ -3,14 +3,15 @@ $where = 1; if (is_numeric($_POST['device_id'])) { - $where .= ' AND E.device_id = ?'; + $where .= ' AND E.device_id = ?'; $param[] = $_POST['device_id']; } if ($_SESSION['userlevel'] >= '5') { $sql = " FROM `alert_log` AS E LEFT JOIN devices AS D ON E.device_id=D.device_id RIGHT JOIN alert_rules AS R ON E.rule_id=R.id WHERE $where"; -} else { - $sql = " FROM `alert_log` AS E LEFT JOIN devices AS D ON E.device_id=D.device_id RIGHT JOIN alert_rules AS R ON E.rule_id=R.id RIGHT JOIN devices_perms AS P ON E.device_id = P.device_id WHERE $where AND P.user_id = ?"; +} +else { + $sql = " FROM `alert_log` AS E LEFT JOIN devices AS D ON E.device_id=D.device_id RIGHT JOIN alert_rules AS R ON E.rule_id=R.id RIGHT JOIN devices_perms AS P ON E.device_id = P.device_id WHERE $where AND P.user_id = ?"; $param[] = array($_SESSION['user_id']); } @@ -19,7 +20,7 @@ if (isset($searchPhrase) && !empty($searchPhrase)) { } $count_sql = "SELECT COUNT(`E`.`id`) $sql"; -$total = dbFetchCell($count_sql,$param); +$total = dbFetchCell($count_sql, $param); if (empty($total)) { $total = 0; } @@ -31,7 +32,7 @@ if (!isset($sort) || empty($sort)) { $sql .= " ORDER BY $sort"; if (isset($current)) { - $limit_low = ($current * $rowCount) - ($rowCount); + $limit_low = (($current * $rowCount) - ($rowCount)); $limit_high = $rowCount; } @@ -42,42 +43,49 @@ if ($rowCount != -1) { $sql = "SELECT D.device_id,name AS alert,state,time_logged,DATE_FORMAT(time_logged, '".$config['dateformat']['mysql']['compact']."') as humandate,details $sql"; $rulei = 0; -foreach (dbFetchRows($sql,$param) as $alertlog) { - $dev = device_by_id_cache($alertlog['device_id']); +foreach (dbFetchRows($sql, $param) as $alertlog) { + $dev = device_by_id_cache($alertlog['device_id']); $fault_detail = alert_details($alertlog['details']); - $alert_state = $alertlog['state']; - if ($alert_state=='0') { - $glyph_icon = 'ok'; + $alert_state = $alertlog['state']; + if ($alert_state == '0') { + $glyph_icon = 'ok'; $glyph_color = 'green'; - $text = 'Ok'; + $text = 'Ok'; } - elseif ($alert_state=='1') { - $glyph_icon = 'remove'; + else if ($alert_state == '1') { + $glyph_icon = 'remove'; $glyph_color = 'red'; - $text = 'Alert'; + $text = 'Alert'; } - elseif ($alert_state=='2') { - $glyph_icon = 'info-sign'; + else if ($alert_state == '2') { + $glyph_icon = 'info-sign'; $glyph_color = 'lightgrey'; - $text = 'Ack'; + $text = 'Ack'; } - elseif ($alert_state=='3') { - $glyph_icon = 'arrow-down'; + else if ($alert_state == '3') { + $glyph_icon = 'arrow-down'; $glyph_color = 'orange'; - $text = 'Worse'; + $text = 'Worse'; } - elseif ($alert_state=='4') { - $glyph_icon = 'arrow-up'; + else if ($alert_state == '4') { + $glyph_icon = 'arrow-up'; $glyph_color = 'khaki'; - $text = 'Better'; - } - $response[] = array('id'=>$rulei++, - 'time_logged'=>$alertlog['humandate'], - 'details'=>'', - 'hostname'=>'
    '.generate_device_link($dev, shorthost($dev['hostname'])).'
    '.$fault_detail.'
    ', - 'alert'=>htmlspecialchars($alertlog['alert']), - 'status'=>" $text"); -} + $text = 'Better'; + }//end if + $response[] = array( + 'id' => $rulei++, + 'time_logged' => $alertlog['humandate'], + 'details' => '', + 'hostname' => '
    '.generate_device_link($dev, shorthost($dev['hostname'])).'
    '.$fault_detail.'
    ', + 'alert' => htmlspecialchars($alertlog['alert']), + 'status' => " $text", + ); +}//end foreach -$output = array('current'=>$current,'rowCount'=>$rowCount,'rows'=>$response,'total'=>$total); -echo _json_encode($output); +$output = array( + 'current' => $current, + 'rowCount' => $rowCount, + 'rows' => $response, + 'total' => $total, +); +echo _json_encode($output); diff --git a/html/includes/table/alerts.inc.php b/html/includes/table/alerts.inc.php index 799404b1a4..2efab5d1f1 100644 --- a/html/includes/table/alerts.inc.php +++ b/html/includes/table/alerts.inc.php @@ -10,18 +10,18 @@ if (isset($searchPhrase) && !empty($searchPhrase)) { $sql_search .= " AND (`timestamp` LIKE '%$searchPhrase%' OR `rule` LIKE '%$searchPhrase%' OR `name` LIKE '%$searchPhrase%' OR `hostname` LIKE '%$searchPhrase%')"; } -$sql = " FROM `alerts` LEFT JOIN `devices` ON `alerts`.`device_id`=`devices`.`device_id`"; +$sql = ' FROM `alerts` LEFT JOIN `devices` ON `alerts`.`device_id`=`devices`.`device_id`'; -if (is_admin() === FALSE && is_read() === FALSE) { - $sql .= " LEFT JOIN `devices_perms` AS `DP` ON `devices`.`device_id` = `DP`.`device_id`"; - $where .= " AND `DP`.`user_id`=?"; +if (is_admin() === false && is_read() === false) { + $sql .= ' LEFT JOIN `devices_perms` AS `DP` ON `devices`.`device_id` = `DP`.`device_id`'; + $where .= ' AND `DP`.`user_id`=?'; $param[] = $_SESSION['user_id']; } $sql .= " RIGHT JOIN alert_rules ON alerts.rule_id=alert_rules.id WHERE $where AND `state` IN (1,2,3,4) $sql_search"; $count_sql = "SELECT COUNT(`alerts`.`id`) $sql"; -$total = dbFetchCell($count_sql,$param); +$total = dbFetchCell($count_sql, $param); if (empty($total)) { $total = 0; } @@ -33,7 +33,7 @@ if (!isset($sort) || empty($sort)) { $sql .= " ORDER BY $sort"; if (isset($current)) { - $limit_low = ($current * $rowCount) - ($rowCount); + $limit_low = (($current * $rowCount) - ($rowCount)); $limit_high = $rowCount; } @@ -43,76 +43,86 @@ if ($rowCount != -1) { $sql = "SELECT `alerts`.*, `devices`.`hostname` AS `hostname`,`alert_rules`.`rule` AS `rule`, `alert_rules`.`name` AS `name`, `alert_rules`.`severity` AS `severity` $sql"; -$rulei = 0; +$rulei = 0; $format = $_POST['format']; -foreach (dbFetchRows($sql,$param) as $alert) { - $log = dbFetchCell("SELECT details FROM alert_log WHERE rule_id = ? AND device_id = ? ORDER BY id DESC LIMIT 1", array($alert['rule_id'],$alert['device_id'])); +foreach (dbFetchRows($sql, $param) as $alert) { + $log = dbFetchCell('SELECT details FROM alert_log WHERE rule_id = ? AND device_id = ? ORDER BY id DESC LIMIT 1', array($alert['rule_id'], $alert['device_id'])); $fault_detail = alert_details($log); - $ico = "ok"; - $col = "green"; - $extra = ""; - $msg = ""; - if ( (int) $alert['state'] === 0 ) { - $ico = "ok"; - $col = "green"; - $extra = "success"; - $msg = "ok"; - } elseif ( (int) $alert['state'] === 1 || (int) $alert['state'] === 3 || (int) $alert['state'] === 4) { - $ico = "volume-up"; - $col = "red"; - $extra = "danger"; - $msg = "alert"; - if ( (int) $alert['state'] === 3) { - $msg = "worse"; - } elseif ( (int) $alert['state'] === 4) { - $msg = "better"; - } - } elseif ( (int) $alert['state'] === 2) { - $ico = "volume-off"; - $col = "#800080"; - $extra = "warning"; - $msg = "muted"; + $ico = 'ok'; + $col = 'green'; + $extra = ''; + $msg = ''; + if ((int) $alert['state'] === 0) { + $ico = 'ok'; + $col = 'green'; + $extra = 'success'; + $msg = 'ok'; } + else if ((int) $alert['state'] === 1 || (int) $alert['state'] === 3 || (int) $alert['state'] === 4) { + $ico = 'volume-up'; + $col = 'red'; + $extra = 'danger'; + $msg = 'alert'; + if ((int) $alert['state'] === 3) { + $msg = 'worse'; + } + else if ((int) $alert['state'] === 4) { + $msg = 'better'; + } + } + else if ((int) $alert['state'] === 2) { + $ico = 'volume-off'; + $col = '#800080'; + $extra = 'warning'; + $msg = 'muted'; + }//end if $alert_checked = ''; - $orig_ico = $ico; - $orig_col = $col; - $orig_class = $extra; + $orig_ico = $ico; + $orig_col = $col; + $orig_class = $extra; $severity = $alert['severity']; if ($alert['state'] == 3) { - $severity .= " +"; - } elseif ($alert['state'] == 4) { - $severity .= " -"; + $severity .= ' +'; + } + else if ($alert['state'] == 4) { + $severity .= ' -'; } $ack_ico = 'volume-up'; $ack_col = 'success'; - if($alert['state'] == 2) { + if ($alert['state'] == 2) { $ack_ico = 'volume-off'; $ack_col = 'danger'; - } + } $hostname = ' -
    - '.generate_device_link($alert).' -
    '.$fault_detail.'
    -
    '; +
    + '.generate_device_link($alert).' +
    '.$fault_detail.'
    +
    '; - $response[] = array('id'=>$rulei++, - 'rule'=>"".htmlentities($alert['name'])."", - 'details'=>'', - 'hostname'=>$hostname, - 'timestamp'=>($alert['timestamp'] ? $alert['timestamp'] : "N/A"), - 'severity'=>$severity, - 'ack_col'=>$ack_col, - 'state'=>$alert['state'], - 'alert_id'=>$alert['id'], - 'ack_ico'=>$ack_ico, - 'extra'=>$extra, - 'msg'=>$msg); + $response[] = array( + 'id' => $rulei++, + 'rule' => ''.htmlentities($alert['name']).'', + 'details' => '', + 'hostname' => $hostname, + 'timestamp' => ($alert['timestamp'] ? $alert['timestamp'] : 'N/A'), + 'severity' => $severity, + 'ack_col' => $ack_col, + 'state' => $alert['state'], + 'alert_id' => $alert['id'], + 'ack_ico' => $ack_ico, + 'extra' => $extra, + 'msg' => $msg, + ); +}//end foreach -} - -$output = array('current'=>$current,'rowCount'=>$rowCount,'rows'=>$response,'total'=>$total); +$output = array( + 'current' => $current, + 'rowCount' => $rowCount, + 'rows' => $response, + 'total' => $total, +); echo _json_encode($output); diff --git a/html/includes/table/arp-search.inc.php b/html/includes/table/arp-search.inc.php index dd5c6225ea..090476048f 100644 --- a/html/includes/table/arp-search.inc.php +++ b/html/includes/table/arp-search.inc.php @@ -2,32 +2,33 @@ $param = array(); -$sql .= " FROM `ipv4_mac` AS M, `ports` AS P, `devices` AS D "; +$sql .= ' FROM `ipv4_mac` AS M, `ports` AS P, `devices` AS D '; -if (is_admin() === FALSE && is_read() === FALSE) { - $sql .= " LEFT JOIN `devices_perms` AS `DP` ON `D`.`device_id` = `DP`.`device_id`"; - $where .= " AND `DP`.`user_id`=?"; +if (is_admin() === false && is_read() === false) { + $sql .= ' LEFT JOIN `devices_perms` AS `DP` ON `D`.`device_id` = `DP`.`device_id`'; + $where .= ' AND `DP`.`user_id`=?'; $param[] = $_SESSION['user_id']; } $sql .= " WHERE M.port_id = P.port_id AND P.device_id = D.device_id $where "; -if (isset($_POST['searchby']) && $_POST['searchby'] == "ip") { - $sql .= " AND `ipv4_address` LIKE ?"; - $param[] = "%".trim($_POST['address'])."%"; -} elseif (isset($_POST['searchby']) && $_POST['searchby'] == "mac") { - $sql .= " AND `mac_address` LIKE ?"; - $param[] = "%".str_replace(array(':', ' ', '-', '.', '0x'),'',mres($_POST['address']))."%"; +if (isset($_POST['searchby']) && $_POST['searchby'] == 'ip') { + $sql .= ' AND `ipv4_address` LIKE ?'; + $param[] = '%'.trim($_POST['address']).'%'; +} +else if (isset($_POST['searchby']) && $_POST['searchby'] == 'mac') { + $sql .= ' AND `mac_address` LIKE ?'; + $param[] = '%'.str_replace(array(':', ' ', '-', '.', '0x'), '', mres($_POST['address'])).'%'; } if (is_numeric($_POST['device_id'])) { - $sql .= " AND P.device_id = ?"; + $sql .= ' AND P.device_id = ?'; $param[] = $_POST['device_id']; } $count_sql = "SELECT COUNT(`M`.`port_id`) $sql"; -$total = dbFetchCell($count_sql,$param); +$total = dbFetchCell($count_sql, $param); if (empty($total)) { $total = 0; } @@ -39,7 +40,7 @@ if (!isset($sort) || empty($sort)) { $sql .= " ORDER BY $sort"; if (isset($current)) { - $limit_low = ($current * $rowCount) - ($rowCount); + $limit_low = (($current * $rowCount) - ($rowCount)); $limit_high = $rowCount; } @@ -51,39 +52,53 @@ $sql = "SELECT *,`P`.`ifDescr` AS `interface` $sql"; foreach (dbFetchRows($sql, $param) as $entry) { if (!$ignore) { - if ($entry['ifInErrors'] > 0 || $entry['ifOutErrors'] > 0) { - $error_img = generate_port_link($entry,"Interface Errors",port_errors); - } else { - $error_img = ""; + $error_img = generate_port_link($entry, "Interface Errors", port_errors); + } + else { + $error_img = ''; } - $arp_host = dbFetchRow("SELECT * FROM ipv4_addresses AS A, ports AS I, devices AS D WHERE A.ipv4_address = ? AND I.port_id = A.port_id AND D.device_id = I.device_id", array($entry['ipv4_address'])); - if ($arp_host) { - $arp_name = generate_device_link($arp_host); - } else { - unset($arp_name); - } - if ($arp_host) { - $arp_if = generate_port_link($arp_host); - } else { - unset($arp_if); - } - if ($arp_host['device_id'] == $entry['device_id']) { - $arp_name = "Localhost"; - } - if ($arp_host['port_id'] == $entry['port_id']) { - $arp_if = "Local port"; - } - $response[] = array('mac_address'=>formatMac($entry['mac_address']), - 'ipv4_address'=>$entry['ipv4_address'], - 'hostname'=>generate_device_link($entry), - 'interface'=>generate_port_link($entry, makeshortif(fixifname(ifLabel($entry['label'])))) . ' ' . $error_img, - 'remote_device'=>$arp_name, - 'remote_interface'=>$arp_if); - } - unset($ignore); -} + $arp_host = dbFetchRow('SELECT * FROM ipv4_addresses AS A, ports AS I, devices AS D WHERE A.ipv4_address = ? AND I.port_id = A.port_id AND D.device_id = I.device_id', array($entry['ipv4_address'])); + if ($arp_host) { + $arp_name = generate_device_link($arp_host); + } + else { + unset($arp_name); + } -$output = array('current'=>$current,'rowCount'=>$rowCount,'rows'=>$response,'total'=>$total); + if ($arp_host) { + $arp_if = generate_port_link($arp_host); + } + else { + unset($arp_if); + } + + if ($arp_host['device_id'] == $entry['device_id']) { + $arp_name = 'Localhost'; + } + + if ($arp_host['port_id'] == $entry['port_id']) { + $arp_if = 'Local port'; + } + + $response[] = array( + 'mac_address' => formatMac($entry['mac_address']), + 'ipv4_address' => $entry['ipv4_address'], + 'hostname' => generate_device_link($entry), + 'interface' => generate_port_link($entry, makeshortif(fixifname(ifLabel($entry['label'])))).' '.$error_img, + 'remote_device' => $arp_name, + 'remote_interface' => $arp_if, + ); + }//end if + + unset($ignore); +}//end foreach + +$output = array( + 'current' => $current, + 'rowCount' => $rowCount, + 'rows' => $response, + 'total' => $total, +); echo _json_encode($output); diff --git a/html/includes/table/devices.inc.php b/html/includes/table/devices.inc.php index 25cf21bd51..129e198f21 100644 --- a/html/includes/table/devices.inc.php +++ b/html/includes/table/devices.inc.php @@ -3,11 +3,11 @@ $where = 1; $param = array(); -$sql = " FROM `devices`"; +$sql = ' FROM `devices`'; -if (is_admin() === FALSE && is_read() === FALSE) { - $sql .= " LEFT JOIN `devices_perms` AS `DP` ON `devices`.`device_id` = `DP`.`device_id`"; - $where .= " AND `DP`.`user_id`=?"; +if (is_admin() === false && is_read() === false) { + $sql .= ' LEFT JOIN `devices_perms` AS `DP` ON `devices`.`device_id` = `DP`.`device_id`'; + $where .= ' AND `DP`.`user_id`=?'; $param[] = $_SESSION['user_id']; } @@ -17,48 +17,87 @@ if (!empty($_POST['location'])) { $sql .= " WHERE $where "; -if (!empty($_POST['hostname'])) { $sql .= " AND hostname LIKE ?"; $param[] = "%".$_POST['hostname']."%"; } -if (!empty($_POST['os'])) { $sql .= " AND os = ?"; $param[] = $_POST['os']; } -if (!empty($_POST['version'])) { $sql .= " AND version = ?"; $param[] = $_POST['version']; } -if (!empty($_POST['hardware'])) { $sql .= " AND hardware = ?"; $param[] = $_POST['hardware']; } -if (!empty($_POST['features'])) { $sql .= " AND features = ?"; $param[] = $_POST['features']; } -if (!empty($_POST['type'])) { - if ($_POST['type'] == 'generic') { - $sql .= " AND ( type = ? OR type = '')"; $param[] = $_POST['type']; - } else { - $sql .= " AND type = ?"; $param[] = $_POST['type']; - } +if (!empty($_POST['hostname'])) { + $sql .= ' AND hostname LIKE ?'; + $param[] = '%'.$_POST['hostname'].'%'; } -if (!empty($_POST['state'])) { - $sql .= " AND status= ?"; - if( is_numeric($_POST['state']) ) { - $param[] = $_POST['state']; - } else { - $param[] = str_replace(array('up','down'),array(1,0),$_POST['state']); + +if (!empty($_POST['os'])) { + $sql .= ' AND os = ?'; + $param[] = $_POST['os']; +} + +if (!empty($_POST['version'])) { + $sql .= ' AND version = ?'; + $param[] = $_POST['version']; +} + +if (!empty($_POST['hardware'])) { + $sql .= ' AND hardware = ?'; + $param[] = $_POST['hardware']; +} + +if (!empty($_POST['features'])) { + $sql .= ' AND features = ?'; + $param[] = $_POST['features']; +} + +if (!empty($_POST['type'])) { + if ($_POST['type'] == 'generic') { + $sql .= " AND ( type = ? OR type = '')"; + $param[] = $_POST['type']; + } + else { + $sql .= ' AND type = ?'; + $param[] = $_POST['type']; } } -if (!empty($_POST['disabled'])) { $sql .= " AND disabled= ?"; $param[] = $_POST['disabled']; } -if (!empty($_POST['ignore'])) { $sql .= " AND `ignore`= ?"; $param[] = $_POST['ignore']; } -if (!empty($_POST['location']) && $_POST['location'] == "Unset") { $location_filter = ''; } + +if (!empty($_POST['state'])) { + $sql .= ' AND status= ?'; + if (is_numeric($_POST['state'])) { + $param[] = $_POST['state']; + } + else { + $param[] = str_replace(array('up', 'down'), array(1, 0), $_POST['state']); + } +} + +if (!empty($_POST['disabled'])) { + $sql .= ' AND disabled= ?'; + $param[] = $_POST['disabled']; +} + +if (!empty($_POST['ignore'])) { + $sql .= ' AND `ignore`= ?'; + $param[] = $_POST['ignore']; +} + +if (!empty($_POST['location']) && $_POST['location'] == 'Unset') { + $location_filter = ''; +} + if (!empty($_POST['location'])) { - $sql .= " AND (((`DB`.`attrib_value`='1' AND `DA`.`attrib_type`='override_sysLocation_string' AND `DA`.`attrib_value` = ?)) OR `location` = ?)"; + $sql .= " AND (((`DB`.`attrib_value`='1' AND `DA`.`attrib_type`='override_sysLocation_string' AND `DA`.`attrib_value` = ?)) OR `location` = ?)"; $param[] = mres($_POST['location']); $param[] = mres($_POST['location']); } -if( !empty($_POST['group']) ) { - require_once('../includes/device-groups.inc.php'); - $sql .= " AND ( "; - foreach( GetDevicesFromGroup($_POST['group']) as $dev ) { - $sql .= "`devices`.`device_id` = ? OR "; + +if (!empty($_POST['group'])) { + include_once '../includes/device-groups.inc.php'; + $sql .= ' AND ( '; + foreach (GetDevicesFromGroup($_POST['group']) as $dev) { + $sql .= '`devices`.`device_id` = ? OR '; $param[] = $dev['device_id']; } - $sql = substr($sql, 0, strlen($sql)-3); - $sql .= " )"; + + $sql = substr($sql, 0, (strlen($sql) - 3)); + $sql .= ' )'; } $count_sql = "SELECT COUNT(`devices`.`device_id`) $sql"; -$total = dbFetchCell($count_sql,$param); +$total = dbFetchCell($count_sql, $param); if (empty($total)) { $total = 0; } @@ -70,7 +109,7 @@ if (!isset($sort) || empty($sort)) { $sql .= " ORDER BY $sort"; if (isset($current)) { - $limit_low = ($current * $rowCount) - ($rowCount); + $limit_low = (($current * $rowCount) - ($rowCount)); $limit_high = $rowCount; } @@ -81,99 +120,124 @@ if ($rowCount != -1) { $sql = "SELECT DISTINCT(`devices`.`device_id`),`devices`.* $sql"; if (!isset($_POST['format'])) { - $_POST['format'] = "list_detail"; + $_POST['format'] = 'list_detail'; } -list($format, $subformat) = explode("_", $_POST['format']); + +list($format, $subformat) = explode('_', $_POST['format']); foreach (dbFetchRows($sql, $param) as $device) { - if (isset($bg) && $bg == $list_colour_b) { - $bg = $list_colour_a; - } else { - $bg = $list_colour_b; - } + if (isset($bg) && $bg == $list_colour_b) { + $bg = $list_colour_a; + } + else { + $bg = $list_colour_b; + } - if ($device['status'] == '0') { - $extra = "danger"; - $msg = $device['status_reason']; - } else { - $extra = "success"; - $msg = "up"; - } - if ($device['ignore'] == '1') { - $extra = "default"; - $msg = "ignored"; - if ($device['status'] == '1') { - $extra = "warning"; - $msg = "ignored"; - } - } - if ($device['disabled'] == '1') { - $extra = "default"; - $msg = "disabled"; - } + if ($device['status'] == '0') { + $extra = 'danger'; + $msg = $device['status_reason']; + } + else { + $extra = 'success'; + $msg = 'up'; + } - $type = strtolower($device['os']); - $image = getImage($device); - - if ($device['os'] == "ios") { - formatCiscoHardware($device, true); - } + if ($device['ignore'] == '1') { + $extra = 'default'; + $msg = 'ignored'; + if ($device['status'] == '1') { + $extra = 'warning'; + $msg = 'ignored'; + } + } - $device['os_text'] = $config['os'][$device['os']]['text']; - $port_count = dbFetchCell("SELECT COUNT(*) FROM `ports` WHERE `device_id` = ?", array($device['device_id'])); - $sensor_count = dbFetchCell("SELECT COUNT(*) FROM `sensors` WHERE `device_id` = ?", array($device['device_id'])); + if ($device['disabled'] == '1') { + $extra = 'default'; + $msg = 'disabled'; + } - if (get_dev_attrib($device,'override_sysLocation_bool')) { - $device['location'] = get_dev_attrib($device,'override_sysLocation_string'); - } + $type = strtolower($device['os']); + $image = getImage($device); - $actions = ('
    -
    '); - $actions .= ' View device '; - $actions .= ('
    -
    '); - $actions .= ' View alerts '; - $actions .= '
    '; - if ($_SESSION['userlevel'] >= "7") { - $actions .= ('
    - Edit device -
    '); - } - $actions .= ('
    -
    -
    - telnet -
    -
    - ssh -
    -
    - https -
    -
    '); + if ($device['os'] == 'ios') { + formatCiscoHardware($device, true); + } - $hostname = generate_device_link($device); - $platform = $device['hardware'] . '
    ' . $device['features']; - $os = $device['os_text'] . '
    ' . $device['version']; - if (extension_loaded('mbstring')) { - $location = mb_substr($device['location'], 0, 32, 'utf8'); - } else { - $location = truncate($device['location'], 32, ''); - } - $uptime = formatUptime($device['uptime'], 'short') . '
    ' . $location; - if ($subformat == "detail") { - $hostname .= '
    ' . $device['sysName']; - if ($port_count) { - $col_port = ' '.$port_count . '
    '; - } - if ($sensor_count) { - $col_port .= ' '.$sensor_count; - } - } else { + $device['os_text'] = $config['os'][$device['os']]['text']; + $port_count = dbFetchCell('SELECT COUNT(*) FROM `ports` WHERE `device_id` = ?', array($device['device_id'])); + $sensor_count = dbFetchCell('SELECT COUNT(*) FROM `sensors` WHERE `device_id` = ?', array($device['device_id'])); - } - $response[] = array('extra'=>$extra,'msg'=>$msg,'icon'=>$image,'hostname'=>$hostname,'ports'=>$col_port,'hardware'=>$platform,'os'=>$os,'uptime'=>$uptime,'actions'=>$actions); -} + if (get_dev_attrib($device, 'override_sysLocation_bool')) { + $device['location'] = get_dev_attrib($device, 'override_sysLocation_string'); + } -$output = array('current'=>$current,'rowCount'=>$rowCount,'rows'=>$response,'total'=>$total); + $actions = ('
    +
    '); + $actions .= ' View device '; + $actions .= ('
    +
    '); + $actions .= ' View alerts '; + $actions .= '
    '; + if ($_SESSION['userlevel'] >= '7') { + $actions .= ('
    + Edit device +
    '); + } + + $actions .= ('
    +
    +
    + telnet +
    +
    + ssh +
    +
    + https +
    +
    '); + + $hostname = generate_device_link($device); + $platform = $device['hardware'].'
    '.$device['features']; + $os = $device['os_text'].'
    '.$device['version']; + if (extension_loaded('mbstring')) { + $location = mb_substr($device['location'], 0, 32, 'utf8'); + } + else { + $location = truncate($device['location'], 32, ''); + } + + $uptime = formatUptime($device['uptime'], 'short').'
    '.$location; + if ($subformat == 'detail') { + $hostname .= '
    '.$device['sysName']; + if ($port_count) { + $col_port = ' '.$port_count.'
    '; + } + + if ($sensor_count) { + $col_port .= ' '.$sensor_count; + } + } + else { + } + + $response[] = array( + 'extra' => $extra, + 'msg' => $msg, + 'icon' => $image, + 'hostname' => $hostname, + 'ports' => $col_port, + 'hardware' => $platform, + 'os' => $os, + 'uptime' => $uptime, + 'actions' => $actions, + ); +}//end foreach + +$output = array( + 'current' => $current, + 'rowCount' => $rowCount, + 'rows' => $response, + 'total' => $total, +); echo _json_encode($output); diff --git a/html/includes/table/eventlog.inc.php b/html/includes/table/eventlog.inc.php index d5e5e7d60e..9cae422965 100644 --- a/html/includes/table/eventlog.inc.php +++ b/html/includes/table/eventlog.inc.php @@ -1,23 +1,22 @@ = '5') { $sql = " FROM `eventlog` AS E LEFT JOIN `devices` AS `D` ON `E`.`host`=`D`.`device_id` WHERE $where"; -} else { - $sql = " FROM `eventlog` AS E, devices_perms AS P WHERE $where AND E.host = P.device_id AND P.user_id = ?"; +} +else { + $sql = " FROM `eventlog` AS E, devices_perms AS P WHERE $where AND E.host = P.device_id AND P.user_id = ?"; $param[] = $_SESSION['user_id']; } @@ -26,7 +25,7 @@ if (isset($searchPhrase) && !empty($searchPhrase)) { } $count_sql = "SELECT COUNT(datetime) $sql"; -$total = dbFetchCell($count_sql,$param); +$total = dbFetchCell($count_sql, $param); if (empty($total)) { $total = 0; } @@ -38,7 +37,7 @@ if (!isset($sort) || empty($sort)) { $sql .= " ORDER BY $sort"; if (isset($current)) { - $limit_low = ($current * $rowCount) - ($rowCount); + $limit_low = (($current * $rowCount) - ($rowCount)); $limit_high = $rowCount; } @@ -48,22 +47,28 @@ if ($rowCount != -1) { $sql = "SELECT `E`.*,DATE_FORMAT(datetime, '".$config['dateformat']['mysql']['compact']."') as humandate $sql"; -foreach (dbFetchRows($sql,$param) as $eventlog) { +foreach (dbFetchRows($sql, $param) as $eventlog) { $dev = device_by_id_cache($eventlog['host']); - if ($eventlog['type'] == "interface") { + if ($eventlog['type'] == 'interface') { $this_if = ifLabel(getifbyid($eventlog['reference'])); - $type = "".generate_port_link($this_if, makeshortif(strtolower($this_if['label']))).""; - } else { - $type = "System"; + $type = ''.generate_port_link($this_if, makeshortif(strtolower($this_if['label']))).''; } - - $response[] = array('datetime'=>$eventlog['humandate'], - 'hostname'=>generate_device_link($dev, shorthost($dev['hostname'])), - 'type'=>$type, - 'message'=>htmlspecialchars($eventlog['message'])); + else { + $type = 'System'; + } + + $response[] = array( + 'datetime' => $eventlog['humandate'], + 'hostname' => generate_device_link($dev, shorthost($dev['hostname'])), + 'type' => $type, + 'message' => htmlspecialchars($eventlog['message']), + ); } -$output = array('current'=>$current,'rowCount'=>$rowCount,'rows'=>$response,'total'=>$total); +$output = array( + 'current' => $current, + 'rowCount' => $rowCount, + 'rows' => $response, + 'total' => $total, +); echo _json_encode($output); - -?> diff --git a/html/includes/table/inventory.inc.php b/html/includes/table/inventory.inc.php index 6c5b92823f..2e4c0b9281 100644 --- a/html/includes/table/inventory.inc.php +++ b/html/includes/table/inventory.inc.php @@ -1,14 +1,15 @@ = '5') { $sql = " FROM entPhysical AS E, devices AS D WHERE $where AND D.device_id = E.device_id"; -} else { - $sql = " FROM entPhysical AS E, devices AS D, devices_perms AS P WHERE $where AND D.device_id = E.device_id AND P.device_id = D.device_id AND P.user_id = ?"; +} +else { + $sql = " FROM entPhysical AS E, devices AS D, devices_perms AS P WHERE $where AND D.device_id = E.device_id AND P.device_id = D.device_id AND P.user_id = ?"; $param[] = $_SESSION['user_id']; } @@ -17,32 +18,32 @@ if (isset($searchPhrase) && !empty($searchPhrase)) { } if (isset($_POST['string']) && strlen($_POST['string'])) { - $sql .= " AND E.entPhysicalDescr LIKE ?"; - $param[] = "%".$_POST['string']."%"; + $sql .= ' AND E.entPhysicalDescr LIKE ?'; + $param[] = '%'.$_POST['string'].'%'; } if (isset($_POST['device_string']) && strlen($_POST['device_string'])) { - $sql .= " AND D.hostname LIKE ?"; - $param[] = "%".$_POST['device_string']."%"; + $sql .= ' AND D.hostname LIKE ?'; + $param[] = '%'.$_POST['device_string'].'%'; } if (isset($_POST['part']) && strlen($_POST['part'])) { - $sql .= " AND E.entPhysicalModelName = ?"; - $param[] = $_POST['part']; + $sql .= ' AND E.entPhysicalModelName = ?'; + $param[] = $_POST['part']; } if (isset($_POST['serial']) && strlen($_POST['serial'])) { - $sql .= " AND E.entPhysicalSerialNum LIKE ?"; - $param[] = "%".$_POST['serial']."%"; + $sql .= ' AND E.entPhysicalSerialNum LIKE ?'; + $param[] = '%'.$_POST['serial'].'%'; } if (isset($_POST['device']) && is_numeric($_POST['device'])) { - $sql .= " AND D.device_id = ?"; - $param[] = $_POST['device']; + $sql .= ' AND D.device_id = ?'; + $param[] = $_POST['device']; } $count_sql = "SELECT COUNT(`entPhysical_id`) $sql"; -$total = dbFetchCell($count_sql,$param); +$total = dbFetchCell($count_sql, $param); if (empty($total)) { $total = 0; } @@ -54,7 +55,7 @@ if (!isset($sort) || empty($sort)) { $sql .= " ORDER BY $sort"; if (isset($current)) { - $limit_low = ($current * $rowCount) - ($rowCount); + $limit_low = (($current * $rowCount) - ($rowCount)); $limit_high = $rowCount; } @@ -65,12 +66,19 @@ if ($rowCount != -1) { $sql = "SELECT `D`.`device_id` AS `device_id`, `D`.`hostname` AS `hostname`,`entPhysicalDescr` AS `description`, `entPhysicalName` AS `name`, `entPhysicalModelName` AS `model`, `entPhysicalSerialNum` AS `serial` $sql"; foreach (dbFetchRows($sql, $param) as $invent) { - $response[] = array('hostname'=>generate_device_link($invent, shortHost($invent['hostname'])), - 'description'=>$invent['description'], - 'name'=>$invent['name'], - 'model'=>$invent['model'], - 'serial'=>$invent['serial']); + $response[] = array( + 'hostname' => generate_device_link($invent, shortHost($invent['hostname'])), + 'description' => $invent['description'], + 'name' => $invent['name'], + 'model' => $invent['model'], + 'serial' => $invent['serial'], + ); } -$output = array('current'=>$current,'rowCount'=>$rowCount,'rows'=>$response,'total'=>$total); +$output = array( + 'current' => $current, + 'rowCount' => $rowCount, + 'rows' => $response, + 'total' => $total, + ); echo _json_encode($output); diff --git a/html/includes/table/mempool.inc.php b/html/includes/table/mempool.inc.php index d3968a5317..2afb80edc0 100644 --- a/html/includes/table/mempool.inc.php +++ b/html/includes/table/mempool.inc.php @@ -1,72 +1,88 @@ generate_device_link($mempool), - 'mempool_descr' => $mempool['mempool_descr'], - 'graph' => $mini_graph, - 'mempool_used' => $bar_link, - 'mempool_perc' => $perc . "%"); - if ($_POST['view'] == "graphs") { - $graph_array['height'] = "100"; - $graph_array['width'] = "216"; - $graph_array['to'] = $config['time']['now']; - $graph_array['id'] = $mempool['mempool_id']; - $graph_array['type'] = $graph_type; - $return_data = true; - include("includes/print-graphrow.inc.php"); - unset($return_data); - $response[] = array('hostname' => $graph_data[0], - 'mempool_descr' => $graph_data[1], - 'graph' => $graph_data[2], - 'mempool_used' => $graph_data[3], - 'mempool_perc' => ''); - } # endif graphs -} -$output = array('current'=>$current,'rowCount'=>$rowCount,'rows'=>$response,'total'=>$count); +$sql = "SELECT * $sql"; +foreach (dbFetchRows($sql, $param) as $mempool) { + $perc = round($mempool['mempool_perc'], 0); + $total = formatStorage($mempool['mempool_total']); + $free = formatStorage($mempool['mempool_free']); + $used = formatStorage($mempool['mempool_used']); + $graph_array['type'] = $graph_type; + $graph_array['id'] = $mempool['mempool_id']; + $graph_array['from'] = $config['time']['day']; + $graph_array['to'] = $config['time']['now']; + $graph_array['height'] = '20'; + $graph_array['width'] = '80'; + $graph_array_zoom = $graph_array; + $graph_array_zoom['height'] = '150'; + $graph_array_zoom['width'] = '400'; + $link = 'graphs/id='.$graph_array['id'].'/type='.$graph_array['type'].'/from='.$graph_array['from'].'/to='.$graph_array['to'].'/'; + $mini_graph = overlib_link($link, generate_graph_tag($graph_array), generate_graph_tag($graph_array_zoom), null); + $background = get_percentage_colours($perc); + $bar_link = overlib_link($link, print_percentage_bar(400, 20, $perc, "$used / $total", 'ffffff', $background['left'], $free, 'ffffff', $background['right']), generate_graph_tag($graph_array_zoom), null); + + $response[] = array( + 'hostname' => generate_device_link($mempool), + 'mempool_descr' => $mempool['mempool_descr'], + 'graph' => $mini_graph, + 'mempool_used' => $bar_link, + 'mempool_perc' => $perc.'%', + ); + if ($_POST['view'] == 'graphs') { + $graph_array['height'] = '100'; + $graph_array['width'] = '216'; + $graph_array['to'] = $config['time']['now']; + $graph_array['id'] = $mempool['mempool_id']; + $graph_array['type'] = $graph_type; + $return_data = true; + include 'includes/print-graphrow.inc.php'; + unset($return_data); + $response[] = array( + 'hostname' => $graph_data[0], + 'mempool_descr' => $graph_data[1], + 'graph' => $graph_data[2], + 'mempool_used' => $graph_data[3], + 'mempool_perc' => '', + ); + } //end if +}//end foreach + +$output = array( + 'current' => $current, + 'rowCount' => $rowCount, + 'rows' => $response, + 'total' => $count, +); echo _json_encode($output); diff --git a/html/includes/table/poll-log.inc.php b/html/includes/table/poll-log.inc.php index 3a0ca3213e..3579759b6c 100644 --- a/html/includes/table/poll-log.inc.php +++ b/html/includes/table/poll-log.inc.php @@ -1,11 +1,12 @@ " 'graphs', 'group' => 'poller')). "'>" .$device['hostname']. "", - 'last_polled' => $device['last_polled'], - 'last_polled_timetaken' => $device['last_polled_timetaken']); + $response[] = array( + 'hostname' => " 'graphs', 'group' => 'poller'))."'>".$device['hostname'].'', + 'last_polled' => $device['last_polled'], + 'last_polled_timetaken' => $device['last_polled_timetaken'], + ); } -$output = array('current'=>$current,'rowCount'=>$rowCount,'rows'=>$response,'total'=>$total); +$output = array( + 'current' => $current, + 'rowCount' => $rowCount, + 'rows' => $response, + 'total' => $total, +); echo _json_encode($output); - -?> diff --git a/html/includes/table/processor.inc.php b/html/includes/table/processor.inc.php index a7b3d97457..bcedd6196f 100644 --- a/html/includes/table/processor.inc.php +++ b/html/includes/table/processor.inc.php @@ -1,67 +1,83 @@ generate_device_link($processor), - 'processor_descr' => $processor['processor_descr'], - 'graph' => $mini_graph, - 'processor_usage' => $bar_link); - if ($_POST['view'] == "graphs") { - $graph_array['height'] = "100"; - $graph_array['width'] = "216"; - $graph_array['to'] = $config['time']['now']; - $graph_array['id'] = $processor['processor_id']; - $graph_array['type'] = $graph_type; - $return_data = true; - include("includes/print-graphrow.inc.php"); - unset($return_data); - $response[] = array('hostname' => $graph_data[0], - 'processor_descr' => $graph_data[1], - 'graph' => $graph_data[2], - 'processor_usage' => $graph_data[3]); - } # endif graphs -} -$output = array('current'=>$current,'rowCount'=>$rowCount,'rows'=>$response,'total'=>$total); +$sql = "SELECT * $sql"; +foreach (dbFetchRows($sql, $param) as $processor) { + $perc = round($processor['processor_usage'], 0); + $graph_array['type'] = $graph_type; + $graph_array['id'] = $processor['processor_id']; + $graph_array['from'] = $config['time']['day']; + $graph_array['to'] = $config['time']['now']; + $graph_array['height'] = '20'; + $graph_array['width'] = '80'; + $graph_array_zoom = $graph_array; + $graph_array_zoom['height'] = '150'; + $graph_array_zoom['width'] = '400'; + $link = 'graphs/id='.$graph_array['id'].'/type='.$graph_array['type'].'/from='.$graph_array['from'].'/to='.$graph_array['to'].'/'; + $mini_graph = overlib_link($link, generate_graph_tag($graph_array), generate_graph_tag($graph_array_zoom), null); + $background = get_percentage_colours($perc); + $bar_link = overlib_link($link, print_percentage_bar(400, 20, $perc, $perc.'%', 'ffffff', $background['left'], (100 - $perc).'%', 'ffffff', $background['right']), generate_graph_tag($graph_array_zoom), null); + + $response[] = array( + 'hostname' => generate_device_link($processor), + 'processor_descr' => $processor['processor_descr'], + 'graph' => $mini_graph, + 'processor_usage' => $bar_link, + ); + if ($_POST['view'] == 'graphs') { + $graph_array['height'] = '100'; + $graph_array['width'] = '216'; + $graph_array['to'] = $config['time']['now']; + $graph_array['id'] = $processor['processor_id']; + $graph_array['type'] = $graph_type; + $return_data = true; + include 'includes/print-graphrow.inc.php'; + unset($return_data); + $response[] = array( + 'hostname' => $graph_data[0], + 'processor_descr' => $graph_data[1], + 'graph' => $graph_data[2], + 'processor_usage' => $graph_data[3], + ); + } //end if +}//end foreach + +$output = array( + 'current' => $current, + 'rowCount' => $rowCount, + 'rows' => $response, + 'total' => $total, +); echo _json_encode($output); diff --git a/html/includes/table/storage.inc.php b/html/includes/table/storage.inc.php index a912ba1d2e..3d301456f0 100644 --- a/html/includes/table/storage.inc.php +++ b/html/includes/table/storage.inc.php @@ -1,14 +1,14 @@ generate_device_link($drive), + 'storage_descr' => $drive['storage_descr'], + 'graph' => $mini_graph, + 'storage_used' => $bar_link, + 'storage_perc' => $perc.'%', + ); + if ($_POST['view'] == 'graphs') { + $graph_array['height'] = '100'; + $graph_array['width'] = '216'; + $graph_array['to'] = $config['time']['now']; + $graph_array['id'] = $drive['storage_id']; + $graph_array['type'] = $graph_type; - $response[] = array('hostname' => generate_device_link($drive), - 'storage_descr' => $drive['storage_descr'], - 'graph' => $mini_graph, - 'storage_used' => $bar_link, - 'storage_perc' => $perc . "%"); - if ($_POST['view'] == "graphs") { - $graph_array['height'] = "100"; - $graph_array['width'] = "216"; - $graph_array['to'] = $config['time']['now']; - $graph_array['id'] = $drive['storage_id']; - $graph_array['type'] = $graph_type; + $return_data = true; + include 'includes/print-graphrow.inc.php'; + unset($return_data); + $response[] = array( + 'hostname' => $graph_data[0], + 'storage_descr' => $graph_data[1], + 'graph' => $graph_data[2], + 'storage_used' => $graph_data[3], + 'storage_perc' => '', + ); + } //end if +}//end foreach - $return_data = true; - include("includes/print-graphrow.inc.php"); - unset($return_data); - $response[] = array('hostname' => $graph_data[0], - 'storage_descr' => $graph_data[1], - 'graph' => $graph_data[2], - 'storage_used' => $graph_data[3], - 'storage_perc' => ''); - - } # endif graphs -} - -$output = array('current'=>$current,'rowCount'=>$rowCount,'rows'=>$response,'total'=>$count); +$output = array( + 'current' => $current, + 'rowCount' => $rowCount, + 'rows' => $response, + 'total' => $count, +); echo _json_encode($output); diff --git a/html/includes/table/syslog.inc.php b/html/includes/table/syslog.inc.php index 81df05d289..987aac65a1 100644 --- a/html/includes/table/syslog.inc.php +++ b/html/includes/table/syslog.inc.php @@ -1,46 +1,44 @@ = ?"; - $param[] = $_POST['from']; -} -if( !empty($_POST['to']) ) { - $where .= " AND timestamp <= ?"; - $param[] = $_POST['to']; +if (!empty($_POST['from'])) { + $where .= ' AND timestamp >= ?'; + $param[] = $_POST['from']; } -if ($_SESSION['userlevel'] >= '5') -{ - $sql = "FROM syslog AS S"; - $sql .= " WHERE ".$where; -} else { - $sql = "FROM syslog AS S, devices_perms AS P"; - $sql .= "WHERE S.device_id = P.device_id AND P.user_id = ?"; - $sql .= $where; - $param = array_merge(array($_SESSION['user_id']), $param); +if (!empty($_POST['to'])) { + $where .= ' AND timestamp <= ?'; + $param[] = $_POST['to']; +} + +if ($_SESSION['userlevel'] >= '5') { + $sql = 'FROM syslog AS S'; + $sql .= ' WHERE '.$where; +} +else { + $sql = 'FROM syslog AS S, devices_perms AS P'; + $sql .= 'WHERE S.device_id = P.device_id AND P.user_id = ?'; + $sql .= $where; + $param = array_merge(array($_SESSION['user_id']), $param); } $count_sql = "SELECT COUNT(timestamp) $sql"; -$total = dbFetchCell($count_sql,$param); +$total = dbFetchCell($count_sql, $param); if (empty($total)) { $total = 0; } @@ -52,7 +50,7 @@ if (!isset($sort) || empty($sort)) { $sql .= " ORDER BY $sort"; if (isset($current)) { - $limit_low = ($current * $rowCount) - ($rowCount); + $limit_low = (($current * $rowCount) - ($rowCount)); $limit_high = $rowCount; } @@ -62,14 +60,20 @@ if ($rowCount != -1) { $sql = "SELECT S.*, DATE_FORMAT(timestamp, '".$config['dateformat']['mysql']['compact']."') AS date $sql"; -foreach (dbFetchRows($sql,$param) as $syslog) { - $dev = device_by_id_cache($syslog['device_id']); - $response[] = array('timestamp'=>$syslog['date'], - 'device_id'=>generate_device_link($dev, shorthost($dev['hostname'])), - 'program'=>$syslog['program'], - 'msg'=>htmlspecialchars($syslog['msg'])); +foreach (dbFetchRows($sql, $param) as $syslog) { + $dev = device_by_id_cache($syslog['device_id']); + $response[] = array( + 'timestamp' => $syslog['date'], + 'device_id' => generate_device_link($dev, shorthost($dev['hostname'])), + 'program' => $syslog['program'], + 'msg' => htmlspecialchars($syslog['msg']), + ); } -$output = array('current'=>$current,'rowCount'=>$rowCount,'rows'=>$response,'total'=>$total); +$output = array( + 'current' => $current, + 'rowCount' => $rowCount, + 'rows' => $response, + 'total' => $total, +); echo _json_encode($output); -?> diff --git a/html/includes/vars.inc.php b/html/includes/vars.inc.php index 788915f694..477f056b46 100644 --- a/html/includes/vars.inc.php +++ b/html/includes/vars.inc.php @@ -1,40 +1,38 @@ $get_var) -{ - if (strstr($key, "opt")) - { - list($name, $value) = explode("|", $get_var); - if (!isset($value)) { $value = "yes"; } - $vars[$name] = $value; - } +foreach ($_GET as $key => $get_var) { + if (strstr($key, 'opt')) { + list($name, $value) = explode('|', $get_var); + if (!isset($value)) { + $value = 'yes'; + } + + $vars[$name] = $value; + } } $segments = explode('/', trim($_SERVER['REQUEST_URI'], '/')); -foreach ($segments as $pos => $segment) -{ - $segment = urldecode($segment); - if ($pos == "0") - { - $vars['page'] = $segment; - } else { - list($name, $value) = explode("=", $segment); - if ($value == "" || !isset($value)) - { - $vars[$name] = yes; - } else { - $vars[$name] = $value; +foreach ($segments as $pos => $segment) { + $segment = urldecode($segment); + if ($pos == '0') { + $vars['page'] = $segment; + } + else { + list($name, $value) = explode('=', $segment); + if ($value == '' || !isset($value)) { + $vars[$name] = yes; + } + else { + $vars[$name] = $value; + } } - } } -foreach ($_GET as $name => $value) -{ - $vars[$name] = $value; +foreach ($_GET as $name => $value) { + $vars[$name] = $value; } -foreach ($_POST as $name => $value) -{ - $vars[$name] = $value; +foreach ($_POST as $name => $value) { + $vars[$name] = $value; } diff --git a/html/index.php b/html/index.php index 57fff1b57a..a3de9ba0c5 100644 --- a/html/index.php +++ b/html/index.php @@ -14,7 +14,8 @@ if( strstr($_SERVER['SERVER_SOFTWARE'],"nginx") ) { $_SERVER['PATH_INFO'] = str_replace($_SERVER['PATH_TRANSLATED'].$_SERVER['PHP_SELF'],"",$_SERVER['ORIG_SCRIPT_FILENAME']); -} else { +} +else { $_SERVER['PATH_INFO'] = !empty($_SERVER['PATH_INFO']) ? $_SERVER['PATH_INFO'] : (!empty($_SERVER['ORIG_PATH_INFO']) ? $_SERVER['ORIG_PATH_INFO'] : ''); } @@ -31,40 +32,40 @@ function catchFatal() { } } -if (strpos($_SERVER['PATH_INFO'], "debug")) -{ - $debug = "1"; - ini_set('display_errors', 0); - ini_set('display_startup_errors', 1); - ini_set('log_errors', 1); - ini_set('error_reporting', E_ALL); - set_error_handler('logErrors'); - register_shutdown_function('catchFatal'); -} else { - $debug = FALSE; - ini_set('display_errors', 0); - ini_set('display_startup_errors', 0); - ini_set('log_errors', 0); - ini_set('error_reporting', 0); +if (strpos($_SERVER['PATH_INFO'], "debug")) { + $debug = "1"; + ini_set('display_errors', 0); + ini_set('display_startup_errors', 1); + ini_set('log_errors', 1); + ini_set('error_reporting', E_ALL); + set_error_handler('logErrors'); + register_shutdown_function('catchFatal'); +} +else { + $debug = FALSE; + ini_set('display_errors', 0); + ini_set('display_startup_errors', 0); + ini_set('log_errors', 0); + ini_set('error_reporting', 0); } // Set variables $msg_box = array(); // Check for install.inc.php -if (!file_exists('../config.php') && $_SERVER['PATH_INFO'] != '/install.php') -{ - // no config.php does so let's redirect to the install - header('Location: /install.php'); - exit; +if (!file_exists('../config.php') && $_SERVER['PATH_INFO'] != '/install.php') { + // no config.php does so let's redirect to the install + header('Location: /install.php'); + exit; } -include("../includes/defaults.inc.php"); -include("../config.php"); -include_once("../includes/definitions.inc.php"); -include("../includes/functions.php"); -include("includes/functions.inc.php"); -include("includes/vars.inc.php"); -include('includes/plugins.inc.php'); +require '../includes/defaults.inc.php'; +require '../config.php'; +require_once '../includes/definitions.inc.php'; +require '../includes/functions.php'; +require 'includes/functions.inc.php'; +require 'includes/vars.inc.php'; +require 'includes/plugins.inc.php'; + Plugins::start(); $runtime_start = utime(); @@ -74,30 +75,33 @@ ob_start(); ini_set('allow_url_fopen', 0); ini_set('display_errors', 0); -include("includes/authenticate.inc.php"); +require 'includes/authenticate.inc.php'; -if (strstr($_SERVER['REQUEST_URI'], 'widescreen=yes')) { $_SESSION['widescreen'] = 1; } -if (strstr($_SERVER['REQUEST_URI'], 'widescreen=no')) { unset($_SESSION['widescreen']); } +if (strstr($_SERVER['REQUEST_URI'], 'widescreen=yes')) { + $_SESSION['widescreen'] = 1; +} +if (strstr($_SERVER['REQUEST_URI'], 'widescreen=no')) { + unset($_SESSION['widescreen']); +} # Load the settings for Multi-Tenancy. -if (isset($config['branding']) && is_array($config['branding'])) -{ - if ($config['branding'][$_SERVER['SERVER_NAME']]) - { - foreach ($config['branding'][$_SERVER['SERVER_NAME']] as $confitem => $confval) - { - eval("\$config['" . $confitem . "'] = \$confval;"); +if (isset($config['branding']) && is_array($config['branding'])) { + if ($config['branding'][$_SERVER['SERVER_NAME']]) { + foreach ($config['branding'][$_SERVER['SERVER_NAME']] as $confitem => $confval) { + eval("\$config['" . $confitem . "'] = \$confval;"); + } } - } else { - foreach ($config['branding']['default'] as $confitem => $confval) - { - eval("\$config['" . $confitem . "'] = \$confval;"); + else { + foreach ($config['branding']['default'] as $confitem => $confval) { + eval("\$config['" . $confitem . "'] = \$confval;"); + } } - } } # page_title_prefix is displayed, unless page_title is set -if (isset($config['page_title'])) { $config['page_title_prefix'] = $config['page_title']; } +if (isset($config['page_title'])) { + $config['page_title_prefix'] = $config['page_title']; +} ?> @@ -119,7 +123,8 @@ if (empty($config['favicon'])) { ' . "\n"); } ?> @@ -169,14 +174,13 @@ if (empty($config['favicon'])) { body { padding-top: 0px !important; - padding-bottom: 0px !important; }"; + padding-bottom: 0px !important; }"; } @@ -188,50 +192,47 @@ if ((isset($vars['bare']) && $vars['bare'] != "yes") || !isset($vars['bare'])) { "); - print_r($_GET); - print_r($vars); - echo(""); +if (isset($devel) || isset($vars['devel'])) { + echo("
    ");
    +    print_r($_GET);
    +    print_r($vars);
    +    echo("
    "); } -if ($_SESSION['authenticated']) -{ - // Authenticated. Print a page. - if (isset($vars['page']) && !strstr("..", $vars['page']) && is_file("pages/" . $vars['page'] . ".inc.php")) - { - include("pages/" . $vars['page'] . ".inc.php"); - } else { - if (isset($config['front_page']) && is_file($config['front_page'])) - { - include($config['front_page']); - } else { - include("pages/front/default.php"); +if ($_SESSION['authenticated']) { + // Authenticated. Print a page. + if (isset($vars['page']) && !strstr("..", $vars['page']) && is_file("pages/" . $vars['page'] . ".inc.php")) { + require "pages/" . $vars['page'] . ".inc.php"; + } + else { + if (isset($config['front_page']) && is_file($config['front_page'])) { + require $config['front_page']; + } + else { + require 'pages/front/default.php'; + } } - } -} else { - // Not Authenticated. Show status page if enabled - if ( $config['public_status'] === true ) - { - if (isset($vars['page']) && strstr("login", $vars['page'])) - { - include("pages/logon.inc.php"); - } else { - echo '
    '; - include("pages/public.inc.php"); - echo '
    '; - echo ''; +} +else { + // Not Authenticated. Show status page if enabled + if ( $config['public_status'] === true ) { + if (isset($vars['page']) && strstr("login", $vars['page'])) { + require 'pages/logon.inc.php'; + } + else { + echo '
    '; + require 'pages/public.inc.php'; + echo '
    '; + echo ''; + } + } + else { + require 'pages/logon.inc.php'; } - } - else - { - include("pages/logon.inc.php"); - } } ?> @@ -239,37 +240,42 @@ if ($_SESSION['authenticated']) MySQL: Cell '.($db_stats['fetchcell']+0).'/'.round($db_stats['fetchcell_sec']+0,3).'s'. - ' Row '.($db_stats['fetchrow']+0). '/'.round($db_stats['fetchrow_sec']+0,3).'s'. - ' Rows '.($db_stats['fetchrows']+0).'/'.round($db_stats['fetchrows_sec']+0,3).'s'. - ' Column '.($db_stats['fetchcol']+0). '/'.round($db_stats['fetchcol_sec']+0,3).'s'); +if ($config['page_gen']) { + echo('
    MySQL: Cell '.($db_stats['fetchcell']+0).'/'.round($db_stats['fetchcell_sec']+0,3).'s'. + ' Row '.($db_stats['fetchrow']+0). '/'.round($db_stats['fetchrow_sec']+0,3).'s'. + ' Rows '.($db_stats['fetchrows']+0).'/'.round($db_stats['fetchrows_sec']+0,3).'s'. + ' Column '.($db_stats['fetchcol']+0). '/'.round($db_stats['fetchcol_sec']+0,3).'s'); - $fullsize = memory_get_usage(); - unset($cache); - $cachesize = $fullsize - memory_get_usage(); - if ($cachesize < 0) { $cachesize = 0; } // Silly PHP! + $fullsize = memory_get_usage(); + unset($cache); + $cachesize = $fullsize - memory_get_usage(); + if ($cachesize < 0) { + $cachesize = 0; + } // Silly PHP! - echo('
    Cached data in memory is '.formatStorage($cachesize).'. Page memory usage is '.formatStorage($fullsize).', peaked at '. formatStorage(memory_get_peak_usage()) .'.'); - echo('
    Generated in ' . $gentime . ' seconds.'); + echo('
    Cached data in memory is '.formatStorage($cachesize).'. Page memory usage is '.formatStorage($fullsize).', peaked at '. formatStorage(memory_get_peak_usage()) .'.'); + echo('
    Generated in ' . $gentime . ' seconds.'); } -if (isset($pagetitle) && is_array($pagetitle)) -{ - # if prefix is set, put it in front - if ($config['page_title_prefix']) { array_unshift($pagetitle,$config['page_title_prefix']); } +if (isset($pagetitle) && is_array($pagetitle)) { + # if prefix is set, put it in front + if ($config['page_title_prefix']) { + array_unshift($pagetitle,$config['page_title_prefix']); + } - # if suffix is set, put it in the back - if ($config['page_title_suffix']) { $pagetitle[] = $config['page_title_suffix']; } + # if suffix is set, put it in the back + if ($config['page_title_suffix']) { + $pagetitle[] = $config['page_title_suffix']; + } - # create and set the title - $title = join(" - ",$pagetitle); - echo(""); + # create and set the title + $title = join(" - ",$pagetitle); + echo(""); } ?> @@ -295,23 +301,21 @@ if(dbFetchCell("SELECT COUNT(`device_id`) FROM `devices` WHERE `last_polled` <= } if(is_array($msg_box)) { - echo(""); + echo(""); } if (is_array($sql_debug) && is_array($php_debug) && $_SESSION['authenticated'] === TRUE) { - - include_once "includes/print-debug.php"; - + require_once "includes/print-debug.php"; } if ($no_refresh !== TRUE && $config['page_refresh'] != 0) { @@ -367,7 +371,8 @@ if ($no_refresh !== TRUE && $config['page_refresh'] != 0) { }); '); -} else { +} +else { echo(' +}//end if diff --git a/html/pages/alert-stats.inc.php b/html/pages/alert-stats.inc.php index d392f1dd20..ab9a0c57fd 100644 --- a/html/pages/alert-stats.inc.php +++ b/html/pages/alert-stats.inc.php @@ -1,12 +1,13 @@ -* This program is free software: you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation, either version 3 of the License, or (at your -* option) any later version. Please see LICENSE.txt at the top level of -* the source code distribution for details. -*/ -require_once('includes/print-graph-alerts.inc.php'); + * LibreNMS + * + * Copyright (c) 2015 Søren Friis Rosiak + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. Please see LICENSE.txt at the top level of + * the source code distribution for details. + */ + +require_once 'includes/print-graph-alerts.inc.php'; diff --git a/html/pages/alerts.inc.php b/html/pages/alerts.inc.php index bcc97a32a0..91526b69ff 100644 --- a/html/pages/alerts.inc.php +++ b/html/pages/alerts.inc.php @@ -1,19 +1,17 @@ - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation, either version 3 of the License, or (at your - * option) any later version. Please see LICENSE.txt at the top level of - * the source code distribution for details. + * LibreNMS + * + * Copyright (c) 2014 Neil Lathwood + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. Please see LICENSE.txt at the top level of + * the source code distribution for details. */ $device['device_id'] = '-1'; -require_once('includes/print-alerts.php'); +require_once 'includes/print-alerts.php'; unset($device['device_id']); - -?> diff --git a/html/pages/api-access.inc.php b/html/pages/api-access.inc.php index a1b6e5a528..6b8a885a7a 100644 --- a/html/pages/api-access.inc.php +++ b/html/pages/api-access.inc.php @@ -12,22 +12,22 @@ * the source code distribution for details. */ -if ($_SESSION['userlevel'] >= '10') -{ -if(empty($_POST['token'])) { +if ($_SESSION['userlevel'] >= '10') { +if (empty($_POST['token'])) { $_POST['token'] = bin2hex(openssl_random_pseudo_bytes(16)); } + ?> -'); - if($_SESSION['api_token'] === TRUE) - { - echo(" - "); + "; unset($_SESSION['api_token']); - } -echo(' +} + +echo '
    @@ -127,19 +125,17 @@ echo(' Disabled Remove -'); +'; - foreach (dbFetchRows("SELECT `AT`.*,`U`.`username` FROM `api_tokens` AS AT JOIN users AS U ON AT.user_id=U.user_id ORDER BY AT.user_id") as $api) - { - if($api['disabled'] == '1') - { - $api_disabled = 'checked'; +foreach (dbFetchRows('SELECT `AT`.*,`U`.`username` FROM `api_tokens` AS AT JOIN users AS U ON AT.user_id=U.user_id ORDER BY AT.user_id') as $api) { + if ($api['disabled'] == '1') { + $api_disabled = 'checked'; } - else - { - $api_disabled = ''; + else { + $api_disabled = ''; } - echo(' + + echo ' '.$api['username'].' '.$api['token_hash'].' @@ -147,14 +143,14 @@ echo(' -'); - } +'; +} - echo(' + echo '
    -'); +'; ?> +else { + include 'includes/error-no-perm.inc.php'; +}//end if diff --git a/html/pages/api-docs.inc.php b/html/pages/api-docs.inc.php index c260b73cec..d3bd68b840 100644 --- a/html/pages/api-docs.inc.php +++ b/html/pages/api-docs.inc.php @@ -17,8 +17,7 @@
    here.'); +print_error('Documentation for the API has now been moved to GitHub, you can go straight to the API Wiki from here.'); ?>
    - diff --git a/html/pages/apps.inc.php b/html/pages/apps.inc.php index 1a20acc41f..cfd2378dde 100644 --- a/html/pages/apps.inc.php +++ b/html/pages/apps.inc.php @@ -1,54 +1,91 @@ Apps » "); +echo "Apps » "; unset($sep); -$link_array = array('page' => 'device', - 'device' => $device['device_id'], - 'tab' => 'apps'); +$link_array = array( + 'page' => 'device', + 'device' => $device['device_id'], + 'tab' => 'apps', +); -foreach ($app_list as $app) -{ - echo($sep); +foreach ($app_list as $app) { + echo $sep; -# if (!$vars['app']) { $vars['app'] = $app['app_type']; } + // if (!$vars['app']) { $vars['app'] = $app['app_type']; } + if ($vars['app'] == $app['app_type']) { + echo ""; + // echo(''); + } + else { + // echo(''); + } - if ($vars['app'] == $app['app_type']) - { - echo(""); - #echo(''); - } else { - #echo(''); - } - echo(generate_link(nicecase($app['app_type']),array('page'=>'apps','app'=>$app['app_type']))); - if ($vars['app'] == $app['app_type']) { echo(""); } - $sep = " | "; + echo generate_link(nicecase($app['app_type']), array('page' => 'apps', 'app' => $app['app_type'])); + if ($vars['app'] == $app['app_type']) { + echo ''; + } + + $sep = ' | '; } print_optionbar_end(); -if($vars['app']) -{ - if (is_file("pages/apps/".mres($vars['app']).".inc.php")) - { - include("pages/apps/".mres($vars['app']).".inc.php"); - } else { - include("pages/apps/default.inc.php"); - } -} else { - include("pages/apps/overview.inc.php"); +if ($vars['app']) { + if (is_file('pages/apps/'.mres($vars['app']).'.inc.php')) { + include 'pages/apps/'.mres($vars['app']).'.inc.php'; + } + else { + include 'pages/apps/default.inc.php'; + } +} +else { + include 'pages/apps/overview.inc.php'; } -$pagetitle[] = "Apps"; -?> +$pagetitle[] = 'Apps'; diff --git a/html/pages/apps/default.inc.php b/html/pages/apps/default.inc.php index e333674057..bf752de29c 100644 --- a/html/pages/apps/default.inc.php +++ b/html/pages/apps/default.inc.php @@ -1,45 +1,41 @@ '.nicecase($vars['app']).''); -echo(''); -$app_devices = dbFetchRows("SELECT * FROM `devices` AS D, `applications` AS A WHERE D.device_id = A.device_id AND A.app_type = ?", array($vars['app'])); +echo '

    '.nicecase($vars['app']).'

    '; +echo '
    '; +$app_devices = dbFetchRows('SELECT * FROM `devices` AS D, `applications` AS A WHERE D.device_id = A.device_id AND A.app_type = ?', array($vars['app'])); -foreach ($app_devices as $app_device) -{ - echo(''); - echo(''); - echo(''); - echo(''); - echo(''); - echo(''); - echo(''); - echo(''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''); - echo(''); -} + echo ''; + echo ''; +}//end foreach -echo('
    '.generate_device_link($app_device, shorthost($app_device['hostname']), array('tab'=>'apps','app'=>$vars['app'])).''.$app_device['app_instance'].''.$app_device['app_status'].'
    '); +foreach ($app_devices as $app_device) { + echo '
    '.generate_device_link($app_device, shorthost($app_device['hostname']), array('tab' => 'apps', 'app' => $vars['app'])).''.$app_device['app_instance'].''.$app_device['app_status'].'
    '; - foreach ($graphs[$vars['app']] as $graph_type) - { - $graph_array['type'] = "application_".$vars['app']."_".$graph_type; - $graph_array['id'] = $app_device['app_id']; - $graph_array_zoom['type'] = "application_".$vars['app']."_".$graph_type; - $graph_array_zoom['id'] = $app_device['app_id']; + foreach ($graphs[$vars['app']] as $graph_type) { + $graph_array['type'] = 'application_'.$vars['app'].'_'.$graph_type; + $graph_array['id'] = $app_device['app_id']; + $graph_array_zoom['type'] = 'application_'.$vars['app'].'_'.$graph_type; + $graph_array_zoom['id'] = $app_device['app_id']; - $link = generate_url(array('page' => 'device', 'device' => $app_device['device_id'],'tab'=>'apps','app'=>$vars['app'])); + $link = generate_url(array('page' => 'device', 'device' => $app_device['device_id'], 'tab' => 'apps', 'app' => $vars['app'])); - echo(overlib_link($link, generate_graph_tag($graph_array), generate_graph_tag($graph_array_zoom), NULL)); - } + echo overlib_link($link, generate_graph_tag($graph_array), generate_graph_tag($graph_array_zoom), null); + } - echo('
    '); - -?> +echo ''; diff --git a/html/pages/authlog.inc.php b/html/pages/authlog.inc.php index 64b4080ad2..3cffbbea9e 100644 --- a/html/pages/authlog.inc.php +++ b/html/pages/authlog.inc.php @@ -1,37 +1,37 @@ = '10') -{ - echo(""); +if ($_SESSION['userlevel'] >= '10') { + echo '
    '; - foreach (dbFetchRows("SELECT *,DATE_FORMAT(datetime, '".$config['dateformat']['mysql']['compact']."') as humandate FROM `authlog` ORDER BY `datetime` DESC LIMIT 0,250") as $entry) - { - if ($bg == $list_colour_a) { $bg = $list_colour_b; } else { $bg=$list_colour_a; } + foreach (dbFetchRows("SELECT *,DATE_FORMAT(datetime, '".$config['dateformat']['mysql']['compact']."') as humandate FROM `authlog` ORDER BY `datetime` DESC LIMIT 0,250") as $entry) { + if ($bg == $list_colour_a) { + $bg = $list_colour_b; + } + else { + $bg = $list_colour_a; + } - echo(" - - - - - - "); - } + echo " + + + + + + '; + }//end foreach - $pagetitle[] = "Authlog"; + $pagetitle[] = 'Authlog'; - echo("
    - " . $entry['datetime'] . " - - ".$entry['user']." - - ".$entry['address']." - - ".$entry['result']." -
    + ".$entry['datetime'].' + + '.$entry['user'].' + + '.$entry['address'].' + + '.$entry['result'].' +
    "); + echo ''; } -else -{ - include("includes/error-no-perm.inc.php"); -} - -?> +else { + include 'includes/error-no-perm.inc.php'; +}//end if diff --git a/html/pages/bill.inc.php b/html/pages/bill.inc.php index 13b640057b..03faf35c17 100644 --- a/html/pages/bill.inc.php +++ b/html/pages/bill.inc.php @@ -2,255 +2,274 @@ $bill_id = mres($vars['bill_id']); -if ($_SESSION['userlevel'] >= "10") -{ - include("pages/bill/actions.inc.php"); +if ($_SESSION['userlevel'] >= '10') { + include 'pages/bill/actions.inc.php'; } -if (bill_permitted($bill_id)) -{ - $bill_data = dbFetchRow("SELECT * FROM bills WHERE bill_id = ?", array($bill_id)); +if (bill_permitted($bill_id)) { + $bill_data = dbFetchRow('SELECT * FROM bills WHERE bill_id = ?', array($bill_id)); - $bill_name = $bill_data['bill_name']; + $bill_name = $bill_data['bill_name']; - $today = str_replace("-", "", dbFetchCell("SELECT CURDATE()")); - $yesterday = str_replace("-", "", dbFetchCell("SELECT DATE_SUB(CURDATE(), INTERVAL 1 DAY)")); - $tomorrow = str_replace("-", "", dbFetchCell("SELECT DATE_ADD(CURDATE(), INTERVAL 1 DAY)")); - $last_month = str_replace("-", "", dbFetchCell("SELECT DATE_SUB(CURDATE(), INTERVAL 1 MONTH)")); + $today = str_replace('-', '', dbFetchCell('SELECT CURDATE()')); + $yesterday = str_replace('-', '', dbFetchCell('SELECT DATE_SUB(CURDATE(), INTERVAL 1 DAY)')); + $tomorrow = str_replace('-', '', dbFetchCell('SELECT DATE_ADD(CURDATE(), INTERVAL 1 DAY)')); + $last_month = str_replace('-', '', dbFetchCell('SELECT DATE_SUB(CURDATE(), INTERVAL 1 MONTH)')); - $rightnow = $today . date(His); - $before = $yesterday . date(His); - $lastmonth = $last_month . date(His); + $rightnow = $today.date(His); + $before = $yesterday.date(His); + $lastmonth = $last_month.date(His); - $bill_name = $bill_data['bill_name']; - $dayofmonth = $bill_data['bill_day']; + $bill_name = $bill_data['bill_name']; + $dayofmonth = $bill_data['bill_day']; - $day_data = getDates($dayofmonth); + $day_data = getDates($dayofmonth); - $datefrom = $day_data['0']; - $dateto = $day_data['1']; - $lastfrom = $day_data['2']; - $lastto = $day_data['3']; + $datefrom = $day_data['0']; + $dateto = $day_data['1']; + $lastfrom = $day_data['2']; + $lastto = $day_data['3']; - $rate_95th = $bill_data['rate_95th']; - $dir_95th = $bill_data['dir_95th']; - $total_data = $bill_data['total_data']; - $rate_average = $bill_data['rate_average']; + $rate_95th = $bill_data['rate_95th']; + $dir_95th = $bill_data['dir_95th']; + $total_data = $bill_data['total_data']; + $rate_average = $bill_data['rate_average']; - if ($rate_95th > $paid_kb) - { - $over = $rate_95th - $paid_kb; - $bill_text = $over . "Kbit excess."; - $bill_color = "#cc0000"; - } - else - { - $under = $paid_kb - $rate_95th; - $bill_text = $under . "Kbit headroom."; - $bill_color = "#0000cc"; - } - - $fromtext = dbFetchCell("SELECT DATE_FORMAT($datefrom, '".$config['dateformat']['mysql']['date']."')"); - $totext = dbFetchCell("SELECT DATE_FORMAT($dateto, '".$config['dateformat']['mysql']['date']."')"); - $unixfrom = dbFetchCell("SELECT UNIX_TIMESTAMP('$datefrom')"); - $unixto = dbFetchCell("SELECT UNIX_TIMESTAMP('$dateto')"); - - $unix_prev_from = dbFetchCell("SELECT UNIX_TIMESTAMP('$lastfrom')"); - $unix_prev_to = dbFetchCell("SELECT UNIX_TIMESTAMP('$lastto')"); - # Speeds up loading for other included pages by setting it before progessing of mysql data! - - $ports = dbFetchRows("SELECT * FROM `bill_ports` AS B, `ports` AS P, `devices` AS D - WHERE B.bill_id = ? AND P.port_id = B.port_id - AND D.device_id = P.device_id", array($bill_id)); - - echo("

    - Bill : " . $bill_data['bill_name'] . "

    "); - - print_optionbar_start(); - - echo("Bill » "); - - if (!$vars['view']) { $vars['view'] = "quick"; } - - if ($vars['view'] == "quick") { echo(""); } - echo('Quick Graphs'); - if ($vars['view'] == "quick") { echo(""); } - - echo(" | "); - - if ($vars['view'] == "accurate") { echo(""); } - echo('Accurate Graphs'); - if ($vars['view'] == "accurate") { echo(""); } - - echo(" | "); - - if ($vars['view'] == "transfer") { echo(""); } - echo('Transfer Graphs'); - if ($vars['view'] == "transfer") { echo(""); } - - echo(" | "); - - if ($vars['view'] == "history") { echo(""); } - echo('Historical Usage'); - if ($vars['view'] == "history") { echo(""); } - - if ($_SESSION['userlevel'] >= "10") - { - echo(" | "); - if ($vars['view'] == "edit") { echo(""); } - echo('Edit'); - if ($vars['view'] == "edit") { echo(""); } - - echo(" | "); - if ($vars['view'] == "delete") { echo(""); } - echo('Delete'); - if ($vars['view'] == "delete") { echo(""); } - - echo(" | "); - if ($vars['view'] == "reset") { echo(""); } - echo('Reset'); - if ($vars['view'] == "reset") { echo(""); } - } - - echo(''); - - print_optionbar_end(); - - if ($vars['view'] == "edit" && $_SESSION['userlevel'] >= "10") - { - include("pages/bill/edit.inc.php"); - } - elseif ($vars['view'] == "delete" && $_SESSION['userlevel'] >= "10") - { - include("pages/bill/delete.inc.php"); - } - elseif ($vars['view'] == "reset" && $_SESSION['userlevel'] >= "10") - { - include("pages/bill/reset.inc.php"); - } - elseif ($vars['view'] == "history") - { - include("pages/bill/history.inc.php"); - } - elseif ($vars['view'] == "transfer") - { - include("pages/bill/transfer.inc.php"); - } - elseif ($vars['view'] == "quick" || $vars['view'] == "accurate") { - - echo("

    Billed Ports

    "); - - // Collected Earlier - foreach ($ports as $port) - { - echo(generate_port_link($port) . " on " . generate_device_link($port) . "
    "); + if ($rate_95th > $paid_kb) { + $over = ($rate_95th - $paid_kb); + $bill_text = $over.'Kbit excess.'; + $bill_color = '#cc0000'; + } + else { + $under = ($paid_kb - $rate_95th); + $bill_text = $under.'Kbit headroom.'; + $bill_color = '#0000cc'; } - echo("

    Bill Summary

    "); + $fromtext = dbFetchCell("SELECT DATE_FORMAT($datefrom, '".$config['dateformat']['mysql']['date']."')"); + $totext = dbFetchCell("SELECT DATE_FORMAT($dateto, '".$config['dateformat']['mysql']['date']."')"); + $unixfrom = dbFetchCell("SELECT UNIX_TIMESTAMP('$datefrom')"); + $unixto = dbFetchCell("SELECT UNIX_TIMESTAMP('$dateto')"); - if ($bill_data['bill_type'] == "quota") - { - // The Customer is billed based on a pre-paid quota with overage in xB + $unix_prev_from = dbFetchCell("SELECT UNIX_TIMESTAMP('$lastfrom')"); + $unix_prev_to = dbFetchCell("SELECT UNIX_TIMESTAMP('$lastto')"); + // Speeds up loading for other included pages by setting it before progessing of mysql data! + $ports = dbFetchRows( + 'SELECT * FROM `bill_ports` AS B, `ports` AS P, `devices` AS D + WHERE B.bill_id = ? AND P.port_id = B.port_id + AND D.device_id = P.device_id', + array($bill_id) + ); - echo("

    Quota Bill

    "); + echo '

    + Bill : '.$bill_data['bill_name'].'

    '; - $percent = round(($total_data) / $bill_data['bill_quota'] * 100, 2); - $unit = "MB"; - $total_data = round($total_data, 2); - echo("Billing Period from " . $fromtext . " to " . $totext); - echo("
    Transferred ".format_bytes_billing($total_data)." of ".format_bytes_billing($bill_data['bill_quota'])." (".$percent."%)"); - echo("
    Average rate " . formatRates($rate_average)); + print_optionbar_start(); - $background = get_percentage_colours($percent); + echo "Bill » "; - echo("

    ".print_percentage_bar (350, 20, $perc, NULL, "ffffff", $background['left'], $percent . "%", "ffffff", $background['right'])."

    "); - - $type="&ave=yes"; - } - elseif ($bill_data['bill_type'] == "cdr") - { - // The customer is billed based on a CDR with 95th%ile overage - - echo("

    CDR / 95th Bill

    "); - - $unit = "kbps"; - $cdr = $bill_data['bill_cdr']; - $rate_95th = round($rate_95th, 2); - - $percent = round(($rate_95th) / $cdr * 100, 2); - - $type="&95th=yes"; - - echo("" . $fromtext . " to " . $totext . " -
    Measured ".format_si($rate_95th)."bps of ".format_si($cdr)."bps (".$percent."%) @ 95th %ile"); - - $background = get_percentage_colours($percent); - - echo("

    ".print_percentage_bar (350, 20, $percent, NULL, "ffffff", $background['left'], $percent . "%", "ffffff", $background['right'])."

    "); - - # echo("

    Billing Period : " . $fromtext . " to " . $totext . "
    - # " . $paidrate_text . "
    - # " . $total_data . "MB transfered in the current billing cycle.
    - # " . $rate_average . "Kbps Average during the current billing cycle.

    - # " . $rate_95th . "Kbps @ 95th Percentile. (" . $dir_95th . ") (" . $bill_text . ") - # - #
    "); + if (!$vars['view']) { + $vars['view'] = 'quick'; } - $lastmonth = dbFetchCell("SELECT UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 1 MONTH))"); - $yesterday = dbFetchCell("SELECT UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 1 DAY))"); - $rightnow = date(U); - - if ($vars['view'] == "accurate") { - - $bi = ""; - - $li = ""; - - $di = ""; - - $mi = ""; - + if ($vars['view'] == 'quick') { + echo ""; } - if ($null) - { - echo(" - @@ -268,39 +287,32 @@ if (bill_permitted($bill_id)) - "); + "; + }//end if - } - - if ($_GET['all']) - { - $ai = ""; - echo("

    Entire Data View

    $ai"); - } - elseif ($_GET['custom']) - { - $cg = ""; - echo("

    Custom Graph

    $cg"); - } - else - { - echo("

    Billing View

    $bi"); -# echo("

    Previous Bill View

    $li"); - echo("

    24 Hour View

    $di"); - echo("

    Monthly View

    $mi"); -# echo("
    Graph All Data (SLOW)"); - } - } # End if details + if ($_GET['all']) { + $ai = ''; + echo "

    Entire Data View

    $ai"; + } + else if ($_GET['custom']) { + $cg = ''; + echo "

    Custom Graph

    $cg"; + } + else { + echo "

    Billing View

    $bi"; + // echo("

    Previous Bill View

    $li"); + echo "

    24 Hour View

    $di"; + echo "

    Monthly View

    $mi"; + // echo("
    Graph All Data (SLOW)"); + }//end if + } //end if } -else -{ - include("includes/error-no-perm.inc.php"); -} - -?> +else { + include 'includes/error-no-perm.inc.php'; +}//end if diff --git a/html/pages/bill/actions.inc.php b/html/pages/bill/actions.inc.php index d55c2944cc..29afb6d3b4 100644 --- a/html/pages/bill/actions.inc.php +++ b/html/pages/bill/actions.inc.php @@ -1,8 +1,7 @@ = 1) { + $quota = array( + 'type' => 'tb', + 'select_tb' => ' selected', + 'data' => $tmp['tb'], + ); + } + else if (($tmp['gb'] >= 1) and ($tmp['gb'] < $base)) { + $quota = array( + 'type' => 'gb', + 'select_gb' => ' selected', + 'data' => $tmp['gb'], + ); + } + else if (($tmp['mb'] >= 1) and ($tmp['mb'] < $base)) { + $quota = array( + 'type' => 'mb', + 'select_mb' => ' selected', + 'data' => $tmp['mb'], + ); + } +}//end if -if ($bill_data['bill_type'] == "quota") { - $data = $bill_data['bill_quota']; - $tmp['mb'] = $data / $base / $base; - $tmp['gb'] = $data / $base / $base / $base; - $tmp['tb'] = $data / $base / $base / $base / $base; - if ($tmp['tb']>=1) { $quota = array("type" => "tb", "select_tb" => " selected", "data" => $tmp['tb']); } - elseif (($tmp['gb']>=1) and ($tmp['gb']<$base)) { $quota = array("type" => "gb", "select_gb" => " selected", "data" => $tmp['gb']); } - elseif (($tmp['mb']>=1) and ($tmp['mb']<$base)) { $quota = array("type" => "mb", "select_mb" => " selected", "data" => $tmp['mb']); } -} -if ($bill_data['bill_type'] == "cdr") { - $data = $bill_data['bill_cdr']; - $tmp['kbps'] = $data / $base; - $tmp['mbps'] = $data / $base / $base; - $tmp['gbps'] = $data / $base / $base / $base; - if ($tmp['gbps']>=1) { $cdr = array("type" => "gbps", "select_gbps" => " selected", "data" => $tmp['gbps']); } - elseif (($tmp['mbps']>=1) and ($tmp['mbps']<$base)) { $cdr = array("type" => "mbps", "select_mbps" => " selected", "data" => $tmp['mbps']); } - elseif (($tmp['kbps']>=1) and ($tmp['kbps']<$base)) { $cdr = array("type" => "kbps", "select_kbps" => " selected", "data" => $tmp['kbps']); } -} +if ($bill_data['bill_type'] == 'cdr') { + $data = $bill_data['bill_cdr']; + $tmp['kbps'] = ($data / $base); + $tmp['mbps'] = ($data / $base / $base); + $tmp['gbps'] = ($data / $base / $base / $base); + if ($tmp['gbps'] >= 1) { + $cdr = array( + 'type' => 'gbps', + 'select_gbps' => ' selected', + 'data' => $tmp['gbps'], + ); + } + else if (($tmp['mbps'] >= 1) and ($tmp['mbps'] < $base)) { + $cdr = array( + 'type' => 'mbps', + 'select_mbps' => ' selected', + 'data' => $tmp['mbps'], + ); + } + else if (($tmp['kbps'] >= 1) and ($tmp['kbps'] < $base)) { + $cdr = array( + 'type' => 'kbps', + 'select_kbps' => ' selected', + 'data' => $tmp['kbps'], + ); + } +}//end if ?>
    - +

    Bill Properties

    - " /> +
    @@ -51,17 +86,35 @@ if ($bill_data['bill_type'] == "cdr") {
    - -
    - /> + />
    - /> + />
    diff --git a/html/pages/device/edit/health.inc.php b/html/pages/device/edit/health.inc.php index 3d7d213527..922bb36c77 100644 --- a/html/pages/device/edit/health.inc.php +++ b/html/pages/device/edit/health.inc.php @@ -30,156 +30,158 @@ $sensor['sensor_id'], 'sensor_limit' => $sensor['sensor_limit'], 'sensor_limit_low' => $sensor['sensor_limit_low'], 'sensor_alert' => $sensor['sensor_alert']); - if($sensor['sensor_alert'] == 1) - { - $alert_status = 'checked'; - } - else - { - $alert_status = ''; - } - if ($sensor['sensor_custom'] == 'No') { - $custom = 'disabled'; - } else { - $custom = ''; - } - echo(' - - '.$sensor['sensor_class'].' - '.$sensor['sensor_type'].' - '.$sensor['sensor_descr'].' - '.$sensor['sensor_current'].' - -
    +foreach (dbFetchRows("SELECT * FROM sensors WHERE device_id = ? AND sensor_deleted='0'", array($device['device_id'])) as $sensor) { + $rollback[] = array( + 'sensor_id' => $sensor['sensor_id'], + 'sensor_limit' => $sensor['sensor_limit'], + 'sensor_limit_low' => $sensor['sensor_limit_low'], + 'sensor_alert' => $sensor['sensor_alert'], + ); + if ($sensor['sensor_alert'] == 1) { + $alert_status = 'checked'; + } + else { + $alert_status = ''; + } + + if ($sensor['sensor_custom'] == 'No') { + $custom = 'disabled'; + } + else { + $custom = ''; + } + + echo ' + + '.$sensor['sensor_class'].' + '.$sensor['sensor_type'].' + '.$sensor['sensor_descr'].' + '.$sensor['sensor_current'].' + +
    -
    - - -
    +
    + + +
    -
    - - - - - +
    + + + + + Clear custom - - -'); + + + '; } - ?>
    - - - - '); +foreach ($rollback as $reset_data) { + echo ' + + + + + '; } ?>
    - diff --git a/html/pages/device/edit/ipmi.inc.php b/html/pages/device/edit/ipmi.inc.php index f3971ca413..0aff50bdd7 100644 --- a/html/pages/device/edit/ipmi.inc.php +++ b/html/pages/device/edit/ipmi.inc.php @@ -1,31 +1,45 @@ "7") - { - $ipmi_hostname = mres($_POST['ipmi_hostname']); - $ipmi_username = mres($_POST['ipmi_username']); - $ipmi_password = mres($_POST['ipmi_password']); +if ($_POST['editing']) { + if ($_SESSION['userlevel'] > '7') { + $ipmi_hostname = mres($_POST['ipmi_hostname']); + $ipmi_username = mres($_POST['ipmi_username']); + $ipmi_password = mres($_POST['ipmi_password']); - if ($ipmi_hostname != '') { set_dev_attrib($device, 'ipmi_hostname', $ipmi_hostname); } else { del_dev_attrib($device, 'ipmi_hostname'); } - if ($ipmi_username != '') { set_dev_attrib($device, 'ipmi_username', $ipmi_username); } else { del_dev_attrib($device, 'ipmi_username'); } - if ($ipmi_password != '') { set_dev_attrib($device, 'ipmi_password', $ipmi_password); } else { del_dev_attrib($device, 'ipmi_password'); } + if ($ipmi_hostname != '') { + set_dev_attrib($device, 'ipmi_hostname', $ipmi_hostname); + } + else { + del_dev_attrib($device, 'ipmi_hostname'); + } - $update_message = "Device IPMI data updated."; - $updated = 1; - } - else - { - include("includes/error-no-perm.inc.php"); - } + if ($ipmi_username != '') { + set_dev_attrib($device, 'ipmi_username', $ipmi_username); + } + else { + del_dev_attrib($device, 'ipmi_username'); + } + + if ($ipmi_password != '') { + set_dev_attrib($device, 'ipmi_password', $ipmi_password); + } + else { + del_dev_attrib($device, 'ipmi_password'); + } + + $update_message = 'Device IPMI data updated.'; + $updated = 1; + } + else { + include 'includes/error-no-perm.inc.php'; + }//end if +}//end if + +if ($updated && $update_message) { + print_message($update_message); } - -if ($updated && $update_message) -{ - print_message($update_message); -} elseif ($update_message) { - print_error($update_message); +else if ($update_message) { + print_error($update_message); } ?> @@ -37,19 +51,19 @@ if ($updated && $update_message)
    - +
    - +
    - +
    diff --git a/html/pages/device/edit/modules.inc.php b/html/pages/device/edit/modules.inc.php index 36a53b3f10..3196171626 100644 --- a/html/pages/device/edit/modules.inc.php +++ b/html/pages/device/edit/modules.inc.php @@ -17,68 +17,57 @@ $module_status) -{ - echo(' +foreach ($config['poller_modules'] as $module => $module_status) { + echo(' '.$module.' -'); + '); - if($module_status == 1) - { - echo('Enabled'); - } - else - { - echo('Disabled'); - } + if($module_status == 1) { + echo('Enabled'); + } + else { + echo('Disabled'); + } - echo(' + echo(' -'); + '); - if (isset($attribs['poll_'.$module])) - { - if ($attribs['poll_'.$module]) - { - echo('Enabled'); - $module_checked = 'checked'; + if (isset($attribs['poll_'.$module])) { + if ($attribs['poll_'.$module]) { + echo('Enabled'); + $module_checked = 'checked'; + } + else { + echo('Disabled'); + $module_checked = ''; + } } - else - { - echo('Disabled'); - $module_checked = ''; + else { + if($module_status == 1) { + echo('Enabled'); + $module_checked = 'checked'; + } + else { + echo('Disabled'); + $module_checked = ''; + } } - } - else - { - if($module_status == 1) - { - echo('Enabled'); - $module_checked = 'checked'; - } - else - { - echo('Disabled'); - $module_checked = ''; - } - } - echo(' + echo(' -'); + '); - echo(' - -'); + echo(''); - echo(' + echo(' -'); + '); } ?> @@ -96,71 +85,56 @@ foreach ($config['poller_modules'] as $module => $module_status) $module_status) -{ - - echo(' +foreach ($config['discovery_modules'] as $module => $module_status) { + echo(' '.$module.' -'); + '); - if($module_status == 1) - { - echo('Enabled'); - } - else - { - echo('Disabled'); - } + if($module_status == 1) { + echo('Enabled'); + } + else { + echo('Disabled'); + } - echo(' + echo(' - -'); + '); - if (isset($attribs['discover_'.$module])) - { - if($attribs['discover_'.$module]) - { - echo('Enabled'); - $module_checked = 'checked'; + if (isset($attribs['discover_'.$module])) { + if($attribs['discover_'.$module]) { + echo('Enabled'); + $module_checked = 'checked'; + } + else { + echo('Disabled'); + $module_checked = ''; + } } - else - { - echo('Disabled'); - $module_checked = ''; + else { + if($module_status == 1) { + echo('Enabled'); + $module_checked = 'checked'; + } + else { + echo('Disabled'); + $module_checked = ''; + } } - } - else - { - if($module_status == 1) - { - echo('Enabled'); - $module_checked = 'checked'; - } - else - { - echo('Disabled'); - $module_checked = ''; - } - } - echo(' + echo(' - -'); + '); - echo(' - -'); + echo(''); - echo(' + echo(' - -'); + '); } echo(' diff --git a/html/pages/device/edit/ports.inc.php b/html/pages/device/edit/ports.inc.php index b382cf05a8..d8dc562e43 100644 --- a/html/pages/device/edit/ports.inc.php +++ b/html/pages/device/edit/ports.inc.php @@ -1,28 +1,26 @@ '); +echo '
    '; -if ($_POST['ignoreport']) -{ - if ($_SESSION['userlevel'] == '10') - { - include("includes/port-edit.inc.php"); - } +if ($_POST['ignoreport']) { + if ($_SESSION['userlevel'] == '10') { + include 'includes/port-edit.inc.php'; + } } -if ($updated && $update_message) -{ - print_message($update_message); -} elseif ($update_message) { - print_error($update_message); +if ($updated && $update_message) { + print_message($update_message); +} +else if ($update_message) { + print_error($update_message); } -echo("
    +echo "
    - "); + "; -echo(" +echo "
    @@ -41,14 +39,14 @@ echo("
    Index Name
    -"); +"; ?> '; + echo ''; + echo ''; + echo ''; - echo(""); - echo(""); - echo(""); - echo(""); + // Mark interfaces which are OperDown (but not AdminDown) yet not ignored or disabled, or up yet ignored or disabled + // - as to draw the attention to a possible problem. + $isportbad = ($port['ifOperStatus'] == 'down' && $port['ifAdminStatus'] != 'down') ? 1 : 0; + $dowecare = ($port['ignore'] == 0 && $port['disabled'] == 0) ? $isportbad : !$isportbad; + $outofsync = $dowecare ? " class='red'" : ''; - # Mark interfaces which are OperDown (but not AdminDown) yet not ignored or disabled, or up yet ignored or disabled - # - as to draw the attention to a possible problem. - $isportbad = ($port['ifOperStatus'] == 'down' && $port['ifAdminStatus'] != 'down') ? 1 : 0; - $dowecare = ($port['ignore'] == 0 && $port['disabled'] == 0) ? $isportbad : !$isportbad; - $outofsync = $dowecare ? " class='red'" : ""; + echo "'; - echo(""); + echo '"); + echo '"); - echo(""); + echo "\n"; - echo("\n"); + $row++; +}//end foreach - $row++; -} - -echo('
    '.$port['ifIndex'].''.$port['label'].''.$port['ifAdminStatus'].'
    ". $port['ifIndex']."".$port['label'] . "". $port['ifAdminStatus']."'.$port['ifOperStatus'].'". $port['ifOperStatus']."'; + echo "'; + echo ""); - echo(""); - echo(""); - echo("'; + echo "'; + echo ""); - echo(""); - echo(""); - echo("".$port['ifAlias'] . "
    '); -echo('
    '); -echo('
    '); - -?> +echo ''; +echo ''; +echo '
    '; diff --git a/html/pages/device/edit/services.inc.php b/html/pages/device/edit/services.inc.php index e6969a9fe9..1f2bc1d30e 100644 --- a/html/pages/device/edit/services.inc.php +++ b/html/pages/device/edit/services.inc.php @@ -1,29 +1,28 @@ = '10') { - include("includes/service-add.inc.php"); + include 'includes/service-add.inc.php'; } } if ($_POST['delsrv']) { if ($_SESSION['userlevel'] >= '10') { - include("includes/service-delete.inc.php"); + include 'includes/service-delete.inc.php'; } } if ($_POST['confirm-editsrv']) { - echo "yeah"; + echo 'yeah'; if ($_SESSION['userlevel'] >= '10') { - include("includes/service-edit.inc.php"); + include 'includes/service-edit.inc.php'; } } - if ($handle = opendir($config['install_dir'] . "/includes/services/")) { + if ($handle = opendir($config['install_dir'].'/includes/services/')) { while (false !== ($file = readdir($handle))) { - if ($file != "." && $file != ".." && !strstr($file, ".")) { + if ($file != '.' && $file != '..' && !strstr($file, '.')) { $servicesform .= ""; } } @@ -31,17 +30,17 @@ if (is_admin() === TRUE || is_read() === TRUE) { closedir($handle); } - $dev = device_by_id_cache($device['device_id']); - $devicesform = ""; + $dev = device_by_id_cache($device['device_id']); + $devicesform = "'; if ($updated) { - print_message("Device Settings Saved"); + print_message('Device Settings Saved'); } - if (dbFetchCell("SELECT COUNT(*) from `services` WHERE `device_id` = ?", array($device['device_id'])) > '0') { - $i = "1"; - foreach (dbFetchRows("select * from services WHERE device_id = ? ORDER BY service_type", array($device['device_id'])) as $service) { - $existform .= ""; + if (dbFetchCell('SELECT COUNT(*) from `services` WHERE `device_id` = ?', array($device['device_id'])) > '0') { + $i = '1'; + foreach (dbFetchRows('select * from services WHERE device_id = ? ORDER BY service_type', array($device['device_id'])) as $service) { + $existform .= "'; } } @@ -49,28 +48,29 @@ if (is_admin() === TRUE || is_read() === TRUE) { if ($existform) { echo '
    '; - if ($_POST['editsrv'] == "yes") { - include_once "includes/print-service-edit.inc.php"; - } else { + if ($_POST['editsrv'] == 'yes') { + include_once 'includes/print-service-edit.inc.php'; + } + else { echo " -

    Edit / Delete Service

    -
    +

    Edit / Delete Service

    +
    -
    - -
    - -
    -
    -
    -
    - -
    -
    +
    + +
    +
    - "; +
    +
    +
    + +
    +
    +
    + "; } echo '
    '; @@ -78,8 +78,8 @@ if (is_admin() === TRUE || is_read() === TRUE) { echo '
    '; - require_once "includes/print-service-add.inc.php"; - -} else { - include("includes/error-no-perm.inc.php"); -} \ No newline at end of file + include_once 'includes/print-service-add.inc.php'; +} +else { + include 'includes/error-no-perm.inc.php'; +} diff --git a/html/pages/device/edit/snmp.inc.php b/html/pages/device/edit/snmp.inc.php index 9e8a5b7b04..59c6bf4cd3 100644 --- a/html/pages/device/edit/snmp.inc.php +++ b/html/pages/device/edit/snmp.inc.php @@ -1,225 +1,240 @@ "7") - { - $community = mres($_POST['community']); - $snmpver = mres($_POST['snmpver']); - $transport = $_POST['transport'] ? mres($_POST['transport']) : $transport = "udp"; - $port = $_POST['port'] ? mres($_POST['port']) : $config['snmp']['port']; - $timeout = mres($_POST['timeout']); - $retries = mres($_POST['retries']); - $poller_group = mres($_POST['poller_group']); - $v3 = array ( - 'authlevel' => mres($_POST['authlevel']), - 'authname' => mres($_POST['authname']), - 'authpass' => mres($_POST['authpass']), - 'authalgo' => mres($_POST['authalgo']), - 'cryptopass' => mres($_POST['cryptopass']), - 'cryptoalgo' => mres($_POST['cryptoalgo']) - ); +if ($_POST['editing']) { + if ($_SESSION['userlevel'] > '7') { + $community = mres($_POST['community']); + $snmpver = mres($_POST['snmpver']); + $transport = $_POST['transport'] ? mres($_POST['transport']) : $transport = 'udp'; + $port = $_POST['port'] ? mres($_POST['port']) : $config['snmp']['port']; + $timeout = mres($_POST['timeout']); + $retries = mres($_POST['retries']); + $poller_group = mres($_POST['poller_group']); + $v3 = array( + 'authlevel' => mres($_POST['authlevel']), + 'authname' => mres($_POST['authname']), + 'authpass' => mres($_POST['authpass']), + 'authalgo' => mres($_POST['authalgo']), + 'cryptopass' => mres($_POST['cryptopass']), + 'cryptoalgo' => mres($_POST['cryptoalgo']), + ); - #FIXME needs better feedback - $update = array( - 'community' => $community, - 'snmpver' => $snmpver, - 'port' => $port, - 'transport' => $transport, - 'poller_group' => $poller_group - ); + // FIXME needs better feedback + $update = array( + 'community' => $community, + 'snmpver' => $snmpver, + 'port' => $port, + 'transport' => $transport, + 'poller_group' => $poller_group, + ); - if ($_POST['timeout']) { $update['timeout'] = $timeout; } - else { $update['timeout'] = array('NULL'); } - if ($_POST['retries']) { $update['retries'] = $retries; } - else { $update['retries'] = array('NULL'); } - - $update = array_merge($update, $v3); - - $device_tmp = deviceArray($device['hostname'], $community, $snmpver, $port, $transport, $v3); - if (isSNMPable($device_tmp)) { - $rows_updated = dbUpdate($update, 'devices', '`device_id` = ?',array($device['device_id'])); - - if ($rows_updated > 0) { - $update_message = $rows_updated . " Device record updated."; - $updated = 1; - } elseif ($rows_updated = '-1') { - $update_message = "Device record unchanged. No update necessary."; - $updated = -1; - } else { - $update_message = "Device record update error."; - $updated = 0; + if ($_POST['timeout']) { + $update['timeout'] = $timeout; + } + else { + $update['timeout'] = array('NULL'); } - } else { - $update_message = "Could not connect to device with new SNMP details"; - $updated = 0; - } - } -} -$device = dbFetchRow("SELECT * FROM `devices` WHERE `device_id` = ?", array($device['device_id'])); + if ($_POST['retries']) { + $update['retries'] = $retries; + } + else { + $update['retries'] = array('NULL'); + } + + $update = array_merge($update, $v3); + + $device_tmp = deviceArray($device['hostname'], $community, $snmpver, $port, $transport, $v3); + if (isSNMPable($device_tmp)) { + $rows_updated = dbUpdate($update, 'devices', '`device_id` = ?', array($device['device_id'])); + + if ($rows_updated > 0) { + $update_message = $rows_updated.' Device record updated.'; + $updated = 1; + } + else if ($rows_updated = '-1') { + $update_message = 'Device record unchanged. No update necessary.'; + $updated = -1; + } + else { + $update_message = 'Device record update error.'; + $updated = 0; + } + } + else { + $update_message = 'Could not connect to device with new SNMP details'; + $updated = 0; + } + }//end if +}//end if + +$device = dbFetchRow('SELECT * FROM `devices` WHERE `device_id` = ?', array($device['device_id'])); $descr = $device['purpose']; -echo('
    -
    '); -if ($updated && $update_message) -{ - print_message($update_message); -} elseif ($update_message) { - print_error($update_message); +echo '
    +
    '; +if ($updated && $update_message) { + print_message($update_message); +} +else if ($update_message) { + print_error($update_message); } -echo('
    -
    '); -echo(" -
    - -
    +echo '
    +
    '; + +echo " + + +
    - +
    - +
    - "; foreach ($config['snmp']['transports'] as $transport) { - echo(""); + + echo '>'.$transport.''; } -echo(" + +echo "
    -
    -
    +
    +
    - +
    - +
    -
    -
    +
    +
    - +
    - -
    - -
    + +
    +
    -
    -
    +
    +
    +
    - +
    - -
    - -
    + +
    + +
    - -
    - -
    + +
    + +
    - -
    - -
    + +
    + +
    - -
    - -
    + +
    + +
    - -
    - -
    + +
    + +
    - -
    - -
    + +
    +
    -
    "); +
    +
    '; -if ($config['distributed_poller'] === TRUE) { - echo(' -
    - -
    - + + '; - foreach (dbFetchRows("SELECT `id`,`group_name` FROM `poller_groups`") as $group) { - echo ''; + + echo '>'.$group['group_name'].''; } - echo(' - -
    -
    - '); -} + echo ' + +
    +
    + '; +}//end if -echo(' - - -'); +echo ' + + + '; ?> diff --git a/html/pages/device/entphysical.inc.php b/html/pages/device/entphysical.inc.php index af167b4ddc..7b5d956faa 100644 --- a/html/pages/device/entphysical.inc.php +++ b/html/pages/device/entphysical.inc.php @@ -1,13 +1,11 @@ "; @@ -33,7 +31,8 @@ function printEntPhysical($ent, $level, $class) if (count($sensor)) { $link = " href='device/device=".$device['device_id'].'/tab=health/metric='.$sensor['sensor_class']."/' onmouseover=\"return overlib('', LEFT,FGCOLOR,'#e5e5e5', BGCOLOR, '#c0c0c0', BORDER, 5, CELLPAD, 4, CAPCOLOR, '#050505');\" onmouseout=\"return nd();\""; } - } else { + } + else { unset($link); } diff --git a/html/pages/device/graphs.inc.php b/html/pages/device/graphs.inc.php index a275e71e31..e4bd13d84c 100644 --- a/html/pages/device/graphs.inc.php +++ b/html/pages/device/graphs.inc.php @@ -1,70 +1,68 @@ 'device', + 'device' => $device['device_id'], + 'tab' => 'graphs', +); -$link_array = array('page' => 'device', - 'device' => $device['device_id'], - 'tab' => 'graphs'); +$bg = '#ffffff'; -$bg="#ffffff"; - -echo('
    '); +echo '
    '; print_optionbar_start(); -echo("Graphs » "); +echo "Graphs » "; -foreach (dbFetchRows("SELECT * FROM device_graphs WHERE device_id = ? ORDER BY graph", array($device['device_id'])) as $graph) -{ - $section = $config['graph_types']['device'][$graph['graph']]['section']; - if ($section != "") { - $graph_enable[$section][$graph['graph']] = $graph['graph']; - } +foreach (dbFetchRows('SELECT * FROM device_graphs WHERE device_id = ? ORDER BY graph', array($device['device_id'])) as $graph) { + $section = $config['graph_types']['device'][$graph['graph']]['section']; + if ($section != '') { + $graph_enable[$section][$graph['graph']] = $graph['graph']; + } } // These are standard graphs we should have for all systems $graph_enable['poller']['poller_perf'] = 'device_poller_perf'; -$graph_enable['poller']['ping_perf'] = 'device_ping_perf'; +$graph_enable['poller']['ping_perf'] = 'device_ping_perf'; -$sep = ""; -foreach ($graph_enable as $section => $nothing) -{ - if (isset($graph_enable) && is_array($graph_enable[$section])) - { - $type = strtolower($section); - if (!$vars['group']) { $vars['group'] = $type; } - echo($sep); - if ($vars['group'] == $type) - { - echo(''); +$sep = ''; +foreach ($graph_enable as $section => $nothing) { + if (isset($graph_enable) && is_array($graph_enable[$section])) { + $type = strtolower($section); + if (!$vars['group']) { + $vars['group'] = $type; + } + + echo $sep; + if ($vars['group'] == $type) { + echo ''; + } + + echo generate_link(ucwords($type), $link_array, array('group' => $type)); + if ($vars['group'] == $type) { + echo ''; + } + + $sep = ' | '; } - echo(generate_link(ucwords($type),$link_array,array('group'=>$type))); - if ($vars['group'] == $type) - { - echo(""); - } - $sep = " | "; - } } -unset ($sep); + +unset($sep); print_optionbar_end(); $graph_enable = $graph_enable[$vars['group']]; -#foreach ($config['graph_types']['device'] as $graph => $entry) -foreach ($graph_enable as $graph => $entry) -{ - $graph_array = array(); - if ($graph_enable[$graph]) - { - $graph_title = $config['graph_types']['device'][$graph]['descr']; - $graph_array['type'] = "device_" . $graph; +// foreach ($config['graph_types']['device'] as $graph => $entry) +foreach ($graph_enable as $graph => $entry) { + $graph_array = array(); + if ($graph_enable[$graph]) { + $graph_title = $config['graph_types']['device'][$graph]['descr']; + $graph_array['type'] = 'device_'.$graph; - include("includes/print-device-graph.php"); - } + include 'includes/print-device-graph.php'; + } } -$pagetitle[] = "Graphs"; - -?> +$pagetitle[] = 'Graphs'; diff --git a/html/pages/device/graphs/netstats_ip_forward.inc.php b/html/pages/device/graphs/netstats_ip_forward.inc.php index cc728ac77c..eda137a788 100644 --- a/html/pages/device/graphs/netstats_ip_forward.inc.php +++ b/html/pages/device/graphs/netstats_ip_forward.inc.php @@ -1,11 +1,8 @@ 'device', - 'device' => $device['device_id'], - 'tab' => 'health'); +if ($storage) { + $datas[] = 'storage'; +} + +if ($diskio) { + $datas[] = 'diskio'; +} + +if ($charge) { + $datas[] = 'charge'; +} + +if ($temperatures) { + $datas[] = 'temperature'; +} + +if ($humidity) { + $datas[] = 'humidity'; +} + +if ($fans) { + $datas[] = 'fanspeed'; +} + +if ($volts) { + $datas[] = 'voltage'; +} + +if ($freqs) { + $datas[] = 'frequency'; +} + +if ($current) { + $datas[] = 'current'; +} + +if ($power) { + $datas[] = 'power'; +} + +if ($dBm) { + $datas[] = 'dbm'; +} + +if ($states) { + $datas[] = 'state'; +} + +if ($load) { + $datas[] = 'load'; +} + +$type_text['overview'] = 'Overview'; +$type_text['charge'] = 'Battery Charge'; +$type_text['temperature'] = 'Temperature'; +$type_text['humidity'] = 'Humidity'; +$type_text['mempool'] = 'Memory'; +$type_text['storage'] = 'Disk Usage'; +$type_text['diskio'] = 'Disk I/O'; +$type_text['processor'] = 'Processor'; +$type_text['voltage'] = 'Voltage'; +$type_text['fanspeed'] = 'Fanspeed'; +$type_text['frequency'] = 'Frequency'; +$type_text['current'] = 'Current'; +$type_text['power'] = 'Power'; +$type_text['dbm'] = 'dBm'; +$type_text['state'] = 'State'; +$type_text['load'] = 'Load'; + +$link_array = array( + 'page' => 'device', + 'device' => $device['device_id'], + 'tab' => 'health', +); print_optionbar_start(); -echo("Health » "); +echo "Health » "; -if (!$vars['metric']) { $vars['metric'] = "overview"; } +if (!$vars['metric']) { + $vars['metric'] = 'overview'; +} unset($sep); -foreach ($datas as $type) -{ - echo($sep); +foreach ($datas as $type) { + echo $sep; - if ($vars['metric'] == $type) - { echo(''); } - echo(generate_link($type_text[$type],$link_array,array('metric'=>$type))); - if ($vars['metric'] == $type) { echo(""); } - $sep = " | "; + if ($vars['metric'] == $type) { + echo ''; + } + + echo generate_link($type_text[$type], $link_array, array('metric' => $type)); + if ($vars['metric'] == $type) { + echo ''; + } + + $sep = ' | '; } print_optionbar_end(); -if (is_file("pages/device/health/".mres($vars['metric']).".inc.php")) -{ - include("pages/device/health/".mres($vars['metric']).".inc.php"); -} else { +if (is_file('pages/device/health/'.mres($vars['metric']).'.inc.php')) { + include 'pages/device/health/'.mres($vars['metric']).'.inc.php'; +} +else { + foreach ($datas as $type) { + if ($type != 'overview') { + $graph_title = $type_text[$type]; + $graph_array['type'] = 'device_'.$type; - foreach ($datas as $type) - { - if ($type != "overview") - { - - $graph_title = $type_text[$type]; - $graph_array['type'] = "device_".$type; - - include("includes/print-device-graph.php"); + include 'includes/print-device-graph.php'; + } } - } } -$pagetitle[] = "Health"; - -?> +$pagetitle[] = 'Health'; diff --git a/html/pages/device/health/charge.inc.php b/html/pages/device/health/charge.inc.php index 7282247bff..0750ae5935 100644 --- a/html/pages/device/health/charge.inc.php +++ b/html/pages/device/health/charge.inc.php @@ -1,9 +1,7 @@ +require 'sensors.inc.php'; diff --git a/html/pages/device/health/current.inc.php b/html/pages/device/health/current.inc.php index 0fa318a9b3..70bd4dc425 100644 --- a/html/pages/device/health/current.inc.php +++ b/html/pages/device/health/current.inc.php @@ -4,6 +4,4 @@ $class = "current"; $unit = "A"; $graph_type = "sensor_current"; -include("sensors.inc.php"); - -?> +require 'sensors.inc.php'; diff --git a/html/pages/device/health/humidity.inc.php b/html/pages/device/health/humidity.inc.php index 93b4772a3f..ffef7afa6a 100644 --- a/html/pages/device/health/humidity.inc.php +++ b/html/pages/device/health/humidity.inc.php @@ -4,6 +4,4 @@ $class = "humidity"; $unit = "%"; $graph_type = "sensor_humidity"; -include("sensors.inc.php"); - -?> +require 'sensors.inc.php'; diff --git a/html/pages/device/health/load.inc.php b/html/pages/device/health/load.inc.php index 399237aaef..18f5b5f5cd 100644 --- a/html/pages/device/health/load.inc.php +++ b/html/pages/device/health/load.inc.php @@ -1,9 +1,7 @@ +require 'sensors.inc.php'; diff --git a/html/pages/device/health/mempool.inc.php b/html/pages/device/health/mempool.inc.php index 6630c31476..613aa1250b 100644 --- a/html/pages/device/health/mempool.inc.php +++ b/html/pages/device/health/mempool.inc.php @@ -1,66 +1,72 @@ "); -echo(""); +echo "
    "; +echo '
    '; $i = '1'; -#FIXME css alternating colours +// FIXME css alternating colours +foreach (dbFetchRows('SELECT * FROM `mempools` WHERE device_id = ?', array($device['device_id'])) as $mempool) { + if (!is_integer($i / 2)) { + $row_colour = $list_colour_a; + } + else { + $row_colour = $list_colour_b; + } -foreach (dbFetchRows("SELECT * FROM `mempools` WHERE device_id = ?", array($device['device_id'])) as $mempool) -{ - if (!is_integer($i/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; } + if ($config['memcached']['enable'] === true) { + $state = $memcache->get('mempool-'.$mempool['mempool_id'].'-state'); + if ($debug) { + print_r($state); + } - if ($config['memcached']['enable'] === TRUE) - { - $state = $memcache->get('mempool-'.$mempool['mempool_id'].'-state'); - if($debug) { print_r($state); } - if(is_array($state)) { $mempool = array_merge($mempool, $state); } - unset($state); - } + if (is_array($state)) { + $mempool = array_merge($mempool, $state); + } - $text_descr = rewrite_entity_descr($mempool['mempool_descr']); + unset($state); + } - $mempool_url = "graphs/id=".$mempool['mempool_id']."/type=mempool_usage/"; - $mini_url = "graph.php?id=".$mempool['mempool_id']."&type=".$graph_type."&from=".$config['time']['day']."&to=".$config['time']['now']."&width=80&height=20&bg=f4f4f4"; + $text_descr = rewrite_entity_descr($mempool['mempool_descr']); - $mempool_popup = "onmouseover=\"return overlib('
    ".$device['hostname']." - ".$text_descr; - $mempool_popup .= "
    "; - $mempool_popup .= "', RIGHT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\""; + $mempool_url = 'graphs/id='.$mempool['mempool_id'].'/type=mempool_usage/'; + $mini_url = 'graph.php?id='.$mempool['mempool_id'].'&type='.$graph_type.'&from='.$config['time']['day'].'&to='.$config['time']['now'].'&width=80&height=20&bg=f4f4f4'; - $total = formatStorage($mempool['mempool_total']); - $used = formatStorage($mempool['mempool_used']); - $free = formatStorage($mempool['mempool_free']); + $mempool_popup = "onmouseover=\"return overlib('
    ".$device['hostname'].' - '.$text_descr; + $mempool_popup .= "
    "; + $mempool_popup .= "', RIGHT".$config['overlib_defaults'].');" onmouseout="return nd();"'; - $perc = round($mempool['mempool_used'] / $mempool['mempool_total'] * 100); + $total = formatStorage($mempool['mempool_total']); + $used = formatStorage($mempool['mempool_used']); + $free = formatStorage($mempool['mempool_free']); - $background = get_percentage_colours($percent); - $right_background = $background['right']; - $left_background = $background['left']; + $perc = round(($mempool['mempool_used'] / $mempool['mempool_total'] * 100)); - echo(" - - - - "); + $background = get_percentage_colours($percent); + $right_background = $background['right']; + $left_background = $background['left']; - echo(" + + + + '; - $graph_array['id'] = $mempool['mempool_id']; - $graph_array['type'] = $graph_type; + echo ""); + include 'includes/print-graphrow.inc.php'; - $i++; -} + echo ''; -echo("
    " . $text_descr . " - ".print_percentage_bar (400, 20, $perc, "$used / $total", "ffffff", $left_background, $free , "ffffff", $right_background)." - ".$perc."%
    "); + echo "
    ".$text_descr." + ".print_percentage_bar(400, 20, $perc, "$used / $total", 'ffffff', $left_background, $free, 'ffffff', $right_background).' + '.$perc.'%
    "; - include("includes/print-graphrow.inc.php"); + $graph_array['id'] = $mempool['mempool_id']; + $graph_array['type'] = $graph_type; - echo("
    "); -echo("
    "); + $i++; +}//end foreach -?> +echo ''; +echo '
    '; diff --git a/html/pages/device/health/processor.inc.php b/html/pages/device/health/processor.inc.php index bde4a3b3f1..725e37c21f 100644 --- a/html/pages/device/health/processor.inc.php +++ b/html/pages/device/health/processor.inc.php @@ -1,46 +1,43 @@ "); -echo(""); +echo "
    "; +echo '
    '; $i = '1'; -foreach (dbFetchRows("SELECT * FROM `processors` WHERE device_id = ?", array($device['device_id'])) as $proc) -{ - $proc_url = "graphs/id=".$proc['processor_id']."/type=processor_usage/"; +foreach (dbFetchRows('SELECT * FROM `processors` WHERE device_id = ?', array($device['device_id'])) as $proc) { + $proc_url = 'graphs/id='.$proc['processor_id'].'/type=processor_usage/'; - $mini_url = "graph.php?id=".$proc['processor_id']."&type=".$graph_type."&from=".$config['time']['day']."&to=".$config['time']['now']."&width=80&height=20&bg=f4f4f4"; + $mini_url = 'graph.php?id='.$proc['processor_id'].'&type='.$graph_type.'&from='.$config['time']['day'].'&to='.$config['time']['now'].'&width=80&height=20&bg=f4f4f4'; - $text_descr = $proc['processor_descr']; + $text_descr = $proc['processor_descr']; - $text_descr = rewrite_entity_descr($text_descr); + $text_descr = rewrite_entity_descr($text_descr); - $proc_popup = "onmouseover=\"return overlib('
    ".$device['hostname']." - ".$text_descr; - $proc_popup .= "
    "; - $proc_popup .= "', RIGHT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\""; + $proc_popup = "onmouseover=\"return overlib('
    ".$device['hostname'].' - '.$text_descr; + $proc_popup .= "
    "; + $proc_popup .= "', RIGHT".$config['overlib_defaults'].');" onmouseout="return nd();"'; - $percent = round($proc['processor_usage']); + $percent = round($proc['processor_usage']); - $background = get_percentage_colours($percent); + $background = get_percentage_colours($percent); - echo(" - + echo (" + - "); + '); - echo("
    " . $text_descr . "
    ".$text_descr." - ".print_percentage_bar (400, 20, $percent, $percent."%", "ffffff", $background['left'], (100 - $percent)."%" , "ffffff", $background['right'])." + ".print_percentage_bar(400, 20, $percent, $percent.'%', 'ffffff', $background['left'], (100 - $percent).'%', 'ffffff', $background['right']).'
    "); + echo "
    "; - $graph_array['id'] = $proc['processor_id']; - $graph_array['type'] = $graph_type; + $graph_array['id'] = $proc['processor_id']; + $graph_array['type'] = $graph_type; - include("includes/print-graphrow.inc.php"); -} + include 'includes/print-graphrow.inc.php'; +}//end foreach -echo("
    "); -echo(""); - -?> +echo ''; +echo ''; diff --git a/html/pages/device/health/state.inc.php b/html/pages/device/health/state.inc.php index 5463962196..9781248bea 100644 --- a/html/pages/device/health/state.inc.php +++ b/html/pages/device/health/state.inc.php @@ -1,7 +1,7 @@ "); +echo ''; -echo(" +echo ' - "); + '; $row = 1; -foreach (dbFetchRows("SELECT * FROM `storage` WHERE device_id = ? ORDER BY storage_descr", array($device['device_id'])) as $drive) -{ - if (is_integer($row/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; } +foreach (dbFetchRows('SELECT * FROM `storage` WHERE device_id = ? ORDER BY storage_descr', array($device['device_id'])) as $drive) { + if (is_integer($row / 2)) { + $row_colour = $list_colour_a; + } + else { + $row_colour = $list_colour_b; + } - $total = $drive['storage_size']; - $used = $drive['storage_used']; - $free = $drive['storage_free']; - $perc = round($drive['storage_perc'], 0); - $used = formatStorage($used); - $total = formatStorage($total); - $free = formatStorage($free); + $total = $drive['storage_size']; + $used = $drive['storage_used']; + $free = $drive['storage_free']; + $perc = round($drive['storage_perc'], 0); + $used = formatStorage($used); + $total = formatStorage($total); + $free = formatStorage($free); - $fs_url = "graphs/id=".$drive['storage_id']."/type=storage_usage/"; + $fs_url = 'graphs/id='.$drive['storage_id'].'/type=storage_usage/'; - $fs_popup = "onmouseover=\"return overlib('
    ".$device['hostname']." - ".$drive['storage_descr']; - $fs_popup .= "
    "; - $fs_popup .= "', RIGHT, FGCOLOR, '#e5e5e5');\" onmouseout=\"return nd();\""; + $fs_popup = "onmouseover=\"return overlib('
    ".$device['hostname'].' - '.$drive['storage_descr']; + $fs_popup .= "
    "; + $fs_popup .= "', RIGHT, FGCOLOR, '#e5e5e5');\" onmouseout=\"return nd();\""; - $background = get_percentage_colours($percent); + $background = get_percentage_colours($percent); - echo(""); + echo "'; - $graph_array['id'] = $drive['storage_id']; - $graph_array['type'] = $graph_type; + $graph_array['id'] = $drive['storage_id']; + $graph_array['type'] = $graph_type; - echo(""); + echo ''; - $row++; -} + $row++; +}//end foreach -echo("
    Drive Usage Free
    " . $drive['storage_descr'] . " - ".print_percentage_bar (400, 20, $perc, "$used / $total", "ffffff", $background['left'], $perc . "%", "ffffff", $background['right'])." - " . $free . "
    ".$drive['storage_descr']." + ".print_percentage_bar(400, 20, $perc, "$used / $total", 'ffffff', $background['left'], $perc.'%', 'ffffff', $background['right']).' + '.$free.'
    "); + echo "
    "; - include("includes/print-graphrow.inc.php"); + include 'includes/print-graphrow.inc.php'; - echo("
    "); - -?> +echo ''; diff --git a/html/pages/device/hrdevice.inc.php b/html/pages/device/hrdevice.inc.php index 68928187b3..d16a0ba839 100644 --- a/html/pages/device/hrdevice.inc.php +++ b/html/pages/device/hrdevice.inc.php @@ -1,70 +1,69 @@ '); +echo ''; // FIXME missing heading +foreach (dbFetchRows('SELECT * FROM `hrDevice` WHERE `device_id` = ? ORDER BY `hrDeviceIndex`', array($device['device_id'])) as $hrdevice) { + echo "'; -foreach (dbFetchRows("SELECT * FROM `hrDevice` WHERE `device_id` = ? ORDER BY `hrDeviceIndex`", array($device['device_id'])) as $hrdevice) -{ - echo(""); + if ($hrdevice['hrDeviceType'] == 'hrDeviceProcessor') { + $proc_id = dbFetchCell("SELECT processor_id FROM processors WHERE device_id = '".$device['device_id']."' AND hrDeviceIndex = '".$hrdevice['hrDeviceIndex']."'"); + $proc_url = 'device/device='.$device['device_id'].'/tab=health/metric=processor/'; + $proc_popup = "onmouseover=\"return overlib('
    ".$device['hostname'].' - '.$hrdevice['hrDeviceDescr']; + $proc_popup .= "
    "; + $proc_popup .= "', RIGHT".$config['overlib_defaults'].');" onmouseout="return nd();"'; + echo "'; - if ($hrdevice['hrDeviceType'] == "hrDeviceProcessor") - { - $proc_id = dbFetchCell("SELECT processor_id FROM processors WHERE device_id = '".$device['device_id']."' AND hrDeviceIndex = '".$hrdevice['hrDeviceIndex']."'"); - $proc_url = "device/device=".$device['device_id']."/tab=health/metric=processor/"; - $proc_popup = "onmouseover=\"return overlib('
    ".$device['hostname']." - ".$hrdevice['hrDeviceDescr']; - $proc_popup .= "
    "; - $proc_popup .= "', RIGHT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\""; - echo(""); + $graph_array['height'] = '20'; + $graph_array['width'] = '100'; + $graph_array['to'] = $config['time']['now']; + $graph_array['id'] = $proc_id; + $graph_array['type'] = 'processor_usage'; + $graph_array['from'] = $config['time']['day']; + $graph_array_zoom = $graph_array; + $graph_array_zoom['height'] = '150'; + $graph_array_zoom['width'] = '400'; - $graph_array['height'] = "20"; - $graph_array['width'] = "100"; - $graph_array['to'] = $config['time']['now']; - $graph_array['id'] = $proc_id; - $graph_array['type'] = 'processor_usage'; - $graph_array['from'] = $config['time']['day']; - $graph_array_zoom = $graph_array; $graph_array_zoom['height'] = "150"; $graph_array_zoom['width'] = "400"; + $mini_graph = overlib_link($proc_url, generate_graph_tag($graph_array), generate_graph_tag($graph_array_zoom), null); - $mini_graph = overlib_link($proc_url, generate_graph_tag($graph_array), generate_graph_tag($graph_array_zoom), NULL); - - echo(''); - } - elseif ($hrdevice['hrDeviceType'] == "hrDeviceNetwork") - { - $int = str_replace("network interface ", "", $hrdevice['hrDeviceDescr']); - $interface = dbFetchRow("SELECT * FROM ports WHERE device_id = ? AND ifDescr = ?", array($device['device_id'], $int)); - if ($interface['ifIndex']) - { - echo(""); - - $graph_array['height'] = "20"; - $graph_array['width'] = "100"; - $graph_array['to'] = $config['time']['now']; - $graph_array['id'] = $interface['port_id']; - $graph_array['type'] = 'port_bits'; - $graph_array['from'] = $config['time']['day']; - $graph_array_zoom = $graph_array; $graph_array_zoom['height'] = "150"; $graph_array_zoom['width'] = "400"; - - // FIXME click on graph should also link to port, but can't use generate_port_link here... - $mini_graph = overlib_link(generate_port_url($interface), generate_graph_tag($graph_array), generate_graph_tag($graph_array_zoom), NULL); - - echo(""); - } else { - echo(""); - echo(""); + echo ''; } - } else { - echo(""); - echo(""); - } + else if ($hrdevice['hrDeviceType'] == 'hrDeviceNetwork') { + $int = str_replace('network interface ', '', $hrdevice['hrDeviceDescr']); + $interface = dbFetchRow('SELECT * FROM ports WHERE device_id = ? AND ifDescr = ?', array($device['device_id'], $int)); + if ($interface['ifIndex']) { + echo ''; - echo(""); - echo(""); - echo(""); -} + $graph_array['height'] = '20'; + $graph_array['width'] = '100'; + $graph_array['to'] = $config['time']['now']; + $graph_array['id'] = $interface['port_id']; + $graph_array['type'] = 'port_bits'; + $graph_array['from'] = $config['time']['day']; + $graph_array_zoom = $graph_array; + $graph_array_zoom['height'] = '150'; + $graph_array_zoom['width'] = '400'; -echo('
    ".$hrdevice['hrDeviceIndex'].'
    ".$hrdevice['hrDeviceIndex']."".$hrdevice['hrDeviceDescr'].'".$hrdevice['hrDeviceDescr']."'.$mini_graph.'".generate_port_link($interface)."$mini_graph".stripslashes($hrdevice['hrDeviceDescr'])."'.$mini_graph.'".stripslashes($hrdevice['hrDeviceDescr'])."'.generate_port_link($interface).'".$hrdevice['hrDeviceType'].''.$hrdevice['hrDeviceStatus']."".$hrdevice['hrDeviceErrors'].''.$hrdevice['hrProcessorLoad']."
    '); + // FIXME click on graph should also link to port, but can't use generate_port_link here... + $mini_graph = overlib_link(generate_port_url($interface), generate_graph_tag($graph_array), generate_graph_tag($graph_array_zoom), null); -$pagetitle[] = "Inventory"; + echo "$mini_graph"; + } + else { + echo ''.stripslashes($hrdevice['hrDeviceDescr']).''; + echo ''; + } + } + else { + echo ''.stripslashes($hrdevice['hrDeviceDescr']).''; + echo ''; + }//end if -?> + echo ''.$hrdevice['hrDeviceType'].''.$hrdevice['hrDeviceStatus'].''; + echo ''.$hrdevice['hrDeviceErrors'].''.$hrdevice['hrProcessorLoad'].''; + echo ''; +}//end foreach + +echo ''; + +$pagetitle[] = 'Inventory'; diff --git a/html/pages/device/loadbalancer/ace_rservers.inc.php b/html/pages/device/loadbalancer/ace_rservers.inc.php index 52f1773c7e..c8b4b2acdc 100644 --- a/html/pages/device/loadbalancer/ace_rservers.inc.php +++ b/html/pages/device/loadbalancer/ace_rservers.inc.php @@ -33,10 +33,10 @@ echo ' Graphs: '; // "pkts" => "Packets", // "errors" => "Errors"); $graph_types = array( - 'curr' => 'CurrentConns', - 'failed' => 'FailedConns', - 'total' => 'TotalConns', - ); + 'curr' => 'CurrentConns', + 'failed' => 'FailedConns', + 'total' => 'TotalConns', +); foreach ($graph_types as $type => $descr) { echo "$type_sep"; @@ -66,7 +66,8 @@ foreach (dbFetchRows('SELECT * FROM `loadbalancer_rservers` WHERE `device_id` = if ($rserver['StateDescr'] == 'Server is now operational') { $rserver_class = 'green'; - } else { + } + else { $rserver_class = 'red'; } @@ -87,7 +88,7 @@ foreach (dbFetchRows('SELECT * FROM `loadbalancer_rservers` WHERE `device_id` = $graph_array['id'] = $rserver['rserver_id']; $graph_array['type'] = $graph_type; - include 'includes/print-graphrow.inc.php'; + require 'includes/print-graphrow.inc.php'; // include("includes/print-interface-graphs.inc.php"); echo ' diff --git a/html/pages/device/loadbalancer/ace_vservers.inc.php b/html/pages/device/loadbalancer/ace_vservers.inc.php index 65032709c8..68ebd1d3f5 100644 --- a/html/pages/device/loadbalancer/ace_vservers.inc.php +++ b/html/pages/device/loadbalancer/ace_vservers.inc.php @@ -2,84 +2,101 @@ print_optionbar_start(); -echo("Serverfarms » "); +echo "Serverfarms » "; -#$auth = TRUE; +// $auth = TRUE; +$menu_options = array('basic' => 'Basic'); -$menu_options = array('basic' => 'Basic', - ); +if (!$_GET['opta']) { + $_GET['opta'] = 'basic'; +} -if (!$_GET['opta']) { $_GET['opta'] = "basic"; } +$sep = ''; +foreach ($menu_options as $option => $text) { + if ($_GET['type'] == $option) { + echo ""; + } -$sep = ""; -foreach ($menu_options as $option => $text) -{ - if ($_GET['type'] == $option) { echo(""); } - echo(''.$text.''); - if ($_GET['type'] == $option) { echo(""); } - echo(" | "); + echo ''.$text.''; + if ($_GET['type'] == $option) { + echo ''; + } + + echo ' | '; } unset($sep); -echo(' Graphs: '); +echo ' Graphs: '; -$graph_types = array("bits" => "Bits", - "pkts" => "Packets", - "conns" => "Connections"); +$graph_types = array( + 'bits' => 'Bits', + 'pkts' => 'Packets', + 'conns' => 'Connections', +); -foreach ($graph_types as $type => $descr) -{ - echo("$type_sep"); - if ($_GET['opte'] == $type) { echo(""); } - echo(''.$descr.''); - echo(''.$text.''); - if ($_GET['opte'] == $type) { echo(""); } +foreach ($graph_types as $type => $descr) { + echo "$type_sep"; + if ($_GET['opte'] == $type) { + echo ""; + } - $type_sep = " | "; + echo ''.$descr.''; + echo ''.$text.''; + if ($_GET['opte'] == $type) { + echo ''; + } + + $type_sep = ' | '; } print_optionbar_end(); -echo("
    "); -$i = "0"; -foreach (dbFetchRows("SELECT * FROM `loadbalancer_vservers` WHERE `device_id` = ? ORDER BY `classmap`", array($device['device_id'])) as $vserver) -{ -if (is_integer($i/2)) { $bg_colour = $list_colour_a; } else { $bg_colour = $list_colour_b; } +echo "
    "; +$i = '0'; +foreach (dbFetchRows('SELECT * FROM `loadbalancer_vservers` WHERE `device_id` = ? ORDER BY `classmap`', array($device['device_id'])) as $vserver) { + if (is_integer($i / 2)) { + $bg_colour = $list_colour_a; + } + else { + $bg_colour = $list_colour_b; + } -if($vserver['serverstate'] == "inService") { $vserver_class="green"; } else { $vserver_class="red"; } + if ($vserver['serverstate'] == 'inService') { + $vserver_class = 'green'; + } + else { + $vserver_class = 'red'; + } -echo(""); -#echo(""); -echo(""); -#echo(""); -echo(""); -echo(""); - if ($_GET['type'] == "graphs") - { - echo(''); - echo(""; + // echo(""); + echo ''; + // echo(""); + echo "'; + echo ''; + if ($_GET['type'] == 'graphs') { + echo ''; + echo ' - "); - } + echo ' + + '; + } -echo(""); -echo(""); + echo ''; + echo ''; - $i++; -} + $i++; +}//end foreach -echo("
    " . $tunnel['local_addr'] . " » " . $tunnel['peer_addr'] . "" . $vserver['classmap'] . "" . $rserver['farm_id'] . "" . $vserver['serverstate'] . "
    "); - $graph_type = "vserver_" . $_GET['opte']; + echo "
    " . $tunnel['local_addr'] . " » " . $tunnel['peer_addr'] . "'.$vserver['classmap'].'" . $rserver['farm_id'] . "".$vserver['serverstate'].'
    '; + $graph_type = 'vserver_'.$_GET['opte']; -$graph_array['height'] = "100"; -$graph_array['width'] = "215"; -$graph_array['to'] = $config['time']['now']; -$graph_array['id'] = $vserver['classmap_id']; -$graph_array['type'] = $graph_type; + $graph_array['height'] = '100'; + $graph_array['width'] = '215'; + $graph_array['to'] = $config['time']['now']; + $graph_array['id'] = $vserver['classmap_id']; + $graph_array['type'] = $graph_type; -include("includes/print-graphrow.inc.php"); + include 'includes/print-graphrow.inc.php'; - echo(" -
    "); - -?> +echo ''; diff --git a/html/pages/device/loadbalancer/netscaler_vsvr.inc.php b/html/pages/device/loadbalancer/netscaler_vsvr.inc.php index a67d755b9a..91abc8204f 100644 --- a/html/pages/device/loadbalancer/netscaler_vsvr.inc.php +++ b/html/pages/device/loadbalancer/netscaler_vsvr.inc.php @@ -1,6 +1,6 @@ VServer
    » "); // echo('All'); diff --git a/html/pages/device/logs.inc.php b/html/pages/device/logs.inc.php index 0b8481a68f..11fd6914ba 100644 --- a/html/pages/device/logs.inc.php +++ b/html/pages/device/logs.inc.php @@ -1,41 +1,43 @@ Logging » "); +echo 'Logging » '; -if ($vars['section'] == "eventlog") { - echo(''); +if ($vars['section'] == 'eventlog') { + echo ''; } -echo(generate_link("Event Log" , $vars, array('section'=>'eventlog'))); -if ($vars['section'] == "eventlog") { - echo(""); + +echo generate_link('Event Log', $vars, array('section' => 'eventlog')); +if ($vars['section'] == 'eventlog') { + echo ''; } if (isset($config['enable_syslog']) && $config['enable_syslog'] == 1) { - echo(" | "); + echo ' | '; - if ($vars['section'] == "syslog") { - echo(''); + if ($vars['section'] == 'syslog') { + echo ''; } - echo(generate_link("Syslog" , $vars, array('section'=>'syslog'))); - if ($vars['section'] == "syslog") { - echo(""); + + echo generate_link('Syslog', $vars, array('section' => 'syslog')); + if ($vars['section'] == 'syslog') { + echo ''; } } -switch ($vars['section']) -{ - case 'syslog': - case 'eventlog': - include('pages/device/logs/'.$vars['section'].'.inc.php'); - break; - default: - print_optionbar_end(); - echo(report_this('Unknown section '.$vars['section'])); - break; -} +switch ($vars['section']) { + case 'syslog': + case 'eventlog': + include 'pages/device/logs/'.$vars['section'].'.inc.php'; + break; -?> + default: + print_optionbar_end(); + echo report_this('Unknown section '.$vars['section']); + break; +} diff --git a/html/pages/device/logs/eventlog.inc.php b/html/pages/device/logs/eventlog.inc.php index aec8bdd98c..7d5204f1cd 100644 --- a/html/pages/device/logs/eventlog.inc.php +++ b/html/pages/device/logs/eventlog.inc.php @@ -2,51 +2,49 @@
    +echo '
    Eventlog entries
    - '); +
    '; -foreach ($entries as $entry) -{ - include("includes/print-event.inc.php"); +foreach ($entries as $entry) { + include 'includes/print-event.inc.php'; } -echo('
    -
    '); +echo ' + '; -$pagetitle[] = "Events"; - -?> +$pagetitle[] = 'Events'; diff --git a/html/pages/device/logs/syslog.inc.php b/html/pages/device/logs/syslog.inc.php index 7aae3b8e0c..1284ad157f 100644 --- a/html/pages/device/logs/syslog.inc.php +++ b/html/pages/device/logs/syslog.inc.php @@ -3,53 +3,54 @@
    +$sql = "SELECT *, DATE_FORMAT(timestamp, '".$config['dateformat']['mysql']['compact']."') AS date from syslog WHERE device_id = ? $where"; +$sql .= ' ORDER BY timestamp DESC LIMIT 1000'; +echo '
    Syslog entries
    - '); -foreach (dbFetchRows($sql, $param) as $entry) { include("includes/print-syslog.inc.php"); } -echo('
    -
    '); -$pagetitle[] = "Syslog"; + '; +foreach (dbFetchRows($sql, $param) as $entry) { + include 'includes/print-syslog.inc.php'; +} -?> +echo '
    + '; +$pagetitle[] = 'Syslog'; diff --git a/html/pages/device/map.inc.php b/html/pages/device/map.inc.php index 522de36a51..918f62e7fc 100644 --- a/html/pages/device/map.inc.php +++ b/html/pages/device/map.inc.php @@ -12,8 +12,6 @@ * the source code distribution for details. */ -$pagetitle[] = "Map"; +$pagetitle[] = 'Map'; -require_once "includes/print-map.inc.php"; - -?> +require_once 'includes/print-map.inc.php'; diff --git a/html/pages/device/munin.inc.php b/html/pages/device/munin.inc.php index 67fd22d6e0..e12279687e 100644 --- a/html/pages/device/munin.inc.php +++ b/html/pages/device/munin.inc.php @@ -1,75 +1,72 @@ 'device', + 'device' => $device['device_id'], + 'tab' => 'munin', +); -$link_array = array('page' => 'device', - 'device' => $device['device_id'], - 'tab' => 'munin'); +$bg = '#ffffff'; -$bg="#ffffff"; - -echo('
    '); +echo '
    '; print_optionbar_start(); -echo("Munin » "); +echo "Munin » "; -$sep = ""; +$sep = ''; -foreach (dbFetchRows("SELECT * FROM munin_plugins WHERE device_id = ? ORDER BY mplug_category, mplug_type", array($device['device_id'])) as $mplug) -{ -# if (strlen($mplug['mplug_category']) == 0) { $mplug['mplug_category'] = "general"; } else { } - $graph_enable[$mplug['mplug_category']][$mplug['mplug_type']]['id'] = $mplug['mplug_id']; - $graph_enable[$mplug['mplug_category']][$mplug['mplug_type']]['title'] = $mplug['mplug_title']; - $graph_enable[$mplug['mplug_category']][$mplug['mplug_type']]['plugin'] = $mplug['mplug_type']; +foreach (dbFetchRows('SELECT * FROM munin_plugins WHERE device_id = ? ORDER BY mplug_category, mplug_type', array($device['device_id'])) as $mplug) { + // if (strlen($mplug['mplug_category']) == 0) { $mplug['mplug_category'] = "general"; } else { } + $graph_enable[$mplug['mplug_category']][$mplug['mplug_type']]['id'] = $mplug['mplug_id']; + $graph_enable[$mplug['mplug_category']][$mplug['mplug_type']]['title'] = $mplug['mplug_title']; + $graph_enable[$mplug['mplug_category']][$mplug['mplug_type']]['plugin'] = $mplug['mplug_type']; } -foreach ($graph_enable as $section => $nothing) -{ - if (isset($graph_enable) && is_array($graph_enable[$section])) - { - $type = strtolower($section); - if (!$vars['group']) { $vars['group'] = $type; } - echo($sep); - if ($vars['group'] == $type) - { - echo(''); +foreach ($graph_enable as $section => $nothing) { + if (isset($graph_enable) && is_array($graph_enable[$section])) { + $type = strtolower($section); + if (!$vars['group']) { + $vars['group'] = $type; + } + + echo $sep; + if ($vars['group'] == $type) { + echo ''; + } + + echo generate_link(ucwords($type), $link_array, array('group' => $type)); + if ($vars['group'] == $type) { + echo ''; + } + + $sep = ' | '; } - echo(generate_link(ucwords($type),$link_array,array('group'=>$type))); - if ($vars['group'] == $type) - { - echo(""); - } - $sep = " | "; - } } -unset ($sep); +unset($sep); print_optionbar_end(); $graph_enable = $graph_enable[$vars['group']]; -#foreach ($config['graph_types']['device'] as $graph => $entry) -foreach ($graph_enable as $graph => $entry) -{ - $graph_array = array(); - if ($graph_enable[$graph]) - { - if (!empty($entry['plugin'])) - { - $graph_title = $entry['title']; - $graph_array['type'] = "munin_graph"; - $graph_array['device'] = $device['device_id']; - $graph_array['plugin'] = $entry['plugin']; - } else { - $graph_title = $config['graph_types']['device'][$graph]['descr']; - $graph_array['type'] = "device_" . $graph; - } +// foreach ($config['graph_types']['device'] as $graph => $entry) +foreach ($graph_enable as $graph => $entry) { + $graph_array = array(); + if ($graph_enable[$graph]) { + if (!empty($entry['plugin'])) { + $graph_title = $entry['title']; + $graph_array['type'] = 'munin_graph'; + $graph_array['device'] = $device['device_id']; + $graph_array['plugin'] = $entry['plugin']; + } + else { + $graph_title = $config['graph_types']['device'][$graph]['descr']; + $graph_array['type'] = 'device_'.$graph; + } - include("includes/print-device-graph.php"); - } + include 'includes/print-device-graph.php'; + } } -$pagetitle[] = "Graphs"; - -?> +$pagetitle[] = 'Graphs'; diff --git a/html/pages/device/overview.inc.php b/html/pages/device/overview.inc.php index aac3b2ca23..13227e0136 100644 --- a/html/pages/device/overview.inc.php +++ b/html/pages/device/overview.inc.php @@ -12,8 +12,18 @@ $services['up'] = dbFetchCell("SELECT COUNT(service_id) FROM `services` WH $services['down'] = dbFetchCell("SELECT COUNT(service_id) FROM `services` WHERE `device_id` = ? AND `service_status` = '0' AND `service_ignore` = '0'", array($device['device_id'])); $services['disabled'] = dbFetchCell("SELECT COUNT(service_id) FROM `services` WHERE `device_id` = ? AND `service_ignore` = '1'", array($device['device_id'])); -if ($services['down']) { $services_colour = $warn_colour_a; } else { $services_colour = $list_colour_a; } -if ($ports['down']) { $ports_colour = $warn_colour_a; } else { $ports_colour = $list_colour_a; } +if ($services['down']) { + $services_colour = $warn_colour_a; +} +else { + $services_colour = $list_colour_a; +} +if ($ports['down']) { + $ports_colour = $warn_colour_a; +} +else { + $ports_colour = $list_colour_a; +} echo('
    @@ -25,39 +35,41 @@ echo('
    '); -include("includes/dev-overview-data.inc.php"); +require 'includes/dev-overview-data.inc.php'; Plugins::call('device_overview_container',array($device)); -include("overview/ports.inc.php"); +require 'overview/ports.inc.php'; echo('
    '); // Right Pane -include("overview/processors.inc.php"); -include("overview/mempools.inc.php"); -include("overview/storage.inc.php"); +require 'overview/processors.inc.php'; +require 'overview/mempools.inc.php'; +require 'overview/storage.inc.php'; -if(is_array($entity_state['group']['c6kxbar'])) { include("overview/c6kxbar.inc.php"); } +if(is_array($entity_state['group']['c6kxbar'])) { + require 'overview/c6kxbar.inc.php'; +} -include("overview/toner.inc.php"); -include("overview/sensors/charge.inc.php"); -include("overview/sensors/temperatures.inc.php"); -include("overview/sensors/humidity.inc.php"); -include("overview/sensors/fanspeeds.inc.php"); -include("overview/sensors/dbm.inc.php"); -include("overview/sensors/voltages.inc.php"); -include("overview/sensors/current.inc.php"); -include("overview/sensors/power.inc.php"); -include("overview/sensors/frequencies.inc.php"); -include("overview/sensors/load.inc.php"); -include("overview/sensors/state.inc.php"); -include("overview/eventlog.inc.php"); -include("overview/services.inc.php"); -include("overview/syslog.inc.php"); +require 'overview/toner.inc.php'; +require 'overview/sensors/charge.inc.php'; +require 'overview/sensors/temperatures.inc.php'; +require 'overview/sensors/humidity.inc.php'; +require 'overview/sensors/fanspeeds.inc.php'; +require 'overview/sensors/dbm.inc.php'; +require 'overview/sensors/voltages.inc.php'; +require 'overview/sensors/current.inc.php'; +require 'overview/sensors/power.inc.php'; +require 'overview/sensors/frequencies.inc.php'; +require 'overview/sensors/load.inc.php'; +require 'overview/sensors/state.inc.php'; +require 'overview/eventlog.inc.php'; +require 'overview/services.inc.php'; +require 'overview/syslog.inc.php'; echo('
    '); -#include("overview/current.inc.php"); +#require 'overview/current.inc.php"); ?> diff --git a/html/pages/device/overview/c6kxbar.inc.php b/html/pages/device/overview/c6kxbar.inc.php index 14f5d54e48..eb04e0a7db 100644 --- a/html/pages/device/overview/c6kxbar.inc.php +++ b/html/pages/device/overview/c6kxbar.inc.php @@ -1,102 +1,99 @@ -
    -
    -
    -
    '); -echo(''); -echo(" Catalyst 6k Crossbar"); -echo('
    - '); +echo '
    +
    +
    +
    +
    '; +echo ''; +echo " Catalyst 6k Crossbar"; +echo '
    +
    '; -foreach ($entity_state['group']['c6kxbar'] as $index => $entry) -{ - // FIXME i'm not sure if this is the correct way to decide what entphysical index it is. slotnum+1? :> - $entity = dbFetchRow("SELECT * FROM entPhysical WHERE device_id = ? AND entPhysicalIndex = ?", array($device['device_id'], $index+1)); +foreach ($entity_state['group']['c6kxbar'] as $index => $entry) { + // FIXME i'm not sure if this is the correct way to decide what entphysical index it is. slotnum+1? :> + $entity = dbFetchRow('SELECT * FROM entPhysical WHERE device_id = ? AND entPhysicalIndex = ?', array($device['device_id'], $index + 1)); - echo(" + echo " - - "); + echo ' + '; - foreach ($entity_state['group']['c6kxbar'][$index] as $subindex => $fabric) - { - if (is_numeric($subindex)) - { - if ($fabric['cc6kxbarModuleChannelFabStatus'] == "ok") - { - $fabric['mode_class'] = "green"; - } else { - $fabric['mode_class'] = "red"; - } + foreach ($entity_state['group']['c6kxbar'][$index] as $subindex => $fabric) { + if (is_numeric($subindex)) { + if ($fabric['cc6kxbarModuleChannelFabStatus'] == 'ok') { + $fabric['mode_class'] = 'green'; + } + else { + $fabric['mode_class'] = 'red'; + } - $percent_in = $fabric['cc6kxbarStatisticsInUtil']; - $background_in = get_percentage_colours($percent_in); + $percent_in = $fabric['cc6kxbarStatisticsInUtil']; + $background_in = get_percentage_colours($percent_in); - $percent_out = $fabric['cc6kxbarStatisticsOutUtil']; - $background_out = get_percentage_colours($percent_out); + $percent_out = $fabric['cc6kxbarStatisticsOutUtil']; + $background_out = get_percentage_colours($percent_out); - $graph_array = array(); - $graph_array['height'] = "100"; - $graph_array['width'] = "210"; - $graph_array['to'] = $config['time']['now']; - $graph_array['device'] = $device['device_id']; - $graph_array['mod'] = $index; - $graph_array['chan'] = $subindex; - $graph_array['type'] = "c6kxbar_util"; - $graph_array['from'] = $config['time']['day']; - $graph_array['legend'] = "no"; + $graph_array = array(); + $graph_array['height'] = '100'; + $graph_array['width'] = '210'; + $graph_array['to'] = $config['time']['now']; + $graph_array['device'] = $device['device_id']; + $graph_array['mod'] = $index; + $graph_array['chan'] = $subindex; + $graph_array['type'] = 'c6kxbar_util'; + $graph_array['from'] = $config['time']['day']; + $graph_array['legend'] = 'no'; - $link_array = $graph_array; - $link_array['page'] = "graphs"; - unset($link_array['height'], $link_array['width'], $link_array['legend']); - $link = generate_url($link_array); + $link_array = $graph_array; + $link_array['page'] = 'graphs'; + unset($link_array['height'], $link_array['width'], $link_array['legend']); + $link = generate_url($link_array); - $text_descr = $entity['entPhysicalName'] . " - Fabric " . $subindex; + $text_descr = $entity['entPhysicalName'].' - Fabric '.$subindex; - $overlib_content = generate_overlib_content($graph_array, $device['hostname'] . " - " . $text_descr); + $overlib_content = generate_overlib_content($graph_array, $device['hostname'].' - '.$text_descr); - $graph_array['width'] = 80; $graph_array['height'] = 20; $graph_array['bg'] = 'ffffff00'; # the 00 at the end makes the area transparent. + $graph_array['width'] = 80; + $graph_array['height'] = 20; + $graph_array['bg'] = 'ffffff00'; + // the 00 at the end makes the area transparent. + $minigraph = generate_graph_tag($graph_array); - $minigraph = generate_graph_tag($graph_array); + echo (' + + + - - - - - - - "); - } - } -} - -echo("
    ".$entity['entPhysicalName'].""); + "; - switch ($entry['']['cc6kxbarModuleModeSwitchingMode']) - { - case "busmode": - # echo 'Bus'; + switch ($entry['']['cc6kxbarModuleModeSwitchingMode']) { + case 'busmode': + // echo 'Bus'; break; - case "crossbarmode": + + case 'crossbarmode': echo 'Crossbar'; break; - case "dcefmode": + + case 'dcefmode': echo 'DCEF'; break; - default: + + default: echo $entry['']['cc6kxbarModuleModeSwitchingMode']; } - echo("
    Fabric '.$subindex." - Fabric ".$subindex."". - - $fabric['cc6kxbarModuleChannelFabStatus']."".formatRates($fabric['cc6kxbarModuleChannelSpeed']*1000000)."".overlib_link($link, $minigraph, $overlib_content)."".print_percentage_bar (125, 20, $percent_in, "Ingress", "ffffff", $background['left'], $percent_in . "%", "ffffff", $background['right'])."".print_percentage_bar (125, 20, $percent_out, "Egress", "ffffff", $background['left'], $percent_out . "%", "ffffff", $background['right'])."
    "); -echo("
    "); -echo("
    "); -echo("
    "); -echo("
    "); - -?> +echo ' '; +echo '
    '; +echo ' '; +echo ' '; +echo ''; diff --git a/html/pages/device/overview/eventlog.inc.php b/html/pages/device/overview/eventlog.inc.php index ff235aa4a8..d555118136 100644 --- a/html/pages/device/overview/eventlog.inc.php +++ b/html/pages/device/overview/eventlog.inc.php @@ -1,25 +1,22 @@ '); - echo('
    +echo '
    '; +echo '
    -
    '); -echo(''); -echo(" Recent Events"); -echo('
    - '); +
    '; +echo ''; +echo " Recent Events"; +echo '
    +
    '; $eventlog = dbFetchRows("SELECT *,DATE_FORMAT(datetime, '".$config['dateformat']['mysql']['compact']."') as humandate FROM `eventlog` WHERE `host` = ? ORDER BY `datetime` DESC LIMIT 0,10", array($device['device_id'])); -foreach ($eventlog as $entry) -{ - include("includes/print-event-short.inc.php"); +foreach ($eventlog as $entry) { + include 'includes/print-event-short.inc.php'; } -echo("
    "); -echo('
    '); -echo('
    '); -echo('
    '); -echo('
    '); - -?> +echo ''; +echo '
    '; +echo ''; +echo ''; +echo ''; diff --git a/html/pages/device/overview/generic/sensor.inc.php b/html/pages/device/overview/generic/sensor.inc.php index 6194c37c00..36bc05cd5d 100644 --- a/html/pages/device/overview/generic/sensor.inc.php +++ b/html/pages/device/overview/generic/sensor.inc.php @@ -1,75 +1,71 @@ +if (count($sensors)) { + echo '
    -
    -
    -
    '); - echo(' ' . $sensor_type . ''); - echo('
    - '); - foreach ($sensors as $sensor) - { - if ($config['memcached']['enable'] === TRUE) - { - $sensor['sensor_current'] = $memcache->get('sensor-'.$sensor['sensor_id'].'-value'); - } +
    +
    +
    '; + echo ' '.$sensor_type.''; + echo '
    +
    '; + foreach ($sensors as $sensor) { + if ($config['memcached']['enable'] === true) { + $sensor['sensor_current'] = $memcache->get('sensor-'.$sensor['sensor_id'].'-value'); + } - if (empty($sensor['sensor_current'])) - { - $sensor['sensor_current'] = "NaN"; - } + if (empty($sensor['sensor_current'])) { + $sensor['sensor_current'] = 'NaN'; + } - // FIXME - make this "four graphs in popup" a function/include and "small graph" a function. - // FIXME - So now we need to clean this up and move it into a function. Isn't it just "print-graphrow"? - // FIXME - DUPLICATED IN health/sensors + // FIXME - make this "four graphs in popup" a function/include and "small graph" a function. + // FIXME - So now we need to clean this up and move it into a function. Isn't it just "print-graphrow"? + // FIXME - DUPLICATED IN health/sensors + $graph_colour = str_replace('#', '', $row_colour); - $graph_colour = str_replace("#", "", $row_colour); + $graph_array = array(); + $graph_array['height'] = '100'; + $graph_array['width'] = '210'; + $graph_array['to'] = $config['time']['now']; + $graph_array['id'] = $sensor['sensor_id']; + $graph_array['type'] = $graph_type; + $graph_array['from'] = $config['time']['day']; + $graph_array['legend'] = 'no'; - $graph_array = array(); - $graph_array['height'] = "100"; - $graph_array['width'] = "210"; - $graph_array['to'] = $config['time']['now']; - $graph_array['id'] = $sensor['sensor_id']; - $graph_array['type'] = $graph_type; - $graph_array['from'] = $config['time']['day']; - $graph_array['legend'] = "no"; + $link_array = $graph_array; + $link_array['page'] = 'graphs'; + unset($link_array['height'], $link_array['width'], $link_array['legend']); + $link = generate_url($link_array); - $link_array = $graph_array; - $link_array['page'] = "graphs"; - unset($link_array['height'], $link_array['width'], $link_array['legend']); - $link = generate_url($link_array); + $overlib_content = '

    '.$device['hostname'].' - '.$sensor['sensor_descr'].'

    '; + foreach (array('day', 'week', 'month', 'year') as $period) { + $graph_array['from'] = $config['time'][$period]; + $overlib_content .= str_replace('"', "\'", generate_graph_tag($graph_array)); + } - $overlib_content = '

    '.$device['hostname']." - ".$sensor['sensor_descr']."

    "; - foreach (array('day','week','month','year') as $period) - { - $graph_array['from'] = $config['time'][$period]; - $overlib_content .= str_replace('"', "\'", generate_graph_tag($graph_array)); - } - $overlib_content .= "
    "; + $overlib_content .= '
    '; - $graph_array['width'] = 80; $graph_array['height'] = 20; $graph_array['bg'] = 'ffffff00'; # the 00 at the end makes the area transparent. - $graph_array['from'] = $config['time']['day']; - $sensor_minigraph = generate_graph_tag($graph_array); + $graph_array['width'] = 80; + $graph_array['height'] = 20; + $graph_array['bg'] = 'ffffff00'; + // the 00 at the end makes the area transparent. + $graph_array['from'] = $config['time']['day']; + $sensor_minigraph = generate_graph_tag($graph_array); - $sensor['sensor_descr'] = truncate($sensor['sensor_descr'], 48, ''); + $sensor['sensor_descr'] = truncate($sensor['sensor_descr'], 48, ''); - echo(" - - - - "); - } + echo ' + + + + '; + }//end foreach - echo("
    ".overlib_link($link, $sensor['sensor_descr'], $overlib_content)."".overlib_link($link, $sensor_minigraph, $overlib_content)."".overlib_link($link, " $sensor['sensor_limit'] ? "style='color: red'" : '') . '>' . $sensor['sensor_current'] . $sensor_unit . "", $overlib_content)."
    '.overlib_link($link, $sensor['sensor_descr'], $overlib_content).''.overlib_link($link, $sensor_minigraph, $overlib_content).''.overlib_link($link, ' $sensor['sensor_limit'] ? "style='color: red'" : '').'>'.$sensor['sensor_current'].$sensor_unit.'', $overlib_content).'
    "); - echo("
    "); - echo("
    "); - echo("
    "); - echo("
    "); -} - -?> + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; +}//end if diff --git a/html/pages/device/overview/mempools.inc.php b/html/pages/device/overview/mempools.inc.php index 3d35a8d554..0699872416 100644 --- a/html/pages/device/overview/mempools.inc.php +++ b/html/pages/device/overview/mempools.inc.php @@ -1,76 +1,77 @@ +if (count($mempools)) { + echo '
    -
    -
    -
    -'); - echo(''); - echo(" Memory Pools"); - echo(' -
    - -'); +
    +
    +
    + '; + echo ''; + echo " Memory Pools"; + echo ' +
    +
    + '; - foreach ($mempools as $mempool) - { + foreach ($mempools as $mempool) { + if ($config['memcached']['enable'] === true) { + $state = $memcache->get('mempool-'.$mempool['mempool_id'].'-state'); + if ($debug) { + print_r($state); + } - if ($config['memcached']['enable'] === TRUE) - { - $state = $memcache->get('mempool-'.$mempool['mempool_id'].'-state'); - if($debug) { print_r($state); } - if(is_array($state)) { $mempool = array_merge($mempool, $state); } - unset($state); - } + if (is_array($state)) { + $mempool = array_merge($mempool, $state); + } - $percent= round($mempool['mempool_perc'],0); - $text_descr = rewrite_entity_descr($mempool['mempool_descr']); - $total = formatStorage($mempool['mempool_total']); - $used = formatStorage($mempool['mempool_used']); - $free = formatStorage($mempool['mempool_free']); - $background = get_percentage_colours($percent); + unset($state); + } - $graph_array = array(); - $graph_array['height'] = "100"; - $graph_array['width'] = "210"; - $graph_array['to'] = $config['time']['now']; - $graph_array['id'] = $mempool['mempool_id']; - $graph_array['type'] = $graph_type; - $graph_array['from'] = $config['time']['day']; - $graph_array['legend'] = "no"; + $percent = round($mempool['mempool_perc'], 0); + $text_descr = rewrite_entity_descr($mempool['mempool_descr']); + $total = formatStorage($mempool['mempool_total']); + $used = formatStorage($mempool['mempool_used']); + $free = formatStorage($mempool['mempool_free']); + $background = get_percentage_colours($percent); - $link_array = $graph_array; - $link_array['page'] = "graphs"; - unset($link_array['height'], $link_array['width'], $link_array['legend']); - $link = generate_url($link_array); + $graph_array = array(); + $graph_array['height'] = '100'; + $graph_array['width'] = '210'; + $graph_array['to'] = $config['time']['now']; + $graph_array['id'] = $mempool['mempool_id']; + $graph_array['type'] = $graph_type; + $graph_array['from'] = $config['time']['day']; + $graph_array['legend'] = 'no'; - $overlib_content = generate_overlib_content($graph_array, $device['hostname'] . " - " . $text_descr); + $link_array = $graph_array; + $link_array['page'] = 'graphs'; + unset($link_array['height'], $link_array['width'], $link_array['legend']); + $link = generate_url($link_array); - $graph_array['width'] = 80; $graph_array['height'] = 20; $graph_array['bg'] = 'ffffff00'; # the 00 at the end makes the area transparent. + $overlib_content = generate_overlib_content($graph_array, $device['hostname'].' - '.$text_descr); - $minigraph = generate_graph_tag($graph_array); + $graph_array['width'] = 80; + $graph_array['height'] = 20; + $graph_array['bg'] = 'ffffff00'; + // the 00 at the end makes the area transparent. + $minigraph = generate_graph_tag($graph_array); - echo(" - - - - "); - } + echo ' + + + + '; + }//end foreach - echo('
    ".overlib_link($link, $text_descr, $overlib_content)."".overlib_link($link, $minigraph, $overlib_content)."".overlib_link($link, print_percentage_bar (200, 20, $percent, NULL, "ffffff", $background['left'], $percent . "%", "ffffff", $background['right']), $overlib_content)." -
    '.overlib_link($link, $text_descr, $overlib_content).''.overlib_link($link, $minigraph, $overlib_content).''.overlib_link($link, print_percentage_bar(200, 20, $percent, null, 'ffffff', $background['left'], $percent.'%', 'ffffff', $background['right']), $overlib_content).' +
    + echo '
    -
    '); - -} - -?> + '; +}//end if diff --git a/html/pages/device/overview/ports.inc.php b/html/pages/device/overview/ports.inc.php index 807f8ee4fb..75cf3ca29f 100644 --- a/html/pages/device/overview/ports.inc.php +++ b/html/pages/device/overview/ports.inc.php @@ -1,68 +1,64 @@ '); - echo('
    +if ($ports['total']) { + echo '
    '; + echo '
    Overall Traffic
    - '); +
    '; - $graph_array['height'] = "100"; - $graph_array['width'] = "485"; - $graph_array['to'] = $config['time']['now']; - $graph_array['device'] = $device['device_id']; - $graph_array['type'] = "device_bits"; - $graph_array['from'] = $config['time']['day']; - $graph_array['legend'] = "no"; - $graph = generate_graph_tag($graph_array); + $graph_array['height'] = '100'; + $graph_array['width'] = '485'; + $graph_array['to'] = $config['time']['now']; + $graph_array['device'] = $device['device_id']; + $graph_array['type'] = 'device_bits'; + $graph_array['from'] = $config['time']['day']; + $graph_array['legend'] = 'no'; + $graph = generate_graph_tag($graph_array); - $link_array = $graph_array; - $link_array['page'] = "graphs"; - unset($link_array['height'], $link_array['width']); - $link = generate_url($link_array); + $link_array = $graph_array; + $link_array['page'] = 'graphs'; + unset($link_array['height'], $link_array['width']); + $link = generate_url($link_array); - $graph_array['width'] = "210"; - $overlib_content = generate_overlib_content($graph_array, $device['hostname'] . " - Device Traffic"); + $graph_array['width'] = '210'; + $overlib_content = generate_overlib_content($graph_array, $device['hostname'].' - Device Traffic'); - echo(' - - '); + echo ' + + '; - echo(' + echo ' - - - - - '); + + + + + '; - echo(' - + "); - echo(""); - echo("
    '); - echo(overlib_link($link, $graph, $overlib_content, NULL)); - echo('
    '; + echo overlib_link($link, $graph, $overlib_content, null); + echo '
    ' . $ports['total'] . ' ' . $ports['up'] . ' ' . $ports['down'] . ' ' . $ports['disabled'] . '
    '.$ports['total'].' '.$ports['up'].' '.$ports['down'].' '.$ports['disabled'].'
    '); + echo '
    '; - $ifsep = ""; + $ifsep = ''; - foreach (dbFetchRows("SELECT * FROM `ports` WHERE device_id = ? AND `deleted` != '1'", array($device['device_id'])) as $data) - { - $data = ifNameDescr($data); - $data = array_merge($data, $device); - echo("$ifsep" . generate_port_link($data, makeshortif(strtolower($data['label'])))); - $ifsep = ", "; - } + foreach (dbFetchRows("SELECT * FROM `ports` WHERE device_id = ? AND `deleted` != '1'", array($device['device_id'])) as $data) { + $data = ifNameDescr($data); + $data = array_merge($data, $device); + echo "$ifsep".generate_port_link($data, makeshortif(strtolower($data['label']))); + $ifsep = ', '; + } - unset($ifsep); - echo("
    "); - echo("
    "); - echo("
    "); - echo("
    "); - echo("
    "); -} - -?> + unset($ifsep); + echo ' '; + echo ''; + echo ''; + echo '
    '; + echo ''; + echo ''; + echo ''; +}//end if diff --git a/html/pages/device/overview/processors.inc.php b/html/pages/device/overview/processors.inc.php index 3394e263ca..8b4d3f2912 100644 --- a/html/pages/device/overview/processors.inc.php +++ b/html/pages/device/overview/processors.inc.php @@ -1,66 +1,63 @@ +if (count($processors)) { + echo '
    -'); - echo(''); - echo(" Processors"); - echo('
    - '); +'; + echo ''; + echo " Processors"; + echo ' +
    '; - foreach ($processors as $proc) - { - $text_descr = rewrite_entity_descr($proc['processor_descr']); + foreach ($processors as $proc) { + $text_descr = rewrite_entity_descr($proc['processor_descr']); - # disable short hrDeviceDescr. need to make this prettier. - #$text_descr = short_hrDeviceDescr($proc['processor_descr']); - $percent = $proc['processor_usage']; - $background = get_percentage_colours($percent); - $graph_colour = str_replace("#", "", $row_colour); + // disable short hrDeviceDescr. need to make this prettier. + // $text_descr = short_hrDeviceDescr($proc['processor_descr']); + $percent = $proc['processor_usage']; + $background = get_percentage_colours($percent); + $graph_colour = str_replace('#', '', $row_colour); - $graph_array = array(); - $graph_array['height'] = "100"; - $graph_array['width'] = "210"; - $graph_array['to'] = $config['time']['now']; - $graph_array['id'] = $proc['processor_id']; - $graph_array['type'] = $graph_type; - $graph_array['from'] = $config['time']['day']; - $graph_array['legend'] = "no"; + $graph_array = array(); + $graph_array['height'] = '100'; + $graph_array['width'] = '210'; + $graph_array['to'] = $config['time']['now']; + $graph_array['id'] = $proc['processor_id']; + $graph_array['type'] = $graph_type; + $graph_array['from'] = $config['time']['day']; + $graph_array['legend'] = 'no'; - $link_array = $graph_array; - $link_array['page'] = "graphs"; - unset($link_array['height'], $link_array['width'], $link_array['legend']); - $link = generate_url($link_array); + $link_array = $graph_array; + $link_array['page'] = 'graphs'; + unset($link_array['height'], $link_array['width'], $link_array['legend']); + $link = generate_url($link_array); - $overlib_content = generate_overlib_content($graph_array, $device['hostname'] . " - " . $text_descr); + $overlib_content = generate_overlib_content($graph_array, $device['hostname'].' - '.$text_descr); - $graph_array['width'] = 80; $graph_array['height'] = 20; $graph_array['bg'] = 'ffffff00'; # the 00 at the end makes the area transparent. + $graph_array['width'] = 80; + $graph_array['height'] = 20; + $graph_array['bg'] = 'ffffff00'; + // the 00 at the end makes the area transparent. + $minigraph = generate_graph_tag($graph_array); - $minigraph = generate_graph_tag($graph_array); - - echo(" - - - + + + - "); - } + '; + }//end foreach - echo('
    ".overlib_link($link, $text_descr, $overlib_content)."".overlib_link($link, $minigraph, $overlib_content)."".overlib_link($link, print_percentage_bar (200, 20, $percent, NULL, "ffffff", $background['left'], $percent . "%", "ffffff", $background['right']), $overlib_content)." + echo '
    '.overlib_link($link, $text_descr, $overlib_content).''.overlib_link($link, $minigraph, $overlib_content).''.overlib_link($link, print_percentage_bar(200, 20, $percent, null, 'ffffff', $background['left'], $percent.'%', 'ffffff', $background['right']), $overlib_content).'
    + echo '
    -
    '); - -} - -?> + '; +}//end if diff --git a/html/pages/device/overview/sensors/charge.inc.php b/html/pages/device/overview/sensors/charge.inc.php index bf40977499..b0df00968a 100644 --- a/html/pages/device/overview/sensors/charge.inc.php +++ b/html/pages/device/overview/sensors/charge.inc.php @@ -1,10 +1,8 @@ +require 'pages/device/overview/generic/sensor.inc.php'; diff --git a/html/pages/device/overview/sensors/load.inc.php b/html/pages/device/overview/sensors/load.inc.php index 989a305b9b..089f93dffb 100644 --- a/html/pages/device/overview/sensors/load.inc.php +++ b/html/pages/device/overview/sensors/load.inc.php @@ -1,8 +1,8 @@ '); - echo('
    +if ($services['total']) { +echo '
    '; + echo '
    -
    '); - echo(" Services"); - echo('
    - '); +
    '; + echo " Services"; + echo '
    +
    '; - echo(" + echo " @@ -19,22 +18,32 @@ echo('
    ');
    -
    $services[total] $services[up] $services[disabled]
    "); +"; - foreach (dbFetchRows("SELECT * FROM services WHERE device_id = ? ORDER BY service_type", array($device['device_id'])) as $data) - { - if ($data['service_status'] == "0" && $data['service_ignore'] == "1") { $status = "grey"; } - if ($data['service_status'] == "1" && $data['service_ignore'] == "1") { $status = "green"; } - if ($data['service_status'] == "0" && $data['service_ignore'] == "0") { $status = "red"; } - if ($data['service_status'] == "1" && $data['service_ignore'] == "0") { $status = "blue"; } - echo("$break" . strtolower($data['service_type']) . ""); - $break = ", "; - } - echo('
    '); - echo("
    "); - echo("
    "); - echo("
    "); - echo("
    "); -} + foreach (dbFetchRows('SELECT * FROM services WHERE device_id = ? ORDER BY service_type', array($device['device_id'])) as $data) { + if ($data['service_status'] == '0' && $data['service_ignore'] == '1') { + $status = 'grey'; + } -?> + if ($data['service_status'] == '1' && $data['service_ignore'] == '1') { + $status = 'green'; + } + + if ($data['service_status'] == '0' && $data['service_ignore'] == '0') { + $status = 'red'; + } + + if ($data['service_status'] == '1' && $data['service_ignore'] == '0') { + $status = 'blue'; + } + + echo "$break".strtolower($data['service_type']).''; + $break = ', '; + } + + echo ''; + echo '
    '; + echo ''; + echo ''; + echo ''; +}//end if diff --git a/html/pages/device/overview/storage.inc.php b/html/pages/device/overview/storage.inc.php index 01c02edb4e..e81b1b5b5d 100644 --- a/html/pages/device/overview/storage.inc.php +++ b/html/pages/device/overview/storage.inc.php @@ -1,91 +1,86 @@ +if (count($drives)) { + echo '
    -
    '); - echo(''); - echo(" Storage"); - echo('
    - '); +
    '; + echo ''; + echo " Storage"; + echo '
    +
    '; - foreach ($drives as $drive) - { - $skipdrive = 0; + foreach ($drives as $drive) { + $skipdrive = 0; - if ($device["os"] == "junos") - { - foreach ($config['ignore_junos_os_drives'] as $jdrive) - { - if (preg_match($jdrive, $drive["storage_descr"])) - { - $skipdrive = 1; + if ($device['os'] == 'junos') { + foreach ($config['ignore_junos_os_drives'] as $jdrive) { + if (preg_match($jdrive, $drive['storage_descr'])) { + $skipdrive = 1; + } + } + + $drive['storage_descr'] = preg_replace('/.*mounted on: (.*)/', '\\1', $drive['storage_descr']); } - } - $drive["storage_descr"] = preg_replace("/.*mounted on: (.*)/", "\\1", $drive["storage_descr"]); - } - if ($device['os'] == "freebsd") - { - foreach ($config['ignore_bsd_os_drives'] as $jdrive) - { - if (preg_match($jdrive, $drive["storage_descr"])) - { - $skipdrive = 1; + if ($device['os'] == 'freebsd') { + foreach ($config['ignore_bsd_os_drives'] as $jdrive) { + if (preg_match($jdrive, $drive['storage_descr'])) { + $skipdrive = 1; + } + } } - } - } - if ($skipdrive) { continue; } - $percent = round($drive['storage_perc'], 0); - $total = formatStorage($drive['storage_size']); - $free = formatStorage($drive['storage_free']); - $used = formatStorage($drive['storage_used']); - $background = get_percentage_colours($percent); + if ($skipdrive) { + continue; + } - $graph_array = array(); - $graph_array['height'] = "100"; - $graph_array['width'] = "210"; - $graph_array['to'] = $config['time']['now']; - $graph_array['id'] = $drive['storage_id']; - $graph_array['type'] = $graph_type; - $graph_array['from'] = $config['time']['day']; - $graph_array['legend'] = "no"; + $percent = round($drive['storage_perc'], 0); + $total = formatStorage($drive['storage_size']); + $free = formatStorage($drive['storage_free']); + $used = formatStorage($drive['storage_used']); + $background = get_percentage_colours($percent); - $link_array = $graph_array; - $link_array['page'] = "graphs"; - unset($link_array['height'], $link_array['width'], $link_array['legend']); - $link = generate_url($link_array); + $graph_array = array(); + $graph_array['height'] = '100'; + $graph_array['width'] = '210'; + $graph_array['to'] = $config['time']['now']; + $graph_array['id'] = $drive['storage_id']; + $graph_array['type'] = $graph_type; + $graph_array['from'] = $config['time']['day']; + $graph_array['legend'] = 'no'; - $overlib_content = generate_overlib_content($graph_array, $device['hostname'] . " - " . $drive['storage_descr']); + $link_array = $graph_array; + $link_array['page'] = 'graphs'; + unset($link_array['height'], $link_array['width'], $link_array['legend']); + $link = generate_url($link_array); - $graph_array['width'] = 80; $graph_array['height'] = 20; $graph_array['bg'] = 'ffffff00'; # the 00 at the end makes the area transparent. + $overlib_content = generate_overlib_content($graph_array, $device['hostname'].' - '.$drive['storage_descr']); - $minigraph = generate_graph_tag($graph_array); + $graph_array['width'] = 80; + $graph_array['height'] = 20; + $graph_array['bg'] = 'ffffff00'; + // the 00 at the end makes the area transparent. + $minigraph = generate_graph_tag($graph_array); - echo(" - - - + + + - "); - } + '; + }//end foreach - echo('
    ".overlib_link($link, $drive['storage_descr'], $overlib_content)."".overlib_link($link, $minigraph, $overlib_content)."".overlib_link($link, print_percentage_bar (200, 20, $percent, NULL, "ffffff", $background['left'], $percent . "%", "ffffff", $background['right']), $overlib_content)." + echo '
    '.overlib_link($link, $drive['storage_descr'], $overlib_content).''.overlib_link($link, $minigraph, $overlib_content).''.overlib_link($link, print_percentage_bar(200, 20, $percent, null, 'ffffff', $background['left'], $percent.'%', 'ffffff', $background['right']), $overlib_content).'
    + echo '
    -
    '); + '; +}//end if -} - -unset ($drive_rows); - -?> +unset($drive_rows); diff --git a/html/pages/device/overview/syslog.inc.php b/html/pages/device/overview/syslog.inc.php index 1d26fbb2a7..bcfb6d2c52 100644 --- a/html/pages/device/overview/syslog.inc.php +++ b/html/pages/device/overview/syslog.inc.php @@ -1,25 +1,24 @@ '); - echo('
    +if ($config['enable_syslog']) { + $syslog = dbFetchRows("SELECT *, DATE_FORMAT(timestamp, '".$config['dateformat']['mysql']['compact']."') AS date from syslog WHERE device_id = ? ORDER BY timestamp DESC LIMIT 20", array($device['device_id'])); + if (count($syslog)) { + echo '
    '; + echo '
    -
    '); - echo(' Recent Syslog'); -echo('
    - '); - foreach ($syslog as $entry) { include("includes/print-syslog.inc.php"); } - echo("
    "); - echo("
    "); - echo("
    "); - echo("
    "); - echo("
    "); - } -} +
    '; + echo ' Recent Syslog'; + echo '
    + '; + foreach ($syslog as $entry) { + include 'includes/print-syslog.inc.php'; + } -?> + echo '
    '; + echo '
    '; + echo ''; + echo ''; + echo ''; + } +} diff --git a/html/pages/device/overview/toner.inc.php b/html/pages/device/overview/toner.inc.php index 347a636195..7c789573c5 100644 --- a/html/pages/device/overview/toner.inc.php +++ b/html/pages/device/overview/toner.inc.php @@ -1,64 +1,62 @@ +if (count($toners)) { + echo '
    -
    '); - echo(''); - echo(" Toner"); - echo('
    - '); +
    '; + echo ''; + echo " Toner"; + echo '
    +
    '; - foreach ($toners as $toner) - { - $percent = round($toner['toner_current'], 0); - $total = formatStorage($toner['toner_size']); - $free = formatStorage($toner['toner_free']); - $used = formatStorage($toner['toner_used']); + foreach ($toners as $toner) { + $percent = round($toner['toner_current'], 0); + $total = formatStorage($toner['toner_size']); + $free = formatStorage($toner['toner_free']); + $used = formatStorage($toner['toner_used']); - $background = toner2colour($toner['toner_descr'], $percent); + $background = toner2colour($toner['toner_descr'], $percent); - $graph_array = array(); - $graph_array['height'] = "100"; - $graph_array['width'] = "210"; - $graph_array['to'] = $config['time']['now']; - $graph_array['id'] = $toner['toner_id']; - $graph_array['type'] = $graph_type; - $graph_array['from'] = $config['time']['day']; - $graph_array['legend'] = "no"; + $graph_array = array(); + $graph_array['height'] = '100'; + $graph_array['width'] = '210'; + $graph_array['to'] = $config['time']['now']; + $graph_array['id'] = $toner['toner_id']; + $graph_array['type'] = $graph_type; + $graph_array['from'] = $config['time']['day']; + $graph_array['legend'] = 'no'; - $link_array = $graph_array; - $link_array['page'] = "graphs"; - unset($link_array['height'], $link_array['width'], $link_array['legend']); - $link = generate_url($link_array); + $link_array = $graph_array; + $link_array['page'] = 'graphs'; + unset($link_array['height'], $link_array['width'], $link_array['legend']); + $link = generate_url($link_array); - $overlib_content = generate_overlib_content($graph_array, $device['hostname'] . " - " . $toner['toner_descr']); + $overlib_content = generate_overlib_content($graph_array, $device['hostname'].' - '.$toner['toner_descr']); - $graph_array['width'] = 80; $graph_array['height'] = 20; $graph_array['bg'] = 'ffffff00'; # the 00 at the end makes the area transparent. + $graph_array['width'] = 80; + $graph_array['height'] = 20; + $graph_array['bg'] = 'ffffff00'; + // the 00 at the end makes the area transparent. + $minigraph = generate_graph_tag($graph_array); - $minigraph = generate_graph_tag($graph_array); - - echo(" - - - + + + - "); - } + '; + }//end foreach - echo("
    ".overlib_link($link, $toner['toner_descr'], $overlib_content)."".overlib_link($link, $minigraph, $overlib_content)."".overlib_link($link, print_percentage_bar (200, 20, $percent, NULL, "ffffff", $background['left'], $percent . "%", "ffffff", $background['right']), $overlib_content)." + echo '
    '.overlib_link($link, $toner['toner_descr'], $overlib_content).''.overlib_link($link, $minigraph, $overlib_content).''.overlib_link($link, print_percentage_bar(200, 20, $percent, null, 'ffffff', $background['left'], $percent.'%', 'ffffff', $background['right']), $overlib_content).'
    "); - echo("
    "); - echo("
    "); - echo("
    "); - echo(""); -} + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; +}//end if -unset ($toner_rows); - -?> +unset($toner_rows); diff --git a/html/pages/device/performance.inc.php b/html/pages/device/performance.inc.php index 8686bf8034..da2056c54b 100644 --- a/html/pages/device/performance.inc.php +++ b/html/pages/device/performance.inc.php @@ -21,7 +21,9 @@ */ -if(!isset($vars['section'])) { $vars['section'] = "performance"; } +if(!isset($vars['section'])) { + $vars['section'] = "performance"; +} if (empty($vars['dtpickerfrom'])) { $vars['dtpickerfrom'] = date($config['dateformat']['byminute'], time() - 3600 * 24 * 2); @@ -57,7 +59,8 @@ if (empty($vars['dtpickerto'])) { if (is_admin() === true || is_read() === true) { $query = "SELECT DATE_FORMAT(timestamp, '".$config['alert_graph_date_format']."') Date, xmt,rcv,loss,min,max,avg FROM `device_perf` WHERE `device_id` = ? AND `timestamp` >= ? AND `timestamp` <= ?"; $param = array($device['device_id'], $vars['dtpickerfrom'], $vars['dtpickerto']); -} else { +} +else { $query = "SELECT DATE_FORMAT(timestamp, '".$config['alert_graph_date_format']."') Date, xmt,rcv,loss,min,max,avg FROM `device_perf`,`devices_perms` WHERE `device_id` = ? AND alert_log.device_id = devices_perms.device_id AND devices_perms.user_id = ? AND `timestamp` >= ? AND `timestamp` <= ?"; $param = array($device['device_id'], $_SESSION['user_id'], $vars['dtpickerfrom'], $vars['dtpickerto']); } @@ -81,7 +84,7 @@ foreach(dbFetchRows($query, $param) as $return_value) { $avg = $return_value['avg']; if ($max > $max_val) { - $max_val = $max; + $max_val = $max; } $data[] = array('x' => $date,'y' => $loss,'group' => 0); @@ -186,4 +189,3 @@ echo $milisec_diff; var graph2d = new vis.Graph2d(container, items, groups, options); - diff --git a/html/pages/device/port.inc.php b/html/pages/device/port.inc.php index ecb25cfd28..a70d40a763 100644 --- a/html/pages/device/port.inc.php +++ b/html/pages/device/port.inc.php @@ -1,15 +1,22 @@ get('port-'.$port['port_id'].'-state'); - if($debug) { print_r($state); } - if(is_array($state)) { $port = array_merge($port, $state); } - unset($state); +if ($config['memcached']['enable'] === true) { + $state = $memcache->get('port-'.$port['port_id'].'-state'); + if ($debug) { + print_r($state); + } + + if (is_array($state)) { + $port = array_merge($port, $state); + } + + unset($state); } $port_details = 1; @@ -17,148 +24,218 @@ $port_details = 1; $hostname = $device['hostname']; $hostid = $device['port_id']; $ifname = $port['ifDescr']; -$ifIndex = $port['ifIndex']; -$speed = humanspeed($port['ifSpeed']); +$ifIndex = $port['ifIndex']; +$speed = humanspeed($port['ifSpeed']); $ifalias = $port['name']; -if ($port['ifPhysAddress']) { $mac = "$port[ifPhysAddress]"; } +if ($port['ifPhysAddress']) { + $mac = "$port[ifPhysAddress]"; +} -$color = "black"; -if ($port['ifAdminStatus'] == "down") { $status = "Disabled"; } -if ($port['ifAdminStatus'] == "up" && $port['ifOperStatus'] == "down") { $status = "Enabled / Disconnected"; } -if ($port['ifAdminStatus'] == "up" && $port['ifOperStatus'] == "up") { $status = "Enabled / Connected"; } +$color = 'black'; +if ($port['ifAdminStatus'] == 'down') { + $status = "Disabled"; +} -$i = 1; +if ($port['ifAdminStatus'] == 'up' && $port['ifOperStatus'] == 'down') { + $status = "Enabled / Disconnected"; +} + +if ($port['ifAdminStatus'] == 'up' && $port['ifOperStatus'] == 'up') { + $status = "Enabled / Connected"; +} + +$i = 1; $inf = fixifName($ifname); -$bg="#ffffff"; +$bg = '#ffffff'; $show_all = 1; -echo("
    "); +echo "
    "; -include("includes/print-interface.inc.php"); +require 'includes/print-interface.inc.php'; -echo("
    "); +echo ''; -$pos = strpos(strtolower($ifname), "vlan"); -if ($pos !== false ) -{ - $broke = yes; +$pos = strpos(strtolower($ifname), 'vlan'); +if ($pos !== false) { + $broke = yes; } -$pos = strpos(strtolower($ifname), "loopback"); +$pos = strpos(strtolower($ifname), 'loopback'); -if ($pos !== false ) -{ - $broke = yes; +if ($pos !== false) { + $broke = yes; } -echo("
    "); +echo "
    "; print_optionbar_start(); -$link_array = array('page' => 'device', - 'device' => $device['device_id'], - 'tab' => 'port', - 'port' => $port['port_id']); +$link_array = array( + 'page' => 'device', + 'device' => $device['device_id'], + 'tab' => 'port', + 'port' => $port['port_id'], +); $menu_options['graphs'] = 'Graphs'; -$menu_options['realtime'] = 'Real time'; // FIXME CONDITIONAL -$menu_options['arp'] = 'ARP Table'; -$menu_options['events'] = 'Eventlog'; +$menu_options['realtime'] = 'Real time'; +// FIXME CONDITIONAL +$menu_options['arp'] = 'ARP Table'; +$menu_options['events'] = 'Eventlog'; -if (dbFetchCell("SELECT COUNT(*) FROM `ports_adsl` WHERE `port_id` = '".$port['port_id']."'") ) -{ $menu_options['adsl'] = 'ADSL'; } - -if (dbFetchCell("SELECT COUNT(*) FROM `ports` WHERE `pagpGroupIfIndex` = '".$port['ifIndex']."' and `device_id` = '".$device['device_id']."'") ) -{ $menu_options['pagp'] = 'PAgP'; } - -if (dbFetchCell("SELECT COUNT(*) FROM `ports_vlans` WHERE `port_id` = '".$port['port_id']."' and `device_id` = '".$device['device_id']."'") ) -{ $menu_options['vlans'] = 'VLANs'; } - -$sep = ""; -foreach ($menu_options as $option => $text) -{ - echo($sep); - if ($vars['view'] == $option) { echo(""); } - echo(generate_link($text,$link_array,array('view'=>$option))); - if ($vars['view'] == $option) { echo(""); } - $sep = " | "; +if (dbFetchCell("SELECT COUNT(*) FROM `ports_adsl` WHERE `port_id` = '".$port['port_id']."'")) { + $menu_options['adsl'] = 'ADSL'; } + +if (dbFetchCell("SELECT COUNT(*) FROM `ports` WHERE `pagpGroupIfIndex` = '".$port['ifIndex']."' and `device_id` = '".$device['device_id']."'")) { + $menu_options['pagp'] = 'PAgP'; +} + +if (dbFetchCell("SELECT COUNT(*) FROM `ports_vlans` WHERE `port_id` = '".$port['port_id']."' and `device_id` = '".$device['device_id']."'")) { + $menu_options['vlans'] = 'VLANs'; +} + +$sep = ''; +foreach ($menu_options as $option => $text) { + echo $sep; + if ($vars['view'] == $option) { + echo ""; + } + + echo generate_link($text, $link_array, array('view' => $option)); + if ($vars['view'] == $option) { + echo ''; + } + + $sep = ' | '; +} + unset($sep); -if (dbFetchCell("SELECT count(*) FROM mac_accounting WHERE port_id = '".$port['port_id']."'") > "0" ) -{ +if (dbFetchCell("SELECT count(*) FROM mac_accounting WHERE port_id = '".$port['port_id']."'") > '0') { + echo generate_link($descr, $link_array, array('view' => 'macaccounting', 'graph' => $type)); - echo(generate_link($descr,$link_array,array('view'=>'macaccounting','graph'=>$type))); + echo ' | Mac Accounting : '; + if ($vars['view'] == 'macaccounting' && $vars['graph'] == 'bits' && $vars['subview'] == 'graphs') { + echo ""; + } - echo(" | Mac Accounting : "); - if ($vars['view'] == "macaccounting" && $vars['graph'] == "bits" && $vars['subview'] == "graphs") { echo(""); } - echo(generate_link("Bits",$link_array,array('view' => 'macaccounting', 'subview' => 'graphs', 'graph'=>'bits'))); - if ($vars['view'] == "macaccounting" && $vars['graph'] == "bits" && $vars['subview'] == "graphs") { echo(""); } + echo generate_link('Bits', $link_array, array('view' => 'macaccounting', 'subview' => 'graphs', 'graph' => 'bits')); + if ($vars['view'] == 'macaccounting' && $vars['graph'] == 'bits' && $vars['subview'] == 'graphs') { + echo ''; + } - echo("("); - if ($vars['view'] == "macaccounting" && $vars['graph'] == "bits" && $vars['subview'] == "minigraphs") { echo(""); } - echo(generate_link("Mini",$link_array,array('view' => 'macaccounting', 'subview' => 'minigraphs', 'graph'=>'bits'))); - if ($vars['view'] == "macaccounting" && $vars['graph'] == "bits" && $vars['subview'] == "minigraphs") { echo(""); } - echo('|'); + echo '('; + if ($vars['view'] == 'macaccounting' && $vars['graph'] == 'bits' && $vars['subview'] == 'minigraphs') { + echo ""; + } - if ($vars['view'] == "macaccounting" && $vars['graph'] == "bits" && $vars['subview'] == "top10") { echo(""); } - echo(generate_link("Top10",$link_array,array('view' => 'macaccounting', 'subview' => 'top10', 'graph'=>'bits'))); - if ($vars['view'] == "macaccounting" && $vars['graph'] == "bits" && $vars['subview'] == "top10") { echo(""); } - echo(") | "); + echo generate_link('Mini', $link_array, array('view' => 'macaccounting', 'subview' => 'minigraphs', 'graph' => 'bits')); + if ($vars['view'] == 'macaccounting' && $vars['graph'] == 'bits' && $vars['subview'] == 'minigraphs') { + echo ''; + } - if ($vars['view'] == "macaccounting" && $vars['graph'] == "pkts" && $vars['subview'] == "graphs") { echo(""); } - echo(generate_link("Packets",$link_array,array('view' => 'macaccounting', 'subview' => 'graphs', 'graph'=>'pkts'))); - if ($vars['view'] == "macaccounting" && $vars['graph'] == "pkts" && $vars['subview'] == "graphs") { echo(""); } - echo("("); - if ($vars['view'] == "macaccounting" && $vars['graph'] == "pkts" && $vars['subview'] == "minigraphs") { echo(""); } - echo(generate_link("Mini",$link_array,array('view' => 'macaccounting', 'subview' => 'minigraphs', 'graph'=>'pkts'))); - if ($vars['view'] == "macaccounting" && $vars['graph'] == "pkts" && $vars['subview'] == "minigraphs") { echo(""); } - echo('|'); - if ($vars['view'] == "macaccounting" && $vars['graph'] == "pkts" && $vars['subview'] == "top10") { echo(""); } - echo(generate_link("Top10",$link_array,array('view' => 'macaccounting', 'subview' => 'top10', 'graph'=>'pkts'))); - if ($vars['view'] == "macaccounting" && $vars['graph'] == "pkts" && $vars['subview'] == "top10") { echo(""); } - echo(")"); -} + echo '|'; -if (dbFetchCell("SELECT COUNT(*) FROM juniAtmVp WHERE port_id = '".$port['port_id']."'") > "0" ) -{ + if ($vars['view'] == 'macaccounting' && $vars['graph'] == 'bits' && $vars['subview'] == 'top10') { + echo ""; + } - // FIXME ATM VPs - // FIXME URLs BROKEN + echo generate_link('Top10', $link_array, array('view' => 'macaccounting', 'subview' => 'top10', 'graph' => 'bits')); + if ($vars['view'] == 'macaccounting' && $vars['graph'] == 'bits' && $vars['subview'] == 'top10') { + echo ''; + } - echo(" | ATM VPs : "); - if ($vars['view'] == "junose-atm-vp" && $vars['graph'] == "bits") { echo(""); } - echo("Bits"); - if ($vars['view'] == "junose-atm-vp" && $vars['graph'] == "bits") { echo(""); } - echo(" | "); - if ($vars['view'] == "junose-atm-vp" && $vars['graph'] == "packets") { echo(""); } - echo("Packets"); - if ($vars['view'] == "junose-atm-vp" && $vars['graph'] == "bits") { echo(""); } - echo(" | "); - if ($vars['view'] == "junose-atm-vp" && $vars['graph'] == "cells") { echo(""); } - echo("Cells"); - if ($vars['view'] == "junose-atm-vp" && $vars['graph'] == "bits") { echo(""); } - echo(" | "); - if ($vars['view'] == "junose-atm-vp" && $vars['graph'] == "errors") { echo(""); } - echo("Errors"); - if ($vars['view'] == "junose-atm-vp" && $vars['graph'] == "bits") { echo(""); } -} + echo ') | '; -if ($_SESSION['userlevel'] >= '10') -{ - echo(" Create Bill"); + if ($vars['view'] == 'macaccounting' && $vars['graph'] == 'pkts' && $vars['subview'] == 'graphs') { + echo ""; + } + + echo generate_link('Packets', $link_array, array('view' => 'macaccounting', 'subview' => 'graphs', 'graph' => 'pkts')); + if ($vars['view'] == 'macaccounting' && $vars['graph'] == 'pkts' && $vars['subview'] == 'graphs') { + echo ''; + } + + echo '('; + if ($vars['view'] == 'macaccounting' && $vars['graph'] == 'pkts' && $vars['subview'] == 'minigraphs') { + echo ""; + } + + echo generate_link('Mini', $link_array, array('view' => 'macaccounting', 'subview' => 'minigraphs', 'graph' => 'pkts')); + if ($vars['view'] == 'macaccounting' && $vars['graph'] == 'pkts' && $vars['subview'] == 'minigraphs') { + echo ''; + } + + echo '|'; + if ($vars['view'] == 'macaccounting' && $vars['graph'] == 'pkts' && $vars['subview'] == 'top10') { + echo ""; + } + + echo generate_link('Top10', $link_array, array('view' => 'macaccounting', 'subview' => 'top10', 'graph' => 'pkts')); + if ($vars['view'] == 'macaccounting' && $vars['graph'] == 'pkts' && $vars['subview'] == 'top10') { + echo ''; + } + + echo ')'; +}//end if + +if (dbFetchCell("SELECT COUNT(*) FROM juniAtmVp WHERE port_id = '".$port['port_id']."'") > '0') { + // FIXME ATM VPs + // FIXME URLs BROKEN + echo ' | ATM VPs : '; + if ($vars['view'] == 'junose-atm-vp' && $vars['graph'] == 'bits') { + echo ""; + } + + echo "Bits"; + if ($vars['view'] == 'junose-atm-vp' && $vars['graph'] == 'bits') { + echo ''; + } + + echo ' | '; + if ($vars['view'] == 'junose-atm-vp' && $vars['graph'] == 'packets') { + echo ""; + } + + echo "Packets"; + if ($vars['view'] == 'junose-atm-vp' && $vars['graph'] == 'bits') { + echo ''; + } + + echo ' | '; + if ($vars['view'] == 'junose-atm-vp' && $vars['graph'] == 'cells') { + echo ""; + } + + echo "Cells"; + if ($vars['view'] == 'junose-atm-vp' && $vars['graph'] == 'bits') { + echo ''; + } + + echo ' | '; + if ($vars['view'] == 'junose-atm-vp' && $vars['graph'] == 'errors') { + echo ""; + } + + echo "Errors"; + if ($vars['view'] == 'junose-atm-vp' && $vars['graph'] == 'bits') { + echo ''; + } +}//end if + +if ($_SESSION['userlevel'] >= '10') { + echo " Create Bill"; } print_optionbar_end(); -echo("
    "); +echo "
    "; -include("pages/device/port/".mres($vars['view']).".inc.php"); +require 'pages/device/port/'.mres($vars['view']).'.inc.php'; -echo("
    "); - -?> +echo '
    '; diff --git a/html/pages/device/port/events.inc.php b/html/pages/device/port/events.inc.php index 6de49ef262..5a113fafe6 100644 --- a/html/pages/device/port/events.inc.php +++ b/html/pages/device/port/events.inc.php @@ -1,15 +1,12 @@ '); +echo ''; -foreach ($entries as $entry) -{ - include("includes/print-event.inc.php"); +foreach ($entries as $entry) { + include 'includes/print-event.inc.php'; } -echo('
    '); +echo ''; -$pagetitle[] = "Events"; - -?> +$pagetitle[] = 'Events'; diff --git a/html/pages/device/port/pagp.inc.php b/html/pages/device/port/pagp.inc.php index e64437e2c2..7a8e41ff50 100644 --- a/html/pages/device/port/pagp.inc.php +++ b/html/pages/device/port/pagp.inc.php @@ -3,34 +3,32 @@ global $config; // FIXME functions! - -if (!$graph_type) { $graph_type = "pagp_bits"; } - -$daily_traffic = "graph.php?port=" . $port['port_id'] . "&type=$graph_type&from=".$config['time']['day']."&to=".$config['time']['now']."&width=215&height=100"; -$daily_url = "graph.php?port=" . $port['port_id'] . "&type=$graph_type&from=".$config['time']['day']."&to=".$config['time']['now']."&width=500&height=150"; - -$weekly_traffic = "graph.php?port=" . $port['port_id'] . "&type=$graph_type&from=".$config['time']['week']."&to=".$config['time']['now']."&width=215&height=100"; -$weekly_url = "graph.php?port=" . $port['port_id'] . "&type=$graph_type&from=".$config['time']['week']."&to=".$config['time']['now']."&width=500&height=150"; - -$monthly_traffic = "graph.php?port=" . $port['port_id'] . "&type=$graph_type&from=".$config['time']['month']."&to=".$config['time']['now']."&width=215&height=100"; -$monthly_url = "graph.php?port=" . $port['port_id'] . "&type=$graph_type&from=".$config['time']['month']."&to=".$config['time']['now']."&width=500&height=150"; - -$yearly_traffic = "graph.php?port=" . $port['port_id'] . "&type=$graph_type&from=".$config['time']['year']."&to=".$config['time']['now']."&width=215&height=100"; -$yearly_url = "graph.php?port=" . $port['port_id'] . "&type=$graph_type&from=".$config['time']['year']."&to=".$config['time']['now']."&width=500&height=150"; - -echo("', LEFT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\"> - "); -echo("', LEFT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\"> - "); -echo("', LEFT".$config['overlib_defaults'].", WIDTH, 350);\" onmouseout=\"return nd();\"> - "); -echo("', LEFT".$config['overlib_defaults'].", WIDTH, 350);\" onmouseout=\"return nd();\"> - "); - -foreach (dbFetchRows("SELECT * FROM `ports` WHERE `pagpGroupIfIndex` = ? and `device_id` = ?", array($port['ifIndex'], $device['device_id'])) as $member) -{ - echo("$br " . generate_port_link($member) . " (PAgP)"); - $br = "
    "; +if (!$graph_type) { + $graph_type = 'pagp_bits'; } -?> +$daily_traffic = 'graph.php?port='.$port['port_id']."&type=$graph_type&from=".$config['time']['day'].'&to='.$config['time']['now'].'&width=215&height=100'; +$daily_url = 'graph.php?port='.$port['port_id']."&type=$graph_type&from=".$config['time']['day'].'&to='.$config['time']['now'].'&width=500&height=150'; + +$weekly_traffic = 'graph.php?port='.$port['port_id']."&type=$graph_type&from=".$config['time']['week'].'&to='.$config['time']['now'].'&width=215&height=100'; +$weekly_url = 'graph.php?port='.$port['port_id']."&type=$graph_type&from=".$config['time']['week'].'&to='.$config['time']['now'].'&width=500&height=150'; + +$monthly_traffic = 'graph.php?port='.$port['port_id']."&type=$graph_type&from=".$config['time']['month'].'&to='.$config['time']['now'].'&width=215&height=100'; +$monthly_url = 'graph.php?port='.$port['port_id']."&type=$graph_type&from=".$config['time']['month'].'&to='.$config['time']['now'].'&width=500&height=150'; + +$yearly_traffic = 'graph.php?port='.$port['port_id']."&type=$graph_type&from=".$config['time']['year'].'&to='.$config['time']['now'].'&width=215&height=100'; +$yearly_url = 'graph.php?port='.$port['port_id']."&type=$graph_type&from=".$config['time']['year'].'&to='.$config['time']['now'].'&width=500&height=150'; + +echo "', LEFT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\"> + "; +echo "', LEFT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\"> + "; +echo "', LEFT".$config['overlib_defaults'].", WIDTH, 350);\" onmouseout=\"return nd();\"> + "; +echo "', LEFT".$config['overlib_defaults'].", WIDTH, 350);\" onmouseout=\"return nd();\"> + "; + +foreach (dbFetchRows('SELECT * FROM `ports` WHERE `pagpGroupIfIndex` = ? and `device_id` = ?', array($port['ifIndex'], $device['device_id'])) as $member) { + echo "$br ".generate_port_link($member).' (PAgP)'; + $br = '
    '; +} diff --git a/html/pages/device/ports.inc.php b/html/pages/device/ports.inc.php index b254b376da..dc941e246f 100644 --- a/html/pages/device/ports.inc.php +++ b/html/pages/device/ports.inc.php @@ -1,15 +1,23 @@ 'device', - 'device' => $device['device_id'], - 'tab' => 'ports'); +$link_array = array( + 'page' => 'device', + 'device' => $device['device_id'], + 'tab' => 'ports', +); print_optionbar_start(); @@ -17,110 +25,136 @@ $menu_options['basic'] = 'Basic'; $menu_options['details'] = 'Details'; $menu_options['arp'] = 'ARP Table'; -if(dbFetchCell("SELECT * FROM links AS L, ports AS I WHERE I.device_id = '".$device['device_id']."' AND I.port_id = L.local_port_id")) -{ - $menu_options['neighbours'] = 'Neighbours'; -} -if(dbFetchCell("SELECT COUNT(*) FROM `ports` WHERE `ifType` = 'adsl'")) -{ - $menu_options['adsl'] = 'ADSL'; +if (dbFetchCell("SELECT * FROM links AS L, ports AS I WHERE I.device_id = '".$device['device_id']."' AND I.port_id = L.local_port_id")) { + $menu_options['neighbours'] = 'Neighbours'; } -$sep = ""; -foreach ($menu_options as $option => $text) -{ - echo($sep); - if ($vars['view'] == $option) { echo(""); } - echo(generate_link($text,$link_array,array('view'=>$option))); - if ($vars['view'] == $option) { echo(""); } - $sep = " | "; +if (dbFetchCell("SELECT COUNT(*) FROM `ports` WHERE `ifType` = 'adsl'")) { + $menu_options['adsl'] = 'ADSL'; +} + +$sep = ''; +foreach ($menu_options as $option => $text) { + echo $sep; + if ($vars['view'] == $option) { + echo ""; + } + + echo generate_link($text, $link_array, array('view' => $option)); + if ($vars['view'] == $option) { + echo ''; + } + + $sep = ' | '; } unset($sep); -echo(' | Graphs: '); +echo ' | Graphs: '; -$graph_types = array("bits" => "Bits", - "upkts" => "Unicast Packets", - "nupkts" => "Non-Unicast Packets", - "errors" => "Errors", - "etherlike" => "Etherlike"); +$graph_types = array( + 'bits' => 'Bits', + 'upkts' => 'Unicast Packets', + 'nupkts' => 'Non-Unicast Packets', + 'errors' => 'Errors', + 'etherlike' => 'Etherlike', +); -foreach ($graph_types as $type => $descr) -{ - echo("$type_sep"); - if ($vars['graph'] == $type && $vars['view'] == "graphs") { echo(""); } - echo(generate_link($descr,$link_array,array('view'=>'graphs','graph'=>$type))); - if ($vars['graph'] == $type && $vars['view'] == "graphs") { echo(""); } +foreach ($graph_types as $type => $descr) { + echo "$type_sep"; + if ($vars['graph'] == $type && $vars['view'] == 'graphs') { + echo ""; + } - echo(' ('); - if ($vars['graph'] == $type && $vars['view'] == "minigraphs") { echo(""); } - echo(generate_link('Mini',$link_array,array('view'=>'minigraphs','graph'=>$type))); - if ($vars['graph'] == $type && $vars['view'] == "minigraphs") { echo(""); } - echo(')'); - $type_sep = " | "; -} + echo generate_link($descr, $link_array, array('view' => 'graphs', 'graph' => $type)); + if ($vars['graph'] == $type && $vars['view'] == 'graphs') { + echo ''; + } + + echo ' ('; + if ($vars['graph'] == $type && $vars['view'] == 'minigraphs') { + echo ""; + } + + echo generate_link('Mini', $link_array, array('view' => 'minigraphs', 'graph' => $type)); + if ($vars['graph'] == $type && $vars['view'] == 'minigraphs') { + echo ''; + } + + echo ')'; + $type_sep = ' | '; +}//end foreach print_optionbar_end(); -if ($vars['view'] == 'minigraphs') -{ - $timeperiods = array('-1day','-1week','-1month','-1year'); - $from = '-1day'; - echo("
    "); - unset ($seperator); +if ($vars['view'] == 'minigraphs') { + $timeperiods = array( + '-1day', + '-1week', + '-1month', + '-1year', + ); + $from = '-1day'; + echo "
    "; + unset($seperator); - // FIXME - FIX THIS. UGLY. - foreach (dbFetchRows("select * from ports WHERE device_id = ? ORDER BY ifIndex", array($device['device_id'])) as $port) - { - echo("
    -
    ".makeshortif($port['ifDescr'])."
    - ".$device['hostname']." - ".$port['ifDescr']."
    \ - ".$port['ifAlias']." \ - \ - ', CENTER, LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 150);\" onmouseout=\"return nd();\" >". - " - -
    ".truncate(short_port_descr($port['ifAlias']), 32, '')."
    -
    "); - } - echo("
    "); -} elseif ($vars['view'] == "arp" || $vars['view'] == "adsl" || $vars['view'] == "neighbours") { - include("ports/".$vars['view'].".inc.php"); -} else { - if ($vars['view'] == "details") { $port_details = 1; } - echo("
    "); - $i = "1"; - - global $port_cache, $port_index_cache; - - $ports = dbFetchRows("SELECT * FROM `ports` WHERE `device_id` = ? AND `deleted` = '0' ORDER BY `ifIndex` ASC", array($device['device_id'])); - // As we've dragged the whole database, lets pre-populate our caches :) - // FIXME - we should probably split the fetching of link/stack/etc into functions and cache them here too to cut down on single row queries. - foreach ($ports as $port) - { - $port_cache[$port['port_id']] = $port; - $port_index_cache[$port['device_id']][$port['ifIndex']] = $port; - } - - foreach ($ports as $port) - { - if ($config['memcached']['enable'] === TRUE) - { - $state = $memcache->get('port-'.$port['port_id'].'-state'); - if($debug) { print_r($state); } - if(is_array($state)) { $port = array_merge($port, $state); } - unset($state); + // FIXME - FIX THIS. UGLY. + foreach (dbFetchRows('select * from ports WHERE device_id = ? ORDER BY ifIndex', array($device['device_id'])) as $port) { + echo "
    +
    ".makeshortif($port['ifDescr']).'
    + ".$device['hostname'].' - '.$port['ifDescr'].'
    \ + '.$port['ifAlias']." \ + \ + ', CENTER, LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 150);\" onmouseout=\"return nd();\" >"." + +
    ".truncate(short_port_descr($port['ifAlias']), 32, '').'
    + '; } - include("includes/print-interface.inc.php"); - - $i++; - } - echo("
    "); + echo '
    '; } +else if ($vars['view'] == 'arp' || $vars['view'] == 'adsl' || $vars['view'] == 'neighbours') { + include 'ports/'.$vars['view'].'.inc.php'; +} +else { + if ($vars['view'] == 'details') { + $port_details = 1; + } -$pagetitle[] = "Ports"; + echo "
    "; + $i = '1'; -?> + global $port_cache, $port_index_cache; + + $ports = dbFetchRows("SELECT * FROM `ports` WHERE `device_id` = ? AND `deleted` = '0' ORDER BY `ifIndex` ASC", array($device['device_id'])); + // As we've dragged the whole database, lets pre-populate our caches :) + // FIXME - we should probably split the fetching of link/stack/etc into functions and cache them here too to cut down on single row queries. + foreach ($ports as $port) { + $port_cache[$port['port_id']] = $port; + $port_index_cache[$port['device_id']][$port['ifIndex']] = $port; + } + + foreach ($ports as $port) { + if ($config['memcached']['enable'] === true) { + $state = $memcache->get('port-'.$port['port_id'].'-state'); + if ($debug) { + print_r($state); + } + + if (is_array($state)) { + $port = array_merge($port, $state); + } + + unset($state); + } + + include 'includes/print-interface.inc.php'; + + $i++; + } + + echo '
    '; +}//end if + +$pagetitle[] = 'Ports'; diff --git a/html/pages/device/ports/neighbours.inc.php b/html/pages/device/ports/neighbours.inc.php index 5e417eb996..b56136881e 100644 --- a/html/pages/device/ports/neighbours.inc.php +++ b/html/pages/device/ports/neighbours.inc.php @@ -10,8 +10,7 @@ echo 'Local Port Protocol '; -foreach (dbFetchRows('SELECT * FROM links AS L, ports AS I WHERE I.device_id = ? AND I.port_id = L.local_port_id', array($device['device_id'])) as $neighbour) -{ +foreach (dbFetchRows('SELECT * FROM links AS L, ports AS I WHERE I.device_id = ? AND I.port_id = L.local_port_id', array($device['device_id'])) as $neighbour) { if ($bg_colour == $list_colour_b) { $bg_colour = $list_colour_a; } diff --git a/html/pages/device/processes.inc.php b/html/pages/device/processes.inc.php index 41fda92887..0ce8e4c70f 100644 --- a/html/pages/device/processes.inc.php +++ b/html/pages/device/processes.inc.php @@ -1,19 +1,21 @@ +/* + * Copyright (C) 2015 Daniel Preussker * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . */ + * along with this program. If not, see . + */ -/** +/* * Process Listing * @author Daniel Preussker * @copyright 2015 f0o, LibreNMS @@ -22,77 +24,89 @@ * @subpackage Pages */ -switch( $vars['order'] ) { - case "vsz": - $order = "`vsz`"; - break; - case "rss": - $order = "`rss`"; - break; - case "cputime": - $order = "`cputime`"; - break; - case "user": - $order = "`user`"; - break; - case "command": - $order = "`command`"; - break; - default: - $order = "`pid`"; - break; +switch ($vars['order']) { + case 'vsz': + $order = '`vsz`'; + break; + + case 'rss': + $order = '`rss`'; + break; + + case 'cputime': + $order = '`cputime`'; + break; + + case 'user': + $order = '`user`'; + break; + + case 'command': + $order = '`command`'; + break; + + default: + $order = '`pid`'; + break; +}//end switch + +if ($vars['by'] == 'desc') { + $by = 'desc'; } -if( $vars['by'] == "desc" ) { - $by = "desc"; -} else { - $by = "asc"; +else { + $by = 'asc'; } $heads = array( - 'PID' => '', - 'VSZ' => 'Virtual Memory', - 'RSS' => 'Resident Memory', - 'cputime' => '', - 'user' => '', - 'command' => '' + 'PID' => '', + 'VSZ' => 'Virtual Memory', + 'RSS' => 'Resident Memory', + 'cputime' => '', + 'user' => '', + 'command' => '', ); echo "
    "; -foreach( $heads as $head=>$extra ) { - unset($lhead, $bhead); - $lhead = strtolower($head); - $bhead = 'asc'; - $icon = ""; - if( '`'.$lhead.'`' == $order ) { - $icon = " class='glyphicon glyphicon-chevron-"; - if( $by == 'asc' ) { - $bhead = 'desc'; - $icon .= 'up'; - } else { - $icon .= 'down'; - } - $icon .= "'"; - } - echo ''; -} -echo ""; +foreach ($heads as $head => $extra) { + unset($lhead, $bhead); + $lhead = strtolower($head); + $bhead = 'asc'; + $icon = ''; + if ('`'.$lhead.'`' == $order) { + $icon = " class='glyphicon glyphicon-chevron-"; + if ($by == 'asc') { + $bhead = 'desc'; + $icon .= 'up'; + } + else { + $icon .= 'down'; + } -foreach (dbFetchRows("SELECT * FROM `processes` WHERE `device_id` = ? ORDER BY ".$order." ".$by, array($device['device_id'])) as $entry) { - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; -} -echo"
     '; - if( !empty($extra) ) { - echo "$head"; - } else { - echo $head; - } - echo '
    '.$entry['pid'].''.format_si($entry['vsz']*1024).''.format_si($entry['rss']*1024).''.$entry['cputime'].''.$entry['user'].''.$entry['command'].'
    "; + $icon .= "'"; + } -?> + echo ' '; + if (!empty($extra)) { + echo "$head"; + } + else { + echo $head; + } + + echo ''; +}//end foreach + +echo ''; + +foreach (dbFetchRows('SELECT * FROM `processes` WHERE `device_id` = ? ORDER BY '.$order.' '.$by, array($device['device_id'])) as $entry) { + echo ''; + echo ''.$entry['pid'].''; + echo ''.format_si(($entry['vsz'] * 1024)).''; + echo ''.format_si(($entry['rss'] * 1024)).''; + echo ''.$entry['cputime'].''; + echo ''.$entry['user'].''; + echo ''.$entry['command'].''; + echo ''; +} + +echo '
    '; diff --git a/html/pages/device/pseudowires.inc.php b/html/pages/device/pseudowires.inc.php index c134c8b661..c48bca5738 100644 --- a/html/pages/device/pseudowires.inc.php +++ b/html/pages/device/pseudowires.inc.php @@ -89,8 +89,7 @@ foreach (dbFetchRows('SELECT * FROM pseudowires AS P, ports AS I WHERE P.port_id 'upkts', 'errors', ); - foreach ($types as $graph_type) - { + foreach ($types as $graph_type) { $pw_a['graph_type'] = 'port_'.$graph_type; print_port_thumbnail($pw_a); } diff --git a/html/pages/device/routing/bgp.inc.php b/html/pages/device/routing/bgp.inc.php index 5b327aca30..17f0629a02 100644 --- a/html/pages/device/routing/bgp.inc.php +++ b/html/pages/device/routing/bgp.inc.php @@ -1,203 +1,275 @@ 'device', - 'device' => $device['device_id'], - 'tab' => 'routing', - 'proto' => 'bgp'); +$link_array = array( + 'page' => 'device', + 'device' => $device['device_id'], + 'tab' => 'routing', + 'proto' => 'bgp', +); -if(!isset($vars['view'])) { $vars['view'] = "basic"; } +if (!isset($vars['view'])) { + $vars['view'] = 'basic'; +} print_optionbar_start(); -echo "Local AS : " .$device['bgpLocalAs']." "; +echo 'Local AS : '.$device['bgpLocalAs'].' '; -echo("BGP » "); +echo "BGP » "; -if ($vars['view'] == "basic") { echo(""); } -echo(generate_link("Basic", $link_array,array('view'=>'basic'))); -if ($vars['view'] == "basic") { echo(""); } +if ($vars['view'] == 'basic') { + echo ""; +} -echo(" | "); +echo generate_link('Basic', $link_array, array('view' => 'basic')); +if ($vars['view'] == 'basic') { + echo ''; +} -if ($vars['view'] == "updates") { echo(""); } -echo(generate_link("Updates", $link_array,array('view'=>'updates'))); -if ($vars['view'] == "updates") { echo(""); } +echo ' | '; -echo(" | Prefixes: "); +if ($vars['view'] == 'updates') { + echo ""; +} -if ($vars['view'] == "prefixes_ipv4unicast") { echo(""); } -echo(generate_link("IPv4", $link_array,array('view'=>'prefixes_ipv4unicast'))); -if ($vars['view'] == "prefixes_ipv4unicast") { echo(""); } +echo generate_link('Updates', $link_array, array('view' => 'updates')); +if ($vars['view'] == 'updates') { + echo ''; +} -echo(" | "); +echo ' | Prefixes: '; -if ($vars['view'] == "prefixes_vpnv4unicast") { echo(""); } -echo(generate_link("VPNv4", $link_array,array('view'=>'prefixes_vpnv4unicast'))); -if ($vars['view'] == "prefixes_vpnv4unicast") { echo(""); } +if ($vars['view'] == 'prefixes_ipv4unicast') { + echo ""; +} -echo(" | "); +echo generate_link('IPv4', $link_array, array('view' => 'prefixes_ipv4unicast')); +if ($vars['view'] == 'prefixes_ipv4unicast') { + echo ''; +} -if ($vars['view'] == "prefixes_ipv6unicast") { echo(""); } -echo(generate_link("IPv6", $link_array,array('view'=>'prefixes_ipv6unicast'))); -if ($vars['view'] == "prefixes_ipv6unicast") { echo(""); } +echo ' | '; -echo(" | Traffic: "); +if ($vars['view'] == 'prefixes_vpnv4unicast') { + echo ""; +} -if ($vars['view'] == "macaccounting_bits") { echo(""); } -echo(generate_link("Bits", $link_array,array('view'=>'macaccounting_bits'))); -if ($vars['view'] == "macaccounting_bits") { echo(""); } -echo(" | "); -if ($vars['view'] == "macaccounting_pkts") { echo(""); } -echo(generate_link("Packets", $link_array,array('view'=>'macaccounting_pkts'))); -if ($vars['view'] == "macaccounting_pkts") { echo(""); } +echo generate_link('VPNv4', $link_array, array('view' => 'prefixes_vpnv4unicast')); +if ($vars['view'] == 'prefixes_vpnv4unicast') { + echo ''; +} + +echo ' | '; + +if ($vars['view'] == 'prefixes_ipv6unicast') { + echo ""; +} + +echo generate_link('IPv6', $link_array, array('view' => 'prefixes_ipv6unicast')); +if ($vars['view'] == 'prefixes_ipv6unicast') { + echo ''; +} + +echo ' | Traffic: '; + +if ($vars['view'] == 'macaccounting_bits') { + echo ""; +} + +echo generate_link('Bits', $link_array, array('view' => 'macaccounting_bits')); +if ($vars['view'] == 'macaccounting_bits') { + echo ''; +} + +echo ' | '; +if ($vars['view'] == 'macaccounting_pkts') { + echo ""; +} + +echo generate_link('Packets', $link_array, array('view' => 'macaccounting_pkts')); +if ($vars['view'] == 'macaccounting_pkts') { + echo ''; +} print_optionbar_end(); -echo(''); -echo(''); +echo '
    Peer addressTypeRemote ASStateUptime
    '; +echo ''; -$i = "1"; +$i = '1'; -foreach (dbFetchRows("SELECT * FROM `bgpPeers` WHERE `device_id` = ? ORDER BY `bgpPEerRemoteAs`, `bgpPeerIdentifier`", array($device['device_id'])) as $peer) -{ - $has_macaccounting = dbFetchCell("SELECT COUNT(*) FROM `ipv4_mac` AS I, mac_accounting AS M WHERE I.ipv4_address = ? AND M.mac = I.mac_address", array($peer['bgpPeerIdentifier'])); - unset($bg_image); - if (!is_integer($i/2)) { $bg_colour = $list_colour_a; } else { $bg_colour = $list_colour_b; } - unset ($alert, $bg_image); - unset ($peerhost, $peername); +foreach (dbFetchRows('SELECT * FROM `bgpPeers` WHERE `device_id` = ? ORDER BY `bgpPEerRemoteAs`, `bgpPeerIdentifier`', array($device['device_id'])) as $peer) { + $has_macaccounting = dbFetchCell('SELECT COUNT(*) FROM `ipv4_mac` AS I, mac_accounting AS M WHERE I.ipv4_address = ? AND M.mac = I.mac_address', array($peer['bgpPeerIdentifier'])); + unset($bg_image); + if (!is_integer($i / 2)) { + $bg_colour = $list_colour_a; + } + else { + $bg_colour = $list_colour_b; + } - if (!is_integer($i/2)) { $bg_colour = $list_colour_b; } else { $bg_colour = $list_colour_a; } - if ($peer['bgpPeerState'] == "established") { $col = "green"; } else { $col = "red"; $peer['alert']=1; } - if ($peer['bgpPeerAdminStatus'] == "start" || $peer['bgpPeerAdminStatus'] == "running") { $admin_col = "green"; } else { $admin_col = "gray"; } - if ($peer['bgpPeerAdminStatus'] == "stop") { $peer['alert']=0; $peer['disabled']=1; } + unset($alert, $bg_image); + unset($peerhost, $peername); - if ($peer['bgpPeerRemoteAs'] == $device['bgpLocalAs']) { $peer_type = "iBGP"; } else { $peer_type = "eBGP"; } + if (!is_integer($i / 2)) { + $bg_colour = $list_colour_b; + } + else { + $bg_colour = $list_colour_a; + } - $query = "SELECT * FROM ipv4_addresses AS A, ports AS I, devices AS D WHERE "; - $query .= "(A.ipv4_address = ? AND I.port_id = A.port_id)"; - $query .= " AND D.device_id = I.device_id"; - $ipv4_host = dbFetchRow($query,array($peer['bgpPeerIdentifier'])); + if ($peer['bgpPeerState'] == 'established') { + $col = 'green'; + } + else { + $col = 'red'; + $peer['alert'] = 1; + } - $query = "SELECT * FROM ipv6_addresses AS A, ports AS I, devices AS D WHERE "; - $query .= "(A.ipv6_address = ? AND I.port_id = A.port_id)"; - $query .= " AND D.device_id = I.device_id"; - $ipv6_host = dbFetchRow($query,array($peer['bgpPeerIdentifier'])); + if ($peer['bgpPeerAdminStatus'] == 'start' || $peer['bgpPeerAdminStatus'] == 'running') { + $admin_col = 'green'; + } + else { + $admin_col = 'gray'; + } - if ($ipv4_host) - { - $peerhost = $ipv4_host; - } elseif ($ipv6_host) { - $peerhost = $ipv6_host; - } else { - unset($peerhost); - } + if ($peer['bgpPeerAdminStatus'] == 'stop') { + $peer['alert'] = 0; + $peer['disabled'] = 1; + } - if (is_array($peerhost)) - { - #$peername = generate_device_link($peerhost); - $peername = generate_device_link($peerhost) ." ". generate_port_link($peerhost); - $peer_url = "device/device=" . $peer['device_id'] . "/tab=routing/proto=bgp/view=updates/"; - } - else - { - #$peername = gethostbyaddr($peer['bgpPeerIdentifier']); // FFffuuu DNS // Cache this in discovery? -# if ($peername == $peer['bgpPeerIdentifier']) -# { -# unset($peername); -# } else { -# $peername = "".$peername.""; -# } - } + if ($peer['bgpPeerRemoteAs'] == $device['bgpLocalAs']) { + $peer_type = "iBGP"; + } + else { + $peer_type = "eBGP"; + } - unset($peer_af); - unset($sep); + $query = 'SELECT * FROM ipv4_addresses AS A, ports AS I, devices AS D WHERE '; + $query .= '(A.ipv4_address = ? AND I.port_id = A.port_id)'; + $query .= ' AND D.device_id = I.device_id'; + $ipv4_host = dbFetchRow($query, array($peer['bgpPeerIdentifier'])); - foreach (dbFetchRows("SELECT * FROM `bgpPeers_cbgp` WHERE `device_id` = ? AND bgpPeerIdentifier = ?", array($device['device_id'], $peer['bgpPeerIdentifier'])) as $afisafi) - { - $afi = $afisafi['afi']; - $safi = $afisafi['safi']; - $this_afisafi = $afi.$safi; - $peer['afi'] .= $sep . $afi .".".$safi; - $sep = "
    "; - $peer['afisafi'][$this_afisafi] = 1; // Build a list of valid AFI/SAFI for this peer - } + $query = 'SELECT * FROM ipv6_addresses AS A, ports AS I, devices AS D WHERE '; + $query .= '(A.ipv6_address = ? AND I.port_id = A.port_id)'; + $query .= ' AND D.device_id = I.device_id'; + $ipv6_host = dbFetchRow($query, array($peer['bgpPeerIdentifier'])); - unset($sep); + if ($ipv4_host) { + $peerhost = $ipv4_host; + } + else if ($ipv6_host) { + $peerhost = $ipv6_host; + } + else { + unset($peerhost); + } - if (filter_var($peer['bgpLocalAddr'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) !== FALSE) { - $peer['bgpPeerIdentifier'] = Net_IPv6::compress($peer['bgpPeerIdentifier']); - } + if (is_array($peerhost)) { + // $peername = generate_device_link($peerhost); + $peername = generate_device_link($peerhost).' '.generate_port_link($peerhost); + $peer_url = 'device/device='.$peer['device_id'].'/tab=routing/proto=bgp/view=updates/'; + } + else { + // FIXME + // $peername = gethostbyaddr($peer['bgpPeerIdentifier']); // FFffuuu DNS // Cache this in discovery? + // if ($peername == $peer['bgpPeerIdentifier']) + // { + // unset($peername); + // } else { + // $peername = "".$peername.""; + // } + } + + unset($peer_af); + unset($sep); + + foreach (dbFetchRows('SELECT * FROM `bgpPeers_cbgp` WHERE `device_id` = ? AND bgpPeerIdentifier = ?', array($device['device_id'], $peer['bgpPeerIdentifier'])) as $afisafi) { + $afi = $afisafi['afi']; + $safi = $afisafi['safi']; + $this_afisafi = $afi.$safi; + $peer['afi'] .= $sep.$afi.'.'.$safi; + $sep = '
    '; + $peer['afisafi'][$this_afisafi] = 1; + // Build a list of valid AFI/SAFI for this peer + } + + unset($sep); + + if (filter_var($peer['bgpLocalAddr'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) !== false) { + $peer['bgpPeerIdentifier'] = Net_IPv6::compress($peer['bgpPeerIdentifier']); + } - $graph_type = "bgp_updates"; - $peer_daily_url = "graph.php?id=" . $peer['bgpPeer_id'] . "&type=" . $graph_type . "&from=".$config['time']['day']."&to=".$config['time']['now']."&width=500&height=150"; - $peeraddresslink = "', LEFT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\">" . $peer['bgpPeerIdentifier'] . ""; + $graph_type = 'bgp_updates'; + $peer_daily_url = 'graph.php?id='.$peer['bgpPeer_id'].'&type='.$graph_type.'&from='.$config['time']['day'].'&to='.$config['time']['now'].'&width=500&height=150'; + $peeraddresslink = "', LEFT".$config['overlib_defaults'].');" onmouseout="return nd();">'.$peer['bgpPeerIdentifier'].''; - echo('
    - "); + echo ' + '; - echo(" - - - - - - - - "); + echo ' + + + + + + + + '; - unset($invalid); + unset($invalid); - switch ($vars['view']) - { + switch ($vars['view']) { case 'prefixes_ipv4unicast': case 'prefixes_ipv4multicast': case 'prefixes_ipv4vpn': case 'prefixes_ipv6unicast': case 'prefixes_ipv6multicast': - list(,$afisafi) = explode("_", $vars['view']); - if (isset($peer['afisafi'][$afisafi])) { $peer['graph'] = 1; } - // FIXME no break?? - case 'updates': - $graph_array['type'] = "bgp_" . $vars['view']; - $graph_array['id'] = $peer['bgpPeer_id']; - } + list(,$afisafi) = explode('_', $vars['view']); + if (isset($peer['afisafi'][$afisafi])) { + $peer['graph'] = 1; + } - switch ($vars['view']) - { + // FIXME no break?? + case 'updates': + $graph_array['type'] = 'bgp_'.$vars['view']; + $graph_array['id'] = $peer['bgpPeer_id']; + } + + switch ($vars['view']) { case 'macaccounting_bits': case 'macaccounting_pkts': - $acc = dbFetchRow("SELECT * FROM `ipv4_mac` AS I, `mac_accounting` AS M, `ports` AS P, `devices` AS D WHERE I.ipv4_address = ? AND M.mac = I.mac_address AND P.port_id = M.port_id AND D.device_id = P.device_id", array($peer['bgpPeerIdentifier'])); - $database = $config['rrd_dir'] . "/" . $device['hostname'] . "/cip-" . $acc['ifIndex'] . "-" . $acc['mac'] . ".rrd"; - if (is_array($acc) && is_file($database)) - { - $peer['graph'] = 1; - $graph_array['id'] = $acc['ma_id']; - $graph_array['type'] = $vars['view']; - } - } + $acc = dbFetchRow('SELECT * FROM `ipv4_mac` AS I, `mac_accounting` AS M, `ports` AS P, `devices` AS D WHERE I.ipv4_address = ? AND M.mac = I.mac_address AND P.port_id = M.port_id AND D.device_id = P.device_id', array($peer['bgpPeerIdentifier'])); + $database = $config['rrd_dir'].'/'.$device['hostname'].'/cip-'.$acc['ifIndex'].'-'.$acc['mac'].'.rrd'; + if (is_array($acc) && is_file($database)) { + $peer['graph'] = 1; + $graph_array['id'] = $acc['ma_id']; + $graph_array['type'] = $vars['view']; + } + } - if ($vars['view'] == 'updates') { $peer['graph'] = 1; } + if ($vars['view'] == 'updates') { + $peer['graph'] = 1; + } - if ($peer['graph']) - { - $graph_array['height'] = "100"; - $graph_array['width'] = "216"; - $graph_array['to'] = $config['time']['now']; - echo('"); - } + echo ''; + } - $i++; + $i++; - unset($valid_afi_safi); -} + unset($valid_afi_safi); +}//end foreach ?>
    Peer addressTypeRemote ASStateUptime
    ".$i."" . $peeraddresslink . "
    ".$peername."
    $peer_type" . (isset($peer['afi']) ? $peer['afi'] : '') . "AS" . $peer['bgpPeerRemoteAs'] . "
    " . $peer['astext'] . "
    " . $peer['bgpPeerAdminStatus'] . "
    " . $peer['bgpPeerState'] . "
    " .formatUptime($peer['bgpPeerFsmEstablishedTime']). "
    - Updates " . $peer['bgpPeerInUpdates'] . " - " . $peer['bgpPeerOutUpdates'] . "
    '.$i.''.$peeraddresslink.'
    '.$peername."
    $peer_type".(isset($peer['afi']) ? $peer['afi'] : '').'AS'.$peer['bgpPeerRemoteAs'].'
    '.$peer['astext']."
    ".$peer['bgpPeerAdminStatus']."
    ".$peer['bgpPeerState'].'
    '.formatUptime($peer['bgpPeerFsmEstablishedTime'])."
    + Updates ".$peer['bgpPeerInUpdates']." + ".$peer['bgpPeerOutUpdates'].'
    '); + if ($peer['graph']) { + $graph_array['height'] = '100'; + $graph_array['width'] = '216'; + $graph_array['to'] = $config['time']['now']; + echo '
    '; - include("includes/print-graphrow.inc.php"); + include 'includes/print-graphrow.inc.php'; - echo("
    diff --git a/html/pages/device/routing/ospf.inc.php b/html/pages/device/routing/ospf.inc.php index ed126a7fe3..7bf6798b7b 100644 --- a/html/pages/device/routing/ospf.inc.php +++ b/html/pages/device/routing/ospf.inc.php @@ -88,8 +88,7 @@ foreach (dbFetchRows('SELECT * FROM `ospf_instances` WHERE `device_id` = ?', arr // # Loop Ports $i_p = ($i_a + 1); $p_sql = "SELECT * FROM `ospf_ports` AS O, `ports` AS P WHERE O.`ospfIfAdminStat` = 'enabled' AND O.`device_id` = ? AND O.`ospfIfAreaId` = ? AND P.port_id = O.port_id"; - foreach (dbFetchRows($p_sql, array($device['device_id'], $area['ospfAreaId'])) as $ospfport) - { + foreach (dbFetchRows($p_sql, array($device['device_id'], $area['ospfAreaId'])) as $ospfport) { if (!is_integer($i_a / 2)) { if (!is_integer($i_p / 2)) { $port_bg = $list_colour_b_b; diff --git a/html/pages/device/showconfig.inc.php b/html/pages/device/showconfig.inc.php index aed9398dd2..9efc95d63a 100644 --- a/html/pages/device/showconfig.inc.php +++ b/html/pages/device/showconfig.inc.php @@ -1,134 +1,135 @@ = '7') { + if (!is_array($config['rancid_configs'])) { + $config['rancid_configs'] = array($config['rancid_configs']); + } -if ($_SESSION['userlevel'] >= "7") -{ + if (isset($config['rancid_configs'][0])) { + foreach ($config['rancid_configs'] as $configs) { + if ($configs[(strlen($configs) - 1)] != '/') { + $configs .= '/'; + } - if (!is_array($config['rancid_configs'])) { $config['rancid_configs'] = array($config['rancid_configs']); } + if (is_file($configs.$device['hostname'])) { + $file = $configs.$device['hostname']; + } + } - if (isset($config['rancid_configs'][0])) { + echo '
    '; - foreach ($config['rancid_configs'] as $configs) { - if ($configs[strlen($configs) - 1] != '/') { - $configs .= '/'; - } - if (is_file($configs . $device['hostname'])) { - $file = $configs . $device['hostname']; - } - } + print_optionbar_start('', ''); - echo('
    '); + echo "Config » "; - print_optionbar_start('', ''); + if (!$vars['rev']) { + echo ''; + echo generate_link('Latest', array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'showconfig')); + echo ''; + } + else { + echo generate_link('Latest', array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'showconfig')); + } - echo("Config » "); + if (function_exists('svn_log')) { + $sep = ' | '; + $svnlogs = svn_log($file, SVN_REVISION_HEAD, null, 8); + $revlist = array(); - if (!$vars['rev']) { - echo(''); - echo(generate_link('Latest', array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'showconfig'))); - echo(""); - } else { - echo(generate_link('Latest', array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'showconfig'))); - } + foreach ($svnlogs as $svnlog) { + echo $sep; + $revlist[] = $svnlog['rev']; - if (function_exists('svn_log')) { + if ($vars['rev'] == $svnlog['rev']) { + echo ''; + } - $sep = " | "; - $svnlogs = svn_log($file, SVN_REVISION_HEAD, NULL, 8); - $revlist = array(); + $linktext = 'r'.$svnlog['rev'].' '.date($config['dateformat']['byminute'], strtotime($svnlog['date'])).''; + echo generate_link($linktext, array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'showconfig', 'rev' => $svnlog['rev'])); - foreach ($svnlogs as $svnlog) { + if ($vars['rev'] == $svnlog['rev']) { + echo ''; + } - echo($sep); - $revlist[] = $svnlog["rev"]; + $sep = ' | '; + } + }//end if - if ($vars['rev'] == $svnlog["rev"]) { - echo(''); - } - $linktext = "r" . $svnlog["rev"] . " " . date($config['dateformat']['byminute'], strtotime($svnlog["date"])) . ""; - echo(generate_link($linktext, array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'showconfig', 'rev' => $svnlog["rev"]))); + print_optionbar_end(); - if ($vars['rev'] == $svnlog["rev"]) { - echo(""); - } + if (function_exists('svn_log') && in_array($vars['rev'], $revlist)) { + list($diff, $errors) = svn_diff($file, ($vars['rev'] - 1), $file, $vars['rev']); + if (!$diff) { + $text = 'No Difference'; + } + else { + $text = ''; + while (!feof($diff)) { + $text .= fread($diff, 8192); + } - $sep = " | "; - } - } + fclose($diff); + fclose($errors); + } + } + else { + $fh = fopen($file, 'r') or die("Can't open file"); + $text = fread($fh, filesize($file)); + fclose($fh); + } - print_optionbar_end(); + if ($config['rancid_ignorecomments']) { + $lines = explode("\n", $text); + for ($i = 0; $i < count($lines); $i++) { + if ($lines[$i][0] == '#') { + unset($lines[$i]); + } + } - if (function_exists('svn_log') && in_array($vars['rev'], $revlist)) { - list($diff, $errors) = svn_diff($file, $vars['rev'] - 1, $file, $vars['rev']); - if (!$diff) { - $text = "No Difference"; - } else { - $text = ""; - while (!feof($diff)) { - $text .= fread($diff, 8192); - } - fclose($diff); - fclose($errors); - } + $text = join("\n", $lines); + } + } + else if ($config['oxidized']['enabled'] === true && isset($config['oxidized']['url'])) { + $node_info = json_decode(file_get_contents($config['oxidized']['url'].'/node/show/'.$device['hostname'].'?format=json'), true); + $text = file_get_contents($config['oxidized']['url'].'/node/fetch/'.$device['hostname']); + if ($text == 'node not found') { + $text = file_get_contents($config['oxidized']['url'].'/node/fetch/'.$device['os'].'/'.$device['hostname']); + } - } else { - $fh = fopen($file, 'r') or die("Can't open file"); - $text = fread($fh, filesize($file)); - fclose($fh); - } - - if ($config['rancid_ignorecomments']) { - $lines = explode("\n", $text); - for ($i = 0; $i < count($lines); $i++) { - if ($lines[$i][0] == "#") { - unset($lines[$i]); - } - } - $text = join("\n", $lines); - } - } elseif ($config['oxidized']['enabled'] === TRUE && isset($config['oxidized']['url'])) { - $node_info = json_decode(file_get_contents($config['oxidized']['url']."/node/show/".$device['hostname']."?format=json"),TRUE); - $text = file_get_contents($config['oxidized']['url']."/node/fetch/".$device['hostname']); - if ($text == "node not found") { - $text = file_get_contents($config['oxidized']['url']."/node/fetch/".$device['os']."/".$device['hostname']); - } - - if (is_array($node_info)) { - echo('
    -
    + if (is_array($node_info)) { + echo '
    +
    -
    -
    Sync status: '.$node_info['last']['status'].'
    -
      -
    • Node: '. $node_info['name'].'
    • -
    • IP: '. $node_info['ip'].'
    • -
    • Model: '. $node_info['model'].'
    • -
    • Last Sync: '. $node_info['last']['end'].'
    • -
    -
    +
    +
    Sync status: '.$node_info['last']['status'].'
    +
      +
    • Node: '.$node_info['name'].'
    • +
    • IP: '.$node_info['ip'].'
    • +
    • Model: '.$node_info['model'].'
    • +
    • Last Sync: '.$node_info['last']['end'].'
    • +
    -
    '); - } else { - echo "
    "; - print_error("We couldn't retrieve the device information from Oxidized"); - $text = ''; - } +
    +
    '; + } + else { + echo '
    '; + print_error("We couldn't retrieve the device information from Oxidized"); + $text = ''; + } + }//end if - } + if (!empty($text)) { + $language = 'ios'; + $geshi = new GeSHi($text, $language); + $geshi->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS); + $geshi->set_overall_style('color: black;'); + // $geshi->set_line_style('color: #999999'); + echo $geshi->parse_code(); + } +}//end if - if (!empty($text)) { - $language = "ios"; - $geshi = new GeSHi($text, $language); - $geshi->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS); - $geshi->set_overall_style('color: black;'); - #$geshi->set_line_style('color: #999999'); - echo($geshi->parse_code()); - } -} - -$pagetitle[] = "Config"; - -?> +$pagetitle[] = 'Config'; diff --git a/html/pages/device/slas.inc.php b/html/pages/device/slas.inc.php index 3cc6cbf119..587c7d7438 100644 --- a/html/pages/device/slas.inc.php +++ b/html/pages/device/slas.inc.php @@ -12,7 +12,7 @@ foreach ($slas as $sla) { $sla_type = $sla['rtt_type']; if (!in_array($sla_type, $sla_types)) { - if (isset($config['sla_type_labels'][$sla_type])) { + if (isset($config['sla_type_labels'][$sla_type])) { $text = $config['sla_type_labels'][$sla_type]; } } diff --git a/html/pages/devices.inc.php b/html/pages/devices.inc.php index 67a8c39edd..0367b8a1c3 100644 --- a/html/pages/devices.inc.php +++ b/html/pages/devices.inc.php @@ -2,7 +2,9 @@ // Set Defaults here -if(!isset($vars['format'])) { $vars['format'] = "list_detail"; } +if(!isset($vars['format'])) { + $vars['format'] = "list_detail"; +} $pagetitle[] = "Devices"; @@ -10,23 +12,19 @@ print_optionbar_start(); echo('Lists » '); -$menu_options = array('basic' => 'Basic', - 'detail' => 'Detail'); +$menu_options = array('basic' => 'Basic', 'detail' => 'Detail'); $sep = ""; -foreach ($menu_options as $option => $text) -{ - echo($sep); - if ($vars['format'] == "list_".$option) - { - echo(""); - } - echo('' . $text . ''); - if ($vars['format'] == "list_".$option) - { - echo(""); - } - $sep = " | "; +foreach ($menu_options as $option => $text) { + echo($sep); + if ($vars['format'] == "list_".$option) { + echo(""); + } + echo('' . $text . ''); + if ($vars['format'] == "list_".$option) { + echo(""); + } + $sep = " | "; } ?> @@ -38,29 +36,26 @@ foreach ($menu_options as $option => $text) 'Bits', - 'processor' => 'CPU', - 'ucd_load' => 'Load', - 'mempool' => 'Memory', - 'uptime' => 'Uptime', - 'storage' => 'Storage', - 'diskio' => 'Disk I/O', - 'poller_perf' => 'Poller', - 'ping_perf' => 'Ping' - ); + 'processor' => 'CPU', + 'ucd_load' => 'Load', + 'mempool' => 'Memory', + 'uptime' => 'Uptime', + 'storage' => 'Storage', + 'diskio' => 'Disk I/O', + 'poller_perf' => 'Poller', + 'ping_perf' => 'Ping' +); $sep = ""; -foreach ($menu_options as $option => $text) -{ - echo($sep); - if ($vars['format'] == 'graph_'.$option) - { - echo(""); - } - echo('' . $text . ''); - if ($vars['format'] == 'graph_'.$option) - { - echo(""); - } - $sep = " | "; +foreach ($menu_options as $option => $text) { + echo($sep); + if ($vars['format'] == 'graph_'.$option) { + echo(""); + } + echo('' . $text . ''); + if ($vars['format'] == 'graph_'.$option) { + echo(""); + } + $sep = " | "; } ?> @@ -69,21 +64,21 @@ foreach ($menu_options as $option => $text) '')).'">Restore Search'); - } else { +} +else { echo('Remove Search'); - } +} - echo(" | "); +echo(" | "); - if (isset($vars['bare']) && $vars['bare'] == "yes") - { +if (isset($vars['bare']) && $vars['bare'] == "yes") { echo('Restore Header'); - } else { +} +else { echo('Remove Header'); - } +} print_optionbar_end(); ?> @@ -94,76 +89,110 @@ print_optionbar_end(); list($format, $subformat) = explode("_", $vars['format'], 2); -if($format == "graph") -{ -$sql_param = array(); +if($format == "graph") { + $sql_param = array(); -if(isset($vars['state'])) -{ - if($vars['state'] == 'up') - { - $state = '1'; - } - elseif($vars['state'] == 'down') - { - $state = '0'; - } -} + if(isset($vars['state'])) { + if($vars['state'] == 'up') { + $state = '1'; + } + elseif($vars['state'] == 'down') { + $state = '0'; + } + } -if (!empty($vars['hostname'])) { $where .= " AND hostname LIKE ?"; $sql_param[] = "%".$vars['hostname']."%"; } -if (!empty($vars['os'])) { $where .= " AND os = ?"; $sql_param[] = $vars['os']; } -if (!empty($vars['version'])) { $where .= " AND version = ?"; $sql_param[] = $vars['version']; } -if (!empty($vars['hardware'])) { $where .= " AND hardware = ?"; $sql_param[] = $vars['hardware']; } -if (!empty($vars['features'])) { $where .= " AND features = ?"; $sql_param[] = $vars['features']; } -if (!empty($vars['type'])) { - if ($vars['type'] == 'generic') { - $where .= " AND ( type = ? OR type = '')"; $sql_param[] = $vars['type']; - } else { - $where .= " AND type = ?"; $sql_param[] = $vars['type']; - } -} -if (!empty($vars['state'])) { - $where .= " AND status= ?"; $sql_param[] = $state; - $where .= " AND disabled='0' AND `ignore`='0'"; $sql_param[] = ''; -} -if (!empty($vars['disabled'])) { $where .= " AND disabled= ?"; $sql_param[] = $vars['disabled']; } -if (!empty($vars['ignore'])) { $where .= " AND `ignore`= ?"; $sql_param[] = $vars['ignore']; } -if (!empty($vars['location']) && $vars['location'] == "Unset") { $location_filter = ''; } -if (!empty($vars['location'])) { $location_filter = $vars['location']; } -if( !empty($vars['group']) ) { - require_once('../includes/device-groups.inc.php'); - $where .= " AND ( "; - foreach( GetDevicesFromGroup($vars['group']) as $dev ) { - $where .= "device_id = ? OR "; - $sql_param[] = $dev['device_id']; - } - $where = substr($where, 0, strlen($where)-3); - $where .= " )"; -} + if (!empty($vars['hostname'])) { + $where .= " AND hostname LIKE ?"; + $sql_param[] = "%".$vars['hostname']."%"; + } + if (!empty($vars['os'])) { + $where .= " AND os = ?"; + $sql_param[] = $vars['os']; + } + if (!empty($vars['version'])) { + $where .= " AND version = ?"; + $sql_param[] = $vars['version']; + } + if (!empty($vars['hardware'])) { + $where .= " AND hardware = ?"; + $sql_param[] = $vars['hardware']; + } + if (!empty($vars['features'])) { + $where .= " AND features = ?"; + $sql_param[] = $vars['features']; + } -$query = "SELECT * FROM `devices` WHERE 1 "; + if (!empty($vars['type'])) { + if ($vars['type'] == 'generic') { + $where .= " AND ( type = ? OR type = '')"; + $sql_param[] = $vars['type']; + } + else { + $where .= " AND type = ?"; + $sql_param[] = $vars['type']; + } + } + if (!empty($vars['state'])) { + $where .= " AND status= ?"; + $sql_param[] = $state; + $where .= " AND disabled='0' AND `ignore`='0'"; + $sql_param[] = ''; + } + if (!empty($vars['disabled'])) { + $where .= " AND disabled= ?"; + $sql_param[] = $vars['disabled']; + } + if (!empty($vars['ignore'])) { + $where .= " AND `ignore`= ?"; + $sql_param[] = $vars['ignore']; + } + if (!empty($vars['location']) && $vars['location'] == "Unset") { + $location_filter = ''; + } + if (!empty($vars['location'])) { + $location_filter = $vars['location']; + } + if( !empty($vars['group']) ) { + require_once('../includes/device-groups.inc.php'); + $where .= " AND ( "; + foreach( GetDevicesFromGroup($vars['group']) as $dev ) { + $where .= "device_id = ? OR "; + $sql_param[] = $dev['device_id']; + } + $where = substr($where, 0, strlen($where)-3); + $where .= " )"; + } -if (isset($where)) { - $query .= $where; -} + $query = "SELECT * FROM `devices` WHERE 1 "; -$query .= " ORDER BY hostname"; + if (isset($where)) { + $query .= $where; + } - $row = 1; - foreach (dbFetchRows($query, $sql_param) as $device) - { - if (is_integer($row/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; } + $query .= " ORDER BY hostname"; - if (device_permitted($device['device_id'])) - { - if (!$location_filter || ((get_dev_attrib($device,'override_sysLocation_bool') && get_dev_attrib($device,'override_sysLocation_string') == $location_filter) - || $device['location'] == $location_filter)) - { - $graph_type = "device_".$subformat; + $row = 1; + foreach (dbFetchRows($query, $sql_param) as $device) { + if (is_integer($row/2)) { + $row_colour = $list_colour_a; + } + else { + $row_colour = $list_colour_b; + } - if ($_SESSION['widescreen']) { $width=270; } else { $width=315; } + if (device_permitted($device['device_id'])) { + if (!$location_filter || ((get_dev_attrib($device,'override_sysLocation_bool') && get_dev_attrib($device,'override_sysLocation_string') == $location_filter) + || $device['location'] == $location_filter)) { + $graph_type = "device_".$subformat; - echo("
    + if ($_SESSION['widescreen']) { + $width=270; + } + else { + $width=315; + } + + echo("\ \ @@ -171,11 +200,11 @@ $query .= " ORDER BY hostname"; "
    "); - } + } + } } - } - -} else { +} +else { ?> @@ -209,22 +238,23 @@ $query .= " ORDER BY hostname"; ""+ '.$config['os'][$tmp_os]['text'].'"+'); + if (is_admin() === TRUE || is_read() === TRUE) { + $sql = "SELECT `os` FROM `devices` AS D WHERE 1 GROUP BY `os` ORDER BY `os`"; + } + else { + $sql = "SELECT `os` FROM `devices` AS `D`, `devices_perms` AS `P` WHERE `P`.`user_id` = ? AND `P`.`device_id` = `D`.`device_id` GROUP BY `os` ORDER BY `os`"; + $param[] = $_SESSION['user_id']; + } + foreach (dbFetch($sql,$param) as $data) { + if ($data['os']) { + $tmp_os = clean_bootgrid($data['os']); + echo('""+'); + } } -} ?> ""+ "
    "+ @@ -233,22 +263,23 @@ foreach (dbFetch($sql,$param) as $data) { ""+ '.$tmp_version.'"+'); } - echo('">'.$tmp_version.'"+'); - } -} + } ?> ""+ "
    "+ @@ -257,22 +288,23 @@ foreach (dbFetch($sql,$param) as $data) { ""+ '.$tmp_hardware.'"+'); + if (is_admin() === TRUE || is_read() === TRUE) { + $sql = "SELECT `hardware` FROM `devices` AS D WHERE 1 GROUP BY `hardware` ORDER BY `hardware`"; + } + else { + $sql = "SELECT `hardware` FROM `devices` AS `D`, `devices_perms` AS `P` WHERE `P`.`user_id` = ? AND `P`.`device_id` = `D`.`device_id` GROUP BY `hardware` ORDER BY `hardware`"; + $param[] = $_SESSION['user_id']; + } + foreach (dbFetch($sql,$param) as $data) { + if ($data['hardware']) { + $tmp_hardware = clean_bootgrid($data['hardware']); + echo('""+'); + } } -} ?> ""+ @@ -282,24 +314,24 @@ foreach (dbFetch($sql,$param) as $data) { ""+ '.$tmp_features.'"+'); + else { + $sql = "SELECT `features` FROM `devices` AS `D`, `devices_perms` AS `P` WHERE `P`.`user_id` = ? AND `P`.`device_id` = `D`.`device_id` GROUP BY `features` ORDER BY `features`"; + $param[] = $_SESSION['user_id']; + } + + foreach (dbFetch($sql,$param) as $data) { + if ($data['features']) { + $tmp_features = clean_bootgrid($data['features']); + echo('""+'); + } } -} ?> ""+ @@ -311,16 +343,16 @@ foreach (dbFetch($sql,$param) as $data) '.$location.'"+'); } - echo('">'.$location.'"+'); } -} ?> ""+ ""+ @@ -329,21 +361,22 @@ foreach (getlocations() as $location) { ""+ '.ucfirst($data['type']).'"+'); + if (is_admin() === TRUE || is_read() === TRUE) { + $sql = "SELECT `type` FROM `devices` AS D WHERE 1 GROUP BY `type` ORDER BY `type`"; + } + else { + $sql = "SELECT `type` FROM `devices` AS `D`, `devices_perms` AS `P` WHERE `P`.`user_id` = ? AND `P`.`device_id` = `D`.`device_id` GROUP BY `type` ORDER BY `type`"; + $param[] = $_SESSION['user_id']; + } + foreach (dbFetch($sql,$param) as $data) { + if ($data['type']) { + echo('""+'); + } } -} ?> ""+ @@ -357,9 +390,9 @@ foreach (dbFetch($sql,$param) as $data) { "

    " var grid = $("#devices").bootgrid({ @@ -400,5 +433,3 @@ var grid = $("#devices").bootgrid({ diff --git a/html/pages/editsrv.inc.php b/html/pages/editsrv.inc.php index 9c56b96d1e..1c04e4510f 100644 --- a/html/pages/editsrv.inc.php +++ b/html/pages/editsrv.inc.php @@ -1,35 +1,30 @@ "5") - { - include("includes/service-edit.inc.php"); + if ($_POST['confirm-editsrv']) { + if ($_SESSION['userlevel'] > '5') { + include 'includes/service-edit.inc.php'; } } - foreach (dbFetchRows("SELECT * FROM `services` AS S, `devices` AS D WHERE S.device_id = D.device_id ORDER BY hostname") as $device) - { - $servicesform .= ""; + foreach (dbFetchRows('SELECT * FROM `services` AS S, `devices` AS D WHERE S.device_id = D.device_id ORDER BY hostname') as $device) { + $servicesform .= "'; } - if ($updated) { print_message("Service updated!"); } + if ($updated) { + print_message('Service updated!'); + } if ($_POST['editsrv'] == 'yes') { - - require_once "includes/print-service-edit.inc.php"; - - } else { - - echo(" + include_once 'includes/print-service-edit.inc.php'; + } + else { + echo "

    Delete Service

    @@ -46,7 +41,6 @@ if (is_admin() === FALSE && is_read() === FALSE) { -
    "); - } - -} + "; + }//end if +}//end if diff --git a/html/pages/edituser.inc.php b/html/pages/edituser.inc.php index 6a9a7d2830..ec2a3f1c9e 100644 --- a/html/pages/edituser.inc.php +++ b/html/pages/edituser.inc.php @@ -1,167 +1,170 @@ "); +echo "
    "; -$pagetitle[] = "Edit user"; +$pagetitle[] = 'Edit user'; -if ($_SESSION['userlevel'] != '10') { include("includes/error-no-perm.inc.php"); } else -{ - if ($vars['user_id'] && !$vars['edit']) - { - $user_data = dbFetchRow("SELECT * FROM users WHERE user_id = ?", array($vars['user_id'])); - echo("

    " . $user_data['realname'] . "

    Change...

    "); - // Perform actions if requested +if ($_SESSION['userlevel'] != '10') { + include 'includes/error-no-perm.inc.php'; +} +else { + if ($vars['user_id'] && !$vars['edit']) { + $user_data = dbFetchRow('SELECT * FROM users WHERE user_id = ?', array($vars['user_id'])); + echo '

    '.$user_data['realname']."

    Change...

    "; + // Perform actions if requested + if ($vars['action'] == 'deldevperm') { + if (dbFetchCell('SELECT COUNT(*) FROM devices_perms WHERE `device_id` = ? AND `user_id` = ?', array($vars['device_id'], $vars['user_id']))) { + dbDelete('devices_perms', '`device_id` = ? AND `user_id` = ?', array($vars['device_id'], $vars['user_id'])); + } + } - if ($vars['action'] == "deldevperm") - { - if (dbFetchCell("SELECT COUNT(*) FROM devices_perms WHERE `device_id` = ? AND `user_id` = ?", array($vars['device_id'] ,$vars['user_id']))) - { - dbDelete('devices_perms', "`device_id` = ? AND `user_id` = ?", array($vars['device_id'], $vars['user_id'])); - } - } - if ($vars['action'] == "adddevperm") - { - if (!dbFetchCell("SELECT COUNT(*) FROM devices_perms WHERE `device_id` = ? AND `user_id` = ?", array($vars['device_id'] ,$vars['user_id']))) - { - dbInsert(array('device_id' => $vars['device_id'], 'user_id' => $vars['user_id']), 'devices_perms'); - } - } - if ($vars['action'] == "delifperm") - { - if (dbFetchCell("SELECT COUNT(*) FROM ports_perms WHERE `port_id` = ? AND `user_id` = ?", array($vars['port_id'], $vars['user_id']))) - { - dbDelete('ports_perms', "`port_id` = ? AND `user_id` = ?", array($vars['port_id'], $vars['user_id'])); - } - } - if ($vars['action'] == "addifperm") - { - if (!dbFetchCell("SELECT COUNT(*) FROM ports_perms WHERE `port_id` = ? AND `user_id` = ?", array($vars['port_id'], $vars['user_id']))) - { - dbInsert(array('port_id' => $vars['port_id'], 'user_id' => $vars['user_id']), 'ports_perms'); - } - } - if ($vars['action'] == "delbillperm") - { - if (dbFetchCell("SELECT COUNT(*) FROM bill_perms WHERE `bill_id` = ? AND `user_id` = ?", array($vars['bill_id'], $vars['user_id']))) - { - dbDelete('bill_perms', "`bill_id` = ? AND `user_id` = ?", array($vars['bill_id'], $vars['user_id'])); - } - } - if ($vars['action'] == "addbillperm") - { - if (!dbFetchCell("SELECT COUNT(*) FROM bill_perms WHERE `bill_id` = ? AND `user_id` = ?", array($vars['bill_id'], $vars['user_id']))) - { - dbInsert(array('bill_id' => $vars['bill_id'], 'user_id' => $vars['user_id']), 'bill_perms'); - } - } + if ($vars['action'] == 'adddevperm') { + if (!dbFetchCell('SELECT COUNT(*) FROM devices_perms WHERE `device_id` = ? AND `user_id` = ?', array($vars['device_id'], $vars['user_id']))) { + dbInsert(array('device_id' => $vars['device_id'], 'user_id' => $vars['user_id']), 'devices_perms'); + } + } - echo('
    -
    '); + if ($vars['action'] == 'delifperm') { + if (dbFetchCell('SELECT COUNT(*) FROM ports_perms WHERE `port_id` = ? AND `user_id` = ?', array($vars['port_id'], $vars['user_id']))) { + dbDelete('ports_perms', '`port_id` = ? AND `user_id` = ?', array($vars['port_id'], $vars['user_id'])); + } + } - // Display devices this users has access to - echo("

    Device Access

    "); + if ($vars['action'] == 'addifperm') { + if (!dbFetchCell('SELECT COUNT(*) FROM ports_perms WHERE `port_id` = ? AND `user_id` = ?', array($vars['port_id'], $vars['user_id']))) { + dbInsert(array('port_id' => $vars['port_id'], 'user_id' => $vars['user_id']), 'ports_perms'); + } + } - echo("
    + if ($vars['action'] == 'delbillperm') { + if (dbFetchCell('SELECT COUNT(*) FROM bill_perms WHERE `bill_id` = ? AND `user_id` = ?', array($vars['bill_id'], $vars['user_id']))) { + dbDelete('bill_perms', '`bill_id` = ? AND `user_id` = ?', array($vars['bill_id'], $vars['user_id'])); + } + } + + if ($vars['action'] == 'addbillperm') { + if (!dbFetchCell('SELECT COUNT(*) FROM bill_perms WHERE `bill_id` = ? AND `user_id` = ?', array($vars['bill_id'], $vars['user_id']))) { + dbInsert(array('bill_id' => $vars['bill_id'], 'user_id' => $vars['user_id']), 'bill_perms'); + } + } + + echo '
    +
    '; + + // Display devices this users has access to + echo '

    Device Access

    '; + + echo "
    - "); + "; - $device_perms = dbFetchRows("SELECT * from devices_perms as P, devices as D WHERE `user_id` = ? AND D.device_id = P.device_id", array($vars['user_id'])); - foreach ($device_perms as $device_perm) - { - echo(""); - $access_list[] = $device_perm['device_id']; - $permdone = "yes"; - } + $device_perms = dbFetchRows('SELECT * from devices_perms as P, devices as D WHERE `user_id` = ? AND D.device_id = P.device_id', array($vars['user_id'])); + foreach ($device_perms as $device_perm) { + echo '"; + $access_list[] = $device_perm['device_id']; + $permdone = 'yes'; + } - echo("
    Device Action
    " . $device_perm['hostname'] . "
    '.$device_perm['hostname']."
    -
    "); + echo ' +
    '; - if (!$permdone) { echo("None Configured"); } + if (!$permdone) { + echo 'None Configured'; + } - // Display devices this user doesn't have access to - echo("

    Grant access to new device

    "); - echo("
    - + // Display devices this user doesn't have access to + echo '

    Grant access to new device

    '; + echo " +
    - "; - $devices = dbFetchRows("SELECT * FROM `devices` ORDER BY hostname"); - foreach ($devices as $device) - { - unset($done); - foreach ($access_list as $ac) { if ($ac == $device['device_id']) { $done = 1; } } - if (!$done) - { - echo(""); - } - } + $devices = dbFetchRows('SELECT * FROM `devices` ORDER BY hostname'); + foreach ($devices as $device) { + unset($done); + foreach ($access_list as $ac) { + if ($ac == $device['device_id']) { + $done = 1; + } + } - echo(" + if (!$done) { + echo "'; + } + } + + echo "
    -
    "); + "; - echo("
    -
    "); - echo("

    Interface Access

    "); + echo "
    +
    "; + echo '

    Interface Access

    '; - $interface_perms = dbFetchRows("SELECT * from ports_perms as P, ports as I, devices as D WHERE `user_id` = ? AND I.port_id = P.port_id AND D.device_id = I.device_id", array($vars['user_id'])); + $interface_perms = dbFetchRows('SELECT * from ports_perms as P, ports as I, devices as D WHERE `user_id` = ? AND I.port_id = P.port_id AND D.device_id = I.device_id', array($vars['user_id'])); - echo("
    + echo "
    - "); - foreach ($interface_perms as $interface_perm) - { - echo(" + "; + foreach ($interface_perms as $interface_perm) { + echo ' - "); - $ipermdone = "yes"; - } - echo("
    Interface name Action
    - ".$interface_perm['hostname']." - ".$interface_perm['ifDescr']."". - "" . $interface_perm['ifAlias'] . " + '.$interface_perm['hostname'].' - '.$interface_perm['ifDescr'].''.''.$interface_perm['ifAlias']." -    +   
    -
    "); + "; + $ipermdone = 'yes'; + } - if (!$ipermdone) { echo("None Configured"); } + echo ' +
    '; - // Display devices this user doesn't have access to - echo("

    Grant access to new interface

    "); + if (!$ipermdone) { + echo 'None Configured'; + } - echo("
    - + // Display devices this user doesn't have access to + echo '

    Grant access to new interface

    '; + + echo " +
    + if (!$done) { + echo "'; + } + } + + echo "
    @@ -176,133 +179,135 @@ if ($_SESSION['userlevel'] != '10') { include("includes/error-no-perm.inc.php");
    - "); + "; - echo("
    -
    "); - echo("

    Bill Access

    "); + echo "
    +
    "; + echo '

    Bill Access

    '; - $bill_perms = dbFetchRows("SELECT * from bills AS B, bill_perms AS P WHERE P.user_id = ? AND P.bill_id = B.bill_id", array($vars['user_id'])); + $bill_perms = dbFetchRows('SELECT * from bills AS B, bill_perms AS P WHERE P.user_id = ? AND P.bill_id = B.bill_id', array($vars['user_id'])); - echo("
    + echo "
    - "); + "; - foreach ($bill_perms as $bill_perm) - { - echo(" + foreach ($bill_perms as $bill_perm) { + echo ' - "); - $bill_access_list[] = $bill_perm['bill_id']; + "; + $bill_access_list[] = $bill_perm['bill_id']; - $bpermdone = "yes"; - } + $bpermdone = 'yes'; + } - echo("
    Bill name Action
    - ".$bill_perm['bill_name']."   + '.$bill_perm['bill_name']."  
    -
    "); + echo ' +
    '; - if (!$bpermdone) { echo("None Configured"); } + if (!$bpermdone) { + echo 'None Configured'; + } - // Display devices this user doesn't have access to - echo("

    Grant access to new bill

    "); - echo("
    - + // Display devices this user doesn't have access to + echo '

    Grant access to new bill

    '; + echo " +
    - "; - $bills = dbFetchRows("SELECT * FROM `bills` ORDER BY `bill_name`"); - foreach ($bills as $bill) - { - unset($done); - foreach ($bill_access_list as $ac) { if ($ac == $bill['bill_id']) { $done = 1; } } - if (!$done) - { - echo(""); - } - } + $bills = dbFetchRows('SELECT * FROM `bills` ORDER BY `bill_name`'); + foreach ($bills as $bill) { + unset($done); + foreach ($bill_access_list as $ac) { + if ($ac == $bill['bill_id']) { + $done = 1; + } + } - echo(" + if (!$done) { + echo "'; + } + } + + echo "
    -
    "); - - } elseif ($vars['user_id'] && $vars['edit']) { - - if($_SESSION['userlevel'] == 11) { - demo_account(); - } else { - - if(!empty($vars['new_level'])) - { - if($vars['can_modify_passwd'] == 'on') { - $vars['can_modify_passwd'] = '1'; - } - update_user($vars['user_id'],$vars['new_realname'],$vars['new_level'],$vars['can_modify_passwd'],$vars['new_email']); - print_message("User has been updated"); +
    "; } - - if(can_update_users() == '1') { - - $users_details = get_user($vars['user_id']); - if(!empty($users_details)) - { - - if(empty($vars['new_realname'])) - { - $vars['new_realname'] = $users_details['realname']; - } - if(empty($vars['new_level'])) - { - $vars['new_level'] = $users_details['level']; - } - if(empty($vars['can_modify_passwd'])) - { - $vars['can_modify_passwd'] = $users_details['can_modify_passwd']; - } elseif($vars['can_modify_passwd'] == 'on') { - $vars['can_modify_passwd'] = '1'; - } - if(empty($vars['new_email'])) - { - $vars['new_email'] = $users_details['email']; + else if ($vars['user_id'] && $vars['edit']) { + if ($_SESSION['userlevel'] == 11) { + demo_account(); } + else { + if (!empty($vars['new_level'])) { + if ($vars['can_modify_passwd'] == 'on') { + $vars['can_modify_passwd'] = '1'; + } - if( $config['twofactor'] ) { - if( $vars['twofactorremove'] ) { - if( dbUpdate(array('twofactor'=>''),users,'user_id = ?',array($vars['user_id'])) ) { - echo "
    TwoFactor credentials removed.
    "; - } else { - echo "
    Couldnt remove user's TwoFactor credentials.
    "; + update_user($vars['user_id'], $vars['new_realname'], $vars['new_level'], $vars['can_modify_passwd'], $vars['new_email']); + print_message('User has been updated'); } - } - if( $vars['twofactorunlock'] ) { - $twofactor = dbFetchRow("SELECT twofactor FROM users WHERE user_id = ?",array($vars['user_id'])); - $twofactor = json_decode($twofactor['twofactor'],true); - $twofactor['fails'] = 0; - if( dbUpdate(array('twofactor'=>json_encode($twofactor)),users,'user_id = ?',array($vars['user_id'])) ) { - echo "
    User unlocked.
    "; - } else { - echo "
    Couldnt reset user's TwoFactor failures.
    "; - } - } - } - echo("
    - + if (can_update_users() == '1') { + $users_details = get_user($vars['user_id']); + if (!empty($users_details)) { + if (empty($vars['new_realname'])) { + $vars['new_realname'] = $users_details['realname']; + } + + if (empty($vars['new_level'])) { + $vars['new_level'] = $users_details['level']; + } + + if (empty($vars['can_modify_passwd'])) { + $vars['can_modify_passwd'] = $users_details['can_modify_passwd']; + } + else if ($vars['can_modify_passwd'] == 'on') { + $vars['can_modify_passwd'] = '1'; + } + + if (empty($vars['new_email'])) { + $vars['new_email'] = $users_details['email']; + } + + if ($config['twofactor']) { + if ($vars['twofactorremove']) { + if (dbUpdate(array('twofactor' => ''), users, 'user_id = ?', array($vars['user_id']))) { + echo "
    TwoFactor credentials removed.
    "; + } + else { + echo "
    Couldnt remove user's TwoFactor credentials.
    "; + } + } + + if ($vars['twofactorunlock']) { + $twofactor = dbFetchRow('SELECT twofactor FROM users WHERE user_id = ?', array($vars['user_id'])); + $twofactor = json_decode($twofactor['twofactor'], true); + $twofactor['fails'] = 0; + if (dbUpdate(array('twofactor' => json_encode($twofactor)), users, 'user_id = ?', array($vars['user_id']))) { + echo "
    User unlocked.
    "; + } + else { + echo "
    Couldnt reset user's TwoFactor failures.
    "; + } + } + } + + echo " +
    - +
    @@ -310,7 +315,7 @@ if ($_SESSION['userlevel'] != '10') { include("includes/error-no-perm.inc.php");
    - +
    @@ -319,10 +324,22 @@ if ($_SESSION['userlevel'] != '10') { include("includes/error-no-perm.inc.php");
    @@ -332,7 +349,10 @@ if ($_SESSION['userlevel'] != '10') { include("includes/error-no-perm.inc.php");
    @@ -340,14 +360,14 @@ if ($_SESSION['userlevel'] != '10') { include("includes/error-no-perm.inc.php");
    - "); - if( $config['twofactor'] ) { - echo "

    Two-Factor Authentication

    "; - $twofactor = dbFetchRow("SELECT twofactor FROM users WHERE user_id = ?",array($vars['user_id'])); - $twofactor = json_decode($twofactor['twofactor'],true); - if( $twofactor['fails'] >= 3 && (!$config['twofactor_lock'] || (time()-$twofactor['last']) < $config['twofactor_lock']) ) { - echo "
    - +
    "; + if ($config['twofactor']) { + echo "

    Two-Factor Authentication

    "; + $twofactor = dbFetchRow('SELECT twofactor FROM users WHERE user_id = ?', array($vars['user_id'])); + $twofactor = json_decode($twofactor['twofactor'], true); + if ($twofactor['fails'] >= 3 && (!$config['twofactor_lock'] || (time() - $twofactor['last']) < $config['twofactor_lock'])) { + echo "
    +
    @@ -355,43 +375,47 @@ if ($_SESSION['userlevel'] != '10') { include("includes/error-no-perm.inc.php");
    "; - } - if( $twofactor['key'] ) { - echo "
    - + } + + if ($twofactor['key']) { + echo " +
    "; - } else { - echo "

    No TwoFactor key generated for this user, Nothing to do.

    "; - } - } - } else { - echo print_error("Error getting user details"); - } - } else { - echo print_error("Authentication method doesn't support updating users"); + } + else { + echo '

    No TwoFactor key generated for this user, Nothing to do.

    '; + } + }//end if + } + else { + echo print_error('Error getting user details'); + }//end if + } + else { + echo print_error("Authentication method doesn't support updating users"); + }//end if + }//end if } - } - } else { + else { + $user_list = get_userlist(); - $user_list = get_userlist(); + echo '

    Select a user to edit

    '; - echo("

    Select a user to edit

    "); - - echo("
    + echo "
    - +
    @@ -399,11 +423,8 @@ if ($_SESSION['userlevel'] != '10') { include("includes/error-no-perm.inc.php"); /
    - "); - } + "; + }//end if +}//end if -} - -echo("
    "); - -?> +echo '
    '; diff --git a/html/pages/eventlog.inc.php b/html/pages/eventlog.inc.php index 4e1cad13d2..2ac41ec91b 100644 --- a/html/pages/eventlog.inc.php +++ b/html/pages/eventlog.inc.php @@ -1,16 +1,15 @@ = '10') -{ - dbQuery("TRUNCATE TABLE `eventlog`"); - print_message("Event log truncated"); +if ($vars['action'] == 'expunge' && $_SESSION['userlevel'] >= '10') { + dbQuery('TRUNCATE TABLE `eventlog`'); + print_message('Event log truncated'); } -$pagetitle[] = "Eventlog"; +$pagetitle[] = 'Eventlog'; print_optionbar_start(); @@ -24,15 +23,17 @@ print_optionbar_start();
    @@ -40,9 +41,7 @@ print_optionbar_start(); diff --git a/html/pages/front/default.php b/html/pages/front/default.php index 7b17f08a45..b69f7f97b1 100644 --- a/html/pages/front/default.php +++ b/html/pages/front/default.php @@ -1,174 +1,180 @@ + +function generate_front_box($frontbox_class, $content) { + echo "
    $content -
    "); + "; + +}//end generate_front_box() + + +echo ' +
    +'; +if ($config['vertical_summary']) { + echo '
    '; +} +else { + echo '
    '; } -echo(' -
    -'); -if ($config['vertical_summary']) { - echo('
    '); -} -else -{ - echo('
    '); -} -echo(' +echo '
    -'); +'; -echo('
    '); +echo '
    '; -echo('
    '); +echo '
    '; $count_boxes = 0; // Device down boxes -if ($_SESSION['userlevel'] >= '10') -{ - $sql = "SELECT * FROM `devices` WHERE `status` = '0' AND `ignore` = '0' LIMIT ".$config['front_page_down_box_limit']; -} else { - $sql = "SELECT * FROM `devices` AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' AND D.status = '0' AND D.ignore = '0' LIMIT".$config['front_page_down_box_limit']; +if ($_SESSION['userlevel'] >= '10') { + $sql = "SELECT * FROM `devices` WHERE `status` = '0' AND `ignore` = '0' LIMIT ".$config['front_page_down_box_limit']; } -foreach (dbFetchRows($sql) as $device) -{ - generate_front_box("device-down", generate_device_link($device, shorthost($device['hostname']))."
    - Device Down
    - ".truncate($device['location'], 20).""); - ++$count_boxes; +else { + $sql = "SELECT * FROM `devices` AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '".$_SESSION['user_id']."' AND D.status = '0' AND D.ignore = '0' LIMIT".$config['front_page_down_box_limit']; } -if ($_SESSION['userlevel'] >= '10') -{ - $sql = "SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0' AND `D`.`status` = '1' LIMIT ".$config['front_page_down_box_limit']; -} else { - $sql = "SELECT * FROM `ports` AS I, `devices` AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' AND I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0' AND `D`.`status` = '1' LIMIT ".$config['front_page_down_box_limit']; +foreach (dbFetchRows($sql) as $device) { + generate_front_box( + 'device-down', + generate_device_link($device, shorthost($device['hostname'])).'
    + Device Down
    + '.truncate($device['location'], 20).'' + ); + ++$count_boxes; +} + +if ($_SESSION['userlevel'] >= '10') { + $sql = "SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0' AND `D`.`status` = '1' LIMIT ".$config['front_page_down_box_limit']; +} +else { + $sql = "SELECT * FROM `ports` AS I, `devices` AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '".$_SESSION['user_id']."' AND I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0' AND `D`.`status` = '1' LIMIT ".$config['front_page_down_box_limit']; } // These things need to become more generic, and more manageable across different frontpages... rewrite inc :> - // Port down boxes -if ($config['warn']['ifdown']) -{ - foreach (dbFetchRows($sql) as $interface) - { - if (!$interface['deleted']) - { - $interface = ifNameDescr($interface); - generate_front_box("port-down", generate_device_link($interface, shorthost($interface['hostname']))."
    +if ($config['warn']['ifdown']) { + foreach (dbFetchRows($sql) as $interface) { + if (!$interface['deleted']) { + $interface = ifNameDescr($interface); + generate_front_box( + 'port-down', + generate_device_link($interface, shorthost($interface['hostname']))."
    Port Down
    - - ".generate_port_link($interface, truncate(makeshortif($interface['label']),13,''))."
    - " . ($interface['ifAlias'] ? ''.truncate($interface['ifAlias'], 20, '').'' : '')); - ++$count_boxes; + + ".generate_port_link($interface, truncate(makeshortif($interface['label']), 13, '')).'
    + '.($interface['ifAlias'] ? ''.truncate($interface['ifAlias'], 20, '').'' : '') + ); + ++$count_boxes; + } } - } } -/* FIXME service permissions? seem nonexisting now.. */ +/* + FIXME service permissions? seem nonexisting now.. */ // Service down boxes -if ($_SESSION['userlevel'] >= '10') -{ - $sql = "SELECT * FROM `services` AS S, `devices` AS D WHERE S.device_id = D.device_id AND service_status = 'down' AND D.ignore = '0' AND S.service_ignore = '0' AND `D`.`status` = '1' LIMIT ".$config['front_page_down_box_limit']; - $param[] = ''; +if ($_SESSION['userlevel'] >= '10') { + $sql = "SELECT * FROM `services` AS S, `devices` AS D WHERE S.device_id = D.device_id AND service_status = 'down' AND D.ignore = '0' AND S.service_ignore = '0' AND `D`.`status` = '1' LIMIT ".$config['front_page_down_box_limit']; + $param[] = ''; } -else -{ - $sql = "SELECT * FROM services AS S, devices AS D, devices_perms AS P WHERE P.`user_id` = ? AND P.`device_id` = D.`device_id` AND S.`device_id` = D.`device_id` AND S.`service_ignore` = '0' AND S.`service_disabled` = '0' AND S.`service_status` = '0' AND `D`.`status` = '1' LIMIT ".$config['front_page_down_box_limit']; - $param[] = $_SESSION['user_id']; +else { + $sql = "SELECT * FROM services AS S, devices AS D, devices_perms AS P WHERE P.`user_id` = ? AND P.`device_id` = D.`device_id` AND S.`device_id` = D.`device_id` AND S.`service_ignore` = '0' AND S.`service_disabled` = '0' AND S.`service_status` = '0' AND `D`.`status` = '1' LIMIT ".$config['front_page_down_box_limit']; + $param[] = $_SESSION['user_id']; } -foreach (dbFetchRows($sql,$param) as $service) -{ - generate_front_box("service-down", generate_device_link($service, shorthost($service['hostname']))."
    + +foreach (dbFetchRows($sql, $param) as $service) { + generate_front_box( + 'service-down', + generate_device_link($service, shorthost($service['hostname'])).'
    Service Down - ".$service['service_type']."
    - ".truncate($interface['ifAlias'], 20).""); - ++$count_boxes; + '.$service['service_type'].'
    + '.truncate($interface['ifAlias'], 20).'' + ); + ++$count_boxes; } // BGP neighbour down boxes -if (isset($config['enable_bgp']) && $config['enable_bgp']) -{ - if ($_SESSION['userlevel'] >= '10') - { - $sql = "SELECT * FROM `devices` AS D, bgpPeers AS B WHERE bgpPeerAdminStatus != 'start' AND bgpPeerState != 'established' AND bgpPeerState != '' AND B.device_id = D.device_id AND D.ignore = 0 AND `D`.`status` = '1' LIMIT ".$config['front_page_down_box_limit']; - } else { - $sql = "SELECT * FROM `devices` AS D, bgpPeers AS B, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' AND bgpPeerAdminStatus != 'start' AND bgpPeerState != 'established' AND bgpPeerState != '' AND B.device_id = D.device_id AND D.ignore = 0 AND `D`.`status` = '1' LIMIT ".$config['front_page_down_box_limit']; - } - foreach (dbFetchRows($sql) as $peer) - { - generate_front_box("bgp-down", generate_device_link($peer, shorthost($peer['hostname']))."
    +if (isset($config['enable_bgp']) && $config['enable_bgp']) { + if ($_SESSION['userlevel'] >= '10') { + $sql = "SELECT * FROM `devices` AS D, bgpPeers AS B WHERE bgpPeerAdminStatus != 'start' AND bgpPeerState != 'established' AND bgpPeerState != '' AND B.device_id = D.device_id AND D.ignore = 0 AND `D`.`status` = '1' LIMIT ".$config['front_page_down_box_limit']; + } + else { + $sql = "SELECT * FROM `devices` AS D, bgpPeers AS B, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '".$_SESSION['user_id']."' AND bgpPeerAdminStatus != 'start' AND bgpPeerState != 'established' AND bgpPeerState != '' AND B.device_id = D.device_id AND D.ignore = 0 AND `D`.`status` = '1' LIMIT ".$config['front_page_down_box_limit']; + } + + foreach (dbFetchRows($sql) as $peer) { + generate_front_box( + 'bgp-down', + generate_device_link($peer, shorthost($peer['hostname']))."
    BGP Down - ".$peer['bgpPeerIdentifier']."
    - AS".truncate($peer['bgpPeerRemoteAs']." ".$peer['astext'], 14, "").""); - ++$count_boxes; - } + ".$peer['bgpPeerIdentifier'].'
    + AS'.truncate($peer['bgpPeerRemoteAs'].' '.$peer['astext'], 14, '').'' + ); + ++$count_boxes; + } } // Device rebooted boxes -if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== FALSE && $config['uptime_warning'] > 0) -{ - if ($_SESSION['userlevel'] >= '10') - { - $sql = "SELECT * FROM `devices` AS D WHERE D.status = '1' AND D.uptime > 0 AND D.uptime < '" . $config['uptime_warning'] . "' AND D.ignore = 0 LIMIT ".$config['front_page_down_box_limit']; - } else { - $sql = "SELECT * FROM `devices` AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' AND D.status = '1' AND D.uptime > 0 AND D.uptime < '" . - $config['uptime_warning'] . "' AND D.ignore = 0 LIMIT ".$config['front_page_down_box_limit']; - } +if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== false && $config['uptime_warning'] > 0) { + if ($_SESSION['userlevel'] >= '10') { + $sql = "SELECT * FROM `devices` AS D WHERE D.status = '1' AND D.uptime > 0 AND D.uptime < '".$config['uptime_warning']."' AND D.ignore = 0 LIMIT ".$config['front_page_down_box_limit']; + } + else { + $sql = "SELECT * FROM `devices` AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '".$_SESSION['user_id']."' AND D.status = '1' AND D.uptime > 0 AND D.uptime < '".$config['uptime_warning']."' AND D.ignore = 0 LIMIT ".$config['front_page_down_box_limit']; + } - foreach (dbFetchRows($sql) as $device) - { - generate_front_box("device-rebooted", generate_device_link($device, shorthost($device['hostname']))."
    + foreach (dbFetchRows($sql) as $device) { + generate_front_box( + 'device-rebooted', + generate_device_link($device, shorthost($device['hostname'])).'
    Device Rebooted
    - ".formatUptime($device['uptime'], 'short').""); - ++$count_boxes; - } + '.formatUptime($device['uptime'], 'short').'' + ); + ++$count_boxes; + } } + if ($count_boxes == 0) { - echo("
    Nothing here yet

    This is where status notifications about devices and services would normally go. You might have none - because you run such a great network, or perhaps you've just started using ".$config['project_name'].". If you're new to ".$config['project_name'].", you might - want to start by adding one or more devices in the Devices menu.

    "); -} -echo('
    '); -echo('
    '); -echo('
    '); -echo(' -
    -
    -'); - -if ($config['vertical_summary']) -{ - echo('
    '); - include_once("includes/device-summary-vert.inc.php"); -} -else -{ - echo('
    '); - include_once("includes/device-summary-horiz.inc.php"); + echo "
    Nothing here yet

    This is where status notifications about devices and services would normally go. You might have none + because you run such a great network, or perhaps you've just started using ".$config['project_name'].". If you're new to ".$config['project_name'].', you might + want to start by adding one or more devices in the Devices menu.

    '; } -echo(' +echo '
    '; +echo '
    '; +echo '
    '; +echo ' +
    +
    +'; + +if ($config['vertical_summary']) { + echo '
    '; + include_once 'includes/device-summary-vert.inc.php'; +} +else { + echo '
    '; + include_once 'includes/device-summary-horiz.inc.php'; +} + +echo '
    -'); +'; -if ($config['enable_syslog']) -{ +if ($config['enable_syslog']) { + $sql = "SELECT *, DATE_FORMAT(timestamp, '".$config['dateformat']['mysql']['compact']."') AS date from syslog ORDER BY timestamp DESC LIMIT 20"; + $query = mysql_query($sql); - $sql = "SELECT *, DATE_FORMAT(timestamp, '".$config['dateformat']['mysql']['compact']."') AS date from syslog ORDER BY timestamp DESC LIMIT 20"; - $query = mysql_query($sql); - - echo('
    + echo '
      @@ -180,35 +186,34 @@ if ($config['enable_syslog'])
    Syslog entries
    -
    '); +
    '; - foreach (dbFetchRows($sql) as $entry) - { - $entry = array_merge($entry, device_by_id_cache($entry['device_id'])); + foreach (dbFetchRows($sql) as $entry) { + $entry = array_merge($entry, device_by_id_cache($entry['device_id'])); - include("includes/print-syslog.inc.php"); - } - echo("
    "); - echo(""); - echo(""); - echo(""); - echo(""); + include 'includes/print-syslog.inc.php'; + } -} else { + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; +} +else { + if ($_SESSION['userlevel'] >= '10') { + $query = "SELECT *,DATE_FORMAT(datetime, '".$config['dateformat']['mysql']['compact']."') as humandate FROM `eventlog` ORDER BY `datetime` DESC LIMIT 0,15"; + $alertquery = 'SELECT devices.device_id,name,state,time_logged FROM alert_log LEFT JOIN devices ON alert_log.device_id=devices.device_id LEFT JOIN alert_rules ON alert_log.rule_id=alert_rules.id ORDER BY `time_logged` DESC LIMIT 0,15'; + } + else { + $query = "SELECT *,DATE_FORMAT(datetime, '".$config['dateformat']['mysql']['compact']."') as humandate FROM `eventlog` AS E, devices_perms AS P WHERE E.host = P.device_id AND P.user_id = ".$_SESSION['user_id'].' ORDER BY `datetime` DESC LIMIT 0,15'; + $alertquery = 'SELECT devices.device_id,name,state,time_logged FROM alert_log LEFT JOIN devices ON alert_log.device_id=devices.device_id LEFT JOIN alert_rules ON alert_log.rule_id=alert_rules.id RIGHT JOIN devices_perms ON alert_log.device_id = devices_perms.device_id AND devices_perms.user_id = '.$_SESSION['user_id'].' ORDER BY `time_logged` DESC LIMIT 0,15'; + } - if ($_SESSION['userlevel'] >= '10') - { - $query = "SELECT *,DATE_FORMAT(datetime, '".$config['dateformat']['mysql']['compact']."') as humandate FROM `eventlog` ORDER BY `datetime` DESC LIMIT 0,15"; - $alertquery = "SELECT devices.device_id,name,state,time_logged FROM alert_log LEFT JOIN devices ON alert_log.device_id=devices.device_id LEFT JOIN alert_rules ON alert_log.rule_id=alert_rules.id ORDER BY `time_logged` DESC LIMIT 0,15"; - } else { - $query = "SELECT *,DATE_FORMAT(datetime, '".$config['dateformat']['mysql']['compact']."') as humandate FROM `eventlog` AS E, devices_perms AS P WHERE E.host = P.device_id AND P.user_id = " . $_SESSION['user_id'] . " ORDER BY `datetime` DESC LIMIT 0,15"; - $alertquery = "SELECT devices.device_id,name,state,time_logged FROM alert_log LEFT JOIN devices ON alert_log.device_id=devices.device_id LEFT JOIN alert_rules ON alert_log.rule_id=alert_rules.id RIGHT JOIN devices_perms ON alert_log.device_id = devices_perms.device_id AND devices_perms.user_id = " . $_SESSION['user_id'] . " ORDER BY `time_logged` DESC LIMIT 0,15"; - } + $data = mysql_query($query); + $alertdata = mysql_query($alertquery); - $data = mysql_query($query); - $alertdata = mysql_query($alertquery); - - echo('
    + echo '
      @@ -220,13 +225,13 @@ if ($config['enable_syslog'])
    Alertlog entries
    - '); +
    '; - foreach (dbFetchRows($alertquery) as $alert_entry) - { - include("includes/print-alerts.inc.php"); - } - echo('
    + foreach (dbFetchRows($alertquery) as $alert_entry) { + include 'includes/print-alerts.inc.php'; + } + + echo '
    @@ -234,24 +239,21 @@ if ($config['enable_syslog'])
    Eventlog entries
    - '); +
    '; - foreach (dbFetchRows($query) as $entry) - { - include("includes/print-event.inc.php"); - } + foreach (dbFetchRows($query) as $entry) { + include 'includes/print-event.inc.php'; + } - echo("
    "); - echo("
    "); - echo("
    "); - echo("
    "); - echo(""); -} + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; +}//end if -echo(""); +echo ''; -echo(' +echo ' -'); - -?> +'; diff --git a/html/pages/front/demo.php b/html/pages/front/demo.php index 1000fbca24..6478a566b8 100644 --- a/html/pages/front/demo.php +++ b/html/pages/front/demo.php @@ -4,56 +4,55 @@ "); +echo ''; -$dev_list = array('6' => 'Central Fileserver', - '7' => 'NE61 Fileserver', - '34' => 'DE56 Fileserver'); +$dev_list = array( + '6' => 'Central Fileserver', + '7' => 'NE61 Fileserver', + '34' => 'DE56 Fileserver', +); -foreach ($dev_list as $device_id => $descr) -{ +foreach ($dev_list as $device_id => $descr) { + echo ''; +}//end foreach - echo(""); - -} - -echo("
    '; + echo "
    ".$descr.'
    '; + $graph_array['height'] = '100'; + $graph_array['width'] = '310'; + $graph_array['to'] = $config['time']['now']; + $graph_array['device'] = $device_id; + $graph_array['type'] = 'device_bits'; + $graph_array['from'] = $config['time']['day']; + $graph_array['legend'] = 'no'; + $graph_array['popup_title'] = $descr; + // $graph_array['link'] = generate_device_link($device_id); + print_graph_popup($graph_array); - echo("
    "); - echo("
    ".$descr."
    "); - $graph_array['height'] = "100"; - $graph_array['width'] = "310"; - $graph_array['to'] = $config['time']['now']; - $graph_array['device'] = $device_id; - $graph_array['type'] = "device_bits"; - $graph_array['from'] = $config['time']['day']; - $graph_array['legend'] = "no"; - $graph_array['popup_title'] = $descr; -# $graph_array['link'] = generate_device_link($device_id); - print_graph_popup($graph_array); + $graph_array['height'] = '50'; + $graph_array['width'] = '180'; - $graph_array['height'] = "50"; - $graph_array['width'] = "180"; + echo "
    "; + $graph_array['type'] = 'device_ucd_memory'; + print_graph_popup($graph_array); + echo '
    '; - echo("
    "); - $graph_array['type'] = "device_ucd_memory"; - print_graph_popup($graph_array); - echo("
    "); + echo "
    "; + $graph_array['type'] = 'device_processor'; + print_graph_popup($graph_array); + echo '
    '; - echo("
    "); - $graph_array['type'] = "device_processor"; - print_graph_popup($graph_array); - echo("
    "); + echo "
    "; + $graph_array['type'] = 'device_storage'; + print_graph_popup($graph_array); + echo '
    '; - echo("
    "); - $graph_array['type'] = "device_storage"; - print_graph_popup($graph_array); - echo("
    "); + echo "
    "; + $graph_array['type'] = 'device_diskio'; + print_graph_popup($graph_array); + echo '
    '; - echo("
    "); - $graph_array['type'] = "device_diskio"; - print_graph_popup($graph_array); - echo("
    "); + echo '
    "); +echo ''; ?> @@ -62,115 +61,105 @@ echo(""); '0' AND A.attrib_value < '86400'"; -foreach (dbFetchRows($sql) as $device) -{ - unset($already); - $i = 0; - while ($i <= count($nodes)) { - $thisnode = $device['device_id']; - if ($nodes[$i] == $thisnode) { - $already = "yes"; +foreach (dbFetchRows($sql) as $device) { + unset($already); + $i = 0; + while ($i <= count($nodes)) { + $thisnode = $device['device_id']; + if ($nodes[$i] == $thisnode) { + $already = 'yes'; + } + + $i++; + } + + if (!$already) { + $nodes[] = $device['device_id']; } - $i++; - } - if (!$already) { $nodes[] = $device['device_id']; } } $sql = "SELECT * FROM `devices` WHERE `status` = '0' AND `ignore` = '0'"; -foreach (dbFetchRows($sql) as $device) -{ - if (device_permitted($device['device_id'])) { - echo("
    - ".generate_device_link($device, shorthost($device['hostname']))."
    - Device Down
    - ".truncate($device['location'], 35)." -
    "); - } +foreach (dbFetchRows($sql) as $device) { + if (device_permitted($device['device_id'])) { + echo "
    + ".generate_device_link($device, shorthost($device['hostname']))."
    + Device Down
    + ".truncate($device['location'], 35).' +
    '; + } } -if ($config['warn']['ifdown']) -{ - $sql = "SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0'"; - foreach (dbFetchRows($sql) as $interface) - { - if (port_permitted($interface['port_id'])) - { - echo("
    - ".generate_device_link($interface, shorthost($interface['hostname']))."
    - Port Down
    - ".generate_port_link($interface, makeshortif($interface['ifDescr']))."
    - ".truncate($interface['ifAlias'], 15)." -
    "); +if ($config['warn']['ifdown']) { + $sql = "SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0'"; + foreach (dbFetchRows($sql) as $interface) { + if (port_permitted($interface['port_id'])) { + echo "
    + ".generate_device_link($interface, shorthost($interface['hostname']))."
    + Port Down
    + ".generate_port_link($interface, makeshortif($interface['ifDescr'])).'
    + '.truncate($interface['ifAlias'], 15).' +
    '; + } } - } } $sql = "SELECT * FROM `services` AS S, `devices` AS D WHERE S.device_id = D.device_id AND service_status = 'down' AND D.ignore = '0' AND S.service_ignore = '0'"; -foreach (dbFetchRows($sql) as $service) -{ - if (device_permitted($service['device_id'])) - { - echo("
    - ".generate_device_link($service, shorthost($service['hostname']))."
    - Service Down
    - ".$service['service_type']."
    - ".truncate($interface['ifAlias'], 15)." -
    "); - } +foreach (dbFetchRows($sql) as $service) { + if (device_permitted($service['device_id'])) { + echo "
    + ".generate_device_link($service, shorthost($service['hostname']))."
    + Service Down
    + ".$service['service_type'].'
    + '.truncate($interface['ifAlias'], 15).' +
    '; + } } $sql = "SELECT * FROM `devices` AS D, bgpPeers AS B WHERE bgpPeerAdminStatus = 'start' AND bgpPeerState != 'established' AND B.device_id = D.device_id"; -foreach (dbFetchRows($sql) as $peer) -{ - if (device_permitted($peer['device_id'])) - { - echo("
    - ".generate_device_link($peer, shorthost($peer['hostname']))."
    - BGP Down
    - ".$peer['bgpPeerIdentifier']."
    - AS".$peer['bgpPeerRemoteAs']." ".truncate($peer['astext'], 10)." -
    "); - } -} - -if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== FALSE && $config['uptime_warning'] > 0) -{ - $sql = "SELECT * FROM devices_attribs AS A, `devices` AS D WHERE - A.attrib_value < '" . $config['uptime_warning'] . "' AND A.attrib_type = 'uptime' AND A.device_id = D.device_id AND ignore = '0' AND disabled = '0'"; - foreach (dbFetchRows($sql) as $device) - { - if (device_permitted($device['device_id']) && $device['attrib_value'] < $config['uptime_warning'] && $device['attrib_type'] == "uptime") - { - echo("
    - ".generate_device_link($device, shorthost($device['hostname']))."
    - Device
    Rebooted

    - ".formatUptime($device['attrib_value'])." -
    "); +foreach (dbFetchRows($sql) as $peer) { + if (device_permitted($peer['device_id'])) { + echo "
    + ".generate_device_link($peer, shorthost($peer['hostname']))."
    + BGP Down
    + ".$peer['bgpPeerIdentifier'].'
    + AS'.$peer['bgpPeerRemoteAs'].' '.truncate($peer['astext'], 10).' +
    '; } - } } -echo(" -
    $errorboxes
    +if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== false && $config['uptime_warning'] > 0) { + $sql = "SELECT * FROM devices_attribs AS A, `devices` AS D WHERE + A.attrib_value < '".$config['uptime_warning']."' AND A.attrib_type = 'uptime' AND A.device_id = D.device_id AND ignore = '0' AND disabled = '0'"; + foreach (dbFetchRows($sql) as $device) { + if (device_permitted($device['device_id']) && $device['attrib_value'] < $config['uptime_warning'] && $device['attrib_type'] == 'uptime') { + echo "
    + ".generate_device_link($device, shorthost($device['hostname']))."
    + Device
    Rebooted

    + ".formatUptime($device['attrib_value']).' +
    '; + } + } +} -

    Recent Syslog Messages

    -"); +echo " +
    $errorboxes
    + +

    Recent Syslog Messages

    + "; $sql = "SELECT *, DATE_FORMAT(timestamp, '".$config['dateformat']['mysql']['compact']."') AS date from `syslog` ORDER BY seq DESC LIMIT 20"; -echo(""); -foreach (dbFetchRows($sql) as $entry) -{ - $entry = array_merge($entry, device_by_id_cache($entry['device_id'])); +echo '
    '; +foreach (dbFetchRows($sql) as $entry) { + $entry = array_merge($entry, device_by_id_cache($entry['device_id'])); - include("includes/print-syslog.inc.php"); + include 'includes/print-syslog.inc.php'; } -echo("
    "); +echo ''; ?> diff --git a/html/pages/front/example2.php b/html/pages/front/example2.php index 717ee75184..e5898ac073 100644 --- a/html/pages/front/example2.php +++ b/html/pages/front/example2.php @@ -4,173 +4,141 @@
    Devices with Alerts
    Host
    Int
    Srv
    +// ?> '0' AND A.attrib_value < '86400'"; -foreach (dbFetchRows($sql) as $device) -{ - unset($already); - $i = 0; - while ($i <= count($nodes)) - { - $thisnode = $device['device_id']; - if ($nodes[$i] == $thisnode) - { - $already = "yes"; +foreach (dbFetchRows($sql) as $device) { + unset($already); + $i = 0; + while ($i <= count($nodes)) { + $thisnode = $device['device_id']; + if ($nodes[$i] == $thisnode) { + $already = 'yes'; + } + + $i++; + } + + if (!$already) { + $nodes[] = $device['device_id']; } - $i++; - } - if (!$already) { $nodes[] = $device['device_id']; } } $sql = "SELECT * FROM `devices` WHERE `status` = '0' AND `ignore` = '0'"; -foreach (dbFetchRows($sql) as $device) -{ - echo("
    -
    ".generate_device_link($device, shorthost($device['hostname']))."
    - Device Down - ".truncate($device['location'], 20)." -
    "); - +foreach (dbFetchRows($sql) as $device) { + echo "
    +
    ".generate_device_link($device, shorthost($device['hostname']))."
    + Device Down + ".truncate($device['location'], 20).' +
    '; } $sql = "SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0'"; -foreach (dbFetchRows($sql) as $interface) -{ - echo("
    -
    ".generate_device_link($interface, shorthost($interface['hostname']))."
    - Port Down - ".generate_port_link($interface, makeshortif($interface['ifDescr']))."
    - ".truncate($interface['ifAlias'], 20)." -
    "); - +foreach (dbFetchRows($sql) as $interface) { + echo "
    +
    ".generate_device_link($interface, shorthost($interface['hostname']))."
    + Port Down + ".generate_port_link($interface, makeshortif($interface['ifDescr'])).'
    + '.truncate($interface['ifAlias'], 20).' +
    '; } $sql = "SELECT * FROM `services` AS S, `devices` AS D WHERE S.device_id = D.device_id AND service_status = 'down' AND D.ignore = '0' AND S.service_ignore = '0'"; -foreach (dbFetchRows($sql) as $service) -{ - echo("
    -
    ".generate_device_link($service, shorthost($service['hostname']))."
    - Service Down - ".$service['service_type']."
    - ".truncate($interface['ifAlias'], 20)." -
    "); - +foreach (dbFetchRows($sql) as $service) { + echo "
    +
    ".generate_device_link($service, shorthost($service['hostname']))."
    + Service Down + ".$service['service_type'].'
    + '.truncate($interface['ifAlias'], 20).' +
    '; } $sql = "SELECT * FROM `devices` AS D, bgpPeers AS B WHERE bgpPeerState != 'established' AND B.device_id = D.device_id"; -foreach (dbFetchRows($sql) as $peer) -{ - echo("
    -
    ".generate_device_link($peer, shorthost($peer['hostname']))."
    - BGP Down - ".$peer['bgpPeerIdentifier']."
    - AS".$peer['bgpPeerRemoteAs']." ".truncate($peer['astext'], 10)." -
    "); - +foreach (dbFetchRows($sql) as $peer) { + echo "
    +
    ".generate_device_link($peer, shorthost($peer['hostname']))."
    + BGP Down + ".$peer['bgpPeerIdentifier'].'
    + AS'.$peer['bgpPeerRemoteAs'].' '.truncate($peer['astext'], 10).' +
    '; } -if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== FALSE && $config['uptime_warning'] > 0) -{ - $sql = "SELECT * FROM `devices` AS D, devices_attribs AS A WHERE A.device_id = D.device_id AND A.attrib_type = 'uptime' AND A.attrib_value < '" . $config['uptime_warning'] . "'"; - foreach (dbFetchRows($sql) as $device) - { - echo("
    -
    ".generate_device_link($device, shorthost($device['hostname']))."
    - Device
    Rebooted

    - ".formatUptime($device['attrib_value'])." -
    "); - } +if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== false && $config['uptime_warning'] > 0) { + $sql = "SELECT * FROM `devices` AS D, devices_attribs AS A WHERE A.device_id = D.device_id AND A.attrib_type = 'uptime' AND A.attrib_value < '".$config['uptime_warning']."'"; + foreach (dbFetchRows($sql) as $device) { + echo "
    +
    ".generate_device_link($device, shorthost($device['hostname']))."
    + Device
    Rebooted

    + ".formatUptime($device['attrib_value']).' +
    '; + } } -echo(" +echo " -
    $errorboxes
    +
    $errorboxes
    -

    Recent Syslog Messages

    +

    Recent Syslog Messages

    -"); + "; $sql = "SELECT *, DATE_FORMAT(timestamp, '".$config['dateformat']['mysql']['compact']."') AS date from syslog ORDER BY timestamp DESC LIMIT 20"; -echo("
    Devices with Alerts
    Host
    Int
    Srv
    "); -foreach (dbFetchRows($sql) as $entry) -{ - include("includes/print-syslog.inc.php"); +echo '
    '; +foreach (dbFetchRows($sql) as $entry) { + include 'includes/print-syslog.inc.php'; } -echo("
    "); -echo("
    +echo ''; - - "); +echo '
    + + + '; // this stuff can be customised to show whatever you want.... +if ($_SESSION['userlevel'] >= '5') { + $sql = "SELECT * FROM ports AS I, devices AS D WHERE `ifAlias` like 'L2TP: %' AND I.device_id = D.device_id AND D.hostname LIKE '%"; + $sql .= $config['mydomain']."' ORDER BY I.ifAlias"; + unset($seperator); + foreach (dbFetchRows($sql) as $interface) { + $ports['l2tp'] .= $seperator.$interface['port_id']; + $seperator = ','; + } -if ($_SESSION['userlevel'] >= '5') -{ - $sql = "SELECT * FROM ports AS I, devices AS D WHERE `ifAlias` like 'L2TP: %' AND I.device_id = D.device_id AND D.hostname LIKE '%"; - $sql .= $config['mydomain'] . "' ORDER BY I.ifAlias"; - unset ($seperator); - foreach (dbFetchRows($sql) as $interface) - { - $ports['l2tp'] .= $seperator . $interface['port_id']; - $seperator = ","; - } + $sql = "SELECT * FROM ports AS I, devices AS D WHERE `ifAlias` like 'Transit: %' AND I.device_id = D.device_id AND D.hostname LIKE '%"; + $sql .= $config['mydomain']."' ORDER BY I.ifAlias"; + unset($seperator); + foreach (dbFetchRows($sql) as $interface) { + $ports['transit'] .= $seperator.$interface['port_id']; + $seperator = ','; + } - $sql = "SELECT * FROM ports AS I, devices AS D WHERE `ifAlias` like 'Transit: %' AND I.device_id = D.device_id AND D.hostname LIKE '%"; - $sql .= $config['mydomain'] . "' ORDER BY I.ifAlias"; - unset ($seperator); - foreach (dbFetchRows($sql) as $interface) - { - $ports['transit'] .= $seperator . $interface['port_id']; - $seperator = ","; - } + $sql = "SELECT * FROM ports AS I, devices AS D WHERE `ifAlias` like 'Server: thlon-pbx%' AND I.device_id = D.device_id AND D.hostname LIKE '%"; + $sql .= $config['mydomain']."' ORDER BY I.ifAlias"; + unset($seperator); + foreach (dbFetchRows($sql) as $interface) { + $ports['voip'] .= $seperator.$interface['port_id']; + $seperator = ','; + } - $sql = "SELECT * FROM ports AS I, devices AS D WHERE `ifAlias` like 'Server: thlon-pbx%' AND I.device_id = D.device_id AND D.hostname LIKE '%"; - $sql .= $config['mydomain'] . "' ORDER BY I.ifAlias"; - unset ($seperator); - foreach (dbFetchRows($sql) as $interface) - { - $ports['voip'] .= $seperator . $interface['port_id']; - $seperator = ","; - } + if ($ports['transit']) { + echo "', CENTER, LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 250);\" onmouseout=\"return nd();\" >"."
    Internet Transit
    "."
    "; + } - if ($ports['transit']) - { - echo("', CENTER, LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 250);\" onmouseout=\"return nd();\" >". - "
    Internet Transit
    ". - "
    "); - } + if ($ports['l2tp']) { + echo "', LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 250);\" onmouseout=\"return nd();\" >"."
    L2TP ADSL
    "."
    "; + } - if ($ports['l2tp']) - { - echo("', LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 250);\" onmouseout=\"return nd();\" >". - "
    L2TP ADSL
    ". - "
    "); - } - - if ($ports['voip']) - { - echo("', LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 250);\" onmouseout=\"return nd();\" >". - "
    VoIP to PSTN
    ". - "
    "); - } - -} + if ($ports['voip']) { + echo "', LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 250);\" onmouseout=\"return nd();\" >"."
    VoIP to PSTN
    "."
    "; + } +}//end if // END VOSTRON - ?> diff --git a/html/pages/front/globe.php b/html/pages/front/globe.php index 75a5917c70..9884b402fa 100644 --- a/html/pages/front/globe.php +++ b/html/pages/front/globe.php @@ -4,16 +4,17 @@ * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . */ + * along with this program. If not, see . + */ -/** +/* * Custom Frontpage * @author f0o * @copyright 2014 f0o, LibreNMS @@ -25,107 +26,111 @@ ?> -
    -
    -
    -
    -
    -
    -
    -
    '; - include_once("includes/device-summary-vert.inc.php"); -echo '
    -
    -
    -
    '; - include_once("includes/front/boxes.inc.php"); -echo '
    -
    -
    -
    -
    -
    -
    '; - $device['device_id'] = '-1'; - require_once('includes/print-alerts.php'); - unset($device['device_id']); -echo '
    -
    +
    +
    +
    +
    +
    +
    +
    +
    '; + include_once("includes/device-summary-vert.inc.php"); +echo '
    +
    +
    +
    '; + include_once("includes/front/boxes.inc.php"); +echo '
    +
    +
    +
    +
    +
    +
    '; + $device['device_id'] = '-1'; + require_once('includes/print-alerts.php'); + unset($device['device_id']); +echo '
    +
    '; //From default.php - This code is not part of above license. if ($config['enable_syslog']) { -$sql = "SELECT *, DATE_FORMAT(timestamp, '".$config['dateformat']['mysql']['compact']."') AS date from syslog ORDER BY seq DESC LIMIT 20"; -$query = mysql_query($sql); -echo('
    + $sql = "SELECT *, DATE_FORMAT(timestamp, '".$config['dateformat']['mysql']['compact']."') AS date from syslog ORDER BY seq DESC LIMIT 20"; + $query = mysql_query($sql); + echo('
      @@ -139,29 +144,28 @@ echo('
    '); - foreach (dbFetchRows($sql) as $entry) - { - $entry = array_merge($entry, device_by_id_cache($entry['device_id'])); + foreach (dbFetchRows($sql) as $entry) { + $entry = array_merge($entry, device_by_id_cache($entry['device_id'])); - include("includes/print-syslog.inc.php"); - } - echo("
    "); - echo("
    "); - echo("
    "); - echo("
    "); - echo("
    "); + include 'includes/print-syslog.inc.php'; + } + echo(""); + echo(""); + echo(""); + echo(""); + echo(""); +} +else { -} else { + if ($_SESSION['userlevel'] == '10') { + $query = "SELECT *,DATE_FORMAT(datetime, '".$config['dateformat']['mysql']['compact']."') as humandate FROM `eventlog` ORDER BY `datetime` DESC LIMIT 0,15"; + } + else { + $query = "SELECT *,DATE_FORMAT(datetime, '".$config['dateformat']['mysql']['compact']."') as humandate FROM `eventlog` AS E, devices_perms AS P WHERE E.host = + P.device_id AND P.user_id = " . $_SESSION['user_id'] . " ORDER BY `datetime` DESC LIMIT 0,15"; + } - if ($_SESSION['userlevel'] == '10') - { - $query = "SELECT *,DATE_FORMAT(datetime, '".$config['dateformat']['mysql']['compact']."') as humandate FROM `eventlog` ORDER BY `datetime` DESC LIMIT 0,15"; - } else { - $query = "SELECT *,DATE_FORMAT(datetime, '".$config['dateformat']['mysql']['compact']."') as humandate FROM `eventlog` AS E, devices_perms AS P WHERE E.host = - P.device_id AND P.user_id = " . $_SESSION['user_id'] . " ORDER BY `datetime` DESC LIMIT 0,15"; - } - - $data = mysql_query($query); + $data = mysql_query($query); echo('
    @@ -177,15 +181,13 @@ echo('
    '); - foreach (dbFetchRows($query) as $entry) - { - include("includes/print-event.inc.php"); - } + foreach (dbFetchRows($query) as $entry) { + include 'includes/print-event.inc.php'; + } - echo("
    "); - echo("
    "); - echo("
    "); - echo(""); - echo(""); + echo(""); + echo(""); + echo(""); + echo(""); + echo(""); } -?> diff --git a/html/pages/front/jt.php b/html/pages/front/jt.php index 2256cf0856..cda0b49bb7 100644 --- a/html/pages/front/jt.php +++ b/html/pages/front/jt.php @@ -5,238 +5,209 @@ $nodes = array(); -$uptimesql = ""; -if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== FALSE && $config['uptime_warning'] > 0) -{ - $uptimesql = " AND A.attrib_value < '" . $config['uptime_warning'] . "'"; +$uptimesql = ''; +if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== false && $config['uptime_warning'] > 0) { + $uptimesql = " AND A.attrib_value < '".$config['uptime_warning']."'"; } -$sql = "SELECT * FROM `devices` AS D, `devices_attribs` AS A WHERE D.status = '1' AND A.device_id = D.device_id AND A.attrib_type = 'uptime' AND A.attrib_value > '0' " . $uptimesql; +$sql = "SELECT * FROM `devices` AS D, `devices_attribs` AS A WHERE D.status = '1' AND A.device_id = D.device_id AND A.attrib_type = 'uptime' AND A.attrib_value > '0' ".$uptimesql; -foreach (dbFetchRows($sql) as $device) -{ - unset($already); - $i = 0; - while ($i <= count($nodes)) { - $thisnode = $device['device_id']; - if ($nodes[$i] == $thisnode) { - $already = "yes"; +foreach (dbFetchRows($sql) as $device) { + unset($already); + $i = 0; + while ($i <= count($nodes)) { + $thisnode = $device['device_id']; + if ($nodes[$i] == $thisnode) { + $already = 'yes'; + } + + $i++; + } + + if (!$already) { + $nodes[] = $device['device_id']; } - $i++; - } - if (!$already) { $nodes[] = $device['device_id']; } } $sql = "SELECT * FROM `devices` WHERE `status` = '0' AND `ignore` = '0'"; -foreach (dbFetchRows($sql) as $device) -{ - if (device_permitted($device['device_id'])) { - echo("
    - ".generate_device_link($device, shorthost($device['hostname']))."
    - Device Down
    - ".truncate($device['location'], 35)." -
    "); - } +foreach (dbFetchRows($sql) as $device) { + if (device_permitted($device['device_id'])) { + echo "
    + ".generate_device_link($device, shorthost($device['hostname']))."
    + Device Down
    + ".truncate($device['location'], 35).' +
    '; + } } if ($config['warn']['ifdown']) { - -$sql = "SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0'"; -foreach (dbFetchRows($sql) as $interface) -{ - if (port_permitted($interface['port_id'])) { - echo("
    - ".generate_device_link($interface, shorthost($interface['hostname']))."
    - Port Down
    - ".generate_port_link($interface, makeshortif($interface['ifDescr']))."
    - ".truncate($interface['ifAlias'], 15)." -
    "); - } -} - + $sql = "SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0'"; + foreach (dbFetchRows($sql) as $interface) { + if (port_permitted($interface['port_id'])) { + echo "
    + ".generate_device_link($interface, shorthost($interface['hostname']))."
    + Port Down
    + ".generate_port_link($interface, makeshortif($interface['ifDescr'])).'
    + '.truncate($interface['ifAlias'], 15).' +
    '; + } + } } $sql = "SELECT * FROM `services` AS S, `devices` AS D WHERE S.device_id = D.device_id AND service_status = 'down' AND D.ignore = '0' AND S.service_ignore = '0'"; -foreach (dbFetchRows($sql) as $service) -{ - if (device_permitted($service['device_id'])) { - echo("
    - ".generate_device_link($service, shorthost($service['hostname']))."
    - Service Down
    - ".$service['service_type']."
    - ".truncate($interface['ifAlias'], 15)." -
    "); - } +foreach (dbFetchRows($sql) as $service) { + if (device_permitted($service['device_id'])) { + echo "
    + ".generate_device_link($service, shorthost($service['hostname']))."
    + Service Down
    + ".$service['service_type'].'
    + '.truncate($interface['ifAlias'], 15).' +
    '; + } } $sql = "SELECT * FROM `devices` AS D, bgpPeers AS B WHERE bgpPeerAdminStatus = 'start' AND bgpPeerState != 'established' AND B.device_id = D.device_id"; -foreach (dbFetchRows($sql) as $peer) -{ - if (device_permitted($peer['device_id'])) { - echo("
    - ".generate_device_link($peer, shorthost($peer['hostname']))."
    - BGP Down
    - ".$peer['bgpPeerIdentifier']."
    - AS".$peer['bgpPeerRemoteAs']." ".truncate($peer['astext'], 10)." -
    "); - } +foreach (dbFetchRows($sql) as $peer) { + if (device_permitted($peer['device_id'])) { + echo "
    + ".generate_device_link($peer, shorthost($peer['hostname']))."
    + BGP Down
    + ".$peer['bgpPeerIdentifier'].'
    + AS'.$peer['bgpPeerRemoteAs'].' '.truncate($peer['astext'], 10).' +
    '; + } } -if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== FALSE && $config['uptime_warning'] > 0) -{ - $sql = "SELECT * FROM devices_attribs AS A, `devices` AS D WHERE A.attrib_value < '" . $config['uptime_warning'] . "' AND A.attrib_type = 'uptime' AND A.device_id = D.device_id AND ignore = '0' AND disabled = '0'"; - foreach (dbFetchRows($sql) as $device) { - if (device_permitted($device['device_id']) && $device['attrib_value'] < $config['uptime_warning'] && $device['attrib_type'] == "uptime") { - echo("
    - ".generate_device_link($device, shorthost($device['hostname']))."
    - Device
    Rebooted

    - ".formatUptime($device['attrib_value'])." -
    "); - } - } +if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== false && $config['uptime_warning'] > 0) { + $sql = "SELECT * FROM devices_attribs AS A, `devices` AS D WHERE A.attrib_value < '".$config['uptime_warning']."' AND A.attrib_type = 'uptime' AND A.device_id = D.device_id AND ignore = '0' AND disabled = '0'"; + foreach (dbFetchRows($sql) as $device) { + if (device_permitted($device['device_id']) && $device['attrib_value'] < $config['uptime_warning'] && $device['attrib_type'] == 'uptime') { + echo "
    + ".generate_device_link($device, shorthost($device['hostname']))."
    + Device
    Rebooted

    + ".formatUptime($device['attrib_value']).' +
    '; + } + } } -echo(" +echo " -
    $errorboxes
    +
    $errorboxes
    -

    Recent Syslog Messages

    +

    Recent Syslog Messages

    -"); + "; $sql = "SELECT *, DATE_FORMAT(timestamp, '".$config['dateformat']['mysql']['compact']."') AS date from syslog,devices WHERE syslog.device_id = devices.device_id ORDER BY seq DESC LIMIT 20"; -echo(""); -foreach (dbFetchRows($sql) as $entry) -{ - include("includes/print-syslog.inc.php"); +echo '
    '; +foreach (dbFetchRows($sql) as $entry) { + include 'includes/print-syslog.inc.php'; } -echo("
    "); -echo("
    +echo ''; - - "); +echo '
    + + + '; // this stuff can be customised to show whatever you want.... +if ($_SESSION['userlevel'] >= '5') { + $sql = "SELECT * FROM ports AS I, devices AS D WHERE `ifAlias` like 'Transit: %' AND I.device_id = D.device_id ORDER BY I.ifAlias"; + unset($seperator); + foreach (dbFetchRows($sql) as $interface) { + $ports['transit'] .= $seperator.$interface['port_id']; + $seperator = ','; + } -if ($_SESSION['userlevel'] >= '5') -{ + $sql = "SELECT * FROM ports AS I, devices AS D WHERE `ifAlias` like 'Peering: %' AND I.device_id = D.device_id ORDER BY I.ifAlias"; + unset($seperator); + foreach (dbFetchRows($sql) as $interface) { + $ports['peering'] .= $seperator.$interface['port_id']; + $seperator = ','; + } - $sql = "SELECT * FROM ports AS I, devices AS D WHERE `ifAlias` like 'Transit: %' AND I.device_id = D.device_id ORDER BY I.ifAlias"; - unset ($seperator); - foreach (dbFetchRows($sql) as $interface) - { - $ports['transit'] .= $seperator . $interface['port_id']; - $seperator = ","; - } + $ports['broadband'] = '3294,3295,688,3534'; + $ports['wave_broadband'] = '827'; - $sql = "SELECT * FROM ports AS I, devices AS D WHERE `ifAlias` like 'Peering: %' AND I.device_id = D.device_id ORDER BY I.ifAlias"; - unset ($seperator); - foreach (dbFetchRows($sql) as $interface) - { - $ports['peering'] .= $seperator . $interface['port_id']; - $seperator = ","; - } + $ports['new_broadband'] = '3659,4149,4121,4108,3676,4135'; - $ports['broadband'] = "3294,3295,688,3534"; - $ports['wave_broadband'] = "827"; + echo "
    "; - $ports['new_broadband'] = "3659,4149,4121,4108,3676,4135"; + if ($ports['peering'] && $ports['transit']) { + echo ""; + } - echo("
    "); + echo '
    '; - if ($ports['peering'] && $ports['transit']) { - echo(""); - } + echo "
    "; - echo("
    "); + if ($ports['transit']) { + echo ""; + } - echo("'; - if ($ports['peering']) { - echo(""); - } + echo "
    "; - echo("
    "); + if ($ports['broadband'] && $ports['wave_broadband'] && $ports['new_broadband']) { + echo ""; + } - echo("
    "); + echo "
    "; - if ($ports['broadband'] && $ports['wave_broadband'] && $ports['new_broadband']) { - echo(""); - } + if ($ports['broadband']) { + echo ""; + } - echo("
    "); + echo "
    "; - if ($ports['broadband']) { - echo(""); - } + if ($ports['new_broadband']) { + echo ""; + } - echo("
    "); + echo '
    '; - if ($ports['new_broadband']) { - echo(""); - } + if ($ports['wave_broadband']) { + echo ""; + } - echo("
    "); - - if ($ports['wave_broadband']) { - echo(""); - } - - echo("
    "); - -} + echo '
    '; +}//end if ?> diff --git a/html/pages/front/traffic.php b/html/pages/front/traffic.php index 5f9a8acced..6b501cf9c1 100644 --- a/html/pages/front/traffic.php +++ b/html/pages/front/traffic.php @@ -3,200 +3,172 @@ 0) -{ - $uptimesql = " AND A.attrib_value < ?"; - $param = array($config['uptime_warning']); +$nodes = array(); +$param = array(); +$uptimesql = ''; +if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== false && $config['uptime_warning'] > 0) { + $uptimesql = ' AND A.attrib_value < ?'; + $param = array($config['uptime_warning']); } -foreach (dbFetchRows("SELECT * FROM `devices` AS D, `devices_attribs` AS A WHERE D.status = '1' AND A.device_id = D.device_id AND A.attrib_type = 'uptime' AND A.attrib_value > '0' " . $uptimesql, $param) as $device) -{ - unset($already); - $i = 0; - while ($i <= count($nodes)) { - $thisnode = $device['device_id']; - if ($nodes[$i] == $thisnode) { - $already = "yes"; +foreach (dbFetchRows("SELECT * FROM `devices` AS D, `devices_attribs` AS A WHERE D.status = '1' AND A.device_id = D.device_id AND A.attrib_type = 'uptime' AND A.attrib_value > '0' ".$uptimesql, $param) as $device) { + unset($already); + $i = 0; + while ($i <= count($nodes)) { + $thisnode = $device['device_id']; + if ($nodes[$i] == $thisnode) { + $already = 'yes'; + } + + $i++; + } + + if (!$already) { + $nodes[] = $device['device_id']; } - $i++; - } - if (!$already) { $nodes[] = $device['device_id']; } } -foreach (dbFetchRows("SELECT * FROM `devices` WHERE `status` = '0' AND `ignore` = '0'") as $device) -{ - if (device_permitted($device['device_id'])) { - echo("
    - ".generate_device_link($device, shorthost($device['hostname']))."
    - Device Down
    - ".truncate($device['location'], 35)." -
    "); - } +foreach (dbFetchRows("SELECT * FROM `devices` WHERE `status` = '0' AND `ignore` = '0'") as $device) { + if (device_permitted($device['device_id'])) { + echo "
    + ".generate_device_link($device, shorthost($device['hostname']))."
    + Device Down
    + ".truncate($device['location'], 35).' +
    '; + } } if ($config['warn']['ifdown']) { - -foreach (dbFetchRows("SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0'") as $interface) -{ - if (port_permitted($interface['port_id'])) { - echo("
    - ".generate_device_link($interface, shorthost($interface['hostname']))."
    - Port Down
    - ".generate_port_link($interface, makeshortif($interface['ifDescr']))."
    - ".truncate($interface['ifAlias'], 15)." -
    "); - } + foreach (dbFetchRows("SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0'") as $interface) { + if (port_permitted($interface['port_id'])) { + echo "
    + ".generate_device_link($interface, shorthost($interface['hostname']))."
    + Port Down
    + ".generate_port_link($interface, makeshortif($interface['ifDescr'])).'
    + '.truncate($interface['ifAlias'], 15).' +
    '; + } + } } +foreach (dbFetchRows("SELECT * FROM `services` AS S, `devices` AS D WHERE S.device_id = D.device_id AND service_status = 'down' AND D.ignore = '0' AND S.service_ignore = '0'") as $service) { + if (device_permitted($service['device_id'])) { + echo "
    + ".generate_device_link($service, shorthost($service['hostname']))."
    + Service Down
    + ".$service['service_type'].'
    + '.truncate($interface['ifAlias'], 15).' +
    '; + } } -foreach (dbFetchRows("SELECT * FROM `services` AS S, `devices` AS D WHERE S.device_id = D.device_id AND service_status = 'down' AND D.ignore = '0' AND S.service_ignore = '0'") as $service) -{ - if (device_permitted($service['device_id'])) { - echo("
    - ".generate_device_link($service, shorthost($service['hostname']))."
    - Service Down
    - ".$service['service_type']."
    - ".truncate($interface['ifAlias'], 15)." -
    "); - } +foreach (dbFetchRows("SELECT * FROM `devices` AS D, bgpPeers AS B WHERE bgpPeerAdminStatus = 'start' AND bgpPeerState != 'established' AND B.device_id = D.device_id") as $peer) { + if (device_permitted($peer['device_id'])) { + echo "
    + ".generate_device_link($peer, shorthost($peer['hostname']))."
    + BGP Down
    + ".$peer['bgpPeerIdentifier'].'
    + AS'.$peer['bgpPeerRemoteAs'].' '.truncate($peer['astext'], 10).' +
    '; + } } -foreach (dbFetchRows("SELECT * FROM `devices` AS D, bgpPeers AS B WHERE bgpPeerAdminStatus = 'start' AND bgpPeerState != 'established' AND B.device_id = D.device_id") as $peer) -{ - if (device_permitted($peer['device_id'])) { - echo("
    - ".generate_device_link($peer, shorthost($peer['hostname']))."
    - BGP Down
    - ".$peer['bgpPeerIdentifier']."
    - AS".$peer['bgpPeerRemoteAs']." ".truncate($peer['astext'], 10)." -
    "); - } +if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== false && $config['uptime_warning'] > 0) { + foreach (dbFetchRows("SELECT * FROM devices_attribs AS A, `devices` AS D WHERE A.attrib_value < ? AND A.attrib_type = 'uptime' AND A.device_id = D.device_id AND ignore = '0' AND disabled = '0'", array($config['uptime_warning'])) as $device) { + if (device_permitted($device['device_id']) && $device['attrib_value'] < $config['uptime_warning'] && $device['attrib_type'] == 'uptime') { + echo "
    + ".generate_device_link($device, shorthost($device['hostname']))."
    + Device
    Rebooted

    + ".formatUptime($device['attrib_value']).' +
    '; + } + } } -if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== FALSE && $config['uptime_warning'] > 0) -{ - foreach (dbFetchRows("SELECT * FROM devices_attribs AS A, `devices` AS D WHERE A.attrib_value < ? AND A.attrib_type = 'uptime' AND A.device_id = D.device_id AND ignore = '0' AND disabled = '0'", array($config['uptime_warning'])) as $device) { - if (device_permitted($device['device_id']) && $device['attrib_value'] < $config['uptime_warning'] && $device['attrib_type'] == "uptime") { - echo("
    - ".generate_device_link($device, shorthost($device['hostname']))."
    - Device
    Rebooted

    - ".formatUptime($device['attrib_value'])." -
    "); - } - } -} +echo " -echo(" +
    $errorboxes
    -
    $errorboxes
    +

    Recent Syslog Messages

    -

    Recent Syslog Messages

    - -"); + "; $sql = "SELECT *, DATE_FORMAT(timestamp, '".$config['dateformat']['mysql']['compact']."') AS date from syslog,devices WHERE syslog.device_id = devices.device_id ORDER BY seq DESC LIMIT 20"; -echo(""); -foreach (dbFetchRows($sql) as $entry) -{ - include("includes/print-syslog.inc.php"); +echo '
    '; +foreach (dbFetchRows($sql) as $entry) { + include 'includes/print-syslog.inc.php'; } -echo("
    "); -echo("
    +echo ''; - - "); +echo '
    + + + '; // this stuff can be customised to show whatever you want.... +if ($_SESSION['userlevel'] >= '5') { + $sql = "SELECT * FROM ports AS I, devices AS D WHERE `ifAlias` like 'Transit: %' AND I.device_id = D.device_id ORDER BY I.ifAlias"; + unset($seperator); + foreach (dbFetchRows($sql) as $interface) { + $ports['transit'] .= $seperator.$interface['port_id']; + $seperator = ','; + } -if ($_SESSION['userlevel'] >= '5') -{ + $sql = "SELECT * FROM ports AS I, devices AS D WHERE `ifAlias` like 'Peering: %' AND I.device_id = D.device_id ORDER BY I.ifAlias"; + unset($seperator); + foreach (dbFetchRows($sql) as $interface) { + $ports['peering'] .= $seperator.$interface['port_id']; + $seperator = ','; + } - $sql = "SELECT * FROM ports AS I, devices AS D WHERE `ifAlias` like 'Transit: %' AND I.device_id = D.device_id ORDER BY I.ifAlias"; - unset ($seperator); - foreach (dbFetchRows($sql) as $interface) - { - $ports['transit'] .= $seperator . $interface['port_id']; - $seperator = ","; - } + $sql = "SELECT * FROM ports AS I, devices AS D WHERE `ifAlias` like 'Core: %' AND I.device_id = D.device_id ORDER BY I.ifAlias"; + unset($seperator); + foreach (dbFetchRows($sql) as $interface) { + $ports['core'] .= $seperator.$interface['port_id']; + $seperator = ','; + } - $sql = "SELECT * FROM ports AS I, devices AS D WHERE `ifAlias` like 'Peering: %' AND I.device_id = D.device_id ORDER BY I.ifAlias"; - unset ($seperator); - foreach (dbFetchRows($sql) as $interface) - { - $ports['peering'] .= $seperator . $interface['port_id']; - $seperator = ","; - } + echo "
    "; - $sql = "SELECT * FROM ports AS I, devices AS D WHERE `ifAlias` like 'Core: %' AND I.device_id = D.device_id ORDER BY I.ifAlias"; - unset ($seperator); - foreach (dbFetchRows($sql) as $interface) - { - $ports['core'] .= $seperator . $interface['port_id']; - $seperator = ","; - } + if ($ports['peering'] && $ports['transit']) { + echo ""; + } - echo("
    "); + echo '
    '; - if ($ports['peering'] && $ports['transit']) - { - echo(""); - } + echo "
    "; - echo("
    "); + if ($ports['transit']) { + echo ""; + } - echo("
    "); + if ($ports['peering']) { + echo ""; + } - if ($ports['transit']) - { - echo(""); - } + if ($ports['core']) { + echo ""; + } - if ($ports['peering']) - { - echo(""); - } - - if ($ports['core']) - { - echo(""); - } - - echo("
    "); - -} + echo '
    '; +}//end if ?> diff --git a/html/pages/graphs.inc.php b/html/pages/graphs.inc.php index 0cc268fceb..78c6a73e09 100644 --- a/html/pages/graphs.inc.php +++ b/html/pages/graphs.inc.php @@ -4,17 +4,21 @@ unset($vars['page']); // Setup here -if($_SESSION['widescreen']) -{ - $graph_width=1700; - $thumb_width=180; -} else { - $graph_width=1075; - $thumb_width=113; +if($_SESSION['widescreen']) { + $graph_width=1700; + $thumb_width=180; +} +else { + $graph_width=1075; + $thumb_width=113; } -if (!is_numeric($vars['from'])) { $vars['from'] = $config['time']['day']; } -if (!is_numeric($vars['to'])) { $vars['to'] = $config['time']['now']; } +if (!is_numeric($vars['from'])) { + $vars['from'] = $config['time']['day']; +} +if (!is_numeric($vars['to'])) { + $vars['to'] = $config['time']['now']; +} preg_match('/^(?P[A-Za-z0-9]+)_(?P.+)/', $vars['type'], $graphtype); @@ -22,208 +26,201 @@ $type = $graphtype['type']; $subtype = $graphtype['subtype']; $id = $vars['id']; -if(is_numeric($vars['device'])) -{ - $device = device_by_id_cache($vars['device']); -} elseif(!empty($vars['device'])) { - $device = device_by_name($vars['device']); +if(is_numeric($vars['device'])) { + $device = device_by_id_cache($vars['device']); +} +elseif(!empty($vars['device'])) { + $device = device_by_name($vars['device']); } -if (is_file("includes/graphs/".$type."/auth.inc.php")) -{ - include("includes/graphs/".$type."/auth.inc.php"); +if (is_file("includes/graphs/".$type."/auth.inc.php")) { + require "includes/graphs/".$type."/auth.inc.php"; } -if (!$auth) -{ - include("includes/error-no-perm.inc.php"); -} else { - if (isset($config['graph_types'][$type][$subtype]['descr'])) - { - $title .= " :: ".$config['graph_types'][$type][$subtype]['descr']; - } else { - $title .= " :: ".ucfirst($subtype); - } +if (!$auth) { + require 'includes/error-no-perm.inc.php'; +} +else { + if (isset($config['graph_types'][$type][$subtype]['descr'])) { + $title .= " :: ".$config['graph_types'][$type][$subtype]['descr']; + } + else { + $title .= " :: ".ucfirst($subtype); + } - $graph_array = $vars; - $graph_array['height'] = "60"; - $graph_array['width'] = $thumb_width; - $graph_array['legend'] = "no"; - $graph_array['to'] = $config['time']['now']; + $graph_array = $vars; + $graph_array['height'] = "60"; + $graph_array['width'] = $thumb_width; + $graph_array['legend'] = "no"; + $graph_array['to'] = $config['time']['now']; - print_optionbar_start(); - echo($title); + print_optionbar_start(); + echo($title); - echo('
    '); - ?> + echo('
    '); +?>
    - '); +'); - print_optionbar_end(); + print_optionbar_end(); - print_optionbar_start(); + print_optionbar_start(); - $thumb_array = array('sixhour' => '6 Hours', 'day' => '24 Hours', 'twoday' => '48 Hours', 'week' => 'One Week', 'twoweek' => 'Two Weeks', - 'month' => 'One Month', 'twomonth' => 'Two Months','year' => 'One Year', 'twoyear' => 'Two Years'); + $thumb_array = array('sixhour' => '6 Hours', 'day' => '24 Hours', 'twoday' => '48 Hours', 'week' => 'One Week', 'twoweek' => 'Two Weeks', + 'month' => 'One Month', 'twomonth' => 'Two Months','year' => 'One Year', 'twoyear' => 'Two Years'); - echo(''); + echo('
    '); - foreach ($thumb_array as $period => $text) - { - $graph_array['from'] = $config['time'][$period]; + foreach ($thumb_array as $period => $text) { + $graph_array['from'] = $config['time'][$period]; - $link_array = $vars; - $link_array['from'] = $graph_array['from']; - $link_array['to'] = $graph_array['to']; - $link_array['page'] = "graphs"; - $link = generate_url($link_array); + $link_array = $vars; + $link_array['from'] = $graph_array['from']; + $link_array['to'] = $graph_array['to']; + $link_array['page'] = "graphs"; + $link = generate_url($link_array); - echo(''); + echo(''); - } + } - echo('
    '); - echo(''.$text.'
    '); - echo(''); - echo(generate_graph_tag($graph_array)); - echo(''); - echo('
    '); + echo(''.$text.'
    '); + echo(''); + echo(generate_graph_tag($graph_array)); + echo(''); + echo('
    '); + echo(''); - $graph_array = $vars; - $graph_array['height'] = "300"; - $graph_array['width'] = $graph_width; + $graph_array = $vars; + $graph_array['height'] = "300"; + $graph_array['width'] = $graph_width; - echo("
    "); + echo("
    "); - // datetime range picker + // datetime range picker ?> - "); - echo(' + echo(" +
    + "); + echo('
    - - + +
    - - + +
    -
    - '); - echo("
    "); + echo("
    "); - if ($vars['legend'] == "no") - { - echo(generate_link("Show Legend",$vars, array('page' => "graphs", 'legend' => NULL))); - } else { - echo(generate_link("Hide Legend",$vars, array('page' => "graphs", 'legend' => "no"))); - } - - // FIXME : do this properly -# if ($type == "port" && $subtype == "bits") -# { - echo(' | '); - if ($vars['previous'] == "yes") - { - echo(generate_link("Hide Previous",$vars, array('page' => "graphs", 'previous' => NULL))); - } else { - echo(generate_link("Show Previous",$vars, array('page' => "graphs", 'previous' => "yes"))); + if ($vars['legend'] == "no") { + echo(generate_link("Show Legend",$vars, array('page' => "graphs", 'legend' => NULL))); + } + else { + echo(generate_link("Hide Legend",$vars, array('page' => "graphs", 'legend' => "no"))); } -# } - echo('
    '); + // FIXME : do this properly + # if ($type == "port" && $subtype == "bits") + # { + echo(' | '); + if ($vars['previous'] == "yes") { + echo(generate_link("Hide Previous",$vars, array('page' => "graphs", 'previous' => NULL))); + } + else { + echo(generate_link("Show Previous",$vars, array('page' => "graphs", 'previous' => "yes"))); + } + # } - if ($vars['showcommand'] == "yes") - { - echo(generate_link("Hide RRD Command",$vars, array('page' => "graphs", 'showcommand' => NULL))); - } else { - echo(generate_link("Show RRD Command",$vars, array('page' => "graphs", 'showcommand' => "yes"))); - } + echo('
    '); - echo('
    '); + if ($vars['showcommand'] == "yes") { + echo(generate_link("Hide RRD Command",$vars, array('page' => "graphs", 'showcommand' => NULL))); + } + else { + echo(generate_link("Show RRD Command",$vars, array('page' => "graphs", 'showcommand' => "yes"))); + } - print_optionbar_end(); + echo('
    '); - echo generate_graph_js_state($graph_array); - - echo('
    '); - echo(generate_graph_tag($graph_array)); - echo("
    "); - - if (isset($config['graph_descr'][$vars['type']])) - { - - print_optionbar_start(); - echo('
    -
    - -
    -
    '); - echo($config['graph_descr'][$vars['type']]); print_optionbar_end(); - } - if ($vars['showcommand']) - { - $_GET = $graph_array; - $command_only = 1; + echo generate_graph_js_state($graph_array); - include("includes/graphs/graph.inc.php"); - } + echo('
    '); + echo(generate_graph_tag($graph_array)); + echo("
    "); + + if (isset($config['graph_descr'][$vars['type']])) { + + print_optionbar_start(); + echo('
    +
    + +
    +
    '); + echo($config['graph_descr'][$vars['type']]); + print_optionbar_end(); + } + + if ($vars['showcommand']) { + $_GET = $graph_array; + $command_only = 1; + + require 'includes/graphs/graph.inc.php'; + } } - -?> diff --git a/html/pages/health.inc.php b/html/pages/health.inc.php index 3b06d4db6b..eb13def9b7 100644 --- a/html/pages/health.inc.php +++ b/html/pages/health.inc.php @@ -30,8 +30,12 @@ $type_text['toner'] = "Toner"; $type_text['dbm'] = "dBm"; $type_text['load'] = "Load"; -if (!$vars['metric']) { $vars['metric'] = "processor"; } -if (!$vars['view']) { $vars['view'] = "detail"; } +if (!$vars['metric']) { + $vars['metric'] = "processor"; +} +if (!$vars['view']) { + $vars['view'] = "detail"; +} $link_array = array('page' => 'health'); @@ -42,48 +46,44 @@ print_optionbar_start('', ''); echo('Health » '); $sep = ""; -foreach ($datas as $texttype) -{ - $metric = strtolower($texttype); - echo($sep); - if ($vars['metric'] == $metric) - { - echo(""); - } +foreach ($datas as $texttype) { + $metric = strtolower($texttype); + echo($sep); + if ($vars['metric'] == $metric) { + echo(""); + } - echo(generate_link($type_text[$metric],$link_array,array('metric'=> $metric, 'view' => $vars['view']))); + echo(generate_link($type_text[$metric],$link_array,array('metric'=> $metric, 'view' => $vars['view']))); - if ($vars['metric'] == $metric) { echo(""); } + if ($vars['metric'] == $metric) { + echo(""); + } - $sep = ' | '; + $sep = ' | '; } unset ($sep); echo('
    '); -if ($vars['view'] == "graphs") -{ - echo(''); +if ($vars['view'] == "graphs") { + echo(''); } echo(generate_link("Graphs",$link_array,array('metric'=> $vars['metric'], 'view' => "graphs"))); -if ($vars['view'] == "graphs") -{ - echo(''); +if ($vars['view'] == "graphs") { + echo(''); } echo(' | '); -if ($vars['view'] != "graphs") -{ - echo(''); +if ($vars['view'] != "graphs") { + echo(''); } echo(generate_link("No Graphs",$link_array,array('metric'=> $vars['metric'], 'view' => "detail"))); -if ($vars['view'] != "graphs") -{ - echo(''); +if ($vars['view'] != "graphs") { + echo(''); } echo('
    '); @@ -91,16 +91,14 @@ echo('
    '); print_optionbar_end(); if (in_array($vars['metric'],array_keys($used_sensors)) - || $vars['metric'] == 'processor' - || $vars['metric'] == 'storage' - || $vars['metric'] == 'toner' - || $vars['metric'] == 'mempool') -{ - include('pages/health/'.$vars['metric'].'.inc.php'); + || $vars['metric'] == 'processor' + || $vars['metric'] == 'storage' + || $vars['metric'] == 'toner' + || $vars['metric'] == 'mempool') { + include('pages/health/'.$vars['metric'].'.inc.php'); } -else -{ - echo("No sensors of type " . $vars['metric'] . " found."); +else { + echo("No sensors of type " . $vars['metric'] . " found."); } ?> diff --git a/html/pages/health/charge.inc.php b/html/pages/health/charge.inc.php index 867b50f9e8..3838d0e790 100644 --- a/html/pages/health/charge.inc.php +++ b/html/pages/health/charge.inc.php @@ -4,6 +4,4 @@ $graph_type = "sensor_charge"; $unit = "%"; $class = "charge"; -include("pages/health/sensors.inc.php"); - -?> +require 'pages/health/sensors.inc.php'; diff --git a/html/pages/health/load.inc.php b/html/pages/health/load.inc.php index d9257519d3..f506e3ca1d 100644 --- a/html/pages/health/load.inc.php +++ b/html/pages/health/load.inc.php @@ -1,9 +1,7 @@ +require 'pages/health/sensors.inc.php'; diff --git a/html/pages/health/sensors.inc.php b/html/pages/health/sensors.inc.php index 02224d485c..52828b9c19 100644 --- a/html/pages/health/sensors.inc.php +++ b/html/pages/health/sensors.inc.php @@ -1,19 +1,18 @@ = '5') -{ - $sql = "SELECT * FROM `sensors` AS S, `devices` AS D WHERE S.sensor_class='".$class."' AND S.device_id = D.device_id ORDER BY D.hostname, S.sensor_descr"; - $param = array(); -} else { - $sql = "SELECT * FROM `sensors` AS S, `devices` AS D, devices_perms as P WHERE S.sensor_class='".$class."' AND S.device_id = D.device_id AND D.device_id = P.device_id AND P.user_id = ? ORDER BY D.hostname, S.sensor_descr"; - $param = array($_SESSION['user_id']); +if ($_SESSION['userlevel'] >= '5') { + $sql = "SELECT * FROM `sensors` AS S, `devices` AS D WHERE S.sensor_class='".$class."' AND S.device_id = D.device_id ORDER BY D.hostname, S.sensor_descr"; + $param = array(); +} +else { + $sql = "SELECT * FROM `sensors` AS S, `devices` AS D, devices_perms as P WHERE S.sensor_class='".$class."' AND S.device_id = D.device_id AND D.device_id = P.device_id AND P.user_id = ? ORDER BY D.hostname, S.sensor_descr"; + $param = array($_SESSION['user_id']); } -echo(''); +echo '
    '; -echo(' +echo ' @@ -21,99 +20,102 @@ echo(' - '); + '; -foreach (dbFetchRows($sql, $param) as $sensor) -{ +foreach (dbFetchRows($sql, $param) as $sensor) { + if ($config['memcached']['enable'] === true) { + $sensor['sensor_current'] = $memcache->get('sensor-'.$sensor['sensor_id'].'-value'); + if ($debug) { + echo 'Memcached['.'sensor-'.$sensor['sensor_id'].'-value'.'='.$sensor['sensor_current'].']'; + } + } - if ($config['memcached']['enable'] === TRUE) - { - $sensor['sensor_current'] = $memcache->get('sensor-'.$sensor['sensor_id'].'-value'); - if($debug) { echo("Memcached[".'sensor-'.$sensor['sensor_id'].'-value'."=".$sensor['sensor_current']."]"); } - } - - if (empty($sensor['sensor_current'])) - { - $sensor['sensor_current'] = "NaN"; - } else { - if ($sensor['sensor_current'] >= $sensor['sensor_limit']) { $alert = 'alert'; } else { $alert = ""; } - } + if (empty($sensor['sensor_current'])) { + $sensor['sensor_current'] = 'NaN'; + } + else { + if ($sensor['sensor_current'] >= $sensor['sensor_limit']) { + $alert = 'alert'; + } + else { + $alert = ''; + } + } // FIXME - make this "four graphs in popup" a function/include and "small graph" a function. // FIXME - So now we need to clean this up and move it into a function. Isn't it just "print-graphrow"? // FIXME - DUPLICATED IN device/overview/sensors - - $graph_colour = str_replace("#", "", $row_colour); + $graph_colour = str_replace('#', '', $row_colour); $graph_array = array(); - $graph_array['height'] = "100"; - $graph_array['width'] = "210"; + $graph_array['height'] = '100'; + $graph_array['width'] = '210'; $graph_array['to'] = $config['time']['now']; $graph_array['id'] = $sensor['sensor_id']; $graph_array['type'] = $graph_type; $graph_array['from'] = $config['time']['day']; - $graph_array['legend'] = "no"; + $graph_array['legend'] = 'no'; - $link_array = $graph_array; - $link_array['page'] = "graphs"; + $link_array = $graph_array; + $link_array['page'] = 'graphs'; unset($link_array['height'], $link_array['width'], $link_array['legend']); $link_graph = generate_url($link_array); - $link = generate_url(array("page" => "device", "device" => $sensor['device_id'], "tab" => "health", "metric" => $sensor['sensor_class'])); + $link = generate_url(array('page' => 'device', 'device' => $sensor['device_id'], 'tab' => 'health', 'metric' => $sensor['sensor_class'])); - $overlib_content = '

    '.$device['hostname']." - ".$sensor['sensor_descr']."

    "; - foreach (array('day','week','month','year') as $period) - { - $graph_array['from'] = $config['time'][$period]; - $overlib_content .= str_replace('"', "\'", generate_graph_tag($graph_array)); + $overlib_content = '

    '.$device['hostname'].' - '.$sensor['sensor_descr'].'

    '; + foreach (array('day', 'week', 'month', 'year') as $period) { + $graph_array['from'] = $config['time'][$period]; + $overlib_content .= str_replace('"', "\'", generate_graph_tag($graph_array)); } - $overlib_content .= "
    "; - $graph_array['width'] = 80; $graph_array['height'] = 20; $graph_array['bg'] = 'ffffff00'; # the 00 at the end makes the area transparent. + $overlib_content .= '
    '; + + $graph_array['width'] = 80; + $graph_array['height'] = 20; + $graph_array['bg'] = 'ffffff00'; + // the 00 at the end makes the area transparent. $graph_array['from'] = $config['time']['day']; - $sensor_minigraph = generate_graph_tag($graph_array); + $sensor_minigraph = generate_graph_tag($graph_array); $sensor['sensor_descr'] = truncate($sensor['sensor_descr'], 48, ''); - echo(' - - + echo ' + + - - - + + + - '); + '; - if ($vars['view'] == "graphs") - { - echo(""); - } # endif graphs -} + echo "', LEFT);\" onmouseout=\"return nd();\"> + "; + echo "', LEFT);\" onmouseout=\"return nd();\"> + "; + echo "', LEFT);\" onmouseout=\"return nd();\"> + "; + echo "', LEFT);\" onmouseout=\"return nd();\"> + "; + echo ''; + } //end if +}//end foreach -echo("
    Device Sensor
    Current Range limit Notes
    ' . generate_device_link($sensor) . ''.overlib_link($link, $sensor['sensor_descr'],$overlib_content).'
    '.generate_device_link($sensor).''.overlib_link($link, $sensor['sensor_descr'], $overlib_content).' '.overlib_link($link_graph, $sensor_minigraph, $overlib_content).' '.$alert.'' . $sensor['sensor_current'] . $unit . '' . round($sensor['sensor_limit_low'],2) . $unit . ' - ' . round($sensor['sensor_limit'],2) . $unit . '' . (isset($sensor['sensor_notes']) ? $sensor['sensor_notes'] : '') . ''.$sensor['sensor_current'].$unit.''.round($sensor['sensor_limit_low'], 2).$unit.' - '.round($sensor['sensor_limit'], 2).$unit.''.(isset($sensor['sensor_notes']) ? $sensor['sensor_notes'] : '').'
    "); + if ($vars['view'] == 'graphs') { + echo "
    "; - $daily_graph = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=".$config['time']['day']."&to=".$config['time']['now']."&width=211&height=100"; - $daily_url = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=".$config['time']['day']."&to=".$config['time']['now']."&width=400&height=150"; + $daily_graph = 'graph.php?id='.$sensor['sensor_id'].'&type='.$graph_type.'&from='.$config['time']['day'].'&to='.$config['time']['now'].'&width=211&height=100'; + $daily_url = 'graph.php?id='.$sensor['sensor_id'].'&type='.$graph_type.'&from='.$config['time']['day'].'&to='.$config['time']['now'].'&width=400&height=150'; - $weekly_graph = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=".$config['time']['week']."&to=".$config['time']['now']."&width=211&height=100"; - $weekly_url = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=".$config['time']['week']."&to=".$config['time']['now']."&width=400&height=150"; + $weekly_graph = 'graph.php?id='.$sensor['sensor_id'].'&type='.$graph_type.'&from='.$config['time']['week'].'&to='.$config['time']['now'].'&width=211&height=100'; + $weekly_url = 'graph.php?id='.$sensor['sensor_id'].'&type='.$graph_type.'&from='.$config['time']['week'].'&to='.$config['time']['now'].'&width=400&height=150'; - $monthly_graph = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=".$config['time']['month']."&to=".$config['time']['now']."&width=211&height=100"; - $monthly_url = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=".$config['time']['month']."&to=".$config['time']['now']."&width=400&height=150"; + $monthly_graph = 'graph.php?id='.$sensor['sensor_id'].'&type='.$graph_type.'&from='.$config['time']['month'].'&to='.$config['time']['now'].'&width=211&height=100'; + $monthly_url = 'graph.php?id='.$sensor['sensor_id'].'&type='.$graph_type.'&from='.$config['time']['month'].'&to='.$config['time']['now'].'&width=400&height=150'; - $yearly_graph = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=".$config['time']['year']."&to=".$config['time']['now']."&width=211&height=100"; - $yearly_url = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=".$config['time']['year']."&to=".$config['time']['now']."&width=400&height=150"; + $yearly_graph = 'graph.php?id='.$sensor['sensor_id'].'&type='.$graph_type.'&from='.$config['time']['year'].'&to='.$config['time']['now'].'&width=211&height=100'; + $yearly_url = 'graph.php?id='.$sensor['sensor_id'].'&type='.$graph_type.'&from='.$config['time']['year'].'&to='.$config['time']['now'].'&width=400&height=150'; - echo("', LEFT);\" onmouseout=\"return nd();\"> - "); - echo("', LEFT);\" onmouseout=\"return nd();\"> - "); - echo("', LEFT);\" onmouseout=\"return nd();\"> - "); - echo("', LEFT);\" onmouseout=\"return nd();\"> - "); - echo("
    "); - -?> +echo ''; diff --git a/html/pages/iftype.inc.php b/html/pages/iftype.inc.php index f4349111cd..8a6d20201b 100644 --- a/html/pages/iftype.inc.php +++ b/html/pages/iftype.inc.php @@ -9,92 +9,102 @@ - Total Graph for ports of type : ".$types."
    "); - -if ($if_list) -{ - $graph_type = "multiport_bits_separate"; - $port['port_id'] = $if_list; - - include("includes/print-interface-graphs.inc.php"); - - echo(""); - - foreach ($ports as $port) - { - $done = "yes"; - unset($class); - $port['ifAlias'] = str_ireplace($type . ": ", "", $port['ifAlias']); - $port['ifAlias'] = str_ireplace("[PNI]", "Private", $port['ifAlias']); - $ifclass = ifclass($port['ifOperStatus'], $port['ifAdminStatus']); - if ($bg == "#ffffff") { $bg = "#e5e5e5"; } else { $bg = "#ffffff"; } - echo(" - " . generate_port_link($port,$port['port_descr_descr']) . "
    - ".generate_device_link($port)." ".generate_port_link($port)." - ".generate_port_link($port, makeshortif($port['ifDescr']))." - ".$port['port_descr_speed']." - ".$port['port_descr_circuit']." - ".$port['port_descr_notes']." - - - MAC Accounting"); - } - - echo('
    '); - - if (file_exists($config['rrd_dir'] . "/" . $port['hostname'] . "/port-" . $port['ifIndex'] . ".rrd")) - { - $graph_type = "port_bits"; - - include("includes/print-interface-graphs.inc.php"); - } - - echo(""); - } - +$types_array = explode(',', $vars['type']); +for ($i = 0; $i < count($types_array); +$i++) { + $types_array[$i] = ucfirst($types_array[$i]); } -else -{ - echo("None found."); + +$types = implode(' + ', $types_array); + +echo " + Total Graph for ports of type : ".$types.'
    '; + +if ($if_list) { + $graph_type = 'multiport_bits_separate'; + $port['port_id'] = $if_list; + + include 'includes/print-interface-graphs.inc.php'; + + echo ''; + + foreach ($ports as $port) { + $done = 'yes'; + unset($class); + $port['ifAlias'] = str_ireplace($type.': ', '', $port['ifAlias']); + $port['ifAlias'] = str_ireplace('[PNI]', 'Private', $port['ifAlias']); + $ifclass = ifclass($port['ifOperStatus'], $port['ifAdminStatus']); + if ($bg == '#ffffff') { + $bg = '#e5e5e5'; + } + else { + $bg = '#ffffff'; + } + + echo " + ".generate_port_link($port, $port['port_descr_descr'])."
    + ".generate_device_link($port).' '.generate_port_link($port).' + '.generate_port_link($port, makeshortif($port['ifDescr'])).' + '.$port['port_descr_speed'].' + '.$port['port_descr_circuit'].' + '.$port['port_descr_notes']." + + + MAC Accounting"; + } + + echo '
    '; + + if (file_exists($config['rrd_dir'].'/'.$port['hostname'].'/port-'.$port['ifIndex'].'.rrd')) { + $graph_type = 'port_bits'; + + include 'includes/print-interface-graphs.inc.php'; + } + + echo ''; + } +} +else { + echo 'None found.'; } ?> diff --git a/html/pages/inventory.inc.php b/html/pages/inventory.inc.php index e53daab965..7fc461e4aa 100644 --- a/html/pages/inventory.inc.php +++ b/html/pages/inventory.inc.php @@ -1,6 +1,6 @@ @@ -29,46 +29,53 @@ var grid = $("#inventory").bootgrid({ header: "
    "+ "
    "+ "
    "+ - "\" placeholder=\"Description\" class=\"form-control input-sm\" />"+ + "\" placeholder=\"Description\" class=\"form-control input-sm\" />"+ "
    "+ "
    "+ " Part No "+ ""+ "
    "+ "
    "+ - "\" placeholder=\"Serial\" class=\"form-control input-sm\"/>"+ + "\" placeholder=\"Serial\" class=\"form-control input-sm\"/>"+ "
    "+ "
    "+ " Device "+ ""+ "
    "+ "
    "+ - "\" placeholder=\"Description\" class=\"form-control input-sm\"/>"+ + " +\" placeholder=\"Description\" class=\"form-control input-sm\"/>"+ "
    "+ ""+ "
    "+ diff --git a/html/pages/locations.inc.php b/html/pages/locations.inc.php index 93dffa0e36..bbe6adcf99 100644 --- a/html/pages/locations.inc.php +++ b/html/pages/locations.inc.php @@ -1,88 +1,92 @@ Locations » '); +echo 'Locations » '; -$menu_options = array('basic' => 'Basic', - 'traffic' => 'Traffic'); +$menu_options = array( + 'basic' => 'Basic', + 'traffic' => 'Traffic', +); -if (!$vars['view']) { $vars['view'] = "basic"; } +if (!$vars['view']) { + $vars['view'] = 'basic'; +} -$sep = ""; -foreach ($menu_options as $option => $text) -{ - echo($sep); - if ($vars['view'] == $option) - { - echo(""); - } - echo('' . $text . ''); - if ($vars['view'] == $option) - { - echo(""); - } - $sep = " | "; +$sep = ''; +foreach ($menu_options as $option => $text) { + echo $sep; + if ($vars['view'] == $option) { + echo ""; + } + + echo ''.$text.''; + if ($vars['view'] == $option) { + echo ''; + } + + $sep = ' | '; } unset($sep); print_optionbar_end(); -echo(''); +echo '
    '; -foreach (getlocations() as $location) -{ - if ($_SESSION['userlevel'] >= '10') - { - $num = dbFetchCell("SELECT COUNT(device_id) FROM devices WHERE location = ?", array($location)); - $net = dbFetchCell("SELECT COUNT(device_id) FROM devices WHERE location = ? AND type = 'network'", array($location)); - $srv = dbFetchCell("SELECT COUNT(device_id) FROM devices WHERE location = ? AND type = 'server'", array($location)); - $fwl = dbFetchCell("SELECT COUNT(device_id) FROM devices WHERE location = ? AND type = 'firewall'", array($location)); - $hostalerts = dbFetchCell("SELECT COUNT(device_id) FROM devices WHERE location = ? AND status = '0'", array($location)); - } else { - $num = dbFetchCell("SELECT COUNT(D.device_id) FROM devices AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = ? AND location = ?", array($_SESSION['user_id'], $location)); - $net = dbFetchCell("SELECT COUNT(D.device_id) FROM devices AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = ? AND location = ? AND D.type = 'network'", array($_SESSION['user_id'], $location)); - $srv = dbFetchCell("SELECT COUNT(D.device_id) FROM devices AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = ? AND location = ? AND type = 'server'", array($_SESSION['user_id'], $location)); - $fwl = dbFetchCell("SELECT COUNT(D.device_id) FROM devices AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = ? AND location = ? AND type = 'firewall'", array($_SESSION['user_id'], $location)); - $hostalerts = dbFetchCell("SELECT COUNT(device_id) FROM devices AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = ? AND location = ? AND status = '0'", array($_SESSION['user_id'], $location)); - } - - if ($hostalerts) { $alert = 'alert'; } else { $alert = ""; } - - if ($location != "") - { - echo(' - - - - - - - - '); - - if ($vars['view'] == "traffic") - { - echo('"); +foreach (getlocations() as $location) { + if ($_SESSION['userlevel'] >= '10') { + $num = dbFetchCell('SELECT COUNT(device_id) FROM devices WHERE location = ?', array($location)); + $net = dbFetchCell("SELECT COUNT(device_id) FROM devices WHERE location = ? AND type = 'network'", array($location)); + $srv = dbFetchCell("SELECT COUNT(device_id) FROM devices WHERE location = ? AND type = 'server'", array($location)); + $fwl = dbFetchCell("SELECT COUNT(device_id) FROM devices WHERE location = ? AND type = 'firewall'", array($location)); + $hostalerts = dbFetchCell("SELECT COUNT(device_id) FROM devices WHERE location = ? AND status = '0'", array($location)); + } + else { + $num = dbFetchCell('SELECT COUNT(D.device_id) FROM devices AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = ? AND location = ?', array($_SESSION['user_id'], $location)); + $net = dbFetchCell("SELECT COUNT(D.device_id) FROM devices AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = ? AND location = ? AND D.type = 'network'", array($_SESSION['user_id'], $location)); + $srv = dbFetchCell("SELECT COUNT(D.device_id) FROM devices AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = ? AND location = ? AND type = 'server'", array($_SESSION['user_id'], $location)); + $fwl = dbFetchCell("SELECT COUNT(D.device_id) FROM devices AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = ? AND location = ? AND type = 'firewall'", array($_SESSION['user_id'], $location)); + $hostalerts = dbFetchCell("SELECT COUNT(device_id) FROM devices AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = ? AND location = ? AND status = '0'", array($_SESSION['user_id'], $location)); } - $done = "yes"; - } -} -echo("
    ' . $location . '' . $alert . '' . $num . ' devices' . $net . ' network' . $srv . ' servers' . $fwl . ' firewalls
    '); - - $graph_array['type'] = "location_bits"; - $graph_array['height'] = "100"; - $graph_array['width'] = "220"; - $graph_array['to'] = $config['time']['now']; - $graph_array['legend'] = "no"; - $graph_array['id'] = $location; - - include("includes/print-graphrow.inc.php"); - - echo("
    "); + if ($hostalerts) { + $alert = 'alert'; + } + else { + $alert = ''; + } -?> + if ($location != '') { + echo ' + '.$location.' + '.$alert.' + '.$num.' devices + '.$net.' network + '.$srv.' servers + '.$fwl.' firewalls + + '; + + if ($vars['view'] == 'traffic') { + echo ''; + + $graph_array['type'] = 'location_bits'; + $graph_array['height'] = '100'; + $graph_array['width'] = '220'; + $graph_array['to'] = $config['time']['now']; + $graph_array['legend'] = 'no'; + $graph_array['id'] = $location; + + include 'includes/print-graphrow.inc.php'; + + echo ''; + } + + $done = 'yes'; + }//end if +}//end foreach + +echo ''; diff --git a/html/pages/logon.inc.php b/html/pages/logon.inc.php index e9819b1b01..a8a156574d 100644 --- a/html/pages/logon.inc.php +++ b/html/pages/logon.inc.php @@ -1,7 +1,8 @@
    @@ -32,14 +33,12 @@ if( $config['twofactor'] && isset($twofactorform) ) {
    'error','message'=>$auth_message,'title'=>'Login error'); } ?>
    diff --git a/html/pages/map.inc.php b/html/pages/map.inc.php index 0fa1cbb5f7..115c0600c3 100644 --- a/html/pages/map.inc.php +++ b/html/pages/map.inc.php @@ -10,6 +10,5 @@ * option) any later version. Please see LICENSE.txt at the top level of * the source code distribution for details. */ -$pagetitle[] = "Map"; -require_once "includes/print-map.inc.php"; -?> +$pagetitle[] = 'Map'; +require_once 'includes/print-map.inc.php'; diff --git a/html/pages/packages.inc.php b/html/pages/packages.inc.php index c3e79c8cf6..ab26fd00a9 100644 --- a/html/pages/packages.inc.php +++ b/html/pages/packages.inc.php @@ -2,8 +2,7 @@ foreach ($vars as $var => $value) { if ($value != '') { - switch ($var) - { + switch ($var) { case 'name': $where .= " AND `$var` = ?"; $param[] = $value; @@ -26,8 +25,7 @@ foreach (dbFetchRows("SELECT * FROM `packages` WHERE 1 $where GROUP BY `name`", foreach ($entry['blah'] as $version => $bleu) { $content = '
    '; - foreach ($bleu as $build => $bloo) - { + foreach ($bleu as $build => $bloo) { if ($build) { $dbuild = '-'.$build; } @@ -36,8 +34,7 @@ foreach (dbFetchRows("SELECT * FROM `packages` WHERE 1 $where GROUP BY `name`", } $content .= '
    '.$version.$dbuild.''; - foreach ($bloo as $device_id => $no) - { + foreach ($bloo as $device_id => $no) { $this_device = device_by_id_cache($device_id); $content .= ''.$this_device['hostname'].' '; } diff --git a/html/pages/plugin.inc.php b/html/pages/plugin.inc.php index daec96f46b..1f718acff2 100644 --- a/html/pages/plugin.inc.php +++ b/html/pages/plugin.inc.php @@ -1,24 +1,18 @@ 'plugin'); +$link_array = array('page' => 'plugin'); -$pagetitle[] = "Plugin"; +$pagetitle[] = 'Plugin'; -if ($vars['view'] == "admin") -{ - include_once('pages/plugin/admin.inc.php'); +if ($vars['view'] == 'admin') { + include_once 'pages/plugin/admin.inc.php'; } -else -{ - $plugin = dbFetchRow("SELECT `plugin_name` FROM `plugins` WHERE `plugin_name` = '".$vars['p']."' AND `plugin_active`='1'"); - if(!empty($plugin)) - { - require('plugins/'.$plugin['plugin_name'].'/'.$plugin['plugin_name'].'.inc.php'); - } - else - { - print_error( "This plugin is either disabled or not available." ); - } +else { + $plugin = dbFetchRow("SELECT `plugin_name` FROM `plugins` WHERE `plugin_name` = '".$vars['p']."' AND `plugin_active`='1'"); + if (!empty($plugin)) { + include 'plugins/'.$plugin['plugin_name'].'/'.$plugin['plugin_name'].'.inc.php'; + } + else { + print_error('This plugin is either disabled or not available.'); + } } - -?> diff --git a/html/pages/plugin/admin.inc.php b/html/pages/plugin/admin.inc.php index 1773d641d8..e20bec1b64 100644 --- a/html/pages/plugin/admin.inc.php +++ b/html/pages/plugin/admin.inc.php @@ -1,33 +1,26 @@ = '10') -{ - - // Scan for new plugins and add to the database - $new_plugins = scan_new_plugins(); +if ($_SESSION['userlevel'] >= '10') { + // Scan for new plugins and add to the database + $new_plugins = scan_new_plugins(); - // Check if we have to toggle enabled / disable a particular module - $plugin_id = $_POST['plugin_id']; - $plugin_active = $_POST['plugin_active']; - if(is_numeric($plugin_id) && is_numeric($plugin_active)) - { - if( $plugin_active == '0') - { - $plugin_active = 1; - } - elseif( $plugin_active == '1') - { - $plugin_active = 0; - } - else - { - $plugin_active = 0; - } + // Check if we have to toggle enabled / disable a particular module + $plugin_id = $_POST['plugin_id']; + $plugin_active = $_POST['plugin_active']; + if (is_numeric($plugin_id) && is_numeric($plugin_active)) { + if ($plugin_active == '0') { + $plugin_active = 1; + } + else if ($plugin_active == '1') { + $plugin_active = 0; + } + else { + $plugin_active = 0; + } - if(dbUpdate(array('plugin_active' => $plugin_active), 'plugins', '`plugin_id` = ?', array($plugin_id))) - { - echo(' + if (dbUpdate(array('plugin_active' => $plugin_active), 'plugins', '`plugin_id` = ?', array($plugin_id))) { + echo ' -'); - } - - } +'; + } + }//end if ?> @@ -49,14 +41,13 @@ $.ajax({ System plugins
    0) - { - echo('
    +if ($new_plugins > 0) { + echo '
    - We have found ' . $new_plugins . ' new plugins that need to be configured and enabled + We have found '.$new_plugins.' new plugins that need to be configured and enabled
    -
    '); - } +
    '; +} ?> @@ -65,24 +56,21 @@ $.ajax({ + echo ' - '); - } - + '; +}//end foreach ?>
    - '. $plugins['plugin_name'] . ' + '.$plugins['plugin_name'].' @@ -91,18 +79,14 @@ $.ajax({
    +else { + include 'includes/error-no-perm.inc.php'; +}//end if diff --git a/html/pages/poll-log.inc.php b/html/pages/poll-log.inc.php index 3abdf05a8e..91ef8132e2 100644 --- a/html/pages/poll-log.inc.php +++ b/html/pages/poll-log.inc.php @@ -1,5 +1,5 @@ diff --git a/html/pages/pollers.inc.php b/html/pages/pollers.inc.php index de85c2344c..3fef3d931c 100644 --- a/html/pages/pollers.inc.php +++ b/html/pages/pollers.inc.php @@ -12,25 +12,32 @@ * the source code distribution for details. */ -$no_refresh = TRUE; +$no_refresh = true; -echo(''; if (isset($vars['tab'])) { - require_once "pages/pollers/".mres($vars['tab']).".inc.php"; + include_once 'pages/pollers/'.mres($vars['tab']).'.inc.php'; } diff --git a/html/pages/pollers/groups.inc.php b/html/pages/pollers/groups.inc.php index 50019dfc26..a914650ae2 100644 --- a/html/pages/pollers/groups.inc.php +++ b/html/pages/pollers/groups.inc.php @@ -12,7 +12,7 @@ * the source code distribution for details. */ -require_once "includes/modal/poller_groups.inc.php"; +require_once 'includes/modal/poller_groups.inc.php'; ?>
    @@ -28,18 +28,17 @@ require_once "includes/modal/poller_groups.inc.php"; + echo ' + -'); +'; } ?> diff --git a/html/pages/pollers/pollers.inc.php b/html/pages/pollers/pollers.inc.php index c5e0eb2799..f948d3a8b1 100644 --- a/html/pages/pollers/pollers.inc.php +++ b/html/pages/pollers/pollers.inc.php @@ -24,26 +24,28 @@ = 300) { $row_class = 'danger'; - } elseif ($old >= 280 && $old < 300) { + } + else if ($old >= 280 && $old < 300) { $row_class = 'warning'; - } else { + } + else { $row_class = 'success'; } - echo(' + + echo ' -'); +'; } ?> diff --git a/html/pages/ports.inc.php b/html/pages/ports.inc.php index 8ff1f7d344..edeea9fbef 100644 --- a/html/pages/ports.inc.php +++ b/html/pages/ports.inc.php @@ -4,29 +4,27 @@ $pagetitle[] = "Ports"; // Set Defaults here -if(!isset($vars['format'])) { $vars['format'] = "list_basic"; } +if(!isset($vars['format'])) { + $vars['format'] = "list_basic"; +} print_optionbar_start(); echo('Lists » '); -$menu_options = array('basic' => 'Basic', - 'detail' => 'Detail'); +$menu_options = array('basic' => 'Basic', 'detail' => 'Detail'); $sep = ""; -foreach ($menu_options as $option => $text) -{ - echo($sep); - if ($vars['format'] == "list_".$option) - { - echo(""); - } - echo('' . $text . ''); - if ($vars['format'] == "list_".$option) - { - echo(""); - } - $sep = " | "; +foreach ($menu_options as $option => $text) { + echo($sep); + if ($vars['format'] == "list_".$option) { + echo(""); + } + echo('' . $text . ''); + if ($vars['format'] == "list_".$option) { + echo(""); + } + $sep = " | "; } ?> @@ -37,24 +35,21 @@ foreach ($menu_options as $option => $text) 'Bits', - 'upkts' => 'Unicast Packets', - 'nupkts' => 'Non-Unicast Packets', - 'errors' => 'Errors'); + 'upkts' => 'Unicast Packets', + 'nupkts' => 'Non-Unicast Packets', + 'errors' => 'Errors'); $sep = ""; -foreach ($menu_options as $option => $text) -{ - echo($sep); - if ($vars['format'] == 'graph_'.$option) - { - echo(''); - } - echo('' . $text . ''); - if ($vars['format'] == 'graph_'.$option) - { - echo(""); - } - $sep = " | "; +foreach ($menu_options as $option => $text) { + echo($sep); + if ($vars['format'] == 'graph_'.$option) { + echo(''); + } + echo('' . $text . ''); + if ($vars['format'] == 'graph_'.$option) { + echo(""); + } + $sep = " | "; } echo('
    '); @@ -64,29 +59,28 @@ echo('
    '); Update URL | '')).'">Search'); - } else { +} +else { echo('Search'); - } +} - echo(" | "); +echo(" | "); - if (isset($vars['bare']) && $vars['bare'] == "yes") - { +if (isset($vars['bare']) && $vars['bare'] == "yes") { echo('Header'); - } else { +} +else { echo('Header'); - } +} echo('
    '); print_optionbar_end(); print_optionbar_start(); -if((isset($vars['searchbar']) && $vars['searchbar'] != "hide") || !isset($vars['searchbar'])) -{ +if((isset($vars['searchbar']) && $vars['searchbar'] != "hide") || !isset($vars['searchbar'])) { ?>
    @@ -95,67 +89,66 @@ if((isset($vars['searchbar']) && $vars['searchbar'] != "hide") || !isset($vars[' = 5) -{ - $results = dbFetchRows("SELECT `device_id`,`hostname` FROM `devices` GROUP BY `hostname` ORDER BY `hostname`"); -} -else -{ - $results = dbFetchRows("SELECT `D`.`device_id`,`D`.`hostname` FROM `devices` AS `D`, `devices_perms` AS `P` WHERE `P`.`user_id` = ? AND `P`.`device_id` = `D`.`device_id` GROUP BY `hostname` ORDER BY `hostname`", array($_SESSION['user_id'])); -} -foreach ($results as $data) -{ - echo(' "); -} + if($_SESSION['userlevel'] >= 5) { + $results = dbFetchRows("SELECT `device_id`,`hostname` FROM `devices` GROUP BY `hostname` ORDER BY `hostname`"); + } + else { + $results = dbFetchRows("SELECT `D`.`device_id`,`D`.`hostname` FROM `devices` AS `D`, `devices_perms` AS `P` WHERE `P`.`user_id` = ? AND `P`.`device_id` = `D`.`device_id` GROUP BY `hostname` ORDER BY `hostname`", array($_SESSION['user_id'])); + } + foreach ($results as $data) { + echo(' "); + } -if($_SESSION['userlevel'] < 5) -{ - $results = dbFetchRows("SELECT `D`.`device_id`,`D`.`hostname` FROM `ports` AS `I` JOIN `devices` AS `D` ON `D`.`device_id`=`I`.`device_id` JOIN `ports_perms` AS `PP` ON `PP`.`port_id`=`I`.`port_id` WHERE `PP`.`user_id` = ? AND `PP`.`port_id` = `I`.`port_id` GROUP BY `hostname` ORDER BY `hostname`", array($_SESSION['user_id'])); -} -else -{ - $results = array(); -} -foreach ($results as $data) -{ - echo(' "); -} + if($_SESSION['userlevel'] < 5) { + $results = dbFetchRows("SELECT `D`.`device_id`,`D`.`hostname` FROM `ports` AS `I` JOIN `devices` AS `D` ON `D`.`device_id`=`I`.`device_id` JOIN `ports_perms` AS `PP` ON `PP`.`port_id`=`I`.`port_id` WHERE `PP`.`user_id` = ? AND `PP`.`port_id` = `I`.`port_id` GROUP BY `hostname` ORDER BY `hostname`", array($_SESSION['user_id'])); + } + else { + $results = array(); + } + foreach ($results as $data) { + echo(' "); + } ?> - placeholder="Hostname" /> + placeholder="Hostname" />
    @@ -164,97 +157,100 @@ foreach (dbFetchRows($sql,$param) as $data) ".$data['ifType'].""); - } -} + if (is_admin() === TRUE || is_read() === TRUE) { + $sql = "SELECT `ifType` FROM `ports` GROUP BY `ifType` ORDER BY `ifType`"; + } + else { + $sql = "SELECT `ifType` FROM `ports` AS `I`, `devices` AS `D`, `devices_perms` AS `P`, `ports_perms` AS `PP` WHERE ((`P`.`user_id` = ? AND `P`.`device_id` = `D`.`device_id`) OR (`PP`.`user_id` = ? AND `PP`.`port_id` = `I`.`port_id` AND `I`.`device_id` = `D`.`device_id`)) AND `D`.`device_id` = `I`.`device_id` GROUP BY `ifType` ORDER BY `ifType`"; + $param[] = array($_SESSION['user_id'],$_SESSION['user_id']); + } + foreach (dbFetchRows($sql,$param) as $data) { + if ($data['ifType']) { + echo(' "); + } + } ?>
    - placeholder="Port Description"/> + placeholder="Port Description"/>
    - > + > - > + > - > + >
    @@ -266,95 +262,98 @@ foreach ($sorts as $sort => $sort_text)
    '.$group['id'].' '.$group['group_name'].' '.$group['descr'].'
    '.$poller['poller_name'].' '.$poller['devices'].' '.$poller['time_taken'].' Seconds '.$poller['last_polled'].'
    - $value) -{ - if ($value != "") - { - switch ($var) - { - case 'hostname': - $where .= " AND D.hostname LIKE ?"; - $param[] = "%".$value."%"; - break; - case 'location': - $where .= " AND D.location LIKE ?"; - $param[] = "%".$value."%"; - break; - case 'device_id': - $where .= " AND D.device_id = ?"; - $param[] = $value; - break; - case 'deleted': - if ($value == 1) { - $where .= " AND `I`.`deleted` = 1"; - $ignore_filter = 1; +foreach ($vars as $var => $value) { + if ($value != "") { + switch ($var) { + case 'hostname': + $where .= " AND D.hostname LIKE ?"; + $param[] = "%".$value."%"; + break; + case 'location': + $where .= " AND D.location LIKE ?"; + $param[] = "%".$value."%"; + break; + case 'device_id': + $where .= " AND D.device_id = ?"; + $param[] = $value; + break; + case 'deleted': + if ($value == 1) { + $where .= " AND `I`.`deleted` = 1"; + $ignore_filter = 1; + } + break; + case 'ignore': + if ($value == 1) { + $where .= " AND (I.ignore = 1 OR D.ignore = 1) AND I.deleted = 0"; + $ignore_filter = 1; + } + break; + case 'disabled': + if ($value == 1) { + $where .= " AND `I`.`disabled` = 1 AND `I`.`deleted` = 0"; + $disabled_filter = 1; + } + break; + case 'ifSpeed': + if (is_numeric($value)) { + $where .= " AND I.$var = ?"; + $param[] = $value; + } + break; + case 'ifType': + $where .= " AND I.$var = ?"; + $param[] = $value; + break; + case 'ifAlias': + case 'port_descr_type': + $where .= " AND I.$var LIKE ?"; + $param[] = "%".$value."%"; + break; + case 'errors': + if ($value == 1) { + $where .= " AND (I.`ifInErrors_delta` > '0' OR I.`ifOutErrors_delta` > '0')"; + } + break; + case 'state': + if ($value == "down") { + $where .= "AND I.ifAdminStatus = ? AND I.ifOperStatus = ?"; + $param[] = "up"; + $param[] = "down"; + } + elseif($value == "up") { + $where .= "AND I.ifAdminStatus = ? AND I.ifOperStatus = ? AND I.ignore = '0' AND D.ignore='0' AND I.deleted='0'"; + $param[] = "up"; + $param[] = "up"; + } + elseif($value == "admindown") { + $where .= "AND I.ifAdminStatus = ? AND D.ignore = 0"; + $param[] = "down"; + } + break; } - break; - case 'ignore': - if ($value == 1) { - $where .= " AND (I.ignore = 1 OR D.ignore = 1) AND I.deleted = 0"; - $ignore_filter = 1; - } - break; - case 'disabled': - if ($value == 1) { - $where .= " AND `I`.`disabled` = 1 AND `I`.`deleted` = 0"; - $disabled_filter = 1; - } - break; - case 'ifSpeed': - if (is_numeric($value)) - { - $where .= " AND I.$var = ?"; - $param[] = $value; - } - break; - case 'ifType': - $where .= " AND I.$var = ?"; - $param[] = $value; - break; - case 'ifAlias': - case 'port_descr_type': - $where .= " AND I.$var LIKE ?"; - $param[] = "%".$value."%"; - break; - case 'errors': - if ($value == 1) - { - $where .= " AND (I.`ifInErrors_delta` > '0' OR I.`ifOutErrors_delta` > '0')"; - } - break; - case 'state': - if ($value == "down") - { - $where .= "AND I.ifAdminStatus = ? AND I.ifOperStatus = ?"; - $param[] = "up"; - $param[] = "down"; - } elseif($value == "up") { - $where .= "AND I.ifAdminStatus = ? AND I.ifOperStatus = ? AND I.ignore = '0' AND D.ignore='0' AND I.deleted='0'"; - $param[] = "up"; - $param[] = "up"; - } elseif($value == "admindown") { - $where .= "AND I.ifAdminStatus = ? AND D.ignore = 0"; - $param[] = "down"; - } - break; } - } } if ($ignore_filter == 0 && $disabled_filter == 0) { @@ -369,49 +368,47 @@ list($format, $subformat) = explode("_", $vars['format']); $ports = dbFetchRows($query, $param); -switch ($vars['sort']) -{ - case 'traffic': - $ports = array_sort($ports, 'ifOctets_rate', SORT_DESC); - break; - case 'traffic_in': - $ports = array_sort($ports, 'ifInOctets_rate', SORT_DESC); - break; - case 'traffic_out': - $ports = array_sort($ports, 'ifOutOctets_rate', SORT_DESC); - break; - case 'packets': - $ports = array_sort($ports, 'ifUcastPkts_rate', SORT_DESC); - break; - case 'packets_in': - $ports = array_sort($ports, 'ifInUcastOctets_rate', SORT_DESC); - break; - case 'packets_out': - $ports = array_sort($ports, 'ifOutUcastOctets_rate', SORT_DESC); - break; - case 'errors': - $ports = array_sort($ports, 'ifErrors_rate', SORT_DESC); - break; - case 'speed': - $ports = array_sort($ports, 'ifSpeed', SORT_DESC); - break; - case 'port': - $ports = array_sort($ports, 'ifDescr', SORT_ASC); - break; - case 'media': - $ports = array_sort($ports, 'ifType', SORT_ASC); - break; - case 'descr': - $ports = array_sort($ports, 'ifAlias', SORT_ASC); - break; - case 'device': - default: - $ports = array_sort($ports, 'hostname', SORT_ASC); +switch ($vars['sort']) { + case 'traffic': + $ports = array_sort($ports, 'ifOctets_rate', SORT_DESC); + break; + case 'traffic_in': + $ports = array_sort($ports, 'ifInOctets_rate', SORT_DESC); + break; + case 'traffic_out': + $ports = array_sort($ports, 'ifOutOctets_rate', SORT_DESC); + break; + case 'packets': + $ports = array_sort($ports, 'ifUcastPkts_rate', SORT_DESC); + break; + case 'packets_in': + $ports = array_sort($ports, 'ifInUcastOctets_rate', SORT_DESC); + break; + case 'packets_out': + $ports = array_sort($ports, 'ifOutUcastOctets_rate', SORT_DESC); + break; + case 'errors': + $ports = array_sort($ports, 'ifErrors_rate', SORT_DESC); + break; + case 'speed': + $ports = array_sort($ports, 'ifSpeed', SORT_DESC); + break; + case 'port': + $ports = array_sort($ports, 'ifDescr', SORT_ASC); + break; + case 'media': + $ports = array_sort($ports, 'ifType', SORT_ASC); + break; + case 'descr': + $ports = array_sort($ports, 'ifAlias', SORT_ASC); + break; + case 'device': + default: + $ports = array_sort($ports, 'hostname', SORT_ASC); } -if(file_exists('pages/ports/'.$format.'.inc.php')) -{ - include('pages/ports/'.$format.'.inc.php'); +if(file_exists('pages/ports/'.$format.'.inc.php')) { + require 'pages/ports/'.$format.'.inc.php'; } ?> diff --git a/html/pages/ports/list.inc.php b/html/pages/ports/list.inc.php index 8ae9c9df36..71f52e6180 100644 --- a/html/pages/ports/list.inc.php +++ b/html/pages/ports/list.inc.php @@ -3,68 +3,75 @@ '); +echo ''; -$cols = array('device' => 'Device', - 'port' => 'Port', - 'speed' => 'Speed', - 'traffic_in' => 'Down', - 'traffic_out' => 'Up', - 'media' => 'Media', - 'descr' => 'Description' ); +$cols = array( + 'device' => 'Device', + 'port' => 'Port', + 'speed' => 'Speed', + 'traffic_in' => 'Down', + 'traffic_out' => 'Up', + 'media' => 'Media', + 'descr' => 'Description', +); -foreach ($cols as $sort => $col) -{ - if (isset($vars['sort']) && $vars['sort'] == $sort) - { - echo(''.$col.' *'); - } else { - echo(''.$col.''); - } +foreach ($cols as $sort => $col) { + if (isset($vars['sort']) && $vars['sort'] == $sort) { + echo ''.$col.' *'; + } + else { + echo ''.$col.''; + } } -echo(" "); +echo ' '; -$ports_disabled = 0; $ports_down = 0; $ports_up = 0; $ports_total = 0; +$ports_disabled = 0; +$ports_down = 0; +$ports_up = 0; +$ports_total = 0; -foreach ($ports as $port) -{ +foreach ($ports as $port) { + if (port_permitted($port['port_id'], $port['device_id'])) { + if ($port['ifAdminStatus'] == 'down') { + $ports_disabled++; + } + else if ($port['ifAdminStatus'] == 'up' && $port['ifOperStatus'] == 'down') { + $ports_down++; + } + else if ($port['ifAdminStatus'] == 'up' && $port['ifOperStatus'] == 'up') { + $ports_up++; + } - if (port_permitted($port['port_id'], $port['device_id'])) - { + $ports_total++; - if ($port['ifAdminStatus'] == "down") { $ports_disabled++; - } elseif ($port['ifAdminStatus'] == "up" && $port['ifOperStatus']== "down") { $ports_down++; - } elseif ($port['ifAdminStatus'] == "up" && $port['ifOperStatus']== "up") { $ports_up++; } - $ports_total++; + $speed = humanspeed($port['ifSpeed']); + $type = humanmedia($port['ifType']); + $ifclass = ifclass($port['ifOperStatus'], $port['ifAdminStatus']); - $speed = humanspeed($port['ifSpeed']); - $type = humanmedia($port['ifType']); - $ifclass = ifclass($port['ifOperStatus'], $port['ifAdminStatus']); + if ((isset($port['in_errors']) && $port['in_errors'] > 0) || (isset($ports['out_errors']) && $port['out_errors'] > 0)) { + $error_img = generate_port_link($port, "Interface Errors", errors); + } + else { + $error_img = ''; + } - if ((isset($port['in_errors']) && $port['in_errors'] > 0) || (isset($ports['out_errors']) && $port['out_errors'] > 0)) - { - $error_img = generate_port_link($port,"Interface Errors",errors); - } else { $error_img = ""; } + $port['in_rate'] = formatRates(($port['ifInOctets_rate'] * 8)); + $port['out_rate'] = formatRates(($port['ifOutOctets_rate'] * 8)); - $port['in_rate'] = formatRates($port['ifInOctets_rate'] * 8); - $port['out_rate'] = formatRates($port['ifOutOctets_rate'] * 8); + $port = ifLabel($port, $device); + echo " + ".generate_device_link($port, shorthost($port['hostname'], '20'))." + ".fixIfName($port['label'])." $error_img + $speed + ".$port['in_rate'].' + '.$port['out_rate']." + $type + ".$port['ifAlias']." + \n"; + }//end if +}//end foreach - $port = ifLabel($port, $device); - echo(" - ".generate_device_link($port, shorthost($port['hostname'], "20"))." - ".fixIfName($port['label'])." $error_img - $speed - ".$port['in_rate']." - ".$port['out_rate']." - $type - " . $port['ifAlias'] . " - \n"); - } -} - -echo(''); -echo("Matched Ports: $ports_total ( Up $ports_up | Down $ports_down | Disabled $ports_disabled )"); -echo(''); - -?> +echo ''; +echo "Matched Ports: $ports_total ( Up $ports_up | Down $ports_down | Disabled $ports_disabled )"; +echo ''; diff --git a/html/pages/preferences.inc.php b/html/pages/preferences.inc.php index f4815df24e..ca2f798352 100644 --- a/html/pages/preferences.inc.php +++ b/html/pages/preferences.inc.php @@ -1,48 +1,41 @@ User Preferences"); +echo '

    User Preferences

    '; if ($_SESSION['userlevel'] == 11) { - demo_account(); - -} else { - -if ($_POST['action'] == "changepass") -{ - if (authenticate($_SESSION['username'],$_POST['old_pass'])) - { - if ($_POST['new_pass'] == "" || $_POST['new_pass2'] == "") - { - $changepass_message = "Password must not be blank."; - } - elseif ($_POST['new_pass'] == $_POST['new_pass2']) - { - changepassword($_SESSION['username'],$_POST['new_pass']); - $changepass_message = "Password Changed."; - } - else - { - $changepass_message = "Passwords don't match."; - } - } else { - $changepass_message = "Incorrect password"; - } } +else { + if ($_POST['action'] == 'changepass') { + if (authenticate($_SESSION['username'], $_POST['old_pass'])) { + if ($_POST['new_pass'] == '' || $_POST['new_pass2'] == '') { + $changepass_message = 'Password must not be blank.'; + } + else if ($_POST['new_pass'] == $_POST['new_pass2']) { + changepassword($_SESSION['username'], $_POST['new_pass']); + $changepass_message = 'Password Changed.'; + } + else { + $changepass_message = "Passwords don't match."; + } + } + else { + $changepass_message = 'Incorrect password'; + } + } -include("includes/update-preferences-password.inc.php"); + include 'includes/update-preferences-password.inc.php'; -echo("
    "); + echo "
    "; -if (passwordscanchange($_SESSION['username'])) -{ - echo("

    Change Password

    "); - echo($changepass_message); - echo(" + if (passwordscanchange($_SESSION['username'])) { + echo '

    Change Password

    '; + echo $changepass_message; + echo "
    @@ -69,93 +62,107 @@ if (passwordscanchange($_SESSION['username']))
    -"); - echo("
    "); -} +"; + echo '
    '; + }//end if -if( $config['twofactor'] === true ) { - if( $_POST['twofactorremove'] == 1 ) { - require_once($config['install_dir']."/html/includes/authentication/twofactor.lib.php"); - if( !isset($_POST['twofactor']) ) { - echo '
    '; - echo ''; - echo twofactor_form(false); - echo '
    '; - } else{ - $twofactor = dbFetchRow('SELECT twofactor FROM users WHERE username = ?', array($_SESSION['username'])); - if( empty($twofactor['twofactor']) ) { - echo '
    Error: How did you even get here?!
    '; - } else { - $twofactor = json_decode($twofactor['twofactor'],true); - } - if( verify_hotp($twofactor['key'],$_POST['twofactor'],$twofactor['counter']) ) { - if( !dbUpdate(array('twofactor' => ''),'users','username = ?',array($_SESSION['username'])) ) { - echo '
    Error while disabling TwoFactor.
    '; - } else { - echo '
    TwoFactor Disabled.
    '; + if ($config['twofactor'] === true) { + if ($_POST['twofactorremove'] == 1) { + include_once $config['install_dir'].'/html/includes/authentication/twofactor.lib.php'; + if (!isset($_POST['twofactor'])) { + echo '
    '; + echo ''; + echo twofactor_form(false); + echo '
    '; + } + else { + $twofactor = dbFetchRow('SELECT twofactor FROM users WHERE username = ?', array($_SESSION['username'])); + if (empty($twofactor['twofactor'])) { + echo '
    Error: How did you even get here?!
    '; + } + else { + $twofactor = json_decode($twofactor['twofactor'], true); + } + + if (verify_hotp($twofactor['key'], $_POST['twofactor'], $twofactor['counter'])) { + if (!dbUpdate(array('twofactor' => ''), 'users', 'username = ?', array($_SESSION['username']))) { + echo '
    Error while disabling TwoFactor.
    '; + } + else { + echo '
    TwoFactor Disabled.
    '; + } + } + else { + session_destroy(); + echo '
    Error: Supplied TwoFactor Token is wrong, you\'ve been logged out.
    '; + } + }//end if } - } else { - session_destroy(); - echo '
    Error: Supplied TwoFactor Token is wrong, you\'ve been logged out.
    '; - } - } - } else { - $twofactor = dbFetchRow("SELECT twofactor FROM users WHERE username = ?", array($_SESSION['username'])); - echo ''; - echo '

    Two-Factor Authentication

    '; - if( !empty($twofactor['twofactor']) ) { - $twofactor = json_decode($twofactor['twofactor'],true); - $twofactor['text'] = "
    + else { + $twofactor = dbFetchRow('SELECT twofactor FROM users WHERE username = ?', array($_SESSION['username'])); + echo ''; + echo '

    Two-Factor Authentication

    '; + if (!empty($twofactor['twofactor'])) { + $twofactor = json_decode($twofactor['twofactor'], true); + $twofactor['text'] = "
    "; - if( $twofactor['counter'] !== false ) { - $twofactor['uri'] = "otpauth://hotp/".$_SESSION['username']."?issuer=LibreNMS&counter=".$twofactor['counter']."&secret=".$twofactor['key']; - $twofactor['text'] .= "
    + if ($twofactor['counter'] !== false) { + $twofactor['uri'] = 'otpauth://hotp/'.$_SESSION['username'].'?issuer=LibreNMS&counter='.$twofactor['counter'].'&secret='.$twofactor['key']; + $twofactor['text'] .= "
    "; - } else { - $twofactor['uri'] = "otpauth://totp/".$_SESSION['username']."?issuer=LibreNMS&secret=".$twofactor['key']; - } - echo '
    + } + else { + $twofactor['uri'] = 'otpauth://totp/'.$_SESSION['username'].'?issuer=LibreNMS&secret='.$twofactor['key']; + } + + echo '
    '; - echo '
    + echo '
    '.$twofactor['text'].'
    '; - echo ''; - echo '
    + echo ''; + echo '
    '; - } else { - if( isset($_POST['gentwofactorkey']) && isset($_POST['twofactortype']) ) { - require_once($config['install_dir']."/html/includes/authentication/twofactor.lib.php"); - $chk = dbFetchRow("SELECT twofactor FROM users WHERE username = ?", array($_SESSION['username'])); - if( empty($chk['twofactor']) ) { - $twofactor = array('key' => twofactor_genkey()); - if( $_POST['twofactortype'] == "counter" ) { - $twofactor['counter'] = 1; - } else { - $twofactor['counter'] = false; - } - if( !dbUpdate(array('twofactor' => json_encode($twofactor)),'users','username = ?',array($_SESSION['username'])) ) { - echo '
    Error inserting TwoFactor details. Please try again later and contact Administrator if error persists.
    '; - } else { - echo '
    Added TwoFactor credentials. Please reload page.
    '; - } - } else { - echo '
    TwoFactor credentials already exists.
    '; - } - } else { - echo '
    + } + else { + if (isset($_POST['gentwofactorkey']) && isset($_POST['twofactortype'])) { + include_once $config['install_dir'].'/html/includes/authentication/twofactor.lib.php'; + $chk = dbFetchRow('SELECT twofactor FROM users WHERE username = ?', array($_SESSION['username'])); + if (empty($chk['twofactor'])) { + $twofactor = array('key' => twofactor_genkey()); + if ($_POST['twofactortype'] == 'counter') { + $twofactor['counter'] = 1; + } + else { + $twofactor['counter'] = false; + } + + if (!dbUpdate(array('twofactor' => json_encode($twofactor)), 'users', 'username = ?', array($_SESSION['username']))) { + echo '
    Error inserting TwoFactor details. Please try again later and contact Administrator if error persists.
    '; + } + else { + echo '
    Added TwoFactor credentials. Please reload page.
    '; + } + } + else { + echo '
    TwoFactor credentials already exists.
    '; + } + } + else { + echo '
    @@ -169,32 +176,34 @@ if( $config['twofactor'] === true ) {
    '; - } + }//end if + }//end if + echo '
    '; + }//end if + }//end if +}//end if + +echo "
    '; - } } -} - -echo("
    "); -echo("
    Device Permissions
    "); - -if ($_SESSION['userlevel'] == '10') { echo("Global Administrative Access"); } -if ($_SESSION['userlevel'] == '5') { echo("Global Viewing Access"); } -if ($_SESSION['userlevel'] == '1') -{ - - foreach (dbFetchRows("SELECT * FROM `devices_perms` AS P, `devices` AS D WHERE `user_id` = ? AND P.device_id = D.device_id", array($_SESSION['user_id'])) as $perm) - { - #FIXME generatedevicelink? - echo("" . $perm['hostname'] . "
    "); - $dev_access = 1; - } - - if (!$dev_access) { echo("No access!"); } -} - -echo("
    "); - -?> +echo '
    '; diff --git a/html/pages/pseudowires.inc.php b/html/pages/pseudowires.inc.php index 5dd77f468c..3408973fd4 100644 --- a/html/pages/pseudowires.inc.php +++ b/html/pages/pseudowires.inc.php @@ -90,8 +90,7 @@ foreach (dbFetchRows('SELECT * FROM pseudowires AS P, ports AS I, devices AS D W $pw_a['to'] = $config['time']['now']; $pw_a['bg'] = $bg; $types = array('bits', 'upkts', 'errors'); - foreach ($types as $graph_type) - { + foreach ($types as $graph_type) { $pw_a['graph_type'] = 'port_'.$graph_type; print_port_thumbnail($pw_a); } diff --git a/html/pages/public.inc.php b/html/pages/public.inc.php index ad89593bcf..bb25838841 100644 --- a/html/pages/public.inc.php +++ b/html/pages/public.inc.php @@ -1,14 +1,14 @@ - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation, either version 3 of the License, or (at your - * option) any later version. Please see LICENSE.txt at the top level of - * the source code distribution for details. + * This file is part of LibreNMS + * + * Copyright (c) 2014 Bohdan Sanders + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. Please see LICENSE.txt at the top level of + * the source code distribution for details. */ ?> @@ -28,14 +28,11 @@ $(document).ready(function() {

    System Status

    @@ -50,9 +47,8 @@ $query = "SELECT * FROM `devices` WHERE 1 AND disabled='0' AND `ignore`='0' ORDE Uptime/Location diff --git a/html/pages/routing/bgp.inc.php b/html/pages/routing/bgp.inc.php index 5e04945626..3268715ec5 100644 --- a/html/pages/routing/bgp.inc.php +++ b/html/pages/routing/bgp.inc.php @@ -1,260 +1,355 @@ 'routing', 'protocol' => 'bgp'); +else { + $link_array = array( + 'page' => 'routing', + 'protocol' => 'bgp', + ); - print_optionbar_start('', ''); + print_optionbar_start('', ''); - echo('BGP » '); + echo 'BGP » '; - if (!$vars['type']) { $vars['type'] = "all"; } - - if ($vars['type'] == "all") { echo(""); } - echo(generate_link("All",$vars, array('type' => 'all'))); - if ($vars['type'] == "all") { echo(""); } - - echo(" | "); - - if ($vars['type'] == "internal") { echo(""); } - echo(generate_link("iBGP",$vars, array('type' => 'internal'))); - if ($vars['type'] == "internal") { echo(""); } - - echo(" | "); - - if ($vars['type'] == "external") { echo(""); } - echo(generate_link("eBGP",$vars, array('type' => 'external'))); - if ($vars['type'] == "external") { echo(""); } - - echo(" | "); - - if ($vars['adminstatus'] == "stop") - { - echo(""); - echo(generate_link("Shutdown",$vars, array('adminstatus' => NULL))); - echo(""); - } else { - echo(generate_link("Shutdown",$vars, array('adminstatus' => 'stop'))); - } - - echo(" | "); - - if ($vars['adminstatus'] == "start") - { - echo(""); - echo(generate_link("Enabled",$vars, array('adminstatus' => NULL))); - echo(""); - } else { - echo(generate_link("Enabled",$vars, array('adminstatus' => 'start'))); - } - - echo(" | "); - - if ($vars['state'] == "down") - { - echo(""); - echo(generate_link("Down",$vars, array('state' => NULL))); - echo(""); - } else { - echo(generate_link("Down",$vars, array('state' => 'down'))); - } - - // End BGP Menu - - if (!isset($vars['view'])) { $vars['view'] = 'details'; } - - echo('
    '); - - if ($vars['view'] == "details") { echo(""); } - echo(generate_link("No Graphs",$vars, array('view' => 'details', 'graph' => 'NULL'))); - if ($vars['view'] == "details") { echo(""); } - - echo(" | "); - - if ($vars['graph'] == "updates") { echo(""); } - echo(generate_link("Updates",$vars, array('view' => 'graphs', 'graph' => 'updates'))); - if ($vars['graph'] == "updates") { echo(""); } - - echo(" | Prefixes: Unicast ("); - if ($vars['graph'] == "prefixes_ipv4unicast") { echo(""); } - echo(generate_link("IPv4",$vars, array('view' => 'graphs', 'graph' => 'prefixes_ipv4unicast'))); - if ($vars['graph'] == "prefixes_ipv4unicast") { echo(""); } - - echo("|"); - - if ($vars['graph'] == "prefixes_ipv6unicast") { echo(""); } - echo(generate_link("IPv6",$vars, array('view' => 'graphs', 'graph' => 'prefixes_ipv6unicast'))); - if ($vars['graph'] == "prefixes_ipv6unicast") { echo(""); } - - echo("|"); - - if ($vars['graph'] == "prefixes_ipv4vpn") { echo(""); } - echo(generate_link("VPNv4",$vars, array('view' => 'graphs', 'graph' => 'prefixes_ipv4vpn'))); - if ($vars['graph'] == "prefixes_ipv4vpn") { echo(""); } - echo(")"); - - echo(" | Multicast ("); - if ($vars['graph'] == "prefixes_ipv4multicast") { echo(""); } - echo(generate_link("IPv4",$vars, array('view' => 'graphs', 'graph' => 'prefixes_ipv4multicast'))); - if ($vars['graph'] == "prefixes_ipv4multicast") { echo(""); } - - echo("|"); - - if ($vars['graph'] == "prefixes_ipv6multicast") { echo(""); } - echo(generate_link("IPv6",$vars, array('view' => 'graphs', 'graph' => 'prefixes_ipv6multicast'))); - if ($vars['graph'] == "prefixes_ipv6multicast") { echo(""); } - echo(")"); - - echo(" | MAC ("); - if ($vars['graph'] == "macaccounting_bits") { echo(""); } - echo(generate_link("Bits",$vars, array('view' => 'graphs', 'graph' => 'macaccounting_bits'))); - if ($vars['graph'] == "macaccounting_bits") { echo(""); } - - echo("|"); - - if ($vars['graph'] == "macaccounting_pkts") { echo(""); } - echo(generate_link("Packets",$vars, array('view' => 'graphs', 'graph' => 'macaccounting_pkts'))); - if ($vars['graph'] == "macaccounting_pkts") { echo(""); } - echo(")"); - - echo('
    '); - - print_optionbar_end(); - - echo(""); - echo(''); - - if ($vars['type'] == "external") - { - $where = "AND D.bgpLocalAs != B.bgpPeerRemoteAs"; - } elseif ($vars['type'] == "internal") { - $where = "AND D.bgpLocalAs = B.bgpPeerRemoteAs"; - } - - if ($vars['adminstatus'] == "stop") - { - $where .= " AND (B.bgpPeerAdminStatus = 'stop')"; - } elseif ($vars['adminstatus'] == "start") - { - $where .= " AND (B.bgpPeerAdminStatus = 'start' || B.bgpPeerAdminStatus = 'running')"; - } - - if ($vars['state'] == "down") - { - $where .= " AND (B.bgpPeerState != 'established')"; - } - - $peer_query = "select * from bgpPeers AS B, devices AS D WHERE B.device_id = D.device_id ".$where." ORDER BY D.hostname, B.bgpPeerRemoteAs, B.bgpPeerIdentifier"; - foreach (dbFetchRows($peer_query) as $peer) - { - unset ($alert, $bg_image); - - if ($peer['bgpPeerState'] == "established") { $col = "green"; } else { $col = "red"; $peer['alert']=1; } - if ($peer['bgpPeerAdminStatus'] == "start" || $peer['bgpPeerAdminStatus'] == "running") { $admin_col = "green"; } else { $admin_col = "gray"; } - if ($peer['bgpPeerAdminStatus'] == "stop") { $peer['alert']=0; $peer['disabled']=1; } - if ($peer['bgpPeerRemoteAs'] == $peer['bgpLocalAs']) { $peer_type = "iBGP"; } else { $peer_type = "eBGP"; - if ($peer['bgpPeerRemoteAS'] >= '64512' && $peer['bgpPeerRemoteAS'] <= '65535') { $peer_type = "Priv eBGP"; } + if (!$vars['type']) { + $vars['type'] = 'all'; } - $peerhost = dbFetchRow("SELECT * FROM ipaddr AS A, ports AS I, devices AS D WHERE A.addr = ? AND I.port_id = A.port_id AND D.device_id = I.device_id", array($peer['bgpPeerIdentifier'])); - - if ($peerhost) { $peername = generate_device_link($peerhost, shorthost($peerhost['hostname'])); } else { unset($peername); } - - // display overlib graphs - - $graph_type = "bgp_updates"; - $local_daily_url = "graph.php?id=" . $peer['bgpPeer_id'] . "&type=" . $graph_type . "&from=".$config['time']['day']."&to=".$config['time']['now']."&width=500&height=150&&afi=ipv4&safi=unicast"; - if (filter_var($peer['bgpLocalAddr'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) !== FALSE) { - $peer_ip = Net_IPv6::compress($peer['bgpLocalAddr']); - } else { - $peer_ip = $peer['bgpLocalAddr']; - } - $localaddresslink = "', LEFT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\">" . $peer_ip . ""; - - $graph_type = "bgp_updates"; - $peer_daily_url = "graph.php?id=" . $peer['bgpPeer_id'] . "&type=" . $graph_type . "&from=".$config['time']['day']."&to=".$config['time']['now']."&width=500&height=150"; - if (filter_var($peer['bgpPeerIdentifier'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) !== FALSE) { - $peer_ident = Net_IPv6::compress($peer['bgpPeerIdentifier']); - } else { - $peer_ident = $peer['bgpPeerIdentifier']; + if ($vars['type'] == 'all') { + echo ""; } - $peeraddresslink = "', LEFT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\">" . $peer_ident . ""; - - echo('"); - - unset($sep); - foreach (dbFetchRows("SELECT * FROM `bgpPeers_cbgp` WHERE `device_id` = ? AND bgpPeerIdentifier = ?", array($peer['device_id'], $peer['bgpPeerIdentifier'])) as $afisafi) - { - $afi = $afisafi['afi']; - $safi = $afisafi['safi']; - $this_afisafi = $afi.$safi; - $peer['afi'] .= $sep . $afi .".".$safi; - $sep = "
    "; - $peer['afisafi'][$this_afisafi] = 1; // Build a list of valid AFI/SAFI for this peer - } - unset($sep); - - echo(" - - - - - - - - "); - - unset($invalid); - switch ($vars['graph']) - { - case 'prefixes_ipv4unicast': - case 'prefixes_ipv4multicast': - case 'prefixes_ipv4vpn': - case 'prefixes_ipv6unicast': - case 'prefixes_ipv6multicast': - list(,$afisafi) = explode("_", $vars['graph']); - if (isset($peer['afisafi'][$afisafi])) { $peer['graph'] = 1; } - case 'updates': - $graph_array['type'] = "bgp_" . $vars['graph']; - $graph_array['id'] = $peer['bgpPeer_id']; + echo generate_link('All', $vars, array('type' => 'all')); + if ($vars['type'] == 'all') { + echo ''; } - switch ($vars['graph']) - { - case 'macaccounting_bits': - case 'macaccounting_pkts': - $acc = dbFetchRow("SELECT * FROM `ipv4_mac` AS I, `mac_accounting` AS M, `ports` AS P, `devices` AS D WHERE I.ipv4_address = ? AND M.mac = I.mac_address AND P.port_id = M.port_id AND D.device_id = P.device_id", array($peer['bgpPeerIdentifier'])); - $database = $config['rrd_dir'] . "/" . $device['hostname'] . "/cip-" . $acc['ifIndex'] . "-" . $acc['mac'] . ".rrd"; - if (is_array($acc) && is_file($database)) - { - $peer['graph'] = 1; - $graph_array['id'] = $acc['ma_id']; - $graph_array['type'] = $vars['graph']; + echo ' | '; + + if ($vars['type'] == 'internal') { + echo ""; + } + + echo generate_link('iBGP', $vars, array('type' => 'internal')); + if ($vars['type'] == 'internal') { + echo ''; + } + + echo ' | '; + + if ($vars['type'] == 'external') { + echo ""; + } + + echo generate_link('eBGP', $vars, array('type' => 'external')); + if ($vars['type'] == 'external') { + echo ''; + } + + echo ' | '; + + if ($vars['adminstatus'] == 'stop') { + echo ""; + echo generate_link('Shutdown', $vars, array('adminstatus' => null)); + echo ''; + } + else { + echo generate_link('Shutdown', $vars, array('adminstatus' => 'stop')); + } + + echo ' | '; + + if ($vars['adminstatus'] == 'start') { + echo ""; + echo generate_link('Enabled', $vars, array('adminstatus' => null)); + echo ''; + } + else { + echo generate_link('Enabled', $vars, array('adminstatus' => 'start')); + } + + echo ' | '; + + if ($vars['state'] == 'down') { + echo ""; + echo generate_link('Down', $vars, array('state' => null)); + echo ''; + } + else { + echo generate_link('Down', $vars, array('state' => 'down')); + } + + // End BGP Menu + if (!isset($vars['view'])) { + $vars['view'] = 'details'; + } + + echo '
    '; + + if ($vars['view'] == 'details') { + echo ""; + } + + echo generate_link('No Graphs', $vars, array('view' => 'details', 'graph' => 'NULL')); + if ($vars['view'] == 'details') { + echo ''; + } + + echo ' | '; + + if ($vars['graph'] == 'updates') { + echo ""; + } + + echo generate_link('Updates', $vars, array('view' => 'graphs', 'graph' => 'updates')); + if ($vars['graph'] == 'updates') { + echo ''; + } + + echo ' | Prefixes: Unicast ('; + if ($vars['graph'] == 'prefixes_ipv4unicast') { + echo ""; + } + + echo generate_link('IPv4', $vars, array('view' => 'graphs', 'graph' => 'prefixes_ipv4unicast')); + if ($vars['graph'] == 'prefixes_ipv4unicast') { + echo ''; + } + + echo '|'; + + if ($vars['graph'] == 'prefixes_ipv6unicast') { + echo ""; + } + + echo generate_link('IPv6', $vars, array('view' => 'graphs', 'graph' => 'prefixes_ipv6unicast')); + if ($vars['graph'] == 'prefixes_ipv6unicast') { + echo ''; + } + + echo '|'; + + if ($vars['graph'] == 'prefixes_ipv4vpn') { + echo ""; + } + + echo generate_link('VPNv4', $vars, array('view' => 'graphs', 'graph' => 'prefixes_ipv4vpn')); + if ($vars['graph'] == 'prefixes_ipv4vpn') { + echo ''; + } + + echo ')'; + + echo ' | Multicast ('; + if ($vars['graph'] == 'prefixes_ipv4multicast') { + echo ""; + } + + echo generate_link('IPv4', $vars, array('view' => 'graphs', 'graph' => 'prefixes_ipv4multicast')); + if ($vars['graph'] == 'prefixes_ipv4multicast') { + echo ''; + } + + echo '|'; + + if ($vars['graph'] == 'prefixes_ipv6multicast') { + echo ""; + } + + echo generate_link('IPv6', $vars, array('view' => 'graphs', 'graph' => 'prefixes_ipv6multicast')); + if ($vars['graph'] == 'prefixes_ipv6multicast') { + echo ''; + } + + echo ')'; + + echo ' | MAC ('; + if ($vars['graph'] == 'macaccounting_bits') { + echo ""; + } + + echo generate_link('Bits', $vars, array('view' => 'graphs', 'graph' => 'macaccounting_bits')); + if ($vars['graph'] == 'macaccounting_bits') { + echo ''; + } + + echo '|'; + + if ($vars['graph'] == 'macaccounting_pkts') { + echo ""; + } + + echo generate_link('Packets', $vars, array('view' => 'graphs', 'graph' => 'macaccounting_pkts')); + if ($vars['graph'] == 'macaccounting_pkts') { + echo ''; + } + + echo ')'; + + echo '
    '; + + print_optionbar_end(); + + echo "
    Local addressPeer addressTypeFamilyRemote ASStateUptime / Updates
    " . $localaddresslink . "
    ".generate_device_link($peer, shorthost($peer['hostname']), array('tab' => 'routing', 'proto' => 'bgp'))."
    »" . $peeraddresslink . "$peer_type".$peer['afi']."AS" . $peer['bgpPeerRemoteAs'] . "
    " . $peer['astext'] . "
    " . $peer['bgpPeerAdminStatus'] . "
    " . $peer['bgpPeerState'] . "
    " .formatUptime($peer['bgpPeerFsmEstablishedTime']). "
    - Updates " . format_si($peer['bgpPeerInUpdates']) . " - " . format_si($peer['bgpPeerOutUpdates']) . "
    "; + echo ''; + + if ($vars['type'] == 'external') { + $where = 'AND D.bgpLocalAs != B.bgpPeerRemoteAs'; + } + else if ($vars['type'] == 'internal') { + $where = 'AND D.bgpLocalAs = B.bgpPeerRemoteAs'; + } + + if ($vars['adminstatus'] == 'stop') { + $where .= " AND (B.bgpPeerAdminStatus = 'stop')"; + } + else if ($vars['adminstatus'] == 'start') { + $where .= " AND (B.bgpPeerAdminStatus = 'start' || B.bgpPeerAdminStatus = 'running')"; + } + + if ($vars['state'] == 'down') { + $where .= " AND (B.bgpPeerState != 'established')"; + } + + $peer_query = 'select * from bgpPeers AS B, devices AS D WHERE B.device_id = D.device_id '.$where.' ORDER BY D.hostname, B.bgpPeerRemoteAs, B.bgpPeerIdentifier'; + foreach (dbFetchRows($peer_query) as $peer) { + unset($alert, $bg_image); + + if ($peer['bgpPeerState'] == 'established') { + $col = 'green'; + } + else { + $col = 'red'; + $peer['alert'] = 1; } - } - if ($vars['graph'] == 'updates') { $peer['graph'] = 1; } + if ($peer['bgpPeerAdminStatus'] == 'start' || $peer['bgpPeerAdminStatus'] == 'running') { + $admin_col = 'green'; + } + else { + $admin_col = 'gray'; + } - if ($peer['graph']) - { - $graph_array['height'] = "100"; - $graph_array['width'] = "218"; - $graph_array['to'] = $config['time']['now']; - echo('"); - } - } + $peerhost = dbFetchRow('SELECT * FROM ipaddr AS A, ports AS I, devices AS D WHERE A.addr = ? AND I.port_id = A.port_id AND D.device_id = I.device_id', array($peer['bgpPeerIdentifier'])); - echo("
    Local addressPeer addressTypeFamilyRemote ASStateUptime / Updates
    '); + if ($peer['bgpPeerAdminStatus'] == 'stop') { + $peer['alert'] = 0; + $peer['disabled'] = 1; + } - include("includes/print-graphrow.inc.php"); + if ($peer['bgpPeerRemoteAs'] == $peer['bgpLocalAs']) { + $peer_type = "iBGP"; + } + else { + $peer_type = "eBGP"; + if ($peer['bgpPeerRemoteAS'] >= '64512' && $peer['bgpPeerRemoteAS'] <= '65535') { + $peer_type = "Priv eBGP"; + } + } - echo("
    "); -} + if ($peerhost) { + $peername = generate_device_link($peerhost, shorthost($peerhost['hostname'])); + } + else { + unset($peername); + } + // display overlib graphs + $graph_type = 'bgp_updates'; + $local_daily_url = 'graph.php?id='.$peer['bgpPeer_id'].'&type='.$graph_type.'&from='.$config['time']['day'].'&to='.$config['time']['now'].'&width=500&height=150&&afi=ipv4&safi=unicast'; + if (filter_var($peer['bgpLocalAddr'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) !== false) { + $peer_ip = Net_IPv6::compress($peer['bgpLocalAddr']); + } + else { + $peer_ip = $peer['bgpLocalAddr']; + } + + $localaddresslink = "', LEFT".$config['overlib_defaults'].');" onmouseout="return nd();">'.$peer_ip.''; + + $graph_type = 'bgp_updates'; + $peer_daily_url = 'graph.php?id='.$peer['bgpPeer_id'].'&type='.$graph_type.'&from='.$config['time']['day'].'&to='.$config['time']['now'].'&width=500&height=150'; + if (filter_var($peer['bgpPeerIdentifier'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) !== false) { + $peer_ident = Net_IPv6::compress($peer['bgpPeerIdentifier']); + } + else { + $peer_ident = $peer['bgpPeerIdentifier']; + } + + $peeraddresslink = "', LEFT".$config['overlib_defaults'].');" onmouseout="return nd();">'.$peer_ident.''; + + echo ''; + + unset($sep); + foreach (dbFetchRows('SELECT * FROM `bgpPeers_cbgp` WHERE `device_id` = ? AND bgpPeerIdentifier = ?', array($peer['device_id'], $peer['bgpPeerIdentifier'])) as $afisafi) { + $afi = $afisafi['afi']; + $safi = $afisafi['safi']; + $this_afisafi = $afi.$safi; + $peer['afi'] .= $sep.$afi.'.'.$safi; + $sep = '
    '; + $peer['afisafi'][$this_afisafi] = 1; + // Build a list of valid AFI/SAFI for this peer + } + + unset($sep); + + echo ' + '.$localaddresslink.'
    '.generate_device_link($peer, shorthost($peer['hostname']), array('tab' => 'routing', 'proto' => 'bgp')).' + » + '.$peeraddresslink." + $peer_type + ".$peer['afi'].' + AS'.$peer['bgpPeerRemoteAs'].'
    '.$peer['astext']." + ".$peer['bgpPeerAdminStatus']."
    ".$peer['bgpPeerState'].'
    + '.formatUptime($peer['bgpPeerFsmEstablishedTime'])."
    + Updates ".format_si($peer['bgpPeerInUpdates'])." + ".format_si($peer['bgpPeerOutUpdates']).''; + + unset($invalid); + switch ($vars['graph']) { + case 'prefixes_ipv4unicast': + case 'prefixes_ipv4multicast': + case 'prefixes_ipv4vpn': + case 'prefixes_ipv6unicast': + case 'prefixes_ipv6multicast': + list(,$afisafi) = explode('_', $vars['graph']); + if (isset($peer['afisafi'][$afisafi])) { + $peer['graph'] = 1; + } + + case 'updates': + $graph_array['type'] = 'bgp_'.$vars['graph']; + $graph_array['id'] = $peer['bgpPeer_id']; + } + + switch ($vars['graph']) { + case 'macaccounting_bits': + case 'macaccounting_pkts': + $acc = dbFetchRow('SELECT * FROM `ipv4_mac` AS I, `mac_accounting` AS M, `ports` AS P, `devices` AS D WHERE I.ipv4_address = ? AND M.mac = I.mac_address AND P.port_id = M.port_id AND D.device_id = P.device_id', array($peer['bgpPeerIdentifier'])); + $database = $config['rrd_dir'].'/'.$device['hostname'].'/cip-'.$acc['ifIndex'].'-'.$acc['mac'].'.rrd'; + if (is_array($acc) && is_file($database)) { + $peer['graph'] = 1; + $graph_array['id'] = $acc['ma_id']; + $graph_array['type'] = $vars['graph']; + } + } + + if ($vars['graph'] == 'updates') { + $peer['graph'] = 1; + } + + if ($peer['graph']) { + $graph_array['height'] = '100'; + $graph_array['width'] = '218'; + $graph_array['to'] = $config['time']['now']; + echo ''; + + include 'includes/print-graphrow.inc.php'; + + echo ''; + } + }//end foreach + + echo ''; +}//end if diff --git a/html/pages/routing/overview.inc.php b/html/pages/routing/overview.inc.php index bd9a9e63e1..c16262143a 100644 --- a/html/pages/routing/overview.inc.php +++ b/html/pages/routing/overview.inc.php @@ -1,7 +1,7 @@ 'IPv4 Address', 'ipv6' => 'IPv6 Address', 'mac' => 'MAC Address', 'arp' => 'ARP Table'); +$sections = array( + 'ipv4' => 'IPv4 Address', + 'ipv6' => 'IPv6 Address', + 'mac' => 'MAC Address', + 'arp' => 'ARP Table', +); -if( dbFetchCell("SELECT 1 from `packages` LIMIT 1") ) { - $sections['packages'] = 'Packages'; +if (dbFetchCell('SELECT 1 from `packages` LIMIT 1')) { + $sections['packages'] = 'Packages'; } -if (!isset($vars['search'])) { $vars['search'] = "ipv4"; } +if (!isset($vars['search'])) { + $vars['search'] = 'ipv4'; +} print_optionbar_start('', ''); - echo('Search » '); +echo 'Search » '; unset($sep); -foreach ($sections as $type => $texttype) -{ - echo($sep); - if ($vars['search'] == $type) - { - echo(""); - } +foreach ($sections as $type => $texttype) { + echo $sep; + if ($vars['search'] == $type) { + echo ""; + } -# echo('' . $texttype .''); - echo(generate_link($texttype, array('page'=>'search','search'=>$type))); + // echo('' . $texttype .''); + echo generate_link($texttype, array('page' => 'search', 'search' => $type)); - if ($vars['search'] == $type) { echo(""); } + if ($vars['search'] == $type) { + echo ''; + } - $sep = ' | '; + $sep = ' | '; } -unset ($sep); + +unset($sep); print_optionbar_end('', ''); -if( file_exists('pages/search/'.$vars['search'].'.inc.php') ) { - include('pages/search/'.$vars['search'].'.inc.php'); -} else { - echo(report_this('Unknown search type '.$vars['search'])); +if (file_exists('pages/search/'.$vars['search'].'.inc.php')) { + include 'pages/search/'.$vars['search'].'.inc.php'; +} +else { + echo report_this('Unknown search type '.$vars['search']); } - -?> diff --git a/html/pages/search/arp.inc.php b/html/pages/search/arp.inc.php index a4dcbd1136..45cd6888a9 100644 --- a/html/pages/search/arp.inc.php +++ b/html/pages/search/arp.inc.php @@ -30,21 +30,22 @@ var grid = $("#arp-search").bootgrid({ '.$data['hostname'].'"+'); + + echo '">'.$data['hostname'].'"+'; } ?> ""+ @@ -53,18 +54,16 @@ foreach (dbFetchRows($sql,$param) as $data) { " "\" class=\"form-control input-sm\" placeholder=\"Address\" />"+ diff --git a/html/pages/search/ipv4.inc.php b/html/pages/search/ipv4.inc.php index e2ea785c07..843acbd1bc 100644 --- a/html/pages/search/ipv4.inc.php +++ b/html/pages/search/ipv4.inc.php @@ -27,22 +27,23 @@ var grid = $("#ipv4-search").bootgrid({ ""+ '.$data['hostname'].'"+'); + + echo '">'.$data['hostname'].'"+'; } ?> ""+ @@ -52,18 +53,16 @@ foreach (dbFetchRows($sql,$param) as $data) { ""+ ""+ "
     "+ "
    "+ - "\" class=\"form-control input-sm\" placeholder=\"IPv4 Address\"/>"+ + "\" class=\"form-control input-sm\" placeholder=\"IPv4 Address\"/>"+ "
     "+ ""+ "
    "+ diff --git a/html/pages/search/ipv6.inc.php b/html/pages/search/ipv6.inc.php index 8ab58d9fff..2b9115013d 100644 --- a/html/pages/search/ipv6.inc.php +++ b/html/pages/search/ipv6.inc.php @@ -26,22 +26,23 @@ var grid = $("#ipv6-search").bootgrid({ ""+ '.$data['hostname'].'"+'); + + echo '">'.$data['hostname'].'"+'; } ?> ""+ @@ -51,9 +52,8 @@ foreach (dbFetchRows($sql,$param) as $data) { ""+ ""+ "
    "+ "
    "+ - "\" class=\"form-control input-sm\" placeholder=\"IPv6 Address\"/>"+ + "\" class=\"form-control input-sm\" placeholder=\"IPv6 Address\"/>"+ "
    "+ ""+ "
    "+ diff --git a/html/pages/search/mac.inc.php b/html/pages/search/mac.inc.php index c040a1e16a..f606e4436a 100644 --- a/html/pages/search/mac.inc.php +++ b/html/pages/search/mac.inc.php @@ -26,21 +26,22 @@ var grid = $("#mac-search").bootgrid({ ""+ @@ -50,17 +51,15 @@ foreach (dbFetchRows($sql,$param) as $data) { ""+ ""+ "
    '-1', - 'rule' => '%macros.device_down = "1"', - 'severity' => 'critical', - 'extra' => '{"mute":false,"count":"-1","delay":"300"}', - 'disabled' => 0, - 'name' => 'Devices up/down', - ); - $default_rules[] = array( - 'device_id' => '-1', - 'rule' => '%devices.uptime < "300" && %macros.device = "1"', - 'severity' => 'critical', - 'extra' => '{"mute":false,"count":"1","delay":"300"}', - 'disabled' => 0, - 'name' => 'Device rebooted', - ); - $default_rules[] = array( - 'device_id' => '-1', - 'rule' => '%bgpPeers.bgpPeerState != "established" && %macros.device_up = "1"', - 'severity' => 'critical', - 'extra' => '{"mute":false,"count":"1","delay":"300"}', - 'disabled' => 0, - 'name' => 'BGP Session down', - ); - $default_rules[] = array( - 'device_id' => '-1', - 'rule' => '%bgpPeers.bgpPeerFsmEstablishedTime < "300" && %bgpPeers.bgpPeerState = "established"', - 'severity' => 'critical', - 'extra' => '{"mute":false,"count":"1","delay":"300"}', - 'disabled' => 0, - 'name' => 'BGP Session establised', - ); - $default_rules[] = array( - 'device_id' => '-1', - 'rule' => '%macros.port_down = "1"', - 'severity' => 'critical', - 'extra' => '{"mute":false,"count":"1","delay":"300"}', - 'disabled' => 0, - 'name' => 'Port status up/down', - ); - $default_rules[] = array( - 'device_id' => '-1', - 'rule' => '%macros.port_usage_perc >= "80"', - 'severity' => 'critical', - 'extra' => '{"mute":false,"count":"-1","delay":"300"}', - 'disabled' => 0, - 'name' => 'Port utilisation over threshold', - ); - $default_rules[] = array( - 'device_id' => '-1', - 'rule' => '%sensors.sensor_current > %sensors.sensor_limit', - 'severity' => 'critical', - 'extra' => '{"mute":false,"count":"-1","delay":"300"}', - 'disabled' => 0, - 'name' => 'Sensor over limit', - ); - $default_rules[] = array( - 'device_id' => '-1', - 'rule' => '%sensors.sensor_current < %sensors.sensor_limit_low', - 'severity' => 'critical', - 'extra' => '{"mute":false,"count":"-1","delay":"300"}', - 'disabled' => 0, - 'name' => 'Sensor under limit', - ); - foreach ($default_rules as $add_rule) { - dbInsert($add_rule, 'alert_rules'); - } -}//end if -require_once 'includes/modal/new_alert_rule.inc.php'; -require_once 'includes/modal/delete_alert_rule.inc.php'; +if(isset($_POST['create-default'])) { + $default_rules[] = array('device_id' => '-1', 'rule' => '%macros.device_down = "1"', 'severity' => 'critical', 'extra' => '{"mute":false,"count":"-1","delay":"300"}', 'disabled' => 0, 'name' => 'Devices up/down'); + $default_rules[] = array('device_id' => '-1', 'rule' => '%devices.uptime < "300" && %macros.device = "1"', 'severity' => 'critical', 'extra' => '{"mute":false,"count":"1","delay":"300"}', 'disabled' => 0, 'name' => 'Device rebooted'); + $default_rules[] = array('device_id' => '-1', 'rule' => '%bgpPeers.bgpPeerState != "established" && %macros.device_up = "1"', 'severity' => 'critical', 'extra' => '{"mute":false,"count":"1","delay":"300"}', 'disabled' => 0, 'name' => 'BGP Session down'); + $default_rules[] = array('device_id' => '-1', 'rule' => '%bgpPeers.bgpPeerFsmEstablishedTime < "300" && %bgpPeers.bgpPeerState = "established"', 'severity' => 'critical', 'extra' => '{"mute":false,"count":"1","delay":"300"}', 'disabled' => 0, 'name' => 'BGP Session establised'); + $default_rules[] = array('device_id' => '-1', 'rule' => '%macros.port_down = "1"', 'severity' => 'critical', 'extra' => '{"mute":false,"count":"1","delay":"300"}', 'disabled' => 0, 'name' => 'Port status up/down'); + $default_rules[] = array('device_id' => '-1', 'rule' => '%macros.port_usage_perc >= "80"', 'severity' => 'critical', 'extra' => '{"mute":false,"count":"-1","delay":"300"}', 'disabled' => 0, 'name' => 'Port utilisation over threshold'); + $default_rules[] = array('device_id' => '-1', 'rule' => '%sensors.sensor_current > %sensors.sensor_limit', 'severity' => 'critical', 'extra' => '{"mute":false,"count":"-1","delay":"300"}', 'disabled' => 0, 'name' => 'Sensor over limit'); + $default_rules[] = array('device_id' => '-1', 'rule' => '%sensors.sensor_current < %sensors.sensor_limit_low', 'severity' => 'critical', 'extra' => '{"mute":false,"count":"-1","delay":"300"}', 'disabled' => 0, 'name' => 'Sensor under limit'); + foreach( $default_rules as $add_rule ) { + dbInsert($add_rule,'alert_rules'); + } +} + +require_once('includes/modal/new_alert_rule.inc.php'); +require_once('includes/modal/delete_alert_rule.inc.php'); + ?>
    0) { + +if(isset($_POST['results_amount']) && $_POST['results_amount'] > 0) { $results = $_POST['results']; -} -else { +} else { $results = 50; } echo '
    - - +
    + @@ -103,150 +49,126 @@ echo '
    - '; + '; -echo ' - +'); -echo ''; - -$rulei = 1; -$count_query = 'SELECT COUNT(id)'; -$full_query = 'SELECT *'; -$sql = ''; -$param = array(); -if (isset($device['device_id']) && $device['device_id'] > 0) { - $sql = 'WHERE (device_id=? OR device_id="-1")'; +$rulei=1; +$count_query = "SELECT COUNT(id)"; +$full_query = "SELECT *"; +$sql = ''; +$param = array(); +if(isset($device['device_id']) && $device['device_id'] > 0) { + $sql = 'WHERE (device_id=? OR device_id="-1")'; $param = array($device['device_id']); } - -$query = " FROM alert_rules $sql ORDER BY device_id,id"; -$count_query = $count_query.$query; -$count = dbFetchCell($count_query, $param); -if (!isset($_POST['page_number']) && $_POST['page_number'] < 1) { +$query = " FROM alert_rules $sql ORDER BY device_id,id"; +$count_query = $count_query . $query; +$count = dbFetchCell($count_query,$param); +if(!isset($_POST['page_number']) && $_POST['page_number'] < 1) { $page_number = 1; -} -else { +} else { $page_number = $_POST['page_number']; } +$start = ($page_number - 1) * $results; +$full_query = $full_query . $query . " LIMIT $start,$results"; -$start = (($page_number - 1) * $results); -$full_query = $full_query.$query." LIMIT $start,$results"; - -foreach (dbFetchRows($full_query, $param) as $rule) { - $sub = dbFetchRows('SELECT * FROM alerts WHERE rule_id = ? ORDER BY id DESC LIMIT 1', array($rule['id'])); - $ico = 'ok'; - $col = 'success'; - $extra = ''; - if (sizeof($sub) == 1) { - $sub = $sub[0]; - if ((int) $sub['state'] === 0) { - $ico = 'ok'; - $col = 'success'; +foreach( dbFetchRows($full_query, $param) as $rule ) { + $sub = dbFetchRows("SELECT * FROM alerts WHERE rule_id = ? ORDER BY id DESC LIMIT 1", array($rule['id'])); + $ico = "ok"; + $col = "success"; + $extra = ""; + if( sizeof($sub) == 1 ) { + $sub = $sub[0]; + if( (int) $sub['state'] === 0 ) { + $ico = "ok"; + $col = "success"; + } elseif( (int) $sub['state'] === 1 ) { + $ico = "remove"; + $col = "danger"; + $extra = "danger"; + } elseif( (int) $sub['state'] === 2 ) { + $ico = "time"; + $col = "default"; + $extra = "warning"; + } + } + $alert_checked = ''; + $orig_ico = $ico; + $orig_col = $col; + $orig_class = $extra; + if( $rule['disabled'] ) { + $ico = "pause"; + $col = ""; + $extra = "active"; + } else { + $alert_checked = 'checked'; } - else if ((int) $sub['state'] === 1) { - $ico = 'remove'; - $col = 'danger'; - $extra = 'danger'; + $rule_extra = json_decode($rule['extra'],TRUE); + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; } - } - - $alert_checked = ''; - $orig_ico = $ico; - $orig_col = $col; - $orig_class = $extra; - if ($rule['disabled']) { - $ico = 'pause'; - $col = ''; - $extra = 'active'; - } - else { - $alert_checked = 'checked'; - } - - $rule_extra = json_decode($rule['extra'], true); - echo ""; - echo ''; - echo ''; - echo "'; - echo ''; - echo ""; - } - - echo ''; - echo ''; - echo ''; - echo "\r\n"; -}//end foreach - -if (($count % $results) > 0) { - echo ' - - '; + echo ""; + echo ""; + echo ""; + echo "\r\n"; } +if($count % $results > 0) { + echo(' + + '); +} echo '
    # Name RuleExtra Enabled Action
    '; +echo (''); if ($_SESSION['userlevel'] >= '10') { - echo ''; + echo(''); } - -echo '
    #".((int) $rulei++)."".$rule['name'].""; + if($rule_extra['invert'] === true) { + echo "Inverted "; } - else if ((int) $sub['state'] === 2) { - $ico = 'time'; - $col = 'default'; - $extra = 'warning'; + echo "".htmlentities($rule['rule'])."".$rule['severity']." "; + if($rule_extra['mute'] === true) { + echo "
    #'.((int) $rulei++).''.$rule['name'].'"; - if ($rule_extra['invert'] === true) { - echo 'Inverted '; - } - - echo ''.htmlentities($rule['rule']).''.$rule['severity'].' "; - if ($rule_extra['mute'] === true) { - echo "Max: '.$rule_extra['count'].'
    Delay: '.$rule_extra['delay'].'
    Interval: '.$rule_extra['interval'].'
    '; - if ($_SESSION['userlevel'] >= '10') { - echo ""; - } - - echo ''; - if ($_SESSION['userlevel'] >= '10') { - echo " "; - echo ""; - } - - echo '
    '.generate_pagination($count, $results, $page_number).'
    Max: ".$rule_extra['count']."
    Delay: ".$rule_extra['delay']."
    Interval: ".$rule_extra['interval']."
    "; + if ($_SESSION['userlevel'] >= '10') { + echo ""; + } + echo ""; + if ($_SESSION['userlevel'] >= '10') { + echo " "; + echo ""; + } + echo "
    '. generate_pagination($count,$results,$page_number) .'
    - - - -
    '; + + + +
    '; -if ($count < 1) { +if($count < 1) { if ($_SESSION['userlevel'] >= '10') { echo '
    -
    -
    -

    - -

    -
    -
    -
    '; +
    +
    +

    + +

    +
    +
    +
    '; } } @@ -258,19 +180,19 @@ $('#ack-alert').click('', function(e) { var alert_id = $(this).data("alert_id"); $.ajax({ type: "POST", - url: "/ajax_form.php", - data: { type: "ack-alert", alert_id: alert_id }, - success: function(msg){ - $("#message").html('
    '+msg+'
    '); - if(msg.indexOf("ERROR:") <= -1) { - setTimeout(function() { - location.reload(1); - }, 1000); - } - }, - error: function(){ - $("#message").html('
    An error occurred acking this alert.
    '); - } + url: "/ajax_form.php", + data: { type: "ack-alert", alert_id: alert_id }, + success: function(msg){ + $("#message").html('
    '+msg+'
    '); + if(msg.indexOf("ERROR:") <= -1) { + setTimeout(function() { + location.reload(1); + }, 1000); + } + }, + error: function(){ + $("#message").html('
    An error occurred acking this alert.
    '); + } }); }); @@ -284,42 +206,42 @@ $('input[name="alert-rule"]').on('switchChange.bootstrapSwitch', function(event var orig_class = $(this).data("orig_class"); $.ajax({ type: 'POST', - url: '/ajax_form.php', - data: { type: "update-alert-rule", alert_id: alert_id, state: state }, - dataType: "html", - success: function(msg) { - if(msg.indexOf("ERROR:") <= -1) { - if(state) { - $('#alert-rule-'+alert_id).removeClass('glyphicon-pause'); - $('#alert-rule-'+alert_id).addClass('glyphicon-'+orig_state); - $('#alert-rule-'+alert_id).removeClass('text-default'); - $('#alert-rule-'+alert_id).addClass('text-'+orig_colour); - $('#row_'+alert_id).removeClass('active'); - $('#row_'+alert_id).addClass(orig_class); - } else { - $('#alert-rule-'+alert_id).removeClass('glyphicon-'+orig_state); - $('#alert-rule-'+alert_id).addClass('glyphicon-pause'); - $('#alert-rule-'+alert_id).removeClass('text-'+orig_colour); - $('#alert-rule-'+alert_id).addClass('text-default'); - $('#row_'+alert_id).removeClass('warning'); - $('#row_'+alert_id).addClass('active'); - } + url: '/ajax_form.php', + data: { type: "update-alert-rule", alert_id: alert_id, state: state }, + dataType: "html", + success: function(msg) { + if(msg.indexOf("ERROR:") <= -1) { + if(state) { + $('#alert-rule-'+alert_id).removeClass('glyphicon-pause'); + $('#alert-rule-'+alert_id).addClass('glyphicon-'+orig_state); + $('#alert-rule-'+alert_id).removeClass('text-default'); + $('#alert-rule-'+alert_id).addClass('text-'+orig_colour); + $('#row_'+alert_id).removeClass('active'); + $('#row_'+alert_id).addClass(orig_class); } else { - $("#message").html('
    '+msg+'
    '); - $('#'+alert_id).bootstrapSwitch('toggleState',true ); - } - }, - error: function() { - $("#message").html('
    This alert could not be updated.
    '); - $('#'+alert_id).bootstrapSwitch('toggleState',true ); + $('#alert-rule-'+alert_id).removeClass('glyphicon-'+orig_state); + $('#alert-rule-'+alert_id).addClass('glyphicon-pause'); + $('#alert-rule-'+alert_id).removeClass('text-'+orig_colour); + $('#alert-rule-'+alert_id).addClass('text-default'); + $('#row_'+alert_id).removeClass('warning'); + $('#row_'+alert_id).addClass('active'); } + } else { + $("#message").html('
    '+msg+'
    '); + $('#'+alert_id).bootstrapSwitch('toggleState',true ); + } + }, + error: function() { + $("#message").html('
    This alert could not be updated.
    '); + $('#'+alert_id).bootstrapSwitch('toggleState',true ); + } }); }); function updateResults(results) { - $('#results_amount').val(results.value); - $('#page_number').val(1); - $('#result_form').submit(); + $('#results_amount').val(results.value); + $('#page_number').val(1); + $('#result_form').submit(); } function changePage(page,e) { diff --git a/html/includes/print-alert-templates.php b/html/includes/print-alert-templates.php index 8ad6e8265d..16a3afdd08 100644 --- a/html/includes/print-alert-templates.php +++ b/html/includes/print-alert-templates.php @@ -1,6 +1,6 @@ @@ -10,17 +10,17 @@ $no_refresh = true;
    0) { +if (isset($_POST['results_amount']) && $_POST['results_amount'] > 0) { $results = $_POST['results']; -} else { +} +else { $results = 50; } @@ -34,37 +34,49 @@ echo '
    '; if ($_SESSION['userlevel'] >= '10') { - echo(''); + echo ''; } echo ' '); -$count_query = "SELECT COUNT(id)"; -$full_query = "SELECT *"; +echo ''; -$query = " FROM `alert_templates`"; +$count_query = 'SELECT COUNT(id)'; +$full_query = 'SELECT *'; -$count_query = $count_query . $query; -$count = dbFetchCell($count_query,$param); -if(!isset($_POST['page_number']) && $_POST['page_number'] < 1) { +$query = ' FROM `alert_templates`'; + +$count_query = $count_query.$query; +$count = dbFetchCell($count_query, $param); +if (!isset($_POST['page_number']) && $_POST['page_number'] < 1) { $page_number = 1; -} else { +} +else { $page_number = $_POST['page_number']; } -$start = ($page_number - 1) * $results; -$full_query = $full_query . $query . " LIMIT $start,$results"; -foreach( dbFetchRows($full_query, $param) as $template ) { +$start = (($page_number - 1) * $results); +$full_query = $full_query.$query." LIMIT $start,$results"; + +foreach (dbFetchRows($full_query, $param) as $template) { echo ' '.$template['name'].' '; @@ -73,14 +85,15 @@ foreach( dbFetchRows($full_query, $param) as $template ) { echo " "; echo ""; } + echo ' '; } -if($count % $results > 0) { - echo(' - '. generate_pagination($count,$results,$page_number) .' - '); +if (($count % $results) > 0) { + echo ' + '.generate_pagination($count, $results, $page_number).' + '; } echo ' diff --git a/html/includes/print-alerts.inc.php b/html/includes/print-alerts.inc.php index dcbab4b3d9..d9758a0f38 100644 --- a/html/includes/print-alerts.inc.php +++ b/html/includes/print-alerts.inc.php @@ -1,49 +1,49 @@ - - ' . $alert_entry['time_logged'] . ' - '); +echo ' + + '.$alert_entry['time_logged'].' + '; if (!isset($alert_entry['device'])) { - $dev = device_by_id_cache($alert_entry['device_id']); - echo(" - " . generate_device_link($dev, shorthost($dev['hostname'])) . " - "); + $dev = device_by_id_cache($alert_entry['device_id']); + echo ' + '.generate_device_link($dev, shorthost($dev['hostname'])).' + '; } -echo("".htmlspecialchars($alert_entry['name']) . ""); +echo ''.htmlspecialchars($alert_entry['name']).''; -if ($alert_state!='') { - if ($alert_state=='0') { - $glyph_icon = 'ok'; +if ($alert_state != '') { + if ($alert_state == '0') { + $glyph_icon = 'ok'; $glyph_color = 'green'; - $text = 'Ok'; + $text = 'Ok'; } - elseif ($alert_state=='1') { - $glyph_icon = 'remove'; + else if ($alert_state == '1') { + $glyph_icon = 'remove'; $glyph_color = 'red'; - $text = 'Alert'; + $text = 'Alert'; } - elseif ($alert_state=='2') { - $glyph_icon = 'info-sign'; + else if ($alert_state == '2') { + $glyph_icon = 'info-sign'; $glyph_color = 'lightgrey'; - $text = 'Ack'; + $text = 'Ack'; } - elseif ($alert_state=='3') { - $glyph_icon = 'arrow-down'; + else if ($alert_state == '3') { + $glyph_icon = 'arrow-down'; $glyph_color = 'orange'; - $text = 'Worse'; + $text = 'Worse'; } - elseif ($alert_state=='4') { - $glyph_icon = 'arrow-up'; + else if ($alert_state == '4') { + $glyph_icon = 'arrow-up'; $glyph_color = 'khaki'; - $text = 'Better'; - } - echo(" $text"); -} + $text = 'Better'; + }//end if + echo " $text"; +}//end if -echo(""); +echo ''; diff --git a/html/includes/print-debug.php b/html/includes/print-debug.php index f35cd05bfe..7fdbbcc6d9 100644 --- a/html/includes/print-debug.php +++ b/html/includes/print-debug.php @@ -1,6 +1,6 @@ @@ -14,25 +14,23 @@ @@ -52,26 +50,25 @@ foreach ($sql_debug as $sql_error) { @@ -97,10 +95,12 @@ if ($_SESSION['userlevel'] >= '10') { if (is_admin() === TRUE || is_read() === TRUE) { $sql = "SELECT `type`,COUNT(`type`) AS total_type FROM `devices` AS D WHERE 1 GROUP BY `type` ORDER BY `type`"; -} else { +} +else { $sql = "SELECT `type`,COUNT(`type`) AS total_type FROM `devices` AS `D`, `devices_perms` AS `P` WHERE `P`.`user_id` = ? AND `P`.`device_id` = `D`.`device_id` GROUP BY `type` ORDER BY `type`"; $param[] = $_SESSION['user_id']; } + foreach (dbFetchRows($sql,$param) as $devtype) { if (empty($devtype['type'])) { $devtype['type'] = 'generic'; @@ -108,9 +108,10 @@ foreach (dbFetchRows($sql,$param) as $devtype) { echo('
  • ' . ucfirst($devtype['type']) . '
  • '); } -require_once('../includes/device-groups.inc.php'); +require_once '../includes/device-groups.inc.php'; + foreach( GetDeviceGroups() as $group ) { - echo '
  • '.ucfirst($group['name']).'
  • '; + echo '
  • '.ucfirst($group['name']).'
  • '; } unset($group); @@ -118,29 +119,24 @@ unset($group); '); if ($_SESSION['userlevel'] >= '10') { -if ($config['show_locations']) -{ - - echo(' + if ($config['show_locations']) { + echo(' - '); -} - echo(' + '); + } + echo('
  • Manage Groups
  • Add Device
  • @@ -155,8 +151,7 @@ if ($config['show_locations'])
  • Alerts ('.$service_alerts.')
  • '); } -if ($_SESSION['userlevel'] >= '10') -{ - echo(' +if ($_SESSION['userlevel'] >= '10') { + echo('
  • Add Service
  • Edit Service
  • @@ -197,36 +190,53 @@ if ($_SESSION['userlevel'] >= '10') 0) -{ - echo('
  • Errored ('.$ports['errored'].')
  • '); +if ($ports['errored'] > 0) { + echo('
  • Errored ('.$ports['errored'].')
  • '); } -if ($ports['ignored'] > 0) -{ - echo('
  • Ignored ('.$ports['ignored'].')
  • '); +if ($ports['ignored'] > 0) { + echo('
  • Ignored ('.$ports['ignored'].')
  • '); } if ($config['enable_billing']) { - echo('
  • Traffic Bills
  • '); $ifbreak = 1; + echo('
  • Traffic Bills
  • '); + $ifbreak = 1; } if ($config['enable_pseudowires']) { - echo('
  • Pseudowires
  • '); $ifbreak = 1; + echo('
  • Pseudowires
  • '); + $ifbreak = 1; } ?> = '5') -{ - echo(' '); - if ($config['int_customers']) { echo('
  • Customers
  • '); $ifbreak = 1; } - if ($config['int_l2tp']) { echo('
  • L2TP
  • '); $ifbreak = 1; } - if ($config['int_transit']) { echo('
  • Transit
  • '); $ifbreak = 1; } - if ($config['int_peering']) { echo('
  • Peering
  • '); $ifbreak = 1; } - if ($config['int_peering'] && $config['int_transit']) { echo('
  • Peering + Transit
  • '); $ifbreak = 1; } - if ($config['int_core']) { echo('
  • Core
  • '); $ifbreak = 1; } +if ($_SESSION['userlevel'] >= '5') { + echo(' '); + if ($config['int_customers']) { + echo('
  • Customers
  • '); + $ifbreak = 1; + } + if ($config['int_l2tp']) { + echo('
  • L2TP
  • '); + $ifbreak = 1; + } + if ($config['int_transit']) { + echo('
  • Transit
  • '); + $ifbreak = 1; + } + if ($config['int_peering']) { + echo('
  • Peering
  • '); + $ifbreak = 1; + } + if ($config['int_peering'] && $config['int_transit']) { + echo('
  • Peering + Transit
  • '); + $ifbreak = 1; + } + if ($config['int_core']) { + echo('
  • Core
  • '); + $ifbreak = 1; + } if (is_array($config['custom_descr']) === FALSE) { $config['custom_descr'] = array($config['custom_descr']); } @@ -239,21 +249,18 @@ if ($_SESSION['userlevel'] >= '5') } if ($ifbreak) { - echo(' '); + echo(' '); } -if (isset($interface_alerts)) -{ - echo('
  • Alerts ('.$interface_alerts.')
  • '); +if (isset($interface_alerts)) { + echo('
  • Alerts ('.$interface_alerts.')
  • '); } $deleted_ports = 0; -foreach (dbFetchRows("SELECT * FROM `ports` AS P, `devices` as D WHERE P.`deleted` = '1' AND D.device_id = P.device_id") as $interface) -{ - if (port_permitted($interface['port_id'], $interface['device_id'])) - { - $deleted_ports++; - } +foreach (dbFetchRows("SELECT * FROM `ports` AS P, `devices` as D WHERE P.`deleted` = '1' AND D.device_id = P.device_id") as $interface) { + if (port_permitted($interface['port_id'], $interface['device_id'])) { + $deleted_ports++; + } } ?> @@ -261,7 +268,9 @@ foreach (dbFetchRows("SELECT * FROM `ports` AS P, `devices` as D WHERE P.`delete
  • Disabled
  • Deleted ('.$deleted_ports.')'); } +if ($deleted_ports) { + echo('
  • Deleted ('.$deleted_ports.')
  • '); +} ?> @@ -270,9 +279,8 @@ if ($deleted_ports) { echo('
  • Processor
  • Storage
  • '); +if ($menu_sensors) { + $sep = 0; + echo(' '); } $icons = array('fanspeed'=>'tachometer','humidity'=>'tint','temperature'=>'fire','current'=>'bolt','frequency'=>'line-chart','power'=>'power-off','voltage'=>'bolt','charge'=>'plus-square','dbm'=>'sun-o', 'load'=>'spinner','state'=>'bullseye'); -foreach (array('fanspeed','humidity','temperature') as $item) -{ - if (isset($menu_sensors[$item])) - { +foreach (array('fanspeed','humidity','temperature') as $item) { + if (isset($menu_sensors[$item])) { + echo('
  • '.nicecase($item).'
  • '); + unset($menu_sensors[$item]);$sep++; + } +} + +if ($sep && array_keys($menu_sensors)) { + echo(' '); + $sep = 0; +} + +foreach (array('current','frequency','power','voltage') as $item) { + if (isset($menu_sensors[$item])) { + echo('
  • '.nicecase($item).'
  • '); + unset($menu_sensors[$item]);$sep++; + } +} + +if ($sep && array_keys($menu_sensors)) { + echo(' '); + $sep = 0; +} + +foreach (array_keys($menu_sensors) as $item) { echo('
  • '.nicecase($item).'
  • '); unset($menu_sensors[$item]);$sep++; - } -} - -if ($sep && array_keys($menu_sensors)) -{ - echo(' '); - $sep = 0; -} - -foreach (array('current','frequency','power','voltage') as $item) -{ - if (isset($menu_sensors[$item])) - { - echo('
  • '.nicecase($item).'
  • '); - unset($menu_sensors[$item]);$sep++; - } -} - -if ($sep && array_keys($menu_sensors)) -{ - echo(' '); - $sep = 0; -} - -foreach (array_keys($menu_sensors) as $item) -{ - echo('
  • '.nicecase($item).'
  • '); - unset($menu_sensors[$item]);$sep++; } ?> @@ -337,27 +337,24 @@ foreach (array_keys($menu_sensors) as $item) $app_count = dbFetchCell("SELECT COUNT(`app_id`) FROM `applications`"); -if ($_SESSION['userlevel'] >= '5' && ($app_count) > "0") -{ +if ($_SESSION['userlevel'] >= '5' && ($app_count) > "0") { ?> + = '5' && ($routing_count['bgp']+$routing_count['ospf']+$routing_count['cef']+$routing_count['vrf']) > "0") -{ +if ($_SESSION['userlevel'] >= '5' && ($routing_count['bgp']+$routing_count['ospf']+$routing_count['cef']+$routing_count['vrf']) > "0") { ?> @@ -440,16 +427,11 @@ if ( dbFetchCell("SELECT 1 from `packages` LIMIT 1") ) { = '10') -{ - if (dbFetchCell("SELECT COUNT(*) from `plugins` WHERE plugin_active = '1'") > 0) { - echo(' - - '); - } - echo(' -
  • Plugin Admin
  • - '); +if ($_SESSION['userlevel'] >= '10') { + if (dbFetchCell("SELECT COUNT(*) from `plugins` WHERE plugin_active = '1'") > 0) { + echo(''); + } + echo('
  • Plugin Admin
  • '); } ?> @@ -457,9 +439,8 @@ if ($_SESSION['userlevel'] >= '10') @@ -476,50 +457,42 @@ if(is_file("includes/print-menubar-custom.inc.php"))
    -"); \ No newline at end of file +"; diff --git a/html/includes/print-service-edit.inc.php b/html/includes/print-service-edit.inc.php index 0954649d6d..d0ad23a569 100644 --- a/html/includes/print-service-edit.inc.php +++ b/html/includes/print-service-edit.inc.php @@ -1,35 +1,33 @@ Edit Service
    - - + +
    - +
    - +
    - +
    -
    "); - -} \ No newline at end of file +"; +}//end if diff --git a/html/includes/print-syslog.inc.php b/html/includes/print-syslog.inc.php index 09467dd7c4..1a7564920d 100644 --- a/html/includes/print-syslog.inc.php +++ b/html/includes/print-syslog.inc.php @@ -1,23 +1,18 @@ "); +if (device_permitted($entry['device_id'])) { + echo ''; - // Stop shortening hostname. Issue #61 - //$entry['hostname'] = shorthost($entry['hostname'], 20); - - if ($vars['page'] != "device") - { - echo("" . $entry['date'] . ""); - echo("".generate_device_link($entry).""); - echo("" . $entry['program'] . " : " . htmlspecialchars($entry['msg']) . ""); - } else { - echo("" . $entry['date'] . "   " . $entry['program'] . "   " . htmlspecialchars($entry['msg']) . ""); - } - - echo(""); + // Stop shortening hostname. Issue #61 + // $entry['hostname'] = shorthost($entry['hostname'], 20); + if ($vars['page'] != 'device') { + echo ''.$entry['date'].''; + echo ''.generate_device_link($entry).''; + echo ''.$entry['program'].' : '.htmlspecialchars($entry['msg']).''; + } + else { + echo ''.$entry['date'].'   '.$entry['program'].'   '.htmlspecialchars($entry['msg']).''; + } + echo ''; } - -?> diff --git a/html/includes/reports/alert-log.pdf.inc.php b/html/includes/reports/alert-log.pdf.inc.php index 5ee0e91ea1..d293b474b9 100644 --- a/html/includes/reports/alert-log.pdf.inc.php +++ b/html/includes/reports/alert-log.pdf.inc.php @@ -1,65 +1,83 @@ AddPage('L'); +$where = '1'; +if (is_numeric($_GET['device_id'])) { + $where .= ' AND E.device_id = ?'; + $param[] = $_GET['device_id']; +} - $where = "1"; - if (is_numeric($_GET['device_id'])) { - $where .= ' AND E.device_id = ?'; - $param[] = $_GET['device_id']; - } - if ($_GET['string']) { - $where .= " AND R.rule LIKE ?"; - $param[] = "%".$_GET['string']."%"; - } +if ($_GET['string']) { + $where .= ' AND R.rule LIKE ?'; + $param[] = '%'.$_GET['string'].'%'; +} - if ($_SESSION['userlevel'] >= '5') { - $query = " FROM `alert_log` AS E LEFT JOIN devices AS D ON E.device_id=D.device_id RIGHT JOIN alert_rules AS R ON E.rule_id=R.id WHERE $where ORDER BY `humandate` DESC"; - } else { - $query = " FROM `alert_log` AS E LEFT JOIN devices AS D ON E.device_id=D.device_id RIGHT JOIN alert_rules AS R ON E.rule_id=R.id RIGHT JOIN devices_perms AS P ON E.device_id = P.device_id WHERE $where AND P.user_id = ? ORDER BY `humandate` DESC"; - $param[] = $_SESSION['user_id']; - } +if ($_SESSION['userlevel'] >= '5') { + $query = " FROM `alert_log` AS E LEFT JOIN devices AS D ON E.device_id=D.device_id RIGHT JOIN alert_rules AS R ON E.rule_id=R.id WHERE $where ORDER BY `humandate` DESC"; +} +else { + $query = " FROM `alert_log` AS E LEFT JOIN devices AS D ON E.device_id=D.device_id RIGHT JOIN alert_rules AS R ON E.rule_id=R.id RIGHT JOIN devices_perms AS P ON E.device_id = P.device_id WHERE $where AND P.user_id = ? ORDER BY `humandate` DESC"; + $param[] = $_SESSION['user_id']; +} - if (isset($_GET['start']) && is_numeric($_GET['start'])) { - $start = mres($_GET['start']); - } else { - $start = 0; - } +if (isset($_GET['start']) && is_numeric($_GET['start'])) { + $start = mres($_GET['start']); +} +else { + $start = 0; +} - if (isset($_GET['results']) && is_numeric($_GET['results'])) { - $numresults = mres($_GET['results']); - } else { - $numresults = 250; - } +if (isset($_GET['results']) && is_numeric($_GET['results'])) { + $numresults = mres($_GET['results']); +} +else { + $numresults = 250; +} - $full_query = "SELECT D.device_id,name,state,time_logged,DATE_FORMAT(time_logged, '".$config['dateformat']['mysql']['compact']."') as humandate $query LIMIT $start,$numresults"; +$full_query = "SELECT D.device_id,name,state,time_logged,DATE_FORMAT(time_logged, '".$config['dateformat']['mysql']['compact']."') as humandate $query LIMIT $start,$numresults"; - foreach (dbFetchRows($full_query, $param) as $alert_entry) { - $hostname = gethostbyid(mres($alert_entry['device_id'])); - $alert_state = $alert_entry['state']; +foreach (dbFetchRows($full_query, $param) as $alert_entry) { + $hostname = gethostbyid(mres($alert_entry['device_id'])); + $alert_state = $alert_entry['state']; - if ($alert_state!='') { - if ($alert_state=='0') { - $glyph_color = 'green'; - $text = 'Ok'; - } elseif ($alert_state=='1') { - $glyph_color = 'red'; - $text = 'Alert'; - } elseif ($alert_state=='2') { - $glyph_color = 'lightgrey'; - $text = 'Ack'; - } elseif ($alert_state=='3') { - $glyph_color = 'orange'; - $text = 'Worse'; - } elseif ($alert_state=='4') { - $glyph_color = 'khaki'; - $text = 'Better'; - } - $data[] = array($alert_entry['time_logged'],$hostname,htmlspecialchars($alert_entry['name']),$text); + if ($alert_state != '') { + if ($alert_state == '0') { + $glyph_color = 'green'; + $text = 'Ok'; + } + else if ($alert_state == '1') { + $glyph_color = 'red'; + $text = 'Alert'; + } + else if ($alert_state == '2') { + $glyph_color = 'lightgrey'; + $text = 'Ack'; + } + else if ($alert_state == '3') { + $glyph_color = 'orange'; + $text = 'Worse'; + } + else if ($alert_state == '4') { + $glyph_color = 'khaki'; + $text = 'Better'; } - } -$header = array('Datetime', 'Device', 'Log', 'Status'); + $data[] = array( + $alert_entry['time_logged'], + $hostname, + htmlspecialchars($alert_entry['name']), + $text, + ); + }//end if +}//end foreach + +$header = array( + 'Datetime', + 'Device', + 'Log', + 'Status', +); $table = << @@ -74,17 +92,19 @@ EOD; foreach ($data as $log) { if ($log[3] == 'Alert') { $tr_col = '#d39392'; - } else { + } + else { $tr_col = '#bbd392'; } + $table .= ' - + '.$log[0].' '.$log[1].' '.$log[2].' '.$log[3].' - - '; + + '; } $table .= << $value) -{ - if ($value != "") - { - switch ($var) - { - case 'hostname': - $where .= " AND D.hostname LIKE ?"; - $param[] = "%".$value."%"; - break; - case 'location': - $where .= " AND D.location LIKE ?"; - $param[] = "%".$value."%"; - break; - case 'device_id': - $where .= " AND D.device_id = ?"; - $param[] = $value; - break; - case 'deleted': - case 'ignore': - if ($value == 1) - { - $where .= " AND (I.ignore = 1 OR D.ignore = 1) AND I.deleted = 0"; - } - break; - case 'disable': - case 'ifSpeed': - if (is_numeric($value)) - { - $where .= " AND I.$var = ?"; - $param[] = $value; - } - break; - case 'ifType': - $where .= " AND I.$var = ?"; - $param[] = $value; - break; - case 'ifAlias': - case 'port_descr_type': - $where .= " AND I.$var LIKE ?"; - $param[] = "%".$value."%"; - break; - case 'errors': - if ($value == 1) - { - $where .= " AND (I.`ifInErrors_delta` > '0' OR I.`ifOutErrors_delta` > '0')"; - } - break; - case 'state': - if ($value == "down") - { - $where .= "AND I.ifAdminStatus = ? AND I.ifOperStatus = ?"; - $param[] = "up"; - $param[] = "down"; - } elseif($value == "up") { - $where .= "AND I.ifAdminStatus = ? AND I.ifOperStatus = ? AND I.ignore = '0' AND D.ignore='0' AND I.deleted='0'"; - $param[] = "up"; - $param[] = "up"; - } elseif($value == "admindown") { - $where .= "AND I.ifAdminStatus = ? AND D.ignore = 0"; - $param[] = "down"; - } - break; - } - } -} +foreach ($vars as $var => $value) { + if ($value != '') { + switch ($var) { + case 'hostname': + $where .= ' AND D.hostname LIKE ?'; + $param[] = '%'.$value.'%'; + break; -$query = "SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id ".$where." ".$query_sort; + case 'location': + $where .= ' AND D.location LIKE ?'; + $param[] = '%'.$value.'%'; + break; + + case 'device_id': + $where .= ' AND D.device_id = ?'; + $param[] = $value; + break; + + case 'deleted': + case 'ignore': + if ($value == 1) { + $where .= ' AND (I.ignore = 1 OR D.ignore = 1) AND I.deleted = 0'; + } + break; + + case 'disable': + case 'ifSpeed': + if (is_numeric($value)) { + $where .= " AND I.$var = ?"; + $param[] = $value; + } + break; + + case 'ifType': + $where .= " AND I.$var = ?"; + $param[] = $value; + break; + + case 'ifAlias': + case 'port_descr_type': + $where .= " AND I.$var LIKE ?"; + $param[] = '%'.$value.'%'; + break; + + case 'errors': + if ($value == 1) { + $where .= " AND (I.`ifInErrors_delta` > '0' OR I.`ifOutErrors_delta` > '0')"; + } + break; + + case 'state': + if ($value == 'down') { + $where .= 'AND I.ifAdminStatus = ? AND I.ifOperStatus = ?'; + $param[] = 'up'; + $param[] = 'down'; + } + else if ($value == 'up') { + $where .= "AND I.ifAdminStatus = ? AND I.ifOperStatus = ? AND I.ignore = '0' AND D.ignore='0' AND I.deleted='0'"; + $param[] = 'up'; + $param[] = 'up'; + } + else if ($value == 'admindown') { + $where .= 'AND I.ifAdminStatus = ? AND D.ignore = 0'; + $param[] = 'down'; + } + break; + }//end switch + }//end if +}//end foreach + +$query = 'SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id '.$where.' '.$query_sort; $row = 1; -list($format, $subformat) = explode("_", $vars['format']); +list($format, $subformat) = explode('_', $vars['format']); $ports = dbFetchRows($query, $param); -switch ($vars['sort']) -{ - case 'traffic': +switch ($vars['sort']) { +case 'traffic': $ports = array_sort($ports, 'ifOctets_rate', SORT_DESC); break; - case 'traffic_in': + +case 'traffic_in': $ports = array_sort($ports, 'ifInOctets_rate', SORT_DESC); break; - case 'traffic_out': + +case 'traffic_out': $ports = array_sort($ports, 'ifOutOctets_rate', SORT_DESC); break; - case 'packets': + +case 'packets': $ports = array_sort($ports, 'ifUcastPkts_rate', SORT_DESC); break; - case 'packets_in': + +case 'packets_in': $ports = array_sort($ports, 'ifInUcastOctets_rate', SORT_DESC); break; - case 'packets_out': + +case 'packets_out': $ports = array_sort($ports, 'ifOutUcastOctets_rate', SORT_DESC); break; - case 'errors': + +case 'errors': $ports = array_sort($ports, 'ifErrors_rate', SORT_DESC); break; - case 'speed': + +case 'speed': $ports = array_sort($ports, 'ifSpeed', SORT_DESC); break; - case 'port': + +case 'port': $ports = array_sort($ports, 'ifDescr', SORT_ASC); break; - case 'media': + +case 'media': $ports = array_sort($ports, 'ifType', SORT_ASC); break; - case 'descr': + +case 'descr': $ports = array_sort($ports, 'ifAlias', SORT_ASC); break; - case 'device': - default: - $ports = array_sort($ports, 'hostname', SORT_ASC); -} -$csv[] = array('Device','Port','Speed','Down','Up','Media','Description'); -foreach( $ports as $port ) { - if( port_permitted($port['port_id'], $port['device_id']) ) { - $speed = humanspeed($port['ifSpeed']); - $type = humanmedia($port['ifType']); - $port['in_rate'] = formatRates($port['ifInOctets_rate'] * 8); - $port['out_rate'] = formatRates($port['ifOutOctets_rate'] * 8); - $port = ifLabel($port, $device); - $csv[] = array($port['hostname'],fixIfName($port['label']),$speed,$port['in_rate'],$port['out_rate'],$type,$port['ifAlias']); - } +case 'device': +default: + $ports = array_sort($ports, 'hostname', SORT_ASC); +}//end switch + +$csv[] = array( + 'Device', + 'Port', + 'Speed', + 'Down', + 'Up', + 'Media', + 'Description', +); +foreach ($ports as $port) { + if (port_permitted($port['port_id'], $port['device_id'])) { + $speed = humanspeed($port['ifSpeed']); + $type = humanmedia($port['ifType']); + $port['in_rate'] = formatRates(($port['ifInOctets_rate'] * 8)); + $port['out_rate'] = formatRates(($port['ifOutOctets_rate'] * 8)); + $port = ifLabel($port, $device); + $csv[] = array( + $port['hostname'], + fixIfName($port['label']), + $speed, + $port['in_rate'], + $port['out_rate'], + $type, + $port['ifAlias'], + ); + } } -?> diff --git a/html/includes/service-add.inc.php b/html/includes/service-add.inc.php index 3bc9eca630..cf1433b274 100644 --- a/html/includes/service-add.inc.php +++ b/html/includes/service-add.inc.php @@ -5,6 +5,6 @@ $updated = '1'; $service_id = add_service(mres($_POST['device']), mres($_POST['type']), mres($_POST['descr']), mres($_POST['ip']), mres($_POST['params'])); if ($service_id) { - $message .= $message_break . "Service added (".$service_id.")!"; - $message_break .= "
    "; -} \ No newline at end of file + $message .= $message_break.'Service added ('.$service_id.')!'; + $message_break .= '
    '; +} diff --git a/html/includes/table/address-search.inc.php b/html/includes/table/address-search.inc.php index a50d06afc7..25eb75360e 100644 --- a/html/includes/table/address-search.inc.php +++ b/html/includes/table/address-search.inc.php @@ -2,56 +2,64 @@ $param = array(); -if (is_admin() === FALSE && is_read() === FALSE) { - $perms_sql .= " LEFT JOIN `devices_perms` AS `DP` ON `D`.`device_id` = `DP`.`device_id`"; - $where .= " AND `DP`.`user_id`=?"; - $param[] = array($_SESSION['user_id']); +if (is_admin() === false && is_read() === false) { + $perms_sql .= ' LEFT JOIN `devices_perms` AS `DP` ON `D`.`device_id` = `DP`.`device_id`'; + $where .= ' AND `DP`.`user_id`=?'; + $param[] = array($_SESSION['user_id']); } -list($address,$prefix) = explode("/", $_POST['address']); +list($address,$prefix) = explode('/', $_POST['address']); if ($_POST['search_type'] == 'ipv4') { - $sql = " FROM `ipv4_addresses` AS A, `ports` AS I, `ipv4_networks` AS N, `devices` AS D"; + $sql = ' FROM `ipv4_addresses` AS A, `ports` AS I, `ipv4_networks` AS N, `devices` AS D'; $sql .= $perms_sql; $sql .= " WHERE I.port_id = A.port_id AND I.device_id = D.device_id AND N.ipv4_network_id = A.ipv4_network_id $where "; if (!empty($address)) { $sql .= " AND ipv4_address LIKE '%".$address."%'"; } + if (!empty($prefix)) { - $sql .= " AND ipv4_prefixlen='?'"; + $sql .= " AND ipv4_prefixlen='?'"; $param[] = array($prefix); } -} elseif ($_POST['search_type'] == 'ipv6') { - $sql = " FROM `ipv6_addresses` AS A, `ports` AS I, `ipv6_networks` AS N, `devices` AS D"; +} +else if ($_POST['search_type'] == 'ipv6') { + $sql = ' FROM `ipv6_addresses` AS A, `ports` AS I, `ipv6_networks` AS N, `devices` AS D'; $sql .= $perms_sql; $sql .= " WHERE I.port_id = A.port_id AND I.device_id = D.device_id AND N.ipv6_network_id = A.ipv6_network_id $where "; if (!empty($address)) { $sql .= " AND (ipv6_address LIKE '%".$address."%' OR ipv6_compressed LIKE '%".$address."%')"; } + if (!empty($prefix)) { $sql .= " AND ipv6_prefixlen = '$prefix'"; } -} elseif ($_POST['search_type'] == 'mac') { - $sql = " FROM `ports` AS I, `devices` AS D"; - $sql .= $perms_sql; - $sql .= " WHERE I.device_id = D.device_id AND `ifPhysAddress` LIKE '%".str_replace(array(':', ' ', '-', '.', '0x'),'',mres($_POST['address']))."%' $where "; } +else if ($_POST['search_type'] == 'mac') { + $sql = ' FROM `ports` AS I, `devices` AS D'; + $sql .= $perms_sql; + $sql .= " WHERE I.device_id = D.device_id AND `ifPhysAddress` LIKE '%".str_replace(array(':', ' ', '-', '.', '0x'), '', mres($_POST['address']))."%' $where "; +}//end if if (is_numeric($_POST['device_id'])) { - $sql .= " AND I.device_id = ?"; + $sql .= ' AND I.device_id = ?'; $param[] = array($_POST['device_id']); } + if ($_POST['interface']) { - $sql .= " AND I.ifDescr LIKE '?'"; + $sql .= " AND I.ifDescr LIKE '?'"; $param[] = array($_POST['interface']); } if ($_POST['search_type'] == 'ipv4') { $count_sql = "SELECT COUNT(`ipv4_address_id`) $sql"; -} elseif ($_POST['search_type'] == 'ipv6') { - $count_sql = "SELECT COUNT(`ipv6_address_id`) $sql"; -} elseif ($_POST['search_type'] == 'mac') { - $count_sql = "SELECT COUNT(`port_id`) $sql"; } -$total = dbFetchCell($count_sql,$param); +else if ($_POST['search_type'] == 'ipv6') { + $count_sql = "SELECT COUNT(`ipv6_address_id`) $sql"; +} +else if ($_POST['search_type'] == 'mac') { + $count_sql = "SELECT COUNT(`port_id`) $sql"; +} + +$total = dbFetchCell($count_sql, $param); if (empty($total)) { $total = 0; } @@ -63,7 +71,7 @@ if (!isset($sort) || empty($sort)) { $sql .= " ORDER BY $sort"; if (isset($current)) { - $limit_low = ($current * $rowCount) - ($rowCount); + $limit_low = (($current * $rowCount) - ($rowCount)); $limit_high = $rowCount; } @@ -75,31 +83,42 @@ $sql = "SELECT *,`I`.`ifDescr` AS `interface` $sql"; foreach (dbFetchRows($sql, $param) as $interface) { $speed = humanspeed($interface['ifSpeed']); - $type = humanmedia($interface['ifType']); + $type = humanmedia($interface['ifType']); if ($_POST['search_type'] == 'ipv6') { - list($prefix, $length) = explode("/", $interface['ipv6_network']); - $address = Net_IPv6::compress($interface['ipv6_address']) . '/'.$length; - } elseif ($_POST['search_type'] == 'mac') { + list($prefix, $length) = explode('/', $interface['ipv6_network']); + $address = Net_IPv6::compress($interface['ipv6_address']).'/'.$length; + } + else if ($_POST['search_type'] == 'mac') { $address = formatMac($interface['ifPhysAddress']); - } else { - list($prefix, $length) = explode("/", $interface['ipv4_network']); - $address = $interface['ipv4_address'] . '/' .$length; + } + else { + list($prefix, $length) = explode('/', $interface['ipv4_network']); + $address = $interface['ipv4_address'].'/'.$length; } if ($interface['in_errors'] > 0 || $interface['out_errors'] > 0) { - $error_img = generate_port_link($interface,"Interface Errors",errors); - } else { - $error_img = ""; + $error_img = generate_port_link($interface, "Interface Errors", errors); } - if (port_permitted($interface['port_id'])) { - $interface = ifLabel ($interface, $interface); - $response[] = array('hostname'=>generate_device_link($interface), - 'interface'=>generate_port_link($interface) . ' ' . $error_img, - 'address'=>$address, - 'description'=>$interface['ifAlias']); + else { + $error_img = ''; } -} -$output = array('current'=>$current,'rowCount'=>$rowCount,'rows'=>$response,'total'=>$total); + if (port_permitted($interface['port_id'])) { + $interface = ifLabel($interface, $interface); + $response[] = array( + 'hostname' => generate_device_link($interface), + 'interface' => generate_port_link($interface).' '.$error_img, + 'address' => $address, + 'description' => $interface['ifAlias'], + ); + } +}//end foreach + +$output = array( + 'current' => $current, + 'rowCount' => $rowCount, + 'rows' => $response, + 'total' => $total, +); echo _json_encode($output); diff --git a/html/includes/table/alert-schedule.inc.php b/html/includes/table/alert-schedule.inc.php index 635e67be92..5d2bfa9b89 100644 --- a/html/includes/table/alert-schedule.inc.php +++ b/html/includes/table/alert-schedule.inc.php @@ -16,8 +16,9 @@ $where = 1; if ($_SESSION['userlevel'] >= '5') { $sql = " FROM `alert_schedule` AS S WHERE $where"; -} else { - $sql = " FROM `alert_schedule` AS S WHERE $where"; +} +else { + $sql = " FROM `alert_schedule` AS S WHERE $where"; $param[] = $_SESSION['user_id']; } @@ -26,7 +27,7 @@ if (isset($searchPhrase) && !empty($searchPhrase)) { } $count_sql = "SELECT COUNT(`id`) $sql"; -$total = dbFetchCell($count_sql,$param); +$total = dbFetchCell($count_sql, $param); if (empty($total)) { $total = 0; } @@ -38,7 +39,7 @@ if (!isset($sort) || empty($sort)) { $sql .= " ORDER BY $sort"; if (isset($current)) { - $limit_low = ($current * $rowCount) - ($rowCount); + $limit_low = (($current * $rowCount) - ($rowCount)); $limit_high = $rowCount; } @@ -48,20 +49,29 @@ if ($rowCount != -1) { $sql = "SELECT `S`.`schedule_id`, DATE_FORMAT(`S`.`start`, '".$config['dateformat']['mysql']['compact']."') AS `start`, DATE_FORMAT(`S`.`end`, '".$config['dateformat']['mysql']['compact']."') AS `end`, `S`.`title` $sql"; -foreach (dbFetchRows($sql,$param) as $schedule) { +foreach (dbFetchRows($sql, $param) as $schedule) { $status = 0; if ($schedule['end'] < date('dS M Y H:i::s')) { $status = 1; } + if (date('dS M Y H:i::s') >= $schedule['start'] && date('dS M Y H:i::s') < $schedule['end']) { $status = 2; } - $response[] = array('title'=>$schedule['title'], - 'start'=>$schedule['start'], - 'end'=>$schedule['end'], - 'id'=>$schedule['schedule_id'], - 'status'=>$status); + + $response[] = array( + 'title' => $schedule['title'], + 'start' => $schedule['start'], + 'end' => $schedule['end'], + 'id' => $schedule['schedule_id'], + 'status' => $status, + ); } -$output = array('current'=>$current,'rowCount'=>$rowCount,'rows'=>$response,'total'=>$total); +$output = array( + 'current' => $current, + 'rowCount' => $rowCount, + 'rows' => $response, + 'total' => $total, +); echo _json_encode($output); diff --git a/html/includes/table/alertlog.inc.php b/html/includes/table/alertlog.inc.php index 0c8e515e62..8b4d94d3e2 100644 --- a/html/includes/table/alertlog.inc.php +++ b/html/includes/table/alertlog.inc.php @@ -3,14 +3,15 @@ $where = 1; if (is_numeric($_POST['device_id'])) { - $where .= ' AND E.device_id = ?'; + $where .= ' AND E.device_id = ?'; $param[] = $_POST['device_id']; } if ($_SESSION['userlevel'] >= '5') { $sql = " FROM `alert_log` AS E LEFT JOIN devices AS D ON E.device_id=D.device_id RIGHT JOIN alert_rules AS R ON E.rule_id=R.id WHERE $where"; -} else { - $sql = " FROM `alert_log` AS E LEFT JOIN devices AS D ON E.device_id=D.device_id RIGHT JOIN alert_rules AS R ON E.rule_id=R.id RIGHT JOIN devices_perms AS P ON E.device_id = P.device_id WHERE $where AND P.user_id = ?"; +} +else { + $sql = " FROM `alert_log` AS E LEFT JOIN devices AS D ON E.device_id=D.device_id RIGHT JOIN alert_rules AS R ON E.rule_id=R.id RIGHT JOIN devices_perms AS P ON E.device_id = P.device_id WHERE $where AND P.user_id = ?"; $param[] = array($_SESSION['user_id']); } @@ -19,7 +20,7 @@ if (isset($searchPhrase) && !empty($searchPhrase)) { } $count_sql = "SELECT COUNT(`E`.`id`) $sql"; -$total = dbFetchCell($count_sql,$param); +$total = dbFetchCell($count_sql, $param); if (empty($total)) { $total = 0; } @@ -31,7 +32,7 @@ if (!isset($sort) || empty($sort)) { $sql .= " ORDER BY $sort"; if (isset($current)) { - $limit_low = ($current * $rowCount) - ($rowCount); + $limit_low = (($current * $rowCount) - ($rowCount)); $limit_high = $rowCount; } @@ -42,42 +43,49 @@ if ($rowCount != -1) { $sql = "SELECT D.device_id,name AS alert,state,time_logged,DATE_FORMAT(time_logged, '".$config['dateformat']['mysql']['compact']."') as humandate,details $sql"; $rulei = 0; -foreach (dbFetchRows($sql,$param) as $alertlog) { - $dev = device_by_id_cache($alertlog['device_id']); +foreach (dbFetchRows($sql, $param) as $alertlog) { + $dev = device_by_id_cache($alertlog['device_id']); $fault_detail = alert_details($alertlog['details']); - $alert_state = $alertlog['state']; - if ($alert_state=='0') { - $glyph_icon = 'ok'; + $alert_state = $alertlog['state']; + if ($alert_state == '0') { + $glyph_icon = 'ok'; $glyph_color = 'green'; - $text = 'Ok'; + $text = 'Ok'; } - elseif ($alert_state=='1') { - $glyph_icon = 'remove'; + else if ($alert_state == '1') { + $glyph_icon = 'remove'; $glyph_color = 'red'; - $text = 'Alert'; + $text = 'Alert'; } - elseif ($alert_state=='2') { - $glyph_icon = 'info-sign'; + else if ($alert_state == '2') { + $glyph_icon = 'info-sign'; $glyph_color = 'lightgrey'; - $text = 'Ack'; + $text = 'Ack'; } - elseif ($alert_state=='3') { - $glyph_icon = 'arrow-down'; + else if ($alert_state == '3') { + $glyph_icon = 'arrow-down'; $glyph_color = 'orange'; - $text = 'Worse'; + $text = 'Worse'; } - elseif ($alert_state=='4') { - $glyph_icon = 'arrow-up'; + else if ($alert_state == '4') { + $glyph_icon = 'arrow-up'; $glyph_color = 'khaki'; - $text = 'Better'; - } - $response[] = array('id'=>$rulei++, - 'time_logged'=>$alertlog['humandate'], - 'details'=>'', - 'hostname'=>'
    '.generate_device_link($dev, shorthost($dev['hostname'])).'
    '.$fault_detail.'
    ', - 'alert'=>htmlspecialchars($alertlog['alert']), - 'status'=>" $text"); -} + $text = 'Better'; + }//end if + $response[] = array( + 'id' => $rulei++, + 'time_logged' => $alertlog['humandate'], + 'details' => '', + 'hostname' => '
    '.generate_device_link($dev, shorthost($dev['hostname'])).'
    '.$fault_detail.'
    ', + 'alert' => htmlspecialchars($alertlog['alert']), + 'status' => " $text", + ); +}//end foreach -$output = array('current'=>$current,'rowCount'=>$rowCount,'rows'=>$response,'total'=>$total); -echo _json_encode($output); +$output = array( + 'current' => $current, + 'rowCount' => $rowCount, + 'rows' => $response, + 'total' => $total, +); +echo _json_encode($output); diff --git a/html/includes/table/alerts.inc.php b/html/includes/table/alerts.inc.php index 799404b1a4..2efab5d1f1 100644 --- a/html/includes/table/alerts.inc.php +++ b/html/includes/table/alerts.inc.php @@ -10,18 +10,18 @@ if (isset($searchPhrase) && !empty($searchPhrase)) { $sql_search .= " AND (`timestamp` LIKE '%$searchPhrase%' OR `rule` LIKE '%$searchPhrase%' OR `name` LIKE '%$searchPhrase%' OR `hostname` LIKE '%$searchPhrase%')"; } -$sql = " FROM `alerts` LEFT JOIN `devices` ON `alerts`.`device_id`=`devices`.`device_id`"; +$sql = ' FROM `alerts` LEFT JOIN `devices` ON `alerts`.`device_id`=`devices`.`device_id`'; -if (is_admin() === FALSE && is_read() === FALSE) { - $sql .= " LEFT JOIN `devices_perms` AS `DP` ON `devices`.`device_id` = `DP`.`device_id`"; - $where .= " AND `DP`.`user_id`=?"; +if (is_admin() === false && is_read() === false) { + $sql .= ' LEFT JOIN `devices_perms` AS `DP` ON `devices`.`device_id` = `DP`.`device_id`'; + $where .= ' AND `DP`.`user_id`=?'; $param[] = $_SESSION['user_id']; } $sql .= " RIGHT JOIN alert_rules ON alerts.rule_id=alert_rules.id WHERE $where AND `state` IN (1,2,3,4) $sql_search"; $count_sql = "SELECT COUNT(`alerts`.`id`) $sql"; -$total = dbFetchCell($count_sql,$param); +$total = dbFetchCell($count_sql, $param); if (empty($total)) { $total = 0; } @@ -33,7 +33,7 @@ if (!isset($sort) || empty($sort)) { $sql .= " ORDER BY $sort"; if (isset($current)) { - $limit_low = ($current * $rowCount) - ($rowCount); + $limit_low = (($current * $rowCount) - ($rowCount)); $limit_high = $rowCount; } @@ -43,76 +43,86 @@ if ($rowCount != -1) { $sql = "SELECT `alerts`.*, `devices`.`hostname` AS `hostname`,`alert_rules`.`rule` AS `rule`, `alert_rules`.`name` AS `name`, `alert_rules`.`severity` AS `severity` $sql"; -$rulei = 0; +$rulei = 0; $format = $_POST['format']; -foreach (dbFetchRows($sql,$param) as $alert) { - $log = dbFetchCell("SELECT details FROM alert_log WHERE rule_id = ? AND device_id = ? ORDER BY id DESC LIMIT 1", array($alert['rule_id'],$alert['device_id'])); +foreach (dbFetchRows($sql, $param) as $alert) { + $log = dbFetchCell('SELECT details FROM alert_log WHERE rule_id = ? AND device_id = ? ORDER BY id DESC LIMIT 1', array($alert['rule_id'], $alert['device_id'])); $fault_detail = alert_details($log); - $ico = "ok"; - $col = "green"; - $extra = ""; - $msg = ""; - if ( (int) $alert['state'] === 0 ) { - $ico = "ok"; - $col = "green"; - $extra = "success"; - $msg = "ok"; - } elseif ( (int) $alert['state'] === 1 || (int) $alert['state'] === 3 || (int) $alert['state'] === 4) { - $ico = "volume-up"; - $col = "red"; - $extra = "danger"; - $msg = "alert"; - if ( (int) $alert['state'] === 3) { - $msg = "worse"; - } elseif ( (int) $alert['state'] === 4) { - $msg = "better"; - } - } elseif ( (int) $alert['state'] === 2) { - $ico = "volume-off"; - $col = "#800080"; - $extra = "warning"; - $msg = "muted"; + $ico = 'ok'; + $col = 'green'; + $extra = ''; + $msg = ''; + if ((int) $alert['state'] === 0) { + $ico = 'ok'; + $col = 'green'; + $extra = 'success'; + $msg = 'ok'; } + else if ((int) $alert['state'] === 1 || (int) $alert['state'] === 3 || (int) $alert['state'] === 4) { + $ico = 'volume-up'; + $col = 'red'; + $extra = 'danger'; + $msg = 'alert'; + if ((int) $alert['state'] === 3) { + $msg = 'worse'; + } + else if ((int) $alert['state'] === 4) { + $msg = 'better'; + } + } + else if ((int) $alert['state'] === 2) { + $ico = 'volume-off'; + $col = '#800080'; + $extra = 'warning'; + $msg = 'muted'; + }//end if $alert_checked = ''; - $orig_ico = $ico; - $orig_col = $col; - $orig_class = $extra; + $orig_ico = $ico; + $orig_col = $col; + $orig_class = $extra; $severity = $alert['severity']; if ($alert['state'] == 3) { - $severity .= " +"; - } elseif ($alert['state'] == 4) { - $severity .= " -"; + $severity .= ' +'; + } + else if ($alert['state'] == 4) { + $severity .= ' -'; } $ack_ico = 'volume-up'; $ack_col = 'success'; - if($alert['state'] == 2) { + if ($alert['state'] == 2) { $ack_ico = 'volume-off'; $ack_col = 'danger'; - } + } $hostname = ' -
    - '.generate_device_link($alert).' -
    '.$fault_detail.'
    -
    '; +
    + '.generate_device_link($alert).' +
    '.$fault_detail.'
    +
    '; - $response[] = array('id'=>$rulei++, - 'rule'=>"".htmlentities($alert['name'])."", - 'details'=>'', - 'hostname'=>$hostname, - 'timestamp'=>($alert['timestamp'] ? $alert['timestamp'] : "N/A"), - 'severity'=>$severity, - 'ack_col'=>$ack_col, - 'state'=>$alert['state'], - 'alert_id'=>$alert['id'], - 'ack_ico'=>$ack_ico, - 'extra'=>$extra, - 'msg'=>$msg); + $response[] = array( + 'id' => $rulei++, + 'rule' => ''.htmlentities($alert['name']).'', + 'details' => '', + 'hostname' => $hostname, + 'timestamp' => ($alert['timestamp'] ? $alert['timestamp'] : 'N/A'), + 'severity' => $severity, + 'ack_col' => $ack_col, + 'state' => $alert['state'], + 'alert_id' => $alert['id'], + 'ack_ico' => $ack_ico, + 'extra' => $extra, + 'msg' => $msg, + ); +}//end foreach -} - -$output = array('current'=>$current,'rowCount'=>$rowCount,'rows'=>$response,'total'=>$total); +$output = array( + 'current' => $current, + 'rowCount' => $rowCount, + 'rows' => $response, + 'total' => $total, +); echo _json_encode($output); diff --git a/html/includes/table/arp-search.inc.php b/html/includes/table/arp-search.inc.php index dd5c6225ea..090476048f 100644 --- a/html/includes/table/arp-search.inc.php +++ b/html/includes/table/arp-search.inc.php @@ -2,32 +2,33 @@ $param = array(); -$sql .= " FROM `ipv4_mac` AS M, `ports` AS P, `devices` AS D "; +$sql .= ' FROM `ipv4_mac` AS M, `ports` AS P, `devices` AS D '; -if (is_admin() === FALSE && is_read() === FALSE) { - $sql .= " LEFT JOIN `devices_perms` AS `DP` ON `D`.`device_id` = `DP`.`device_id`"; - $where .= " AND `DP`.`user_id`=?"; +if (is_admin() === false && is_read() === false) { + $sql .= ' LEFT JOIN `devices_perms` AS `DP` ON `D`.`device_id` = `DP`.`device_id`'; + $where .= ' AND `DP`.`user_id`=?'; $param[] = $_SESSION['user_id']; } $sql .= " WHERE M.port_id = P.port_id AND P.device_id = D.device_id $where "; -if (isset($_POST['searchby']) && $_POST['searchby'] == "ip") { - $sql .= " AND `ipv4_address` LIKE ?"; - $param[] = "%".trim($_POST['address'])."%"; -} elseif (isset($_POST['searchby']) && $_POST['searchby'] == "mac") { - $sql .= " AND `mac_address` LIKE ?"; - $param[] = "%".str_replace(array(':', ' ', '-', '.', '0x'),'',mres($_POST['address']))."%"; +if (isset($_POST['searchby']) && $_POST['searchby'] == 'ip') { + $sql .= ' AND `ipv4_address` LIKE ?'; + $param[] = '%'.trim($_POST['address']).'%'; +} +else if (isset($_POST['searchby']) && $_POST['searchby'] == 'mac') { + $sql .= ' AND `mac_address` LIKE ?'; + $param[] = '%'.str_replace(array(':', ' ', '-', '.', '0x'), '', mres($_POST['address'])).'%'; } if (is_numeric($_POST['device_id'])) { - $sql .= " AND P.device_id = ?"; + $sql .= ' AND P.device_id = ?'; $param[] = $_POST['device_id']; } $count_sql = "SELECT COUNT(`M`.`port_id`) $sql"; -$total = dbFetchCell($count_sql,$param); +$total = dbFetchCell($count_sql, $param); if (empty($total)) { $total = 0; } @@ -39,7 +40,7 @@ if (!isset($sort) || empty($sort)) { $sql .= " ORDER BY $sort"; if (isset($current)) { - $limit_low = ($current * $rowCount) - ($rowCount); + $limit_low = (($current * $rowCount) - ($rowCount)); $limit_high = $rowCount; } @@ -51,39 +52,53 @@ $sql = "SELECT *,`P`.`ifDescr` AS `interface` $sql"; foreach (dbFetchRows($sql, $param) as $entry) { if (!$ignore) { - if ($entry['ifInErrors'] > 0 || $entry['ifOutErrors'] > 0) { - $error_img = generate_port_link($entry,"Interface Errors",port_errors); - } else { - $error_img = ""; + $error_img = generate_port_link($entry, "Interface Errors", port_errors); + } + else { + $error_img = ''; } - $arp_host = dbFetchRow("SELECT * FROM ipv4_addresses AS A, ports AS I, devices AS D WHERE A.ipv4_address = ? AND I.port_id = A.port_id AND D.device_id = I.device_id", array($entry['ipv4_address'])); - if ($arp_host) { - $arp_name = generate_device_link($arp_host); - } else { - unset($arp_name); - } - if ($arp_host) { - $arp_if = generate_port_link($arp_host); - } else { - unset($arp_if); - } - if ($arp_host['device_id'] == $entry['device_id']) { - $arp_name = "Localhost"; - } - if ($arp_host['port_id'] == $entry['port_id']) { - $arp_if = "Local port"; - } - $response[] = array('mac_address'=>formatMac($entry['mac_address']), - 'ipv4_address'=>$entry['ipv4_address'], - 'hostname'=>generate_device_link($entry), - 'interface'=>generate_port_link($entry, makeshortif(fixifname(ifLabel($entry['label'])))) . ' ' . $error_img, - 'remote_device'=>$arp_name, - 'remote_interface'=>$arp_if); - } - unset($ignore); -} + $arp_host = dbFetchRow('SELECT * FROM ipv4_addresses AS A, ports AS I, devices AS D WHERE A.ipv4_address = ? AND I.port_id = A.port_id AND D.device_id = I.device_id', array($entry['ipv4_address'])); + if ($arp_host) { + $arp_name = generate_device_link($arp_host); + } + else { + unset($arp_name); + } -$output = array('current'=>$current,'rowCount'=>$rowCount,'rows'=>$response,'total'=>$total); + if ($arp_host) { + $arp_if = generate_port_link($arp_host); + } + else { + unset($arp_if); + } + + if ($arp_host['device_id'] == $entry['device_id']) { + $arp_name = 'Localhost'; + } + + if ($arp_host['port_id'] == $entry['port_id']) { + $arp_if = 'Local port'; + } + + $response[] = array( + 'mac_address' => formatMac($entry['mac_address']), + 'ipv4_address' => $entry['ipv4_address'], + 'hostname' => generate_device_link($entry), + 'interface' => generate_port_link($entry, makeshortif(fixifname(ifLabel($entry['label'])))).' '.$error_img, + 'remote_device' => $arp_name, + 'remote_interface' => $arp_if, + ); + }//end if + + unset($ignore); +}//end foreach + +$output = array( + 'current' => $current, + 'rowCount' => $rowCount, + 'rows' => $response, + 'total' => $total, +); echo _json_encode($output); diff --git a/html/includes/table/devices.inc.php b/html/includes/table/devices.inc.php index 25cf21bd51..129e198f21 100644 --- a/html/includes/table/devices.inc.php +++ b/html/includes/table/devices.inc.php @@ -3,11 +3,11 @@ $where = 1; $param = array(); -$sql = " FROM `devices`"; +$sql = ' FROM `devices`'; -if (is_admin() === FALSE && is_read() === FALSE) { - $sql .= " LEFT JOIN `devices_perms` AS `DP` ON `devices`.`device_id` = `DP`.`device_id`"; - $where .= " AND `DP`.`user_id`=?"; +if (is_admin() === false && is_read() === false) { + $sql .= ' LEFT JOIN `devices_perms` AS `DP` ON `devices`.`device_id` = `DP`.`device_id`'; + $where .= ' AND `DP`.`user_id`=?'; $param[] = $_SESSION['user_id']; } @@ -17,48 +17,87 @@ if (!empty($_POST['location'])) { $sql .= " WHERE $where "; -if (!empty($_POST['hostname'])) { $sql .= " AND hostname LIKE ?"; $param[] = "%".$_POST['hostname']."%"; } -if (!empty($_POST['os'])) { $sql .= " AND os = ?"; $param[] = $_POST['os']; } -if (!empty($_POST['version'])) { $sql .= " AND version = ?"; $param[] = $_POST['version']; } -if (!empty($_POST['hardware'])) { $sql .= " AND hardware = ?"; $param[] = $_POST['hardware']; } -if (!empty($_POST['features'])) { $sql .= " AND features = ?"; $param[] = $_POST['features']; } -if (!empty($_POST['type'])) { - if ($_POST['type'] == 'generic') { - $sql .= " AND ( type = ? OR type = '')"; $param[] = $_POST['type']; - } else { - $sql .= " AND type = ?"; $param[] = $_POST['type']; - } +if (!empty($_POST['hostname'])) { + $sql .= ' AND hostname LIKE ?'; + $param[] = '%'.$_POST['hostname'].'%'; } -if (!empty($_POST['state'])) { - $sql .= " AND status= ?"; - if( is_numeric($_POST['state']) ) { - $param[] = $_POST['state']; - } else { - $param[] = str_replace(array('up','down'),array(1,0),$_POST['state']); + +if (!empty($_POST['os'])) { + $sql .= ' AND os = ?'; + $param[] = $_POST['os']; +} + +if (!empty($_POST['version'])) { + $sql .= ' AND version = ?'; + $param[] = $_POST['version']; +} + +if (!empty($_POST['hardware'])) { + $sql .= ' AND hardware = ?'; + $param[] = $_POST['hardware']; +} + +if (!empty($_POST['features'])) { + $sql .= ' AND features = ?'; + $param[] = $_POST['features']; +} + +if (!empty($_POST['type'])) { + if ($_POST['type'] == 'generic') { + $sql .= " AND ( type = ? OR type = '')"; + $param[] = $_POST['type']; + } + else { + $sql .= ' AND type = ?'; + $param[] = $_POST['type']; } } -if (!empty($_POST['disabled'])) { $sql .= " AND disabled= ?"; $param[] = $_POST['disabled']; } -if (!empty($_POST['ignore'])) { $sql .= " AND `ignore`= ?"; $param[] = $_POST['ignore']; } -if (!empty($_POST['location']) && $_POST['location'] == "Unset") { $location_filter = ''; } + +if (!empty($_POST['state'])) { + $sql .= ' AND status= ?'; + if (is_numeric($_POST['state'])) { + $param[] = $_POST['state']; + } + else { + $param[] = str_replace(array('up', 'down'), array(1, 0), $_POST['state']); + } +} + +if (!empty($_POST['disabled'])) { + $sql .= ' AND disabled= ?'; + $param[] = $_POST['disabled']; +} + +if (!empty($_POST['ignore'])) { + $sql .= ' AND `ignore`= ?'; + $param[] = $_POST['ignore']; +} + +if (!empty($_POST['location']) && $_POST['location'] == 'Unset') { + $location_filter = ''; +} + if (!empty($_POST['location'])) { - $sql .= " AND (((`DB`.`attrib_value`='1' AND `DA`.`attrib_type`='override_sysLocation_string' AND `DA`.`attrib_value` = ?)) OR `location` = ?)"; + $sql .= " AND (((`DB`.`attrib_value`='1' AND `DA`.`attrib_type`='override_sysLocation_string' AND `DA`.`attrib_value` = ?)) OR `location` = ?)"; $param[] = mres($_POST['location']); $param[] = mres($_POST['location']); } -if( !empty($_POST['group']) ) { - require_once('../includes/device-groups.inc.php'); - $sql .= " AND ( "; - foreach( GetDevicesFromGroup($_POST['group']) as $dev ) { - $sql .= "`devices`.`device_id` = ? OR "; + +if (!empty($_POST['group'])) { + include_once '../includes/device-groups.inc.php'; + $sql .= ' AND ( '; + foreach (GetDevicesFromGroup($_POST['group']) as $dev) { + $sql .= '`devices`.`device_id` = ? OR '; $param[] = $dev['device_id']; } - $sql = substr($sql, 0, strlen($sql)-3); - $sql .= " )"; + + $sql = substr($sql, 0, (strlen($sql) - 3)); + $sql .= ' )'; } $count_sql = "SELECT COUNT(`devices`.`device_id`) $sql"; -$total = dbFetchCell($count_sql,$param); +$total = dbFetchCell($count_sql, $param); if (empty($total)) { $total = 0; } @@ -70,7 +109,7 @@ if (!isset($sort) || empty($sort)) { $sql .= " ORDER BY $sort"; if (isset($current)) { - $limit_low = ($current * $rowCount) - ($rowCount); + $limit_low = (($current * $rowCount) - ($rowCount)); $limit_high = $rowCount; } @@ -81,99 +120,124 @@ if ($rowCount != -1) { $sql = "SELECT DISTINCT(`devices`.`device_id`),`devices`.* $sql"; if (!isset($_POST['format'])) { - $_POST['format'] = "list_detail"; + $_POST['format'] = 'list_detail'; } -list($format, $subformat) = explode("_", $_POST['format']); + +list($format, $subformat) = explode('_', $_POST['format']); foreach (dbFetchRows($sql, $param) as $device) { - if (isset($bg) && $bg == $list_colour_b) { - $bg = $list_colour_a; - } else { - $bg = $list_colour_b; - } + if (isset($bg) && $bg == $list_colour_b) { + $bg = $list_colour_a; + } + else { + $bg = $list_colour_b; + } - if ($device['status'] == '0') { - $extra = "danger"; - $msg = $device['status_reason']; - } else { - $extra = "success"; - $msg = "up"; - } - if ($device['ignore'] == '1') { - $extra = "default"; - $msg = "ignored"; - if ($device['status'] == '1') { - $extra = "warning"; - $msg = "ignored"; - } - } - if ($device['disabled'] == '1') { - $extra = "default"; - $msg = "disabled"; - } + if ($device['status'] == '0') { + $extra = 'danger'; + $msg = $device['status_reason']; + } + else { + $extra = 'success'; + $msg = 'up'; + } - $type = strtolower($device['os']); - $image = getImage($device); - - if ($device['os'] == "ios") { - formatCiscoHardware($device, true); - } + if ($device['ignore'] == '1') { + $extra = 'default'; + $msg = 'ignored'; + if ($device['status'] == '1') { + $extra = 'warning'; + $msg = 'ignored'; + } + } - $device['os_text'] = $config['os'][$device['os']]['text']; - $port_count = dbFetchCell("SELECT COUNT(*) FROM `ports` WHERE `device_id` = ?", array($device['device_id'])); - $sensor_count = dbFetchCell("SELECT COUNT(*) FROM `sensors` WHERE `device_id` = ?", array($device['device_id'])); + if ($device['disabled'] == '1') { + $extra = 'default'; + $msg = 'disabled'; + } - if (get_dev_attrib($device,'override_sysLocation_bool')) { - $device['location'] = get_dev_attrib($device,'override_sysLocation_string'); - } + $type = strtolower($device['os']); + $image = getImage($device); - $actions = ('
    -
    '); - $actions .= ' View device '; - $actions .= ('
    -
    '); - $actions .= ' View alerts '; - $actions .= '
    '; - if ($_SESSION['userlevel'] >= "7") { - $actions .= ('
    - Edit device -
    '); - } - $actions .= ('
    -
    -
    - telnet -
    -
    - ssh -
    -
    - https -
    -
    '); + if ($device['os'] == 'ios') { + formatCiscoHardware($device, true); + } - $hostname = generate_device_link($device); - $platform = $device['hardware'] . '
    ' . $device['features']; - $os = $device['os_text'] . '
    ' . $device['version']; - if (extension_loaded('mbstring')) { - $location = mb_substr($device['location'], 0, 32, 'utf8'); - } else { - $location = truncate($device['location'], 32, ''); - } - $uptime = formatUptime($device['uptime'], 'short') . '
    ' . $location; - if ($subformat == "detail") { - $hostname .= '
    ' . $device['sysName']; - if ($port_count) { - $col_port = ' '.$port_count . '
    '; - } - if ($sensor_count) { - $col_port .= ' '.$sensor_count; - } - } else { + $device['os_text'] = $config['os'][$device['os']]['text']; + $port_count = dbFetchCell('SELECT COUNT(*) FROM `ports` WHERE `device_id` = ?', array($device['device_id'])); + $sensor_count = dbFetchCell('SELECT COUNT(*) FROM `sensors` WHERE `device_id` = ?', array($device['device_id'])); - } - $response[] = array('extra'=>$extra,'msg'=>$msg,'icon'=>$image,'hostname'=>$hostname,'ports'=>$col_port,'hardware'=>$platform,'os'=>$os,'uptime'=>$uptime,'actions'=>$actions); -} + if (get_dev_attrib($device, 'override_sysLocation_bool')) { + $device['location'] = get_dev_attrib($device, 'override_sysLocation_string'); + } -$output = array('current'=>$current,'rowCount'=>$rowCount,'rows'=>$response,'total'=>$total); + $actions = ('
    +
    '); + $actions .= ' View device '; + $actions .= ('
    +
    '); + $actions .= ' View alerts '; + $actions .= '
    '; + if ($_SESSION['userlevel'] >= '7') { + $actions .= ('
    + Edit device +
    '); + } + + $actions .= ('
    +
    +
    + telnet +
    +
    + ssh +
    +
    + https +
    +
    '); + + $hostname = generate_device_link($device); + $platform = $device['hardware'].'
    '.$device['features']; + $os = $device['os_text'].'
    '.$device['version']; + if (extension_loaded('mbstring')) { + $location = mb_substr($device['location'], 0, 32, 'utf8'); + } + else { + $location = truncate($device['location'], 32, ''); + } + + $uptime = formatUptime($device['uptime'], 'short').'
    '.$location; + if ($subformat == 'detail') { + $hostname .= '
    '.$device['sysName']; + if ($port_count) { + $col_port = ' '.$port_count.'
    '; + } + + if ($sensor_count) { + $col_port .= ' '.$sensor_count; + } + } + else { + } + + $response[] = array( + 'extra' => $extra, + 'msg' => $msg, + 'icon' => $image, + 'hostname' => $hostname, + 'ports' => $col_port, + 'hardware' => $platform, + 'os' => $os, + 'uptime' => $uptime, + 'actions' => $actions, + ); +}//end foreach + +$output = array( + 'current' => $current, + 'rowCount' => $rowCount, + 'rows' => $response, + 'total' => $total, +); echo _json_encode($output); diff --git a/html/includes/table/eventlog.inc.php b/html/includes/table/eventlog.inc.php index d5e5e7d60e..9cae422965 100644 --- a/html/includes/table/eventlog.inc.php +++ b/html/includes/table/eventlog.inc.php @@ -1,23 +1,22 @@ = '5') { $sql = " FROM `eventlog` AS E LEFT JOIN `devices` AS `D` ON `E`.`host`=`D`.`device_id` WHERE $where"; -} else { - $sql = " FROM `eventlog` AS E, devices_perms AS P WHERE $where AND E.host = P.device_id AND P.user_id = ?"; +} +else { + $sql = " FROM `eventlog` AS E, devices_perms AS P WHERE $where AND E.host = P.device_id AND P.user_id = ?"; $param[] = $_SESSION['user_id']; } @@ -26,7 +25,7 @@ if (isset($searchPhrase) && !empty($searchPhrase)) { } $count_sql = "SELECT COUNT(datetime) $sql"; -$total = dbFetchCell($count_sql,$param); +$total = dbFetchCell($count_sql, $param); if (empty($total)) { $total = 0; } @@ -38,7 +37,7 @@ if (!isset($sort) || empty($sort)) { $sql .= " ORDER BY $sort"; if (isset($current)) { - $limit_low = ($current * $rowCount) - ($rowCount); + $limit_low = (($current * $rowCount) - ($rowCount)); $limit_high = $rowCount; } @@ -48,22 +47,28 @@ if ($rowCount != -1) { $sql = "SELECT `E`.*,DATE_FORMAT(datetime, '".$config['dateformat']['mysql']['compact']."') as humandate $sql"; -foreach (dbFetchRows($sql,$param) as $eventlog) { +foreach (dbFetchRows($sql, $param) as $eventlog) { $dev = device_by_id_cache($eventlog['host']); - if ($eventlog['type'] == "interface") { + if ($eventlog['type'] == 'interface') { $this_if = ifLabel(getifbyid($eventlog['reference'])); - $type = "".generate_port_link($this_if, makeshortif(strtolower($this_if['label']))).""; - } else { - $type = "System"; + $type = ''.generate_port_link($this_if, makeshortif(strtolower($this_if['label']))).''; } - - $response[] = array('datetime'=>$eventlog['humandate'], - 'hostname'=>generate_device_link($dev, shorthost($dev['hostname'])), - 'type'=>$type, - 'message'=>htmlspecialchars($eventlog['message'])); + else { + $type = 'System'; + } + + $response[] = array( + 'datetime' => $eventlog['humandate'], + 'hostname' => generate_device_link($dev, shorthost($dev['hostname'])), + 'type' => $type, + 'message' => htmlspecialchars($eventlog['message']), + ); } -$output = array('current'=>$current,'rowCount'=>$rowCount,'rows'=>$response,'total'=>$total); +$output = array( + 'current' => $current, + 'rowCount' => $rowCount, + 'rows' => $response, + 'total' => $total, +); echo _json_encode($output); - -?> diff --git a/html/includes/table/inventory.inc.php b/html/includes/table/inventory.inc.php index 6c5b92823f..2e4c0b9281 100644 --- a/html/includes/table/inventory.inc.php +++ b/html/includes/table/inventory.inc.php @@ -1,14 +1,15 @@ = '5') { $sql = " FROM entPhysical AS E, devices AS D WHERE $where AND D.device_id = E.device_id"; -} else { - $sql = " FROM entPhysical AS E, devices AS D, devices_perms AS P WHERE $where AND D.device_id = E.device_id AND P.device_id = D.device_id AND P.user_id = ?"; +} +else { + $sql = " FROM entPhysical AS E, devices AS D, devices_perms AS P WHERE $where AND D.device_id = E.device_id AND P.device_id = D.device_id AND P.user_id = ?"; $param[] = $_SESSION['user_id']; } @@ -17,32 +18,32 @@ if (isset($searchPhrase) && !empty($searchPhrase)) { } if (isset($_POST['string']) && strlen($_POST['string'])) { - $sql .= " AND E.entPhysicalDescr LIKE ?"; - $param[] = "%".$_POST['string']."%"; + $sql .= ' AND E.entPhysicalDescr LIKE ?'; + $param[] = '%'.$_POST['string'].'%'; } if (isset($_POST['device_string']) && strlen($_POST['device_string'])) { - $sql .= " AND D.hostname LIKE ?"; - $param[] = "%".$_POST['device_string']."%"; + $sql .= ' AND D.hostname LIKE ?'; + $param[] = '%'.$_POST['device_string'].'%'; } if (isset($_POST['part']) && strlen($_POST['part'])) { - $sql .= " AND E.entPhysicalModelName = ?"; - $param[] = $_POST['part']; + $sql .= ' AND E.entPhysicalModelName = ?'; + $param[] = $_POST['part']; } if (isset($_POST['serial']) && strlen($_POST['serial'])) { - $sql .= " AND E.entPhysicalSerialNum LIKE ?"; - $param[] = "%".$_POST['serial']."%"; + $sql .= ' AND E.entPhysicalSerialNum LIKE ?'; + $param[] = '%'.$_POST['serial'].'%'; } if (isset($_POST['device']) && is_numeric($_POST['device'])) { - $sql .= " AND D.device_id = ?"; - $param[] = $_POST['device']; + $sql .= ' AND D.device_id = ?'; + $param[] = $_POST['device']; } $count_sql = "SELECT COUNT(`entPhysical_id`) $sql"; -$total = dbFetchCell($count_sql,$param); +$total = dbFetchCell($count_sql, $param); if (empty($total)) { $total = 0; } @@ -54,7 +55,7 @@ if (!isset($sort) || empty($sort)) { $sql .= " ORDER BY $sort"; if (isset($current)) { - $limit_low = ($current * $rowCount) - ($rowCount); + $limit_low = (($current * $rowCount) - ($rowCount)); $limit_high = $rowCount; } @@ -65,12 +66,19 @@ if ($rowCount != -1) { $sql = "SELECT `D`.`device_id` AS `device_id`, `D`.`hostname` AS `hostname`,`entPhysicalDescr` AS `description`, `entPhysicalName` AS `name`, `entPhysicalModelName` AS `model`, `entPhysicalSerialNum` AS `serial` $sql"; foreach (dbFetchRows($sql, $param) as $invent) { - $response[] = array('hostname'=>generate_device_link($invent, shortHost($invent['hostname'])), - 'description'=>$invent['description'], - 'name'=>$invent['name'], - 'model'=>$invent['model'], - 'serial'=>$invent['serial']); + $response[] = array( + 'hostname' => generate_device_link($invent, shortHost($invent['hostname'])), + 'description' => $invent['description'], + 'name' => $invent['name'], + 'model' => $invent['model'], + 'serial' => $invent['serial'], + ); } -$output = array('current'=>$current,'rowCount'=>$rowCount,'rows'=>$response,'total'=>$total); +$output = array( + 'current' => $current, + 'rowCount' => $rowCount, + 'rows' => $response, + 'total' => $total, + ); echo _json_encode($output); diff --git a/html/includes/table/mempool.inc.php b/html/includes/table/mempool.inc.php index d3968a5317..2afb80edc0 100644 --- a/html/includes/table/mempool.inc.php +++ b/html/includes/table/mempool.inc.php @@ -1,72 +1,88 @@ generate_device_link($mempool), - 'mempool_descr' => $mempool['mempool_descr'], - 'graph' => $mini_graph, - 'mempool_used' => $bar_link, - 'mempool_perc' => $perc . "%"); - if ($_POST['view'] == "graphs") { - $graph_array['height'] = "100"; - $graph_array['width'] = "216"; - $graph_array['to'] = $config['time']['now']; - $graph_array['id'] = $mempool['mempool_id']; - $graph_array['type'] = $graph_type; - $return_data = true; - include("includes/print-graphrow.inc.php"); - unset($return_data); - $response[] = array('hostname' => $graph_data[0], - 'mempool_descr' => $graph_data[1], - 'graph' => $graph_data[2], - 'mempool_used' => $graph_data[3], - 'mempool_perc' => ''); - } # endif graphs -} -$output = array('current'=>$current,'rowCount'=>$rowCount,'rows'=>$response,'total'=>$count); +$sql = "SELECT * $sql"; +foreach (dbFetchRows($sql, $param) as $mempool) { + $perc = round($mempool['mempool_perc'], 0); + $total = formatStorage($mempool['mempool_total']); + $free = formatStorage($mempool['mempool_free']); + $used = formatStorage($mempool['mempool_used']); + $graph_array['type'] = $graph_type; + $graph_array['id'] = $mempool['mempool_id']; + $graph_array['from'] = $config['time']['day']; + $graph_array['to'] = $config['time']['now']; + $graph_array['height'] = '20'; + $graph_array['width'] = '80'; + $graph_array_zoom = $graph_array; + $graph_array_zoom['height'] = '150'; + $graph_array_zoom['width'] = '400'; + $link = 'graphs/id='.$graph_array['id'].'/type='.$graph_array['type'].'/from='.$graph_array['from'].'/to='.$graph_array['to'].'/'; + $mini_graph = overlib_link($link, generate_graph_tag($graph_array), generate_graph_tag($graph_array_zoom), null); + $background = get_percentage_colours($perc); + $bar_link = overlib_link($link, print_percentage_bar(400, 20, $perc, "$used / $total", 'ffffff', $background['left'], $free, 'ffffff', $background['right']), generate_graph_tag($graph_array_zoom), null); + + $response[] = array( + 'hostname' => generate_device_link($mempool), + 'mempool_descr' => $mempool['mempool_descr'], + 'graph' => $mini_graph, + 'mempool_used' => $bar_link, + 'mempool_perc' => $perc.'%', + ); + if ($_POST['view'] == 'graphs') { + $graph_array['height'] = '100'; + $graph_array['width'] = '216'; + $graph_array['to'] = $config['time']['now']; + $graph_array['id'] = $mempool['mempool_id']; + $graph_array['type'] = $graph_type; + $return_data = true; + include 'includes/print-graphrow.inc.php'; + unset($return_data); + $response[] = array( + 'hostname' => $graph_data[0], + 'mempool_descr' => $graph_data[1], + 'graph' => $graph_data[2], + 'mempool_used' => $graph_data[3], + 'mempool_perc' => '', + ); + } //end if +}//end foreach + +$output = array( + 'current' => $current, + 'rowCount' => $rowCount, + 'rows' => $response, + 'total' => $count, +); echo _json_encode($output); diff --git a/html/includes/table/poll-log.inc.php b/html/includes/table/poll-log.inc.php index 3a0ca3213e..3579759b6c 100644 --- a/html/includes/table/poll-log.inc.php +++ b/html/includes/table/poll-log.inc.php @@ -1,11 +1,12 @@ " 'graphs', 'group' => 'poller')). "'>" .$device['hostname']. "", - 'last_polled' => $device['last_polled'], - 'last_polled_timetaken' => $device['last_polled_timetaken']); + $response[] = array( + 'hostname' => " 'graphs', 'group' => 'poller'))."'>".$device['hostname'].'', + 'last_polled' => $device['last_polled'], + 'last_polled_timetaken' => $device['last_polled_timetaken'], + ); } -$output = array('current'=>$current,'rowCount'=>$rowCount,'rows'=>$response,'total'=>$total); +$output = array( + 'current' => $current, + 'rowCount' => $rowCount, + 'rows' => $response, + 'total' => $total, +); echo _json_encode($output); - -?> diff --git a/html/includes/table/processor.inc.php b/html/includes/table/processor.inc.php index a7b3d97457..bcedd6196f 100644 --- a/html/includes/table/processor.inc.php +++ b/html/includes/table/processor.inc.php @@ -1,67 +1,83 @@ generate_device_link($processor), - 'processor_descr' => $processor['processor_descr'], - 'graph' => $mini_graph, - 'processor_usage' => $bar_link); - if ($_POST['view'] == "graphs") { - $graph_array['height'] = "100"; - $graph_array['width'] = "216"; - $graph_array['to'] = $config['time']['now']; - $graph_array['id'] = $processor['processor_id']; - $graph_array['type'] = $graph_type; - $return_data = true; - include("includes/print-graphrow.inc.php"); - unset($return_data); - $response[] = array('hostname' => $graph_data[0], - 'processor_descr' => $graph_data[1], - 'graph' => $graph_data[2], - 'processor_usage' => $graph_data[3]); - } # endif graphs -} -$output = array('current'=>$current,'rowCount'=>$rowCount,'rows'=>$response,'total'=>$total); +$sql = "SELECT * $sql"; +foreach (dbFetchRows($sql, $param) as $processor) { + $perc = round($processor['processor_usage'], 0); + $graph_array['type'] = $graph_type; + $graph_array['id'] = $processor['processor_id']; + $graph_array['from'] = $config['time']['day']; + $graph_array['to'] = $config['time']['now']; + $graph_array['height'] = '20'; + $graph_array['width'] = '80'; + $graph_array_zoom = $graph_array; + $graph_array_zoom['height'] = '150'; + $graph_array_zoom['width'] = '400'; + $link = 'graphs/id='.$graph_array['id'].'/type='.$graph_array['type'].'/from='.$graph_array['from'].'/to='.$graph_array['to'].'/'; + $mini_graph = overlib_link($link, generate_graph_tag($graph_array), generate_graph_tag($graph_array_zoom), null); + $background = get_percentage_colours($perc); + $bar_link = overlib_link($link, print_percentage_bar(400, 20, $perc, $perc.'%', 'ffffff', $background['left'], (100 - $perc).'%', 'ffffff', $background['right']), generate_graph_tag($graph_array_zoom), null); + + $response[] = array( + 'hostname' => generate_device_link($processor), + 'processor_descr' => $processor['processor_descr'], + 'graph' => $mini_graph, + 'processor_usage' => $bar_link, + ); + if ($_POST['view'] == 'graphs') { + $graph_array['height'] = '100'; + $graph_array['width'] = '216'; + $graph_array['to'] = $config['time']['now']; + $graph_array['id'] = $processor['processor_id']; + $graph_array['type'] = $graph_type; + $return_data = true; + include 'includes/print-graphrow.inc.php'; + unset($return_data); + $response[] = array( + 'hostname' => $graph_data[0], + 'processor_descr' => $graph_data[1], + 'graph' => $graph_data[2], + 'processor_usage' => $graph_data[3], + ); + } //end if +}//end foreach + +$output = array( + 'current' => $current, + 'rowCount' => $rowCount, + 'rows' => $response, + 'total' => $total, +); echo _json_encode($output); diff --git a/html/includes/table/storage.inc.php b/html/includes/table/storage.inc.php index a912ba1d2e..3d301456f0 100644 --- a/html/includes/table/storage.inc.php +++ b/html/includes/table/storage.inc.php @@ -1,14 +1,14 @@ generate_device_link($drive), + 'storage_descr' => $drive['storage_descr'], + 'graph' => $mini_graph, + 'storage_used' => $bar_link, + 'storage_perc' => $perc.'%', + ); + if ($_POST['view'] == 'graphs') { + $graph_array['height'] = '100'; + $graph_array['width'] = '216'; + $graph_array['to'] = $config['time']['now']; + $graph_array['id'] = $drive['storage_id']; + $graph_array['type'] = $graph_type; - $response[] = array('hostname' => generate_device_link($drive), - 'storage_descr' => $drive['storage_descr'], - 'graph' => $mini_graph, - 'storage_used' => $bar_link, - 'storage_perc' => $perc . "%"); - if ($_POST['view'] == "graphs") { - $graph_array['height'] = "100"; - $graph_array['width'] = "216"; - $graph_array['to'] = $config['time']['now']; - $graph_array['id'] = $drive['storage_id']; - $graph_array['type'] = $graph_type; + $return_data = true; + include 'includes/print-graphrow.inc.php'; + unset($return_data); + $response[] = array( + 'hostname' => $graph_data[0], + 'storage_descr' => $graph_data[1], + 'graph' => $graph_data[2], + 'storage_used' => $graph_data[3], + 'storage_perc' => '', + ); + } //end if +}//end foreach - $return_data = true; - include("includes/print-graphrow.inc.php"); - unset($return_data); - $response[] = array('hostname' => $graph_data[0], - 'storage_descr' => $graph_data[1], - 'graph' => $graph_data[2], - 'storage_used' => $graph_data[3], - 'storage_perc' => ''); - - } # endif graphs -} - -$output = array('current'=>$current,'rowCount'=>$rowCount,'rows'=>$response,'total'=>$count); +$output = array( + 'current' => $current, + 'rowCount' => $rowCount, + 'rows' => $response, + 'total' => $count, +); echo _json_encode($output); diff --git a/html/includes/table/syslog.inc.php b/html/includes/table/syslog.inc.php index 81df05d289..987aac65a1 100644 --- a/html/includes/table/syslog.inc.php +++ b/html/includes/table/syslog.inc.php @@ -1,46 +1,44 @@ = ?"; - $param[] = $_POST['from']; -} -if( !empty($_POST['to']) ) { - $where .= " AND timestamp <= ?"; - $param[] = $_POST['to']; +if (!empty($_POST['from'])) { + $where .= ' AND timestamp >= ?'; + $param[] = $_POST['from']; } -if ($_SESSION['userlevel'] >= '5') -{ - $sql = "FROM syslog AS S"; - $sql .= " WHERE ".$where; -} else { - $sql = "FROM syslog AS S, devices_perms AS P"; - $sql .= "WHERE S.device_id = P.device_id AND P.user_id = ?"; - $sql .= $where; - $param = array_merge(array($_SESSION['user_id']), $param); +if (!empty($_POST['to'])) { + $where .= ' AND timestamp <= ?'; + $param[] = $_POST['to']; +} + +if ($_SESSION['userlevel'] >= '5') { + $sql = 'FROM syslog AS S'; + $sql .= ' WHERE '.$where; +} +else { + $sql = 'FROM syslog AS S, devices_perms AS P'; + $sql .= 'WHERE S.device_id = P.device_id AND P.user_id = ?'; + $sql .= $where; + $param = array_merge(array($_SESSION['user_id']), $param); } $count_sql = "SELECT COUNT(timestamp) $sql"; -$total = dbFetchCell($count_sql,$param); +$total = dbFetchCell($count_sql, $param); if (empty($total)) { $total = 0; } @@ -52,7 +50,7 @@ if (!isset($sort) || empty($sort)) { $sql .= " ORDER BY $sort"; if (isset($current)) { - $limit_low = ($current * $rowCount) - ($rowCount); + $limit_low = (($current * $rowCount) - ($rowCount)); $limit_high = $rowCount; } @@ -62,14 +60,20 @@ if ($rowCount != -1) { $sql = "SELECT S.*, DATE_FORMAT(timestamp, '".$config['dateformat']['mysql']['compact']."') AS date $sql"; -foreach (dbFetchRows($sql,$param) as $syslog) { - $dev = device_by_id_cache($syslog['device_id']); - $response[] = array('timestamp'=>$syslog['date'], - 'device_id'=>generate_device_link($dev, shorthost($dev['hostname'])), - 'program'=>$syslog['program'], - 'msg'=>htmlspecialchars($syslog['msg'])); +foreach (dbFetchRows($sql, $param) as $syslog) { + $dev = device_by_id_cache($syslog['device_id']); + $response[] = array( + 'timestamp' => $syslog['date'], + 'device_id' => generate_device_link($dev, shorthost($dev['hostname'])), + 'program' => $syslog['program'], + 'msg' => htmlspecialchars($syslog['msg']), + ); } -$output = array('current'=>$current,'rowCount'=>$rowCount,'rows'=>$response,'total'=>$total); +$output = array( + 'current' => $current, + 'rowCount' => $rowCount, + 'rows' => $response, + 'total' => $total, +); echo _json_encode($output); -?> diff --git a/html/includes/vars.inc.php b/html/includes/vars.inc.php index 788915f694..477f056b46 100644 --- a/html/includes/vars.inc.php +++ b/html/includes/vars.inc.php @@ -1,40 +1,38 @@ $get_var) -{ - if (strstr($key, "opt")) - { - list($name, $value) = explode("|", $get_var); - if (!isset($value)) { $value = "yes"; } - $vars[$name] = $value; - } +foreach ($_GET as $key => $get_var) { + if (strstr($key, 'opt')) { + list($name, $value) = explode('|', $get_var); + if (!isset($value)) { + $value = 'yes'; + } + + $vars[$name] = $value; + } } $segments = explode('/', trim($_SERVER['REQUEST_URI'], '/')); -foreach ($segments as $pos => $segment) -{ - $segment = urldecode($segment); - if ($pos == "0") - { - $vars['page'] = $segment; - } else { - list($name, $value) = explode("=", $segment); - if ($value == "" || !isset($value)) - { - $vars[$name] = yes; - } else { - $vars[$name] = $value; +foreach ($segments as $pos => $segment) { + $segment = urldecode($segment); + if ($pos == '0') { + $vars['page'] = $segment; + } + else { + list($name, $value) = explode('=', $segment); + if ($value == '' || !isset($value)) { + $vars[$name] = yes; + } + else { + $vars[$name] = $value; + } } - } } -foreach ($_GET as $name => $value) -{ - $vars[$name] = $value; +foreach ($_GET as $name => $value) { + $vars[$name] = $value; } -foreach ($_POST as $name => $value) -{ - $vars[$name] = $value; +foreach ($_POST as $name => $value) { + $vars[$name] = $value; } diff --git a/html/index.php b/html/index.php index 57fff1b57a..a3de9ba0c5 100644 --- a/html/index.php +++ b/html/index.php @@ -14,7 +14,8 @@ if( strstr($_SERVER['SERVER_SOFTWARE'],"nginx") ) { $_SERVER['PATH_INFO'] = str_replace($_SERVER['PATH_TRANSLATED'].$_SERVER['PHP_SELF'],"",$_SERVER['ORIG_SCRIPT_FILENAME']); -} else { +} +else { $_SERVER['PATH_INFO'] = !empty($_SERVER['PATH_INFO']) ? $_SERVER['PATH_INFO'] : (!empty($_SERVER['ORIG_PATH_INFO']) ? $_SERVER['ORIG_PATH_INFO'] : ''); } @@ -31,40 +32,40 @@ function catchFatal() { } } -if (strpos($_SERVER['PATH_INFO'], "debug")) -{ - $debug = "1"; - ini_set('display_errors', 0); - ini_set('display_startup_errors', 1); - ini_set('log_errors', 1); - ini_set('error_reporting', E_ALL); - set_error_handler('logErrors'); - register_shutdown_function('catchFatal'); -} else { - $debug = FALSE; - ini_set('display_errors', 0); - ini_set('display_startup_errors', 0); - ini_set('log_errors', 0); - ini_set('error_reporting', 0); +if (strpos($_SERVER['PATH_INFO'], "debug")) { + $debug = "1"; + ini_set('display_errors', 0); + ini_set('display_startup_errors', 1); + ini_set('log_errors', 1); + ini_set('error_reporting', E_ALL); + set_error_handler('logErrors'); + register_shutdown_function('catchFatal'); +} +else { + $debug = FALSE; + ini_set('display_errors', 0); + ini_set('display_startup_errors', 0); + ini_set('log_errors', 0); + ini_set('error_reporting', 0); } // Set variables $msg_box = array(); // Check for install.inc.php -if (!file_exists('../config.php') && $_SERVER['PATH_INFO'] != '/install.php') -{ - // no config.php does so let's redirect to the install - header('Location: /install.php'); - exit; +if (!file_exists('../config.php') && $_SERVER['PATH_INFO'] != '/install.php') { + // no config.php does so let's redirect to the install + header('Location: /install.php'); + exit; } -include("../includes/defaults.inc.php"); -include("../config.php"); -include_once("../includes/definitions.inc.php"); -include("../includes/functions.php"); -include("includes/functions.inc.php"); -include("includes/vars.inc.php"); -include('includes/plugins.inc.php'); +require '../includes/defaults.inc.php'; +require '../config.php'; +require_once '../includes/definitions.inc.php'; +require '../includes/functions.php'; +require 'includes/functions.inc.php'; +require 'includes/vars.inc.php'; +require 'includes/plugins.inc.php'; + Plugins::start(); $runtime_start = utime(); @@ -74,30 +75,33 @@ ob_start(); ini_set('allow_url_fopen', 0); ini_set('display_errors', 0); -include("includes/authenticate.inc.php"); +require 'includes/authenticate.inc.php'; -if (strstr($_SERVER['REQUEST_URI'], 'widescreen=yes')) { $_SESSION['widescreen'] = 1; } -if (strstr($_SERVER['REQUEST_URI'], 'widescreen=no')) { unset($_SESSION['widescreen']); } +if (strstr($_SERVER['REQUEST_URI'], 'widescreen=yes')) { + $_SESSION['widescreen'] = 1; +} +if (strstr($_SERVER['REQUEST_URI'], 'widescreen=no')) { + unset($_SESSION['widescreen']); +} # Load the settings for Multi-Tenancy. -if (isset($config['branding']) && is_array($config['branding'])) -{ - if ($config['branding'][$_SERVER['SERVER_NAME']]) - { - foreach ($config['branding'][$_SERVER['SERVER_NAME']] as $confitem => $confval) - { - eval("\$config['" . $confitem . "'] = \$confval;"); +if (isset($config['branding']) && is_array($config['branding'])) { + if ($config['branding'][$_SERVER['SERVER_NAME']]) { + foreach ($config['branding'][$_SERVER['SERVER_NAME']] as $confitem => $confval) { + eval("\$config['" . $confitem . "'] = \$confval;"); + } } - } else { - foreach ($config['branding']['default'] as $confitem => $confval) - { - eval("\$config['" . $confitem . "'] = \$confval;"); + else { + foreach ($config['branding']['default'] as $confitem => $confval) { + eval("\$config['" . $confitem . "'] = \$confval;"); + } } - } } # page_title_prefix is displayed, unless page_title is set -if (isset($config['page_title'])) { $config['page_title_prefix'] = $config['page_title']; } +if (isset($config['page_title'])) { + $config['page_title_prefix'] = $config['page_title']; +} ?> @@ -119,7 +123,8 @@ if (empty($config['favicon'])) { ' . "\n"); } ?> @@ -169,14 +174,13 @@ if (empty($config['favicon'])) { body { padding-top: 0px !important; - padding-bottom: 0px !important; }"; + padding-bottom: 0px !important; }"; } @@ -188,50 +192,47 @@ if ((isset($vars['bare']) && $vars['bare'] != "yes") || !isset($vars['bare'])) { "); - print_r($_GET); - print_r($vars); - echo(""); +if (isset($devel) || isset($vars['devel'])) { + echo("
    ");
    +    print_r($_GET);
    +    print_r($vars);
    +    echo("
    "); } -if ($_SESSION['authenticated']) -{ - // Authenticated. Print a page. - if (isset($vars['page']) && !strstr("..", $vars['page']) && is_file("pages/" . $vars['page'] . ".inc.php")) - { - include("pages/" . $vars['page'] . ".inc.php"); - } else { - if (isset($config['front_page']) && is_file($config['front_page'])) - { - include($config['front_page']); - } else { - include("pages/front/default.php"); +if ($_SESSION['authenticated']) { + // Authenticated. Print a page. + if (isset($vars['page']) && !strstr("..", $vars['page']) && is_file("pages/" . $vars['page'] . ".inc.php")) { + require "pages/" . $vars['page'] . ".inc.php"; + } + else { + if (isset($config['front_page']) && is_file($config['front_page'])) { + require $config['front_page']; + } + else { + require 'pages/front/default.php'; + } } - } -} else { - // Not Authenticated. Show status page if enabled - if ( $config['public_status'] === true ) - { - if (isset($vars['page']) && strstr("login", $vars['page'])) - { - include("pages/logon.inc.php"); - } else { - echo '
    '; - include("pages/public.inc.php"); - echo '
    '; - echo ''; +} +else { + // Not Authenticated. Show status page if enabled + if ( $config['public_status'] === true ) { + if (isset($vars['page']) && strstr("login", $vars['page'])) { + require 'pages/logon.inc.php'; + } + else { + echo '
    '; + require 'pages/public.inc.php'; + echo '
    '; + echo ''; + } + } + else { + require 'pages/logon.inc.php'; } - } - else - { - include("pages/logon.inc.php"); - } } ?> @@ -239,37 +240,42 @@ if ($_SESSION['authenticated']) MySQL: Cell '.($db_stats['fetchcell']+0).'/'.round($db_stats['fetchcell_sec']+0,3).'s'. - ' Row '.($db_stats['fetchrow']+0). '/'.round($db_stats['fetchrow_sec']+0,3).'s'. - ' Rows '.($db_stats['fetchrows']+0).'/'.round($db_stats['fetchrows_sec']+0,3).'s'. - ' Column '.($db_stats['fetchcol']+0). '/'.round($db_stats['fetchcol_sec']+0,3).'s'); +if ($config['page_gen']) { + echo('
    MySQL: Cell '.($db_stats['fetchcell']+0).'/'.round($db_stats['fetchcell_sec']+0,3).'s'. + ' Row '.($db_stats['fetchrow']+0). '/'.round($db_stats['fetchrow_sec']+0,3).'s'. + ' Rows '.($db_stats['fetchrows']+0).'/'.round($db_stats['fetchrows_sec']+0,3).'s'. + ' Column '.($db_stats['fetchcol']+0). '/'.round($db_stats['fetchcol_sec']+0,3).'s'); - $fullsize = memory_get_usage(); - unset($cache); - $cachesize = $fullsize - memory_get_usage(); - if ($cachesize < 0) { $cachesize = 0; } // Silly PHP! + $fullsize = memory_get_usage(); + unset($cache); + $cachesize = $fullsize - memory_get_usage(); + if ($cachesize < 0) { + $cachesize = 0; + } // Silly PHP! - echo('
    Cached data in memory is '.formatStorage($cachesize).'. Page memory usage is '.formatStorage($fullsize).', peaked at '. formatStorage(memory_get_peak_usage()) .'.'); - echo('
    Generated in ' . $gentime . ' seconds.'); + echo('
    Cached data in memory is '.formatStorage($cachesize).'. Page memory usage is '.formatStorage($fullsize).', peaked at '. formatStorage(memory_get_peak_usage()) .'.'); + echo('
    Generated in ' . $gentime . ' seconds.'); } -if (isset($pagetitle) && is_array($pagetitle)) -{ - # if prefix is set, put it in front - if ($config['page_title_prefix']) { array_unshift($pagetitle,$config['page_title_prefix']); } +if (isset($pagetitle) && is_array($pagetitle)) { + # if prefix is set, put it in front + if ($config['page_title_prefix']) { + array_unshift($pagetitle,$config['page_title_prefix']); + } - # if suffix is set, put it in the back - if ($config['page_title_suffix']) { $pagetitle[] = $config['page_title_suffix']; } + # if suffix is set, put it in the back + if ($config['page_title_suffix']) { + $pagetitle[] = $config['page_title_suffix']; + } - # create and set the title - $title = join(" - ",$pagetitle); - echo(""); + # create and set the title + $title = join(" - ",$pagetitle); + echo(""); } ?> @@ -295,23 +301,21 @@ if(dbFetchCell("SELECT COUNT(`device_id`) FROM `devices` WHERE `last_polled` <= } if(is_array($msg_box)) { - echo(""); + echo(""); } if (is_array($sql_debug) && is_array($php_debug) && $_SESSION['authenticated'] === TRUE) { - - include_once "includes/print-debug.php"; - + require_once "includes/print-debug.php"; } if ($no_refresh !== TRUE && $config['page_refresh'] != 0) { @@ -367,7 +371,8 @@ if ($no_refresh !== TRUE && $config['page_refresh'] != 0) { }); '); -} else { +} +else { echo(' +}//end if diff --git a/html/pages/alert-stats.inc.php b/html/pages/alert-stats.inc.php index d392f1dd20..ab9a0c57fd 100644 --- a/html/pages/alert-stats.inc.php +++ b/html/pages/alert-stats.inc.php @@ -1,12 +1,13 @@ -* This program is free software: you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation, either version 3 of the License, or (at your -* option) any later version. Please see LICENSE.txt at the top level of -* the source code distribution for details. -*/ -require_once('includes/print-graph-alerts.inc.php'); + * LibreNMS + * + * Copyright (c) 2015 Søren Friis Rosiak + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. Please see LICENSE.txt at the top level of + * the source code distribution for details. + */ + +require_once 'includes/print-graph-alerts.inc.php'; diff --git a/html/pages/alerts.inc.php b/html/pages/alerts.inc.php index bcc97a32a0..fae3fba5e5 100644 --- a/html/pages/alerts.inc.php +++ b/html/pages/alerts.inc.php @@ -13,7 +13,5 @@ */ $device['device_id'] = '-1'; -require_once('includes/print-alerts.php'); +require_once 'includes/print-alerts.php'; unset($device['device_id']); - -?> diff --git a/html/pages/api-access.inc.php b/html/pages/api-access.inc.php index a1b6e5a528..6b8a885a7a 100644 --- a/html/pages/api-access.inc.php +++ b/html/pages/api-access.inc.php @@ -12,22 +12,22 @@ * the source code distribution for details. */ -if ($_SESSION['userlevel'] >= '10') -{ -if(empty($_POST['token'])) { +if ($_SESSION['userlevel'] >= '10') { +if (empty($_POST['token'])) { $_POST['token'] = bin2hex(openssl_random_pseudo_bytes(16)); } + ?> -'); - if($_SESSION['api_token'] === TRUE) - { - echo(" - "); + "; unset($_SESSION['api_token']); - } -echo(' +} + +echo '
    @@ -127,19 +125,17 @@ echo(' Disabled Remove -'); +'; - foreach (dbFetchRows("SELECT `AT`.*,`U`.`username` FROM `api_tokens` AS AT JOIN users AS U ON AT.user_id=U.user_id ORDER BY AT.user_id") as $api) - { - if($api['disabled'] == '1') - { - $api_disabled = 'checked'; +foreach (dbFetchRows('SELECT `AT`.*,`U`.`username` FROM `api_tokens` AS AT JOIN users AS U ON AT.user_id=U.user_id ORDER BY AT.user_id') as $api) { + if ($api['disabled'] == '1') { + $api_disabled = 'checked'; } - else - { - $api_disabled = ''; + else { + $api_disabled = ''; } - echo(' + + echo ' '.$api['username'].' '.$api['token_hash'].' @@ -147,14 +143,14 @@ echo(' -'); - } +'; +} - echo(' + echo '
    -'); +'; ?> +else { + include 'includes/error-no-perm.inc.php'; +}//end if diff --git a/html/pages/api-docs.inc.php b/html/pages/api-docs.inc.php index c260b73cec..d3bd68b840 100644 --- a/html/pages/api-docs.inc.php +++ b/html/pages/api-docs.inc.php @@ -17,8 +17,7 @@
    here.'); +print_error('Documentation for the API has now been moved to GitHub, you can go straight to the API Wiki from here.'); ?>
    - diff --git a/html/pages/apps.inc.php b/html/pages/apps.inc.php index 1a20acc41f..cfd2378dde 100644 --- a/html/pages/apps.inc.php +++ b/html/pages/apps.inc.php @@ -1,54 +1,91 @@ Apps » "); +echo "Apps » "; unset($sep); -$link_array = array('page' => 'device', - 'device' => $device['device_id'], - 'tab' => 'apps'); +$link_array = array( + 'page' => 'device', + 'device' => $device['device_id'], + 'tab' => 'apps', +); -foreach ($app_list as $app) -{ - echo($sep); +foreach ($app_list as $app) { + echo $sep; -# if (!$vars['app']) { $vars['app'] = $app['app_type']; } + // if (!$vars['app']) { $vars['app'] = $app['app_type']; } + if ($vars['app'] == $app['app_type']) { + echo ""; + // echo(''); + } + else { + // echo(''); + } - if ($vars['app'] == $app['app_type']) - { - echo(""); - #echo(''); - } else { - #echo(''); - } - echo(generate_link(nicecase($app['app_type']),array('page'=>'apps','app'=>$app['app_type']))); - if ($vars['app'] == $app['app_type']) { echo(""); } - $sep = " | "; + echo generate_link(nicecase($app['app_type']), array('page' => 'apps', 'app' => $app['app_type'])); + if ($vars['app'] == $app['app_type']) { + echo ''; + } + + $sep = ' | '; } print_optionbar_end(); -if($vars['app']) -{ - if (is_file("pages/apps/".mres($vars['app']).".inc.php")) - { - include("pages/apps/".mres($vars['app']).".inc.php"); - } else { - include("pages/apps/default.inc.php"); - } -} else { - include("pages/apps/overview.inc.php"); +if ($vars['app']) { + if (is_file('pages/apps/'.mres($vars['app']).'.inc.php')) { + include 'pages/apps/'.mres($vars['app']).'.inc.php'; + } + else { + include 'pages/apps/default.inc.php'; + } +} +else { + include 'pages/apps/overview.inc.php'; } -$pagetitle[] = "Apps"; -?> +$pagetitle[] = 'Apps'; diff --git a/html/pages/apps/default.inc.php b/html/pages/apps/default.inc.php index e333674057..bf752de29c 100644 --- a/html/pages/apps/default.inc.php +++ b/html/pages/apps/default.inc.php @@ -1,45 +1,41 @@ '.nicecase($vars['app']).''); -echo(''); -$app_devices = dbFetchRows("SELECT * FROM `devices` AS D, `applications` AS A WHERE D.device_id = A.device_id AND A.app_type = ?", array($vars['app'])); +echo '

    '.nicecase($vars['app']).'

    '; +echo '
    '; +$app_devices = dbFetchRows('SELECT * FROM `devices` AS D, `applications` AS A WHERE D.device_id = A.device_id AND A.app_type = ?', array($vars['app'])); -foreach ($app_devices as $app_device) -{ - echo(''); - echo(''); - echo(''); - echo(''); - echo(''); - echo(''); - echo(''); - echo(''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''); - echo(''); -} + echo ''; + echo ''; +}//end foreach -echo('
    '.generate_device_link($app_device, shorthost($app_device['hostname']), array('tab'=>'apps','app'=>$vars['app'])).''.$app_device['app_instance'].''.$app_device['app_status'].'
    '); +foreach ($app_devices as $app_device) { + echo '
    '.generate_device_link($app_device, shorthost($app_device['hostname']), array('tab' => 'apps', 'app' => $vars['app'])).''.$app_device['app_instance'].''.$app_device['app_status'].'
    '; - foreach ($graphs[$vars['app']] as $graph_type) - { - $graph_array['type'] = "application_".$vars['app']."_".$graph_type; - $graph_array['id'] = $app_device['app_id']; - $graph_array_zoom['type'] = "application_".$vars['app']."_".$graph_type; - $graph_array_zoom['id'] = $app_device['app_id']; + foreach ($graphs[$vars['app']] as $graph_type) { + $graph_array['type'] = 'application_'.$vars['app'].'_'.$graph_type; + $graph_array['id'] = $app_device['app_id']; + $graph_array_zoom['type'] = 'application_'.$vars['app'].'_'.$graph_type; + $graph_array_zoom['id'] = $app_device['app_id']; - $link = generate_url(array('page' => 'device', 'device' => $app_device['device_id'],'tab'=>'apps','app'=>$vars['app'])); + $link = generate_url(array('page' => 'device', 'device' => $app_device['device_id'], 'tab' => 'apps', 'app' => $vars['app'])); - echo(overlib_link($link, generate_graph_tag($graph_array), generate_graph_tag($graph_array_zoom), NULL)); - } + echo overlib_link($link, generate_graph_tag($graph_array), generate_graph_tag($graph_array_zoom), null); + } - echo('
    '); - -?> +echo ''; diff --git a/html/pages/authlog.inc.php b/html/pages/authlog.inc.php index 64b4080ad2..3cffbbea9e 100644 --- a/html/pages/authlog.inc.php +++ b/html/pages/authlog.inc.php @@ -1,37 +1,37 @@ = '10') -{ - echo(""); +if ($_SESSION['userlevel'] >= '10') { + echo '
    '; - foreach (dbFetchRows("SELECT *,DATE_FORMAT(datetime, '".$config['dateformat']['mysql']['compact']."') as humandate FROM `authlog` ORDER BY `datetime` DESC LIMIT 0,250") as $entry) - { - if ($bg == $list_colour_a) { $bg = $list_colour_b; } else { $bg=$list_colour_a; } + foreach (dbFetchRows("SELECT *,DATE_FORMAT(datetime, '".$config['dateformat']['mysql']['compact']."') as humandate FROM `authlog` ORDER BY `datetime` DESC LIMIT 0,250") as $entry) { + if ($bg == $list_colour_a) { + $bg = $list_colour_b; + } + else { + $bg = $list_colour_a; + } - echo(" - - - - - - "); - } + echo " + + + + + + '; + }//end foreach - $pagetitle[] = "Authlog"; + $pagetitle[] = 'Authlog'; - echo("
    - " . $entry['datetime'] . " - - ".$entry['user']." - - ".$entry['address']." - - ".$entry['result']." -
    + ".$entry['datetime'].' + + '.$entry['user'].' + + '.$entry['address'].' + + '.$entry['result'].' +
    "); + echo ''; } -else -{ - include("includes/error-no-perm.inc.php"); -} - -?> +else { + include 'includes/error-no-perm.inc.php'; +}//end if diff --git a/html/pages/bill.inc.php b/html/pages/bill.inc.php index 13b640057b..03faf35c17 100644 --- a/html/pages/bill.inc.php +++ b/html/pages/bill.inc.php @@ -2,255 +2,274 @@ $bill_id = mres($vars['bill_id']); -if ($_SESSION['userlevel'] >= "10") -{ - include("pages/bill/actions.inc.php"); +if ($_SESSION['userlevel'] >= '10') { + include 'pages/bill/actions.inc.php'; } -if (bill_permitted($bill_id)) -{ - $bill_data = dbFetchRow("SELECT * FROM bills WHERE bill_id = ?", array($bill_id)); +if (bill_permitted($bill_id)) { + $bill_data = dbFetchRow('SELECT * FROM bills WHERE bill_id = ?', array($bill_id)); - $bill_name = $bill_data['bill_name']; + $bill_name = $bill_data['bill_name']; - $today = str_replace("-", "", dbFetchCell("SELECT CURDATE()")); - $yesterday = str_replace("-", "", dbFetchCell("SELECT DATE_SUB(CURDATE(), INTERVAL 1 DAY)")); - $tomorrow = str_replace("-", "", dbFetchCell("SELECT DATE_ADD(CURDATE(), INTERVAL 1 DAY)")); - $last_month = str_replace("-", "", dbFetchCell("SELECT DATE_SUB(CURDATE(), INTERVAL 1 MONTH)")); + $today = str_replace('-', '', dbFetchCell('SELECT CURDATE()')); + $yesterday = str_replace('-', '', dbFetchCell('SELECT DATE_SUB(CURDATE(), INTERVAL 1 DAY)')); + $tomorrow = str_replace('-', '', dbFetchCell('SELECT DATE_ADD(CURDATE(), INTERVAL 1 DAY)')); + $last_month = str_replace('-', '', dbFetchCell('SELECT DATE_SUB(CURDATE(), INTERVAL 1 MONTH)')); - $rightnow = $today . date(His); - $before = $yesterday . date(His); - $lastmonth = $last_month . date(His); + $rightnow = $today.date(His); + $before = $yesterday.date(His); + $lastmonth = $last_month.date(His); - $bill_name = $bill_data['bill_name']; - $dayofmonth = $bill_data['bill_day']; + $bill_name = $bill_data['bill_name']; + $dayofmonth = $bill_data['bill_day']; - $day_data = getDates($dayofmonth); + $day_data = getDates($dayofmonth); - $datefrom = $day_data['0']; - $dateto = $day_data['1']; - $lastfrom = $day_data['2']; - $lastto = $day_data['3']; + $datefrom = $day_data['0']; + $dateto = $day_data['1']; + $lastfrom = $day_data['2']; + $lastto = $day_data['3']; - $rate_95th = $bill_data['rate_95th']; - $dir_95th = $bill_data['dir_95th']; - $total_data = $bill_data['total_data']; - $rate_average = $bill_data['rate_average']; + $rate_95th = $bill_data['rate_95th']; + $dir_95th = $bill_data['dir_95th']; + $total_data = $bill_data['total_data']; + $rate_average = $bill_data['rate_average']; - if ($rate_95th > $paid_kb) - { - $over = $rate_95th - $paid_kb; - $bill_text = $over . "Kbit excess."; - $bill_color = "#cc0000"; - } - else - { - $under = $paid_kb - $rate_95th; - $bill_text = $under . "Kbit headroom."; - $bill_color = "#0000cc"; - } - - $fromtext = dbFetchCell("SELECT DATE_FORMAT($datefrom, '".$config['dateformat']['mysql']['date']."')"); - $totext = dbFetchCell("SELECT DATE_FORMAT($dateto, '".$config['dateformat']['mysql']['date']."')"); - $unixfrom = dbFetchCell("SELECT UNIX_TIMESTAMP('$datefrom')"); - $unixto = dbFetchCell("SELECT UNIX_TIMESTAMP('$dateto')"); - - $unix_prev_from = dbFetchCell("SELECT UNIX_TIMESTAMP('$lastfrom')"); - $unix_prev_to = dbFetchCell("SELECT UNIX_TIMESTAMP('$lastto')"); - # Speeds up loading for other included pages by setting it before progessing of mysql data! - - $ports = dbFetchRows("SELECT * FROM `bill_ports` AS B, `ports` AS P, `devices` AS D - WHERE B.bill_id = ? AND P.port_id = B.port_id - AND D.device_id = P.device_id", array($bill_id)); - - echo("

    - Bill : " . $bill_data['bill_name'] . "

    "); - - print_optionbar_start(); - - echo("Bill » "); - - if (!$vars['view']) { $vars['view'] = "quick"; } - - if ($vars['view'] == "quick") { echo(""); } - echo('Quick Graphs'); - if ($vars['view'] == "quick") { echo(""); } - - echo(" | "); - - if ($vars['view'] == "accurate") { echo(""); } - echo('Accurate Graphs'); - if ($vars['view'] == "accurate") { echo(""); } - - echo(" | "); - - if ($vars['view'] == "transfer") { echo(""); } - echo('Transfer Graphs'); - if ($vars['view'] == "transfer") { echo(""); } - - echo(" | "); - - if ($vars['view'] == "history") { echo(""); } - echo('Historical Usage'); - if ($vars['view'] == "history") { echo(""); } - - if ($_SESSION['userlevel'] >= "10") - { - echo(" | "); - if ($vars['view'] == "edit") { echo(""); } - echo('Edit'); - if ($vars['view'] == "edit") { echo(""); } - - echo(" | "); - if ($vars['view'] == "delete") { echo(""); } - echo('Delete'); - if ($vars['view'] == "delete") { echo(""); } - - echo(" | "); - if ($vars['view'] == "reset") { echo(""); } - echo('Reset'); - if ($vars['view'] == "reset") { echo(""); } - } - - echo(''); - - print_optionbar_end(); - - if ($vars['view'] == "edit" && $_SESSION['userlevel'] >= "10") - { - include("pages/bill/edit.inc.php"); - } - elseif ($vars['view'] == "delete" && $_SESSION['userlevel'] >= "10") - { - include("pages/bill/delete.inc.php"); - } - elseif ($vars['view'] == "reset" && $_SESSION['userlevel'] >= "10") - { - include("pages/bill/reset.inc.php"); - } - elseif ($vars['view'] == "history") - { - include("pages/bill/history.inc.php"); - } - elseif ($vars['view'] == "transfer") - { - include("pages/bill/transfer.inc.php"); - } - elseif ($vars['view'] == "quick" || $vars['view'] == "accurate") { - - echo("

    Billed Ports

    "); - - // Collected Earlier - foreach ($ports as $port) - { - echo(generate_port_link($port) . " on " . generate_device_link($port) . "
    "); + if ($rate_95th > $paid_kb) { + $over = ($rate_95th - $paid_kb); + $bill_text = $over.'Kbit excess.'; + $bill_color = '#cc0000'; + } + else { + $under = ($paid_kb - $rate_95th); + $bill_text = $under.'Kbit headroom.'; + $bill_color = '#0000cc'; } - echo("

    Bill Summary

    "); + $fromtext = dbFetchCell("SELECT DATE_FORMAT($datefrom, '".$config['dateformat']['mysql']['date']."')"); + $totext = dbFetchCell("SELECT DATE_FORMAT($dateto, '".$config['dateformat']['mysql']['date']."')"); + $unixfrom = dbFetchCell("SELECT UNIX_TIMESTAMP('$datefrom')"); + $unixto = dbFetchCell("SELECT UNIX_TIMESTAMP('$dateto')"); - if ($bill_data['bill_type'] == "quota") - { - // The Customer is billed based on a pre-paid quota with overage in xB + $unix_prev_from = dbFetchCell("SELECT UNIX_TIMESTAMP('$lastfrom')"); + $unix_prev_to = dbFetchCell("SELECT UNIX_TIMESTAMP('$lastto')"); + // Speeds up loading for other included pages by setting it before progessing of mysql data! + $ports = dbFetchRows( + 'SELECT * FROM `bill_ports` AS B, `ports` AS P, `devices` AS D + WHERE B.bill_id = ? AND P.port_id = B.port_id + AND D.device_id = P.device_id', + array($bill_id) + ); - echo("

    Quota Bill

    "); + echo '

    + Bill : '.$bill_data['bill_name'].'

    '; - $percent = round(($total_data) / $bill_data['bill_quota'] * 100, 2); - $unit = "MB"; - $total_data = round($total_data, 2); - echo("Billing Period from " . $fromtext . " to " . $totext); - echo("
    Transferred ".format_bytes_billing($total_data)." of ".format_bytes_billing($bill_data['bill_quota'])." (".$percent."%)"); - echo("
    Average rate " . formatRates($rate_average)); + print_optionbar_start(); - $background = get_percentage_colours($percent); + echo "Bill » "; - echo("

    ".print_percentage_bar (350, 20, $perc, NULL, "ffffff", $background['left'], $percent . "%", "ffffff", $background['right'])."

    "); - - $type="&ave=yes"; - } - elseif ($bill_data['bill_type'] == "cdr") - { - // The customer is billed based on a CDR with 95th%ile overage - - echo("

    CDR / 95th Bill

    "); - - $unit = "kbps"; - $cdr = $bill_data['bill_cdr']; - $rate_95th = round($rate_95th, 2); - - $percent = round(($rate_95th) / $cdr * 100, 2); - - $type="&95th=yes"; - - echo("" . $fromtext . " to " . $totext . " -
    Measured ".format_si($rate_95th)."bps of ".format_si($cdr)."bps (".$percent."%) @ 95th %ile"); - - $background = get_percentage_colours($percent); - - echo("

    ".print_percentage_bar (350, 20, $percent, NULL, "ffffff", $background['left'], $percent . "%", "ffffff", $background['right'])."

    "); - - # echo("

    Billing Period : " . $fromtext . " to " . $totext . "
    - # " . $paidrate_text . "
    - # " . $total_data . "MB transfered in the current billing cycle.
    - # " . $rate_average . "Kbps Average during the current billing cycle.

    - # " . $rate_95th . "Kbps @ 95th Percentile. (" . $dir_95th . ") (" . $bill_text . ") - # - #
    "); + if (!$vars['view']) { + $vars['view'] = 'quick'; } - $lastmonth = dbFetchCell("SELECT UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 1 MONTH))"); - $yesterday = dbFetchCell("SELECT UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 1 DAY))"); - $rightnow = date(U); - - if ($vars['view'] == "accurate") { - - $bi = ""; - - $li = ""; - - $di = ""; - - $mi = ""; - + if ($vars['view'] == 'quick') { + echo ""; } - if ($null) - { - echo(" - @@ -268,39 +287,32 @@ if (bill_permitted($bill_id)) - "); + "; + }//end if - } - - if ($_GET['all']) - { - $ai = ""; - echo("

    Entire Data View

    $ai"); - } - elseif ($_GET['custom']) - { - $cg = ""; - echo("

    Custom Graph

    $cg"); - } - else - { - echo("

    Billing View

    $bi"); -# echo("

    Previous Bill View

    $li"); - echo("

    24 Hour View

    $di"); - echo("

    Monthly View

    $mi"); -# echo("
    Graph All Data (SLOW)"); - } - } # End if details + if ($_GET['all']) { + $ai = ''; + echo "

    Entire Data View

    $ai"; + } + else if ($_GET['custom']) { + $cg = ''; + echo "

    Custom Graph

    $cg"; + } + else { + echo "

    Billing View

    $bi"; + // echo("

    Previous Bill View

    $li"); + echo "

    24 Hour View

    $di"; + echo "

    Monthly View

    $mi"; + // echo("
    Graph All Data (SLOW)"); + }//end if + } //end if } -else -{ - include("includes/error-no-perm.inc.php"); -} - -?> +else { + include 'includes/error-no-perm.inc.php'; +}//end if diff --git a/html/pages/bill/actions.inc.php b/html/pages/bill/actions.inc.php index d55c2944cc..29afb6d3b4 100644 --- a/html/pages/bill/actions.inc.php +++ b/html/pages/bill/actions.inc.php @@ -1,8 +1,7 @@ = 1) { + $quota = array( + 'type' => 'tb', + 'select_tb' => ' selected', + 'data' => $tmp['tb'], + ); + } + else if (($tmp['gb'] >= 1) and ($tmp['gb'] < $base)) { + $quota = array( + 'type' => 'gb', + 'select_gb' => ' selected', + 'data' => $tmp['gb'], + ); + } + else if (($tmp['mb'] >= 1) and ($tmp['mb'] < $base)) { + $quota = array( + 'type' => 'mb', + 'select_mb' => ' selected', + 'data' => $tmp['mb'], + ); + } +}//end if -if ($bill_data['bill_type'] == "quota") { - $data = $bill_data['bill_quota']; - $tmp['mb'] = $data / $base / $base; - $tmp['gb'] = $data / $base / $base / $base; - $tmp['tb'] = $data / $base / $base / $base / $base; - if ($tmp['tb']>=1) { $quota = array("type" => "tb", "select_tb" => " selected", "data" => $tmp['tb']); } - elseif (($tmp['gb']>=1) and ($tmp['gb']<$base)) { $quota = array("type" => "gb", "select_gb" => " selected", "data" => $tmp['gb']); } - elseif (($tmp['mb']>=1) and ($tmp['mb']<$base)) { $quota = array("type" => "mb", "select_mb" => " selected", "data" => $tmp['mb']); } -} -if ($bill_data['bill_type'] == "cdr") { - $data = $bill_data['bill_cdr']; - $tmp['kbps'] = $data / $base; - $tmp['mbps'] = $data / $base / $base; - $tmp['gbps'] = $data / $base / $base / $base; - if ($tmp['gbps']>=1) { $cdr = array("type" => "gbps", "select_gbps" => " selected", "data" => $tmp['gbps']); } - elseif (($tmp['mbps']>=1) and ($tmp['mbps']<$base)) { $cdr = array("type" => "mbps", "select_mbps" => " selected", "data" => $tmp['mbps']); } - elseif (($tmp['kbps']>=1) and ($tmp['kbps']<$base)) { $cdr = array("type" => "kbps", "select_kbps" => " selected", "data" => $tmp['kbps']); } -} +if ($bill_data['bill_type'] == 'cdr') { + $data = $bill_data['bill_cdr']; + $tmp['kbps'] = ($data / $base); + $tmp['mbps'] = ($data / $base / $base); + $tmp['gbps'] = ($data / $base / $base / $base); + if ($tmp['gbps'] >= 1) { + $cdr = array( + 'type' => 'gbps', + 'select_gbps' => ' selected', + 'data' => $tmp['gbps'], + ); + } + else if (($tmp['mbps'] >= 1) and ($tmp['mbps'] < $base)) { + $cdr = array( + 'type' => 'mbps', + 'select_mbps' => ' selected', + 'data' => $tmp['mbps'], + ); + } + else if (($tmp['kbps'] >= 1) and ($tmp['kbps'] < $base)) { + $cdr = array( + 'type' => 'kbps', + 'select_kbps' => ' selected', + 'data' => $tmp['kbps'], + ); + } +}//end if ?>
    - +

    Bill Properties

    - " /> +
    @@ -51,17 +86,35 @@ if ($bill_data['bill_type'] == "cdr") {
    - -
    @@ -121,19 +124,19 @@ foreach ($config['device_types'] as $type)
    - value="" /> + value="" />
    - /> + />
    - /> + />
    diff --git a/html/pages/device/edit/health.inc.php b/html/pages/device/edit/health.inc.php index 3d7d213527..922bb36c77 100644 --- a/html/pages/device/edit/health.inc.php +++ b/html/pages/device/edit/health.inc.php @@ -30,156 +30,158 @@ $sensor['sensor_id'], 'sensor_limit' => $sensor['sensor_limit'], 'sensor_limit_low' => $sensor['sensor_limit_low'], 'sensor_alert' => $sensor['sensor_alert']); - if($sensor['sensor_alert'] == 1) - { - $alert_status = 'checked'; - } - else - { - $alert_status = ''; - } - if ($sensor['sensor_custom'] == 'No') { - $custom = 'disabled'; - } else { - $custom = ''; - } - echo(' - - '.$sensor['sensor_class'].' - '.$sensor['sensor_type'].' - '.$sensor['sensor_descr'].' - '.$sensor['sensor_current'].' - -
    +foreach (dbFetchRows("SELECT * FROM sensors WHERE device_id = ? AND sensor_deleted='0'", array($device['device_id'])) as $sensor) { + $rollback[] = array( + 'sensor_id' => $sensor['sensor_id'], + 'sensor_limit' => $sensor['sensor_limit'], + 'sensor_limit_low' => $sensor['sensor_limit_low'], + 'sensor_alert' => $sensor['sensor_alert'], + ); + if ($sensor['sensor_alert'] == 1) { + $alert_status = 'checked'; + } + else { + $alert_status = ''; + } + + if ($sensor['sensor_custom'] == 'No') { + $custom = 'disabled'; + } + else { + $custom = ''; + } + + echo ' + + '.$sensor['sensor_class'].' + '.$sensor['sensor_type'].' + '.$sensor['sensor_descr'].' + '.$sensor['sensor_current'].' + +
    -
    - - -
    +
    + + +
    -
    - - - - - +
    + + + + + Clear custom - - -'); + + + '; } - ?>
    - - - - '); +foreach ($rollback as $reset_data) { + echo ' + + + + + '; } ?>
    - diff --git a/html/pages/device/edit/ipmi.inc.php b/html/pages/device/edit/ipmi.inc.php index f3971ca413..0aff50bdd7 100644 --- a/html/pages/device/edit/ipmi.inc.php +++ b/html/pages/device/edit/ipmi.inc.php @@ -1,31 +1,45 @@ "7") - { - $ipmi_hostname = mres($_POST['ipmi_hostname']); - $ipmi_username = mres($_POST['ipmi_username']); - $ipmi_password = mres($_POST['ipmi_password']); +if ($_POST['editing']) { + if ($_SESSION['userlevel'] > '7') { + $ipmi_hostname = mres($_POST['ipmi_hostname']); + $ipmi_username = mres($_POST['ipmi_username']); + $ipmi_password = mres($_POST['ipmi_password']); - if ($ipmi_hostname != '') { set_dev_attrib($device, 'ipmi_hostname', $ipmi_hostname); } else { del_dev_attrib($device, 'ipmi_hostname'); } - if ($ipmi_username != '') { set_dev_attrib($device, 'ipmi_username', $ipmi_username); } else { del_dev_attrib($device, 'ipmi_username'); } - if ($ipmi_password != '') { set_dev_attrib($device, 'ipmi_password', $ipmi_password); } else { del_dev_attrib($device, 'ipmi_password'); } + if ($ipmi_hostname != '') { + set_dev_attrib($device, 'ipmi_hostname', $ipmi_hostname); + } + else { + del_dev_attrib($device, 'ipmi_hostname'); + } - $update_message = "Device IPMI data updated."; - $updated = 1; - } - else - { - include("includes/error-no-perm.inc.php"); - } + if ($ipmi_username != '') { + set_dev_attrib($device, 'ipmi_username', $ipmi_username); + } + else { + del_dev_attrib($device, 'ipmi_username'); + } + + if ($ipmi_password != '') { + set_dev_attrib($device, 'ipmi_password', $ipmi_password); + } + else { + del_dev_attrib($device, 'ipmi_password'); + } + + $update_message = 'Device IPMI data updated.'; + $updated = 1; + } + else { + include 'includes/error-no-perm.inc.php'; + }//end if +}//end if + +if ($updated && $update_message) { + print_message($update_message); } - -if ($updated && $update_message) -{ - print_message($update_message); -} elseif ($update_message) { - print_error($update_message); +else if ($update_message) { + print_error($update_message); } ?> @@ -37,19 +51,19 @@ if ($updated && $update_message)
    - +
    - +
    - +
    diff --git a/html/pages/device/edit/modules.inc.php b/html/pages/device/edit/modules.inc.php index 36a53b3f10..3196171626 100644 --- a/html/pages/device/edit/modules.inc.php +++ b/html/pages/device/edit/modules.inc.php @@ -17,68 +17,57 @@ $module_status) -{ - echo(' +foreach ($config['poller_modules'] as $module => $module_status) { + echo(' '.$module.' -'); + '); - if($module_status == 1) - { - echo('Enabled'); - } - else - { - echo('Disabled'); - } + if($module_status == 1) { + echo('Enabled'); + } + else { + echo('Disabled'); + } - echo(' + echo(' -'); + '); - if (isset($attribs['poll_'.$module])) - { - if ($attribs['poll_'.$module]) - { - echo('Enabled'); - $module_checked = 'checked'; + if (isset($attribs['poll_'.$module])) { + if ($attribs['poll_'.$module]) { + echo('Enabled'); + $module_checked = 'checked'; + } + else { + echo('Disabled'); + $module_checked = ''; + } } - else - { - echo('Disabled'); - $module_checked = ''; + else { + if($module_status == 1) { + echo('Enabled'); + $module_checked = 'checked'; + } + else { + echo('Disabled'); + $module_checked = ''; + } } - } - else - { - if($module_status == 1) - { - echo('Enabled'); - $module_checked = 'checked'; - } - else - { - echo('Disabled'); - $module_checked = ''; - } - } - echo(' + echo(' -'); + '); - echo(' - -'); + echo(''); - echo(' + echo(' -'); + '); } ?> @@ -96,71 +85,56 @@ foreach ($config['poller_modules'] as $module => $module_status) $module_status) -{ - - echo(' +foreach ($config['discovery_modules'] as $module => $module_status) { + echo(' '.$module.' -'); + '); - if($module_status == 1) - { - echo('Enabled'); - } - else - { - echo('Disabled'); - } + if($module_status == 1) { + echo('Enabled'); + } + else { + echo('Disabled'); + } - echo(' + echo(' - -'); + '); - if (isset($attribs['discover_'.$module])) - { - if($attribs['discover_'.$module]) - { - echo('Enabled'); - $module_checked = 'checked'; + if (isset($attribs['discover_'.$module])) { + if($attribs['discover_'.$module]) { + echo('Enabled'); + $module_checked = 'checked'; + } + else { + echo('Disabled'); + $module_checked = ''; + } } - else - { - echo('Disabled'); - $module_checked = ''; + else { + if($module_status == 1) { + echo('Enabled'); + $module_checked = 'checked'; + } + else { + echo('Disabled'); + $module_checked = ''; + } } - } - else - { - if($module_status == 1) - { - echo('Enabled'); - $module_checked = 'checked'; - } - else - { - echo('Disabled'); - $module_checked = ''; - } - } - echo(' + echo(' - -'); + '); - echo(' - -'); + echo(''); - echo(' + echo(' - -'); + '); } echo(' diff --git a/html/pages/device/edit/ports.inc.php b/html/pages/device/edit/ports.inc.php index b382cf05a8..d8dc562e43 100644 --- a/html/pages/device/edit/ports.inc.php +++ b/html/pages/device/edit/ports.inc.php @@ -1,28 +1,26 @@ '); +echo '
    '; -if ($_POST['ignoreport']) -{ - if ($_SESSION['userlevel'] == '10') - { - include("includes/port-edit.inc.php"); - } +if ($_POST['ignoreport']) { + if ($_SESSION['userlevel'] == '10') { + include 'includes/port-edit.inc.php'; + } } -if ($updated && $update_message) -{ - print_message($update_message); -} elseif ($update_message) { - print_error($update_message); +if ($updated && $update_message) { + print_message($update_message); +} +else if ($update_message) { + print_error($update_message); } -echo("
    +echo "
    - "); + "; -echo(" +echo "
    @@ -41,14 +39,14 @@ echo("
    Index Name
    -"); +"; ?> '; + echo ''; + echo ''; + echo ''; - echo(""); - echo(""); - echo(""); - echo(""); + // Mark interfaces which are OperDown (but not AdminDown) yet not ignored or disabled, or up yet ignored or disabled + // - as to draw the attention to a possible problem. + $isportbad = ($port['ifOperStatus'] == 'down' && $port['ifAdminStatus'] != 'down') ? 1 : 0; + $dowecare = ($port['ignore'] == 0 && $port['disabled'] == 0) ? $isportbad : !$isportbad; + $outofsync = $dowecare ? " class='red'" : ''; - # Mark interfaces which are OperDown (but not AdminDown) yet not ignored or disabled, or up yet ignored or disabled - # - as to draw the attention to a possible problem. - $isportbad = ($port['ifOperStatus'] == 'down' && $port['ifAdminStatus'] != 'down') ? 1 : 0; - $dowecare = ($port['ignore'] == 0 && $port['disabled'] == 0) ? $isportbad : !$isportbad; - $outofsync = $dowecare ? " class='red'" : ""; + echo "'; - echo(""); + echo '"); + echo '"); - echo(""); + echo "\n"; - echo("\n"); + $row++; +}//end foreach - $row++; -} - -echo('
    '.$port['ifIndex'].''.$port['label'].''.$port['ifAdminStatus'].'
    ". $port['ifIndex']."".$port['label'] . "". $port['ifAdminStatus']."'.$port['ifOperStatus'].'". $port['ifOperStatus']."'; + echo "'; + echo ""); - echo(""); - echo(""); - echo("'; + echo "'; + echo ""); - echo(""); - echo(""); - echo("".$port['ifAlias'] . "
    '); -echo('
    '); -echo('
    '); - -?> +echo ''; +echo ''; +echo '
    '; diff --git a/html/pages/device/edit/services.inc.php b/html/pages/device/edit/services.inc.php index e6969a9fe9..1f2bc1d30e 100644 --- a/html/pages/device/edit/services.inc.php +++ b/html/pages/device/edit/services.inc.php @@ -1,29 +1,28 @@ = '10') { - include("includes/service-add.inc.php"); + include 'includes/service-add.inc.php'; } } if ($_POST['delsrv']) { if ($_SESSION['userlevel'] >= '10') { - include("includes/service-delete.inc.php"); + include 'includes/service-delete.inc.php'; } } if ($_POST['confirm-editsrv']) { - echo "yeah"; + echo 'yeah'; if ($_SESSION['userlevel'] >= '10') { - include("includes/service-edit.inc.php"); + include 'includes/service-edit.inc.php'; } } - if ($handle = opendir($config['install_dir'] . "/includes/services/")) { + if ($handle = opendir($config['install_dir'].'/includes/services/')) { while (false !== ($file = readdir($handle))) { - if ($file != "." && $file != ".." && !strstr($file, ".")) { + if ($file != '.' && $file != '..' && !strstr($file, '.')) { $servicesform .= ""; } } @@ -31,17 +30,17 @@ if (is_admin() === TRUE || is_read() === TRUE) { closedir($handle); } - $dev = device_by_id_cache($device['device_id']); - $devicesform = ""; + $dev = device_by_id_cache($device['device_id']); + $devicesform = "'; if ($updated) { - print_message("Device Settings Saved"); + print_message('Device Settings Saved'); } - if (dbFetchCell("SELECT COUNT(*) from `services` WHERE `device_id` = ?", array($device['device_id'])) > '0') { - $i = "1"; - foreach (dbFetchRows("select * from services WHERE device_id = ? ORDER BY service_type", array($device['device_id'])) as $service) { - $existform .= ""; + if (dbFetchCell('SELECT COUNT(*) from `services` WHERE `device_id` = ?', array($device['device_id'])) > '0') { + $i = '1'; + foreach (dbFetchRows('select * from services WHERE device_id = ? ORDER BY service_type', array($device['device_id'])) as $service) { + $existform .= "'; } } @@ -49,28 +48,29 @@ if (is_admin() === TRUE || is_read() === TRUE) { if ($existform) { echo '
    '; - if ($_POST['editsrv'] == "yes") { - include_once "includes/print-service-edit.inc.php"; - } else { + if ($_POST['editsrv'] == 'yes') { + include_once 'includes/print-service-edit.inc.php'; + } + else { echo " -

    Edit / Delete Service

    -
    +

    Edit / Delete Service

    +
    -
    - -
    - -
    -
    -
    -
    - -
    -
    +
    + +
    +
    - "; +
    +
    +
    + +
    +
    +
    + "; } echo '
    '; @@ -78,8 +78,8 @@ if (is_admin() === TRUE || is_read() === TRUE) { echo '
    '; - require_once "includes/print-service-add.inc.php"; - -} else { - include("includes/error-no-perm.inc.php"); -} \ No newline at end of file + include_once 'includes/print-service-add.inc.php'; +} +else { + include 'includes/error-no-perm.inc.php'; +} diff --git a/html/pages/device/edit/snmp.inc.php b/html/pages/device/edit/snmp.inc.php index 9e8a5b7b04..59c6bf4cd3 100644 --- a/html/pages/device/edit/snmp.inc.php +++ b/html/pages/device/edit/snmp.inc.php @@ -1,225 +1,240 @@ "7") - { - $community = mres($_POST['community']); - $snmpver = mres($_POST['snmpver']); - $transport = $_POST['transport'] ? mres($_POST['transport']) : $transport = "udp"; - $port = $_POST['port'] ? mres($_POST['port']) : $config['snmp']['port']; - $timeout = mres($_POST['timeout']); - $retries = mres($_POST['retries']); - $poller_group = mres($_POST['poller_group']); - $v3 = array ( - 'authlevel' => mres($_POST['authlevel']), - 'authname' => mres($_POST['authname']), - 'authpass' => mres($_POST['authpass']), - 'authalgo' => mres($_POST['authalgo']), - 'cryptopass' => mres($_POST['cryptopass']), - 'cryptoalgo' => mres($_POST['cryptoalgo']) - ); +if ($_POST['editing']) { + if ($_SESSION['userlevel'] > '7') { + $community = mres($_POST['community']); + $snmpver = mres($_POST['snmpver']); + $transport = $_POST['transport'] ? mres($_POST['transport']) : $transport = 'udp'; + $port = $_POST['port'] ? mres($_POST['port']) : $config['snmp']['port']; + $timeout = mres($_POST['timeout']); + $retries = mres($_POST['retries']); + $poller_group = mres($_POST['poller_group']); + $v3 = array( + 'authlevel' => mres($_POST['authlevel']), + 'authname' => mres($_POST['authname']), + 'authpass' => mres($_POST['authpass']), + 'authalgo' => mres($_POST['authalgo']), + 'cryptopass' => mres($_POST['cryptopass']), + 'cryptoalgo' => mres($_POST['cryptoalgo']), + ); - #FIXME needs better feedback - $update = array( - 'community' => $community, - 'snmpver' => $snmpver, - 'port' => $port, - 'transport' => $transport, - 'poller_group' => $poller_group - ); + // FIXME needs better feedback + $update = array( + 'community' => $community, + 'snmpver' => $snmpver, + 'port' => $port, + 'transport' => $transport, + 'poller_group' => $poller_group, + ); - if ($_POST['timeout']) { $update['timeout'] = $timeout; } - else { $update['timeout'] = array('NULL'); } - if ($_POST['retries']) { $update['retries'] = $retries; } - else { $update['retries'] = array('NULL'); } - - $update = array_merge($update, $v3); - - $device_tmp = deviceArray($device['hostname'], $community, $snmpver, $port, $transport, $v3); - if (isSNMPable($device_tmp)) { - $rows_updated = dbUpdate($update, 'devices', '`device_id` = ?',array($device['device_id'])); - - if ($rows_updated > 0) { - $update_message = $rows_updated . " Device record updated."; - $updated = 1; - } elseif ($rows_updated = '-1') { - $update_message = "Device record unchanged. No update necessary."; - $updated = -1; - } else { - $update_message = "Device record update error."; - $updated = 0; + if ($_POST['timeout']) { + $update['timeout'] = $timeout; + } + else { + $update['timeout'] = array('NULL'); } - } else { - $update_message = "Could not connect to device with new SNMP details"; - $updated = 0; - } - } -} -$device = dbFetchRow("SELECT * FROM `devices` WHERE `device_id` = ?", array($device['device_id'])); + if ($_POST['retries']) { + $update['retries'] = $retries; + } + else { + $update['retries'] = array('NULL'); + } + + $update = array_merge($update, $v3); + + $device_tmp = deviceArray($device['hostname'], $community, $snmpver, $port, $transport, $v3); + if (isSNMPable($device_tmp)) { + $rows_updated = dbUpdate($update, 'devices', '`device_id` = ?', array($device['device_id'])); + + if ($rows_updated > 0) { + $update_message = $rows_updated.' Device record updated.'; + $updated = 1; + } + else if ($rows_updated = '-1') { + $update_message = 'Device record unchanged. No update necessary.'; + $updated = -1; + } + else { + $update_message = 'Device record update error.'; + $updated = 0; + } + } + else { + $update_message = 'Could not connect to device with new SNMP details'; + $updated = 0; + } + }//end if +}//end if + +$device = dbFetchRow('SELECT * FROM `devices` WHERE `device_id` = ?', array($device['device_id'])); $descr = $device['purpose']; -echo('
    -
    '); -if ($updated && $update_message) -{ - print_message($update_message); -} elseif ($update_message) { - print_error($update_message); +echo '
    +
    '; +if ($updated && $update_message) { + print_message($update_message); +} +else if ($update_message) { + print_error($update_message); } -echo('
    -
    '); -echo(" -
    - -
    +echo '
    +
    '; + +echo " + + +
    - +
    - +
    - "; foreach ($config['snmp']['transports'] as $transport) { - echo(""); + + echo '>'.$transport.''; } -echo(" + +echo "
    -
    -
    +
    +
    - +
    - +
    -
    -
    +
    +
    - +
    - -
    - -
    + +
    +
    -
    -
    +
    +
    +
    - +
    - -
    - -
    + +
    + +
    - -
    - -
    + +
    + +
    - -
    - -
    + +
    + +
    - -
    - -
    + +
    + +
    - -
    - -
    + +
    + +
    - -
    - -
    + +
    +
    -
    "); +
    +
    '; -if ($config['distributed_poller'] === TRUE) { - echo(' -
    - -
    - + + '; - foreach (dbFetchRows("SELECT `id`,`group_name` FROM `poller_groups`") as $group) { - echo ''; + + echo '>'.$group['group_name'].''; } - echo(' - -
    -
    - '); -} + echo ' + +
    +
    + '; +}//end if -echo(' - - -'); +echo ' + + + '; ?> diff --git a/html/pages/device/entphysical.inc.php b/html/pages/device/entphysical.inc.php index af167b4ddc..7b5d956faa 100644 --- a/html/pages/device/entphysical.inc.php +++ b/html/pages/device/entphysical.inc.php @@ -1,13 +1,11 @@ "; @@ -33,7 +31,8 @@ function printEntPhysical($ent, $level, $class) if (count($sensor)) { $link = " href='device/device=".$device['device_id'].'/tab=health/metric='.$sensor['sensor_class']."/' onmouseover=\"return overlib('', LEFT,FGCOLOR,'#e5e5e5', BGCOLOR, '#c0c0c0', BORDER, 5, CELLPAD, 4, CAPCOLOR, '#050505');\" onmouseout=\"return nd();\""; } - } else { + } + else { unset($link); } diff --git a/html/pages/device/graphs.inc.php b/html/pages/device/graphs.inc.php index a275e71e31..e4bd13d84c 100644 --- a/html/pages/device/graphs.inc.php +++ b/html/pages/device/graphs.inc.php @@ -1,70 +1,68 @@ 'device', + 'device' => $device['device_id'], + 'tab' => 'graphs', +); -$link_array = array('page' => 'device', - 'device' => $device['device_id'], - 'tab' => 'graphs'); +$bg = '#ffffff'; -$bg="#ffffff"; - -echo('
    '); +echo '
    '; print_optionbar_start(); -echo("Graphs » "); +echo "Graphs » "; -foreach (dbFetchRows("SELECT * FROM device_graphs WHERE device_id = ? ORDER BY graph", array($device['device_id'])) as $graph) -{ - $section = $config['graph_types']['device'][$graph['graph']]['section']; - if ($section != "") { - $graph_enable[$section][$graph['graph']] = $graph['graph']; - } +foreach (dbFetchRows('SELECT * FROM device_graphs WHERE device_id = ? ORDER BY graph', array($device['device_id'])) as $graph) { + $section = $config['graph_types']['device'][$graph['graph']]['section']; + if ($section != '') { + $graph_enable[$section][$graph['graph']] = $graph['graph']; + } } // These are standard graphs we should have for all systems $graph_enable['poller']['poller_perf'] = 'device_poller_perf'; -$graph_enable['poller']['ping_perf'] = 'device_ping_perf'; +$graph_enable['poller']['ping_perf'] = 'device_ping_perf'; -$sep = ""; -foreach ($graph_enable as $section => $nothing) -{ - if (isset($graph_enable) && is_array($graph_enable[$section])) - { - $type = strtolower($section); - if (!$vars['group']) { $vars['group'] = $type; } - echo($sep); - if ($vars['group'] == $type) - { - echo(''); +$sep = ''; +foreach ($graph_enable as $section => $nothing) { + if (isset($graph_enable) && is_array($graph_enable[$section])) { + $type = strtolower($section); + if (!$vars['group']) { + $vars['group'] = $type; + } + + echo $sep; + if ($vars['group'] == $type) { + echo ''; + } + + echo generate_link(ucwords($type), $link_array, array('group' => $type)); + if ($vars['group'] == $type) { + echo ''; + } + + $sep = ' | '; } - echo(generate_link(ucwords($type),$link_array,array('group'=>$type))); - if ($vars['group'] == $type) - { - echo(""); - } - $sep = " | "; - } } -unset ($sep); + +unset($sep); print_optionbar_end(); $graph_enable = $graph_enable[$vars['group']]; -#foreach ($config['graph_types']['device'] as $graph => $entry) -foreach ($graph_enable as $graph => $entry) -{ - $graph_array = array(); - if ($graph_enable[$graph]) - { - $graph_title = $config['graph_types']['device'][$graph]['descr']; - $graph_array['type'] = "device_" . $graph; +// foreach ($config['graph_types']['device'] as $graph => $entry) +foreach ($graph_enable as $graph => $entry) { + $graph_array = array(); + if ($graph_enable[$graph]) { + $graph_title = $config['graph_types']['device'][$graph]['descr']; + $graph_array['type'] = 'device_'.$graph; - include("includes/print-device-graph.php"); - } + include 'includes/print-device-graph.php'; + } } -$pagetitle[] = "Graphs"; - -?> +$pagetitle[] = 'Graphs'; diff --git a/html/pages/device/graphs/netstats_ip_forward.inc.php b/html/pages/device/graphs/netstats_ip_forward.inc.php index cc728ac77c..eda137a788 100644 --- a/html/pages/device/graphs/netstats_ip_forward.inc.php +++ b/html/pages/device/graphs/netstats_ip_forward.inc.php @@ -1,11 +1,8 @@ 'device', - 'device' => $device['device_id'], - 'tab' => 'health'); +if ($storage) { + $datas[] = 'storage'; +} + +if ($diskio) { + $datas[] = 'diskio'; +} + +if ($charge) { + $datas[] = 'charge'; +} + +if ($temperatures) { + $datas[] = 'temperature'; +} + +if ($humidity) { + $datas[] = 'humidity'; +} + +if ($fans) { + $datas[] = 'fanspeed'; +} + +if ($volts) { + $datas[] = 'voltage'; +} + +if ($freqs) { + $datas[] = 'frequency'; +} + +if ($current) { + $datas[] = 'current'; +} + +if ($power) { + $datas[] = 'power'; +} + +if ($dBm) { + $datas[] = 'dbm'; +} + +if ($states) { + $datas[] = 'state'; +} + +if ($load) { + $datas[] = 'load'; +} + +$type_text['overview'] = 'Overview'; +$type_text['charge'] = 'Battery Charge'; +$type_text['temperature'] = 'Temperature'; +$type_text['humidity'] = 'Humidity'; +$type_text['mempool'] = 'Memory'; +$type_text['storage'] = 'Disk Usage'; +$type_text['diskio'] = 'Disk I/O'; +$type_text['processor'] = 'Processor'; +$type_text['voltage'] = 'Voltage'; +$type_text['fanspeed'] = 'Fanspeed'; +$type_text['frequency'] = 'Frequency'; +$type_text['current'] = 'Current'; +$type_text['power'] = 'Power'; +$type_text['dbm'] = 'dBm'; +$type_text['state'] = 'State'; +$type_text['load'] = 'Load'; + +$link_array = array( + 'page' => 'device', + 'device' => $device['device_id'], + 'tab' => 'health', +); print_optionbar_start(); -echo("Health » "); +echo "Health » "; -if (!$vars['metric']) { $vars['metric'] = "overview"; } +if (!$vars['metric']) { + $vars['metric'] = 'overview'; +} unset($sep); -foreach ($datas as $type) -{ - echo($sep); +foreach ($datas as $type) { + echo $sep; - if ($vars['metric'] == $type) - { echo(''); } - echo(generate_link($type_text[$type],$link_array,array('metric'=>$type))); - if ($vars['metric'] == $type) { echo(""); } - $sep = " | "; + if ($vars['metric'] == $type) { + echo ''; + } + + echo generate_link($type_text[$type], $link_array, array('metric' => $type)); + if ($vars['metric'] == $type) { + echo ''; + } + + $sep = ' | '; } print_optionbar_end(); -if (is_file("pages/device/health/".mres($vars['metric']).".inc.php")) -{ - include("pages/device/health/".mres($vars['metric']).".inc.php"); -} else { +if (is_file('pages/device/health/'.mres($vars['metric']).'.inc.php')) { + include 'pages/device/health/'.mres($vars['metric']).'.inc.php'; +} +else { + foreach ($datas as $type) { + if ($type != 'overview') { + $graph_title = $type_text[$type]; + $graph_array['type'] = 'device_'.$type; - foreach ($datas as $type) - { - if ($type != "overview") - { - - $graph_title = $type_text[$type]; - $graph_array['type'] = "device_".$type; - - include("includes/print-device-graph.php"); + include 'includes/print-device-graph.php'; + } } - } } -$pagetitle[] = "Health"; - -?> +$pagetitle[] = 'Health'; diff --git a/html/pages/device/health/charge.inc.php b/html/pages/device/health/charge.inc.php index 7282247bff..0750ae5935 100644 --- a/html/pages/device/health/charge.inc.php +++ b/html/pages/device/health/charge.inc.php @@ -1,9 +1,7 @@ +require 'sensors.inc.php'; diff --git a/html/pages/device/health/current.inc.php b/html/pages/device/health/current.inc.php index 0fa318a9b3..70bd4dc425 100644 --- a/html/pages/device/health/current.inc.php +++ b/html/pages/device/health/current.inc.php @@ -4,6 +4,4 @@ $class = "current"; $unit = "A"; $graph_type = "sensor_current"; -include("sensors.inc.php"); - -?> +require 'sensors.inc.php'; diff --git a/html/pages/device/health/humidity.inc.php b/html/pages/device/health/humidity.inc.php index 93b4772a3f..ffef7afa6a 100644 --- a/html/pages/device/health/humidity.inc.php +++ b/html/pages/device/health/humidity.inc.php @@ -4,6 +4,4 @@ $class = "humidity"; $unit = "%"; $graph_type = "sensor_humidity"; -include("sensors.inc.php"); - -?> +require 'sensors.inc.php'; diff --git a/html/pages/device/health/load.inc.php b/html/pages/device/health/load.inc.php index 399237aaef..18f5b5f5cd 100644 --- a/html/pages/device/health/load.inc.php +++ b/html/pages/device/health/load.inc.php @@ -1,9 +1,7 @@ +require 'sensors.inc.php'; diff --git a/html/pages/device/health/mempool.inc.php b/html/pages/device/health/mempool.inc.php index 6630c31476..613aa1250b 100644 --- a/html/pages/device/health/mempool.inc.php +++ b/html/pages/device/health/mempool.inc.php @@ -1,66 +1,72 @@ "); -echo(""); +echo "
    "; +echo '
    '; $i = '1'; -#FIXME css alternating colours +// FIXME css alternating colours +foreach (dbFetchRows('SELECT * FROM `mempools` WHERE device_id = ?', array($device['device_id'])) as $mempool) { + if (!is_integer($i / 2)) { + $row_colour = $list_colour_a; + } + else { + $row_colour = $list_colour_b; + } -foreach (dbFetchRows("SELECT * FROM `mempools` WHERE device_id = ?", array($device['device_id'])) as $mempool) -{ - if (!is_integer($i/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; } + if ($config['memcached']['enable'] === true) { + $state = $memcache->get('mempool-'.$mempool['mempool_id'].'-state'); + if ($debug) { + print_r($state); + } - if ($config['memcached']['enable'] === TRUE) - { - $state = $memcache->get('mempool-'.$mempool['mempool_id'].'-state'); - if($debug) { print_r($state); } - if(is_array($state)) { $mempool = array_merge($mempool, $state); } - unset($state); - } + if (is_array($state)) { + $mempool = array_merge($mempool, $state); + } - $text_descr = rewrite_entity_descr($mempool['mempool_descr']); + unset($state); + } - $mempool_url = "graphs/id=".$mempool['mempool_id']."/type=mempool_usage/"; - $mini_url = "graph.php?id=".$mempool['mempool_id']."&type=".$graph_type."&from=".$config['time']['day']."&to=".$config['time']['now']."&width=80&height=20&bg=f4f4f4"; + $text_descr = rewrite_entity_descr($mempool['mempool_descr']); - $mempool_popup = "onmouseover=\"return overlib('
    ".$device['hostname']." - ".$text_descr; - $mempool_popup .= "
    "; - $mempool_popup .= "', RIGHT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\""; + $mempool_url = 'graphs/id='.$mempool['mempool_id'].'/type=mempool_usage/'; + $mini_url = 'graph.php?id='.$mempool['mempool_id'].'&type='.$graph_type.'&from='.$config['time']['day'].'&to='.$config['time']['now'].'&width=80&height=20&bg=f4f4f4'; - $total = formatStorage($mempool['mempool_total']); - $used = formatStorage($mempool['mempool_used']); - $free = formatStorage($mempool['mempool_free']); + $mempool_popup = "onmouseover=\"return overlib('
    ".$device['hostname'].' - '.$text_descr; + $mempool_popup .= "
    "; + $mempool_popup .= "', RIGHT".$config['overlib_defaults'].');" onmouseout="return nd();"'; - $perc = round($mempool['mempool_used'] / $mempool['mempool_total'] * 100); + $total = formatStorage($mempool['mempool_total']); + $used = formatStorage($mempool['mempool_used']); + $free = formatStorage($mempool['mempool_free']); - $background = get_percentage_colours($percent); - $right_background = $background['right']; - $left_background = $background['left']; + $perc = round(($mempool['mempool_used'] / $mempool['mempool_total'] * 100)); - echo(" - - - - "); + $background = get_percentage_colours($percent); + $right_background = $background['right']; + $left_background = $background['left']; - echo(" + + + + '; - $graph_array['id'] = $mempool['mempool_id']; - $graph_array['type'] = $graph_type; + echo ""); + include 'includes/print-graphrow.inc.php'; - $i++; -} + echo ''; -echo("
    " . $text_descr . " - ".print_percentage_bar (400, 20, $perc, "$used / $total", "ffffff", $left_background, $free , "ffffff", $right_background)." - ".$perc."%
    "); + echo "
    ".$text_descr." + ".print_percentage_bar(400, 20, $perc, "$used / $total", 'ffffff', $left_background, $free, 'ffffff', $right_background).' + '.$perc.'%
    "; - include("includes/print-graphrow.inc.php"); + $graph_array['id'] = $mempool['mempool_id']; + $graph_array['type'] = $graph_type; - echo("
    "); -echo("
    "); + $i++; +}//end foreach -?> +echo ''; +echo '
    '; diff --git a/html/pages/device/health/processor.inc.php b/html/pages/device/health/processor.inc.php index bde4a3b3f1..725e37c21f 100644 --- a/html/pages/device/health/processor.inc.php +++ b/html/pages/device/health/processor.inc.php @@ -1,46 +1,43 @@ "); -echo(""); +echo "
    "; +echo '
    '; $i = '1'; -foreach (dbFetchRows("SELECT * FROM `processors` WHERE device_id = ?", array($device['device_id'])) as $proc) -{ - $proc_url = "graphs/id=".$proc['processor_id']."/type=processor_usage/"; +foreach (dbFetchRows('SELECT * FROM `processors` WHERE device_id = ?', array($device['device_id'])) as $proc) { + $proc_url = 'graphs/id='.$proc['processor_id'].'/type=processor_usage/'; - $mini_url = "graph.php?id=".$proc['processor_id']."&type=".$graph_type."&from=".$config['time']['day']."&to=".$config['time']['now']."&width=80&height=20&bg=f4f4f4"; + $mini_url = 'graph.php?id='.$proc['processor_id'].'&type='.$graph_type.'&from='.$config['time']['day'].'&to='.$config['time']['now'].'&width=80&height=20&bg=f4f4f4'; - $text_descr = $proc['processor_descr']; + $text_descr = $proc['processor_descr']; - $text_descr = rewrite_entity_descr($text_descr); + $text_descr = rewrite_entity_descr($text_descr); - $proc_popup = "onmouseover=\"return overlib('
    ".$device['hostname']." - ".$text_descr; - $proc_popup .= "
    "; - $proc_popup .= "', RIGHT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\""; + $proc_popup = "onmouseover=\"return overlib('
    ".$device['hostname'].' - '.$text_descr; + $proc_popup .= "
    "; + $proc_popup .= "', RIGHT".$config['overlib_defaults'].');" onmouseout="return nd();"'; - $percent = round($proc['processor_usage']); + $percent = round($proc['processor_usage']); - $background = get_percentage_colours($percent); + $background = get_percentage_colours($percent); - echo(" - + echo (" + - "); + '); - echo("
    " . $text_descr . "
    ".$text_descr." - ".print_percentage_bar (400, 20, $percent, $percent."%", "ffffff", $background['left'], (100 - $percent)."%" , "ffffff", $background['right'])." + ".print_percentage_bar(400, 20, $percent, $percent.'%', 'ffffff', $background['left'], (100 - $percent).'%', 'ffffff', $background['right']).'
    "); + echo "
    "; - $graph_array['id'] = $proc['processor_id']; - $graph_array['type'] = $graph_type; + $graph_array['id'] = $proc['processor_id']; + $graph_array['type'] = $graph_type; - include("includes/print-graphrow.inc.php"); -} + include 'includes/print-graphrow.inc.php'; +}//end foreach -echo("
    "); -echo(""); - -?> +echo ''; +echo ''; diff --git a/html/pages/device/health/state.inc.php b/html/pages/device/health/state.inc.php index 5463962196..9781248bea 100644 --- a/html/pages/device/health/state.inc.php +++ b/html/pages/device/health/state.inc.php @@ -1,7 +1,7 @@ "); +echo ''; -echo(" +echo ' - "); + '; $row = 1; -foreach (dbFetchRows("SELECT * FROM `storage` WHERE device_id = ? ORDER BY storage_descr", array($device['device_id'])) as $drive) -{ - if (is_integer($row/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; } +foreach (dbFetchRows('SELECT * FROM `storage` WHERE device_id = ? ORDER BY storage_descr', array($device['device_id'])) as $drive) { + if (is_integer($row / 2)) { + $row_colour = $list_colour_a; + } + else { + $row_colour = $list_colour_b; + } - $total = $drive['storage_size']; - $used = $drive['storage_used']; - $free = $drive['storage_free']; - $perc = round($drive['storage_perc'], 0); - $used = formatStorage($used); - $total = formatStorage($total); - $free = formatStorage($free); + $total = $drive['storage_size']; + $used = $drive['storage_used']; + $free = $drive['storage_free']; + $perc = round($drive['storage_perc'], 0); + $used = formatStorage($used); + $total = formatStorage($total); + $free = formatStorage($free); - $fs_url = "graphs/id=".$drive['storage_id']."/type=storage_usage/"; + $fs_url = 'graphs/id='.$drive['storage_id'].'/type=storage_usage/'; - $fs_popup = "onmouseover=\"return overlib('
    ".$device['hostname']." - ".$drive['storage_descr']; - $fs_popup .= "
    "; - $fs_popup .= "', RIGHT, FGCOLOR, '#e5e5e5');\" onmouseout=\"return nd();\""; + $fs_popup = "onmouseover=\"return overlib('
    ".$device['hostname'].' - '.$drive['storage_descr']; + $fs_popup .= "
    "; + $fs_popup .= "', RIGHT, FGCOLOR, '#e5e5e5');\" onmouseout=\"return nd();\""; - $background = get_percentage_colours($percent); + $background = get_percentage_colours($percent); - echo(""); + echo "'; - $graph_array['id'] = $drive['storage_id']; - $graph_array['type'] = $graph_type; + $graph_array['id'] = $drive['storage_id']; + $graph_array['type'] = $graph_type; - echo(""); + echo ''; - $row++; -} + $row++; +}//end foreach -echo("
    Drive Usage Free
    " . $drive['storage_descr'] . " - ".print_percentage_bar (400, 20, $perc, "$used / $total", "ffffff", $background['left'], $perc . "%", "ffffff", $background['right'])." - " . $free . "
    ".$drive['storage_descr']." + ".print_percentage_bar(400, 20, $perc, "$used / $total", 'ffffff', $background['left'], $perc.'%', 'ffffff', $background['right']).' + '.$free.'
    "); + echo "
    "; - include("includes/print-graphrow.inc.php"); + include 'includes/print-graphrow.inc.php'; - echo("
    "); - -?> +echo ''; diff --git a/html/pages/device/hrdevice.inc.php b/html/pages/device/hrdevice.inc.php index 68928187b3..d16a0ba839 100644 --- a/html/pages/device/hrdevice.inc.php +++ b/html/pages/device/hrdevice.inc.php @@ -1,70 +1,69 @@ '); +echo ''; // FIXME missing heading +foreach (dbFetchRows('SELECT * FROM `hrDevice` WHERE `device_id` = ? ORDER BY `hrDeviceIndex`', array($device['device_id'])) as $hrdevice) { + echo "'; -foreach (dbFetchRows("SELECT * FROM `hrDevice` WHERE `device_id` = ? ORDER BY `hrDeviceIndex`", array($device['device_id'])) as $hrdevice) -{ - echo(""); + if ($hrdevice['hrDeviceType'] == 'hrDeviceProcessor') { + $proc_id = dbFetchCell("SELECT processor_id FROM processors WHERE device_id = '".$device['device_id']."' AND hrDeviceIndex = '".$hrdevice['hrDeviceIndex']."'"); + $proc_url = 'device/device='.$device['device_id'].'/tab=health/metric=processor/'; + $proc_popup = "onmouseover=\"return overlib('
    ".$device['hostname'].' - '.$hrdevice['hrDeviceDescr']; + $proc_popup .= "
    "; + $proc_popup .= "', RIGHT".$config['overlib_defaults'].');" onmouseout="return nd();"'; + echo "'; - if ($hrdevice['hrDeviceType'] == "hrDeviceProcessor") - { - $proc_id = dbFetchCell("SELECT processor_id FROM processors WHERE device_id = '".$device['device_id']."' AND hrDeviceIndex = '".$hrdevice['hrDeviceIndex']."'"); - $proc_url = "device/device=".$device['device_id']."/tab=health/metric=processor/"; - $proc_popup = "onmouseover=\"return overlib('
    ".$device['hostname']." - ".$hrdevice['hrDeviceDescr']; - $proc_popup .= "
    "; - $proc_popup .= "', RIGHT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\""; - echo(""); + $graph_array['height'] = '20'; + $graph_array['width'] = '100'; + $graph_array['to'] = $config['time']['now']; + $graph_array['id'] = $proc_id; + $graph_array['type'] = 'processor_usage'; + $graph_array['from'] = $config['time']['day']; + $graph_array_zoom = $graph_array; + $graph_array_zoom['height'] = '150'; + $graph_array_zoom['width'] = '400'; - $graph_array['height'] = "20"; - $graph_array['width'] = "100"; - $graph_array['to'] = $config['time']['now']; - $graph_array['id'] = $proc_id; - $graph_array['type'] = 'processor_usage'; - $graph_array['from'] = $config['time']['day']; - $graph_array_zoom = $graph_array; $graph_array_zoom['height'] = "150"; $graph_array_zoom['width'] = "400"; + $mini_graph = overlib_link($proc_url, generate_graph_tag($graph_array), generate_graph_tag($graph_array_zoom), null); - $mini_graph = overlib_link($proc_url, generate_graph_tag($graph_array), generate_graph_tag($graph_array_zoom), NULL); - - echo(''); - } - elseif ($hrdevice['hrDeviceType'] == "hrDeviceNetwork") - { - $int = str_replace("network interface ", "", $hrdevice['hrDeviceDescr']); - $interface = dbFetchRow("SELECT * FROM ports WHERE device_id = ? AND ifDescr = ?", array($device['device_id'], $int)); - if ($interface['ifIndex']) - { - echo(""); - - $graph_array['height'] = "20"; - $graph_array['width'] = "100"; - $graph_array['to'] = $config['time']['now']; - $graph_array['id'] = $interface['port_id']; - $graph_array['type'] = 'port_bits'; - $graph_array['from'] = $config['time']['day']; - $graph_array_zoom = $graph_array; $graph_array_zoom['height'] = "150"; $graph_array_zoom['width'] = "400"; - - // FIXME click on graph should also link to port, but can't use generate_port_link here... - $mini_graph = overlib_link(generate_port_url($interface), generate_graph_tag($graph_array), generate_graph_tag($graph_array_zoom), NULL); - - echo(""); - } else { - echo(""); - echo(""); + echo ''; } - } else { - echo(""); - echo(""); - } + else if ($hrdevice['hrDeviceType'] == 'hrDeviceNetwork') { + $int = str_replace('network interface ', '', $hrdevice['hrDeviceDescr']); + $interface = dbFetchRow('SELECT * FROM ports WHERE device_id = ? AND ifDescr = ?', array($device['device_id'], $int)); + if ($interface['ifIndex']) { + echo ''; - echo(""); - echo(""); - echo(""); -} + $graph_array['height'] = '20'; + $graph_array['width'] = '100'; + $graph_array['to'] = $config['time']['now']; + $graph_array['id'] = $interface['port_id']; + $graph_array['type'] = 'port_bits'; + $graph_array['from'] = $config['time']['day']; + $graph_array_zoom = $graph_array; + $graph_array_zoom['height'] = '150'; + $graph_array_zoom['width'] = '400'; -echo('
    ".$hrdevice['hrDeviceIndex'].'
    ".$hrdevice['hrDeviceIndex']."".$hrdevice['hrDeviceDescr'].'".$hrdevice['hrDeviceDescr']."'.$mini_graph.'".generate_port_link($interface)."$mini_graph".stripslashes($hrdevice['hrDeviceDescr'])."'.$mini_graph.'".stripslashes($hrdevice['hrDeviceDescr'])."'.generate_port_link($interface).'".$hrdevice['hrDeviceType'].''.$hrdevice['hrDeviceStatus']."".$hrdevice['hrDeviceErrors'].''.$hrdevice['hrProcessorLoad']."
    '); + // FIXME click on graph should also link to port, but can't use generate_port_link here... + $mini_graph = overlib_link(generate_port_url($interface), generate_graph_tag($graph_array), generate_graph_tag($graph_array_zoom), null); -$pagetitle[] = "Inventory"; + echo "$mini_graph"; + } + else { + echo ''.stripslashes($hrdevice['hrDeviceDescr']).''; + echo ''; + } + } + else { + echo ''.stripslashes($hrdevice['hrDeviceDescr']).''; + echo ''; + }//end if -?> + echo ''.$hrdevice['hrDeviceType'].''.$hrdevice['hrDeviceStatus'].''; + echo ''.$hrdevice['hrDeviceErrors'].''.$hrdevice['hrProcessorLoad'].''; + echo ''; +}//end foreach + +echo ''; + +$pagetitle[] = 'Inventory'; diff --git a/html/pages/device/loadbalancer/ace_rservers.inc.php b/html/pages/device/loadbalancer/ace_rservers.inc.php index 52f1773c7e..c8b4b2acdc 100644 --- a/html/pages/device/loadbalancer/ace_rservers.inc.php +++ b/html/pages/device/loadbalancer/ace_rservers.inc.php @@ -33,10 +33,10 @@ echo ' Graphs: '; // "pkts" => "Packets", // "errors" => "Errors"); $graph_types = array( - 'curr' => 'CurrentConns', - 'failed' => 'FailedConns', - 'total' => 'TotalConns', - ); + 'curr' => 'CurrentConns', + 'failed' => 'FailedConns', + 'total' => 'TotalConns', +); foreach ($graph_types as $type => $descr) { echo "$type_sep"; @@ -66,7 +66,8 @@ foreach (dbFetchRows('SELECT * FROM `loadbalancer_rservers` WHERE `device_id` = if ($rserver['StateDescr'] == 'Server is now operational') { $rserver_class = 'green'; - } else { + } + else { $rserver_class = 'red'; } @@ -87,7 +88,7 @@ foreach (dbFetchRows('SELECT * FROM `loadbalancer_rservers` WHERE `device_id` = $graph_array['id'] = $rserver['rserver_id']; $graph_array['type'] = $graph_type; - include 'includes/print-graphrow.inc.php'; + require 'includes/print-graphrow.inc.php'; // include("includes/print-interface-graphs.inc.php"); echo ' diff --git a/html/pages/device/loadbalancer/ace_vservers.inc.php b/html/pages/device/loadbalancer/ace_vservers.inc.php index 65032709c8..68ebd1d3f5 100644 --- a/html/pages/device/loadbalancer/ace_vservers.inc.php +++ b/html/pages/device/loadbalancer/ace_vservers.inc.php @@ -2,84 +2,101 @@ print_optionbar_start(); -echo("Serverfarms » "); +echo "Serverfarms » "; -#$auth = TRUE; +// $auth = TRUE; +$menu_options = array('basic' => 'Basic'); -$menu_options = array('basic' => 'Basic', - ); +if (!$_GET['opta']) { + $_GET['opta'] = 'basic'; +} -if (!$_GET['opta']) { $_GET['opta'] = "basic"; } +$sep = ''; +foreach ($menu_options as $option => $text) { + if ($_GET['type'] == $option) { + echo ""; + } -$sep = ""; -foreach ($menu_options as $option => $text) -{ - if ($_GET['type'] == $option) { echo(""); } - echo(''.$text.''); - if ($_GET['type'] == $option) { echo(""); } - echo(" | "); + echo ''.$text.''; + if ($_GET['type'] == $option) { + echo ''; + } + + echo ' | '; } unset($sep); -echo(' Graphs: '); +echo ' Graphs: '; -$graph_types = array("bits" => "Bits", - "pkts" => "Packets", - "conns" => "Connections"); +$graph_types = array( + 'bits' => 'Bits', + 'pkts' => 'Packets', + 'conns' => 'Connections', +); -foreach ($graph_types as $type => $descr) -{ - echo("$type_sep"); - if ($_GET['opte'] == $type) { echo(""); } - echo(''.$descr.''); - echo(''.$text.''); - if ($_GET['opte'] == $type) { echo(""); } +foreach ($graph_types as $type => $descr) { + echo "$type_sep"; + if ($_GET['opte'] == $type) { + echo ""; + } - $type_sep = " | "; + echo ''.$descr.''; + echo ''.$text.''; + if ($_GET['opte'] == $type) { + echo ''; + } + + $type_sep = ' | '; } print_optionbar_end(); -echo("
    "); -$i = "0"; -foreach (dbFetchRows("SELECT * FROM `loadbalancer_vservers` WHERE `device_id` = ? ORDER BY `classmap`", array($device['device_id'])) as $vserver) -{ -if (is_integer($i/2)) { $bg_colour = $list_colour_a; } else { $bg_colour = $list_colour_b; } +echo "
    "; +$i = '0'; +foreach (dbFetchRows('SELECT * FROM `loadbalancer_vservers` WHERE `device_id` = ? ORDER BY `classmap`', array($device['device_id'])) as $vserver) { + if (is_integer($i / 2)) { + $bg_colour = $list_colour_a; + } + else { + $bg_colour = $list_colour_b; + } -if($vserver['serverstate'] == "inService") { $vserver_class="green"; } else { $vserver_class="red"; } + if ($vserver['serverstate'] == 'inService') { + $vserver_class = 'green'; + } + else { + $vserver_class = 'red'; + } -echo(""); -#echo(""); -echo(""); -#echo(""); -echo(""); -echo(""); - if ($_GET['type'] == "graphs") - { - echo(''); - echo(""; + // echo(""); + echo ''; + // echo(""); + echo "'; + echo ''; + if ($_GET['type'] == 'graphs') { + echo ''; + echo ' - "); - } + echo ' + + '; + } -echo(""); -echo(""); + echo ''; + echo ''; - $i++; -} + $i++; +}//end foreach -echo("
    " . $tunnel['local_addr'] . " » " . $tunnel['peer_addr'] . "" . $vserver['classmap'] . "" . $rserver['farm_id'] . "" . $vserver['serverstate'] . "
    "); - $graph_type = "vserver_" . $_GET['opte']; + echo "
    " . $tunnel['local_addr'] . " » " . $tunnel['peer_addr'] . "'.$vserver['classmap'].'" . $rserver['farm_id'] . "".$vserver['serverstate'].'
    '; + $graph_type = 'vserver_'.$_GET['opte']; -$graph_array['height'] = "100"; -$graph_array['width'] = "215"; -$graph_array['to'] = $config['time']['now']; -$graph_array['id'] = $vserver['classmap_id']; -$graph_array['type'] = $graph_type; + $graph_array['height'] = '100'; + $graph_array['width'] = '215'; + $graph_array['to'] = $config['time']['now']; + $graph_array['id'] = $vserver['classmap_id']; + $graph_array['type'] = $graph_type; -include("includes/print-graphrow.inc.php"); + include 'includes/print-graphrow.inc.php'; - echo(" -
    "); - -?> +echo ''; diff --git a/html/pages/device/loadbalancer/netscaler_vsvr.inc.php b/html/pages/device/loadbalancer/netscaler_vsvr.inc.php index a67d755b9a..91abc8204f 100644 --- a/html/pages/device/loadbalancer/netscaler_vsvr.inc.php +++ b/html/pages/device/loadbalancer/netscaler_vsvr.inc.php @@ -1,6 +1,6 @@ VServer
    » "); // echo('All'); diff --git a/html/pages/device/logs.inc.php b/html/pages/device/logs.inc.php index 0b8481a68f..11fd6914ba 100644 --- a/html/pages/device/logs.inc.php +++ b/html/pages/device/logs.inc.php @@ -1,41 +1,43 @@ Logging » "); +echo 'Logging » '; -if ($vars['section'] == "eventlog") { - echo(''); +if ($vars['section'] == 'eventlog') { + echo ''; } -echo(generate_link("Event Log" , $vars, array('section'=>'eventlog'))); -if ($vars['section'] == "eventlog") { - echo(""); + +echo generate_link('Event Log', $vars, array('section' => 'eventlog')); +if ($vars['section'] == 'eventlog') { + echo ''; } if (isset($config['enable_syslog']) && $config['enable_syslog'] == 1) { - echo(" | "); + echo ' | '; - if ($vars['section'] == "syslog") { - echo(''); + if ($vars['section'] == 'syslog') { + echo ''; } - echo(generate_link("Syslog" , $vars, array('section'=>'syslog'))); - if ($vars['section'] == "syslog") { - echo(""); + + echo generate_link('Syslog', $vars, array('section' => 'syslog')); + if ($vars['section'] == 'syslog') { + echo ''; } } -switch ($vars['section']) -{ - case 'syslog': - case 'eventlog': - include('pages/device/logs/'.$vars['section'].'.inc.php'); - break; - default: - print_optionbar_end(); - echo(report_this('Unknown section '.$vars['section'])); - break; -} +switch ($vars['section']) { + case 'syslog': + case 'eventlog': + include 'pages/device/logs/'.$vars['section'].'.inc.php'; + break; -?> + default: + print_optionbar_end(); + echo report_this('Unknown section '.$vars['section']); + break; +} diff --git a/html/pages/device/logs/eventlog.inc.php b/html/pages/device/logs/eventlog.inc.php index aec8bdd98c..7d5204f1cd 100644 --- a/html/pages/device/logs/eventlog.inc.php +++ b/html/pages/device/logs/eventlog.inc.php @@ -2,51 +2,49 @@
    +echo '
    Eventlog entries
    - '); +
    '; -foreach ($entries as $entry) -{ - include("includes/print-event.inc.php"); +foreach ($entries as $entry) { + include 'includes/print-event.inc.php'; } -echo('
    -
    '); +echo ' + '; -$pagetitle[] = "Events"; - -?> +$pagetitle[] = 'Events'; diff --git a/html/pages/device/logs/syslog.inc.php b/html/pages/device/logs/syslog.inc.php index 7aae3b8e0c..1284ad157f 100644 --- a/html/pages/device/logs/syslog.inc.php +++ b/html/pages/device/logs/syslog.inc.php @@ -3,53 +3,54 @@
    +$sql = "SELECT *, DATE_FORMAT(timestamp, '".$config['dateformat']['mysql']['compact']."') AS date from syslog WHERE device_id = ? $where"; +$sql .= ' ORDER BY timestamp DESC LIMIT 1000'; +echo '
    Syslog entries
    - '); -foreach (dbFetchRows($sql, $param) as $entry) { include("includes/print-syslog.inc.php"); } -echo('
    -
    '); -$pagetitle[] = "Syslog"; + '; +foreach (dbFetchRows($sql, $param) as $entry) { + include 'includes/print-syslog.inc.php'; +} -?> +echo '
    + '; +$pagetitle[] = 'Syslog'; diff --git a/html/pages/device/map.inc.php b/html/pages/device/map.inc.php index 522de36a51..918f62e7fc 100644 --- a/html/pages/device/map.inc.php +++ b/html/pages/device/map.inc.php @@ -12,8 +12,6 @@ * the source code distribution for details. */ -$pagetitle[] = "Map"; +$pagetitle[] = 'Map'; -require_once "includes/print-map.inc.php"; - -?> +require_once 'includes/print-map.inc.php'; diff --git a/html/pages/device/munin.inc.php b/html/pages/device/munin.inc.php index 67fd22d6e0..e12279687e 100644 --- a/html/pages/device/munin.inc.php +++ b/html/pages/device/munin.inc.php @@ -1,75 +1,72 @@ 'device', + 'device' => $device['device_id'], + 'tab' => 'munin', +); -$link_array = array('page' => 'device', - 'device' => $device['device_id'], - 'tab' => 'munin'); +$bg = '#ffffff'; -$bg="#ffffff"; - -echo('
    '); +echo '
    '; print_optionbar_start(); -echo("Munin » "); +echo "Munin » "; -$sep = ""; +$sep = ''; -foreach (dbFetchRows("SELECT * FROM munin_plugins WHERE device_id = ? ORDER BY mplug_category, mplug_type", array($device['device_id'])) as $mplug) -{ -# if (strlen($mplug['mplug_category']) == 0) { $mplug['mplug_category'] = "general"; } else { } - $graph_enable[$mplug['mplug_category']][$mplug['mplug_type']]['id'] = $mplug['mplug_id']; - $graph_enable[$mplug['mplug_category']][$mplug['mplug_type']]['title'] = $mplug['mplug_title']; - $graph_enable[$mplug['mplug_category']][$mplug['mplug_type']]['plugin'] = $mplug['mplug_type']; +foreach (dbFetchRows('SELECT * FROM munin_plugins WHERE device_id = ? ORDER BY mplug_category, mplug_type', array($device['device_id'])) as $mplug) { + // if (strlen($mplug['mplug_category']) == 0) { $mplug['mplug_category'] = "general"; } else { } + $graph_enable[$mplug['mplug_category']][$mplug['mplug_type']]['id'] = $mplug['mplug_id']; + $graph_enable[$mplug['mplug_category']][$mplug['mplug_type']]['title'] = $mplug['mplug_title']; + $graph_enable[$mplug['mplug_category']][$mplug['mplug_type']]['plugin'] = $mplug['mplug_type']; } -foreach ($graph_enable as $section => $nothing) -{ - if (isset($graph_enable) && is_array($graph_enable[$section])) - { - $type = strtolower($section); - if (!$vars['group']) { $vars['group'] = $type; } - echo($sep); - if ($vars['group'] == $type) - { - echo(''); +foreach ($graph_enable as $section => $nothing) { + if (isset($graph_enable) && is_array($graph_enable[$section])) { + $type = strtolower($section); + if (!$vars['group']) { + $vars['group'] = $type; + } + + echo $sep; + if ($vars['group'] == $type) { + echo ''; + } + + echo generate_link(ucwords($type), $link_array, array('group' => $type)); + if ($vars['group'] == $type) { + echo ''; + } + + $sep = ' | '; } - echo(generate_link(ucwords($type),$link_array,array('group'=>$type))); - if ($vars['group'] == $type) - { - echo(""); - } - $sep = " | "; - } } -unset ($sep); +unset($sep); print_optionbar_end(); $graph_enable = $graph_enable[$vars['group']]; -#foreach ($config['graph_types']['device'] as $graph => $entry) -foreach ($graph_enable as $graph => $entry) -{ - $graph_array = array(); - if ($graph_enable[$graph]) - { - if (!empty($entry['plugin'])) - { - $graph_title = $entry['title']; - $graph_array['type'] = "munin_graph"; - $graph_array['device'] = $device['device_id']; - $graph_array['plugin'] = $entry['plugin']; - } else { - $graph_title = $config['graph_types']['device'][$graph]['descr']; - $graph_array['type'] = "device_" . $graph; - } +// foreach ($config['graph_types']['device'] as $graph => $entry) +foreach ($graph_enable as $graph => $entry) { + $graph_array = array(); + if ($graph_enable[$graph]) { + if (!empty($entry['plugin'])) { + $graph_title = $entry['title']; + $graph_array['type'] = 'munin_graph'; + $graph_array['device'] = $device['device_id']; + $graph_array['plugin'] = $entry['plugin']; + } + else { + $graph_title = $config['graph_types']['device'][$graph]['descr']; + $graph_array['type'] = 'device_'.$graph; + } - include("includes/print-device-graph.php"); - } + include 'includes/print-device-graph.php'; + } } -$pagetitle[] = "Graphs"; - -?> +$pagetitle[] = 'Graphs'; diff --git a/html/pages/device/overview.inc.php b/html/pages/device/overview.inc.php index aac3b2ca23..13227e0136 100644 --- a/html/pages/device/overview.inc.php +++ b/html/pages/device/overview.inc.php @@ -12,8 +12,18 @@ $services['up'] = dbFetchCell("SELECT COUNT(service_id) FROM `services` WH $services['down'] = dbFetchCell("SELECT COUNT(service_id) FROM `services` WHERE `device_id` = ? AND `service_status` = '0' AND `service_ignore` = '0'", array($device['device_id'])); $services['disabled'] = dbFetchCell("SELECT COUNT(service_id) FROM `services` WHERE `device_id` = ? AND `service_ignore` = '1'", array($device['device_id'])); -if ($services['down']) { $services_colour = $warn_colour_a; } else { $services_colour = $list_colour_a; } -if ($ports['down']) { $ports_colour = $warn_colour_a; } else { $ports_colour = $list_colour_a; } +if ($services['down']) { + $services_colour = $warn_colour_a; +} +else { + $services_colour = $list_colour_a; +} +if ($ports['down']) { + $ports_colour = $warn_colour_a; +} +else { + $ports_colour = $list_colour_a; +} echo('
    @@ -25,39 +35,41 @@ echo('
    '); -include("includes/dev-overview-data.inc.php"); +require 'includes/dev-overview-data.inc.php'; Plugins::call('device_overview_container',array($device)); -include("overview/ports.inc.php"); +require 'overview/ports.inc.php'; echo('
    '); // Right Pane -include("overview/processors.inc.php"); -include("overview/mempools.inc.php"); -include("overview/storage.inc.php"); +require 'overview/processors.inc.php'; +require 'overview/mempools.inc.php'; +require 'overview/storage.inc.php'; -if(is_array($entity_state['group']['c6kxbar'])) { include("overview/c6kxbar.inc.php"); } +if(is_array($entity_state['group']['c6kxbar'])) { + require 'overview/c6kxbar.inc.php'; +} -include("overview/toner.inc.php"); -include("overview/sensors/charge.inc.php"); -include("overview/sensors/temperatures.inc.php"); -include("overview/sensors/humidity.inc.php"); -include("overview/sensors/fanspeeds.inc.php"); -include("overview/sensors/dbm.inc.php"); -include("overview/sensors/voltages.inc.php"); -include("overview/sensors/current.inc.php"); -include("overview/sensors/power.inc.php"); -include("overview/sensors/frequencies.inc.php"); -include("overview/sensors/load.inc.php"); -include("overview/sensors/state.inc.php"); -include("overview/eventlog.inc.php"); -include("overview/services.inc.php"); -include("overview/syslog.inc.php"); +require 'overview/toner.inc.php'; +require 'overview/sensors/charge.inc.php'; +require 'overview/sensors/temperatures.inc.php'; +require 'overview/sensors/humidity.inc.php'; +require 'overview/sensors/fanspeeds.inc.php'; +require 'overview/sensors/dbm.inc.php'; +require 'overview/sensors/voltages.inc.php'; +require 'overview/sensors/current.inc.php'; +require 'overview/sensors/power.inc.php'; +require 'overview/sensors/frequencies.inc.php'; +require 'overview/sensors/load.inc.php'; +require 'overview/sensors/state.inc.php'; +require 'overview/eventlog.inc.php'; +require 'overview/services.inc.php'; +require 'overview/syslog.inc.php'; echo('
    '); -#include("overview/current.inc.php"); +#require 'overview/current.inc.php"); ?> diff --git a/html/pages/device/overview/c6kxbar.inc.php b/html/pages/device/overview/c6kxbar.inc.php index 14f5d54e48..eb04e0a7db 100644 --- a/html/pages/device/overview/c6kxbar.inc.php +++ b/html/pages/device/overview/c6kxbar.inc.php @@ -1,102 +1,99 @@ -
    -
    -
    -
    '); -echo(''); -echo(" Catalyst 6k Crossbar"); -echo('
    - '); +echo '
    +
    +
    +
    +
    '; +echo ''; +echo " Catalyst 6k Crossbar"; +echo '
    +
    '; -foreach ($entity_state['group']['c6kxbar'] as $index => $entry) -{ - // FIXME i'm not sure if this is the correct way to decide what entphysical index it is. slotnum+1? :> - $entity = dbFetchRow("SELECT * FROM entPhysical WHERE device_id = ? AND entPhysicalIndex = ?", array($device['device_id'], $index+1)); +foreach ($entity_state['group']['c6kxbar'] as $index => $entry) { + // FIXME i'm not sure if this is the correct way to decide what entphysical index it is. slotnum+1? :> + $entity = dbFetchRow('SELECT * FROM entPhysical WHERE device_id = ? AND entPhysicalIndex = ?', array($device['device_id'], $index + 1)); - echo(" + echo " - - "); + echo ' + '; - foreach ($entity_state['group']['c6kxbar'][$index] as $subindex => $fabric) - { - if (is_numeric($subindex)) - { - if ($fabric['cc6kxbarModuleChannelFabStatus'] == "ok") - { - $fabric['mode_class'] = "green"; - } else { - $fabric['mode_class'] = "red"; - } + foreach ($entity_state['group']['c6kxbar'][$index] as $subindex => $fabric) { + if (is_numeric($subindex)) { + if ($fabric['cc6kxbarModuleChannelFabStatus'] == 'ok') { + $fabric['mode_class'] = 'green'; + } + else { + $fabric['mode_class'] = 'red'; + } - $percent_in = $fabric['cc6kxbarStatisticsInUtil']; - $background_in = get_percentage_colours($percent_in); + $percent_in = $fabric['cc6kxbarStatisticsInUtil']; + $background_in = get_percentage_colours($percent_in); - $percent_out = $fabric['cc6kxbarStatisticsOutUtil']; - $background_out = get_percentage_colours($percent_out); + $percent_out = $fabric['cc6kxbarStatisticsOutUtil']; + $background_out = get_percentage_colours($percent_out); - $graph_array = array(); - $graph_array['height'] = "100"; - $graph_array['width'] = "210"; - $graph_array['to'] = $config['time']['now']; - $graph_array['device'] = $device['device_id']; - $graph_array['mod'] = $index; - $graph_array['chan'] = $subindex; - $graph_array['type'] = "c6kxbar_util"; - $graph_array['from'] = $config['time']['day']; - $graph_array['legend'] = "no"; + $graph_array = array(); + $graph_array['height'] = '100'; + $graph_array['width'] = '210'; + $graph_array['to'] = $config['time']['now']; + $graph_array['device'] = $device['device_id']; + $graph_array['mod'] = $index; + $graph_array['chan'] = $subindex; + $graph_array['type'] = 'c6kxbar_util'; + $graph_array['from'] = $config['time']['day']; + $graph_array['legend'] = 'no'; - $link_array = $graph_array; - $link_array['page'] = "graphs"; - unset($link_array['height'], $link_array['width'], $link_array['legend']); - $link = generate_url($link_array); + $link_array = $graph_array; + $link_array['page'] = 'graphs'; + unset($link_array['height'], $link_array['width'], $link_array['legend']); + $link = generate_url($link_array); - $text_descr = $entity['entPhysicalName'] . " - Fabric " . $subindex; + $text_descr = $entity['entPhysicalName'].' - Fabric '.$subindex; - $overlib_content = generate_overlib_content($graph_array, $device['hostname'] . " - " . $text_descr); + $overlib_content = generate_overlib_content($graph_array, $device['hostname'].' - '.$text_descr); - $graph_array['width'] = 80; $graph_array['height'] = 20; $graph_array['bg'] = 'ffffff00'; # the 00 at the end makes the area transparent. + $graph_array['width'] = 80; + $graph_array['height'] = 20; + $graph_array['bg'] = 'ffffff00'; + // the 00 at the end makes the area transparent. + $minigraph = generate_graph_tag($graph_array); - $minigraph = generate_graph_tag($graph_array); + echo (' + + + - - - - - - - "); - } - } -} - -echo("
    ".$entity['entPhysicalName'].""); + "; - switch ($entry['']['cc6kxbarModuleModeSwitchingMode']) - { - case "busmode": - # echo 'Bus'; + switch ($entry['']['cc6kxbarModuleModeSwitchingMode']) { + case 'busmode': + // echo 'Bus'; break; - case "crossbarmode": + + case 'crossbarmode': echo 'Crossbar'; break; - case "dcefmode": + + case 'dcefmode': echo 'DCEF'; break; - default: + + default: echo $entry['']['cc6kxbarModuleModeSwitchingMode']; } - echo("
    Fabric '.$subindex." - Fabric ".$subindex."". - - $fabric['cc6kxbarModuleChannelFabStatus']."".formatRates($fabric['cc6kxbarModuleChannelSpeed']*1000000)."".overlib_link($link, $minigraph, $overlib_content)."".print_percentage_bar (125, 20, $percent_in, "Ingress", "ffffff", $background['left'], $percent_in . "%", "ffffff", $background['right'])."".print_percentage_bar (125, 20, $percent_out, "Egress", "ffffff", $background['left'], $percent_out . "%", "ffffff", $background['right'])."
    "); -echo("
    "); -echo("
    "); -echo("
    "); -echo("
    "); - -?> +echo ' '; +echo '
    '; +echo ' '; +echo ' '; +echo ''; diff --git a/html/pages/device/overview/eventlog.inc.php b/html/pages/device/overview/eventlog.inc.php index ff235aa4a8..d555118136 100644 --- a/html/pages/device/overview/eventlog.inc.php +++ b/html/pages/device/overview/eventlog.inc.php @@ -1,25 +1,22 @@ '); - echo('
    +echo '
    '; +echo '
    -
    '); -echo(''); -echo(" Recent Events"); -echo('
    - '); +
    '; +echo ''; +echo " Recent Events"; +echo '
    +
    '; $eventlog = dbFetchRows("SELECT *,DATE_FORMAT(datetime, '".$config['dateformat']['mysql']['compact']."') as humandate FROM `eventlog` WHERE `host` = ? ORDER BY `datetime` DESC LIMIT 0,10", array($device['device_id'])); -foreach ($eventlog as $entry) -{ - include("includes/print-event-short.inc.php"); +foreach ($eventlog as $entry) { + include 'includes/print-event-short.inc.php'; } -echo("
    "); -echo('
    '); -echo('
    '); -echo('
    '); -echo('
    '); - -?> +echo ''; +echo '
    '; +echo ''; +echo ''; +echo ''; diff --git a/html/pages/device/overview/generic/sensor.inc.php b/html/pages/device/overview/generic/sensor.inc.php index 6194c37c00..36bc05cd5d 100644 --- a/html/pages/device/overview/generic/sensor.inc.php +++ b/html/pages/device/overview/generic/sensor.inc.php @@ -1,75 +1,71 @@ +if (count($sensors)) { + echo '
    -
    -
    -
    '); - echo(' ' . $sensor_type . ''); - echo('
    - '); - foreach ($sensors as $sensor) - { - if ($config['memcached']['enable'] === TRUE) - { - $sensor['sensor_current'] = $memcache->get('sensor-'.$sensor['sensor_id'].'-value'); - } +
    +
    +
    '; + echo ' '.$sensor_type.''; + echo '
    +
    '; + foreach ($sensors as $sensor) { + if ($config['memcached']['enable'] === true) { + $sensor['sensor_current'] = $memcache->get('sensor-'.$sensor['sensor_id'].'-value'); + } - if (empty($sensor['sensor_current'])) - { - $sensor['sensor_current'] = "NaN"; - } + if (empty($sensor['sensor_current'])) { + $sensor['sensor_current'] = 'NaN'; + } - // FIXME - make this "four graphs in popup" a function/include and "small graph" a function. - // FIXME - So now we need to clean this up and move it into a function. Isn't it just "print-graphrow"? - // FIXME - DUPLICATED IN health/sensors + // FIXME - make this "four graphs in popup" a function/include and "small graph" a function. + // FIXME - So now we need to clean this up and move it into a function. Isn't it just "print-graphrow"? + // FIXME - DUPLICATED IN health/sensors + $graph_colour = str_replace('#', '', $row_colour); - $graph_colour = str_replace("#", "", $row_colour); + $graph_array = array(); + $graph_array['height'] = '100'; + $graph_array['width'] = '210'; + $graph_array['to'] = $config['time']['now']; + $graph_array['id'] = $sensor['sensor_id']; + $graph_array['type'] = $graph_type; + $graph_array['from'] = $config['time']['day']; + $graph_array['legend'] = 'no'; - $graph_array = array(); - $graph_array['height'] = "100"; - $graph_array['width'] = "210"; - $graph_array['to'] = $config['time']['now']; - $graph_array['id'] = $sensor['sensor_id']; - $graph_array['type'] = $graph_type; - $graph_array['from'] = $config['time']['day']; - $graph_array['legend'] = "no"; + $link_array = $graph_array; + $link_array['page'] = 'graphs'; + unset($link_array['height'], $link_array['width'], $link_array['legend']); + $link = generate_url($link_array); - $link_array = $graph_array; - $link_array['page'] = "graphs"; - unset($link_array['height'], $link_array['width'], $link_array['legend']); - $link = generate_url($link_array); + $overlib_content = '

    '.$device['hostname'].' - '.$sensor['sensor_descr'].'

    '; + foreach (array('day', 'week', 'month', 'year') as $period) { + $graph_array['from'] = $config['time'][$period]; + $overlib_content .= str_replace('"', "\'", generate_graph_tag($graph_array)); + } - $overlib_content = '

    '.$device['hostname']." - ".$sensor['sensor_descr']."

    "; - foreach (array('day','week','month','year') as $period) - { - $graph_array['from'] = $config['time'][$period]; - $overlib_content .= str_replace('"', "\'", generate_graph_tag($graph_array)); - } - $overlib_content .= "
    "; + $overlib_content .= '
    '; - $graph_array['width'] = 80; $graph_array['height'] = 20; $graph_array['bg'] = 'ffffff00'; # the 00 at the end makes the area transparent. - $graph_array['from'] = $config['time']['day']; - $sensor_minigraph = generate_graph_tag($graph_array); + $graph_array['width'] = 80; + $graph_array['height'] = 20; + $graph_array['bg'] = 'ffffff00'; + // the 00 at the end makes the area transparent. + $graph_array['from'] = $config['time']['day']; + $sensor_minigraph = generate_graph_tag($graph_array); - $sensor['sensor_descr'] = truncate($sensor['sensor_descr'], 48, ''); + $sensor['sensor_descr'] = truncate($sensor['sensor_descr'], 48, ''); - echo(" - - - - "); - } + echo ' + + + + '; + }//end foreach - echo("
    ".overlib_link($link, $sensor['sensor_descr'], $overlib_content)."".overlib_link($link, $sensor_minigraph, $overlib_content)."".overlib_link($link, " $sensor['sensor_limit'] ? "style='color: red'" : '') . '>' . $sensor['sensor_current'] . $sensor_unit . "", $overlib_content)."
    '.overlib_link($link, $sensor['sensor_descr'], $overlib_content).''.overlib_link($link, $sensor_minigraph, $overlib_content).''.overlib_link($link, ' $sensor['sensor_limit'] ? "style='color: red'" : '').'>'.$sensor['sensor_current'].$sensor_unit.'', $overlib_content).'
    "); - echo("
    "); - echo("
    "); - echo("
    "); - echo("
    "); -} - -?> + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; +}//end if diff --git a/html/pages/device/overview/mempools.inc.php b/html/pages/device/overview/mempools.inc.php index 3d35a8d554..0699872416 100644 --- a/html/pages/device/overview/mempools.inc.php +++ b/html/pages/device/overview/mempools.inc.php @@ -1,76 +1,77 @@ +if (count($mempools)) { + echo '
    -
    -
    -
    -'); - echo(''); - echo(" Memory Pools"); - echo(' -
    - -'); +
    +
    +
    + '; + echo ''; + echo " Memory Pools"; + echo ' +
    +
    + '; - foreach ($mempools as $mempool) - { + foreach ($mempools as $mempool) { + if ($config['memcached']['enable'] === true) { + $state = $memcache->get('mempool-'.$mempool['mempool_id'].'-state'); + if ($debug) { + print_r($state); + } - if ($config['memcached']['enable'] === TRUE) - { - $state = $memcache->get('mempool-'.$mempool['mempool_id'].'-state'); - if($debug) { print_r($state); } - if(is_array($state)) { $mempool = array_merge($mempool, $state); } - unset($state); - } + if (is_array($state)) { + $mempool = array_merge($mempool, $state); + } - $percent= round($mempool['mempool_perc'],0); - $text_descr = rewrite_entity_descr($mempool['mempool_descr']); - $total = formatStorage($mempool['mempool_total']); - $used = formatStorage($mempool['mempool_used']); - $free = formatStorage($mempool['mempool_free']); - $background = get_percentage_colours($percent); + unset($state); + } - $graph_array = array(); - $graph_array['height'] = "100"; - $graph_array['width'] = "210"; - $graph_array['to'] = $config['time']['now']; - $graph_array['id'] = $mempool['mempool_id']; - $graph_array['type'] = $graph_type; - $graph_array['from'] = $config['time']['day']; - $graph_array['legend'] = "no"; + $percent = round($mempool['mempool_perc'], 0); + $text_descr = rewrite_entity_descr($mempool['mempool_descr']); + $total = formatStorage($mempool['mempool_total']); + $used = formatStorage($mempool['mempool_used']); + $free = formatStorage($mempool['mempool_free']); + $background = get_percentage_colours($percent); - $link_array = $graph_array; - $link_array['page'] = "graphs"; - unset($link_array['height'], $link_array['width'], $link_array['legend']); - $link = generate_url($link_array); + $graph_array = array(); + $graph_array['height'] = '100'; + $graph_array['width'] = '210'; + $graph_array['to'] = $config['time']['now']; + $graph_array['id'] = $mempool['mempool_id']; + $graph_array['type'] = $graph_type; + $graph_array['from'] = $config['time']['day']; + $graph_array['legend'] = 'no'; - $overlib_content = generate_overlib_content($graph_array, $device['hostname'] . " - " . $text_descr); + $link_array = $graph_array; + $link_array['page'] = 'graphs'; + unset($link_array['height'], $link_array['width'], $link_array['legend']); + $link = generate_url($link_array); - $graph_array['width'] = 80; $graph_array['height'] = 20; $graph_array['bg'] = 'ffffff00'; # the 00 at the end makes the area transparent. + $overlib_content = generate_overlib_content($graph_array, $device['hostname'].' - '.$text_descr); - $minigraph = generate_graph_tag($graph_array); + $graph_array['width'] = 80; + $graph_array['height'] = 20; + $graph_array['bg'] = 'ffffff00'; + // the 00 at the end makes the area transparent. + $minigraph = generate_graph_tag($graph_array); - echo(" - - - - "); - } + echo ' + + + + '; + }//end foreach - echo('
    ".overlib_link($link, $text_descr, $overlib_content)."".overlib_link($link, $minigraph, $overlib_content)."".overlib_link($link, print_percentage_bar (200, 20, $percent, NULL, "ffffff", $background['left'], $percent . "%", "ffffff", $background['right']), $overlib_content)." -
    '.overlib_link($link, $text_descr, $overlib_content).''.overlib_link($link, $minigraph, $overlib_content).''.overlib_link($link, print_percentage_bar(200, 20, $percent, null, 'ffffff', $background['left'], $percent.'%', 'ffffff', $background['right']), $overlib_content).' +
    + echo '
    -
    '); - -} - -?> + '; +}//end if diff --git a/html/pages/device/overview/ports.inc.php b/html/pages/device/overview/ports.inc.php index 807f8ee4fb..75cf3ca29f 100644 --- a/html/pages/device/overview/ports.inc.php +++ b/html/pages/device/overview/ports.inc.php @@ -1,68 +1,64 @@ '); - echo('
    +if ($ports['total']) { + echo '
    '; + echo '
    Overall Traffic
    - '); +
    '; - $graph_array['height'] = "100"; - $graph_array['width'] = "485"; - $graph_array['to'] = $config['time']['now']; - $graph_array['device'] = $device['device_id']; - $graph_array['type'] = "device_bits"; - $graph_array['from'] = $config['time']['day']; - $graph_array['legend'] = "no"; - $graph = generate_graph_tag($graph_array); + $graph_array['height'] = '100'; + $graph_array['width'] = '485'; + $graph_array['to'] = $config['time']['now']; + $graph_array['device'] = $device['device_id']; + $graph_array['type'] = 'device_bits'; + $graph_array['from'] = $config['time']['day']; + $graph_array['legend'] = 'no'; + $graph = generate_graph_tag($graph_array); - $link_array = $graph_array; - $link_array['page'] = "graphs"; - unset($link_array['height'], $link_array['width']); - $link = generate_url($link_array); + $link_array = $graph_array; + $link_array['page'] = 'graphs'; + unset($link_array['height'], $link_array['width']); + $link = generate_url($link_array); - $graph_array['width'] = "210"; - $overlib_content = generate_overlib_content($graph_array, $device['hostname'] . " - Device Traffic"); + $graph_array['width'] = '210'; + $overlib_content = generate_overlib_content($graph_array, $device['hostname'].' - Device Traffic'); - echo(' - - '); + echo ' + + '; - echo(' + echo ' - - - - - '); + + + + + '; - echo(' - + "); - echo(""); - echo("
    '); - echo(overlib_link($link, $graph, $overlib_content, NULL)); - echo('
    '; + echo overlib_link($link, $graph, $overlib_content, null); + echo '
    ' . $ports['total'] . ' ' . $ports['up'] . ' ' . $ports['down'] . ' ' . $ports['disabled'] . '
    '.$ports['total'].' '.$ports['up'].' '.$ports['down'].' '.$ports['disabled'].'
    '); + echo '
    '; - $ifsep = ""; + $ifsep = ''; - foreach (dbFetchRows("SELECT * FROM `ports` WHERE device_id = ? AND `deleted` != '1'", array($device['device_id'])) as $data) - { - $data = ifNameDescr($data); - $data = array_merge($data, $device); - echo("$ifsep" . generate_port_link($data, makeshortif(strtolower($data['label'])))); - $ifsep = ", "; - } + foreach (dbFetchRows("SELECT * FROM `ports` WHERE device_id = ? AND `deleted` != '1'", array($device['device_id'])) as $data) { + $data = ifNameDescr($data); + $data = array_merge($data, $device); + echo "$ifsep".generate_port_link($data, makeshortif(strtolower($data['label']))); + $ifsep = ', '; + } - unset($ifsep); - echo("
    "); - echo("
    "); - echo("
    "); - echo("
    "); - echo("
    "); -} - -?> + unset($ifsep); + echo ' '; + echo ''; + echo ''; + echo '
    '; + echo ''; + echo ''; + echo ''; +}//end if diff --git a/html/pages/device/overview/processors.inc.php b/html/pages/device/overview/processors.inc.php index 3394e263ca..8b4d3f2912 100644 --- a/html/pages/device/overview/processors.inc.php +++ b/html/pages/device/overview/processors.inc.php @@ -1,66 +1,63 @@ +if (count($processors)) { + echo '
    -'); - echo(''); - echo(" Processors"); - echo('
    - '); +'; + echo ''; + echo " Processors"; + echo ' +
    '; - foreach ($processors as $proc) - { - $text_descr = rewrite_entity_descr($proc['processor_descr']); + foreach ($processors as $proc) { + $text_descr = rewrite_entity_descr($proc['processor_descr']); - # disable short hrDeviceDescr. need to make this prettier. - #$text_descr = short_hrDeviceDescr($proc['processor_descr']); - $percent = $proc['processor_usage']; - $background = get_percentage_colours($percent); - $graph_colour = str_replace("#", "", $row_colour); + // disable short hrDeviceDescr. need to make this prettier. + // $text_descr = short_hrDeviceDescr($proc['processor_descr']); + $percent = $proc['processor_usage']; + $background = get_percentage_colours($percent); + $graph_colour = str_replace('#', '', $row_colour); - $graph_array = array(); - $graph_array['height'] = "100"; - $graph_array['width'] = "210"; - $graph_array['to'] = $config['time']['now']; - $graph_array['id'] = $proc['processor_id']; - $graph_array['type'] = $graph_type; - $graph_array['from'] = $config['time']['day']; - $graph_array['legend'] = "no"; + $graph_array = array(); + $graph_array['height'] = '100'; + $graph_array['width'] = '210'; + $graph_array['to'] = $config['time']['now']; + $graph_array['id'] = $proc['processor_id']; + $graph_array['type'] = $graph_type; + $graph_array['from'] = $config['time']['day']; + $graph_array['legend'] = 'no'; - $link_array = $graph_array; - $link_array['page'] = "graphs"; - unset($link_array['height'], $link_array['width'], $link_array['legend']); - $link = generate_url($link_array); + $link_array = $graph_array; + $link_array['page'] = 'graphs'; + unset($link_array['height'], $link_array['width'], $link_array['legend']); + $link = generate_url($link_array); - $overlib_content = generate_overlib_content($graph_array, $device['hostname'] . " - " . $text_descr); + $overlib_content = generate_overlib_content($graph_array, $device['hostname'].' - '.$text_descr); - $graph_array['width'] = 80; $graph_array['height'] = 20; $graph_array['bg'] = 'ffffff00'; # the 00 at the end makes the area transparent. + $graph_array['width'] = 80; + $graph_array['height'] = 20; + $graph_array['bg'] = 'ffffff00'; + // the 00 at the end makes the area transparent. + $minigraph = generate_graph_tag($graph_array); - $minigraph = generate_graph_tag($graph_array); - - echo(" - - - + + + - "); - } + '; + }//end foreach - echo('
    ".overlib_link($link, $text_descr, $overlib_content)."".overlib_link($link, $minigraph, $overlib_content)."".overlib_link($link, print_percentage_bar (200, 20, $percent, NULL, "ffffff", $background['left'], $percent . "%", "ffffff", $background['right']), $overlib_content)." + echo '
    '.overlib_link($link, $text_descr, $overlib_content).''.overlib_link($link, $minigraph, $overlib_content).''.overlib_link($link, print_percentage_bar(200, 20, $percent, null, 'ffffff', $background['left'], $percent.'%', 'ffffff', $background['right']), $overlib_content).'
    + echo '
    -
    '); - -} - -?> + '; +}//end if diff --git a/html/pages/device/overview/sensors/charge.inc.php b/html/pages/device/overview/sensors/charge.inc.php index bf40977499..b0df00968a 100644 --- a/html/pages/device/overview/sensors/charge.inc.php +++ b/html/pages/device/overview/sensors/charge.inc.php @@ -1,10 +1,8 @@ +require 'pages/device/overview/generic/sensor.inc.php'; diff --git a/html/pages/device/overview/sensors/load.inc.php b/html/pages/device/overview/sensors/load.inc.php index 989a305b9b..089f93dffb 100644 --- a/html/pages/device/overview/sensors/load.inc.php +++ b/html/pages/device/overview/sensors/load.inc.php @@ -1,8 +1,8 @@ '); - echo('
    +if ($services['total']) { +echo '
    '; + echo '
    -
    '); - echo(" Services"); - echo('
    - '); +
    '; + echo " Services"; + echo '
    +
    '; - echo(" + echo " @@ -19,22 +18,32 @@ echo('
    ');
    -
    $services[total] $services[up] $services[disabled]
    "); +"; - foreach (dbFetchRows("SELECT * FROM services WHERE device_id = ? ORDER BY service_type", array($device['device_id'])) as $data) - { - if ($data['service_status'] == "0" && $data['service_ignore'] == "1") { $status = "grey"; } - if ($data['service_status'] == "1" && $data['service_ignore'] == "1") { $status = "green"; } - if ($data['service_status'] == "0" && $data['service_ignore'] == "0") { $status = "red"; } - if ($data['service_status'] == "1" && $data['service_ignore'] == "0") { $status = "blue"; } - echo("$break" . strtolower($data['service_type']) . ""); - $break = ", "; - } - echo('
    '); - echo("
    "); - echo("
    "); - echo("
    "); - echo("
    "); -} + foreach (dbFetchRows('SELECT * FROM services WHERE device_id = ? ORDER BY service_type', array($device['device_id'])) as $data) { + if ($data['service_status'] == '0' && $data['service_ignore'] == '1') { + $status = 'grey'; + } -?> + if ($data['service_status'] == '1' && $data['service_ignore'] == '1') { + $status = 'green'; + } + + if ($data['service_status'] == '0' && $data['service_ignore'] == '0') { + $status = 'red'; + } + + if ($data['service_status'] == '1' && $data['service_ignore'] == '0') { + $status = 'blue'; + } + + echo "$break".strtolower($data['service_type']).''; + $break = ', '; + } + + echo ''; + echo '
    '; + echo ''; + echo ''; + echo ''; +}//end if diff --git a/html/pages/device/overview/storage.inc.php b/html/pages/device/overview/storage.inc.php index 01c02edb4e..e81b1b5b5d 100644 --- a/html/pages/device/overview/storage.inc.php +++ b/html/pages/device/overview/storage.inc.php @@ -1,91 +1,86 @@ +if (count($drives)) { + echo '
    -
    '); - echo(''); - echo(" Storage"); - echo('
    - '); +
    '; + echo ''; + echo " Storage"; + echo '
    +
    '; - foreach ($drives as $drive) - { - $skipdrive = 0; + foreach ($drives as $drive) { + $skipdrive = 0; - if ($device["os"] == "junos") - { - foreach ($config['ignore_junos_os_drives'] as $jdrive) - { - if (preg_match($jdrive, $drive["storage_descr"])) - { - $skipdrive = 1; + if ($device['os'] == 'junos') { + foreach ($config['ignore_junos_os_drives'] as $jdrive) { + if (preg_match($jdrive, $drive['storage_descr'])) { + $skipdrive = 1; + } + } + + $drive['storage_descr'] = preg_replace('/.*mounted on: (.*)/', '\\1', $drive['storage_descr']); } - } - $drive["storage_descr"] = preg_replace("/.*mounted on: (.*)/", "\\1", $drive["storage_descr"]); - } - if ($device['os'] == "freebsd") - { - foreach ($config['ignore_bsd_os_drives'] as $jdrive) - { - if (preg_match($jdrive, $drive["storage_descr"])) - { - $skipdrive = 1; + if ($device['os'] == 'freebsd') { + foreach ($config['ignore_bsd_os_drives'] as $jdrive) { + if (preg_match($jdrive, $drive['storage_descr'])) { + $skipdrive = 1; + } + } } - } - } - if ($skipdrive) { continue; } - $percent = round($drive['storage_perc'], 0); - $total = formatStorage($drive['storage_size']); - $free = formatStorage($drive['storage_free']); - $used = formatStorage($drive['storage_used']); - $background = get_percentage_colours($percent); + if ($skipdrive) { + continue; + } - $graph_array = array(); - $graph_array['height'] = "100"; - $graph_array['width'] = "210"; - $graph_array['to'] = $config['time']['now']; - $graph_array['id'] = $drive['storage_id']; - $graph_array['type'] = $graph_type; - $graph_array['from'] = $config['time']['day']; - $graph_array['legend'] = "no"; + $percent = round($drive['storage_perc'], 0); + $total = formatStorage($drive['storage_size']); + $free = formatStorage($drive['storage_free']); + $used = formatStorage($drive['storage_used']); + $background = get_percentage_colours($percent); - $link_array = $graph_array; - $link_array['page'] = "graphs"; - unset($link_array['height'], $link_array['width'], $link_array['legend']); - $link = generate_url($link_array); + $graph_array = array(); + $graph_array['height'] = '100'; + $graph_array['width'] = '210'; + $graph_array['to'] = $config['time']['now']; + $graph_array['id'] = $drive['storage_id']; + $graph_array['type'] = $graph_type; + $graph_array['from'] = $config['time']['day']; + $graph_array['legend'] = 'no'; - $overlib_content = generate_overlib_content($graph_array, $device['hostname'] . " - " . $drive['storage_descr']); + $link_array = $graph_array; + $link_array['page'] = 'graphs'; + unset($link_array['height'], $link_array['width'], $link_array['legend']); + $link = generate_url($link_array); - $graph_array['width'] = 80; $graph_array['height'] = 20; $graph_array['bg'] = 'ffffff00'; # the 00 at the end makes the area transparent. + $overlib_content = generate_overlib_content($graph_array, $device['hostname'].' - '.$drive['storage_descr']); - $minigraph = generate_graph_tag($graph_array); + $graph_array['width'] = 80; + $graph_array['height'] = 20; + $graph_array['bg'] = 'ffffff00'; + // the 00 at the end makes the area transparent. + $minigraph = generate_graph_tag($graph_array); - echo(" - - - + + + - "); - } + '; + }//end foreach - echo('
    ".overlib_link($link, $drive['storage_descr'], $overlib_content)."".overlib_link($link, $minigraph, $overlib_content)."".overlib_link($link, print_percentage_bar (200, 20, $percent, NULL, "ffffff", $background['left'], $percent . "%", "ffffff", $background['right']), $overlib_content)." + echo '
    '.overlib_link($link, $drive['storage_descr'], $overlib_content).''.overlib_link($link, $minigraph, $overlib_content).''.overlib_link($link, print_percentage_bar(200, 20, $percent, null, 'ffffff', $background['left'], $percent.'%', 'ffffff', $background['right']), $overlib_content).'
    + echo '
    -
    '); + '; +}//end if -} - -unset ($drive_rows); - -?> +unset($drive_rows); diff --git a/html/pages/device/overview/syslog.inc.php b/html/pages/device/overview/syslog.inc.php index 1d26fbb2a7..bcfb6d2c52 100644 --- a/html/pages/device/overview/syslog.inc.php +++ b/html/pages/device/overview/syslog.inc.php @@ -1,25 +1,24 @@ '); - echo('
    +if ($config['enable_syslog']) { + $syslog = dbFetchRows("SELECT *, DATE_FORMAT(timestamp, '".$config['dateformat']['mysql']['compact']."') AS date from syslog WHERE device_id = ? ORDER BY timestamp DESC LIMIT 20", array($device['device_id'])); + if (count($syslog)) { + echo '
    '; + echo '
    -
    '); - echo(' Recent Syslog'); -echo('
    - '); - foreach ($syslog as $entry) { include("includes/print-syslog.inc.php"); } - echo("
    "); - echo("
    "); - echo("
    "); - echo("
    "); - echo("
    "); - } -} +
    '; + echo ' Recent Syslog'; + echo '
    + '; + foreach ($syslog as $entry) { + include 'includes/print-syslog.inc.php'; + } -?> + echo '
    '; + echo '
    '; + echo ''; + echo ''; + echo ''; + } +} diff --git a/html/pages/device/overview/toner.inc.php b/html/pages/device/overview/toner.inc.php index 347a636195..7c789573c5 100644 --- a/html/pages/device/overview/toner.inc.php +++ b/html/pages/device/overview/toner.inc.php @@ -1,64 +1,62 @@ +if (count($toners)) { + echo '
    -
    '); - echo(''); - echo(" Toner"); - echo('
    - '); +
    '; + echo ''; + echo " Toner"; + echo '
    +
    '; - foreach ($toners as $toner) - { - $percent = round($toner['toner_current'], 0); - $total = formatStorage($toner['toner_size']); - $free = formatStorage($toner['toner_free']); - $used = formatStorage($toner['toner_used']); + foreach ($toners as $toner) { + $percent = round($toner['toner_current'], 0); + $total = formatStorage($toner['toner_size']); + $free = formatStorage($toner['toner_free']); + $used = formatStorage($toner['toner_used']); - $background = toner2colour($toner['toner_descr'], $percent); + $background = toner2colour($toner['toner_descr'], $percent); - $graph_array = array(); - $graph_array['height'] = "100"; - $graph_array['width'] = "210"; - $graph_array['to'] = $config['time']['now']; - $graph_array['id'] = $toner['toner_id']; - $graph_array['type'] = $graph_type; - $graph_array['from'] = $config['time']['day']; - $graph_array['legend'] = "no"; + $graph_array = array(); + $graph_array['height'] = '100'; + $graph_array['width'] = '210'; + $graph_array['to'] = $config['time']['now']; + $graph_array['id'] = $toner['toner_id']; + $graph_array['type'] = $graph_type; + $graph_array['from'] = $config['time']['day']; + $graph_array['legend'] = 'no'; - $link_array = $graph_array; - $link_array['page'] = "graphs"; - unset($link_array['height'], $link_array['width'], $link_array['legend']); - $link = generate_url($link_array); + $link_array = $graph_array; + $link_array['page'] = 'graphs'; + unset($link_array['height'], $link_array['width'], $link_array['legend']); + $link = generate_url($link_array); - $overlib_content = generate_overlib_content($graph_array, $device['hostname'] . " - " . $toner['toner_descr']); + $overlib_content = generate_overlib_content($graph_array, $device['hostname'].' - '.$toner['toner_descr']); - $graph_array['width'] = 80; $graph_array['height'] = 20; $graph_array['bg'] = 'ffffff00'; # the 00 at the end makes the area transparent. + $graph_array['width'] = 80; + $graph_array['height'] = 20; + $graph_array['bg'] = 'ffffff00'; + // the 00 at the end makes the area transparent. + $minigraph = generate_graph_tag($graph_array); - $minigraph = generate_graph_tag($graph_array); - - echo(" - - - + + + - "); - } + '; + }//end foreach - echo("
    ".overlib_link($link, $toner['toner_descr'], $overlib_content)."".overlib_link($link, $minigraph, $overlib_content)."".overlib_link($link, print_percentage_bar (200, 20, $percent, NULL, "ffffff", $background['left'], $percent . "%", "ffffff", $background['right']), $overlib_content)." + echo '
    '.overlib_link($link, $toner['toner_descr'], $overlib_content).''.overlib_link($link, $minigraph, $overlib_content).''.overlib_link($link, print_percentage_bar(200, 20, $percent, null, 'ffffff', $background['left'], $percent.'%', 'ffffff', $background['right']), $overlib_content).'
    "); - echo("
    "); - echo("
    "); - echo("
    "); - echo(""); -} + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; +}//end if -unset ($toner_rows); - -?> +unset($toner_rows); diff --git a/html/pages/device/performance.inc.php b/html/pages/device/performance.inc.php index 8686bf8034..da2056c54b 100644 --- a/html/pages/device/performance.inc.php +++ b/html/pages/device/performance.inc.php @@ -21,7 +21,9 @@ */ -if(!isset($vars['section'])) { $vars['section'] = "performance"; } +if(!isset($vars['section'])) { + $vars['section'] = "performance"; +} if (empty($vars['dtpickerfrom'])) { $vars['dtpickerfrom'] = date($config['dateformat']['byminute'], time() - 3600 * 24 * 2); @@ -57,7 +59,8 @@ if (empty($vars['dtpickerto'])) { if (is_admin() === true || is_read() === true) { $query = "SELECT DATE_FORMAT(timestamp, '".$config['alert_graph_date_format']."') Date, xmt,rcv,loss,min,max,avg FROM `device_perf` WHERE `device_id` = ? AND `timestamp` >= ? AND `timestamp` <= ?"; $param = array($device['device_id'], $vars['dtpickerfrom'], $vars['dtpickerto']); -} else { +} +else { $query = "SELECT DATE_FORMAT(timestamp, '".$config['alert_graph_date_format']."') Date, xmt,rcv,loss,min,max,avg FROM `device_perf`,`devices_perms` WHERE `device_id` = ? AND alert_log.device_id = devices_perms.device_id AND devices_perms.user_id = ? AND `timestamp` >= ? AND `timestamp` <= ?"; $param = array($device['device_id'], $_SESSION['user_id'], $vars['dtpickerfrom'], $vars['dtpickerto']); } @@ -81,7 +84,7 @@ foreach(dbFetchRows($query, $param) as $return_value) { $avg = $return_value['avg']; if ($max > $max_val) { - $max_val = $max; + $max_val = $max; } $data[] = array('x' => $date,'y' => $loss,'group' => 0); @@ -186,4 +189,3 @@ echo $milisec_diff; var graph2d = new vis.Graph2d(container, items, groups, options); - diff --git a/html/pages/device/port.inc.php b/html/pages/device/port.inc.php index ecb25cfd28..a70d40a763 100644 --- a/html/pages/device/port.inc.php +++ b/html/pages/device/port.inc.php @@ -1,15 +1,22 @@ get('port-'.$port['port_id'].'-state'); - if($debug) { print_r($state); } - if(is_array($state)) { $port = array_merge($port, $state); } - unset($state); +if ($config['memcached']['enable'] === true) { + $state = $memcache->get('port-'.$port['port_id'].'-state'); + if ($debug) { + print_r($state); + } + + if (is_array($state)) { + $port = array_merge($port, $state); + } + + unset($state); } $port_details = 1; @@ -17,148 +24,218 @@ $port_details = 1; $hostname = $device['hostname']; $hostid = $device['port_id']; $ifname = $port['ifDescr']; -$ifIndex = $port['ifIndex']; -$speed = humanspeed($port['ifSpeed']); +$ifIndex = $port['ifIndex']; +$speed = humanspeed($port['ifSpeed']); $ifalias = $port['name']; -if ($port['ifPhysAddress']) { $mac = "$port[ifPhysAddress]"; } +if ($port['ifPhysAddress']) { + $mac = "$port[ifPhysAddress]"; +} -$color = "black"; -if ($port['ifAdminStatus'] == "down") { $status = "Disabled"; } -if ($port['ifAdminStatus'] == "up" && $port['ifOperStatus'] == "down") { $status = "Enabled / Disconnected"; } -if ($port['ifAdminStatus'] == "up" && $port['ifOperStatus'] == "up") { $status = "Enabled / Connected"; } +$color = 'black'; +if ($port['ifAdminStatus'] == 'down') { + $status = "Disabled"; +} -$i = 1; +if ($port['ifAdminStatus'] == 'up' && $port['ifOperStatus'] == 'down') { + $status = "Enabled / Disconnected"; +} + +if ($port['ifAdminStatus'] == 'up' && $port['ifOperStatus'] == 'up') { + $status = "Enabled / Connected"; +} + +$i = 1; $inf = fixifName($ifname); -$bg="#ffffff"; +$bg = '#ffffff'; $show_all = 1; -echo("
    "); +echo "
    "; -include("includes/print-interface.inc.php"); +require 'includes/print-interface.inc.php'; -echo("
    "); +echo ''; -$pos = strpos(strtolower($ifname), "vlan"); -if ($pos !== false ) -{ - $broke = yes; +$pos = strpos(strtolower($ifname), 'vlan'); +if ($pos !== false) { + $broke = yes; } -$pos = strpos(strtolower($ifname), "loopback"); +$pos = strpos(strtolower($ifname), 'loopback'); -if ($pos !== false ) -{ - $broke = yes; +if ($pos !== false) { + $broke = yes; } -echo("
    "); +echo "
    "; print_optionbar_start(); -$link_array = array('page' => 'device', - 'device' => $device['device_id'], - 'tab' => 'port', - 'port' => $port['port_id']); +$link_array = array( + 'page' => 'device', + 'device' => $device['device_id'], + 'tab' => 'port', + 'port' => $port['port_id'], +); $menu_options['graphs'] = 'Graphs'; -$menu_options['realtime'] = 'Real time'; // FIXME CONDITIONAL -$menu_options['arp'] = 'ARP Table'; -$menu_options['events'] = 'Eventlog'; +$menu_options['realtime'] = 'Real time'; +// FIXME CONDITIONAL +$menu_options['arp'] = 'ARP Table'; +$menu_options['events'] = 'Eventlog'; -if (dbFetchCell("SELECT COUNT(*) FROM `ports_adsl` WHERE `port_id` = '".$port['port_id']."'") ) -{ $menu_options['adsl'] = 'ADSL'; } - -if (dbFetchCell("SELECT COUNT(*) FROM `ports` WHERE `pagpGroupIfIndex` = '".$port['ifIndex']."' and `device_id` = '".$device['device_id']."'") ) -{ $menu_options['pagp'] = 'PAgP'; } - -if (dbFetchCell("SELECT COUNT(*) FROM `ports_vlans` WHERE `port_id` = '".$port['port_id']."' and `device_id` = '".$device['device_id']."'") ) -{ $menu_options['vlans'] = 'VLANs'; } - -$sep = ""; -foreach ($menu_options as $option => $text) -{ - echo($sep); - if ($vars['view'] == $option) { echo(""); } - echo(generate_link($text,$link_array,array('view'=>$option))); - if ($vars['view'] == $option) { echo(""); } - $sep = " | "; +if (dbFetchCell("SELECT COUNT(*) FROM `ports_adsl` WHERE `port_id` = '".$port['port_id']."'")) { + $menu_options['adsl'] = 'ADSL'; } + +if (dbFetchCell("SELECT COUNT(*) FROM `ports` WHERE `pagpGroupIfIndex` = '".$port['ifIndex']."' and `device_id` = '".$device['device_id']."'")) { + $menu_options['pagp'] = 'PAgP'; +} + +if (dbFetchCell("SELECT COUNT(*) FROM `ports_vlans` WHERE `port_id` = '".$port['port_id']."' and `device_id` = '".$device['device_id']."'")) { + $menu_options['vlans'] = 'VLANs'; +} + +$sep = ''; +foreach ($menu_options as $option => $text) { + echo $sep; + if ($vars['view'] == $option) { + echo ""; + } + + echo generate_link($text, $link_array, array('view' => $option)); + if ($vars['view'] == $option) { + echo ''; + } + + $sep = ' | '; +} + unset($sep); -if (dbFetchCell("SELECT count(*) FROM mac_accounting WHERE port_id = '".$port['port_id']."'") > "0" ) -{ +if (dbFetchCell("SELECT count(*) FROM mac_accounting WHERE port_id = '".$port['port_id']."'") > '0') { + echo generate_link($descr, $link_array, array('view' => 'macaccounting', 'graph' => $type)); - echo(generate_link($descr,$link_array,array('view'=>'macaccounting','graph'=>$type))); + echo ' | Mac Accounting : '; + if ($vars['view'] == 'macaccounting' && $vars['graph'] == 'bits' && $vars['subview'] == 'graphs') { + echo ""; + } - echo(" | Mac Accounting : "); - if ($vars['view'] == "macaccounting" && $vars['graph'] == "bits" && $vars['subview'] == "graphs") { echo(""); } - echo(generate_link("Bits",$link_array,array('view' => 'macaccounting', 'subview' => 'graphs', 'graph'=>'bits'))); - if ($vars['view'] == "macaccounting" && $vars['graph'] == "bits" && $vars['subview'] == "graphs") { echo(""); } + echo generate_link('Bits', $link_array, array('view' => 'macaccounting', 'subview' => 'graphs', 'graph' => 'bits')); + if ($vars['view'] == 'macaccounting' && $vars['graph'] == 'bits' && $vars['subview'] == 'graphs') { + echo ''; + } - echo("("); - if ($vars['view'] == "macaccounting" && $vars['graph'] == "bits" && $vars['subview'] == "minigraphs") { echo(""); } - echo(generate_link("Mini",$link_array,array('view' => 'macaccounting', 'subview' => 'minigraphs', 'graph'=>'bits'))); - if ($vars['view'] == "macaccounting" && $vars['graph'] == "bits" && $vars['subview'] == "minigraphs") { echo(""); } - echo('|'); + echo '('; + if ($vars['view'] == 'macaccounting' && $vars['graph'] == 'bits' && $vars['subview'] == 'minigraphs') { + echo ""; + } - if ($vars['view'] == "macaccounting" && $vars['graph'] == "bits" && $vars['subview'] == "top10") { echo(""); } - echo(generate_link("Top10",$link_array,array('view' => 'macaccounting', 'subview' => 'top10', 'graph'=>'bits'))); - if ($vars['view'] == "macaccounting" && $vars['graph'] == "bits" && $vars['subview'] == "top10") { echo(""); } - echo(") | "); + echo generate_link('Mini', $link_array, array('view' => 'macaccounting', 'subview' => 'minigraphs', 'graph' => 'bits')); + if ($vars['view'] == 'macaccounting' && $vars['graph'] == 'bits' && $vars['subview'] == 'minigraphs') { + echo ''; + } - if ($vars['view'] == "macaccounting" && $vars['graph'] == "pkts" && $vars['subview'] == "graphs") { echo(""); } - echo(generate_link("Packets",$link_array,array('view' => 'macaccounting', 'subview' => 'graphs', 'graph'=>'pkts'))); - if ($vars['view'] == "macaccounting" && $vars['graph'] == "pkts" && $vars['subview'] == "graphs") { echo(""); } - echo("("); - if ($vars['view'] == "macaccounting" && $vars['graph'] == "pkts" && $vars['subview'] == "minigraphs") { echo(""); } - echo(generate_link("Mini",$link_array,array('view' => 'macaccounting', 'subview' => 'minigraphs', 'graph'=>'pkts'))); - if ($vars['view'] == "macaccounting" && $vars['graph'] == "pkts" && $vars['subview'] == "minigraphs") { echo(""); } - echo('|'); - if ($vars['view'] == "macaccounting" && $vars['graph'] == "pkts" && $vars['subview'] == "top10") { echo(""); } - echo(generate_link("Top10",$link_array,array('view' => 'macaccounting', 'subview' => 'top10', 'graph'=>'pkts'))); - if ($vars['view'] == "macaccounting" && $vars['graph'] == "pkts" && $vars['subview'] == "top10") { echo(""); } - echo(")"); -} + echo '|'; -if (dbFetchCell("SELECT COUNT(*) FROM juniAtmVp WHERE port_id = '".$port['port_id']."'") > "0" ) -{ + if ($vars['view'] == 'macaccounting' && $vars['graph'] == 'bits' && $vars['subview'] == 'top10') { + echo ""; + } - // FIXME ATM VPs - // FIXME URLs BROKEN + echo generate_link('Top10', $link_array, array('view' => 'macaccounting', 'subview' => 'top10', 'graph' => 'bits')); + if ($vars['view'] == 'macaccounting' && $vars['graph'] == 'bits' && $vars['subview'] == 'top10') { + echo ''; + } - echo(" | ATM VPs : "); - if ($vars['view'] == "junose-atm-vp" && $vars['graph'] == "bits") { echo(""); } - echo("Bits"); - if ($vars['view'] == "junose-atm-vp" && $vars['graph'] == "bits") { echo(""); } - echo(" | "); - if ($vars['view'] == "junose-atm-vp" && $vars['graph'] == "packets") { echo(""); } - echo("Packets"); - if ($vars['view'] == "junose-atm-vp" && $vars['graph'] == "bits") { echo(""); } - echo(" | "); - if ($vars['view'] == "junose-atm-vp" && $vars['graph'] == "cells") { echo(""); } - echo("Cells"); - if ($vars['view'] == "junose-atm-vp" && $vars['graph'] == "bits") { echo(""); } - echo(" | "); - if ($vars['view'] == "junose-atm-vp" && $vars['graph'] == "errors") { echo(""); } - echo("Errors"); - if ($vars['view'] == "junose-atm-vp" && $vars['graph'] == "bits") { echo(""); } -} + echo ') | '; -if ($_SESSION['userlevel'] >= '10') -{ - echo(" Create Bill"); + if ($vars['view'] == 'macaccounting' && $vars['graph'] == 'pkts' && $vars['subview'] == 'graphs') { + echo ""; + } + + echo generate_link('Packets', $link_array, array('view' => 'macaccounting', 'subview' => 'graphs', 'graph' => 'pkts')); + if ($vars['view'] == 'macaccounting' && $vars['graph'] == 'pkts' && $vars['subview'] == 'graphs') { + echo ''; + } + + echo '('; + if ($vars['view'] == 'macaccounting' && $vars['graph'] == 'pkts' && $vars['subview'] == 'minigraphs') { + echo ""; + } + + echo generate_link('Mini', $link_array, array('view' => 'macaccounting', 'subview' => 'minigraphs', 'graph' => 'pkts')); + if ($vars['view'] == 'macaccounting' && $vars['graph'] == 'pkts' && $vars['subview'] == 'minigraphs') { + echo ''; + } + + echo '|'; + if ($vars['view'] == 'macaccounting' && $vars['graph'] == 'pkts' && $vars['subview'] == 'top10') { + echo ""; + } + + echo generate_link('Top10', $link_array, array('view' => 'macaccounting', 'subview' => 'top10', 'graph' => 'pkts')); + if ($vars['view'] == 'macaccounting' && $vars['graph'] == 'pkts' && $vars['subview'] == 'top10') { + echo ''; + } + + echo ')'; +}//end if + +if (dbFetchCell("SELECT COUNT(*) FROM juniAtmVp WHERE port_id = '".$port['port_id']."'") > '0') { + // FIXME ATM VPs + // FIXME URLs BROKEN + echo ' | ATM VPs : '; + if ($vars['view'] == 'junose-atm-vp' && $vars['graph'] == 'bits') { + echo ""; + } + + echo "Bits"; + if ($vars['view'] == 'junose-atm-vp' && $vars['graph'] == 'bits') { + echo ''; + } + + echo ' | '; + if ($vars['view'] == 'junose-atm-vp' && $vars['graph'] == 'packets') { + echo ""; + } + + echo "Packets"; + if ($vars['view'] == 'junose-atm-vp' && $vars['graph'] == 'bits') { + echo ''; + } + + echo ' | '; + if ($vars['view'] == 'junose-atm-vp' && $vars['graph'] == 'cells') { + echo ""; + } + + echo "Cells"; + if ($vars['view'] == 'junose-atm-vp' && $vars['graph'] == 'bits') { + echo ''; + } + + echo ' | '; + if ($vars['view'] == 'junose-atm-vp' && $vars['graph'] == 'errors') { + echo ""; + } + + echo "Errors"; + if ($vars['view'] == 'junose-atm-vp' && $vars['graph'] == 'bits') { + echo ''; + } +}//end if + +if ($_SESSION['userlevel'] >= '10') { + echo " Create Bill"; } print_optionbar_end(); -echo("
    "); +echo "
    "; -include("pages/device/port/".mres($vars['view']).".inc.php"); +require 'pages/device/port/'.mres($vars['view']).'.inc.php'; -echo("
    "); - -?> +echo '
    '; diff --git a/html/pages/device/port/events.inc.php b/html/pages/device/port/events.inc.php index 6de49ef262..5a113fafe6 100644 --- a/html/pages/device/port/events.inc.php +++ b/html/pages/device/port/events.inc.php @@ -1,15 +1,12 @@ '); +echo ''; -foreach ($entries as $entry) -{ - include("includes/print-event.inc.php"); +foreach ($entries as $entry) { + include 'includes/print-event.inc.php'; } -echo('
    '); +echo ''; -$pagetitle[] = "Events"; - -?> +$pagetitle[] = 'Events'; diff --git a/html/pages/device/port/pagp.inc.php b/html/pages/device/port/pagp.inc.php index e64437e2c2..7a8e41ff50 100644 --- a/html/pages/device/port/pagp.inc.php +++ b/html/pages/device/port/pagp.inc.php @@ -3,34 +3,32 @@ global $config; // FIXME functions! - -if (!$graph_type) { $graph_type = "pagp_bits"; } - -$daily_traffic = "graph.php?port=" . $port['port_id'] . "&type=$graph_type&from=".$config['time']['day']."&to=".$config['time']['now']."&width=215&height=100"; -$daily_url = "graph.php?port=" . $port['port_id'] . "&type=$graph_type&from=".$config['time']['day']."&to=".$config['time']['now']."&width=500&height=150"; - -$weekly_traffic = "graph.php?port=" . $port['port_id'] . "&type=$graph_type&from=".$config['time']['week']."&to=".$config['time']['now']."&width=215&height=100"; -$weekly_url = "graph.php?port=" . $port['port_id'] . "&type=$graph_type&from=".$config['time']['week']."&to=".$config['time']['now']."&width=500&height=150"; - -$monthly_traffic = "graph.php?port=" . $port['port_id'] . "&type=$graph_type&from=".$config['time']['month']."&to=".$config['time']['now']."&width=215&height=100"; -$monthly_url = "graph.php?port=" . $port['port_id'] . "&type=$graph_type&from=".$config['time']['month']."&to=".$config['time']['now']."&width=500&height=150"; - -$yearly_traffic = "graph.php?port=" . $port['port_id'] . "&type=$graph_type&from=".$config['time']['year']."&to=".$config['time']['now']."&width=215&height=100"; -$yearly_url = "graph.php?port=" . $port['port_id'] . "&type=$graph_type&from=".$config['time']['year']."&to=".$config['time']['now']."&width=500&height=150"; - -echo("', LEFT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\"> - "); -echo("', LEFT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\"> - "); -echo("', LEFT".$config['overlib_defaults'].", WIDTH, 350);\" onmouseout=\"return nd();\"> - "); -echo("', LEFT".$config['overlib_defaults'].", WIDTH, 350);\" onmouseout=\"return nd();\"> - "); - -foreach (dbFetchRows("SELECT * FROM `ports` WHERE `pagpGroupIfIndex` = ? and `device_id` = ?", array($port['ifIndex'], $device['device_id'])) as $member) -{ - echo("$br " . generate_port_link($member) . " (PAgP)"); - $br = "
    "; +if (!$graph_type) { + $graph_type = 'pagp_bits'; } -?> +$daily_traffic = 'graph.php?port='.$port['port_id']."&type=$graph_type&from=".$config['time']['day'].'&to='.$config['time']['now'].'&width=215&height=100'; +$daily_url = 'graph.php?port='.$port['port_id']."&type=$graph_type&from=".$config['time']['day'].'&to='.$config['time']['now'].'&width=500&height=150'; + +$weekly_traffic = 'graph.php?port='.$port['port_id']."&type=$graph_type&from=".$config['time']['week'].'&to='.$config['time']['now'].'&width=215&height=100'; +$weekly_url = 'graph.php?port='.$port['port_id']."&type=$graph_type&from=".$config['time']['week'].'&to='.$config['time']['now'].'&width=500&height=150'; + +$monthly_traffic = 'graph.php?port='.$port['port_id']."&type=$graph_type&from=".$config['time']['month'].'&to='.$config['time']['now'].'&width=215&height=100'; +$monthly_url = 'graph.php?port='.$port['port_id']."&type=$graph_type&from=".$config['time']['month'].'&to='.$config['time']['now'].'&width=500&height=150'; + +$yearly_traffic = 'graph.php?port='.$port['port_id']."&type=$graph_type&from=".$config['time']['year'].'&to='.$config['time']['now'].'&width=215&height=100'; +$yearly_url = 'graph.php?port='.$port['port_id']."&type=$graph_type&from=".$config['time']['year'].'&to='.$config['time']['now'].'&width=500&height=150'; + +echo "', LEFT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\"> + "; +echo "', LEFT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\"> + "; +echo "', LEFT".$config['overlib_defaults'].", WIDTH, 350);\" onmouseout=\"return nd();\"> + "; +echo "', LEFT".$config['overlib_defaults'].", WIDTH, 350);\" onmouseout=\"return nd();\"> + "; + +foreach (dbFetchRows('SELECT * FROM `ports` WHERE `pagpGroupIfIndex` = ? and `device_id` = ?', array($port['ifIndex'], $device['device_id'])) as $member) { + echo "$br ".generate_port_link($member).' (PAgP)'; + $br = '
    '; +} diff --git a/html/pages/device/ports.inc.php b/html/pages/device/ports.inc.php index b254b376da..dc941e246f 100644 --- a/html/pages/device/ports.inc.php +++ b/html/pages/device/ports.inc.php @@ -1,15 +1,23 @@ 'device', - 'device' => $device['device_id'], - 'tab' => 'ports'); +$link_array = array( + 'page' => 'device', + 'device' => $device['device_id'], + 'tab' => 'ports', +); print_optionbar_start(); @@ -17,110 +25,136 @@ $menu_options['basic'] = 'Basic'; $menu_options['details'] = 'Details'; $menu_options['arp'] = 'ARP Table'; -if(dbFetchCell("SELECT * FROM links AS L, ports AS I WHERE I.device_id = '".$device['device_id']."' AND I.port_id = L.local_port_id")) -{ - $menu_options['neighbours'] = 'Neighbours'; -} -if(dbFetchCell("SELECT COUNT(*) FROM `ports` WHERE `ifType` = 'adsl'")) -{ - $menu_options['adsl'] = 'ADSL'; +if (dbFetchCell("SELECT * FROM links AS L, ports AS I WHERE I.device_id = '".$device['device_id']."' AND I.port_id = L.local_port_id")) { + $menu_options['neighbours'] = 'Neighbours'; } -$sep = ""; -foreach ($menu_options as $option => $text) -{ - echo($sep); - if ($vars['view'] == $option) { echo(""); } - echo(generate_link($text,$link_array,array('view'=>$option))); - if ($vars['view'] == $option) { echo(""); } - $sep = " | "; +if (dbFetchCell("SELECT COUNT(*) FROM `ports` WHERE `ifType` = 'adsl'")) { + $menu_options['adsl'] = 'ADSL'; +} + +$sep = ''; +foreach ($menu_options as $option => $text) { + echo $sep; + if ($vars['view'] == $option) { + echo ""; + } + + echo generate_link($text, $link_array, array('view' => $option)); + if ($vars['view'] == $option) { + echo ''; + } + + $sep = ' | '; } unset($sep); -echo(' | Graphs: '); +echo ' | Graphs: '; -$graph_types = array("bits" => "Bits", - "upkts" => "Unicast Packets", - "nupkts" => "Non-Unicast Packets", - "errors" => "Errors", - "etherlike" => "Etherlike"); +$graph_types = array( + 'bits' => 'Bits', + 'upkts' => 'Unicast Packets', + 'nupkts' => 'Non-Unicast Packets', + 'errors' => 'Errors', + 'etherlike' => 'Etherlike', +); -foreach ($graph_types as $type => $descr) -{ - echo("$type_sep"); - if ($vars['graph'] == $type && $vars['view'] == "graphs") { echo(""); } - echo(generate_link($descr,$link_array,array('view'=>'graphs','graph'=>$type))); - if ($vars['graph'] == $type && $vars['view'] == "graphs") { echo(""); } +foreach ($graph_types as $type => $descr) { + echo "$type_sep"; + if ($vars['graph'] == $type && $vars['view'] == 'graphs') { + echo ""; + } - echo(' ('); - if ($vars['graph'] == $type && $vars['view'] == "minigraphs") { echo(""); } - echo(generate_link('Mini',$link_array,array('view'=>'minigraphs','graph'=>$type))); - if ($vars['graph'] == $type && $vars['view'] == "minigraphs") { echo(""); } - echo(')'); - $type_sep = " | "; -} + echo generate_link($descr, $link_array, array('view' => 'graphs', 'graph' => $type)); + if ($vars['graph'] == $type && $vars['view'] == 'graphs') { + echo ''; + } + + echo ' ('; + if ($vars['graph'] == $type && $vars['view'] == 'minigraphs') { + echo ""; + } + + echo generate_link('Mini', $link_array, array('view' => 'minigraphs', 'graph' => $type)); + if ($vars['graph'] == $type && $vars['view'] == 'minigraphs') { + echo ''; + } + + echo ')'; + $type_sep = ' | '; +}//end foreach print_optionbar_end(); -if ($vars['view'] == 'minigraphs') -{ - $timeperiods = array('-1day','-1week','-1month','-1year'); - $from = '-1day'; - echo("
    "); - unset ($seperator); +if ($vars['view'] == 'minigraphs') { + $timeperiods = array( + '-1day', + '-1week', + '-1month', + '-1year', + ); + $from = '-1day'; + echo "
    "; + unset($seperator); - // FIXME - FIX THIS. UGLY. - foreach (dbFetchRows("select * from ports WHERE device_id = ? ORDER BY ifIndex", array($device['device_id'])) as $port) - { - echo("
    -
    ".makeshortif($port['ifDescr'])."
    - ".$device['hostname']." - ".$port['ifDescr']."
    \ - ".$port['ifAlias']." \ - \ - ', CENTER, LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 150);\" onmouseout=\"return nd();\" >". - " - -
    ".truncate(short_port_descr($port['ifAlias']), 32, '')."
    -
    "); - } - echo("
    "); -} elseif ($vars['view'] == "arp" || $vars['view'] == "adsl" || $vars['view'] == "neighbours") { - include("ports/".$vars['view'].".inc.php"); -} else { - if ($vars['view'] == "details") { $port_details = 1; } - echo("
    "); - $i = "1"; - - global $port_cache, $port_index_cache; - - $ports = dbFetchRows("SELECT * FROM `ports` WHERE `device_id` = ? AND `deleted` = '0' ORDER BY `ifIndex` ASC", array($device['device_id'])); - // As we've dragged the whole database, lets pre-populate our caches :) - // FIXME - we should probably split the fetching of link/stack/etc into functions and cache them here too to cut down on single row queries. - foreach ($ports as $port) - { - $port_cache[$port['port_id']] = $port; - $port_index_cache[$port['device_id']][$port['ifIndex']] = $port; - } - - foreach ($ports as $port) - { - if ($config['memcached']['enable'] === TRUE) - { - $state = $memcache->get('port-'.$port['port_id'].'-state'); - if($debug) { print_r($state); } - if(is_array($state)) { $port = array_merge($port, $state); } - unset($state); + // FIXME - FIX THIS. UGLY. + foreach (dbFetchRows('select * from ports WHERE device_id = ? ORDER BY ifIndex', array($device['device_id'])) as $port) { + echo "
    +
    ".makeshortif($port['ifDescr']).'
    + ".$device['hostname'].' - '.$port['ifDescr'].'
    \ + '.$port['ifAlias']." \ + \ + ', CENTER, LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 150);\" onmouseout=\"return nd();\" >"." + +
    ".truncate(short_port_descr($port['ifAlias']), 32, '').'
    + '; } - include("includes/print-interface.inc.php"); - - $i++; - } - echo("
    "); + echo '
    '; } +else if ($vars['view'] == 'arp' || $vars['view'] == 'adsl' || $vars['view'] == 'neighbours') { + include 'ports/'.$vars['view'].'.inc.php'; +} +else { + if ($vars['view'] == 'details') { + $port_details = 1; + } -$pagetitle[] = "Ports"; + echo "
    "; + $i = '1'; -?> + global $port_cache, $port_index_cache; + + $ports = dbFetchRows("SELECT * FROM `ports` WHERE `device_id` = ? AND `deleted` = '0' ORDER BY `ifIndex` ASC", array($device['device_id'])); + // As we've dragged the whole database, lets pre-populate our caches :) + // FIXME - we should probably split the fetching of link/stack/etc into functions and cache them here too to cut down on single row queries. + foreach ($ports as $port) { + $port_cache[$port['port_id']] = $port; + $port_index_cache[$port['device_id']][$port['ifIndex']] = $port; + } + + foreach ($ports as $port) { + if ($config['memcached']['enable'] === true) { + $state = $memcache->get('port-'.$port['port_id'].'-state'); + if ($debug) { + print_r($state); + } + + if (is_array($state)) { + $port = array_merge($port, $state); + } + + unset($state); + } + + include 'includes/print-interface.inc.php'; + + $i++; + } + + echo '
    '; +}//end if + +$pagetitle[] = 'Ports'; diff --git a/html/pages/device/ports/neighbours.inc.php b/html/pages/device/ports/neighbours.inc.php index 5e417eb996..b56136881e 100644 --- a/html/pages/device/ports/neighbours.inc.php +++ b/html/pages/device/ports/neighbours.inc.php @@ -10,8 +10,7 @@ echo 'Local Port Protocol '; -foreach (dbFetchRows('SELECT * FROM links AS L, ports AS I WHERE I.device_id = ? AND I.port_id = L.local_port_id', array($device['device_id'])) as $neighbour) -{ +foreach (dbFetchRows('SELECT * FROM links AS L, ports AS I WHERE I.device_id = ? AND I.port_id = L.local_port_id', array($device['device_id'])) as $neighbour) { if ($bg_colour == $list_colour_b) { $bg_colour = $list_colour_a; } diff --git a/html/pages/device/processes.inc.php b/html/pages/device/processes.inc.php index 41fda92887..0ce8e4c70f 100644 --- a/html/pages/device/processes.inc.php +++ b/html/pages/device/processes.inc.php @@ -1,19 +1,21 @@ +/* + * Copyright (C) 2015 Daniel Preussker * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . */ + * along with this program. If not, see . + */ -/** +/* * Process Listing * @author Daniel Preussker * @copyright 2015 f0o, LibreNMS @@ -22,77 +24,89 @@ * @subpackage Pages */ -switch( $vars['order'] ) { - case "vsz": - $order = "`vsz`"; - break; - case "rss": - $order = "`rss`"; - break; - case "cputime": - $order = "`cputime`"; - break; - case "user": - $order = "`user`"; - break; - case "command": - $order = "`command`"; - break; - default: - $order = "`pid`"; - break; +switch ($vars['order']) { + case 'vsz': + $order = '`vsz`'; + break; + + case 'rss': + $order = '`rss`'; + break; + + case 'cputime': + $order = '`cputime`'; + break; + + case 'user': + $order = '`user`'; + break; + + case 'command': + $order = '`command`'; + break; + + default: + $order = '`pid`'; + break; +}//end switch + +if ($vars['by'] == 'desc') { + $by = 'desc'; } -if( $vars['by'] == "desc" ) { - $by = "desc"; -} else { - $by = "asc"; +else { + $by = 'asc'; } $heads = array( - 'PID' => '', - 'VSZ' => 'Virtual Memory', - 'RSS' => 'Resident Memory', - 'cputime' => '', - 'user' => '', - 'command' => '' + 'PID' => '', + 'VSZ' => 'Virtual Memory', + 'RSS' => 'Resident Memory', + 'cputime' => '', + 'user' => '', + 'command' => '', ); echo "
    "; -foreach( $heads as $head=>$extra ) { - unset($lhead, $bhead); - $lhead = strtolower($head); - $bhead = 'asc'; - $icon = ""; - if( '`'.$lhead.'`' == $order ) { - $icon = " class='glyphicon glyphicon-chevron-"; - if( $by == 'asc' ) { - $bhead = 'desc'; - $icon .= 'up'; - } else { - $icon .= 'down'; - } - $icon .= "'"; - } - echo ''; -} -echo ""; +foreach ($heads as $head => $extra) { + unset($lhead, $bhead); + $lhead = strtolower($head); + $bhead = 'asc'; + $icon = ''; + if ('`'.$lhead.'`' == $order) { + $icon = " class='glyphicon glyphicon-chevron-"; + if ($by == 'asc') { + $bhead = 'desc'; + $icon .= 'up'; + } + else { + $icon .= 'down'; + } -foreach (dbFetchRows("SELECT * FROM `processes` WHERE `device_id` = ? ORDER BY ".$order." ".$by, array($device['device_id'])) as $entry) { - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; -} -echo"
     '; - if( !empty($extra) ) { - echo "$head"; - } else { - echo $head; - } - echo '
    '.$entry['pid'].''.format_si($entry['vsz']*1024).''.format_si($entry['rss']*1024).''.$entry['cputime'].''.$entry['user'].''.$entry['command'].'
    "; + $icon .= "'"; + } -?> + echo ' '; + if (!empty($extra)) { + echo "$head"; + } + else { + echo $head; + } + + echo ''; +}//end foreach + +echo ''; + +foreach (dbFetchRows('SELECT * FROM `processes` WHERE `device_id` = ? ORDER BY '.$order.' '.$by, array($device['device_id'])) as $entry) { + echo ''; + echo ''.$entry['pid'].''; + echo ''.format_si(($entry['vsz'] * 1024)).''; + echo ''.format_si(($entry['rss'] * 1024)).''; + echo ''.$entry['cputime'].''; + echo ''.$entry['user'].''; + echo ''.$entry['command'].''; + echo ''; +} + +echo '
    '; diff --git a/html/pages/device/pseudowires.inc.php b/html/pages/device/pseudowires.inc.php index c134c8b661..c48bca5738 100644 --- a/html/pages/device/pseudowires.inc.php +++ b/html/pages/device/pseudowires.inc.php @@ -89,8 +89,7 @@ foreach (dbFetchRows('SELECT * FROM pseudowires AS P, ports AS I WHERE P.port_id 'upkts', 'errors', ); - foreach ($types as $graph_type) - { + foreach ($types as $graph_type) { $pw_a['graph_type'] = 'port_'.$graph_type; print_port_thumbnail($pw_a); } diff --git a/html/pages/device/routing/bgp.inc.php b/html/pages/device/routing/bgp.inc.php index 5b327aca30..17f0629a02 100644 --- a/html/pages/device/routing/bgp.inc.php +++ b/html/pages/device/routing/bgp.inc.php @@ -1,203 +1,275 @@ 'device', - 'device' => $device['device_id'], - 'tab' => 'routing', - 'proto' => 'bgp'); +$link_array = array( + 'page' => 'device', + 'device' => $device['device_id'], + 'tab' => 'routing', + 'proto' => 'bgp', +); -if(!isset($vars['view'])) { $vars['view'] = "basic"; } +if (!isset($vars['view'])) { + $vars['view'] = 'basic'; +} print_optionbar_start(); -echo "Local AS : " .$device['bgpLocalAs']." "; +echo 'Local AS : '.$device['bgpLocalAs'].' '; -echo("BGP » "); +echo "BGP » "; -if ($vars['view'] == "basic") { echo(""); } -echo(generate_link("Basic", $link_array,array('view'=>'basic'))); -if ($vars['view'] == "basic") { echo(""); } +if ($vars['view'] == 'basic') { + echo ""; +} -echo(" | "); +echo generate_link('Basic', $link_array, array('view' => 'basic')); +if ($vars['view'] == 'basic') { + echo ''; +} -if ($vars['view'] == "updates") { echo(""); } -echo(generate_link("Updates", $link_array,array('view'=>'updates'))); -if ($vars['view'] == "updates") { echo(""); } +echo ' | '; -echo(" | Prefixes: "); +if ($vars['view'] == 'updates') { + echo ""; +} -if ($vars['view'] == "prefixes_ipv4unicast") { echo(""); } -echo(generate_link("IPv4", $link_array,array('view'=>'prefixes_ipv4unicast'))); -if ($vars['view'] == "prefixes_ipv4unicast") { echo(""); } +echo generate_link('Updates', $link_array, array('view' => 'updates')); +if ($vars['view'] == 'updates') { + echo ''; +} -echo(" | "); +echo ' | Prefixes: '; -if ($vars['view'] == "prefixes_vpnv4unicast") { echo(""); } -echo(generate_link("VPNv4", $link_array,array('view'=>'prefixes_vpnv4unicast'))); -if ($vars['view'] == "prefixes_vpnv4unicast") { echo(""); } +if ($vars['view'] == 'prefixes_ipv4unicast') { + echo ""; +} -echo(" | "); +echo generate_link('IPv4', $link_array, array('view' => 'prefixes_ipv4unicast')); +if ($vars['view'] == 'prefixes_ipv4unicast') { + echo ''; +} -if ($vars['view'] == "prefixes_ipv6unicast") { echo(""); } -echo(generate_link("IPv6", $link_array,array('view'=>'prefixes_ipv6unicast'))); -if ($vars['view'] == "prefixes_ipv6unicast") { echo(""); } +echo ' | '; -echo(" | Traffic: "); +if ($vars['view'] == 'prefixes_vpnv4unicast') { + echo ""; +} -if ($vars['view'] == "macaccounting_bits") { echo(""); } -echo(generate_link("Bits", $link_array,array('view'=>'macaccounting_bits'))); -if ($vars['view'] == "macaccounting_bits") { echo(""); } -echo(" | "); -if ($vars['view'] == "macaccounting_pkts") { echo(""); } -echo(generate_link("Packets", $link_array,array('view'=>'macaccounting_pkts'))); -if ($vars['view'] == "macaccounting_pkts") { echo(""); } +echo generate_link('VPNv4', $link_array, array('view' => 'prefixes_vpnv4unicast')); +if ($vars['view'] == 'prefixes_vpnv4unicast') { + echo ''; +} + +echo ' | '; + +if ($vars['view'] == 'prefixes_ipv6unicast') { + echo ""; +} + +echo generate_link('IPv6', $link_array, array('view' => 'prefixes_ipv6unicast')); +if ($vars['view'] == 'prefixes_ipv6unicast') { + echo ''; +} + +echo ' | Traffic: '; + +if ($vars['view'] == 'macaccounting_bits') { + echo ""; +} + +echo generate_link('Bits', $link_array, array('view' => 'macaccounting_bits')); +if ($vars['view'] == 'macaccounting_bits') { + echo ''; +} + +echo ' | '; +if ($vars['view'] == 'macaccounting_pkts') { + echo ""; +} + +echo generate_link('Packets', $link_array, array('view' => 'macaccounting_pkts')); +if ($vars['view'] == 'macaccounting_pkts') { + echo ''; +} print_optionbar_end(); -echo(''); -echo(''); +echo '
    Peer addressTypeRemote ASStateUptime
    '; +echo ''; -$i = "1"; +$i = '1'; -foreach (dbFetchRows("SELECT * FROM `bgpPeers` WHERE `device_id` = ? ORDER BY `bgpPEerRemoteAs`, `bgpPeerIdentifier`", array($device['device_id'])) as $peer) -{ - $has_macaccounting = dbFetchCell("SELECT COUNT(*) FROM `ipv4_mac` AS I, mac_accounting AS M WHERE I.ipv4_address = ? AND M.mac = I.mac_address", array($peer['bgpPeerIdentifier'])); - unset($bg_image); - if (!is_integer($i/2)) { $bg_colour = $list_colour_a; } else { $bg_colour = $list_colour_b; } - unset ($alert, $bg_image); - unset ($peerhost, $peername); +foreach (dbFetchRows('SELECT * FROM `bgpPeers` WHERE `device_id` = ? ORDER BY `bgpPEerRemoteAs`, `bgpPeerIdentifier`', array($device['device_id'])) as $peer) { + $has_macaccounting = dbFetchCell('SELECT COUNT(*) FROM `ipv4_mac` AS I, mac_accounting AS M WHERE I.ipv4_address = ? AND M.mac = I.mac_address', array($peer['bgpPeerIdentifier'])); + unset($bg_image); + if (!is_integer($i / 2)) { + $bg_colour = $list_colour_a; + } + else { + $bg_colour = $list_colour_b; + } - if (!is_integer($i/2)) { $bg_colour = $list_colour_b; } else { $bg_colour = $list_colour_a; } - if ($peer['bgpPeerState'] == "established") { $col = "green"; } else { $col = "red"; $peer['alert']=1; } - if ($peer['bgpPeerAdminStatus'] == "start" || $peer['bgpPeerAdminStatus'] == "running") { $admin_col = "green"; } else { $admin_col = "gray"; } - if ($peer['bgpPeerAdminStatus'] == "stop") { $peer['alert']=0; $peer['disabled']=1; } + unset($alert, $bg_image); + unset($peerhost, $peername); - if ($peer['bgpPeerRemoteAs'] == $device['bgpLocalAs']) { $peer_type = "iBGP"; } else { $peer_type = "eBGP"; } + if (!is_integer($i / 2)) { + $bg_colour = $list_colour_b; + } + else { + $bg_colour = $list_colour_a; + } - $query = "SELECT * FROM ipv4_addresses AS A, ports AS I, devices AS D WHERE "; - $query .= "(A.ipv4_address = ? AND I.port_id = A.port_id)"; - $query .= " AND D.device_id = I.device_id"; - $ipv4_host = dbFetchRow($query,array($peer['bgpPeerIdentifier'])); + if ($peer['bgpPeerState'] == 'established') { + $col = 'green'; + } + else { + $col = 'red'; + $peer['alert'] = 1; + } - $query = "SELECT * FROM ipv6_addresses AS A, ports AS I, devices AS D WHERE "; - $query .= "(A.ipv6_address = ? AND I.port_id = A.port_id)"; - $query .= " AND D.device_id = I.device_id"; - $ipv6_host = dbFetchRow($query,array($peer['bgpPeerIdentifier'])); + if ($peer['bgpPeerAdminStatus'] == 'start' || $peer['bgpPeerAdminStatus'] == 'running') { + $admin_col = 'green'; + } + else { + $admin_col = 'gray'; + } - if ($ipv4_host) - { - $peerhost = $ipv4_host; - } elseif ($ipv6_host) { - $peerhost = $ipv6_host; - } else { - unset($peerhost); - } + if ($peer['bgpPeerAdminStatus'] == 'stop') { + $peer['alert'] = 0; + $peer['disabled'] = 1; + } - if (is_array($peerhost)) - { - #$peername = generate_device_link($peerhost); - $peername = generate_device_link($peerhost) ." ". generate_port_link($peerhost); - $peer_url = "device/device=" . $peer['device_id'] . "/tab=routing/proto=bgp/view=updates/"; - } - else - { - #$peername = gethostbyaddr($peer['bgpPeerIdentifier']); // FFffuuu DNS // Cache this in discovery? -# if ($peername == $peer['bgpPeerIdentifier']) -# { -# unset($peername); -# } else { -# $peername = "".$peername.""; -# } - } + if ($peer['bgpPeerRemoteAs'] == $device['bgpLocalAs']) { + $peer_type = "iBGP"; + } + else { + $peer_type = "eBGP"; + } - unset($peer_af); - unset($sep); + $query = 'SELECT * FROM ipv4_addresses AS A, ports AS I, devices AS D WHERE '; + $query .= '(A.ipv4_address = ? AND I.port_id = A.port_id)'; + $query .= ' AND D.device_id = I.device_id'; + $ipv4_host = dbFetchRow($query, array($peer['bgpPeerIdentifier'])); - foreach (dbFetchRows("SELECT * FROM `bgpPeers_cbgp` WHERE `device_id` = ? AND bgpPeerIdentifier = ?", array($device['device_id'], $peer['bgpPeerIdentifier'])) as $afisafi) - { - $afi = $afisafi['afi']; - $safi = $afisafi['safi']; - $this_afisafi = $afi.$safi; - $peer['afi'] .= $sep . $afi .".".$safi; - $sep = "
    "; - $peer['afisafi'][$this_afisafi] = 1; // Build a list of valid AFI/SAFI for this peer - } + $query = 'SELECT * FROM ipv6_addresses AS A, ports AS I, devices AS D WHERE '; + $query .= '(A.ipv6_address = ? AND I.port_id = A.port_id)'; + $query .= ' AND D.device_id = I.device_id'; + $ipv6_host = dbFetchRow($query, array($peer['bgpPeerIdentifier'])); - unset($sep); + if ($ipv4_host) { + $peerhost = $ipv4_host; + } + else if ($ipv6_host) { + $peerhost = $ipv6_host; + } + else { + unset($peerhost); + } - if (filter_var($peer['bgpLocalAddr'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) !== FALSE) { - $peer['bgpPeerIdentifier'] = Net_IPv6::compress($peer['bgpPeerIdentifier']); - } + if (is_array($peerhost)) { + // $peername = generate_device_link($peerhost); + $peername = generate_device_link($peerhost).' '.generate_port_link($peerhost); + $peer_url = 'device/device='.$peer['device_id'].'/tab=routing/proto=bgp/view=updates/'; + } + else { + // FIXME + // $peername = gethostbyaddr($peer['bgpPeerIdentifier']); // FFffuuu DNS // Cache this in discovery? + // if ($peername == $peer['bgpPeerIdentifier']) + // { + // unset($peername); + // } else { + // $peername = "".$peername.""; + // } + } + + unset($peer_af); + unset($sep); + + foreach (dbFetchRows('SELECT * FROM `bgpPeers_cbgp` WHERE `device_id` = ? AND bgpPeerIdentifier = ?', array($device['device_id'], $peer['bgpPeerIdentifier'])) as $afisafi) { + $afi = $afisafi['afi']; + $safi = $afisafi['safi']; + $this_afisafi = $afi.$safi; + $peer['afi'] .= $sep.$afi.'.'.$safi; + $sep = '
    '; + $peer['afisafi'][$this_afisafi] = 1; + // Build a list of valid AFI/SAFI for this peer + } + + unset($sep); + + if (filter_var($peer['bgpLocalAddr'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) !== false) { + $peer['bgpPeerIdentifier'] = Net_IPv6::compress($peer['bgpPeerIdentifier']); + } - $graph_type = "bgp_updates"; - $peer_daily_url = "graph.php?id=" . $peer['bgpPeer_id'] . "&type=" . $graph_type . "&from=".$config['time']['day']."&to=".$config['time']['now']."&width=500&height=150"; - $peeraddresslink = "', LEFT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\">" . $peer['bgpPeerIdentifier'] . ""; + $graph_type = 'bgp_updates'; + $peer_daily_url = 'graph.php?id='.$peer['bgpPeer_id'].'&type='.$graph_type.'&from='.$config['time']['day'].'&to='.$config['time']['now'].'&width=500&height=150'; + $peeraddresslink = "', LEFT".$config['overlib_defaults'].');" onmouseout="return nd();">'.$peer['bgpPeerIdentifier'].''; - echo('
    - "); + echo ' + '; - echo(" - - - - - - - - "); + echo ' + + + + + + + + '; - unset($invalid); + unset($invalid); - switch ($vars['view']) - { + switch ($vars['view']) { case 'prefixes_ipv4unicast': case 'prefixes_ipv4multicast': case 'prefixes_ipv4vpn': case 'prefixes_ipv6unicast': case 'prefixes_ipv6multicast': - list(,$afisafi) = explode("_", $vars['view']); - if (isset($peer['afisafi'][$afisafi])) { $peer['graph'] = 1; } - // FIXME no break?? - case 'updates': - $graph_array['type'] = "bgp_" . $vars['view']; - $graph_array['id'] = $peer['bgpPeer_id']; - } + list(,$afisafi) = explode('_', $vars['view']); + if (isset($peer['afisafi'][$afisafi])) { + $peer['graph'] = 1; + } - switch ($vars['view']) - { + // FIXME no break?? + case 'updates': + $graph_array['type'] = 'bgp_'.$vars['view']; + $graph_array['id'] = $peer['bgpPeer_id']; + } + + switch ($vars['view']) { case 'macaccounting_bits': case 'macaccounting_pkts': - $acc = dbFetchRow("SELECT * FROM `ipv4_mac` AS I, `mac_accounting` AS M, `ports` AS P, `devices` AS D WHERE I.ipv4_address = ? AND M.mac = I.mac_address AND P.port_id = M.port_id AND D.device_id = P.device_id", array($peer['bgpPeerIdentifier'])); - $database = $config['rrd_dir'] . "/" . $device['hostname'] . "/cip-" . $acc['ifIndex'] . "-" . $acc['mac'] . ".rrd"; - if (is_array($acc) && is_file($database)) - { - $peer['graph'] = 1; - $graph_array['id'] = $acc['ma_id']; - $graph_array['type'] = $vars['view']; - } - } + $acc = dbFetchRow('SELECT * FROM `ipv4_mac` AS I, `mac_accounting` AS M, `ports` AS P, `devices` AS D WHERE I.ipv4_address = ? AND M.mac = I.mac_address AND P.port_id = M.port_id AND D.device_id = P.device_id', array($peer['bgpPeerIdentifier'])); + $database = $config['rrd_dir'].'/'.$device['hostname'].'/cip-'.$acc['ifIndex'].'-'.$acc['mac'].'.rrd'; + if (is_array($acc) && is_file($database)) { + $peer['graph'] = 1; + $graph_array['id'] = $acc['ma_id']; + $graph_array['type'] = $vars['view']; + } + } - if ($vars['view'] == 'updates') { $peer['graph'] = 1; } + if ($vars['view'] == 'updates') { + $peer['graph'] = 1; + } - if ($peer['graph']) - { - $graph_array['height'] = "100"; - $graph_array['width'] = "216"; - $graph_array['to'] = $config['time']['now']; - echo('"); - } + echo ''; + } - $i++; + $i++; - unset($valid_afi_safi); -} + unset($valid_afi_safi); +}//end foreach ?>
    Peer addressTypeRemote ASStateUptime
    ".$i."" . $peeraddresslink . "
    ".$peername."
    $peer_type" . (isset($peer['afi']) ? $peer['afi'] : '') . "AS" . $peer['bgpPeerRemoteAs'] . "
    " . $peer['astext'] . "
    " . $peer['bgpPeerAdminStatus'] . "
    " . $peer['bgpPeerState'] . "
    " .formatUptime($peer['bgpPeerFsmEstablishedTime']). "
    - Updates " . $peer['bgpPeerInUpdates'] . " - " . $peer['bgpPeerOutUpdates'] . "
    '.$i.''.$peeraddresslink.'
    '.$peername."
    $peer_type".(isset($peer['afi']) ? $peer['afi'] : '').'AS'.$peer['bgpPeerRemoteAs'].'
    '.$peer['astext']."
    ".$peer['bgpPeerAdminStatus']."
    ".$peer['bgpPeerState'].'
    '.formatUptime($peer['bgpPeerFsmEstablishedTime'])."
    + Updates ".$peer['bgpPeerInUpdates']." + ".$peer['bgpPeerOutUpdates'].'
    '); + if ($peer['graph']) { + $graph_array['height'] = '100'; + $graph_array['width'] = '216'; + $graph_array['to'] = $config['time']['now']; + echo '
    '; - include("includes/print-graphrow.inc.php"); + include 'includes/print-graphrow.inc.php'; - echo("
    diff --git a/html/pages/device/routing/ospf.inc.php b/html/pages/device/routing/ospf.inc.php index ed126a7fe3..7bf6798b7b 100644 --- a/html/pages/device/routing/ospf.inc.php +++ b/html/pages/device/routing/ospf.inc.php @@ -88,8 +88,7 @@ foreach (dbFetchRows('SELECT * FROM `ospf_instances` WHERE `device_id` = ?', arr // # Loop Ports $i_p = ($i_a + 1); $p_sql = "SELECT * FROM `ospf_ports` AS O, `ports` AS P WHERE O.`ospfIfAdminStat` = 'enabled' AND O.`device_id` = ? AND O.`ospfIfAreaId` = ? AND P.port_id = O.port_id"; - foreach (dbFetchRows($p_sql, array($device['device_id'], $area['ospfAreaId'])) as $ospfport) - { + foreach (dbFetchRows($p_sql, array($device['device_id'], $area['ospfAreaId'])) as $ospfport) { if (!is_integer($i_a / 2)) { if (!is_integer($i_p / 2)) { $port_bg = $list_colour_b_b; diff --git a/html/pages/device/showconfig.inc.php b/html/pages/device/showconfig.inc.php index aed9398dd2..9efc95d63a 100644 --- a/html/pages/device/showconfig.inc.php +++ b/html/pages/device/showconfig.inc.php @@ -1,134 +1,135 @@ = '7') { + if (!is_array($config['rancid_configs'])) { + $config['rancid_configs'] = array($config['rancid_configs']); + } -if ($_SESSION['userlevel'] >= "7") -{ + if (isset($config['rancid_configs'][0])) { + foreach ($config['rancid_configs'] as $configs) { + if ($configs[(strlen($configs) - 1)] != '/') { + $configs .= '/'; + } - if (!is_array($config['rancid_configs'])) { $config['rancid_configs'] = array($config['rancid_configs']); } + if (is_file($configs.$device['hostname'])) { + $file = $configs.$device['hostname']; + } + } - if (isset($config['rancid_configs'][0])) { + echo '
    '; - foreach ($config['rancid_configs'] as $configs) { - if ($configs[strlen($configs) - 1] != '/') { - $configs .= '/'; - } - if (is_file($configs . $device['hostname'])) { - $file = $configs . $device['hostname']; - } - } + print_optionbar_start('', ''); - echo('
    '); + echo "Config » "; - print_optionbar_start('', ''); + if (!$vars['rev']) { + echo ''; + echo generate_link('Latest', array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'showconfig')); + echo ''; + } + else { + echo generate_link('Latest', array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'showconfig')); + } - echo("Config » "); + if (function_exists('svn_log')) { + $sep = ' | '; + $svnlogs = svn_log($file, SVN_REVISION_HEAD, null, 8); + $revlist = array(); - if (!$vars['rev']) { - echo(''); - echo(generate_link('Latest', array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'showconfig'))); - echo(""); - } else { - echo(generate_link('Latest', array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'showconfig'))); - } + foreach ($svnlogs as $svnlog) { + echo $sep; + $revlist[] = $svnlog['rev']; - if (function_exists('svn_log')) { + if ($vars['rev'] == $svnlog['rev']) { + echo ''; + } - $sep = " | "; - $svnlogs = svn_log($file, SVN_REVISION_HEAD, NULL, 8); - $revlist = array(); + $linktext = 'r'.$svnlog['rev'].' '.date($config['dateformat']['byminute'], strtotime($svnlog['date'])).''; + echo generate_link($linktext, array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'showconfig', 'rev' => $svnlog['rev'])); - foreach ($svnlogs as $svnlog) { + if ($vars['rev'] == $svnlog['rev']) { + echo ''; + } - echo($sep); - $revlist[] = $svnlog["rev"]; + $sep = ' | '; + } + }//end if - if ($vars['rev'] == $svnlog["rev"]) { - echo(''); - } - $linktext = "r" . $svnlog["rev"] . " " . date($config['dateformat']['byminute'], strtotime($svnlog["date"])) . ""; - echo(generate_link($linktext, array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'showconfig', 'rev' => $svnlog["rev"]))); + print_optionbar_end(); - if ($vars['rev'] == $svnlog["rev"]) { - echo(""); - } + if (function_exists('svn_log') && in_array($vars['rev'], $revlist)) { + list($diff, $errors) = svn_diff($file, ($vars['rev'] - 1), $file, $vars['rev']); + if (!$diff) { + $text = 'No Difference'; + } + else { + $text = ''; + while (!feof($diff)) { + $text .= fread($diff, 8192); + } - $sep = " | "; - } - } + fclose($diff); + fclose($errors); + } + } + else { + $fh = fopen($file, 'r') or die("Can't open file"); + $text = fread($fh, filesize($file)); + fclose($fh); + } - print_optionbar_end(); + if ($config['rancid_ignorecomments']) { + $lines = explode("\n", $text); + for ($i = 0; $i < count($lines); $i++) { + if ($lines[$i][0] == '#') { + unset($lines[$i]); + } + } - if (function_exists('svn_log') && in_array($vars['rev'], $revlist)) { - list($diff, $errors) = svn_diff($file, $vars['rev'] - 1, $file, $vars['rev']); - if (!$diff) { - $text = "No Difference"; - } else { - $text = ""; - while (!feof($diff)) { - $text .= fread($diff, 8192); - } - fclose($diff); - fclose($errors); - } + $text = join("\n", $lines); + } + } + else if ($config['oxidized']['enabled'] === true && isset($config['oxidized']['url'])) { + $node_info = json_decode(file_get_contents($config['oxidized']['url'].'/node/show/'.$device['hostname'].'?format=json'), true); + $text = file_get_contents($config['oxidized']['url'].'/node/fetch/'.$device['hostname']); + if ($text == 'node not found') { + $text = file_get_contents($config['oxidized']['url'].'/node/fetch/'.$device['os'].'/'.$device['hostname']); + } - } else { - $fh = fopen($file, 'r') or die("Can't open file"); - $text = fread($fh, filesize($file)); - fclose($fh); - } - - if ($config['rancid_ignorecomments']) { - $lines = explode("\n", $text); - for ($i = 0; $i < count($lines); $i++) { - if ($lines[$i][0] == "#") { - unset($lines[$i]); - } - } - $text = join("\n", $lines); - } - } elseif ($config['oxidized']['enabled'] === TRUE && isset($config['oxidized']['url'])) { - $node_info = json_decode(file_get_contents($config['oxidized']['url']."/node/show/".$device['hostname']."?format=json"),TRUE); - $text = file_get_contents($config['oxidized']['url']."/node/fetch/".$device['hostname']); - if ($text == "node not found") { - $text = file_get_contents($config['oxidized']['url']."/node/fetch/".$device['os']."/".$device['hostname']); - } - - if (is_array($node_info)) { - echo('
    -
    + if (is_array($node_info)) { + echo '
    +
    -
    -
    Sync status: '.$node_info['last']['status'].'
    -
      -
    • Node: '. $node_info['name'].'
    • -
    • IP: '. $node_info['ip'].'
    • -
    • Model: '. $node_info['model'].'
    • -
    • Last Sync: '. $node_info['last']['end'].'
    • -
    -
    +
    +
    Sync status: '.$node_info['last']['status'].'
    +
      +
    • Node: '.$node_info['name'].'
    • +
    • IP: '.$node_info['ip'].'
    • +
    • Model: '.$node_info['model'].'
    • +
    • Last Sync: '.$node_info['last']['end'].'
    • +
    -
    '); - } else { - echo "
    "; - print_error("We couldn't retrieve the device information from Oxidized"); - $text = ''; - } +
    +
    '; + } + else { + echo '
    '; + print_error("We couldn't retrieve the device information from Oxidized"); + $text = ''; + } + }//end if - } + if (!empty($text)) { + $language = 'ios'; + $geshi = new GeSHi($text, $language); + $geshi->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS); + $geshi->set_overall_style('color: black;'); + // $geshi->set_line_style('color: #999999'); + echo $geshi->parse_code(); + } +}//end if - if (!empty($text)) { - $language = "ios"; - $geshi = new GeSHi($text, $language); - $geshi->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS); - $geshi->set_overall_style('color: black;'); - #$geshi->set_line_style('color: #999999'); - echo($geshi->parse_code()); - } -} - -$pagetitle[] = "Config"; - -?> +$pagetitle[] = 'Config'; diff --git a/html/pages/device/slas.inc.php b/html/pages/device/slas.inc.php index 3cc6cbf119..587c7d7438 100644 --- a/html/pages/device/slas.inc.php +++ b/html/pages/device/slas.inc.php @@ -12,7 +12,7 @@ foreach ($slas as $sla) { $sla_type = $sla['rtt_type']; if (!in_array($sla_type, $sla_types)) { - if (isset($config['sla_type_labels'][$sla_type])) { + if (isset($config['sla_type_labels'][$sla_type])) { $text = $config['sla_type_labels'][$sla_type]; } } diff --git a/html/pages/devices.inc.php b/html/pages/devices.inc.php index 67a8c39edd..0367b8a1c3 100644 --- a/html/pages/devices.inc.php +++ b/html/pages/devices.inc.php @@ -2,7 +2,9 @@ // Set Defaults here -if(!isset($vars['format'])) { $vars['format'] = "list_detail"; } +if(!isset($vars['format'])) { + $vars['format'] = "list_detail"; +} $pagetitle[] = "Devices"; @@ -10,23 +12,19 @@ print_optionbar_start(); echo('Lists » '); -$menu_options = array('basic' => 'Basic', - 'detail' => 'Detail'); +$menu_options = array('basic' => 'Basic', 'detail' => 'Detail'); $sep = ""; -foreach ($menu_options as $option => $text) -{ - echo($sep); - if ($vars['format'] == "list_".$option) - { - echo(""); - } - echo('' . $text . ''); - if ($vars['format'] == "list_".$option) - { - echo(""); - } - $sep = " | "; +foreach ($menu_options as $option => $text) { + echo($sep); + if ($vars['format'] == "list_".$option) { + echo(""); + } + echo('' . $text . ''); + if ($vars['format'] == "list_".$option) { + echo(""); + } + $sep = " | "; } ?> @@ -38,29 +36,26 @@ foreach ($menu_options as $option => $text) 'Bits', - 'processor' => 'CPU', - 'ucd_load' => 'Load', - 'mempool' => 'Memory', - 'uptime' => 'Uptime', - 'storage' => 'Storage', - 'diskio' => 'Disk I/O', - 'poller_perf' => 'Poller', - 'ping_perf' => 'Ping' - ); + 'processor' => 'CPU', + 'ucd_load' => 'Load', + 'mempool' => 'Memory', + 'uptime' => 'Uptime', + 'storage' => 'Storage', + 'diskio' => 'Disk I/O', + 'poller_perf' => 'Poller', + 'ping_perf' => 'Ping' +); $sep = ""; -foreach ($menu_options as $option => $text) -{ - echo($sep); - if ($vars['format'] == 'graph_'.$option) - { - echo(""); - } - echo('' . $text . ''); - if ($vars['format'] == 'graph_'.$option) - { - echo(""); - } - $sep = " | "; +foreach ($menu_options as $option => $text) { + echo($sep); + if ($vars['format'] == 'graph_'.$option) { + echo(""); + } + echo('' . $text . ''); + if ($vars['format'] == 'graph_'.$option) { + echo(""); + } + $sep = " | "; } ?> @@ -69,21 +64,21 @@ foreach ($menu_options as $option => $text) '')).'">Restore Search'); - } else { +} +else { echo('Remove Search'); - } +} - echo(" | "); +echo(" | "); - if (isset($vars['bare']) && $vars['bare'] == "yes") - { +if (isset($vars['bare']) && $vars['bare'] == "yes") { echo('Restore Header'); - } else { +} +else { echo('Remove Header'); - } +} print_optionbar_end(); ?> @@ -94,76 +89,110 @@ print_optionbar_end(); list($format, $subformat) = explode("_", $vars['format'], 2); -if($format == "graph") -{ -$sql_param = array(); +if($format == "graph") { + $sql_param = array(); -if(isset($vars['state'])) -{ - if($vars['state'] == 'up') - { - $state = '1'; - } - elseif($vars['state'] == 'down') - { - $state = '0'; - } -} + if(isset($vars['state'])) { + if($vars['state'] == 'up') { + $state = '1'; + } + elseif($vars['state'] == 'down') { + $state = '0'; + } + } -if (!empty($vars['hostname'])) { $where .= " AND hostname LIKE ?"; $sql_param[] = "%".$vars['hostname']."%"; } -if (!empty($vars['os'])) { $where .= " AND os = ?"; $sql_param[] = $vars['os']; } -if (!empty($vars['version'])) { $where .= " AND version = ?"; $sql_param[] = $vars['version']; } -if (!empty($vars['hardware'])) { $where .= " AND hardware = ?"; $sql_param[] = $vars['hardware']; } -if (!empty($vars['features'])) { $where .= " AND features = ?"; $sql_param[] = $vars['features']; } -if (!empty($vars['type'])) { - if ($vars['type'] == 'generic') { - $where .= " AND ( type = ? OR type = '')"; $sql_param[] = $vars['type']; - } else { - $where .= " AND type = ?"; $sql_param[] = $vars['type']; - } -} -if (!empty($vars['state'])) { - $where .= " AND status= ?"; $sql_param[] = $state; - $where .= " AND disabled='0' AND `ignore`='0'"; $sql_param[] = ''; -} -if (!empty($vars['disabled'])) { $where .= " AND disabled= ?"; $sql_param[] = $vars['disabled']; } -if (!empty($vars['ignore'])) { $where .= " AND `ignore`= ?"; $sql_param[] = $vars['ignore']; } -if (!empty($vars['location']) && $vars['location'] == "Unset") { $location_filter = ''; } -if (!empty($vars['location'])) { $location_filter = $vars['location']; } -if( !empty($vars['group']) ) { - require_once('../includes/device-groups.inc.php'); - $where .= " AND ( "; - foreach( GetDevicesFromGroup($vars['group']) as $dev ) { - $where .= "device_id = ? OR "; - $sql_param[] = $dev['device_id']; - } - $where = substr($where, 0, strlen($where)-3); - $where .= " )"; -} + if (!empty($vars['hostname'])) { + $where .= " AND hostname LIKE ?"; + $sql_param[] = "%".$vars['hostname']."%"; + } + if (!empty($vars['os'])) { + $where .= " AND os = ?"; + $sql_param[] = $vars['os']; + } + if (!empty($vars['version'])) { + $where .= " AND version = ?"; + $sql_param[] = $vars['version']; + } + if (!empty($vars['hardware'])) { + $where .= " AND hardware = ?"; + $sql_param[] = $vars['hardware']; + } + if (!empty($vars['features'])) { + $where .= " AND features = ?"; + $sql_param[] = $vars['features']; + } -$query = "SELECT * FROM `devices` WHERE 1 "; + if (!empty($vars['type'])) { + if ($vars['type'] == 'generic') { + $where .= " AND ( type = ? OR type = '')"; + $sql_param[] = $vars['type']; + } + else { + $where .= " AND type = ?"; + $sql_param[] = $vars['type']; + } + } + if (!empty($vars['state'])) { + $where .= " AND status= ?"; + $sql_param[] = $state; + $where .= " AND disabled='0' AND `ignore`='0'"; + $sql_param[] = ''; + } + if (!empty($vars['disabled'])) { + $where .= " AND disabled= ?"; + $sql_param[] = $vars['disabled']; + } + if (!empty($vars['ignore'])) { + $where .= " AND `ignore`= ?"; + $sql_param[] = $vars['ignore']; + } + if (!empty($vars['location']) && $vars['location'] == "Unset") { + $location_filter = ''; + } + if (!empty($vars['location'])) { + $location_filter = $vars['location']; + } + if( !empty($vars['group']) ) { + require_once('../includes/device-groups.inc.php'); + $where .= " AND ( "; + foreach( GetDevicesFromGroup($vars['group']) as $dev ) { + $where .= "device_id = ? OR "; + $sql_param[] = $dev['device_id']; + } + $where = substr($where, 0, strlen($where)-3); + $where .= " )"; + } -if (isset($where)) { - $query .= $where; -} + $query = "SELECT * FROM `devices` WHERE 1 "; -$query .= " ORDER BY hostname"; + if (isset($where)) { + $query .= $where; + } - $row = 1; - foreach (dbFetchRows($query, $sql_param) as $device) - { - if (is_integer($row/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; } + $query .= " ORDER BY hostname"; - if (device_permitted($device['device_id'])) - { - if (!$location_filter || ((get_dev_attrib($device,'override_sysLocation_bool') && get_dev_attrib($device,'override_sysLocation_string') == $location_filter) - || $device['location'] == $location_filter)) - { - $graph_type = "device_".$subformat; + $row = 1; + foreach (dbFetchRows($query, $sql_param) as $device) { + if (is_integer($row/2)) { + $row_colour = $list_colour_a; + } + else { + $row_colour = $list_colour_b; + } - if ($_SESSION['widescreen']) { $width=270; } else { $width=315; } + if (device_permitted($device['device_id'])) { + if (!$location_filter || ((get_dev_attrib($device,'override_sysLocation_bool') && get_dev_attrib($device,'override_sysLocation_string') == $location_filter) + || $device['location'] == $location_filter)) { + $graph_type = "device_".$subformat; - echo("
    + if ($_SESSION['widescreen']) { + $width=270; + } + else { + $width=315; + } + + echo("\ \ @@ -171,11 +200,11 @@ $query .= " ORDER BY hostname"; "
    "); - } + } + } } - } - -} else { +} +else { ?> @@ -209,22 +238,23 @@ $query .= " ORDER BY hostname"; ""+ '.$config['os'][$tmp_os]['text'].'"+'); + if (is_admin() === TRUE || is_read() === TRUE) { + $sql = "SELECT `os` FROM `devices` AS D WHERE 1 GROUP BY `os` ORDER BY `os`"; + } + else { + $sql = "SELECT `os` FROM `devices` AS `D`, `devices_perms` AS `P` WHERE `P`.`user_id` = ? AND `P`.`device_id` = `D`.`device_id` GROUP BY `os` ORDER BY `os`"; + $param[] = $_SESSION['user_id']; + } + foreach (dbFetch($sql,$param) as $data) { + if ($data['os']) { + $tmp_os = clean_bootgrid($data['os']); + echo('""+'); + } } -} ?> ""+ "
    "+ @@ -233,22 +263,23 @@ foreach (dbFetch($sql,$param) as $data) { ""+ '.$tmp_version.'"+'); } - echo('">'.$tmp_version.'"+'); - } -} + } ?> ""+ "
    "+ @@ -257,22 +288,23 @@ foreach (dbFetch($sql,$param) as $data) { ""+ '.$tmp_hardware.'"+'); + if (is_admin() === TRUE || is_read() === TRUE) { + $sql = "SELECT `hardware` FROM `devices` AS D WHERE 1 GROUP BY `hardware` ORDER BY `hardware`"; + } + else { + $sql = "SELECT `hardware` FROM `devices` AS `D`, `devices_perms` AS `P` WHERE `P`.`user_id` = ? AND `P`.`device_id` = `D`.`device_id` GROUP BY `hardware` ORDER BY `hardware`"; + $param[] = $_SESSION['user_id']; + } + foreach (dbFetch($sql,$param) as $data) { + if ($data['hardware']) { + $tmp_hardware = clean_bootgrid($data['hardware']); + echo('""+'); + } } -} ?> ""+ @@ -282,24 +314,24 @@ foreach (dbFetch($sql,$param) as $data) { ""+ '.$tmp_features.'"+'); + else { + $sql = "SELECT `features` FROM `devices` AS `D`, `devices_perms` AS `P` WHERE `P`.`user_id` = ? AND `P`.`device_id` = `D`.`device_id` GROUP BY `features` ORDER BY `features`"; + $param[] = $_SESSION['user_id']; + } + + foreach (dbFetch($sql,$param) as $data) { + if ($data['features']) { + $tmp_features = clean_bootgrid($data['features']); + echo('""+'); + } } -} ?> ""+ @@ -311,16 +343,16 @@ foreach (dbFetch($sql,$param) as $data) '.$location.'"+'); } - echo('">'.$location.'"+'); } -} ?> ""+ ""+ @@ -329,21 +361,22 @@ foreach (getlocations() as $location) { ""+ '.ucfirst($data['type']).'"+'); + if (is_admin() === TRUE || is_read() === TRUE) { + $sql = "SELECT `type` FROM `devices` AS D WHERE 1 GROUP BY `type` ORDER BY `type`"; + } + else { + $sql = "SELECT `type` FROM `devices` AS `D`, `devices_perms` AS `P` WHERE `P`.`user_id` = ? AND `P`.`device_id` = `D`.`device_id` GROUP BY `type` ORDER BY `type`"; + $param[] = $_SESSION['user_id']; + } + foreach (dbFetch($sql,$param) as $data) { + if ($data['type']) { + echo('""+'); + } } -} ?> ""+ @@ -357,9 +390,9 @@ foreach (dbFetch($sql,$param) as $data) { "

    " var grid = $("#devices").bootgrid({ @@ -400,5 +433,3 @@ var grid = $("#devices").bootgrid({ diff --git a/html/pages/editsrv.inc.php b/html/pages/editsrv.inc.php index 9c56b96d1e..1c04e4510f 100644 --- a/html/pages/editsrv.inc.php +++ b/html/pages/editsrv.inc.php @@ -1,35 +1,30 @@ "5") - { - include("includes/service-edit.inc.php"); + if ($_POST['confirm-editsrv']) { + if ($_SESSION['userlevel'] > '5') { + include 'includes/service-edit.inc.php'; } } - foreach (dbFetchRows("SELECT * FROM `services` AS S, `devices` AS D WHERE S.device_id = D.device_id ORDER BY hostname") as $device) - { - $servicesform .= ""; + foreach (dbFetchRows('SELECT * FROM `services` AS S, `devices` AS D WHERE S.device_id = D.device_id ORDER BY hostname') as $device) { + $servicesform .= "'; } - if ($updated) { print_message("Service updated!"); } + if ($updated) { + print_message('Service updated!'); + } if ($_POST['editsrv'] == 'yes') { - - require_once "includes/print-service-edit.inc.php"; - - } else { - - echo(" + include_once 'includes/print-service-edit.inc.php'; + } + else { + echo "

    Delete Service

    @@ -46,7 +41,6 @@ if (is_admin() === FALSE && is_read() === FALSE) { -
    "); - } - -} + "; + }//end if +}//end if diff --git a/html/pages/edituser.inc.php b/html/pages/edituser.inc.php index 6a9a7d2830..ec2a3f1c9e 100644 --- a/html/pages/edituser.inc.php +++ b/html/pages/edituser.inc.php @@ -1,167 +1,170 @@ "); +echo "
    "; -$pagetitle[] = "Edit user"; +$pagetitle[] = 'Edit user'; -if ($_SESSION['userlevel'] != '10') { include("includes/error-no-perm.inc.php"); } else -{ - if ($vars['user_id'] && !$vars['edit']) - { - $user_data = dbFetchRow("SELECT * FROM users WHERE user_id = ?", array($vars['user_id'])); - echo("

    " . $user_data['realname'] . "

    Change...

    "); - // Perform actions if requested +if ($_SESSION['userlevel'] != '10') { + include 'includes/error-no-perm.inc.php'; +} +else { + if ($vars['user_id'] && !$vars['edit']) { + $user_data = dbFetchRow('SELECT * FROM users WHERE user_id = ?', array($vars['user_id'])); + echo '

    '.$user_data['realname']."

    Change...

    "; + // Perform actions if requested + if ($vars['action'] == 'deldevperm') { + if (dbFetchCell('SELECT COUNT(*) FROM devices_perms WHERE `device_id` = ? AND `user_id` = ?', array($vars['device_id'], $vars['user_id']))) { + dbDelete('devices_perms', '`device_id` = ? AND `user_id` = ?', array($vars['device_id'], $vars['user_id'])); + } + } - if ($vars['action'] == "deldevperm") - { - if (dbFetchCell("SELECT COUNT(*) FROM devices_perms WHERE `device_id` = ? AND `user_id` = ?", array($vars['device_id'] ,$vars['user_id']))) - { - dbDelete('devices_perms', "`device_id` = ? AND `user_id` = ?", array($vars['device_id'], $vars['user_id'])); - } - } - if ($vars['action'] == "adddevperm") - { - if (!dbFetchCell("SELECT COUNT(*) FROM devices_perms WHERE `device_id` = ? AND `user_id` = ?", array($vars['device_id'] ,$vars['user_id']))) - { - dbInsert(array('device_id' => $vars['device_id'], 'user_id' => $vars['user_id']), 'devices_perms'); - } - } - if ($vars['action'] == "delifperm") - { - if (dbFetchCell("SELECT COUNT(*) FROM ports_perms WHERE `port_id` = ? AND `user_id` = ?", array($vars['port_id'], $vars['user_id']))) - { - dbDelete('ports_perms', "`port_id` = ? AND `user_id` = ?", array($vars['port_id'], $vars['user_id'])); - } - } - if ($vars['action'] == "addifperm") - { - if (!dbFetchCell("SELECT COUNT(*) FROM ports_perms WHERE `port_id` = ? AND `user_id` = ?", array($vars['port_id'], $vars['user_id']))) - { - dbInsert(array('port_id' => $vars['port_id'], 'user_id' => $vars['user_id']), 'ports_perms'); - } - } - if ($vars['action'] == "delbillperm") - { - if (dbFetchCell("SELECT COUNT(*) FROM bill_perms WHERE `bill_id` = ? AND `user_id` = ?", array($vars['bill_id'], $vars['user_id']))) - { - dbDelete('bill_perms', "`bill_id` = ? AND `user_id` = ?", array($vars['bill_id'], $vars['user_id'])); - } - } - if ($vars['action'] == "addbillperm") - { - if (!dbFetchCell("SELECT COUNT(*) FROM bill_perms WHERE `bill_id` = ? AND `user_id` = ?", array($vars['bill_id'], $vars['user_id']))) - { - dbInsert(array('bill_id' => $vars['bill_id'], 'user_id' => $vars['user_id']), 'bill_perms'); - } - } + if ($vars['action'] == 'adddevperm') { + if (!dbFetchCell('SELECT COUNT(*) FROM devices_perms WHERE `device_id` = ? AND `user_id` = ?', array($vars['device_id'], $vars['user_id']))) { + dbInsert(array('device_id' => $vars['device_id'], 'user_id' => $vars['user_id']), 'devices_perms'); + } + } - echo('
    -
    '); + if ($vars['action'] == 'delifperm') { + if (dbFetchCell('SELECT COUNT(*) FROM ports_perms WHERE `port_id` = ? AND `user_id` = ?', array($vars['port_id'], $vars['user_id']))) { + dbDelete('ports_perms', '`port_id` = ? AND `user_id` = ?', array($vars['port_id'], $vars['user_id'])); + } + } - // Display devices this users has access to - echo("

    Device Access

    "); + if ($vars['action'] == 'addifperm') { + if (!dbFetchCell('SELECT COUNT(*) FROM ports_perms WHERE `port_id` = ? AND `user_id` = ?', array($vars['port_id'], $vars['user_id']))) { + dbInsert(array('port_id' => $vars['port_id'], 'user_id' => $vars['user_id']), 'ports_perms'); + } + } - echo("
    + if ($vars['action'] == 'delbillperm') { + if (dbFetchCell('SELECT COUNT(*) FROM bill_perms WHERE `bill_id` = ? AND `user_id` = ?', array($vars['bill_id'], $vars['user_id']))) { + dbDelete('bill_perms', '`bill_id` = ? AND `user_id` = ?', array($vars['bill_id'], $vars['user_id'])); + } + } + + if ($vars['action'] == 'addbillperm') { + if (!dbFetchCell('SELECT COUNT(*) FROM bill_perms WHERE `bill_id` = ? AND `user_id` = ?', array($vars['bill_id'], $vars['user_id']))) { + dbInsert(array('bill_id' => $vars['bill_id'], 'user_id' => $vars['user_id']), 'bill_perms'); + } + } + + echo '
    +
    '; + + // Display devices this users has access to + echo '

    Device Access

    '; + + echo "
    - "); + "; - $device_perms = dbFetchRows("SELECT * from devices_perms as P, devices as D WHERE `user_id` = ? AND D.device_id = P.device_id", array($vars['user_id'])); - foreach ($device_perms as $device_perm) - { - echo(""); - $access_list[] = $device_perm['device_id']; - $permdone = "yes"; - } + $device_perms = dbFetchRows('SELECT * from devices_perms as P, devices as D WHERE `user_id` = ? AND D.device_id = P.device_id', array($vars['user_id'])); + foreach ($device_perms as $device_perm) { + echo '"; + $access_list[] = $device_perm['device_id']; + $permdone = 'yes'; + } - echo("
    Device Action
    " . $device_perm['hostname'] . "
    '.$device_perm['hostname']."
    -
    "); + echo ' +
    '; - if (!$permdone) { echo("None Configured"); } + if (!$permdone) { + echo 'None Configured'; + } - // Display devices this user doesn't have access to - echo("

    Grant access to new device

    "); - echo("
    - + // Display devices this user doesn't have access to + echo '

    Grant access to new device

    '; + echo " +
    - "; - $devices = dbFetchRows("SELECT * FROM `devices` ORDER BY hostname"); - foreach ($devices as $device) - { - unset($done); - foreach ($access_list as $ac) { if ($ac == $device['device_id']) { $done = 1; } } - if (!$done) - { - echo(""); - } - } + $devices = dbFetchRows('SELECT * FROM `devices` ORDER BY hostname'); + foreach ($devices as $device) { + unset($done); + foreach ($access_list as $ac) { + if ($ac == $device['device_id']) { + $done = 1; + } + } - echo(" + if (!$done) { + echo "'; + } + } + + echo "
    -
    "); + "; - echo("
    -
    "); - echo("

    Interface Access

    "); + echo "
    +
    "; + echo '

    Interface Access

    '; - $interface_perms = dbFetchRows("SELECT * from ports_perms as P, ports as I, devices as D WHERE `user_id` = ? AND I.port_id = P.port_id AND D.device_id = I.device_id", array($vars['user_id'])); + $interface_perms = dbFetchRows('SELECT * from ports_perms as P, ports as I, devices as D WHERE `user_id` = ? AND I.port_id = P.port_id AND D.device_id = I.device_id', array($vars['user_id'])); - echo("
    + echo "
    - "); - foreach ($interface_perms as $interface_perm) - { - echo(" + "; + foreach ($interface_perms as $interface_perm) { + echo ' - "); - $ipermdone = "yes"; - } - echo("
    Interface name Action
    - ".$interface_perm['hostname']." - ".$interface_perm['ifDescr']."". - "" . $interface_perm['ifAlias'] . " + '.$interface_perm['hostname'].' - '.$interface_perm['ifDescr'].''.''.$interface_perm['ifAlias']." -    +   
    -
    "); + "; + $ipermdone = 'yes'; + } - if (!$ipermdone) { echo("None Configured"); } + echo ' +
    '; - // Display devices this user doesn't have access to - echo("

    Grant access to new interface

    "); + if (!$ipermdone) { + echo 'None Configured'; + } - echo("
    - + // Display devices this user doesn't have access to + echo '

    Grant access to new interface

    '; + + echo " +
    + if (!$done) { + echo "'; + } + } + + echo "
    @@ -176,133 +179,135 @@ if ($_SESSION['userlevel'] != '10') { include("includes/error-no-perm.inc.php");
    - "); + "; - echo("
    -
    "); - echo("

    Bill Access

    "); + echo "
    +
    "; + echo '

    Bill Access

    '; - $bill_perms = dbFetchRows("SELECT * from bills AS B, bill_perms AS P WHERE P.user_id = ? AND P.bill_id = B.bill_id", array($vars['user_id'])); + $bill_perms = dbFetchRows('SELECT * from bills AS B, bill_perms AS P WHERE P.user_id = ? AND P.bill_id = B.bill_id', array($vars['user_id'])); - echo("
    + echo "
    - "); + "; - foreach ($bill_perms as $bill_perm) - { - echo(" + foreach ($bill_perms as $bill_perm) { + echo ' - "); - $bill_access_list[] = $bill_perm['bill_id']; + "; + $bill_access_list[] = $bill_perm['bill_id']; - $bpermdone = "yes"; - } + $bpermdone = 'yes'; + } - echo("
    Bill name Action
    - ".$bill_perm['bill_name']."   + '.$bill_perm['bill_name']."  
    -
    "); + echo ' +
    '; - if (!$bpermdone) { echo("None Configured"); } + if (!$bpermdone) { + echo 'None Configured'; + } - // Display devices this user doesn't have access to - echo("

    Grant access to new bill

    "); - echo("
    - + // Display devices this user doesn't have access to + echo '

    Grant access to new bill

    '; + echo " +
    - "; - $bills = dbFetchRows("SELECT * FROM `bills` ORDER BY `bill_name`"); - foreach ($bills as $bill) - { - unset($done); - foreach ($bill_access_list as $ac) { if ($ac == $bill['bill_id']) { $done = 1; } } - if (!$done) - { - echo(""); - } - } + $bills = dbFetchRows('SELECT * FROM `bills` ORDER BY `bill_name`'); + foreach ($bills as $bill) { + unset($done); + foreach ($bill_access_list as $ac) { + if ($ac == $bill['bill_id']) { + $done = 1; + } + } - echo(" + if (!$done) { + echo "'; + } + } + + echo "
    -
    "); - - } elseif ($vars['user_id'] && $vars['edit']) { - - if($_SESSION['userlevel'] == 11) { - demo_account(); - } else { - - if(!empty($vars['new_level'])) - { - if($vars['can_modify_passwd'] == 'on') { - $vars['can_modify_passwd'] = '1'; - } - update_user($vars['user_id'],$vars['new_realname'],$vars['new_level'],$vars['can_modify_passwd'],$vars['new_email']); - print_message("User has been updated"); +
    "; } - - if(can_update_users() == '1') { - - $users_details = get_user($vars['user_id']); - if(!empty($users_details)) - { - - if(empty($vars['new_realname'])) - { - $vars['new_realname'] = $users_details['realname']; - } - if(empty($vars['new_level'])) - { - $vars['new_level'] = $users_details['level']; - } - if(empty($vars['can_modify_passwd'])) - { - $vars['can_modify_passwd'] = $users_details['can_modify_passwd']; - } elseif($vars['can_modify_passwd'] == 'on') { - $vars['can_modify_passwd'] = '1'; - } - if(empty($vars['new_email'])) - { - $vars['new_email'] = $users_details['email']; + else if ($vars['user_id'] && $vars['edit']) { + if ($_SESSION['userlevel'] == 11) { + demo_account(); } + else { + if (!empty($vars['new_level'])) { + if ($vars['can_modify_passwd'] == 'on') { + $vars['can_modify_passwd'] = '1'; + } - if( $config['twofactor'] ) { - if( $vars['twofactorremove'] ) { - if( dbUpdate(array('twofactor'=>''),users,'user_id = ?',array($vars['user_id'])) ) { - echo "
    TwoFactor credentials removed.
    "; - } else { - echo "
    Couldnt remove user's TwoFactor credentials.
    "; + update_user($vars['user_id'], $vars['new_realname'], $vars['new_level'], $vars['can_modify_passwd'], $vars['new_email']); + print_message('User has been updated'); } - } - if( $vars['twofactorunlock'] ) { - $twofactor = dbFetchRow("SELECT twofactor FROM users WHERE user_id = ?",array($vars['user_id'])); - $twofactor = json_decode($twofactor['twofactor'],true); - $twofactor['fails'] = 0; - if( dbUpdate(array('twofactor'=>json_encode($twofactor)),users,'user_id = ?',array($vars['user_id'])) ) { - echo "
    User unlocked.
    "; - } else { - echo "
    Couldnt reset user's TwoFactor failures.
    "; - } - } - } - echo("
    - + if (can_update_users() == '1') { + $users_details = get_user($vars['user_id']); + if (!empty($users_details)) { + if (empty($vars['new_realname'])) { + $vars['new_realname'] = $users_details['realname']; + } + + if (empty($vars['new_level'])) { + $vars['new_level'] = $users_details['level']; + } + + if (empty($vars['can_modify_passwd'])) { + $vars['can_modify_passwd'] = $users_details['can_modify_passwd']; + } + else if ($vars['can_modify_passwd'] == 'on') { + $vars['can_modify_passwd'] = '1'; + } + + if (empty($vars['new_email'])) { + $vars['new_email'] = $users_details['email']; + } + + if ($config['twofactor']) { + if ($vars['twofactorremove']) { + if (dbUpdate(array('twofactor' => ''), users, 'user_id = ?', array($vars['user_id']))) { + echo "
    TwoFactor credentials removed.
    "; + } + else { + echo "
    Couldnt remove user's TwoFactor credentials.
    "; + } + } + + if ($vars['twofactorunlock']) { + $twofactor = dbFetchRow('SELECT twofactor FROM users WHERE user_id = ?', array($vars['user_id'])); + $twofactor = json_decode($twofactor['twofactor'], true); + $twofactor['fails'] = 0; + if (dbUpdate(array('twofactor' => json_encode($twofactor)), users, 'user_id = ?', array($vars['user_id']))) { + echo "
    User unlocked.
    "; + } + else { + echo "
    Couldnt reset user's TwoFactor failures.
    "; + } + } + } + + echo " +
    - +
    @@ -310,7 +315,7 @@ if ($_SESSION['userlevel'] != '10') { include("includes/error-no-perm.inc.php");
    - +
    @@ -319,10 +324,22 @@ if ($_SESSION['userlevel'] != '10') { include("includes/error-no-perm.inc.php");
    @@ -332,7 +349,10 @@ if ($_SESSION['userlevel'] != '10') { include("includes/error-no-perm.inc.php");
    @@ -340,14 +360,14 @@ if ($_SESSION['userlevel'] != '10') { include("includes/error-no-perm.inc.php");
    - "); - if( $config['twofactor'] ) { - echo "

    Two-Factor Authentication

    "; - $twofactor = dbFetchRow("SELECT twofactor FROM users WHERE user_id = ?",array($vars['user_id'])); - $twofactor = json_decode($twofactor['twofactor'],true); - if( $twofactor['fails'] >= 3 && (!$config['twofactor_lock'] || (time()-$twofactor['last']) < $config['twofactor_lock']) ) { - echo "
    - +
    "; + if ($config['twofactor']) { + echo "

    Two-Factor Authentication

    "; + $twofactor = dbFetchRow('SELECT twofactor FROM users WHERE user_id = ?', array($vars['user_id'])); + $twofactor = json_decode($twofactor['twofactor'], true); + if ($twofactor['fails'] >= 3 && (!$config['twofactor_lock'] || (time() - $twofactor['last']) < $config['twofactor_lock'])) { + echo "
    +
    @@ -355,43 +375,47 @@ if ($_SESSION['userlevel'] != '10') { include("includes/error-no-perm.inc.php");
    "; - } - if( $twofactor['key'] ) { - echo "
    - + } + + if ($twofactor['key']) { + echo " +
    "; - } else { - echo "

    No TwoFactor key generated for this user, Nothing to do.

    "; - } - } - } else { - echo print_error("Error getting user details"); - } - } else { - echo print_error("Authentication method doesn't support updating users"); + } + else { + echo '

    No TwoFactor key generated for this user, Nothing to do.

    '; + } + }//end if + } + else { + echo print_error('Error getting user details'); + }//end if + } + else { + echo print_error("Authentication method doesn't support updating users"); + }//end if + }//end if } - } - } else { + else { + $user_list = get_userlist(); - $user_list = get_userlist(); + echo '

    Select a user to edit

    '; - echo("

    Select a user to edit

    "); - - echo("
    + echo "
    - +
    @@ -399,11 +423,8 @@ if ($_SESSION['userlevel'] != '10') { include("includes/error-no-perm.inc.php"); /
    - "); - } + "; + }//end if +}//end if -} - -echo("
    "); - -?> +echo '
    '; diff --git a/html/pages/eventlog.inc.php b/html/pages/eventlog.inc.php index 4e1cad13d2..2ac41ec91b 100644 --- a/html/pages/eventlog.inc.php +++ b/html/pages/eventlog.inc.php @@ -1,16 +1,15 @@ = '10') -{ - dbQuery("TRUNCATE TABLE `eventlog`"); - print_message("Event log truncated"); +if ($vars['action'] == 'expunge' && $_SESSION['userlevel'] >= '10') { + dbQuery('TRUNCATE TABLE `eventlog`'); + print_message('Event log truncated'); } -$pagetitle[] = "Eventlog"; +$pagetitle[] = 'Eventlog'; print_optionbar_start(); @@ -24,15 +23,17 @@ print_optionbar_start();
    @@ -40,9 +41,7 @@ print_optionbar_start(); diff --git a/html/pages/front/default.php b/html/pages/front/default.php index 7b17f08a45..b69f7f97b1 100644 --- a/html/pages/front/default.php +++ b/html/pages/front/default.php @@ -1,174 +1,180 @@ + +function generate_front_box($frontbox_class, $content) { + echo "
    $content -
    "); + "; + +}//end generate_front_box() + + +echo ' +
    +'; +if ($config['vertical_summary']) { + echo '
    '; +} +else { + echo '
    '; } -echo(' -
    -'); -if ($config['vertical_summary']) { - echo('
    '); -} -else -{ - echo('
    '); -} -echo(' +echo '
    -'); +'; -echo('
    '); +echo '
    '; -echo('
    '); +echo '
    '; $count_boxes = 0; // Device down boxes -if ($_SESSION['userlevel'] >= '10') -{ - $sql = "SELECT * FROM `devices` WHERE `status` = '0' AND `ignore` = '0' LIMIT ".$config['front_page_down_box_limit']; -} else { - $sql = "SELECT * FROM `devices` AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' AND D.status = '0' AND D.ignore = '0' LIMIT".$config['front_page_down_box_limit']; +if ($_SESSION['userlevel'] >= '10') { + $sql = "SELECT * FROM `devices` WHERE `status` = '0' AND `ignore` = '0' LIMIT ".$config['front_page_down_box_limit']; } -foreach (dbFetchRows($sql) as $device) -{ - generate_front_box("device-down", generate_device_link($device, shorthost($device['hostname']))."
    - Device Down
    - ".truncate($device['location'], 20).""); - ++$count_boxes; +else { + $sql = "SELECT * FROM `devices` AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '".$_SESSION['user_id']."' AND D.status = '0' AND D.ignore = '0' LIMIT".$config['front_page_down_box_limit']; } -if ($_SESSION['userlevel'] >= '10') -{ - $sql = "SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0' AND `D`.`status` = '1' LIMIT ".$config['front_page_down_box_limit']; -} else { - $sql = "SELECT * FROM `ports` AS I, `devices` AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' AND I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0' AND `D`.`status` = '1' LIMIT ".$config['front_page_down_box_limit']; +foreach (dbFetchRows($sql) as $device) { + generate_front_box( + 'device-down', + generate_device_link($device, shorthost($device['hostname'])).'
    + Device Down
    + '.truncate($device['location'], 20).'' + ); + ++$count_boxes; +} + +if ($_SESSION['userlevel'] >= '10') { + $sql = "SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0' AND `D`.`status` = '1' LIMIT ".$config['front_page_down_box_limit']; +} +else { + $sql = "SELECT * FROM `ports` AS I, `devices` AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '".$_SESSION['user_id']."' AND I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0' AND `D`.`status` = '1' LIMIT ".$config['front_page_down_box_limit']; } // These things need to become more generic, and more manageable across different frontpages... rewrite inc :> - // Port down boxes -if ($config['warn']['ifdown']) -{ - foreach (dbFetchRows($sql) as $interface) - { - if (!$interface['deleted']) - { - $interface = ifNameDescr($interface); - generate_front_box("port-down", generate_device_link($interface, shorthost($interface['hostname']))."
    +if ($config['warn']['ifdown']) { + foreach (dbFetchRows($sql) as $interface) { + if (!$interface['deleted']) { + $interface = ifNameDescr($interface); + generate_front_box( + 'port-down', + generate_device_link($interface, shorthost($interface['hostname']))."
    Port Down
    - - ".generate_port_link($interface, truncate(makeshortif($interface['label']),13,''))."
    - " . ($interface['ifAlias'] ? ''.truncate($interface['ifAlias'], 20, '').'' : '')); - ++$count_boxes; + + ".generate_port_link($interface, truncate(makeshortif($interface['label']), 13, '')).'
    + '.($interface['ifAlias'] ? ''.truncate($interface['ifAlias'], 20, '').'' : '') + ); + ++$count_boxes; + } } - } } -/* FIXME service permissions? seem nonexisting now.. */ +/* + FIXME service permissions? seem nonexisting now.. */ // Service down boxes -if ($_SESSION['userlevel'] >= '10') -{ - $sql = "SELECT * FROM `services` AS S, `devices` AS D WHERE S.device_id = D.device_id AND service_status = 'down' AND D.ignore = '0' AND S.service_ignore = '0' AND `D`.`status` = '1' LIMIT ".$config['front_page_down_box_limit']; - $param[] = ''; +if ($_SESSION['userlevel'] >= '10') { + $sql = "SELECT * FROM `services` AS S, `devices` AS D WHERE S.device_id = D.device_id AND service_status = 'down' AND D.ignore = '0' AND S.service_ignore = '0' AND `D`.`status` = '1' LIMIT ".$config['front_page_down_box_limit']; + $param[] = ''; } -else -{ - $sql = "SELECT * FROM services AS S, devices AS D, devices_perms AS P WHERE P.`user_id` = ? AND P.`device_id` = D.`device_id` AND S.`device_id` = D.`device_id` AND S.`service_ignore` = '0' AND S.`service_disabled` = '0' AND S.`service_status` = '0' AND `D`.`status` = '1' LIMIT ".$config['front_page_down_box_limit']; - $param[] = $_SESSION['user_id']; +else { + $sql = "SELECT * FROM services AS S, devices AS D, devices_perms AS P WHERE P.`user_id` = ? AND P.`device_id` = D.`device_id` AND S.`device_id` = D.`device_id` AND S.`service_ignore` = '0' AND S.`service_disabled` = '0' AND S.`service_status` = '0' AND `D`.`status` = '1' LIMIT ".$config['front_page_down_box_limit']; + $param[] = $_SESSION['user_id']; } -foreach (dbFetchRows($sql,$param) as $service) -{ - generate_front_box("service-down", generate_device_link($service, shorthost($service['hostname']))."
    + +foreach (dbFetchRows($sql, $param) as $service) { + generate_front_box( + 'service-down', + generate_device_link($service, shorthost($service['hostname'])).'
    Service Down - ".$service['service_type']."
    - ".truncate($interface['ifAlias'], 20).""); - ++$count_boxes; + '.$service['service_type'].'
    + '.truncate($interface['ifAlias'], 20).'' + ); + ++$count_boxes; } // BGP neighbour down boxes -if (isset($config['enable_bgp']) && $config['enable_bgp']) -{ - if ($_SESSION['userlevel'] >= '10') - { - $sql = "SELECT * FROM `devices` AS D, bgpPeers AS B WHERE bgpPeerAdminStatus != 'start' AND bgpPeerState != 'established' AND bgpPeerState != '' AND B.device_id = D.device_id AND D.ignore = 0 AND `D`.`status` = '1' LIMIT ".$config['front_page_down_box_limit']; - } else { - $sql = "SELECT * FROM `devices` AS D, bgpPeers AS B, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' AND bgpPeerAdminStatus != 'start' AND bgpPeerState != 'established' AND bgpPeerState != '' AND B.device_id = D.device_id AND D.ignore = 0 AND `D`.`status` = '1' LIMIT ".$config['front_page_down_box_limit']; - } - foreach (dbFetchRows($sql) as $peer) - { - generate_front_box("bgp-down", generate_device_link($peer, shorthost($peer['hostname']))."
    +if (isset($config['enable_bgp']) && $config['enable_bgp']) { + if ($_SESSION['userlevel'] >= '10') { + $sql = "SELECT * FROM `devices` AS D, bgpPeers AS B WHERE bgpPeerAdminStatus != 'start' AND bgpPeerState != 'established' AND bgpPeerState != '' AND B.device_id = D.device_id AND D.ignore = 0 AND `D`.`status` = '1' LIMIT ".$config['front_page_down_box_limit']; + } + else { + $sql = "SELECT * FROM `devices` AS D, bgpPeers AS B, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '".$_SESSION['user_id']."' AND bgpPeerAdminStatus != 'start' AND bgpPeerState != 'established' AND bgpPeerState != '' AND B.device_id = D.device_id AND D.ignore = 0 AND `D`.`status` = '1' LIMIT ".$config['front_page_down_box_limit']; + } + + foreach (dbFetchRows($sql) as $peer) { + generate_front_box( + 'bgp-down', + generate_device_link($peer, shorthost($peer['hostname']))."
    BGP Down - ".$peer['bgpPeerIdentifier']."
    - AS".truncate($peer['bgpPeerRemoteAs']." ".$peer['astext'], 14, "").""); - ++$count_boxes; - } + ".$peer['bgpPeerIdentifier'].'
    + AS'.truncate($peer['bgpPeerRemoteAs'].' '.$peer['astext'], 14, '').'' + ); + ++$count_boxes; + } } // Device rebooted boxes -if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== FALSE && $config['uptime_warning'] > 0) -{ - if ($_SESSION['userlevel'] >= '10') - { - $sql = "SELECT * FROM `devices` AS D WHERE D.status = '1' AND D.uptime > 0 AND D.uptime < '" . $config['uptime_warning'] . "' AND D.ignore = 0 LIMIT ".$config['front_page_down_box_limit']; - } else { - $sql = "SELECT * FROM `devices` AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' AND D.status = '1' AND D.uptime > 0 AND D.uptime < '" . - $config['uptime_warning'] . "' AND D.ignore = 0 LIMIT ".$config['front_page_down_box_limit']; - } +if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== false && $config['uptime_warning'] > 0) { + if ($_SESSION['userlevel'] >= '10') { + $sql = "SELECT * FROM `devices` AS D WHERE D.status = '1' AND D.uptime > 0 AND D.uptime < '".$config['uptime_warning']."' AND D.ignore = 0 LIMIT ".$config['front_page_down_box_limit']; + } + else { + $sql = "SELECT * FROM `devices` AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '".$_SESSION['user_id']."' AND D.status = '1' AND D.uptime > 0 AND D.uptime < '".$config['uptime_warning']."' AND D.ignore = 0 LIMIT ".$config['front_page_down_box_limit']; + } - foreach (dbFetchRows($sql) as $device) - { - generate_front_box("device-rebooted", generate_device_link($device, shorthost($device['hostname']))."
    + foreach (dbFetchRows($sql) as $device) { + generate_front_box( + 'device-rebooted', + generate_device_link($device, shorthost($device['hostname'])).'
    Device Rebooted
    - ".formatUptime($device['uptime'], 'short').""); - ++$count_boxes; - } + '.formatUptime($device['uptime'], 'short').'' + ); + ++$count_boxes; + } } + if ($count_boxes == 0) { - echo("
    Nothing here yet

    This is where status notifications about devices and services would normally go. You might have none - because you run such a great network, or perhaps you've just started using ".$config['project_name'].". If you're new to ".$config['project_name'].", you might - want to start by adding one or more devices in the Devices menu.

    "); -} -echo('
    '); -echo('
    '); -echo('
    '); -echo(' -
    -
    -'); - -if ($config['vertical_summary']) -{ - echo('
    '); - include_once("includes/device-summary-vert.inc.php"); -} -else -{ - echo('
    '); - include_once("includes/device-summary-horiz.inc.php"); + echo "
    Nothing here yet

    This is where status notifications about devices and services would normally go. You might have none + because you run such a great network, or perhaps you've just started using ".$config['project_name'].". If you're new to ".$config['project_name'].', you might + want to start by adding one or more devices in the Devices menu.

    '; } -echo(' +echo '
    '; +echo '
    '; +echo '
    '; +echo ' +
    +
    +'; + +if ($config['vertical_summary']) { + echo '
    '; + include_once 'includes/device-summary-vert.inc.php'; +} +else { + echo '
    '; + include_once 'includes/device-summary-horiz.inc.php'; +} + +echo '
    -'); +'; -if ($config['enable_syslog']) -{ +if ($config['enable_syslog']) { + $sql = "SELECT *, DATE_FORMAT(timestamp, '".$config['dateformat']['mysql']['compact']."') AS date from syslog ORDER BY timestamp DESC LIMIT 20"; + $query = mysql_query($sql); - $sql = "SELECT *, DATE_FORMAT(timestamp, '".$config['dateformat']['mysql']['compact']."') AS date from syslog ORDER BY timestamp DESC LIMIT 20"; - $query = mysql_query($sql); - - echo('
    + echo '
      @@ -180,35 +186,34 @@ if ($config['enable_syslog'])
    Syslog entries
    -
    '); +
    '; - foreach (dbFetchRows($sql) as $entry) - { - $entry = array_merge($entry, device_by_id_cache($entry['device_id'])); + foreach (dbFetchRows($sql) as $entry) { + $entry = array_merge($entry, device_by_id_cache($entry['device_id'])); - include("includes/print-syslog.inc.php"); - } - echo("
    "); - echo(""); - echo(""); - echo(""); - echo(""); + include 'includes/print-syslog.inc.php'; + } -} else { + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; +} +else { + if ($_SESSION['userlevel'] >= '10') { + $query = "SELECT *,DATE_FORMAT(datetime, '".$config['dateformat']['mysql']['compact']."') as humandate FROM `eventlog` ORDER BY `datetime` DESC LIMIT 0,15"; + $alertquery = 'SELECT devices.device_id,name,state,time_logged FROM alert_log LEFT JOIN devices ON alert_log.device_id=devices.device_id LEFT JOIN alert_rules ON alert_log.rule_id=alert_rules.id ORDER BY `time_logged` DESC LIMIT 0,15'; + } + else { + $query = "SELECT *,DATE_FORMAT(datetime, '".$config['dateformat']['mysql']['compact']."') as humandate FROM `eventlog` AS E, devices_perms AS P WHERE E.host = P.device_id AND P.user_id = ".$_SESSION['user_id'].' ORDER BY `datetime` DESC LIMIT 0,15'; + $alertquery = 'SELECT devices.device_id,name,state,time_logged FROM alert_log LEFT JOIN devices ON alert_log.device_id=devices.device_id LEFT JOIN alert_rules ON alert_log.rule_id=alert_rules.id RIGHT JOIN devices_perms ON alert_log.device_id = devices_perms.device_id AND devices_perms.user_id = '.$_SESSION['user_id'].' ORDER BY `time_logged` DESC LIMIT 0,15'; + } - if ($_SESSION['userlevel'] >= '10') - { - $query = "SELECT *,DATE_FORMAT(datetime, '".$config['dateformat']['mysql']['compact']."') as humandate FROM `eventlog` ORDER BY `datetime` DESC LIMIT 0,15"; - $alertquery = "SELECT devices.device_id,name,state,time_logged FROM alert_log LEFT JOIN devices ON alert_log.device_id=devices.device_id LEFT JOIN alert_rules ON alert_log.rule_id=alert_rules.id ORDER BY `time_logged` DESC LIMIT 0,15"; - } else { - $query = "SELECT *,DATE_FORMAT(datetime, '".$config['dateformat']['mysql']['compact']."') as humandate FROM `eventlog` AS E, devices_perms AS P WHERE E.host = P.device_id AND P.user_id = " . $_SESSION['user_id'] . " ORDER BY `datetime` DESC LIMIT 0,15"; - $alertquery = "SELECT devices.device_id,name,state,time_logged FROM alert_log LEFT JOIN devices ON alert_log.device_id=devices.device_id LEFT JOIN alert_rules ON alert_log.rule_id=alert_rules.id RIGHT JOIN devices_perms ON alert_log.device_id = devices_perms.device_id AND devices_perms.user_id = " . $_SESSION['user_id'] . " ORDER BY `time_logged` DESC LIMIT 0,15"; - } + $data = mysql_query($query); + $alertdata = mysql_query($alertquery); - $data = mysql_query($query); - $alertdata = mysql_query($alertquery); - - echo('
    + echo '
      @@ -220,13 +225,13 @@ if ($config['enable_syslog'])
    Alertlog entries
    - '); +
    '; - foreach (dbFetchRows($alertquery) as $alert_entry) - { - include("includes/print-alerts.inc.php"); - } - echo('
    + foreach (dbFetchRows($alertquery) as $alert_entry) { + include 'includes/print-alerts.inc.php'; + } + + echo '
    @@ -234,24 +239,21 @@ if ($config['enable_syslog'])
    Eventlog entries
    - '); +
    '; - foreach (dbFetchRows($query) as $entry) - { - include("includes/print-event.inc.php"); - } + foreach (dbFetchRows($query) as $entry) { + include 'includes/print-event.inc.php'; + } - echo("
    "); - echo("
    "); - echo("
    "); - echo("
    "); - echo(""); -} + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; +}//end if -echo(""); +echo ''; -echo(' +echo ' -'); - -?> +'; diff --git a/html/pages/front/demo.php b/html/pages/front/demo.php index 1000fbca24..6478a566b8 100644 --- a/html/pages/front/demo.php +++ b/html/pages/front/demo.php @@ -4,56 +4,55 @@ "); +echo ''; -$dev_list = array('6' => 'Central Fileserver', - '7' => 'NE61 Fileserver', - '34' => 'DE56 Fileserver'); +$dev_list = array( + '6' => 'Central Fileserver', + '7' => 'NE61 Fileserver', + '34' => 'DE56 Fileserver', +); -foreach ($dev_list as $device_id => $descr) -{ +foreach ($dev_list as $device_id => $descr) { + echo ''; +}//end foreach - echo(""); - -} - -echo("
    '; + echo "
    ".$descr.'
    '; + $graph_array['height'] = '100'; + $graph_array['width'] = '310'; + $graph_array['to'] = $config['time']['now']; + $graph_array['device'] = $device_id; + $graph_array['type'] = 'device_bits'; + $graph_array['from'] = $config['time']['day']; + $graph_array['legend'] = 'no'; + $graph_array['popup_title'] = $descr; + // $graph_array['link'] = generate_device_link($device_id); + print_graph_popup($graph_array); - echo("
    "); - echo("
    ".$descr."
    "); - $graph_array['height'] = "100"; - $graph_array['width'] = "310"; - $graph_array['to'] = $config['time']['now']; - $graph_array['device'] = $device_id; - $graph_array['type'] = "device_bits"; - $graph_array['from'] = $config['time']['day']; - $graph_array['legend'] = "no"; - $graph_array['popup_title'] = $descr; -# $graph_array['link'] = generate_device_link($device_id); - print_graph_popup($graph_array); + $graph_array['height'] = '50'; + $graph_array['width'] = '180'; - $graph_array['height'] = "50"; - $graph_array['width'] = "180"; + echo "
    "; + $graph_array['type'] = 'device_ucd_memory'; + print_graph_popup($graph_array); + echo '
    '; - echo("
    "); - $graph_array['type'] = "device_ucd_memory"; - print_graph_popup($graph_array); - echo("
    "); + echo "
    "; + $graph_array['type'] = 'device_processor'; + print_graph_popup($graph_array); + echo '
    '; - echo("
    "); - $graph_array['type'] = "device_processor"; - print_graph_popup($graph_array); - echo("
    "); + echo "
    "; + $graph_array['type'] = 'device_storage'; + print_graph_popup($graph_array); + echo '
    '; - echo("
    "); - $graph_array['type'] = "device_storage"; - print_graph_popup($graph_array); - echo("
    "); + echo "
    "; + $graph_array['type'] = 'device_diskio'; + print_graph_popup($graph_array); + echo '
    '; - echo("
    "); - $graph_array['type'] = "device_diskio"; - print_graph_popup($graph_array); - echo("
    "); + echo '
    "); +echo ''; ?> @@ -62,115 +61,105 @@ echo(""); '0' AND A.attrib_value < '86400'"; -foreach (dbFetchRows($sql) as $device) -{ - unset($already); - $i = 0; - while ($i <= count($nodes)) { - $thisnode = $device['device_id']; - if ($nodes[$i] == $thisnode) { - $already = "yes"; +foreach (dbFetchRows($sql) as $device) { + unset($already); + $i = 0; + while ($i <= count($nodes)) { + $thisnode = $device['device_id']; + if ($nodes[$i] == $thisnode) { + $already = 'yes'; + } + + $i++; + } + + if (!$already) { + $nodes[] = $device['device_id']; } - $i++; - } - if (!$already) { $nodes[] = $device['device_id']; } } $sql = "SELECT * FROM `devices` WHERE `status` = '0' AND `ignore` = '0'"; -foreach (dbFetchRows($sql) as $device) -{ - if (device_permitted($device['device_id'])) { - echo("
    - ".generate_device_link($device, shorthost($device['hostname']))."
    - Device Down
    - ".truncate($device['location'], 35)." -
    "); - } +foreach (dbFetchRows($sql) as $device) { + if (device_permitted($device['device_id'])) { + echo "
    + ".generate_device_link($device, shorthost($device['hostname']))."
    + Device Down
    + ".truncate($device['location'], 35).' +
    '; + } } -if ($config['warn']['ifdown']) -{ - $sql = "SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0'"; - foreach (dbFetchRows($sql) as $interface) - { - if (port_permitted($interface['port_id'])) - { - echo("
    - ".generate_device_link($interface, shorthost($interface['hostname']))."
    - Port Down
    - ".generate_port_link($interface, makeshortif($interface['ifDescr']))."
    - ".truncate($interface['ifAlias'], 15)." -
    "); +if ($config['warn']['ifdown']) { + $sql = "SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0'"; + foreach (dbFetchRows($sql) as $interface) { + if (port_permitted($interface['port_id'])) { + echo "
    + ".generate_device_link($interface, shorthost($interface['hostname']))."
    + Port Down
    + ".generate_port_link($interface, makeshortif($interface['ifDescr'])).'
    + '.truncate($interface['ifAlias'], 15).' +
    '; + } } - } } $sql = "SELECT * FROM `services` AS S, `devices` AS D WHERE S.device_id = D.device_id AND service_status = 'down' AND D.ignore = '0' AND S.service_ignore = '0'"; -foreach (dbFetchRows($sql) as $service) -{ - if (device_permitted($service['device_id'])) - { - echo("
    - ".generate_device_link($service, shorthost($service['hostname']))."
    - Service Down
    - ".$service['service_type']."
    - ".truncate($interface['ifAlias'], 15)." -
    "); - } +foreach (dbFetchRows($sql) as $service) { + if (device_permitted($service['device_id'])) { + echo "
    + ".generate_device_link($service, shorthost($service['hostname']))."
    + Service Down
    + ".$service['service_type'].'
    + '.truncate($interface['ifAlias'], 15).' +
    '; + } } $sql = "SELECT * FROM `devices` AS D, bgpPeers AS B WHERE bgpPeerAdminStatus = 'start' AND bgpPeerState != 'established' AND B.device_id = D.device_id"; -foreach (dbFetchRows($sql) as $peer) -{ - if (device_permitted($peer['device_id'])) - { - echo("
    - ".generate_device_link($peer, shorthost($peer['hostname']))."
    - BGP Down
    - ".$peer['bgpPeerIdentifier']."
    - AS".$peer['bgpPeerRemoteAs']." ".truncate($peer['astext'], 10)." -
    "); - } -} - -if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== FALSE && $config['uptime_warning'] > 0) -{ - $sql = "SELECT * FROM devices_attribs AS A, `devices` AS D WHERE - A.attrib_value < '" . $config['uptime_warning'] . "' AND A.attrib_type = 'uptime' AND A.device_id = D.device_id AND ignore = '0' AND disabled = '0'"; - foreach (dbFetchRows($sql) as $device) - { - if (device_permitted($device['device_id']) && $device['attrib_value'] < $config['uptime_warning'] && $device['attrib_type'] == "uptime") - { - echo("
    - ".generate_device_link($device, shorthost($device['hostname']))."
    - Device
    Rebooted

    - ".formatUptime($device['attrib_value'])." -
    "); +foreach (dbFetchRows($sql) as $peer) { + if (device_permitted($peer['device_id'])) { + echo "
    + ".generate_device_link($peer, shorthost($peer['hostname']))."
    + BGP Down
    + ".$peer['bgpPeerIdentifier'].'
    + AS'.$peer['bgpPeerRemoteAs'].' '.truncate($peer['astext'], 10).' +
    '; } - } } -echo(" -
    $errorboxes
    +if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== false && $config['uptime_warning'] > 0) { + $sql = "SELECT * FROM devices_attribs AS A, `devices` AS D WHERE + A.attrib_value < '".$config['uptime_warning']."' AND A.attrib_type = 'uptime' AND A.device_id = D.device_id AND ignore = '0' AND disabled = '0'"; + foreach (dbFetchRows($sql) as $device) { + if (device_permitted($device['device_id']) && $device['attrib_value'] < $config['uptime_warning'] && $device['attrib_type'] == 'uptime') { + echo "
    + ".generate_device_link($device, shorthost($device['hostname']))."
    + Device
    Rebooted

    + ".formatUptime($device['attrib_value']).' +
    '; + } + } +} -

    Recent Syslog Messages

    -"); +echo " +
    $errorboxes
    + +

    Recent Syslog Messages

    + "; $sql = "SELECT *, DATE_FORMAT(timestamp, '".$config['dateformat']['mysql']['compact']."') AS date from `syslog` ORDER BY seq DESC LIMIT 20"; -echo(""); -foreach (dbFetchRows($sql) as $entry) -{ - $entry = array_merge($entry, device_by_id_cache($entry['device_id'])); +echo '
    '; +foreach (dbFetchRows($sql) as $entry) { + $entry = array_merge($entry, device_by_id_cache($entry['device_id'])); - include("includes/print-syslog.inc.php"); + include 'includes/print-syslog.inc.php'; } -echo("
    "); +echo ''; ?> diff --git a/html/pages/front/example2.php b/html/pages/front/example2.php index 717ee75184..e5898ac073 100644 --- a/html/pages/front/example2.php +++ b/html/pages/front/example2.php @@ -4,173 +4,141 @@
    Devices with Alerts
    Host
    Int
    Srv
    +// ?> '0' AND A.attrib_value < '86400'"; -foreach (dbFetchRows($sql) as $device) -{ - unset($already); - $i = 0; - while ($i <= count($nodes)) - { - $thisnode = $device['device_id']; - if ($nodes[$i] == $thisnode) - { - $already = "yes"; +foreach (dbFetchRows($sql) as $device) { + unset($already); + $i = 0; + while ($i <= count($nodes)) { + $thisnode = $device['device_id']; + if ($nodes[$i] == $thisnode) { + $already = 'yes'; + } + + $i++; + } + + if (!$already) { + $nodes[] = $device['device_id']; } - $i++; - } - if (!$already) { $nodes[] = $device['device_id']; } } $sql = "SELECT * FROM `devices` WHERE `status` = '0' AND `ignore` = '0'"; -foreach (dbFetchRows($sql) as $device) -{ - echo("
    -
    ".generate_device_link($device, shorthost($device['hostname']))."
    - Device Down - ".truncate($device['location'], 20)." -
    "); - +foreach (dbFetchRows($sql) as $device) { + echo "
    +
    ".generate_device_link($device, shorthost($device['hostname']))."
    + Device Down + ".truncate($device['location'], 20).' +
    '; } $sql = "SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0'"; -foreach (dbFetchRows($sql) as $interface) -{ - echo("
    -
    ".generate_device_link($interface, shorthost($interface['hostname']))."
    - Port Down - ".generate_port_link($interface, makeshortif($interface['ifDescr']))."
    - ".truncate($interface['ifAlias'], 20)." -
    "); - +foreach (dbFetchRows($sql) as $interface) { + echo "
    +
    ".generate_device_link($interface, shorthost($interface['hostname']))."
    + Port Down + ".generate_port_link($interface, makeshortif($interface['ifDescr'])).'
    + '.truncate($interface['ifAlias'], 20).' +
    '; } $sql = "SELECT * FROM `services` AS S, `devices` AS D WHERE S.device_id = D.device_id AND service_status = 'down' AND D.ignore = '0' AND S.service_ignore = '0'"; -foreach (dbFetchRows($sql) as $service) -{ - echo("
    -
    ".generate_device_link($service, shorthost($service['hostname']))."
    - Service Down - ".$service['service_type']."
    - ".truncate($interface['ifAlias'], 20)." -
    "); - +foreach (dbFetchRows($sql) as $service) { + echo "
    +
    ".generate_device_link($service, shorthost($service['hostname']))."
    + Service Down + ".$service['service_type'].'
    + '.truncate($interface['ifAlias'], 20).' +
    '; } $sql = "SELECT * FROM `devices` AS D, bgpPeers AS B WHERE bgpPeerState != 'established' AND B.device_id = D.device_id"; -foreach (dbFetchRows($sql) as $peer) -{ - echo("
    -
    ".generate_device_link($peer, shorthost($peer['hostname']))."
    - BGP Down - ".$peer['bgpPeerIdentifier']."
    - AS".$peer['bgpPeerRemoteAs']." ".truncate($peer['astext'], 10)." -
    "); - +foreach (dbFetchRows($sql) as $peer) { + echo "
    +
    ".generate_device_link($peer, shorthost($peer['hostname']))."
    + BGP Down + ".$peer['bgpPeerIdentifier'].'
    + AS'.$peer['bgpPeerRemoteAs'].' '.truncate($peer['astext'], 10).' +
    '; } -if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== FALSE && $config['uptime_warning'] > 0) -{ - $sql = "SELECT * FROM `devices` AS D, devices_attribs AS A WHERE A.device_id = D.device_id AND A.attrib_type = 'uptime' AND A.attrib_value < '" . $config['uptime_warning'] . "'"; - foreach (dbFetchRows($sql) as $device) - { - echo("
    -
    ".generate_device_link($device, shorthost($device['hostname']))."
    - Device
    Rebooted

    - ".formatUptime($device['attrib_value'])." -
    "); - } +if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== false && $config['uptime_warning'] > 0) { + $sql = "SELECT * FROM `devices` AS D, devices_attribs AS A WHERE A.device_id = D.device_id AND A.attrib_type = 'uptime' AND A.attrib_value < '".$config['uptime_warning']."'"; + foreach (dbFetchRows($sql) as $device) { + echo "
    +
    ".generate_device_link($device, shorthost($device['hostname']))."
    + Device
    Rebooted

    + ".formatUptime($device['attrib_value']).' +
    '; + } } -echo(" +echo " -
    $errorboxes
    +
    $errorboxes
    -

    Recent Syslog Messages

    +

    Recent Syslog Messages

    -"); + "; $sql = "SELECT *, DATE_FORMAT(timestamp, '".$config['dateformat']['mysql']['compact']."') AS date from syslog ORDER BY timestamp DESC LIMIT 20"; -echo("
    Devices with Alerts
    Host
    Int
    Srv
    "); -foreach (dbFetchRows($sql) as $entry) -{ - include("includes/print-syslog.inc.php"); +echo '
    '; +foreach (dbFetchRows($sql) as $entry) { + include 'includes/print-syslog.inc.php'; } -echo("
    "); -echo("
    +echo ''; - - "); +echo '
    + + + '; // this stuff can be customised to show whatever you want.... +if ($_SESSION['userlevel'] >= '5') { + $sql = "SELECT * FROM ports AS I, devices AS D WHERE `ifAlias` like 'L2TP: %' AND I.device_id = D.device_id AND D.hostname LIKE '%"; + $sql .= $config['mydomain']."' ORDER BY I.ifAlias"; + unset($seperator); + foreach (dbFetchRows($sql) as $interface) { + $ports['l2tp'] .= $seperator.$interface['port_id']; + $seperator = ','; + } -if ($_SESSION['userlevel'] >= '5') -{ - $sql = "SELECT * FROM ports AS I, devices AS D WHERE `ifAlias` like 'L2TP: %' AND I.device_id = D.device_id AND D.hostname LIKE '%"; - $sql .= $config['mydomain'] . "' ORDER BY I.ifAlias"; - unset ($seperator); - foreach (dbFetchRows($sql) as $interface) - { - $ports['l2tp'] .= $seperator . $interface['port_id']; - $seperator = ","; - } + $sql = "SELECT * FROM ports AS I, devices AS D WHERE `ifAlias` like 'Transit: %' AND I.device_id = D.device_id AND D.hostname LIKE '%"; + $sql .= $config['mydomain']."' ORDER BY I.ifAlias"; + unset($seperator); + foreach (dbFetchRows($sql) as $interface) { + $ports['transit'] .= $seperator.$interface['port_id']; + $seperator = ','; + } - $sql = "SELECT * FROM ports AS I, devices AS D WHERE `ifAlias` like 'Transit: %' AND I.device_id = D.device_id AND D.hostname LIKE '%"; - $sql .= $config['mydomain'] . "' ORDER BY I.ifAlias"; - unset ($seperator); - foreach (dbFetchRows($sql) as $interface) - { - $ports['transit'] .= $seperator . $interface['port_id']; - $seperator = ","; - } + $sql = "SELECT * FROM ports AS I, devices AS D WHERE `ifAlias` like 'Server: thlon-pbx%' AND I.device_id = D.device_id AND D.hostname LIKE '%"; + $sql .= $config['mydomain']."' ORDER BY I.ifAlias"; + unset($seperator); + foreach (dbFetchRows($sql) as $interface) { + $ports['voip'] .= $seperator.$interface['port_id']; + $seperator = ','; + } - $sql = "SELECT * FROM ports AS I, devices AS D WHERE `ifAlias` like 'Server: thlon-pbx%' AND I.device_id = D.device_id AND D.hostname LIKE '%"; - $sql .= $config['mydomain'] . "' ORDER BY I.ifAlias"; - unset ($seperator); - foreach (dbFetchRows($sql) as $interface) - { - $ports['voip'] .= $seperator . $interface['port_id']; - $seperator = ","; - } + if ($ports['transit']) { + echo "', CENTER, LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 250);\" onmouseout=\"return nd();\" >"."
    Internet Transit
    "."
    "; + } - if ($ports['transit']) - { - echo("', CENTER, LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 250);\" onmouseout=\"return nd();\" >". - "
    Internet Transit
    ". - "
    "); - } + if ($ports['l2tp']) { + echo "', LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 250);\" onmouseout=\"return nd();\" >"."
    L2TP ADSL
    "."
    "; + } - if ($ports['l2tp']) - { - echo("', LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 250);\" onmouseout=\"return nd();\" >". - "
    L2TP ADSL
    ". - "
    "); - } - - if ($ports['voip']) - { - echo("', LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 250);\" onmouseout=\"return nd();\" >". - "
    VoIP to PSTN
    ". - "
    "); - } - -} + if ($ports['voip']) { + echo "', LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 250);\" onmouseout=\"return nd();\" >"."
    VoIP to PSTN
    "."
    "; + } +}//end if // END VOSTRON - ?> diff --git a/html/pages/front/globe.php b/html/pages/front/globe.php index 75a5917c70..9884b402fa 100644 --- a/html/pages/front/globe.php +++ b/html/pages/front/globe.php @@ -4,16 +4,17 @@ * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . */ + * along with this program. If not, see . + */ -/** +/* * Custom Frontpage * @author f0o * @copyright 2014 f0o, LibreNMS @@ -25,107 +26,111 @@ ?> -
    -
    -
    -
    -
    -
    -
    -
    '; - include_once("includes/device-summary-vert.inc.php"); -echo '
    -
    -
    -
    '; - include_once("includes/front/boxes.inc.php"); -echo '
    -
    -
    -
    -
    -
    -
    '; - $device['device_id'] = '-1'; - require_once('includes/print-alerts.php'); - unset($device['device_id']); -echo '
    -
    +
    +
    +
    +
    +
    +
    +
    +
    '; + include_once("includes/device-summary-vert.inc.php"); +echo '
    +
    +
    +
    '; + include_once("includes/front/boxes.inc.php"); +echo '
    +
    +
    +
    +
    +
    +
    '; + $device['device_id'] = '-1'; + require_once('includes/print-alerts.php'); + unset($device['device_id']); +echo '
    +
    '; //From default.php - This code is not part of above license. if ($config['enable_syslog']) { -$sql = "SELECT *, DATE_FORMAT(timestamp, '".$config['dateformat']['mysql']['compact']."') AS date from syslog ORDER BY seq DESC LIMIT 20"; -$query = mysql_query($sql); -echo('
    + $sql = "SELECT *, DATE_FORMAT(timestamp, '".$config['dateformat']['mysql']['compact']."') AS date from syslog ORDER BY seq DESC LIMIT 20"; + $query = mysql_query($sql); + echo('
      @@ -139,29 +144,28 @@ echo('
    '); - foreach (dbFetchRows($sql) as $entry) - { - $entry = array_merge($entry, device_by_id_cache($entry['device_id'])); + foreach (dbFetchRows($sql) as $entry) { + $entry = array_merge($entry, device_by_id_cache($entry['device_id'])); - include("includes/print-syslog.inc.php"); - } - echo("
    "); - echo("
    "); - echo("
    "); - echo("
    "); - echo("
    "); + include 'includes/print-syslog.inc.php'; + } + echo(""); + echo(""); + echo(""); + echo(""); + echo(""); +} +else { -} else { + if ($_SESSION['userlevel'] == '10') { + $query = "SELECT *,DATE_FORMAT(datetime, '".$config['dateformat']['mysql']['compact']."') as humandate FROM `eventlog` ORDER BY `datetime` DESC LIMIT 0,15"; + } + else { + $query = "SELECT *,DATE_FORMAT(datetime, '".$config['dateformat']['mysql']['compact']."') as humandate FROM `eventlog` AS E, devices_perms AS P WHERE E.host = + P.device_id AND P.user_id = " . $_SESSION['user_id'] . " ORDER BY `datetime` DESC LIMIT 0,15"; + } - if ($_SESSION['userlevel'] == '10') - { - $query = "SELECT *,DATE_FORMAT(datetime, '".$config['dateformat']['mysql']['compact']."') as humandate FROM `eventlog` ORDER BY `datetime` DESC LIMIT 0,15"; - } else { - $query = "SELECT *,DATE_FORMAT(datetime, '".$config['dateformat']['mysql']['compact']."') as humandate FROM `eventlog` AS E, devices_perms AS P WHERE E.host = - P.device_id AND P.user_id = " . $_SESSION['user_id'] . " ORDER BY `datetime` DESC LIMIT 0,15"; - } - - $data = mysql_query($query); + $data = mysql_query($query); echo('
    @@ -177,15 +181,13 @@ echo('
    '); - foreach (dbFetchRows($query) as $entry) - { - include("includes/print-event.inc.php"); - } + foreach (dbFetchRows($query) as $entry) { + include 'includes/print-event.inc.php'; + } - echo("
    "); - echo("
    "); - echo("
    "); - echo(""); - echo(""); + echo(""); + echo(""); + echo(""); + echo(""); + echo(""); } -?> diff --git a/html/pages/front/jt.php b/html/pages/front/jt.php index 2256cf0856..cda0b49bb7 100644 --- a/html/pages/front/jt.php +++ b/html/pages/front/jt.php @@ -5,238 +5,209 @@ $nodes = array(); -$uptimesql = ""; -if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== FALSE && $config['uptime_warning'] > 0) -{ - $uptimesql = " AND A.attrib_value < '" . $config['uptime_warning'] . "'"; +$uptimesql = ''; +if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== false && $config['uptime_warning'] > 0) { + $uptimesql = " AND A.attrib_value < '".$config['uptime_warning']."'"; } -$sql = "SELECT * FROM `devices` AS D, `devices_attribs` AS A WHERE D.status = '1' AND A.device_id = D.device_id AND A.attrib_type = 'uptime' AND A.attrib_value > '0' " . $uptimesql; +$sql = "SELECT * FROM `devices` AS D, `devices_attribs` AS A WHERE D.status = '1' AND A.device_id = D.device_id AND A.attrib_type = 'uptime' AND A.attrib_value > '0' ".$uptimesql; -foreach (dbFetchRows($sql) as $device) -{ - unset($already); - $i = 0; - while ($i <= count($nodes)) { - $thisnode = $device['device_id']; - if ($nodes[$i] == $thisnode) { - $already = "yes"; +foreach (dbFetchRows($sql) as $device) { + unset($already); + $i = 0; + while ($i <= count($nodes)) { + $thisnode = $device['device_id']; + if ($nodes[$i] == $thisnode) { + $already = 'yes'; + } + + $i++; + } + + if (!$already) { + $nodes[] = $device['device_id']; } - $i++; - } - if (!$already) { $nodes[] = $device['device_id']; } } $sql = "SELECT * FROM `devices` WHERE `status` = '0' AND `ignore` = '0'"; -foreach (dbFetchRows($sql) as $device) -{ - if (device_permitted($device['device_id'])) { - echo("
    - ".generate_device_link($device, shorthost($device['hostname']))."
    - Device Down
    - ".truncate($device['location'], 35)." -
    "); - } +foreach (dbFetchRows($sql) as $device) { + if (device_permitted($device['device_id'])) { + echo "
    + ".generate_device_link($device, shorthost($device['hostname']))."
    + Device Down
    + ".truncate($device['location'], 35).' +
    '; + } } if ($config['warn']['ifdown']) { - -$sql = "SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0'"; -foreach (dbFetchRows($sql) as $interface) -{ - if (port_permitted($interface['port_id'])) { - echo("
    - ".generate_device_link($interface, shorthost($interface['hostname']))."
    - Port Down
    - ".generate_port_link($interface, makeshortif($interface['ifDescr']))."
    - ".truncate($interface['ifAlias'], 15)." -
    "); - } -} - + $sql = "SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0'"; + foreach (dbFetchRows($sql) as $interface) { + if (port_permitted($interface['port_id'])) { + echo "
    + ".generate_device_link($interface, shorthost($interface['hostname']))."
    + Port Down
    + ".generate_port_link($interface, makeshortif($interface['ifDescr'])).'
    + '.truncate($interface['ifAlias'], 15).' +
    '; + } + } } $sql = "SELECT * FROM `services` AS S, `devices` AS D WHERE S.device_id = D.device_id AND service_status = 'down' AND D.ignore = '0' AND S.service_ignore = '0'"; -foreach (dbFetchRows($sql) as $service) -{ - if (device_permitted($service['device_id'])) { - echo("
    - ".generate_device_link($service, shorthost($service['hostname']))."
    - Service Down
    - ".$service['service_type']."
    - ".truncate($interface['ifAlias'], 15)." -
    "); - } +foreach (dbFetchRows($sql) as $service) { + if (device_permitted($service['device_id'])) { + echo "
    + ".generate_device_link($service, shorthost($service['hostname']))."
    + Service Down
    + ".$service['service_type'].'
    + '.truncate($interface['ifAlias'], 15).' +
    '; + } } $sql = "SELECT * FROM `devices` AS D, bgpPeers AS B WHERE bgpPeerAdminStatus = 'start' AND bgpPeerState != 'established' AND B.device_id = D.device_id"; -foreach (dbFetchRows($sql) as $peer) -{ - if (device_permitted($peer['device_id'])) { - echo("
    - ".generate_device_link($peer, shorthost($peer['hostname']))."
    - BGP Down
    - ".$peer['bgpPeerIdentifier']."
    - AS".$peer['bgpPeerRemoteAs']." ".truncate($peer['astext'], 10)." -
    "); - } +foreach (dbFetchRows($sql) as $peer) { + if (device_permitted($peer['device_id'])) { + echo "
    + ".generate_device_link($peer, shorthost($peer['hostname']))."
    + BGP Down
    + ".$peer['bgpPeerIdentifier'].'
    + AS'.$peer['bgpPeerRemoteAs'].' '.truncate($peer['astext'], 10).' +
    '; + } } -if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== FALSE && $config['uptime_warning'] > 0) -{ - $sql = "SELECT * FROM devices_attribs AS A, `devices` AS D WHERE A.attrib_value < '" . $config['uptime_warning'] . "' AND A.attrib_type = 'uptime' AND A.device_id = D.device_id AND ignore = '0' AND disabled = '0'"; - foreach (dbFetchRows($sql) as $device) { - if (device_permitted($device['device_id']) && $device['attrib_value'] < $config['uptime_warning'] && $device['attrib_type'] == "uptime") { - echo("
    - ".generate_device_link($device, shorthost($device['hostname']))."
    - Device
    Rebooted

    - ".formatUptime($device['attrib_value'])." -
    "); - } - } +if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== false && $config['uptime_warning'] > 0) { + $sql = "SELECT * FROM devices_attribs AS A, `devices` AS D WHERE A.attrib_value < '".$config['uptime_warning']."' AND A.attrib_type = 'uptime' AND A.device_id = D.device_id AND ignore = '0' AND disabled = '0'"; + foreach (dbFetchRows($sql) as $device) { + if (device_permitted($device['device_id']) && $device['attrib_value'] < $config['uptime_warning'] && $device['attrib_type'] == 'uptime') { + echo "
    + ".generate_device_link($device, shorthost($device['hostname']))."
    + Device
    Rebooted

    + ".formatUptime($device['attrib_value']).' +
    '; + } + } } -echo(" +echo " -
    $errorboxes
    +
    $errorboxes
    -

    Recent Syslog Messages

    +

    Recent Syslog Messages

    -"); + "; $sql = "SELECT *, DATE_FORMAT(timestamp, '".$config['dateformat']['mysql']['compact']."') AS date from syslog,devices WHERE syslog.device_id = devices.device_id ORDER BY seq DESC LIMIT 20"; -echo(""); -foreach (dbFetchRows($sql) as $entry) -{ - include("includes/print-syslog.inc.php"); +echo '
    '; +foreach (dbFetchRows($sql) as $entry) { + include 'includes/print-syslog.inc.php'; } -echo("
    "); -echo("
    +echo ''; - - "); +echo '
    + + + '; // this stuff can be customised to show whatever you want.... +if ($_SESSION['userlevel'] >= '5') { + $sql = "SELECT * FROM ports AS I, devices AS D WHERE `ifAlias` like 'Transit: %' AND I.device_id = D.device_id ORDER BY I.ifAlias"; + unset($seperator); + foreach (dbFetchRows($sql) as $interface) { + $ports['transit'] .= $seperator.$interface['port_id']; + $seperator = ','; + } -if ($_SESSION['userlevel'] >= '5') -{ + $sql = "SELECT * FROM ports AS I, devices AS D WHERE `ifAlias` like 'Peering: %' AND I.device_id = D.device_id ORDER BY I.ifAlias"; + unset($seperator); + foreach (dbFetchRows($sql) as $interface) { + $ports['peering'] .= $seperator.$interface['port_id']; + $seperator = ','; + } - $sql = "SELECT * FROM ports AS I, devices AS D WHERE `ifAlias` like 'Transit: %' AND I.device_id = D.device_id ORDER BY I.ifAlias"; - unset ($seperator); - foreach (dbFetchRows($sql) as $interface) - { - $ports['transit'] .= $seperator . $interface['port_id']; - $seperator = ","; - } + $ports['broadband'] = '3294,3295,688,3534'; + $ports['wave_broadband'] = '827'; - $sql = "SELECT * FROM ports AS I, devices AS D WHERE `ifAlias` like 'Peering: %' AND I.device_id = D.device_id ORDER BY I.ifAlias"; - unset ($seperator); - foreach (dbFetchRows($sql) as $interface) - { - $ports['peering'] .= $seperator . $interface['port_id']; - $seperator = ","; - } + $ports['new_broadband'] = '3659,4149,4121,4108,3676,4135'; - $ports['broadband'] = "3294,3295,688,3534"; - $ports['wave_broadband'] = "827"; + echo "
    "; - $ports['new_broadband'] = "3659,4149,4121,4108,3676,4135"; + if ($ports['peering'] && $ports['transit']) { + echo ""; + } - echo("
    "); + echo '
    '; - if ($ports['peering'] && $ports['transit']) { - echo(""); - } + echo "
    "; - echo("
    "); + if ($ports['transit']) { + echo ""; + } - echo("'; - if ($ports['peering']) { - echo(""); - } + echo "
    "; - echo("
    "); + if ($ports['broadband'] && $ports['wave_broadband'] && $ports['new_broadband']) { + echo ""; + } - echo("
    "); + echo "
    "; - if ($ports['broadband'] && $ports['wave_broadband'] && $ports['new_broadband']) { - echo(""); - } + if ($ports['broadband']) { + echo ""; + } - echo("
    "); + echo "
    "; - if ($ports['broadband']) { - echo(""); - } + if ($ports['new_broadband']) { + echo ""; + } - echo("
    "); + echo '
    '; - if ($ports['new_broadband']) { - echo(""); - } + if ($ports['wave_broadband']) { + echo ""; + } - echo("
    "); - - if ($ports['wave_broadband']) { - echo(""); - } - - echo("
    "); - -} + echo '
    '; +}//end if ?> diff --git a/html/pages/front/traffic.php b/html/pages/front/traffic.php index 5f9a8acced..6b501cf9c1 100644 --- a/html/pages/front/traffic.php +++ b/html/pages/front/traffic.php @@ -3,200 +3,172 @@ 0) -{ - $uptimesql = " AND A.attrib_value < ?"; - $param = array($config['uptime_warning']); +$nodes = array(); +$param = array(); +$uptimesql = ''; +if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== false && $config['uptime_warning'] > 0) { + $uptimesql = ' AND A.attrib_value < ?'; + $param = array($config['uptime_warning']); } -foreach (dbFetchRows("SELECT * FROM `devices` AS D, `devices_attribs` AS A WHERE D.status = '1' AND A.device_id = D.device_id AND A.attrib_type = 'uptime' AND A.attrib_value > '0' " . $uptimesql, $param) as $device) -{ - unset($already); - $i = 0; - while ($i <= count($nodes)) { - $thisnode = $device['device_id']; - if ($nodes[$i] == $thisnode) { - $already = "yes"; +foreach (dbFetchRows("SELECT * FROM `devices` AS D, `devices_attribs` AS A WHERE D.status = '1' AND A.device_id = D.device_id AND A.attrib_type = 'uptime' AND A.attrib_value > '0' ".$uptimesql, $param) as $device) { + unset($already); + $i = 0; + while ($i <= count($nodes)) { + $thisnode = $device['device_id']; + if ($nodes[$i] == $thisnode) { + $already = 'yes'; + } + + $i++; + } + + if (!$already) { + $nodes[] = $device['device_id']; } - $i++; - } - if (!$already) { $nodes[] = $device['device_id']; } } -foreach (dbFetchRows("SELECT * FROM `devices` WHERE `status` = '0' AND `ignore` = '0'") as $device) -{ - if (device_permitted($device['device_id'])) { - echo("
    - ".generate_device_link($device, shorthost($device['hostname']))."
    - Device Down
    - ".truncate($device['location'], 35)." -
    "); - } +foreach (dbFetchRows("SELECT * FROM `devices` WHERE `status` = '0' AND `ignore` = '0'") as $device) { + if (device_permitted($device['device_id'])) { + echo "
    + ".generate_device_link($device, shorthost($device['hostname']))."
    + Device Down
    + ".truncate($device['location'], 35).' +
    '; + } } if ($config['warn']['ifdown']) { - -foreach (dbFetchRows("SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0'") as $interface) -{ - if (port_permitted($interface['port_id'])) { - echo("
    - ".generate_device_link($interface, shorthost($interface['hostname']))."
    - Port Down
    - ".generate_port_link($interface, makeshortif($interface['ifDescr']))."
    - ".truncate($interface['ifAlias'], 15)." -
    "); - } + foreach (dbFetchRows("SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0'") as $interface) { + if (port_permitted($interface['port_id'])) { + echo "
    + ".generate_device_link($interface, shorthost($interface['hostname']))."
    + Port Down
    + ".generate_port_link($interface, makeshortif($interface['ifDescr'])).'
    + '.truncate($interface['ifAlias'], 15).' +
    '; + } + } } +foreach (dbFetchRows("SELECT * FROM `services` AS S, `devices` AS D WHERE S.device_id = D.device_id AND service_status = 'down' AND D.ignore = '0' AND S.service_ignore = '0'") as $service) { + if (device_permitted($service['device_id'])) { + echo "
    + ".generate_device_link($service, shorthost($service['hostname']))."
    + Service Down
    + ".$service['service_type'].'
    + '.truncate($interface['ifAlias'], 15).' +
    '; + } } -foreach (dbFetchRows("SELECT * FROM `services` AS S, `devices` AS D WHERE S.device_id = D.device_id AND service_status = 'down' AND D.ignore = '0' AND S.service_ignore = '0'") as $service) -{ - if (device_permitted($service['device_id'])) { - echo("
    - ".generate_device_link($service, shorthost($service['hostname']))."
    - Service Down
    - ".$service['service_type']."
    - ".truncate($interface['ifAlias'], 15)." -
    "); - } +foreach (dbFetchRows("SELECT * FROM `devices` AS D, bgpPeers AS B WHERE bgpPeerAdminStatus = 'start' AND bgpPeerState != 'established' AND B.device_id = D.device_id") as $peer) { + if (device_permitted($peer['device_id'])) { + echo "
    + ".generate_device_link($peer, shorthost($peer['hostname']))."
    + BGP Down
    + ".$peer['bgpPeerIdentifier'].'
    + AS'.$peer['bgpPeerRemoteAs'].' '.truncate($peer['astext'], 10).' +
    '; + } } -foreach (dbFetchRows("SELECT * FROM `devices` AS D, bgpPeers AS B WHERE bgpPeerAdminStatus = 'start' AND bgpPeerState != 'established' AND B.device_id = D.device_id") as $peer) -{ - if (device_permitted($peer['device_id'])) { - echo("
    - ".generate_device_link($peer, shorthost($peer['hostname']))."
    - BGP Down
    - ".$peer['bgpPeerIdentifier']."
    - AS".$peer['bgpPeerRemoteAs']." ".truncate($peer['astext'], 10)." -
    "); - } +if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== false && $config['uptime_warning'] > 0) { + foreach (dbFetchRows("SELECT * FROM devices_attribs AS A, `devices` AS D WHERE A.attrib_value < ? AND A.attrib_type = 'uptime' AND A.device_id = D.device_id AND ignore = '0' AND disabled = '0'", array($config['uptime_warning'])) as $device) { + if (device_permitted($device['device_id']) && $device['attrib_value'] < $config['uptime_warning'] && $device['attrib_type'] == 'uptime') { + echo "
    + ".generate_device_link($device, shorthost($device['hostname']))."
    + Device
    Rebooted

    + ".formatUptime($device['attrib_value']).' +
    '; + } + } } -if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== FALSE && $config['uptime_warning'] > 0) -{ - foreach (dbFetchRows("SELECT * FROM devices_attribs AS A, `devices` AS D WHERE A.attrib_value < ? AND A.attrib_type = 'uptime' AND A.device_id = D.device_id AND ignore = '0' AND disabled = '0'", array($config['uptime_warning'])) as $device) { - if (device_permitted($device['device_id']) && $device['attrib_value'] < $config['uptime_warning'] && $device['attrib_type'] == "uptime") { - echo("
    - ".generate_device_link($device, shorthost($device['hostname']))."
    - Device
    Rebooted

    - ".formatUptime($device['attrib_value'])." -
    "); - } - } -} +echo " -echo(" +
    $errorboxes
    -
    $errorboxes
    +

    Recent Syslog Messages

    -

    Recent Syslog Messages

    - -"); + "; $sql = "SELECT *, DATE_FORMAT(timestamp, '".$config['dateformat']['mysql']['compact']."') AS date from syslog,devices WHERE syslog.device_id = devices.device_id ORDER BY seq DESC LIMIT 20"; -echo(""); -foreach (dbFetchRows($sql) as $entry) -{ - include("includes/print-syslog.inc.php"); +echo '
    '; +foreach (dbFetchRows($sql) as $entry) { + include 'includes/print-syslog.inc.php'; } -echo("
    "); -echo("
    +echo ''; - - "); +echo '
    + + + '; // this stuff can be customised to show whatever you want.... +if ($_SESSION['userlevel'] >= '5') { + $sql = "SELECT * FROM ports AS I, devices AS D WHERE `ifAlias` like 'Transit: %' AND I.device_id = D.device_id ORDER BY I.ifAlias"; + unset($seperator); + foreach (dbFetchRows($sql) as $interface) { + $ports['transit'] .= $seperator.$interface['port_id']; + $seperator = ','; + } -if ($_SESSION['userlevel'] >= '5') -{ + $sql = "SELECT * FROM ports AS I, devices AS D WHERE `ifAlias` like 'Peering: %' AND I.device_id = D.device_id ORDER BY I.ifAlias"; + unset($seperator); + foreach (dbFetchRows($sql) as $interface) { + $ports['peering'] .= $seperator.$interface['port_id']; + $seperator = ','; + } - $sql = "SELECT * FROM ports AS I, devices AS D WHERE `ifAlias` like 'Transit: %' AND I.device_id = D.device_id ORDER BY I.ifAlias"; - unset ($seperator); - foreach (dbFetchRows($sql) as $interface) - { - $ports['transit'] .= $seperator . $interface['port_id']; - $seperator = ","; - } + $sql = "SELECT * FROM ports AS I, devices AS D WHERE `ifAlias` like 'Core: %' AND I.device_id = D.device_id ORDER BY I.ifAlias"; + unset($seperator); + foreach (dbFetchRows($sql) as $interface) { + $ports['core'] .= $seperator.$interface['port_id']; + $seperator = ','; + } - $sql = "SELECT * FROM ports AS I, devices AS D WHERE `ifAlias` like 'Peering: %' AND I.device_id = D.device_id ORDER BY I.ifAlias"; - unset ($seperator); - foreach (dbFetchRows($sql) as $interface) - { - $ports['peering'] .= $seperator . $interface['port_id']; - $seperator = ","; - } + echo "
    "; - $sql = "SELECT * FROM ports AS I, devices AS D WHERE `ifAlias` like 'Core: %' AND I.device_id = D.device_id ORDER BY I.ifAlias"; - unset ($seperator); - foreach (dbFetchRows($sql) as $interface) - { - $ports['core'] .= $seperator . $interface['port_id']; - $seperator = ","; - } + if ($ports['peering'] && $ports['transit']) { + echo ""; + } - echo("
    "); + echo '
    '; - if ($ports['peering'] && $ports['transit']) - { - echo(""); - } + echo "
    "; - echo("
    "); + if ($ports['transit']) { + echo ""; + } - echo("
    "); + if ($ports['peering']) { + echo ""; + } - if ($ports['transit']) - { - echo(""); - } + if ($ports['core']) { + echo ""; + } - if ($ports['peering']) - { - echo(""); - } - - if ($ports['core']) - { - echo(""); - } - - echo("
    "); - -} + echo '
    '; +}//end if ?> diff --git a/html/pages/graphs.inc.php b/html/pages/graphs.inc.php index 0cc268fceb..78c6a73e09 100644 --- a/html/pages/graphs.inc.php +++ b/html/pages/graphs.inc.php @@ -4,17 +4,21 @@ unset($vars['page']); // Setup here -if($_SESSION['widescreen']) -{ - $graph_width=1700; - $thumb_width=180; -} else { - $graph_width=1075; - $thumb_width=113; +if($_SESSION['widescreen']) { + $graph_width=1700; + $thumb_width=180; +} +else { + $graph_width=1075; + $thumb_width=113; } -if (!is_numeric($vars['from'])) { $vars['from'] = $config['time']['day']; } -if (!is_numeric($vars['to'])) { $vars['to'] = $config['time']['now']; } +if (!is_numeric($vars['from'])) { + $vars['from'] = $config['time']['day']; +} +if (!is_numeric($vars['to'])) { + $vars['to'] = $config['time']['now']; +} preg_match('/^(?P[A-Za-z0-9]+)_(?P.+)/', $vars['type'], $graphtype); @@ -22,208 +26,201 @@ $type = $graphtype['type']; $subtype = $graphtype['subtype']; $id = $vars['id']; -if(is_numeric($vars['device'])) -{ - $device = device_by_id_cache($vars['device']); -} elseif(!empty($vars['device'])) { - $device = device_by_name($vars['device']); +if(is_numeric($vars['device'])) { + $device = device_by_id_cache($vars['device']); +} +elseif(!empty($vars['device'])) { + $device = device_by_name($vars['device']); } -if (is_file("includes/graphs/".$type."/auth.inc.php")) -{ - include("includes/graphs/".$type."/auth.inc.php"); +if (is_file("includes/graphs/".$type."/auth.inc.php")) { + require "includes/graphs/".$type."/auth.inc.php"; } -if (!$auth) -{ - include("includes/error-no-perm.inc.php"); -} else { - if (isset($config['graph_types'][$type][$subtype]['descr'])) - { - $title .= " :: ".$config['graph_types'][$type][$subtype]['descr']; - } else { - $title .= " :: ".ucfirst($subtype); - } +if (!$auth) { + require 'includes/error-no-perm.inc.php'; +} +else { + if (isset($config['graph_types'][$type][$subtype]['descr'])) { + $title .= " :: ".$config['graph_types'][$type][$subtype]['descr']; + } + else { + $title .= " :: ".ucfirst($subtype); + } - $graph_array = $vars; - $graph_array['height'] = "60"; - $graph_array['width'] = $thumb_width; - $graph_array['legend'] = "no"; - $graph_array['to'] = $config['time']['now']; + $graph_array = $vars; + $graph_array['height'] = "60"; + $graph_array['width'] = $thumb_width; + $graph_array['legend'] = "no"; + $graph_array['to'] = $config['time']['now']; - print_optionbar_start(); - echo($title); + print_optionbar_start(); + echo($title); - echo('
    '); - ?> + echo('
    '); +?>
    - '); +'); - print_optionbar_end(); + print_optionbar_end(); - print_optionbar_start(); + print_optionbar_start(); - $thumb_array = array('sixhour' => '6 Hours', 'day' => '24 Hours', 'twoday' => '48 Hours', 'week' => 'One Week', 'twoweek' => 'Two Weeks', - 'month' => 'One Month', 'twomonth' => 'Two Months','year' => 'One Year', 'twoyear' => 'Two Years'); + $thumb_array = array('sixhour' => '6 Hours', 'day' => '24 Hours', 'twoday' => '48 Hours', 'week' => 'One Week', 'twoweek' => 'Two Weeks', + 'month' => 'One Month', 'twomonth' => 'Two Months','year' => 'One Year', 'twoyear' => 'Two Years'); - echo(''); + echo('
    '); - foreach ($thumb_array as $period => $text) - { - $graph_array['from'] = $config['time'][$period]; + foreach ($thumb_array as $period => $text) { + $graph_array['from'] = $config['time'][$period]; - $link_array = $vars; - $link_array['from'] = $graph_array['from']; - $link_array['to'] = $graph_array['to']; - $link_array['page'] = "graphs"; - $link = generate_url($link_array); + $link_array = $vars; + $link_array['from'] = $graph_array['from']; + $link_array['to'] = $graph_array['to']; + $link_array['page'] = "graphs"; + $link = generate_url($link_array); - echo(''); + echo(''); - } + } - echo('
    '); - echo(''.$text.'
    '); - echo(''); - echo(generate_graph_tag($graph_array)); - echo(''); - echo('
    '); + echo(''.$text.'
    '); + echo(''); + echo(generate_graph_tag($graph_array)); + echo(''); + echo('
    '); + echo(''); - $graph_array = $vars; - $graph_array['height'] = "300"; - $graph_array['width'] = $graph_width; + $graph_array = $vars; + $graph_array['height'] = "300"; + $graph_array['width'] = $graph_width; - echo("
    "); + echo("
    "); - // datetime range picker + // datetime range picker ?> - "); - echo(' + echo(" +
    + "); + echo('
    - - + +
    - - + +
    -
    - '); - echo("
    "); + echo("
    "); - if ($vars['legend'] == "no") - { - echo(generate_link("Show Legend",$vars, array('page' => "graphs", 'legend' => NULL))); - } else { - echo(generate_link("Hide Legend",$vars, array('page' => "graphs", 'legend' => "no"))); - } - - // FIXME : do this properly -# if ($type == "port" && $subtype == "bits") -# { - echo(' | '); - if ($vars['previous'] == "yes") - { - echo(generate_link("Hide Previous",$vars, array('page' => "graphs", 'previous' => NULL))); - } else { - echo(generate_link("Show Previous",$vars, array('page' => "graphs", 'previous' => "yes"))); + if ($vars['legend'] == "no") { + echo(generate_link("Show Legend",$vars, array('page' => "graphs", 'legend' => NULL))); + } + else { + echo(generate_link("Hide Legend",$vars, array('page' => "graphs", 'legend' => "no"))); } -# } - echo('
    '); + // FIXME : do this properly + # if ($type == "port" && $subtype == "bits") + # { + echo(' | '); + if ($vars['previous'] == "yes") { + echo(generate_link("Hide Previous",$vars, array('page' => "graphs", 'previous' => NULL))); + } + else { + echo(generate_link("Show Previous",$vars, array('page' => "graphs", 'previous' => "yes"))); + } + # } - if ($vars['showcommand'] == "yes") - { - echo(generate_link("Hide RRD Command",$vars, array('page' => "graphs", 'showcommand' => NULL))); - } else { - echo(generate_link("Show RRD Command",$vars, array('page' => "graphs", 'showcommand' => "yes"))); - } + echo('
    '); - echo('
    '); + if ($vars['showcommand'] == "yes") { + echo(generate_link("Hide RRD Command",$vars, array('page' => "graphs", 'showcommand' => NULL))); + } + else { + echo(generate_link("Show RRD Command",$vars, array('page' => "graphs", 'showcommand' => "yes"))); + } - print_optionbar_end(); + echo('
    '); - echo generate_graph_js_state($graph_array); - - echo('
    '); - echo(generate_graph_tag($graph_array)); - echo("
    "); - - if (isset($config['graph_descr'][$vars['type']])) - { - - print_optionbar_start(); - echo('
    -
    - -
    -
    '); - echo($config['graph_descr'][$vars['type']]); print_optionbar_end(); - } - if ($vars['showcommand']) - { - $_GET = $graph_array; - $command_only = 1; + echo generate_graph_js_state($graph_array); - include("includes/graphs/graph.inc.php"); - } + echo('
    '); + echo(generate_graph_tag($graph_array)); + echo("
    "); + + if (isset($config['graph_descr'][$vars['type']])) { + + print_optionbar_start(); + echo('
    +
    + +
    +
    '); + echo($config['graph_descr'][$vars['type']]); + print_optionbar_end(); + } + + if ($vars['showcommand']) { + $_GET = $graph_array; + $command_only = 1; + + require 'includes/graphs/graph.inc.php'; + } } - -?> diff --git a/html/pages/health.inc.php b/html/pages/health.inc.php index 3b06d4db6b..eb13def9b7 100644 --- a/html/pages/health.inc.php +++ b/html/pages/health.inc.php @@ -30,8 +30,12 @@ $type_text['toner'] = "Toner"; $type_text['dbm'] = "dBm"; $type_text['load'] = "Load"; -if (!$vars['metric']) { $vars['metric'] = "processor"; } -if (!$vars['view']) { $vars['view'] = "detail"; } +if (!$vars['metric']) { + $vars['metric'] = "processor"; +} +if (!$vars['view']) { + $vars['view'] = "detail"; +} $link_array = array('page' => 'health'); @@ -42,48 +46,44 @@ print_optionbar_start('', ''); echo('Health » '); $sep = ""; -foreach ($datas as $texttype) -{ - $metric = strtolower($texttype); - echo($sep); - if ($vars['metric'] == $metric) - { - echo(""); - } +foreach ($datas as $texttype) { + $metric = strtolower($texttype); + echo($sep); + if ($vars['metric'] == $metric) { + echo(""); + } - echo(generate_link($type_text[$metric],$link_array,array('metric'=> $metric, 'view' => $vars['view']))); + echo(generate_link($type_text[$metric],$link_array,array('metric'=> $metric, 'view' => $vars['view']))); - if ($vars['metric'] == $metric) { echo(""); } + if ($vars['metric'] == $metric) { + echo(""); + } - $sep = ' | '; + $sep = ' | '; } unset ($sep); echo('
    '); -if ($vars['view'] == "graphs") -{ - echo(''); +if ($vars['view'] == "graphs") { + echo(''); } echo(generate_link("Graphs",$link_array,array('metric'=> $vars['metric'], 'view' => "graphs"))); -if ($vars['view'] == "graphs") -{ - echo(''); +if ($vars['view'] == "graphs") { + echo(''); } echo(' | '); -if ($vars['view'] != "graphs") -{ - echo(''); +if ($vars['view'] != "graphs") { + echo(''); } echo(generate_link("No Graphs",$link_array,array('metric'=> $vars['metric'], 'view' => "detail"))); -if ($vars['view'] != "graphs") -{ - echo(''); +if ($vars['view'] != "graphs") { + echo(''); } echo('
    '); @@ -91,16 +91,14 @@ echo('
    '); print_optionbar_end(); if (in_array($vars['metric'],array_keys($used_sensors)) - || $vars['metric'] == 'processor' - || $vars['metric'] == 'storage' - || $vars['metric'] == 'toner' - || $vars['metric'] == 'mempool') -{ - include('pages/health/'.$vars['metric'].'.inc.php'); + || $vars['metric'] == 'processor' + || $vars['metric'] == 'storage' + || $vars['metric'] == 'toner' + || $vars['metric'] == 'mempool') { + include('pages/health/'.$vars['metric'].'.inc.php'); } -else -{ - echo("No sensors of type " . $vars['metric'] . " found."); +else { + echo("No sensors of type " . $vars['metric'] . " found."); } ?> diff --git a/html/pages/health/charge.inc.php b/html/pages/health/charge.inc.php index 867b50f9e8..3838d0e790 100644 --- a/html/pages/health/charge.inc.php +++ b/html/pages/health/charge.inc.php @@ -4,6 +4,4 @@ $graph_type = "sensor_charge"; $unit = "%"; $class = "charge"; -include("pages/health/sensors.inc.php"); - -?> +require 'pages/health/sensors.inc.php'; diff --git a/html/pages/health/load.inc.php b/html/pages/health/load.inc.php index d9257519d3..f506e3ca1d 100644 --- a/html/pages/health/load.inc.php +++ b/html/pages/health/load.inc.php @@ -1,9 +1,7 @@ +require 'pages/health/sensors.inc.php'; diff --git a/html/pages/health/sensors.inc.php b/html/pages/health/sensors.inc.php index 02224d485c..52828b9c19 100644 --- a/html/pages/health/sensors.inc.php +++ b/html/pages/health/sensors.inc.php @@ -1,19 +1,18 @@ = '5') -{ - $sql = "SELECT * FROM `sensors` AS S, `devices` AS D WHERE S.sensor_class='".$class."' AND S.device_id = D.device_id ORDER BY D.hostname, S.sensor_descr"; - $param = array(); -} else { - $sql = "SELECT * FROM `sensors` AS S, `devices` AS D, devices_perms as P WHERE S.sensor_class='".$class."' AND S.device_id = D.device_id AND D.device_id = P.device_id AND P.user_id = ? ORDER BY D.hostname, S.sensor_descr"; - $param = array($_SESSION['user_id']); +if ($_SESSION['userlevel'] >= '5') { + $sql = "SELECT * FROM `sensors` AS S, `devices` AS D WHERE S.sensor_class='".$class."' AND S.device_id = D.device_id ORDER BY D.hostname, S.sensor_descr"; + $param = array(); +} +else { + $sql = "SELECT * FROM `sensors` AS S, `devices` AS D, devices_perms as P WHERE S.sensor_class='".$class."' AND S.device_id = D.device_id AND D.device_id = P.device_id AND P.user_id = ? ORDER BY D.hostname, S.sensor_descr"; + $param = array($_SESSION['user_id']); } -echo(''); +echo '
    '; -echo(' +echo ' @@ -21,99 +20,102 @@ echo(' - '); + '; -foreach (dbFetchRows($sql, $param) as $sensor) -{ +foreach (dbFetchRows($sql, $param) as $sensor) { + if ($config['memcached']['enable'] === true) { + $sensor['sensor_current'] = $memcache->get('sensor-'.$sensor['sensor_id'].'-value'); + if ($debug) { + echo 'Memcached['.'sensor-'.$sensor['sensor_id'].'-value'.'='.$sensor['sensor_current'].']'; + } + } - if ($config['memcached']['enable'] === TRUE) - { - $sensor['sensor_current'] = $memcache->get('sensor-'.$sensor['sensor_id'].'-value'); - if($debug) { echo("Memcached[".'sensor-'.$sensor['sensor_id'].'-value'."=".$sensor['sensor_current']."]"); } - } - - if (empty($sensor['sensor_current'])) - { - $sensor['sensor_current'] = "NaN"; - } else { - if ($sensor['sensor_current'] >= $sensor['sensor_limit']) { $alert = 'alert'; } else { $alert = ""; } - } + if (empty($sensor['sensor_current'])) { + $sensor['sensor_current'] = 'NaN'; + } + else { + if ($sensor['sensor_current'] >= $sensor['sensor_limit']) { + $alert = 'alert'; + } + else { + $alert = ''; + } + } // FIXME - make this "four graphs in popup" a function/include and "small graph" a function. // FIXME - So now we need to clean this up and move it into a function. Isn't it just "print-graphrow"? // FIXME - DUPLICATED IN device/overview/sensors - - $graph_colour = str_replace("#", "", $row_colour); + $graph_colour = str_replace('#', '', $row_colour); $graph_array = array(); - $graph_array['height'] = "100"; - $graph_array['width'] = "210"; + $graph_array['height'] = '100'; + $graph_array['width'] = '210'; $graph_array['to'] = $config['time']['now']; $graph_array['id'] = $sensor['sensor_id']; $graph_array['type'] = $graph_type; $graph_array['from'] = $config['time']['day']; - $graph_array['legend'] = "no"; + $graph_array['legend'] = 'no'; - $link_array = $graph_array; - $link_array['page'] = "graphs"; + $link_array = $graph_array; + $link_array['page'] = 'graphs'; unset($link_array['height'], $link_array['width'], $link_array['legend']); $link_graph = generate_url($link_array); - $link = generate_url(array("page" => "device", "device" => $sensor['device_id'], "tab" => "health", "metric" => $sensor['sensor_class'])); + $link = generate_url(array('page' => 'device', 'device' => $sensor['device_id'], 'tab' => 'health', 'metric' => $sensor['sensor_class'])); - $overlib_content = '

    '.$device['hostname']." - ".$sensor['sensor_descr']."

    "; - foreach (array('day','week','month','year') as $period) - { - $graph_array['from'] = $config['time'][$period]; - $overlib_content .= str_replace('"', "\'", generate_graph_tag($graph_array)); + $overlib_content = '

    '.$device['hostname'].' - '.$sensor['sensor_descr'].'

    '; + foreach (array('day', 'week', 'month', 'year') as $period) { + $graph_array['from'] = $config['time'][$period]; + $overlib_content .= str_replace('"', "\'", generate_graph_tag($graph_array)); } - $overlib_content .= "
    "; - $graph_array['width'] = 80; $graph_array['height'] = 20; $graph_array['bg'] = 'ffffff00'; # the 00 at the end makes the area transparent. + $overlib_content .= '
    '; + + $graph_array['width'] = 80; + $graph_array['height'] = 20; + $graph_array['bg'] = 'ffffff00'; + // the 00 at the end makes the area transparent. $graph_array['from'] = $config['time']['day']; - $sensor_minigraph = generate_graph_tag($graph_array); + $sensor_minigraph = generate_graph_tag($graph_array); $sensor['sensor_descr'] = truncate($sensor['sensor_descr'], 48, ''); - echo(' - - + echo ' + + - - - + + + - '); + '; - if ($vars['view'] == "graphs") - { - echo(""); - } # endif graphs -} + echo "', LEFT);\" onmouseout=\"return nd();\"> + "; + echo "', LEFT);\" onmouseout=\"return nd();\"> + "; + echo "', LEFT);\" onmouseout=\"return nd();\"> + "; + echo "', LEFT);\" onmouseout=\"return nd();\"> + "; + echo ''; + } //end if +}//end foreach -echo("
    Device Sensor
    Current Range limit Notes
    ' . generate_device_link($sensor) . ''.overlib_link($link, $sensor['sensor_descr'],$overlib_content).'
    '.generate_device_link($sensor).''.overlib_link($link, $sensor['sensor_descr'], $overlib_content).' '.overlib_link($link_graph, $sensor_minigraph, $overlib_content).' '.$alert.'' . $sensor['sensor_current'] . $unit . '' . round($sensor['sensor_limit_low'],2) . $unit . ' - ' . round($sensor['sensor_limit'],2) . $unit . '' . (isset($sensor['sensor_notes']) ? $sensor['sensor_notes'] : '') . ''.$sensor['sensor_current'].$unit.''.round($sensor['sensor_limit_low'], 2).$unit.' - '.round($sensor['sensor_limit'], 2).$unit.''.(isset($sensor['sensor_notes']) ? $sensor['sensor_notes'] : '').'
    "); + if ($vars['view'] == 'graphs') { + echo "
    "; - $daily_graph = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=".$config['time']['day']."&to=".$config['time']['now']."&width=211&height=100"; - $daily_url = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=".$config['time']['day']."&to=".$config['time']['now']."&width=400&height=150"; + $daily_graph = 'graph.php?id='.$sensor['sensor_id'].'&type='.$graph_type.'&from='.$config['time']['day'].'&to='.$config['time']['now'].'&width=211&height=100'; + $daily_url = 'graph.php?id='.$sensor['sensor_id'].'&type='.$graph_type.'&from='.$config['time']['day'].'&to='.$config['time']['now'].'&width=400&height=150'; - $weekly_graph = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=".$config['time']['week']."&to=".$config['time']['now']."&width=211&height=100"; - $weekly_url = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=".$config['time']['week']."&to=".$config['time']['now']."&width=400&height=150"; + $weekly_graph = 'graph.php?id='.$sensor['sensor_id'].'&type='.$graph_type.'&from='.$config['time']['week'].'&to='.$config['time']['now'].'&width=211&height=100'; + $weekly_url = 'graph.php?id='.$sensor['sensor_id'].'&type='.$graph_type.'&from='.$config['time']['week'].'&to='.$config['time']['now'].'&width=400&height=150'; - $monthly_graph = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=".$config['time']['month']."&to=".$config['time']['now']."&width=211&height=100"; - $monthly_url = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=".$config['time']['month']."&to=".$config['time']['now']."&width=400&height=150"; + $monthly_graph = 'graph.php?id='.$sensor['sensor_id'].'&type='.$graph_type.'&from='.$config['time']['month'].'&to='.$config['time']['now'].'&width=211&height=100'; + $monthly_url = 'graph.php?id='.$sensor['sensor_id'].'&type='.$graph_type.'&from='.$config['time']['month'].'&to='.$config['time']['now'].'&width=400&height=150'; - $yearly_graph = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=".$config['time']['year']."&to=".$config['time']['now']."&width=211&height=100"; - $yearly_url = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=".$config['time']['year']."&to=".$config['time']['now']."&width=400&height=150"; + $yearly_graph = 'graph.php?id='.$sensor['sensor_id'].'&type='.$graph_type.'&from='.$config['time']['year'].'&to='.$config['time']['now'].'&width=211&height=100'; + $yearly_url = 'graph.php?id='.$sensor['sensor_id'].'&type='.$graph_type.'&from='.$config['time']['year'].'&to='.$config['time']['now'].'&width=400&height=150'; - echo("', LEFT);\" onmouseout=\"return nd();\"> - "); - echo("', LEFT);\" onmouseout=\"return nd();\"> - "); - echo("', LEFT);\" onmouseout=\"return nd();\"> - "); - echo("', LEFT);\" onmouseout=\"return nd();\"> - "); - echo("
    "); - -?> +echo ''; diff --git a/html/pages/iftype.inc.php b/html/pages/iftype.inc.php index f4349111cd..8a6d20201b 100644 --- a/html/pages/iftype.inc.php +++ b/html/pages/iftype.inc.php @@ -9,92 +9,102 @@ - Total Graph for ports of type : ".$types."
    "); - -if ($if_list) -{ - $graph_type = "multiport_bits_separate"; - $port['port_id'] = $if_list; - - include("includes/print-interface-graphs.inc.php"); - - echo(""); - - foreach ($ports as $port) - { - $done = "yes"; - unset($class); - $port['ifAlias'] = str_ireplace($type . ": ", "", $port['ifAlias']); - $port['ifAlias'] = str_ireplace("[PNI]", "Private", $port['ifAlias']); - $ifclass = ifclass($port['ifOperStatus'], $port['ifAdminStatus']); - if ($bg == "#ffffff") { $bg = "#e5e5e5"; } else { $bg = "#ffffff"; } - echo(" - " . generate_port_link($port,$port['port_descr_descr']) . "
    - ".generate_device_link($port)." ".generate_port_link($port)." - ".generate_port_link($port, makeshortif($port['ifDescr']))." - ".$port['port_descr_speed']." - ".$port['port_descr_circuit']." - ".$port['port_descr_notes']." - - - MAC Accounting"); - } - - echo('
    '); - - if (file_exists($config['rrd_dir'] . "/" . $port['hostname'] . "/port-" . $port['ifIndex'] . ".rrd")) - { - $graph_type = "port_bits"; - - include("includes/print-interface-graphs.inc.php"); - } - - echo(""); - } - +$types_array = explode(',', $vars['type']); +for ($i = 0; $i < count($types_array); +$i++) { + $types_array[$i] = ucfirst($types_array[$i]); } -else -{ - echo("None found."); + +$types = implode(' + ', $types_array); + +echo " + Total Graph for ports of type : ".$types.'
    '; + +if ($if_list) { + $graph_type = 'multiport_bits_separate'; + $port['port_id'] = $if_list; + + include 'includes/print-interface-graphs.inc.php'; + + echo ''; + + foreach ($ports as $port) { + $done = 'yes'; + unset($class); + $port['ifAlias'] = str_ireplace($type.': ', '', $port['ifAlias']); + $port['ifAlias'] = str_ireplace('[PNI]', 'Private', $port['ifAlias']); + $ifclass = ifclass($port['ifOperStatus'], $port['ifAdminStatus']); + if ($bg == '#ffffff') { + $bg = '#e5e5e5'; + } + else { + $bg = '#ffffff'; + } + + echo " + ".generate_port_link($port, $port['port_descr_descr'])."
    + ".generate_device_link($port).' '.generate_port_link($port).' + '.generate_port_link($port, makeshortif($port['ifDescr'])).' + '.$port['port_descr_speed'].' + '.$port['port_descr_circuit'].' + '.$port['port_descr_notes']." + + + MAC Accounting"; + } + + echo '
    '; + + if (file_exists($config['rrd_dir'].'/'.$port['hostname'].'/port-'.$port['ifIndex'].'.rrd')) { + $graph_type = 'port_bits'; + + include 'includes/print-interface-graphs.inc.php'; + } + + echo ''; + } +} +else { + echo 'None found.'; } ?> diff --git a/html/pages/inventory.inc.php b/html/pages/inventory.inc.php index e53daab965..7fc461e4aa 100644 --- a/html/pages/inventory.inc.php +++ b/html/pages/inventory.inc.php @@ -1,6 +1,6 @@ @@ -29,46 +29,53 @@ var grid = $("#inventory").bootgrid({ header: "
    "+ "
    "+ "
    "+ - "\" placeholder=\"Description\" class=\"form-control input-sm\" />"+ + "\" placeholder=\"Description\" class=\"form-control input-sm\" />"+ "
    "+ "
    "+ " Part No "+ ""+ "
    "+ "
    "+ - "\" placeholder=\"Serial\" class=\"form-control input-sm\"/>"+ + "\" placeholder=\"Serial\" class=\"form-control input-sm\"/>"+ "
    "+ "
    "+ " Device "+ ""+ "
    "+ "
    "+ - "\" placeholder=\"Description\" class=\"form-control input-sm\"/>"+ + " +\" placeholder=\"Description\" class=\"form-control input-sm\"/>"+ "
    "+ ""+ "
    "+ diff --git a/html/pages/locations.inc.php b/html/pages/locations.inc.php index 93dffa0e36..bbe6adcf99 100644 --- a/html/pages/locations.inc.php +++ b/html/pages/locations.inc.php @@ -1,88 +1,92 @@ Locations » '); +echo 'Locations » '; -$menu_options = array('basic' => 'Basic', - 'traffic' => 'Traffic'); +$menu_options = array( + 'basic' => 'Basic', + 'traffic' => 'Traffic', +); -if (!$vars['view']) { $vars['view'] = "basic"; } +if (!$vars['view']) { + $vars['view'] = 'basic'; +} -$sep = ""; -foreach ($menu_options as $option => $text) -{ - echo($sep); - if ($vars['view'] == $option) - { - echo(""); - } - echo('' . $text . ''); - if ($vars['view'] == $option) - { - echo(""); - } - $sep = " | "; +$sep = ''; +foreach ($menu_options as $option => $text) { + echo $sep; + if ($vars['view'] == $option) { + echo ""; + } + + echo ''.$text.''; + if ($vars['view'] == $option) { + echo ''; + } + + $sep = ' | '; } unset($sep); print_optionbar_end(); -echo(''); +echo '
    '; -foreach (getlocations() as $location) -{ - if ($_SESSION['userlevel'] >= '10') - { - $num = dbFetchCell("SELECT COUNT(device_id) FROM devices WHERE location = ?", array($location)); - $net = dbFetchCell("SELECT COUNT(device_id) FROM devices WHERE location = ? AND type = 'network'", array($location)); - $srv = dbFetchCell("SELECT COUNT(device_id) FROM devices WHERE location = ? AND type = 'server'", array($location)); - $fwl = dbFetchCell("SELECT COUNT(device_id) FROM devices WHERE location = ? AND type = 'firewall'", array($location)); - $hostalerts = dbFetchCell("SELECT COUNT(device_id) FROM devices WHERE location = ? AND status = '0'", array($location)); - } else { - $num = dbFetchCell("SELECT COUNT(D.device_id) FROM devices AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = ? AND location = ?", array($_SESSION['user_id'], $location)); - $net = dbFetchCell("SELECT COUNT(D.device_id) FROM devices AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = ? AND location = ? AND D.type = 'network'", array($_SESSION['user_id'], $location)); - $srv = dbFetchCell("SELECT COUNT(D.device_id) FROM devices AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = ? AND location = ? AND type = 'server'", array($_SESSION['user_id'], $location)); - $fwl = dbFetchCell("SELECT COUNT(D.device_id) FROM devices AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = ? AND location = ? AND type = 'firewall'", array($_SESSION['user_id'], $location)); - $hostalerts = dbFetchCell("SELECT COUNT(device_id) FROM devices AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = ? AND location = ? AND status = '0'", array($_SESSION['user_id'], $location)); - } - - if ($hostalerts) { $alert = 'alert'; } else { $alert = ""; } - - if ($location != "") - { - echo(' - - - - - - - - '); - - if ($vars['view'] == "traffic") - { - echo('"); +foreach (getlocations() as $location) { + if ($_SESSION['userlevel'] >= '10') { + $num = dbFetchCell('SELECT COUNT(device_id) FROM devices WHERE location = ?', array($location)); + $net = dbFetchCell("SELECT COUNT(device_id) FROM devices WHERE location = ? AND type = 'network'", array($location)); + $srv = dbFetchCell("SELECT COUNT(device_id) FROM devices WHERE location = ? AND type = 'server'", array($location)); + $fwl = dbFetchCell("SELECT COUNT(device_id) FROM devices WHERE location = ? AND type = 'firewall'", array($location)); + $hostalerts = dbFetchCell("SELECT COUNT(device_id) FROM devices WHERE location = ? AND status = '0'", array($location)); + } + else { + $num = dbFetchCell('SELECT COUNT(D.device_id) FROM devices AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = ? AND location = ?', array($_SESSION['user_id'], $location)); + $net = dbFetchCell("SELECT COUNT(D.device_id) FROM devices AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = ? AND location = ? AND D.type = 'network'", array($_SESSION['user_id'], $location)); + $srv = dbFetchCell("SELECT COUNT(D.device_id) FROM devices AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = ? AND location = ? AND type = 'server'", array($_SESSION['user_id'], $location)); + $fwl = dbFetchCell("SELECT COUNT(D.device_id) FROM devices AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = ? AND location = ? AND type = 'firewall'", array($_SESSION['user_id'], $location)); + $hostalerts = dbFetchCell("SELECT COUNT(device_id) FROM devices AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = ? AND location = ? AND status = '0'", array($_SESSION['user_id'], $location)); } - $done = "yes"; - } -} -echo("
    ' . $location . '' . $alert . '' . $num . ' devices' . $net . ' network' . $srv . ' servers' . $fwl . ' firewalls
    '); - - $graph_array['type'] = "location_bits"; - $graph_array['height'] = "100"; - $graph_array['width'] = "220"; - $graph_array['to'] = $config['time']['now']; - $graph_array['legend'] = "no"; - $graph_array['id'] = $location; - - include("includes/print-graphrow.inc.php"); - - echo("
    "); + if ($hostalerts) { + $alert = 'alert'; + } + else { + $alert = ''; + } -?> + if ($location != '') { + echo ' + '.$location.' + '.$alert.' + '.$num.' devices + '.$net.' network + '.$srv.' servers + '.$fwl.' firewalls + + '; + + if ($vars['view'] == 'traffic') { + echo ''; + + $graph_array['type'] = 'location_bits'; + $graph_array['height'] = '100'; + $graph_array['width'] = '220'; + $graph_array['to'] = $config['time']['now']; + $graph_array['legend'] = 'no'; + $graph_array['id'] = $location; + + include 'includes/print-graphrow.inc.php'; + + echo ''; + } + + $done = 'yes'; + }//end if +}//end foreach + +echo ''; diff --git a/html/pages/logon.inc.php b/html/pages/logon.inc.php index e9819b1b01..a8a156574d 100644 --- a/html/pages/logon.inc.php +++ b/html/pages/logon.inc.php @@ -1,7 +1,8 @@
    @@ -32,14 +33,12 @@ if( $config['twofactor'] && isset($twofactorform) ) {
    'error','message'=>$auth_message,'title'=>'Login error'); } ?>
    diff --git a/html/pages/map.inc.php b/html/pages/map.inc.php index 0fa1cbb5f7..115c0600c3 100644 --- a/html/pages/map.inc.php +++ b/html/pages/map.inc.php @@ -10,6 +10,5 @@ * option) any later version. Please see LICENSE.txt at the top level of * the source code distribution for details. */ -$pagetitle[] = "Map"; -require_once "includes/print-map.inc.php"; -?> +$pagetitle[] = 'Map'; +require_once 'includes/print-map.inc.php'; diff --git a/html/pages/packages.inc.php b/html/pages/packages.inc.php index c3e79c8cf6..ab26fd00a9 100644 --- a/html/pages/packages.inc.php +++ b/html/pages/packages.inc.php @@ -2,8 +2,7 @@ foreach ($vars as $var => $value) { if ($value != '') { - switch ($var) - { + switch ($var) { case 'name': $where .= " AND `$var` = ?"; $param[] = $value; @@ -26,8 +25,7 @@ foreach (dbFetchRows("SELECT * FROM `packages` WHERE 1 $where GROUP BY `name`", foreach ($entry['blah'] as $version => $bleu) { $content = '
    '; - foreach ($bleu as $build => $bloo) - { + foreach ($bleu as $build => $bloo) { if ($build) { $dbuild = '-'.$build; } @@ -36,8 +34,7 @@ foreach (dbFetchRows("SELECT * FROM `packages` WHERE 1 $where GROUP BY `name`", } $content .= '
    '.$version.$dbuild.''; - foreach ($bloo as $device_id => $no) - { + foreach ($bloo as $device_id => $no) { $this_device = device_by_id_cache($device_id); $content .= ''.$this_device['hostname'].' '; } diff --git a/html/pages/plugin.inc.php b/html/pages/plugin.inc.php index daec96f46b..1f718acff2 100644 --- a/html/pages/plugin.inc.php +++ b/html/pages/plugin.inc.php @@ -1,24 +1,18 @@ 'plugin'); +$link_array = array('page' => 'plugin'); -$pagetitle[] = "Plugin"; +$pagetitle[] = 'Plugin'; -if ($vars['view'] == "admin") -{ - include_once('pages/plugin/admin.inc.php'); +if ($vars['view'] == 'admin') { + include_once 'pages/plugin/admin.inc.php'; } -else -{ - $plugin = dbFetchRow("SELECT `plugin_name` FROM `plugins` WHERE `plugin_name` = '".$vars['p']."' AND `plugin_active`='1'"); - if(!empty($plugin)) - { - require('plugins/'.$plugin['plugin_name'].'/'.$plugin['plugin_name'].'.inc.php'); - } - else - { - print_error( "This plugin is either disabled or not available." ); - } +else { + $plugin = dbFetchRow("SELECT `plugin_name` FROM `plugins` WHERE `plugin_name` = '".$vars['p']."' AND `plugin_active`='1'"); + if (!empty($plugin)) { + include 'plugins/'.$plugin['plugin_name'].'/'.$plugin['plugin_name'].'.inc.php'; + } + else { + print_error('This plugin is either disabled or not available.'); + } } - -?> diff --git a/html/pages/plugin/admin.inc.php b/html/pages/plugin/admin.inc.php index 1773d641d8..e20bec1b64 100644 --- a/html/pages/plugin/admin.inc.php +++ b/html/pages/plugin/admin.inc.php @@ -1,33 +1,26 @@ = '10') -{ - - // Scan for new plugins and add to the database - $new_plugins = scan_new_plugins(); +if ($_SESSION['userlevel'] >= '10') { + // Scan for new plugins and add to the database + $new_plugins = scan_new_plugins(); - // Check if we have to toggle enabled / disable a particular module - $plugin_id = $_POST['plugin_id']; - $plugin_active = $_POST['plugin_active']; - if(is_numeric($plugin_id) && is_numeric($plugin_active)) - { - if( $plugin_active == '0') - { - $plugin_active = 1; - } - elseif( $plugin_active == '1') - { - $plugin_active = 0; - } - else - { - $plugin_active = 0; - } + // Check if we have to toggle enabled / disable a particular module + $plugin_id = $_POST['plugin_id']; + $plugin_active = $_POST['plugin_active']; + if (is_numeric($plugin_id) && is_numeric($plugin_active)) { + if ($plugin_active == '0') { + $plugin_active = 1; + } + else if ($plugin_active == '1') { + $plugin_active = 0; + } + else { + $plugin_active = 0; + } - if(dbUpdate(array('plugin_active' => $plugin_active), 'plugins', '`plugin_id` = ?', array($plugin_id))) - { - echo(' + if (dbUpdate(array('plugin_active' => $plugin_active), 'plugins', '`plugin_id` = ?', array($plugin_id))) { + echo ' -'); - } - - } +'; + } + }//end if ?> @@ -49,14 +41,13 @@ $.ajax({ System plugins
    0) - { - echo('
    +if ($new_plugins > 0) { + echo '
    - We have found ' . $new_plugins . ' new plugins that need to be configured and enabled + We have found '.$new_plugins.' new plugins that need to be configured and enabled
    -
    '); - } +
    '; +} ?> @@ -65,24 +56,21 @@ $.ajax({ + echo ' - '); - } - + '; +}//end foreach ?>
    - '. $plugins['plugin_name'] . ' + '.$plugins['plugin_name'].' @@ -91,18 +79,14 @@ $.ajax({
    +else { + include 'includes/error-no-perm.inc.php'; +}//end if diff --git a/html/pages/poll-log.inc.php b/html/pages/poll-log.inc.php index 3abdf05a8e..91ef8132e2 100644 --- a/html/pages/poll-log.inc.php +++ b/html/pages/poll-log.inc.php @@ -1,5 +1,5 @@ diff --git a/html/pages/pollers.inc.php b/html/pages/pollers.inc.php index de85c2344c..3fef3d931c 100644 --- a/html/pages/pollers.inc.php +++ b/html/pages/pollers.inc.php @@ -12,25 +12,32 @@ * the source code distribution for details. */ -$no_refresh = TRUE; +$no_refresh = true; -echo(''; if (isset($vars['tab'])) { - require_once "pages/pollers/".mres($vars['tab']).".inc.php"; + include_once 'pages/pollers/'.mres($vars['tab']).'.inc.php'; } diff --git a/html/pages/pollers/groups.inc.php b/html/pages/pollers/groups.inc.php index 50019dfc26..a914650ae2 100644 --- a/html/pages/pollers/groups.inc.php +++ b/html/pages/pollers/groups.inc.php @@ -12,7 +12,7 @@ * the source code distribution for details. */ -require_once "includes/modal/poller_groups.inc.php"; +require_once 'includes/modal/poller_groups.inc.php'; ?>
    @@ -28,18 +28,17 @@ require_once "includes/modal/poller_groups.inc.php"; + echo ' + -'); +'; } ?> diff --git a/html/pages/pollers/pollers.inc.php b/html/pages/pollers/pollers.inc.php index c5e0eb2799..f948d3a8b1 100644 --- a/html/pages/pollers/pollers.inc.php +++ b/html/pages/pollers/pollers.inc.php @@ -24,26 +24,28 @@ = 300) { $row_class = 'danger'; - } elseif ($old >= 280 && $old < 300) { + } + else if ($old >= 280 && $old < 300) { $row_class = 'warning'; - } else { + } + else { $row_class = 'success'; } - echo(' + + echo ' -'); +'; } ?> diff --git a/html/pages/ports.inc.php b/html/pages/ports.inc.php index 8ff1f7d344..edeea9fbef 100644 --- a/html/pages/ports.inc.php +++ b/html/pages/ports.inc.php @@ -4,29 +4,27 @@ $pagetitle[] = "Ports"; // Set Defaults here -if(!isset($vars['format'])) { $vars['format'] = "list_basic"; } +if(!isset($vars['format'])) { + $vars['format'] = "list_basic"; +} print_optionbar_start(); echo('Lists » '); -$menu_options = array('basic' => 'Basic', - 'detail' => 'Detail'); +$menu_options = array('basic' => 'Basic', 'detail' => 'Detail'); $sep = ""; -foreach ($menu_options as $option => $text) -{ - echo($sep); - if ($vars['format'] == "list_".$option) - { - echo(""); - } - echo('' . $text . ''); - if ($vars['format'] == "list_".$option) - { - echo(""); - } - $sep = " | "; +foreach ($menu_options as $option => $text) { + echo($sep); + if ($vars['format'] == "list_".$option) { + echo(""); + } + echo('' . $text . ''); + if ($vars['format'] == "list_".$option) { + echo(""); + } + $sep = " | "; } ?> @@ -37,24 +35,21 @@ foreach ($menu_options as $option => $text) 'Bits', - 'upkts' => 'Unicast Packets', - 'nupkts' => 'Non-Unicast Packets', - 'errors' => 'Errors'); + 'upkts' => 'Unicast Packets', + 'nupkts' => 'Non-Unicast Packets', + 'errors' => 'Errors'); $sep = ""; -foreach ($menu_options as $option => $text) -{ - echo($sep); - if ($vars['format'] == 'graph_'.$option) - { - echo(''); - } - echo('' . $text . ''); - if ($vars['format'] == 'graph_'.$option) - { - echo(""); - } - $sep = " | "; +foreach ($menu_options as $option => $text) { + echo($sep); + if ($vars['format'] == 'graph_'.$option) { + echo(''); + } + echo('' . $text . ''); + if ($vars['format'] == 'graph_'.$option) { + echo(""); + } + $sep = " | "; } echo('
    '); @@ -64,29 +59,28 @@ echo('
    '); Update URL | '')).'">Search'); - } else { +} +else { echo('Search'); - } +} - echo(" | "); +echo(" | "); - if (isset($vars['bare']) && $vars['bare'] == "yes") - { +if (isset($vars['bare']) && $vars['bare'] == "yes") { echo('Header'); - } else { +} +else { echo('Header'); - } +} echo('
    '); print_optionbar_end(); print_optionbar_start(); -if((isset($vars['searchbar']) && $vars['searchbar'] != "hide") || !isset($vars['searchbar'])) -{ +if((isset($vars['searchbar']) && $vars['searchbar'] != "hide") || !isset($vars['searchbar'])) { ?>
    @@ -95,67 +89,66 @@ if((isset($vars['searchbar']) && $vars['searchbar'] != "hide") || !isset($vars[' = 5) -{ - $results = dbFetchRows("SELECT `device_id`,`hostname` FROM `devices` GROUP BY `hostname` ORDER BY `hostname`"); -} -else -{ - $results = dbFetchRows("SELECT `D`.`device_id`,`D`.`hostname` FROM `devices` AS `D`, `devices_perms` AS `P` WHERE `P`.`user_id` = ? AND `P`.`device_id` = `D`.`device_id` GROUP BY `hostname` ORDER BY `hostname`", array($_SESSION['user_id'])); -} -foreach ($results as $data) -{ - echo(' "); -} + if($_SESSION['userlevel'] >= 5) { + $results = dbFetchRows("SELECT `device_id`,`hostname` FROM `devices` GROUP BY `hostname` ORDER BY `hostname`"); + } + else { + $results = dbFetchRows("SELECT `D`.`device_id`,`D`.`hostname` FROM `devices` AS `D`, `devices_perms` AS `P` WHERE `P`.`user_id` = ? AND `P`.`device_id` = `D`.`device_id` GROUP BY `hostname` ORDER BY `hostname`", array($_SESSION['user_id'])); + } + foreach ($results as $data) { + echo(' "); + } -if($_SESSION['userlevel'] < 5) -{ - $results = dbFetchRows("SELECT `D`.`device_id`,`D`.`hostname` FROM `ports` AS `I` JOIN `devices` AS `D` ON `D`.`device_id`=`I`.`device_id` JOIN `ports_perms` AS `PP` ON `PP`.`port_id`=`I`.`port_id` WHERE `PP`.`user_id` = ? AND `PP`.`port_id` = `I`.`port_id` GROUP BY `hostname` ORDER BY `hostname`", array($_SESSION['user_id'])); -} -else -{ - $results = array(); -} -foreach ($results as $data) -{ - echo(' "); -} + if($_SESSION['userlevel'] < 5) { + $results = dbFetchRows("SELECT `D`.`device_id`,`D`.`hostname` FROM `ports` AS `I` JOIN `devices` AS `D` ON `D`.`device_id`=`I`.`device_id` JOIN `ports_perms` AS `PP` ON `PP`.`port_id`=`I`.`port_id` WHERE `PP`.`user_id` = ? AND `PP`.`port_id` = `I`.`port_id` GROUP BY `hostname` ORDER BY `hostname`", array($_SESSION['user_id'])); + } + else { + $results = array(); + } + foreach ($results as $data) { + echo(' "); + } ?> - placeholder="Hostname" /> + placeholder="Hostname" />
    @@ -164,97 +157,100 @@ foreach (dbFetchRows($sql,$param) as $data) ".$data['ifType'].""); - } -} + if (is_admin() === TRUE || is_read() === TRUE) { + $sql = "SELECT `ifType` FROM `ports` GROUP BY `ifType` ORDER BY `ifType`"; + } + else { + $sql = "SELECT `ifType` FROM `ports` AS `I`, `devices` AS `D`, `devices_perms` AS `P`, `ports_perms` AS `PP` WHERE ((`P`.`user_id` = ? AND `P`.`device_id` = `D`.`device_id`) OR (`PP`.`user_id` = ? AND `PP`.`port_id` = `I`.`port_id` AND `I`.`device_id` = `D`.`device_id`)) AND `D`.`device_id` = `I`.`device_id` GROUP BY `ifType` ORDER BY `ifType`"; + $param[] = array($_SESSION['user_id'],$_SESSION['user_id']); + } + foreach (dbFetchRows($sql,$param) as $data) { + if ($data['ifType']) { + echo(' "); + } + } ?>
    - placeholder="Port Description"/> + placeholder="Port Description"/>
    - > + > - > + > - > + >
    @@ -266,95 +262,98 @@ foreach ($sorts as $sort => $sort_text)
    '.$group['id'].' '.$group['group_name'].' '.$group['descr'].'
    '.$poller['poller_name'].' '.$poller['devices'].' '.$poller['time_taken'].' Seconds '.$poller['last_polled'].'
    - $value) -{ - if ($value != "") - { - switch ($var) - { - case 'hostname': - $where .= " AND D.hostname LIKE ?"; - $param[] = "%".$value."%"; - break; - case 'location': - $where .= " AND D.location LIKE ?"; - $param[] = "%".$value."%"; - break; - case 'device_id': - $where .= " AND D.device_id = ?"; - $param[] = $value; - break; - case 'deleted': - if ($value == 1) { - $where .= " AND `I`.`deleted` = 1"; - $ignore_filter = 1; +foreach ($vars as $var => $value) { + if ($value != "") { + switch ($var) { + case 'hostname': + $where .= " AND D.hostname LIKE ?"; + $param[] = "%".$value."%"; + break; + case 'location': + $where .= " AND D.location LIKE ?"; + $param[] = "%".$value."%"; + break; + case 'device_id': + $where .= " AND D.device_id = ?"; + $param[] = $value; + break; + case 'deleted': + if ($value == 1) { + $where .= " AND `I`.`deleted` = 1"; + $ignore_filter = 1; + } + break; + case 'ignore': + if ($value == 1) { + $where .= " AND (I.ignore = 1 OR D.ignore = 1) AND I.deleted = 0"; + $ignore_filter = 1; + } + break; + case 'disabled': + if ($value == 1) { + $where .= " AND `I`.`disabled` = 1 AND `I`.`deleted` = 0"; + $disabled_filter = 1; + } + break; + case 'ifSpeed': + if (is_numeric($value)) { + $where .= " AND I.$var = ?"; + $param[] = $value; + } + break; + case 'ifType': + $where .= " AND I.$var = ?"; + $param[] = $value; + break; + case 'ifAlias': + case 'port_descr_type': + $where .= " AND I.$var LIKE ?"; + $param[] = "%".$value."%"; + break; + case 'errors': + if ($value == 1) { + $where .= " AND (I.`ifInErrors_delta` > '0' OR I.`ifOutErrors_delta` > '0')"; + } + break; + case 'state': + if ($value == "down") { + $where .= "AND I.ifAdminStatus = ? AND I.ifOperStatus = ?"; + $param[] = "up"; + $param[] = "down"; + } + elseif($value == "up") { + $where .= "AND I.ifAdminStatus = ? AND I.ifOperStatus = ? AND I.ignore = '0' AND D.ignore='0' AND I.deleted='0'"; + $param[] = "up"; + $param[] = "up"; + } + elseif($value == "admindown") { + $where .= "AND I.ifAdminStatus = ? AND D.ignore = 0"; + $param[] = "down"; + } + break; } - break; - case 'ignore': - if ($value == 1) { - $where .= " AND (I.ignore = 1 OR D.ignore = 1) AND I.deleted = 0"; - $ignore_filter = 1; - } - break; - case 'disabled': - if ($value == 1) { - $where .= " AND `I`.`disabled` = 1 AND `I`.`deleted` = 0"; - $disabled_filter = 1; - } - break; - case 'ifSpeed': - if (is_numeric($value)) - { - $where .= " AND I.$var = ?"; - $param[] = $value; - } - break; - case 'ifType': - $where .= " AND I.$var = ?"; - $param[] = $value; - break; - case 'ifAlias': - case 'port_descr_type': - $where .= " AND I.$var LIKE ?"; - $param[] = "%".$value."%"; - break; - case 'errors': - if ($value == 1) - { - $where .= " AND (I.`ifInErrors_delta` > '0' OR I.`ifOutErrors_delta` > '0')"; - } - break; - case 'state': - if ($value == "down") - { - $where .= "AND I.ifAdminStatus = ? AND I.ifOperStatus = ?"; - $param[] = "up"; - $param[] = "down"; - } elseif($value == "up") { - $where .= "AND I.ifAdminStatus = ? AND I.ifOperStatus = ? AND I.ignore = '0' AND D.ignore='0' AND I.deleted='0'"; - $param[] = "up"; - $param[] = "up"; - } elseif($value == "admindown") { - $where .= "AND I.ifAdminStatus = ? AND D.ignore = 0"; - $param[] = "down"; - } - break; } - } } if ($ignore_filter == 0 && $disabled_filter == 0) { @@ -369,49 +368,47 @@ list($format, $subformat) = explode("_", $vars['format']); $ports = dbFetchRows($query, $param); -switch ($vars['sort']) -{ - case 'traffic': - $ports = array_sort($ports, 'ifOctets_rate', SORT_DESC); - break; - case 'traffic_in': - $ports = array_sort($ports, 'ifInOctets_rate', SORT_DESC); - break; - case 'traffic_out': - $ports = array_sort($ports, 'ifOutOctets_rate', SORT_DESC); - break; - case 'packets': - $ports = array_sort($ports, 'ifUcastPkts_rate', SORT_DESC); - break; - case 'packets_in': - $ports = array_sort($ports, 'ifInUcastOctets_rate', SORT_DESC); - break; - case 'packets_out': - $ports = array_sort($ports, 'ifOutUcastOctets_rate', SORT_DESC); - break; - case 'errors': - $ports = array_sort($ports, 'ifErrors_rate', SORT_DESC); - break; - case 'speed': - $ports = array_sort($ports, 'ifSpeed', SORT_DESC); - break; - case 'port': - $ports = array_sort($ports, 'ifDescr', SORT_ASC); - break; - case 'media': - $ports = array_sort($ports, 'ifType', SORT_ASC); - break; - case 'descr': - $ports = array_sort($ports, 'ifAlias', SORT_ASC); - break; - case 'device': - default: - $ports = array_sort($ports, 'hostname', SORT_ASC); +switch ($vars['sort']) { + case 'traffic': + $ports = array_sort($ports, 'ifOctets_rate', SORT_DESC); + break; + case 'traffic_in': + $ports = array_sort($ports, 'ifInOctets_rate', SORT_DESC); + break; + case 'traffic_out': + $ports = array_sort($ports, 'ifOutOctets_rate', SORT_DESC); + break; + case 'packets': + $ports = array_sort($ports, 'ifUcastPkts_rate', SORT_DESC); + break; + case 'packets_in': + $ports = array_sort($ports, 'ifInUcastOctets_rate', SORT_DESC); + break; + case 'packets_out': + $ports = array_sort($ports, 'ifOutUcastOctets_rate', SORT_DESC); + break; + case 'errors': + $ports = array_sort($ports, 'ifErrors_rate', SORT_DESC); + break; + case 'speed': + $ports = array_sort($ports, 'ifSpeed', SORT_DESC); + break; + case 'port': + $ports = array_sort($ports, 'ifDescr', SORT_ASC); + break; + case 'media': + $ports = array_sort($ports, 'ifType', SORT_ASC); + break; + case 'descr': + $ports = array_sort($ports, 'ifAlias', SORT_ASC); + break; + case 'device': + default: + $ports = array_sort($ports, 'hostname', SORT_ASC); } -if(file_exists('pages/ports/'.$format.'.inc.php')) -{ - include('pages/ports/'.$format.'.inc.php'); +if(file_exists('pages/ports/'.$format.'.inc.php')) { + require 'pages/ports/'.$format.'.inc.php'; } ?> diff --git a/html/pages/ports/list.inc.php b/html/pages/ports/list.inc.php index 8ae9c9df36..71f52e6180 100644 --- a/html/pages/ports/list.inc.php +++ b/html/pages/ports/list.inc.php @@ -3,68 +3,75 @@ '); +echo ''; -$cols = array('device' => 'Device', - 'port' => 'Port', - 'speed' => 'Speed', - 'traffic_in' => 'Down', - 'traffic_out' => 'Up', - 'media' => 'Media', - 'descr' => 'Description' ); +$cols = array( + 'device' => 'Device', + 'port' => 'Port', + 'speed' => 'Speed', + 'traffic_in' => 'Down', + 'traffic_out' => 'Up', + 'media' => 'Media', + 'descr' => 'Description', +); -foreach ($cols as $sort => $col) -{ - if (isset($vars['sort']) && $vars['sort'] == $sort) - { - echo(''.$col.' *'); - } else { - echo(''.$col.''); - } +foreach ($cols as $sort => $col) { + if (isset($vars['sort']) && $vars['sort'] == $sort) { + echo ''.$col.' *'; + } + else { + echo ''.$col.''; + } } -echo(" "); +echo ' '; -$ports_disabled = 0; $ports_down = 0; $ports_up = 0; $ports_total = 0; +$ports_disabled = 0; +$ports_down = 0; +$ports_up = 0; +$ports_total = 0; -foreach ($ports as $port) -{ +foreach ($ports as $port) { + if (port_permitted($port['port_id'], $port['device_id'])) { + if ($port['ifAdminStatus'] == 'down') { + $ports_disabled++; + } + else if ($port['ifAdminStatus'] == 'up' && $port['ifOperStatus'] == 'down') { + $ports_down++; + } + else if ($port['ifAdminStatus'] == 'up' && $port['ifOperStatus'] == 'up') { + $ports_up++; + } - if (port_permitted($port['port_id'], $port['device_id'])) - { + $ports_total++; - if ($port['ifAdminStatus'] == "down") { $ports_disabled++; - } elseif ($port['ifAdminStatus'] == "up" && $port['ifOperStatus']== "down") { $ports_down++; - } elseif ($port['ifAdminStatus'] == "up" && $port['ifOperStatus']== "up") { $ports_up++; } - $ports_total++; + $speed = humanspeed($port['ifSpeed']); + $type = humanmedia($port['ifType']); + $ifclass = ifclass($port['ifOperStatus'], $port['ifAdminStatus']); - $speed = humanspeed($port['ifSpeed']); - $type = humanmedia($port['ifType']); - $ifclass = ifclass($port['ifOperStatus'], $port['ifAdminStatus']); + if ((isset($port['in_errors']) && $port['in_errors'] > 0) || (isset($ports['out_errors']) && $port['out_errors'] > 0)) { + $error_img = generate_port_link($port, "Interface Errors", errors); + } + else { + $error_img = ''; + } - if ((isset($port['in_errors']) && $port['in_errors'] > 0) || (isset($ports['out_errors']) && $port['out_errors'] > 0)) - { - $error_img = generate_port_link($port,"Interface Errors",errors); - } else { $error_img = ""; } + $port['in_rate'] = formatRates(($port['ifInOctets_rate'] * 8)); + $port['out_rate'] = formatRates(($port['ifOutOctets_rate'] * 8)); - $port['in_rate'] = formatRates($port['ifInOctets_rate'] * 8); - $port['out_rate'] = formatRates($port['ifOutOctets_rate'] * 8); + $port = ifLabel($port, $device); + echo " + ".generate_device_link($port, shorthost($port['hostname'], '20'))." + ".fixIfName($port['label'])." $error_img + $speed + ".$port['in_rate'].' + '.$port['out_rate']." + $type + ".$port['ifAlias']." + \n"; + }//end if +}//end foreach - $port = ifLabel($port, $device); - echo(" - ".generate_device_link($port, shorthost($port['hostname'], "20"))." - ".fixIfName($port['label'])." $error_img - $speed - ".$port['in_rate']." - ".$port['out_rate']." - $type - " . $port['ifAlias'] . " - \n"); - } -} - -echo(''); -echo("Matched Ports: $ports_total ( Up $ports_up | Down $ports_down | Disabled $ports_disabled )"); -echo(''); - -?> +echo ''; +echo "Matched Ports: $ports_total ( Up $ports_up | Down $ports_down | Disabled $ports_disabled )"; +echo ''; diff --git a/html/pages/preferences.inc.php b/html/pages/preferences.inc.php index f4815df24e..ca2f798352 100644 --- a/html/pages/preferences.inc.php +++ b/html/pages/preferences.inc.php @@ -1,48 +1,41 @@ User Preferences"); +echo '

    User Preferences

    '; if ($_SESSION['userlevel'] == 11) { - demo_account(); - -} else { - -if ($_POST['action'] == "changepass") -{ - if (authenticate($_SESSION['username'],$_POST['old_pass'])) - { - if ($_POST['new_pass'] == "" || $_POST['new_pass2'] == "") - { - $changepass_message = "Password must not be blank."; - } - elseif ($_POST['new_pass'] == $_POST['new_pass2']) - { - changepassword($_SESSION['username'],$_POST['new_pass']); - $changepass_message = "Password Changed."; - } - else - { - $changepass_message = "Passwords don't match."; - } - } else { - $changepass_message = "Incorrect password"; - } } +else { + if ($_POST['action'] == 'changepass') { + if (authenticate($_SESSION['username'], $_POST['old_pass'])) { + if ($_POST['new_pass'] == '' || $_POST['new_pass2'] == '') { + $changepass_message = 'Password must not be blank.'; + } + else if ($_POST['new_pass'] == $_POST['new_pass2']) { + changepassword($_SESSION['username'], $_POST['new_pass']); + $changepass_message = 'Password Changed.'; + } + else { + $changepass_message = "Passwords don't match."; + } + } + else { + $changepass_message = 'Incorrect password'; + } + } -include("includes/update-preferences-password.inc.php"); + include 'includes/update-preferences-password.inc.php'; -echo("
    "); + echo "
    "; -if (passwordscanchange($_SESSION['username'])) -{ - echo("

    Change Password

    "); - echo($changepass_message); - echo(" + if (passwordscanchange($_SESSION['username'])) { + echo '

    Change Password

    '; + echo $changepass_message; + echo "
    @@ -69,93 +62,107 @@ if (passwordscanchange($_SESSION['username']))
    -"); - echo("
    "); -} +"; + echo '
    '; + }//end if -if( $config['twofactor'] === true ) { - if( $_POST['twofactorremove'] == 1 ) { - require_once($config['install_dir']."/html/includes/authentication/twofactor.lib.php"); - if( !isset($_POST['twofactor']) ) { - echo '
    '; - echo ''; - echo twofactor_form(false); - echo '
    '; - } else{ - $twofactor = dbFetchRow('SELECT twofactor FROM users WHERE username = ?', array($_SESSION['username'])); - if( empty($twofactor['twofactor']) ) { - echo '
    Error: How did you even get here?!
    '; - } else { - $twofactor = json_decode($twofactor['twofactor'],true); - } - if( verify_hotp($twofactor['key'],$_POST['twofactor'],$twofactor['counter']) ) { - if( !dbUpdate(array('twofactor' => ''),'users','username = ?',array($_SESSION['username'])) ) { - echo '
    Error while disabling TwoFactor.
    '; - } else { - echo '
    TwoFactor Disabled.
    '; + if ($config['twofactor'] === true) { + if ($_POST['twofactorremove'] == 1) { + include_once $config['install_dir'].'/html/includes/authentication/twofactor.lib.php'; + if (!isset($_POST['twofactor'])) { + echo '
    '; + echo ''; + echo twofactor_form(false); + echo '
    '; + } + else { + $twofactor = dbFetchRow('SELECT twofactor FROM users WHERE username = ?', array($_SESSION['username'])); + if (empty($twofactor['twofactor'])) { + echo '
    Error: How did you even get here?!
    '; + } + else { + $twofactor = json_decode($twofactor['twofactor'], true); + } + + if (verify_hotp($twofactor['key'], $_POST['twofactor'], $twofactor['counter'])) { + if (!dbUpdate(array('twofactor' => ''), 'users', 'username = ?', array($_SESSION['username']))) { + echo '
    Error while disabling TwoFactor.
    '; + } + else { + echo '
    TwoFactor Disabled.
    '; + } + } + else { + session_destroy(); + echo '
    Error: Supplied TwoFactor Token is wrong, you\'ve been logged out.
    '; + } + }//end if } - } else { - session_destroy(); - echo '
    Error: Supplied TwoFactor Token is wrong, you\'ve been logged out.
    '; - } - } - } else { - $twofactor = dbFetchRow("SELECT twofactor FROM users WHERE username = ?", array($_SESSION['username'])); - echo ''; - echo '

    Two-Factor Authentication

    '; - if( !empty($twofactor['twofactor']) ) { - $twofactor = json_decode($twofactor['twofactor'],true); - $twofactor['text'] = "
    + else { + $twofactor = dbFetchRow('SELECT twofactor FROM users WHERE username = ?', array($_SESSION['username'])); + echo ''; + echo '

    Two-Factor Authentication

    '; + if (!empty($twofactor['twofactor'])) { + $twofactor = json_decode($twofactor['twofactor'], true); + $twofactor['text'] = "
    "; - if( $twofactor['counter'] !== false ) { - $twofactor['uri'] = "otpauth://hotp/".$_SESSION['username']."?issuer=LibreNMS&counter=".$twofactor['counter']."&secret=".$twofactor['key']; - $twofactor['text'] .= "
    + if ($twofactor['counter'] !== false) { + $twofactor['uri'] = 'otpauth://hotp/'.$_SESSION['username'].'?issuer=LibreNMS&counter='.$twofactor['counter'].'&secret='.$twofactor['key']; + $twofactor['text'] .= "
    "; - } else { - $twofactor['uri'] = "otpauth://totp/".$_SESSION['username']."?issuer=LibreNMS&secret=".$twofactor['key']; - } - echo '
    + } + else { + $twofactor['uri'] = 'otpauth://totp/'.$_SESSION['username'].'?issuer=LibreNMS&secret='.$twofactor['key']; + } + + echo '
    '; - echo '
    + echo '
    '.$twofactor['text'].'
    '; - echo ''; - echo '
    + echo ''; + echo '
    '; - } else { - if( isset($_POST['gentwofactorkey']) && isset($_POST['twofactortype']) ) { - require_once($config['install_dir']."/html/includes/authentication/twofactor.lib.php"); - $chk = dbFetchRow("SELECT twofactor FROM users WHERE username = ?", array($_SESSION['username'])); - if( empty($chk['twofactor']) ) { - $twofactor = array('key' => twofactor_genkey()); - if( $_POST['twofactortype'] == "counter" ) { - $twofactor['counter'] = 1; - } else { - $twofactor['counter'] = false; - } - if( !dbUpdate(array('twofactor' => json_encode($twofactor)),'users','username = ?',array($_SESSION['username'])) ) { - echo '
    Error inserting TwoFactor details. Please try again later and contact Administrator if error persists.
    '; - } else { - echo '
    Added TwoFactor credentials. Please reload page.
    '; - } - } else { - echo '
    TwoFactor credentials already exists.
    '; - } - } else { - echo '
    + } + else { + if (isset($_POST['gentwofactorkey']) && isset($_POST['twofactortype'])) { + include_once $config['install_dir'].'/html/includes/authentication/twofactor.lib.php'; + $chk = dbFetchRow('SELECT twofactor FROM users WHERE username = ?', array($_SESSION['username'])); + if (empty($chk['twofactor'])) { + $twofactor = array('key' => twofactor_genkey()); + if ($_POST['twofactortype'] == 'counter') { + $twofactor['counter'] = 1; + } + else { + $twofactor['counter'] = false; + } + + if (!dbUpdate(array('twofactor' => json_encode($twofactor)), 'users', 'username = ?', array($_SESSION['username']))) { + echo '
    Error inserting TwoFactor details. Please try again later and contact Administrator if error persists.
    '; + } + else { + echo '
    Added TwoFactor credentials. Please reload page.
    '; + } + } + else { + echo '
    TwoFactor credentials already exists.
    '; + } + } + else { + echo '
    @@ -169,32 +176,34 @@ if( $config['twofactor'] === true ) {
    '; - } + }//end if + }//end if + echo '
    '; + }//end if + }//end if +}//end if + +echo "
    '; - } } -} - -echo("
    "); -echo("
    Device Permissions
    "); - -if ($_SESSION['userlevel'] == '10') { echo("Global Administrative Access"); } -if ($_SESSION['userlevel'] == '5') { echo("Global Viewing Access"); } -if ($_SESSION['userlevel'] == '1') -{ - - foreach (dbFetchRows("SELECT * FROM `devices_perms` AS P, `devices` AS D WHERE `user_id` = ? AND P.device_id = D.device_id", array($_SESSION['user_id'])) as $perm) - { - #FIXME generatedevicelink? - echo("" . $perm['hostname'] . "
    "); - $dev_access = 1; - } - - if (!$dev_access) { echo("No access!"); } -} - -echo("
    "); - -?> +echo '
    '; diff --git a/html/pages/pseudowires.inc.php b/html/pages/pseudowires.inc.php index 5dd77f468c..3408973fd4 100644 --- a/html/pages/pseudowires.inc.php +++ b/html/pages/pseudowires.inc.php @@ -90,8 +90,7 @@ foreach (dbFetchRows('SELECT * FROM pseudowires AS P, ports AS I, devices AS D W $pw_a['to'] = $config['time']['now']; $pw_a['bg'] = $bg; $types = array('bits', 'upkts', 'errors'); - foreach ($types as $graph_type) - { + foreach ($types as $graph_type) { $pw_a['graph_type'] = 'port_'.$graph_type; print_port_thumbnail($pw_a); } diff --git a/html/pages/public.inc.php b/html/pages/public.inc.php index ad89593bcf..71181a977e 100644 --- a/html/pages/public.inc.php +++ b/html/pages/public.inc.php @@ -1,4 +1,5 @@

    System Status

    @@ -50,9 +49,8 @@ $query = "SELECT * FROM `devices` WHERE 1 AND disabled='0' AND `ignore`='0' ORDE Uptime/Location diff --git a/html/pages/routing/bgp.inc.php b/html/pages/routing/bgp.inc.php index 5e04945626..3268715ec5 100644 --- a/html/pages/routing/bgp.inc.php +++ b/html/pages/routing/bgp.inc.php @@ -1,260 +1,355 @@ 'routing', 'protocol' => 'bgp'); +else { + $link_array = array( + 'page' => 'routing', + 'protocol' => 'bgp', + ); - print_optionbar_start('', ''); + print_optionbar_start('', ''); - echo('BGP » '); + echo 'BGP » '; - if (!$vars['type']) { $vars['type'] = "all"; } - - if ($vars['type'] == "all") { echo(""); } - echo(generate_link("All",$vars, array('type' => 'all'))); - if ($vars['type'] == "all") { echo(""); } - - echo(" | "); - - if ($vars['type'] == "internal") { echo(""); } - echo(generate_link("iBGP",$vars, array('type' => 'internal'))); - if ($vars['type'] == "internal") { echo(""); } - - echo(" | "); - - if ($vars['type'] == "external") { echo(""); } - echo(generate_link("eBGP",$vars, array('type' => 'external'))); - if ($vars['type'] == "external") { echo(""); } - - echo(" | "); - - if ($vars['adminstatus'] == "stop") - { - echo(""); - echo(generate_link("Shutdown",$vars, array('adminstatus' => NULL))); - echo(""); - } else { - echo(generate_link("Shutdown",$vars, array('adminstatus' => 'stop'))); - } - - echo(" | "); - - if ($vars['adminstatus'] == "start") - { - echo(""); - echo(generate_link("Enabled",$vars, array('adminstatus' => NULL))); - echo(""); - } else { - echo(generate_link("Enabled",$vars, array('adminstatus' => 'start'))); - } - - echo(" | "); - - if ($vars['state'] == "down") - { - echo(""); - echo(generate_link("Down",$vars, array('state' => NULL))); - echo(""); - } else { - echo(generate_link("Down",$vars, array('state' => 'down'))); - } - - // End BGP Menu - - if (!isset($vars['view'])) { $vars['view'] = 'details'; } - - echo('
    '); - - if ($vars['view'] == "details") { echo(""); } - echo(generate_link("No Graphs",$vars, array('view' => 'details', 'graph' => 'NULL'))); - if ($vars['view'] == "details") { echo(""); } - - echo(" | "); - - if ($vars['graph'] == "updates") { echo(""); } - echo(generate_link("Updates",$vars, array('view' => 'graphs', 'graph' => 'updates'))); - if ($vars['graph'] == "updates") { echo(""); } - - echo(" | Prefixes: Unicast ("); - if ($vars['graph'] == "prefixes_ipv4unicast") { echo(""); } - echo(generate_link("IPv4",$vars, array('view' => 'graphs', 'graph' => 'prefixes_ipv4unicast'))); - if ($vars['graph'] == "prefixes_ipv4unicast") { echo(""); } - - echo("|"); - - if ($vars['graph'] == "prefixes_ipv6unicast") { echo(""); } - echo(generate_link("IPv6",$vars, array('view' => 'graphs', 'graph' => 'prefixes_ipv6unicast'))); - if ($vars['graph'] == "prefixes_ipv6unicast") { echo(""); } - - echo("|"); - - if ($vars['graph'] == "prefixes_ipv4vpn") { echo(""); } - echo(generate_link("VPNv4",$vars, array('view' => 'graphs', 'graph' => 'prefixes_ipv4vpn'))); - if ($vars['graph'] == "prefixes_ipv4vpn") { echo(""); } - echo(")"); - - echo(" | Multicast ("); - if ($vars['graph'] == "prefixes_ipv4multicast") { echo(""); } - echo(generate_link("IPv4",$vars, array('view' => 'graphs', 'graph' => 'prefixes_ipv4multicast'))); - if ($vars['graph'] == "prefixes_ipv4multicast") { echo(""); } - - echo("|"); - - if ($vars['graph'] == "prefixes_ipv6multicast") { echo(""); } - echo(generate_link("IPv6",$vars, array('view' => 'graphs', 'graph' => 'prefixes_ipv6multicast'))); - if ($vars['graph'] == "prefixes_ipv6multicast") { echo(""); } - echo(")"); - - echo(" | MAC ("); - if ($vars['graph'] == "macaccounting_bits") { echo(""); } - echo(generate_link("Bits",$vars, array('view' => 'graphs', 'graph' => 'macaccounting_bits'))); - if ($vars['graph'] == "macaccounting_bits") { echo(""); } - - echo("|"); - - if ($vars['graph'] == "macaccounting_pkts") { echo(""); } - echo(generate_link("Packets",$vars, array('view' => 'graphs', 'graph' => 'macaccounting_pkts'))); - if ($vars['graph'] == "macaccounting_pkts") { echo(""); } - echo(")"); - - echo('
    '); - - print_optionbar_end(); - - echo(""); - echo(''); - - if ($vars['type'] == "external") - { - $where = "AND D.bgpLocalAs != B.bgpPeerRemoteAs"; - } elseif ($vars['type'] == "internal") { - $where = "AND D.bgpLocalAs = B.bgpPeerRemoteAs"; - } - - if ($vars['adminstatus'] == "stop") - { - $where .= " AND (B.bgpPeerAdminStatus = 'stop')"; - } elseif ($vars['adminstatus'] == "start") - { - $where .= " AND (B.bgpPeerAdminStatus = 'start' || B.bgpPeerAdminStatus = 'running')"; - } - - if ($vars['state'] == "down") - { - $where .= " AND (B.bgpPeerState != 'established')"; - } - - $peer_query = "select * from bgpPeers AS B, devices AS D WHERE B.device_id = D.device_id ".$where." ORDER BY D.hostname, B.bgpPeerRemoteAs, B.bgpPeerIdentifier"; - foreach (dbFetchRows($peer_query) as $peer) - { - unset ($alert, $bg_image); - - if ($peer['bgpPeerState'] == "established") { $col = "green"; } else { $col = "red"; $peer['alert']=1; } - if ($peer['bgpPeerAdminStatus'] == "start" || $peer['bgpPeerAdminStatus'] == "running") { $admin_col = "green"; } else { $admin_col = "gray"; } - if ($peer['bgpPeerAdminStatus'] == "stop") { $peer['alert']=0; $peer['disabled']=1; } - if ($peer['bgpPeerRemoteAs'] == $peer['bgpLocalAs']) { $peer_type = "iBGP"; } else { $peer_type = "eBGP"; - if ($peer['bgpPeerRemoteAS'] >= '64512' && $peer['bgpPeerRemoteAS'] <= '65535') { $peer_type = "Priv eBGP"; } + if (!$vars['type']) { + $vars['type'] = 'all'; } - $peerhost = dbFetchRow("SELECT * FROM ipaddr AS A, ports AS I, devices AS D WHERE A.addr = ? AND I.port_id = A.port_id AND D.device_id = I.device_id", array($peer['bgpPeerIdentifier'])); - - if ($peerhost) { $peername = generate_device_link($peerhost, shorthost($peerhost['hostname'])); } else { unset($peername); } - - // display overlib graphs - - $graph_type = "bgp_updates"; - $local_daily_url = "graph.php?id=" . $peer['bgpPeer_id'] . "&type=" . $graph_type . "&from=".$config['time']['day']."&to=".$config['time']['now']."&width=500&height=150&&afi=ipv4&safi=unicast"; - if (filter_var($peer['bgpLocalAddr'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) !== FALSE) { - $peer_ip = Net_IPv6::compress($peer['bgpLocalAddr']); - } else { - $peer_ip = $peer['bgpLocalAddr']; - } - $localaddresslink = "', LEFT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\">" . $peer_ip . ""; - - $graph_type = "bgp_updates"; - $peer_daily_url = "graph.php?id=" . $peer['bgpPeer_id'] . "&type=" . $graph_type . "&from=".$config['time']['day']."&to=".$config['time']['now']."&width=500&height=150"; - if (filter_var($peer['bgpPeerIdentifier'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) !== FALSE) { - $peer_ident = Net_IPv6::compress($peer['bgpPeerIdentifier']); - } else { - $peer_ident = $peer['bgpPeerIdentifier']; + if ($vars['type'] == 'all') { + echo ""; } - $peeraddresslink = "', LEFT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\">" . $peer_ident . ""; - - echo('"); - - unset($sep); - foreach (dbFetchRows("SELECT * FROM `bgpPeers_cbgp` WHERE `device_id` = ? AND bgpPeerIdentifier = ?", array($peer['device_id'], $peer['bgpPeerIdentifier'])) as $afisafi) - { - $afi = $afisafi['afi']; - $safi = $afisafi['safi']; - $this_afisafi = $afi.$safi; - $peer['afi'] .= $sep . $afi .".".$safi; - $sep = "
    "; - $peer['afisafi'][$this_afisafi] = 1; // Build a list of valid AFI/SAFI for this peer - } - unset($sep); - - echo(" - - - - - - - - "); - - unset($invalid); - switch ($vars['graph']) - { - case 'prefixes_ipv4unicast': - case 'prefixes_ipv4multicast': - case 'prefixes_ipv4vpn': - case 'prefixes_ipv6unicast': - case 'prefixes_ipv6multicast': - list(,$afisafi) = explode("_", $vars['graph']); - if (isset($peer['afisafi'][$afisafi])) { $peer['graph'] = 1; } - case 'updates': - $graph_array['type'] = "bgp_" . $vars['graph']; - $graph_array['id'] = $peer['bgpPeer_id']; + echo generate_link('All', $vars, array('type' => 'all')); + if ($vars['type'] == 'all') { + echo ''; } - switch ($vars['graph']) - { - case 'macaccounting_bits': - case 'macaccounting_pkts': - $acc = dbFetchRow("SELECT * FROM `ipv4_mac` AS I, `mac_accounting` AS M, `ports` AS P, `devices` AS D WHERE I.ipv4_address = ? AND M.mac = I.mac_address AND P.port_id = M.port_id AND D.device_id = P.device_id", array($peer['bgpPeerIdentifier'])); - $database = $config['rrd_dir'] . "/" . $device['hostname'] . "/cip-" . $acc['ifIndex'] . "-" . $acc['mac'] . ".rrd"; - if (is_array($acc) && is_file($database)) - { - $peer['graph'] = 1; - $graph_array['id'] = $acc['ma_id']; - $graph_array['type'] = $vars['graph']; + echo ' | '; + + if ($vars['type'] == 'internal') { + echo ""; + } + + echo generate_link('iBGP', $vars, array('type' => 'internal')); + if ($vars['type'] == 'internal') { + echo ''; + } + + echo ' | '; + + if ($vars['type'] == 'external') { + echo ""; + } + + echo generate_link('eBGP', $vars, array('type' => 'external')); + if ($vars['type'] == 'external') { + echo ''; + } + + echo ' | '; + + if ($vars['adminstatus'] == 'stop') { + echo ""; + echo generate_link('Shutdown', $vars, array('adminstatus' => null)); + echo ''; + } + else { + echo generate_link('Shutdown', $vars, array('adminstatus' => 'stop')); + } + + echo ' | '; + + if ($vars['adminstatus'] == 'start') { + echo ""; + echo generate_link('Enabled', $vars, array('adminstatus' => null)); + echo ''; + } + else { + echo generate_link('Enabled', $vars, array('adminstatus' => 'start')); + } + + echo ' | '; + + if ($vars['state'] == 'down') { + echo ""; + echo generate_link('Down', $vars, array('state' => null)); + echo ''; + } + else { + echo generate_link('Down', $vars, array('state' => 'down')); + } + + // End BGP Menu + if (!isset($vars['view'])) { + $vars['view'] = 'details'; + } + + echo '
    '; + + if ($vars['view'] == 'details') { + echo ""; + } + + echo generate_link('No Graphs', $vars, array('view' => 'details', 'graph' => 'NULL')); + if ($vars['view'] == 'details') { + echo ''; + } + + echo ' | '; + + if ($vars['graph'] == 'updates') { + echo ""; + } + + echo generate_link('Updates', $vars, array('view' => 'graphs', 'graph' => 'updates')); + if ($vars['graph'] == 'updates') { + echo ''; + } + + echo ' | Prefixes: Unicast ('; + if ($vars['graph'] == 'prefixes_ipv4unicast') { + echo ""; + } + + echo generate_link('IPv4', $vars, array('view' => 'graphs', 'graph' => 'prefixes_ipv4unicast')); + if ($vars['graph'] == 'prefixes_ipv4unicast') { + echo ''; + } + + echo '|'; + + if ($vars['graph'] == 'prefixes_ipv6unicast') { + echo ""; + } + + echo generate_link('IPv6', $vars, array('view' => 'graphs', 'graph' => 'prefixes_ipv6unicast')); + if ($vars['graph'] == 'prefixes_ipv6unicast') { + echo ''; + } + + echo '|'; + + if ($vars['graph'] == 'prefixes_ipv4vpn') { + echo ""; + } + + echo generate_link('VPNv4', $vars, array('view' => 'graphs', 'graph' => 'prefixes_ipv4vpn')); + if ($vars['graph'] == 'prefixes_ipv4vpn') { + echo ''; + } + + echo ')'; + + echo ' | Multicast ('; + if ($vars['graph'] == 'prefixes_ipv4multicast') { + echo ""; + } + + echo generate_link('IPv4', $vars, array('view' => 'graphs', 'graph' => 'prefixes_ipv4multicast')); + if ($vars['graph'] == 'prefixes_ipv4multicast') { + echo ''; + } + + echo '|'; + + if ($vars['graph'] == 'prefixes_ipv6multicast') { + echo ""; + } + + echo generate_link('IPv6', $vars, array('view' => 'graphs', 'graph' => 'prefixes_ipv6multicast')); + if ($vars['graph'] == 'prefixes_ipv6multicast') { + echo ''; + } + + echo ')'; + + echo ' | MAC ('; + if ($vars['graph'] == 'macaccounting_bits') { + echo ""; + } + + echo generate_link('Bits', $vars, array('view' => 'graphs', 'graph' => 'macaccounting_bits')); + if ($vars['graph'] == 'macaccounting_bits') { + echo ''; + } + + echo '|'; + + if ($vars['graph'] == 'macaccounting_pkts') { + echo ""; + } + + echo generate_link('Packets', $vars, array('view' => 'graphs', 'graph' => 'macaccounting_pkts')); + if ($vars['graph'] == 'macaccounting_pkts') { + echo ''; + } + + echo ')'; + + echo '
    '; + + print_optionbar_end(); + + echo "
    Local addressPeer addressTypeFamilyRemote ASStateUptime / Updates
    " . $localaddresslink . "
    ".generate_device_link($peer, shorthost($peer['hostname']), array('tab' => 'routing', 'proto' => 'bgp'))."
    »" . $peeraddresslink . "$peer_type".$peer['afi']."AS" . $peer['bgpPeerRemoteAs'] . "
    " . $peer['astext'] . "
    " . $peer['bgpPeerAdminStatus'] . "
    " . $peer['bgpPeerState'] . "
    " .formatUptime($peer['bgpPeerFsmEstablishedTime']). "
    - Updates " . format_si($peer['bgpPeerInUpdates']) . " - " . format_si($peer['bgpPeerOutUpdates']) . "
    "; + echo ''; + + if ($vars['type'] == 'external') { + $where = 'AND D.bgpLocalAs != B.bgpPeerRemoteAs'; + } + else if ($vars['type'] == 'internal') { + $where = 'AND D.bgpLocalAs = B.bgpPeerRemoteAs'; + } + + if ($vars['adminstatus'] == 'stop') { + $where .= " AND (B.bgpPeerAdminStatus = 'stop')"; + } + else if ($vars['adminstatus'] == 'start') { + $where .= " AND (B.bgpPeerAdminStatus = 'start' || B.bgpPeerAdminStatus = 'running')"; + } + + if ($vars['state'] == 'down') { + $where .= " AND (B.bgpPeerState != 'established')"; + } + + $peer_query = 'select * from bgpPeers AS B, devices AS D WHERE B.device_id = D.device_id '.$where.' ORDER BY D.hostname, B.bgpPeerRemoteAs, B.bgpPeerIdentifier'; + foreach (dbFetchRows($peer_query) as $peer) { + unset($alert, $bg_image); + + if ($peer['bgpPeerState'] == 'established') { + $col = 'green'; + } + else { + $col = 'red'; + $peer['alert'] = 1; } - } - if ($vars['graph'] == 'updates') { $peer['graph'] = 1; } + if ($peer['bgpPeerAdminStatus'] == 'start' || $peer['bgpPeerAdminStatus'] == 'running') { + $admin_col = 'green'; + } + else { + $admin_col = 'gray'; + } - if ($peer['graph']) - { - $graph_array['height'] = "100"; - $graph_array['width'] = "218"; - $graph_array['to'] = $config['time']['now']; - echo('"); - } - } + $peerhost = dbFetchRow('SELECT * FROM ipaddr AS A, ports AS I, devices AS D WHERE A.addr = ? AND I.port_id = A.port_id AND D.device_id = I.device_id', array($peer['bgpPeerIdentifier'])); - echo("
    Local addressPeer addressTypeFamilyRemote ASStateUptime / Updates
    '); + if ($peer['bgpPeerAdminStatus'] == 'stop') { + $peer['alert'] = 0; + $peer['disabled'] = 1; + } - include("includes/print-graphrow.inc.php"); + if ($peer['bgpPeerRemoteAs'] == $peer['bgpLocalAs']) { + $peer_type = "iBGP"; + } + else { + $peer_type = "eBGP"; + if ($peer['bgpPeerRemoteAS'] >= '64512' && $peer['bgpPeerRemoteAS'] <= '65535') { + $peer_type = "Priv eBGP"; + } + } - echo("
    "); -} + if ($peerhost) { + $peername = generate_device_link($peerhost, shorthost($peerhost['hostname'])); + } + else { + unset($peername); + } + // display overlib graphs + $graph_type = 'bgp_updates'; + $local_daily_url = 'graph.php?id='.$peer['bgpPeer_id'].'&type='.$graph_type.'&from='.$config['time']['day'].'&to='.$config['time']['now'].'&width=500&height=150&&afi=ipv4&safi=unicast'; + if (filter_var($peer['bgpLocalAddr'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) !== false) { + $peer_ip = Net_IPv6::compress($peer['bgpLocalAddr']); + } + else { + $peer_ip = $peer['bgpLocalAddr']; + } + + $localaddresslink = "', LEFT".$config['overlib_defaults'].');" onmouseout="return nd();">'.$peer_ip.''; + + $graph_type = 'bgp_updates'; + $peer_daily_url = 'graph.php?id='.$peer['bgpPeer_id'].'&type='.$graph_type.'&from='.$config['time']['day'].'&to='.$config['time']['now'].'&width=500&height=150'; + if (filter_var($peer['bgpPeerIdentifier'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) !== false) { + $peer_ident = Net_IPv6::compress($peer['bgpPeerIdentifier']); + } + else { + $peer_ident = $peer['bgpPeerIdentifier']; + } + + $peeraddresslink = "', LEFT".$config['overlib_defaults'].');" onmouseout="return nd();">'.$peer_ident.''; + + echo ''; + + unset($sep); + foreach (dbFetchRows('SELECT * FROM `bgpPeers_cbgp` WHERE `device_id` = ? AND bgpPeerIdentifier = ?', array($peer['device_id'], $peer['bgpPeerIdentifier'])) as $afisafi) { + $afi = $afisafi['afi']; + $safi = $afisafi['safi']; + $this_afisafi = $afi.$safi; + $peer['afi'] .= $sep.$afi.'.'.$safi; + $sep = '
    '; + $peer['afisafi'][$this_afisafi] = 1; + // Build a list of valid AFI/SAFI for this peer + } + + unset($sep); + + echo ' + '.$localaddresslink.'
    '.generate_device_link($peer, shorthost($peer['hostname']), array('tab' => 'routing', 'proto' => 'bgp')).' + » + '.$peeraddresslink." + $peer_type + ".$peer['afi'].' + AS'.$peer['bgpPeerRemoteAs'].'
    '.$peer['astext']." + ".$peer['bgpPeerAdminStatus']."
    ".$peer['bgpPeerState'].'
    + '.formatUptime($peer['bgpPeerFsmEstablishedTime'])."
    + Updates ".format_si($peer['bgpPeerInUpdates'])." + ".format_si($peer['bgpPeerOutUpdates']).''; + + unset($invalid); + switch ($vars['graph']) { + case 'prefixes_ipv4unicast': + case 'prefixes_ipv4multicast': + case 'prefixes_ipv4vpn': + case 'prefixes_ipv6unicast': + case 'prefixes_ipv6multicast': + list(,$afisafi) = explode('_', $vars['graph']); + if (isset($peer['afisafi'][$afisafi])) { + $peer['graph'] = 1; + } + + case 'updates': + $graph_array['type'] = 'bgp_'.$vars['graph']; + $graph_array['id'] = $peer['bgpPeer_id']; + } + + switch ($vars['graph']) { + case 'macaccounting_bits': + case 'macaccounting_pkts': + $acc = dbFetchRow('SELECT * FROM `ipv4_mac` AS I, `mac_accounting` AS M, `ports` AS P, `devices` AS D WHERE I.ipv4_address = ? AND M.mac = I.mac_address AND P.port_id = M.port_id AND D.device_id = P.device_id', array($peer['bgpPeerIdentifier'])); + $database = $config['rrd_dir'].'/'.$device['hostname'].'/cip-'.$acc['ifIndex'].'-'.$acc['mac'].'.rrd'; + if (is_array($acc) && is_file($database)) { + $peer['graph'] = 1; + $graph_array['id'] = $acc['ma_id']; + $graph_array['type'] = $vars['graph']; + } + } + + if ($vars['graph'] == 'updates') { + $peer['graph'] = 1; + } + + if ($peer['graph']) { + $graph_array['height'] = '100'; + $graph_array['width'] = '218'; + $graph_array['to'] = $config['time']['now']; + echo ''; + + include 'includes/print-graphrow.inc.php'; + + echo ''; + } + }//end foreach + + echo ''; +}//end if diff --git a/html/pages/routing/overview.inc.php b/html/pages/routing/overview.inc.php index bd9a9e63e1..c16262143a 100644 --- a/html/pages/routing/overview.inc.php +++ b/html/pages/routing/overview.inc.php @@ -1,7 +1,7 @@ 'IPv4 Address', 'ipv6' => 'IPv6 Address', 'mac' => 'MAC Address', 'arp' => 'ARP Table'); +$sections = array( + 'ipv4' => 'IPv4 Address', + 'ipv6' => 'IPv6 Address', + 'mac' => 'MAC Address', + 'arp' => 'ARP Table', +); -if( dbFetchCell("SELECT 1 from `packages` LIMIT 1") ) { - $sections['packages'] = 'Packages'; +if (dbFetchCell('SELECT 1 from `packages` LIMIT 1')) { + $sections['packages'] = 'Packages'; } -if (!isset($vars['search'])) { $vars['search'] = "ipv4"; } +if (!isset($vars['search'])) { + $vars['search'] = 'ipv4'; +} print_optionbar_start('', ''); - echo('Search » '); +echo 'Search » '; unset($sep); -foreach ($sections as $type => $texttype) -{ - echo($sep); - if ($vars['search'] == $type) - { - echo(""); - } +foreach ($sections as $type => $texttype) { + echo $sep; + if ($vars['search'] == $type) { + echo ""; + } -# echo('' . $texttype .''); - echo(generate_link($texttype, array('page'=>'search','search'=>$type))); + // echo('' . $texttype .''); + echo generate_link($texttype, array('page' => 'search', 'search' => $type)); - if ($vars['search'] == $type) { echo(""); } + if ($vars['search'] == $type) { + echo ''; + } - $sep = ' | '; + $sep = ' | '; } -unset ($sep); + +unset($sep); print_optionbar_end('', ''); -if( file_exists('pages/search/'.$vars['search'].'.inc.php') ) { - include('pages/search/'.$vars['search'].'.inc.php'); -} else { - echo(report_this('Unknown search type '.$vars['search'])); +if (file_exists('pages/search/'.$vars['search'].'.inc.php')) { + include 'pages/search/'.$vars['search'].'.inc.php'; +} +else { + echo report_this('Unknown search type '.$vars['search']); } - -?> diff --git a/html/pages/search/arp.inc.php b/html/pages/search/arp.inc.php index a4dcbd1136..45cd6888a9 100644 --- a/html/pages/search/arp.inc.php +++ b/html/pages/search/arp.inc.php @@ -30,21 +30,22 @@ var grid = $("#arp-search").bootgrid({ '.$data['hostname'].'"+'); + + echo '">'.$data['hostname'].'"+'; } ?> ""+ @@ -53,18 +54,16 @@ foreach (dbFetchRows($sql,$param) as $data) { " "\" class=\"form-control input-sm\" placeholder=\"Address\" />"+ diff --git a/html/pages/search/ipv4.inc.php b/html/pages/search/ipv4.inc.php index e2ea785c07..843acbd1bc 100644 --- a/html/pages/search/ipv4.inc.php +++ b/html/pages/search/ipv4.inc.php @@ -27,22 +27,23 @@ var grid = $("#ipv4-search").bootgrid({ ""+ '.$data['hostname'].'"+'); + + echo '">'.$data['hostname'].'"+'; } ?> ""+ @@ -52,18 +53,16 @@ foreach (dbFetchRows($sql,$param) as $data) { ""+ ""+ "
     "+ "
    "+ - "\" class=\"form-control input-sm\" placeholder=\"IPv4 Address\"/>"+ + "\" class=\"form-control input-sm\" placeholder=\"IPv4 Address\"/>"+ "
     "+ ""+ "
    "+ diff --git a/html/pages/search/ipv6.inc.php b/html/pages/search/ipv6.inc.php index 8ab58d9fff..2b9115013d 100644 --- a/html/pages/search/ipv6.inc.php +++ b/html/pages/search/ipv6.inc.php @@ -26,22 +26,23 @@ var grid = $("#ipv6-search").bootgrid({ ""+ '.$data['hostname'].'"+'); + + echo '">'.$data['hostname'].'"+'; } ?> ""+ @@ -51,9 +52,8 @@ foreach (dbFetchRows($sql,$param) as $data) { ""+ ""+ "
    "+ "
    "+ - "\" class=\"form-control input-sm\" placeholder=\"IPv6 Address\"/>"+ + "\" class=\"form-control input-sm\" placeholder=\"IPv6 Address\"/>"+ "
    "+ ""+ "
    "+ diff --git a/html/pages/search/mac.inc.php b/html/pages/search/mac.inc.php index c040a1e16a..f606e4436a 100644 --- a/html/pages/search/mac.inc.php +++ b/html/pages/search/mac.inc.php @@ -26,21 +26,22 @@ var grid = $("#mac-search").bootgrid({ ""+ @@ -50,17 +51,15 @@ foreach (dbFetchRows($sql,$param) as $data) { ""+ ""+ "
    0) { + +if(isset($_POST['results_amount']) && $_POST['results_amount'] > 0) { $results = $_POST['results']; -} -else { +} else { $results = 50; } @@ -34,49 +34,37 @@ echo '
    '; if ($_SESSION['userlevel'] >= '10') { - echo ''; + echo(''); } echo ' '); -echo ''; +$count_query = "SELECT COUNT(id)"; +$full_query = "SELECT *"; -$count_query = 'SELECT COUNT(id)'; -$full_query = 'SELECT *'; +$query = " FROM `alert_templates`"; -$query = ' FROM `alert_templates`'; - -$count_query = $count_query.$query; -$count = dbFetchCell($count_query, $param); -if (!isset($_POST['page_number']) && $_POST['page_number'] < 1) { +$count_query = $count_query . $query; +$count = dbFetchCell($count_query,$param); +if(!isset($_POST['page_number']) && $_POST['page_number'] < 1) { $page_number = 1; -} -else { +} else { $page_number = $_POST['page_number']; } +$start = ($page_number - 1) * $results; +$full_query = $full_query . $query . " LIMIT $start,$results"; -$start = (($page_number - 1) * $results); -$full_query = $full_query.$query." LIMIT $start,$results"; - -foreach (dbFetchRows($full_query, $param) as $template) { +foreach( dbFetchRows($full_query, $param) as $template ) { echo ' '.$template['name'].' '; @@ -85,15 +73,14 @@ foreach (dbFetchRows($full_query, $param) as $template) { echo " "; echo ""; } - echo ' '; } -if (($count % $results) > 0) { - echo ' - '.generate_pagination($count, $results, $page_number).' - '; +if($count % $results > 0) { + echo(' + '. generate_pagination($count,$results,$page_number) .' + '); } echo ' diff --git a/html/includes/print-alerts.inc.php b/html/includes/print-alerts.inc.php index d9758a0f38..dcbab4b3d9 100644 --- a/html/includes/print-alerts.inc.php +++ b/html/includes/print-alerts.inc.php @@ -1,49 +1,49 @@ - - '.$alert_entry['time_logged'].' - '; +echo(' + + ' . $alert_entry['time_logged'] . ' + '); if (!isset($alert_entry['device'])) { - $dev = device_by_id_cache($alert_entry['device_id']); - echo ' - '.generate_device_link($dev, shorthost($dev['hostname'])).' - '; + $dev = device_by_id_cache($alert_entry['device_id']); + echo(" + " . generate_device_link($dev, shorthost($dev['hostname'])) . " + "); } -echo ''.htmlspecialchars($alert_entry['name']).''; +echo("".htmlspecialchars($alert_entry['name']) . ""); -if ($alert_state != '') { - if ($alert_state == '0') { - $glyph_icon = 'ok'; +if ($alert_state!='') { + if ($alert_state=='0') { + $glyph_icon = 'ok'; $glyph_color = 'green'; - $text = 'Ok'; + $text = 'Ok'; } - else if ($alert_state == '1') { - $glyph_icon = 'remove'; + elseif ($alert_state=='1') { + $glyph_icon = 'remove'; $glyph_color = 'red'; - $text = 'Alert'; + $text = 'Alert'; } - else if ($alert_state == '2') { - $glyph_icon = 'info-sign'; + elseif ($alert_state=='2') { + $glyph_icon = 'info-sign'; $glyph_color = 'lightgrey'; - $text = 'Ack'; + $text = 'Ack'; } - else if ($alert_state == '3') { - $glyph_icon = 'arrow-down'; + elseif ($alert_state=='3') { + $glyph_icon = 'arrow-down'; $glyph_color = 'orange'; - $text = 'Worse'; + $text = 'Worse'; } - else if ($alert_state == '4') { - $glyph_icon = 'arrow-up'; + elseif ($alert_state=='4') { + $glyph_icon = 'arrow-up'; $glyph_color = 'khaki'; - $text = 'Better'; - }//end if - echo " $text"; -}//end if + $text = 'Better'; + } + echo(" $text"); +} -echo ''; +echo(""); diff --git a/html/includes/print-debug.php b/html/includes/print-debug.php index 7fdbbcc6d9..f35cd05bfe 100644 --- a/html/includes/print-debug.php +++ b/html/includes/print-debug.php @@ -1,6 +1,6 @@ @@ -14,23 +14,25 @@ @@ -50,25 +52,26 @@ foreach ($sql_debug as $sql_error) { @@ -95,12 +97,10 @@ if ($_SESSION['userlevel'] >= '10') { if (is_admin() === TRUE || is_read() === TRUE) { $sql = "SELECT `type`,COUNT(`type`) AS total_type FROM `devices` AS D WHERE 1 GROUP BY `type` ORDER BY `type`"; -} -else { +} else { $sql = "SELECT `type`,COUNT(`type`) AS total_type FROM `devices` AS `D`, `devices_perms` AS `P` WHERE `P`.`user_id` = ? AND `P`.`device_id` = `D`.`device_id` GROUP BY `type` ORDER BY `type`"; $param[] = $_SESSION['user_id']; } - foreach (dbFetchRows($sql,$param) as $devtype) { if (empty($devtype['type'])) { $devtype['type'] = 'generic'; @@ -108,10 +108,9 @@ foreach (dbFetchRows($sql,$param) as $devtype) { echo('
  • ' . ucfirst($devtype['type']) . '
  • '); } -require_once '../includes/device-groups.inc.php'; - +require_once('../includes/device-groups.inc.php'); foreach( GetDeviceGroups() as $group ) { - echo '
  • '.ucfirst($group['name']).'
  • '; + echo '
  • '.ucfirst($group['name']).'
  • '; } unset($group); @@ -119,24 +118,29 @@ unset($group); '); if ($_SESSION['userlevel'] >= '10') { - if ($config['show_locations']) { - echo(' +if ($config['show_locations']) +{ + + echo(' - '); + Locations + + + '); +} + echo('
  • Manage Groups
  • Add Device
  • @@ -151,7 +155,8 @@ if ($_SESSION['userlevel'] >= '10') {
  • Alerts ('.$service_alerts.')
  • '); } -if ($_SESSION['userlevel'] >= '10') { - echo(' +if ($_SESSION['userlevel'] >= '10') +{ + echo('
  • Add Service
  • Edit Service
  • @@ -190,53 +197,36 @@ if ($_SESSION['userlevel'] >= '10') { 0) { - echo('
  • Errored ('.$ports['errored'].')
  • '); +if ($ports['errored'] > 0) +{ + echo('
  • Errored ('.$ports['errored'].')
  • '); } -if ($ports['ignored'] > 0) { - echo('
  • Ignored ('.$ports['ignored'].')
  • '); +if ($ports['ignored'] > 0) +{ + echo('
  • Ignored ('.$ports['ignored'].')
  • '); } if ($config['enable_billing']) { - echo('
  • Traffic Bills
  • '); - $ifbreak = 1; + echo('
  • Traffic Bills
  • '); $ifbreak = 1; } if ($config['enable_pseudowires']) { - echo('
  • Pseudowires
  • '); - $ifbreak = 1; + echo('
  • Pseudowires
  • '); $ifbreak = 1; } ?> = '5') { - echo(' '); - if ($config['int_customers']) { - echo('
  • Customers
  • '); - $ifbreak = 1; - } - if ($config['int_l2tp']) { - echo('
  • L2TP
  • '); - $ifbreak = 1; - } - if ($config['int_transit']) { - echo('
  • Transit
  • '); - $ifbreak = 1; - } - if ($config['int_peering']) { - echo('
  • Peering
  • '); - $ifbreak = 1; - } - if ($config['int_peering'] && $config['int_transit']) { - echo('
  • Peering + Transit
  • '); - $ifbreak = 1; - } - if ($config['int_core']) { - echo('
  • Core
  • '); - $ifbreak = 1; - } +if ($_SESSION['userlevel'] >= '5') +{ + echo(' '); + if ($config['int_customers']) { echo('
  • Customers
  • '); $ifbreak = 1; } + if ($config['int_l2tp']) { echo('
  • L2TP
  • '); $ifbreak = 1; } + if ($config['int_transit']) { echo('
  • Transit
  • '); $ifbreak = 1; } + if ($config['int_peering']) { echo('
  • Peering
  • '); $ifbreak = 1; } + if ($config['int_peering'] && $config['int_transit']) { echo('
  • Peering + Transit
  • '); $ifbreak = 1; } + if ($config['int_core']) { echo('
  • Core
  • '); $ifbreak = 1; } if (is_array($config['custom_descr']) === FALSE) { $config['custom_descr'] = array($config['custom_descr']); } @@ -249,18 +239,21 @@ if ($_SESSION['userlevel'] >= '5') { } if ($ifbreak) { - echo(' '); + echo(' '); } -if (isset($interface_alerts)) { - echo('
  • Alerts ('.$interface_alerts.')
  • '); +if (isset($interface_alerts)) +{ + echo('
  • Alerts ('.$interface_alerts.')
  • '); } $deleted_ports = 0; -foreach (dbFetchRows("SELECT * FROM `ports` AS P, `devices` as D WHERE P.`deleted` = '1' AND D.device_id = P.device_id") as $interface) { - if (port_permitted($interface['port_id'], $interface['device_id'])) { - $deleted_ports++; - } +foreach (dbFetchRows("SELECT * FROM `ports` AS P, `devices` as D WHERE P.`deleted` = '1' AND D.device_id = P.device_id") as $interface) +{ + if (port_permitted($interface['port_id'], $interface['device_id'])) + { + $deleted_ports++; + } } ?> @@ -268,9 +261,7 @@ foreach (dbFetchRows("SELECT * FROM `ports` AS P, `devices` as D WHERE P.`delete
  • Disabled
  • Deleted ('.$deleted_ports.')'); -} +if ($deleted_ports) { echo('
  • Deleted ('.$deleted_ports.')
  • '); } ?> @@ -279,8 +270,9 @@ if ($deleted_ports) { Processor
  • Storage
  • '); +if ($menu_sensors) +{ + $sep = 0; + echo(' '); } $icons = array('fanspeed'=>'tachometer','humidity'=>'tint','temperature'=>'fire','current'=>'bolt','frequency'=>'line-chart','power'=>'power-off','voltage'=>'bolt','charge'=>'plus-square','dbm'=>'sun-o', 'load'=>'spinner','state'=>'bullseye'); -foreach (array('fanspeed','humidity','temperature') as $item) { - if (isset($menu_sensors[$item])) { - echo('
  • '.nicecase($item).'
  • '); - unset($menu_sensors[$item]);$sep++; - } -} - -if ($sep && array_keys($menu_sensors)) { - echo(' '); - $sep = 0; -} - -foreach (array('current','frequency','power','voltage') as $item) { - if (isset($menu_sensors[$item])) { - echo('
  • '.nicecase($item).'
  • '); - unset($menu_sensors[$item]);$sep++; - } -} - -if ($sep && array_keys($menu_sensors)) { - echo(' '); - $sep = 0; -} - -foreach (array_keys($menu_sensors) as $item) { +foreach (array('fanspeed','humidity','temperature') as $item) +{ + if (isset($menu_sensors[$item])) + { echo('
  • '.nicecase($item).'
  • '); unset($menu_sensors[$item]);$sep++; + } +} + +if ($sep && array_keys($menu_sensors)) +{ + echo(' '); + $sep = 0; +} + +foreach (array('current','frequency','power','voltage') as $item) +{ + if (isset($menu_sensors[$item])) + { + echo('
  • '.nicecase($item).'
  • '); + unset($menu_sensors[$item]);$sep++; + } +} + +if ($sep && array_keys($menu_sensors)) +{ + echo(' '); + $sep = 0; +} + +foreach (array_keys($menu_sensors) as $item) +{ + echo('
  • '.nicecase($item).'
  • '); + unset($menu_sensors[$item]);$sep++; } ?> @@ -337,24 +337,27 @@ foreach (array_keys($menu_sensors) as $item) { $app_count = dbFetchCell("SELECT COUNT(`app_id`) FROM `applications`"); -if ($_SESSION['userlevel'] >= '5' && ($app_count) > "0") { +if ($_SESSION['userlevel'] >= '5' && ($app_count) > "0") +{ ?> + = '5' && ($routing_count['bgp']+$routing_count['ospf']+$routing_count['cef']+$routing_count['vrf']) > "0") { +if ($_SESSION['userlevel'] >= '5' && ($routing_count['bgp']+$routing_count['ospf']+$routing_count['cef']+$routing_count['vrf']) > "0") +{ ?> @@ -427,11 +440,16 @@ if ( dbFetchCell("SELECT 1 from `packages` LIMIT 1") ) { = '10') { - if (dbFetchCell("SELECT COUNT(*) from `plugins` WHERE plugin_active = '1'") > 0) { - echo(''); - } - echo('
  • Plugin Admin
  • '); +if ($_SESSION['userlevel'] >= '10') +{ + if (dbFetchCell("SELECT COUNT(*) from `plugins` WHERE plugin_active = '1'") > 0) { + echo(' + + '); + } + echo(' +
  • Plugin Admin
  • + '); } ?> @@ -439,8 +457,9 @@ if ($_SESSION['userlevel'] >= '10') { @@ -457,42 +476,50 @@ if(is_file("includes/print-menubar-custom.inc.php")) {
    -"; +"); \ No newline at end of file diff --git a/html/includes/print-service-edit.inc.php b/html/includes/print-service-edit.inc.php index d0ad23a569..0954649d6d 100644 --- a/html/includes/print-service-edit.inc.php +++ b/html/includes/print-service-edit.inc.php @@ -1,33 +1,35 @@ Edit Service
    - - + +
    - +
    - +
    - +
    -
    "; -}//end if +"); + +} \ No newline at end of file diff --git a/html/includes/print-syslog.inc.php b/html/includes/print-syslog.inc.php index 1a7564920d..09467dd7c4 100644 --- a/html/includes/print-syslog.inc.php +++ b/html/includes/print-syslog.inc.php @@ -1,18 +1,23 @@ '; +if (device_permitted($entry['device_id'])) +{ + echo(""); - // Stop shortening hostname. Issue #61 - // $entry['hostname'] = shorthost($entry['hostname'], 20); - if ($vars['page'] != 'device') { - echo ''.$entry['date'].''; - echo ''.generate_device_link($entry).''; - echo ''.$entry['program'].' : '.htmlspecialchars($entry['msg']).''; - } - else { - echo ''.$entry['date'].'   '.$entry['program'].'   '.htmlspecialchars($entry['msg']).''; - } + // Stop shortening hostname. Issue #61 + //$entry['hostname'] = shorthost($entry['hostname'], 20); + + if ($vars['page'] != "device") + { + echo("" . $entry['date'] . ""); + echo("".generate_device_link($entry).""); + echo("" . $entry['program'] . " : " . htmlspecialchars($entry['msg']) . ""); + } else { + echo("" . $entry['date'] . "   " . $entry['program'] . "   " . htmlspecialchars($entry['msg']) . ""); + } + + echo(""); - echo ''; } + +?> diff --git a/html/includes/reports/alert-log.pdf.inc.php b/html/includes/reports/alert-log.pdf.inc.php index d293b474b9..5ee0e91ea1 100644 --- a/html/includes/reports/alert-log.pdf.inc.php +++ b/html/includes/reports/alert-log.pdf.inc.php @@ -1,83 +1,65 @@ AddPage('L'); -$where = '1'; -if (is_numeric($_GET['device_id'])) { - $where .= ' AND E.device_id = ?'; - $param[] = $_GET['device_id']; -} -if ($_GET['string']) { - $where .= ' AND R.rule LIKE ?'; - $param[] = '%'.$_GET['string'].'%'; -} + $where = "1"; + if (is_numeric($_GET['device_id'])) { + $where .= ' AND E.device_id = ?'; + $param[] = $_GET['device_id']; + } + if ($_GET['string']) { + $where .= " AND R.rule LIKE ?"; + $param[] = "%".$_GET['string']."%"; + } -if ($_SESSION['userlevel'] >= '5') { - $query = " FROM `alert_log` AS E LEFT JOIN devices AS D ON E.device_id=D.device_id RIGHT JOIN alert_rules AS R ON E.rule_id=R.id WHERE $where ORDER BY `humandate` DESC"; -} -else { - $query = " FROM `alert_log` AS E LEFT JOIN devices AS D ON E.device_id=D.device_id RIGHT JOIN alert_rules AS R ON E.rule_id=R.id RIGHT JOIN devices_perms AS P ON E.device_id = P.device_id WHERE $where AND P.user_id = ? ORDER BY `humandate` DESC"; - $param[] = $_SESSION['user_id']; -} + if ($_SESSION['userlevel'] >= '5') { + $query = " FROM `alert_log` AS E LEFT JOIN devices AS D ON E.device_id=D.device_id RIGHT JOIN alert_rules AS R ON E.rule_id=R.id WHERE $where ORDER BY `humandate` DESC"; + } else { + $query = " FROM `alert_log` AS E LEFT JOIN devices AS D ON E.device_id=D.device_id RIGHT JOIN alert_rules AS R ON E.rule_id=R.id RIGHT JOIN devices_perms AS P ON E.device_id = P.device_id WHERE $where AND P.user_id = ? ORDER BY `humandate` DESC"; + $param[] = $_SESSION['user_id']; + } -if (isset($_GET['start']) && is_numeric($_GET['start'])) { - $start = mres($_GET['start']); -} -else { - $start = 0; -} + if (isset($_GET['start']) && is_numeric($_GET['start'])) { + $start = mres($_GET['start']); + } else { + $start = 0; + } -if (isset($_GET['results']) && is_numeric($_GET['results'])) { - $numresults = mres($_GET['results']); -} -else { - $numresults = 250; -} + if (isset($_GET['results']) && is_numeric($_GET['results'])) { + $numresults = mres($_GET['results']); + } else { + $numresults = 250; + } -$full_query = "SELECT D.device_id,name,state,time_logged,DATE_FORMAT(time_logged, '".$config['dateformat']['mysql']['compact']."') as humandate $query LIMIT $start,$numresults"; + $full_query = "SELECT D.device_id,name,state,time_logged,DATE_FORMAT(time_logged, '".$config['dateformat']['mysql']['compact']."') as humandate $query LIMIT $start,$numresults"; -foreach (dbFetchRows($full_query, $param) as $alert_entry) { - $hostname = gethostbyid(mres($alert_entry['device_id'])); - $alert_state = $alert_entry['state']; + foreach (dbFetchRows($full_query, $param) as $alert_entry) { + $hostname = gethostbyid(mres($alert_entry['device_id'])); + $alert_state = $alert_entry['state']; - if ($alert_state != '') { - if ($alert_state == '0') { - $glyph_color = 'green'; - $text = 'Ok'; - } - else if ($alert_state == '1') { - $glyph_color = 'red'; - $text = 'Alert'; - } - else if ($alert_state == '2') { - $glyph_color = 'lightgrey'; - $text = 'Ack'; - } - else if ($alert_state == '3') { - $glyph_color = 'orange'; - $text = 'Worse'; - } - else if ($alert_state == '4') { - $glyph_color = 'khaki'; - $text = 'Better'; + if ($alert_state!='') { + if ($alert_state=='0') { + $glyph_color = 'green'; + $text = 'Ok'; + } elseif ($alert_state=='1') { + $glyph_color = 'red'; + $text = 'Alert'; + } elseif ($alert_state=='2') { + $glyph_color = 'lightgrey'; + $text = 'Ack'; + } elseif ($alert_state=='3') { + $glyph_color = 'orange'; + $text = 'Worse'; + } elseif ($alert_state=='4') { + $glyph_color = 'khaki'; + $text = 'Better'; + } + $data[] = array($alert_entry['time_logged'],$hostname,htmlspecialchars($alert_entry['name']),$text); } + } - $data[] = array( - $alert_entry['time_logged'], - $hostname, - htmlspecialchars($alert_entry['name']), - $text, - ); - }//end if -}//end foreach - -$header = array( - 'Datetime', - 'Device', - 'Log', - 'Status', -); +$header = array('Datetime', 'Device', 'Log', 'Status'); $table = << @@ -92,19 +74,17 @@ EOD; foreach ($data as $log) { if ($log[3] == 'Alert') { $tr_col = '#d39392'; - } - else { + } else { $tr_col = '#bbd392'; } - $table .= ' - + '.$log[0].' '.$log[1].' '.$log[2].' '.$log[3].' - - '; + + '; } $table .= << $value) { - if ($value != '') { - switch ($var) { - case 'hostname': - $where .= ' AND D.hostname LIKE ?'; - $param[] = '%'.$value.'%'; - break; +foreach ($vars as $var => $value) +{ + if ($value != "") + { + switch ($var) + { + case 'hostname': + $where .= " AND D.hostname LIKE ?"; + $param[] = "%".$value."%"; + break; + case 'location': + $where .= " AND D.location LIKE ?"; + $param[] = "%".$value."%"; + break; + case 'device_id': + $where .= " AND D.device_id = ?"; + $param[] = $value; + break; + case 'deleted': + case 'ignore': + if ($value == 1) + { + $where .= " AND (I.ignore = 1 OR D.ignore = 1) AND I.deleted = 0"; + } + break; + case 'disable': + case 'ifSpeed': + if (is_numeric($value)) + { + $where .= " AND I.$var = ?"; + $param[] = $value; + } + break; + case 'ifType': + $where .= " AND I.$var = ?"; + $param[] = $value; + break; + case 'ifAlias': + case 'port_descr_type': + $where .= " AND I.$var LIKE ?"; + $param[] = "%".$value."%"; + break; + case 'errors': + if ($value == 1) + { + $where .= " AND (I.`ifInErrors_delta` > '0' OR I.`ifOutErrors_delta` > '0')"; + } + break; + case 'state': + if ($value == "down") + { + $where .= "AND I.ifAdminStatus = ? AND I.ifOperStatus = ?"; + $param[] = "up"; + $param[] = "down"; + } elseif($value == "up") { + $where .= "AND I.ifAdminStatus = ? AND I.ifOperStatus = ? AND I.ignore = '0' AND D.ignore='0' AND I.deleted='0'"; + $param[] = "up"; + $param[] = "up"; + } elseif($value == "admindown") { + $where .= "AND I.ifAdminStatus = ? AND D.ignore = 0"; + $param[] = "down"; + } + break; + } + } +} - case 'location': - $where .= ' AND D.location LIKE ?'; - $param[] = '%'.$value.'%'; - break; - - case 'device_id': - $where .= ' AND D.device_id = ?'; - $param[] = $value; - break; - - case 'deleted': - case 'ignore': - if ($value == 1) { - $where .= ' AND (I.ignore = 1 OR D.ignore = 1) AND I.deleted = 0'; - } - break; - - case 'disable': - case 'ifSpeed': - if (is_numeric($value)) { - $where .= " AND I.$var = ?"; - $param[] = $value; - } - break; - - case 'ifType': - $where .= " AND I.$var = ?"; - $param[] = $value; - break; - - case 'ifAlias': - case 'port_descr_type': - $where .= " AND I.$var LIKE ?"; - $param[] = '%'.$value.'%'; - break; - - case 'errors': - if ($value == 1) { - $where .= " AND (I.`ifInErrors_delta` > '0' OR I.`ifOutErrors_delta` > '0')"; - } - break; - - case 'state': - if ($value == 'down') { - $where .= 'AND I.ifAdminStatus = ? AND I.ifOperStatus = ?'; - $param[] = 'up'; - $param[] = 'down'; - } - else if ($value == 'up') { - $where .= "AND I.ifAdminStatus = ? AND I.ifOperStatus = ? AND I.ignore = '0' AND D.ignore='0' AND I.deleted='0'"; - $param[] = 'up'; - $param[] = 'up'; - } - else if ($value == 'admindown') { - $where .= 'AND I.ifAdminStatus = ? AND D.ignore = 0'; - $param[] = 'down'; - } - break; - }//end switch - }//end if -}//end foreach - -$query = 'SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id '.$where.' '.$query_sort; +$query = "SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id ".$where." ".$query_sort; $row = 1; -list($format, $subformat) = explode('_', $vars['format']); +list($format, $subformat) = explode("_", $vars['format']); $ports = dbFetchRows($query, $param); -switch ($vars['sort']) { -case 'traffic': +switch ($vars['sort']) +{ + case 'traffic': $ports = array_sort($ports, 'ifOctets_rate', SORT_DESC); break; - -case 'traffic_in': + case 'traffic_in': $ports = array_sort($ports, 'ifInOctets_rate', SORT_DESC); break; - -case 'traffic_out': + case 'traffic_out': $ports = array_sort($ports, 'ifOutOctets_rate', SORT_DESC); break; - -case 'packets': + case 'packets': $ports = array_sort($ports, 'ifUcastPkts_rate', SORT_DESC); break; - -case 'packets_in': + case 'packets_in': $ports = array_sort($ports, 'ifInUcastOctets_rate', SORT_DESC); break; - -case 'packets_out': + case 'packets_out': $ports = array_sort($ports, 'ifOutUcastOctets_rate', SORT_DESC); break; - -case 'errors': + case 'errors': $ports = array_sort($ports, 'ifErrors_rate', SORT_DESC); break; - -case 'speed': + case 'speed': $ports = array_sort($ports, 'ifSpeed', SORT_DESC); break; - -case 'port': + case 'port': $ports = array_sort($ports, 'ifDescr', SORT_ASC); break; - -case 'media': + case 'media': $ports = array_sort($ports, 'ifType', SORT_ASC); break; - -case 'descr': + case 'descr': $ports = array_sort($ports, 'ifAlias', SORT_ASC); break; - -case 'device': -default: + case 'device': + default: $ports = array_sort($ports, 'hostname', SORT_ASC); -}//end switch - -$csv[] = array( - 'Device', - 'Port', - 'Speed', - 'Down', - 'Up', - 'Media', - 'Description', -); -foreach ($ports as $port) { - if (port_permitted($port['port_id'], $port['device_id'])) { - $speed = humanspeed($port['ifSpeed']); - $type = humanmedia($port['ifType']); - $port['in_rate'] = formatRates(($port['ifInOctets_rate'] * 8)); - $port['out_rate'] = formatRates(($port['ifOutOctets_rate'] * 8)); - $port = ifLabel($port, $device); - $csv[] = array( - $port['hostname'], - fixIfName($port['label']), - $speed, - $port['in_rate'], - $port['out_rate'], - $type, - $port['ifAlias'], - ); - } } + +$csv[] = array('Device','Port','Speed','Down','Up','Media','Description'); +foreach( $ports as $port ) { + if( port_permitted($port['port_id'], $port['device_id']) ) { + $speed = humanspeed($port['ifSpeed']); + $type = humanmedia($port['ifType']); + $port['in_rate'] = formatRates($port['ifInOctets_rate'] * 8); + $port['out_rate'] = formatRates($port['ifOutOctets_rate'] * 8); + $port = ifLabel($port, $device); + $csv[] = array($port['hostname'],fixIfName($port['label']),$speed,$port['in_rate'],$port['out_rate'],$type,$port['ifAlias']); + } +} +?> diff --git a/html/includes/service-add.inc.php b/html/includes/service-add.inc.php index cf1433b274..3bc9eca630 100644 --- a/html/includes/service-add.inc.php +++ b/html/includes/service-add.inc.php @@ -5,6 +5,6 @@ $updated = '1'; $service_id = add_service(mres($_POST['device']), mres($_POST['type']), mres($_POST['descr']), mres($_POST['ip']), mres($_POST['params'])); if ($service_id) { - $message .= $message_break.'Service added ('.$service_id.')!'; - $message_break .= '
    '; -} + $message .= $message_break . "Service added (".$service_id.")!"; + $message_break .= "
    "; +} \ No newline at end of file diff --git a/html/includes/table/address-search.inc.php b/html/includes/table/address-search.inc.php index 25eb75360e..a50d06afc7 100644 --- a/html/includes/table/address-search.inc.php +++ b/html/includes/table/address-search.inc.php @@ -2,64 +2,56 @@ $param = array(); -if (is_admin() === false && is_read() === false) { - $perms_sql .= ' LEFT JOIN `devices_perms` AS `DP` ON `D`.`device_id` = `DP`.`device_id`'; - $where .= ' AND `DP`.`user_id`=?'; - $param[] = array($_SESSION['user_id']); +if (is_admin() === FALSE && is_read() === FALSE) { + $perms_sql .= " LEFT JOIN `devices_perms` AS `DP` ON `D`.`device_id` = `DP`.`device_id`"; + $where .= " AND `DP`.`user_id`=?"; + $param[] = array($_SESSION['user_id']); } -list($address,$prefix) = explode('/', $_POST['address']); +list($address,$prefix) = explode("/", $_POST['address']); if ($_POST['search_type'] == 'ipv4') { - $sql = ' FROM `ipv4_addresses` AS A, `ports` AS I, `ipv4_networks` AS N, `devices` AS D'; + $sql = " FROM `ipv4_addresses` AS A, `ports` AS I, `ipv4_networks` AS N, `devices` AS D"; $sql .= $perms_sql; $sql .= " WHERE I.port_id = A.port_id AND I.device_id = D.device_id AND N.ipv4_network_id = A.ipv4_network_id $where "; if (!empty($address)) { $sql .= " AND ipv4_address LIKE '%".$address."%'"; } - if (!empty($prefix)) { - $sql .= " AND ipv4_prefixlen='?'"; + $sql .= " AND ipv4_prefixlen='?'"; $param[] = array($prefix); } -} -else if ($_POST['search_type'] == 'ipv6') { - $sql = ' FROM `ipv6_addresses` AS A, `ports` AS I, `ipv6_networks` AS N, `devices` AS D'; +} elseif ($_POST['search_type'] == 'ipv6') { + $sql = " FROM `ipv6_addresses` AS A, `ports` AS I, `ipv6_networks` AS N, `devices` AS D"; $sql .= $perms_sql; $sql .= " WHERE I.port_id = A.port_id AND I.device_id = D.device_id AND N.ipv6_network_id = A.ipv6_network_id $where "; if (!empty($address)) { $sql .= " AND (ipv6_address LIKE '%".$address."%' OR ipv6_compressed LIKE '%".$address."%')"; } - if (!empty($prefix)) { $sql .= " AND ipv6_prefixlen = '$prefix'"; } -} -else if ($_POST['search_type'] == 'mac') { - $sql = ' FROM `ports` AS I, `devices` AS D'; +} elseif ($_POST['search_type'] == 'mac') { + $sql = " FROM `ports` AS I, `devices` AS D"; $sql .= $perms_sql; - $sql .= " WHERE I.device_id = D.device_id AND `ifPhysAddress` LIKE '%".str_replace(array(':', ' ', '-', '.', '0x'), '', mres($_POST['address']))."%' $where "; -}//end if + $sql .= " WHERE I.device_id = D.device_id AND `ifPhysAddress` LIKE '%".str_replace(array(':', ' ', '-', '.', '0x'),'',mres($_POST['address']))."%' $where "; +} if (is_numeric($_POST['device_id'])) { - $sql .= ' AND I.device_id = ?'; + $sql .= " AND I.device_id = ?"; $param[] = array($_POST['device_id']); } - if ($_POST['interface']) { - $sql .= " AND I.ifDescr LIKE '?'"; + $sql .= " AND I.ifDescr LIKE '?'"; $param[] = array($_POST['interface']); } if ($_POST['search_type'] == 'ipv4') { $count_sql = "SELECT COUNT(`ipv4_address_id`) $sql"; -} -else if ($_POST['search_type'] == 'ipv6') { +} elseif ($_POST['search_type'] == 'ipv6') { $count_sql = "SELECT COUNT(`ipv6_address_id`) $sql"; +} elseif ($_POST['search_type'] == 'mac') { + $count_sql = "SELECT COUNT(`port_id`) $sql"; } -else if ($_POST['search_type'] == 'mac') { - $count_sql = "SELECT COUNT(`port_id`) $sql"; -} - -$total = dbFetchCell($count_sql, $param); +$total = dbFetchCell($count_sql,$param); if (empty($total)) { $total = 0; } @@ -71,7 +63,7 @@ if (!isset($sort) || empty($sort)) { $sql .= " ORDER BY $sort"; if (isset($current)) { - $limit_low = (($current * $rowCount) - ($rowCount)); + $limit_low = ($current * $rowCount) - ($rowCount); $limit_high = $rowCount; } @@ -83,42 +75,31 @@ $sql = "SELECT *,`I`.`ifDescr` AS `interface` $sql"; foreach (dbFetchRows($sql, $param) as $interface) { $speed = humanspeed($interface['ifSpeed']); - $type = humanmedia($interface['ifType']); + $type = humanmedia($interface['ifType']); if ($_POST['search_type'] == 'ipv6') { - list($prefix, $length) = explode('/', $interface['ipv6_network']); - $address = Net_IPv6::compress($interface['ipv6_address']).'/'.$length; - } - else if ($_POST['search_type'] == 'mac') { + list($prefix, $length) = explode("/", $interface['ipv6_network']); + $address = Net_IPv6::compress($interface['ipv6_address']) . '/'.$length; + } elseif ($_POST['search_type'] == 'mac') { $address = formatMac($interface['ifPhysAddress']); - } - else { - list($prefix, $length) = explode('/', $interface['ipv4_network']); - $address = $interface['ipv4_address'].'/'.$length; + } else { + list($prefix, $length) = explode("/", $interface['ipv4_network']); + $address = $interface['ipv4_address'] . '/' .$length; } if ($interface['in_errors'] > 0 || $interface['out_errors'] > 0) { - $error_img = generate_port_link($interface, "Interface Errors", errors); + $error_img = generate_port_link($interface,"Interface Errors",errors); + } else { + $error_img = ""; } - else { - $error_img = ''; - } - if (port_permitted($interface['port_id'])) { - $interface = ifLabel($interface, $interface); - $response[] = array( - 'hostname' => generate_device_link($interface), - 'interface' => generate_port_link($interface).' '.$error_img, - 'address' => $address, - 'description' => $interface['ifAlias'], - ); + $interface = ifLabel ($interface, $interface); + $response[] = array('hostname'=>generate_device_link($interface), + 'interface'=>generate_port_link($interface) . ' ' . $error_img, + 'address'=>$address, + 'description'=>$interface['ifAlias']); } -}//end foreach +} -$output = array( - 'current' => $current, - 'rowCount' => $rowCount, - 'rows' => $response, - 'total' => $total, -); +$output = array('current'=>$current,'rowCount'=>$rowCount,'rows'=>$response,'total'=>$total); echo _json_encode($output); diff --git a/html/includes/table/alert-schedule.inc.php b/html/includes/table/alert-schedule.inc.php index 5d2bfa9b89..635e67be92 100644 --- a/html/includes/table/alert-schedule.inc.php +++ b/html/includes/table/alert-schedule.inc.php @@ -16,9 +16,8 @@ $where = 1; if ($_SESSION['userlevel'] >= '5') { $sql = " FROM `alert_schedule` AS S WHERE $where"; -} -else { - $sql = " FROM `alert_schedule` AS S WHERE $where"; +} else { + $sql = " FROM `alert_schedule` AS S WHERE $where"; $param[] = $_SESSION['user_id']; } @@ -27,7 +26,7 @@ if (isset($searchPhrase) && !empty($searchPhrase)) { } $count_sql = "SELECT COUNT(`id`) $sql"; -$total = dbFetchCell($count_sql, $param); +$total = dbFetchCell($count_sql,$param); if (empty($total)) { $total = 0; } @@ -39,7 +38,7 @@ if (!isset($sort) || empty($sort)) { $sql .= " ORDER BY $sort"; if (isset($current)) { - $limit_low = (($current * $rowCount) - ($rowCount)); + $limit_low = ($current * $rowCount) - ($rowCount); $limit_high = $rowCount; } @@ -49,29 +48,20 @@ if ($rowCount != -1) { $sql = "SELECT `S`.`schedule_id`, DATE_FORMAT(`S`.`start`, '".$config['dateformat']['mysql']['compact']."') AS `start`, DATE_FORMAT(`S`.`end`, '".$config['dateformat']['mysql']['compact']."') AS `end`, `S`.`title` $sql"; -foreach (dbFetchRows($sql, $param) as $schedule) { +foreach (dbFetchRows($sql,$param) as $schedule) { $status = 0; if ($schedule['end'] < date('dS M Y H:i::s')) { $status = 1; } - if (date('dS M Y H:i::s') >= $schedule['start'] && date('dS M Y H:i::s') < $schedule['end']) { $status = 2; } - - $response[] = array( - 'title' => $schedule['title'], - 'start' => $schedule['start'], - 'end' => $schedule['end'], - 'id' => $schedule['schedule_id'], - 'status' => $status, - ); + $response[] = array('title'=>$schedule['title'], + 'start'=>$schedule['start'], + 'end'=>$schedule['end'], + 'id'=>$schedule['schedule_id'], + 'status'=>$status); } -$output = array( - 'current' => $current, - 'rowCount' => $rowCount, - 'rows' => $response, - 'total' => $total, -); +$output = array('current'=>$current,'rowCount'=>$rowCount,'rows'=>$response,'total'=>$total); echo _json_encode($output); diff --git a/html/includes/table/alertlog.inc.php b/html/includes/table/alertlog.inc.php index 8b4d94d3e2..0c8e515e62 100644 --- a/html/includes/table/alertlog.inc.php +++ b/html/includes/table/alertlog.inc.php @@ -3,15 +3,14 @@ $where = 1; if (is_numeric($_POST['device_id'])) { - $where .= ' AND E.device_id = ?'; + $where .= ' AND E.device_id = ?'; $param[] = $_POST['device_id']; } if ($_SESSION['userlevel'] >= '5') { $sql = " FROM `alert_log` AS E LEFT JOIN devices AS D ON E.device_id=D.device_id RIGHT JOIN alert_rules AS R ON E.rule_id=R.id WHERE $where"; -} -else { - $sql = " FROM `alert_log` AS E LEFT JOIN devices AS D ON E.device_id=D.device_id RIGHT JOIN alert_rules AS R ON E.rule_id=R.id RIGHT JOIN devices_perms AS P ON E.device_id = P.device_id WHERE $where AND P.user_id = ?"; +} else { + $sql = " FROM `alert_log` AS E LEFT JOIN devices AS D ON E.device_id=D.device_id RIGHT JOIN alert_rules AS R ON E.rule_id=R.id RIGHT JOIN devices_perms AS P ON E.device_id = P.device_id WHERE $where AND P.user_id = ?"; $param[] = array($_SESSION['user_id']); } @@ -20,7 +19,7 @@ if (isset($searchPhrase) && !empty($searchPhrase)) { } $count_sql = "SELECT COUNT(`E`.`id`) $sql"; -$total = dbFetchCell($count_sql, $param); +$total = dbFetchCell($count_sql,$param); if (empty($total)) { $total = 0; } @@ -32,7 +31,7 @@ if (!isset($sort) || empty($sort)) { $sql .= " ORDER BY $sort"; if (isset($current)) { - $limit_low = (($current * $rowCount) - ($rowCount)); + $limit_low = ($current * $rowCount) - ($rowCount); $limit_high = $rowCount; } @@ -43,49 +42,42 @@ if ($rowCount != -1) { $sql = "SELECT D.device_id,name AS alert,state,time_logged,DATE_FORMAT(time_logged, '".$config['dateformat']['mysql']['compact']."') as humandate,details $sql"; $rulei = 0; -foreach (dbFetchRows($sql, $param) as $alertlog) { - $dev = device_by_id_cache($alertlog['device_id']); +foreach (dbFetchRows($sql,$param) as $alertlog) { + $dev = device_by_id_cache($alertlog['device_id']); $fault_detail = alert_details($alertlog['details']); - $alert_state = $alertlog['state']; - if ($alert_state == '0') { - $glyph_icon = 'ok'; + $alert_state = $alertlog['state']; + if ($alert_state=='0') { + $glyph_icon = 'ok'; $glyph_color = 'green'; - $text = 'Ok'; + $text = 'Ok'; } - else if ($alert_state == '1') { - $glyph_icon = 'remove'; + elseif ($alert_state=='1') { + $glyph_icon = 'remove'; $glyph_color = 'red'; - $text = 'Alert'; + $text = 'Alert'; } - else if ($alert_state == '2') { - $glyph_icon = 'info-sign'; + elseif ($alert_state=='2') { + $glyph_icon = 'info-sign'; $glyph_color = 'lightgrey'; - $text = 'Ack'; + $text = 'Ack'; } - else if ($alert_state == '3') { - $glyph_icon = 'arrow-down'; + elseif ($alert_state=='3') { + $glyph_icon = 'arrow-down'; $glyph_color = 'orange'; - $text = 'Worse'; + $text = 'Worse'; } - else if ($alert_state == '4') { - $glyph_icon = 'arrow-up'; + elseif ($alert_state=='4') { + $glyph_icon = 'arrow-up'; $glyph_color = 'khaki'; - $text = 'Better'; - }//end if - $response[] = array( - 'id' => $rulei++, - 'time_logged' => $alertlog['humandate'], - 'details' => '', - 'hostname' => '
    '.generate_device_link($dev, shorthost($dev['hostname'])).'
    '.$fault_detail.'
    ', - 'alert' => htmlspecialchars($alertlog['alert']), - 'status' => " $text", - ); -}//end foreach + $text = 'Better'; + } + $response[] = array('id'=>$rulei++, + 'time_logged'=>$alertlog['humandate'], + 'details'=>'', + 'hostname'=>'
    '.generate_device_link($dev, shorthost($dev['hostname'])).'
    '.$fault_detail.'
    ', + 'alert'=>htmlspecialchars($alertlog['alert']), + 'status'=>" $text"); +} -$output = array( - 'current' => $current, - 'rowCount' => $rowCount, - 'rows' => $response, - 'total' => $total, -); -echo _json_encode($output); +$output = array('current'=>$current,'rowCount'=>$rowCount,'rows'=>$response,'total'=>$total); +echo _json_encode($output); diff --git a/html/includes/table/alerts.inc.php b/html/includes/table/alerts.inc.php index 2efab5d1f1..799404b1a4 100644 --- a/html/includes/table/alerts.inc.php +++ b/html/includes/table/alerts.inc.php @@ -10,18 +10,18 @@ if (isset($searchPhrase) && !empty($searchPhrase)) { $sql_search .= " AND (`timestamp` LIKE '%$searchPhrase%' OR `rule` LIKE '%$searchPhrase%' OR `name` LIKE '%$searchPhrase%' OR `hostname` LIKE '%$searchPhrase%')"; } -$sql = ' FROM `alerts` LEFT JOIN `devices` ON `alerts`.`device_id`=`devices`.`device_id`'; +$sql = " FROM `alerts` LEFT JOIN `devices` ON `alerts`.`device_id`=`devices`.`device_id`"; -if (is_admin() === false && is_read() === false) { - $sql .= ' LEFT JOIN `devices_perms` AS `DP` ON `devices`.`device_id` = `DP`.`device_id`'; - $where .= ' AND `DP`.`user_id`=?'; +if (is_admin() === FALSE && is_read() === FALSE) { + $sql .= " LEFT JOIN `devices_perms` AS `DP` ON `devices`.`device_id` = `DP`.`device_id`"; + $where .= " AND `DP`.`user_id`=?"; $param[] = $_SESSION['user_id']; } $sql .= " RIGHT JOIN alert_rules ON alerts.rule_id=alert_rules.id WHERE $where AND `state` IN (1,2,3,4) $sql_search"; $count_sql = "SELECT COUNT(`alerts`.`id`) $sql"; -$total = dbFetchCell($count_sql, $param); +$total = dbFetchCell($count_sql,$param); if (empty($total)) { $total = 0; } @@ -33,7 +33,7 @@ if (!isset($sort) || empty($sort)) { $sql .= " ORDER BY $sort"; if (isset($current)) { - $limit_low = (($current * $rowCount) - ($rowCount)); + $limit_low = ($current * $rowCount) - ($rowCount); $limit_high = $rowCount; } @@ -43,86 +43,76 @@ if ($rowCount != -1) { $sql = "SELECT `alerts`.*, `devices`.`hostname` AS `hostname`,`alert_rules`.`rule` AS `rule`, `alert_rules`.`name` AS `name`, `alert_rules`.`severity` AS `severity` $sql"; -$rulei = 0; +$rulei = 0; $format = $_POST['format']; -foreach (dbFetchRows($sql, $param) as $alert) { - $log = dbFetchCell('SELECT details FROM alert_log WHERE rule_id = ? AND device_id = ? ORDER BY id DESC LIMIT 1', array($alert['rule_id'], $alert['device_id'])); +foreach (dbFetchRows($sql,$param) as $alert) { + $log = dbFetchCell("SELECT details FROM alert_log WHERE rule_id = ? AND device_id = ? ORDER BY id DESC LIMIT 1", array($alert['rule_id'],$alert['device_id'])); $fault_detail = alert_details($log); - $ico = 'ok'; - $col = 'green'; - $extra = ''; - $msg = ''; - if ((int) $alert['state'] === 0) { - $ico = 'ok'; - $col = 'green'; - $extra = 'success'; - $msg = 'ok'; - } - else if ((int) $alert['state'] === 1 || (int) $alert['state'] === 3 || (int) $alert['state'] === 4) { - $ico = 'volume-up'; - $col = 'red'; - $extra = 'danger'; - $msg = 'alert'; - if ((int) $alert['state'] === 3) { - $msg = 'worse'; - } - else if ((int) $alert['state'] === 4) { - $msg = 'better'; + $ico = "ok"; + $col = "green"; + $extra = ""; + $msg = ""; + if ( (int) $alert['state'] === 0 ) { + $ico = "ok"; + $col = "green"; + $extra = "success"; + $msg = "ok"; + } elseif ( (int) $alert['state'] === 1 || (int) $alert['state'] === 3 || (int) $alert['state'] === 4) { + $ico = "volume-up"; + $col = "red"; + $extra = "danger"; + $msg = "alert"; + if ( (int) $alert['state'] === 3) { + $msg = "worse"; + } elseif ( (int) $alert['state'] === 4) { + $msg = "better"; } + } elseif ( (int) $alert['state'] === 2) { + $ico = "volume-off"; + $col = "#800080"; + $extra = "warning"; + $msg = "muted"; } - else if ((int) $alert['state'] === 2) { - $ico = 'volume-off'; - $col = '#800080'; - $extra = 'warning'; - $msg = 'muted'; - }//end if $alert_checked = ''; - $orig_ico = $ico; - $orig_col = $col; - $orig_class = $extra; + $orig_ico = $ico; + $orig_col = $col; + $orig_class = $extra; $severity = $alert['severity']; if ($alert['state'] == 3) { - $severity .= ' +'; - } - else if ($alert['state'] == 4) { - $severity .= ' -'; + $severity .= " +"; + } elseif ($alert['state'] == 4) { + $severity .= " -"; } $ack_ico = 'volume-up'; $ack_col = 'success'; - if ($alert['state'] == 2) { + if($alert['state'] == 2) { $ack_ico = 'volume-off'; $ack_col = 'danger'; - } + } $hostname = ' -
    - '.generate_device_link($alert).' -
    '.$fault_detail.'
    -
    '; +
    + '.generate_device_link($alert).' +
    '.$fault_detail.'
    +
    '; - $response[] = array( - 'id' => $rulei++, - 'rule' => ''.htmlentities($alert['name']).'', - 'details' => '', - 'hostname' => $hostname, - 'timestamp' => ($alert['timestamp'] ? $alert['timestamp'] : 'N/A'), - 'severity' => $severity, - 'ack_col' => $ack_col, - 'state' => $alert['state'], - 'alert_id' => $alert['id'], - 'ack_ico' => $ack_ico, - 'extra' => $extra, - 'msg' => $msg, - ); -}//end foreach + $response[] = array('id'=>$rulei++, + 'rule'=>"".htmlentities($alert['name'])."", + 'details'=>'', + 'hostname'=>$hostname, + 'timestamp'=>($alert['timestamp'] ? $alert['timestamp'] : "N/A"), + 'severity'=>$severity, + 'ack_col'=>$ack_col, + 'state'=>$alert['state'], + 'alert_id'=>$alert['id'], + 'ack_ico'=>$ack_ico, + 'extra'=>$extra, + 'msg'=>$msg); -$output = array( - 'current' => $current, - 'rowCount' => $rowCount, - 'rows' => $response, - 'total' => $total, -); +} + +$output = array('current'=>$current,'rowCount'=>$rowCount,'rows'=>$response,'total'=>$total); echo _json_encode($output); diff --git a/html/includes/table/arp-search.inc.php b/html/includes/table/arp-search.inc.php index 090476048f..dd5c6225ea 100644 --- a/html/includes/table/arp-search.inc.php +++ b/html/includes/table/arp-search.inc.php @@ -2,33 +2,32 @@ $param = array(); -$sql .= ' FROM `ipv4_mac` AS M, `ports` AS P, `devices` AS D '; +$sql .= " FROM `ipv4_mac` AS M, `ports` AS P, `devices` AS D "; -if (is_admin() === false && is_read() === false) { - $sql .= ' LEFT JOIN `devices_perms` AS `DP` ON `D`.`device_id` = `DP`.`device_id`'; - $where .= ' AND `DP`.`user_id`=?'; +if (is_admin() === FALSE && is_read() === FALSE) { + $sql .= " LEFT JOIN `devices_perms` AS `DP` ON `D`.`device_id` = `DP`.`device_id`"; + $where .= " AND `DP`.`user_id`=?"; $param[] = $_SESSION['user_id']; } $sql .= " WHERE M.port_id = P.port_id AND P.device_id = D.device_id $where "; -if (isset($_POST['searchby']) && $_POST['searchby'] == 'ip') { - $sql .= ' AND `ipv4_address` LIKE ?'; - $param[] = '%'.trim($_POST['address']).'%'; -} -else if (isset($_POST['searchby']) && $_POST['searchby'] == 'mac') { - $sql .= ' AND `mac_address` LIKE ?'; - $param[] = '%'.str_replace(array(':', ' ', '-', '.', '0x'), '', mres($_POST['address'])).'%'; +if (isset($_POST['searchby']) && $_POST['searchby'] == "ip") { + $sql .= " AND `ipv4_address` LIKE ?"; + $param[] = "%".trim($_POST['address'])."%"; +} elseif (isset($_POST['searchby']) && $_POST['searchby'] == "mac") { + $sql .= " AND `mac_address` LIKE ?"; + $param[] = "%".str_replace(array(':', ' ', '-', '.', '0x'),'',mres($_POST['address']))."%"; } if (is_numeric($_POST['device_id'])) { - $sql .= ' AND P.device_id = ?'; + $sql .= " AND P.device_id = ?"; $param[] = $_POST['device_id']; } $count_sql = "SELECT COUNT(`M`.`port_id`) $sql"; -$total = dbFetchCell($count_sql, $param); +$total = dbFetchCell($count_sql,$param); if (empty($total)) { $total = 0; } @@ -40,7 +39,7 @@ if (!isset($sort) || empty($sort)) { $sql .= " ORDER BY $sort"; if (isset($current)) { - $limit_low = (($current * $rowCount) - ($rowCount)); + $limit_low = ($current * $rowCount) - ($rowCount); $limit_high = $rowCount; } @@ -52,53 +51,39 @@ $sql = "SELECT *,`P`.`ifDescr` AS `interface` $sql"; foreach (dbFetchRows($sql, $param) as $entry) { if (!$ignore) { + if ($entry['ifInErrors'] > 0 || $entry['ifOutErrors'] > 0) { - $error_img = generate_port_link($entry, "Interface Errors", port_errors); - } - else { - $error_img = ''; + $error_img = generate_port_link($entry,"Interface Errors",port_errors); + } else { + $error_img = ""; } - $arp_host = dbFetchRow('SELECT * FROM ipv4_addresses AS A, ports AS I, devices AS D WHERE A.ipv4_address = ? AND I.port_id = A.port_id AND D.device_id = I.device_id', array($entry['ipv4_address'])); - if ($arp_host) { - $arp_name = generate_device_link($arp_host); - } - else { - unset($arp_name); - } - - if ($arp_host) { - $arp_if = generate_port_link($arp_host); - } - else { - unset($arp_if); - } - - if ($arp_host['device_id'] == $entry['device_id']) { - $arp_name = 'Localhost'; - } - - if ($arp_host['port_id'] == $entry['port_id']) { - $arp_if = 'Local port'; - } - - $response[] = array( - 'mac_address' => formatMac($entry['mac_address']), - 'ipv4_address' => $entry['ipv4_address'], - 'hostname' => generate_device_link($entry), - 'interface' => generate_port_link($entry, makeshortif(fixifname(ifLabel($entry['label'])))).' '.$error_img, - 'remote_device' => $arp_name, - 'remote_interface' => $arp_if, - ); - }//end if - + $arp_host = dbFetchRow("SELECT * FROM ipv4_addresses AS A, ports AS I, devices AS D WHERE A.ipv4_address = ? AND I.port_id = A.port_id AND D.device_id = I.device_id", array($entry['ipv4_address'])); + if ($arp_host) { + $arp_name = generate_device_link($arp_host); + } else { + unset($arp_name); + } + if ($arp_host) { + $arp_if = generate_port_link($arp_host); + } else { + unset($arp_if); + } + if ($arp_host['device_id'] == $entry['device_id']) { + $arp_name = "Localhost"; + } + if ($arp_host['port_id'] == $entry['port_id']) { + $arp_if = "Local port"; + } + $response[] = array('mac_address'=>formatMac($entry['mac_address']), + 'ipv4_address'=>$entry['ipv4_address'], + 'hostname'=>generate_device_link($entry), + 'interface'=>generate_port_link($entry, makeshortif(fixifname(ifLabel($entry['label'])))) . ' ' . $error_img, + 'remote_device'=>$arp_name, + 'remote_interface'=>$arp_if); + } unset($ignore); -}//end foreach +} -$output = array( - 'current' => $current, - 'rowCount' => $rowCount, - 'rows' => $response, - 'total' => $total, -); +$output = array('current'=>$current,'rowCount'=>$rowCount,'rows'=>$response,'total'=>$total); echo _json_encode($output); diff --git a/html/includes/table/devices.inc.php b/html/includes/table/devices.inc.php index 129e198f21..25cf21bd51 100644 --- a/html/includes/table/devices.inc.php +++ b/html/includes/table/devices.inc.php @@ -3,11 +3,11 @@ $where = 1; $param = array(); -$sql = ' FROM `devices`'; +$sql = " FROM `devices`"; -if (is_admin() === false && is_read() === false) { - $sql .= ' LEFT JOIN `devices_perms` AS `DP` ON `devices`.`device_id` = `DP`.`device_id`'; - $where .= ' AND `DP`.`user_id`=?'; +if (is_admin() === FALSE && is_read() === FALSE) { + $sql .= " LEFT JOIN `devices_perms` AS `DP` ON `devices`.`device_id` = `DP`.`device_id`"; + $where .= " AND `DP`.`user_id`=?"; $param[] = $_SESSION['user_id']; } @@ -17,87 +17,48 @@ if (!empty($_POST['location'])) { $sql .= " WHERE $where "; -if (!empty($_POST['hostname'])) { - $sql .= ' AND hostname LIKE ?'; - $param[] = '%'.$_POST['hostname'].'%'; +if (!empty($_POST['hostname'])) { $sql .= " AND hostname LIKE ?"; $param[] = "%".$_POST['hostname']."%"; } +if (!empty($_POST['os'])) { $sql .= " AND os = ?"; $param[] = $_POST['os']; } +if (!empty($_POST['version'])) { $sql .= " AND version = ?"; $param[] = $_POST['version']; } +if (!empty($_POST['hardware'])) { $sql .= " AND hardware = ?"; $param[] = $_POST['hardware']; } +if (!empty($_POST['features'])) { $sql .= " AND features = ?"; $param[] = $_POST['features']; } +if (!empty($_POST['type'])) { + if ($_POST['type'] == 'generic') { + $sql .= " AND ( type = ? OR type = '')"; $param[] = $_POST['type']; + } else { + $sql .= " AND type = ?"; $param[] = $_POST['type']; + } } - -if (!empty($_POST['os'])) { - $sql .= ' AND os = ?'; - $param[] = $_POST['os']; -} - -if (!empty($_POST['version'])) { - $sql .= ' AND version = ?'; - $param[] = $_POST['version']; -} - -if (!empty($_POST['hardware'])) { - $sql .= ' AND hardware = ?'; - $param[] = $_POST['hardware']; -} - -if (!empty($_POST['features'])) { - $sql .= ' AND features = ?'; - $param[] = $_POST['features']; -} - -if (!empty($_POST['type'])) { - if ($_POST['type'] == 'generic') { - $sql .= " AND ( type = ? OR type = '')"; - $param[] = $_POST['type']; - } - else { - $sql .= ' AND type = ?'; - $param[] = $_POST['type']; - } -} - if (!empty($_POST['state'])) { - $sql .= ' AND status= ?'; - if (is_numeric($_POST['state'])) { + $sql .= " AND status= ?"; + if( is_numeric($_POST['state']) ) { $param[] = $_POST['state']; - } - else { - $param[] = str_replace(array('up', 'down'), array(1, 0), $_POST['state']); + } else { + $param[] = str_replace(array('up','down'),array(1,0),$_POST['state']); } } - -if (!empty($_POST['disabled'])) { - $sql .= ' AND disabled= ?'; - $param[] = $_POST['disabled']; -} - -if (!empty($_POST['ignore'])) { - $sql .= ' AND `ignore`= ?'; - $param[] = $_POST['ignore']; -} - -if (!empty($_POST['location']) && $_POST['location'] == 'Unset') { - $location_filter = ''; -} - +if (!empty($_POST['disabled'])) { $sql .= " AND disabled= ?"; $param[] = $_POST['disabled']; } +if (!empty($_POST['ignore'])) { $sql .= " AND `ignore`= ?"; $param[] = $_POST['ignore']; } +if (!empty($_POST['location']) && $_POST['location'] == "Unset") { $location_filter = ''; } if (!empty($_POST['location'])) { - $sql .= " AND (((`DB`.`attrib_value`='1' AND `DA`.`attrib_type`='override_sysLocation_string' AND `DA`.`attrib_value` = ?)) OR `location` = ?)"; + $sql .= " AND (((`DB`.`attrib_value`='1' AND `DA`.`attrib_type`='override_sysLocation_string' AND `DA`.`attrib_value` = ?)) OR `location` = ?)"; $param[] = mres($_POST['location']); $param[] = mres($_POST['location']); } - -if (!empty($_POST['group'])) { - include_once '../includes/device-groups.inc.php'; - $sql .= ' AND ( '; - foreach (GetDevicesFromGroup($_POST['group']) as $dev) { - $sql .= '`devices`.`device_id` = ? OR '; +if( !empty($_POST['group']) ) { + require_once('../includes/device-groups.inc.php'); + $sql .= " AND ( "; + foreach( GetDevicesFromGroup($_POST['group']) as $dev ) { + $sql .= "`devices`.`device_id` = ? OR "; $param[] = $dev['device_id']; } - - $sql = substr($sql, 0, (strlen($sql) - 3)); - $sql .= ' )'; + $sql = substr($sql, 0, strlen($sql)-3); + $sql .= " )"; } $count_sql = "SELECT COUNT(`devices`.`device_id`) $sql"; -$total = dbFetchCell($count_sql, $param); +$total = dbFetchCell($count_sql,$param); if (empty($total)) { $total = 0; } @@ -109,7 +70,7 @@ if (!isset($sort) || empty($sort)) { $sql .= " ORDER BY $sort"; if (isset($current)) { - $limit_low = (($current * $rowCount) - ($rowCount)); + $limit_low = ($current * $rowCount) - ($rowCount); $limit_high = $rowCount; } @@ -120,124 +81,99 @@ if ($rowCount != -1) { $sql = "SELECT DISTINCT(`devices`.`device_id`),`devices`.* $sql"; if (!isset($_POST['format'])) { - $_POST['format'] = 'list_detail'; + $_POST['format'] = "list_detail"; } - -list($format, $subformat) = explode('_', $_POST['format']); +list($format, $subformat) = explode("_", $_POST['format']); foreach (dbFetchRows($sql, $param) as $device) { - if (isset($bg) && $bg == $list_colour_b) { - $bg = $list_colour_a; - } - else { - $bg = $list_colour_b; - } + if (isset($bg) && $bg == $list_colour_b) { + $bg = $list_colour_a; + } else { + $bg = $list_colour_b; + } - if ($device['status'] == '0') { - $extra = 'danger'; - $msg = $device['status_reason']; - } - else { - $extra = 'success'; - $msg = 'up'; - } + if ($device['status'] == '0') { + $extra = "danger"; + $msg = $device['status_reason']; + } else { + $extra = "success"; + $msg = "up"; + } + if ($device['ignore'] == '1') { + $extra = "default"; + $msg = "ignored"; + if ($device['status'] == '1') { + $extra = "warning"; + $msg = "ignored"; + } + } + if ($device['disabled'] == '1') { + $extra = "default"; + $msg = "disabled"; + } - if ($device['ignore'] == '1') { - $extra = 'default'; - $msg = 'ignored'; - if ($device['status'] == '1') { - $extra = 'warning'; - $msg = 'ignored'; - } - } + $type = strtolower($device['os']); + $image = getImage($device); + + if ($device['os'] == "ios") { + formatCiscoHardware($device, true); + } - if ($device['disabled'] == '1') { - $extra = 'default'; - $msg = 'disabled'; - } + $device['os_text'] = $config['os'][$device['os']]['text']; + $port_count = dbFetchCell("SELECT COUNT(*) FROM `ports` WHERE `device_id` = ?", array($device['device_id'])); + $sensor_count = dbFetchCell("SELECT COUNT(*) FROM `sensors` WHERE `device_id` = ?", array($device['device_id'])); - $type = strtolower($device['os']); - $image = getImage($device); + if (get_dev_attrib($device,'override_sysLocation_bool')) { + $device['location'] = get_dev_attrib($device,'override_sysLocation_string'); + } - if ($device['os'] == 'ios') { - formatCiscoHardware($device, true); - } + $actions = ('
    +
    '); + $actions .= ' View device '; + $actions .= ('
    +
    '); + $actions .= ' View alerts '; + $actions .= '
    '; + if ($_SESSION['userlevel'] >= "7") { + $actions .= ('
    + Edit device +
    '); + } + $actions .= ('
    +
    +
    + telnet +
    +
    + ssh +
    +
    + https +
    +
    '); - $device['os_text'] = $config['os'][$device['os']]['text']; - $port_count = dbFetchCell('SELECT COUNT(*) FROM `ports` WHERE `device_id` = ?', array($device['device_id'])); - $sensor_count = dbFetchCell('SELECT COUNT(*) FROM `sensors` WHERE `device_id` = ?', array($device['device_id'])); + $hostname = generate_device_link($device); + $platform = $device['hardware'] . '
    ' . $device['features']; + $os = $device['os_text'] . '
    ' . $device['version']; + if (extension_loaded('mbstring')) { + $location = mb_substr($device['location'], 0, 32, 'utf8'); + } else { + $location = truncate($device['location'], 32, ''); + } + $uptime = formatUptime($device['uptime'], 'short') . '
    ' . $location; + if ($subformat == "detail") { + $hostname .= '
    ' . $device['sysName']; + if ($port_count) { + $col_port = ' '.$port_count . '
    '; + } + if ($sensor_count) { + $col_port .= ' '.$sensor_count; + } + } else { - if (get_dev_attrib($device, 'override_sysLocation_bool')) { - $device['location'] = get_dev_attrib($device, 'override_sysLocation_string'); - } + } + $response[] = array('extra'=>$extra,'msg'=>$msg,'icon'=>$image,'hostname'=>$hostname,'ports'=>$col_port,'hardware'=>$platform,'os'=>$os,'uptime'=>$uptime,'actions'=>$actions); +} - $actions = ('
    -
    '); - $actions .= ' View device '; - $actions .= ('
    -
    '); - $actions .= ' View alerts '; - $actions .= '
    '; - if ($_SESSION['userlevel'] >= '7') { - $actions .= ('
    - Edit device -
    '); - } - - $actions .= ('
    -
    -
    - telnet -
    -
    - ssh -
    -
    - https -
    -
    '); - - $hostname = generate_device_link($device); - $platform = $device['hardware'].'
    '.$device['features']; - $os = $device['os_text'].'
    '.$device['version']; - if (extension_loaded('mbstring')) { - $location = mb_substr($device['location'], 0, 32, 'utf8'); - } - else { - $location = truncate($device['location'], 32, ''); - } - - $uptime = formatUptime($device['uptime'], 'short').'
    '.$location; - if ($subformat == 'detail') { - $hostname .= '
    '.$device['sysName']; - if ($port_count) { - $col_port = ' '.$port_count.'
    '; - } - - if ($sensor_count) { - $col_port .= ' '.$sensor_count; - } - } - else { - } - - $response[] = array( - 'extra' => $extra, - 'msg' => $msg, - 'icon' => $image, - 'hostname' => $hostname, - 'ports' => $col_port, - 'hardware' => $platform, - 'os' => $os, - 'uptime' => $uptime, - 'actions' => $actions, - ); -}//end foreach - -$output = array( - 'current' => $current, - 'rowCount' => $rowCount, - 'rows' => $response, - 'total' => $total, -); +$output = array('current'=>$current,'rowCount'=>$rowCount,'rows'=>$response,'total'=>$total); echo _json_encode($output); diff --git a/html/includes/table/eventlog.inc.php b/html/includes/table/eventlog.inc.php index 9cae422965..d5e5e7d60e 100644 --- a/html/includes/table/eventlog.inc.php +++ b/html/includes/table/eventlog.inc.php @@ -1,22 +1,23 @@ = '5') { $sql = " FROM `eventlog` AS E LEFT JOIN `devices` AS `D` ON `E`.`host`=`D`.`device_id` WHERE $where"; -} -else { - $sql = " FROM `eventlog` AS E, devices_perms AS P WHERE $where AND E.host = P.device_id AND P.user_id = ?"; +} else { + $sql = " FROM `eventlog` AS E, devices_perms AS P WHERE $where AND E.host = P.device_id AND P.user_id = ?"; $param[] = $_SESSION['user_id']; } @@ -25,7 +26,7 @@ if (isset($searchPhrase) && !empty($searchPhrase)) { } $count_sql = "SELECT COUNT(datetime) $sql"; -$total = dbFetchCell($count_sql, $param); +$total = dbFetchCell($count_sql,$param); if (empty($total)) { $total = 0; } @@ -37,7 +38,7 @@ if (!isset($sort) || empty($sort)) { $sql .= " ORDER BY $sort"; if (isset($current)) { - $limit_low = (($current * $rowCount) - ($rowCount)); + $limit_low = ($current * $rowCount) - ($rowCount); $limit_high = $rowCount; } @@ -47,28 +48,22 @@ if ($rowCount != -1) { $sql = "SELECT `E`.*,DATE_FORMAT(datetime, '".$config['dateformat']['mysql']['compact']."') as humandate $sql"; -foreach (dbFetchRows($sql, $param) as $eventlog) { +foreach (dbFetchRows($sql,$param) as $eventlog) { $dev = device_by_id_cache($eventlog['host']); - if ($eventlog['type'] == 'interface') { + if ($eventlog['type'] == "interface") { $this_if = ifLabel(getifbyid($eventlog['reference'])); - $type = ''.generate_port_link($this_if, makeshortif(strtolower($this_if['label']))).''; + $type = "".generate_port_link($this_if, makeshortif(strtolower($this_if['label']))).""; + } else { + $type = "System"; } - else { - $type = 'System'; - } - - $response[] = array( - 'datetime' => $eventlog['humandate'], - 'hostname' => generate_device_link($dev, shorthost($dev['hostname'])), - 'type' => $type, - 'message' => htmlspecialchars($eventlog['message']), - ); + + $response[] = array('datetime'=>$eventlog['humandate'], + 'hostname'=>generate_device_link($dev, shorthost($dev['hostname'])), + 'type'=>$type, + 'message'=>htmlspecialchars($eventlog['message'])); } -$output = array( - 'current' => $current, - 'rowCount' => $rowCount, - 'rows' => $response, - 'total' => $total, -); +$output = array('current'=>$current,'rowCount'=>$rowCount,'rows'=>$response,'total'=>$total); echo _json_encode($output); + +?> diff --git a/html/includes/table/inventory.inc.php b/html/includes/table/inventory.inc.php index 2e4c0b9281..6c5b92823f 100644 --- a/html/includes/table/inventory.inc.php +++ b/html/includes/table/inventory.inc.php @@ -1,15 +1,14 @@ = '5') { $sql = " FROM entPhysical AS E, devices AS D WHERE $where AND D.device_id = E.device_id"; -} -else { - $sql = " FROM entPhysical AS E, devices AS D, devices_perms AS P WHERE $where AND D.device_id = E.device_id AND P.device_id = D.device_id AND P.user_id = ?"; +} else { + $sql = " FROM entPhysical AS E, devices AS D, devices_perms AS P WHERE $where AND D.device_id = E.device_id AND P.device_id = D.device_id AND P.user_id = ?"; $param[] = $_SESSION['user_id']; } @@ -18,32 +17,32 @@ if (isset($searchPhrase) && !empty($searchPhrase)) { } if (isset($_POST['string']) && strlen($_POST['string'])) { - $sql .= ' AND E.entPhysicalDescr LIKE ?'; - $param[] = '%'.$_POST['string'].'%'; + $sql .= " AND E.entPhysicalDescr LIKE ?"; + $param[] = "%".$_POST['string']."%"; } if (isset($_POST['device_string']) && strlen($_POST['device_string'])) { - $sql .= ' AND D.hostname LIKE ?'; - $param[] = '%'.$_POST['device_string'].'%'; + $sql .= " AND D.hostname LIKE ?"; + $param[] = "%".$_POST['device_string']."%"; } if (isset($_POST['part']) && strlen($_POST['part'])) { - $sql .= ' AND E.entPhysicalModelName = ?'; - $param[] = $_POST['part']; + $sql .= " AND E.entPhysicalModelName = ?"; + $param[] = $_POST['part']; } if (isset($_POST['serial']) && strlen($_POST['serial'])) { - $sql .= ' AND E.entPhysicalSerialNum LIKE ?'; - $param[] = '%'.$_POST['serial'].'%'; + $sql .= " AND E.entPhysicalSerialNum LIKE ?"; + $param[] = "%".$_POST['serial']."%"; } if (isset($_POST['device']) && is_numeric($_POST['device'])) { - $sql .= ' AND D.device_id = ?'; - $param[] = $_POST['device']; + $sql .= " AND D.device_id = ?"; + $param[] = $_POST['device']; } $count_sql = "SELECT COUNT(`entPhysical_id`) $sql"; -$total = dbFetchCell($count_sql, $param); +$total = dbFetchCell($count_sql,$param); if (empty($total)) { $total = 0; } @@ -55,7 +54,7 @@ if (!isset($sort) || empty($sort)) { $sql .= " ORDER BY $sort"; if (isset($current)) { - $limit_low = (($current * $rowCount) - ($rowCount)); + $limit_low = ($current * $rowCount) - ($rowCount); $limit_high = $rowCount; } @@ -66,19 +65,12 @@ if ($rowCount != -1) { $sql = "SELECT `D`.`device_id` AS `device_id`, `D`.`hostname` AS `hostname`,`entPhysicalDescr` AS `description`, `entPhysicalName` AS `name`, `entPhysicalModelName` AS `model`, `entPhysicalSerialNum` AS `serial` $sql"; foreach (dbFetchRows($sql, $param) as $invent) { - $response[] = array( - 'hostname' => generate_device_link($invent, shortHost($invent['hostname'])), - 'description' => $invent['description'], - 'name' => $invent['name'], - 'model' => $invent['model'], - 'serial' => $invent['serial'], - ); + $response[] = array('hostname'=>generate_device_link($invent, shortHost($invent['hostname'])), + 'description'=>$invent['description'], + 'name'=>$invent['name'], + 'model'=>$invent['model'], + 'serial'=>$invent['serial']); } -$output = array( - 'current' => $current, - 'rowCount' => $rowCount, - 'rows' => $response, - 'total' => $total, - ); +$output = array('current'=>$current,'rowCount'=>$rowCount,'rows'=>$response,'total'=>$total); echo _json_encode($output); diff --git a/html/includes/table/mempool.inc.php b/html/includes/table/mempool.inc.php index 2afb80edc0..d3968a5317 100644 --- a/html/includes/table/mempool.inc.php +++ b/html/includes/table/mempool.inc.php @@ -1,88 +1,72 @@ generate_device_link($mempool), - 'mempool_descr' => $mempool['mempool_descr'], - 'graph' => $mini_graph, - 'mempool_used' => $bar_link, - 'mempool_perc' => $perc.'%', - ); - if ($_POST['view'] == 'graphs') { - $graph_array['height'] = '100'; - $graph_array['width'] = '216'; - $graph_array['to'] = $config['time']['now']; - $graph_array['id'] = $mempool['mempool_id']; - $graph_array['type'] = $graph_type; - $return_data = true; - include 'includes/print-graphrow.inc.php'; - unset($return_data); - $response[] = array( - 'hostname' => $graph_data[0], - 'mempool_descr' => $graph_data[1], - 'graph' => $graph_data[2], - 'mempool_used' => $graph_data[3], - 'mempool_perc' => '', - ); - } //end if -}//end foreach - -$output = array( - 'current' => $current, - 'rowCount' => $rowCount, - 'rows' => $response, - 'total' => $count, -); + $response[] = array('hostname' => generate_device_link($mempool), + 'mempool_descr' => $mempool['mempool_descr'], + 'graph' => $mini_graph, + 'mempool_used' => $bar_link, + 'mempool_perc' => $perc . "%"); + if ($_POST['view'] == "graphs") { + $graph_array['height'] = "100"; + $graph_array['width'] = "216"; + $graph_array['to'] = $config['time']['now']; + $graph_array['id'] = $mempool['mempool_id']; + $graph_array['type'] = $graph_type; + $return_data = true; + include("includes/print-graphrow.inc.php"); + unset($return_data); + $response[] = array('hostname' => $graph_data[0], + 'mempool_descr' => $graph_data[1], + 'graph' => $graph_data[2], + 'mempool_used' => $graph_data[3], + 'mempool_perc' => ''); + } # endif graphs +} +$output = array('current'=>$current,'rowCount'=>$rowCount,'rows'=>$response,'total'=>$count); echo _json_encode($output); diff --git a/html/includes/table/poll-log.inc.php b/html/includes/table/poll-log.inc.php index 3579759b6c..3a0ca3213e 100644 --- a/html/includes/table/poll-log.inc.php +++ b/html/includes/table/poll-log.inc.php @@ -1,12 +1,11 @@ " 'graphs', 'group' => 'poller'))."'>".$device['hostname'].'', - 'last_polled' => $device['last_polled'], - 'last_polled_timetaken' => $device['last_polled_timetaken'], - ); + $response[] = array('hostname' => " 'graphs', 'group' => 'poller')). "'>" .$device['hostname']. "", + 'last_polled' => $device['last_polled'], + 'last_polled_timetaken' => $device['last_polled_timetaken']); } -$output = array( - 'current' => $current, - 'rowCount' => $rowCount, - 'rows' => $response, - 'total' => $total, -); +$output = array('current'=>$current,'rowCount'=>$rowCount,'rows'=>$response,'total'=>$total); echo _json_encode($output); + +?> diff --git a/html/includes/table/processor.inc.php b/html/includes/table/processor.inc.php index bcedd6196f..a7b3d97457 100644 --- a/html/includes/table/processor.inc.php +++ b/html/includes/table/processor.inc.php @@ -1,83 +1,67 @@ generate_device_link($processor), - 'processor_descr' => $processor['processor_descr'], - 'graph' => $mini_graph, - 'processor_usage' => $bar_link, - ); - if ($_POST['view'] == 'graphs') { - $graph_array['height'] = '100'; - $graph_array['width'] = '216'; - $graph_array['to'] = $config['time']['now']; - $graph_array['id'] = $processor['processor_id']; - $graph_array['type'] = $graph_type; - $return_data = true; - include 'includes/print-graphrow.inc.php'; - unset($return_data); - $response[] = array( - 'hostname' => $graph_data[0], - 'processor_descr' => $graph_data[1], - 'graph' => $graph_data[2], - 'processor_usage' => $graph_data[3], - ); - } //end if -}//end foreach - -$output = array( - 'current' => $current, - 'rowCount' => $rowCount, - 'rows' => $response, - 'total' => $total, -); + $response[] = array('hostname' => generate_device_link($processor), + 'processor_descr' => $processor['processor_descr'], + 'graph' => $mini_graph, + 'processor_usage' => $bar_link); + if ($_POST['view'] == "graphs") { + $graph_array['height'] = "100"; + $graph_array['width'] = "216"; + $graph_array['to'] = $config['time']['now']; + $graph_array['id'] = $processor['processor_id']; + $graph_array['type'] = $graph_type; + $return_data = true; + include("includes/print-graphrow.inc.php"); + unset($return_data); + $response[] = array('hostname' => $graph_data[0], + 'processor_descr' => $graph_data[1], + 'graph' => $graph_data[2], + 'processor_usage' => $graph_data[3]); + } # endif graphs +} +$output = array('current'=>$current,'rowCount'=>$rowCount,'rows'=>$response,'total'=>$total); echo _json_encode($output); diff --git a/html/includes/table/storage.inc.php b/html/includes/table/storage.inc.php index 3d301456f0..a912ba1d2e 100644 --- a/html/includes/table/storage.inc.php +++ b/html/includes/table/storage.inc.php @@ -1,14 +1,14 @@ generate_device_link($drive), - 'storage_descr' => $drive['storage_descr'], - 'graph' => $mini_graph, - 'storage_used' => $bar_link, - 'storage_perc' => $perc.'%', - ); - if ($_POST['view'] == 'graphs') { - $graph_array['height'] = '100'; - $graph_array['width'] = '216'; - $graph_array['to'] = $config['time']['now']; - $graph_array['id'] = $drive['storage_id']; - $graph_array['type'] = $graph_type; + $graph_array['type'] = $graph_type; + $graph_array['id'] = $drive['storage_id']; + $graph_array['from'] = $config['time']['day']; + $graph_array['to'] = $config['time']['now']; + $graph_array['height'] = "20"; + $graph_array['width'] = "80"; + $graph_array_zoom = $graph_array; + $graph_array_zoom['height'] = "150"; + $graph_array_zoom['width'] = "400"; + $link = "graphs/id=" . $graph_array['id'] . "/type=" . $graph_array['type'] . "/from=" . $graph_array['from'] . "/to=" . $graph_array['to'] . "/"; + $mini_graph = overlib_link($link, generate_graph_tag($graph_array), generate_graph_tag($graph_array_zoom), NULL); + $background = get_percentage_colours($perc); + $bar_link = overlib_link($link, print_percentage_bar (400, 20, $perc, "$used / $total", "ffffff", $background['left'], $free, "ffffff", $background['right']), generate_graph_tag($graph_array_zoom), NULL); - $return_data = true; - include 'includes/print-graphrow.inc.php'; - unset($return_data); - $response[] = array( - 'hostname' => $graph_data[0], - 'storage_descr' => $graph_data[1], - 'graph' => $graph_data[2], - 'storage_used' => $graph_data[3], - 'storage_perc' => '', - ); - } //end if -}//end foreach + $response[] = array('hostname' => generate_device_link($drive), + 'storage_descr' => $drive['storage_descr'], + 'graph' => $mini_graph, + 'storage_used' => $bar_link, + 'storage_perc' => $perc . "%"); + if ($_POST['view'] == "graphs") { + $graph_array['height'] = "100"; + $graph_array['width'] = "216"; + $graph_array['to'] = $config['time']['now']; + $graph_array['id'] = $drive['storage_id']; + $graph_array['type'] = $graph_type; -$output = array( - 'current' => $current, - 'rowCount' => $rowCount, - 'rows' => $response, - 'total' => $count, -); + $return_data = true; + include("includes/print-graphrow.inc.php"); + unset($return_data); + $response[] = array('hostname' => $graph_data[0], + 'storage_descr' => $graph_data[1], + 'graph' => $graph_data[2], + 'storage_used' => $graph_data[3], + 'storage_perc' => ''); + + } # endif graphs +} + +$output = array('current'=>$current,'rowCount'=>$rowCount,'rows'=>$response,'total'=>$count); echo _json_encode($output); diff --git a/html/includes/table/syslog.inc.php b/html/includes/table/syslog.inc.php index 987aac65a1..81df05d289 100644 --- a/html/includes/table/syslog.inc.php +++ b/html/includes/table/syslog.inc.php @@ -1,44 +1,46 @@ = ?'; - $param[] = $_POST['from']; +if( !empty($_POST['from']) ) { + $where .= " AND timestamp >= ?"; + $param[] = $_POST['from']; +} +if( !empty($_POST['to']) ) { + $where .= " AND timestamp <= ?"; + $param[] = $_POST['to']; } -if (!empty($_POST['to'])) { - $where .= ' AND timestamp <= ?'; - $param[] = $_POST['to']; -} - -if ($_SESSION['userlevel'] >= '5') { - $sql = 'FROM syslog AS S'; - $sql .= ' WHERE '.$where; -} -else { - $sql = 'FROM syslog AS S, devices_perms AS P'; - $sql .= 'WHERE S.device_id = P.device_id AND P.user_id = ?'; - $sql .= $where; - $param = array_merge(array($_SESSION['user_id']), $param); +if ($_SESSION['userlevel'] >= '5') +{ + $sql = "FROM syslog AS S"; + $sql .= " WHERE ".$where; +} else { + $sql = "FROM syslog AS S, devices_perms AS P"; + $sql .= "WHERE S.device_id = P.device_id AND P.user_id = ?"; + $sql .= $where; + $param = array_merge(array($_SESSION['user_id']), $param); } $count_sql = "SELECT COUNT(timestamp) $sql"; -$total = dbFetchCell($count_sql, $param); +$total = dbFetchCell($count_sql,$param); if (empty($total)) { $total = 0; } @@ -50,7 +52,7 @@ if (!isset($sort) || empty($sort)) { $sql .= " ORDER BY $sort"; if (isset($current)) { - $limit_low = (($current * $rowCount) - ($rowCount)); + $limit_low = ($current * $rowCount) - ($rowCount); $limit_high = $rowCount; } @@ -60,20 +62,14 @@ if ($rowCount != -1) { $sql = "SELECT S.*, DATE_FORMAT(timestamp, '".$config['dateformat']['mysql']['compact']."') AS date $sql"; -foreach (dbFetchRows($sql, $param) as $syslog) { - $dev = device_by_id_cache($syslog['device_id']); - $response[] = array( - 'timestamp' => $syslog['date'], - 'device_id' => generate_device_link($dev, shorthost($dev['hostname'])), - 'program' => $syslog['program'], - 'msg' => htmlspecialchars($syslog['msg']), - ); +foreach (dbFetchRows($sql,$param) as $syslog) { + $dev = device_by_id_cache($syslog['device_id']); + $response[] = array('timestamp'=>$syslog['date'], + 'device_id'=>generate_device_link($dev, shorthost($dev['hostname'])), + 'program'=>$syslog['program'], + 'msg'=>htmlspecialchars($syslog['msg'])); } -$output = array( - 'current' => $current, - 'rowCount' => $rowCount, - 'rows' => $response, - 'total' => $total, -); +$output = array('current'=>$current,'rowCount'=>$rowCount,'rows'=>$response,'total'=>$total); echo _json_encode($output); +?> diff --git a/html/includes/vars.inc.php b/html/includes/vars.inc.php index 477f056b46..788915f694 100644 --- a/html/includes/vars.inc.php +++ b/html/includes/vars.inc.php @@ -1,38 +1,40 @@ $get_var) { - if (strstr($key, 'opt')) { - list($name, $value) = explode('|', $get_var); - if (!isset($value)) { - $value = 'yes'; - } - - $vars[$name] = $value; - } +foreach ($_GET as $key=>$get_var) +{ + if (strstr($key, "opt")) + { + list($name, $value) = explode("|", $get_var); + if (!isset($value)) { $value = "yes"; } + $vars[$name] = $value; + } } $segments = explode('/', trim($_SERVER['REQUEST_URI'], '/')); -foreach ($segments as $pos => $segment) { - $segment = urldecode($segment); - if ($pos == '0') { - $vars['page'] = $segment; - } - else { - list($name, $value) = explode('=', $segment); - if ($value == '' || !isset($value)) { - $vars[$name] = yes; - } - else { - $vars[$name] = $value; - } +foreach ($segments as $pos => $segment) +{ + $segment = urldecode($segment); + if ($pos == "0") + { + $vars['page'] = $segment; + } else { + list($name, $value) = explode("=", $segment); + if ($value == "" || !isset($value)) + { + $vars[$name] = yes; + } else { + $vars[$name] = $value; } + } } -foreach ($_GET as $name => $value) { - $vars[$name] = $value; +foreach ($_GET as $name => $value) +{ + $vars[$name] = $value; } -foreach ($_POST as $name => $value) { - $vars[$name] = $value; +foreach ($_POST as $name => $value) +{ + $vars[$name] = $value; } diff --git a/html/index.php b/html/index.php index a3de9ba0c5..57fff1b57a 100644 --- a/html/index.php +++ b/html/index.php @@ -14,8 +14,7 @@ if( strstr($_SERVER['SERVER_SOFTWARE'],"nginx") ) { $_SERVER['PATH_INFO'] = str_replace($_SERVER['PATH_TRANSLATED'].$_SERVER['PHP_SELF'],"",$_SERVER['ORIG_SCRIPT_FILENAME']); -} -else { +} else { $_SERVER['PATH_INFO'] = !empty($_SERVER['PATH_INFO']) ? $_SERVER['PATH_INFO'] : (!empty($_SERVER['ORIG_PATH_INFO']) ? $_SERVER['ORIG_PATH_INFO'] : ''); } @@ -32,40 +31,40 @@ function catchFatal() { } } -if (strpos($_SERVER['PATH_INFO'], "debug")) { - $debug = "1"; - ini_set('display_errors', 0); - ini_set('display_startup_errors', 1); - ini_set('log_errors', 1); - ini_set('error_reporting', E_ALL); - set_error_handler('logErrors'); - register_shutdown_function('catchFatal'); -} -else { - $debug = FALSE; - ini_set('display_errors', 0); - ini_set('display_startup_errors', 0); - ini_set('log_errors', 0); - ini_set('error_reporting', 0); +if (strpos($_SERVER['PATH_INFO'], "debug")) +{ + $debug = "1"; + ini_set('display_errors', 0); + ini_set('display_startup_errors', 1); + ini_set('log_errors', 1); + ini_set('error_reporting', E_ALL); + set_error_handler('logErrors'); + register_shutdown_function('catchFatal'); +} else { + $debug = FALSE; + ini_set('display_errors', 0); + ini_set('display_startup_errors', 0); + ini_set('log_errors', 0); + ini_set('error_reporting', 0); } // Set variables $msg_box = array(); // Check for install.inc.php -if (!file_exists('../config.php') && $_SERVER['PATH_INFO'] != '/install.php') { - // no config.php does so let's redirect to the install - header('Location: /install.php'); - exit; +if (!file_exists('../config.php') && $_SERVER['PATH_INFO'] != '/install.php') +{ + // no config.php does so let's redirect to the install + header('Location: /install.php'); + exit; } -require '../includes/defaults.inc.php'; -require '../config.php'; -require_once '../includes/definitions.inc.php'; -require '../includes/functions.php'; -require 'includes/functions.inc.php'; -require 'includes/vars.inc.php'; -require 'includes/plugins.inc.php'; - +include("../includes/defaults.inc.php"); +include("../config.php"); +include_once("../includes/definitions.inc.php"); +include("../includes/functions.php"); +include("includes/functions.inc.php"); +include("includes/vars.inc.php"); +include('includes/plugins.inc.php'); Plugins::start(); $runtime_start = utime(); @@ -75,33 +74,30 @@ ob_start(); ini_set('allow_url_fopen', 0); ini_set('display_errors', 0); -require 'includes/authenticate.inc.php'; +include("includes/authenticate.inc.php"); -if (strstr($_SERVER['REQUEST_URI'], 'widescreen=yes')) { - $_SESSION['widescreen'] = 1; -} -if (strstr($_SERVER['REQUEST_URI'], 'widescreen=no')) { - unset($_SESSION['widescreen']); -} +if (strstr($_SERVER['REQUEST_URI'], 'widescreen=yes')) { $_SESSION['widescreen'] = 1; } +if (strstr($_SERVER['REQUEST_URI'], 'widescreen=no')) { unset($_SESSION['widescreen']); } # Load the settings for Multi-Tenancy. -if (isset($config['branding']) && is_array($config['branding'])) { - if ($config['branding'][$_SERVER['SERVER_NAME']]) { - foreach ($config['branding'][$_SERVER['SERVER_NAME']] as $confitem => $confval) { - eval("\$config['" . $confitem . "'] = \$confval;"); - } +if (isset($config['branding']) && is_array($config['branding'])) +{ + if ($config['branding'][$_SERVER['SERVER_NAME']]) + { + foreach ($config['branding'][$_SERVER['SERVER_NAME']] as $confitem => $confval) + { + eval("\$config['" . $confitem . "'] = \$confval;"); } - else { - foreach ($config['branding']['default'] as $confitem => $confval) { - eval("\$config['" . $confitem . "'] = \$confval;"); - } + } else { + foreach ($config['branding']['default'] as $confitem => $confval) + { + eval("\$config['" . $confitem . "'] = \$confval;"); } + } } # page_title_prefix is displayed, unless page_title is set -if (isset($config['page_title'])) { - $config['page_title_prefix'] = $config['page_title']; -} +if (isset($config['page_title'])) { $config['page_title_prefix'] = $config['page_title']; } ?> @@ -123,8 +119,7 @@ if (empty($config['favicon'])) { ' . "\n"); } ?> @@ -174,13 +169,14 @@ else { body { padding-top: 0px !important; - padding-bottom: 0px !important; }"; + padding-bottom: 0px !important; }"; } @@ -192,47 +188,50 @@ else { "); - print_r($_GET); - print_r($vars); - echo(""); +if (isset($devel) || isset($vars['devel'])) +{ + echo("
    ");
    +  print_r($_GET);
    +  print_r($vars);
    +  echo("
    "); } -if ($_SESSION['authenticated']) { - // Authenticated. Print a page. - if (isset($vars['page']) && !strstr("..", $vars['page']) && is_file("pages/" . $vars['page'] . ".inc.php")) { - require "pages/" . $vars['page'] . ".inc.php"; - } - else { - if (isset($config['front_page']) && is_file($config['front_page'])) { - require $config['front_page']; - } - else { - require 'pages/front/default.php'; - } +if ($_SESSION['authenticated']) +{ + // Authenticated. Print a page. + if (isset($vars['page']) && !strstr("..", $vars['page']) && is_file("pages/" . $vars['page'] . ".inc.php")) + { + include("pages/" . $vars['page'] . ".inc.php"); + } else { + if (isset($config['front_page']) && is_file($config['front_page'])) + { + include($config['front_page']); + } else { + include("pages/front/default.php"); } + } -} -else { - // Not Authenticated. Show status page if enabled - if ( $config['public_status'] === true ) { - if (isset($vars['page']) && strstr("login", $vars['page'])) { - require 'pages/logon.inc.php'; - } - else { - echo '
    '; - require 'pages/public.inc.php'; - echo '
    '; - echo ''; - } - } - else { - require 'pages/logon.inc.php'; +} else { + // Not Authenticated. Show status page if enabled + if ( $config['public_status'] === true ) + { + if (isset($vars['page']) && strstr("login", $vars['page'])) + { + include("pages/logon.inc.php"); + } else { + echo '
    '; + include("pages/public.inc.php"); + echo '
    '; + echo ''; } + } + else + { + include("pages/logon.inc.php"); + } } ?> @@ -240,42 +239,37 @@ else { MySQL: Cell '.($db_stats['fetchcell']+0).'/'.round($db_stats['fetchcell_sec']+0,3).'s'. - ' Row '.($db_stats['fetchrow']+0). '/'.round($db_stats['fetchrow_sec']+0,3).'s'. - ' Rows '.($db_stats['fetchrows']+0).'/'.round($db_stats['fetchrows_sec']+0,3).'s'. - ' Column '.($db_stats['fetchcol']+0). '/'.round($db_stats['fetchcol_sec']+0,3).'s'); +if ($config['page_gen']) +{ + echo('
    MySQL: Cell '.($db_stats['fetchcell']+0).'/'.round($db_stats['fetchcell_sec']+0,3).'s'. + ' Row '.($db_stats['fetchrow']+0). '/'.round($db_stats['fetchrow_sec']+0,3).'s'. + ' Rows '.($db_stats['fetchrows']+0).'/'.round($db_stats['fetchrows_sec']+0,3).'s'. + ' Column '.($db_stats['fetchcol']+0). '/'.round($db_stats['fetchcol_sec']+0,3).'s'); - $fullsize = memory_get_usage(); - unset($cache); - $cachesize = $fullsize - memory_get_usage(); - if ($cachesize < 0) { - $cachesize = 0; - } // Silly PHP! + $fullsize = memory_get_usage(); + unset($cache); + $cachesize = $fullsize - memory_get_usage(); + if ($cachesize < 0) { $cachesize = 0; } // Silly PHP! - echo('
    Cached data in memory is '.formatStorage($cachesize).'. Page memory usage is '.formatStorage($fullsize).', peaked at '. formatStorage(memory_get_peak_usage()) .'.'); - echo('
    Generated in ' . $gentime . ' seconds.'); + echo('
    Cached data in memory is '.formatStorage($cachesize).'. Page memory usage is '.formatStorage($fullsize).', peaked at '. formatStorage(memory_get_peak_usage()) .'.'); + echo('
    Generated in ' . $gentime . ' seconds.'); } -if (isset($pagetitle) && is_array($pagetitle)) { - # if prefix is set, put it in front - if ($config['page_title_prefix']) { - array_unshift($pagetitle,$config['page_title_prefix']); - } +if (isset($pagetitle) && is_array($pagetitle)) +{ + # if prefix is set, put it in front + if ($config['page_title_prefix']) { array_unshift($pagetitle,$config['page_title_prefix']); } - # if suffix is set, put it in the back - if ($config['page_title_suffix']) { - $pagetitle[] = $config['page_title_suffix']; - } + # if suffix is set, put it in the back + if ($config['page_title_suffix']) { $pagetitle[] = $config['page_title_suffix']; } - # create and set the title - $title = join(" - ",$pagetitle); - echo(""); + # create and set the title + $title = join(" - ",$pagetitle); + echo(""); } ?> @@ -301,21 +295,23 @@ if(dbFetchCell("SELECT COUNT(`device_id`) FROM `devices` WHERE `last_polled` <= } if(is_array($msg_box)) { - echo(""); + echo(""); } if (is_array($sql_debug) && is_array($php_debug) && $_SESSION['authenticated'] === TRUE) { - require_once "includes/print-debug.php"; + + include_once "includes/print-debug.php"; + } if ($no_refresh !== TRUE && $config['page_refresh'] != 0) { @@ -371,8 +367,7 @@ if ($no_refresh !== TRUE && $config['page_refresh'] != 0) { }); '); -} -else { +} else { echo(' diff --git a/html/pages/alert-stats.inc.php b/html/pages/alert-stats.inc.php index ab9a0c57fd..d392f1dd20 100644 --- a/html/pages/alert-stats.inc.php +++ b/html/pages/alert-stats.inc.php @@ -1,13 +1,12 @@ - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation, either version 3 of the License, or (at your - * option) any later version. Please see LICENSE.txt at the top level of - * the source code distribution for details. - */ - -require_once 'includes/print-graph-alerts.inc.php'; +* LibreNMS +* +* Copyright (c) 2015 Søren Friis Rosiak +* This program is free software: you can redistribute it and/or modify it +* under the terms of the GNU General Public License as published by the +* Free Software Foundation, either version 3 of the License, or (at your +* option) any later version. Please see LICENSE.txt at the top level of +* the source code distribution for details. +*/ +require_once('includes/print-graph-alerts.inc.php'); diff --git a/html/pages/alerts.inc.php b/html/pages/alerts.inc.php index 91526b69ff..bcc97a32a0 100644 --- a/html/pages/alerts.inc.php +++ b/html/pages/alerts.inc.php @@ -1,17 +1,19 @@ - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation, either version 3 of the License, or (at your - * option) any later version. Please see LICENSE.txt at the top level of - * the source code distribution for details. + * LibreNMS + * + * Copyright (c) 2014 Neil Lathwood + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. Please see LICENSE.txt at the top level of + * the source code distribution for details. */ $device['device_id'] = '-1'; -require_once 'includes/print-alerts.php'; +require_once('includes/print-alerts.php'); unset($device['device_id']); + +?> diff --git a/html/pages/api-access.inc.php b/html/pages/api-access.inc.php index 6b8a885a7a..a1b6e5a528 100644 --- a/html/pages/api-access.inc.php +++ b/html/pages/api-access.inc.php @@ -12,22 +12,22 @@ * the source code distribution for details. */ -if ($_SESSION['userlevel'] >= '10') { -if (empty($_POST['token'])) { +if ($_SESSION['userlevel'] >= '10') +{ +if(empty($_POST['token'])) { $_POST['token'] = bin2hex(openssl_random_pseudo_bytes(16)); } - ?> -'; -if ($_SESSION['api_token'] === true) { - echo " - "; + "); unset($_SESSION['api_token']); -} - -echo ' + } +echo('
    @@ -125,17 +127,19 @@ echo ' Disabled Remove -'; +'); -foreach (dbFetchRows('SELECT `AT`.*,`U`.`username` FROM `api_tokens` AS AT JOIN users AS U ON AT.user_id=U.user_id ORDER BY AT.user_id') as $api) { - if ($api['disabled'] == '1') { - $api_disabled = 'checked'; + foreach (dbFetchRows("SELECT `AT`.*,`U`.`username` FROM `api_tokens` AS AT JOIN users AS U ON AT.user_id=U.user_id ORDER BY AT.user_id") as $api) + { + if($api['disabled'] == '1') + { + $api_disabled = 'checked'; } - else { - $api_disabled = ''; + else + { + $api_disabled = ''; } - - echo ' + echo(' '.$api['username'].' '.$api['token_hash'].' @@ -143,14 +147,14 @@ foreach (dbFetchRows('SELECT `AT`.*,`U`.`username` FROM `api_tokens` AS AT JOIN -'; -} +'); + } - echo ' + echo('
    -'; +'); ?> diff --git a/html/pages/api-docs.inc.php b/html/pages/api-docs.inc.php index d3bd68b840..c260b73cec 100644 --- a/html/pages/api-docs.inc.php +++ b/html/pages/api-docs.inc.php @@ -17,7 +17,8 @@
    here.'); + print_error('Documentation for the API has now been moved to GitHub, you can go straight to the API Wiki from here.'); ?>
    + diff --git a/html/pages/apps.inc.php b/html/pages/apps.inc.php index cfd2378dde..1a20acc41f 100644 --- a/html/pages/apps.inc.php +++ b/html/pages/apps.inc.php @@ -1,91 +1,54 @@ Apps » "; +echo("Apps » "); unset($sep); -$link_array = array( - 'page' => 'device', - 'device' => $device['device_id'], - 'tab' => 'apps', -); +$link_array = array('page' => 'device', + 'device' => $device['device_id'], + 'tab' => 'apps'); -foreach ($app_list as $app) { - echo $sep; +foreach ($app_list as $app) +{ + echo($sep); - // if (!$vars['app']) { $vars['app'] = $app['app_type']; } - if ($vars['app'] == $app['app_type']) { - echo ""; - // echo(''); - } - else { - // echo(''); - } +# if (!$vars['app']) { $vars['app'] = $app['app_type']; } - echo generate_link(nicecase($app['app_type']), array('page' => 'apps', 'app' => $app['app_type'])); - if ($vars['app'] == $app['app_type']) { - echo ''; - } - - $sep = ' | '; + if ($vars['app'] == $app['app_type']) + { + echo(""); + #echo(''); + } else { + #echo(''); + } + echo(generate_link(nicecase($app['app_type']),array('page'=>'apps','app'=>$app['app_type']))); + if ($vars['app'] == $app['app_type']) { echo(""); } + $sep = " | "; } print_optionbar_end(); -if ($vars['app']) { - if (is_file('pages/apps/'.mres($vars['app']).'.inc.php')) { - include 'pages/apps/'.mres($vars['app']).'.inc.php'; - } - else { - include 'pages/apps/default.inc.php'; - } -} -else { - include 'pages/apps/overview.inc.php'; +if($vars['app']) +{ + if (is_file("pages/apps/".mres($vars['app']).".inc.php")) + { + include("pages/apps/".mres($vars['app']).".inc.php"); + } else { + include("pages/apps/default.inc.php"); + } +} else { + include("pages/apps/overview.inc.php"); } -$pagetitle[] = 'Apps'; +$pagetitle[] = "Apps"; +?> diff --git a/html/pages/apps/default.inc.php b/html/pages/apps/default.inc.php index bf752de29c..e333674057 100644 --- a/html/pages/apps/default.inc.php +++ b/html/pages/apps/default.inc.php @@ -1,41 +1,45 @@ '.nicecase($vars['app']).''; -echo ''; -$app_devices = dbFetchRows('SELECT * FROM `devices` AS D, `applications` AS A WHERE D.device_id = A.device_id AND A.app_type = ?', array($vars['app'])); +echo('

    '.nicecase($vars['app']).'

    '); +echo('
    '); +$app_devices = dbFetchRows("SELECT * FROM `devices` AS D, `applications` AS A WHERE D.device_id = A.device_id AND A.app_type = ?", array($vars['app'])); -foreach ($app_devices as $app_device) { - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''); + echo(''); + echo(''); + echo(''); + echo(''); + echo(''); + echo(''); + echo(''; - echo ''; -}//end foreach + echo(''); + echo(''); +} -echo '
    '.generate_device_link($app_device, shorthost($app_device['hostname']), array('tab' => 'apps', 'app' => $vars['app'])).''.$app_device['app_instance'].''.$app_device['app_status'].'
    '; +foreach ($app_devices as $app_device) +{ + echo('
    '.generate_device_link($app_device, shorthost($app_device['hostname']), array('tab'=>'apps','app'=>$vars['app'])).''.$app_device['app_instance'].''.$app_device['app_status'].'
    '); - foreach ($graphs[$vars['app']] as $graph_type) { - $graph_array['type'] = 'application_'.$vars['app'].'_'.$graph_type; - $graph_array['id'] = $app_device['app_id']; - $graph_array_zoom['type'] = 'application_'.$vars['app'].'_'.$graph_type; - $graph_array_zoom['id'] = $app_device['app_id']; + foreach ($graphs[$vars['app']] as $graph_type) + { + $graph_array['type'] = "application_".$vars['app']."_".$graph_type; + $graph_array['id'] = $app_device['app_id']; + $graph_array_zoom['type'] = "application_".$vars['app']."_".$graph_type; + $graph_array_zoom['id'] = $app_device['app_id']; - $link = generate_url(array('page' => 'device', 'device' => $app_device['device_id'], 'tab' => 'apps', 'app' => $vars['app'])); + $link = generate_url(array('page' => 'device', 'device' => $app_device['device_id'],'tab'=>'apps','app'=>$vars['app'])); - echo overlib_link($link, generate_graph_tag($graph_array), generate_graph_tag($graph_array_zoom), null); - } + echo(overlib_link($link, generate_graph_tag($graph_array), generate_graph_tag($graph_array_zoom), NULL)); + } - echo '
    '; +echo(''); + +?> diff --git a/html/pages/authlog.inc.php b/html/pages/authlog.inc.php index 3cffbbea9e..64b4080ad2 100644 --- a/html/pages/authlog.inc.php +++ b/html/pages/authlog.inc.php @@ -1,37 +1,37 @@ = '10') { - echo ''; +if ($_SESSION['userlevel'] >= '10') +{ + echo("
    "); - foreach (dbFetchRows("SELECT *,DATE_FORMAT(datetime, '".$config['dateformat']['mysql']['compact']."') as humandate FROM `authlog` ORDER BY `datetime` DESC LIMIT 0,250") as $entry) { - if ($bg == $list_colour_a) { - $bg = $list_colour_b; - } - else { - $bg = $list_colour_a; - } + foreach (dbFetchRows("SELECT *,DATE_FORMAT(datetime, '".$config['dateformat']['mysql']['compact']."') as humandate FROM `authlog` ORDER BY `datetime` DESC LIMIT 0,250") as $entry) + { + if ($bg == $list_colour_a) { $bg = $list_colour_b; } else { $bg=$list_colour_a; } - echo " - - - - - - '; - }//end foreach + echo(" + + + + + + "); + } - $pagetitle[] = 'Authlog'; + $pagetitle[] = "Authlog"; - echo '
    - ".$entry['datetime'].' - - '.$entry['user'].' - - '.$entry['address'].' - - '.$entry['result'].' -
    + " . $entry['datetime'] . " + + ".$entry['user']." + + ".$entry['address']." + + ".$entry['result']." +
    '; + echo(""); } -else { - include 'includes/error-no-perm.inc.php'; -}//end if +else +{ + include("includes/error-no-perm.inc.php"); +} + +?> diff --git a/html/pages/bill.inc.php b/html/pages/bill.inc.php index 03faf35c17..13b640057b 100644 --- a/html/pages/bill.inc.php +++ b/html/pages/bill.inc.php @@ -2,274 +2,255 @@ $bill_id = mres($vars['bill_id']); -if ($_SESSION['userlevel'] >= '10') { - include 'pages/bill/actions.inc.php'; +if ($_SESSION['userlevel'] >= "10") +{ + include("pages/bill/actions.inc.php"); } -if (bill_permitted($bill_id)) { - $bill_data = dbFetchRow('SELECT * FROM bills WHERE bill_id = ?', array($bill_id)); +if (bill_permitted($bill_id)) +{ + $bill_data = dbFetchRow("SELECT * FROM bills WHERE bill_id = ?", array($bill_id)); - $bill_name = $bill_data['bill_name']; + $bill_name = $bill_data['bill_name']; - $today = str_replace('-', '', dbFetchCell('SELECT CURDATE()')); - $yesterday = str_replace('-', '', dbFetchCell('SELECT DATE_SUB(CURDATE(), INTERVAL 1 DAY)')); - $tomorrow = str_replace('-', '', dbFetchCell('SELECT DATE_ADD(CURDATE(), INTERVAL 1 DAY)')); - $last_month = str_replace('-', '', dbFetchCell('SELECT DATE_SUB(CURDATE(), INTERVAL 1 MONTH)')); + $today = str_replace("-", "", dbFetchCell("SELECT CURDATE()")); + $yesterday = str_replace("-", "", dbFetchCell("SELECT DATE_SUB(CURDATE(), INTERVAL 1 DAY)")); + $tomorrow = str_replace("-", "", dbFetchCell("SELECT DATE_ADD(CURDATE(), INTERVAL 1 DAY)")); + $last_month = str_replace("-", "", dbFetchCell("SELECT DATE_SUB(CURDATE(), INTERVAL 1 MONTH)")); - $rightnow = $today.date(His); - $before = $yesterday.date(His); - $lastmonth = $last_month.date(His); + $rightnow = $today . date(His); + $before = $yesterday . date(His); + $lastmonth = $last_month . date(His); - $bill_name = $bill_data['bill_name']; - $dayofmonth = $bill_data['bill_day']; + $bill_name = $bill_data['bill_name']; + $dayofmonth = $bill_data['bill_day']; - $day_data = getDates($dayofmonth); + $day_data = getDates($dayofmonth); - $datefrom = $day_data['0']; - $dateto = $day_data['1']; - $lastfrom = $day_data['2']; - $lastto = $day_data['3']; + $datefrom = $day_data['0']; + $dateto = $day_data['1']; + $lastfrom = $day_data['2']; + $lastto = $day_data['3']; - $rate_95th = $bill_data['rate_95th']; - $dir_95th = $bill_data['dir_95th']; - $total_data = $bill_data['total_data']; - $rate_average = $bill_data['rate_average']; + $rate_95th = $bill_data['rate_95th']; + $dir_95th = $bill_data['dir_95th']; + $total_data = $bill_data['total_data']; + $rate_average = $bill_data['rate_average']; - if ($rate_95th > $paid_kb) { - $over = ($rate_95th - $paid_kb); - $bill_text = $over.'Kbit excess.'; - $bill_color = '#cc0000'; - } - else { - $under = ($paid_kb - $rate_95th); - $bill_text = $under.'Kbit headroom.'; - $bill_color = '#0000cc'; + if ($rate_95th > $paid_kb) + { + $over = $rate_95th - $paid_kb; + $bill_text = $over . "Kbit excess."; + $bill_color = "#cc0000"; + } + else + { + $under = $paid_kb - $rate_95th; + $bill_text = $under . "Kbit headroom."; + $bill_color = "#0000cc"; + } + + $fromtext = dbFetchCell("SELECT DATE_FORMAT($datefrom, '".$config['dateformat']['mysql']['date']."')"); + $totext = dbFetchCell("SELECT DATE_FORMAT($dateto, '".$config['dateformat']['mysql']['date']."')"); + $unixfrom = dbFetchCell("SELECT UNIX_TIMESTAMP('$datefrom')"); + $unixto = dbFetchCell("SELECT UNIX_TIMESTAMP('$dateto')"); + + $unix_prev_from = dbFetchCell("SELECT UNIX_TIMESTAMP('$lastfrom')"); + $unix_prev_to = dbFetchCell("SELECT UNIX_TIMESTAMP('$lastto')"); + # Speeds up loading for other included pages by setting it before progessing of mysql data! + + $ports = dbFetchRows("SELECT * FROM `bill_ports` AS B, `ports` AS P, `devices` AS D + WHERE B.bill_id = ? AND P.port_id = B.port_id + AND D.device_id = P.device_id", array($bill_id)); + + echo("

    + Bill : " . $bill_data['bill_name'] . "

    "); + + print_optionbar_start(); + + echo("Bill » "); + + if (!$vars['view']) { $vars['view'] = "quick"; } + + if ($vars['view'] == "quick") { echo(""); } + echo('Quick Graphs'); + if ($vars['view'] == "quick") { echo(""); } + + echo(" | "); + + if ($vars['view'] == "accurate") { echo(""); } + echo('Accurate Graphs'); + if ($vars['view'] == "accurate") { echo(""); } + + echo(" | "); + + if ($vars['view'] == "transfer") { echo(""); } + echo('Transfer Graphs'); + if ($vars['view'] == "transfer") { echo(""); } + + echo(" | "); + + if ($vars['view'] == "history") { echo(""); } + echo('Historical Usage'); + if ($vars['view'] == "history") { echo(""); } + + if ($_SESSION['userlevel'] >= "10") + { + echo(" | "); + if ($vars['view'] == "edit") { echo(""); } + echo('Edit'); + if ($vars['view'] == "edit") { echo(""); } + + echo(" | "); + if ($vars['view'] == "delete") { echo(""); } + echo('Delete'); + if ($vars['view'] == "delete") { echo(""); } + + echo(" | "); + if ($vars['view'] == "reset") { echo(""); } + echo('Reset'); + if ($vars['view'] == "reset") { echo(""); } + } + + echo(''); + + print_optionbar_end(); + + if ($vars['view'] == "edit" && $_SESSION['userlevel'] >= "10") + { + include("pages/bill/edit.inc.php"); + } + elseif ($vars['view'] == "delete" && $_SESSION['userlevel'] >= "10") + { + include("pages/bill/delete.inc.php"); + } + elseif ($vars['view'] == "reset" && $_SESSION['userlevel'] >= "10") + { + include("pages/bill/reset.inc.php"); + } + elseif ($vars['view'] == "history") + { + include("pages/bill/history.inc.php"); + } + elseif ($vars['view'] == "transfer") + { + include("pages/bill/transfer.inc.php"); + } + elseif ($vars['view'] == "quick" || $vars['view'] == "accurate") { + + echo("

    Billed Ports

    "); + + // Collected Earlier + foreach ($ports as $port) + { + echo(generate_port_link($port) . " on " . generate_device_link($port) . "
    "); } - $fromtext = dbFetchCell("SELECT DATE_FORMAT($datefrom, '".$config['dateformat']['mysql']['date']."')"); - $totext = dbFetchCell("SELECT DATE_FORMAT($dateto, '".$config['dateformat']['mysql']['date']."')"); - $unixfrom = dbFetchCell("SELECT UNIX_TIMESTAMP('$datefrom')"); - $unixto = dbFetchCell("SELECT UNIX_TIMESTAMP('$dateto')"); + echo("

    Bill Summary

    "); - $unix_prev_from = dbFetchCell("SELECT UNIX_TIMESTAMP('$lastfrom')"); - $unix_prev_to = dbFetchCell("SELECT UNIX_TIMESTAMP('$lastto')"); - // Speeds up loading for other included pages by setting it before progessing of mysql data! - $ports = dbFetchRows( - 'SELECT * FROM `bill_ports` AS B, `ports` AS P, `devices` AS D - WHERE B.bill_id = ? AND P.port_id = B.port_id - AND D.device_id = P.device_id', - array($bill_id) - ); + if ($bill_data['bill_type'] == "quota") + { + // The Customer is billed based on a pre-paid quota with overage in xB - echo '

    - Bill : '.$bill_data['bill_name'].'

    '; + echo("

    Quota Bill

    "); - print_optionbar_start(); + $percent = round(($total_data) / $bill_data['bill_quota'] * 100, 2); + $unit = "MB"; + $total_data = round($total_data, 2); + echo("Billing Period from " . $fromtext . " to " . $totext); + echo("
    Transferred ".format_bytes_billing($total_data)." of ".format_bytes_billing($bill_data['bill_quota'])." (".$percent."%)"); + echo("
    Average rate " . formatRates($rate_average)); - echo "Bill » "; + $background = get_percentage_colours($percent); - if (!$vars['view']) { - $vars['view'] = 'quick'; + echo("

    ".print_percentage_bar (350, 20, $perc, NULL, "ffffff", $background['left'], $percent . "%", "ffffff", $background['right'])."

    "); + + $type="&ave=yes"; + } + elseif ($bill_data['bill_type'] == "cdr") + { + // The customer is billed based on a CDR with 95th%ile overage + + echo("

    CDR / 95th Bill

    "); + + $unit = "kbps"; + $cdr = $bill_data['bill_cdr']; + $rate_95th = round($rate_95th, 2); + + $percent = round(($rate_95th) / $cdr * 100, 2); + + $type="&95th=yes"; + + echo("" . $fromtext . " to " . $totext . " +
    Measured ".format_si($rate_95th)."bps of ".format_si($cdr)."bps (".$percent."%) @ 95th %ile"); + + $background = get_percentage_colours($percent); + + echo("

    ".print_percentage_bar (350, 20, $percent, NULL, "ffffff", $background['left'], $percent . "%", "ffffff", $background['right'])."

    "); + + # echo("

    Billing Period : " . $fromtext . " to " . $totext . "
    + # " . $paidrate_text . "
    + # " . $total_data . "MB transfered in the current billing cycle.
    + # " . $rate_average . "Kbps Average during the current billing cycle.

    + # " . $rate_95th . "Kbps @ 95th Percentile. (" . $dir_95th . ") (" . $bill_text . ") + # + #
    "); } - if ($vars['view'] == 'quick') { - echo ""; + $lastmonth = dbFetchCell("SELECT UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 1 MONTH))"); + $yesterday = dbFetchCell("SELECT UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 1 DAY))"); + $rightnow = date(U); + + if ($vars['view'] == "accurate") { + + $bi = ""; + + $li = ""; + + $di = ""; + + $mi = ""; + } - echo 'Quick Graphs'; - if ($vars['view'] == 'quick') { - echo ''; - } - - echo ' | '; - - if ($vars['view'] == 'accurate') { - echo ""; - } - - echo 'Accurate Graphs'; - if ($vars['view'] == 'accurate') { - echo ''; - } - - echo ' | '; - - if ($vars['view'] == 'transfer') { - echo ""; - } - - echo 'Transfer Graphs'; - if ($vars['view'] == 'transfer') { - echo ''; - } - - echo ' | '; - - if ($vars['view'] == 'history') { - echo ""; - } - - echo 'Historical Usage'; - if ($vars['view'] == 'history') { - echo ''; - } - - if ($_SESSION['userlevel'] >= '10') { - echo ' | '; - if ($vars['view'] == 'edit') { - echo ""; - } - - echo 'Edit'; - if ($vars['view'] == 'edit') { - echo ''; - } - - echo ' | '; - if ($vars['view'] == 'delete') { - echo ""; - } - - echo 'Delete'; - if ($vars['view'] == 'delete') { - echo ''; - } - - echo ' | '; - if ($vars['view'] == 'reset') { - echo ""; - } - - echo 'Reset'; - if ($vars['view'] == 'reset') { - echo ''; - } - }//end if - - echo ''; - - print_optionbar_end(); - - if ($vars['view'] == 'edit' && $_SESSION['userlevel'] >= '10') { - include 'pages/bill/edit.inc.php'; - } - else if ($vars['view'] == 'delete' && $_SESSION['userlevel'] >= '10') { - include 'pages/bill/delete.inc.php'; - } - else if ($vars['view'] == 'reset' && $_SESSION['userlevel'] >= '10') { - include 'pages/bill/reset.inc.php'; - } - else if ($vars['view'] == 'history') { - include 'pages/bill/history.inc.php'; - } - else if ($vars['view'] == 'transfer') { - include 'pages/bill/transfer.inc.php'; - } - else if ($vars['view'] == 'quick' || $vars['view'] == 'accurate') { - echo '

    Billed Ports

    '; - - // Collected Earlier - foreach ($ports as $port) { - echo generate_port_link($port).' on '.generate_device_link($port).'
    '; - } - - echo '

    Bill Summary

    '; - - if ($bill_data['bill_type'] == 'quota') { - // The Customer is billed based on a pre-paid quota with overage in xB - echo '

    Quota Bill

    '; - - $percent = round((($total_data) / $bill_data['bill_quota'] * 100), 2); - $unit = 'MB'; - $total_data = round($total_data, 2); - echo 'Billing Period from '.$fromtext.' to '.$totext; - echo '
    Transferred '.format_bytes_billing($total_data).' of '.format_bytes_billing($bill_data['bill_quota']).' ('.$percent.'%)'; - echo '
    Average rate '.formatRates($rate_average); - - $background = get_percentage_colours($percent); - - echo '

    '.print_percentage_bar(350, 20, $perc, null, 'ffffff', $background['left'], $percent.'%', 'ffffff', $background['right']).'

    '; - - $type = '&ave=yes'; - } - else if ($bill_data['bill_type'] == 'cdr') { - // The customer is billed based on a CDR with 95th%ile overage - echo '

    CDR / 95th Bill

    '; - - $unit = 'kbps'; - $cdr = $bill_data['bill_cdr']; - $rate_95th = round($rate_95th, 2); - - $percent = round((($rate_95th) / $cdr * 100), 2); - - $type = '&95th=yes'; - - echo ''.$fromtext.' to '.$totext.' -
    Measured '.format_si($rate_95th).'bps of '.format_si($cdr).'bps ('.$percent.'%) @ 95th %ile'; - - $background = get_percentage_colours($percent); - - echo '

    '.print_percentage_bar(350, 20, $percent, null, 'ffffff', $background['left'], $percent.'%', 'ffffff', $background['right']).'

    '; - - // echo("

    Billing Period : " . $fromtext . " to " . $totext . "
    - // " . $paidrate_text . "
    - // " . $total_data . "MB transfered in the current billing cycle.
    - // " . $rate_average . "Kbps Average during the current billing cycle.

    - // " . $rate_95th . "Kbps @ 95th Percentile. (" . $dir_95th . ") (" . $bill_text . ") - // - //
    "); - }//end if - - $lastmonth = dbFetchCell('SELECT UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 1 MONTH))'); - $yesterday = dbFetchCell('SELECT UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 1 DAY))'); - $rightnow = date(U); - - if ($vars['view'] == 'accurate') { - $bi = ""; - - $li = ""; - - $di = ""; - }//end if - - if ($null) { - echo " - @@ -287,32 +268,39 @@ if (bill_permitted($bill_id)) { - "; - }//end if + "); - if ($_GET['all']) { - $ai = ''; - echo "

    Entire Data View

    $ai"; - } - else if ($_GET['custom']) { - $cg = ''; - echo "

    Custom Graph

    $cg"; - } - else { - echo "

    Billing View

    $bi"; - // echo("

    Previous Bill View

    $li"); - echo "

    24 Hour View

    $di"; - echo "

    Monthly View

    $mi"; - // echo("
    Graph All Data (SLOW)"); - }//end if - } //end if + } + + if ($_GET['all']) + { + $ai = ""; + echo("

    Entire Data View

    $ai"); + } + elseif ($_GET['custom']) + { + $cg = ""; + echo("

    Custom Graph

    $cg"); + } + else + { + echo("

    Billing View

    $bi"); +# echo("

    Previous Bill View

    $li"); + echo("

    24 Hour View

    $di"); + echo("

    Monthly View

    $mi"); +# echo("
    Graph All Data (SLOW)"); + } + } # End if details } -else { - include 'includes/error-no-perm.inc.php'; -}//end if +else +{ + include("includes/error-no-perm.inc.php"); +} + +?> diff --git a/html/pages/bill/actions.inc.php b/html/pages/bill/actions.inc.php index 29afb6d3b4..d55c2944cc 100644 --- a/html/pages/bill/actions.inc.php +++ b/html/pages/bill/actions.inc.php @@ -1,7 +1,8 @@ = 1) { - $quota = array( - 'type' => 'tb', - 'select_tb' => ' selected', - 'data' => $tmp['tb'], - ); - } - else if (($tmp['gb'] >= 1) and ($tmp['gb'] < $base)) { - $quota = array( - 'type' => 'gb', - 'select_gb' => ' selected', - 'data' => $tmp['gb'], - ); - } - else if (($tmp['mb'] >= 1) and ($tmp['mb'] < $base)) { - $quota = array( - 'type' => 'mb', - 'select_mb' => ' selected', - 'data' => $tmp['mb'], - ); - } -}//end if +$base = $config["billing"]["base"]; -if ($bill_data['bill_type'] == 'cdr') { - $data = $bill_data['bill_cdr']; - $tmp['kbps'] = ($data / $base); - $tmp['mbps'] = ($data / $base / $base); - $tmp['gbps'] = ($data / $base / $base / $base); - if ($tmp['gbps'] >= 1) { - $cdr = array( - 'type' => 'gbps', - 'select_gbps' => ' selected', - 'data' => $tmp['gbps'], - ); - } - else if (($tmp['mbps'] >= 1) and ($tmp['mbps'] < $base)) { - $cdr = array( - 'type' => 'mbps', - 'select_mbps' => ' selected', - 'data' => $tmp['mbps'], - ); - } - else if (($tmp['kbps'] >= 1) and ($tmp['kbps'] < $base)) { - $cdr = array( - 'type' => 'kbps', - 'select_kbps' => ' selected', - 'data' => $tmp['kbps'], - ); - } -}//end if +if ($bill_data['bill_type'] == "quota") { + $data = $bill_data['bill_quota']; + $tmp['mb'] = $data / $base / $base; + $tmp['gb'] = $data / $base / $base / $base; + $tmp['tb'] = $data / $base / $base / $base / $base; + if ($tmp['tb']>=1) { $quota = array("type" => "tb", "select_tb" => " selected", "data" => $tmp['tb']); } + elseif (($tmp['gb']>=1) and ($tmp['gb']<$base)) { $quota = array("type" => "gb", "select_gb" => " selected", "data" => $tmp['gb']); } + elseif (($tmp['mb']>=1) and ($tmp['mb']<$base)) { $quota = array("type" => "mb", "select_mb" => " selected", "data" => $tmp['mb']); } +} +if ($bill_data['bill_type'] == "cdr") { + $data = $bill_data['bill_cdr']; + $tmp['kbps'] = $data / $base; + $tmp['mbps'] = $data / $base / $base; + $tmp['gbps'] = $data / $base / $base / $base; + if ($tmp['gbps']>=1) { $cdr = array("type" => "gbps", "select_gbps" => " selected", "data" => $tmp['gbps']); } + elseif (($tmp['mbps']>=1) and ($tmp['mbps']<$base)) { $cdr = array("type" => "mbps", "select_mbps" => " selected", "data" => $tmp['mbps']); } + elseif (($tmp['kbps']>=1) and ($tmp['kbps']<$base)) { $cdr = array("type" => "kbps", "select_kbps" => " selected", "data" => $tmp['kbps']); } +} ?>
    - +

    Bill Properties

    - + " />
    @@ -86,35 +51,17 @@ function billType() {
    - -
    @@ -124,19 +121,19 @@ if ($unknown) {
    - value="" /> + value="" />
    - /> + />
    - /> + />
    diff --git a/html/pages/device/edit/health.inc.php b/html/pages/device/edit/health.inc.php index 922bb36c77..3d7d213527 100644 --- a/html/pages/device/edit/health.inc.php +++ b/html/pages/device/edit/health.inc.php @@ -30,158 +30,156 @@ $sensor['sensor_id'], - 'sensor_limit' => $sensor['sensor_limit'], - 'sensor_limit_low' => $sensor['sensor_limit_low'], - 'sensor_alert' => $sensor['sensor_alert'], - ); - if ($sensor['sensor_alert'] == 1) { - $alert_status = 'checked'; - } - else { - $alert_status = ''; - } - - if ($sensor['sensor_custom'] == 'No') { - $custom = 'disabled'; - } - else { - $custom = ''; - } - - echo ' - - '.$sensor['sensor_class'].' - '.$sensor['sensor_type'].' - '.$sensor['sensor_descr'].' - '.$sensor['sensor_current'].' - -
    +foreach ( dbFetchRows("SELECT * FROM sensors WHERE device_id = ? AND sensor_deleted='0'", array($device['device_id'])) as $sensor) +{ + $rollback[] = array('sensor_id' => $sensor['sensor_id'], 'sensor_limit' => $sensor['sensor_limit'], 'sensor_limit_low' => $sensor['sensor_limit_low'], 'sensor_alert' => $sensor['sensor_alert']); + if($sensor['sensor_alert'] == 1) + { + $alert_status = 'checked'; + } + else + { + $alert_status = ''; + } + if ($sensor['sensor_custom'] == 'No') { + $custom = 'disabled'; + } else { + $custom = ''; + } + echo(' + + '.$sensor['sensor_class'].' + '.$sensor['sensor_type'].' + '.$sensor['sensor_descr'].' + '.$sensor['sensor_current'].' + +
    -
    - - -
    +
    + + +
    -
    - - - - - +
    + + + + + Clear custom - - - '; + + +'); } + ?>
    - - - - '; +foreach($rollback as $reset_data) +{ + echo (' + + + + + '); } ?>
    + diff --git a/html/pages/device/edit/ipmi.inc.php b/html/pages/device/edit/ipmi.inc.php index 0aff50bdd7..f3971ca413 100644 --- a/html/pages/device/edit/ipmi.inc.php +++ b/html/pages/device/edit/ipmi.inc.php @@ -1,45 +1,31 @@ '7') { - $ipmi_hostname = mres($_POST['ipmi_hostname']); - $ipmi_username = mres($_POST['ipmi_username']); - $ipmi_password = mres($_POST['ipmi_password']); +if ($_POST['editing']) +{ + if ($_SESSION['userlevel'] > "7") + { + $ipmi_hostname = mres($_POST['ipmi_hostname']); + $ipmi_username = mres($_POST['ipmi_username']); + $ipmi_password = mres($_POST['ipmi_password']); - if ($ipmi_hostname != '') { - set_dev_attrib($device, 'ipmi_hostname', $ipmi_hostname); - } - else { - del_dev_attrib($device, 'ipmi_hostname'); - } + if ($ipmi_hostname != '') { set_dev_attrib($device, 'ipmi_hostname', $ipmi_hostname); } else { del_dev_attrib($device, 'ipmi_hostname'); } + if ($ipmi_username != '') { set_dev_attrib($device, 'ipmi_username', $ipmi_username); } else { del_dev_attrib($device, 'ipmi_username'); } + if ($ipmi_password != '') { set_dev_attrib($device, 'ipmi_password', $ipmi_password); } else { del_dev_attrib($device, 'ipmi_password'); } - if ($ipmi_username != '') { - set_dev_attrib($device, 'ipmi_username', $ipmi_username); - } - else { - del_dev_attrib($device, 'ipmi_username'); - } - - if ($ipmi_password != '') { - set_dev_attrib($device, 'ipmi_password', $ipmi_password); - } - else { - del_dev_attrib($device, 'ipmi_password'); - } - - $update_message = 'Device IPMI data updated.'; - $updated = 1; - } - else { - include 'includes/error-no-perm.inc.php'; - }//end if -}//end if - -if ($updated && $update_message) { - print_message($update_message); + $update_message = "Device IPMI data updated."; + $updated = 1; + } + else + { + include("includes/error-no-perm.inc.php"); + } } -else if ($update_message) { - print_error($update_message); + +if ($updated && $update_message) +{ + print_message($update_message); +} elseif ($update_message) { + print_error($update_message); } ?> @@ -51,19 +37,19 @@ else if ($update_message) {
    - +
    - +
    - +
    diff --git a/html/pages/device/edit/modules.inc.php b/html/pages/device/edit/modules.inc.php index 3196171626..36a53b3f10 100644 --- a/html/pages/device/edit/modules.inc.php +++ b/html/pages/device/edit/modules.inc.php @@ -17,57 +17,68 @@ $module_status) { - echo(' +foreach ($config['poller_modules'] as $module => $module_status) +{ + echo(' '.$module.' - '); +'); - if($module_status == 1) { - echo('Enabled'); - } - else { - echo('Disabled'); - } + if($module_status == 1) + { + echo('Enabled'); + } + else + { + echo('Disabled'); + } - echo(' + echo(' - '); +'); - if (isset($attribs['poll_'.$module])) { - if ($attribs['poll_'.$module]) { - echo('Enabled'); - $module_checked = 'checked'; - } - else { - echo('Disabled'); - $module_checked = ''; - } + if (isset($attribs['poll_'.$module])) + { + if ($attribs['poll_'.$module]) + { + echo('Enabled'); + $module_checked = 'checked'; } - else { - if($module_status == 1) { - echo('Enabled'); - $module_checked = 'checked'; - } - else { - echo('Disabled'); - $module_checked = ''; - } + else + { + echo('Disabled'); + $module_checked = ''; } + } + else + { + if($module_status == 1) + { + echo('Enabled'); + $module_checked = 'checked'; + } + else + { + echo('Disabled'); + $module_checked = ''; + } + } - echo(' + echo(' - '); +'); - echo(''); + echo(' + +'); - echo(' + echo(' - '); +'); } ?> @@ -85,56 +96,71 @@ foreach ($config['poller_modules'] as $module => $module_status) { $module_status) { - echo(' +foreach ($config['discovery_modules'] as $module => $module_status) +{ + + echo(' '.$module.' - '); +'); - if($module_status == 1) { - echo('Enabled'); - } - else { - echo('Disabled'); - } + if($module_status == 1) + { + echo('Enabled'); + } + else + { + echo('Disabled'); + } - echo(' + echo(' - '); + +'); - if (isset($attribs['discover_'.$module])) { - if($attribs['discover_'.$module]) { - echo('Enabled'); - $module_checked = 'checked'; - } - else { - echo('Disabled'); - $module_checked = ''; - } + if (isset($attribs['discover_'.$module])) + { + if($attribs['discover_'.$module]) + { + echo('Enabled'); + $module_checked = 'checked'; } - else { - if($module_status == 1) { - echo('Enabled'); - $module_checked = 'checked'; - } - else { - echo('Disabled'); - $module_checked = ''; - } + else + { + echo('Disabled'); + $module_checked = ''; } + } + else + { + if($module_status == 1) + { + echo('Enabled'); + $module_checked = 'checked'; + } + else + { + echo('Disabled'); + $module_checked = ''; + } + } - echo(' + echo(' - '); + +'); - echo(''); + echo(' + +'); - echo(' + echo(' - '); + +'); } echo(' diff --git a/html/pages/device/edit/ports.inc.php b/html/pages/device/edit/ports.inc.php index d8dc562e43..b382cf05a8 100644 --- a/html/pages/device/edit/ports.inc.php +++ b/html/pages/device/edit/ports.inc.php @@ -1,26 +1,28 @@ '; +echo('
    '); -if ($_POST['ignoreport']) { - if ($_SESSION['userlevel'] == '10') { - include 'includes/port-edit.inc.php'; - } +if ($_POST['ignoreport']) +{ + if ($_SESSION['userlevel'] == '10') + { + include("includes/port-edit.inc.php"); + } } -if ($updated && $update_message) { - print_message($update_message); -} -else if ($update_message) { - print_error($update_message); +if ($updated && $update_message) +{ + print_message($update_message); +} elseif ($update_message) { + print_error($update_message); } -echo "
    +echo("
    - "; + "); -echo " +echo("
    @@ -39,14 +41,14 @@ echo "
    Index Name
    -"; +"); ?> '; - echo ''; - echo ''; - echo ''; + if (is_integer($row/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; } - // Mark interfaces which are OperDown (but not AdminDown) yet not ignored or disabled, or up yet ignored or disabled - // - as to draw the attention to a possible problem. - $isportbad = ($port['ifOperStatus'] == 'down' && $port['ifAdminStatus'] != 'down') ? 1 : 0; - $dowecare = ($port['ignore'] == 0 && $port['disabled'] == 0) ? $isportbad : !$isportbad; - $outofsync = $dowecare ? " class='red'" : ''; + echo(""); + echo(""); + echo(""); + echo(""); - echo "'; + # Mark interfaces which are OperDown (but not AdminDown) yet not ignored or disabled, or up yet ignored or disabled + # - as to draw the attention to a possible problem. + $isportbad = ($port['ifOperStatus'] == 'down' && $port['ifAdminStatus'] != 'down') ? 1 : 0; + $dowecare = ($port['ignore'] == 0 && $port['disabled'] == 0) ? $isportbad : !$isportbad; + $outofsync = $dowecare ? " class='red'" : ""; - echo '"); - echo '"); - echo "\n"; + echo(""); + echo(""); - $row++; -}//end foreach + echo("\n"); -echo '
    '.$port['ifIndex'].''.$port['label'].''.$port['ifAdminStatus'].'
    ". $port['ifIndex']."".$port['label'] . "". $port['ifAdminStatus']."'.$port['ifOperStatus'].''; - echo "'; - echo "". $port['ifOperStatus']."'; - echo "'; - echo ""); + echo(""); + echo(""); + echo("
    "); + echo(""); + echo(""); + echo("".$port['ifAlias'] . "
    '; -echo '
    '; -echo '
    '; + $row++; +} + +echo(''); +echo(''); +echo('
    '); + +?> diff --git a/html/pages/device/edit/services.inc.php b/html/pages/device/edit/services.inc.php index 1f2bc1d30e..e6969a9fe9 100644 --- a/html/pages/device/edit/services.inc.php +++ b/html/pages/device/edit/services.inc.php @@ -1,28 +1,29 @@ = '10') { - include 'includes/service-add.inc.php'; + include("includes/service-add.inc.php"); } } if ($_POST['delsrv']) { if ($_SESSION['userlevel'] >= '10') { - include 'includes/service-delete.inc.php'; + include("includes/service-delete.inc.php"); } } if ($_POST['confirm-editsrv']) { - echo 'yeah'; + echo "yeah"; if ($_SESSION['userlevel'] >= '10') { - include 'includes/service-edit.inc.php'; + include("includes/service-edit.inc.php"); } } - if ($handle = opendir($config['install_dir'].'/includes/services/')) { + if ($handle = opendir($config['install_dir'] . "/includes/services/")) { while (false !== ($file = readdir($handle))) { - if ($file != '.' && $file != '..' && !strstr($file, '.')) { + if ($file != "." && $file != ".." && !strstr($file, ".")) { $servicesform .= ""; } } @@ -30,17 +31,17 @@ if (is_admin() === true || is_read() === true) { closedir($handle); } - $dev = device_by_id_cache($device['device_id']); - $devicesform = "'; + $dev = device_by_id_cache($device['device_id']); + $devicesform = ""; if ($updated) { - print_message('Device Settings Saved'); + print_message("Device Settings Saved"); } - if (dbFetchCell('SELECT COUNT(*) from `services` WHERE `device_id` = ?', array($device['device_id'])) > '0') { - $i = '1'; - foreach (dbFetchRows('select * from services WHERE device_id = ? ORDER BY service_type', array($device['device_id'])) as $service) { - $existform .= "'; + if (dbFetchCell("SELECT COUNT(*) from `services` WHERE `device_id` = ?", array($device['device_id'])) > '0') { + $i = "1"; + foreach (dbFetchRows("select * from services WHERE device_id = ? ORDER BY service_type", array($device['device_id'])) as $service) { + $existform .= ""; } } @@ -48,29 +49,28 @@ if (is_admin() === true || is_read() === true) { if ($existform) { echo '
    '; - if ($_POST['editsrv'] == 'yes') { - include_once 'includes/print-service-edit.inc.php'; - } - else { + if ($_POST['editsrv'] == "yes") { + include_once "includes/print-service-edit.inc.php"; + } else { echo " -

    Edit / Delete Service

    -
    +

    Edit / Delete Service

    +
    -
    - -
    - +
    + +
    + +
    +
    +
    +
    + +
    +
    -
    -
    -
    - -
    -
    -
    -
    "; + "; } echo '
    '; @@ -78,8 +78,8 @@ if (is_admin() === true || is_read() === true) { echo '
    '; - include_once 'includes/print-service-add.inc.php'; -} -else { - include 'includes/error-no-perm.inc.php'; -} + require_once "includes/print-service-add.inc.php"; + +} else { + include("includes/error-no-perm.inc.php"); +} \ No newline at end of file diff --git a/html/pages/device/edit/snmp.inc.php b/html/pages/device/edit/snmp.inc.php index 59c6bf4cd3..9e8a5b7b04 100644 --- a/html/pages/device/edit/snmp.inc.php +++ b/html/pages/device/edit/snmp.inc.php @@ -1,240 +1,225 @@ '7') { - $community = mres($_POST['community']); - $snmpver = mres($_POST['snmpver']); - $transport = $_POST['transport'] ? mres($_POST['transport']) : $transport = 'udp'; - $port = $_POST['port'] ? mres($_POST['port']) : $config['snmp']['port']; - $timeout = mres($_POST['timeout']); - $retries = mres($_POST['retries']); - $poller_group = mres($_POST['poller_group']); - $v3 = array( - 'authlevel' => mres($_POST['authlevel']), - 'authname' => mres($_POST['authname']), - 'authpass' => mres($_POST['authpass']), - 'authalgo' => mres($_POST['authalgo']), - 'cryptopass' => mres($_POST['cryptopass']), - 'cryptoalgo' => mres($_POST['cryptoalgo']), - ); +if ($_POST['editing']) +{ + if ($_SESSION['userlevel'] > "7") + { + $community = mres($_POST['community']); + $snmpver = mres($_POST['snmpver']); + $transport = $_POST['transport'] ? mres($_POST['transport']) : $transport = "udp"; + $port = $_POST['port'] ? mres($_POST['port']) : $config['snmp']['port']; + $timeout = mres($_POST['timeout']); + $retries = mres($_POST['retries']); + $poller_group = mres($_POST['poller_group']); + $v3 = array ( + 'authlevel' => mres($_POST['authlevel']), + 'authname' => mres($_POST['authname']), + 'authpass' => mres($_POST['authpass']), + 'authalgo' => mres($_POST['authalgo']), + 'cryptopass' => mres($_POST['cryptopass']), + 'cryptoalgo' => mres($_POST['cryptoalgo']) + ); - // FIXME needs better feedback - $update = array( - 'community' => $community, - 'snmpver' => $snmpver, - 'port' => $port, - 'transport' => $transport, - 'poller_group' => $poller_group, - ); + #FIXME needs better feedback + $update = array( + 'community' => $community, + 'snmpver' => $snmpver, + 'port' => $port, + 'transport' => $transport, + 'poller_group' => $poller_group + ); - if ($_POST['timeout']) { - $update['timeout'] = $timeout; - } - else { - $update['timeout'] = array('NULL'); + if ($_POST['timeout']) { $update['timeout'] = $timeout; } + else { $update['timeout'] = array('NULL'); } + if ($_POST['retries']) { $update['retries'] = $retries; } + else { $update['retries'] = array('NULL'); } + + $update = array_merge($update, $v3); + + $device_tmp = deviceArray($device['hostname'], $community, $snmpver, $port, $transport, $v3); + if (isSNMPable($device_tmp)) { + $rows_updated = dbUpdate($update, 'devices', '`device_id` = ?',array($device['device_id'])); + + if ($rows_updated > 0) { + $update_message = $rows_updated . " Device record updated."; + $updated = 1; + } elseif ($rows_updated = '-1') { + $update_message = "Device record unchanged. No update necessary."; + $updated = -1; + } else { + $update_message = "Device record update error."; + $updated = 0; } + } else { + $update_message = "Could not connect to device with new SNMP details"; + $updated = 0; + } + } +} - if ($_POST['retries']) { - $update['retries'] = $retries; - } - else { - $update['retries'] = array('NULL'); - } - - $update = array_merge($update, $v3); - - $device_tmp = deviceArray($device['hostname'], $community, $snmpver, $port, $transport, $v3); - if (isSNMPable($device_tmp)) { - $rows_updated = dbUpdate($update, 'devices', '`device_id` = ?', array($device['device_id'])); - - if ($rows_updated > 0) { - $update_message = $rows_updated.' Device record updated.'; - $updated = 1; - } - else if ($rows_updated = '-1') { - $update_message = 'Device record unchanged. No update necessary.'; - $updated = -1; - } - else { - $update_message = 'Device record update error.'; - $updated = 0; - } - } - else { - $update_message = 'Could not connect to device with new SNMP details'; - $updated = 0; - } - }//end if -}//end if - -$device = dbFetchRow('SELECT * FROM `devices` WHERE `device_id` = ?', array($device['device_id'])); +$device = dbFetchRow("SELECT * FROM `devices` WHERE `device_id` = ?", array($device['device_id'])); $descr = $device['purpose']; -echo '
    -
    '; -if ($updated && $update_message) { - print_message($update_message); -} -else if ($update_message) { - print_error($update_message); +echo('
    +
    '); +if ($updated && $update_message) +{ + print_message($update_message); +} elseif ($update_message) { + print_error($update_message); } +echo('
    +
    '); -echo '
    -
    '; - -echo " -
    - -
    +echo(" + + +
    - +
    - +
    - "); foreach ($config['snmp']['transports'] as $transport) { - echo "'; + echo(">".$transport.""); } - -echo " +echo("
    -
    -
    +
    +
    - +
    - +
    -
    -
    +
    +
    - +
    - -
    - + +
    + +
    -
    -
    -
    +
    +
    - +
    - -
    - -
    + +
    + +
    - -
    - -
    + +
    + +
    - -
    - -
    + +
    + +
    - -
    - -
    + +
    + +
    - -
    - -
    + +
    + +
    - -
    - + +
    + +
    -
    -
    '; +
    "); -if ($config['distributed_poller'] === true) { - echo ' -
    - -
    - + + '); - foreach (dbFetchRows('SELECT `id`,`group_name` FROM `poller_groups`') as $group) { - echo ''; + echo '>' . $group['group_name'] . ''; } - echo ' - -
    -
    - '; -}//end if + echo(' + +
    +
    + '); +} -echo ' - - - '; +echo(' + + +'); ?> diff --git a/html/pages/device/entphysical.inc.php b/html/pages/device/entphysical.inc.php index 7b5d956faa..af167b4ddc 100644 --- a/html/pages/device/entphysical.inc.php +++ b/html/pages/device/entphysical.inc.php @@ -1,11 +1,13 @@ "; @@ -31,8 +33,7 @@ function printEntPhysical($ent, $level, $class) { if (count($sensor)) { $link = " href='device/device=".$device['device_id'].'/tab=health/metric='.$sensor['sensor_class']."/' onmouseover=\"return overlib('', LEFT,FGCOLOR,'#e5e5e5', BGCOLOR, '#c0c0c0', BORDER, 5, CELLPAD, 4, CAPCOLOR, '#050505');\" onmouseout=\"return nd();\""; } - } - else { + } else { unset($link); } diff --git a/html/pages/device/graphs.inc.php b/html/pages/device/graphs.inc.php index e4bd13d84c..a275e71e31 100644 --- a/html/pages/device/graphs.inc.php +++ b/html/pages/device/graphs.inc.php @@ -1,68 +1,70 @@ 'device', - 'device' => $device['device_id'], - 'tab' => 'graphs', -); -$bg = '#ffffff'; +$link_array = array('page' => 'device', + 'device' => $device['device_id'], + 'tab' => 'graphs'); -echo '
    '; +$bg="#ffffff"; + +echo('
    '); print_optionbar_start(); -echo "Graphs » "; +echo("Graphs » "); -foreach (dbFetchRows('SELECT * FROM device_graphs WHERE device_id = ? ORDER BY graph', array($device['device_id'])) as $graph) { - $section = $config['graph_types']['device'][$graph['graph']]['section']; - if ($section != '') { - $graph_enable[$section][$graph['graph']] = $graph['graph']; - } +foreach (dbFetchRows("SELECT * FROM device_graphs WHERE device_id = ? ORDER BY graph", array($device['device_id'])) as $graph) +{ + $section = $config['graph_types']['device'][$graph['graph']]['section']; + if ($section != "") { + $graph_enable[$section][$graph['graph']] = $graph['graph']; + } } // These are standard graphs we should have for all systems $graph_enable['poller']['poller_perf'] = 'device_poller_perf'; -$graph_enable['poller']['ping_perf'] = 'device_ping_perf'; +$graph_enable['poller']['ping_perf'] = 'device_ping_perf'; -$sep = ''; -foreach ($graph_enable as $section => $nothing) { - if (isset($graph_enable) && is_array($graph_enable[$section])) { - $type = strtolower($section); - if (!$vars['group']) { - $vars['group'] = $type; - } - - echo $sep; - if ($vars['group'] == $type) { - echo ''; - } - - echo generate_link(ucwords($type), $link_array, array('group' => $type)); - if ($vars['group'] == $type) { - echo ''; - } - - $sep = ' | '; +$sep = ""; +foreach ($graph_enable as $section => $nothing) +{ + if (isset($graph_enable) && is_array($graph_enable[$section])) + { + $type = strtolower($section); + if (!$vars['group']) { $vars['group'] = $type; } + echo($sep); + if ($vars['group'] == $type) + { + echo(''); } + echo(generate_link(ucwords($type),$link_array,array('group'=>$type))); + if ($vars['group'] == $type) + { + echo(""); + } + $sep = " | "; + } } - -unset($sep); +unset ($sep); print_optionbar_end(); $graph_enable = $graph_enable[$vars['group']]; -// foreach ($config['graph_types']['device'] as $graph => $entry) -foreach ($graph_enable as $graph => $entry) { - $graph_array = array(); - if ($graph_enable[$graph]) { - $graph_title = $config['graph_types']['device'][$graph]['descr']; - $graph_array['type'] = 'device_'.$graph; +#foreach ($config['graph_types']['device'] as $graph => $entry) +foreach ($graph_enable as $graph => $entry) +{ + $graph_array = array(); + if ($graph_enable[$graph]) + { + $graph_title = $config['graph_types']['device'][$graph]['descr']; + $graph_array['type'] = "device_" . $graph; - include 'includes/print-device-graph.php'; - } + include("includes/print-device-graph.php"); + } } -$pagetitle[] = 'Graphs'; +$pagetitle[] = "Graphs"; + +?> diff --git a/html/pages/device/graphs/netstats_ip_forward.inc.php b/html/pages/device/graphs/netstats_ip_forward.inc.php index eda137a788..cc728ac77c 100644 --- a/html/pages/device/graphs/netstats_ip_forward.inc.php +++ b/html/pages/device/graphs/netstats_ip_forward.inc.php @@ -1,8 +1,11 @@ 'device', - 'device' => $device['device_id'], - 'tab' => 'health', -); +$link_array = array('page' => 'device', + 'device' => $device['device_id'], + 'tab' => 'health'); print_optionbar_start(); -echo "Health » "; +echo("Health » "); -if (!$vars['metric']) { - $vars['metric'] = 'overview'; -} +if (!$vars['metric']) { $vars['metric'] = "overview"; } unset($sep); -foreach ($datas as $type) { - echo $sep; +foreach ($datas as $type) +{ + echo($sep); - if ($vars['metric'] == $type) { - echo ''; - } - - echo generate_link($type_text[$type], $link_array, array('metric' => $type)); - if ($vars['metric'] == $type) { - echo ''; - } - - $sep = ' | '; + if ($vars['metric'] == $type) + { echo(''); } + echo(generate_link($type_text[$type],$link_array,array('metric'=>$type))); + if ($vars['metric'] == $type) { echo(""); } + $sep = " | "; } print_optionbar_end(); -if (is_file('pages/device/health/'.mres($vars['metric']).'.inc.php')) { - include 'pages/device/health/'.mres($vars['metric']).'.inc.php'; -} -else { - foreach ($datas as $type) { - if ($type != 'overview') { - $graph_title = $type_text[$type]; - $graph_array['type'] = 'device_'.$type; +if (is_file("pages/device/health/".mres($vars['metric']).".inc.php")) +{ + include("pages/device/health/".mres($vars['metric']).".inc.php"); +} else { - include 'includes/print-device-graph.php'; - } + foreach ($datas as $type) + { + if ($type != "overview") + { + + $graph_title = $type_text[$type]; + $graph_array['type'] = "device_".$type; + + include("includes/print-device-graph.php"); } + } } -$pagetitle[] = 'Health'; +$pagetitle[] = "Health"; + +?> diff --git a/html/pages/device/health/charge.inc.php b/html/pages/device/health/charge.inc.php index 0750ae5935..7282247bff 100644 --- a/html/pages/device/health/charge.inc.php +++ b/html/pages/device/health/charge.inc.php @@ -1,7 +1,9 @@ diff --git a/html/pages/device/health/current.inc.php b/html/pages/device/health/current.inc.php index 70bd4dc425..0fa318a9b3 100644 --- a/html/pages/device/health/current.inc.php +++ b/html/pages/device/health/current.inc.php @@ -4,4 +4,6 @@ $class = "current"; $unit = "A"; $graph_type = "sensor_current"; -require 'sensors.inc.php'; +include("sensors.inc.php"); + +?> diff --git a/html/pages/device/health/humidity.inc.php b/html/pages/device/health/humidity.inc.php index ffef7afa6a..93b4772a3f 100644 --- a/html/pages/device/health/humidity.inc.php +++ b/html/pages/device/health/humidity.inc.php @@ -4,4 +4,6 @@ $class = "humidity"; $unit = "%"; $graph_type = "sensor_humidity"; -require 'sensors.inc.php'; +include("sensors.inc.php"); + +?> diff --git a/html/pages/device/health/load.inc.php b/html/pages/device/health/load.inc.php index 18f5b5f5cd..399237aaef 100644 --- a/html/pages/device/health/load.inc.php +++ b/html/pages/device/health/load.inc.php @@ -1,7 +1,9 @@ diff --git a/html/pages/device/health/mempool.inc.php b/html/pages/device/health/mempool.inc.php index 613aa1250b..6630c31476 100644 --- a/html/pages/device/health/mempool.inc.php +++ b/html/pages/device/health/mempool.inc.php @@ -1,72 +1,66 @@ "; -echo ''; +echo("
    "); +echo("
    "); $i = '1'; -// FIXME css alternating colours -foreach (dbFetchRows('SELECT * FROM `mempools` WHERE device_id = ?', array($device['device_id'])) as $mempool) { - if (!is_integer($i / 2)) { - $row_colour = $list_colour_a; - } - else { - $row_colour = $list_colour_b; - } +#FIXME css alternating colours - if ($config['memcached']['enable'] === true) { - $state = $memcache->get('mempool-'.$mempool['mempool_id'].'-state'); - if ($debug) { - print_r($state); - } +foreach (dbFetchRows("SELECT * FROM `mempools` WHERE device_id = ?", array($device['device_id'])) as $mempool) +{ + if (!is_integer($i/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; } - if (is_array($state)) { - $mempool = array_merge($mempool, $state); - } + if ($config['memcached']['enable'] === TRUE) + { + $state = $memcache->get('mempool-'.$mempool['mempool_id'].'-state'); + if($debug) { print_r($state); } + if(is_array($state)) { $mempool = array_merge($mempool, $state); } + unset($state); + } - unset($state); - } + $text_descr = rewrite_entity_descr($mempool['mempool_descr']); - $text_descr = rewrite_entity_descr($mempool['mempool_descr']); + $mempool_url = "graphs/id=".$mempool['mempool_id']."/type=mempool_usage/"; + $mini_url = "graph.php?id=".$mempool['mempool_id']."&type=".$graph_type."&from=".$config['time']['day']."&to=".$config['time']['now']."&width=80&height=20&bg=f4f4f4"; - $mempool_url = 'graphs/id='.$mempool['mempool_id'].'/type=mempool_usage/'; - $mini_url = 'graph.php?id='.$mempool['mempool_id'].'&type='.$graph_type.'&from='.$config['time']['day'].'&to='.$config['time']['now'].'&width=80&height=20&bg=f4f4f4'; + $mempool_popup = "onmouseover=\"return overlib('
    ".$device['hostname']." - ".$text_descr; + $mempool_popup .= "
    "; + $mempool_popup .= "', RIGHT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\""; - $mempool_popup = "onmouseover=\"return overlib('
    ".$device['hostname'].' - '.$text_descr; - $mempool_popup .= "
    "; - $mempool_popup .= "', RIGHT".$config['overlib_defaults'].');" onmouseout="return nd();"'; + $total = formatStorage($mempool['mempool_total']); + $used = formatStorage($mempool['mempool_used']); + $free = formatStorage($mempool['mempool_free']); - $total = formatStorage($mempool['mempool_total']); - $used = formatStorage($mempool['mempool_used']); - $free = formatStorage($mempool['mempool_free']); + $perc = round($mempool['mempool_used'] / $mempool['mempool_total'] * 100); - $perc = round(($mempool['mempool_used'] / $mempool['mempool_total'] * 100)); + $background = get_percentage_colours($percent); + $right_background = $background['right']; + $left_background = $background['left']; - $background = get_percentage_colours($percent); - $right_background = $background['right']; - $left_background = $background['left']; + echo(" + + + + "); - echo " - - - - '; + echo(""); - echo ''; + $i++; +} - $i++; -}//end foreach +echo("
    " . $text_descr . " + ".print_percentage_bar (400, 20, $perc, "$used / $total", "ffffff", $left_background, $free , "ffffff", $right_background)." + ".$perc."%
    ".$text_descr." - ".print_percentage_bar(400, 20, $perc, "$used / $total", 'ffffff', $left_background, $free, 'ffffff', $right_background).' - '.$perc.'%
    "); - echo "
    "; + $graph_array['id'] = $mempool['mempool_id']; + $graph_array['type'] = $graph_type; - $graph_array['id'] = $mempool['mempool_id']; - $graph_array['type'] = $graph_type; + include("includes/print-graphrow.inc.php"); - include 'includes/print-graphrow.inc.php'; + echo("
    "); +echo("
    "); -echo ''; -echo '
    '; +?> diff --git a/html/pages/device/health/processor.inc.php b/html/pages/device/health/processor.inc.php index 725e37c21f..bde4a3b3f1 100644 --- a/html/pages/device/health/processor.inc.php +++ b/html/pages/device/health/processor.inc.php @@ -1,43 +1,46 @@ "; -echo ''; +echo("
    "); +echo("
    "); $i = '1'; -foreach (dbFetchRows('SELECT * FROM `processors` WHERE device_id = ?', array($device['device_id'])) as $proc) { - $proc_url = 'graphs/id='.$proc['processor_id'].'/type=processor_usage/'; +foreach (dbFetchRows("SELECT * FROM `processors` WHERE device_id = ?", array($device['device_id'])) as $proc) +{ + $proc_url = "graphs/id=".$proc['processor_id']."/type=processor_usage/"; - $mini_url = 'graph.php?id='.$proc['processor_id'].'&type='.$graph_type.'&from='.$config['time']['day'].'&to='.$config['time']['now'].'&width=80&height=20&bg=f4f4f4'; + $mini_url = "graph.php?id=".$proc['processor_id']."&type=".$graph_type."&from=".$config['time']['day']."&to=".$config['time']['now']."&width=80&height=20&bg=f4f4f4"; - $text_descr = $proc['processor_descr']; + $text_descr = $proc['processor_descr']; - $text_descr = rewrite_entity_descr($text_descr); + $text_descr = rewrite_entity_descr($text_descr); - $proc_popup = "onmouseover=\"return overlib('
    ".$device['hostname'].' - '.$text_descr; - $proc_popup .= "
    "; - $proc_popup .= "', RIGHT".$config['overlib_defaults'].');" onmouseout="return nd();"'; + $proc_popup = "onmouseover=\"return overlib('
    ".$device['hostname']." - ".$text_descr; + $proc_popup .= "
    "; + $proc_popup .= "', RIGHT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\""; - $percent = round($proc['processor_usage']); + $percent = round($proc['processor_usage']); - $background = get_percentage_colours($percent); + $background = get_percentage_colours($percent); - echo (" - + echo(" + - '); + "); - echo "
    ".$text_descr."
    " . $text_descr . " - ".print_percentage_bar(400, 20, $percent, $percent.'%', 'ffffff', $background['left'], (100 - $percent).'%', 'ffffff', $background['right']).' + ".print_percentage_bar (400, 20, $percent, $percent."%", "ffffff", $background['left'], (100 - $percent)."%" , "ffffff", $background['right'])."
    "; + echo("
    "); - $graph_array['id'] = $proc['processor_id']; - $graph_array['type'] = $graph_type; + $graph_array['id'] = $proc['processor_id']; + $graph_array['type'] = $graph_type; - include 'includes/print-graphrow.inc.php'; -}//end foreach + include("includes/print-graphrow.inc.php"); +} -echo '
    '; -echo ''; +echo(""); +echo(""); + +?> diff --git a/html/pages/device/health/state.inc.php b/html/pages/device/health/state.inc.php index 9781248bea..5463962196 100644 --- a/html/pages/device/health/state.inc.php +++ b/html/pages/device/health/state.inc.php @@ -1,7 +1,7 @@ '; +echo(""); -echo ' +echo(" - '; + "); $row = 1; -foreach (dbFetchRows('SELECT * FROM `storage` WHERE device_id = ? ORDER BY storage_descr', array($device['device_id'])) as $drive) { - if (is_integer($row / 2)) { - $row_colour = $list_colour_a; - } - else { - $row_colour = $list_colour_b; - } +foreach (dbFetchRows("SELECT * FROM `storage` WHERE device_id = ? ORDER BY storage_descr", array($device['device_id'])) as $drive) +{ + if (is_integer($row/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; } - $total = $drive['storage_size']; - $used = $drive['storage_used']; - $free = $drive['storage_free']; - $perc = round($drive['storage_perc'], 0); - $used = formatStorage($used); - $total = formatStorage($total); - $free = formatStorage($free); + $total = $drive['storage_size']; + $used = $drive['storage_used']; + $free = $drive['storage_free']; + $perc = round($drive['storage_perc'], 0); + $used = formatStorage($used); + $total = formatStorage($total); + $free = formatStorage($free); - $fs_url = 'graphs/id='.$drive['storage_id'].'/type=storage_usage/'; + $fs_url = "graphs/id=".$drive['storage_id']."/type=storage_usage/"; - $fs_popup = "onmouseover=\"return overlib('
    ".$device['hostname'].' - '.$drive['storage_descr']; - $fs_popup .= "
    "; - $fs_popup .= "', RIGHT, FGCOLOR, '#e5e5e5');\" onmouseout=\"return nd();\""; + $fs_popup = "onmouseover=\"return overlib('
    ".$device['hostname']." - ".$drive['storage_descr']; + $fs_popup .= "
    "; + $fs_popup .= "', RIGHT, FGCOLOR, '#e5e5e5');\" onmouseout=\"return nd();\""; - $background = get_percentage_colours($percent); + $background = get_percentage_colours($percent); - echo "'; + echo(""); - $graph_array['id'] = $drive['storage_id']; - $graph_array['type'] = $graph_type; + $graph_array['id'] = $drive['storage_id']; + $graph_array['type'] = $graph_type; - echo "'; + echo(""); - $row++; -}//end foreach + $row++; +} -echo '
    Drive Usage Free
    ".$drive['storage_descr']." - ".print_percentage_bar(400, 20, $perc, "$used / $total", 'ffffff', $background['left'], $perc.'%', 'ffffff', $background['right']).' - '.$free.'
    " . $drive['storage_descr'] . " + ".print_percentage_bar (400, 20, $perc, "$used / $total", "ffffff", $background['left'], $perc . "%", "ffffff", $background['right'])." + " . $free . "
    "; + echo("
    "); - include 'includes/print-graphrow.inc.php'; + include("includes/print-graphrow.inc.php"); - echo '
    '; +echo(""); + +?> diff --git a/html/pages/device/hrdevice.inc.php b/html/pages/device/hrdevice.inc.php index d16a0ba839..68928187b3 100644 --- a/html/pages/device/hrdevice.inc.php +++ b/html/pages/device/hrdevice.inc.php @@ -1,69 +1,70 @@ '; +echo(''); // FIXME missing heading -foreach (dbFetchRows('SELECT * FROM `hrDevice` WHERE `device_id` = ? ORDER BY `hrDeviceIndex`', array($device['device_id'])) as $hrdevice) { - echo "'; - if ($hrdevice['hrDeviceType'] == 'hrDeviceProcessor') { - $proc_id = dbFetchCell("SELECT processor_id FROM processors WHERE device_id = '".$device['device_id']."' AND hrDeviceIndex = '".$hrdevice['hrDeviceIndex']."'"); - $proc_url = 'device/device='.$device['device_id'].'/tab=health/metric=processor/'; - $proc_popup = "onmouseover=\"return overlib('
    ".$device['hostname'].' - '.$hrdevice['hrDeviceDescr']; - $proc_popup .= "
    "; - $proc_popup .= "', RIGHT".$config['overlib_defaults'].');" onmouseout="return nd();"'; - echo "'; +foreach (dbFetchRows("SELECT * FROM `hrDevice` WHERE `device_id` = ? ORDER BY `hrDeviceIndex`", array($device['device_id'])) as $hrdevice) +{ + echo(""); - $graph_array['height'] = '20'; - $graph_array['width'] = '100'; - $graph_array['to'] = $config['time']['now']; - $graph_array['id'] = $proc_id; - $graph_array['type'] = 'processor_usage'; - $graph_array['from'] = $config['time']['day']; - $graph_array_zoom = $graph_array; - $graph_array_zoom['height'] = '150'; - $graph_array_zoom['width'] = '400'; + if ($hrdevice['hrDeviceType'] == "hrDeviceProcessor") + { + $proc_id = dbFetchCell("SELECT processor_id FROM processors WHERE device_id = '".$device['device_id']."' AND hrDeviceIndex = '".$hrdevice['hrDeviceIndex']."'"); + $proc_url = "device/device=".$device['device_id']."/tab=health/metric=processor/"; + $proc_popup = "onmouseover=\"return overlib('
    ".$device['hostname']." - ".$hrdevice['hrDeviceDescr']; + $proc_popup .= "
    "; + $proc_popup .= "', RIGHT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\""; + echo(""); - $mini_graph = overlib_link($proc_url, generate_graph_tag($graph_array), generate_graph_tag($graph_array_zoom), null); + $graph_array['height'] = "20"; + $graph_array['width'] = "100"; + $graph_array['to'] = $config['time']['now']; + $graph_array['id'] = $proc_id; + $graph_array['type'] = 'processor_usage'; + $graph_array['from'] = $config['time']['day']; + $graph_array_zoom = $graph_array; $graph_array_zoom['height'] = "150"; $graph_array_zoom['width'] = "400"; - echo ''; + $mini_graph = overlib_link($proc_url, generate_graph_tag($graph_array), generate_graph_tag($graph_array_zoom), NULL); + + echo(''); + } + elseif ($hrdevice['hrDeviceType'] == "hrDeviceNetwork") + { + $int = str_replace("network interface ", "", $hrdevice['hrDeviceDescr']); + $interface = dbFetchRow("SELECT * FROM ports WHERE device_id = ? AND ifDescr = ?", array($device['device_id'], $int)); + if ($interface['ifIndex']) + { + echo(""); + + $graph_array['height'] = "20"; + $graph_array['width'] = "100"; + $graph_array['to'] = $config['time']['now']; + $graph_array['id'] = $interface['port_id']; + $graph_array['type'] = 'port_bits'; + $graph_array['from'] = $config['time']['day']; + $graph_array_zoom = $graph_array; $graph_array_zoom['height'] = "150"; $graph_array_zoom['width'] = "400"; + + // FIXME click on graph should also link to port, but can't use generate_port_link here... + $mini_graph = overlib_link(generate_port_url($interface), generate_graph_tag($graph_array), generate_graph_tag($graph_array_zoom), NULL); + + echo(""); + } else { + echo(""); + echo(""); } - else if ($hrdevice['hrDeviceType'] == 'hrDeviceNetwork') { - $int = str_replace('network interface ', '', $hrdevice['hrDeviceDescr']); - $interface = dbFetchRow('SELECT * FROM ports WHERE device_id = ? AND ifDescr = ?', array($device['device_id'], $int)); - if ($interface['ifIndex']) { - echo ''; + } else { + echo(""); + echo(""); + } - $graph_array['height'] = '20'; - $graph_array['width'] = '100'; - $graph_array['to'] = $config['time']['now']; - $graph_array['id'] = $interface['port_id']; - $graph_array['type'] = 'port_bits'; - $graph_array['from'] = $config['time']['day']; - $graph_array_zoom = $graph_array; - $graph_array_zoom['height'] = '150'; - $graph_array_zoom['width'] = '400'; + echo(""); + echo(""); + echo(""); +} - // FIXME click on graph should also link to port, but can't use generate_port_link here... - $mini_graph = overlib_link(generate_port_url($interface), generate_graph_tag($graph_array), generate_graph_tag($graph_array_zoom), null); +echo('
    ".$hrdevice['hrDeviceIndex'].'".$hrdevice['hrDeviceDescr'].'
    ".$hrdevice['hrDeviceIndex']."".$hrdevice['hrDeviceDescr']."'.$mini_graph.''.$mini_graph.'".generate_port_link($interface)."$mini_graph".stripslashes($hrdevice['hrDeviceDescr'])."'.generate_port_link($interface).'".stripslashes($hrdevice['hrDeviceDescr'])."".$hrdevice['hrDeviceType'].''.$hrdevice['hrDeviceStatus']."".$hrdevice['hrDeviceErrors'].''.$hrdevice['hrProcessorLoad']."
    '); - echo "$mini_graph"; - } - else { - echo ''.stripslashes($hrdevice['hrDeviceDescr']).''; - echo ''; - } - } - else { - echo ''.stripslashes($hrdevice['hrDeviceDescr']).''; - echo ''; - }//end if +$pagetitle[] = "Inventory"; - echo ''.$hrdevice['hrDeviceType'].''.$hrdevice['hrDeviceStatus'].''; - echo ''.$hrdevice['hrDeviceErrors'].''.$hrdevice['hrProcessorLoad'].''; - echo ''; -}//end foreach - -echo ''; - -$pagetitle[] = 'Inventory'; +?> diff --git a/html/pages/device/loadbalancer/ace_rservers.inc.php b/html/pages/device/loadbalancer/ace_rservers.inc.php index c8b4b2acdc..52f1773c7e 100644 --- a/html/pages/device/loadbalancer/ace_rservers.inc.php +++ b/html/pages/device/loadbalancer/ace_rservers.inc.php @@ -33,10 +33,10 @@ echo ' Graphs: '; // "pkts" => "Packets", // "errors" => "Errors"); $graph_types = array( - 'curr' => 'CurrentConns', - 'failed' => 'FailedConns', - 'total' => 'TotalConns', -); + 'curr' => 'CurrentConns', + 'failed' => 'FailedConns', + 'total' => 'TotalConns', + ); foreach ($graph_types as $type => $descr) { echo "$type_sep"; @@ -66,8 +66,7 @@ foreach (dbFetchRows('SELECT * FROM `loadbalancer_rservers` WHERE `device_id` = if ($rserver['StateDescr'] == 'Server is now operational') { $rserver_class = 'green'; - } - else { + } else { $rserver_class = 'red'; } @@ -88,7 +87,7 @@ foreach (dbFetchRows('SELECT * FROM `loadbalancer_rservers` WHERE `device_id` = $graph_array['id'] = $rserver['rserver_id']; $graph_array['type'] = $graph_type; - require 'includes/print-graphrow.inc.php'; + include 'includes/print-graphrow.inc.php'; // include("includes/print-interface-graphs.inc.php"); echo ' diff --git a/html/pages/device/loadbalancer/ace_vservers.inc.php b/html/pages/device/loadbalancer/ace_vservers.inc.php index 68ebd1d3f5..65032709c8 100644 --- a/html/pages/device/loadbalancer/ace_vservers.inc.php +++ b/html/pages/device/loadbalancer/ace_vservers.inc.php @@ -2,101 +2,84 @@ print_optionbar_start(); -echo "Serverfarms » "; +echo("Serverfarms » "); -// $auth = TRUE; -$menu_options = array('basic' => 'Basic'); +#$auth = TRUE; -if (!$_GET['opta']) { - $_GET['opta'] = 'basic'; -} +$menu_options = array('basic' => 'Basic', + ); -$sep = ''; -foreach ($menu_options as $option => $text) { - if ($_GET['type'] == $option) { - echo ""; - } +if (!$_GET['opta']) { $_GET['opta'] = "basic"; } - echo ''.$text.''; - if ($_GET['type'] == $option) { - echo ''; - } - - echo ' | '; +$sep = ""; +foreach ($menu_options as $option => $text) +{ + if ($_GET['type'] == $option) { echo(""); } + echo(''.$text.''); + if ($_GET['type'] == $option) { echo(""); } + echo(" | "); } unset($sep); -echo ' Graphs: '; +echo(' Graphs: '); -$graph_types = array( - 'bits' => 'Bits', - 'pkts' => 'Packets', - 'conns' => 'Connections', -); +$graph_types = array("bits" => "Bits", + "pkts" => "Packets", + "conns" => "Connections"); -foreach ($graph_types as $type => $descr) { - echo "$type_sep"; - if ($_GET['opte'] == $type) { - echo ""; - } +foreach ($graph_types as $type => $descr) +{ + echo("$type_sep"); + if ($_GET['opte'] == $type) { echo(""); } + echo(''.$descr.''); + echo(''.$text.''); + if ($_GET['opte'] == $type) { echo(""); } - echo ''.$descr.''; - echo ''.$text.''; - if ($_GET['opte'] == $type) { - echo ''; - } - - $type_sep = ' | '; + $type_sep = " | "; } print_optionbar_end(); -echo "
    "; -$i = '0'; -foreach (dbFetchRows('SELECT * FROM `loadbalancer_vservers` WHERE `device_id` = ? ORDER BY `classmap`', array($device['device_id'])) as $vserver) { - if (is_integer($i / 2)) { - $bg_colour = $list_colour_a; - } - else { - $bg_colour = $list_colour_b; - } +echo("
    "); +$i = "0"; +foreach (dbFetchRows("SELECT * FROM `loadbalancer_vservers` WHERE `device_id` = ? ORDER BY `classmap`", array($device['device_id'])) as $vserver) +{ +if (is_integer($i/2)) { $bg_colour = $list_colour_a; } else { $bg_colour = $list_colour_b; } - if ($vserver['serverstate'] == 'inService') { - $vserver_class = 'green'; - } - else { - $vserver_class = 'red'; - } +if($vserver['serverstate'] == "inService") { $vserver_class="green"; } else { $vserver_class="red"; } - echo ""; - // echo(""); - echo ''; - // echo(""); - echo "'; - echo ''; - if ($_GET['type'] == 'graphs') { - echo ''; - echo '"); +#echo(""); +echo(""); +#echo(""); +echo(""); +echo(""); + if ($_GET['type'] == "graphs") + { + echo(''); + echo(" - '; - } + echo(" + + "); + } - echo ''; - echo ''; +echo(""); +echo(""); - $i++; -}//end foreach + $i++; +} -echo '
    " . $tunnel['local_addr'] . " » " . $tunnel['peer_addr'] . "'.$vserver['classmap'].'" . $rserver['farm_id'] . "".$vserver['serverstate'].'
    '; - $graph_type = 'vserver_'.$_GET['opte']; +echo("
    " . $tunnel['local_addr'] . " » " . $tunnel['peer_addr'] . "" . $vserver['classmap'] . "" . $rserver['farm_id'] . "" . $vserver['serverstate'] . "
    "); + $graph_type = "vserver_" . $_GET['opte']; - $graph_array['height'] = '100'; - $graph_array['width'] = '215'; - $graph_array['to'] = $config['time']['now']; - $graph_array['id'] = $vserver['classmap_id']; - $graph_array['type'] = $graph_type; +$graph_array['height'] = "100"; +$graph_array['width'] = "215"; +$graph_array['to'] = $config['time']['now']; +$graph_array['id'] = $vserver['classmap_id']; +$graph_array['type'] = $graph_type; - include 'includes/print-graphrow.inc.php'; +include("includes/print-graphrow.inc.php"); - echo ' -
    '; +echo(""); + +?> diff --git a/html/pages/device/loadbalancer/netscaler_vsvr.inc.php b/html/pages/device/loadbalancer/netscaler_vsvr.inc.php index 91abc8204f..a67d755b9a 100644 --- a/html/pages/device/loadbalancer/netscaler_vsvr.inc.php +++ b/html/pages/device/loadbalancer/netscaler_vsvr.inc.php @@ -1,6 +1,6 @@ VServer » "); // echo('All'); diff --git a/html/pages/device/logs.inc.php b/html/pages/device/logs.inc.php index 11fd6914ba..0b8481a68f 100644 --- a/html/pages/device/logs.inc.php +++ b/html/pages/device/logs.inc.php @@ -1,43 +1,41 @@ Logging » '; +echo("Logging » "); -if ($vars['section'] == 'eventlog') { - echo ''; +if ($vars['section'] == "eventlog") { + echo(''); } - -echo generate_link('Event Log', $vars, array('section' => 'eventlog')); -if ($vars['section'] == 'eventlog') { - echo ''; +echo(generate_link("Event Log" , $vars, array('section'=>'eventlog'))); +if ($vars['section'] == "eventlog") { + echo(""); } if (isset($config['enable_syslog']) && $config['enable_syslog'] == 1) { - echo ' | '; + echo(" | "); - if ($vars['section'] == 'syslog') { - echo ''; + if ($vars['section'] == "syslog") { + echo(''); } - - echo generate_link('Syslog', $vars, array('section' => 'syslog')); - if ($vars['section'] == 'syslog') { - echo ''; + echo(generate_link("Syslog" , $vars, array('section'=>'syslog'))); + if ($vars['section'] == "syslog") { + echo(""); } } -switch ($vars['section']) { - case 'syslog': - case 'eventlog': - include 'pages/device/logs/'.$vars['section'].'.inc.php'; - break; - - default: - print_optionbar_end(); - echo report_this('Unknown section '.$vars['section']); - break; +switch ($vars['section']) +{ + case 'syslog': + case 'eventlog': + include('pages/device/logs/'.$vars['section'].'.inc.php'); + break; + default: + print_optionbar_end(); + echo(report_this('Unknown section '.$vars['section'])); + break; } + +?> diff --git a/html/pages/device/logs/eventlog.inc.php b/html/pages/device/logs/eventlog.inc.php index 7d5204f1cd..aec8bdd98c 100644 --- a/html/pages/device/logs/eventlog.inc.php +++ b/html/pages/device/logs/eventlog.inc.php @@ -2,49 +2,51 @@
    +echo('
    Eventlog entries
    - '; +
    '); -foreach ($entries as $entry) { - include 'includes/print-event.inc.php'; +foreach ($entries as $entry) +{ + include("includes/print-event.inc.php"); } -echo '
    -
    '; +echo(' + '); -$pagetitle[] = 'Events'; +$pagetitle[] = "Events"; + +?> diff --git a/html/pages/device/logs/syslog.inc.php b/html/pages/device/logs/syslog.inc.php index 1284ad157f..7aae3b8e0c 100644 --- a/html/pages/device/logs/syslog.inc.php +++ b/html/pages/device/logs/syslog.inc.php @@ -3,54 +3,53 @@
    +$sql = "SELECT *, DATE_FORMAT(timestamp, '".$config['dateformat']['mysql']['compact']."') AS date from syslog WHERE device_id = ? $where"; +$sql .= " ORDER BY timestamp DESC LIMIT 1000"; +echo('
    Syslog entries
    - '; -foreach (dbFetchRows($sql, $param) as $entry) { - include 'includes/print-syslog.inc.php'; -} +
    '); +foreach (dbFetchRows($sql, $param) as $entry) { include("includes/print-syslog.inc.php"); } +echo('
    +
    '); +$pagetitle[] = "Syslog"; -echo ' - '; -$pagetitle[] = 'Syslog'; +?> diff --git a/html/pages/device/map.inc.php b/html/pages/device/map.inc.php index 918f62e7fc..522de36a51 100644 --- a/html/pages/device/map.inc.php +++ b/html/pages/device/map.inc.php @@ -12,6 +12,8 @@ * the source code distribution for details. */ -$pagetitle[] = 'Map'; +$pagetitle[] = "Map"; -require_once 'includes/print-map.inc.php'; +require_once "includes/print-map.inc.php"; + +?> diff --git a/html/pages/device/munin.inc.php b/html/pages/device/munin.inc.php index e12279687e..67fd22d6e0 100644 --- a/html/pages/device/munin.inc.php +++ b/html/pages/device/munin.inc.php @@ -1,72 +1,75 @@ 'device', - 'device' => $device['device_id'], - 'tab' => 'munin', -); -$bg = '#ffffff'; +$link_array = array('page' => 'device', + 'device' => $device['device_id'], + 'tab' => 'munin'); -echo '
    '; +$bg="#ffffff"; + +echo('
    '); print_optionbar_start(); -echo "Munin » "; +echo("Munin » "); -$sep = ''; +$sep = ""; -foreach (dbFetchRows('SELECT * FROM munin_plugins WHERE device_id = ? ORDER BY mplug_category, mplug_type', array($device['device_id'])) as $mplug) { - // if (strlen($mplug['mplug_category']) == 0) { $mplug['mplug_category'] = "general"; } else { } - $graph_enable[$mplug['mplug_category']][$mplug['mplug_type']]['id'] = $mplug['mplug_id']; - $graph_enable[$mplug['mplug_category']][$mplug['mplug_type']]['title'] = $mplug['mplug_title']; - $graph_enable[$mplug['mplug_category']][$mplug['mplug_type']]['plugin'] = $mplug['mplug_type']; +foreach (dbFetchRows("SELECT * FROM munin_plugins WHERE device_id = ? ORDER BY mplug_category, mplug_type", array($device['device_id'])) as $mplug) +{ +# if (strlen($mplug['mplug_category']) == 0) { $mplug['mplug_category'] = "general"; } else { } + $graph_enable[$mplug['mplug_category']][$mplug['mplug_type']]['id'] = $mplug['mplug_id']; + $graph_enable[$mplug['mplug_category']][$mplug['mplug_type']]['title'] = $mplug['mplug_title']; + $graph_enable[$mplug['mplug_category']][$mplug['mplug_type']]['plugin'] = $mplug['mplug_type']; } -foreach ($graph_enable as $section => $nothing) { - if (isset($graph_enable) && is_array($graph_enable[$section])) { - $type = strtolower($section); - if (!$vars['group']) { - $vars['group'] = $type; - } - - echo $sep; - if ($vars['group'] == $type) { - echo ''; - } - - echo generate_link(ucwords($type), $link_array, array('group' => $type)); - if ($vars['group'] == $type) { - echo ''; - } - - $sep = ' | '; +foreach ($graph_enable as $section => $nothing) +{ + if (isset($graph_enable) && is_array($graph_enable[$section])) + { + $type = strtolower($section); + if (!$vars['group']) { $vars['group'] = $type; } + echo($sep); + if ($vars['group'] == $type) + { + echo(''); } + echo(generate_link(ucwords($type),$link_array,array('group'=>$type))); + if ($vars['group'] == $type) + { + echo(""); + } + $sep = " | "; + } } -unset($sep); +unset ($sep); print_optionbar_end(); $graph_enable = $graph_enable[$vars['group']]; -// foreach ($config['graph_types']['device'] as $graph => $entry) -foreach ($graph_enable as $graph => $entry) { - $graph_array = array(); - if ($graph_enable[$graph]) { - if (!empty($entry['plugin'])) { - $graph_title = $entry['title']; - $graph_array['type'] = 'munin_graph'; - $graph_array['device'] = $device['device_id']; - $graph_array['plugin'] = $entry['plugin']; - } - else { - $graph_title = $config['graph_types']['device'][$graph]['descr']; - $graph_array['type'] = 'device_'.$graph; - } - - include 'includes/print-device-graph.php'; +#foreach ($config['graph_types']['device'] as $graph => $entry) +foreach ($graph_enable as $graph => $entry) +{ + $graph_array = array(); + if ($graph_enable[$graph]) + { + if (!empty($entry['plugin'])) + { + $graph_title = $entry['title']; + $graph_array['type'] = "munin_graph"; + $graph_array['device'] = $device['device_id']; + $graph_array['plugin'] = $entry['plugin']; + } else { + $graph_title = $config['graph_types']['device'][$graph]['descr']; + $graph_array['type'] = "device_" . $graph; } + + include("includes/print-device-graph.php"); + } } -$pagetitle[] = 'Graphs'; +$pagetitle[] = "Graphs"; + +?> diff --git a/html/pages/device/overview.inc.php b/html/pages/device/overview.inc.php index 13227e0136..aac3b2ca23 100644 --- a/html/pages/device/overview.inc.php +++ b/html/pages/device/overview.inc.php @@ -12,18 +12,8 @@ $services['up'] = dbFetchCell("SELECT COUNT(service_id) FROM `services` WH $services['down'] = dbFetchCell("SELECT COUNT(service_id) FROM `services` WHERE `device_id` = ? AND `service_status` = '0' AND `service_ignore` = '0'", array($device['device_id'])); $services['disabled'] = dbFetchCell("SELECT COUNT(service_id) FROM `services` WHERE `device_id` = ? AND `service_ignore` = '1'", array($device['device_id'])); -if ($services['down']) { - $services_colour = $warn_colour_a; -} -else { - $services_colour = $list_colour_a; -} -if ($ports['down']) { - $ports_colour = $warn_colour_a; -} -else { - $ports_colour = $list_colour_a; -} +if ($services['down']) { $services_colour = $warn_colour_a; } else { $services_colour = $list_colour_a; } +if ($ports['down']) { $ports_colour = $warn_colour_a; } else { $ports_colour = $list_colour_a; } echo('
    @@ -35,41 +25,39 @@ echo('
    '); -require 'includes/dev-overview-data.inc.php'; +include("includes/dev-overview-data.inc.php"); Plugins::call('device_overview_container',array($device)); -require 'overview/ports.inc.php'; +include("overview/ports.inc.php"); echo('
    '); // Right Pane -require 'overview/processors.inc.php'; -require 'overview/mempools.inc.php'; -require 'overview/storage.inc.php'; +include("overview/processors.inc.php"); +include("overview/mempools.inc.php"); +include("overview/storage.inc.php"); -if(is_array($entity_state['group']['c6kxbar'])) { - require 'overview/c6kxbar.inc.php'; -} +if(is_array($entity_state['group']['c6kxbar'])) { include("overview/c6kxbar.inc.php"); } -require 'overview/toner.inc.php'; -require 'overview/sensors/charge.inc.php'; -require 'overview/sensors/temperatures.inc.php'; -require 'overview/sensors/humidity.inc.php'; -require 'overview/sensors/fanspeeds.inc.php'; -require 'overview/sensors/dbm.inc.php'; -require 'overview/sensors/voltages.inc.php'; -require 'overview/sensors/current.inc.php'; -require 'overview/sensors/power.inc.php'; -require 'overview/sensors/frequencies.inc.php'; -require 'overview/sensors/load.inc.php'; -require 'overview/sensors/state.inc.php'; -require 'overview/eventlog.inc.php'; -require 'overview/services.inc.php'; -require 'overview/syslog.inc.php'; +include("overview/toner.inc.php"); +include("overview/sensors/charge.inc.php"); +include("overview/sensors/temperatures.inc.php"); +include("overview/sensors/humidity.inc.php"); +include("overview/sensors/fanspeeds.inc.php"); +include("overview/sensors/dbm.inc.php"); +include("overview/sensors/voltages.inc.php"); +include("overview/sensors/current.inc.php"); +include("overview/sensors/power.inc.php"); +include("overview/sensors/frequencies.inc.php"); +include("overview/sensors/load.inc.php"); +include("overview/sensors/state.inc.php"); +include("overview/eventlog.inc.php"); +include("overview/services.inc.php"); +include("overview/syslog.inc.php"); echo('
    '); -#require 'overview/current.inc.php"); +#include("overview/current.inc.php"); ?> diff --git a/html/pages/device/overview/c6kxbar.inc.php b/html/pages/device/overview/c6kxbar.inc.php index eb04e0a7db..14f5d54e48 100644 --- a/html/pages/device/overview/c6kxbar.inc.php +++ b/html/pages/device/overview/c6kxbar.inc.php @@ -1,99 +1,102 @@ -
    -
    -
    -
    '; -echo ''; -echo " Catalyst 6k Crossbar"; -echo '
    - '; + echo('
    +
    +
    +
    +
    '); +echo(''); +echo(" Catalyst 6k Crossbar"); +echo('
    +
    '); -foreach ($entity_state['group']['c6kxbar'] as $index => $entry) { - // FIXME i'm not sure if this is the correct way to decide what entphysical index it is. slotnum+1? :> - $entity = dbFetchRow('SELECT * FROM entPhysical WHERE device_id = ? AND entPhysicalIndex = ?', array($device['device_id'], $index + 1)); +foreach ($entity_state['group']['c6kxbar'] as $index => $entry) +{ + // FIXME i'm not sure if this is the correct way to decide what entphysical index it is. slotnum+1? :> + $entity = dbFetchRow("SELECT * FROM entPhysical WHERE device_id = ? AND entPhysicalIndex = ?", array($device['device_id'], $index+1)); - echo " + echo(" - - '; + echo(" + "); - foreach ($entity_state['group']['c6kxbar'][$index] as $subindex => $fabric) { - if (is_numeric($subindex)) { - if ($fabric['cc6kxbarModuleChannelFabStatus'] == 'ok') { - $fabric['mode_class'] = 'green'; - } - else { - $fabric['mode_class'] = 'red'; - } + foreach ($entity_state['group']['c6kxbar'][$index] as $subindex => $fabric) + { + if (is_numeric($subindex)) + { + if ($fabric['cc6kxbarModuleChannelFabStatus'] == "ok") + { + $fabric['mode_class'] = "green"; + } else { + $fabric['mode_class'] = "red"; + } - $percent_in = $fabric['cc6kxbarStatisticsInUtil']; - $background_in = get_percentage_colours($percent_in); + $percent_in = $fabric['cc6kxbarStatisticsInUtil']; + $background_in = get_percentage_colours($percent_in); - $percent_out = $fabric['cc6kxbarStatisticsOutUtil']; - $background_out = get_percentage_colours($percent_out); + $percent_out = $fabric['cc6kxbarStatisticsOutUtil']; + $background_out = get_percentage_colours($percent_out); - $graph_array = array(); - $graph_array['height'] = '100'; - $graph_array['width'] = '210'; - $graph_array['to'] = $config['time']['now']; - $graph_array['device'] = $device['device_id']; - $graph_array['mod'] = $index; - $graph_array['chan'] = $subindex; - $graph_array['type'] = 'c6kxbar_util'; - $graph_array['from'] = $config['time']['day']; - $graph_array['legend'] = 'no'; + $graph_array = array(); + $graph_array['height'] = "100"; + $graph_array['width'] = "210"; + $graph_array['to'] = $config['time']['now']; + $graph_array['device'] = $device['device_id']; + $graph_array['mod'] = $index; + $graph_array['chan'] = $subindex; + $graph_array['type'] = "c6kxbar_util"; + $graph_array['from'] = $config['time']['day']; + $graph_array['legend'] = "no"; - $link_array = $graph_array; - $link_array['page'] = 'graphs'; - unset($link_array['height'], $link_array['width'], $link_array['legend']); - $link = generate_url($link_array); + $link_array = $graph_array; + $link_array['page'] = "graphs"; + unset($link_array['height'], $link_array['width'], $link_array['legend']); + $link = generate_url($link_array); - $text_descr = $entity['entPhysicalName'].' - Fabric '.$subindex; + $text_descr = $entity['entPhysicalName'] . " - Fabric " . $subindex; - $overlib_content = generate_overlib_content($graph_array, $device['hostname'].' - '.$text_descr); + $overlib_content = generate_overlib_content($graph_array, $device['hostname'] . " - " . $text_descr); - $graph_array['width'] = 80; - $graph_array['height'] = 20; - $graph_array['bg'] = 'ffffff00'; - // the 00 at the end makes the area transparent. - $minigraph = generate_graph_tag($graph_array); + $graph_array['width'] = 80; $graph_array['height'] = 20; $graph_array['bg'] = 'ffffff00'; # the 00 at the end makes the area transparent. - echo (' - - - + + + + + + + "); + } + } +} + +echo("
    ".$entity['entPhysicalName'].""; + "); - switch ($entry['']['cc6kxbarModuleModeSwitchingMode']) { - case 'busmode': - // echo 'Bus'; + switch ($entry['']['cc6kxbarModuleModeSwitchingMode']) + { + case "busmode": + # echo 'Bus'; break; - - case 'crossbarmode': + case "crossbarmode": echo 'Crossbar'; break; - - case 'dcefmode': + case "dcefmode": echo 'DCEF'; break; - - default: + default: echo $entry['']['cc6kxbarModuleModeSwitchingMode']; } - echo '
    Fabric '.$subindex." + Fabric ".$subindex."". + + $fabric['cc6kxbarModuleChannelFabStatus']."".formatRates($fabric['cc6kxbarModuleChannelSpeed']*1000000)."".overlib_link($link, $minigraph, $overlib_content)."".print_percentage_bar (125, 20, $percent_in, "Ingress", "ffffff", $background['left'], $percent_in . "%", "ffffff", $background['right'])."".print_percentage_bar (125, 20, $percent_out, "Egress", "ffffff", $background['left'], $percent_out . "%", "ffffff", $background['right'])."
    "); +echo("
    "); +echo("
    "); +echo("
    "); +echo("
    "); + +?> diff --git a/html/pages/device/overview/eventlog.inc.php b/html/pages/device/overview/eventlog.inc.php index d555118136..ff235aa4a8 100644 --- a/html/pages/device/overview/eventlog.inc.php +++ b/html/pages/device/overview/eventlog.inc.php @@ -1,22 +1,25 @@ '; -echo '
    +echo('
    '); + echo('
    -
    '; -echo ''; -echo " Recent Events"; -echo '
    - '; +
    '); +echo(''); +echo(" Recent Events"); +echo('
    +
    '); $eventlog = dbFetchRows("SELECT *,DATE_FORMAT(datetime, '".$config['dateformat']['mysql']['compact']."') as humandate FROM `eventlog` WHERE `host` = ? ORDER BY `datetime` DESC LIMIT 0,10", array($device['device_id'])); -foreach ($eventlog as $entry) { - include 'includes/print-event-short.inc.php'; +foreach ($eventlog as $entry) +{ + include("includes/print-event-short.inc.php"); } -echo '
    '; -echo '
    '; -echo '
    '; -echo '
    '; -echo '
    '; +echo(""); +echo('
    '); +echo('
    '); +echo(''); +echo(''); + +?> diff --git a/html/pages/device/overview/generic/sensor.inc.php b/html/pages/device/overview/generic/sensor.inc.php index 36bc05cd5d..6194c37c00 100644 --- a/html/pages/device/overview/generic/sensor.inc.php +++ b/html/pages/device/overview/generic/sensor.inc.php @@ -1,71 +1,75 @@ +if (count($sensors)) +{ + echo('
    -
    -
    -
    '; - echo ' '.$sensor_type.''; - echo '
    - '; - foreach ($sensors as $sensor) { - if ($config['memcached']['enable'] === true) { - $sensor['sensor_current'] = $memcache->get('sensor-'.$sensor['sensor_id'].'-value'); - } +
    +
    +
    '); + echo(' ' . $sensor_type . ''); + echo('
    +
    '); + foreach ($sensors as $sensor) + { + if ($config['memcached']['enable'] === TRUE) + { + $sensor['sensor_current'] = $memcache->get('sensor-'.$sensor['sensor_id'].'-value'); + } - if (empty($sensor['sensor_current'])) { - $sensor['sensor_current'] = 'NaN'; - } + if (empty($sensor['sensor_current'])) + { + $sensor['sensor_current'] = "NaN"; + } - // FIXME - make this "four graphs in popup" a function/include and "small graph" a function. - // FIXME - So now we need to clean this up and move it into a function. Isn't it just "print-graphrow"? - // FIXME - DUPLICATED IN health/sensors - $graph_colour = str_replace('#', '', $row_colour); + // FIXME - make this "four graphs in popup" a function/include and "small graph" a function. + // FIXME - So now we need to clean this up and move it into a function. Isn't it just "print-graphrow"? + // FIXME - DUPLICATED IN health/sensors - $graph_array = array(); - $graph_array['height'] = '100'; - $graph_array['width'] = '210'; - $graph_array['to'] = $config['time']['now']; - $graph_array['id'] = $sensor['sensor_id']; - $graph_array['type'] = $graph_type; - $graph_array['from'] = $config['time']['day']; - $graph_array['legend'] = 'no'; + $graph_colour = str_replace("#", "", $row_colour); - $link_array = $graph_array; - $link_array['page'] = 'graphs'; - unset($link_array['height'], $link_array['width'], $link_array['legend']); - $link = generate_url($link_array); + $graph_array = array(); + $graph_array['height'] = "100"; + $graph_array['width'] = "210"; + $graph_array['to'] = $config['time']['now']; + $graph_array['id'] = $sensor['sensor_id']; + $graph_array['type'] = $graph_type; + $graph_array['from'] = $config['time']['day']; + $graph_array['legend'] = "no"; - $overlib_content = '

    '.$device['hostname'].' - '.$sensor['sensor_descr'].'

    '; - foreach (array('day', 'week', 'month', 'year') as $period) { - $graph_array['from'] = $config['time'][$period]; - $overlib_content .= str_replace('"', "\'", generate_graph_tag($graph_array)); - } + $link_array = $graph_array; + $link_array['page'] = "graphs"; + unset($link_array['height'], $link_array['width'], $link_array['legend']); + $link = generate_url($link_array); - $overlib_content .= '
    '; + $overlib_content = '

    '.$device['hostname']." - ".$sensor['sensor_descr']."

    "; + foreach (array('day','week','month','year') as $period) + { + $graph_array['from'] = $config['time'][$period]; + $overlib_content .= str_replace('"', "\'", generate_graph_tag($graph_array)); + } + $overlib_content .= "
    "; - $graph_array['width'] = 80; - $graph_array['height'] = 20; - $graph_array['bg'] = 'ffffff00'; - // the 00 at the end makes the area transparent. - $graph_array['from'] = $config['time']['day']; - $sensor_minigraph = generate_graph_tag($graph_array); + $graph_array['width'] = 80; $graph_array['height'] = 20; $graph_array['bg'] = 'ffffff00'; # the 00 at the end makes the area transparent. + $graph_array['from'] = $config['time']['day']; + $sensor_minigraph = generate_graph_tag($graph_array); - $sensor['sensor_descr'] = truncate($sensor['sensor_descr'], 48, ''); + $sensor['sensor_descr'] = truncate($sensor['sensor_descr'], 48, ''); - echo ' - - - - '; - }//end foreach + echo(" + + + + "); + } - echo '
    '.overlib_link($link, $sensor['sensor_descr'], $overlib_content).''.overlib_link($link, $sensor_minigraph, $overlib_content).''.overlib_link($link, ' $sensor['sensor_limit'] ? "style='color: red'" : '').'>'.$sensor['sensor_current'].$sensor_unit.'', $overlib_content).'
    ".overlib_link($link, $sensor['sensor_descr'], $overlib_content)."".overlib_link($link, $sensor_minigraph, $overlib_content)."".overlib_link($link, " $sensor['sensor_limit'] ? "style='color: red'" : '') . '>' . $sensor['sensor_current'] . $sensor_unit . "", $overlib_content)."
    '; - echo '
    '; - echo '
    '; - echo '
    '; - echo '
    '; -}//end if + echo(""); + echo(""); + echo(""); + echo(""); + echo(""); +} + +?> diff --git a/html/pages/device/overview/mempools.inc.php b/html/pages/device/overview/mempools.inc.php index 0699872416..3d35a8d554 100644 --- a/html/pages/device/overview/mempools.inc.php +++ b/html/pages/device/overview/mempools.inc.php @@ -1,77 +1,76 @@ +if (count($mempools)) +{ + echo('
    -
    -
    -
    - '; - echo ''; - echo " Memory Pools"; - echo ' -
    - - '; +
    +
    +
    +'); + echo(''); + echo(" Memory Pools"); + echo(' +
    +
    +'); - foreach ($mempools as $mempool) { - if ($config['memcached']['enable'] === true) { - $state = $memcache->get('mempool-'.$mempool['mempool_id'].'-state'); - if ($debug) { - print_r($state); - } + foreach ($mempools as $mempool) + { - if (is_array($state)) { - $mempool = array_merge($mempool, $state); - } + if ($config['memcached']['enable'] === TRUE) + { + $state = $memcache->get('mempool-'.$mempool['mempool_id'].'-state'); + if($debug) { print_r($state); } + if(is_array($state)) { $mempool = array_merge($mempool, $state); } + unset($state); + } - unset($state); - } + $percent= round($mempool['mempool_perc'],0); + $text_descr = rewrite_entity_descr($mempool['mempool_descr']); + $total = formatStorage($mempool['mempool_total']); + $used = formatStorage($mempool['mempool_used']); + $free = formatStorage($mempool['mempool_free']); + $background = get_percentage_colours($percent); - $percent = round($mempool['mempool_perc'], 0); - $text_descr = rewrite_entity_descr($mempool['mempool_descr']); - $total = formatStorage($mempool['mempool_total']); - $used = formatStorage($mempool['mempool_used']); - $free = formatStorage($mempool['mempool_free']); - $background = get_percentage_colours($percent); + $graph_array = array(); + $graph_array['height'] = "100"; + $graph_array['width'] = "210"; + $graph_array['to'] = $config['time']['now']; + $graph_array['id'] = $mempool['mempool_id']; + $graph_array['type'] = $graph_type; + $graph_array['from'] = $config['time']['day']; + $graph_array['legend'] = "no"; - $graph_array = array(); - $graph_array['height'] = '100'; - $graph_array['width'] = '210'; - $graph_array['to'] = $config['time']['now']; - $graph_array['id'] = $mempool['mempool_id']; - $graph_array['type'] = $graph_type; - $graph_array['from'] = $config['time']['day']; - $graph_array['legend'] = 'no'; + $link_array = $graph_array; + $link_array['page'] = "graphs"; + unset($link_array['height'], $link_array['width'], $link_array['legend']); + $link = generate_url($link_array); - $link_array = $graph_array; - $link_array['page'] = 'graphs'; - unset($link_array['height'], $link_array['width'], $link_array['legend']); - $link = generate_url($link_array); + $overlib_content = generate_overlib_content($graph_array, $device['hostname'] . " - " . $text_descr); - $overlib_content = generate_overlib_content($graph_array, $device['hostname'].' - '.$text_descr); + $graph_array['width'] = 80; $graph_array['height'] = 20; $graph_array['bg'] = 'ffffff00'; # the 00 at the end makes the area transparent. - $graph_array['width'] = 80; - $graph_array['height'] = 20; - $graph_array['bg'] = 'ffffff00'; - // the 00 at the end makes the area transparent. - $minigraph = generate_graph_tag($graph_array); + $minigraph = generate_graph_tag($graph_array); - echo ' - - - - '; - }//end foreach + echo(" + + + + "); + } - echo '
    '.overlib_link($link, $text_descr, $overlib_content).''.overlib_link($link, $minigraph, $overlib_content).''.overlib_link($link, print_percentage_bar(200, 20, $percent, null, 'ffffff', $background['left'], $percent.'%', 'ffffff', $background['right']), $overlib_content).' -
    ".overlib_link($link, $text_descr, $overlib_content)."".overlib_link($link, $minigraph, $overlib_content)."".overlib_link($link, print_percentage_bar (200, 20, $percent, NULL, "ffffff", $background['left'], $percent . "%", "ffffff", $background['right']), $overlib_content)." +
    + echo('
    -
    '; -}//end if + '); + +} + +?> diff --git a/html/pages/device/overview/ports.inc.php b/html/pages/device/overview/ports.inc.php index 75cf3ca29f..807f8ee4fb 100644 --- a/html/pages/device/overview/ports.inc.php +++ b/html/pages/device/overview/ports.inc.php @@ -1,64 +1,68 @@ '; - echo '
    +if ($ports['total']) +{ + echo('
    '); + echo('
    Overall Traffic
    - '; +
    '); - $graph_array['height'] = '100'; - $graph_array['width'] = '485'; - $graph_array['to'] = $config['time']['now']; - $graph_array['device'] = $device['device_id']; - $graph_array['type'] = 'device_bits'; - $graph_array['from'] = $config['time']['day']; - $graph_array['legend'] = 'no'; - $graph = generate_graph_tag($graph_array); + $graph_array['height'] = "100"; + $graph_array['width'] = "485"; + $graph_array['to'] = $config['time']['now']; + $graph_array['device'] = $device['device_id']; + $graph_array['type'] = "device_bits"; + $graph_array['from'] = $config['time']['day']; + $graph_array['legend'] = "no"; + $graph = generate_graph_tag($graph_array); - $link_array = $graph_array; - $link_array['page'] = 'graphs'; - unset($link_array['height'], $link_array['width']); - $link = generate_url($link_array); + $link_array = $graph_array; + $link_array['page'] = "graphs"; + unset($link_array['height'], $link_array['width']); + $link = generate_url($link_array); - $graph_array['width'] = '210'; - $overlib_content = generate_overlib_content($graph_array, $device['hostname'].' - Device Traffic'); + $graph_array['width'] = "210"; + $overlib_content = generate_overlib_content($graph_array, $device['hostname'] . " - Device Traffic"); - echo ' - - '; + echo(' + + '); - echo ' + echo(' - - - - - '; + + + + + '); - echo ' - + '; - echo ''; - echo '
    '; - echo overlib_link($link, $graph, $overlib_content, null); - echo '
    '); + echo(overlib_link($link, $graph, $overlib_content, NULL)); + echo('
    '.$ports['total'].' '.$ports['up'].' '.$ports['down'].' '.$ports['disabled'].'
    ' . $ports['total'] . ' ' . $ports['up'] . ' ' . $ports['down'] . ' ' . $ports['disabled'] . '
    '; + echo('
    '); - $ifsep = ''; + $ifsep = ""; - foreach (dbFetchRows("SELECT * FROM `ports` WHERE device_id = ? AND `deleted` != '1'", array($device['device_id'])) as $data) { - $data = ifNameDescr($data); - $data = array_merge($data, $device); - echo "$ifsep".generate_port_link($data, makeshortif(strtolower($data['label']))); - $ifsep = ', '; - } + foreach (dbFetchRows("SELECT * FROM `ports` WHERE device_id = ? AND `deleted` != '1'", array($device['device_id'])) as $data) + { + $data = ifNameDescr($data); + $data = array_merge($data, $device); + echo("$ifsep" . generate_port_link($data, makeshortif(strtolower($data['label'])))); + $ifsep = ", "; + } - unset($ifsep); - echo '
    '; - echo '
    '; - echo '
    '; - echo '
    '; - echo '
    '; -}//end if + unset($ifsep); + echo(" "); + echo(""); + echo(""); + echo("
    "); + echo(""); + echo(""); + echo(""); +} + +?> diff --git a/html/pages/device/overview/processors.inc.php b/html/pages/device/overview/processors.inc.php index 8b4d3f2912..3394e263ca 100644 --- a/html/pages/device/overview/processors.inc.php +++ b/html/pages/device/overview/processors.inc.php @@ -1,63 +1,66 @@ +if (count($processors)) +{ + echo('
    -'; - echo ''; - echo " Processors"; - echo '
    - '; +'); + echo(''); + echo(" Processors"); + echo(' +
    '); - foreach ($processors as $proc) { - $text_descr = rewrite_entity_descr($proc['processor_descr']); + foreach ($processors as $proc) + { + $text_descr = rewrite_entity_descr($proc['processor_descr']); - // disable short hrDeviceDescr. need to make this prettier. - // $text_descr = short_hrDeviceDescr($proc['processor_descr']); - $percent = $proc['processor_usage']; - $background = get_percentage_colours($percent); - $graph_colour = str_replace('#', '', $row_colour); + # disable short hrDeviceDescr. need to make this prettier. + #$text_descr = short_hrDeviceDescr($proc['processor_descr']); + $percent = $proc['processor_usage']; + $background = get_percentage_colours($percent); + $graph_colour = str_replace("#", "", $row_colour); - $graph_array = array(); - $graph_array['height'] = '100'; - $graph_array['width'] = '210'; - $graph_array['to'] = $config['time']['now']; - $graph_array['id'] = $proc['processor_id']; - $graph_array['type'] = $graph_type; - $graph_array['from'] = $config['time']['day']; - $graph_array['legend'] = 'no'; + $graph_array = array(); + $graph_array['height'] = "100"; + $graph_array['width'] = "210"; + $graph_array['to'] = $config['time']['now']; + $graph_array['id'] = $proc['processor_id']; + $graph_array['type'] = $graph_type; + $graph_array['from'] = $config['time']['day']; + $graph_array['legend'] = "no"; - $link_array = $graph_array; - $link_array['page'] = 'graphs'; - unset($link_array['height'], $link_array['width'], $link_array['legend']); - $link = generate_url($link_array); + $link_array = $graph_array; + $link_array['page'] = "graphs"; + unset($link_array['height'], $link_array['width'], $link_array['legend']); + $link = generate_url($link_array); - $overlib_content = generate_overlib_content($graph_array, $device['hostname'].' - '.$text_descr); + $overlib_content = generate_overlib_content($graph_array, $device['hostname'] . " - " . $text_descr); - $graph_array['width'] = 80; - $graph_array['height'] = 20; - $graph_array['bg'] = 'ffffff00'; - // the 00 at the end makes the area transparent. - $minigraph = generate_graph_tag($graph_array); + $graph_array['width'] = 80; $graph_array['height'] = 20; $graph_array['bg'] = 'ffffff00'; # the 00 at the end makes the area transparent. - echo ' - - - + + + - '; - }//end foreach + "); + } - echo '
    '.overlib_link($link, $text_descr, $overlib_content).''.overlib_link($link, $minigraph, $overlib_content).''.overlib_link($link, print_percentage_bar(200, 20, $percent, null, 'ffffff', $background['left'], $percent.'%', 'ffffff', $background['right']), $overlib_content).' + $minigraph = generate_graph_tag($graph_array); + + echo("
    ".overlib_link($link, $text_descr, $overlib_content)."".overlib_link($link, $minigraph, $overlib_content)."".overlib_link($link, print_percentage_bar (200, 20, $percent, NULL, "ffffff", $background['left'], $percent . "%", "ffffff", $background['right']), $overlib_content)."
    + echo('
    -
    '; -}//end if + '); + +} + +?> diff --git a/html/pages/device/overview/sensors/charge.inc.php b/html/pages/device/overview/sensors/charge.inc.php index b0df00968a..bf40977499 100644 --- a/html/pages/device/overview/sensors/charge.inc.php +++ b/html/pages/device/overview/sensors/charge.inc.php @@ -1,8 +1,10 @@ diff --git a/html/pages/device/overview/sensors/load.inc.php b/html/pages/device/overview/sensors/load.inc.php index 089f93dffb..989a305b9b 100644 --- a/html/pages/device/overview/sensors/load.inc.php +++ b/html/pages/device/overview/sensors/load.inc.php @@ -1,8 +1,8 @@ '; - echo '
    +if ($services['total']) +{ +echo('
    '); + echo('
    -
    '; - echo " Services"; - echo '
    - '; +
    '); + echo(" Services"); + echo('
    +
    '); - echo " + echo(" @@ -18,32 +19,22 @@ echo '
    ';
    -
    $services[total] $services[up] $services[disabled]
    "; +"); - foreach (dbFetchRows('SELECT * FROM services WHERE device_id = ? ORDER BY service_type', array($device['device_id'])) as $data) { - if ($data['service_status'] == '0' && $data['service_ignore'] == '1') { - $status = 'grey'; - } + foreach (dbFetchRows("SELECT * FROM services WHERE device_id = ? ORDER BY service_type", array($device['device_id'])) as $data) + { + if ($data['service_status'] == "0" && $data['service_ignore'] == "1") { $status = "grey"; } + if ($data['service_status'] == "1" && $data['service_ignore'] == "1") { $status = "green"; } + if ($data['service_status'] == "0" && $data['service_ignore'] == "0") { $status = "red"; } + if ($data['service_status'] == "1" && $data['service_ignore'] == "0") { $status = "blue"; } + echo("$break" . strtolower($data['service_type']) . ""); + $break = ", "; + } + echo('
    '); + echo("
    "); + echo("
    "); + echo("
    "); + echo("
    "); +} - if ($data['service_status'] == '1' && $data['service_ignore'] == '1') { - $status = 'green'; - } - - if ($data['service_status'] == '0' && $data['service_ignore'] == '0') { - $status = 'red'; - } - - if ($data['service_status'] == '1' && $data['service_ignore'] == '0') { - $status = 'blue'; - } - - echo "$break".strtolower($data['service_type']).''; - $break = ', '; - } - - echo ''; - echo '
    '; - echo ''; - echo ''; - echo ''; -}//end if +?> diff --git a/html/pages/device/overview/storage.inc.php b/html/pages/device/overview/storage.inc.php index e81b1b5b5d..01c02edb4e 100644 --- a/html/pages/device/overview/storage.inc.php +++ b/html/pages/device/overview/storage.inc.php @@ -1,86 +1,91 @@ +if (count($drives)) +{ + echo('
    -
    '; - echo ''; - echo " Storage"; - echo '
    - '; +
    '); + echo(''); + echo(" Storage"); + echo('
    +
    '); - foreach ($drives as $drive) { - $skipdrive = 0; + foreach ($drives as $drive) + { + $skipdrive = 0; - if ($device['os'] == 'junos') { - foreach ($config['ignore_junos_os_drives'] as $jdrive) { - if (preg_match($jdrive, $drive['storage_descr'])) { - $skipdrive = 1; - } - } - - $drive['storage_descr'] = preg_replace('/.*mounted on: (.*)/', '\\1', $drive['storage_descr']); + if ($device["os"] == "junos") + { + foreach ($config['ignore_junos_os_drives'] as $jdrive) + { + if (preg_match($jdrive, $drive["storage_descr"])) + { + $skipdrive = 1; } + } + $drive["storage_descr"] = preg_replace("/.*mounted on: (.*)/", "\\1", $drive["storage_descr"]); + } - if ($device['os'] == 'freebsd') { - foreach ($config['ignore_bsd_os_drives'] as $jdrive) { - if (preg_match($jdrive, $drive['storage_descr'])) { - $skipdrive = 1; - } - } + if ($device['os'] == "freebsd") + { + foreach ($config['ignore_bsd_os_drives'] as $jdrive) + { + if (preg_match($jdrive, $drive["storage_descr"])) + { + $skipdrive = 1; } + } + } - if ($skipdrive) { - continue; - } + if ($skipdrive) { continue; } + $percent = round($drive['storage_perc'], 0); + $total = formatStorage($drive['storage_size']); + $free = formatStorage($drive['storage_free']); + $used = formatStorage($drive['storage_used']); + $background = get_percentage_colours($percent); - $percent = round($drive['storage_perc'], 0); - $total = formatStorage($drive['storage_size']); - $free = formatStorage($drive['storage_free']); - $used = formatStorage($drive['storage_used']); - $background = get_percentage_colours($percent); + $graph_array = array(); + $graph_array['height'] = "100"; + $graph_array['width'] = "210"; + $graph_array['to'] = $config['time']['now']; + $graph_array['id'] = $drive['storage_id']; + $graph_array['type'] = $graph_type; + $graph_array['from'] = $config['time']['day']; + $graph_array['legend'] = "no"; - $graph_array = array(); - $graph_array['height'] = '100'; - $graph_array['width'] = '210'; - $graph_array['to'] = $config['time']['now']; - $graph_array['id'] = $drive['storage_id']; - $graph_array['type'] = $graph_type; - $graph_array['from'] = $config['time']['day']; - $graph_array['legend'] = 'no'; + $link_array = $graph_array; + $link_array['page'] = "graphs"; + unset($link_array['height'], $link_array['width'], $link_array['legend']); + $link = generate_url($link_array); - $link_array = $graph_array; - $link_array['page'] = 'graphs'; - unset($link_array['height'], $link_array['width'], $link_array['legend']); - $link = generate_url($link_array); + $overlib_content = generate_overlib_content($graph_array, $device['hostname'] . " - " . $drive['storage_descr']); - $overlib_content = generate_overlib_content($graph_array, $device['hostname'].' - '.$drive['storage_descr']); + $graph_array['width'] = 80; $graph_array['height'] = 20; $graph_array['bg'] = 'ffffff00'; # the 00 at the end makes the area transparent. - $graph_array['width'] = 80; - $graph_array['height'] = 20; - $graph_array['bg'] = 'ffffff00'; - // the 00 at the end makes the area transparent. - $minigraph = generate_graph_tag($graph_array); + $minigraph = generate_graph_tag($graph_array); - echo ' - - - + + + - '; - }//end foreach + "); + } - echo '
    '.overlib_link($link, $drive['storage_descr'], $overlib_content).''.overlib_link($link, $minigraph, $overlib_content).''.overlib_link($link, print_percentage_bar(200, 20, $percent, null, 'ffffff', $background['left'], $percent.'%', 'ffffff', $background['right']), $overlib_content).' + echo("
    ".overlib_link($link, $drive['storage_descr'], $overlib_content)."".overlib_link($link, $minigraph, $overlib_content)."".overlib_link($link, print_percentage_bar (200, 20, $percent, NULL, "ffffff", $background['left'], $percent . "%", "ffffff", $background['right']), $overlib_content)."
    + echo('
    -
    '; -}//end if + '); -unset($drive_rows); +} + +unset ($drive_rows); + +?> diff --git a/html/pages/device/overview/syslog.inc.php b/html/pages/device/overview/syslog.inc.php index bcfb6d2c52..1d26fbb2a7 100644 --- a/html/pages/device/overview/syslog.inc.php +++ b/html/pages/device/overview/syslog.inc.php @@ -1,24 +1,25 @@ '; - echo '
    +if ($config['enable_syslog']) +{ + $syslog = dbFetchRows("SELECT *, DATE_FORMAT(timestamp, '".$config['dateformat']['mysql']['compact']."') AS date from syslog WHERE device_id = ? ORDER BY timestamp DESC LIMIT 20", array($device['device_id'])); + if (count($syslog)) + { +echo('
    '); + echo('
    -
    '; - echo ' Recent Syslog'; - echo '
    - '; - foreach ($syslog as $entry) { - include 'includes/print-syslog.inc.php'; - } - - echo '
    '; - echo '
    '; - echo '
    '; - echo '
    '; - echo '
    '; - } +
    '); + echo(' Recent Syslog'); +echo('
    + '); + foreach ($syslog as $entry) { include("includes/print-syslog.inc.php"); } + echo("
    "); + echo("
    "); + echo(""); + echo(""); + echo(""); + } } + +?> diff --git a/html/pages/device/overview/toner.inc.php b/html/pages/device/overview/toner.inc.php index 7c789573c5..347a636195 100644 --- a/html/pages/device/overview/toner.inc.php +++ b/html/pages/device/overview/toner.inc.php @@ -1,62 +1,64 @@ +if (count($toners)) +{ + echo('
    -
    '; - echo ''; - echo " Toner"; - echo '
    - '; +
    '); + echo(''); + echo(" Toner"); + echo('
    +
    '); - foreach ($toners as $toner) { - $percent = round($toner['toner_current'], 0); - $total = formatStorage($toner['toner_size']); - $free = formatStorage($toner['toner_free']); - $used = formatStorage($toner['toner_used']); + foreach ($toners as $toner) + { + $percent = round($toner['toner_current'], 0); + $total = formatStorage($toner['toner_size']); + $free = formatStorage($toner['toner_free']); + $used = formatStorage($toner['toner_used']); - $background = toner2colour($toner['toner_descr'], $percent); + $background = toner2colour($toner['toner_descr'], $percent); - $graph_array = array(); - $graph_array['height'] = '100'; - $graph_array['width'] = '210'; - $graph_array['to'] = $config['time']['now']; - $graph_array['id'] = $toner['toner_id']; - $graph_array['type'] = $graph_type; - $graph_array['from'] = $config['time']['day']; - $graph_array['legend'] = 'no'; + $graph_array = array(); + $graph_array['height'] = "100"; + $graph_array['width'] = "210"; + $graph_array['to'] = $config['time']['now']; + $graph_array['id'] = $toner['toner_id']; + $graph_array['type'] = $graph_type; + $graph_array['from'] = $config['time']['day']; + $graph_array['legend'] = "no"; - $link_array = $graph_array; - $link_array['page'] = 'graphs'; - unset($link_array['height'], $link_array['width'], $link_array['legend']); - $link = generate_url($link_array); + $link_array = $graph_array; + $link_array['page'] = "graphs"; + unset($link_array['height'], $link_array['width'], $link_array['legend']); + $link = generate_url($link_array); - $overlib_content = generate_overlib_content($graph_array, $device['hostname'].' - '.$toner['toner_descr']); + $overlib_content = generate_overlib_content($graph_array, $device['hostname'] . " - " . $toner['toner_descr']); - $graph_array['width'] = 80; - $graph_array['height'] = 20; - $graph_array['bg'] = 'ffffff00'; - // the 00 at the end makes the area transparent. - $minigraph = generate_graph_tag($graph_array); + $graph_array['width'] = 80; $graph_array['height'] = 20; $graph_array['bg'] = 'ffffff00'; # the 00 at the end makes the area transparent. - echo ' - - - + + + - '; - }//end foreach + "); + } - echo '
    '.overlib_link($link, $toner['toner_descr'], $overlib_content).''.overlib_link($link, $minigraph, $overlib_content).''.overlib_link($link, print_percentage_bar(200, 20, $percent, null, 'ffffff', $background['left'], $percent.'%', 'ffffff', $background['right']), $overlib_content).' + $minigraph = generate_graph_tag($graph_array); + + echo("
    ".overlib_link($link, $toner['toner_descr'], $overlib_content)."".overlib_link($link, $minigraph, $overlib_content)."".overlib_link($link, print_percentage_bar (200, 20, $percent, NULL, "ffffff", $background['left'], $percent . "%", "ffffff", $background['right']), $overlib_content)."
    '; - echo '
    '; - echo '
    '; - echo '
    '; - echo ''; -}//end if + echo(""); + echo(""); + echo(""); + echo(""); + echo(""); +} -unset($toner_rows); +unset ($toner_rows); + +?> diff --git a/html/pages/device/performance.inc.php b/html/pages/device/performance.inc.php index da2056c54b..8686bf8034 100644 --- a/html/pages/device/performance.inc.php +++ b/html/pages/device/performance.inc.php @@ -21,9 +21,7 @@ */ -if(!isset($vars['section'])) { - $vars['section'] = "performance"; -} +if(!isset($vars['section'])) { $vars['section'] = "performance"; } if (empty($vars['dtpickerfrom'])) { $vars['dtpickerfrom'] = date($config['dateformat']['byminute'], time() - 3600 * 24 * 2); @@ -59,8 +57,7 @@ if (empty($vars['dtpickerto'])) { if (is_admin() === true || is_read() === true) { $query = "SELECT DATE_FORMAT(timestamp, '".$config['alert_graph_date_format']."') Date, xmt,rcv,loss,min,max,avg FROM `device_perf` WHERE `device_id` = ? AND `timestamp` >= ? AND `timestamp` <= ?"; $param = array($device['device_id'], $vars['dtpickerfrom'], $vars['dtpickerto']); -} -else { +} else { $query = "SELECT DATE_FORMAT(timestamp, '".$config['alert_graph_date_format']."') Date, xmt,rcv,loss,min,max,avg FROM `device_perf`,`devices_perms` WHERE `device_id` = ? AND alert_log.device_id = devices_perms.device_id AND devices_perms.user_id = ? AND `timestamp` >= ? AND `timestamp` <= ?"; $param = array($device['device_id'], $_SESSION['user_id'], $vars['dtpickerfrom'], $vars['dtpickerto']); } @@ -84,7 +81,7 @@ foreach(dbFetchRows($query, $param) as $return_value) { $avg = $return_value['avg']; if ($max > $max_val) { - $max_val = $max; + $max_val = $max; } $data[] = array('x' => $date,'y' => $loss,'group' => 0); @@ -189,3 +186,4 @@ echo $milisec_diff; var graph2d = new vis.Graph2d(container, items, groups, options); + diff --git a/html/pages/device/port.inc.php b/html/pages/device/port.inc.php index a70d40a763..ecb25cfd28 100644 --- a/html/pages/device/port.inc.php +++ b/html/pages/device/port.inc.php @@ -1,22 +1,15 @@ get('port-'.$port['port_id'].'-state'); - if ($debug) { - print_r($state); - } - - if (is_array($state)) { - $port = array_merge($port, $state); - } - - unset($state); +if ($config['memcached']['enable'] === TRUE) +{ + $state = $memcache->get('port-'.$port['port_id'].'-state'); + if($debug) { print_r($state); } + if(is_array($state)) { $port = array_merge($port, $state); } + unset($state); } $port_details = 1; @@ -24,218 +17,148 @@ $port_details = 1; $hostname = $device['hostname']; $hostid = $device['port_id']; $ifname = $port['ifDescr']; -$ifIndex = $port['ifIndex']; -$speed = humanspeed($port['ifSpeed']); +$ifIndex = $port['ifIndex']; +$speed = humanspeed($port['ifSpeed']); $ifalias = $port['name']; -if ($port['ifPhysAddress']) { - $mac = "$port[ifPhysAddress]"; -} +if ($port['ifPhysAddress']) { $mac = "$port[ifPhysAddress]"; } -$color = 'black'; -if ($port['ifAdminStatus'] == 'down') { - $status = "Disabled"; -} +$color = "black"; +if ($port['ifAdminStatus'] == "down") { $status = "Disabled"; } +if ($port['ifAdminStatus'] == "up" && $port['ifOperStatus'] == "down") { $status = "Enabled / Disconnected"; } +if ($port['ifAdminStatus'] == "up" && $port['ifOperStatus'] == "up") { $status = "Enabled / Connected"; } -if ($port['ifAdminStatus'] == 'up' && $port['ifOperStatus'] == 'down') { - $status = "Enabled / Disconnected"; -} - -if ($port['ifAdminStatus'] == 'up' && $port['ifOperStatus'] == 'up') { - $status = "Enabled / Connected"; -} - -$i = 1; +$i = 1; $inf = fixifName($ifname); -$bg = '#ffffff'; +$bg="#ffffff"; $show_all = 1; -echo "
    "; +echo("
    "); -require 'includes/print-interface.inc.php'; +include("includes/print-interface.inc.php"); -echo '
    '; +echo(""); -$pos = strpos(strtolower($ifname), 'vlan'); -if ($pos !== false) { - $broke = yes; +$pos = strpos(strtolower($ifname), "vlan"); +if ($pos !== false ) +{ + $broke = yes; } -$pos = strpos(strtolower($ifname), 'loopback'); +$pos = strpos(strtolower($ifname), "loopback"); -if ($pos !== false) { - $broke = yes; +if ($pos !== false ) +{ + $broke = yes; } -echo "
    "; +echo("
    "); print_optionbar_start(); -$link_array = array( - 'page' => 'device', - 'device' => $device['device_id'], - 'tab' => 'port', - 'port' => $port['port_id'], -); +$link_array = array('page' => 'device', + 'device' => $device['device_id'], + 'tab' => 'port', + 'port' => $port['port_id']); $menu_options['graphs'] = 'Graphs'; -$menu_options['realtime'] = 'Real time'; -// FIXME CONDITIONAL -$menu_options['arp'] = 'ARP Table'; -$menu_options['events'] = 'Eventlog'; +$menu_options['realtime'] = 'Real time'; // FIXME CONDITIONAL +$menu_options['arp'] = 'ARP Table'; +$menu_options['events'] = 'Eventlog'; -if (dbFetchCell("SELECT COUNT(*) FROM `ports_adsl` WHERE `port_id` = '".$port['port_id']."'")) { - $menu_options['adsl'] = 'ADSL'; +if (dbFetchCell("SELECT COUNT(*) FROM `ports_adsl` WHERE `port_id` = '".$port['port_id']."'") ) +{ $menu_options['adsl'] = 'ADSL'; } + +if (dbFetchCell("SELECT COUNT(*) FROM `ports` WHERE `pagpGroupIfIndex` = '".$port['ifIndex']."' and `device_id` = '".$device['device_id']."'") ) +{ $menu_options['pagp'] = 'PAgP'; } + +if (dbFetchCell("SELECT COUNT(*) FROM `ports_vlans` WHERE `port_id` = '".$port['port_id']."' and `device_id` = '".$device['device_id']."'") ) +{ $menu_options['vlans'] = 'VLANs'; } + +$sep = ""; +foreach ($menu_options as $option => $text) +{ + echo($sep); + if ($vars['view'] == $option) { echo(""); } + echo(generate_link($text,$link_array,array('view'=>$option))); + if ($vars['view'] == $option) { echo(""); } + $sep = " | "; } - -if (dbFetchCell("SELECT COUNT(*) FROM `ports` WHERE `pagpGroupIfIndex` = '".$port['ifIndex']."' and `device_id` = '".$device['device_id']."'")) { - $menu_options['pagp'] = 'PAgP'; -} - -if (dbFetchCell("SELECT COUNT(*) FROM `ports_vlans` WHERE `port_id` = '".$port['port_id']."' and `device_id` = '".$device['device_id']."'")) { - $menu_options['vlans'] = 'VLANs'; -} - -$sep = ''; -foreach ($menu_options as $option => $text) { - echo $sep; - if ($vars['view'] == $option) { - echo ""; - } - - echo generate_link($text, $link_array, array('view' => $option)); - if ($vars['view'] == $option) { - echo ''; - } - - $sep = ' | '; -} - unset($sep); -if (dbFetchCell("SELECT count(*) FROM mac_accounting WHERE port_id = '".$port['port_id']."'") > '0') { - echo generate_link($descr, $link_array, array('view' => 'macaccounting', 'graph' => $type)); +if (dbFetchCell("SELECT count(*) FROM mac_accounting WHERE port_id = '".$port['port_id']."'") > "0" ) +{ - echo ' | Mac Accounting : '; - if ($vars['view'] == 'macaccounting' && $vars['graph'] == 'bits' && $vars['subview'] == 'graphs') { - echo ""; - } + echo(generate_link($descr,$link_array,array('view'=>'macaccounting','graph'=>$type))); - echo generate_link('Bits', $link_array, array('view' => 'macaccounting', 'subview' => 'graphs', 'graph' => 'bits')); - if ($vars['view'] == 'macaccounting' && $vars['graph'] == 'bits' && $vars['subview'] == 'graphs') { - echo ''; - } + echo(" | Mac Accounting : "); + if ($vars['view'] == "macaccounting" && $vars['graph'] == "bits" && $vars['subview'] == "graphs") { echo(""); } + echo(generate_link("Bits",$link_array,array('view' => 'macaccounting', 'subview' => 'graphs', 'graph'=>'bits'))); + if ($vars['view'] == "macaccounting" && $vars['graph'] == "bits" && $vars['subview'] == "graphs") { echo(""); } - echo '('; - if ($vars['view'] == 'macaccounting' && $vars['graph'] == 'bits' && $vars['subview'] == 'minigraphs') { - echo ""; - } + echo("("); + if ($vars['view'] == "macaccounting" && $vars['graph'] == "bits" && $vars['subview'] == "minigraphs") { echo(""); } + echo(generate_link("Mini",$link_array,array('view' => 'macaccounting', 'subview' => 'minigraphs', 'graph'=>'bits'))); + if ($vars['view'] == "macaccounting" && $vars['graph'] == "bits" && $vars['subview'] == "minigraphs") { echo(""); } + echo('|'); - echo generate_link('Mini', $link_array, array('view' => 'macaccounting', 'subview' => 'minigraphs', 'graph' => 'bits')); - if ($vars['view'] == 'macaccounting' && $vars['graph'] == 'bits' && $vars['subview'] == 'minigraphs') { - echo ''; - } + if ($vars['view'] == "macaccounting" && $vars['graph'] == "bits" && $vars['subview'] == "top10") { echo(""); } + echo(generate_link("Top10",$link_array,array('view' => 'macaccounting', 'subview' => 'top10', 'graph'=>'bits'))); + if ($vars['view'] == "macaccounting" && $vars['graph'] == "bits" && $vars['subview'] == "top10") { echo(""); } + echo(") | "); - echo '|'; + if ($vars['view'] == "macaccounting" && $vars['graph'] == "pkts" && $vars['subview'] == "graphs") { echo(""); } + echo(generate_link("Packets",$link_array,array('view' => 'macaccounting', 'subview' => 'graphs', 'graph'=>'pkts'))); + if ($vars['view'] == "macaccounting" && $vars['graph'] == "pkts" && $vars['subview'] == "graphs") { echo(""); } + echo("("); + if ($vars['view'] == "macaccounting" && $vars['graph'] == "pkts" && $vars['subview'] == "minigraphs") { echo(""); } + echo(generate_link("Mini",$link_array,array('view' => 'macaccounting', 'subview' => 'minigraphs', 'graph'=>'pkts'))); + if ($vars['view'] == "macaccounting" && $vars['graph'] == "pkts" && $vars['subview'] == "minigraphs") { echo(""); } + echo('|'); + if ($vars['view'] == "macaccounting" && $vars['graph'] == "pkts" && $vars['subview'] == "top10") { echo(""); } + echo(generate_link("Top10",$link_array,array('view' => 'macaccounting', 'subview' => 'top10', 'graph'=>'pkts'))); + if ($vars['view'] == "macaccounting" && $vars['graph'] == "pkts" && $vars['subview'] == "top10") { echo(""); } + echo(")"); +} - if ($vars['view'] == 'macaccounting' && $vars['graph'] == 'bits' && $vars['subview'] == 'top10') { - echo ""; - } +if (dbFetchCell("SELECT COUNT(*) FROM juniAtmVp WHERE port_id = '".$port['port_id']."'") > "0" ) +{ - echo generate_link('Top10', $link_array, array('view' => 'macaccounting', 'subview' => 'top10', 'graph' => 'bits')); - if ($vars['view'] == 'macaccounting' && $vars['graph'] == 'bits' && $vars['subview'] == 'top10') { - echo ''; - } + // FIXME ATM VPs + // FIXME URLs BROKEN - echo ') | '; + echo(" | ATM VPs : "); + if ($vars['view'] == "junose-atm-vp" && $vars['graph'] == "bits") { echo(""); } + echo("Bits"); + if ($vars['view'] == "junose-atm-vp" && $vars['graph'] == "bits") { echo(""); } + echo(" | "); + if ($vars['view'] == "junose-atm-vp" && $vars['graph'] == "packets") { echo(""); } + echo("Packets"); + if ($vars['view'] == "junose-atm-vp" && $vars['graph'] == "bits") { echo(""); } + echo(" | "); + if ($vars['view'] == "junose-atm-vp" && $vars['graph'] == "cells") { echo(""); } + echo("Cells"); + if ($vars['view'] == "junose-atm-vp" && $vars['graph'] == "bits") { echo(""); } + echo(" | "); + if ($vars['view'] == "junose-atm-vp" && $vars['graph'] == "errors") { echo(""); } + echo("Errors"); + if ($vars['view'] == "junose-atm-vp" && $vars['graph'] == "bits") { echo(""); } +} - if ($vars['view'] == 'macaccounting' && $vars['graph'] == 'pkts' && $vars['subview'] == 'graphs') { - echo ""; - } - - echo generate_link('Packets', $link_array, array('view' => 'macaccounting', 'subview' => 'graphs', 'graph' => 'pkts')); - if ($vars['view'] == 'macaccounting' && $vars['graph'] == 'pkts' && $vars['subview'] == 'graphs') { - echo ''; - } - - echo '('; - if ($vars['view'] == 'macaccounting' && $vars['graph'] == 'pkts' && $vars['subview'] == 'minigraphs') { - echo ""; - } - - echo generate_link('Mini', $link_array, array('view' => 'macaccounting', 'subview' => 'minigraphs', 'graph' => 'pkts')); - if ($vars['view'] == 'macaccounting' && $vars['graph'] == 'pkts' && $vars['subview'] == 'minigraphs') { - echo ''; - } - - echo '|'; - if ($vars['view'] == 'macaccounting' && $vars['graph'] == 'pkts' && $vars['subview'] == 'top10') { - echo ""; - } - - echo generate_link('Top10', $link_array, array('view' => 'macaccounting', 'subview' => 'top10', 'graph' => 'pkts')); - if ($vars['view'] == 'macaccounting' && $vars['graph'] == 'pkts' && $vars['subview'] == 'top10') { - echo ''; - } - - echo ')'; -}//end if - -if (dbFetchCell("SELECT COUNT(*) FROM juniAtmVp WHERE port_id = '".$port['port_id']."'") > '0') { - // FIXME ATM VPs - // FIXME URLs BROKEN - echo ' | ATM VPs : '; - if ($vars['view'] == 'junose-atm-vp' && $vars['graph'] == 'bits') { - echo ""; - } - - echo "Bits"; - if ($vars['view'] == 'junose-atm-vp' && $vars['graph'] == 'bits') { - echo ''; - } - - echo ' | '; - if ($vars['view'] == 'junose-atm-vp' && $vars['graph'] == 'packets') { - echo ""; - } - - echo "Packets"; - if ($vars['view'] == 'junose-atm-vp' && $vars['graph'] == 'bits') { - echo ''; - } - - echo ' | '; - if ($vars['view'] == 'junose-atm-vp' && $vars['graph'] == 'cells') { - echo ""; - } - - echo "Cells"; - if ($vars['view'] == 'junose-atm-vp' && $vars['graph'] == 'bits') { - echo ''; - } - - echo ' | '; - if ($vars['view'] == 'junose-atm-vp' && $vars['graph'] == 'errors') { - echo ""; - } - - echo "Errors"; - if ($vars['view'] == 'junose-atm-vp' && $vars['graph'] == 'bits') { - echo ''; - } -}//end if - -if ($_SESSION['userlevel'] >= '10') { - echo " Create Bill"; +if ($_SESSION['userlevel'] >= '10') +{ + echo(" Create Bill"); } print_optionbar_end(); -echo "
    "; +echo("
    "); -require 'pages/device/port/'.mres($vars['view']).'.inc.php'; +include("pages/device/port/".mres($vars['view']).".inc.php"); -echo '
    '; +echo("
    "); + +?> diff --git a/html/pages/device/port/events.inc.php b/html/pages/device/port/events.inc.php index 5a113fafe6..6de49ef262 100644 --- a/html/pages/device/port/events.inc.php +++ b/html/pages/device/port/events.inc.php @@ -1,12 +1,15 @@ '; +echo(''); -foreach ($entries as $entry) { - include 'includes/print-event.inc.php'; +foreach ($entries as $entry) +{ + include("includes/print-event.inc.php"); } -echo '
    '; +echo(''); -$pagetitle[] = 'Events'; +$pagetitle[] = "Events"; + +?> diff --git a/html/pages/device/port/pagp.inc.php b/html/pages/device/port/pagp.inc.php index 7a8e41ff50..e64437e2c2 100644 --- a/html/pages/device/port/pagp.inc.php +++ b/html/pages/device/port/pagp.inc.php @@ -3,32 +3,34 @@ global $config; // FIXME functions! -if (!$graph_type) { - $graph_type = 'pagp_bits'; + +if (!$graph_type) { $graph_type = "pagp_bits"; } + +$daily_traffic = "graph.php?port=" . $port['port_id'] . "&type=$graph_type&from=".$config['time']['day']."&to=".$config['time']['now']."&width=215&height=100"; +$daily_url = "graph.php?port=" . $port['port_id'] . "&type=$graph_type&from=".$config['time']['day']."&to=".$config['time']['now']."&width=500&height=150"; + +$weekly_traffic = "graph.php?port=" . $port['port_id'] . "&type=$graph_type&from=".$config['time']['week']."&to=".$config['time']['now']."&width=215&height=100"; +$weekly_url = "graph.php?port=" . $port['port_id'] . "&type=$graph_type&from=".$config['time']['week']."&to=".$config['time']['now']."&width=500&height=150"; + +$monthly_traffic = "graph.php?port=" . $port['port_id'] . "&type=$graph_type&from=".$config['time']['month']."&to=".$config['time']['now']."&width=215&height=100"; +$monthly_url = "graph.php?port=" . $port['port_id'] . "&type=$graph_type&from=".$config['time']['month']."&to=".$config['time']['now']."&width=500&height=150"; + +$yearly_traffic = "graph.php?port=" . $port['port_id'] . "&type=$graph_type&from=".$config['time']['year']."&to=".$config['time']['now']."&width=215&height=100"; +$yearly_url = "graph.php?port=" . $port['port_id'] . "&type=$graph_type&from=".$config['time']['year']."&to=".$config['time']['now']."&width=500&height=150"; + +echo("', LEFT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\"> + "); +echo("', LEFT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\"> + "); +echo("', LEFT".$config['overlib_defaults'].", WIDTH, 350);\" onmouseout=\"return nd();\"> + "); +echo("', LEFT".$config['overlib_defaults'].", WIDTH, 350);\" onmouseout=\"return nd();\"> + "); + +foreach (dbFetchRows("SELECT * FROM `ports` WHERE `pagpGroupIfIndex` = ? and `device_id` = ?", array($port['ifIndex'], $device['device_id'])) as $member) +{ + echo("$br " . generate_port_link($member) . " (PAgP)"); + $br = "
    "; } -$daily_traffic = 'graph.php?port='.$port['port_id']."&type=$graph_type&from=".$config['time']['day'].'&to='.$config['time']['now'].'&width=215&height=100'; -$daily_url = 'graph.php?port='.$port['port_id']."&type=$graph_type&from=".$config['time']['day'].'&to='.$config['time']['now'].'&width=500&height=150'; - -$weekly_traffic = 'graph.php?port='.$port['port_id']."&type=$graph_type&from=".$config['time']['week'].'&to='.$config['time']['now'].'&width=215&height=100'; -$weekly_url = 'graph.php?port='.$port['port_id']."&type=$graph_type&from=".$config['time']['week'].'&to='.$config['time']['now'].'&width=500&height=150'; - -$monthly_traffic = 'graph.php?port='.$port['port_id']."&type=$graph_type&from=".$config['time']['month'].'&to='.$config['time']['now'].'&width=215&height=100'; -$monthly_url = 'graph.php?port='.$port['port_id']."&type=$graph_type&from=".$config['time']['month'].'&to='.$config['time']['now'].'&width=500&height=150'; - -$yearly_traffic = 'graph.php?port='.$port['port_id']."&type=$graph_type&from=".$config['time']['year'].'&to='.$config['time']['now'].'&width=215&height=100'; -$yearly_url = 'graph.php?port='.$port['port_id']."&type=$graph_type&from=".$config['time']['year'].'&to='.$config['time']['now'].'&width=500&height=150'; - -echo "', LEFT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\"> - "; -echo "', LEFT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\"> - "; -echo "', LEFT".$config['overlib_defaults'].", WIDTH, 350);\" onmouseout=\"return nd();\"> - "; -echo "', LEFT".$config['overlib_defaults'].", WIDTH, 350);\" onmouseout=\"return nd();\"> - "; - -foreach (dbFetchRows('SELECT * FROM `ports` WHERE `pagpGroupIfIndex` = ? and `device_id` = ?', array($port['ifIndex'], $device['device_id'])) as $member) { - echo "$br ".generate_port_link($member).' (PAgP)'; - $br = '
    '; -} +?> diff --git a/html/pages/device/ports.inc.php b/html/pages/device/ports.inc.php index dc941e246f..b254b376da 100644 --- a/html/pages/device/ports.inc.php +++ b/html/pages/device/ports.inc.php @@ -1,23 +1,15 @@ 'device', - 'device' => $device['device_id'], - 'tab' => 'ports', -); +$link_array = array('page' => 'device', + 'device' => $device['device_id'], + 'tab' => 'ports'); print_optionbar_start(); @@ -25,136 +17,110 @@ $menu_options['basic'] = 'Basic'; $menu_options['details'] = 'Details'; $menu_options['arp'] = 'ARP Table'; -if (dbFetchCell("SELECT * FROM links AS L, ports AS I WHERE I.device_id = '".$device['device_id']."' AND I.port_id = L.local_port_id")) { - $menu_options['neighbours'] = 'Neighbours'; +if(dbFetchCell("SELECT * FROM links AS L, ports AS I WHERE I.device_id = '".$device['device_id']."' AND I.port_id = L.local_port_id")) +{ + $menu_options['neighbours'] = 'Neighbours'; +} +if(dbFetchCell("SELECT COUNT(*) FROM `ports` WHERE `ifType` = 'adsl'")) +{ + $menu_options['adsl'] = 'ADSL'; } -if (dbFetchCell("SELECT COUNT(*) FROM `ports` WHERE `ifType` = 'adsl'")) { - $menu_options['adsl'] = 'ADSL'; -} - -$sep = ''; -foreach ($menu_options as $option => $text) { - echo $sep; - if ($vars['view'] == $option) { - echo ""; - } - - echo generate_link($text, $link_array, array('view' => $option)); - if ($vars['view'] == $option) { - echo ''; - } - - $sep = ' | '; +$sep = ""; +foreach ($menu_options as $option => $text) +{ + echo($sep); + if ($vars['view'] == $option) { echo(""); } + echo(generate_link($text,$link_array,array('view'=>$option))); + if ($vars['view'] == $option) { echo(""); } + $sep = " | "; } unset($sep); -echo ' | Graphs: '; +echo(' | Graphs: '); -$graph_types = array( - 'bits' => 'Bits', - 'upkts' => 'Unicast Packets', - 'nupkts' => 'Non-Unicast Packets', - 'errors' => 'Errors', - 'etherlike' => 'Etherlike', -); +$graph_types = array("bits" => "Bits", + "upkts" => "Unicast Packets", + "nupkts" => "Non-Unicast Packets", + "errors" => "Errors", + "etherlike" => "Etherlike"); -foreach ($graph_types as $type => $descr) { - echo "$type_sep"; - if ($vars['graph'] == $type && $vars['view'] == 'graphs') { - echo ""; - } +foreach ($graph_types as $type => $descr) +{ + echo("$type_sep"); + if ($vars['graph'] == $type && $vars['view'] == "graphs") { echo(""); } + echo(generate_link($descr,$link_array,array('view'=>'graphs','graph'=>$type))); + if ($vars['graph'] == $type && $vars['view'] == "graphs") { echo(""); } - echo generate_link($descr, $link_array, array('view' => 'graphs', 'graph' => $type)); - if ($vars['graph'] == $type && $vars['view'] == 'graphs') { - echo ''; - } - - echo ' ('; - if ($vars['graph'] == $type && $vars['view'] == 'minigraphs') { - echo ""; - } - - echo generate_link('Mini', $link_array, array('view' => 'minigraphs', 'graph' => $type)); - if ($vars['graph'] == $type && $vars['view'] == 'minigraphs') { - echo ''; - } - - echo ')'; - $type_sep = ' | '; -}//end foreach + echo(' ('); + if ($vars['graph'] == $type && $vars['view'] == "minigraphs") { echo(""); } + echo(generate_link('Mini',$link_array,array('view'=>'minigraphs','graph'=>$type))); + if ($vars['graph'] == $type && $vars['view'] == "minigraphs") { echo(""); } + echo(')'); + $type_sep = " | "; +} print_optionbar_end(); -if ($vars['view'] == 'minigraphs') { - $timeperiods = array( - '-1day', - '-1week', - '-1month', - '-1year', - ); - $from = '-1day'; - echo "
    "; - unset($seperator); +if ($vars['view'] == 'minigraphs') +{ + $timeperiods = array('-1day','-1week','-1month','-1year'); + $from = '-1day'; + echo("
    "); + unset ($seperator); - // FIXME - FIX THIS. UGLY. - foreach (dbFetchRows('select * from ports WHERE device_id = ? ORDER BY ifIndex', array($device['device_id'])) as $port) { - echo "
    -
    ".makeshortif($port['ifDescr']).'
    - ".$device['hostname'].' - '.$port['ifDescr'].'
    \ - '.$port['ifAlias']." \ - \ - ', CENTER, LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 150);\" onmouseout=\"return nd();\" >"." - -
    ".truncate(short_port_descr($port['ifAlias']), 32, '').'
    -
    '; + // FIXME - FIX THIS. UGLY. + foreach (dbFetchRows("select * from ports WHERE device_id = ? ORDER BY ifIndex", array($device['device_id'])) as $port) + { + echo("
    +
    ".makeshortif($port['ifDescr'])."
    + ".$device['hostname']." - ".$port['ifDescr']."
    \ + ".$port['ifAlias']." \ + \ + ', CENTER, LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 150);\" onmouseout=\"return nd();\" >". + " + +
    ".truncate(short_port_descr($port['ifAlias']), 32, '')."
    +
    "); + } + echo("
    "); +} elseif ($vars['view'] == "arp" || $vars['view'] == "adsl" || $vars['view'] == "neighbours") { + include("ports/".$vars['view'].".inc.php"); +} else { + if ($vars['view'] == "details") { $port_details = 1; } + echo("
    "); + $i = "1"; + + global $port_cache, $port_index_cache; + + $ports = dbFetchRows("SELECT * FROM `ports` WHERE `device_id` = ? AND `deleted` = '0' ORDER BY `ifIndex` ASC", array($device['device_id'])); + // As we've dragged the whole database, lets pre-populate our caches :) + // FIXME - we should probably split the fetching of link/stack/etc into functions and cache them here too to cut down on single row queries. + foreach ($ports as $port) + { + $port_cache[$port['port_id']] = $port; + $port_index_cache[$port['device_id']][$port['ifIndex']] = $port; + } + + foreach ($ports as $port) + { + if ($config['memcached']['enable'] === TRUE) + { + $state = $memcache->get('port-'.$port['port_id'].'-state'); + if($debug) { print_r($state); } + if(is_array($state)) { $port = array_merge($port, $state); } + unset($state); } - echo ''; + include("includes/print-interface.inc.php"); + + $i++; + } + echo("
    "); } -else if ($vars['view'] == 'arp' || $vars['view'] == 'adsl' || $vars['view'] == 'neighbours') { - include 'ports/'.$vars['view'].'.inc.php'; -} -else { - if ($vars['view'] == 'details') { - $port_details = 1; - } - echo "
    "; - $i = '1'; +$pagetitle[] = "Ports"; - global $port_cache, $port_index_cache; - - $ports = dbFetchRows("SELECT * FROM `ports` WHERE `device_id` = ? AND `deleted` = '0' ORDER BY `ifIndex` ASC", array($device['device_id'])); - // As we've dragged the whole database, lets pre-populate our caches :) - // FIXME - we should probably split the fetching of link/stack/etc into functions and cache them here too to cut down on single row queries. - foreach ($ports as $port) { - $port_cache[$port['port_id']] = $port; - $port_index_cache[$port['device_id']][$port['ifIndex']] = $port; - } - - foreach ($ports as $port) { - if ($config['memcached']['enable'] === true) { - $state = $memcache->get('port-'.$port['port_id'].'-state'); - if ($debug) { - print_r($state); - } - - if (is_array($state)) { - $port = array_merge($port, $state); - } - - unset($state); - } - - include 'includes/print-interface.inc.php'; - - $i++; - } - - echo '
    '; -}//end if - -$pagetitle[] = 'Ports'; +?> diff --git a/html/pages/device/ports/neighbours.inc.php b/html/pages/device/ports/neighbours.inc.php index b56136881e..5e417eb996 100644 --- a/html/pages/device/ports/neighbours.inc.php +++ b/html/pages/device/ports/neighbours.inc.php @@ -10,7 +10,8 @@ echo 'Local Port Protocol '; -foreach (dbFetchRows('SELECT * FROM links AS L, ports AS I WHERE I.device_id = ? AND I.port_id = L.local_port_id', array($device['device_id'])) as $neighbour) { +foreach (dbFetchRows('SELECT * FROM links AS L, ports AS I WHERE I.device_id = ? AND I.port_id = L.local_port_id', array($device['device_id'])) as $neighbour) +{ if ($bg_colour == $list_colour_b) { $bg_colour = $list_colour_a; } diff --git a/html/pages/device/processes.inc.php b/html/pages/device/processes.inc.php index 0ce8e4c70f..41fda92887 100644 --- a/html/pages/device/processes.inc.php +++ b/html/pages/device/processes.inc.php @@ -1,21 +1,19 @@ +/* Copyright (C) 2015 Daniel Preussker * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ + * along with this program. If not, see . */ -/* +/** * Process Listing * @author Daniel Preussker * @copyright 2015 f0o, LibreNMS @@ -24,89 +22,77 @@ * @subpackage Pages */ -switch ($vars['order']) { - case 'vsz': - $order = '`vsz`'; - break; - - case 'rss': - $order = '`rss`'; - break; - - case 'cputime': - $order = '`cputime`'; - break; - - case 'user': - $order = '`user`'; - break; - - case 'command': - $order = '`command`'; - break; - - default: - $order = '`pid`'; - break; -}//end switch - -if ($vars['by'] == 'desc') { - $by = 'desc'; +switch( $vars['order'] ) { + case "vsz": + $order = "`vsz`"; + break; + case "rss": + $order = "`rss`"; + break; + case "cputime": + $order = "`cputime`"; + break; + case "user": + $order = "`user`"; + break; + case "command": + $order = "`command`"; + break; + default: + $order = "`pid`"; + break; } -else { - $by = 'asc'; +if( $vars['by'] == "desc" ) { + $by = "desc"; +} else { + $by = "asc"; } $heads = array( - 'PID' => '', - 'VSZ' => 'Virtual Memory', - 'RSS' => 'Resident Memory', - 'cputime' => '', - 'user' => '', - 'command' => '', + 'PID' => '', + 'VSZ' => 'Virtual Memory', + 'RSS' => 'Resident Memory', + 'cputime' => '', + 'user' => '', + 'command' => '' ); echo "
    "; -foreach ($heads as $head => $extra) { - unset($lhead, $bhead); - $lhead = strtolower($head); - $bhead = 'asc'; - $icon = ''; - if ('`'.$lhead.'`' == $order) { - $icon = " class='glyphicon glyphicon-chevron-"; - if ($by == 'asc') { - $bhead = 'desc'; - $icon .= 'up'; - } - else { - $icon .= 'down'; - } - - $icon .= "'"; - } - - echo ''; -}//end foreach - -echo ''; - -foreach (dbFetchRows('SELECT * FROM `processes` WHERE `device_id` = ? ORDER BY '.$order.' '.$by, array($device['device_id'])) as $entry) { - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; +foreach( $heads as $head=>$extra ) { + unset($lhead, $bhead); + $lhead = strtolower($head); + $bhead = 'asc'; + $icon = ""; + if( '`'.$lhead.'`' == $order ) { + $icon = " class='glyphicon glyphicon-chevron-"; + if( $by == 'asc' ) { + $bhead = 'desc'; + $icon .= 'up'; + } else { + $icon .= 'down'; + } + $icon .= "'"; + } + echo ''; } +echo ""; -echo '
     '; - if (!empty($extra)) { - echo "$head"; - } - else { - echo $head; - } - - echo '
    '.$entry['pid'].''.format_si(($entry['vsz'] * 1024)).''.format_si(($entry['rss'] * 1024)).''.$entry['cputime'].''.$entry['user'].''.$entry['command'].'
     '; + if( !empty($extra) ) { + echo "$head"; + } else { + echo $head; + } + echo '
    '; +foreach (dbFetchRows("SELECT * FROM `processes` WHERE `device_id` = ? ORDER BY ".$order." ".$by, array($device['device_id'])) as $entry) { + echo ''; + echo ''.$entry['pid'].''; + echo ''.format_si($entry['vsz']*1024).''; + echo ''.format_si($entry['rss']*1024).''; + echo ''.$entry['cputime'].''; + echo ''.$entry['user'].''; + echo ''.$entry['command'].''; + echo ''; +} +echo"
    "; + +?> diff --git a/html/pages/device/pseudowires.inc.php b/html/pages/device/pseudowires.inc.php index c48bca5738..c134c8b661 100644 --- a/html/pages/device/pseudowires.inc.php +++ b/html/pages/device/pseudowires.inc.php @@ -89,7 +89,8 @@ foreach (dbFetchRows('SELECT * FROM pseudowires AS P, ports AS I WHERE P.port_id 'upkts', 'errors', ); - foreach ($types as $graph_type) { + foreach ($types as $graph_type) + { $pw_a['graph_type'] = 'port_'.$graph_type; print_port_thumbnail($pw_a); } diff --git a/html/pages/device/routing/bgp.inc.php b/html/pages/device/routing/bgp.inc.php index 17f0629a02..5b327aca30 100644 --- a/html/pages/device/routing/bgp.inc.php +++ b/html/pages/device/routing/bgp.inc.php @@ -1,275 +1,203 @@ 'device', - 'device' => $device['device_id'], - 'tab' => 'routing', - 'proto' => 'bgp', -); +$link_array = array('page' => 'device', + 'device' => $device['device_id'], + 'tab' => 'routing', + 'proto' => 'bgp'); -if (!isset($vars['view'])) { - $vars['view'] = 'basic'; -} +if(!isset($vars['view'])) { $vars['view'] = "basic"; } print_optionbar_start(); -echo 'Local AS : '.$device['bgpLocalAs'].' '; +echo "Local AS : " .$device['bgpLocalAs']." "; -echo "BGP » "; +echo("BGP » "); -if ($vars['view'] == 'basic') { - echo ""; -} +if ($vars['view'] == "basic") { echo(""); } +echo(generate_link("Basic", $link_array,array('view'=>'basic'))); +if ($vars['view'] == "basic") { echo(""); } -echo generate_link('Basic', $link_array, array('view' => 'basic')); -if ($vars['view'] == 'basic') { - echo ''; -} +echo(" | "); -echo ' | '; +if ($vars['view'] == "updates") { echo(""); } +echo(generate_link("Updates", $link_array,array('view'=>'updates'))); +if ($vars['view'] == "updates") { echo(""); } -if ($vars['view'] == 'updates') { - echo ""; -} +echo(" | Prefixes: "); -echo generate_link('Updates', $link_array, array('view' => 'updates')); -if ($vars['view'] == 'updates') { - echo ''; -} +if ($vars['view'] == "prefixes_ipv4unicast") { echo(""); } +echo(generate_link("IPv4", $link_array,array('view'=>'prefixes_ipv4unicast'))); +if ($vars['view'] == "prefixes_ipv4unicast") { echo(""); } -echo ' | Prefixes: '; +echo(" | "); -if ($vars['view'] == 'prefixes_ipv4unicast') { - echo ""; -} +if ($vars['view'] == "prefixes_vpnv4unicast") { echo(""); } +echo(generate_link("VPNv4", $link_array,array('view'=>'prefixes_vpnv4unicast'))); +if ($vars['view'] == "prefixes_vpnv4unicast") { echo(""); } -echo generate_link('IPv4', $link_array, array('view' => 'prefixes_ipv4unicast')); -if ($vars['view'] == 'prefixes_ipv4unicast') { - echo ''; -} +echo(" | "); -echo ' | '; +if ($vars['view'] == "prefixes_ipv6unicast") { echo(""); } +echo(generate_link("IPv6", $link_array,array('view'=>'prefixes_ipv6unicast'))); +if ($vars['view'] == "prefixes_ipv6unicast") { echo(""); } -if ($vars['view'] == 'prefixes_vpnv4unicast') { - echo ""; -} +echo(" | Traffic: "); -echo generate_link('VPNv4', $link_array, array('view' => 'prefixes_vpnv4unicast')); -if ($vars['view'] == 'prefixes_vpnv4unicast') { - echo ''; -} - -echo ' | '; - -if ($vars['view'] == 'prefixes_ipv6unicast') { - echo ""; -} - -echo generate_link('IPv6', $link_array, array('view' => 'prefixes_ipv6unicast')); -if ($vars['view'] == 'prefixes_ipv6unicast') { - echo ''; -} - -echo ' | Traffic: '; - -if ($vars['view'] == 'macaccounting_bits') { - echo ""; -} - -echo generate_link('Bits', $link_array, array('view' => 'macaccounting_bits')); -if ($vars['view'] == 'macaccounting_bits') { - echo ''; -} - -echo ' | '; -if ($vars['view'] == 'macaccounting_pkts') { - echo ""; -} - -echo generate_link('Packets', $link_array, array('view' => 'macaccounting_pkts')); -if ($vars['view'] == 'macaccounting_pkts') { - echo ''; -} +if ($vars['view'] == "macaccounting_bits") { echo(""); } +echo(generate_link("Bits", $link_array,array('view'=>'macaccounting_bits'))); +if ($vars['view'] == "macaccounting_bits") { echo(""); } +echo(" | "); +if ($vars['view'] == "macaccounting_pkts") { echo(""); } +echo(generate_link("Packets", $link_array,array('view'=>'macaccounting_pkts'))); +if ($vars['view'] == "macaccounting_pkts") { echo(""); } print_optionbar_end(); -echo ''; -echo ''; +echo('
    Peer addressTypeRemote ASStateUptime
    '); +echo(''); -$i = '1'; +$i = "1"; -foreach (dbFetchRows('SELECT * FROM `bgpPeers` WHERE `device_id` = ? ORDER BY `bgpPEerRemoteAs`, `bgpPeerIdentifier`', array($device['device_id'])) as $peer) { - $has_macaccounting = dbFetchCell('SELECT COUNT(*) FROM `ipv4_mac` AS I, mac_accounting AS M WHERE I.ipv4_address = ? AND M.mac = I.mac_address', array($peer['bgpPeerIdentifier'])); - unset($bg_image); - if (!is_integer($i / 2)) { - $bg_colour = $list_colour_a; - } - else { - $bg_colour = $list_colour_b; - } +foreach (dbFetchRows("SELECT * FROM `bgpPeers` WHERE `device_id` = ? ORDER BY `bgpPEerRemoteAs`, `bgpPeerIdentifier`", array($device['device_id'])) as $peer) +{ + $has_macaccounting = dbFetchCell("SELECT COUNT(*) FROM `ipv4_mac` AS I, mac_accounting AS M WHERE I.ipv4_address = ? AND M.mac = I.mac_address", array($peer['bgpPeerIdentifier'])); + unset($bg_image); + if (!is_integer($i/2)) { $bg_colour = $list_colour_a; } else { $bg_colour = $list_colour_b; } + unset ($alert, $bg_image); + unset ($peerhost, $peername); - unset($alert, $bg_image); - unset($peerhost, $peername); + if (!is_integer($i/2)) { $bg_colour = $list_colour_b; } else { $bg_colour = $list_colour_a; } + if ($peer['bgpPeerState'] == "established") { $col = "green"; } else { $col = "red"; $peer['alert']=1; } + if ($peer['bgpPeerAdminStatus'] == "start" || $peer['bgpPeerAdminStatus'] == "running") { $admin_col = "green"; } else { $admin_col = "gray"; } + if ($peer['bgpPeerAdminStatus'] == "stop") { $peer['alert']=0; $peer['disabled']=1; } - if (!is_integer($i / 2)) { - $bg_colour = $list_colour_b; - } - else { - $bg_colour = $list_colour_a; - } + if ($peer['bgpPeerRemoteAs'] == $device['bgpLocalAs']) { $peer_type = "iBGP"; } else { $peer_type = "eBGP"; } - if ($peer['bgpPeerState'] == 'established') { - $col = 'green'; - } - else { - $col = 'red'; - $peer['alert'] = 1; - } + $query = "SELECT * FROM ipv4_addresses AS A, ports AS I, devices AS D WHERE "; + $query .= "(A.ipv4_address = ? AND I.port_id = A.port_id)"; + $query .= " AND D.device_id = I.device_id"; + $ipv4_host = dbFetchRow($query,array($peer['bgpPeerIdentifier'])); - if ($peer['bgpPeerAdminStatus'] == 'start' || $peer['bgpPeerAdminStatus'] == 'running') { - $admin_col = 'green'; - } - else { - $admin_col = 'gray'; - } + $query = "SELECT * FROM ipv6_addresses AS A, ports AS I, devices AS D WHERE "; + $query .= "(A.ipv6_address = ? AND I.port_id = A.port_id)"; + $query .= " AND D.device_id = I.device_id"; + $ipv6_host = dbFetchRow($query,array($peer['bgpPeerIdentifier'])); - if ($peer['bgpPeerAdminStatus'] == 'stop') { - $peer['alert'] = 0; - $peer['disabled'] = 1; - } + if ($ipv4_host) + { + $peerhost = $ipv4_host; + } elseif ($ipv6_host) { + $peerhost = $ipv6_host; + } else { + unset($peerhost); + } - if ($peer['bgpPeerRemoteAs'] == $device['bgpLocalAs']) { - $peer_type = "iBGP"; - } - else { - $peer_type = "eBGP"; - } + if (is_array($peerhost)) + { + #$peername = generate_device_link($peerhost); + $peername = generate_device_link($peerhost) ." ". generate_port_link($peerhost); + $peer_url = "device/device=" . $peer['device_id'] . "/tab=routing/proto=bgp/view=updates/"; + } + else + { + #$peername = gethostbyaddr($peer['bgpPeerIdentifier']); // FFffuuu DNS // Cache this in discovery? +# if ($peername == $peer['bgpPeerIdentifier']) +# { +# unset($peername); +# } else { +# $peername = "".$peername.""; +# } + } - $query = 'SELECT * FROM ipv4_addresses AS A, ports AS I, devices AS D WHERE '; - $query .= '(A.ipv4_address = ? AND I.port_id = A.port_id)'; - $query .= ' AND D.device_id = I.device_id'; - $ipv4_host = dbFetchRow($query, array($peer['bgpPeerIdentifier'])); + unset($peer_af); + unset($sep); - $query = 'SELECT * FROM ipv6_addresses AS A, ports AS I, devices AS D WHERE '; - $query .= '(A.ipv6_address = ? AND I.port_id = A.port_id)'; - $query .= ' AND D.device_id = I.device_id'; - $ipv6_host = dbFetchRow($query, array($peer['bgpPeerIdentifier'])); + foreach (dbFetchRows("SELECT * FROM `bgpPeers_cbgp` WHERE `device_id` = ? AND bgpPeerIdentifier = ?", array($device['device_id'], $peer['bgpPeerIdentifier'])) as $afisafi) + { + $afi = $afisafi['afi']; + $safi = $afisafi['safi']; + $this_afisafi = $afi.$safi; + $peer['afi'] .= $sep . $afi .".".$safi; + $sep = "
    "; + $peer['afisafi'][$this_afisafi] = 1; // Build a list of valid AFI/SAFI for this peer + } - if ($ipv4_host) { - $peerhost = $ipv4_host; - } - else if ($ipv6_host) { - $peerhost = $ipv6_host; - } - else { - unset($peerhost); - } + unset($sep); - if (is_array($peerhost)) { - // $peername = generate_device_link($peerhost); - $peername = generate_device_link($peerhost).' '.generate_port_link($peerhost); - $peer_url = 'device/device='.$peer['device_id'].'/tab=routing/proto=bgp/view=updates/'; - } - else { - // FIXME - // $peername = gethostbyaddr($peer['bgpPeerIdentifier']); // FFffuuu DNS // Cache this in discovery? - // if ($peername == $peer['bgpPeerIdentifier']) - // { - // unset($peername); - // } else { - // $peername = "".$peername.""; - // } - } - - unset($peer_af); - unset($sep); - - foreach (dbFetchRows('SELECT * FROM `bgpPeers_cbgp` WHERE `device_id` = ? AND bgpPeerIdentifier = ?', array($device['device_id'], $peer['bgpPeerIdentifier'])) as $afisafi) { - $afi = $afisafi['afi']; - $safi = $afisafi['safi']; - $this_afisafi = $afi.$safi; - $peer['afi'] .= $sep.$afi.'.'.$safi; - $sep = '
    '; - $peer['afisafi'][$this_afisafi] = 1; - // Build a list of valid AFI/SAFI for this peer - } - - unset($sep); - - if (filter_var($peer['bgpLocalAddr'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) !== false) { - $peer['bgpPeerIdentifier'] = Net_IPv6::compress($peer['bgpPeerIdentifier']); - } + if (filter_var($peer['bgpLocalAddr'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) !== FALSE) { + $peer['bgpPeerIdentifier'] = Net_IPv6::compress($peer['bgpPeerIdentifier']); + } - $graph_type = 'bgp_updates'; - $peer_daily_url = 'graph.php?id='.$peer['bgpPeer_id'].'&type='.$graph_type.'&from='.$config['time']['day'].'&to='.$config['time']['now'].'&width=500&height=150'; - $peeraddresslink = "', LEFT".$config['overlib_defaults'].');" onmouseout="return nd();">'.$peer['bgpPeerIdentifier'].''; + $graph_type = "bgp_updates"; + $peer_daily_url = "graph.php?id=" . $peer['bgpPeer_id'] . "&type=" . $graph_type . "&from=".$config['time']['day']."&to=".$config['time']['now']."&width=500&height=150"; + $peeraddresslink = "', LEFT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\">" . $peer['bgpPeerIdentifier'] . ""; - echo '
    - '; + echo(' + "); - echo ' - - - - - - - - '; + echo(" + + + + + + + + "); - unset($invalid); + unset($invalid); - switch ($vars['view']) { + switch ($vars['view']) + { case 'prefixes_ipv4unicast': case 'prefixes_ipv4multicast': case 'prefixes_ipv4vpn': case 'prefixes_ipv6unicast': case 'prefixes_ipv6multicast': - list(,$afisafi) = explode('_', $vars['view']); - if (isset($peer['afisafi'][$afisafi])) { - $peer['graph'] = 1; - } - - // FIXME no break?? + list(,$afisafi) = explode("_", $vars['view']); + if (isset($peer['afisafi'][$afisafi])) { $peer['graph'] = 1; } + // FIXME no break?? case 'updates': - $graph_array['type'] = 'bgp_'.$vars['view']; - $graph_array['id'] = $peer['bgpPeer_id']; - } + $graph_array['type'] = "bgp_" . $vars['view']; + $graph_array['id'] = $peer['bgpPeer_id']; + } - switch ($vars['view']) { + switch ($vars['view']) + { case 'macaccounting_bits': case 'macaccounting_pkts': - $acc = dbFetchRow('SELECT * FROM `ipv4_mac` AS I, `mac_accounting` AS M, `ports` AS P, `devices` AS D WHERE I.ipv4_address = ? AND M.mac = I.mac_address AND P.port_id = M.port_id AND D.device_id = P.device_id', array($peer['bgpPeerIdentifier'])); - $database = $config['rrd_dir'].'/'.$device['hostname'].'/cip-'.$acc['ifIndex'].'-'.$acc['mac'].'.rrd'; - if (is_array($acc) && is_file($database)) { - $peer['graph'] = 1; - $graph_array['id'] = $acc['ma_id']; - $graph_array['type'] = $vars['view']; - } - } + $acc = dbFetchRow("SELECT * FROM `ipv4_mac` AS I, `mac_accounting` AS M, `ports` AS P, `devices` AS D WHERE I.ipv4_address = ? AND M.mac = I.mac_address AND P.port_id = M.port_id AND D.device_id = P.device_id", array($peer['bgpPeerIdentifier'])); + $database = $config['rrd_dir'] . "/" . $device['hostname'] . "/cip-" . $acc['ifIndex'] . "-" . $acc['mac'] . ".rrd"; + if (is_array($acc) && is_file($database)) + { + $peer['graph'] = 1; + $graph_array['id'] = $acc['ma_id']; + $graph_array['type'] = $vars['view']; + } + } - if ($vars['view'] == 'updates') { - $peer['graph'] = 1; - } + if ($vars['view'] == 'updates') { $peer['graph'] = 1; } - if ($peer['graph']) { - $graph_array['height'] = '100'; - $graph_array['width'] = '216'; - $graph_array['to'] = $config['time']['now']; - echo ''; - } + echo(""); + } - $i++; + $i++; - unset($valid_afi_safi); -}//end foreach + unset($valid_afi_safi); +} ?>
    Peer addressTypeRemote ASStateUptime
    '.$i.''.$peeraddresslink.'
    '.$peername."
    $peer_type".(isset($peer['afi']) ? $peer['afi'] : '').'AS'.$peer['bgpPeerRemoteAs'].'
    '.$peer['astext']."
    ".$peer['bgpPeerAdminStatus']."
    ".$peer['bgpPeerState'].'
    '.formatUptime($peer['bgpPeerFsmEstablishedTime'])."
    - Updates ".$peer['bgpPeerInUpdates']." - ".$peer['bgpPeerOutUpdates'].'
    ".$i."" . $peeraddresslink . "
    ".$peername."
    $peer_type" . (isset($peer['afi']) ? $peer['afi'] : '') . "AS" . $peer['bgpPeerRemoteAs'] . "
    " . $peer['astext'] . "
    " . $peer['bgpPeerAdminStatus'] . "
    " . $peer['bgpPeerState'] . "
    " .formatUptime($peer['bgpPeerFsmEstablishedTime']). "
    + Updates " . $peer['bgpPeerInUpdates'] . " + " . $peer['bgpPeerOutUpdates'] . "
    '; + if ($peer['graph']) + { + $graph_array['height'] = "100"; + $graph_array['width'] = "216"; + $graph_array['to'] = $config['time']['now']; + echo('
    '); - include 'includes/print-graphrow.inc.php'; + include("includes/print-graphrow.inc.php"); - echo '
    diff --git a/html/pages/device/routing/ospf.inc.php b/html/pages/device/routing/ospf.inc.php index 7bf6798b7b..ed126a7fe3 100644 --- a/html/pages/device/routing/ospf.inc.php +++ b/html/pages/device/routing/ospf.inc.php @@ -88,7 +88,8 @@ foreach (dbFetchRows('SELECT * FROM `ospf_instances` WHERE `device_id` = ?', arr // # Loop Ports $i_p = ($i_a + 1); $p_sql = "SELECT * FROM `ospf_ports` AS O, `ports` AS P WHERE O.`ospfIfAdminStat` = 'enabled' AND O.`device_id` = ? AND O.`ospfIfAreaId` = ? AND P.port_id = O.port_id"; - foreach (dbFetchRows($p_sql, array($device['device_id'], $area['ospfAreaId'])) as $ospfport) { + foreach (dbFetchRows($p_sql, array($device['device_id'], $area['ospfAreaId'])) as $ospfport) + { if (!is_integer($i_a / 2)) { if (!is_integer($i_p / 2)) { $port_bg = $list_colour_b_b; diff --git a/html/pages/device/showconfig.inc.php b/html/pages/device/showconfig.inc.php index 9efc95d63a..aed9398dd2 100644 --- a/html/pages/device/showconfig.inc.php +++ b/html/pages/device/showconfig.inc.php @@ -1,135 +1,134 @@ = '7') { - if (!is_array($config['rancid_configs'])) { - $config['rancid_configs'] = array($config['rancid_configs']); - } - if (isset($config['rancid_configs'][0])) { - foreach ($config['rancid_configs'] as $configs) { - if ($configs[(strlen($configs) - 1)] != '/') { - $configs .= '/'; - } +if ($_SESSION['userlevel'] >= "7") +{ - if (is_file($configs.$device['hostname'])) { - $file = $configs.$device['hostname']; - } - } + if (!is_array($config['rancid_configs'])) { $config['rancid_configs'] = array($config['rancid_configs']); } - echo '
    '; + if (isset($config['rancid_configs'][0])) { - print_optionbar_start('', ''); + foreach ($config['rancid_configs'] as $configs) { + if ($configs[strlen($configs) - 1] != '/') { + $configs .= '/'; + } + if (is_file($configs . $device['hostname'])) { + $file = $configs . $device['hostname']; + } + } - echo "Config » "; + echo('
    '); - if (!$vars['rev']) { - echo ''; - echo generate_link('Latest', array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'showconfig')); - echo ''; - } - else { - echo generate_link('Latest', array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'showconfig')); - } + print_optionbar_start('', ''); - if (function_exists('svn_log')) { - $sep = ' | '; - $svnlogs = svn_log($file, SVN_REVISION_HEAD, null, 8); - $revlist = array(); + echo("Config » "); - foreach ($svnlogs as $svnlog) { - echo $sep; - $revlist[] = $svnlog['rev']; + if (!$vars['rev']) { + echo(''); + echo(generate_link('Latest', array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'showconfig'))); + echo(""); + } else { + echo(generate_link('Latest', array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'showconfig'))); + } - if ($vars['rev'] == $svnlog['rev']) { - echo ''; - } + if (function_exists('svn_log')) { - $linktext = 'r'.$svnlog['rev'].' '.date($config['dateformat']['byminute'], strtotime($svnlog['date'])).''; - echo generate_link($linktext, array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'showconfig', 'rev' => $svnlog['rev'])); + $sep = " | "; + $svnlogs = svn_log($file, SVN_REVISION_HEAD, NULL, 8); + $revlist = array(); - if ($vars['rev'] == $svnlog['rev']) { - echo ''; - } + foreach ($svnlogs as $svnlog) { - $sep = ' | '; - } - }//end if + echo($sep); + $revlist[] = $svnlog["rev"]; - print_optionbar_end(); + if ($vars['rev'] == $svnlog["rev"]) { + echo(''); + } + $linktext = "r" . $svnlog["rev"] . " " . date($config['dateformat']['byminute'], strtotime($svnlog["date"])) . ""; + echo(generate_link($linktext, array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'showconfig', 'rev' => $svnlog["rev"]))); - if (function_exists('svn_log') && in_array($vars['rev'], $revlist)) { - list($diff, $errors) = svn_diff($file, ($vars['rev'] - 1), $file, $vars['rev']); - if (!$diff) { - $text = 'No Difference'; - } - else { - $text = ''; - while (!feof($diff)) { - $text .= fread($diff, 8192); - } + if ($vars['rev'] == $svnlog["rev"]) { + echo(""); + } - fclose($diff); - fclose($errors); - } - } - else { - $fh = fopen($file, 'r') or die("Can't open file"); - $text = fread($fh, filesize($file)); - fclose($fh); - } + $sep = " | "; + } + } - if ($config['rancid_ignorecomments']) { - $lines = explode("\n", $text); - for ($i = 0; $i < count($lines); $i++) { - if ($lines[$i][0] == '#') { - unset($lines[$i]); - } - } + print_optionbar_end(); - $text = join("\n", $lines); - } - } - else if ($config['oxidized']['enabled'] === true && isset($config['oxidized']['url'])) { - $node_info = json_decode(file_get_contents($config['oxidized']['url'].'/node/show/'.$device['hostname'].'?format=json'), true); - $text = file_get_contents($config['oxidized']['url'].'/node/fetch/'.$device['hostname']); - if ($text == 'node not found') { - $text = file_get_contents($config['oxidized']['url'].'/node/fetch/'.$device['os'].'/'.$device['hostname']); - } + if (function_exists('svn_log') && in_array($vars['rev'], $revlist)) { + list($diff, $errors) = svn_diff($file, $vars['rev'] - 1, $file, $vars['rev']); + if (!$diff) { + $text = "No Difference"; + } else { + $text = ""; + while (!feof($diff)) { + $text .= fread($diff, 8192); + } + fclose($diff); + fclose($errors); + } - if (is_array($node_info)) { - echo '
    -
    + } else { + $fh = fopen($file, 'r') or die("Can't open file"); + $text = fread($fh, filesize($file)); + fclose($fh); + } + + if ($config['rancid_ignorecomments']) { + $lines = explode("\n", $text); + for ($i = 0; $i < count($lines); $i++) { + if ($lines[$i][0] == "#") { + unset($lines[$i]); + } + } + $text = join("\n", $lines); + } + } elseif ($config['oxidized']['enabled'] === TRUE && isset($config['oxidized']['url'])) { + $node_info = json_decode(file_get_contents($config['oxidized']['url']."/node/show/".$device['hostname']."?format=json"),TRUE); + $text = file_get_contents($config['oxidized']['url']."/node/fetch/".$device['hostname']); + if ($text == "node not found") { + $text = file_get_contents($config['oxidized']['url']."/node/fetch/".$device['os']."/".$device['hostname']); + } + + if (is_array($node_info)) { + echo('
    +
    -
    -
    Sync status: '.$node_info['last']['status'].'
    -
      -
    • Node: '.$node_info['name'].'
    • -
    • IP: '.$node_info['ip'].'
    • -
    • Model: '.$node_info['model'].'
    • -
    • Last Sync: '.$node_info['last']['end'].'
    • -
    +
    +
    Sync status: '.$node_info['last']['status'].'
    +
      +
    • Node: '. $node_info['name'].'
    • +
    • IP: '. $node_info['ip'].'
    • +
    • Model: '. $node_info['model'].'
    • +
    • Last Sync: '. $node_info['last']['end'].'
    • +
    +
    -
    -
    '; - } - else { - echo '
    '; - print_error("We couldn't retrieve the device information from Oxidized"); - $text = ''; - } - }//end if +
    '); + } else { + echo "
    "; + print_error("We couldn't retrieve the device information from Oxidized"); + $text = ''; + } - if (!empty($text)) { - $language = 'ios'; - $geshi = new GeSHi($text, $language); - $geshi->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS); - $geshi->set_overall_style('color: black;'); - // $geshi->set_line_style('color: #999999'); - echo $geshi->parse_code(); - } -}//end if + } -$pagetitle[] = 'Config'; + if (!empty($text)) { + $language = "ios"; + $geshi = new GeSHi($text, $language); + $geshi->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS); + $geshi->set_overall_style('color: black;'); + #$geshi->set_line_style('color: #999999'); + echo($geshi->parse_code()); + } +} + +$pagetitle[] = "Config"; + +?> diff --git a/html/pages/device/slas.inc.php b/html/pages/device/slas.inc.php index 587c7d7438..3cc6cbf119 100644 --- a/html/pages/device/slas.inc.php +++ b/html/pages/device/slas.inc.php @@ -12,7 +12,7 @@ foreach ($slas as $sla) { $sla_type = $sla['rtt_type']; if (!in_array($sla_type, $sla_types)) { - if (isset($config['sla_type_labels'][$sla_type])) { + if (isset($config['sla_type_labels'][$sla_type])) { $text = $config['sla_type_labels'][$sla_type]; } } diff --git a/html/pages/devices.inc.php b/html/pages/devices.inc.php index 0367b8a1c3..67a8c39edd 100644 --- a/html/pages/devices.inc.php +++ b/html/pages/devices.inc.php @@ -2,9 +2,7 @@ // Set Defaults here -if(!isset($vars['format'])) { - $vars['format'] = "list_detail"; -} +if(!isset($vars['format'])) { $vars['format'] = "list_detail"; } $pagetitle[] = "Devices"; @@ -12,19 +10,23 @@ print_optionbar_start(); echo('Lists » '); -$menu_options = array('basic' => 'Basic', 'detail' => 'Detail'); +$menu_options = array('basic' => 'Basic', + 'detail' => 'Detail'); $sep = ""; -foreach ($menu_options as $option => $text) { - echo($sep); - if ($vars['format'] == "list_".$option) { - echo(""); - } - echo('' . $text . ''); - if ($vars['format'] == "list_".$option) { - echo(""); - } - $sep = " | "; +foreach ($menu_options as $option => $text) +{ + echo($sep); + if ($vars['format'] == "list_".$option) + { + echo(""); + } + echo('' . $text . ''); + if ($vars['format'] == "list_".$option) + { + echo(""); + } + $sep = " | "; } ?> @@ -36,26 +38,29 @@ foreach ($menu_options as $option => $text) { 'Bits', - 'processor' => 'CPU', - 'ucd_load' => 'Load', - 'mempool' => 'Memory', - 'uptime' => 'Uptime', - 'storage' => 'Storage', - 'diskio' => 'Disk I/O', - 'poller_perf' => 'Poller', - 'ping_perf' => 'Ping' -); + 'processor' => 'CPU', + 'ucd_load' => 'Load', + 'mempool' => 'Memory', + 'uptime' => 'Uptime', + 'storage' => 'Storage', + 'diskio' => 'Disk I/O', + 'poller_perf' => 'Poller', + 'ping_perf' => 'Ping' + ); $sep = ""; -foreach ($menu_options as $option => $text) { - echo($sep); - if ($vars['format'] == 'graph_'.$option) { - echo(""); - } - echo('' . $text . ''); - if ($vars['format'] == 'graph_'.$option) { - echo(""); - } - $sep = " | "; +foreach ($menu_options as $option => $text) +{ + echo($sep); + if ($vars['format'] == 'graph_'.$option) + { + echo(""); + } + echo('' . $text . ''); + if ($vars['format'] == 'graph_'.$option) + { + echo(""); + } + $sep = " | "; } ?> @@ -64,21 +69,21 @@ foreach ($menu_options as $option => $text) { '')).'">Restore Search'); -} -else { + } else { echo('Remove Search'); -} + } -echo(" | "); + echo(" | "); -if (isset($vars['bare']) && $vars['bare'] == "yes") { + if (isset($vars['bare']) && $vars['bare'] == "yes") + { echo('Restore Header'); -} -else { + } else { echo('Remove Header'); -} + } print_optionbar_end(); ?> @@ -89,110 +94,76 @@ print_optionbar_end(); list($format, $subformat) = explode("_", $vars['format'], 2); -if($format == "graph") { - $sql_param = array(); +if($format == "graph") +{ +$sql_param = array(); - if(isset($vars['state'])) { - if($vars['state'] == 'up') { - $state = '1'; - } - elseif($vars['state'] == 'down') { - $state = '0'; - } - } +if(isset($vars['state'])) +{ + if($vars['state'] == 'up') + { + $state = '1'; + } + elseif($vars['state'] == 'down') + { + $state = '0'; + } +} - if (!empty($vars['hostname'])) { - $where .= " AND hostname LIKE ?"; - $sql_param[] = "%".$vars['hostname']."%"; - } - if (!empty($vars['os'])) { - $where .= " AND os = ?"; - $sql_param[] = $vars['os']; - } - if (!empty($vars['version'])) { - $where .= " AND version = ?"; - $sql_param[] = $vars['version']; - } - if (!empty($vars['hardware'])) { - $where .= " AND hardware = ?"; - $sql_param[] = $vars['hardware']; - } - if (!empty($vars['features'])) { - $where .= " AND features = ?"; - $sql_param[] = $vars['features']; - } +if (!empty($vars['hostname'])) { $where .= " AND hostname LIKE ?"; $sql_param[] = "%".$vars['hostname']."%"; } +if (!empty($vars['os'])) { $where .= " AND os = ?"; $sql_param[] = $vars['os']; } +if (!empty($vars['version'])) { $where .= " AND version = ?"; $sql_param[] = $vars['version']; } +if (!empty($vars['hardware'])) { $where .= " AND hardware = ?"; $sql_param[] = $vars['hardware']; } +if (!empty($vars['features'])) { $where .= " AND features = ?"; $sql_param[] = $vars['features']; } +if (!empty($vars['type'])) { + if ($vars['type'] == 'generic') { + $where .= " AND ( type = ? OR type = '')"; $sql_param[] = $vars['type']; + } else { + $where .= " AND type = ?"; $sql_param[] = $vars['type']; + } +} +if (!empty($vars['state'])) { + $where .= " AND status= ?"; $sql_param[] = $state; + $where .= " AND disabled='0' AND `ignore`='0'"; $sql_param[] = ''; +} +if (!empty($vars['disabled'])) { $where .= " AND disabled= ?"; $sql_param[] = $vars['disabled']; } +if (!empty($vars['ignore'])) { $where .= " AND `ignore`= ?"; $sql_param[] = $vars['ignore']; } +if (!empty($vars['location']) && $vars['location'] == "Unset") { $location_filter = ''; } +if (!empty($vars['location'])) { $location_filter = $vars['location']; } +if( !empty($vars['group']) ) { + require_once('../includes/device-groups.inc.php'); + $where .= " AND ( "; + foreach( GetDevicesFromGroup($vars['group']) as $dev ) { + $where .= "device_id = ? OR "; + $sql_param[] = $dev['device_id']; + } + $where = substr($where, 0, strlen($where)-3); + $where .= " )"; +} - if (!empty($vars['type'])) { - if ($vars['type'] == 'generic') { - $where .= " AND ( type = ? OR type = '')"; - $sql_param[] = $vars['type']; - } - else { - $where .= " AND type = ?"; - $sql_param[] = $vars['type']; - } - } - if (!empty($vars['state'])) { - $where .= " AND status= ?"; - $sql_param[] = $state; - $where .= " AND disabled='0' AND `ignore`='0'"; - $sql_param[] = ''; - } - if (!empty($vars['disabled'])) { - $where .= " AND disabled= ?"; - $sql_param[] = $vars['disabled']; - } - if (!empty($vars['ignore'])) { - $where .= " AND `ignore`= ?"; - $sql_param[] = $vars['ignore']; - } - if (!empty($vars['location']) && $vars['location'] == "Unset") { - $location_filter = ''; - } - if (!empty($vars['location'])) { - $location_filter = $vars['location']; - } - if( !empty($vars['group']) ) { - require_once('../includes/device-groups.inc.php'); - $where .= " AND ( "; - foreach( GetDevicesFromGroup($vars['group']) as $dev ) { - $where .= "device_id = ? OR "; - $sql_param[] = $dev['device_id']; - } - $where = substr($where, 0, strlen($where)-3); - $where .= " )"; - } +$query = "SELECT * FROM `devices` WHERE 1 "; - $query = "SELECT * FROM `devices` WHERE 1 "; +if (isset($where)) { + $query .= $where; +} - if (isset($where)) { - $query .= $where; - } +$query .= " ORDER BY hostname"; - $query .= " ORDER BY hostname"; + $row = 1; + foreach (dbFetchRows($query, $sql_param) as $device) + { + if (is_integer($row/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; } - $row = 1; - foreach (dbFetchRows($query, $sql_param) as $device) { - if (is_integer($row/2)) { - $row_colour = $list_colour_a; - } - else { - $row_colour = $list_colour_b; - } + if (device_permitted($device['device_id'])) + { + if (!$location_filter || ((get_dev_attrib($device,'override_sysLocation_bool') && get_dev_attrib($device,'override_sysLocation_string') == $location_filter) + || $device['location'] == $location_filter)) + { + $graph_type = "device_".$subformat; - if (device_permitted($device['device_id'])) { - if (!$location_filter || ((get_dev_attrib($device,'override_sysLocation_bool') && get_dev_attrib($device,'override_sysLocation_string') == $location_filter) - || $device['location'] == $location_filter)) { - $graph_type = "device_".$subformat; + if ($_SESSION['widescreen']) { $width=270; } else { $width=315; } - if ($_SESSION['widescreen']) { - $width=270; - } - else { - $width=315; - } - - echo(""); - } - } + } } -} -else { + } + +} else { ?> @@ -238,23 +209,22 @@ else { ""+ '.$config['os'][$tmp_os]['text'].'"+'); +if (is_admin() === TRUE || is_read() === TRUE) { + $sql = "SELECT `os` FROM `devices` AS D WHERE 1 GROUP BY `os` ORDER BY `os`"; +} else { + $sql = "SELECT `os` FROM `devices` AS `D`, `devices_perms` AS `P` WHERE `P`.`user_id` = ? AND `P`.`device_id` = `D`.`device_id` GROUP BY `os` ORDER BY `os`"; + $param[] = $_SESSION['user_id']; +} +foreach (dbFetch($sql,$param) as $data) { + if ($data['os']) { + $tmp_os = clean_bootgrid($data['os']); + echo('""+'); } +} ?> ""+ "
    "+ @@ -263,23 +233,22 @@ else { ""+ '.$tmp_version.'"+'); +if (is_admin() === TRUE || is_read() === TRUE) { + $sql = "SELECT `version` FROM `devices` AS D WHERE 1 GROUP BY `version` ORDER BY `version`"; +} else { + $sql = "SELECT `version` FROM `devices` AS `D`, `devices_perms` AS `P` WHERE `P`.`user_id` = ? AND `P`.`device_id` = `D`.`device_id` GROUP BY `version` ORDER BY `version`"; + $param[] = $_SESSION['user_id']; +} +foreach (dbFetch($sql,$param) as $data) { + if ($data['version']) { + $tmp_version = clean_bootgrid($data['version']); + echo('""+'); + } +} ?> ""+ "
    "+ @@ -288,23 +257,22 @@ else { ""+ '.$tmp_hardware.'"+'); +if (is_admin() === TRUE || is_read() === TRUE) { + $sql = "SELECT `hardware` FROM `devices` AS D WHERE 1 GROUP BY `hardware` ORDER BY `hardware`"; +} else { + $sql = "SELECT `hardware` FROM `devices` AS `D`, `devices_perms` AS `P` WHERE `P`.`user_id` = ? AND `P`.`device_id` = `D`.`device_id` GROUP BY `hardware` ORDER BY `hardware`"; + $param[] = $_SESSION['user_id']; +} +foreach (dbFetch($sql,$param) as $data) { + if ($data['hardware']) { + $tmp_hardware = clean_bootgrid($data['hardware']); + echo('""+'); } +} ?> ""+ @@ -314,24 +282,24 @@ else { ""+ '.$tmp_features.'"+'); - } + echo('">'.$tmp_features.'"+'); } +} ?> ""+ @@ -343,16 +311,16 @@ else { '.$location.'"+'); +foreach (getlocations() as $location) { + if ($location) { + $location = clean_bootgrid($location); + echo('""+'); } +} ?> ""+ ""+ @@ -361,22 +329,21 @@ else { ""+ '.ucfirst($data['type']).'"+'); +if (is_admin() === TRUE || is_read() === TRUE) { + $sql = "SELECT `type` FROM `devices` AS D WHERE 1 GROUP BY `type` ORDER BY `type`"; +} else { + $sql = "SELECT `type` FROM `devices` AS `D`, `devices_perms` AS `P` WHERE `P`.`user_id` = ? AND `P`.`device_id` = `D`.`device_id` GROUP BY `type` ORDER BY `type`"; + $param[] = $_SESSION['user_id']; +} +foreach (dbFetch($sql,$param) as $data) { + if ($data['type']) { + echo('""+'); } +} ?> ""+ @@ -390,9 +357,9 @@ else { "

    " var grid = $("#devices").bootgrid({ @@ -433,3 +400,5 @@ var grid = $("#devices").bootgrid({ diff --git a/html/pages/editsrv.inc.php b/html/pages/editsrv.inc.php index 1c04e4510f..9c56b96d1e 100644 --- a/html/pages/editsrv.inc.php +++ b/html/pages/editsrv.inc.php @@ -1,30 +1,35 @@ '5') { - include 'includes/service-edit.inc.php'; + include "includes/error-no-perm.inc.php"; + +} else { + + $pagetitle[] = "Edit service"; + + if ($_POST['confirm-editsrv']) + { + if ($_SESSION['userlevel'] > "5") + { + include("includes/service-edit.inc.php"); } } - foreach (dbFetchRows('SELECT * FROM `services` AS S, `devices` AS D WHERE S.device_id = D.device_id ORDER BY hostname') as $device) { - $servicesform .= "'; + foreach (dbFetchRows("SELECT * FROM `services` AS S, `devices` AS D WHERE S.device_id = D.device_id ORDER BY hostname") as $device) + { + $servicesform .= ""; } - if ($updated) { - print_message('Service updated!'); - } + if ($updated) { print_message("Service updated!"); } if ($_POST['editsrv'] == 'yes') { - include_once 'includes/print-service-edit.inc.php'; - } - else { - echo " + + require_once "includes/print-service-edit.inc.php"; + + } else { + + echo("

    Delete Service

    @@ -41,6 +46,7 @@ else { -
    "; - }//end if -}//end if + "); + } + +} diff --git a/html/pages/edituser.inc.php b/html/pages/edituser.inc.php index ec2a3f1c9e..6a9a7d2830 100644 --- a/html/pages/edituser.inc.php +++ b/html/pages/edituser.inc.php @@ -1,170 +1,167 @@ "; +echo("
    "); -$pagetitle[] = 'Edit user'; +$pagetitle[] = "Edit user"; -if ($_SESSION['userlevel'] != '10') { - include 'includes/error-no-perm.inc.php'; -} -else { - if ($vars['user_id'] && !$vars['edit']) { - $user_data = dbFetchRow('SELECT * FROM users WHERE user_id = ?', array($vars['user_id'])); - echo '

    '.$user_data['realname']."

    Change...

    "; - // Perform actions if requested - if ($vars['action'] == 'deldevperm') { - if (dbFetchCell('SELECT COUNT(*) FROM devices_perms WHERE `device_id` = ? AND `user_id` = ?', array($vars['device_id'], $vars['user_id']))) { - dbDelete('devices_perms', '`device_id` = ? AND `user_id` = ?', array($vars['device_id'], $vars['user_id'])); - } - } +if ($_SESSION['userlevel'] != '10') { include("includes/error-no-perm.inc.php"); } else +{ + if ($vars['user_id'] && !$vars['edit']) + { + $user_data = dbFetchRow("SELECT * FROM users WHERE user_id = ?", array($vars['user_id'])); + echo("

    " . $user_data['realname'] . "

    Change...

    "); + // Perform actions if requested - if ($vars['action'] == 'adddevperm') { - if (!dbFetchCell('SELECT COUNT(*) FROM devices_perms WHERE `device_id` = ? AND `user_id` = ?', array($vars['device_id'], $vars['user_id']))) { - dbInsert(array('device_id' => $vars['device_id'], 'user_id' => $vars['user_id']), 'devices_perms'); - } - } + if ($vars['action'] == "deldevperm") + { + if (dbFetchCell("SELECT COUNT(*) FROM devices_perms WHERE `device_id` = ? AND `user_id` = ?", array($vars['device_id'] ,$vars['user_id']))) + { + dbDelete('devices_perms', "`device_id` = ? AND `user_id` = ?", array($vars['device_id'], $vars['user_id'])); + } + } + if ($vars['action'] == "adddevperm") + { + if (!dbFetchCell("SELECT COUNT(*) FROM devices_perms WHERE `device_id` = ? AND `user_id` = ?", array($vars['device_id'] ,$vars['user_id']))) + { + dbInsert(array('device_id' => $vars['device_id'], 'user_id' => $vars['user_id']), 'devices_perms'); + } + } + if ($vars['action'] == "delifperm") + { + if (dbFetchCell("SELECT COUNT(*) FROM ports_perms WHERE `port_id` = ? AND `user_id` = ?", array($vars['port_id'], $vars['user_id']))) + { + dbDelete('ports_perms', "`port_id` = ? AND `user_id` = ?", array($vars['port_id'], $vars['user_id'])); + } + } + if ($vars['action'] == "addifperm") + { + if (!dbFetchCell("SELECT COUNT(*) FROM ports_perms WHERE `port_id` = ? AND `user_id` = ?", array($vars['port_id'], $vars['user_id']))) + { + dbInsert(array('port_id' => $vars['port_id'], 'user_id' => $vars['user_id']), 'ports_perms'); + } + } + if ($vars['action'] == "delbillperm") + { + if (dbFetchCell("SELECT COUNT(*) FROM bill_perms WHERE `bill_id` = ? AND `user_id` = ?", array($vars['bill_id'], $vars['user_id']))) + { + dbDelete('bill_perms', "`bill_id` = ? AND `user_id` = ?", array($vars['bill_id'], $vars['user_id'])); + } + } + if ($vars['action'] == "addbillperm") + { + if (!dbFetchCell("SELECT COUNT(*) FROM bill_perms WHERE `bill_id` = ? AND `user_id` = ?", array($vars['bill_id'], $vars['user_id']))) + { + dbInsert(array('bill_id' => $vars['bill_id'], 'user_id' => $vars['user_id']), 'bill_perms'); + } + } - if ($vars['action'] == 'delifperm') { - if (dbFetchCell('SELECT COUNT(*) FROM ports_perms WHERE `port_id` = ? AND `user_id` = ?', array($vars['port_id'], $vars['user_id']))) { - dbDelete('ports_perms', '`port_id` = ? AND `user_id` = ?', array($vars['port_id'], $vars['user_id'])); - } - } + echo('
    +
    '); - if ($vars['action'] == 'addifperm') { - if (!dbFetchCell('SELECT COUNT(*) FROM ports_perms WHERE `port_id` = ? AND `user_id` = ?', array($vars['port_id'], $vars['user_id']))) { - dbInsert(array('port_id' => $vars['port_id'], 'user_id' => $vars['user_id']), 'ports_perms'); - } - } + // Display devices this users has access to + echo("

    Device Access

    "); - if ($vars['action'] == 'delbillperm') { - if (dbFetchCell('SELECT COUNT(*) FROM bill_perms WHERE `bill_id` = ? AND `user_id` = ?', array($vars['bill_id'], $vars['user_id']))) { - dbDelete('bill_perms', '`bill_id` = ? AND `user_id` = ?', array($vars['bill_id'], $vars['user_id'])); - } - } - - if ($vars['action'] == 'addbillperm') { - if (!dbFetchCell('SELECT COUNT(*) FROM bill_perms WHERE `bill_id` = ? AND `user_id` = ?', array($vars['bill_id'], $vars['user_id']))) { - dbInsert(array('bill_id' => $vars['bill_id'], 'user_id' => $vars['user_id']), 'bill_perms'); - } - } - - echo '
    -
    '; - - // Display devices this users has access to - echo '

    Device Access

    '; - - echo "
    + echo("
    - "; + "); - $device_perms = dbFetchRows('SELECT * from devices_perms as P, devices as D WHERE `user_id` = ? AND D.device_id = P.device_id', array($vars['user_id'])); - foreach ($device_perms as $device_perm) { - echo '"; - $access_list[] = $device_perm['device_id']; - $permdone = 'yes'; - } + $device_perms = dbFetchRows("SELECT * from devices_perms as P, devices as D WHERE `user_id` = ? AND D.device_id = P.device_id", array($vars['user_id'])); + foreach ($device_perms as $device_perm) + { + echo(""); + $access_list[] = $device_perm['device_id']; + $permdone = "yes"; + } - echo '
    Device Action
    '.$device_perm['hostname']."
    " . $device_perm['hostname'] . "
    -
    '; + echo(" +
    "); - if (!$permdone) { - echo 'None Configured'; - } + if (!$permdone) { echo("None Configured"); } - // Display devices this user doesn't have access to - echo '

    Grant access to new device

    '; - echo "
    - + // Display devices this user doesn't have access to + echo("

    Grant access to new device

    "); + echo(" +
    - "); - $devices = dbFetchRows('SELECT * FROM `devices` ORDER BY hostname'); - foreach ($devices as $device) { - unset($done); - foreach ($access_list as $ac) { - if ($ac == $device['device_id']) { - $done = 1; - } - } + $devices = dbFetchRows("SELECT * FROM `devices` ORDER BY hostname"); + foreach ($devices as $device) + { + unset($done); + foreach ($access_list as $ac) { if ($ac == $device['device_id']) { $done = 1; } } + if (!$done) + { + echo(""); + } + } - if (!$done) { - echo "'; - } - } - - echo " + echo("
    -
    "; + "); - echo "
    -
    "; - echo '

    Interface Access

    '; + echo("
    +
    "); + echo("

    Interface Access

    "); - $interface_perms = dbFetchRows('SELECT * from ports_perms as P, ports as I, devices as D WHERE `user_id` = ? AND I.port_id = P.port_id AND D.device_id = I.device_id', array($vars['user_id'])); + $interface_perms = dbFetchRows("SELECT * from ports_perms as P, ports as I, devices as D WHERE `user_id` = ? AND I.port_id = P.port_id AND D.device_id = I.device_id", array($vars['user_id'])); - echo "
    + echo("
    - "; - foreach ($interface_perms as $interface_perm) { - echo ' + "); + foreach ($interface_perms as $interface_perm) + { + echo(" - "; - $ipermdone = 'yes'; - } + "); + $ipermdone = "yes"; + } + echo("
    Interface name Action
    - '.$interface_perm['hostname'].' - '.$interface_perm['ifDescr'].''.''.$interface_perm['ifAlias']." + ".$interface_perm['hostname']." - ".$interface_perm['ifDescr']."". + "" . $interface_perm['ifAlias'] . " -    +   
    +
    "); - echo ' -
    '; + if (!$ipermdone) { echo("None Configured"); } - if (!$ipermdone) { - echo 'None Configured'; - } + // Display devices this user doesn't have access to + echo("

    Grant access to new interface

    "); - // Display devices this user doesn't have access to - echo '

    Grant access to new interface

    '; - - echo "
    - + echo(" +
    + echo("
    @@ -179,135 +176,133 @@ else {
    - "; + "); - echo "
    -
    "; - echo '

    Bill Access

    '; + echo("
    +
    "); + echo("

    Bill Access

    "); - $bill_perms = dbFetchRows('SELECT * from bills AS B, bill_perms AS P WHERE P.user_id = ? AND P.bill_id = B.bill_id', array($vars['user_id'])); + $bill_perms = dbFetchRows("SELECT * from bills AS B, bill_perms AS P WHERE P.user_id = ? AND P.bill_id = B.bill_id", array($vars['user_id'])); - echo "
    + echo("
    - "; + "); - foreach ($bill_perms as $bill_perm) { - echo ' + foreach ($bill_perms as $bill_perm) + { + echo(" - "; - $bill_access_list[] = $bill_perm['bill_id']; + "); + $bill_access_list[] = $bill_perm['bill_id']; - $bpermdone = 'yes'; - } + $bpermdone = "yes"; + } - echo '
    Bill name Action
    - '.$bill_perm['bill_name']."   + ".$bill_perm['bill_name']."  
    -
    '; + echo(" +
    "); - if (!$bpermdone) { - echo 'None Configured'; - } + if (!$bpermdone) { echo("None Configured"); } - // Display devices this user doesn't have access to - echo '

    Grant access to new bill

    '; - echo "
    - + // Display devices this user doesn't have access to + echo("

    Grant access to new bill

    "); + echo(" +
    - "); - $bills = dbFetchRows('SELECT * FROM `bills` ORDER BY `bill_name`'); - foreach ($bills as $bill) { - unset($done); - foreach ($bill_access_list as $ac) { - if ($ac == $bill['bill_id']) { - $done = 1; - } - } + $bills = dbFetchRows("SELECT * FROM `bills` ORDER BY `bill_name`"); + foreach ($bills as $bill) + { + unset($done); + foreach ($bill_access_list as $ac) { if ($ac == $bill['bill_id']) { $done = 1; } } + if (!$done) + { + echo(""); + } + } - if (!$done) { - echo "'; - } - } - - echo " + echo("
    -
    "; +
    "); + + } elseif ($vars['user_id'] && $vars['edit']) { + + if($_SESSION['userlevel'] == 11) { + demo_account(); + } else { + + if(!empty($vars['new_level'])) + { + if($vars['can_modify_passwd'] == 'on') { + $vars['can_modify_passwd'] = '1'; + } + update_user($vars['user_id'],$vars['new_realname'],$vars['new_level'],$vars['can_modify_passwd'],$vars['new_email']); + print_message("User has been updated"); } - else if ($vars['user_id'] && $vars['edit']) { - if ($_SESSION['userlevel'] == 11) { - demo_account(); + + if(can_update_users() == '1') { + + $users_details = get_user($vars['user_id']); + if(!empty($users_details)) + { + + if(empty($vars['new_realname'])) + { + $vars['new_realname'] = $users_details['realname']; + } + if(empty($vars['new_level'])) + { + $vars['new_level'] = $users_details['level']; + } + if(empty($vars['can_modify_passwd'])) + { + $vars['can_modify_passwd'] = $users_details['can_modify_passwd']; + } elseif($vars['can_modify_passwd'] == 'on') { + $vars['can_modify_passwd'] = '1'; + } + if(empty($vars['new_email'])) + { + $vars['new_email'] = $users_details['email']; } - else { - if (!empty($vars['new_level'])) { - if ($vars['can_modify_passwd'] == 'on') { - $vars['can_modify_passwd'] = '1'; - } - update_user($vars['user_id'], $vars['new_realname'], $vars['new_level'], $vars['can_modify_passwd'], $vars['new_email']); - print_message('User has been updated'); + if( $config['twofactor'] ) { + if( $vars['twofactorremove'] ) { + if( dbUpdate(array('twofactor'=>''),users,'user_id = ?',array($vars['user_id'])) ) { + echo "
    TwoFactor credentials removed.
    "; + } else { + echo "
    Couldnt remove user's TwoFactor credentials.
    "; } + } + if( $vars['twofactorunlock'] ) { + $twofactor = dbFetchRow("SELECT twofactor FROM users WHERE user_id = ?",array($vars['user_id'])); + $twofactor = json_decode($twofactor['twofactor'],true); + $twofactor['fails'] = 0; + if( dbUpdate(array('twofactor'=>json_encode($twofactor)),users,'user_id = ?',array($vars['user_id'])) ) { + echo "
    User unlocked.
    "; + } else { + echo "
    Couldnt reset user's TwoFactor failures.
    "; + } + } + } - if (can_update_users() == '1') { - $users_details = get_user($vars['user_id']); - if (!empty($users_details)) { - if (empty($vars['new_realname'])) { - $vars['new_realname'] = $users_details['realname']; - } - - if (empty($vars['new_level'])) { - $vars['new_level'] = $users_details['level']; - } - - if (empty($vars['can_modify_passwd'])) { - $vars['can_modify_passwd'] = $users_details['can_modify_passwd']; - } - else if ($vars['can_modify_passwd'] == 'on') { - $vars['can_modify_passwd'] = '1'; - } - - if (empty($vars['new_email'])) { - $vars['new_email'] = $users_details['email']; - } - - if ($config['twofactor']) { - if ($vars['twofactorremove']) { - if (dbUpdate(array('twofactor' => ''), users, 'user_id = ?', array($vars['user_id']))) { - echo "
    TwoFactor credentials removed.
    "; - } - else { - echo "
    Couldnt remove user's TwoFactor credentials.
    "; - } - } - - if ($vars['twofactorunlock']) { - $twofactor = dbFetchRow('SELECT twofactor FROM users WHERE user_id = ?', array($vars['user_id'])); - $twofactor = json_decode($twofactor['twofactor'], true); - $twofactor['fails'] = 0; - if (dbUpdate(array('twofactor' => json_encode($twofactor)), users, 'user_id = ?', array($vars['user_id']))) { - echo "
    User unlocked.
    "; - } - else { - echo "
    Couldnt reset user's TwoFactor failures.
    "; - } - } - } - - echo "
    - + echo(" +
    - +
    @@ -315,7 +310,7 @@ else {
    - +
    @@ -324,22 +319,10 @@ else {
    @@ -349,10 +332,7 @@ else {
    @@ -360,14 +340,14 @@ else {
    - "; - if ($config['twofactor']) { - echo "

    Two-Factor Authentication

    "; - $twofactor = dbFetchRow('SELECT twofactor FROM users WHERE user_id = ?', array($vars['user_id'])); - $twofactor = json_decode($twofactor['twofactor'], true); - if ($twofactor['fails'] >= 3 && (!$config['twofactor_lock'] || (time() - $twofactor['last']) < $config['twofactor_lock'])) { - echo "
    - +
    "); + if( $config['twofactor'] ) { + echo "

    Two-Factor Authentication

    "; + $twofactor = dbFetchRow("SELECT twofactor FROM users WHERE user_id = ?",array($vars['user_id'])); + $twofactor = json_decode($twofactor['twofactor'],true); + if( $twofactor['fails'] >= 3 && (!$config['twofactor_lock'] || (time()-$twofactor['last']) < $config['twofactor_lock']) ) { + echo "
    +
    @@ -375,47 +355,43 @@ else {
    "; - } - - if ($twofactor['key']) { - echo "
    - + } + if( $twofactor['key'] ) { + echo " +
    "; - } - else { - echo '

    No TwoFactor key generated for this user, Nothing to do.

    '; - } - }//end if - } - else { - echo print_error('Error getting user details'); - }//end if - } - else { - echo print_error("Authentication method doesn't support updating users"); - }//end if - }//end if + } else { + echo "

    No TwoFactor key generated for this user, Nothing to do.

    "; + } + } + } else { + echo print_error("Error getting user details"); + } + } else { + echo print_error("Authentication method doesn't support updating users"); } - else { - $user_list = get_userlist(); + } + } else { - echo '

    Select a user to edit

    '; + $user_list = get_userlist(); - echo "
    + echo("

    Select a user to edit

    "); + + echo("
    - +
    @@ -423,8 +399,11 @@ else { /
    - "; - }//end if -}//end if + "); + } -echo '
    '; +} + +echo("
    "); + +?> diff --git a/html/pages/eventlog.inc.php b/html/pages/eventlog.inc.php index 2ac41ec91b..4e1cad13d2 100644 --- a/html/pages/eventlog.inc.php +++ b/html/pages/eventlog.inc.php @@ -1,15 +1,16 @@ = '10') { - dbQuery('TRUNCATE TABLE `eventlog`'); - print_message('Event log truncated'); +if ($vars['action'] == "expunge" && $_SESSION['userlevel'] >= '10') +{ + dbQuery("TRUNCATE TABLE `eventlog`"); + print_message("Event log truncated"); } -$pagetitle[] = 'Eventlog'; +$pagetitle[] = "Eventlog"; print_optionbar_start(); @@ -23,17 +24,15 @@ print_optionbar_start();
    @@ -41,7 +40,9 @@ print_optionbar_start(); diff --git a/html/pages/front/default.php b/html/pages/front/default.php index b69f7f97b1..7b17f08a45 100644 --- a/html/pages/front/default.php +++ b/html/pages/front/default.php @@ -1,180 +1,174 @@ +function generate_front_box ($frontbox_class, $content) +{ +echo("
    $content -
    "; + "); +} -}//end generate_front_box() - - -echo ' +echo('
    -'; +'); if ($config['vertical_summary']) { - echo '
    '; + echo('
    '); } -else { - echo '
    '; +else +{ + echo('
    '); } - -echo ' +echo('
    -'; +'); -echo '
    '; +echo('
    '); -echo '
    '; +echo('
    '); $count_boxes = 0; // Device down boxes -if ($_SESSION['userlevel'] >= '10') { - $sql = "SELECT * FROM `devices` WHERE `status` = '0' AND `ignore` = '0' LIMIT ".$config['front_page_down_box_limit']; +if ($_SESSION['userlevel'] >= '10') +{ + $sql = "SELECT * FROM `devices` WHERE `status` = '0' AND `ignore` = '0' LIMIT ".$config['front_page_down_box_limit']; +} else { + $sql = "SELECT * FROM `devices` AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' AND D.status = '0' AND D.ignore = '0' LIMIT".$config['front_page_down_box_limit']; } -else { - $sql = "SELECT * FROM `devices` AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '".$_SESSION['user_id']."' AND D.status = '0' AND D.ignore = '0' LIMIT".$config['front_page_down_box_limit']; -} - -foreach (dbFetchRows($sql) as $device) { - generate_front_box( - 'device-down', - generate_device_link($device, shorthost($device['hostname'])).'
    +foreach (dbFetchRows($sql) as $device) +{ + generate_front_box("device-down", generate_device_link($device, shorthost($device['hostname']))."
    Device Down
    - '.truncate($device['location'], 20).'' - ); - ++$count_boxes; + ".truncate($device['location'], 20).""); + ++$count_boxes; } -if ($_SESSION['userlevel'] >= '10') { - $sql = "SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0' AND `D`.`status` = '1' LIMIT ".$config['front_page_down_box_limit']; -} -else { - $sql = "SELECT * FROM `ports` AS I, `devices` AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '".$_SESSION['user_id']."' AND I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0' AND `D`.`status` = '1' LIMIT ".$config['front_page_down_box_limit']; +if ($_SESSION['userlevel'] >= '10') +{ + $sql = "SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0' AND `D`.`status` = '1' LIMIT ".$config['front_page_down_box_limit']; +} else { + $sql = "SELECT * FROM `ports` AS I, `devices` AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' AND I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0' AND `D`.`status` = '1' LIMIT ".$config['front_page_down_box_limit']; } // These things need to become more generic, and more manageable across different frontpages... rewrite inc :> + // Port down boxes -if ($config['warn']['ifdown']) { - foreach (dbFetchRows($sql) as $interface) { - if (!$interface['deleted']) { - $interface = ifNameDescr($interface); - generate_front_box( - 'port-down', - generate_device_link($interface, shorthost($interface['hostname']))."
    +if ($config['warn']['ifdown']) +{ + foreach (dbFetchRows($sql) as $interface) + { + if (!$interface['deleted']) + { + $interface = ifNameDescr($interface); + generate_front_box("port-down", generate_device_link($interface, shorthost($interface['hostname']))."
    Port Down
    - - ".generate_port_link($interface, truncate(makeshortif($interface['label']), 13, '')).'
    - '.($interface['ifAlias'] ? ''.truncate($interface['ifAlias'], 20, '').'' : '') - ); - ++$count_boxes; - } + + ".generate_port_link($interface, truncate(makeshortif($interface['label']),13,''))."
    + " . ($interface['ifAlias'] ? ''.truncate($interface['ifAlias'], 20, '').'' : '')); + ++$count_boxes; } + } } -/* - FIXME service permissions? seem nonexisting now.. */ +/* FIXME service permissions? seem nonexisting now.. */ // Service down boxes -if ($_SESSION['userlevel'] >= '10') { - $sql = "SELECT * FROM `services` AS S, `devices` AS D WHERE S.device_id = D.device_id AND service_status = 'down' AND D.ignore = '0' AND S.service_ignore = '0' AND `D`.`status` = '1' LIMIT ".$config['front_page_down_box_limit']; - $param[] = ''; +if ($_SESSION['userlevel'] >= '10') +{ + $sql = "SELECT * FROM `services` AS S, `devices` AS D WHERE S.device_id = D.device_id AND service_status = 'down' AND D.ignore = '0' AND S.service_ignore = '0' AND `D`.`status` = '1' LIMIT ".$config['front_page_down_box_limit']; + $param[] = ''; } -else { - $sql = "SELECT * FROM services AS S, devices AS D, devices_perms AS P WHERE P.`user_id` = ? AND P.`device_id` = D.`device_id` AND S.`device_id` = D.`device_id` AND S.`service_ignore` = '0' AND S.`service_disabled` = '0' AND S.`service_status` = '0' AND `D`.`status` = '1' LIMIT ".$config['front_page_down_box_limit']; - $param[] = $_SESSION['user_id']; +else +{ + $sql = "SELECT * FROM services AS S, devices AS D, devices_perms AS P WHERE P.`user_id` = ? AND P.`device_id` = D.`device_id` AND S.`device_id` = D.`device_id` AND S.`service_ignore` = '0' AND S.`service_disabled` = '0' AND S.`service_status` = '0' AND `D`.`status` = '1' LIMIT ".$config['front_page_down_box_limit']; + $param[] = $_SESSION['user_id']; } - -foreach (dbFetchRows($sql, $param) as $service) { - generate_front_box( - 'service-down', - generate_device_link($service, shorthost($service['hostname'])).'
    +foreach (dbFetchRows($sql,$param) as $service) +{ + generate_front_box("service-down", generate_device_link($service, shorthost($service['hostname']))."
    Service Down - '.$service['service_type'].'
    - '.truncate($interface['ifAlias'], 20).'' - ); - ++$count_boxes; + ".$service['service_type']."
    + ".truncate($interface['ifAlias'], 20).""); + ++$count_boxes; } // BGP neighbour down boxes -if (isset($config['enable_bgp']) && $config['enable_bgp']) { - if ($_SESSION['userlevel'] >= '10') { - $sql = "SELECT * FROM `devices` AS D, bgpPeers AS B WHERE bgpPeerAdminStatus != 'start' AND bgpPeerState != 'established' AND bgpPeerState != '' AND B.device_id = D.device_id AND D.ignore = 0 AND `D`.`status` = '1' LIMIT ".$config['front_page_down_box_limit']; - } - else { - $sql = "SELECT * FROM `devices` AS D, bgpPeers AS B, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '".$_SESSION['user_id']."' AND bgpPeerAdminStatus != 'start' AND bgpPeerState != 'established' AND bgpPeerState != '' AND B.device_id = D.device_id AND D.ignore = 0 AND `D`.`status` = '1' LIMIT ".$config['front_page_down_box_limit']; - } - - foreach (dbFetchRows($sql) as $peer) { - generate_front_box( - 'bgp-down', - generate_device_link($peer, shorthost($peer['hostname']))."
    +if (isset($config['enable_bgp']) && $config['enable_bgp']) +{ + if ($_SESSION['userlevel'] >= '10') + { + $sql = "SELECT * FROM `devices` AS D, bgpPeers AS B WHERE bgpPeerAdminStatus != 'start' AND bgpPeerState != 'established' AND bgpPeerState != '' AND B.device_id = D.device_id AND D.ignore = 0 AND `D`.`status` = '1' LIMIT ".$config['front_page_down_box_limit']; + } else { + $sql = "SELECT * FROM `devices` AS D, bgpPeers AS B, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' AND bgpPeerAdminStatus != 'start' AND bgpPeerState != 'established' AND bgpPeerState != '' AND B.device_id = D.device_id AND D.ignore = 0 AND `D`.`status` = '1' LIMIT ".$config['front_page_down_box_limit']; + } + foreach (dbFetchRows($sql) as $peer) + { + generate_front_box("bgp-down", generate_device_link($peer, shorthost($peer['hostname']))."
    BGP Down - ".$peer['bgpPeerIdentifier'].'
    - AS'.truncate($peer['bgpPeerRemoteAs'].' '.$peer['astext'], 14, '').'' - ); - ++$count_boxes; - } + ".$peer['bgpPeerIdentifier']."
    + AS".truncate($peer['bgpPeerRemoteAs']." ".$peer['astext'], 14, "").""); + ++$count_boxes; + } } // Device rebooted boxes -if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== false && $config['uptime_warning'] > 0) { - if ($_SESSION['userlevel'] >= '10') { - $sql = "SELECT * FROM `devices` AS D WHERE D.status = '1' AND D.uptime > 0 AND D.uptime < '".$config['uptime_warning']."' AND D.ignore = 0 LIMIT ".$config['front_page_down_box_limit']; - } - else { - $sql = "SELECT * FROM `devices` AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '".$_SESSION['user_id']."' AND D.status = '1' AND D.uptime > 0 AND D.uptime < '".$config['uptime_warning']."' AND D.ignore = 0 LIMIT ".$config['front_page_down_box_limit']; - } +if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== FALSE && $config['uptime_warning'] > 0) +{ + if ($_SESSION['userlevel'] >= '10') + { + $sql = "SELECT * FROM `devices` AS D WHERE D.status = '1' AND D.uptime > 0 AND D.uptime < '" . $config['uptime_warning'] . "' AND D.ignore = 0 LIMIT ".$config['front_page_down_box_limit']; + } else { + $sql = "SELECT * FROM `devices` AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' AND D.status = '1' AND D.uptime > 0 AND D.uptime < '" . + $config['uptime_warning'] . "' AND D.ignore = 0 LIMIT ".$config['front_page_down_box_limit']; + } - foreach (dbFetchRows($sql) as $device) { - generate_front_box( - 'device-rebooted', - generate_device_link($device, shorthost($device['hostname'])).'
    + foreach (dbFetchRows($sql) as $device) + { + generate_front_box("device-rebooted", generate_device_link($device, shorthost($device['hostname']))."
    Device Rebooted
    - '.formatUptime($device['uptime'], 'short').'' - ); - ++$count_boxes; - } + ".formatUptime($device['uptime'], 'short').""); + ++$count_boxes; + } } - if ($count_boxes == 0) { - echo "
    Nothing here yet

    This is where status notifications about devices and services would normally go. You might have none - because you run such a great network, or perhaps you've just started using ".$config['project_name'].". If you're new to ".$config['project_name'].', you might - want to start by adding one or more devices in the Devices menu.

    '; + echo("
    Nothing here yet

    This is where status notifications about devices and services would normally go. You might have none + because you run such a great network, or perhaps you've just started using ".$config['project_name'].". If you're new to ".$config['project_name'].", you might + want to start by adding one or more devices in the Devices menu.

    "); } - -echo '
    '; -echo '
    '; -echo '
    '; -echo ' +echo('
    '); +echo('
    '); +echo('
    '); +echo('
    -'; +'); -if ($config['vertical_summary']) { - echo '
    '; - include_once 'includes/device-summary-vert.inc.php'; +if ($config['vertical_summary']) +{ + echo('
    '); + include_once("includes/device-summary-vert.inc.php"); } -else { - echo '
    '; - include_once 'includes/device-summary-horiz.inc.php'; +else +{ + echo('
    '); + include_once("includes/device-summary-horiz.inc.php"); } -echo ' +echo('
    -'; +'); -if ($config['enable_syslog']) { - $sql = "SELECT *, DATE_FORMAT(timestamp, '".$config['dateformat']['mysql']['compact']."') AS date from syslog ORDER BY timestamp DESC LIMIT 20"; - $query = mysql_query($sql); +if ($config['enable_syslog']) +{ - echo '
    + $sql = "SELECT *, DATE_FORMAT(timestamp, '".$config['dateformat']['mysql']['compact']."') AS date from syslog ORDER BY timestamp DESC LIMIT 20"; + $query = mysql_query($sql); + + echo('
      @@ -186,34 +180,35 @@ if ($config['enable_syslog']) {
    Syslog entries
    -
    '; +
    '); - foreach (dbFetchRows($sql) as $entry) { - $entry = array_merge($entry, device_by_id_cache($entry['device_id'])); + foreach (dbFetchRows($sql) as $entry) + { + $entry = array_merge($entry, device_by_id_cache($entry['device_id'])); - include 'includes/print-syslog.inc.php'; - } + include("includes/print-syslog.inc.php"); + } + echo("
    "); + echo(""); + echo(""); + echo(""); + echo(""); - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; -} -else { - if ($_SESSION['userlevel'] >= '10') { - $query = "SELECT *,DATE_FORMAT(datetime, '".$config['dateformat']['mysql']['compact']."') as humandate FROM `eventlog` ORDER BY `datetime` DESC LIMIT 0,15"; - $alertquery = 'SELECT devices.device_id,name,state,time_logged FROM alert_log LEFT JOIN devices ON alert_log.device_id=devices.device_id LEFT JOIN alert_rules ON alert_log.rule_id=alert_rules.id ORDER BY `time_logged` DESC LIMIT 0,15'; - } - else { - $query = "SELECT *,DATE_FORMAT(datetime, '".$config['dateformat']['mysql']['compact']."') as humandate FROM `eventlog` AS E, devices_perms AS P WHERE E.host = P.device_id AND P.user_id = ".$_SESSION['user_id'].' ORDER BY `datetime` DESC LIMIT 0,15'; - $alertquery = 'SELECT devices.device_id,name,state,time_logged FROM alert_log LEFT JOIN devices ON alert_log.device_id=devices.device_id LEFT JOIN alert_rules ON alert_log.rule_id=alert_rules.id RIGHT JOIN devices_perms ON alert_log.device_id = devices_perms.device_id AND devices_perms.user_id = '.$_SESSION['user_id'].' ORDER BY `time_logged` DESC LIMIT 0,15'; - } +} else { - $data = mysql_query($query); - $alertdata = mysql_query($alertquery); + if ($_SESSION['userlevel'] >= '10') + { + $query = "SELECT *,DATE_FORMAT(datetime, '".$config['dateformat']['mysql']['compact']."') as humandate FROM `eventlog` ORDER BY `datetime` DESC LIMIT 0,15"; + $alertquery = "SELECT devices.device_id,name,state,time_logged FROM alert_log LEFT JOIN devices ON alert_log.device_id=devices.device_id LEFT JOIN alert_rules ON alert_log.rule_id=alert_rules.id ORDER BY `time_logged` DESC LIMIT 0,15"; + } else { + $query = "SELECT *,DATE_FORMAT(datetime, '".$config['dateformat']['mysql']['compact']."') as humandate FROM `eventlog` AS E, devices_perms AS P WHERE E.host = P.device_id AND P.user_id = " . $_SESSION['user_id'] . " ORDER BY `datetime` DESC LIMIT 0,15"; + $alertquery = "SELECT devices.device_id,name,state,time_logged FROM alert_log LEFT JOIN devices ON alert_log.device_id=devices.device_id LEFT JOIN alert_rules ON alert_log.rule_id=alert_rules.id RIGHT JOIN devices_perms ON alert_log.device_id = devices_perms.device_id AND devices_perms.user_id = " . $_SESSION['user_id'] . " ORDER BY `time_logged` DESC LIMIT 0,15"; + } - echo '
    + $data = mysql_query($query); + $alertdata = mysql_query($alertquery); + + echo('
      @@ -225,13 +220,13 @@ else {
    Alertlog entries
    - '; +
    '); - foreach (dbFetchRows($alertquery) as $alert_entry) { - include 'includes/print-alerts.inc.php'; - } - - echo '
    + foreach (dbFetchRows($alertquery) as $alert_entry) + { + include("includes/print-alerts.inc.php"); + } + echo('
    @@ -239,21 +234,24 @@ else {
    Eventlog entries
    - '; +
    '); - foreach (dbFetchRows($query) as $entry) { - include 'includes/print-event.inc.php'; - } + foreach (dbFetchRows($query) as $entry) + { + include("includes/print-event.inc.php"); + } - echo '
    '; - echo '
    '; - echo '
    '; - echo '
    '; - echo ''; -}//end if + echo(""); + echo(""); + echo(""); + echo(""); + echo(""); +} -echo ''; +echo(""); -echo ' +echo(' -'; +'); + +?> diff --git a/html/pages/front/demo.php b/html/pages/front/demo.php index 6478a566b8..1000fbca24 100644 --- a/html/pages/front/demo.php +++ b/html/pages/front/demo.php @@ -4,55 +4,56 @@ '; +echo(""); -$dev_list = array( - '6' => 'Central Fileserver', - '7' => 'NE61 Fileserver', - '34' => 'DE56 Fileserver', -); +$dev_list = array('6' => 'Central Fileserver', + '7' => 'NE61 Fileserver', + '34' => 'DE56 Fileserver'); -foreach ($dev_list as $device_id => $descr) { - echo ''; -}//end foreach + echo("
    "); + $graph_array['type'] = "device_diskio"; + print_graph_popup($graph_array); + echo("
    "); -echo '
    '; - echo "
    ".$descr.'
    '; - $graph_array['height'] = '100'; - $graph_array['width'] = '310'; - $graph_array['to'] = $config['time']['now']; - $graph_array['device'] = $device_id; - $graph_array['type'] = 'device_bits'; - $graph_array['from'] = $config['time']['day']; - $graph_array['legend'] = 'no'; - $graph_array['popup_title'] = $descr; - // $graph_array['link'] = generate_device_link($device_id); - print_graph_popup($graph_array); +foreach ($dev_list as $device_id => $descr) +{ - $graph_array['height'] = '50'; - $graph_array['width'] = '180'; + echo("
    "); + echo("
    ".$descr."
    "); + $graph_array['height'] = "100"; + $graph_array['width'] = "310"; + $graph_array['to'] = $config['time']['now']; + $graph_array['device'] = $device_id; + $graph_array['type'] = "device_bits"; + $graph_array['from'] = $config['time']['day']; + $graph_array['legend'] = "no"; + $graph_array['popup_title'] = $descr; +# $graph_array['link'] = generate_device_link($device_id); + print_graph_popup($graph_array); - echo "
    "; - $graph_array['type'] = 'device_ucd_memory'; - print_graph_popup($graph_array); - echo '
    '; + $graph_array['height'] = "50"; + $graph_array['width'] = "180"; - echo "
    "; - $graph_array['type'] = 'device_processor'; - print_graph_popup($graph_array); - echo '
    '; + echo("
    "); + $graph_array['type'] = "device_ucd_memory"; + print_graph_popup($graph_array); + echo("
    "); - echo "
    "; - $graph_array['type'] = 'device_storage'; - print_graph_popup($graph_array); - echo '
    '; + echo("
    "); + $graph_array['type'] = "device_processor"; + print_graph_popup($graph_array); + echo("
    "); - echo "
    "; - $graph_array['type'] = 'device_diskio'; - print_graph_popup($graph_array); - echo '
    '; + echo("
    "); + $graph_array['type'] = "device_storage"; + print_graph_popup($graph_array); + echo("
    "); - echo '
    '; + echo(""); + +} + +echo(""); ?> @@ -61,105 +62,115 @@ echo ''; '0' AND A.attrib_value < '86400'"; -foreach (dbFetchRows($sql) as $device) { - unset($already); - $i = 0; - while ($i <= count($nodes)) { - $thisnode = $device['device_id']; - if ($nodes[$i] == $thisnode) { - $already = 'yes'; - } - - $i++; - } - - if (!$already) { - $nodes[] = $device['device_id']; +foreach (dbFetchRows($sql) as $device) +{ + unset($already); + $i = 0; + while ($i <= count($nodes)) { + $thisnode = $device['device_id']; + if ($nodes[$i] == $thisnode) { + $already = "yes"; } + $i++; + } + if (!$already) { $nodes[] = $device['device_id']; } } $sql = "SELECT * FROM `devices` WHERE `status` = '0' AND `ignore` = '0'"; -foreach (dbFetchRows($sql) as $device) { - if (device_permitted($device['device_id'])) { - echo "
    - ".generate_device_link($device, shorthost($device['hostname']))."
    - Device Down
    - ".truncate($device['location'], 35).' -
    '; - } +foreach (dbFetchRows($sql) as $device) +{ + if (device_permitted($device['device_id'])) { + echo("
    + ".generate_device_link($device, shorthost($device['hostname']))."
    + Device Down
    + ".truncate($device['location'], 35)." +
    "); + } } -if ($config['warn']['ifdown']) { - $sql = "SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0'"; - foreach (dbFetchRows($sql) as $interface) { - if (port_permitted($interface['port_id'])) { - echo "
    - ".generate_device_link($interface, shorthost($interface['hostname']))."
    - Port Down
    - ".generate_port_link($interface, makeshortif($interface['ifDescr'])).'
    - '.truncate($interface['ifAlias'], 15).' -
    '; - } +if ($config['warn']['ifdown']) +{ + $sql = "SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0'"; + foreach (dbFetchRows($sql) as $interface) + { + if (port_permitted($interface['port_id'])) + { + echo("
    + ".generate_device_link($interface, shorthost($interface['hostname']))."
    + Port Down
    + ".generate_port_link($interface, makeshortif($interface['ifDescr']))."
    + ".truncate($interface['ifAlias'], 15)." +
    "); } + } } $sql = "SELECT * FROM `services` AS S, `devices` AS D WHERE S.device_id = D.device_id AND service_status = 'down' AND D.ignore = '0' AND S.service_ignore = '0'"; -foreach (dbFetchRows($sql) as $service) { - if (device_permitted($service['device_id'])) { - echo "
    - ".generate_device_link($service, shorthost($service['hostname']))."
    - Service Down
    - ".$service['service_type'].'
    - '.truncate($interface['ifAlias'], 15).' -
    '; - } +foreach (dbFetchRows($sql) as $service) +{ + if (device_permitted($service['device_id'])) + { + echo("
    + ".generate_device_link($service, shorthost($service['hostname']))."
    + Service Down
    + ".$service['service_type']."
    + ".truncate($interface['ifAlias'], 15)." +
    "); + } } $sql = "SELECT * FROM `devices` AS D, bgpPeers AS B WHERE bgpPeerAdminStatus = 'start' AND bgpPeerState != 'established' AND B.device_id = D.device_id"; -foreach (dbFetchRows($sql) as $peer) { - if (device_permitted($peer['device_id'])) { - echo "
    - ".generate_device_link($peer, shorthost($peer['hostname']))."
    - BGP Down
    - ".$peer['bgpPeerIdentifier'].'
    - AS'.$peer['bgpPeerRemoteAs'].' '.truncate($peer['astext'], 10).' -
    '; - } +foreach (dbFetchRows($sql) as $peer) +{ + if (device_permitted($peer['device_id'])) + { + echo("
    + ".generate_device_link($peer, shorthost($peer['hostname']))."
    + BGP Down
    + ".$peer['bgpPeerIdentifier']."
    + AS".$peer['bgpPeerRemoteAs']." ".truncate($peer['astext'], 10)." +
    "); + } } -if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== false && $config['uptime_warning'] > 0) { - $sql = "SELECT * FROM devices_attribs AS A, `devices` AS D WHERE - A.attrib_value < '".$config['uptime_warning']."' AND A.attrib_type = 'uptime' AND A.device_id = D.device_id AND ignore = '0' AND disabled = '0'"; - foreach (dbFetchRows($sql) as $device) { - if (device_permitted($device['device_id']) && $device['attrib_value'] < $config['uptime_warning'] && $device['attrib_type'] == 'uptime') { - echo "
    - ".generate_device_link($device, shorthost($device['hostname']))."
    - Device
    Rebooted

    - ".formatUptime($device['attrib_value']).' -
    '; - } +if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== FALSE && $config['uptime_warning'] > 0) +{ + $sql = "SELECT * FROM devices_attribs AS A, `devices` AS D WHERE + A.attrib_value < '" . $config['uptime_warning'] . "' AND A.attrib_type = 'uptime' AND A.device_id = D.device_id AND ignore = '0' AND disabled = '0'"; + foreach (dbFetchRows($sql) as $device) + { + if (device_permitted($device['device_id']) && $device['attrib_value'] < $config['uptime_warning'] && $device['attrib_type'] == "uptime") + { + echo("
    + ".generate_device_link($device, shorthost($device['hostname']))."
    + Device
    Rebooted

    + ".formatUptime($device['attrib_value'])." +
    "); } + } } -echo " -
    $errorboxes
    +echo(" +
    $errorboxes
    -

    Recent Syslog Messages

    - "; +

    Recent Syslog Messages

    +"); $sql = "SELECT *, DATE_FORMAT(timestamp, '".$config['dateformat']['mysql']['compact']."') AS date from `syslog` ORDER BY seq DESC LIMIT 20"; -echo ''; -foreach (dbFetchRows($sql) as $entry) { - $entry = array_merge($entry, device_by_id_cache($entry['device_id'])); +echo("
    "); +foreach (dbFetchRows($sql) as $entry) +{ + $entry = array_merge($entry, device_by_id_cache($entry['device_id'])); - include 'includes/print-syslog.inc.php'; + include("includes/print-syslog.inc.php"); } -echo '
    '; +echo(""); ?> diff --git a/html/pages/front/example2.php b/html/pages/front/example2.php index e5898ac073..717ee75184 100644 --- a/html/pages/front/example2.php +++ b/html/pages/front/example2.php @@ -4,141 +4,173 @@
    Devices with Alerts
    Host
    Int
    Srv
    +# ?> '0' AND A.attrib_value < '86400'"; -foreach (dbFetchRows($sql) as $device) { - unset($already); - $i = 0; - while ($i <= count($nodes)) { - $thisnode = $device['device_id']; - if ($nodes[$i] == $thisnode) { - $already = 'yes'; - } - - $i++; - } - - if (!$already) { - $nodes[] = $device['device_id']; +foreach (dbFetchRows($sql) as $device) +{ + unset($already); + $i = 0; + while ($i <= count($nodes)) + { + $thisnode = $device['device_id']; + if ($nodes[$i] == $thisnode) + { + $already = "yes"; } + $i++; + } + if (!$already) { $nodes[] = $device['device_id']; } } $sql = "SELECT * FROM `devices` WHERE `status` = '0' AND `ignore` = '0'"; -foreach (dbFetchRows($sql) as $device) { - echo "
    -
    ".generate_device_link($device, shorthost($device['hostname']))."
    - Device Down - ".truncate($device['location'], 20).' -
    '; +foreach (dbFetchRows($sql) as $device) +{ + echo("
    +
    ".generate_device_link($device, shorthost($device['hostname']))."
    + Device Down + ".truncate($device['location'], 20)." +
    "); + } $sql = "SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0'"; -foreach (dbFetchRows($sql) as $interface) { - echo "
    -
    ".generate_device_link($interface, shorthost($interface['hostname']))."
    - Port Down - ".generate_port_link($interface, makeshortif($interface['ifDescr'])).'
    - '.truncate($interface['ifAlias'], 20).' -
    '; +foreach (dbFetchRows($sql) as $interface) +{ + echo("
    +
    ".generate_device_link($interface, shorthost($interface['hostname']))."
    + Port Down + ".generate_port_link($interface, makeshortif($interface['ifDescr']))."
    + ".truncate($interface['ifAlias'], 20)." +
    "); + } $sql = "SELECT * FROM `services` AS S, `devices` AS D WHERE S.device_id = D.device_id AND service_status = 'down' AND D.ignore = '0' AND S.service_ignore = '0'"; -foreach (dbFetchRows($sql) as $service) { - echo "
    -
    ".generate_device_link($service, shorthost($service['hostname']))."
    - Service Down - ".$service['service_type'].'
    - '.truncate($interface['ifAlias'], 20).' -
    '; +foreach (dbFetchRows($sql) as $service) +{ + echo("
    +
    ".generate_device_link($service, shorthost($service['hostname']))."
    + Service Down + ".$service['service_type']."
    + ".truncate($interface['ifAlias'], 20)." +
    "); + } $sql = "SELECT * FROM `devices` AS D, bgpPeers AS B WHERE bgpPeerState != 'established' AND B.device_id = D.device_id"; -foreach (dbFetchRows($sql) as $peer) { - echo "
    -
    ".generate_device_link($peer, shorthost($peer['hostname']))."
    - BGP Down - ".$peer['bgpPeerIdentifier'].'
    - AS'.$peer['bgpPeerRemoteAs'].' '.truncate($peer['astext'], 10).' -
    '; +foreach (dbFetchRows($sql) as $peer) +{ + echo("
    +
    ".generate_device_link($peer, shorthost($peer['hostname']))."
    + BGP Down + ".$peer['bgpPeerIdentifier']."
    + AS".$peer['bgpPeerRemoteAs']." ".truncate($peer['astext'], 10)." +
    "); + } -if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== false && $config['uptime_warning'] > 0) { - $sql = "SELECT * FROM `devices` AS D, devices_attribs AS A WHERE A.device_id = D.device_id AND A.attrib_type = 'uptime' AND A.attrib_value < '".$config['uptime_warning']."'"; - foreach (dbFetchRows($sql) as $device) { - echo "
    -
    ".generate_device_link($device, shorthost($device['hostname']))."
    - Device
    Rebooted

    - ".formatUptime($device['attrib_value']).' -
    '; - } +if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== FALSE && $config['uptime_warning'] > 0) +{ + $sql = "SELECT * FROM `devices` AS D, devices_attribs AS A WHERE A.device_id = D.device_id AND A.attrib_type = 'uptime' AND A.attrib_value < '" . $config['uptime_warning'] . "'"; + foreach (dbFetchRows($sql) as $device) + { + echo("
    +
    ".generate_device_link($device, shorthost($device['hostname']))."
    + Device
    Rebooted

    + ".formatUptime($device['attrib_value'])." +
    "); + } } -echo " +echo(" -
    $errorboxes
    +
    $errorboxes
    -

    Recent Syslog Messages

    +

    Recent Syslog Messages

    - "; +"); $sql = "SELECT *, DATE_FORMAT(timestamp, '".$config['dateformat']['mysql']['compact']."') AS date from syslog ORDER BY timestamp DESC LIMIT 20"; -echo '
    Devices with Alerts
    Host
    Int
    Srv
    '; -foreach (dbFetchRows($sql) as $entry) { - include 'includes/print-syslog.inc.php'; +echo("
    "); +foreach (dbFetchRows($sql) as $entry) +{ + include("includes/print-syslog.inc.php"); } +echo("
    "); -echo ''; +echo("
    -echo '
    - - - '; + + "); // this stuff can be customised to show whatever you want.... -if ($_SESSION['userlevel'] >= '5') { - $sql = "SELECT * FROM ports AS I, devices AS D WHERE `ifAlias` like 'L2TP: %' AND I.device_id = D.device_id AND D.hostname LIKE '%"; - $sql .= $config['mydomain']."' ORDER BY I.ifAlias"; - unset($seperator); - foreach (dbFetchRows($sql) as $interface) { - $ports['l2tp'] .= $seperator.$interface['port_id']; - $seperator = ','; - } - $sql = "SELECT * FROM ports AS I, devices AS D WHERE `ifAlias` like 'Transit: %' AND I.device_id = D.device_id AND D.hostname LIKE '%"; - $sql .= $config['mydomain']."' ORDER BY I.ifAlias"; - unset($seperator); - foreach (dbFetchRows($sql) as $interface) { - $ports['transit'] .= $seperator.$interface['port_id']; - $seperator = ','; - } +if ($_SESSION['userlevel'] >= '5') +{ + $sql = "SELECT * FROM ports AS I, devices AS D WHERE `ifAlias` like 'L2TP: %' AND I.device_id = D.device_id AND D.hostname LIKE '%"; + $sql .= $config['mydomain'] . "' ORDER BY I.ifAlias"; + unset ($seperator); + foreach (dbFetchRows($sql) as $interface) + { + $ports['l2tp'] .= $seperator . $interface['port_id']; + $seperator = ","; + } - $sql = "SELECT * FROM ports AS I, devices AS D WHERE `ifAlias` like 'Server: thlon-pbx%' AND I.device_id = D.device_id AND D.hostname LIKE '%"; - $sql .= $config['mydomain']."' ORDER BY I.ifAlias"; - unset($seperator); - foreach (dbFetchRows($sql) as $interface) { - $ports['voip'] .= $seperator.$interface['port_id']; - $seperator = ','; - } + $sql = "SELECT * FROM ports AS I, devices AS D WHERE `ifAlias` like 'Transit: %' AND I.device_id = D.device_id AND D.hostname LIKE '%"; + $sql .= $config['mydomain'] . "' ORDER BY I.ifAlias"; + unset ($seperator); + foreach (dbFetchRows($sql) as $interface) + { + $ports['transit'] .= $seperator . $interface['port_id']; + $seperator = ","; + } - if ($ports['transit']) { - echo "', CENTER, LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 250);\" onmouseout=\"return nd();\" >"."
    Internet Transit
    "."
    "; - } + $sql = "SELECT * FROM ports AS I, devices AS D WHERE `ifAlias` like 'Server: thlon-pbx%' AND I.device_id = D.device_id AND D.hostname LIKE '%"; + $sql .= $config['mydomain'] . "' ORDER BY I.ifAlias"; + unset ($seperator); + foreach (dbFetchRows($sql) as $interface) + { + $ports['voip'] .= $seperator . $interface['port_id']; + $seperator = ","; + } - if ($ports['l2tp']) { - echo "', LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 250);\" onmouseout=\"return nd();\" >"."
    L2TP ADSL
    "."
    "; - } + if ($ports['transit']) + { + echo("', CENTER, LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 250);\" onmouseout=\"return nd();\" >". + "
    Internet Transit
    ". + "
    "); + } - if ($ports['voip']) { - echo "', LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 250);\" onmouseout=\"return nd();\" >"."
    VoIP to PSTN
    "."
    "; - } -}//end if + if ($ports['l2tp']) + { + echo("', LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 250);\" onmouseout=\"return nd();\" >". + "
    L2TP ADSL
    ". + "
    "); + } + + if ($ports['voip']) + { + echo("', LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 250);\" onmouseout=\"return nd();\" >". + "
    VoIP to PSTN
    ". + "
    "); + } + +} // END VOSTRON + ?> diff --git a/html/pages/front/globe.php b/html/pages/front/globe.php index 9884b402fa..75a5917c70 100644 --- a/html/pages/front/globe.php +++ b/html/pages/front/globe.php @@ -4,17 +4,16 @@ * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ + * along with this program. If not, see . */ -/* +/** * Custom Frontpage * @author f0o * @copyright 2014 f0o, LibreNMS @@ -26,111 +25,107 @@ ?> -
    -
    -
    -
    -
    -
    -
    -
    '; - include_once("includes/device-summary-vert.inc.php"); -echo '
    -
    -
    -
    '; - include_once("includes/front/boxes.inc.php"); -echo '
    -
    -
    -
    -
    -
    -
    '; - $device['device_id'] = '-1'; - require_once('includes/print-alerts.php'); - unset($device['device_id']); -echo '
    -
    +
    +
    +
    +
    +
    +
    +
    +
    '; + include_once("includes/device-summary-vert.inc.php"); +echo '
    +
    +
    +
    '; + include_once("includes/front/boxes.inc.php"); +echo '
    +
    +
    +
    +
    +
    +
    '; + $device['device_id'] = '-1'; + require_once('includes/print-alerts.php'); + unset($device['device_id']); +echo '
    +
    '; //From default.php - This code is not part of above license. if ($config['enable_syslog']) { - $sql = "SELECT *, DATE_FORMAT(timestamp, '".$config['dateformat']['mysql']['compact']."') AS date from syslog ORDER BY seq DESC LIMIT 20"; - $query = mysql_query($sql); - echo('
    +$sql = "SELECT *, DATE_FORMAT(timestamp, '".$config['dateformat']['mysql']['compact']."') AS date from syslog ORDER BY seq DESC LIMIT 20"; +$query = mysql_query($sql); +echo('
      @@ -144,28 +139,29 @@ if ($config['enable_syslog']) {
    '); - foreach (dbFetchRows($sql) as $entry) { - $entry = array_merge($entry, device_by_id_cache($entry['device_id'])); + foreach (dbFetchRows($sql) as $entry) + { + $entry = array_merge($entry, device_by_id_cache($entry['device_id'])); - include 'includes/print-syslog.inc.php'; - } - echo("
    "); - echo("
    "); - echo("
    "); - echo("
    "); - echo(""); -} -else { + include("includes/print-syslog.inc.php"); + } + echo(""); + echo(""); + echo(""); + echo(""); + echo(""); - if ($_SESSION['userlevel'] == '10') { - $query = "SELECT *,DATE_FORMAT(datetime, '".$config['dateformat']['mysql']['compact']."') as humandate FROM `eventlog` ORDER BY `datetime` DESC LIMIT 0,15"; - } - else { - $query = "SELECT *,DATE_FORMAT(datetime, '".$config['dateformat']['mysql']['compact']."') as humandate FROM `eventlog` AS E, devices_perms AS P WHERE E.host = - P.device_id AND P.user_id = " . $_SESSION['user_id'] . " ORDER BY `datetime` DESC LIMIT 0,15"; - } +} else { - $data = mysql_query($query); + if ($_SESSION['userlevel'] == '10') + { + $query = "SELECT *,DATE_FORMAT(datetime, '".$config['dateformat']['mysql']['compact']."') as humandate FROM `eventlog` ORDER BY `datetime` DESC LIMIT 0,15"; + } else { + $query = "SELECT *,DATE_FORMAT(datetime, '".$config['dateformat']['mysql']['compact']."') as humandate FROM `eventlog` AS E, devices_perms AS P WHERE E.host = + P.device_id AND P.user_id = " . $_SESSION['user_id'] . " ORDER BY `datetime` DESC LIMIT 0,15"; + } + + $data = mysql_query($query); echo('
    @@ -181,13 +177,15 @@ else {
    '); - foreach (dbFetchRows($query) as $entry) { - include 'includes/print-event.inc.php'; - } + foreach (dbFetchRows($query) as $entry) + { + include("includes/print-event.inc.php"); + } - echo("
    "); - echo("
    "); - echo(""); - echo(""); - echo(""); + echo(""); + echo(""); + echo(""); + echo(""); + echo(""); } +?> diff --git a/html/pages/front/jt.php b/html/pages/front/jt.php index cda0b49bb7..2256cf0856 100644 --- a/html/pages/front/jt.php +++ b/html/pages/front/jt.php @@ -5,209 +5,238 @@ $nodes = array(); -$uptimesql = ''; -if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== false && $config['uptime_warning'] > 0) { - $uptimesql = " AND A.attrib_value < '".$config['uptime_warning']."'"; +$uptimesql = ""; +if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== FALSE && $config['uptime_warning'] > 0) +{ + $uptimesql = " AND A.attrib_value < '" . $config['uptime_warning'] . "'"; } -$sql = "SELECT * FROM `devices` AS D, `devices_attribs` AS A WHERE D.status = '1' AND A.device_id = D.device_id AND A.attrib_type = 'uptime' AND A.attrib_value > '0' ".$uptimesql; +$sql = "SELECT * FROM `devices` AS D, `devices_attribs` AS A WHERE D.status = '1' AND A.device_id = D.device_id AND A.attrib_type = 'uptime' AND A.attrib_value > '0' " . $uptimesql; -foreach (dbFetchRows($sql) as $device) { - unset($already); - $i = 0; - while ($i <= count($nodes)) { - $thisnode = $device['device_id']; - if ($nodes[$i] == $thisnode) { - $already = 'yes'; - } - - $i++; - } - - if (!$already) { - $nodes[] = $device['device_id']; +foreach (dbFetchRows($sql) as $device) +{ + unset($already); + $i = 0; + while ($i <= count($nodes)) { + $thisnode = $device['device_id']; + if ($nodes[$i] == $thisnode) { + $already = "yes"; } + $i++; + } + if (!$already) { $nodes[] = $device['device_id']; } } $sql = "SELECT * FROM `devices` WHERE `status` = '0' AND `ignore` = '0'"; -foreach (dbFetchRows($sql) as $device) { - if (device_permitted($device['device_id'])) { - echo "
    - ".generate_device_link($device, shorthost($device['hostname']))."
    - Device Down
    - ".truncate($device['location'], 35).' -
    '; - } +foreach (dbFetchRows($sql) as $device) +{ + if (device_permitted($device['device_id'])) { + echo("
    + ".generate_device_link($device, shorthost($device['hostname']))."
    + Device Down
    + ".truncate($device['location'], 35)." +
    "); + } } if ($config['warn']['ifdown']) { - $sql = "SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0'"; - foreach (dbFetchRows($sql) as $interface) { - if (port_permitted($interface['port_id'])) { - echo "
    - ".generate_device_link($interface, shorthost($interface['hostname']))."
    - Port Down
    - ".generate_port_link($interface, makeshortif($interface['ifDescr'])).'
    - '.truncate($interface['ifAlias'], 15).' -
    '; - } - } + +$sql = "SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0'"; +foreach (dbFetchRows($sql) as $interface) +{ + if (port_permitted($interface['port_id'])) { + echo("
    + ".generate_device_link($interface, shorthost($interface['hostname']))."
    + Port Down
    + ".generate_port_link($interface, makeshortif($interface['ifDescr']))."
    + ".truncate($interface['ifAlias'], 15)." +
    "); + } +} + } $sql = "SELECT * FROM `services` AS S, `devices` AS D WHERE S.device_id = D.device_id AND service_status = 'down' AND D.ignore = '0' AND S.service_ignore = '0'"; -foreach (dbFetchRows($sql) as $service) { - if (device_permitted($service['device_id'])) { - echo "
    - ".generate_device_link($service, shorthost($service['hostname']))."
    - Service Down
    - ".$service['service_type'].'
    - '.truncate($interface['ifAlias'], 15).' -
    '; - } +foreach (dbFetchRows($sql) as $service) +{ + if (device_permitted($service['device_id'])) { + echo("
    + ".generate_device_link($service, shorthost($service['hostname']))."
    + Service Down
    + ".$service['service_type']."
    + ".truncate($interface['ifAlias'], 15)." +
    "); + } } $sql = "SELECT * FROM `devices` AS D, bgpPeers AS B WHERE bgpPeerAdminStatus = 'start' AND bgpPeerState != 'established' AND B.device_id = D.device_id"; -foreach (dbFetchRows($sql) as $peer) { - if (device_permitted($peer['device_id'])) { - echo "
    - ".generate_device_link($peer, shorthost($peer['hostname']))."
    - BGP Down
    - ".$peer['bgpPeerIdentifier'].'
    - AS'.$peer['bgpPeerRemoteAs'].' '.truncate($peer['astext'], 10).' -
    '; - } +foreach (dbFetchRows($sql) as $peer) +{ + if (device_permitted($peer['device_id'])) { + echo("
    + ".generate_device_link($peer, shorthost($peer['hostname']))."
    + BGP Down
    + ".$peer['bgpPeerIdentifier']."
    + AS".$peer['bgpPeerRemoteAs']." ".truncate($peer['astext'], 10)." +
    "); + } } -if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== false && $config['uptime_warning'] > 0) { - $sql = "SELECT * FROM devices_attribs AS A, `devices` AS D WHERE A.attrib_value < '".$config['uptime_warning']."' AND A.attrib_type = 'uptime' AND A.device_id = D.device_id AND ignore = '0' AND disabled = '0'"; - foreach (dbFetchRows($sql) as $device) { - if (device_permitted($device['device_id']) && $device['attrib_value'] < $config['uptime_warning'] && $device['attrib_type'] == 'uptime') { - echo "
    - ".generate_device_link($device, shorthost($device['hostname']))."
    - Device
    Rebooted

    - ".formatUptime($device['attrib_value']).' -
    '; - } - } +if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== FALSE && $config['uptime_warning'] > 0) +{ + $sql = "SELECT * FROM devices_attribs AS A, `devices` AS D WHERE A.attrib_value < '" . $config['uptime_warning'] . "' AND A.attrib_type = 'uptime' AND A.device_id = D.device_id AND ignore = '0' AND disabled = '0'"; + foreach (dbFetchRows($sql) as $device) { + if (device_permitted($device['device_id']) && $device['attrib_value'] < $config['uptime_warning'] && $device['attrib_type'] == "uptime") { + echo("
    + ".generate_device_link($device, shorthost($device['hostname']))."
    + Device
    Rebooted

    + ".formatUptime($device['attrib_value'])." +
    "); + } + } } -echo " +echo(" -
    $errorboxes
    +
    $errorboxes
    -

    Recent Syslog Messages

    +

    Recent Syslog Messages

    - "; +"); $sql = "SELECT *, DATE_FORMAT(timestamp, '".$config['dateformat']['mysql']['compact']."') AS date from syslog,devices WHERE syslog.device_id = devices.device_id ORDER BY seq DESC LIMIT 20"; -echo ''; -foreach (dbFetchRows($sql) as $entry) { - include 'includes/print-syslog.inc.php'; +echo("
    "); +foreach (dbFetchRows($sql) as $entry) +{ + include("includes/print-syslog.inc.php"); } +echo("
    "); -echo ''; +echo("
    -echo '
    - - - '; + + "); // this stuff can be customised to show whatever you want.... -if ($_SESSION['userlevel'] >= '5') { - $sql = "SELECT * FROM ports AS I, devices AS D WHERE `ifAlias` like 'Transit: %' AND I.device_id = D.device_id ORDER BY I.ifAlias"; - unset($seperator); - foreach (dbFetchRows($sql) as $interface) { - $ports['transit'] .= $seperator.$interface['port_id']; - $seperator = ','; - } - $sql = "SELECT * FROM ports AS I, devices AS D WHERE `ifAlias` like 'Peering: %' AND I.device_id = D.device_id ORDER BY I.ifAlias"; - unset($seperator); - foreach (dbFetchRows($sql) as $interface) { - $ports['peering'] .= $seperator.$interface['port_id']; - $seperator = ','; - } +if ($_SESSION['userlevel'] >= '5') +{ - $ports['broadband'] = '3294,3295,688,3534'; - $ports['wave_broadband'] = '827'; + $sql = "SELECT * FROM ports AS I, devices AS D WHERE `ifAlias` like 'Transit: %' AND I.device_id = D.device_id ORDER BY I.ifAlias"; + unset ($seperator); + foreach (dbFetchRows($sql) as $interface) + { + $ports['transit'] .= $seperator . $interface['port_id']; + $seperator = ","; + } - $ports['new_broadband'] = '3659,4149,4121,4108,3676,4135'; + $sql = "SELECT * FROM ports AS I, devices AS D WHERE `ifAlias` like 'Peering: %' AND I.device_id = D.device_id ORDER BY I.ifAlias"; + unset ($seperator); + foreach (dbFetchRows($sql) as $interface) + { + $ports['peering'] .= $seperator . $interface['port_id']; + $seperator = ","; + } - echo "
    "; + $ports['broadband'] = "3294,3295,688,3534"; + $ports['wave_broadband'] = "827"; - if ($ports['peering'] && $ports['transit']) { - echo ""; - } + $ports['new_broadband'] = "3659,4149,4121,4108,3676,4135"; - echo '
    '; + echo("
    "); - echo ""); - if ($ports['peering']) { - echo ""; - } + echo("
    "); - echo '
    '; + if ($ports['transit']) { + echo(""); + } - echo ""); - echo "
    "; + echo("
    "); - if ($ports['broadband']) { - echo ""; - } + if ($ports['broadband'] && $ports['wave_broadband'] && $ports['new_broadband']) { + echo(""); + } - echo "
    "; + echo("'; + echo("'; -}//end if + echo("
    "); + + if ($ports['wave_broadband']) { + echo(""); + } + + echo("
    "); + +} ?> diff --git a/html/pages/front/traffic.php b/html/pages/front/traffic.php index 6b501cf9c1..5f9a8acced 100644 --- a/html/pages/front/traffic.php +++ b/html/pages/front/traffic.php @@ -3,172 +3,200 @@ 0) { - $uptimesql = ' AND A.attrib_value < ?'; - $param = array($config['uptime_warning']); +$nodes = array(); +$param = array(); +$uptimesql = ""; +if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== FALSE && $config['uptime_warning'] > 0) +{ + $uptimesql = " AND A.attrib_value < ?"; + $param = array($config['uptime_warning']); } -foreach (dbFetchRows("SELECT * FROM `devices` AS D, `devices_attribs` AS A WHERE D.status = '1' AND A.device_id = D.device_id AND A.attrib_type = 'uptime' AND A.attrib_value > '0' ".$uptimesql, $param) as $device) { - unset($already); - $i = 0; - while ($i <= count($nodes)) { - $thisnode = $device['device_id']; - if ($nodes[$i] == $thisnode) { - $already = 'yes'; - } - - $i++; - } - - if (!$already) { - $nodes[] = $device['device_id']; +foreach (dbFetchRows("SELECT * FROM `devices` AS D, `devices_attribs` AS A WHERE D.status = '1' AND A.device_id = D.device_id AND A.attrib_type = 'uptime' AND A.attrib_value > '0' " . $uptimesql, $param) as $device) +{ + unset($already); + $i = 0; + while ($i <= count($nodes)) { + $thisnode = $device['device_id']; + if ($nodes[$i] == $thisnode) { + $already = "yes"; } + $i++; + } + if (!$already) { $nodes[] = $device['device_id']; } } -foreach (dbFetchRows("SELECT * FROM `devices` WHERE `status` = '0' AND `ignore` = '0'") as $device) { - if (device_permitted($device['device_id'])) { - echo "
    - ".generate_device_link($device, shorthost($device['hostname']))."
    - Device Down
    - ".truncate($device['location'], 35).' -
    '; - } +foreach (dbFetchRows("SELECT * FROM `devices` WHERE `status` = '0' AND `ignore` = '0'") as $device) +{ + if (device_permitted($device['device_id'])) { + echo("
    + ".generate_device_link($device, shorthost($device['hostname']))."
    + Device Down
    + ".truncate($device['location'], 35)." +
    "); + } } if ($config['warn']['ifdown']) { - foreach (dbFetchRows("SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0'") as $interface) { - if (port_permitted($interface['port_id'])) { - echo "
    - ".generate_device_link($interface, shorthost($interface['hostname']))."
    - Port Down
    - ".generate_port_link($interface, makeshortif($interface['ifDescr'])).'
    - '.truncate($interface['ifAlias'], 15).' -
    '; - } - } + +foreach (dbFetchRows("SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0'") as $interface) +{ + if (port_permitted($interface['port_id'])) { + echo("
    + ".generate_device_link($interface, shorthost($interface['hostname']))."
    + Port Down
    + ".generate_port_link($interface, makeshortif($interface['ifDescr']))."
    + ".truncate($interface['ifAlias'], 15)." +
    "); + } } -foreach (dbFetchRows("SELECT * FROM `services` AS S, `devices` AS D WHERE S.device_id = D.device_id AND service_status = 'down' AND D.ignore = '0' AND S.service_ignore = '0'") as $service) { - if (device_permitted($service['device_id'])) { - echo "
    - ".generate_device_link($service, shorthost($service['hostname']))."
    - Service Down
    - ".$service['service_type'].'
    - '.truncate($interface['ifAlias'], 15).' -
    '; - } } -foreach (dbFetchRows("SELECT * FROM `devices` AS D, bgpPeers AS B WHERE bgpPeerAdminStatus = 'start' AND bgpPeerState != 'established' AND B.device_id = D.device_id") as $peer) { - if (device_permitted($peer['device_id'])) { - echo "
    - ".generate_device_link($peer, shorthost($peer['hostname']))."
    - BGP Down
    - ".$peer['bgpPeerIdentifier'].'
    - AS'.$peer['bgpPeerRemoteAs'].' '.truncate($peer['astext'], 10).' -
    '; - } +foreach (dbFetchRows("SELECT * FROM `services` AS S, `devices` AS D WHERE S.device_id = D.device_id AND service_status = 'down' AND D.ignore = '0' AND S.service_ignore = '0'") as $service) +{ + if (device_permitted($service['device_id'])) { + echo("
    + ".generate_device_link($service, shorthost($service['hostname']))."
    + Service Down
    + ".$service['service_type']."
    + ".truncate($interface['ifAlias'], 15)." +
    "); + } } -if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== false && $config['uptime_warning'] > 0) { - foreach (dbFetchRows("SELECT * FROM devices_attribs AS A, `devices` AS D WHERE A.attrib_value < ? AND A.attrib_type = 'uptime' AND A.device_id = D.device_id AND ignore = '0' AND disabled = '0'", array($config['uptime_warning'])) as $device) { - if (device_permitted($device['device_id']) && $device['attrib_value'] < $config['uptime_warning'] && $device['attrib_type'] == 'uptime') { - echo "
    - ".generate_device_link($device, shorthost($device['hostname']))."
    - Device
    Rebooted

    - ".formatUptime($device['attrib_value']).' -
    '; - } - } +foreach (dbFetchRows("SELECT * FROM `devices` AS D, bgpPeers AS B WHERE bgpPeerAdminStatus = 'start' AND bgpPeerState != 'established' AND B.device_id = D.device_id") as $peer) +{ + if (device_permitted($peer['device_id'])) { + echo("
    + ".generate_device_link($peer, shorthost($peer['hostname']))."
    + BGP Down
    + ".$peer['bgpPeerIdentifier']."
    + AS".$peer['bgpPeerRemoteAs']." ".truncate($peer['astext'], 10)." +
    "); + } } -echo " +if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== FALSE && $config['uptime_warning'] > 0) +{ + foreach (dbFetchRows("SELECT * FROM devices_attribs AS A, `devices` AS D WHERE A.attrib_value < ? AND A.attrib_type = 'uptime' AND A.device_id = D.device_id AND ignore = '0' AND disabled = '0'", array($config['uptime_warning'])) as $device) { + if (device_permitted($device['device_id']) && $device['attrib_value'] < $config['uptime_warning'] && $device['attrib_type'] == "uptime") { + echo("
    + ".generate_device_link($device, shorthost($device['hostname']))."
    + Device
    Rebooted

    + ".formatUptime($device['attrib_value'])." +
    "); + } + } +} -
    $errorboxes
    +echo(" -

    Recent Syslog Messages

    +
    $errorboxes
    - "; +

    Recent Syslog Messages

    + +"); $sql = "SELECT *, DATE_FORMAT(timestamp, '".$config['dateformat']['mysql']['compact']."') AS date from syslog,devices WHERE syslog.device_id = devices.device_id ORDER BY seq DESC LIMIT 20"; -echo ''; -foreach (dbFetchRows($sql) as $entry) { - include 'includes/print-syslog.inc.php'; +echo("
    "); +foreach (dbFetchRows($sql) as $entry) +{ + include("includes/print-syslog.inc.php"); } +echo("
    "); -echo ''; +echo("
    -echo '
    - - - '; + + "); // this stuff can be customised to show whatever you want.... -if ($_SESSION['userlevel'] >= '5') { - $sql = "SELECT * FROM ports AS I, devices AS D WHERE `ifAlias` like 'Transit: %' AND I.device_id = D.device_id ORDER BY I.ifAlias"; - unset($seperator); - foreach (dbFetchRows($sql) as $interface) { - $ports['transit'] .= $seperator.$interface['port_id']; - $seperator = ','; - } - $sql = "SELECT * FROM ports AS I, devices AS D WHERE `ifAlias` like 'Peering: %' AND I.device_id = D.device_id ORDER BY I.ifAlias"; - unset($seperator); - foreach (dbFetchRows($sql) as $interface) { - $ports['peering'] .= $seperator.$interface['port_id']; - $seperator = ','; - } +if ($_SESSION['userlevel'] >= '5') +{ - $sql = "SELECT * FROM ports AS I, devices AS D WHERE `ifAlias` like 'Core: %' AND I.device_id = D.device_id ORDER BY I.ifAlias"; - unset($seperator); - foreach (dbFetchRows($sql) as $interface) { - $ports['core'] .= $seperator.$interface['port_id']; - $seperator = ','; - } + $sql = "SELECT * FROM ports AS I, devices AS D WHERE `ifAlias` like 'Transit: %' AND I.device_id = D.device_id ORDER BY I.ifAlias"; + unset ($seperator); + foreach (dbFetchRows($sql) as $interface) + { + $ports['transit'] .= $seperator . $interface['port_id']; + $seperator = ","; + } - echo "
    "; + $sql = "SELECT * FROM ports AS I, devices AS D WHERE `ifAlias` like 'Peering: %' AND I.device_id = D.device_id ORDER BY I.ifAlias"; + unset ($seperator); + foreach (dbFetchRows($sql) as $interface) + { + $ports['peering'] .= $seperator . $interface['port_id']; + $seperator = ","; + } - if ($ports['peering'] && $ports['transit']) { - echo ""; - } + $sql = "SELECT * FROM ports AS I, devices AS D WHERE `ifAlias` like 'Core: %' AND I.device_id = D.device_id ORDER BY I.ifAlias"; + unset ($seperator); + foreach (dbFetchRows($sql) as $interface) + { + $ports['core'] .= $seperator . $interface['port_id']; + $seperator = ","; + } - echo '
    '; + echo("
    "); - echo ""); - if ($ports['peering']) { - echo ""; - } + echo("'; -}//end if + if ($ports['peering']) + { + echo(""); + } + + if ($ports['core']) + { + echo(""); + } + + echo("
    "); + +} ?> diff --git a/html/pages/graphs.inc.php b/html/pages/graphs.inc.php index 78c6a73e09..0cc268fceb 100644 --- a/html/pages/graphs.inc.php +++ b/html/pages/graphs.inc.php @@ -4,21 +4,17 @@ unset($vars['page']); // Setup here -if($_SESSION['widescreen']) { - $graph_width=1700; - $thumb_width=180; -} -else { - $graph_width=1075; - $thumb_width=113; +if($_SESSION['widescreen']) +{ + $graph_width=1700; + $thumb_width=180; +} else { + $graph_width=1075; + $thumb_width=113; } -if (!is_numeric($vars['from'])) { - $vars['from'] = $config['time']['day']; -} -if (!is_numeric($vars['to'])) { - $vars['to'] = $config['time']['now']; -} +if (!is_numeric($vars['from'])) { $vars['from'] = $config['time']['day']; } +if (!is_numeric($vars['to'])) { $vars['to'] = $config['time']['now']; } preg_match('/^(?P[A-Za-z0-9]+)_(?P.+)/', $vars['type'], $graphtype); @@ -26,201 +22,208 @@ $type = $graphtype['type']; $subtype = $graphtype['subtype']; $id = $vars['id']; -if(is_numeric($vars['device'])) { - $device = device_by_id_cache($vars['device']); -} -elseif(!empty($vars['device'])) { - $device = device_by_name($vars['device']); +if(is_numeric($vars['device'])) +{ + $device = device_by_id_cache($vars['device']); +} elseif(!empty($vars['device'])) { + $device = device_by_name($vars['device']); } -if (is_file("includes/graphs/".$type."/auth.inc.php")) { - require "includes/graphs/".$type."/auth.inc.php"; +if (is_file("includes/graphs/".$type."/auth.inc.php")) +{ + include("includes/graphs/".$type."/auth.inc.php"); } -if (!$auth) { - require 'includes/error-no-perm.inc.php'; -} -else { - if (isset($config['graph_types'][$type][$subtype]['descr'])) { - $title .= " :: ".$config['graph_types'][$type][$subtype]['descr']; - } - else { - $title .= " :: ".ucfirst($subtype); - } +if (!$auth) +{ + include("includes/error-no-perm.inc.php"); +} else { + if (isset($config['graph_types'][$type][$subtype]['descr'])) + { + $title .= " :: ".$config['graph_types'][$type][$subtype]['descr']; + } else { + $title .= " :: ".ucfirst($subtype); + } - $graph_array = $vars; - $graph_array['height'] = "60"; - $graph_array['width'] = $thumb_width; - $graph_array['legend'] = "no"; - $graph_array['to'] = $config['time']['now']; + $graph_array = $vars; + $graph_array['height'] = "60"; + $graph_array['width'] = $thumb_width; + $graph_array['legend'] = "no"; + $graph_array['to'] = $config['time']['now']; - print_optionbar_start(); - echo($title); + print_optionbar_start(); + echo($title); - echo('
    '); -?> + echo('
    '); + ?>
    -'); + '); - print_optionbar_end(); + print_optionbar_end(); - print_optionbar_start(); + print_optionbar_start(); - $thumb_array = array('sixhour' => '6 Hours', 'day' => '24 Hours', 'twoday' => '48 Hours', 'week' => 'One Week', 'twoweek' => 'Two Weeks', - 'month' => 'One Month', 'twomonth' => 'Two Months','year' => 'One Year', 'twoyear' => 'Two Years'); + $thumb_array = array('sixhour' => '6 Hours', 'day' => '24 Hours', 'twoday' => '48 Hours', 'week' => 'One Week', 'twoweek' => 'Two Weeks', + 'month' => 'One Month', 'twomonth' => 'Two Months','year' => 'One Year', 'twoyear' => 'Two Years'); - echo(''); + echo('
    '); - foreach ($thumb_array as $period => $text) { - $graph_array['from'] = $config['time'][$period]; + foreach ($thumb_array as $period => $text) + { + $graph_array['from'] = $config['time'][$period]; - $link_array = $vars; - $link_array['from'] = $graph_array['from']; - $link_array['to'] = $graph_array['to']; - $link_array['page'] = "graphs"; - $link = generate_url($link_array); + $link_array = $vars; + $link_array['from'] = $graph_array['from']; + $link_array['to'] = $graph_array['to']; + $link_array['page'] = "graphs"; + $link = generate_url($link_array); - echo(''); + echo(''); - } + } - echo('
    '); - echo(''.$text.'
    '); - echo(''); - echo(generate_graph_tag($graph_array)); - echo(''); - echo('
    '); + echo(''.$text.'
    '); + echo(''); + echo(generate_graph_tag($graph_array)); + echo(''); + echo('
    '); + echo(''); - $graph_array = $vars; - $graph_array['height'] = "300"; - $graph_array['width'] = $graph_width; + $graph_array = $vars; + $graph_array['height'] = "300"; + $graph_array['width'] = $graph_width; - echo("
    "); + echo("
    "); - // datetime range picker + // datetime range picker ?> - "); - echo(' + echo(" +
    + "); + echo('
    - - + +
    - - + +
    -
    - '); - echo("
    "); + echo("
    "); - if ($vars['legend'] == "no") { - echo(generate_link("Show Legend",$vars, array('page' => "graphs", 'legend' => NULL))); - } - else { - echo(generate_link("Hide Legend",$vars, array('page' => "graphs", 'legend' => "no"))); - } + if ($vars['legend'] == "no") + { + echo(generate_link("Show Legend",$vars, array('page' => "graphs", 'legend' => NULL))); + } else { + echo(generate_link("Hide Legend",$vars, array('page' => "graphs", 'legend' => "no"))); + } - // FIXME : do this properly - # if ($type == "port" && $subtype == "bits") - # { + // FIXME : do this properly +# if ($type == "port" && $subtype == "bits") +# { echo(' | '); - if ($vars['previous'] == "yes") { - echo(generate_link("Hide Previous",$vars, array('page' => "graphs", 'previous' => NULL))); + if ($vars['previous'] == "yes") + { + echo(generate_link("Hide Previous",$vars, array('page' => "graphs", 'previous' => NULL))); + } else { + echo(generate_link("Show Previous",$vars, array('page' => "graphs", 'previous' => "yes"))); } - else { - echo(generate_link("Show Previous",$vars, array('page' => "graphs", 'previous' => "yes"))); - } - # } +# } - echo('
    '); + echo('
    '); - if ($vars['showcommand'] == "yes") { - echo(generate_link("Hide RRD Command",$vars, array('page' => "graphs", 'showcommand' => NULL))); - } - else { - echo(generate_link("Show RRD Command",$vars, array('page' => "graphs", 'showcommand' => "yes"))); - } + if ($vars['showcommand'] == "yes") + { + echo(generate_link("Hide RRD Command",$vars, array('page' => "graphs", 'showcommand' => NULL))); + } else { + echo(generate_link("Show RRD Command",$vars, array('page' => "graphs", 'showcommand' => "yes"))); + } - echo('
    '); + echo('
    '); - print_optionbar_end(); + print_optionbar_end(); - echo generate_graph_js_state($graph_array); + echo generate_graph_js_state($graph_array); - echo('
    '); - echo(generate_graph_tag($graph_array)); - echo("
    "); + echo('
    '); + echo(generate_graph_tag($graph_array)); + echo("
    "); - if (isset($config['graph_descr'][$vars['type']])) { + if (isset($config['graph_descr'][$vars['type']])) + { - print_optionbar_start(); - echo('
    -
    + print_optionbar_start(); + echo('
    +
    -
    -
    '); - echo($config['graph_descr'][$vars['type']]); - print_optionbar_end(); - } +
    +
    '); + echo($config['graph_descr'][$vars['type']]); + print_optionbar_end(); + } - if ($vars['showcommand']) { - $_GET = $graph_array; - $command_only = 1; + if ($vars['showcommand']) + { + $_GET = $graph_array; + $command_only = 1; - require 'includes/graphs/graph.inc.php'; - } + include("includes/graphs/graph.inc.php"); + } } + +?> diff --git a/html/pages/health.inc.php b/html/pages/health.inc.php index eb13def9b7..3b06d4db6b 100644 --- a/html/pages/health.inc.php +++ b/html/pages/health.inc.php @@ -30,12 +30,8 @@ $type_text['toner'] = "Toner"; $type_text['dbm'] = "dBm"; $type_text['load'] = "Load"; -if (!$vars['metric']) { - $vars['metric'] = "processor"; -} -if (!$vars['view']) { - $vars['view'] = "detail"; -} +if (!$vars['metric']) { $vars['metric'] = "processor"; } +if (!$vars['view']) { $vars['view'] = "detail"; } $link_array = array('page' => 'health'); @@ -46,44 +42,48 @@ print_optionbar_start('', ''); echo('Health » '); $sep = ""; -foreach ($datas as $texttype) { - $metric = strtolower($texttype); - echo($sep); - if ($vars['metric'] == $metric) { - echo(""); - } +foreach ($datas as $texttype) +{ + $metric = strtolower($texttype); + echo($sep); + if ($vars['metric'] == $metric) + { + echo(""); + } - echo(generate_link($type_text[$metric],$link_array,array('metric'=> $metric, 'view' => $vars['view']))); + echo(generate_link($type_text[$metric],$link_array,array('metric'=> $metric, 'view' => $vars['view']))); - if ($vars['metric'] == $metric) { - echo(""); - } + if ($vars['metric'] == $metric) { echo(""); } - $sep = ' | '; + $sep = ' | '; } unset ($sep); echo('
    '); -if ($vars['view'] == "graphs") { - echo(''); +if ($vars['view'] == "graphs") +{ + echo(''); } echo(generate_link("Graphs",$link_array,array('metric'=> $vars['metric'], 'view' => "graphs"))); -if ($vars['view'] == "graphs") { - echo(''); +if ($vars['view'] == "graphs") +{ + echo(''); } echo(' | '); -if ($vars['view'] != "graphs") { - echo(''); +if ($vars['view'] != "graphs") +{ + echo(''); } echo(generate_link("No Graphs",$link_array,array('metric'=> $vars['metric'], 'view' => "detail"))); -if ($vars['view'] != "graphs") { - echo(''); +if ($vars['view'] != "graphs") +{ + echo(''); } echo('
    '); @@ -91,14 +91,16 @@ echo('
    '); print_optionbar_end(); if (in_array($vars['metric'],array_keys($used_sensors)) - || $vars['metric'] == 'processor' - || $vars['metric'] == 'storage' - || $vars['metric'] == 'toner' - || $vars['metric'] == 'mempool') { - include('pages/health/'.$vars['metric'].'.inc.php'); + || $vars['metric'] == 'processor' + || $vars['metric'] == 'storage' + || $vars['metric'] == 'toner' + || $vars['metric'] == 'mempool') +{ + include('pages/health/'.$vars['metric'].'.inc.php'); } -else { - echo("No sensors of type " . $vars['metric'] . " found."); +else +{ + echo("No sensors of type " . $vars['metric'] . " found."); } ?> diff --git a/html/pages/health/charge.inc.php b/html/pages/health/charge.inc.php index 3838d0e790..867b50f9e8 100644 --- a/html/pages/health/charge.inc.php +++ b/html/pages/health/charge.inc.php @@ -4,4 +4,6 @@ $graph_type = "sensor_charge"; $unit = "%"; $class = "charge"; -require 'pages/health/sensors.inc.php'; +include("pages/health/sensors.inc.php"); + +?> diff --git a/html/pages/health/load.inc.php b/html/pages/health/load.inc.php index f506e3ca1d..d9257519d3 100644 --- a/html/pages/health/load.inc.php +++ b/html/pages/health/load.inc.php @@ -1,7 +1,9 @@ diff --git a/html/pages/health/sensors.inc.php b/html/pages/health/sensors.inc.php index 52828b9c19..02224d485c 100644 --- a/html/pages/health/sensors.inc.php +++ b/html/pages/health/sensors.inc.php @@ -1,18 +1,19 @@ = '5') { - $sql = "SELECT * FROM `sensors` AS S, `devices` AS D WHERE S.sensor_class='".$class."' AND S.device_id = D.device_id ORDER BY D.hostname, S.sensor_descr"; - $param = array(); -} -else { - $sql = "SELECT * FROM `sensors` AS S, `devices` AS D, devices_perms as P WHERE S.sensor_class='".$class."' AND S.device_id = D.device_id AND D.device_id = P.device_id AND P.user_id = ? ORDER BY D.hostname, S.sensor_descr"; - $param = array($_SESSION['user_id']); + +if ($_SESSION['userlevel'] >= '5') +{ + $sql = "SELECT * FROM `sensors` AS S, `devices` AS D WHERE S.sensor_class='".$class."' AND S.device_id = D.device_id ORDER BY D.hostname, S.sensor_descr"; + $param = array(); +} else { + $sql = "SELECT * FROM `sensors` AS S, `devices` AS D, devices_perms as P WHERE S.sensor_class='".$class."' AND S.device_id = D.device_id AND D.device_id = P.device_id AND P.user_id = ? ORDER BY D.hostname, S.sensor_descr"; + $param = array($_SESSION['user_id']); } -echo ''; +echo('
    '); -echo ' +echo(' @@ -20,102 +21,99 @@ echo ' - '; + '); -foreach (dbFetchRows($sql, $param) as $sensor) { - if ($config['memcached']['enable'] === true) { - $sensor['sensor_current'] = $memcache->get('sensor-'.$sensor['sensor_id'].'-value'); - if ($debug) { - echo 'Memcached['.'sensor-'.$sensor['sensor_id'].'-value'.'='.$sensor['sensor_current'].']'; - } - } +foreach (dbFetchRows($sql, $param) as $sensor) +{ - if (empty($sensor['sensor_current'])) { - $sensor['sensor_current'] = 'NaN'; - } - else { - if ($sensor['sensor_current'] >= $sensor['sensor_limit']) { - $alert = 'alert'; - } - else { - $alert = ''; - } - } + if ($config['memcached']['enable'] === TRUE) + { + $sensor['sensor_current'] = $memcache->get('sensor-'.$sensor['sensor_id'].'-value'); + if($debug) { echo("Memcached[".'sensor-'.$sensor['sensor_id'].'-value'."=".$sensor['sensor_current']."]"); } + } + + if (empty($sensor['sensor_current'])) + { + $sensor['sensor_current'] = "NaN"; + } else { + if ($sensor['sensor_current'] >= $sensor['sensor_limit']) { $alert = 'alert'; } else { $alert = ""; } + } // FIXME - make this "four graphs in popup" a function/include and "small graph" a function. // FIXME - So now we need to clean this up and move it into a function. Isn't it just "print-graphrow"? // FIXME - DUPLICATED IN device/overview/sensors - $graph_colour = str_replace('#', '', $row_colour); + + $graph_colour = str_replace("#", "", $row_colour); $graph_array = array(); - $graph_array['height'] = '100'; - $graph_array['width'] = '210'; + $graph_array['height'] = "100"; + $graph_array['width'] = "210"; $graph_array['to'] = $config['time']['now']; $graph_array['id'] = $sensor['sensor_id']; $graph_array['type'] = $graph_type; $graph_array['from'] = $config['time']['day']; - $graph_array['legend'] = 'no'; + $graph_array['legend'] = "no"; - $link_array = $graph_array; - $link_array['page'] = 'graphs'; + $link_array = $graph_array; + $link_array['page'] = "graphs"; unset($link_array['height'], $link_array['width'], $link_array['legend']); $link_graph = generate_url($link_array); - $link = generate_url(array('page' => 'device', 'device' => $sensor['device_id'], 'tab' => 'health', 'metric' => $sensor['sensor_class'])); + $link = generate_url(array("page" => "device", "device" => $sensor['device_id'], "tab" => "health", "metric" => $sensor['sensor_class'])); - $overlib_content = '

    '.$device['hostname'].' - '.$sensor['sensor_descr'].'

    '; - foreach (array('day', 'week', 'month', 'year') as $period) { - $graph_array['from'] = $config['time'][$period]; - $overlib_content .= str_replace('"', "\'", generate_graph_tag($graph_array)); + $overlib_content = '

    '.$device['hostname']." - ".$sensor['sensor_descr']."

    "; + foreach (array('day','week','month','year') as $period) + { + $graph_array['from'] = $config['time'][$period]; + $overlib_content .= str_replace('"', "\'", generate_graph_tag($graph_array)); } + $overlib_content .= "
    "; - $overlib_content .= '
    '; - - $graph_array['width'] = 80; - $graph_array['height'] = 20; - $graph_array['bg'] = 'ffffff00'; - // the 00 at the end makes the area transparent. + $graph_array['width'] = 80; $graph_array['height'] = 20; $graph_array['bg'] = 'ffffff00'; # the 00 at the end makes the area transparent. $graph_array['from'] = $config['time']['day']; - $sensor_minigraph = generate_graph_tag($graph_array); + $sensor_minigraph = generate_graph_tag($graph_array); $sensor['sensor_descr'] = truncate($sensor['sensor_descr'], 48, ''); - echo ' - - + echo(' + + - - - + + + - '; + '); - if ($vars['view'] == 'graphs') { - echo "'; - } //end if -}//end foreach + echo("', LEFT);\" onmouseout=\"return nd();\"> + "); + echo("', LEFT);\" onmouseout=\"return nd();\"> + "); + echo("', LEFT);\" onmouseout=\"return nd();\"> + "); + echo("', LEFT);\" onmouseout=\"return nd();\"> + "); + echo(""); + } # endif graphs +} -echo '
    Device Sensor
    Current Range limit Notes
    '.generate_device_link($sensor).''.overlib_link($link, $sensor['sensor_descr'], $overlib_content).'
    ' . generate_device_link($sensor) . ''.overlib_link($link, $sensor['sensor_descr'],$overlib_content).' '.overlib_link($link_graph, $sensor_minigraph, $overlib_content).' '.$alert.''.$sensor['sensor_current'].$unit.''.round($sensor['sensor_limit_low'], 2).$unit.' - '.round($sensor['sensor_limit'], 2).$unit.''.(isset($sensor['sensor_notes']) ? $sensor['sensor_notes'] : '').'' . $sensor['sensor_current'] . $unit . '' . round($sensor['sensor_limit_low'],2) . $unit . ' - ' . round($sensor['sensor_limit'],2) . $unit . '' . (isset($sensor['sensor_notes']) ? $sensor['sensor_notes'] : '') . '
    "; + if ($vars['view'] == "graphs") + { + echo("
    "); - $daily_graph = 'graph.php?id='.$sensor['sensor_id'].'&type='.$graph_type.'&from='.$config['time']['day'].'&to='.$config['time']['now'].'&width=211&height=100'; - $daily_url = 'graph.php?id='.$sensor['sensor_id'].'&type='.$graph_type.'&from='.$config['time']['day'].'&to='.$config['time']['now'].'&width=400&height=150'; + $daily_graph = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=".$config['time']['day']."&to=".$config['time']['now']."&width=211&height=100"; + $daily_url = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=".$config['time']['day']."&to=".$config['time']['now']."&width=400&height=150"; - $weekly_graph = 'graph.php?id='.$sensor['sensor_id'].'&type='.$graph_type.'&from='.$config['time']['week'].'&to='.$config['time']['now'].'&width=211&height=100'; - $weekly_url = 'graph.php?id='.$sensor['sensor_id'].'&type='.$graph_type.'&from='.$config['time']['week'].'&to='.$config['time']['now'].'&width=400&height=150'; + $weekly_graph = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=".$config['time']['week']."&to=".$config['time']['now']."&width=211&height=100"; + $weekly_url = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=".$config['time']['week']."&to=".$config['time']['now']."&width=400&height=150"; - $monthly_graph = 'graph.php?id='.$sensor['sensor_id'].'&type='.$graph_type.'&from='.$config['time']['month'].'&to='.$config['time']['now'].'&width=211&height=100'; - $monthly_url = 'graph.php?id='.$sensor['sensor_id'].'&type='.$graph_type.'&from='.$config['time']['month'].'&to='.$config['time']['now'].'&width=400&height=150'; + $monthly_graph = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=".$config['time']['month']."&to=".$config['time']['now']."&width=211&height=100"; + $monthly_url = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=".$config['time']['month']."&to=".$config['time']['now']."&width=400&height=150"; - $yearly_graph = 'graph.php?id='.$sensor['sensor_id'].'&type='.$graph_type.'&from='.$config['time']['year'].'&to='.$config['time']['now'].'&width=211&height=100'; - $yearly_url = 'graph.php?id='.$sensor['sensor_id'].'&type='.$graph_type.'&from='.$config['time']['year'].'&to='.$config['time']['now'].'&width=400&height=150'; + $yearly_graph = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=".$config['time']['year']."&to=".$config['time']['now']."&width=211&height=100"; + $yearly_url = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=".$config['time']['year']."&to=".$config['time']['now']."&width=400&height=150"; - echo "', LEFT);\" onmouseout=\"return nd();\"> - "; - echo "', LEFT);\" onmouseout=\"return nd();\"> - "; - echo "', LEFT);\" onmouseout=\"return nd();\"> - "; - echo "', LEFT);\" onmouseout=\"return nd();\"> - "; - echo '
    '; +echo(""); + +?> diff --git a/html/pages/iftype.inc.php b/html/pages/iftype.inc.php index 8a6d20201b..f4349111cd 100644 --- a/html/pages/iftype.inc.php +++ b/html/pages/iftype.inc.php @@ -9,102 +9,92 @@ + Total Graph for ports of type : ".$types."
    "); -echo " - Total Graph for ports of type : ".$types.'
    '; +if ($if_list) +{ + $graph_type = "multiport_bits_separate"; + $port['port_id'] = $if_list; -if ($if_list) { - $graph_type = 'multiport_bits_separate'; - $port['port_id'] = $if_list; + include("includes/print-interface-graphs.inc.php"); - include 'includes/print-interface-graphs.inc.php'; + echo(""); - echo ''; + foreach ($ports as $port) + { + $done = "yes"; + unset($class); + $port['ifAlias'] = str_ireplace($type . ": ", "", $port['ifAlias']); + $port['ifAlias'] = str_ireplace("[PNI]", "Private", $port['ifAlias']); + $ifclass = ifclass($port['ifOperStatus'], $port['ifAdminStatus']); + if ($bg == "#ffffff") { $bg = "#e5e5e5"; } else { $bg = "#ffffff"; } + echo(" + " . generate_port_link($port,$port['port_descr_descr']) . "
    + ".generate_device_link($port)." ".generate_port_link($port)." + ".generate_port_link($port, makeshortif($port['ifDescr']))." + ".$port['port_descr_speed']." + ".$port['port_descr_circuit']." + ".$port['port_descr_notes']." + + + - ".generate_port_link($port, $port['port_descr_descr'])."
    - ".generate_device_link($port).' '.generate_port_link($port).' - '.generate_port_link($port, makeshortif($port['ifDescr'])).' - '.$port['port_descr_speed'].' - '.$port['port_descr_circuit'].' - '.$port['port_descr_notes']." - - - MAC Accounting"; - } - - echo '
    '; - - if (file_exists($config['rrd_dir'].'/'.$port['hostname'].'/port-'.$port['ifIndex'].'.rrd')) { - $graph_type = 'port_bits'; - - include 'includes/print-interface-graphs.inc.php'; - } - - echo ''; + if (dbFetchCell("SELECT count(*) FROM mac_accounting WHERE port_id = ?", array($port['port_id']))) + { + echo(" MAC Accounting"); } + + echo('
    '); + + if (file_exists($config['rrd_dir'] . "/" . $port['hostname'] . "/port-" . $port['ifIndex'] . ".rrd")) + { + $graph_type = "port_bits"; + + include("includes/print-interface-graphs.inc.php"); + } + + echo(""); + } + } -else { - echo 'None found.'; +else +{ + echo("None found."); } ?> diff --git a/html/pages/inventory.inc.php b/html/pages/inventory.inc.php index 7fc461e4aa..e53daab965 100644 --- a/html/pages/inventory.inc.php +++ b/html/pages/inventory.inc.php @@ -1,6 +1,6 @@ @@ -29,53 +29,46 @@ var grid = $("#inventory").bootgrid({ header: "
    "+ "
    "+ "
    "+ - "\" placeholder=\"Description\" class=\"form-control input-sm\" />"+ + "\" placeholder=\"Description\" class=\"form-control input-sm\" />"+ "
    "+ "
    "+ " Part No "+ ""+ "
    "+ "
    "+ - "\" placeholder=\"Serial\" class=\"form-control input-sm\"/>"+ + "\" placeholder=\"Serial\" class=\"form-control input-sm\"/>"+ "
    "+ "
    "+ " Device "+ ""+ "
    "+ "
    "+ - " -\" placeholder=\"Description\" class=\"form-control input-sm\"/>"+ + "\" placeholder=\"Description\" class=\"form-control input-sm\"/>"+ "
    "+ ""+ "
    "+ diff --git a/html/pages/locations.inc.php b/html/pages/locations.inc.php index bbe6adcf99..93dffa0e36 100644 --- a/html/pages/locations.inc.php +++ b/html/pages/locations.inc.php @@ -1,92 +1,88 @@ Locations » '; +echo('Locations » '); -$menu_options = array( - 'basic' => 'Basic', - 'traffic' => 'Traffic', -); +$menu_options = array('basic' => 'Basic', + 'traffic' => 'Traffic'); -if (!$vars['view']) { - $vars['view'] = 'basic'; -} +if (!$vars['view']) { $vars['view'] = "basic"; } -$sep = ''; -foreach ($menu_options as $option => $text) { - echo $sep; - if ($vars['view'] == $option) { - echo ""; - } - - echo ''.$text.''; - if ($vars['view'] == $option) { - echo ''; - } - - $sep = ' | '; +$sep = ""; +foreach ($menu_options as $option => $text) +{ + echo($sep); + if ($vars['view'] == $option) + { + echo(""); + } + echo('' . $text . ''); + if ($vars['view'] == $option) + { + echo(""); + } + $sep = " | "; } unset($sep); print_optionbar_end(); -echo ''; +echo('
    '); -foreach (getlocations() as $location) { - if ($_SESSION['userlevel'] >= '10') { - $num = dbFetchCell('SELECT COUNT(device_id) FROM devices WHERE location = ?', array($location)); - $net = dbFetchCell("SELECT COUNT(device_id) FROM devices WHERE location = ? AND type = 'network'", array($location)); - $srv = dbFetchCell("SELECT COUNT(device_id) FROM devices WHERE location = ? AND type = 'server'", array($location)); - $fwl = dbFetchCell("SELECT COUNT(device_id) FROM devices WHERE location = ? AND type = 'firewall'", array($location)); - $hostalerts = dbFetchCell("SELECT COUNT(device_id) FROM devices WHERE location = ? AND status = '0'", array($location)); - } - else { - $num = dbFetchCell('SELECT COUNT(D.device_id) FROM devices AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = ? AND location = ?', array($_SESSION['user_id'], $location)); - $net = dbFetchCell("SELECT COUNT(D.device_id) FROM devices AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = ? AND location = ? AND D.type = 'network'", array($_SESSION['user_id'], $location)); - $srv = dbFetchCell("SELECT COUNT(D.device_id) FROM devices AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = ? AND location = ? AND type = 'server'", array($_SESSION['user_id'], $location)); - $fwl = dbFetchCell("SELECT COUNT(D.device_id) FROM devices AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = ? AND location = ? AND type = 'firewall'", array($_SESSION['user_id'], $location)); - $hostalerts = dbFetchCell("SELECT COUNT(device_id) FROM devices AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = ? AND location = ? AND status = '0'", array($_SESSION['user_id'], $location)); +foreach (getlocations() as $location) +{ + if ($_SESSION['userlevel'] >= '10') + { + $num = dbFetchCell("SELECT COUNT(device_id) FROM devices WHERE location = ?", array($location)); + $net = dbFetchCell("SELECT COUNT(device_id) FROM devices WHERE location = ? AND type = 'network'", array($location)); + $srv = dbFetchCell("SELECT COUNT(device_id) FROM devices WHERE location = ? AND type = 'server'", array($location)); + $fwl = dbFetchCell("SELECT COUNT(device_id) FROM devices WHERE location = ? AND type = 'firewall'", array($location)); + $hostalerts = dbFetchCell("SELECT COUNT(device_id) FROM devices WHERE location = ? AND status = '0'", array($location)); + } else { + $num = dbFetchCell("SELECT COUNT(D.device_id) FROM devices AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = ? AND location = ?", array($_SESSION['user_id'], $location)); + $net = dbFetchCell("SELECT COUNT(D.device_id) FROM devices AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = ? AND location = ? AND D.type = 'network'", array($_SESSION['user_id'], $location)); + $srv = dbFetchCell("SELECT COUNT(D.device_id) FROM devices AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = ? AND location = ? AND type = 'server'", array($_SESSION['user_id'], $location)); + $fwl = dbFetchCell("SELECT COUNT(D.device_id) FROM devices AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = ? AND location = ? AND type = 'firewall'", array($_SESSION['user_id'], $location)); + $hostalerts = dbFetchCell("SELECT COUNT(device_id) FROM devices AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = ? AND location = ? AND status = '0'", array($_SESSION['user_id'], $location)); + } + + if ($hostalerts) { $alert = 'alert'; } else { $alert = ""; } + + if ($location != "") + { + echo(' + + + + + + + + '); + + if ($vars['view'] == "traffic") + { + echo('"); } + $done = "yes"; + } +} - if ($hostalerts) { - $alert = 'alert'; - } - else { - $alert = ''; - } +echo("
    ' . $location . '' . $alert . '' . $num . ' devices' . $net . ' network' . $srv . ' servers' . $fwl . ' firewalls
    '); + + $graph_array['type'] = "location_bits"; + $graph_array['height'] = "100"; + $graph_array['width'] = "220"; + $graph_array['to'] = $config['time']['now']; + $graph_array['legend'] = "no"; + $graph_array['id'] = $location; + + include("includes/print-graphrow.inc.php"); + + echo("
    "); - if ($location != '') { - echo ' - '.$location.' - '.$alert.' - '.$num.' devices - '.$net.' network - '.$srv.' servers - '.$fwl.' firewalls - - '; - - if ($vars['view'] == 'traffic') { - echo ''; - - $graph_array['type'] = 'location_bits'; - $graph_array['height'] = '100'; - $graph_array['width'] = '220'; - $graph_array['to'] = $config['time']['now']; - $graph_array['legend'] = 'no'; - $graph_array['id'] = $location; - - include 'includes/print-graphrow.inc.php'; - - echo ''; - } - - $done = 'yes'; - }//end if -}//end foreach - -echo ''; +?> diff --git a/html/pages/logon.inc.php b/html/pages/logon.inc.php index a8a156574d..e9819b1b01 100644 --- a/html/pages/logon.inc.php +++ b/html/pages/logon.inc.php @@ -1,8 +1,7 @@
    @@ -33,12 +32,14 @@ else {
    'error','message'=>$auth_message,'title'=>'Login error'); } ?>
    diff --git a/html/pages/map.inc.php b/html/pages/map.inc.php index 115c0600c3..0fa1cbb5f7 100644 --- a/html/pages/map.inc.php +++ b/html/pages/map.inc.php @@ -10,5 +10,6 @@ * option) any later version. Please see LICENSE.txt at the top level of * the source code distribution for details. */ -$pagetitle[] = 'Map'; -require_once 'includes/print-map.inc.php'; +$pagetitle[] = "Map"; +require_once "includes/print-map.inc.php"; +?> diff --git a/html/pages/packages.inc.php b/html/pages/packages.inc.php index ab26fd00a9..c3e79c8cf6 100644 --- a/html/pages/packages.inc.php +++ b/html/pages/packages.inc.php @@ -2,7 +2,8 @@ foreach ($vars as $var => $value) { if ($value != '') { - switch ($var) { + switch ($var) + { case 'name': $where .= " AND `$var` = ?"; $param[] = $value; @@ -25,7 +26,8 @@ foreach (dbFetchRows("SELECT * FROM `packages` WHERE 1 $where GROUP BY `name`", foreach ($entry['blah'] as $version => $bleu) { $content = '
    '; - foreach ($bleu as $build => $bloo) { + foreach ($bleu as $build => $bloo) + { if ($build) { $dbuild = '-'.$build; } @@ -34,7 +36,8 @@ foreach (dbFetchRows("SELECT * FROM `packages` WHERE 1 $where GROUP BY `name`", } $content .= '
    '.$version.$dbuild.''; - foreach ($bloo as $device_id => $no) { + foreach ($bloo as $device_id => $no) + { $this_device = device_by_id_cache($device_id); $content .= ''.$this_device['hostname'].' '; } diff --git a/html/pages/plugin.inc.php b/html/pages/plugin.inc.php index 1f718acff2..daec96f46b 100644 --- a/html/pages/plugin.inc.php +++ b/html/pages/plugin.inc.php @@ -1,18 +1,24 @@ 'plugin'); +$link_array = array('page' => 'plugin'); -$pagetitle[] = 'Plugin'; +$pagetitle[] = "Plugin"; -if ($vars['view'] == 'admin') { - include_once 'pages/plugin/admin.inc.php'; +if ($vars['view'] == "admin") +{ + include_once('pages/plugin/admin.inc.php'); } -else { - $plugin = dbFetchRow("SELECT `plugin_name` FROM `plugins` WHERE `plugin_name` = '".$vars['p']."' AND `plugin_active`='1'"); - if (!empty($plugin)) { - include 'plugins/'.$plugin['plugin_name'].'/'.$plugin['plugin_name'].'.inc.php'; - } - else { - print_error('This plugin is either disabled or not available.'); - } +else +{ + $plugin = dbFetchRow("SELECT `plugin_name` FROM `plugins` WHERE `plugin_name` = '".$vars['p']."' AND `plugin_active`='1'"); + if(!empty($plugin)) + { + require('plugins/'.$plugin['plugin_name'].'/'.$plugin['plugin_name'].'.inc.php'); + } + else + { + print_error( "This plugin is either disabled or not available." ); + } } + +?> diff --git a/html/pages/plugin/admin.inc.php b/html/pages/plugin/admin.inc.php index e20bec1b64..1773d641d8 100644 --- a/html/pages/plugin/admin.inc.php +++ b/html/pages/plugin/admin.inc.php @@ -1,26 +1,33 @@ = '10') { - // Scan for new plugins and add to the database - $new_plugins = scan_new_plugins(); +if ($_SESSION['userlevel'] >= '10') +{ + + // Scan for new plugins and add to the database + $new_plugins = scan_new_plugins(); - // Check if we have to toggle enabled / disable a particular module - $plugin_id = $_POST['plugin_id']; - $plugin_active = $_POST['plugin_active']; - if (is_numeric($plugin_id) && is_numeric($plugin_active)) { - if ($plugin_active == '0') { - $plugin_active = 1; - } - else if ($plugin_active == '1') { - $plugin_active = 0; - } - else { - $plugin_active = 0; - } + // Check if we have to toggle enabled / disable a particular module + $plugin_id = $_POST['plugin_id']; + $plugin_active = $_POST['plugin_active']; + if(is_numeric($plugin_id) && is_numeric($plugin_active)) + { + if( $plugin_active == '0') + { + $plugin_active = 1; + } + elseif( $plugin_active == '1') + { + $plugin_active = 0; + } + else + { + $plugin_active = 0; + } - if (dbUpdate(array('plugin_active' => $plugin_active), 'plugins', '`plugin_id` = ?', array($plugin_id))) { - echo ' + if(dbUpdate(array('plugin_active' => $plugin_active), 'plugins', '`plugin_id` = ?', array($plugin_id))) + { + echo(' -'; - } - }//end if +'); + } + + } ?> @@ -41,13 +49,14 @@ $.ajax({ System plugins
    0) { - echo '
    + if($new_plugins > 0) + { + echo('
    - We have found '.$new_plugins.' new plugins that need to be configured and enabled + We have found ' . $new_plugins . ' new plugins that need to be configured and enabled
    -
    '; -} +
    '); + } ?> @@ -56,21 +65,24 @@ if ($new_plugins > 0) { + foreach (dbFetchRows("SELECT * FROM plugins") as $plugins) + { + if($plugins['plugin_active'] == 1) + { + $plugin_colour = 'bg-success'; + $plugin_button = 'danger'; + $plugin_label = 'Disable'; + } + else + { + $plugin_colour = 'bg-danger'; + $plugin_button = 'success'; + $plugin_label = 'Enable'; + } + echo(' - '; -}//end foreach + '); + } + ?>
    - '.$plugins['plugin_name'].' + '. $plugins['plugin_name'] . ' @@ -79,14 +91,18 @@ foreach (dbFetchRows('SELECT * FROM plugins') as $plugins) {
    diff --git a/html/pages/poll-log.inc.php b/html/pages/poll-log.inc.php index 91ef8132e2..3abdf05a8e 100644 --- a/html/pages/poll-log.inc.php +++ b/html/pages/poll-log.inc.php @@ -1,5 +1,5 @@ diff --git a/html/pages/pollers.inc.php b/html/pages/pollers.inc.php index 3fef3d931c..de85c2344c 100644 --- a/html/pages/pollers.inc.php +++ b/html/pages/pollers.inc.php @@ -12,32 +12,25 @@ * the source code distribution for details. */ -$no_refresh = true; +$no_refresh = TRUE; -echo ''); if (isset($vars['tab'])) { - include_once 'pages/pollers/'.mres($vars['tab']).'.inc.php'; + require_once "pages/pollers/".mres($vars['tab']).".inc.php"; } diff --git a/html/pages/pollers/groups.inc.php b/html/pages/pollers/groups.inc.php index a914650ae2..50019dfc26 100644 --- a/html/pages/pollers/groups.inc.php +++ b/html/pages/pollers/groups.inc.php @@ -12,7 +12,7 @@ * the source code distribution for details. */ -require_once 'includes/modal/poller_groups.inc.php'; +require_once "includes/modal/poller_groups.inc.php"; ?>
    @@ -28,17 +28,18 @@ require_once 'includes/modal/poller_groups.inc.php'; + echo(' + -'; +'); } ?> diff --git a/html/pages/pollers/pollers.inc.php b/html/pages/pollers/pollers.inc.php index f948d3a8b1..c5e0eb2799 100644 --- a/html/pages/pollers/pollers.inc.php +++ b/html/pages/pollers/pollers.inc.php @@ -24,28 +24,26 @@ = 300) { $row_class = 'danger'; - } - else if ($old >= 280 && $old < 300) { + } elseif ($old >= 280 && $old < 300) { $row_class = 'warning'; - } - else { + } else { $row_class = 'success'; } - - echo ' + echo(' -'; +'); } ?> diff --git a/html/pages/ports.inc.php b/html/pages/ports.inc.php index edeea9fbef..8ff1f7d344 100644 --- a/html/pages/ports.inc.php +++ b/html/pages/ports.inc.php @@ -4,27 +4,29 @@ $pagetitle[] = "Ports"; // Set Defaults here -if(!isset($vars['format'])) { - $vars['format'] = "list_basic"; -} +if(!isset($vars['format'])) { $vars['format'] = "list_basic"; } print_optionbar_start(); echo('Lists » '); -$menu_options = array('basic' => 'Basic', 'detail' => 'Detail'); +$menu_options = array('basic' => 'Basic', + 'detail' => 'Detail'); $sep = ""; -foreach ($menu_options as $option => $text) { - echo($sep); - if ($vars['format'] == "list_".$option) { - echo(""); - } - echo('' . $text . ''); - if ($vars['format'] == "list_".$option) { - echo(""); - } - $sep = " | "; +foreach ($menu_options as $option => $text) +{ + echo($sep); + if ($vars['format'] == "list_".$option) + { + echo(""); + } + echo('' . $text . ''); + if ($vars['format'] == "list_".$option) + { + echo(""); + } + $sep = " | "; } ?> @@ -35,21 +37,24 @@ foreach ($menu_options as $option => $text) { 'Bits', - 'upkts' => 'Unicast Packets', - 'nupkts' => 'Non-Unicast Packets', - 'errors' => 'Errors'); + 'upkts' => 'Unicast Packets', + 'nupkts' => 'Non-Unicast Packets', + 'errors' => 'Errors'); $sep = ""; -foreach ($menu_options as $option => $text) { - echo($sep); - if ($vars['format'] == 'graph_'.$option) { - echo(''); - } - echo('' . $text . ''); - if ($vars['format'] == 'graph_'.$option) { - echo(""); - } - $sep = " | "; +foreach ($menu_options as $option => $text) +{ + echo($sep); + if ($vars['format'] == 'graph_'.$option) + { + echo(''); + } + echo('' . $text . ''); + if ($vars['format'] == 'graph_'.$option) + { + echo(""); + } + $sep = " | "; } echo('
    '); @@ -59,28 +64,29 @@ echo('
    '); Update URL | '')).'">Search'); -} -else { + } else { echo('Search'); -} + } -echo(" | "); + echo(" | "); -if (isset($vars['bare']) && $vars['bare'] == "yes") { + if (isset($vars['bare']) && $vars['bare'] == "yes") + { echo('Header'); -} -else { + } else { echo('Header'); -} + } echo('
    '); print_optionbar_end(); print_optionbar_start(); -if((isset($vars['searchbar']) && $vars['searchbar'] != "hide") || !isset($vars['searchbar'])) { +if((isset($vars['searchbar']) && $vars['searchbar'] != "hide") || !isset($vars['searchbar'])) +{ ?>
    @@ -89,66 +95,67 @@ if((isset($vars['searchbar']) && $vars['searchbar'] != "hide") || !isset($vars[' = 5) { - $results = dbFetchRows("SELECT `device_id`,`hostname` FROM `devices` GROUP BY `hostname` ORDER BY `hostname`"); - } - else { - $results = dbFetchRows("SELECT `D`.`device_id`,`D`.`hostname` FROM `devices` AS `D`, `devices_perms` AS `P` WHERE `P`.`user_id` = ? AND `P`.`device_id` = `D`.`device_id` GROUP BY `hostname` ORDER BY `hostname`", array($_SESSION['user_id'])); - } - foreach ($results as $data) { - echo(' "); - } +if($_SESSION['userlevel'] >= 5) +{ + $results = dbFetchRows("SELECT `device_id`,`hostname` FROM `devices` GROUP BY `hostname` ORDER BY `hostname`"); +} +else +{ + $results = dbFetchRows("SELECT `D`.`device_id`,`D`.`hostname` FROM `devices` AS `D`, `devices_perms` AS `P` WHERE `P`.`user_id` = ? AND `P`.`device_id` = `D`.`device_id` GROUP BY `hostname` ORDER BY `hostname`", array($_SESSION['user_id'])); +} +foreach ($results as $data) +{ + echo(' "); +} - if($_SESSION['userlevel'] < 5) { - $results = dbFetchRows("SELECT `D`.`device_id`,`D`.`hostname` FROM `ports` AS `I` JOIN `devices` AS `D` ON `D`.`device_id`=`I`.`device_id` JOIN `ports_perms` AS `PP` ON `PP`.`port_id`=`I`.`port_id` WHERE `PP`.`user_id` = ? AND `PP`.`port_id` = `I`.`port_id` GROUP BY `hostname` ORDER BY `hostname`", array($_SESSION['user_id'])); - } - else { - $results = array(); - } - foreach ($results as $data) { - echo(' "); - } +if($_SESSION['userlevel'] < 5) +{ + $results = dbFetchRows("SELECT `D`.`device_id`,`D`.`hostname` FROM `ports` AS `I` JOIN `devices` AS `D` ON `D`.`device_id`=`I`.`device_id` JOIN `ports_perms` AS `PP` ON `PP`.`port_id`=`I`.`port_id` WHERE `PP`.`user_id` = ? AND `PP`.`port_id` = `I`.`port_id` GROUP BY `hostname` ORDER BY `hostname`", array($_SESSION['user_id'])); +} +else +{ + $results = array(); +} +foreach ($results as $data) +{ + echo(' "); +} ?> - placeholder="Hostname" /> + placeholder="Hostname" />
    @@ -157,100 +164,97 @@ if((isset($vars['searchbar']) && $vars['searchbar'] != "hide") || !isset($vars[' ".$data['ifType'].""); - } - } +if (is_admin() === TRUE || is_read() === TRUE) { + $sql = "SELECT `ifType` FROM `ports` GROUP BY `ifType` ORDER BY `ifType`"; +} else { + $sql = "SELECT `ifType` FROM `ports` AS `I`, `devices` AS `D`, `devices_perms` AS `P`, `ports_perms` AS `PP` WHERE ((`P`.`user_id` = ? AND `P`.`device_id` = `D`.`device_id`) OR (`PP`.`user_id` = ? AND `PP`.`port_id` = `I`.`port_id` AND `I`.`device_id` = `D`.`device_id`)) AND `D`.`device_id` = `I`.`device_id` GROUP BY `ifType` ORDER BY `ifType`"; + $param[] = array($_SESSION['user_id'],$_SESSION['user_id']); +} +foreach (dbFetchRows($sql,$param) as $data) +{ + if ($data['ifType']) + { + echo(' "); + } +} ?>
    - placeholder="Port Description"/> + placeholder="Port Description"/>
    - > + > - > + > - > + >
    @@ -262,98 +266,95 @@ if((isset($vars['searchbar']) && $vars['searchbar'] != "hide") || !isset($vars['
    '.$group['id'].' '.$group['group_name'].' '.$group['descr'].'
    '.$poller['poller_name'].' '.$poller['devices'].' '.$poller['time_taken'].' Seconds '.$poller['last_polled'].'
    - $value) { - if ($value != "") { - switch ($var) { - case 'hostname': - $where .= " AND D.hostname LIKE ?"; - $param[] = "%".$value."%"; - break; - case 'location': - $where .= " AND D.location LIKE ?"; - $param[] = "%".$value."%"; - break; - case 'device_id': - $where .= " AND D.device_id = ?"; - $param[] = $value; - break; - case 'deleted': - if ($value == 1) { - $where .= " AND `I`.`deleted` = 1"; - $ignore_filter = 1; - } - break; - case 'ignore': - if ($value == 1) { - $where .= " AND (I.ignore = 1 OR D.ignore = 1) AND I.deleted = 0"; - $ignore_filter = 1; - } - break; - case 'disabled': - if ($value == 1) { - $where .= " AND `I`.`disabled` = 1 AND `I`.`deleted` = 0"; - $disabled_filter = 1; - } - break; - case 'ifSpeed': - if (is_numeric($value)) { - $where .= " AND I.$var = ?"; - $param[] = $value; - } - break; - case 'ifType': - $where .= " AND I.$var = ?"; - $param[] = $value; - break; - case 'ifAlias': - case 'port_descr_type': - $where .= " AND I.$var LIKE ?"; - $param[] = "%".$value."%"; - break; - case 'errors': - if ($value == 1) { - $where .= " AND (I.`ifInErrors_delta` > '0' OR I.`ifOutErrors_delta` > '0')"; - } - break; - case 'state': - if ($value == "down") { - $where .= "AND I.ifAdminStatus = ? AND I.ifOperStatus = ?"; - $param[] = "up"; - $param[] = "down"; - } - elseif($value == "up") { - $where .= "AND I.ifAdminStatus = ? AND I.ifOperStatus = ? AND I.ignore = '0' AND D.ignore='0' AND I.deleted='0'"; - $param[] = "up"; - $param[] = "up"; - } - elseif($value == "admindown") { - $where .= "AND I.ifAdminStatus = ? AND D.ignore = 0"; - $param[] = "down"; - } - break; +foreach ($vars as $var => $value) +{ + if ($value != "") + { + switch ($var) + { + case 'hostname': + $where .= " AND D.hostname LIKE ?"; + $param[] = "%".$value."%"; + break; + case 'location': + $where .= " AND D.location LIKE ?"; + $param[] = "%".$value."%"; + break; + case 'device_id': + $where .= " AND D.device_id = ?"; + $param[] = $value; + break; + case 'deleted': + if ($value == 1) { + $where .= " AND `I`.`deleted` = 1"; + $ignore_filter = 1; } + break; + case 'ignore': + if ($value == 1) { + $where .= " AND (I.ignore = 1 OR D.ignore = 1) AND I.deleted = 0"; + $ignore_filter = 1; + } + break; + case 'disabled': + if ($value == 1) { + $where .= " AND `I`.`disabled` = 1 AND `I`.`deleted` = 0"; + $disabled_filter = 1; + } + break; + case 'ifSpeed': + if (is_numeric($value)) + { + $where .= " AND I.$var = ?"; + $param[] = $value; + } + break; + case 'ifType': + $where .= " AND I.$var = ?"; + $param[] = $value; + break; + case 'ifAlias': + case 'port_descr_type': + $where .= " AND I.$var LIKE ?"; + $param[] = "%".$value."%"; + break; + case 'errors': + if ($value == 1) + { + $where .= " AND (I.`ifInErrors_delta` > '0' OR I.`ifOutErrors_delta` > '0')"; + } + break; + case 'state': + if ($value == "down") + { + $where .= "AND I.ifAdminStatus = ? AND I.ifOperStatus = ?"; + $param[] = "up"; + $param[] = "down"; + } elseif($value == "up") { + $where .= "AND I.ifAdminStatus = ? AND I.ifOperStatus = ? AND I.ignore = '0' AND D.ignore='0' AND I.deleted='0'"; + $param[] = "up"; + $param[] = "up"; + } elseif($value == "admindown") { + $where .= "AND I.ifAdminStatus = ? AND D.ignore = 0"; + $param[] = "down"; + } + break; } + } } if ($ignore_filter == 0 && $disabled_filter == 0) { @@ -368,47 +369,49 @@ list($format, $subformat) = explode("_", $vars['format']); $ports = dbFetchRows($query, $param); -switch ($vars['sort']) { - case 'traffic': - $ports = array_sort($ports, 'ifOctets_rate', SORT_DESC); - break; - case 'traffic_in': - $ports = array_sort($ports, 'ifInOctets_rate', SORT_DESC); - break; - case 'traffic_out': - $ports = array_sort($ports, 'ifOutOctets_rate', SORT_DESC); - break; - case 'packets': - $ports = array_sort($ports, 'ifUcastPkts_rate', SORT_DESC); - break; - case 'packets_in': - $ports = array_sort($ports, 'ifInUcastOctets_rate', SORT_DESC); - break; - case 'packets_out': - $ports = array_sort($ports, 'ifOutUcastOctets_rate', SORT_DESC); - break; - case 'errors': - $ports = array_sort($ports, 'ifErrors_rate', SORT_DESC); - break; - case 'speed': - $ports = array_sort($ports, 'ifSpeed', SORT_DESC); - break; - case 'port': - $ports = array_sort($ports, 'ifDescr', SORT_ASC); - break; - case 'media': - $ports = array_sort($ports, 'ifType', SORT_ASC); - break; - case 'descr': - $ports = array_sort($ports, 'ifAlias', SORT_ASC); - break; - case 'device': - default: - $ports = array_sort($ports, 'hostname', SORT_ASC); +switch ($vars['sort']) +{ + case 'traffic': + $ports = array_sort($ports, 'ifOctets_rate', SORT_DESC); + break; + case 'traffic_in': + $ports = array_sort($ports, 'ifInOctets_rate', SORT_DESC); + break; + case 'traffic_out': + $ports = array_sort($ports, 'ifOutOctets_rate', SORT_DESC); + break; + case 'packets': + $ports = array_sort($ports, 'ifUcastPkts_rate', SORT_DESC); + break; + case 'packets_in': + $ports = array_sort($ports, 'ifInUcastOctets_rate', SORT_DESC); + break; + case 'packets_out': + $ports = array_sort($ports, 'ifOutUcastOctets_rate', SORT_DESC); + break; + case 'errors': + $ports = array_sort($ports, 'ifErrors_rate', SORT_DESC); + break; + case 'speed': + $ports = array_sort($ports, 'ifSpeed', SORT_DESC); + break; + case 'port': + $ports = array_sort($ports, 'ifDescr', SORT_ASC); + break; + case 'media': + $ports = array_sort($ports, 'ifType', SORT_ASC); + break; + case 'descr': + $ports = array_sort($ports, 'ifAlias', SORT_ASC); + break; + case 'device': + default: + $ports = array_sort($ports, 'hostname', SORT_ASC); } -if(file_exists('pages/ports/'.$format.'.inc.php')) { - require 'pages/ports/'.$format.'.inc.php'; +if(file_exists('pages/ports/'.$format.'.inc.php')) +{ + include('pages/ports/'.$format.'.inc.php'); } ?> diff --git a/html/pages/ports/list.inc.php b/html/pages/ports/list.inc.php index 71f52e6180..8ae9c9df36 100644 --- a/html/pages/ports/list.inc.php +++ b/html/pages/ports/list.inc.php @@ -3,75 +3,68 @@ '; +echo(''); -$cols = array( - 'device' => 'Device', - 'port' => 'Port', - 'speed' => 'Speed', - 'traffic_in' => 'Down', - 'traffic_out' => 'Up', - 'media' => 'Media', - 'descr' => 'Description', -); +$cols = array('device' => 'Device', + 'port' => 'Port', + 'speed' => 'Speed', + 'traffic_in' => 'Down', + 'traffic_out' => 'Up', + 'media' => 'Media', + 'descr' => 'Description' ); -foreach ($cols as $sort => $col) { - if (isset($vars['sort']) && $vars['sort'] == $sort) { - echo ''.$col.' *'; - } - else { - echo ''.$col.''; - } +foreach ($cols as $sort => $col) +{ + if (isset($vars['sort']) && $vars['sort'] == $sort) + { + echo(''.$col.' *'); + } else { + echo(''.$col.''); + } } -echo ' '; +echo(" "); -$ports_disabled = 0; -$ports_down = 0; -$ports_up = 0; -$ports_total = 0; +$ports_disabled = 0; $ports_down = 0; $ports_up = 0; $ports_total = 0; -foreach ($ports as $port) { - if (port_permitted($port['port_id'], $port['device_id'])) { - if ($port['ifAdminStatus'] == 'down') { - $ports_disabled++; - } - else if ($port['ifAdminStatus'] == 'up' && $port['ifOperStatus'] == 'down') { - $ports_down++; - } - else if ($port['ifAdminStatus'] == 'up' && $port['ifOperStatus'] == 'up') { - $ports_up++; - } +foreach ($ports as $port) +{ - $ports_total++; + if (port_permitted($port['port_id'], $port['device_id'])) + { - $speed = humanspeed($port['ifSpeed']); - $type = humanmedia($port['ifType']); - $ifclass = ifclass($port['ifOperStatus'], $port['ifAdminStatus']); + if ($port['ifAdminStatus'] == "down") { $ports_disabled++; + } elseif ($port['ifAdminStatus'] == "up" && $port['ifOperStatus']== "down") { $ports_down++; + } elseif ($port['ifAdminStatus'] == "up" && $port['ifOperStatus']== "up") { $ports_up++; } + $ports_total++; - if ((isset($port['in_errors']) && $port['in_errors'] > 0) || (isset($ports['out_errors']) && $port['out_errors'] > 0)) { - $error_img = generate_port_link($port, "Interface Errors", errors); - } - else { - $error_img = ''; - } + $speed = humanspeed($port['ifSpeed']); + $type = humanmedia($port['ifType']); + $ifclass = ifclass($port['ifOperStatus'], $port['ifAdminStatus']); - $port['in_rate'] = formatRates(($port['ifInOctets_rate'] * 8)); - $port['out_rate'] = formatRates(($port['ifOutOctets_rate'] * 8)); + if ((isset($port['in_errors']) && $port['in_errors'] > 0) || (isset($ports['out_errors']) && $port['out_errors'] > 0)) + { + $error_img = generate_port_link($port,"Interface Errors",errors); + } else { $error_img = ""; } - $port = ifLabel($port, $device); - echo " - ".generate_device_link($port, shorthost($port['hostname'], '20'))." - ".fixIfName($port['label'])." $error_img - $speed - ".$port['in_rate'].' - '.$port['out_rate']." - $type - ".$port['ifAlias']." - \n"; - }//end if -}//end foreach + $port['in_rate'] = formatRates($port['ifInOctets_rate'] * 8); + $port['out_rate'] = formatRates($port['ifOutOctets_rate'] * 8); -echo ''; -echo "Matched Ports: $ports_total ( Up $ports_up | Down $ports_down | Disabled $ports_disabled )"; -echo ''; + $port = ifLabel($port, $device); + echo(" + ".generate_device_link($port, shorthost($port['hostname'], "20"))." + ".fixIfName($port['label'])." $error_img + $speed + ".$port['in_rate']." + ".$port['out_rate']." + $type + " . $port['ifAlias'] . " + \n"); + } +} + +echo(''); +echo("Matched Ports: $ports_total ( Up $ports_up | Down $ports_down | Disabled $ports_disabled )"); +echo(''); + +?> diff --git a/html/pages/preferences.inc.php b/html/pages/preferences.inc.php index ca2f798352..f4815df24e 100644 --- a/html/pages/preferences.inc.php +++ b/html/pages/preferences.inc.php @@ -1,41 +1,48 @@ User Preferences'; +echo("

    User Preferences

    "); if ($_SESSION['userlevel'] == 11) { + demo_account(); -} -else { - if ($_POST['action'] == 'changepass') { - if (authenticate($_SESSION['username'], $_POST['old_pass'])) { - if ($_POST['new_pass'] == '' || $_POST['new_pass2'] == '') { - $changepass_message = 'Password must not be blank.'; - } - else if ($_POST['new_pass'] == $_POST['new_pass2']) { - changepassword($_SESSION['username'], $_POST['new_pass']); - $changepass_message = 'Password Changed.'; - } - else { - $changepass_message = "Passwords don't match."; - } - } - else { - $changepass_message = 'Incorrect password'; - } + +} else { + +if ($_POST['action'] == "changepass") +{ + if (authenticate($_SESSION['username'],$_POST['old_pass'])) + { + if ($_POST['new_pass'] == "" || $_POST['new_pass2'] == "") + { + $changepass_message = "Password must not be blank."; } + elseif ($_POST['new_pass'] == $_POST['new_pass2']) + { + changepassword($_SESSION['username'],$_POST['new_pass']); + $changepass_message = "Password Changed."; + } + else + { + $changepass_message = "Passwords don't match."; + } + } else { + $changepass_message = "Incorrect password"; + } +} - include 'includes/update-preferences-password.inc.php'; +include("includes/update-preferences-password.inc.php"); - echo "
    "; +echo("
    "); - if (passwordscanchange($_SESSION['username'])) { - echo '

    Change Password

    '; - echo $changepass_message; - echo " +if (passwordscanchange($_SESSION['username'])) +{ + echo("

    Change Password

    "); + echo($changepass_message); + echo("
    @@ -62,107 +69,93 @@ else {
    -"; - echo '
    '; - }//end if +"); + echo("
    "); +} - if ($config['twofactor'] === true) { - if ($_POST['twofactorremove'] == 1) { - include_once $config['install_dir'].'/html/includes/authentication/twofactor.lib.php'; - if (!isset($_POST['twofactor'])) { - echo '
    '; - echo ''; - echo twofactor_form(false); - echo '
    '; - } - else { - $twofactor = dbFetchRow('SELECT twofactor FROM users WHERE username = ?', array($_SESSION['username'])); - if (empty($twofactor['twofactor'])) { - echo '
    Error: How did you even get here?!
    '; - } - else { - $twofactor = json_decode($twofactor['twofactor'], true); - } - - if (verify_hotp($twofactor['key'], $_POST['twofactor'], $twofactor['counter'])) { - if (!dbUpdate(array('twofactor' => ''), 'users', 'username = ?', array($_SESSION['username']))) { - echo '
    Error while disabling TwoFactor.
    '; - } - else { - echo '
    TwoFactor Disabled.
    '; - } - } - else { - session_destroy(); - echo '
    Error: Supplied TwoFactor Token is wrong, you\'ve been logged out.
    '; - } - }//end if +if( $config['twofactor'] === true ) { + if( $_POST['twofactorremove'] == 1 ) { + require_once($config['install_dir']."/html/includes/authentication/twofactor.lib.php"); + if( !isset($_POST['twofactor']) ) { + echo '
    '; + echo ''; + echo twofactor_form(false); + echo '
    '; + } else{ + $twofactor = dbFetchRow('SELECT twofactor FROM users WHERE username = ?', array($_SESSION['username'])); + if( empty($twofactor['twofactor']) ) { + echo '
    Error: How did you even get here?!
    '; + } else { + $twofactor = json_decode($twofactor['twofactor'],true); + } + if( verify_hotp($twofactor['key'],$_POST['twofactor'],$twofactor['counter']) ) { + if( !dbUpdate(array('twofactor' => ''),'users','username = ?',array($_SESSION['username'])) ) { + echo '
    Error while disabling TwoFactor.
    '; + } else { + echo '
    TwoFactor Disabled.
    '; } - else { - $twofactor = dbFetchRow('SELECT twofactor FROM users WHERE username = ?', array($_SESSION['username'])); - echo ''; - echo '

    Two-Factor Authentication

    '; - if (!empty($twofactor['twofactor'])) { - $twofactor = json_decode($twofactor['twofactor'], true); - $twofactor['text'] = "
    + } else { + session_destroy(); + echo '
    Error: Supplied TwoFactor Token is wrong, you\'ve been logged out.
    '; + } + } + } else { + $twofactor = dbFetchRow("SELECT twofactor FROM users WHERE username = ?", array($_SESSION['username'])); + echo ''; + echo '

    Two-Factor Authentication

    '; + if( !empty($twofactor['twofactor']) ) { + $twofactor = json_decode($twofactor['twofactor'],true); + $twofactor['text'] = "
    "; - if ($twofactor['counter'] !== false) { - $twofactor['uri'] = 'otpauth://hotp/'.$_SESSION['username'].'?issuer=LibreNMS&counter='.$twofactor['counter'].'&secret='.$twofactor['key']; - $twofactor['text'] .= "
    + if( $twofactor['counter'] !== false ) { + $twofactor['uri'] = "otpauth://hotp/".$_SESSION['username']."?issuer=LibreNMS&counter=".$twofactor['counter']."&secret=".$twofactor['key']; + $twofactor['text'] .= "
    "; - } - else { - $twofactor['uri'] = 'otpauth://totp/'.$_SESSION['username'].'?issuer=LibreNMS&secret='.$twofactor['key']; - } - - echo '
    + } else { + $twofactor['uri'] = "otpauth://totp/".$_SESSION['username']."?issuer=LibreNMS&secret=".$twofactor['key']; + } + echo '
    '; - echo '
    + echo '
    '.$twofactor['text'].'
    '; - echo ''; - echo '
    + echo ''; + echo '
    '; - } - else { - if (isset($_POST['gentwofactorkey']) && isset($_POST['twofactortype'])) { - include_once $config['install_dir'].'/html/includes/authentication/twofactor.lib.php'; - $chk = dbFetchRow('SELECT twofactor FROM users WHERE username = ?', array($_SESSION['username'])); - if (empty($chk['twofactor'])) { - $twofactor = array('key' => twofactor_genkey()); - if ($_POST['twofactortype'] == 'counter') { - $twofactor['counter'] = 1; - } - else { - $twofactor['counter'] = false; - } - - if (!dbUpdate(array('twofactor' => json_encode($twofactor)), 'users', 'username = ?', array($_SESSION['username']))) { - echo '
    Error inserting TwoFactor details. Please try again later and contact Administrator if error persists.
    '; - } - else { - echo '
    Added TwoFactor credentials. Please reload page.
    '; - } - } - else { - echo '
    TwoFactor credentials already exists.
    '; - } - } - else { - echo '
    + } else { + if( isset($_POST['gentwofactorkey']) && isset($_POST['twofactortype']) ) { + require_once($config['install_dir']."/html/includes/authentication/twofactor.lib.php"); + $chk = dbFetchRow("SELECT twofactor FROM users WHERE username = ?", array($_SESSION['username'])); + if( empty($chk['twofactor']) ) { + $twofactor = array('key' => twofactor_genkey()); + if( $_POST['twofactortype'] == "counter" ) { + $twofactor['counter'] = 1; + } else { + $twofactor['counter'] = false; + } + if( !dbUpdate(array('twofactor' => json_encode($twofactor)),'users','username = ?',array($_SESSION['username'])) ) { + echo '
    Error inserting TwoFactor details. Please try again later and contact Administrator if error persists.
    '; + } else { + echo '
    Added TwoFactor credentials. Please reload page.
    '; + } + } else { + echo '
    TwoFactor credentials already exists.
    '; + } + } else { + echo '
    @@ -176,34 +169,32 @@ else {
    '; - }//end if - }//end if - echo '
    '; - }//end if - }//end if -}//end if - -echo "
    '; + } } -echo '
    '; +} + +echo("
    "); +echo("
    Device Permissions
    "); + +if ($_SESSION['userlevel'] == '10') { echo("Global Administrative Access"); } +if ($_SESSION['userlevel'] == '5') { echo("Global Viewing Access"); } +if ($_SESSION['userlevel'] == '1') +{ + + foreach (dbFetchRows("SELECT * FROM `devices_perms` AS P, `devices` AS D WHERE `user_id` = ? AND P.device_id = D.device_id", array($_SESSION['user_id'])) as $perm) + { + #FIXME generatedevicelink? + echo("" . $perm['hostname'] . "
    "); + $dev_access = 1; + } + + if (!$dev_access) { echo("No access!"); } +} + +echo("
    "); + +?> diff --git a/html/pages/pseudowires.inc.php b/html/pages/pseudowires.inc.php index 3408973fd4..5dd77f468c 100644 --- a/html/pages/pseudowires.inc.php +++ b/html/pages/pseudowires.inc.php @@ -90,7 +90,8 @@ foreach (dbFetchRows('SELECT * FROM pseudowires AS P, ports AS I, devices AS D W $pw_a['to'] = $config['time']['now']; $pw_a['bg'] = $bg; $types = array('bits', 'upkts', 'errors'); - foreach ($types as $graph_type) { + foreach ($types as $graph_type) + { $pw_a['graph_type'] = 'port_'.$graph_type; print_port_thumbnail($pw_a); } diff --git a/html/pages/public.inc.php b/html/pages/public.inc.php index bb25838841..ad89593bcf 100644 --- a/html/pages/public.inc.php +++ b/html/pages/public.inc.php @@ -1,14 +1,14 @@ - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation, either version 3 of the License, or (at your - * option) any later version. Please see LICENSE.txt at the top level of - * the source code distribution for details. + * This file is part of LibreNMS + * + * Copyright (c) 2014 Bohdan Sanders + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. Please see LICENSE.txt at the top level of + * the source code distribution for details. */ ?> @@ -28,11 +28,14 @@ $(document).ready(function() {

    System Status

    @@ -47,8 +50,9 @@ $query = "SELECT * FROM `devices` WHERE 1 AND disabled='0' AND `ignore`='0' ORDE Uptime/Location diff --git a/html/pages/routing/bgp.inc.php b/html/pages/routing/bgp.inc.php index 3268715ec5..5e04945626 100644 --- a/html/pages/routing/bgp.inc.php +++ b/html/pages/routing/bgp.inc.php @@ -1,355 +1,260 @@ 'routing', - 'protocol' => 'bgp', - ); +else +{ + $link_array = array('page' => 'routing', 'protocol' => 'bgp'); - print_optionbar_start('', ''); + print_optionbar_start('', ''); - echo 'BGP » '; + echo('BGP » '); - if (!$vars['type']) { - $vars['type'] = 'all'; + if (!$vars['type']) { $vars['type'] = "all"; } + + if ($vars['type'] == "all") { echo(""); } + echo(generate_link("All",$vars, array('type' => 'all'))); + if ($vars['type'] == "all") { echo(""); } + + echo(" | "); + + if ($vars['type'] == "internal") { echo(""); } + echo(generate_link("iBGP",$vars, array('type' => 'internal'))); + if ($vars['type'] == "internal") { echo(""); } + + echo(" | "); + + if ($vars['type'] == "external") { echo(""); } + echo(generate_link("eBGP",$vars, array('type' => 'external'))); + if ($vars['type'] == "external") { echo(""); } + + echo(" | "); + + if ($vars['adminstatus'] == "stop") + { + echo(""); + echo(generate_link("Shutdown",$vars, array('adminstatus' => NULL))); + echo(""); + } else { + echo(generate_link("Shutdown",$vars, array('adminstatus' => 'stop'))); + } + + echo(" | "); + + if ($vars['adminstatus'] == "start") + { + echo(""); + echo(generate_link("Enabled",$vars, array('adminstatus' => NULL))); + echo(""); + } else { + echo(generate_link("Enabled",$vars, array('adminstatus' => 'start'))); + } + + echo(" | "); + + if ($vars['state'] == "down") + { + echo(""); + echo(generate_link("Down",$vars, array('state' => NULL))); + echo(""); + } else { + echo(generate_link("Down",$vars, array('state' => 'down'))); + } + + // End BGP Menu + + if (!isset($vars['view'])) { $vars['view'] = 'details'; } + + echo('
    '); + + if ($vars['view'] == "details") { echo(""); } + echo(generate_link("No Graphs",$vars, array('view' => 'details', 'graph' => 'NULL'))); + if ($vars['view'] == "details") { echo(""); } + + echo(" | "); + + if ($vars['graph'] == "updates") { echo(""); } + echo(generate_link("Updates",$vars, array('view' => 'graphs', 'graph' => 'updates'))); + if ($vars['graph'] == "updates") { echo(""); } + + echo(" | Prefixes: Unicast ("); + if ($vars['graph'] == "prefixes_ipv4unicast") { echo(""); } + echo(generate_link("IPv4",$vars, array('view' => 'graphs', 'graph' => 'prefixes_ipv4unicast'))); + if ($vars['graph'] == "prefixes_ipv4unicast") { echo(""); } + + echo("|"); + + if ($vars['graph'] == "prefixes_ipv6unicast") { echo(""); } + echo(generate_link("IPv6",$vars, array('view' => 'graphs', 'graph' => 'prefixes_ipv6unicast'))); + if ($vars['graph'] == "prefixes_ipv6unicast") { echo(""); } + + echo("|"); + + if ($vars['graph'] == "prefixes_ipv4vpn") { echo(""); } + echo(generate_link("VPNv4",$vars, array('view' => 'graphs', 'graph' => 'prefixes_ipv4vpn'))); + if ($vars['graph'] == "prefixes_ipv4vpn") { echo(""); } + echo(")"); + + echo(" | Multicast ("); + if ($vars['graph'] == "prefixes_ipv4multicast") { echo(""); } + echo(generate_link("IPv4",$vars, array('view' => 'graphs', 'graph' => 'prefixes_ipv4multicast'))); + if ($vars['graph'] == "prefixes_ipv4multicast") { echo(""); } + + echo("|"); + + if ($vars['graph'] == "prefixes_ipv6multicast") { echo(""); } + echo(generate_link("IPv6",$vars, array('view' => 'graphs', 'graph' => 'prefixes_ipv6multicast'))); + if ($vars['graph'] == "prefixes_ipv6multicast") { echo(""); } + echo(")"); + + echo(" | MAC ("); + if ($vars['graph'] == "macaccounting_bits") { echo(""); } + echo(generate_link("Bits",$vars, array('view' => 'graphs', 'graph' => 'macaccounting_bits'))); + if ($vars['graph'] == "macaccounting_bits") { echo(""); } + + echo("|"); + + if ($vars['graph'] == "macaccounting_pkts") { echo(""); } + echo(generate_link("Packets",$vars, array('view' => 'graphs', 'graph' => 'macaccounting_pkts'))); + if ($vars['graph'] == "macaccounting_pkts") { echo(""); } + echo(")"); + + echo('
    '); + + print_optionbar_end(); + + echo(""); + echo(''); + + if ($vars['type'] == "external") + { + $where = "AND D.bgpLocalAs != B.bgpPeerRemoteAs"; + } elseif ($vars['type'] == "internal") { + $where = "AND D.bgpLocalAs = B.bgpPeerRemoteAs"; + } + + if ($vars['adminstatus'] == "stop") + { + $where .= " AND (B.bgpPeerAdminStatus = 'stop')"; + } elseif ($vars['adminstatus'] == "start") + { + $where .= " AND (B.bgpPeerAdminStatus = 'start' || B.bgpPeerAdminStatus = 'running')"; + } + + if ($vars['state'] == "down") + { + $where .= " AND (B.bgpPeerState != 'established')"; + } + + $peer_query = "select * from bgpPeers AS B, devices AS D WHERE B.device_id = D.device_id ".$where." ORDER BY D.hostname, B.bgpPeerRemoteAs, B.bgpPeerIdentifier"; + foreach (dbFetchRows($peer_query) as $peer) + { + unset ($alert, $bg_image); + + if ($peer['bgpPeerState'] == "established") { $col = "green"; } else { $col = "red"; $peer['alert']=1; } + if ($peer['bgpPeerAdminStatus'] == "start" || $peer['bgpPeerAdminStatus'] == "running") { $admin_col = "green"; } else { $admin_col = "gray"; } + if ($peer['bgpPeerAdminStatus'] == "stop") { $peer['alert']=0; $peer['disabled']=1; } + if ($peer['bgpPeerRemoteAs'] == $peer['bgpLocalAs']) { $peer_type = "iBGP"; } else { $peer_type = "eBGP"; + if ($peer['bgpPeerRemoteAS'] >= '64512' && $peer['bgpPeerRemoteAS'] <= '65535') { $peer_type = "Priv eBGP"; } } - if ($vars['type'] == 'all') { - echo ""; + $peerhost = dbFetchRow("SELECT * FROM ipaddr AS A, ports AS I, devices AS D WHERE A.addr = ? AND I.port_id = A.port_id AND D.device_id = I.device_id", array($peer['bgpPeerIdentifier'])); + + if ($peerhost) { $peername = generate_device_link($peerhost, shorthost($peerhost['hostname'])); } else { unset($peername); } + + // display overlib graphs + + $graph_type = "bgp_updates"; + $local_daily_url = "graph.php?id=" . $peer['bgpPeer_id'] . "&type=" . $graph_type . "&from=".$config['time']['day']."&to=".$config['time']['now']."&width=500&height=150&&afi=ipv4&safi=unicast"; + if (filter_var($peer['bgpLocalAddr'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) !== FALSE) { + $peer_ip = Net_IPv6::compress($peer['bgpLocalAddr']); + } else { + $peer_ip = $peer['bgpLocalAddr']; + } + $localaddresslink = "', LEFT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\">" . $peer_ip . ""; + + $graph_type = "bgp_updates"; + $peer_daily_url = "graph.php?id=" . $peer['bgpPeer_id'] . "&type=" . $graph_type . "&from=".$config['time']['day']."&to=".$config['time']['now']."&width=500&height=150"; + if (filter_var($peer['bgpPeerIdentifier'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) !== FALSE) { + $peer_ident = Net_IPv6::compress($peer['bgpPeerIdentifier']); + } else { + $peer_ident = $peer['bgpPeerIdentifier']; } - echo generate_link('All', $vars, array('type' => 'all')); - if ($vars['type'] == 'all') { - echo ''; + $peeraddresslink = "', LEFT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\">" . $peer_ident . ""; + + echo('"); + + unset($sep); + foreach (dbFetchRows("SELECT * FROM `bgpPeers_cbgp` WHERE `device_id` = ? AND bgpPeerIdentifier = ?", array($peer['device_id'], $peer['bgpPeerIdentifier'])) as $afisafi) + { + $afi = $afisafi['afi']; + $safi = $afisafi['safi']; + $this_afisafi = $afi.$safi; + $peer['afi'] .= $sep . $afi .".".$safi; + $sep = "
    "; + $peer['afisafi'][$this_afisafi] = 1; // Build a list of valid AFI/SAFI for this peer } + unset($sep); - echo ' | '; - - if ($vars['type'] == 'internal') { - echo ""; - } - - echo generate_link('iBGP', $vars, array('type' => 'internal')); - if ($vars['type'] == 'internal') { - echo ''; - } - - echo ' | '; - - if ($vars['type'] == 'external') { - echo ""; - } - - echo generate_link('eBGP', $vars, array('type' => 'external')); - if ($vars['type'] == 'external') { - echo ''; - } - - echo ' | '; - - if ($vars['adminstatus'] == 'stop') { - echo ""; - echo generate_link('Shutdown', $vars, array('adminstatus' => null)); - echo ''; - } - else { - echo generate_link('Shutdown', $vars, array('adminstatus' => 'stop')); - } - - echo ' | '; - - if ($vars['adminstatus'] == 'start') { - echo ""; - echo generate_link('Enabled', $vars, array('adminstatus' => null)); - echo ''; - } - else { - echo generate_link('Enabled', $vars, array('adminstatus' => 'start')); - } - - echo ' | '; - - if ($vars['state'] == 'down') { - echo ""; - echo generate_link('Down', $vars, array('state' => null)); - echo ''; - } - else { - echo generate_link('Down', $vars, array('state' => 'down')); - } - - // End BGP Menu - if (!isset($vars['view'])) { - $vars['view'] = 'details'; - } - - echo '
    '; - - if ($vars['view'] == 'details') { - echo ""; - } - - echo generate_link('No Graphs', $vars, array('view' => 'details', 'graph' => 'NULL')); - if ($vars['view'] == 'details') { - echo ''; - } - - echo ' | '; - - if ($vars['graph'] == 'updates') { - echo ""; - } - - echo generate_link('Updates', $vars, array('view' => 'graphs', 'graph' => 'updates')); - if ($vars['graph'] == 'updates') { - echo ''; - } - - echo ' | Prefixes: Unicast ('; - if ($vars['graph'] == 'prefixes_ipv4unicast') { - echo ""; - } - - echo generate_link('IPv4', $vars, array('view' => 'graphs', 'graph' => 'prefixes_ipv4unicast')); - if ($vars['graph'] == 'prefixes_ipv4unicast') { - echo ''; - } - - echo '|'; - - if ($vars['graph'] == 'prefixes_ipv6unicast') { - echo ""; - } - - echo generate_link('IPv6', $vars, array('view' => 'graphs', 'graph' => 'prefixes_ipv6unicast')); - if ($vars['graph'] == 'prefixes_ipv6unicast') { - echo ''; - } - - echo '|'; - - if ($vars['graph'] == 'prefixes_ipv4vpn') { - echo ""; - } - - echo generate_link('VPNv4', $vars, array('view' => 'graphs', 'graph' => 'prefixes_ipv4vpn')); - if ($vars['graph'] == 'prefixes_ipv4vpn') { - echo ''; - } - - echo ')'; - - echo ' | Multicast ('; - if ($vars['graph'] == 'prefixes_ipv4multicast') { - echo ""; - } - - echo generate_link('IPv4', $vars, array('view' => 'graphs', 'graph' => 'prefixes_ipv4multicast')); - if ($vars['graph'] == 'prefixes_ipv4multicast') { - echo ''; - } - - echo '|'; - - if ($vars['graph'] == 'prefixes_ipv6multicast') { - echo ""; - } - - echo generate_link('IPv6', $vars, array('view' => 'graphs', 'graph' => 'prefixes_ipv6multicast')); - if ($vars['graph'] == 'prefixes_ipv6multicast') { - echo ''; - } - - echo ')'; - - echo ' | MAC ('; - if ($vars['graph'] == 'macaccounting_bits') { - echo ""; - } - - echo generate_link('Bits', $vars, array('view' => 'graphs', 'graph' => 'macaccounting_bits')); - if ($vars['graph'] == 'macaccounting_bits') { - echo ''; - } - - echo '|'; - - if ($vars['graph'] == 'macaccounting_pkts') { - echo ""; - } - - echo generate_link('Packets', $vars, array('view' => 'graphs', 'graph' => 'macaccounting_pkts')); - if ($vars['graph'] == 'macaccounting_pkts') { - echo ''; - } - - echo ')'; - - echo '
    '; - - print_optionbar_end(); - - echo "
    Local addressPeer addressTypeFamilyRemote ASStateUptime / Updates
    "; - echo ''; - - if ($vars['type'] == 'external') { - $where = 'AND D.bgpLocalAs != B.bgpPeerRemoteAs'; - } - else if ($vars['type'] == 'internal') { - $where = 'AND D.bgpLocalAs = B.bgpPeerRemoteAs'; - } - - if ($vars['adminstatus'] == 'stop') { - $where .= " AND (B.bgpPeerAdminStatus = 'stop')"; - } - else if ($vars['adminstatus'] == 'start') { - $where .= " AND (B.bgpPeerAdminStatus = 'start' || B.bgpPeerAdminStatus = 'running')"; - } - - if ($vars['state'] == 'down') { - $where .= " AND (B.bgpPeerState != 'established')"; - } - - $peer_query = 'select * from bgpPeers AS B, devices AS D WHERE B.device_id = D.device_id '.$where.' ORDER BY D.hostname, B.bgpPeerRemoteAs, B.bgpPeerIdentifier'; - foreach (dbFetchRows($peer_query) as $peer) { - unset($alert, $bg_image); - - if ($peer['bgpPeerState'] == 'established') { - $col = 'green'; - } - else { - $col = 'red'; - $peer['alert'] = 1; - } - - if ($peer['bgpPeerAdminStatus'] == 'start' || $peer['bgpPeerAdminStatus'] == 'running') { - $admin_col = 'green'; - } - else { - $admin_col = 'gray'; - } - - if ($peer['bgpPeerAdminStatus'] == 'stop') { - $peer['alert'] = 0; - $peer['disabled'] = 1; - } - - if ($peer['bgpPeerRemoteAs'] == $peer['bgpLocalAs']) { - $peer_type = "iBGP"; - } - else { - $peer_type = "eBGP"; - if ($peer['bgpPeerRemoteAS'] >= '64512' && $peer['bgpPeerRemoteAS'] <= '65535') { - $peer_type = "Priv eBGP"; - } - } - - $peerhost = dbFetchRow('SELECT * FROM ipaddr AS A, ports AS I, devices AS D WHERE A.addr = ? AND I.port_id = A.port_id AND D.device_id = I.device_id', array($peer['bgpPeerIdentifier'])); - - if ($peerhost) { - $peername = generate_device_link($peerhost, shorthost($peerhost['hostname'])); - } - else { - unset($peername); - } - - // display overlib graphs - $graph_type = 'bgp_updates'; - $local_daily_url = 'graph.php?id='.$peer['bgpPeer_id'].'&type='.$graph_type.'&from='.$config['time']['day'].'&to='.$config['time']['now'].'&width=500&height=150&&afi=ipv4&safi=unicast'; - if (filter_var($peer['bgpLocalAddr'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) !== false) { - $peer_ip = Net_IPv6::compress($peer['bgpLocalAddr']); - } - else { - $peer_ip = $peer['bgpLocalAddr']; - } - - $localaddresslink = "', LEFT".$config['overlib_defaults'].');" onmouseout="return nd();">'.$peer_ip.''; - - $graph_type = 'bgp_updates'; - $peer_daily_url = 'graph.php?id='.$peer['bgpPeer_id'].'&type='.$graph_type.'&from='.$config['time']['day'].'&to='.$config['time']['now'].'&width=500&height=150'; - if (filter_var($peer['bgpPeerIdentifier'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) !== false) { - $peer_ident = Net_IPv6::compress($peer['bgpPeerIdentifier']); - } - else { - $peer_ident = $peer['bgpPeerIdentifier']; - } - - $peeraddresslink = "', LEFT".$config['overlib_defaults'].');" onmouseout="return nd();">'.$peer_ident.''; - - echo ''; - - unset($sep); - foreach (dbFetchRows('SELECT * FROM `bgpPeers_cbgp` WHERE `device_id` = ? AND bgpPeerIdentifier = ?', array($peer['device_id'], $peer['bgpPeerIdentifier'])) as $afisafi) { - $afi = $afisafi['afi']; - $safi = $afisafi['safi']; - $this_afisafi = $afi.$safi; - $peer['afi'] .= $sep.$afi.'.'.$safi; - $sep = '
    '; - $peer['afisafi'][$this_afisafi] = 1; - // Build a list of valid AFI/SAFI for this peer - } - - unset($sep); - - echo ' - + echo(" + - + - - - - '; + + + + "); - unset($invalid); - switch ($vars['graph']) { - case 'prefixes_ipv4unicast': - case 'prefixes_ipv4multicast': - case 'prefixes_ipv4vpn': - case 'prefixes_ipv6unicast': - case 'prefixes_ipv6multicast': - list(,$afisafi) = explode('_', $vars['graph']); - if (isset($peer['afisafi'][$afisafi])) { - $peer['graph'] = 1; - } + unset($invalid); + switch ($vars['graph']) + { + case 'prefixes_ipv4unicast': + case 'prefixes_ipv4multicast': + case 'prefixes_ipv4vpn': + case 'prefixes_ipv6unicast': + case 'prefixes_ipv6multicast': + list(,$afisafi) = explode("_", $vars['graph']); + if (isset($peer['afisafi'][$afisafi])) { $peer['graph'] = 1; } + case 'updates': + $graph_array['type'] = "bgp_" . $vars['graph']; + $graph_array['id'] = $peer['bgpPeer_id']; + } - case 'updates': - $graph_array['type'] = 'bgp_'.$vars['graph']; - $graph_array['id'] = $peer['bgpPeer_id']; + switch ($vars['graph']) + { + case 'macaccounting_bits': + case 'macaccounting_pkts': + $acc = dbFetchRow("SELECT * FROM `ipv4_mac` AS I, `mac_accounting` AS M, `ports` AS P, `devices` AS D WHERE I.ipv4_address = ? AND M.mac = I.mac_address AND P.port_id = M.port_id AND D.device_id = P.device_id", array($peer['bgpPeerIdentifier'])); + $database = $config['rrd_dir'] . "/" . $device['hostname'] . "/cip-" . $acc['ifIndex'] . "-" . $acc['mac'] . ".rrd"; + if (is_array($acc) && is_file($database)) + { + $peer['graph'] = 1; + $graph_array['id'] = $acc['ma_id']; + $graph_array['type'] = $vars['graph']; } + } - switch ($vars['graph']) { - case 'macaccounting_bits': - case 'macaccounting_pkts': - $acc = dbFetchRow('SELECT * FROM `ipv4_mac` AS I, `mac_accounting` AS M, `ports` AS P, `devices` AS D WHERE I.ipv4_address = ? AND M.mac = I.mac_address AND P.port_id = M.port_id AND D.device_id = P.device_id', array($peer['bgpPeerIdentifier'])); - $database = $config['rrd_dir'].'/'.$device['hostname'].'/cip-'.$acc['ifIndex'].'-'.$acc['mac'].'.rrd'; - if (is_array($acc) && is_file($database)) { - $peer['graph'] = 1; - $graph_array['id'] = $acc['ma_id']; - $graph_array['type'] = $vars['graph']; - } - } + if ($vars['graph'] == 'updates') { $peer['graph'] = 1; } - if ($vars['graph'] == 'updates') { - $peer['graph'] = 1; - } + if ($peer['graph']) + { + $graph_array['height'] = "100"; + $graph_array['width'] = "218"; + $graph_array['to'] = $config['time']['now']; + echo('"); + } + } - echo ''; - } - }//end foreach + echo("
    Local addressPeer addressTypeFamilyRemote ASStateUptime / Updates
    '.$localaddresslink.'
    '.generate_device_link($peer, shorthost($peer['hostname']), array('tab' => 'routing', 'proto' => 'bgp')).'
    " . $localaddresslink . "
    ".generate_device_link($peer, shorthost($peer['hostname']), array('tab' => 'routing', 'proto' => 'bgp'))."
    »'.$peeraddresslink."" . $peeraddresslink . " $peer_type".$peer['afi'].'AS'.$peer['bgpPeerRemoteAs'].'
    '.$peer['astext']."
    ".$peer['bgpPeerAdminStatus']."
    ".$peer['bgpPeerState'].'
    '.formatUptime($peer['bgpPeerFsmEstablishedTime'])."
    - Updates ".format_si($peer['bgpPeerInUpdates'])." - ".format_si($peer['bgpPeerOutUpdates']).'
    ".$peer['afi']."AS" . $peer['bgpPeerRemoteAs'] . "
    " . $peer['astext'] . "
    " . $peer['bgpPeerAdminStatus'] . "
    " . $peer['bgpPeerState'] . "
    " .formatUptime($peer['bgpPeerFsmEstablishedTime']). "
    + Updates " . format_si($peer['bgpPeerInUpdates']) . " + " . format_si($peer['bgpPeerOutUpdates']) . "
    '); - if ($peer['graph']) { - $graph_array['height'] = '100'; - $graph_array['width'] = '218'; - $graph_array['to'] = $config['time']['now']; - echo '
    '; + include("includes/print-graphrow.inc.php"); - include 'includes/print-graphrow.inc.php'; + echo("
    "); +} - echo ''; -}//end if diff --git a/html/pages/routing/overview.inc.php b/html/pages/routing/overview.inc.php index c16262143a..bd9a9e63e1 100644 --- a/html/pages/routing/overview.inc.php +++ b/html/pages/routing/overview.inc.php @@ -1,7 +1,7 @@ 'IPv4 Address', - 'ipv6' => 'IPv6 Address', - 'mac' => 'MAC Address', - 'arp' => 'ARP Table', -); +$sections = array('ipv4' => 'IPv4 Address', 'ipv6' => 'IPv6 Address', 'mac' => 'MAC Address', 'arp' => 'ARP Table'); -if (dbFetchCell('SELECT 1 from `packages` LIMIT 1')) { - $sections['packages'] = 'Packages'; +if( dbFetchCell("SELECT 1 from `packages` LIMIT 1") ) { + $sections['packages'] = 'Packages'; } -if (!isset($vars['search'])) { - $vars['search'] = 'ipv4'; -} +if (!isset($vars['search'])) { $vars['search'] = "ipv4"; } print_optionbar_start('', ''); -echo 'Search » '; + echo('Search » '); unset($sep); -foreach ($sections as $type => $texttype) { - echo $sep; - if ($vars['search'] == $type) { - echo ""; - } +foreach ($sections as $type => $texttype) +{ + echo($sep); + if ($vars['search'] == $type) + { + echo(""); + } - // echo('' . $texttype .''); - echo generate_link($texttype, array('page' => 'search', 'search' => $type)); +# echo('' . $texttype .''); + echo(generate_link($texttype, array('page'=>'search','search'=>$type))); - if ($vars['search'] == $type) { - echo ''; - } + if ($vars['search'] == $type) { echo(""); } - $sep = ' | '; + $sep = ' | '; } - -unset($sep); +unset ($sep); print_optionbar_end('', ''); -if (file_exists('pages/search/'.$vars['search'].'.inc.php')) { - include 'pages/search/'.$vars['search'].'.inc.php'; -} -else { - echo report_this('Unknown search type '.$vars['search']); +if( file_exists('pages/search/'.$vars['search'].'.inc.php') ) { + include('pages/search/'.$vars['search'].'.inc.php'); +} else { + echo(report_this('Unknown search type '.$vars['search'])); } + +?> diff --git a/html/pages/search/arp.inc.php b/html/pages/search/arp.inc.php index 45cd6888a9..a4dcbd1136 100644 --- a/html/pages/search/arp.inc.php +++ b/html/pages/search/arp.inc.php @@ -30,22 +30,21 @@ var grid = $("#arp-search").bootgrid({ '.$data['hostname'].'"+'; + echo('">'.$data['hostname'].'"+'); } ?> ""+ @@ -54,16 +53,18 @@ foreach (dbFetchRows($sql, $param) as $data) { " "\" class=\"form-control input-sm\" placeholder=\"Address\" />"+ diff --git a/html/pages/search/ipv4.inc.php b/html/pages/search/ipv4.inc.php index 843acbd1bc..e2ea785c07 100644 --- a/html/pages/search/ipv4.inc.php +++ b/html/pages/search/ipv4.inc.php @@ -27,23 +27,22 @@ var grid = $("#ipv4-search").bootgrid({ ""+ '.$data['hostname'].'"+'; + echo('">'.$data['hostname'].'"+'); } ?> ""+ @@ -53,16 +52,18 @@ foreach (dbFetchRows($sql, $param) as $data) { ""+ ""+ "
     "+ "
    "+ - "\" class=\"form-control input-sm\" placeholder=\"IPv4 Address\"/>"+ + "\" class=\"form-control input-sm\" placeholder=\"IPv4 Address\"/>"+ "
     "+ ""+ "
    "+ diff --git a/html/pages/search/ipv6.inc.php b/html/pages/search/ipv6.inc.php index 2b9115013d..8ab58d9fff 100644 --- a/html/pages/search/ipv6.inc.php +++ b/html/pages/search/ipv6.inc.php @@ -26,23 +26,22 @@ var grid = $("#ipv6-search").bootgrid({ ""+ '.$data['hostname'].'"+'; + echo('">'.$data['hostname'].'"+'); } ?> ""+ @@ -52,8 +51,9 @@ foreach (dbFetchRows($sql, $param) as $data) { ""+ ""+ "
    "+ "
    "+ - "\" class=\"form-control input-sm\" placeholder=\"IPv6 Address\"/>"+ + "\" class=\"form-control input-sm\" placeholder=\"IPv6 Address\"/>"+ "
    "+ ""+ "
    "+ diff --git a/html/pages/search/mac.inc.php b/html/pages/search/mac.inc.php index f606e4436a..c040a1e16a 100644 --- a/html/pages/search/mac.inc.php +++ b/html/pages/search/mac.inc.php @@ -26,22 +26,21 @@ var grid = $("#mac-search").bootgrid({ ""+ @@ -51,15 +50,17 @@ foreach (dbFetchRows($sql, $param) as $data) { ""+ ""+ "
    '-1', 'rule' => '%macros.device_down = "1"', 'severity' => 'critical', 'extra' => '{"mute":false,"count":"-1","delay":"300"}', 'disabled' => 0, 'name' => 'Devices up/down'); - $default_rules[] = array('device_id' => '-1', 'rule' => '%devices.uptime < "300" && %macros.device = "1"', 'severity' => 'critical', 'extra' => '{"mute":false,"count":"1","delay":"300"}', 'disabled' => 0, 'name' => 'Device rebooted'); - $default_rules[] = array('device_id' => '-1', 'rule' => '%bgpPeers.bgpPeerState != "established" && %macros.device_up = "1"', 'severity' => 'critical', 'extra' => '{"mute":false,"count":"1","delay":"300"}', 'disabled' => 0, 'name' => 'BGP Session down'); - $default_rules[] = array('device_id' => '-1', 'rule' => '%bgpPeers.bgpPeerFsmEstablishedTime < "300" && %bgpPeers.bgpPeerState = "established"', 'severity' => 'critical', 'extra' => '{"mute":false,"count":"1","delay":"300"}', 'disabled' => 0, 'name' => 'BGP Session establised'); - $default_rules[] = array('device_id' => '-1', 'rule' => '%macros.port_down = "1"', 'severity' => 'critical', 'extra' => '{"mute":false,"count":"1","delay":"300"}', 'disabled' => 0, 'name' => 'Port status up/down'); - $default_rules[] = array('device_id' => '-1', 'rule' => '%macros.port_usage_perc >= "80"', 'severity' => 'critical', 'extra' => '{"mute":false,"count":"-1","delay":"300"}', 'disabled' => 0, 'name' => 'Port utilisation over threshold'); - $default_rules[] = array('device_id' => '-1', 'rule' => '%sensors.sensor_current > %sensors.sensor_limit', 'severity' => 'critical', 'extra' => '{"mute":false,"count":"-1","delay":"300"}', 'disabled' => 0, 'name' => 'Sensor over limit'); - $default_rules[] = array('device_id' => '-1', 'rule' => '%sensors.sensor_current < %sensors.sensor_limit_low', 'severity' => 'critical', 'extra' => '{"mute":false,"count":"-1","delay":"300"}', 'disabled' => 0, 'name' => 'Sensor under limit'); - foreach( $default_rules as $add_rule ) { - dbInsert($add_rule,'alert_rules'); +if (isset($_POST['create-default'])) { + $default_rules[] = array( + 'device_id' => '-1', + 'rule' => '%macros.device_down = "1"', + 'severity' => 'critical', + 'extra' => '{"mute":false,"count":"-1","delay":"300"}', + 'disabled' => 0, + 'name' => 'Devices up/down', + ); + $default_rules[] = array( + 'device_id' => '-1', + 'rule' => '%devices.uptime < "300" && %macros.device = "1"', + 'severity' => 'critical', + 'extra' => '{"mute":false,"count":"1","delay":"300"}', + 'disabled' => 0, + 'name' => 'Device rebooted', + ); + $default_rules[] = array( + 'device_id' => '-1', + 'rule' => '%bgpPeers.bgpPeerState != "established" && %macros.device_up = "1"', + 'severity' => 'critical', + 'extra' => '{"mute":false,"count":"1","delay":"300"}', + 'disabled' => 0, + 'name' => 'BGP Session down', + ); + $default_rules[] = array( + 'device_id' => '-1', + 'rule' => '%bgpPeers.bgpPeerFsmEstablishedTime < "300" && %bgpPeers.bgpPeerState = "established"', + 'severity' => 'critical', + 'extra' => '{"mute":false,"count":"1","delay":"300"}', + 'disabled' => 0, + 'name' => 'BGP Session establised', + ); + $default_rules[] = array( + 'device_id' => '-1', + 'rule' => '%macros.port_down = "1"', + 'severity' => 'critical', + 'extra' => '{"mute":false,"count":"1","delay":"300"}', + 'disabled' => 0, + 'name' => 'Port status up/down', + ); + $default_rules[] = array( + 'device_id' => '-1', + 'rule' => '%macros.port_usage_perc >= "80"', + 'severity' => 'critical', + 'extra' => '{"mute":false,"count":"-1","delay":"300"}', + 'disabled' => 0, + 'name' => 'Port utilisation over threshold', + ); + $default_rules[] = array( + 'device_id' => '-1', + 'rule' => '%sensors.sensor_current > %sensors.sensor_limit', + 'severity' => 'critical', + 'extra' => '{"mute":false,"count":"-1","delay":"300"}', + 'disabled' => 0, + 'name' => 'Sensor over limit', + ); + $default_rules[] = array( + 'device_id' => '-1', + 'rule' => '%sensors.sensor_current < %sensors.sensor_limit_low', + 'severity' => 'critical', + 'extra' => '{"mute":false,"count":"-1","delay":"300"}', + 'disabled' => 0, + 'name' => 'Sensor under limit', + ); + foreach ($default_rules as $add_rule) { + dbInsert($add_rule, 'alert_rules'); } -} - -require_once('includes/modal/new_alert_rule.inc.php'); -require_once('includes/modal/delete_alert_rule.inc.php'); +}//end if +require_once 'includes/modal/new_alert_rule.inc.php'; +require_once 'includes/modal/delete_alert_rule.inc.php'; ?>
    0) { +if (isset($_POST['results_amount']) && $_POST['results_amount'] > 0) { $results = $_POST['results']; -} else { +} +else { $results = 50; } echo '
    - - +
    + @@ -49,126 +103,150 @@ echo '
    - '; + '; -echo (' - + '); -$rulei=1; -$count_query = "SELECT COUNT(id)"; -$full_query = "SELECT *"; -$sql = ''; -$param = array(); -if(isset($device['device_id']) && $device['device_id'] > 0) { - $sql = 'WHERE (device_id=? OR device_id="-1")'; +echo ''; + +$rulei = 1; +$count_query = 'SELECT COUNT(id)'; +$full_query = 'SELECT *'; +$sql = ''; +$param = array(); +if (isset($device['device_id']) && $device['device_id'] > 0) { + $sql = 'WHERE (device_id=? OR device_id="-1")'; $param = array($device['device_id']); } -$query = " FROM alert_rules $sql ORDER BY device_id,id"; -$count_query = $count_query . $query; -$count = dbFetchCell($count_query,$param); -if(!isset($_POST['page_number']) && $_POST['page_number'] < 1) { + +$query = " FROM alert_rules $sql ORDER BY device_id,id"; +$count_query = $count_query.$query; +$count = dbFetchCell($count_query, $param); +if (!isset($_POST['page_number']) && $_POST['page_number'] < 1) { $page_number = 1; -} else { +} +else { $page_number = $_POST['page_number']; } -$start = ($page_number - 1) * $results; -$full_query = $full_query . $query . " LIMIT $start,$results"; -foreach( dbFetchRows($full_query, $param) as $rule ) { - $sub = dbFetchRows("SELECT * FROM alerts WHERE rule_id = ? ORDER BY id DESC LIMIT 1", array($rule['id'])); - $ico = "ok"; - $col = "success"; - $extra = ""; - if( sizeof($sub) == 1 ) { - $sub = $sub[0]; - if( (int) $sub['state'] === 0 ) { - $ico = "ok"; - $col = "success"; - } elseif( (int) $sub['state'] === 1 ) { - $ico = "remove"; - $col = "danger"; - $extra = "danger"; - } elseif( (int) $sub['state'] === 2 ) { - $ico = "time"; - $col = "default"; - $extra = "warning"; - } - } - $alert_checked = ''; - $orig_ico = $ico; - $orig_col = $col; - $orig_class = $extra; - if( $rule['disabled'] ) { - $ico = "pause"; - $col = ""; - $extra = "active"; - } else { - $alert_checked = 'checked'; +$start = (($page_number - 1) * $results); +$full_query = $full_query.$query." LIMIT $start,$results"; + +foreach (dbFetchRows($full_query, $param) as $rule) { + $sub = dbFetchRows('SELECT * FROM alerts WHERE rule_id = ? ORDER BY id DESC LIMIT 1', array($rule['id'])); + $ico = 'ok'; + $col = 'success'; + $extra = ''; + if (sizeof($sub) == 1) { + $sub = $sub[0]; + if ((int) $sub['state'] === 0) { + $ico = 'ok'; + $col = 'success'; } - $rule_extra = json_decode($rule['extra'],TRUE); - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; + else if ((int) $sub['state'] === 2) { + $ico = 'time'; + $col = 'default'; + $extra = 'warning'; } - echo ""; - echo ""; - echo ""; - echo "\r\n"; + } + + $alert_checked = ''; + $orig_ico = $ico; + $orig_col = $col; + $orig_class = $extra; + if ($rule['disabled']) { + $ico = 'pause'; + $col = ''; + $extra = 'active'; + } + else { + $alert_checked = 'checked'; + } + + $rule_extra = json_decode($rule['extra'], true); + echo ""; + echo ''; + echo ''; + echo "'; + echo ''; + echo ""; + } + + echo ''; + echo ''; + echo ''; + echo "\r\n"; +}//end foreach + +if (($count % $results) > 0) { + echo ' + + '; } -if($count % $results > 0) { - echo(' - - '); -} echo '
    # Name RuleExtra Enabled Action
    '); +echo ''; if ($_SESSION['userlevel'] >= '10') { - echo(''); + echo ''; } -echo ('
    #".((int) $rulei++)."".$rule['name'].""; - if($rule_extra['invert'] === true) { - echo "Inverted "; + else if ((int) $sub['state'] === 1) { + $ico = 'remove'; + $col = 'danger'; + $extra = 'danger'; } - echo "".htmlentities($rule['rule'])."".$rule['severity']." "; - if($rule_extra['mute'] === true) { - echo "Max: ".$rule_extra['count']."
    Delay: ".$rule_extra['delay']."
    Interval: ".$rule_extra['interval']."
    "; - if ($_SESSION['userlevel'] >= '10') { - echo ""; - } - echo ""; - if ($_SESSION['userlevel'] >= '10') { - echo " "; - echo ""; - } - echo "
    #'.((int) $rulei++).''.$rule['name'].'"; + if ($rule_extra['invert'] === true) { + echo 'Inverted '; + } + + echo ''.htmlentities($rule['rule']).''.$rule['severity'].' "; + if ($rule_extra['mute'] === true) { + echo "Max: '.$rule_extra['count'].'
    Delay: '.$rule_extra['delay'].'
    Interval: '.$rule_extra['interval'].'
    '; + if ($_SESSION['userlevel'] >= '10') { + echo ""; + } + + echo ''; + if ($_SESSION['userlevel'] >= '10') { + echo " "; + echo ""; + } + + echo '
    '.generate_pagination($count, $results, $page_number).'
    '. generate_pagination($count,$results,$page_number) .'
    - - - -
    '; + + + +
    '; -if($count < 1) { +if ($count < 1) { if ($_SESSION['userlevel'] >= '10') { echo '
    -
    -
    -

    - -

    -
    -
    -
    '; +
    +
    +

    + +

    +
    +
    +
    '; } } @@ -180,19 +258,19 @@ $('#ack-alert').click('', function(e) { var alert_id = $(this).data("alert_id"); $.ajax({ type: "POST", - url: "/ajax_form.php", - data: { type: "ack-alert", alert_id: alert_id }, - success: function(msg){ - $("#message").html('
    '+msg+'
    '); - if(msg.indexOf("ERROR:") <= -1) { - setTimeout(function() { - location.reload(1); - }, 1000); - } - }, - error: function(){ - $("#message").html('
    An error occurred acking this alert.
    '); - } + url: "/ajax_form.php", + data: { type: "ack-alert", alert_id: alert_id }, + success: function(msg){ + $("#message").html('
    '+msg+'
    '); + if(msg.indexOf("ERROR:") <= -1) { + setTimeout(function() { + location.reload(1); + }, 1000); + } + }, + error: function(){ + $("#message").html('
    An error occurred acking this alert.
    '); + } }); }); @@ -206,42 +284,42 @@ $('input[name="alert-rule"]').on('switchChange.bootstrapSwitch', function(event var orig_class = $(this).data("orig_class"); $.ajax({ type: 'POST', - url: '/ajax_form.php', - data: { type: "update-alert-rule", alert_id: alert_id, state: state }, - dataType: "html", - success: function(msg) { - if(msg.indexOf("ERROR:") <= -1) { - if(state) { - $('#alert-rule-'+alert_id).removeClass('glyphicon-pause'); - $('#alert-rule-'+alert_id).addClass('glyphicon-'+orig_state); - $('#alert-rule-'+alert_id).removeClass('text-default'); - $('#alert-rule-'+alert_id).addClass('text-'+orig_colour); - $('#row_'+alert_id).removeClass('active'); - $('#row_'+alert_id).addClass(orig_class); + url: '/ajax_form.php', + data: { type: "update-alert-rule", alert_id: alert_id, state: state }, + dataType: "html", + success: function(msg) { + if(msg.indexOf("ERROR:") <= -1) { + if(state) { + $('#alert-rule-'+alert_id).removeClass('glyphicon-pause'); + $('#alert-rule-'+alert_id).addClass('glyphicon-'+orig_state); + $('#alert-rule-'+alert_id).removeClass('text-default'); + $('#alert-rule-'+alert_id).addClass('text-'+orig_colour); + $('#row_'+alert_id).removeClass('active'); + $('#row_'+alert_id).addClass(orig_class); + } else { + $('#alert-rule-'+alert_id).removeClass('glyphicon-'+orig_state); + $('#alert-rule-'+alert_id).addClass('glyphicon-pause'); + $('#alert-rule-'+alert_id).removeClass('text-'+orig_colour); + $('#alert-rule-'+alert_id).addClass('text-default'); + $('#row_'+alert_id).removeClass('warning'); + $('#row_'+alert_id).addClass('active'); + } } else { - $('#alert-rule-'+alert_id).removeClass('glyphicon-'+orig_state); - $('#alert-rule-'+alert_id).addClass('glyphicon-pause'); - $('#alert-rule-'+alert_id).removeClass('text-'+orig_colour); - $('#alert-rule-'+alert_id).addClass('text-default'); - $('#row_'+alert_id).removeClass('warning'); - $('#row_'+alert_id).addClass('active'); + $("#message").html('
    '+msg+'
    '); + $('#'+alert_id).bootstrapSwitch('toggleState',true ); + } + }, + error: function() { + $("#message").html('
    This alert could not be updated.
    '); + $('#'+alert_id).bootstrapSwitch('toggleState',true ); } - } else { - $("#message").html('
    '+msg+'
    '); - $('#'+alert_id).bootstrapSwitch('toggleState',true ); - } - }, - error: function() { - $("#message").html('
    This alert could not be updated.
    '); - $('#'+alert_id).bootstrapSwitch('toggleState',true ); - } }); }); function updateResults(results) { - $('#results_amount').val(results.value); - $('#page_number').val(1); - $('#result_form').submit(); + $('#results_amount').val(results.value); + $('#page_number').val(1); + $('#result_form').submit(); } function changePage(page,e) { diff --git a/html/includes/print-alert-templates.php b/html/includes/print-alert-templates.php index 16a3afdd08..8ad6e8265d 100644 --- a/html/includes/print-alert-templates.php +++ b/html/includes/print-alert-templates.php @@ -1,6 +1,6 @@ @@ -10,17 +10,17 @@ $no_refresh = TRUE;