engelsystem/includes/model/LogEntries_model.php

39 lines
951 B
PHP
Raw Normal View History

2012-12-26 14:02:27 +01:00
<?php
/**
* Creates a log entry.
2013-10-13 00:52:44 +02:00
*
2012-12-26 14:02:27 +01:00
* @param $nick Username
2013-10-13 00:52:44 +02:00
* @param $message Log
* Message
2012-12-26 14:02:27 +01:00
*/
function LogEntry_create($nick, $message) {
2014-12-28 13:44:56 +01:00
return sql_query("INSERT INTO `LogEntries` SET `timestamp`='" . sql_escape(time()) . "', `nick`='" . sql_escape($nick) . "', `message`='" . sql_escape($message) . "'");
2012-12-26 14:02:27 +01:00
}
2012-12-27 02:18:56 +01:00
/**
2015-06-07 20:42:01 +02:00
* Returns log entries with maximum count of 10000.
2012-12-27 02:18:56 +01:00
*/
2012-12-26 20:36:31 +01:00
function LogEntries() {
2014-12-15 19:07:53 +01:00
return sql_select("SELECT * FROM `LogEntries` ORDER BY `timestamp` DESC LIMIT 10000");
2012-12-26 20:36:31 +01:00
}
2014-12-15 21:23:57 +01:00
/**
* Returns log entries filtered by a keyword
*/
function LogEntries_filter($keyword) {
2016-09-30 18:49:33 +02:00
if ($keyword == "") {
return LogEntries();
}
2014-12-15 21:23:57 +01:00
return sql_select("SELECT * FROM `LogEntries` WHERE `nick` LIKE '%" . sql_escape($keyword) . "%' OR `message` LIKE '%" . sql_escape($keyword) . "%' ORDER BY `timestamp` DESC");
}
2015-06-07 20:12:18 +02:00
/**
* Delete all log entries.
*/
function LogEntries_clear_all() {
return sql_query("TRUNCATE `LogEntries`");
}
2014-12-15 21:23:57 +01:00
?>