diff options
Diffstat (limited to 'modules-available/statistics/baseconfig/getconfig.inc.php')
-rw-r--r-- | modules-available/statistics/baseconfig/getconfig.inc.php | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/modules-available/statistics/baseconfig/getconfig.inc.php b/modules-available/statistics/baseconfig/getconfig.inc.php index 053827db..f90cd49d 100644 --- a/modules-available/statistics/baseconfig/getconfig.inc.php +++ b/modules-available/statistics/baseconfig/getconfig.inc.php @@ -1,18 +1,41 @@ <?php +/** @var ?string $uuid */ +/** @var ?string $ip */ + // Location handling: figure out location if (Request::any('force', 0, 'int') === 1 && Request::any('module', false, 'string') === 'statistics') { // Force location for testing, but require logged in admin if (User::load()) { - $uuid = Request::any('value', '', 'string'); + $uuid = Request::any('value', null, 'string'); } } -if (!$uuid) // Required at this point, bail out if not given +if ($uuid === null) // Required at this point, bail out if not given return; // 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); } + +if ($ip !== null) { +// Statistics about booted system + ConfigHolder::addPostHook(function () use ($ip, $uuid) { + $type = Request::get('type', 'default', 'string'); + // System + if ($type !== 'default') { + Database::exec("INSERT INTO statistic (dateline, typeid, clientip, machineuuid, username, data) + VALUES (UNIX_TIMESTAMP(), :type, :ip, :uuid, '', :data)", + ['type' => 'boot-system', 'ip' => $ip, 'uuid' => $uuid, 'data' => $type]); + } + // Runmode + $mode = ConfigHolder::get('SLX_RUNMODE_MODULE'); + if (!empty($mode)) { + Database::exec("INSERT INTO statistic (dateline, typeid, clientip, machineuuid, username, data) + VALUES (UNIX_TIMESTAMP(), :type, :ip, :uuid, '', :data)", + ['type' => 'boot-runmode', 'ip' => $ip, 'uuid' => $uuid, 'data' => $mode]); + } + }); +}
\ No newline at end of file |