diff --git a/html/includes/graphs/device/mib.inc.php b/html/includes/graphs/device/mib.inc.php
index 49f2b9a3e..7f76f3bbe 100644
--- a/html/includes/graphs/device/mib.inc.php
+++ b/html/includes/graphs/device/mib.inc.php
@@ -20,7 +20,8 @@ foreach (glob($prefix."*.rrd") as $filename) {
$instance = substr($globpart, 0, -4); // take off ".rrd"
$ds = array();
- $mibvar = end(explode("-", $subtype));
+ $mibparts = explode("-", $subtype);
+ $mibvar = end($mibparts);
$ds['ds'] = name_shorten($mibvar);
$ds['descr'] = "$mibvar-$instance";
$ds['filename'] = $filename;
@@ -33,5 +34,3 @@ $nototal = 0;
$simple_rrd = true;
include("includes/graphs/generic_multi_line.inc.php");
-
-?>
diff --git a/html/includes/graphs/graph.inc.php b/html/includes/graphs/graph.inc.php
index d0b001500..5c6bfe1c1 100644
--- a/html/includes/graphs/graph.inc.php
+++ b/html/includes/graphs/graph.inc.php
@@ -41,10 +41,10 @@ $subtype = $graphtype['subtype'];
$auth = is_client_authorized($_SERVER['REMOTE_ADDR']);
include($config['install_dir'] . "/html/includes/graphs/$type/auth.inc.php");
-if ($auth && is_file($config['install_dir'] . "/html/includes/graphs/$type/$subtype.inc.php")) {
+if ($auth === true && is_file($config['install_dir'] . "/html/includes/graphs/$type/$subtype.inc.php")) {
include($config['install_dir'] . "/html/includes/graphs/$type/$subtype.inc.php");
}
-elseif ($auth && is_mib_graph($type, $subtype)) {
+elseif ($auth === true && is_mib_graph($type, $subtype)) {
include($config['install_dir'] . "/html/includes/graphs/$type/mib.inc.php");
}
else {
diff --git a/includes/common.php b/includes/common.php
index 3fbdd53f5..8e7499841 100644
--- a/includes/common.php
+++ b/includes/common.php
@@ -652,11 +652,14 @@ function d_print_r($var, $no_debug_text = null)
* Substitute for $subst if necessary.
* @return the shortened name
*/
-function name_shorten($name, $common, $subst = "mibval", $len = 19)
+function name_shorten($name, $common = null, $subst = "mibval", $len = 19)
{
- if (strlen($name) > $len && strpos($name, $common) >= 0) {
- $newname = str_replace($common, '', $name);
- $name = $newname;
+ if ($common !== null) {
+ // remove common from the beginning of the string, if present
+ if (strlen($name) > $len && strpos($name, $common) >= 0) {
+ $newname = str_replace($common, '', $name);
+ $name = $newname;
+ }
}
if (strlen($name) > $len) {
$name = $subst;
@@ -690,8 +693,8 @@ function is_mib_graph($type, $subtype)
*/
function is_client_authorized($clientip)
{
-
global $config;
+
if (isset($config['allow_unauth_graphs']) && $config['allow_unauth_graphs']) {
d_echo("Unauthorized graphs allowed\n");
return true;
diff --git a/includes/polling/mib.inc.php b/includes/polling/mib.inc.php
index 16c1430b1..07d6c16fc 100644
--- a/includes/polling/mib.inc.php
+++ b/includes/polling/mib.inc.php
@@ -14,5 +14,3 @@
$devicemib = array($device['sysObjectID'] => "all");
poll_mibs($devicemib, $device, $graphs);
-
-?>
diff --git a/includes/snmp.inc.php b/includes/snmp.inc.php
index a2526203f..91574c8e2 100644
--- a/includes/snmp.inc.php
+++ b/includes/snmp.inc.php
@@ -946,7 +946,7 @@ function snmp_translate($oid, $module, $mibdir = null)
$cmd .= " 2>/dev/null"; // ignore invalid MIBs
$lines = preg_split('/\n+/', external_exec($cmd));
- if (!$lines) {
+ if (empty($lines)) {
d_echo("No results from snmptranslate\n");
return null;
}
@@ -1051,7 +1051,7 @@ function save_mibs($device, $mibname, $oids, $mibdef, &$graphs)
foreach ($oids as $index => $array) {
foreach ($array as $oid => $val) {
$type = oid_rrd_type($oid, $mibdef);
- if (!$type) {
+ if ($type === false) {
continue;
}
$usedoids[$index][$oid] = $val;