From fc7404a3c4102f8fe0aeb11462ba63047389057c Mon Sep 17 00:00:00 2001 From: laf Date: Mon, 13 Jan 2014 10:05:19 +0000 Subject: [PATCH] Updates bringing forms / tables inline with Bootstrap v3, also adds Global search box --- README.md | 1 - html/ajax_search.php | 145 +++++++++ html/includes/device-header.inc.php | 8 +- html/includes/front/boxes.inc.php | 11 +- html/includes/print-event.inc.php | 1 - html/includes/print-menubar.php | 436 +++++++++++++--------------- html/includes/print-syslog.inc.php | 3 +- html/includes/topnav.inc.php | 88 +++--- html/index.php | 4 +- html/pages/addhost.inc.php | 173 ++++++----- html/pages/addsrv.inc.php | 81 +++--- html/pages/adduser.inc.php | 70 ++++- html/pages/bill/edit.inc.php | 192 ++++++------ html/pages/bills.inc.php | 171 ++++++----- html/pages/bills/pmonth.inc.php | 24 +- html/pages/bills/search.inc.php | 56 ++-- html/pages/delsrv.inc.php | 24 +- html/pages/devices.inc.php | 269 +++++++++-------- html/pages/edituser.inc.php | 14 +- html/pages/eventlog.inc.php | 44 +-- html/pages/front/default.php | 32 +- html/pages/health.inc.php | 2 +- html/pages/health/mempool.inc.php | 10 +- html/pages/health/processor.inc.php | 10 +- html/pages/health/storage.inc.php | 12 +- html/pages/inventory.inc.php | 37 +-- html/pages/ports.inc.php | 311 ++++++++++---------- html/pages/preferences.inc.php | 45 ++- html/pages/search/arp.inc.php | 36 +-- html/pages/search/ipv4.inc.php | 38 +-- html/pages/search/ipv6.inc.php | 38 +-- html/pages/search/mac.inc.php | 38 +-- html/pages/services.inc.php | 28 +- includes/common.php | 2 +- includes/functions.php | 32 ++ 35 files changed, 1409 insertions(+), 1077 deletions(-) create mode 100755 html/ajax_search.php diff --git a/README.md b/README.md index bfe376ea0..427399d19 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,6 @@ exception): - scripts/*/mysql: GPLv2 only - check_mk (scripts/observium_agent*): GPLv2 - qTip (html/css/jquery.qtip.min.css and html/js/qtip/jquery.qtip.min.js): GPLv2 - - jqPlot (html/js/jqplot/*): MIT or GPLv2 Introduction ------------ diff --git a/html/ajax_search.php b/html/ajax_search.php new file mode 100755 index 000000000..d25b3537f --- /dev/null +++ b/html/ajax_search.php @@ -0,0 +1,145 @@ +0) + { + $found = 0; + + if($_REQUEST['type'] == 'device') { + + // Device search + $results = dbFetchRows("SELECT * FROM `devices` WHERE `hostname` LIKE '%" . $search . "%' OR `location` LIKE '%" . $search . "%' ORDER BY hostname LIMIT 8"); + if (count($results)) + { + $found = 1; + $devices = count($results); + + foreach ($results as $result) + { + $name = $result['hostname']; + if (strlen($name) > 36) { $name = substr($name, 0, 36) . "..."; } + if($result['disabled'] == 1) + { + $highlight_colour = '#808080'; + } + elseif($result['ignored'] == 1 && $result['disabled'] == 0) + { + $highlight_colour = '#000000'; + } + elseif($result['status'] == 0 && $result['ignore'] == 0 && $result['disabled'] == 0) + { + $highlight_colour = '#ff0000'; + } + elseif($result['status'] == 1 && $result['ignore'] == 0 && $result['disabled'] == 0) + { + $highlight_colour = '#008000'; + } + $num_ports = dbFetchCell("SELECT COUNT(*) FROM `ports` WHERE device_id = ?", array($result['device_id'])); + $device[]=array('name'=>$name, + 'url'=> generate_device_url($result), + 'colours'=>$highlight_colour, + 'device_ports'=>$num_ports, + 'device_image'=>getImageSrc($result), + 'device_hardware'=>$result['hardware'], + 'device_os'=>$config['os'][$result['os']]['text'], + 'version'=>$result['version'], + 'location'=>$result['location']); + } + } + $json = json_encode($device); + print_r($json); + exit; + + } elseif($_REQUEST['type'] == 'ports') { + // Search ports + $results = dbFetchRows("SELECT `ports`.* AS P,`devices`.* AS D FROM `ports` LEFT JOIN `devices` ON `ports`.`device_id` = `devices`.`device_id` WHERE `ifAlias` LIKE '%" . $search . "%' OR `ifDescr` LIKE '%" . $search . "%' ORDER BY ifDescr LIMIT 8"); + + if (count($results)) + { + $found = 1; + + foreach ($results as $result) + { + $name = $result['ifDescr']; + if (strlen($name) > 36) + { + $name = substr($name, 0, 36) . "..."; + } + $description = $result['ifAlias']; + if (strlen($description) > 50) + { + $description = substr($description, 0, 50) . "..."; + } + + if($result['deleted'] == 0 && ($result['ignore'] == 0 || $result['ignore'] == 0) && ($result['ifInErrors_delta'] > 0 || $result['ifOutErrors_delta'] > 0)) + { + // Errored ports + $port_colour = '#ffa500'; + } + elseif($result['deleted'] == 0 && ($result['ignore'] == 1 || $result['ignore'] == 1)) + { + // Ignored ports + $port_colour = '#000000'; + + } + elseif($result['deleted'] == 0 && $result['ifAdminStatus'] == 'down' && $result['ignore'] == 0 && $result['ignore'] == 0) + { + // Shutdown ports + $port_colour = '#808080'; + } + elseif($result['deleted'] == 0 && $result['ifOperStatus'] == 'down' && $result['ifAdminStatus'] == 'up' && $result['ignore'] == 0 && $result['ignore'] == 0) + { + // Down ports + $port_colour = '#ff0000'; + } + elseif($result['deleted'] == 0 && $result['ifOperStatus'] == 'up' && $result['ignore'] == 0 && $result['ignore'] == 0) + { + // Up ports + $port_colour = '#008000'; + } + + $ports[]=array('count'=>count($results), + 'url'=>generate_port_url($result), + 'name'=>$name, + 'description'=>$description, + 'colours'=>$highlight_colour, + 'hostname'=>$result['hostname']); + + } + } + $json = json_encode($ports); + print_r($json); + exit; + + } + } +} +?> diff --git a/html/includes/device-header.inc.php b/html/includes/device-header.inc.php index b2cffd031..c2dac7c7d 100644 --- a/html/includes/device-header.inc.php +++ b/html/includes/device-header.inc.php @@ -1,17 +1,17 @@ + '.$image.' ' . generate_device_link($device) . '
' . $device['location'] . ' diff --git a/html/includes/front/boxes.inc.php b/html/includes/front/boxes.inc.php index f02d0a06c..3ae0f6995 100644 --- a/html/includes/front/boxes.inc.php +++ b/html/includes/front/boxes.inc.php @@ -11,11 +11,14 @@ * the source code distribution for details. */ ?> - - \n
\n"); +echo(' +
+'); foreach (get_matching_files($config['html_dir']."/includes/front/", "/^top_.*\.php$/") as $file) { echo("
\n"); @@ -23,7 +26,7 @@ foreach (get_matching_files($config['html_dir']."/includes/front/", "/^top_.*\.p echo("
\n"); } -echo("
\n"); echo("
\n"); ?> + diff --git a/html/includes/print-event.inc.php b/html/includes/print-event.inc.php index d73df7b05..35b3f6298 100644 --- a/html/includes/print-event.inc.php +++ b/html/includes/print-event.inc.php @@ -8,7 +8,6 @@ $icon = geteventicon($entry['message']); if ($icon) { $icon = ''; } echo(' - ' . $entry['datetime'] . ' '); diff --git a/html/includes/print-menubar.php b/html/includes/print-menubar.php index dc7096a2c..2f9182523 100644 --- a/html/includes/print-menubar.php +++ b/html/includes/print-menubar.php @@ -12,56 +12,46 @@ if (isset($config['enable_bgp']) && $config['enable_bgp']) ?> - + - - - - -
  • Locations - - - - -
  • - - - -
  • Ports - - - -
  • - + + -
  • Health - - - -
  • - + + = '5' && ($app_count) > "0") { ?> - -
  • Apps - -
  • - + = '5' && ($routing_count['bgp']+$routing_count['ospf { ?> - -
  • Routing - - -
  • + -
  • Packages - -
  • + - + -
    - -
    - - - - - + + + + + diff --git a/html/includes/print-syslog.inc.php b/html/includes/print-syslog.inc.php index cade34cee..26c511601 100644 --- a/html/includes/print-syslog.inc.php +++ b/html/includes/print-syslog.inc.php @@ -2,8 +2,7 @@ if (device_permitted($entry['device_id'])) { - echo(" - "); + echo(""); $entry['hostname'] = shorthost($entry['hostname'], 20); diff --git a/html/includes/topnav.inc.php b/html/includes/topnav.inc.php index 7e1d48769..129192635 100644 --- a/html/includes/topnav.inc.php +++ b/html/includes/topnav.inc.php @@ -33,7 +33,7 @@ if($_SESSION['userlevel'] >= 5) $ports['errored'] = dbFetchCell("SELECT COUNT(*) FROM ports AS I, devices AS D WHERE I.deleted = '0' AND D.device_id = I.device_id AND (I.ignore = '0' OR D.ignore = '0') AND (I.ifInErrors_delta > '0' OR I.ifOutErrors_delta > '0')"); $services['count'] = dbFetchCell("SELECT COUNT(service_id) FROM services"); - $services['up'] = dbFetchCell("SELECT COUNT(service_id) FROM services WHERE service_status = '1' AND service_ignore ='0'"); + $services['up'] = dbFetchCell("SELECT COUNT(service_id) FROM services WHERE service_status = '1' AND service_ignore ='0' AND service_disabled='0'"); $services['down'] = dbFetchCell("SELECT COUNT(service_id) FROM services WHERE service_status = '0' AND service_ignore = '0'"); $services['ignored'] = dbFetchCell("SELECT COUNT(service_id) FROM services WHERE service_ignore = '1'"); $services['disabled'] = dbFetchCell("SELECT COUNT(service_id) FROM services WHERE service_disabled = '1'"); @@ -49,7 +49,7 @@ else $ports['up'] = dbFetchCell("SELECT COUNT(*) FROM ports AS I, devices AS D, devices_perms AS P WHERE I.deleted = '0' AND P.user_id = ? AND P.device_id = D.device_id AND I.device_id = D.device_id AND ifOperStatus = 'up'", array($_SESSION['user_id'])); $ports['down'] = dbFetchCell("SELECT COUNT(*) FROM ports AS I, devices AS D, devices_perms AS P WHERE I.deleted = '0' AND P.user_id = ? AND P.device_id = D.device_id AND I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up'", array($_SESSION['user_id'])); $ports['disabled'] = dbFetchCell("SELECT COUNT(*) FROM ports AS I, devices AS D, devices_perms AS P WHERE I.deleted = '0' AND P.user_id = ? AND P.device_id = D.device_id AND I.device_id = D.device_id AND ifAdminStatus = 'down'", array($_SESSION['user_id'])); - $ports['errored'] = dbFetchCell("SELECT COUNT(*) FROM ports AS I, devices AS D, devices_perms AS P WHERE I.deleted = '0' AND P.user_id = ? AND P.device_id = D.device_id AND I.device_id = D.device_id AND (I.in_errors > '0' OR I.out_errors > '0')", array($_SESSION['user_id'])); + $ports['errolabel label-danger'] = dbFetchCell("SELECT COUNT(*) FROM ports AS I, devices AS D, devices_perms AS P WHERE I.deleted = '0' AND P.user_id = ? AND P.device_id = D.device_id AND I.device_id = D.device_id AND (I.in_errors > '0' OR I.out_errors > '0')", array($_SESSION['user_id'])); $services['count'] = dbFetchCell("SELECT COUNT(service_id) 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", array($_SESSION['user_id'])); $services['up'] = dbFetchCell("SELECT COUNT(service_id) 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 service_status = '1' AND service_ignore ='0'", array($_SESSION['user_id'])); @@ -62,44 +62,52 @@ if ($ports['down']) { $ports['bgcolour'] = "#ffcccc"; } else { $ports['bgcolo if ($services['down']) { $services['bgcolour'] = "#ffcccc"; } else { $services['bgcolour'] = "transparent"; } ?> - - - - - - - - - - - - - - - - - - - - - - - - - - +
    +
    +
    +
    Devices ( up down ignored disabled )
    Ports ( up down ignored shutdown )
    + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - + + + + + + + + +
     TotalUpDownIgnoredDisabled
    Devices up down ignored disabled
    Ports up down ignored shutdown
    Services ( up down ignored disabled )
    Services up down ignored disabled
    + +
    +   +
    + + diff --git a/html/index.php b/html/index.php index e96d566d0..78643f8f0 100755 --- a/html/index.php +++ b/html/index.php @@ -141,7 +141,9 @@ if ($config['favicon']) { echo(' --> - + + + diff --git a/html/pages/addhost.inc.php b/html/pages/addhost.inc.php index 07deeac8c..4ab7dc271 100644 --- a/html/pages/addhost.inc.php +++ b/html/pages/addhost.inc.php @@ -62,79 +62,104 @@ $pagetitle[] = "Add host"; ?> -
    -

    Devices will be checked for Ping and SNMP reachability before being probed. Only devices with recognised OSes will be added.

    - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Hostname
    SNMP Version - -  Port -
    SNMPv1/2c Configuration
    Community
    SNMPv3 Configuration
    Auth Level - -
    Auth User Name
    Auth Password
    Auth Algorithm - -
    Crypto Password
    Crypto Algorithm - -
    + +
    Devices will be checked for Ping and SNMP reachability before being probed. Only devices with recognised OSes will be added.
    +
    +
    + +
    + +
    +
    +
    +
    +
    + +
    + +
    +
    + +
    +
    +
    +
    +
    +
    + +
    +
    +
    + +
    + +
    +
    +
    +
    +
    +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    +
    +
    + +
    + +
    +
    +
    +
    +
    + +
    + +
    +
    +
    +
    +
    diff --git a/html/pages/addsrv.inc.php b/html/pages/addsrv.inc.php index 644f5ff29..23c945b9e 100644 --- a/html/pages/addsrv.inc.php +++ b/html/pages/addsrv.inc.php @@ -46,46 +46,55 @@ else echo("

    Add Service

    -
    - - - - - - - - - - - - - - - - - - - - - - - -
    - Device - - + +
    + -
    - Type - - $servicesform -
    Description
    IP Address
    Parameters
    - - +
    +
    +
    + +
    + +
    + +
    +
    +
    +
    +
    + +
    + +
    +
    +
    +
    +
    + +
    + +
    +
    +
    +
    + + "); } diff --git a/html/pages/adduser.inc.php b/html/pages/adduser.inc.php index 64af94aa9..1747d3cd9 100644 --- a/html/pages/adduser.inc.php +++ b/html/pages/adduser.inc.php @@ -1,7 +1,5 @@ "); - if ($_SESSION['userlevel'] < '10') { include("includes/error-no-perm.inc.php"); @@ -44,23 +42,65 @@ else } } - echo("
    "); - echo("Username
    "); + echo(" "); + echo(" +
    + +
    + +
    +
    +
    +
    "); ?> - Password
    +
    + +
    + +
    +
    +
    +
    + Please enter a password!
    "); } - echo("Realname
    "); - echo("Level
    "); - echo(" Allow the user to change his password.

    "); - echo(" "); + +echo(" +
    "); + echo(" +
    + +
    +
    +
    +
    "); + echo("
    + +
    + +
    +
    +
    +
    "); + echo("
    +
    +
    + +
    +
    +
    +
    +
    "); + echo(""); echo("
    "); } else @@ -69,6 +109,4 @@ else } } -echo(""); - -?> \ No newline at end of file +?> diff --git a/html/pages/bill/edit.inc.php b/html/pages/bill/edit.inc.php index 1e60a8ac7..5135879c9 100644 --- a/html/pages/bill/edit.inc.php +++ b/html/pages/bill/edit.inc.php @@ -29,50 +29,78 @@ if ($bill_data['bill_type'] == "cdr") { ?> -
    + - /css/bootstrap.min.css"> -
    - Bill Properties -
    - -
    - " /> +

    Bill Properties

    +
    + +
    + " /> +
    +
    +
    +
    +
    + +
    +
    + +
    +
    +
    -
    - -
    - /> CDR 95th - /> Quota - - +
    + +
    + +
    + -
    +
    -
    -
    - Optional Information -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
    -
    -
    +

    Optional Information

    +
    + +
    + +
    +
    +
    +
    +
    + +
    + +
    +
    +
    +
    +
    + +
    + +
    +
    +
    -
    -
    - Billed Ports -
    + +

    Billed Ports

    +
    ", $portbtn); $portbtn = str_replace("
    ',;", "
    ',", $portbtn); $portalias = (empty($port['ifAlias']) ? "" : " - ".$port['ifAlias'].""); - $devicebtn = str_replace("\">".$port['hostname'], "\" style=\"color: #000;\"> ".$port['hostname'], $devicebtn); - $portbtn = str_replace("\">".strtolower($port['ifName']), "\" style=\"color: #000;\"> ".$port['ifName']."".$portalias, $portbtn); + $devicebtn = str_replace("\">".$port['hostname'], "\" style=\"color: #000;\"> ".$port['hostname'], $devicebtn); + $portbtn = str_replace("\">".strtolower($port['ifName']), "\" style=\"color: #000;\"> ".$port['ifName']."".$portalias, $portbtn); echo(" \n"); echo(" \n"); echo(" \n"); @@ -164,16 +190,15 @@ if (is_array($ports))
    -
    + -
    - Add Port -
    - -
    - + - -
    +
    -
    - -
    - -
    +
    -
    -
    -
    +
    + +
    + +
    +
    +
    +
    + diff --git a/html/pages/bills.inc.php b/html/pages/bills.inc.php index ef69e3738..adf2a7724 100644 --- a/html/pages/bills.inc.php +++ b/html/pages/bills.inc.php @@ -59,7 +59,6 @@ elseif ($vars['view'] == "add") ?> -

    Bill : Add Bill

    -
    +

    Bill : Add Bill

    + + -