summaryrefslogtreecommitdiff
path: root/includes/model/LogEntries_model.php
blob: 09bd03dc014ea18a41e6962267ed4636d2405a86 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php

/**
 * Creates a log entry.
 *
 * @param $nick Username
 * @param $message Log
 *          Message
 */
function LogEntry_create($nick, $message) {
  return sql_query("INSERT INTO `LogEntries` SET `timestamp`='" . sql_escape(time()) . "', `nick`='" . sql_escape($nick) . "', `message`='" . sql_escape($message) . "'");
}

/**
 * Returns log entries with maximum count of 10000.
 */
function LogEntries() {
  return sql_select("SELECT * FROM `LogEntries` ORDER BY `timestamp` DESC LIMIT 10000");
}

/**
 * Returns log entries filtered by a keyword
 */
function LogEntries_filter($keyword) {
  if ($keyword == "") {
    return LogEntries();
  }
  return sql_select("SELECT * FROM `LogEntries` WHERE `nick` LIKE '%" . sql_escape($keyword) . "%' OR `message` LIKE '%" . sql_escape($keyword) . "%' ORDER BY `timestamp` DESC");
}

/**
 * Delete all log entries.
 */
function LogEntries_clear_all() {
  return sql_query("TRUNCATE `LogEntries`");
}

?>