summaryrefslogtreecommitdiffstats
path: root/modules-available/syslog/page.inc.php
diff options
context:
space:
mode:
Diffstat (limited to 'modules-available/syslog/page.inc.php')
-rw-r--r--modules-available/syslog/page.inc.php41
1 files changed, 39 insertions, 2 deletions
diff --git a/modules-available/syslog/page.inc.php b/modules-available/syslog/page.inc.php
index 153b591f..6c1a0a16 100644
--- a/modules-available/syslog/page.inc.php
+++ b/modules-available/syslog/page.inc.php
@@ -3,6 +3,9 @@
class Page_SysLog extends Page
{
+ const PROP_ANON_DAYS = 'syslog.anon-days'; // Copy in cronjob
+
+
protected function doPreprocess()
{
User::load();
@@ -11,10 +14,31 @@ 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 > 180) {
+ 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');
+ }
+ User::assertPermission('*');
}
protected function doRender()
{
+ $data = ['anondays' => Property::get(self::PROP_ANON_DAYS, 0)];
+ Permission::addGlobalTags($data['perms'], NULL, ['configure-anonymization', 'export-user-data']);
+ Render::addTemplate("heading", $data);
+
+ if (!User::hasPermission("view")) {
+ Message::addError('main.no-permission');
+ return;
+ }
+
$cutoff = strtotime('-1 month');
$res = Database::simpleQuery("SELECT logtypeid, Count(*) AS counter FROM clientlog WHERE dateline > $cutoff GROUP BY logtypeid ORDER BY counter ASC");
$types = array();
@@ -57,9 +81,22 @@ class Page_SysLog extends Page
$whereClause .= "machineuuid='" . preg_replace('/[^0-9a-zA-Z\-]/', '', Request::get('machineuuid', '', 'string')) . "'";
}
+
+ $allowedLocations = User::getAllowedLocations("view");
+ $joinClause = "";
+ if (!in_array(0, $allowedLocations)) {
+ $joinClause = "INNER JOIN machine USING (machineuuid)";
+ if (empty($whereClause))
+ $whereClause .= ' WHERE ';
+ else
+ $whereClause .= ' AND ';
+
+ $whereClause .= 'locationid IN (:allowedLocations)';
+ }
+
$lines = array();
- $paginate = new Paginate("SELECT logid, dateline, logtypeid, clientip, machineuuid, description, extra FROM clientlog $whereClause ORDER BY logid DESC", 50);
- $res = $paginate->exec();
+ $paginate = new Paginate("SELECT logid, dateline, logtypeid, clientlog.clientip, clientlog.machineuuid, description, extra FROM clientlog $joinClause $whereClause ORDER BY logid DESC", 50);
+ $res = $paginate->exec(array("allowedLocations" => $allowedLocations));
while ($row = $res->fetch(PDO::FETCH_ASSOC)) {
$row['date'] = Util::prettyTime($row['dateline']);
$row['icon'] = $this->eventToIconName($row['logtypeid']);