$smarty->assign('community_slogan', $GLOBALS['community_slogan']); /** * Auto Login */ if ($GLOBALS['installed']) { //if the user is not logged in and the remember me cookie is set if (!isset($_SESSION['user_id']) and !empty($_COOKIE["remember_me"])) { require_once ROOT_DIR . '/lib/core/user_old.class.php'; require_once ROOT_DIR . '/lib/core/UserRememberMeList.class.php'; require_once ROOT_DIR . '/lib/extern/phpass/PasswordHash.php'; //get user_id and password from remember_me cookie $remember_me_cookie = explode(",", $_COOKIE["remember_me"]); $user_id = $remember_me_cookie[0]; $password = $remember_me_cookie[1]; //check if the user exists $user_data = User_old::getUserById($user_id); if (!empty($user_data)) { //get the remember_mes of the user from the database $user_remember_me_list = new UserRememberMeList($user_id, "create_date", "desc"); $user_remember_me_list = $user_remember_me_list->getUserRememberMeList(); //check if any remember me matches the password stored in the cookie $phpass = new PasswordHash(8, false); foreach ($user_remember_me_list as $user_remember_me) { if ($phpass->CheckPassword($password, $user_remember_me->getPassword())) { //if a remember me matches, then login and set a new random password on the remember me //store the session-id to the database $stmt = DB::getInstance()->prepare("UPDATE users SET session_id = ? WHERE id = ?"); $stmt->execute(array(session_id(), $user_data['id'])); //store the $_SESSION['user_id'] = $user_data['id']; //generate long random password