summaryrefslogtreecommitdiffstats
path: root/modules-available/locationinfo/inc/infopanel.inc.php
diff options
context:
space:
mode:
authorSimon Rettberg2020-06-29 10:51:46 +0200
committerSimon Rettberg2020-07-30 13:26:52 +0200
commit086d666e191264688c0c5a9e34fe1e2228b29820 (patch)
tree258e269a2772edb0d31a141651a08d722ef84ec3 /modules-available/locationinfo/inc/infopanel.inc.php
parent[inc/Request] Don't treat 0 as empty (diff)
downloadslx-admin-086d666e191264688c0c5a9e34fe1e2228b29820.tar.gz
slx-admin-086d666e191264688c0c5a9e34fe1e2228b29820.tar.xz
slx-admin-086d666e191264688c0c5a9e34fe1e2228b29820.zip
[locationinfo] Add option to show hostnames
Diffstat (limited to 'modules-available/locationinfo/inc/infopanel.inc.php')
-rw-r--r--modules-available/locationinfo/inc/infopanel.inc.php26
1 files changed, 22 insertions, 4 deletions
diff --git a/modules-available/locationinfo/inc/infopanel.inc.php b/modules-available/locationinfo/inc/infopanel.inc.php
index 1e2e7313..b0ee0d56 100644
--- a/modules-available/locationinfo/inc/infopanel.inc.php
+++ b/modules-available/locationinfo/inc/infopanel.inc.php
@@ -65,7 +65,7 @@ class InfoPanel
$config['locations'][$lid]['config'] = $overrides[$lid];
}
}
- self::appendMachineData($config['locations'], $lids, true);
+ self::appendMachineData($config['locations'], $lids, true, $config['hostname']);
}
self::appendOpeningTimes($config['locations'], $lids);
@@ -87,7 +87,7 @@ class InfoPanel
* @param array $array location list to populate with machine data
* @param bool $withPosition Defines if coords should be included or not.
*/
- public static function appendMachineData(&$array, $idList = false, $withPosition = false)
+ public static function appendMachineData(&$array, $idList = false, $withPosition = false, $withHostname = false)
{
if (empty($array) && $idList === false)
return;
@@ -101,8 +101,14 @@ class InfoPanel
$ignoreList = RunMode::getAllClients(false, false);
}
- $positionCol = $withPosition ? 'm.position,' : '';
- $query = "SELECT m.locationid, m.machineuuid, $positionCol m.logintime, m.lastseen, m.lastboot, m.state FROM machine m
+ $extraCols = '';
+ if ($withPosition) {
+ $extraCols .= 'm.position,';
+ }
+ if ($withHostname) {
+ $extraCols .= 'm.hostname,';
+ }
+ $query = "SELECT m.locationid, m.machineuuid, m.hostname, $extraCols m.logintime, m.lastseen, m.lastboot, m.state FROM machine m
WHERE m.locationid IN (:idlist)";
$dbquery = Database::simpleQuery($query, array('idlist' => $idList));
@@ -129,6 +135,18 @@ class InfoPanel
}
}
}
+ if ($withHostname) {
+ if (ip2long($row['hostname']) !== false) {
+ $pc['host'] = $row['hostname'];
+ } else {
+ $i = strpos($row['hostname'], '.');
+ if ($i === false) {
+ $pc['host'] = $row['hostname'];
+ } else {
+ $pc['host'] = substr($row['hostname'], 0, $i);
+ }
+ }
+ }
$pc['pcState'] = LocationInfo::getPcState($row);
//$pc['pcState'] = ['BROKEN', 'OFFLINE', 'IDLE', 'OCCUPIED', 'STANDBY'][mt_rand(0,4)]; // XXX