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.php18
-rw-r--r--includes/model/User_model.php7
3 files changed, 25 insertions, 7 deletions
diff --git a/includes/model/LogEntries_model.php b/includes/model/LogEntries_model.php
index f8a552f2..1fa97356 100644
--- a/includes/model/LogEntries_model.php
+++ b/includes/model/LogEntries_model.php
@@ -6,17 +6,14 @@
* @param $message Log Message
*/
function LogEntry_create($nick, $message) {
- $timestamp = time();
-
- sql_query("INSERT INTO `LogEntries` SET `timestamp`=" . sql_escape($timestamp) . ", `nick`='" . sql_escape($nick) . "', `message`='" . sql_escape($message) . "'");
+ return sql_query("INSERT INTO `LogEntries` SET `timestamp`=" . sql_escape(time()) . ", `nick`='" . sql_escape($nick) . "', `message`='" . sql_escape($message) . "'");
}
/**
* Returns log entries of the last 24 hours with maximum count of 1000.
*/
function LogEntries() {
- $log_entries_source = sql_select("SELECT * FROM `LogEntries` WHERE `timestamp` > " . (time() - 24*60*60) . " ORDER BY `timestamp` DESC LIMIT 1000");
- return $log_entries_source;
+ return sql_select("SELECT * FROM `LogEntries` WHERE `timestamp` > " . (time() - 24*60*60) . " ORDER BY `timestamp` DESC LIMIT 1000");
}
diff --git a/includes/model/Sprache_model.php b/includes/model/Sprache_model.php
new file mode 100644
index 00000000..55683411
--- /dev/null
+++ b/includes/model/Sprache_model.php
@@ -0,0 +1,18 @@
+<?php
+
+/**
+ * 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)
+ return false;
+ 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 4e833aef..7eb31e8e 100644
--- a/includes/model/User_model.php
+++ b/includes/model/User_model.php
@@ -1,11 +1,12 @@
<?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)
+ return false;
if(count($user_source) > 0)
return $user_source[0];
return null;
@@ -31,7 +32,9 @@ function User_by_api_key($api_key) {
*/
function User_reset_api_key(&$user) {
$user['api_key'] = md5($user['Nick'] . time() . rand());
- sql_query("UPDATE `User` SET `api_key`='" . sql_escape($user['api_key']) . "' WHERE `UID`='" . sql_escape($user['UID']) . "' LIMIT 1");
+ $result = sql_query("UPDATE `User` SET `api_key`='" . sql_escape($user['api_key']) . "' WHERE `UID`='" . sql_escape($user['UID']) . "' LIMIT 1");
+ if($result === false)
+ return false;
engelsystem_log("API key resetted.");
}