summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2025-08-07 17:51:54 +0200
committerSimon Rettberg2025-08-07 17:51:54 +0200
commited9b97d6c7dddb153b2e0178fd0bd0e8d6bf4f16 (patch)
tree9ca54ef9e079899695568faa6cb77d6d63f44256
parentJS: Reorganize script to lower number of ready listeners (diff)
downloadslx-admin-ed9b97d6c7dddb153b2e0178fd0bd0e8d6bf4f16.tar.gz
slx-admin-ed9b97d6c7dddb153b2e0178fd0bd0e8d6bf4f16.tar.xz
slx-admin-ed9b97d6c7dddb153b2e0178fd0bd0e8d6bf4f16.zip
[syslog] Improve POSTs for audit logging
-rw-r--r--modules-available/syslog/api.inc.php1
-rw-r--r--modules-available/syslog/page.inc.php46
-rw-r--r--modules-available/syslog/templates/heading.html4
-rw-r--r--modules-available/syslog/templates/page-syslog.html2
4 files changed, 29 insertions, 24 deletions
diff --git a/modules-available/syslog/api.inc.php b/modules-available/syslog/api.inc.php
index d2fa4a85..c810feb7 100644
--- a/modules-available/syslog/api.inc.php
+++ b/modules-available/syslog/api.inc.php
@@ -21,6 +21,7 @@ if (($user = Request::post('export-user', false, 'string')) !== false) {
ORDER BY dateline ASC", ['user' => $user])];
}
echo "# Begin log\n";
+ // Interleave by dateline
for (;;) {
unset($best);
foreach ($srcs as &$src) {
diff --git a/modules-available/syslog/page.inc.php b/modules-available/syslog/page.inc.php
index bbc12e92..632e5e3f 100644
--- a/modules-available/syslog/page.inc.php
+++ b/modules-available/syslog/page.inc.php
@@ -14,31 +14,35 @@ class Page_SysLog extends Page
Message::addError('main.no-permission');
Util::redirect('?do=Main');
}
-
- if (($days = Request::post('anondays', false, 'int')) !== false) {
- User::assertPermission('configure-anonymization', NULL,'?do=syslog');
- if ($days < 0 || $days > 366) {
- Audit::overrideResponseCode(400);
- Message::addError('anon-days-out-of-range', $days);
- } else {
- Property::set(self::PROP_ANON_DAYS, $days);
- Message::addSuccess('anon-days-saved');
+ $action = Request::post('action', null, 'string');
+ if ($action !== null) {
+ if ($action === 'anondays') {
+ User::assertPermission('configure-anonymization', NULL,'?do=syslog');
+ $days = Request::post('anondays', 0, 'int');
+ if ($days < 0 || $days > 366) {
+ Audit::overrideResponseCode(400);
+ Message::addError('anon-days-out-of-range', $days);
+ } else {
+ Property::set(self::PROP_ANON_DAYS, $days);
+ Message::addSuccess('anon-days-saved');
+ }
+ Util::redirect('?do=syslog', 200);
}
- Util::redirect('?do=syslog');
- }
- if (Request::isPost()) {
- $pairs = [];
- foreach (['search', 'filter', 'not', 'machineuuid'] as $key) {
- $val = Request::any($key, false, 'string');
- if (!empty($val)) {
- if ($key === 'not') {
- $val = (bool)$val;
+
+ if ($action === 'filter') {
+ $pairs = [];
+ foreach (['search', 'filter', 'not', 'machineuuid'] as $key) {
+ $val = Request::any($key, false, 'string');
+ if (!empty($val)) {
+ if ($key === 'not') {
+ $val = (bool)$val;
+ }
+ $pairs[$key] = $val;
}
- $pairs[$key] = $val;
+ Session::set('log_' . $key, $pairs[$key] ?? false, false);
}
- Session::set('log_' . $key, $pairs[$key] ?? false, false);
+ Util::redirect('?do=syslog&' . http_build_query($pairs), 200);
}
- Util::redirect('?do=syslog&' . http_build_query($pairs));
}
User::assertPermission('*');
}
diff --git a/modules-available/syslog/templates/heading.html b/modules-available/syslog/templates/heading.html
index 8dd3d440..45e09a32 100644
--- a/modules-available/syslog/templates/heading.html
+++ b/modules-available/syslog/templates/heading.html
@@ -26,7 +26,7 @@
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">{{lang_cancel}}</button>
<button {{perms.configure-anonymization.disabled}} type="submit"
- class="btn btn-primary">
+ name="action" value="anondays" class="btn btn-primary">
<span class="glyphicon glyphicon-floppy-disk"></span>
{{lang_save}}
</button>
@@ -53,7 +53,7 @@
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">{{lang_cancel}}</button>
- <button type="submit" class="btn btn-primary">
+ <button type="submit" class="btn btn-primary" name="action" value="user-export">
<span class="glyphicon glyphicon-export"></span>
{{lang_export}}
</button>
diff --git a/modules-available/syslog/templates/page-syslog.html b/modules-available/syslog/templates/page-syslog.html
index 33be4ab7..0ac202ce 100644
--- a/modules-available/syslog/templates/page-syslog.html
+++ b/modules-available/syslog/templates/page-syslog.html
@@ -28,7 +28,7 @@
<input class="form-control" placeholder="{{lang_searchString}}" value="{{search}}" name="search">
</div>
<div class="col-sm-1">
- <button class="btn btn-primary" type="submit">{{lang_applyFilter}}</button>
+ <button class="btn btn-primary" type="submit" name="action" value="filter">{{lang_applyFilter}}</button>
</div>
</div>
</form>