Revision 931
Added by doc almost 16 years ago
class.login.php | ||
---|---|---|
323 | 323 |
if(isset($_COOKIE['REMEMBER_KEY']) AND $_COOKIE['REMEMBER_KEY'] != '') { |
324 | 324 |
// Check if the remember key is correct |
325 | 325 |
$database = new database(); |
326 |
$check_query = $database->query("SELECT user_id FROM ".$this->USERS_TABLE." WHERE remember_key = '".$this->get_safe_remember_key()."' LIMIT 1"); |
|
326 |
$sql = "SELECT `user_id` FROM `" . $this->USERS_TABLE . "` WHERE `remember_key` = '"; |
|
327 |
$sql .= $this->get_safe_remember_key() . "' LIMIT 1"; |
|
328 |
$check_query = $database->query($sql); |
|
329 |
|
|
327 | 330 |
if($check_query->numRows() > 0) { |
328 | 331 |
$check_fetch = $check_query->fetchRow(); |
329 | 332 |
$user_id = $check_fetch['user_id']; |
... | ... | |
407 | 410 |
} |
408 | 411 |
} |
409 | 412 |
|
410 |
// convert "REMEMBER_KEY" to a number and then repad |
|
411 |
// any non numeric character will cause intval to return null thus returning 11 0's |
|
413 |
// sanities the REMEMBER_KEY cookie to avoid SQL injection |
|
412 | 414 |
function get_safe_remember_key() { |
413 |
return str_pad(intval(substr($_COOKIE['REMEMBER_KEY'],0,11)),11,"0",STR_PAD_LEFT); // SQL Injection prevention |
|
415 |
if (!((strlen($_COOKIE['REMEMBER_KEY']) == 23) && (substr($_COOKIE['REMEMBER_KEY'], 11, 1) == '_'))) return ''; |
|
416 |
// create a clean cookie (XXXXXXXXXXX_YYYYYYYYYYY) where X:= numeric, Y:= hash |
|
417 |
$clean_cookie = sprintf('%011d', (int) substr($_COOKIE['REMEMBER_KEY'], 0, 11)) . substr($_COOKIE['REMEMBER_KEY'], 11); |
|
418 |
return ($clean_cookie == $_COOKIE['REMEMBER_KEY']) ? $this->add_slashes($clean_cookie) : ''; |
|
414 | 419 |
} |
415 | 420 |
|
416 | 421 |
// Warn user that they have had to many login attemps |
Also available in: Unified diff
Fixed bug with smart login option (remember me) (ticket #689)