Update rss and user handling.

This commit is contained in:
DariusIII
2015-06-08 03:29:38 +02:00
parent 402af5c784
commit 25b488ed4e
2 changed files with 31 additions and 11 deletions
+10 -4
View File
@@ -145,8 +145,13 @@ class BasePage
if ($sab->integratedBool !== false && $sab->url != '' && $sab->apikey != '') {
$this->smarty->assign('sabapikeytype', $sab->apikeytype);
}
if ($this->userdata["role"] == Users::ROLE_ADMIN)
$this->smarty->assign('isadmin',"true");
switch ((int)$this->userdata['role']) {
case Users::ROLE_ADMIN:
$this->smarty->assign('isadmin', 'true');
break;
case Users::ROLE_MODERATOR:
$this->smarty->assign('ismod', 'true');
}
if ($this->userdata["hideads"] == "1")
{
@@ -159,8 +164,9 @@ class BasePage
}
else
{
$this->smarty->assign('isadmin',"false");
$this->smarty->assign('loggedin',"false");
$this->smarty->assign('isadmin', 'false');
$this->smarty->assign('ismod', 'false');
$this->smarty->assign('loggedin', 'false');
$this->floodCheck();
$this->handleCaptcha();
+21 -7
View File
@@ -404,12 +404,22 @@ class Users
$this->pdo->queryExec(sprintf("update users set grabs = grabs + %d where id = %d ", $num, $id));
}
public function getByIdAndRssToken($id, $rsstoken)
/**
* Check if the user is in the database, and if their API key is good, return user data if so.
*
* @param int $userID ID of the user.
* @param string $rssToken API key.
*
* @return bool|array
*/
public function getByIdAndRssToken($userID, $rssToken)
{
$user = $this->getById($userID);
if ($user === false) {
return false;
}
$res = $this->getById($id);
return ($res && $res["rsstoken"] == $rsstoken ? $res : null);
return ($user['rsstoken'] != $rssToken ? false : $user);
}
public function getById($id)
@@ -569,18 +579,22 @@ class Users
return $this->pdo->queryInsert($sql);
}
/**
* Verify if the user is logged in.
*
* @return bool
*/
public function isLoggedIn()
{
if (isset($_SESSION['uid'])) {
return true;
} elseif (isset($_COOKIE['uid']) && isset($_COOKIE['idh'])) {
} else if (isset($_COOKIE['uid']) && isset($_COOKIE['idh'])) {
$u = $this->getById($_COOKIE['uid']);
if (($_COOKIE['idh'] == $this->hashSHA1($u["userseed"] . $_COOKIE['uid'])) && ($u["role"] != Users::ROLE_DISABLED)) {
if (($_COOKIE['idh'] == $this->hashSHA1($u["userseed"] . $_COOKIE['uid'])) && ($u["role"] != self::ROLE_DISABLED)) {
$this->login($_COOKIE['uid'], $_SERVER['REMOTE_ADDR']);
}
}
return isset($_SESSION['uid']);
}