function getMessages($fromMessageId = 0, $messageType = 0, $maxMessags = 1) { $msgType = $messageType; if ($msgType != 0) { $msgType = "WHERE type='" . $msgType . "'"; } else { $msgType = ""; } try { $db = new PDO("sqlite:" . $this->dbName, $this->dbLogin, $this->dbPass); $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } catch (PDOException $errorExcept) { die("Error with Database: " . $errorExcept); } $result = null; // if ($fromMessageId>0) { // $range_sql = "WHERE id>=".$fromMessageId." AND id<".($fromMessageId+$maxMessags)." "; // } else { // $range_sql = ""; // } // $result = $db->query ("SELECT * FROM messages ".$range_sql.$msgType." ORDER BY date DESC LIMIT ".$maxMessags); $result = $db->query("SELECT * FROM messages ORDER BY date DESC LIMIT " . $fromMessageId . "," . $maxMessags); $messagesData = array(); $aid = 0; while ($row = $result->fetchObject()) { $messagesData[$aid] = $row; $user = new class_User(); $userFullName = $user->getUser('id', $messagesData[$aid]->user_id); $messagesData[$aid]->userFullName = $userFullName->login; $aid++; } return $messagesData; }
function authUser($userName, $userPass) { $userName = strip_tags($userName); $userPass = strip_tags($userPass); $userDataRec = new class_User(); $userData = $userDataRec->getUser("login", strtolower($userName)); $passHash = md5($userPass); $passDbHash = $userData->password; $authOk = false; if ($passHash != $passDbHash) { $authOk = false; } else { $authOk = true; } return $authOk; }