summaryrefslogtreecommitdiffstats
path: root/modules/syslog.inc.php
diff options
context:
space:
mode:
authorSimon Rettberg2014-05-19 15:30:59 +0200
committerSimon Rettberg2014-05-19 15:30:59 +0200
commitf6ceaa03052e6878afd53a4bbb7f4429849fe25a (patch)
tree9f5582c8c275494728f6d6dcf656479714688934 /modules/syslog.inc.php
parentWorking on config.tgz composition through config modules (diff)
downloadslx-admin-f6ceaa03052e6878afd53a4bbb7f4429849fe25a.tar.gz
slx-admin-f6ceaa03052e6878afd53a4bbb7f4429849fe25a.tar.xz
slx-admin-f6ceaa03052e6878afd53a4bbb7f4429849fe25a.zip
OO style modules
Diffstat (limited to 'modules/syslog.inc.php')
-rw-r--r--modules/syslog.inc.php113
1 files changed, 59 insertions, 54 deletions
diff --git a/modules/syslog.inc.php b/modules/syslog.inc.php
index 62c94edf..2c54b8f4 100644
--- a/modules/syslog.inc.php
+++ b/modules/syslog.inc.php
@@ -1,64 +1,69 @@
<?php
-require_once('inc/paginate.inc.php');
-
-User::load();
+class Page_SysLog extends Page
+{
-if (!User::isLoggedIn()) {
- Util::redirect('?do=main');
-}
+ protected function doPreprocess()
+ {
+ User::load();
-function render_module()
-{
- Render::setTitle('Client Log');
-
- if (isset($_GET['filter'])) {
- $filter = $_GET['filter'];
- $not = isset($_GET['not']) ? 'NOT' : '';
- } elseif (isset($_POST['filter'])) {
- $filter = $_POST['filter'];
- $not = isset($_POST['not']) ? 'NOT' : '';
- Session::set('log_filter', $filter);
- Session::set('log_not', $not);
- Session::save();
- } else {
- $filter = Session::get('log_filter');
- $not = Session::get('log_not') ? 'NOT' : '';
- }
- if (!empty($filter)) {
- $filterList = explode(',', $filter);
- $whereClause = array();
- foreach ($filterList as $filterItem) {
- $filterItem = preg_replace('/[^a-z0-9_\-]/', '', trim($filterItem));
- if (empty($filterItem) || in_array($filterItem, $whereClause)) continue;
- $whereClause[] = "'$filterItem'";
+ if (!User::isLoggedIn()) {
+ Util::redirect('?do=Main');
}
- if (!empty($whereClause)) $whereClause = ' WHERE logtypeid ' . $not . ' IN (' . implode(', ', $whereClause) . ')';
}
- if (!isset($whereClause) || empty($whereClause)) $whereClause = '';
- $today = date('d.m.Y');
- $yesterday = date('d.m.Y', time() - 86400);
- $lines = array();
- $paginate = new Paginate("SELECT logid, dateline, logtypeid, clientip, description, extra FROM clientlog $whereClause ORDER BY logid DESC", 50);
- $res = $paginate->exec();
- while ($row = $res->fetch(PDO::FETCH_ASSOC)) {
- $day = date('d.m.Y', $row['dateline']);
- // TODO: No output strings in source files!
- if ($day === $today) {
- $day = 'Heute';
- } elseif ($day === $yesterday) {
- $day = 'Gestern';
+ protected function doRender()
+ {
+ Render::setTitle('Client Log');
+
+ if (isset($_GET['filter'])) {
+ $filter = $_GET['filter'];
+ $not = isset($_GET['not']) ? 'NOT' : '';
+ } elseif (isset($_POST['filter'])) {
+ $filter = $_POST['filter'];
+ $not = isset($_POST['not']) ? 'NOT' : '';
+ Session::set('log_filter', $filter);
+ Session::set('log_not', $not);
+ Session::save();
+ } else {
+ $filter = Session::get('log_filter');
+ $not = Session::get('log_not') ? 'NOT' : '';
}
- $row['date'] = $day . date(' H:i', $row['dateline']);
- $lines[] = $row;
+ if (!empty($filter)) {
+ $filterList = explode(',', $filter);
+ $whereClause = array();
+ foreach ($filterList as $filterItem) {
+ $filterItem = preg_replace('/[^a-z0-9_\-]/', '', trim($filterItem));
+ if (empty($filterItem) || in_array($filterItem, $whereClause)) continue;
+ $whereClause[] = "'$filterItem'";
+ }
+ if (!empty($whereClause)) $whereClause = ' WHERE logtypeid ' . $not . ' IN (' . implode(', ', $whereClause) . ')';
+ }
+ if (!isset($whereClause) || empty($whereClause)) $whereClause = '';
+
+ $today = date('d.m.Y');
+ $yesterday = date('d.m.Y', time() - 86400);
+ $lines = array();
+ $paginate = new Paginate("SELECT logid, dateline, logtypeid, clientip, description, extra FROM clientlog $whereClause ORDER BY logid DESC", 50);
+ $res = $paginate->exec();
+ while ($row = $res->fetch(PDO::FETCH_ASSOC)) {
+ $day = date('d.m.Y', $row['dateline']);
+ // TODO: No output strings in source files!
+ if ($day === $today) {
+ $day = 'Heute';
+ } elseif ($day === $yesterday) {
+ $day = 'Gestern';
+ }
+ $row['date'] = $day . date(' H:i', $row['dateline']);
+ $lines[] = $row;
+ }
+
+ $paginate->render('page-syslog', array(
+ 'token' => Session::get('token'),
+ 'filter' => $filter,
+ 'not' => $not,
+ 'list' => $lines
+ ));
}
-
- $paginate->render('page-syslog', array(
- 'token' => Session::get('token'),
- 'filter' => $filter,
- 'not' => $not,
- 'list' => $lines
- ));
-}
+}