2009-12-30 07:59:40 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class LogDatabaseTheme extends Themelet {
|
2010-02-03 13:57:39 +00:00
|
|
|
protected function heie($var) {
|
|
|
|
if(isset($_GET[$var])) return html_escape($_GET[$var]);
|
|
|
|
else return "";
|
|
|
|
}
|
2010-02-12 17:22:19 +00:00
|
|
|
|
|
|
|
protected function ueie($var) {
|
|
|
|
if(isset($_GET[$var])) return $var."=".url_escape($_GET[$var]);
|
|
|
|
else return "";
|
|
|
|
}
|
|
|
|
|
|
|
|
public function display_events($events, $page_num, $page_total) {
|
2010-02-03 13:57:39 +00:00
|
|
|
$table = "
|
|
|
|
<style>
|
|
|
|
.sizedinputs TD INPUT {
|
|
|
|
width: 100%;
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
<table class='zebra'>
|
|
|
|
<thead>
|
2018-07-22 14:08:53 +00:00
|
|
|
<tr><th>Time</th><th>Module</th><th>User</th><th colspan='3'>Message</th></tr>
|
2010-02-03 13:57:39 +00:00
|
|
|
<form action='".make_link("log/view")."' method='GET'>
|
|
|
|
<tr class='sizedinputs'>
|
2018-07-22 14:08:53 +00:00
|
|
|
<td><input type='date' name='time-start' value='".$this->heie("time-start")."'>
|
|
|
|
<br><input type='date' name='time-end' value='".$this->heie("time-end")."'></td>
|
2010-02-03 13:57:39 +00:00
|
|
|
<td><input type='text' name='module' value='".$this->heie("module")."'></td>
|
|
|
|
<td><input type='text' name='user' value='".$this->heie("user")."'></td>
|
2018-07-22 14:08:53 +00:00
|
|
|
<td><input type='text' name='message' value='".$this->heie("message")."'></td>
|
2010-02-03 13:57:39 +00:00
|
|
|
<td>
|
|
|
|
<select name='priority'>
|
|
|
|
<option value='".SCORE_LOG_DEBUG."'>Debug</option>
|
|
|
|
<option value='".SCORE_LOG_INFO."' selected>Info</option>
|
|
|
|
<option value='".SCORE_LOG_WARNING."'>Warning</option>
|
|
|
|
<option value='".SCORE_LOG_ERROR."'>Error</option>
|
|
|
|
<option value='".SCORE_LOG_CRITICAL."'>Critical</option>
|
|
|
|
</select>
|
|
|
|
</td>
|
2012-03-30 16:18:01 +00:00
|
|
|
<td><input type='submit' value='Search'></td>
|
2010-02-03 13:57:39 +00:00
|
|
|
</tr>
|
|
|
|
</form>
|
|
|
|
</thead>
|
|
|
|
<tbody>\n";
|
2012-02-04 20:35:21 +00:00
|
|
|
reset($events); // rewind to first element in array.
|
|
|
|
|
2009-12-30 07:59:40 +00:00
|
|
|
foreach($events as $event) {
|
2010-01-05 10:52:23 +00:00
|
|
|
$c = $this->pri_to_col($event['priority']);
|
2012-02-22 14:27:56 +00:00
|
|
|
$table .= "<tr style='color: $c'>";
|
2012-06-09 15:25:51 +00:00
|
|
|
$table .= "<td>".str_replace(" ", " ", substr($event['date_sent'], 0, 19))."</td>";
|
2010-01-05 10:52:23 +00:00
|
|
|
$table .= "<td>".$event['section']."</td>";
|
|
|
|
if($event['username'] == "Anonymous") {
|
|
|
|
$table .= "<td>".$event['address']."</td>";
|
|
|
|
}
|
|
|
|
else {
|
2010-02-01 23:04:06 +00:00
|
|
|
$table .= "<td><span title='".$event['address']."'>".
|
|
|
|
"<a href='".make_link("user/".url_escape($event['username']))."'>".html_escape($event['username'])."</a>".
|
|
|
|
"</span></td>";
|
2010-01-05 10:52:23 +00:00
|
|
|
}
|
2018-07-22 14:08:53 +00:00
|
|
|
$table .= "<td colspan='3'>".$this->scan_entities(html_escape($event['message']))."</td>";
|
2010-01-05 10:52:23 +00:00
|
|
|
$table .= "</tr>\n";
|
2009-12-30 07:59:40 +00:00
|
|
|
}
|
|
|
|
$table .= "</tbody></table>";
|
|
|
|
|
|
|
|
global $page;
|
|
|
|
$page->set_title("Event Log");
|
|
|
|
$page->set_heading("Event Log");
|
|
|
|
$page->add_block(new NavBlock());
|
|
|
|
$page->add_block(new Block("Events", $table));
|
2018-07-22 14:08:53 +00:00
|
|
|
$this->display_paginator($page, "log/view", $this->get_args(), $page_num, $page_total);
|
|
|
|
}
|
2010-02-12 17:22:19 +00:00
|
|
|
|
2018-07-22 14:08:53 +00:00
|
|
|
protected function get_args() {
|
2010-05-23 19:48:07 +00:00
|
|
|
$args = "";
|
|
|
|
// Check if each arg is actually empty and skip it if so
|
2018-07-22 14:08:53 +00:00
|
|
|
if(strlen($this->ueie("time-start")))
|
|
|
|
$args .= $this->ueie("time-start")."&";
|
|
|
|
if(strlen($this->ueie("time-end")))
|
|
|
|
$args .= $this->ueie("time-end")."&";
|
|
|
|
if(strlen($this->ueie("module")))
|
|
|
|
$args .= $this->ueie("module")."&";
|
|
|
|
if(strlen($this->ueie("user")))
|
|
|
|
$args .= $this->ueie("user")."&";
|
|
|
|
if(strlen($this->ueie("message")))
|
|
|
|
$args .= $this->ueie("message")."&";
|
|
|
|
if(strlen($this->ueie("priority")))
|
|
|
|
$args .= $this->ueie("priority");
|
2010-05-23 19:48:07 +00:00
|
|
|
// If there are no args at all, set $args to null to prevent an unnecessary ? at the end of the paginator url
|
|
|
|
if(strlen($args) == 0)
|
|
|
|
$args = null;
|
2018-07-22 14:08:53 +00:00
|
|
|
return $args;
|
2009-12-30 07:59:40 +00:00
|
|
|
}
|
2010-01-05 10:52:23 +00:00
|
|
|
|
|
|
|
protected function pri_to_col($pri) {
|
|
|
|
switch($pri) {
|
|
|
|
case SCORE_LOG_DEBUG: return "#999";
|
|
|
|
case SCORE_LOG_INFO: return "#000";
|
|
|
|
case SCORE_LOG_WARNING: return "#800";
|
|
|
|
case SCORE_LOG_ERROR: return "#C00";
|
|
|
|
case SCORE_LOG_CRITICAL: return "#F00";
|
|
|
|
default: return "";
|
|
|
|
}
|
|
|
|
}
|
2010-02-02 00:55:34 +00:00
|
|
|
|
|
|
|
protected function scan_entities($line) {
|
|
|
|
$line = preg_replace_callback("/Image #(\d+)/s", array($this, "link_image"), $line);
|
|
|
|
return $line;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function link_image($id) {
|
|
|
|
$iid = int_escape($id[1]);
|
|
|
|
return "<a href='".make_link("post/view/$iid")."'>Image #$iid</a>";
|
|
|
|
}
|
2009-12-30 07:59:40 +00:00
|
|
|
}
|
2014-04-26 02:54:51 +00:00
|
|
|
|