searchable event log
This commit is contained in:
parent
3b2941a5bc
commit
5e4f387983
@ -44,7 +44,31 @@ class LogDatabase extends SimpleExtension {
|
||||
global $database, $user;
|
||||
if($event->page_matches("log/view")) {
|
||||
if($user->is_admin()) {
|
||||
$events = $database->get_all("SELECT * FROM score_log ORDER BY id DESC LIMIT 50");
|
||||
$wheres = array();
|
||||
$args = array();
|
||||
if(!empty($_GET["time"])) {
|
||||
$wheres[] = "date_sent LIKE ?";
|
||||
$args[] = $_GET["time"]."%";
|
||||
}
|
||||
if(!empty($_GET["module"])) {
|
||||
$wheres[] = "section = ?";
|
||||
$args[] = $_GET["module"];
|
||||
}
|
||||
if(!empty($_GET["user"])) {
|
||||
$wheres[] = "(username = ? OR address = ?)";
|
||||
$args[] = $_GET["user"];
|
||||
$args[] = $_GET["user"];
|
||||
}
|
||||
if(!empty($_GET["priority"])) {
|
||||
$wheres[] = "priority >= ?";
|
||||
$args[] = int_escape($_GET["priority"]);
|
||||
}
|
||||
$where = "";
|
||||
if(count($wheres) > 0) {
|
||||
$where = "WHERE ";
|
||||
$where .= join(" AND ", $wheres);
|
||||
}
|
||||
$events = $database->get_all("SELECT * FROM score_log $where ORDER BY id DESC LIMIT 50", $args);
|
||||
$this->theme->display_events($events);
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,39 @@
|
||||
<?php
|
||||
|
||||
class LogDatabaseTheme extends Themelet {
|
||||
protected function heie($var) {
|
||||
if(isset($_GET[$var])) return html_escape($_GET[$var]);
|
||||
else return "";
|
||||
}
|
||||
public function display_events($events) {
|
||||
$table = "<table class='zebra'>";
|
||||
$table .= "<thead><th>Time</th><th>Module</th><th>User</th><th>Message</th></thead>";
|
||||
$table .= "<tbody>\n";
|
||||
$table = "
|
||||
<style>
|
||||
.sizedinputs TD INPUT {
|
||||
width: 100%;
|
||||
}
|
||||
</style>
|
||||
<table class='zebra'>
|
||||
<thead>
|
||||
<tr><th>Time</th><th>Module</th><th>User</th><th>Message</th></tr>
|
||||
<form action='".make_link("log/view")."' method='GET'>
|
||||
<tr class='sizedinputs'>
|
||||
<td><input type='text' name='time' value='".$this->heie("time")."'></td>
|
||||
<td><input type='text' name='module' value='".$this->heie("module")."'></td>
|
||||
<td><input type='text' name='user' value='".$this->heie("user")."'></td>
|
||||
<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>
|
||||
<input type='submit' value='Search' style='width: 20%'>
|
||||
</td>
|
||||
</tr>
|
||||
</form>
|
||||
</thead>
|
||||
<tbody>\n";
|
||||
$n = 0;
|
||||
foreach($events as $event) {
|
||||
$oe = ($n++ % 2 == 0) ? "even" : "odd";
|
||||
|
Loading…
x
Reference in New Issue
Block a user