Location: PHPKode > projects > Banshee PHP Framework > controllers/password.php
<?php
	class password_controller extends controller {
		public function execute() {
			if ((empty($_GET["key"]) == false) && ($_GET["key"] == $_SESSION["reset_password_key"])) {
				$this->output->add_javascript("md5.js");
				$this->output->add_javascript("password.js");

				$this->output->add_tag("reset", $_GET["key"]);
			} else if ($_SERVER["REQUEST_METHOD"] == "POST") {
				if ($_POST["submit_button"] == "Reset password") {
					/* Send password link
					 */
					if (($user = $this->model->get_user($_POST["username"], $_POST["email"])) != false) {
						$_SESSION["reset_password_key"] = md5(microtime().rand(0, 100000));
						$_SESSION["reset_password_username"] = $_POST["username"];

						$this->model->send_password_link($user, $_SESSION["reset_password_key"]);
					}
					$this->output->add_tag("link_sent");
				} else if ($_POST["submit_button"] == "Save password") {
					/* Save password
					 */
					if ($this->model->password_oke($_POST) == false) {
						$this->output->add_tag("reset", $_POST["key"]);
					} else if ($this->model->save_password($_SESSION["reset_password_username"], $_POST) == false) {
						$this->output->add_message("Error while saving password.");
						$this->output->add_tag("reset", $_POST["key"]);
					} else {
						$this->output->add_tag("result", "Password has been saved.", array("url" => LOGIN_PAGE));
						unset($_SESSION["reset_password_key"]);
						unset($_SESSION["reset_password_username"]);
					}
				} else {
					$this->output->add_tag("result", "Huh?", array("url" => "password"));
				}
			} else {
				$this->output->add_tag("request");
			}
		}
	}
?>
Return current item: Banshee PHP Framework