From cd55ead3e2810e209b726faca12fa749f6875d0f Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Sat, 16 Dec 2017 18:33:16 +0100 Subject: Fix A LOT of type problems, logic flaws, uninitialized variables etc. Most of them were found by phpstorm, so I put in some time and went through the list, fixing quite a bunch of them. --- modules-available/statistics/inc/parser.inc.php | 3 +-- modules-available/statistics/page.inc.php | 7 +++---- modules-available/statistics/templates/filterbox.html | 7 ++++--- 3 files changed, 8 insertions(+), 9 deletions(-) (limited to 'modules-available/statistics') diff --git a/modules-available/statistics/inc/parser.inc.php b/modules-available/statistics/inc/parser.inc.php index acf6ebd4..679055a7 100644 --- a/modules-available/statistics/inc/parser.inc.php +++ b/modules-available/statistics/inc/parser.inc.php @@ -99,8 +99,8 @@ class Parser { $hdds = array(); // Could have more than one disk - linear scan $lines = preg_split("/[\r\n]+/", $data); - $dev = false; $i = 0; + $mbrToMbFactor = $sectorToMbFactor = 0; foreach ($lines as $line) { if (preg_match('/^Disk (\S+):.* (\d+) bytes/i', $line, $out)) { // --- Beginning of MBR disk --- @@ -260,7 +260,6 @@ class Parser { public static function parseSmartctl(&$hdds, $data) { $lines = preg_split("/[\r\n]+/", $data); - $i = 0; foreach ($lines as $line) { if (preg_match('/^NEXTHDD=(.+)$/', $line, $out)) { unset($dev); diff --git a/modules-available/statistics/page.inc.php b/modules-available/statistics/page.inc.php index c3ecf52b..bd67123e 100644 --- a/modules-available/statistics/page.inc.php +++ b/modules-available/statistics/page.inc.php @@ -622,7 +622,6 @@ class Page_Statistics extends Page . ' badsectors ' . $xtra . ' FROM machine' . " $join WHERE $where $sort", $args); $rows = array(); - $NOW = time(); $singleMachine = 'none'; while ($row = $res->fetch(PDO::FETCH_ASSOC)) { if ($singleMachine === 'none') { @@ -894,7 +893,7 @@ class Page_Statistics extends Page continue; // Don't differentiate between session and idle for non-clients if ($first && $row['dateline'] > $cutoff && $client['lastboot'] > $cutoff) { // Special case: offline before - $spans['graph'] .= '
 
'; + $spans['graph'] .= '
 
'; } $first = false; if ($row['dateline'] + $row['data'] < $cutoff || $row['data'] > 864000) { @@ -931,10 +930,10 @@ class Page_Statistics extends Page } if ($first && $client['lastboot'] > $cutoff) { // Special case: offline before - $spans['graph'] .= '
 
'; + $spans['graph'] .= '
 
'; } elseif ($first) { // Not seen in last two weeks - $spans['graph'] .= '
 
'; + $spans['graph'] .= '
 
'; } if (isset($client['state_occupied'])) { $spans['graph'] .= '
 
'; diff --git a/modules-available/statistics/templates/filterbox.html b/modules-available/statistics/templates/filterbox.html index 31daabc6..32464031 100644 --- a/modules-available/statistics/templates/filterbox.html +++ b/modules-available/statistics/templates/filterbox.html @@ -105,6 +105,7 @@ var slxFilterNames = { slxLocations = {{{locations}}}; var slxFilterDel = '{{delimiter}}'; +var $modal, $queryForm; document.addEventListener("DOMContentLoaded", function () { @@ -217,7 +218,7 @@ function popupFilter(field) { function addFilterFromForm() { var argument1 = $('#argumentInput').val(); var argument2 = $('#argumentSelect').val(); - var argument = argument1 == '' ? argument2 : argument1; + var argument = argument1 ? argument1 : argument2; var col = $('#columnSelect').val(); var op = $('#operatorSelect').val(); @@ -246,8 +247,8 @@ function toggleSort(field) { /* equal sign should always be first, the rest doesn't matter*/ function myOpSort(a,b) { - if (a == '=') { return -1; } - else if (a == b) {return 0} + if (a === '=') { return -1; } + else if (a === b) {return 0} else { return 1;} } -- cgit v1.2.3-55-g7522