From 4130d6bdc1bf4d888e8c5ccd97602fe761e8ab9d Mon Sep 17 00:00:00 2001 From: bohdan-s Date: Sat, 21 Jun 2014 09:50:24 -0400 Subject: [PATCH 1/6] First Status page --- html/index.php | 17 +++++- html/pages/public.inc.php | 116 ++++++++++++++++++++++++++++++++++++++ includes/defaults.inc.php | 1 + 3 files changed, 131 insertions(+), 3 deletions(-) create mode 100644 html/pages/public.inc.php diff --git a/html/index.php b/html/index.php index 4351af2da..2b90769c5 100755 --- a/html/index.php +++ b/html/index.php @@ -205,9 +205,20 @@ if ($_SESSION['authenticated']) } } else { - // Not Authenticated. Print login. - include("pages/logon.inc.php"); - + // Not Authenticated. Show status page if enabled + if ( $config['public_status'] ) + { + if (isset($vars['page']) && strstr("login", $vars['page'])) + { + include("pages/logon.inc.php"); + } else { + include("pages/public.inc.php"); + } + } + else + { + include("pages/logon.inc.php"); + } exit; } ?> diff --git a/html/pages/public.inc.php b/html/pages/public.inc.php new file mode 100644 index 000000000..ae70f8a9b --- /dev/null +++ b/html/pages/public.inc.php @@ -0,0 +1,116 @@ +

System Status

'; + +$query = "SELECT * FROM `devices` WHERE 1 ".$where." ORDER BY hostname"; + +list($format, $subformat) = explode("_", $vars['format']); + +if($format == "graph") +{ + $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 ($_SESSION['widescreen']) { $width=270; } else { $width=315; } + + echo("
+ ".$device['hostname']." - ".$interface['ifDescr']."
\ + \ + ', CENTER, LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 150);\" onmouseout=\"return nd();\" >". + " + + "); + } + } + } + +} else { + + echo('
+
+ '); + if ($subformat == "detail" || $subformat == "basic") + { + echo(' + + + + + + + + '); + } + + foreach (dbFetchRows($query, $sql_param) as $device) + { + if (!device_permitted($device['device_id'])) + { + include("includes/hostbox-basic.inc.php"); + } + } + echo("
DevicePlatformOperating SystemUptime/Location
"); + echo('
'); + echo('
'); +} + +?> + diff --git a/includes/defaults.inc.php b/includes/defaults.inc.php index a0e0ad167..60bb9a7c9 100644 --- a/includes/defaults.inc.php +++ b/includes/defaults.inc.php @@ -118,6 +118,7 @@ $config['page_title_suffix'] = $config['project_name']; $config['timestamp_format'] = 'd-m-Y H:i:s'; $config['page_gen'] = 0; # display MySqL & PHP stats in footer? $config['login_message'] = "Unauthorised access or use shall render the user liable to criminal and/or civil prosecution."; +$config['public_status'] = false; // Enable public accessable status page $config['old_graphs'] = 1; // RRDfiles from before the great rra reform. This is default for a while. From c9ea8fb69ad03b69912ec2231c9f0032a57b5926 Mon Sep 17 00:00:00 2001 From: bohdan-s Date: Sat, 21 Jun 2014 20:24:44 -0400 Subject: [PATCH 2/6] Move status and logon pages to same page, remove kernel version from status page --- html/includes/hostbox-public.inc.php | 50 ++++++++++++++++++++++++++++ html/index.php | 6 ++++ html/pages/public.inc.php | 24 ++++++++++--- 3 files changed, 76 insertions(+), 4 deletions(-) create mode 100644 html/includes/hostbox-public.inc.php diff --git a/html/includes/hostbox-public.inc.php b/html/includes/hostbox-public.inc.php new file mode 100644 index 000000000..78067eb4a --- /dev/null +++ b/html/includes/hostbox-public.inc.php @@ -0,0 +1,50 @@ + --> + + + ' . $image . ' + ' . generate_device_link($device) . '' + ); + +echo(''); +if ($port_count) { echo(' '.$port_count); } +echo('
'); +if ($sensor_count) { echo(' '.$sensor_count); } +echo(''); +echo(' ' . $device['hardware'] . ' ' . $device['features'] . ''); +//echo(' ' . $device['os_text'] . ' ' . $device['version'] . ''); +echo(' ' . formatUptime($device['uptime'], 'short') . '
'); + +if (get_dev_attrib($device,'override_sysLocation_bool')) { $device['location'] = get_dev_attrib($device,'override_sysLocation_string'); } +echo(' ' . truncate($device['location'],32, '') . ''); + +echo(' '); + +?> diff --git a/html/index.php b/html/index.php index 2b90769c5..b30229775 100755 --- a/html/index.php +++ b/html/index.php @@ -212,7 +212,13 @@ if ($_SESSION['authenticated']) { include("pages/logon.inc.php"); } else { + echo '
'; include("pages/public.inc.php"); + echo '
'; + echo ''; } } else diff --git a/html/pages/public.inc.php b/html/pages/public.inc.php index ae70f8a9b..eb82fcd6c 100644 --- a/html/pages/public.inc.php +++ b/html/pages/public.inc.php @@ -1,3 +1,20 @@ + +

System Status

'; +echo '

System Status

'; $query = "SELECT * FROM `devices` WHERE 1 ".$where." ORDER BY hostname"; @@ -81,7 +98,7 @@ if($format == "graph") Device Platform - Operating System + Uptime/Location '); } @@ -90,7 +107,7 @@ if($format == "graph") { if (!device_permitted($device['device_id'])) { - include("includes/hostbox-basic.inc.php"); + include("includes/hostbox-public.inc.php"); } } echo(""); @@ -105,7 +122,6 @@ if($format == "graph")

