mirror of
https://github.com/NNTmux/newznab-tmux.git
synced 2026-08-28 17:01:16 +00:00
Update login and Users
This commit is contained in:
+2
-2
@@ -881,7 +881,7 @@ class Users
|
||||
$this->pdo->queryExec(
|
||||
sprintf(
|
||||
'UPDATE users SET lastlogin = NOW() %s WHERE id = %d',
|
||||
($host == '' ? '' : (', host = ' . $this->pdo->escapeString($host))),
|
||||
($host === '' ? '' : (', host = ' . $this->pdo->escapeString($host))),
|
||||
$userID
|
||||
)
|
||||
);
|
||||
@@ -1518,7 +1518,7 @@ class Users
|
||||
)
|
||||
);
|
||||
|
||||
return (int)$result['role'] === (int)$roleID ? true : false;
|
||||
return $result['role'] === $roleID;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+26
-33
@@ -2,53 +2,46 @@
|
||||
|
||||
use nntmux\Captcha;
|
||||
use nntmux\Logging;
|
||||
use nntmux\utility\Utility;
|
||||
|
||||
$page->smarty->assign(['error' => '', 'username' => '', 'rememberme' => '']);
|
||||
|
||||
$captcha = new Captcha($page);
|
||||
|
||||
if ($page->isPostBack()) {
|
||||
if (!isset($_POST["username"]) || !isset($_POST["password"])) {
|
||||
$page->smarty->assign('error', "Please enter your username and password.");
|
||||
} elseif ($captcha->getError() === false) {
|
||||
$username = htmlspecialchars($_POST["username"]);
|
||||
$page->smarty->assign('username', $username);
|
||||
$logging = new Logging(['Settings' => $page->settings]);
|
||||
$res = $page->users->getByUsername($username);
|
||||
if (!isset($_POST['username']) || !isset($_POST['password'])) {
|
||||
$page->smarty->assign('error', 'Please enter your username and password.');
|
||||
} elseif ($captcha->getError() === false) {
|
||||
$username = htmlspecialchars($_POST['username']);
|
||||
$page->smarty->assign('username', $username);
|
||||
$logging = new Logging(['Settings' => $page->settings]);
|
||||
$res = $page->users->getByUsername($username);
|
||||
|
||||
if ($res) {
|
||||
$dis = $page->users->isDisabled($username);
|
||||
if ($dis) {
|
||||
$page->smarty->assign('error', 'Your account has been disabled.');
|
||||
} else if ($page->users->checkPassword($_POST['password'], $res['password'], $res['id'])) {
|
||||
$rememberMe = (isset($_POST['rememberme']) && $_POST['rememberme'] === 'on') ? 1 : 0;
|
||||
$page->users->login($res['id'], $_SERVER['REMOTE_ADDR'], $rememberMe);
|
||||
|
||||
if (!$res) {
|
||||
$res = $page->users->getByEmail($username);
|
||||
}
|
||||
|
||||
if ($res) {
|
||||
if ($dis) {
|
||||
$page->smarty->assign('error', "Your account has been disabled.");
|
||||
} else if ($page->users->checkPassword($_POST["password"], $res["password"], $res['id'])) {
|
||||
$rememberMe = (isset($_POST['rememberme']) && $_POST['rememberme'] == 'on') ? 1 : 0;
|
||||
$page->users->login($res["id"], $_SERVER['REMOTE_ADDR'], $rememberMe);
|
||||
|
||||
if (isset($_POST["redirect"]) && $_POST["redirect"] != "") {
|
||||
header("Location: " . $_POST["redirect"]);
|
||||
} else {
|
||||
header("Location: " . WWW_TOP . $page->settings->home_link);
|
||||
}
|
||||
die();
|
||||
if (isset($_POST['redirect']) && $_POST['redirect'] !== '') {
|
||||
header('Location: ' . $_POST['redirect']);
|
||||
} else {
|
||||
$page->smarty->assign('error', "Incorrect username or password.");
|
||||
$logging->LogBadPasswd($username, $_SERVER['REMOTE_ADDR']);
|
||||
header('Location: ' . WWW_TOP . $page->settings->home_link);
|
||||
}
|
||||
die();
|
||||
} else {
|
||||
$page->smarty->assign('error', "Incorrect username or password.");
|
||||
$page->smarty->assign('error', 'Incorrect username or password.');
|
||||
$logging->LogBadPasswd($username, $_SERVER['REMOTE_ADDR']);
|
||||
}
|
||||
} else {
|
||||
$page->smarty->assign('error', 'Incorrect username or password.');
|
||||
$logging->LogBadPasswd($username, $_SERVER['REMOTE_ADDR']);
|
||||
}
|
||||
}
|
||||
|
||||
$page->smarty->assign('redirect', (isset($_GET['redirect'])) ? $_GET['redirect'] : '');
|
||||
$page->meta_title = "Login";
|
||||
$page->meta_keywords = "Login";
|
||||
$page->meta_description = "Login";
|
||||
$page->smarty->assign('redirect', $_GET['redirect'] ?? '');
|
||||
$page->meta_title = 'Login';
|
||||
$page->meta_keywords = 'Login';
|
||||
$page->meta_description = 'Login';
|
||||
$page->content = $page->smarty->fetch('login.tpl');
|
||||
$page->render();
|
||||
|
||||
Reference in New Issue
Block a user