diff options
Diffstat (limited to 'modules-available/statistics')
11 files changed, 20 insertions, 20 deletions
diff --git a/modules-available/statistics/baseconfig/getconfig.inc.php b/modules-available/statistics/baseconfig/getconfig.inc.php index e8afeffb..7bf25d5d 100644 --- a/modules-available/statistics/baseconfig/getconfig.inc.php +++ b/modules-available/statistics/baseconfig/getconfig.inc.php @@ -13,7 +13,7 @@ if (!$uuid) // Required at this point, bail out if not given // Query machine specific settings $res = Database::simpleQuery("SELECT setting, value FROM setting_machine WHERE machineuuid = :uuid", ['uuid' => $uuid]); -while ($row = $res->fetch(PDO::FETCH_ASSOC)) { +foreach ($res as $row) { ConfigHolder::add($row['setting'], $row['value'], 500); } diff --git a/modules-available/statistics/hooks/config-tgz.inc.php b/modules-available/statistics/hooks/config-tgz.inc.php index 8dffbff6..0a43e115 100644 --- a/modules-available/statistics/hooks/config-tgz.inc.php +++ b/modules-available/statistics/hooks/config-tgz.inc.php @@ -9,7 +9,7 @@ $res = Database::simpleQuery('SELECT h.hwname FROM statistic_hw h' if ($res !== false) { // CHeck this in case we're running on old DB during update $content = ''; - while ($row = $res->fetch(PDO::FETCH_ASSOC)) { + foreach ($res as $row) { $content .= $row['hwname'] . "=beamer\n"; } diff --git a/modules-available/statistics/hooks/cron.inc.php b/modules-available/statistics/hooks/cron.inc.php index 0de233a8..aecc4e3b 100644 --- a/modules-available/statistics/hooks/cron.inc.php +++ b/modules-available/statistics/hooks/cron.inc.php @@ -26,7 +26,7 @@ function state_cleanup() // Query for logging $res = Database::simpleQuery("SELECT machineuuid, clientip, state, logintime, lastseen, live_memfree, live_swapfree, live_tmpfree FROM machine WHERE lastseen < If(state = 'STANDBY', $standby, $on) AND state <> 'OFFLINE'"); - while ($row = $res->fetch(PDO::FETCH_ASSOC)) { + foreach ($res as $row) { Database::exec('INSERT INTO clientlog (dateline, logtypeid, clientip, machineuuid, description, extra) VALUES (UNIX_TIMESTAMP(), :type, :client, :uuid, :description, :longdesc)', array( 'type' => 'machine-mismatch-cron', diff --git a/modules-available/statistics/inc/statistics.inc.php b/modules-available/statistics/inc/statistics.inc.php index 1f8a081a..e3eaccc0 100644 --- a/modules-available/statistics/inc/statistics.inc.php +++ b/modules-available/statistics/inc/statistics.inc.php @@ -60,7 +60,7 @@ class Statistics } $res = Database::simpleQuery("SELECT $fields FROM machine WHERE clientip = :ip $sort", compact('ip')); $list = array(); - while ($row = $res->fetch(PDO::FETCH_ASSOC)) { + foreach ($res as $row) { $m = new Machine(); foreach ($row as $key => $val) { $m->{$key} = $val; diff --git a/modules-available/statistics/install.inc.php b/modules-available/statistics/install.inc.php index 3becce8f..15d0d633 100644 --- a/modules-available/statistics/install.inc.php +++ b/modules-available/statistics/install.inc.php @@ -248,7 +248,7 @@ if (!tableHasColumn('machine', 'live_tmpsize')) { // 2019-02-20: Convert bogus UUIDs $res2 = Database::simpleQuery("SELECT machineuuid, macaddr FROM machine WHERE machineuuid LIKE '00000000000000_-%'"); -while ($row = $res2->fetch(PDO::FETCH_ASSOC)) { +foreach ($res2 as $row) { $new = strtoupper('baad1d00-9491-4716-b98b-' . preg_replace('/[^0-9a-f]/i', '', $row['macaddr'])); error_log('Replacing ' . $row['machineuuid'] . ' with ' . $new); if (strlen($new) === 36) { diff --git a/modules-available/statistics/page.inc.php b/modules-available/statistics/page.inc.php index 20ff929a..6224d69c 100644 --- a/modules-available/statistics/page.inc.php +++ b/modules-available/statistics/page.inc.php @@ -171,7 +171,7 @@ class Page_Statistics extends Page $ids = array_flip($ids); $allowedMachines = []; $seenLocations = []; - while ($row = $res->fetch(PDO::FETCH_ASSOC)) { + foreach ($res as $row) { unset($ids[$row['machineuuid']]); settype($row['locationid'], 'int'); if (in_array($row['locationid'], $allowedLocations)) { @@ -202,7 +202,7 @@ class Page_Statistics extends Page $res = Database::simpleQuery('SELECT machineuuid, locationid FROM machine WHERE machineuuid IN (:ids)', compact('ids')); $ids = array_flip($ids); $delete = []; - while ($row = $res->fetch(PDO::FETCH_ASSOC)) { + foreach ($res as $row) { unset($ids[$row['machineuuid']]); if (in_array($row['locationid'], $allowedLocations)) { $delete[] = $row['machineuuid']; diff --git a/modules-available/statistics/pages/list.inc.php b/modules-available/statistics/pages/list.inc.php index e9af994a..d3c8069e 100644 --- a/modules-available/statistics/pages/list.inc.php +++ b/modules-available/statistics/pages/list.inc.php @@ -59,7 +59,7 @@ class SubPage // Only make client clickable if user is allowed to view details page $detailsAllowedLocations = User::getAllowedLocations("machine.view-details"); $location = self::buildLocationLookup(); - while ($row = $res->fetch(PDO::FETCH_ASSOC)) { + foreach ($res as $row) { if ($singleMachine === 'none') { $singleMachine = $row['machineuuid']; } else { diff --git a/modules-available/statistics/pages/machine.inc.php b/modules-available/statistics/pages/machine.inc.php index 87e8ad14..677ff580 100644 --- a/modules-available/statistics/pages/machine.inc.php +++ b/modules-available/statistics/pages/machine.inc.php @@ -36,7 +36,7 @@ class SubPage 'end' => $row['logintime'] + 300, )); $session = false; - while ($r = $res->fetch(PDO::FETCH_ASSOC)) { + foreach ($res as $r) { if ($session === false || abs($session['dateline'] - $row['logintime']) > abs($r['dateline'] - $row['logintime'])) { $session = $r; } @@ -201,7 +201,7 @@ class SubPage array('screen' => DeviceType::SCREEN, 'uuid' => $uuid)); $client['screens'] = array(); $ports = array(); - while ($row = $res->fetch(PDO::FETCH_ASSOC)) { + foreach ($res as $row) { if ($row['disconnecttime'] != 0) continue; $ports[] = $row['connector']; @@ -227,7 +227,7 @@ class SubPage $spans['graph'] = ''; $last = false; $first = true; - while ($row = $res->fetch(PDO::FETCH_ASSOC)) { + foreach ($res as $row) { if (!$client['isclient'] && $row['typeid'] === Statistics::SESSION_LENGTH) continue; // Don't differentiate between session and idle for non-clients if ($first && $row['dateline'] > $cutoff && $client['lastboot'] > $cutoff) { @@ -325,7 +325,7 @@ class SubPage . ' WHERE machineuuid = :uuid ORDER BY logid DESC LIMIT 25', array('uuid' => $client['machineuuid'])); $count = 0; $log = array(); - while ($row = $lres->fetch(PDO::FETCH_ASSOC)) { + foreach ($lres as $row) { if (substr($row['description'], -5) === 'on :0' && strpos($row['description'], 'root logged') === false) { continue; } diff --git a/modules-available/statistics/pages/projectors.inc.php b/modules-available/statistics/pages/projectors.inc.php index cc808cf0..97a21ebd 100644 --- a/modules-available/statistics/pages/projectors.inc.php +++ b/modules-available/statistics/pages/projectors.inc.php @@ -52,7 +52,7 @@ class SubPage 'screen' => DeviceType::SCREEN, )); $data = array( - 'projectors' => $res->fetchAll(PDO::FETCH_ASSOC) + 'projectors' => $res->fetchAll() ); Render::addTemplate('projector-list', $data); } diff --git a/modules-available/statistics/pages/replace.inc.php b/modules-available/statistics/pages/replace.inc.php index 9c16aed7..77f311ea 100644 --- a/modules-available/statistics/pages/replace.inc.php +++ b/modules-available/statistics/pages/replace.inc.php @@ -106,7 +106,7 @@ class SubPage FROM machine old INNER JOIN machine new ON (old.clientip = new.clientip AND old.lastseen < new.firstseen AND old.lastseen > $oldCutoff AND new.firstseen > $newCutoff) ORDER BY oldhost ASC, oldip ASC"); $list = []; - while ($row = $res->fetch(PDO::FETCH_ASSOC)) { + foreach ($res as $row) { $row['oldlastseen_s'] = Util::prettyTime($row['oldlastseen']); $row['newfirstseen_s'] = Util::prettyTime($row['newfirstseen']); $list[] = $row; diff --git a/modules-available/statistics/pages/summary.inc.php b/modules-available/statistics/pages/summary.inc.php index ce67070e..4599b8b6 100644 --- a/modules-available/statistics/pages/summary.inc.php +++ b/modules-available/statistics/pages/summary.inc.php @@ -67,7 +67,7 @@ class SubPage $points1 = array('data' => array(), 'label' => 'Online', 'fillColor' => '#efe', 'strokeColor' => '#aea', 'pointColor' => '#7e7', 'pointStrokeColor' => '#fff', 'pointHighlightFill' => '#fff', 'pointHighlightStroke' => '#7e7'); $points2 = array('data' => array(), 'label' => 'In use', 'fillColor' => '#fee', 'strokeColor' => '#eaa', 'pointColor' => '#e77', 'pointStrokeColor' => '#fff', 'pointHighlightFill' => '#fff', 'pointHighlightStroke' => '#e77'); $sum = 0; - while ($row = $res->fetch(PDO::FETCH_ASSOC)) { + foreach ($res as $row) { $x = explode('#', $row['data']); if ($sum === 0) { $labels[] = date('H:i', $row['dateline']); @@ -103,7 +103,7 @@ class SubPage $lines = array(); $json = array(); $id = 0; - while ($row = $res->fetch(PDO::FETCH_ASSOC)) { + foreach ($res as $row) { if (empty($row['systemmodel'])) { continue; } @@ -131,7 +131,7 @@ class SubPage $res = Database::simpleQuery("SELECT mbram, Count(*) AS `count` FROM machine m $join WHERE $where GROUP BY mbram", $args); $lines = array(); - while ($row = $res->fetch(PDO::FETCH_ASSOC)) { + foreach ($res as $row) { $gb = (int)ceil($row['mbram'] / 1024); for ($i = 1; $i < count(StatisticsFilter::SIZE_RAM); ++$i) { if (StatisticsFilter::SIZE_RAM[$i] < $gb) { @@ -178,7 +178,7 @@ class SubPage WHERE $where GROUP BY kvmstate ORDER BY `count` DESC", $args); $lines = array(); $json = array(); - while ($row = $res->fetch(PDO::FETCH_ASSOC)) { + foreach ($res as $row) { $lines[] = $row; $json[] = array( 'color' => isset($colors[$row['kvmstate']]) ? $colors[$row['kvmstate']] : '#000', @@ -198,7 +198,7 @@ class SubPage $res = Database::simpleQuery("SELECT id44mb, Count(*) AS `count` FROM machine m $join WHERE $where GROUP BY id44mb", $args); $lines = array(); $total = 0; - while ($row = $res->fetch(PDO::FETCH_ASSOC)) { + foreach ($res as $row) { $total += $row['count']; $gb = (int)ceil($row['id44mb'] / 1024); for ($i = 1; $i < count(StatisticsFilter::SIZE_ID44); ++$i) { @@ -251,7 +251,7 @@ class SubPage . " WHERE firstseen > :cutoff AND $where ORDER BY firstseen DESC LIMIT 32", $args); $rows = array(); $count = 0; - while ($row = $res->fetch(PDO::FETCH_ASSOC)) { + foreach ($res as $row) { if (empty($row['hostname'])) { $row['hostname'] = $row['clientip']; } |