#28 begin log
parent
213b6261c8
commit
0dabaa505e
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
if(sql_num_query("SHOW TABLES LIKE 'LogEntries'") == 0) {
|
||||
sql_query("CREATE TABLE `LogEntries` (
|
||||
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
|
||||
`timestamp` INT NOT NULL ,
|
||||
`nick` VARCHAR( 23 ) NOT NULL ,
|
||||
`message` TEXT NOT NULL ,
|
||||
INDEX ( `timestamp` )
|
||||
) ENGINE = InnoDB;");
|
||||
$applied = true;
|
||||
}
|
||||
|
||||
if(sql_num_query("SHOW TABLES LIKE 'ChangeLog'") == 0) {
|
||||
sql_query("DROP TABLE `ChangeLog`");
|
||||
$applied = true;
|
||||
}
|
||||
|
||||
?>
|
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Creates a log entry.
|
||||
* @param $nick Username
|
||||
* @param $message Log Message
|
||||
*/
|
||||
function LogEntry_create($nick, $message) {
|
||||
$timestamp = date();
|
||||
|
||||
sql_query("INSERT INTO `LogEntries` SET `timestamp`=" . sql_escape($timestamp) . ", `nick`='" . sql_escape($nick) . "', `message`='" . sql_escape($message) . "'");
|
||||
}
|
||||
|
||||
|
||||
?>
|
@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Returns user by id.
|
||||
* @param $id UID
|
||||
*/
|
||||
function User($id) {
|
||||
$user_source = sql_select("SELECT * FROM `User` WHERE `UID`=" . sql_escape($id) . " LIMIT 1");
|
||||
if(count($user_source) > 0)
|
||||
return $user_source[0];
|
||||
return null;
|
||||
}
|
||||
|
||||
?>
|
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Write a log entry. This should be used to log user's activity.
|
||||
* @param $message
|
||||
*/
|
||||
function engelsystem_log($message) {
|
||||
global $user;
|
||||
|
||||
if(isset($user)) {
|
||||
$nick = $user['Nick'];
|
||||
} else {
|
||||
$nick = "Guest";
|
||||
}
|
||||
|
||||
LogEntry_create($nick, $message);
|
||||
}
|
||||
|
||||
?>
|
Loading…
Reference in New Issue