diff --git a/INSTALL b/INSTALL index 843be6064..8b8c7dc29 100644 --- a/INSTALL +++ b/INSTALL @@ -1,24 +1,24 @@ -Please see http://www.observium.org for up to date installation instructions. - -Please also contact us through the mailing list or on IRC if you run into any issues. - -------- - -Some notes about how to set up your systems, which have not found their way -onto the wiki just yet: - -Customer port parsing -===================== - -Set your port description to: - -Cust: CustomerName {CircuitDesc} (OptionalNotes) [Speed] - -Transit/peering/core port parsing -================================= - -Set your port description to: - -Transit: whateveryoulike -Peering: whateveryoulike -Core: whateveryoulike +Please see http://www.observium.org for up to date installation instructions. + +Please also contact us through the mailing list or on IRC if you run into any issues. + +------- + +Some notes about how to set up your systems, which have not found their way +onto the wiki just yet: + +Customer port parsing +===================== + +Set your port description to: + +Cust: CustomerName {CircuitDesc} (OptionalNotes) [Speed] + +Transit/peering/core port parsing +================================= + +Set your port description to: + +Transit: whateveryoulike +Peering: whateveryoulike +Core: whateveryoulike diff --git a/config.php.default b/config.php.default index dd99430fb..cf7bf1abd 100755 --- a/config.php.default +++ b/config.php.default @@ -9,14 +9,14 @@ $config['db_pass'] = "PASSWORD"; $config['db_name'] = "observium"; ### Locations -$config['install_dir'] = "/opt/observium"; -$config['html_dir'] = $config['install_dir'] . "/html"; -$config['rrd_dir'] = $config['install_dir'] . "/rrd"; +$config['install_dir'] = "/opt/observium"; +$config['html_dir'] = $config['install_dir'] . "/html"; +$config['rrd_dir'] = $config['install_dir'] . "/rrd"; $config['log_file'] = $config['install_dir'] . "/observium.log"; ### Thie should *only* be set if you want to *force* a particular hostname/port ### It will prevent the web interface being usable form any other hostname -#$config['base_url'] = "http://observium.company.com"; +#$config['base_url'] = "http://observium.company.com"; ### Enable the below to use rrdcached. be sure rrd_dir is within the rrdcached dir ### and that your web server has permission to talk to rrdcached. diff --git a/html/billing-graph.php b/html/billing-graph.php index 12b6776d8..5e9c25fef 100755 --- a/html/billing-graph.php +++ b/html/billing-graph.php @@ -105,7 +105,7 @@ foreach (dbFetch("SELECT *, UNIX_TIMESTAMP(timestamp) AS formatted_date FROM bil $tot_data[$i] = $out_data[$i] + $in_data[$i]; $tot_data_inv[$i] = $tot_data[$i] * -1; - if($tot_data[$i] > $max_value) { $max_value = $tot_data[$i]; } + if ($tot_data[$i] > $max_value) { $max_value = $tot_data[$i]; } $ticks[$i] = $timestamp; $per_data[$i] = $rate_95th / $div; diff --git a/html/includes/functions.inc.php b/html/includes/functions.inc.php index 3b781c394..045712786 100644 --- a/html/includes/functions.inc.php +++ b/html/includes/functions.inc.php @@ -5,7 +5,7 @@ function rrdtool_graph($graph_file, $options) global $config, $debug; - if($debug) { echo("$options"); } + if ($debug) { echo("$options"); } $command = $config['rrdtool'] . " -"; @@ -39,10 +39,10 @@ function rrdtool_graph($graph_file, $options) // proc_close in order to avoid a deadlock $return_value = proc_close($process); - if($debug) + if ($debug) { echo("

"); - if($debug) { echo("graph $graph_file $options"); } + if ($debug) { echo("graph $graph_file $options"); } echo("

"); echo "command returned $return_value\n"; echo("

