From f37c95a560f0d2bac96e4b0e650d12691181b876 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Tue, 7 Aug 2018 16:48:13 +0200 Subject: [syslog] Add user export feature This will export all rows from tables that log user related content, data, events, helping administrators to conform to DSGVO information requests. Closes #3401 --- modules-available/syslog/api.inc.php | 39 ++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'modules-available/syslog/api.inc.php') diff --git a/modules-available/syslog/api.inc.php b/modules-available/syslog/api.inc.php index 18c42c31..945f9d09 100644 --- a/modules-available/syslog/api.inc.php +++ b/modules-available/syslog/api.inc.php @@ -1,5 +1,44 @@ Database::simpleQuery("SELECT dateline, logtypeid AS typeid, clientip, description FROM clientlog + WHERE description REGEXP :exp + ORDER BY dateline ASC", ['exp' => $exp])]; + if (Module::get('statistics') !== false) { + $srcs[] = ['res' => Database::simpleQuery("SELECT dateline, typeid, clientip, data AS description FROM statistic + WHERE username = :user + ORDER BY dateline ASC", ['user' => $user])]; + } + echo "# Begin log\n"; + for (;;) { + unset($best); + foreach ($srcs as &$src) { + if (!isset($src['row'])) { + $src['row'] = $src['res']->fetch(PDO::FETCH_ASSOC); + } + if ($src['row'] !== false && (!isset($best) || $src['row']['dateline'] < $best['dateline'])) { + $best =& $src['row']; + } + } + if (!isset($best)) + break; + echo date('Y-m-d H:i:s', $best['dateline']), "\t", $best['typeid'], "\t", $best['clientip'], "\t", $best['description'], "\n"; + $best = null; // so we repopulate on next iteration + } + die("# End log\n"); +} + if (empty($_POST['type'])) die('Missing options.'); $type = mb_strtolower($_POST['type']); -- cgit v1.2.3-55-g7522