summaryrefslogtreecommitdiff
path: root/includes/model
diff options
context:
space:
mode:
Diffstat (limited to 'includes/model')
-rw-r--r--includes/model/LogEntries_model.php7
-rw-r--r--includes/model/Sprache_model.php14
-rw-r--r--includes/model/User_model.php15
3 files changed, 24 insertions, 12 deletions
diff --git a/includes/model/LogEntries_model.php b/includes/model/LogEntries_model.php
index 1fa97356..30e2b58c 100644
--- a/includes/model/LogEntries_model.php
+++ b/includes/model/LogEntries_model.php
@@ -2,8 +2,10 @@
/**
* Creates a log entry.
+ *
* @param $nick Username
- * @param $message Log Message
+ * @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) . "'");
@@ -13,8 +15,7 @@ function LogEntry_create($nick, $message) {
* Returns log entries of the last 24 hours with maximum count of 1000.
*/
function LogEntries() {
- return sql_select("SELECT * FROM `LogEntries` WHERE `timestamp` > " . (time() - 24*60*60) . " ORDER BY `timestamp` DESC LIMIT 1000");
+ return sql_select("SELECT * FROM `LogEntries` WHERE `timestamp` > " . (time() - 24 * 60 * 60) . " ORDER BY `timestamp` DESC LIMIT 1000");
}
-
?> \ No newline at end of file
diff --git a/includes/model/Sprache_model.php b/includes/model/Sprache_model.php
index 55683411..0b18dbca 100644
--- a/includes/model/Sprache_model.php
+++ b/includes/model/Sprache_model.php
@@ -2,17 +2,23 @@
/**
* Load a string by key.
+ *
* @param string $textid
* @param string $sprache
*/
function Sprache($textid, $sprache) {
- $sprache_source = sql_select("SELECT * FROM `Sprache` WHERE `TextID`='" . sql_escape($textid) . "' AND `Sprache`='" . sql_escape($sprache) . "' LIMIT 1");
- if($sprache_source === false)
+ $sprache_source = sql_select("
+ SELECT *
+ FROM `Sprache`
+ WHERE `TextID`='" . sql_escape($textid) . "'
+ AND `Sprache`='" . sql_escape($sprache) . "'
+ LIMIT 1
+ ");
+ if ($sprache_source === false)
return false;
- if(count($sprache_source) == 1)
+ if (count($sprache_source) == 1)
return $sprache_source[0];
return null;
}
-
?> \ No newline at end of file
diff --git a/includes/model/User_model.php b/includes/model/User_model.php
index 7eb31e8e..884aeae8 100644
--- a/includes/model/User_model.php
+++ b/includes/model/User_model.php
@@ -1,25 +1,29 @@
<?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($user_source === false)
+ if ($user_source === false)
return false;
- if(count($user_source) > 0)
+ if (count($user_source) > 0)
return $user_source[0];
return null;
}
/**
* Returns User by api_key.
- * @param string $api_key User api key
+ *
+ * @param string $api_key
+ * User api key
* @return Matching user, null or false on error
*/
function User_by_api_key($api_key) {
$user = sql_select("SELECT * FROM `User` WHERE `api_key`='" . sql_escape($api_key) . "' LIMIT 1");
- if($user === false)
+ if ($user === false)
return false;
if (count($user) == 0)
return null;
@@ -28,12 +32,13 @@ function User_by_api_key($api_key) {
/**
* Generates a new api key for given user.
+ *
* @param User $user
*/
function User_reset_api_key(&$user) {
$user['api_key'] = md5($user['Nick'] . time() . rand());
$result = sql_query("UPDATE `User` SET `api_key`='" . sql_escape($user['api_key']) . "' WHERE `UID`='" . sql_escape($user['UID']) . "' LIMIT 1");
- if($result === false)
+ if ($result === false)
return false;
engelsystem_log("API key resetted.");
}