summaryrefslogtreecommitdiffstats
path: root/modules-available/statistics
diff options
context:
space:
mode:
authorSimon Rettberg2019-11-27 17:25:46 +0100
committerSimon Rettberg2019-11-27 17:25:46 +0100
commitca312a6ace43a6fde58d1c09057c7b0bd34f15a2 (patch)
tree3cb4e5ac2b29f7fcc99dfda5df26f11a64caeaf3 /modules-available/statistics
parent[js_ip/locations] Mode cidr/ip handling to own module (diff)
downloadslx-admin-ca312a6ace43a6fde58d1c09057c7b0bd34f15a2.tar.gz
slx-admin-ca312a6ace43a6fde58d1c09057c7b0bd34f15a2.tar.xz
slx-admin-ca312a6ace43a6fde58d1c09057c7b0bd34f15a2.zip
[statistics/rebootcontrol] Implement editing subnet
Diffstat (limited to 'modules-available/statistics')
-rw-r--r--modules-available/statistics/api.inc.php24
-rw-r--r--modules-available/statistics/page.inc.php2
2 files changed, 25 insertions, 1 deletions
diff --git a/modules-available/statistics/api.inc.php b/modules-available/statistics/api.inc.php
index 1cf98ae4..64925791 100644
--- a/modules-available/statistics/api.inc.php
+++ b/modules-available/statistics/api.inc.php
@@ -158,6 +158,30 @@ if ($type{0} === '~') {
}
}
+ // Inform WOL (rebootcontrol) module about subnet size
+ if (Module::get('rebootcontrol') !== false) {
+ $subnet = Request::post('subnet', false, 'string');
+ if ($subnet !== false && ($subnet = explode('/', $subnet)) !== false && count($subnet) === 2
+ && $subnet[0] === $ip && $subnet[1] >= 8 && $subnet[1] < 32) {
+ $start = ip2long($ip);
+ if ($start !== false) {
+ $maskHost = (int)(pow(2, 32 - $subnet[1]) - 1);
+ $maskNet = ~$maskHost & 0xffffffff;
+ $end = $start | $maskHost;
+ $start &= $maskNet;
+ $netparams = ['start' => sprintf('%u', $start), 'end' => sprintf('%u', $end), 'now' => $NOW];
+ $affected = Database::exec('UPDATE reboot_subnet
+ SET lastseen = :now, seencount = seencount + 1
+ WHERE start = :start AND end = :end', $netparams);
+ if ($affected === 0) {
+ // New entry
+ Database::exec('INSERT INTO reboot_subnet (start, end, fixed, isdirect, lastseen, seencount)
+ VALUES (:start, :end, 0, 0, :now, 1)', $netparams);
+ }
+ }
+ }
+ }
+
// Write statistics data
} else if ($type === '~runstate') {
diff --git a/modules-available/statistics/page.inc.php b/modules-available/statistics/page.inc.php
index 68649d91..be838fc0 100644
--- a/modules-available/statistics/page.inc.php
+++ b/modules-available/statistics/page.inc.php
@@ -129,7 +129,7 @@ class Page_Statistics extends Page
}
$task = RebootControl::execute($allowedMachines, $action, 0, $locactionId);
if (Taskmanager::isTask($task)) {
- Util::redirect("?do=rebootcontrol&taskid=" . $task["id"]);
+ Util::redirect("?do=rebootcontrol&what=task&taskid=" . $task["id"]);
}
}
}