mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Apply fixes from StyleCI (#12117)
* Apply fixes from StyleCI * Disable style check
This commit is contained in:
@@ -8,18 +8,17 @@
|
||||
* @package librenms
|
||||
* @subpackage map
|
||||
* @copyright (C) 2006 - 2012 Adam Armstrong
|
||||
*
|
||||
*/
|
||||
|
||||
use LibreNMS\Config;
|
||||
|
||||
$links = 1;
|
||||
|
||||
$init_modules = array('web', 'auth');
|
||||
$init_modules = ['web', 'auth'];
|
||||
require realpath(__DIR__ . '/..') . '/includes/init.php';
|
||||
|
||||
if (!Auth::check()) {
|
||||
die('Unauthorized');
|
||||
if (! Auth::check()) {
|
||||
exit('Unauthorized');
|
||||
}
|
||||
|
||||
$options = getopt('d::');
|
||||
@@ -52,19 +51,19 @@ if (isset($_GET['format']) && preg_match("/^[a-z]*$/", $_GET['format'])) {
|
||||
graph [bgcolor=transparent];
|
||||
';
|
||||
|
||||
if (!Auth::check()) {
|
||||
if (! Auth::check()) {
|
||||
$map .= "\"Not authenticated\" [fontsize=20 fillcolor=\"lightblue\", URL=\"/\" shape=box3d]\n";
|
||||
} else {
|
||||
$locations = getlocations();
|
||||
$loc_count = 1;
|
||||
foreach (dbFetch("SELECT *, locations.location FROM devices LEFT JOIN locations ON devices.location_id = locations.id WHERE 1 ".$where, $param) as $device) {
|
||||
foreach (dbFetch("SELECT *, locations.location FROM devices LEFT JOIN locations ON devices.location_id = locations.id WHERE 1 " . $where, $param) as $device) {
|
||||
if ($device) {
|
||||
$links = dbFetch("SELECT * from ports AS I, links AS L WHERE I.device_id = ? AND L.local_port_id = I.port_id ORDER BY L.remote_hostname", array($device['device_id']));
|
||||
$links = dbFetch("SELECT * from ports AS I, links AS L WHERE I.device_id = ? AND L.local_port_id = I.port_id ORDER BY L.remote_hostname", [$device['device_id']]);
|
||||
if (count($links)) {
|
||||
if ($anon) {
|
||||
$device['hostname'] = md5($device['hostname']);
|
||||
}
|
||||
if (!isset($locations[$device['location']])) {
|
||||
if (! isset($locations[$device['location']])) {
|
||||
$locations[$device['location']] = $loc_count;
|
||||
$loc_count++;
|
||||
}
|
||||
@@ -83,7 +82,7 @@ if (isset($_GET['format']) && preg_match("/^[a-z]*$/", $_GET['format'])) {
|
||||
$done = 1;
|
||||
}
|
||||
|
||||
if (!$done) {
|
||||
if (! $done) {
|
||||
$linkdone[$local_port_id][$remote_port_id] = true;
|
||||
|
||||
$links++;
|
||||
@@ -105,8 +104,8 @@ if (isset($_GET['format']) && preg_match("/^[a-z]*$/", $_GET['format'])) {
|
||||
$src = md5($src);
|
||||
}
|
||||
if ($remote_port_id) {
|
||||
$dst = dbFetchCell("SELECT `hostname` FROM `devices` AS D, `ports` AS I WHERE I.port_id = ? AND D.device_id = I.device_id", array($remote_port_id));
|
||||
$dst_host = dbFetchCell("SELECT D.device_id FROM `devices` AS D, `ports` AS I WHERE I.port_id = ? AND D.device_id = I.device_id", array($remote_port_id));
|
||||
$dst = dbFetchCell("SELECT `hostname` FROM `devices` AS D, `ports` AS I WHERE I.port_id = ? AND D.device_id = I.device_id", [$remote_port_id]);
|
||||
$dst_host = dbFetchCell("SELECT D.device_id FROM `devices` AS D, `ports` AS I WHERE I.port_id = ? AND D.device_id = I.device_id", [$remote_port_id]);
|
||||
} else {
|
||||
unset($dst_host);
|
||||
$dst = $link['remote_hostname'];
|
||||
@@ -117,22 +116,22 @@ if (isset($_GET['format']) && preg_match("/^[a-z]*$/", $_GET['format'])) {
|
||||
$src = md5($src);
|
||||
}
|
||||
|
||||
$sif = cleanPort(dbFetchRow("SELECT * FROM ports WHERE `port_id` = ?", array($link['local_port_id'])), $device);
|
||||
$sif = cleanPort(dbFetchRow("SELECT * FROM ports WHERE `port_id` = ?", [$link['local_port_id']]), $device);
|
||||
if ($remote_port_id) {
|
||||
$dif = cleanPort(dbFetchRow("SELECT * FROM ports WHERE `port_id` = ?", array($link['remote_port_id'])));
|
||||
$dif = cleanPort(dbFetchRow("SELECT * FROM ports WHERE `port_id` = ?", [$link['remote_port_id']]));
|
||||
} else {
|
||||
$dif['label'] = $link['remote_port'];
|
||||
$dif['port_id'] = $link['remote_hostname'] . '/' . $link['remote_port'];
|
||||
}
|
||||
|
||||
if ($where == "") {
|
||||
if (!$ifdone[$dst][$dif['port_id']] && !$ifdone[$src][$sif['port_id']]) {
|
||||
if (! $ifdone[$dst][$dif['port_id']] && ! $ifdone[$src][$sif['port_id']]) {
|
||||
$map .= "\"$src\" -> \"" . $dst . "\" [weight=500000, arrowsize=0, len=0];\n";
|
||||
}
|
||||
$ifdone[$src][$sif['port_id']] = 1;
|
||||
} else {
|
||||
$map .= "\"" . $sif['port_id'] . "\" [label=\"" . $sif['label'] . "\", fontsize=12, fillcolor=lightblue, URL=\"" . Config::get('base_url') . "/device/device=" . $device['device_id'] . "/tab=port/port=$local_port_id/\"]\n";
|
||||
if (!$ifdone[$src][$sif['port_id']]) {
|
||||
if (! $ifdone[$src][$sif['port_id']]) {
|
||||
$map .= "\"$src\" -> \"" . $sif['port_id'] . "\" [weight=500000, arrowsize=0, len=0];\n";
|
||||
$ifdone[$src][$sif['port_id']] = 1;
|
||||
}
|
||||
@@ -153,7 +152,7 @@ if (isset($_GET['format']) && preg_match("/^[a-z]*$/", $_GET['format'])) {
|
||||
$map .= "]\n";
|
||||
}
|
||||
|
||||
if (!$ifdone[$dst][$dif['port_id']]) {
|
||||
if (! $ifdone[$dst][$dif['port_id']]) {
|
||||
$map .= "\"" . $dif['port_id'] . "\" -> \"$dst\" [weight=500000, arrowsize=0, len=0];\n";
|
||||
$ifdone[$dst][$dif['port_id']] = 1;
|
||||
}
|
||||
@@ -180,7 +179,7 @@ if (isset($_GET['format']) && preg_match("/^[a-z]*$/", $_GET['format'])) {
|
||||
$_GET['format'] = 'png:gd';
|
||||
break;
|
||||
case 'dot':
|
||||
echo($map);
|
||||
echo $map;
|
||||
exit();
|
||||
default:
|
||||
$_GET['format'] = 'png:gd';
|
||||
@@ -198,11 +197,11 @@ if (isset($_GET['format']) && preg_match("/^[a-z]*$/", $_GET['format'])) {
|
||||
$maptool = Config::get('dot');
|
||||
}
|
||||
|
||||
$descriptorspec = array(0 => array("pipe", "r"),1 => array("pipe", "w") );
|
||||
$descriptorspec = [0 => ["pipe", "r"], 1 => ["pipe", "w"]];
|
||||
|
||||
$mapfile = Config::get('temp_dir') . "/" . strgen() . ".png";
|
||||
|
||||
$process = proc_open($maptool.' -T'.$_GET['format'], $descriptorspec, $pipes);
|
||||
$process = proc_open($maptool . ' -T' . $_GET['format'], $descriptorspec, $pipes);
|
||||
|
||||
if (is_resource($process)) {
|
||||
fwrite($pipes[0], "$map");
|
||||
|
Reference in New Issue
Block a user