diff options
author | Simon Rettberg | 2017-12-16 18:33:16 +0100 |
---|---|---|
committer | Simon Rettberg | 2017-12-16 18:33:16 +0100 |
commit | cd55ead3e2810e209b726faca12fa749f6875d0f (patch) | |
tree | 94b2f29b023e8a0c5100e1d06c974c3c04f890fd /modules-available/statistics | |
parent | Merge branch 'permission-manager' of openslx.org:openslx-ng/slx-admin into pe... (diff) | |
download | slx-admin-cd55ead3e2810e209b726faca12fa749f6875d0f.tar.gz slx-admin-cd55ead3e2810e209b726faca12fa749f6875d0f.tar.xz slx-admin-cd55ead3e2810e209b726faca12fa749f6875d0f.zip |
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.
Diffstat (limited to 'modules-available/statistics')
-rw-r--r-- | modules-available/statistics/inc/parser.inc.php | 3 | ||||
-rw-r--r-- | modules-available/statistics/page.inc.php | 7 | ||||
-rw-r--r-- | modules-available/statistics/templates/filterbox.html | 7 |
3 files changed, 8 insertions, 9 deletions
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'] .= '<div style="background:#444;left:0%;width:' . round((min($row['dateline'], $client['lastboot']) - $cutoff) * $scale, 2) . '%"> </div>'; + $spans['graph'] .= '<div style="background:#444;left:0;width:' . round((min($row['dateline'], $client['lastboot']) - $cutoff) * $scale, 2) . '%"> </div>'; } $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'] .= '<div style="background:#444;left:0%;width:' . round(($client['lastboot'] - $cutoff) * $scale, 2) . '%"> </div>'; + $spans['graph'] .= '<div style="background:#444;left:0;width:' . round(($client['lastboot'] - $cutoff) * $scale, 2) . '%"> </div>'; } elseif ($first) { // Not seen in last two weeks - $spans['graph'] .= '<div style="background:#444;left:0%;width:100%"> </div>'; + $spans['graph'] .= '<div style="background:#444;left:0;width:100%"> </div>'; } if (isset($client['state_occupied'])) { $spans['graph'] .= '<div style="background:#e99;left:' . round(($client['logintime'] - $cutoff) * $scale, 2) . '%;width:' . round(($NOW - $client['logintime'] + 900) * $scale, 2) . '%"> </div>'; 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;} } |