' . (isset($config['footer']) ? $config['footer'] : '')); -echo('
Admins Logon Here. '); echo('
Powered by ' . $config['project_name_version'].'. '); echo( $config['project_name'].' is Free Software, released under the GNU GPLv3.
'); echo(' Copyright © 2006-2012 by Adam Armstrong. Copyright © 2013-'.date("Y").' by the '.$config['project_name'].' Contributors.'); From 9fb82b844d50b05b67064a128b62eb6dd5e55962 Mon Sep 17 00:00:00 2001 From: bohdan-s Date: Sat, 21 Jun 2014 22:02:16 -0400 Subject: [PATCH 3/6] Cleaned up code and changed to jquery, re: laf suggestions --- html/includes/hostbox-public.inc.php | 4 +- html/index.php | 4 +- html/pages/public.inc.php | 148 +++++++-------------------- 3 files changed, 42 insertions(+), 114 deletions(-) diff --git a/html/includes/hostbox-public.inc.php b/html/includes/hostbox-public.inc.php index 78067eb4a..633f8cfbd 100644 --- a/html/includes/hostbox-public.inc.php +++ b/html/includes/hostbox-public.inc.php @@ -26,8 +26,7 @@ $type = strtolower($device['os']); if ($device['os'] == "ios") { formatCiscoHardware($device, true); } $device['os_text'] = $config['os'][$device['os']]['text']; -echo(' - +echo(' ' . $image . ' ' . generate_device_link($device) . '' @@ -39,7 +38,6 @@ echo('
'); if ($sensor_count) { echo(' '.$sensor_count); } echo(''); echo(' ' . $device['hardware'] . ' ' . $device['features'] . ''); -//echo(' ' . $device['os_text'] . ' ' . $device['version'] . ''); echo(' ' . formatUptime($device['uptime'], 'short') . '
'); if (get_dev_attrib($device,'override_sysLocation_bool')) { $device['location'] = get_dev_attrib($device,'override_sysLocation_string'); } diff --git a/html/index.php b/html/index.php index b30229775..c552e4ced 100755 --- a/html/index.php +++ b/html/index.php @@ -206,7 +206,7 @@ if ($_SESSION['authenticated']) } else { // Not Authenticated. Show status page if enabled - if ( $config['public_status'] ) + if ( $config['public_status'] === true ) { if (isset($vars['page']) && strstr("login", $vars['page'])) { @@ -216,7 +216,7 @@ if ($_SESSION['authenticated']) include("pages/public.inc.php"); echo '
'; echo ''; } diff --git a/html/pages/public.inc.php b/html/pages/public.inc.php index eb82fcd6c..0dae8bd47 100644 --- a/html/pages/public.inc.php +++ b/html/pages/public.inc.php @@ -1,132 +1,62 @@ +

System Status

'; - -$query = "SELECT * FROM `devices` WHERE 1 ".$where." ORDER BY hostname"; - -list($format, $subformat) = explode("_", $vars['format']); - -if($format == "graph") -{ - $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 ($_SESSION['widescreen']) { $width=270; } else { $width=315; } - - echo("
- ".$device['hostname']." - ".$interface['ifDescr']."
\ - \ - ', CENTER, LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 150);\" onmouseout=\"return nd();\" >". - " - - "); - } - } - } - -} else { - - echo('
-
- '); - if ($subformat == "detail" || $subformat == "basic") - { - echo(' - - - - - - - - '); - } - - foreach (dbFetchRows($query, $sql_param) as $device) - { - if (!device_permitted($device['device_id'])) - { - include("includes/hostbox-public.inc.php"); - } - } - echo("
DevicePlatformUptime/Location
"); - echo('
'); - echo('
'); -} +$query = "SELECT * FROM `devices` ORDER BY hostname"; ?> -
-
-
-
+

System Status

+
+
+ + + + + + + + + + +
DevicePlatformUptime/Location
+
+
+
+
+
+

' . (isset($config['footer']) ? $config['footer'] : '')); echo('
Powered by ' . $config['project_name_version'].'. '); echo( $config['project_name'].' is Free Software, released under the GNU GPLv3.
'); echo(' Copyright © 2006-2012 by Adam Armstrong. Copyright © 2013-'.date("Y").' by the '.$config['project_name'].' Contributors.'); ?> -
-
-
+
+
+
From 282c4e705a756b1bf838ba59996067b801177e9e Mon Sep 17 00:00:00 2001 From: bohdan-s Date: Sun, 22 Jun 2014 19:51:35 -0400 Subject: [PATCH 4/6] Fix footer, remove ignored/disabled devices form status page, cleanup white space at top of page --- html/index.php | 10 +++++++--- html/pages/public.inc.php | 17 +---------------- 2 files changed, 8 insertions(+), 19 deletions(-) diff --git a/html/index.php b/html/index.php index c552e4ced..04a47905d 100755 --- a/html/index.php +++ b/html/index.php @@ -163,19 +163,24 @@ if (!$vars['bare'] == "yes") { if ($_SESSION['authenticated']) { include("includes/print-menubar.php"); - } else { - echo('
'); } } ?>
+
 

+
diff --git a/html/pages/public.inc.php b/html/pages/public.inc.php index 0dae8bd47..751147419 100644 --- a/html/pages/public.inc.php +++ b/html/pages/public.inc.php @@ -21,8 +21,7 @@ $(document).ready(function() { $sql_param = array(); $pagetitle[] = "Public Devices"; - -$query = "SELECT * FROM `devices` ORDER BY hostname"; +$query = "SELECT * FROM `devices` WHERE 1 AND disabled='0' AND `ignore`='0' ORDER BY hostname"; ?>

System Status

@@ -46,17 +45,3 @@ foreach (dbFetchRows($query, $sql_param) as $device)
-
-
-
-
-
' . (isset($config['footer']) ? $config['footer'] : '')); -echo('
Powered by ' . $config['project_name_version'].'. '); -echo( $config['project_name'].' is Free Software, released under the GNU GPLv3.
'); -echo(' Copyright © 2006-2012 by Adam Armstrong. Copyright © 2013-'.date("Y").' by the '.$config['project_name'].' Contributors.'); -?> -
-
-
-
From 26fa96f3eed455851cb1bb7ad1cc82f0e8405eb8 Mon Sep 17 00:00:00 2001 From: bohdan-s Date: Mon, 23 Jun 2014 23:22:15 -0400 Subject: [PATCH 5/6] Add Copyright to new file --- html/pages/public.inc.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/html/pages/public.inc.php b/html/pages/public.inc.php index 751147419..cb8837554 100644 --- a/html/pages/public.inc.php +++ b/html/pages/public.inc.php @@ -1,3 +1,17 @@ + + * Copyright (C) 2013-2014 by individual LibreNMS contributors + * + * 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. + */ +?>