summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelix Favre <gnomus@gnomus.de>2014-12-15 21:23:57 +0100
committerFelix Favre <gnomus@gnomus.de>2014-12-15 21:23:57 +0100
commitbe1bb5fbeb2cb93105b12cc9d9b4cae676f59a7f (patch)
tree85615b140784a093a5db3439132e489c5047f992
parent388dd0e1369755875a8eeb2259291f57d0a92990 (diff)
add simple search to log view
-rw-r--r--includes/model/LogEntries_model.php9
-rw-r--r--includes/pages/admin_log.php20
2 files changed, 24 insertions, 5 deletions
diff --git a/includes/model/LogEntries_model.php b/includes/model/LogEntries_model.php
index 49e063dc..2e8a8cf7 100644
--- a/includes/model/LogEntries_model.php
+++ b/includes/model/LogEntries_model.php
@@ -18,4 +18,11 @@ function LogEntries() {
return sql_select("SELECT * FROM `LogEntries` ORDER BY `timestamp` DESC LIMIT 10000");
}
-?> \ No newline at end of file
+/**
+ * Returns log entries filtered by a keyword
+ */
+function LogEntries_filter($keyword) {
+ return sql_select("SELECT * FROM `LogEntries` WHERE `nick` LIKE '%" . sql_escape($keyword) . "%' OR `message` LIKE '%" . sql_escape($keyword) . "%' ORDER BY `timestamp` DESC");
+}
+
+?>
diff --git a/includes/pages/admin_log.php b/includes/pages/admin_log.php
index 6a687e17..70b74d17 100644
--- a/includes/pages/admin_log.php
+++ b/includes/pages/admin_log.php
@@ -4,20 +4,32 @@ function admin_log_title() {
}
function admin_log() {
- $log_entries_source = LogEntries();
+
+ if (isset($_POST['keyword'])) {
+ $filter = $_POST['keyword'];
+ $log_entries_source = LogEntries_filter($_POST['keyword']);
+ } else {
+ $filter = "";
+ $log_entries_source = LogEntries();
+ }
+
$log_entries = array();
foreach ($log_entries_source as $log_entry) {
$log_entry['date'] = date("d.m.Y H:i", $log_entry['timestamp']);
$log_entries[] = $log_entry;
}
-
+
return page_with_title(admin_log_title(), array(
msg(),
+ form(array(
+ form_text('keyword', _("Suche"), $filter),
+ form_submit(_("Suche"), "Go")
+ )),
table(array(
'date' => "Time",
'nick' => "Angel",
- 'message' => "Log Entry"
- ), $log_entries)
+ 'message' => "Log Entry"
+ ), $log_entries)
));
}
?>