Zeile 41 | Zeile 41 |
---|
*/ public $login_data = array();
|
*/ public $login_data = array();
|
| /** * @var bool */
|
public $captcha_verified = true;
|
public $captcha_verified = true;
|
| /** * @var bool|captcha */
|
private $captcha = false;
|
private $captcha = false;
|
| /** * @var int */
|
public $username_method = null;
|
public $username_method = null;
|
| /** * @param int $check_captcha */
|
function verify_attempts($check_captcha = 0)
|
function verify_attempts($check_captcha = 0)
|
{ global $db, $mybb;
| { global $db, $mybb;
|
$user = &$this->data;
if($check_captcha) { if(!isset($mybb->cookies['loginattempts']))
|
$user = &$this->data;
if($check_captcha) { if(!isset($mybb->cookies['loginattempts']))
|
{
| {
|
$mybb->cookies['loginattempts'] = 0; } if($mybb->settings['failedcaptchalogincount'] > 0 && ($user['loginattempts'] > $mybb->settings['failedcaptchalogincount'] || (int)$mybb->cookies['loginattempts'] > $mybb->settings['failedcaptchalogincount']))
| $mybb->cookies['loginattempts'] = 0; } if($mybb->settings['failedcaptchalogincount'] > 0 && ($user['loginattempts'] > $mybb->settings['failedcaptchalogincount'] || (int)$mybb->cookies['loginattempts'] > $mybb->settings['failedcaptchalogincount']))
|
Zeile 66 | Zeile 78 |
---|
} } }
|
} } }
|
| /** * @return bool */
|
function verify_captcha() { global $db, $mybb;
|
function verify_captcha() { global $db, $mybb;
|
$user = &$this->data;
| $user = &$this->data;
|
if($user['imagestring'] || $mybb->settings['captchaimage'] != 1) { // Check their current captcha input - if correct, hide the captcha input area
| if($user['imagestring'] || $mybb->settings['captchaimage'] != 1) { // Check their current captcha input - if correct, hide the captcha input area
|
Zeile 80 | Zeile 95 |
---|
$this->captcha = new captcha;
if($this->captcha->validate_captcha() == false)
|
$this->captcha = new captcha;
if($this->captcha->validate_captcha() == false)
|
{
| {
|
// CAPTCHA validation failed foreach($this->captcha->get_errors() as $error) { $this->set_error($error); } return false;
|
// CAPTCHA validation failed foreach($this->captcha->get_errors() as $error) { $this->set_error($error); } return false;
|
}
| }
|
else { $this->captcha_verified = true;
| else { $this->captcha_verified = true;
|
Zeile 95 | Zeile 110 |
---|
} } else if($mybb->input['quick_login'] == 1 && $mybb->input['quick_password'] && $mybb->input['quick_username'])
|
} } else if($mybb->input['quick_login'] == 1 && $mybb->input['quick_password'] && $mybb->input['quick_username'])
|
{
| {
|
$this->set_error('regimagerequired'); return false; } else { $this->set_error('regimageinvalid');
|
$this->set_error('regimagerequired'); return false; } else { $this->set_error('regimageinvalid');
|
return false; }
| return false; }
|
}
|
}
|
| /** * @return bool */
|
function verify_username() { $this->get_login_data();
| function verify_username() { $this->get_login_data();
|
Zeile 115 | Zeile 133 |
---|
$this->invalid_combination(); return false; }
|
$this->invalid_combination(); return false; }
|
| return true;
|
}
|
}
|
| /** * @param bool $strict * * @return bool */
|
function verify_password($strict = true) { global $db, $mybb, $plugins;
| function verify_password($strict = true) { global $db, $mybb, $plugins;
|
Zeile 138 | Zeile 163 |
---|
$plugins->run_hooks('datahandler_login_verify_password_start', $args);
$user = &$this->data;
|
$plugins->run_hooks('datahandler_login_verify_password_start', $args);
$user = &$this->data;
|
$password = md5($user['password']);
| |
if(!$this->login_data['uid'] || $this->login_data['uid'] && !$this->login_data['salt'] && $strict == false) {
| if(!$this->login_data['uid'] || $this->login_data['uid'] && !$this->login_data['salt'] && $strict == false) {
|
Zeile 149 | Zeile 172 |
---|
if($strict == true) { if(!$this->login_data['salt'])
|
if($strict == true) { if(!$this->login_data['salt'])
|
{
| {
|
// Generate a salt for this user and assume the password stored in db is a plain md5 password
|
// Generate a salt for this user and assume the password stored in db is a plain md5 password
|
$this->login_data['salt'] = generate_salt(); $this->login_data['password'] = salt_password($this->login_data['password'], $this->login_data['salt']);
$sql_array = array( "salt" => $this->login_data['salt'], "password" => $this->login_data['password'] );
$db->update_query("users", $sql_array, "uid = '{$this->login_data['uid']}'");
| $password_fields = create_password($this->login_data['password']); $this->login_data = array_merge($this->login_data, $password_fields); $db->update_query("users", $password_fields, "uid = '{$this->login_data['uid']}'");
|
}
if(!$this->login_data['loginkey'])
| }
if(!$this->login_data['loginkey'])
|
Zeile 171 | Zeile 188 |
---|
);
$db->update_query("users", $sql_array, "uid = '{$this->login_data['uid']}'");
|
);
$db->update_query("users", $sql_array, "uid = '{$this->login_data['uid']}'");
|
} }
$salted_password = md5(md5($this->login_data['salt']).$password);
$plugins->run_hooks('datahandler_login_verify_password_end', $args);
| } }
$plugins->run_hooks('datahandler_login_verify_password_end', $args);
|
|
|
if($salted_password !== $this->login_data['password'])
| if(!verify_user_password($this->login_data, $user['password']))
|
{ $this->invalid_combination(true); return false; }
|
{ $this->invalid_combination(true); return false; }
|
| return true;
|
}
|
}
|
| /** * @param bool $show_login_attempts */
|
function invalid_combination($show_login_attempts = false) { global $db, $lang, $mybb;
| function invalid_combination($show_login_attempts = false) { global $db, $lang, $mybb;
|
Zeile 198 | Zeile 218 |
---|
$login_text = ''; if($show_login_attempts) {
|
$login_text = ''; if($show_login_attempts) {
|
if($mybb->settings['failedlogincount'] != 0 && $mybb->settings['failedlogintext'] == 1)
| if($mybb->settings['failedlogincount'] != 0 && $mybb->settings['failedlogintext'] == 1 && $this->login_data['uid'] != 0)
|
{
|
{
|
$logins = login_attempt_check(false) + 1;
| $logins = login_attempt_check($this->login_data['uid'], false) + 1;
|
$login_text = $lang->sprintf($lang->failed_login_again, $mybb->settings['failedlogincount'] - $logins); } }
| $login_text = $lang->sprintf($lang->failed_login_again, $mybb->settings['failedlogincount'] - $logins); } }
|
Zeile 226 | Zeile 246 |
---|
$user = &$this->data;
$options = array(
|
$user = &$this->data;
$options = array(
|
'fields' => array('uid', 'username', 'password', 'salt', 'loginkey', 'coppauser', 'usergroup', 'loginattempts'),
| 'fields' => '*',
|
'username_method' => (int)$settings['username_method'] );
| 'username_method' => (int)$settings['username_method'] );
|
Zeile 236 | Zeile 256 |
---|
}
$this->login_data = get_user_by_username($user['username'], $options);
|
}
$this->login_data = get_user_by_username($user['username'], $options);
|
}
| }
|
|
|
| /** * @return bool */
|
function validate_login() { global $plugins, $mybb;
| function validate_login() { global $plugins, $mybb;
|
Zeile 272 | Zeile 295 |
---|
return true; }
|
return true; }
|
| /** * @return bool true */
|
function complete_login() { global $plugins, $db, $mybb, $session;
| function complete_login() { global $plugins, $db, $mybb, $session;
|
Zeile 283 | Zeile 309 |
---|
// Login to MyBB my_setcookie('loginattempts', 1); my_setcookie("sid", $session->sid, -1, true);
|
// Login to MyBB my_setcookie('loginattempts', 1); my_setcookie("sid", $session->sid, -1, true);
|
$ip_address = $db->escape_binary($session->packedip); $db->delete_query("sessions", "ip = {$ip_address} AND sid != '{$session->sid}'");
| |
$newsession = array( "uid" => $user['uid'], );
|
$newsession = array( "uid" => $user['uid'], );
|
|
|
$db->update_query("sessions", $newsession, "sid = '{$session->sid}'"); $db->update_query("users", array("loginattempts" => 1), "uid = '{$user['uid']}'");
| $db->update_query("sessions", $newsession, "sid = '{$session->sid}'"); $db->update_query("users", array("loginattempts" => 1), "uid = '{$user['uid']}'");
|
Zeile 300 | Zeile 323 |
---|
$remember = -1; }
|
$remember = -1; }
|
my_setcookie("mybbuser", $user['uid']."_".$user['loginkey'], $remember, true);
| my_setcookie("mybbuser", $user['uid']."_".$user['loginkey'], $remember, true, "lax");
|
if($this->captcha !== false) { $this->captcha->invalidate_captcha();
| if($this->captcha !== false) { $this->captcha->invalidate_captcha();
|