"); @@ -66,7 +66,7 @@ function generate_url($vars, $new_vars = array()) foreach($vars as $var => $value) { - if($value != "") + if ($value != "") { $url .= $var ."=".$value."/"; } @@ -187,6 +187,7 @@ function overlib_link($url, $text, $contents, $class) function generate_graph_popup($graph_array) { global $config; + ## Take $graph_array and print day,week,month,year graps in overlib, hovered over graph $graph = generate_graph_tag($graph_array); @@ -270,6 +271,7 @@ function port_permitted($interface_id, $device_id = NULL) function application_permitted($app_id, $device_id = NULL) { global $permissions; + if (is_numeric($app_id)) { if (!$device_id) { $device_id = device_by_id_cache ($app_id); } @@ -345,7 +347,7 @@ STATE; function print_percentage_bar($width, $height, $percent, $left_text, $left_colour, $left_background, $right_text, $right_colour, $right_background) { - if($percent > "100") { $size_percent = "100"; } else { $size_percent = $percent; } + if ($percent > "100") { $size_percent = "100"; } else { $size_percent = $percent; } $output = '
@@ -379,7 +381,7 @@ function generate_port_link($args, $text = NULL, $type = NULL) $graph_array['legend'] = "yes"; $graph_array['height'] = "100"; $graph_array['width'] = "340"; - $graph_array['to'] = $config['time']['now']; + $graph_array['to'] = $config['time']['now']; $graph_array['from'] = $config['time']['day']; $graph_array['id'] = $args['interface_id']; $content .= generate_graph_tag($graph_array); diff --git a/html/includes/graphs/device/collectd.inc.php b/html/includes/graphs/device/collectd.inc.php index f1b55d5a6..294ac0e72 100755 --- a/html/includes/graphs/device/collectd.inc.php +++ b/html/includes/graphs/device/collectd.inc.php @@ -27,7 +27,7 @@ function makeTextBlock($text, $fontfile, $fontsize, $width) { $currentLine = 0; foreach ($words as $word) { $lineSize = imagettfbbox($fontsize, 0, $fontfile, $lines[$currentLine] . ' ' . $word); - if($lineSize[2] - $lineSize[0] < $width) { + if ($lineSize[2] - $lineSize[0] < $width) { $lines[$currentLine] .= ' ' . $word; } else { $currentLine++; @@ -47,6 +47,7 @@ function makeTextBlock($text, $fontfile, $fontsize, $width) { */ function error($code, $code_msg, $title, $msg) { global $config; + header(sprintf("HTTP/1.0 %d %s", $code, $code_msg)); header("Pragma: no-cache"); header("Expires: Mon, 01 Jan 2008 00:00:00 CET"); @@ -197,9 +198,9 @@ if (isset($MetaGraphDefs[$type])) { if(isset($rrd_cmd)) { - if($config['rrdcached']) { $rrd_cmd .= " --daemon ".$config['rrdcached'] . " "; } - if($_GET['from']) { $from = mres($_GET['from']); } - if($_GET['to']) { $to = mres($_GET['to']); } + if ($config['rrdcached']) { $rrd_cmd .= " --daemon ".$config['rrdcached'] . " "; } + if ($_GET['from']) { $from = mres($_GET['from']); } + if ($_GET['to']) { $to = mres($_GET['to']); } $rrd_cmd .= " -s " . $from . " -e " . $to; } diff --git a/html/includes/graphs/device/netstat_icmp.inc.php b/html/includes/graphs/device/netstat_icmp.inc.php index 3ea622ab5..83b4980b0 100644 --- a/html/includes/graphs/device/netstat_icmp.inc.php +++ b/html/includes/graphs/device/netstat_icmp.inc.php @@ -23,7 +23,7 @@ foreach($stats as $stat => $colour) $rrd_list[$i]['filename'] = $rrd_filename; $rrd_list[$i]['descr'] = str_replace("icmp", "", $stat); $rrd_list[$i]['rra'] = $stat; - if(strpos($stat, "Out") !== FALSE) + if (strpos($stat, "Out") !== FALSE) { $rrd_list[$i]['invert'] = TRUE; } diff --git a/html/includes/graphs/device/netstat_icmp_info.inc.php b/html/includes/graphs/device/netstat_icmp_info.inc.php index 38be4fbbb..1bf7b7dd6 100644 --- a/html/includes/graphs/device/netstat_icmp_info.inc.php +++ b/html/includes/graphs/device/netstat_icmp_info.inc.php @@ -23,7 +23,7 @@ foreach($stats as $stat => $array) $rrd_list[$i]['filename'] = $rrd_filename; $rrd_list[$i]['descr'] = str_replace("icmp", "", $stat); $rrd_list[$i]['rra'] = $stat; - if(strpos($stat, "Out") !== FALSE) + if (strpos($stat, "Out") !== FALSE) { $rrd_list[$i]['invert'] = TRUE; } diff --git a/html/includes/graphs/device/netstat_ip.inc.php b/html/includes/graphs/device/netstat_ip.inc.php index b3fcf0a6b..4ffa6ac96 100644 --- a/html/includes/graphs/device/netstat_ip.inc.php +++ b/html/includes/graphs/device/netstat_ip.inc.php @@ -20,7 +20,7 @@ foreach($stats as $stat => $array) $rrd_list[$i]['filename'] = $rrd_filename; $rrd_list[$i]['descr'] = str_replace("ip", "", $stat); $rrd_list[$i]['rra'] = $stat; - if(strpos($stat, "Out") !== FALSE) + if (strpos($stat, "Out") !== FALSE) { $rrd_list[$i]['invert'] = TRUE; } diff --git a/html/includes/graphs/device/netstat_snmp.inc.php b/html/includes/graphs/device/netstat_snmp.inc.php index 9c70ecf07..34e82b595 100644 --- a/html/includes/graphs/device/netstat_snmp.inc.php +++ b/html/includes/graphs/device/netstat_snmp.inc.php @@ -20,7 +20,7 @@ foreach($stats as $stat) $rrd_list[$i]['filename'] = $rrd_filename; $rrd_list[$i]['descr'] = str_replace("snmp", "", $stat); $rrd_list[$i]['rra'] = $stat; - if(strpos($stat, "Out") !== FALSE) + if (strpos($stat, "Out") !== FALSE) { $rrd_list[$i]['invert'] = TRUE; } diff --git a/html/includes/graphs/device/netstat_snmp_pkt.inc.php b/html/includes/graphs/device/netstat_snmp_pkt.inc.php index 46d084790..035059108 100644 --- a/html/includes/graphs/device/netstat_snmp_pkt.inc.php +++ b/html/includes/graphs/device/netstat_snmp_pkt.inc.php @@ -15,7 +15,7 @@ foreach($stats as $stat) $rrd_list[$i]['filename'] = $rrd_filename; $rrd_list[$i]['descr'] = str_replace("snmp", "", $stat); $rrd_list[$i]['rra'] = $stat; - if(strpos($stat, "Out") !== FALSE) + if (strpos($stat, "Out") !== FALSE) { $rrd_list[$i]['invert'] = TRUE; } diff --git a/html/includes/graphs/device/netstat_tcp.inc.php b/html/includes/graphs/device/netstat_tcp.inc.php index 7ef50e642..2c977115b 100644 --- a/html/includes/graphs/device/netstat_tcp.inc.php +++ b/html/includes/graphs/device/netstat_tcp.inc.php @@ -14,7 +14,7 @@ foreach($stats as $stat) $rrd_list[$i]['filename'] = $rrd_filename; $rrd_list[$i]['descr'] = str_replace("tcp", "", $stat); $rrd_list[$i]['rra'] = $stat; - if(strpos($stat, "Out") !== FALSE || strpos($stat, "Retrans") !== FALSE || strpos($stat, "Attempt") !== FALSE) + if (strpos($stat, "Out") !== FALSE || strpos($stat, "Retrans") !== FALSE || strpos($stat, "Attempt") !== FALSE) { $rrd_list[$i]['invert'] = TRUE; } diff --git a/html/includes/graphs/device/netstat_udp.inc.php b/html/includes/graphs/device/netstat_udp.inc.php index 016e110e2..caa723fe5 100644 --- a/html/includes/graphs/device/netstat_udp.inc.php +++ b/html/includes/graphs/device/netstat_udp.inc.php @@ -14,7 +14,7 @@ foreach($stats as $stat) $rrd_list[$i]['filename'] = $rrd_filename; $rrd_list[$i]['descr'] = str_replace("udp", "", $stat); $rrd_list[$i]['rra'] = $stat; - if(strpos($stat, "Out") !== FALSE || strpos($stat, "Retrans") !== FALSE || strpos($stat, "Attempt") !== FALSE) + if (strpos($stat, "Out") !== FALSE || strpos($stat, "Retrans") !== FALSE || strpos($stat, "Attempt") !== FALSE) { $rrd_list[$i]['invert'] = TRUE; } diff --git a/html/includes/graphs/generic_bits.inc.php b/html/includes/graphs/generic_bits.inc.php index 8e3daa94f..40586bed1 100644 --- a/html/includes/graphs/generic_bits.inc.php +++ b/html/includes/graphs/generic_bits.inc.php @@ -38,8 +38,8 @@ $rrd_options .= " CDEF:inbits=inoctets,8,*"; $rrd_options .= " CDEF:inbits_max=inoctets_max,8,*"; if ($config['rrdgraph_real_95th']) { - $rrd_options .= " CDEF:highbits=inoctets,outoctets,MAX,8,*"; - $rrd_options .= " VDEF:95thhigh=highbits,95,PERCENT"; + $rrd_options .= " CDEF:highbits=inoctets,outoctets,MAX,8,*"; + $rrd_options .= " VDEF:95thhigh=highbits,95,PERCENT"; } $rrd_options .= " VDEF:totin=inoctets,TOTAL"; @@ -67,8 +67,8 @@ $rrd_options .= " GPRINT:outbits_max:MAX:%6.2lf%s"; $rrd_options .= " GPRINT:95thout:%6.2lf%s\\\\n"; if ($config['rrdgraph_real_95th']) { - $rrd_options .= " HRULE:95thhigh#FF0000:\"Highest\""; - $rrd_options .= " GPRINT:95thhigh:\"%30.2lf%s\\n\""; + $rrd_options .= " HRULE:95thhigh#FF0000:\"Highest\""; + $rrd_options .= " GPRINT:95thhigh:\"%30.2lf%s\\n\""; } $rrd_options .= " GPRINT:tot:'Total %6.2lf%s'"; diff --git a/html/includes/graphs/generic_multi_line.inc.php b/html/includes/graphs/generic_multi_line.inc.php index 464e9d46d..37886d499 100644 --- a/html/includes/graphs/generic_multi_line.inc.php +++ b/html/includes/graphs/generic_multi_line.inc.php @@ -27,7 +27,7 @@ foreach ($rrd_list as $rrd) $rrd_options .= " DEF:".$id."=$filename:$rra:AVERAGE"; - if(!$basicrrd) + if (!$basicrrd) { $rrd_options .= " DEF:".$id."min=$filename:$rra:MIN"; $rrd_options .= " DEF:".$id."max=$filename:$rra:MAX"; @@ -45,7 +45,7 @@ foreach ($rrd_list as $rrd) } - if(!$basicrrd) + if (!$basicrrd) { $rrd_optionsb .= " GPRINT:".$id.":LAST:%5.2lf%s GPRINT:".$id."min:MIN:%5.2lf%s"; $rrd_optionsb .= " GPRINT:".$id."max:MAX:%5.2lf%s GPRINT:".$id.":AVERAGE:'%5.2lf%s\\n'"; diff --git a/html/includes/graphs/generic_multi_simplex_seperated.inc.php b/html/includes/graphs/generic_multi_simplex_seperated.inc.php index 08fef77ec..4e252a2d1 100644 --- a/html/includes/graphs/generic_multi_simplex_seperated.inc.php +++ b/html/includes/graphs/generic_multi_simplex_seperated.inc.php @@ -48,7 +48,7 @@ foreach ($rrd_list as $i => $rrd) } ## Are our text values related to te multiplier/divisor or not? - if(isset($text_orig) && $text_orig) + if (isset($text_orig) && $text_orig) { $t_defname = $rrd['rra']; } else { diff --git a/html/includes/graphs/macaccounting/auth.inc.php b/html/includes/graphs/macaccounting/auth.inc.php index 50f892587..d1a6cc759 100644 --- a/html/includes/graphs/macaccounting/auth.inc.php +++ b/html/includes/graphs/macaccounting/auth.inc.php @@ -5,7 +5,7 @@ if (is_numeric($id)) $acc = dbFetchRow("SELECT * FROM `mac_accounting` AS M, `ports` AS I, `devices` AS D WHERE M.ma_id = ? AND I.interface_id = M.interface_id AND I.device_id = D.device_id", array($id)); - if($debug) { + if ($debug) { echo("
");
     print_r($acc);
     echo("
"); @@ -14,13 +14,13 @@ if (is_numeric($id)) if (is_array($acc)) { - if($auth || port_permitted($acc['interface_id'])) + if ($auth || port_permitted($acc['interface_id'])) { - if($debug) { echo($config['rrd_dir'] . "/" . $acc['hostname'] . "/" . safename("cip-" . $acc['ifIndex'] . "-" . $acc['mac'] . ".rrd")); } + if ($debug) { echo($config['rrd_dir'] . "/" . $acc['hostname'] . "/" . safename("cip-" . $acc['ifIndex'] . "-" . $acc['mac'] . ".rrd")); } - if(is_file($config['rrd_dir'] . "/" . $acc['hostname'] . "/" . safename("cip-" . $acc['ifIndex'] . "-" . $acc['mac'] . ".rrd"))) + if (is_file($config['rrd_dir'] . "/" . $acc['hostname'] . "/" . safename("cip-" . $acc['ifIndex'] . "-" . $acc['mac'] . ".rrd"))) { - if($debug) { echo("exists"); } + if ($debug) { echo("exists"); } $rrd_filename = $config['rrd_dir'] . "/" . $acc['hostname'] . "/" . safename("cip-" . $acc['ifIndex'] . "-" . $acc['mac'] . ".rrd"); $port = get_port_by_id($acc['interface_id']); $device = device_by_id_cache($port['device_id']); diff --git a/html/includes/header.inc.php b/html/includes/header.inc.php index e4545a58e..05f35aabd 100644 --- a/html/includes/header.inc.php +++ b/html/includes/header.inc.php @@ -48,7 +48,7 @@ if (isset($_SESSION['authenticated']) && $_SESSION['authenticated'])
- + diff --git a/html/includes/hostbox-basic.inc.php b/html/includes/hostbox-basic.inc.php index c21dc3ca4..11be6edbc 100644 --- a/html/includes/hostbox-basic.inc.php +++ b/html/includes/hostbox-basic.inc.php @@ -30,7 +30,7 @@ $device['os_text'] = $config['os'][$device['os']]['text']; echo(' ' . generate_device_link($device) . '' - ); + ); echo(' ' . $device['hardware'] . ' ' . $device['features'] . ''); echo(' ' . $device['os_text'] . ' ' . $device['version'] . ''); diff --git a/html/includes/hostbox.inc.php b/html/includes/hostbox.inc.php index d08b9b2fc..43597c875 100644 --- a/html/includes/hostbox.inc.php +++ b/html/includes/hostbox.inc.php @@ -36,7 +36,7 @@ echo(' ' . $image . ' ' . generate_device_link($device) . '
' . $device['sysName'] . '' - ); + ); echo (''); if ($port_count) { echo(' '.$port_count); } diff --git a/html/includes/javascript-interfacepicker.inc.php b/html/includes/javascript-interfacepicker.inc.php index d3011b02a..61116f594 100644 --- a/html/includes/javascript-interfacepicker.inc.php +++ b/html/includes/javascript-interfacepicker.inc.php @@ -7,12 +7,12 @@ function getInterfaceList(sel) { var deviceId = sel.options[sel.selectedIndex].value; document.getElementById('interface_id').options.length = 0; // Empty city select box - if (deviceId.length>0){ + if (deviceId.length>0) { var index = ajax.length; ajax[index] = new sack(); ajax[index].requestFile = '/ajax_listports.php?device_id='+deviceId; // Specifying which file to get - ajax[index].onCompletion = function(){ createInterfaces(index) }; // Specify function that will be executed after file has been found + ajax[index].onCompletion = function() { createInterfaces(index) }; // Specify function that will be executed after file has been found ajax[index].runAJAX(); // Execute AJAX function } } diff --git a/html/includes/print-interface.inc.php b/html/includes/print-interface.inc.php index 3f28947c3..99374eaaf 100644 --- a/html/includes/print-interface.inc.php +++ b/html/includes/print-interface.inc.php @@ -223,7 +223,7 @@ if ($port['pagpGroupIfIndex'] && $port['pagpGroupIfIndex'] != $port['ifIndex']) foreach(dbFetchRows("SELECT * FROM `ports_stack` WHERE `interface_id_low` = ? and `device_id` = ?", array($port['ifIndex'], $device['device_id'])) as $higher_if) { - if($higher_if['interface_id_high']) + if ($higher_if['interface_id_high']) { $this_port = get_port_by_index_cache($device['device_id'], $higher_if['interface_id_high']); echo("$br " . generate_port_link($this_port) . ""); @@ -233,7 +233,7 @@ foreach(dbFetchRows("SELECT * FROM `ports_stack` WHERE `interface_id_low` = ? an foreach(dbFetchRows("SELECT * FROM `ports_stack` WHERE `interface_id_high` = ? and `device_id` = ?", array($port['ifIndex'], $device['device_id'])) as $lower_if) { - if($lower_if['interface_id_low']) + if ($lower_if['interface_id_low']) { $this_port = get_port_by_index_cache($device['device_id'], $lower_if['interface_id_low']); echo("$br " . generate_port_link($this_port) . ""); diff --git a/html/includes/print-menubar.php b/html/includes/print-menubar.php index f9674ae99..1b1e5e22c 100644 --- a/html/includes/print-menubar.php +++ b/html/includes/print-menubar.php @@ -49,7 +49,7 @@ foreach (dbFetchRows("SELECT * FROM `devices`") as $device)
-

Search

+

Search

@@ -98,7 +98,7 @@ if ($_SESSION['userlevel'] >= '10') {
diff --git a/html/pages/device/entphysical.inc.php b/html/pages/device/entphysical.inc.php index 5b592d21c..007fa2602 100644 --- a/html/pages/device/entphysical.inc.php +++ b/html/pages/device/entphysical.inc.php @@ -19,7 +19,7 @@ function printEntPhysical($ent, $level, $class) echo(" "); # FIXME /ciscosensors? doesn't exist anymore methinks? or does it? $sensor = dbFetchRow("SELECT * FROM `sensors` WHERE `device_id` = ? AND `entPhysicalIndex` = ?", array($device['device_id'], $ent['entPhysicalIndex'])); - if(count($sensor)) + if (count($sensor)) { $link = " href='device/".$device['device_id']."/health/".$sensor['sensor_class']."/' onmouseover=\"return overlib('', LEFT,FGCOLOR,'#e5e5e5', BGCOLOR, '#c0c0c0', BORDER, 5, CELLPAD, 4, CAPCOLOR, '#050505');\" onmouseout=\"return nd();\""; } diff --git a/html/pages/device/graphs/ipSytemStats.inc.php b/html/pages/device/graphs/ipSytemStats.inc.php index 3d4958963..f18bf825f 100644 --- a/html/pages/device/graphs/ipSytemStats.inc.php +++ b/html/pages/device/graphs/ipSytemStats.inc.php @@ -1,6 +1,6 @@ "); if ($vars['subview'] == "top10") { - if(!isset($vars['sort'])) { $vars['sort'] = "in"; } - if(!isset($vars['period'])) { $vars['period'] = "1day"; } + if (!isset($vars['sort'])) { $vars['sort'] = "in"; } + if (!isset($vars['period'])) { $vars['period'] = "1day"; } $from = "-" . $vars['period']; diff --git a/html/pages/device/port/realtime.inc.php b/html/pages/device/port/realtime.inc.php index 9bfc63389..cde53e704 100644 --- a/html/pages/device/port/realtime.inc.php +++ b/html/pages/device/port/realtime.inc.php @@ -3,7 +3,7 @@ ### FIXME - do this in a function and/or do it in graph-realtime.php if(!isset($vars['interval'])) { - if($device['os'] == "linux") { + if ($device['os'] == "linux") { $vars['interval'] = "15"; } else { $vars['interval'] = "2"; diff --git a/html/pages/device/ports/neighbours.inc.php b/html/pages/device/ports/neighbours.inc.php index 0240176ac..8c1ea6feb 100644 --- a/html/pages/device/ports/neighbours.inc.php +++ b/html/pages/device/ports/neighbours.inc.php @@ -18,7 +18,7 @@ foreach(dbFetchRows("SELECT * FROM links AS L, ports AS I WHERE I.device_id = ? echo(''); echo(''.generate_port_link($neighbour).'
'.$neighbour['ifAlias'].''); - if(is_numeric($neighbour['remote_interface_id']) && $neighbour['remote_interface_id']) + if (is_numeric($neighbour['remote_interface_id']) && $neighbour['remote_interface_id']) { $remote_port = get_port_by_id($neighbour['remote_interface_id']); $remote_device = device_by_id_cache($remote_port['device_id']); diff --git a/html/pages/device/routing.inc.php b/html/pages/device/routing.inc.php index 998fd2607..e1456c899 100644 --- a/html/pages/device/routing.inc.php +++ b/html/pages/device/routing.inc.php @@ -43,7 +43,7 @@ if (is_file("pages/device/routing/".mres($vars['proto']).".inc.php")) { if ($type != "overview") { - if(is_file("pages/device/routing/overview/".mres($type).".inc.php")) { + if (is_file("pages/device/routing/overview/".mres($type).".inc.php")) { $g_i++; if (!is_integer($g_i/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; } diff --git a/html/pages/device/routing/bgp.inc.php b/html/pages/device/routing/bgp.inc.php index 2485314c4..89066142e 100644 --- a/html/pages/device/routing/bgp.inc.php +++ b/html/pages/device/routing/bgp.inc.php @@ -134,7 +134,7 @@ foreach (dbFetchRows("SELECT * FROM `bgpPeers` WHERE `device_id` = ? ORDER BY `b echo(" ".$i." " . $peeraddresslink . "
".generate_device_link($peer, shorthost($peer['hostname']), 'bgp/')." - $peer_type + $peer_type " . (isset($peer['afi']) ? $peer['afi'] : '') . " AS" . $peer['bgpPeerRemoteAs'] . "
" . $peer['astext'] . " " . $peer['bgpPeerAdminStatus'] . "
" . $peer['bgpPeerState'] . "
@@ -177,7 +177,7 @@ foreach (dbFetchRows("SELECT * FROM `bgpPeers` WHERE `device_id` = ? ORDER BY `b if ($vars['view'] == 'updates') { $peer['graph'] = 1; } - if($peer['graph']) + if ($peer['graph']) { $graph_array['height'] = "100"; $graph_array['width'] = "216"; diff --git a/html/pages/device/routing/cef.inc.php b/html/pages/device/routing/cef.inc.php index b832f9984..7a48909d7 100644 --- a/html/pages/device/routing/cef.inc.php +++ b/html/pages/device/routing/cef.inc.php @@ -3,7 +3,7 @@ print_optionbar_start(); $menu_options = array('basic' => 'Basic', - 'graphs' => 'Graphs', + 'graphs' => 'Graphs', ); if (!$_GET['optb']) { $_GET['optb'] = "basic"; } @@ -48,7 +48,7 @@ foreach (dbFetchRows("SELECT * FROM `cef_switching` WHERE `device_id` = ? ORDER $interval = $cef['updated'] - $cef['updated_prev']; - if(!$entity['entPhysicalModelName'] && $entity['entPhysicalContainedIn']) + if (!$entity['entPhysicalModelName'] && $entity['entPhysicalContainedIn']) { $parent_entity = dbFetchRow("SELECT * FROM `entPhysical` WHERE device_id = ? AND `entPhysicalIndex` = ?", array($device['device_id'], $entity['entPhysicalContainedIn'])); $entity_descr = $entity['entPhysicalName'] . " (" . $parent_entity['entPhysicalModelName'] .")"; @@ -77,19 +77,19 @@ foreach (dbFetchRows("SELECT * FROM `cef_switching` WHERE `device_id` = ? ORDER echo(""); echo("".format_si($cef['drop'])); - if($cef['drop'] > $cef['drop_prev']) { echo(" (".round(($cef['drop']-$cef['drop_prev'])/$interval,2)."/sec)"); } + if ($cef['drop'] > $cef['drop_prev']) { echo(" (".round(($cef['drop']-$cef['drop_prev'])/$interval,2)."/sec)"); } echo(""); echo("".format_si($cef['punt'])); - if($cef['punt'] > $cef['punt_prev']) { echo(" (".round(($cef['punt']-$cef['punt_prev'])/$interval,2)."/sec)"); } + if ($cef['punt'] > $cef['punt_prev']) { echo(" (".round(($cef['punt']-$cef['punt_prev'])/$interval,2)."/sec)"); } echo(""); echo("".format_si($cef['punt2host'])); - if($cef['punt2host'] > $cef['punt2host_prev']) { echo(" (".round(($cef['punt2host']-$cef['punt2host_prev'])/$interval,2)."/sec)"); } + if ($cef['punt2host'] > $cef['punt2host_prev']) { echo(" (".round(($cef['punt2host']-$cef['punt2host_prev'])/$interval,2)."/sec)"); } echo(""); echo(" "); - if($_GET['optb'] == "graphs") + if ($_GET['optb'] == "graphs") { $graph_array['height'] = "100"; $graph_array['width'] = "215"; diff --git a/html/pages/device/routing/ospf.inc.php b/html/pages/device/routing/ospf.inc.php index c60151312..b161b487b 100644 --- a/html/pages/device/routing/ospf.inc.php +++ b/html/pages/device/routing/ospf.inc.php @@ -109,7 +109,7 @@ foreach (dbFetchRows("SELECT * FROM `ospf_instances` WHERE `device_id` = ?", arr $host = @dbFetchRow("SELECT * FROM ipv4_addresses AS A, ports AS I, devices AS D WHERE A.ipv4_address = ? AND I.interface_id = A.interface_id AND D.device_id = I.device_id", array($nbr['ospfNbrRtrId'])); - if(is_array($host)) { $rtr_id = generate_dev_link($host, $nbr['ospfNbrRtrId']); } else { $rtr_id = "unknown"; } + if (is_array($host)) { $rtr_id = generate_dev_link($host, $nbr['ospfNbrRtrId']); } else { $rtr_id = "unknown"; } echo(''); echo(' '); diff --git a/html/pages/devices.inc.php b/html/pages/devices.inc.php index db7d192ef..33da73e7f 100644 --- a/html/pages/devices.inc.php +++ b/html/pages/devices.inc.php @@ -203,7 +203,7 @@ foreach ($menu_options as $option => $text) '')).'">Restore Search'); } else { @@ -212,7 +212,7 @@ foreach ($menu_options as $option => $text) echo(" | "); - if($vars['bare'] == "yes") + if ($vars['bare'] == "yes") { echo('Restore Header'); } else { @@ -262,7 +262,7 @@ if($format == "graph") } else { echo(''); - if($subformat = "detail") + if ($subformat = "detail") { echo(''); } @@ -274,7 +274,7 @@ if($format == "graph") if (!$location_filter || ((get_dev_attrib($device,'override_sysLocation_bool') && get_dev_attrib($device,'override_sysLocation_string') == $location_filter) || $device['location'] == $location_filter)) { - if($subformat == "detail") + if ($subformat == "detail") { include("includes/hostbox.inc.php"); } else { diff --git a/html/pages/front/default.php b/html/pages/front/default.php index 1a151899d..c7af666d2 100644 --- a/html/pages/front/default.php +++ b/html/pages/front/default.php @@ -15,7 +15,7 @@ $sql = mysql_query("SELECT * FROM `devices` WHERE `status` = '0' AND `ignore` = } else { $sql = mysql_query("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'"); } -while ($device = mysql_fetch_assoc($sql)){ +while ($device = mysql_fetch_assoc($sql)) { generate_front_box("#ffaaaa", "
".generate_device_link($device, shorthost($device['hostname']))."
Device Down
diff --git a/html/pages/front/demo.php b/html/pages/front/demo.php index bb9719cc4..8d6973d6e 100644 --- a/html/pages/front/demo.php +++ b/html/pages/front/demo.php @@ -69,7 +69,7 @@ $nodes = array(); $sql = mysql_query("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' AND A.attrib_value < '86400'"); -while ($device = mysql_fetch_array($sql)){ +while ($device = mysql_fetch_array($sql)) { unset($already); $i = 0; while ($i <= count($nodes)) { @@ -84,7 +84,7 @@ while ($device = mysql_fetch_array($sql)){ $sql = mysql_query("SELECT * FROM `devices` WHERE `status` = '0' AND `ignore` = '0'"); -while ($device = mysql_fetch_array($sql)){ +while ($device = mysql_fetch_array($sql)) { if (device_permitted($device['device_id'])) { echo("
".generate_device_link($device, shorthost($device['hostname']))."
@@ -157,7 +157,7 @@ if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== FALSE && $c } echo(" -
$errorboxes
+
$errorboxes

Recent Syslog Messages

"); diff --git a/html/pages/front/example2.php b/html/pages/front/example2.php index dd5d8daf9..3b167566e 100644 --- a/html/pages/front/example2.php +++ b/html/pages/front/example2.php @@ -28,7 +28,7 @@ while ($device = mysql_fetch_assoc($sql)) } $sql = mysql_query("SELECT * FROM `devices` WHERE `status` = '0' AND `ignore` = '0'"); -while ($device = mysql_fetch_assoc($sql)){ +while ($device = mysql_fetch_assoc($sql)) { echo("
".generate_device_link($device, shorthost($device['hostname']))."
@@ -39,7 +39,7 @@ while ($device = mysql_fetch_assoc($sql)){ } $sql = mysql_query("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'"); -while ($interface = mysql_fetch_assoc($sql)){ +while ($interface = mysql_fetch_assoc($sql)) { echo("
".generate_device_link($interface, shorthost($interface['hostname']))."
@@ -51,7 +51,7 @@ while ($interface = mysql_fetch_assoc($sql)){ } $sql = mysql_query("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'"); -while ($service = mysql_fetch_assoc($sql)){ +while ($service = mysql_fetch_assoc($sql)) { echo("
".generate_device_link($service, shorthost($service['hostname']))."
@@ -63,7 +63,7 @@ while ($service = mysql_fetch_assoc($sql)){ } $sql = mysql_query("SELECT * FROM `devices` AS D, bgpPeers AS B WHERE bgpPeerState != 'established' AND B.device_id = D.device_id"); -while ($peer = mysql_fetch_assoc($sql)){ +while ($peer = mysql_fetch_assoc($sql)) { echo("
".generate_device_link($peer, shorthost($peer['hostname']))."
@@ -77,7 +77,7 @@ while ($peer = mysql_fetch_assoc($sql)){ if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== FALSE && $config['uptime_warning'] > 0) { $sql = mysql_query("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'] . "'"); - while ($device = mysql_fetch_assoc($sql)){ + while ($device = mysql_fetch_assoc($sql)) { echo("
".generate_device_link($device, shorthost($device['hostname']))."
@@ -89,7 +89,7 @@ if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== FALSE && $c echo(" -
$errorboxes
+
$errorboxes

Recent Syslog Messages

diff --git a/html/pages/front/jt.php b/html/pages/front/jt.php index 1c7beb4f4..afcf180c3 100644 --- a/html/pages/front/jt.php +++ b/html/pages/front/jt.php @@ -14,7 +14,7 @@ if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== FALSE && $c $sql = mysql_query("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); -while ($device = mysql_fetch_assoc($sql)){ +while ($device = mysql_fetch_assoc($sql)) { unset($already); $i = 0; while ($i <= count($nodes)) { @@ -29,7 +29,7 @@ while ($device = mysql_fetch_assoc($sql)){ $sql = mysql_query("SELECT * FROM `devices` WHERE `status` = '0' AND `ignore` = '0'"); -while ($device = mysql_fetch_assoc($sql)){ +while ($device = mysql_fetch_assoc($sql)) { if (device_permitted($device['device_id'])) { echo("
".generate_device_link($device, shorthost($device['hostname']))."
@@ -42,7 +42,7 @@ while ($device = mysql_fetch_assoc($sql)){ if ($config['warn']['ifdown']) { $sql = mysql_query("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'"); -while ($interface = mysql_fetch_assoc($sql)){ +while ($interface = mysql_fetch_assoc($sql)) { if (port_permitted($interface['interface_id'])) { echo("
".generate_device_link($interface, shorthost($interface['hostname']))."
@@ -56,7 +56,7 @@ while ($interface = mysql_fetch_assoc($sql)){ } $sql = mysql_query("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'"); -while ($service = mysql_fetch_assoc($sql)){ +while ($service = mysql_fetch_assoc($sql)) { if (device_permitted($service['device_id'])) { echo("
".generate_device_link($service, shorthost($service['hostname']))."
@@ -68,7 +68,7 @@ while ($service = mysql_fetch_assoc($sql)){ } $sql = mysql_query("SELECT * FROM `devices` AS D, bgpPeers AS B WHERE bgpPeerAdminStatus = 'start' AND bgpPeerState != 'established' AND B.device_id = D.device_id"); -while ($peer = mysql_fetch_assoc($sql)){ +while ($peer = mysql_fetch_assoc($sql)) { if (device_permitted($peer['device_id'])) { echo("
".generate_device_link($peer, shorthost($peer['hostname']))."
@@ -82,7 +82,7 @@ while ($peer = mysql_fetch_assoc($sql)){ if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== FALSE && $config['uptime_warning'] > 0) { $sql = mysql_query("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'"); - while ($device = mysql_fetch_assoc($sql)){ + while ($device = mysql_fetch_assoc($sql)) { if (device_permitted($device['device_id']) && $device['attrib_value'] < $config['uptime_warning'] && $device['attrib_type'] == "uptime") { echo("
".generate_device_link($device, shorthost($device['hostname']))."
@@ -96,7 +96,7 @@ if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== FALSE && $c echo(" -
$errorboxes
+
$errorboxes

Recent Syslog Messages

diff --git a/html/pages/front/traffic.php b/html/pages/front/traffic.php index 36ba7ad96..a8478b011 100644 --- a/html/pages/front/traffic.php +++ b/html/pages/front/traffic.php @@ -81,7 +81,7 @@ foreach (dbFetchRows("SELECT * FROM `devices` AS D, bgpPeers AS B WHERE bgpPeerA 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){ + 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']))."
@@ -95,7 +95,7 @@ if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== FALSE && $c echo(" -
$errorboxes
+
$errorboxes

Recent Syslog Messages

diff --git a/html/pages/health/sensors.inc.php b/html/pages/health/sensors.inc.php index 2316075ad..a4c42d284 100644 --- a/html/pages/health/sensors.inc.php +++ b/html/pages/health/sensors.inc.php @@ -16,8 +16,8 @@ echo('
DeviceOperating SystemPlatformUptime/Location
'); echo(' - - + + @@ -47,8 +47,8 @@ foreach (dbFetchRows($sql, $param) as $sensor) echo(" - - + + diff --git a/html/pages/inventory.inc.php b/html/pages/inventory.inc.php index cdfb21a93..f1d9346ed 100644 --- a/html/pages/inventory.inc.php +++ b/html/pages/inventory.inc.php @@ -38,7 +38,7 @@ ?> - + ' . $alert . ' - + '); - if($vars['view'] == "traffic") + if ($vars['view'] == "traffic") { echo(' - + - + @@ -191,7 +191,7 @@ else if ($_GET['optc'] == 'updates') { $peer['graph'] = 1; } - if($peer['graph']) + if ($peer['graph']) { $graph_array['height'] = "100"; $graph_array['width'] = "220"; diff --git a/html/pages/routing/overview.inc.php b/html/pages/routing/overview.inc.php index bb8274707..f6c1432b5 100644 --- a/html/pages/routing/overview.inc.php +++ b/html/pages/routing/overview.inc.php @@ -2,9 +2,9 @@ foreach ($datas as $type) { - if($type != "overview") + if ($type != "overview") { - if(is_file("pages/routing/overview/".mres($type).".inc.php")) { + if (is_file("pages/routing/overview/".mres($type).".inc.php")) { $g_i++; if (!is_integer($g_i/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; } diff --git a/html/pages/routing/vrf.inc.php b/html/pages/routing/vrf.inc.php index adf87b5a1..c825486fa 100644 --- a/html/pages/routing/vrf.inc.php +++ b/html/pages/routing/vrf.inc.php @@ -2,8 +2,8 @@ if ($_SESSION['userlevel'] >= '5') { - if(!isset($_GET['optb'])) { $_GET['optb'] = "all"; } - if(!isset($_GET['optc'])) { $_GET['optc'] = "basic"; } + if (!isset($_GET['optb'])) { $_GET['optb'] = "all"; } + if (!isset($_GET['optc'])) { $_GET['optc'] = "basic"; } print_optionbar_start(); diff --git a/html/pages/search/ipv4.inc.php b/html/pages/search/ipv4.inc.php index 9827be7f0..f7d87b27c 100644 --- a/html/pages/search/ipv4.inc.php +++ b/html/pages/search/ipv4.inc.php @@ -19,8 +19,8 @@ foreach (dbFetchRows("SELECT `device_id`,`hostname` FROM `devices` GROUP BY `hos
Device Sensor Current Range limit Notes
" . generate_device_link($sensor) . " $sensor_popup$sensor_minigraph$alert$sensor_minigraph$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'] : '') . " ' . $num . ' devices ' . $net . ' network' . $srv . ' servers' . $srv . ' servers ' . $fwl . ' firewalls
'); diff --git a/html/pages/routing/bgp.inc.php b/html/pages/routing/bgp.inc.php index 66c4c89f9..f6dc79d58 100644 --- a/html/pages/routing/bgp.inc.php +++ b/html/pages/routing/bgp.inc.php @@ -11,7 +11,7 @@ else echo('BGP » '); - if(!$_GET['optb']) { $_GET['optb'] = "all"; } + if (!$_GET['optb']) { $_GET['optb'] = "all"; } if ($_GET['opta'] == "bgp" && $_GET['optb'] == "all") { echo(""); } echo('All'); @@ -38,7 +38,7 @@ else echo('
'); - if(!$_GET['optc']) { $_GET['optc'] = "nographs"; } + if (!$_GET['optc']) { $_GET['optc'] = "nographs"; } if ($_GET['opta'] == "bgp" && $_GET['optc'] == "nographs") { echo(""); } echo('No Graphs'); @@ -148,9 +148,9 @@ else echo("
" . $localaddresslink . "
".generate_device_link($peer, shorthost($peer['hostname']), 'routing/bgp/')."
»» " . $peeraddresslink . "$peer_type$peer_type ".$peer['afi']." AS" . $peer['bgpPeerRemoteAs'] . "
" . $peer['astext'] . "
" . $peer['bgpPeerAdminStatus'] . "
" . $peer['bgpPeerState'] . "
diff --git a/html/pages/search/ipv6.inc.php b/html/pages/search/ipv6.inc.php index ede224ca3..5124a8d3f 100644 --- a/html/pages/search/ipv6.inc.php +++ b/html/pages/search/ipv6.inc.php @@ -19,8 +19,8 @@ foreach (dbFetchRows("SELECT `device_id`,`hostname` FROM `devices` GROUP BY `hos diff --git a/html/pages/search/mac.inc.php b/html/pages/search/mac.inc.php index 608e77f44..b2eabc2c5 100644 --- a/html/pages/search/mac.inc.php +++ b/html/pages/search/mac.inc.php @@ -19,8 +19,8 @@ foreach (dbFetchRows("SELECT `device_id`,`hostname` FROM `devices` GROUP BY `hos diff --git a/html/pages/syslog.inc.php b/html/pages/syslog.inc.php index 9a46b3444..1832523d8 100644 --- a/html/pages/syslog.inc.php +++ b/html/pages/syslog.inc.php @@ -17,7 +17,7 @@ foreach (dbFetchRows("SELECT `program` FROM `syslog` GROUP BY `program` ORDER BY `program`") as $data) { echo(""); } ?> @@ -32,7 +32,7 @@ { echo(""); } @@ -69,7 +69,7 @@ if (is_numeric($_POST['device'])) if ($_SESSION['userlevel'] >= '5') { $sql = "SELECT *, DATE_FORMAT(timestamp, '%Y-%m-%d %T') AS date from syslog AS S"; - if(count($array)) + if (count($array)) { $sql .= " WHERE 1 ".$where; } @@ -77,7 +77,7 @@ if ($_SESSION['userlevel'] >= '5') } else { $sql = "SELECT *, DATE_FORMAT(timestamp, '%Y-%m-%d %T') AS date from syslog AS S, devices_perms AS P"; $sql .= "WHERE S.device_id = P.device_id AND P.user_id = ?"; - if(count($array)) + if (count($array)) { $sql .= " WHERE 1 ".$where; } diff --git a/includes/common.php b/includes/common.php index 18b213f73..ec849c8d1 100644 --- a/includes/common.php +++ b/includes/common.php @@ -201,9 +201,9 @@ function device_by_id_cache($device_id, $refresh = '0') function truncate($substring, $max = 50, $rep = '...') { - if (strlen($substring) < 1){ $string = $rep; } else { $string = $substring; } + if (strlen($substring) < 1) { $string = $rep; } else { $string = $substring; } $leave = $max - strlen ($rep); - if (strlen($string) > $max){ return substr_replace($string, $rep, $leave); } else { return $string; } + if (strlen($string) > $max) { return substr_replace($string, $rep, $leave); } else { return $string; } } function mres($string) diff --git a/includes/dbFacile.php b/includes/dbFacile.php index a0acba997..d035a1c27 100644 --- a/includes/dbFacile.php +++ b/includes/dbFacile.php @@ -27,7 +27,7 @@ function dbQuery($sql, $parameters = array()) { $fullSql = dbMakeQuery($sql, $parameters); if ($debug) { echo(" SQL[".$fullSql."] "); } /* - if($this->logFile) + if ($this->logFile) $time_start = microtime(true); */ @@ -35,13 +35,13 @@ function dbQuery($sql, $parameters = array()) { $result = mysql_query($fullSql); // sets $this->result /* - if($this->logFile) { + if ($this->logFile) { $time_end = microtime(true); fwrite($this->logFile, date('Y-m-d H:i:s') . "\n" . $fullSql . "\n" . number_format($time_end - $time_start, 8) . " seconds\n\n"); } */ - if($result === false && (error_reporting() & 1)) { + if ($result === false && (error_reporting() & 1)) { // aye. this gets triggers on duplicate Contact insert //trigger_error('QDB - Error in query: ' . $fullSql . ' : ' . mysql_error(), E_USER_WARNING); } @@ -61,7 +61,7 @@ function dbInsert($data, $table) { // it allows the method to work for those that would rather it (or expect it to) // follow closer with SQL convention: // insert into the TABLE this DATA - if(is_string($data) && is_array($table)) { + if (is_string($data) && is_array($table)) { $tmp = $data; $data = $table; $table = $tmp; @@ -73,12 +73,12 @@ function dbInsert($data, $table) { $time_start = microtime(true); dbBeginTransaction(); $result = dbQuery($sql, $data); - if($result) { + if ($result) { $id = mysql_insert_id(); dbCommitTransaction(); #return $id; } else { - if($table != 'Contact') { + if ($table != 'Contact') { trigger_error('QDB - Insert failed.', E_USER_WARNING); } dbRollbackTransaction(); @@ -108,7 +108,7 @@ function dbUpdate($data, $table, $where = null, $parameters = array()) { // it allows the method to work for those that would rather it (or expect it to) // follow closer with SQL convention: // update the TABLE with this DATA - if(is_string($data) && is_array($table)) { + if (is_string($data) && is_array($table)) { $tmp = $data; $data = $table; $table = $tmp; @@ -123,13 +123,13 @@ function dbUpdate($data, $table, $where = null, $parameters = array()) { } $sql = substr($sql, 0, -1); // strip off last comma - if($where) { + if ($where) { $sql .= ' WHERE ' . $where; $data = array_merge($data, $parameters); } $time_start = microtime(true); - if(dbQuery($sql, $data)) { + if (dbQuery($sql, $data)) { $return = mysql_affected_rows(); } else { #echo("$fullSql"); @@ -146,10 +146,10 @@ function dbUpdate($data, $table, $where = null, $parameters = array()) { function dbDelete($table, $where = null, $parameters = array()) { $sql = 'DELETE FROM `' . $table.'`'; - if($where) { + if ($where) { $sql .= ' WHERE ' . $where; } - if(dbQuery($sql, $parameters)) { + if (dbQuery($sql, $parameters)) { return mysql_affected_rows(); } else { return false; @@ -166,7 +166,7 @@ function dbFetchRows($sql, $parameters = array()) { $time_start = microtime(true); $result = dbQuery($sql, $parameters); - if(mysql_num_rows($result) > 0) { + if (mysql_num_rows($result) > 0) { $rows = array(); while ($row = mysql_fetch_assoc($result)) { $rows[] = $row; @@ -194,7 +194,7 @@ function dbFetch($sql, $parameters = array()) { /* // for now, don't do the iterator thing $result = dbQuery($sql, $parameters); - if($result) { + if ($result) { // return new iterator return new dbIterator($result); } else { @@ -212,7 +212,7 @@ function dbFetchRow($sql = null, $parameters = array()) { $time_start = microtime(true); $result = dbQuery($sql, $parameters); - if($result) { + if ($result) { $row = mysql_fetch_assoc($result); mysql_free_result($result); $time_end = microtime(true); @@ -236,7 +236,7 @@ function dbFetchCell($sql, $parameters = array()) { $time_start = microtime(true); $row = dbFetchRow($sql, $parameters); - if($row) { + if ($row) { return array_shift($row); // shift first field off first row } $time_end = microtime(true); @@ -276,7 +276,7 @@ function dbFetchKeyValue($sql, $parameters = array()) { $data = array(); foreach(dbFetch($sql, $parameters) as $row) { $key = array_shift($row); - if(sizeof($row) == 1) { // if there were only 2 fields in the result + if (sizeof($row) == 1) { // if there were only 2 fields in the result // use the second for the value $data[ $key ] = array_shift($row); } else { // if more than 2 fields were fetched @@ -301,7 +301,7 @@ function dbMakeQuery($sql, $parameters) { $questionParams = array(); $namedParams = array(); foreach($parameters as $key => $value) { - if(is_numeric($key)) { + if (is_numeric($key)) { $questionParams[] = $value; } else { $namedParams[ ':' . $key ] = $value; @@ -320,9 +320,9 @@ function dbMakeQuery($sql, $parameters) { $query .= $result[ $i ]; $j = $i+1; - if(array_key_exists($j, $result)) { + if (array_key_exists($j, $result)) { $test = $result[ $j ]; - if($test == '?') { + if ($test == '?') { $query .= array_shift($questionParams); } else { $query .= $namedParams[ $test ]; @@ -341,7 +341,7 @@ function dbPrepareData($data) { // don't quote or esc if value is an array, we treat it // as a "decorator" that tells us not to escape the // value contained in the array - if(is_array($value) && !is_object($value)) { + if (is_array($value) && !is_object($value)) { $escape = false; $value = array_shift($value); } @@ -349,7 +349,7 @@ function dbPrepareData($data) { // that are aliases, or part of other tables through joins //if(!in_array($key, $columns)) // skip invalid fields // continue; - if($escape) { + if ($escape) { $values[$key] = "'" . mysql_real_escape_string($value) . "'"; } else $values[$key] = $value; @@ -365,7 +365,7 @@ function dbPrepareData($data) { function dbPlaceHolders($values) { $data = array(); foreach($values as $key => $value) { - if(is_numeric($key)) + if (is_numeric($key)) $data[] = '?'; else $data[] = ':' . $key; @@ -410,7 +410,7 @@ class dbIterator implements Iterator { public function next() { $this->i++; $a = mysql_data_seek($this->result, $this->i); - if($a === false) { + if ($a === false) { $this->i = 0; } return $a; diff --git a/includes/discovery/entity-sensor.inc.php b/includes/discovery/entity-sensor.inc.php index 2068aa920..4faba5cca 100644 --- a/includes/discovery/entity-sensor.inc.php +++ b/includes/discovery/entity-sensor.inc.php @@ -71,7 +71,7 @@ if (is_array($oids)) if (is_numeric($entry['entPhySensorPrecision']) && $entry['entPhySensorPrecision'] > "0") { $divisor = $divisor . str_pad('', $entry['entPhySensorPrecision'], "0"); } $current = $current * $multiplier / $divisor; - if ($type == "temperature") { if ($current > "200"){ $thisisnotbullshit = FALSE; } $descr = preg_replace("/[T|t]emperature[|s]/", "", $descr); } + if ($type == "temperature") { if ($current > "200") { $thisisnotbullshit = FALSE; } $descr = preg_replace("/[T|t]emperature[|s]/", "", $descr); } #echo($descr . "|" . $index . "|" .$current . "|" . $multiplier . "|" . $divisor ."|" . $entry['entPhySensorScale'] . "|" . $entry['entPhySensorPrecision'] . "\n"); diff --git a/includes/functions.php b/includes/functions.php index a0ad8486b..bb233c659 100755 --- a/includes/functions.php +++ b/includes/functions.php @@ -134,14 +134,14 @@ function getImage($host) { $image = ''; } else { - if (file_exists($config['html_dir'] . "/images/os/$type" . ".png")){ $image = ''; - } elseif (file_exists($config['html_dir'] . "/images/os/$type" . ".gif")){ $image = ''; } + if (file_exists($config['html_dir'] . "/images/os/$type" . ".png")) { $image = ''; + } elseif (file_exists($config['html_dir'] . "/images/os/$type" . ".gif")) { $image = ''; } if ($type == "linux") { $features = strtolower(trim($data['features'])); list($distro) = explode(" ", $features); - if (file_exists($config['html_dir'] . "/images/os/$distro" . ".png")){ $image = ''; - } elseif (file_exists($config['html_dir'] . "/images/os/$distro" . ".gif")){ $image = ''; } + if (file_exists($config['html_dir'] . "/images/os/$distro" . ".png")) { $image = ''; + } elseif (file_exists($config['html_dir'] . "/images/os/$distro" . ".gif")) { $image = ''; } } } diff --git a/includes/polling/os/catos.inc.php b/includes/polling/os/catos.inc.php index ea05a5686..ef190303b 100755 --- a/includes/polling/os/catos.inc.php +++ b/includes/polling/os/catos.inc.php @@ -8,7 +8,7 @@ #Cisco Systems, Inc. WS-C4003 Cisco Catalyst Operating System Software, Version 6.4(13) Copyright (c) 1995-2004 by Cisco Systems, Inc. #Cisco Systems, Inc. WS-C4006 Cisco Catalyst Operating System Software, Version 6.3(9) Copyright (c) 1995-2002 by Cisco Systems, Inc. -if (strstr($ciscomodel, "OID")){ unset($ciscomodel); } +if (strstr($ciscomodel, "OID")) { unset($ciscomodel); } if (!strstr($ciscomodel, " ") && strlen($ciscomodel) >= '3') { diff --git a/includes/snmp.inc.php b/includes/snmp.inc.php index 7f4c9c58f..600b0fb21 100644 --- a/includes/snmp.inc.php +++ b/includes/snmp.inc.php @@ -640,7 +640,7 @@ function snmp_cache_port_oids($oids, $port, $device, $array, $mib=0) $x=0; $values = explode("\n", $data); #echo("Caching: ifIndex $port\n"); - foreach ($oids as $oid){ + foreach ($oids as $oid) { if (!strstr($values[$x], "at this OID")) { $array[$port][$oid] = $values[$x]; @@ -686,7 +686,7 @@ function snmp_cache_portIfIndex($device, $array) { $entry = str_replace("CISCO-STACK-MIB::portIfIndex.", "", $entry); list($slotport, $ifIndex) = explode(" ", $entry); - if ($slotport && $ifIndex){ + if ($slotport && $ifIndex) { $array[$ifIndex]['portIfIndex'] = $slotport; $array[$slotport]['ifIndex'] = $ifIndex; } diff --git a/includes/syslog.php b/includes/syslog.php index d129e4cf3..360453151 100755 --- a/includes/syslog.php +++ b/includes/syslog.php @@ -6,11 +6,11 @@ # $device_id_ip = @dbFetchCell("SELECT device_id FROM ipv4_addresses AS A, ports AS I WHERE A.ipv4_address = '" . $entry['host']."' AND I.interface_id = A.interface_id"); -function get_cache($host, $value){ +function get_cache($host, $value) { global $dev_cache; - if (!isset($dev_cache[$host][$value])){ - switch($value){ + if (!isset($dev_cache[$host][$value])) { + switch($value) { case 'device_id': //Try by hostname $dev_cache[$host]['device_id'] = dbFetchCell('SELECT `device_id` FROM devices WHERE `hostname` = ? OR `sysName` = ?', array($host, $host)); @@ -39,7 +39,7 @@ function process_syslog ($entry, $update) { global $dev_cache; foreach($config['syslog_filter'] as $bi) - if (strpos($entry['msg'], $bi) !== FALSE){ + if (strpos($entry['msg'], $bi) !== FALSE) { print_r($entry); echo('D-'.$bi); return $entry; @@ -49,9 +49,9 @@ function process_syslog ($entry, $update) { if ($entry['device_id']) { $os = get_cache($entry['host'], 'os'); - if (in_array($os, array('ios', 'iosxe', 'catos'))){ + if (in_array($os, array('ios', 'iosxe', 'catos'))) { $matches = array(); -# if (preg_match('#%(?P.*):( ?)(?P.*)#', $entry['msg'], $matches)){ +# if (preg_match('#%(?P.*):( ?)(?P.*)#', $entry['msg'], $matches)) { # $entry['msg'] = $matches['msg']; # $entry['program'] = $matches['program']; # } @@ -86,29 +86,29 @@ function process_syslog ($entry, $update) { if (!$entry['msg']) { $entry['msg'] = $entry['program']; unset ($entry['program']); } - } elseif($os == 'linux' and get_cache($entry['host'], 'version') == 'Point'){ + } elseif($os == 'linux' and get_cache($entry['host'], 'version') == 'Point') { //Cisco WAP200 and similar $matches = array(); - if (preg_match('#Log: \[(?P.*)\] - (?P.*)#', $entry['msg'], $matches)){ + if (preg_match('#Log: \[(?P.*)\] - (?P.*)#', $entry['msg'], $matches)) { $entry['msg'] = $matches['msg']; $entry['program'] = $matches['program']; } unset($matches); - } elseif($os == 'linux'){ + } elseif($os == 'linux') { $matches = array(); //User_CommonName/123.213.132.231:39872 VERIFY OK: depth=1, /C=PL/ST=Malopolska/O=VLO/CN=v-lo.krakow.pl/emailAddress=root@v-lo.krakow.pl - if ($entry['facility'] == 'daemon' and preg_match('#/([0-9]{1,3}\.){3}[0-9]{1,3}:[0-9]{4,} ([A-Z]([A-Za-z])+( ?)){2,}:#', $entry['msg'])){ + if ($entry['facility'] == 'daemon' and preg_match('#/([0-9]{1,3}\.) {3}[0-9]{1,3}:[0-9]{4,} ([A-Z]([A-Za-z])+( ?)) {2,}:#', $entry['msg'])) { $entry['program'] = 'OpenVPN'; } //pop3-login: Login: user=, method=PLAIN, rip=123.213.132.231, lip=123.213.132.231, TLS //POP3(username): Disconnected: Logged out top=0/0, retr=0/0, del=0/1, size=2802 - elseif($entry['facility'] == 'mail' and preg_match('#^(((pop3|imap)\-login)|((POP3|IMAP)\(.*\))):', $entry['msg'])){ + elseif($entry['facility'] == 'mail' and preg_match('#^(((pop3|imap)\-login)|((POP3|IMAP)\(.*\))):', $entry['msg'])) { $entry['program'] = 'Dovecot'; } //pam_krb5(sshd:auth): authentication failure; logname=root uid=0 euid=0 tty=ssh ruser= rhost=123.213.132.231 //pam_krb5[sshd:auth]: authentication failure; logname=root uid=0 euid=0 tty=ssh ruser= rhost=123.213.132.231 - elseif(preg_match('#^(?P(.*((\(|\[).*(\)|\])))):(?P.*)$#', $entry['msg'], $matches)){ + elseif(preg_match('#^(?P(.*((\(|\[).*(\)|\])))):(?P.*)$#', $entry['msg'], $matches)) { $entry['msg'] = $matches['msg']; $entry['program'] = $matches['program']; } @@ -117,18 +117,18 @@ function process_syslog ($entry, $update) { //pam_krb5: authentication failure; logname=root uid=0 euid=0 tty=ssh ruser= rhost=123.213.132.231 ## Disabled because broke this: //diskio.c: don't know how to handle 10 request - #elseif($pos = strpos($entry['msg'], ';') or $pos = strpos($entry['msg'], ':')){ + #elseif($pos = strpos($entry['msg'], ';') or $pos = strpos($entry['msg'], ':')) { # $entry['program'] = substr($entry['msg'], 0, $pos); # $entry['msg'] = substr($entry['msg'], $pos+1); #} //fallback, better than nothing... - elseif(empty($entry['program']) and !empty($entry['facility'])){ + elseif(empty($entry['program']) and !empty($entry['facility'])) { $entry['program'] = $entry['facility']; } unset($matches); } - if (!isset($entry['program'])){ + if (!isset($entry['program'])) { $entry['program'] = $entry['msg']; unset($entry['msg']); }