diff options
author | Simon Rettberg | 2023-11-14 14:47:55 +0100 |
---|---|---|
committer | Simon Rettberg | 2023-11-14 14:47:55 +0100 |
commit | 06bff0b9b84d47c43f9bc8aff06a29d85ebb7ed0 (patch) | |
tree | 7e5493b102074672d8cfd8fe1a61e49f080edbe8 /modules-available/statistics/baseconfig | |
parent | Update phpstorm config (diff) | |
download | slx-admin-06bff0b9b84d47c43f9bc8aff06a29d85ebb7ed0.tar.gz slx-admin-06bff0b9b84d47c43f9bc8aff06a29d85ebb7ed0.tar.xz slx-admin-06bff0b9b84d47c43f9bc8aff06a29d85ebb7ed0.zip |
Add function param/return types, fix a lot more phpstorm complaints
Diffstat (limited to 'modules-available/statistics/baseconfig')
-rw-r--r-- | modules-available/statistics/baseconfig/getconfig.inc.php | 37 |
1 files changed, 21 insertions, 16 deletions
diff --git a/modules-available/statistics/baseconfig/getconfig.inc.php b/modules-available/statistics/baseconfig/getconfig.inc.php index 7bf25d5d..f90cd49d 100644 --- a/modules-available/statistics/baseconfig/getconfig.inc.php +++ b/modules-available/statistics/baseconfig/getconfig.inc.php @@ -1,14 +1,17 @@ <?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 @@ -17,20 +20,22 @@ 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) + 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) + ['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]); - } -}); + ['type' => 'boot-runmode', 'ip' => $ip, 'uuid' => $uuid, 'data' => $mode]); + } + }); +}
\ No newline at end of file |