/** * Changes the player password * * @param string $newpassword the new password! * @return bool success */ public function update_password($newpassword) { $login_salt = substr(md5(uniqid(rand(), true)), 0, 5); $update_password['password'] = md5($newpassword . $login_salt); $update_password['login_salt'] = $login_salt; $password_query = $this->db->AutoExecute('players', $update_password, 'UPDATE', 'id = ' . $this->id); $this->password = $update_password['password']; if ($this->id == $_COOKIE['logged_in_user_id']) { $hash = md5($this->id . $this->password . $this->login_rand); $_SESSION['hash'] = $hash; code_cookie::set("cookie_hash", $hash, mktime() + 2592000); } if ($password_query) { return true; } else { return false; } }
/** * sets the player id * * @param int $id player id */ public static function set_id($id) { self::$id = $id; }