From d6db01abb5478f5c400991a6c4fa8263c9370de4 Mon Sep 17 00:00:00 2001 From: Tony Murray Date: Wed, 29 Nov 2017 02:23:19 -0600 Subject: [PATCH] refactor: Refactor fix php codesniffer 3.x issues (#7816) We cannot use 3.x because it requires php 5.4, so update to 2.9.1 or newer 2.x release. --- LibreNMS/Component.php | 4 +- LibreNMS/Config.php | 2 +- composer.json | 2 +- html/ajax_rulesuggest.php | 2 +- html/includes/forms/create-alert-item.inc.php | 2 +- html/includes/forms/test-transport.inc.php | 2 +- html/includes/modal/new_bill.inc.php | 12 +- html/install.php | 14 +- html/pages/bill.inc.php | 132 +++++++++--------- html/pages/bill/addoreditbill.inc.php | 20 ++- html/pages/bill/edit.inc.php | 2 +- html/pages/bills.inc.php | 50 ++++--- html/pages/device/edit/device.inc.php | 36 +++-- html/pages/ports.inc.php | 75 ++++++---- includes/alerts.inc.php | 2 +- .../discovery/processors/hrdevice.inc.php | 2 +- .../polling/applications/freeswitch.inc.php | 2 +- includes/polling/applications/unbound.inc.php | 2 +- includes/polling/cisco-asa-firewall.inc.php | 2 +- includes/polling/mef.inc.php | 2 +- includes/polling/mib/ceraos-mib.inc.php | 2 +- includes/polling/os/calix.inc.php | 5 - .../polling/wireless/cambium-generic.inc.php | 28 ++-- 23 files changed, 231 insertions(+), 171 deletions(-) diff --git a/LibreNMS/Component.php b/LibreNMS/Component.php index 8ed8dbc425..f90710cfe9 100644 --- a/LibreNMS/Component.php +++ b/LibreNMS/Component.php @@ -302,7 +302,7 @@ class Component } // Ignore type, we cant change that. - unset($AVP['type'],$OLD[$device_id][$COMPONENT]['type']); + unset($AVP['type'], $OLD[$device_id][$COMPONENT]['type']); // If the Status has changed we need to add a log entry if ($AVP['status'] != $OLD[$device_id][$COMPONENT]['status']) { @@ -322,7 +322,7 @@ class Component } // Unset the reserved field. We don't want to insert it below. - unset($AVP[$k],$OLD[$device_id][$COMPONENT][$k]); + unset($AVP[$k], $OLD[$device_id][$COMPONENT][$k]); } } diff --git a/LibreNMS/Config.php b/LibreNMS/Config.php index d48608464a..cf4e0a5836 100644 --- a/LibreNMS/Config.php +++ b/LibreNMS/Config.php @@ -163,7 +163,7 @@ class Config * @param string $group webui group (only set when initially created) * @param string $sub_group webui subgroup (only set when initially created) */ - public static function set($key, $value, $persist = false, $default ='', $descr='', $group='', $sub_group='') + public static function set($key, $value, $persist = false, $default = '', $descr = '', $group = '', $sub_group = '') { global $config; diff --git a/composer.json b/composer.json index 35154264ab..43df1d098d 100644 --- a/composer.json +++ b/composer.json @@ -34,7 +34,7 @@ "palanik/corsslim": "^1.1" }, "require-dev": { - "squizlabs/php_codesniffer": "2.6.*", + "squizlabs/php_codesniffer": "^2.9.1", "phpunit/phpunit": "4.*", "jakub-onderka/php-parallel-lint": "*", "jakub-onderka/php-console-highlighter": "*", diff --git a/html/ajax_rulesuggest.php b/html/ajax_rulesuggest.php index 4481bca8d3..094d957d52 100644 --- a/html/ajax_rulesuggest.php +++ b/html/ajax_rulesuggest.php @@ -63,7 +63,7 @@ header('Content-type: application/json'); $obj = array(array('name' => 'Error: No suggestions found.')); $term = array(); $current = false; -if (isset($_GET['term'],$_GET['device_id'])) { +if (isset($_GET['term'], $_GET['device_id'])) { $chk = array(); $_GET['term'] = mres($_GET['term']); $_GET['device_id'] = mres($_GET['device_id']); diff --git a/html/includes/forms/create-alert-item.inc.php b/html/includes/forms/create-alert-item.inc.php index 40ded90fa6..b45524ddb4 100644 --- a/html/includes/forms/create-alert-item.inc.php +++ b/html/includes/forms/create-alert-item.inc.php @@ -80,7 +80,7 @@ if (empty($rule)) { $_POST['target'] = $target; $_POST['map_id'] = ''; include 'create-map-item.inc.php'; - unset($ret,$target,$raw,$rule,$msg,$map_id); + unset($ret, $target, $raw, $rule, $msg, $map_id); } } } else { diff --git a/html/includes/forms/test-transport.inc.php b/html/includes/forms/test-transport.inc.php index 77a978b4d3..3207000cf4 100644 --- a/html/includes/forms/test-transport.inc.php +++ b/html/includes/forms/test-transport.inc.php @@ -50,7 +50,7 @@ if (file_exists($config['install_dir']."/includes/alerts/transport.".$transport. $opts = $config['alert']['transports'][$transport]; if ($opts) { eval('$tmp = function($obj,$opts) { global $config; '.file_get_contents($config['install_dir'].'/includes/alerts/transport.'.$transport.'.php').' return false; };'); - $tmp = $tmp($obj,$opts); + $tmp = $tmp($obj, $opts); if ($tmp) { $status = 'ok'; } diff --git a/html/includes/modal/new_bill.inc.php b/html/includes/modal/new_bill.inc.php index 3a02e45c6a..54156cf6ee 100644 --- a/html/includes/modal/new_bill.inc.php +++ b/html/includes/modal/new_bill.inc.php @@ -12,7 +12,7 @@ */ if (is_admin() !== false) { require 'includes/javascript-interfacepicker.inc.php'; - + $port_device_id = -1; if (is_numeric($vars['port'])) { $port = dbFetchRow('SELECT * FROM `ports` AS P, `devices` AS D WHERE `port_id` = ? AND D.device_id = P.device_id', array($vars['port'])); @@ -53,7 +53,8 @@ if (is_admin() !== false) {
- - + + ";
- + } + ?>>Next Stage
@@ -498,9 +501,12 @@ if (Auth::get()->canManageUsers()) { - + } + ?>>Generate Config
diff --git a/html/pages/bill.inc.php b/html/pages/bill.inc.php index 70c1b264e9..2995ba5940 100644 --- a/html/pages/bill.inc.php +++ b/html/pages/bill.inc.php @@ -99,41 +99,41 @@ if (bill_permitted($bill_id)) { 'transfer' => 'Transfer Graphs', 'history' => 'Historical Graphs' ); - if ($_SESSION['userlevel'] >= '10') { - $menu_options['edit'] = 'Edit'; - $menu_options['delete'] = 'Delete'; - $menu_options['reset'] = 'Reset'; - } +if ($_SESSION['userlevel'] >= '10') { + $menu_options['edit'] = 'Edit'; + $menu_options['delete'] = 'Delete'; + $menu_options['reset'] = 'Reset'; +} $sep = ''; - foreach ($menu_options as $option => $text) { - echo $sep; - if ($vars['view'] == $option) { - echo ""; - } - - echo generate_link($text, $vars, array('view' => $option)); - if ($vars['view'] == $option) { - echo ''; - } - - $sep = ' | '; +foreach ($menu_options as $option => $text) { + echo $sep; + if ($vars['view'] == $option) { + echo ""; } + + echo generate_link($text, $vars, array('view' => $option)); + if ($vars['view'] == $option) { + echo ''; + } + + $sep = ' | '; +} echo '
Back to Bills
'; print_optionbar_end(); - if ($vars['view'] == 'edit' && $_SESSION['userlevel'] >= '10') { - include 'pages/bill/edit.inc.php'; - } elseif ($vars['view'] == 'delete' && $_SESSION['userlevel'] >= '10') { - include 'pages/bill/delete.inc.php'; - } elseif ($vars['view'] == 'reset' && $_SESSION['userlevel'] >= '10') { - include 'pages/bill/reset.inc.php'; - } elseif ($vars['view'] == 'history') { - include 'pages/bill/history.inc.php'; - } elseif ($vars['view'] == 'transfer') { - include 'pages/bill/transfer.inc.php'; - } elseif ($vars['view'] == 'quick' || $vars['view'] == 'accurate') { +if ($vars['view'] == 'edit' && $_SESSION['userlevel'] >= '10') { + include 'pages/bill/edit.inc.php'; +} elseif ($vars['view'] == 'delete' && $_SESSION['userlevel'] >= '10') { + include 'pages/bill/delete.inc.php'; +} elseif ($vars['view'] == 'reset' && $_SESSION['userlevel'] >= '10') { + include 'pages/bill/reset.inc.php'; +} elseif ($vars['view'] == 'history') { + include 'pages/bill/history.inc.php'; +} elseif ($vars['view'] == 'transfer') { + include 'pages/bill/transfer.inc.php'; +} elseif ($vars['view'] == 'quick' || $vars['view'] == 'accurate') { ?> @@ -147,18 +147,18 @@ if (bill_permitted($bill_id)) {

-
- +
+ +
+
+
+
+

+ Bill Summary +

-
-
-
-

- Bill Summary -

-
- - +
+ - -
-
-
-
+ + +
+
+
-
-
-

Billing View

-
- -
+
+
+

Billing View

+
+ +
-
-
-

24 Hour View

-
- -
+
+
+

24 Hour View

+
+ +
-
-
-

Monthly View

-
- -
+
+
+

Monthly View

+
+ +
Billing Type
@@ -86,7 +92,7 @@ - +