summaryrefslogtreecommitdiffstats
path: root/modules-available/statistics
diff options
context:
space:
mode:
Diffstat (limited to 'modules-available/statistics')
-rw-r--r--modules-available/statistics/inc/statistics.inc.php4
-rw-r--r--modules-available/statistics/inc/statisticshooks.inc.php9
-rw-r--r--modules-available/statistics/pages/list.inc.php4
-rw-r--r--modules-available/statistics/pages/machine.inc.php8
-rw-r--r--modules-available/statistics/pages/summary.inc.php6
5 files changed, 19 insertions, 12 deletions
diff --git a/modules-available/statistics/inc/statistics.inc.php b/modules-available/statistics/inc/statistics.inc.php
index 2a9ca3c9..c12f5be4 100644
--- a/modules-available/statistics/inc/statistics.inc.php
+++ b/modules-available/statistics/inc/statistics.inc.php
@@ -46,11 +46,11 @@ class Statistics
* @param string $sort something like 'lastseen ASC' - not sanitized, don't pass user input!
* @return Machine[] list of matches
*/
- public static function getMachinesByIp(string $ip, int $returnData, bool $sort = false): array
+ public static function getMachinesByIp(string $ip, int $returnData, string $sort = null): array
{
$fields = self::initFields($returnData);
- if ($sort === false) {
+ if ($sort === null) {
$sort = '';
} else {
$sort = "ORDER BY $sort";
diff --git a/modules-available/statistics/inc/statisticshooks.inc.php b/modules-available/statistics/inc/statisticshooks.inc.php
index b17cf4a9..405ed5f7 100644
--- a/modules-available/statistics/inc/statisticshooks.inc.php
+++ b/modules-available/statistics/inc/statisticshooks.inc.php
@@ -13,7 +13,11 @@ class StatisticsHooks
['machineuuid' => $machineuuid]);
}
- public static function getBaseconfigName(string $machineuuid): string
+ /**
+ * Hook for baseconfig.
+ * @return false|string Client name, or false if invalid
+ */
+ public static function getBaseconfigName(string $machineuuid)
{
self::getRow($machineuuid);
if (self::$row === false)
@@ -21,6 +25,9 @@ class StatisticsHooks
return self::$row['hostname'] ?: self::$row['clientip'];
}
+ /**
+ * Hook for baseconfig.
+ */
public static function baseconfigLocationResolver(string $machineuuid): int
{
self::getRow($machineuuid);
diff --git a/modules-available/statistics/pages/list.inc.php b/modules-available/statistics/pages/list.inc.php
index b318cc68..facffdd0 100644
--- a/modules-available/statistics/pages/list.inc.php
+++ b/modules-available/statistics/pages/list.inc.php
@@ -89,9 +89,9 @@ class SubPage
$row['subnet'] = "$octets[0].$octets[1].$octets[2]";
$row['lastoctet'] = $octets[3];
}
- $row['ramclass'] = StatisticsStyling::ramColorClass($row['mbram']);
+ $row['ramclass'] = StatisticsStyling::ramColorClass((int)$row['mbram']);
$row['kvmclass'] = StatisticsStyling::kvmColorClass($row['kvmstate']);
- $row['hddclass'] = StatisticsStyling::hddColorClass($row['gbtmp']);
+ $row['hddclass'] = StatisticsStyling::hddColorClass((int)$row['gbtmp']);
if (empty($row['hostname'])) {
$row['hostname'] = $row['clientip'];
}
diff --git a/modules-available/statistics/pages/machine.inc.php b/modules-available/statistics/pages/machine.inc.php
index 24bf7c1e..fe82797d 100644
--- a/modules-available/statistics/pages/machine.inc.php
+++ b/modules-available/statistics/pages/machine.inc.php
@@ -219,9 +219,9 @@ class SubPage
$client['live_cpuidle'] = 100 - $client['live_cpuload'];
}
$client['live_cputemppercent'] = max(0, min(100, 110 - $client['live_cputemp']));
- $client['ramclass'] = StatisticsStyling::ramColorClass($client['mbram']);
+ $client['ramclass'] = StatisticsStyling::ramColorClass((int)$client['mbram']);
$client['kvmclass'] = StatisticsStyling::kvmColorClass($client['kvmstate']);
- $client['hddclass'] = StatisticsStyling::hddColorClass($client['gbtmp']);
+ $client['hddclass'] = StatisticsStyling::hddColorClass((int)$client['gbtmp']);
// Format HDD data to strings
foreach ($hdds['hdds'] as &$hdd) {
$hdd['smart_status_failed'] = !($client['smart_status//passed'] ?? 1);
@@ -405,8 +405,8 @@ class SubPage
}
if (count($spans['rows']) > 10) {
$spans['hasrows2'] = true;
- $spans['rows2'] = array_slice($spans['rows'], ceil(count($spans['rows']) / 2));
- $spans['rows'] = array_slice($spans['rows'], 0, ceil(count($spans['rows']) / 2));
+ $spans['rows2'] = array_slice($spans['rows'], (int)ceil(count($spans['rows']) / 2));
+ $spans['rows'] = array_slice($spans['rows'], 0, (int)ceil(count($spans['rows']) / 2));
}
$spans['isclient'] = $client['isclient'];
Render::addTemplate('machine-usage', $spans);
diff --git a/modules-available/statistics/pages/summary.inc.php b/modules-available/statistics/pages/summary.inc.php
index d0538b38..e9c25456 100644
--- a/modules-available/statistics/pages/summary.inc.php
+++ b/modules-available/statistics/pages/summary.inc.php
@@ -129,7 +129,7 @@ class SubPage
['data' => $points1, 'label' => 'Online', 'borderColor' => '#8f3'],
['data' => $points2, 'label' => 'In use', 'borderColor' => '#e76'],
]]);
- $data['markings'] = json_encode($lectures, true);
+ $data['markings'] = json_encode($lectures);
}
if (Module::get('runmode') !== false) {
$res = Database::queryFirst('SELECT Count(*) AS cnt FROM machine m INNER JOIN runmode r USING (machineuuid)'
@@ -287,9 +287,9 @@ class SubPage
$row['firstseen'] = Util::prettyTime($row['firstseen']);
$row['gbram'] = round(round($row['mbram'] / 500) / 2, 1); // Trial and error until we got "expected" rounding..
$row['gbtmp'] = round($row['id44mb'] / 1024);
- $row['ramclass'] = StatisticsStyling::ramColorClass($row['mbram']);
+ $row['ramclass'] = StatisticsStyling::ramColorClass((int)$row['mbram']);
$row['kvmclass'] = StatisticsStyling::kvmColorClass($row['kvmstate']);
- $row['hddclass'] = StatisticsStyling::hddColorClass($row['gbtmp']);
+ $row['hddclass'] = StatisticsStyling::hddColorClass((int)$row['gbtmp']);
$row['kvmicon'] = $row['kvmstate'] === 'ENABLED' ? '✓' : '✗';
if (++$count > 5) {
$row['collapse'] = 'collapse';