Location: PHPKode > projects > Banshee PHP Framework > models/password.php
<?php
	class password_model extends model {
		public function get_user($username, $email) {
			$query = "select * from users where username=%s and email=%s";

			if (($result = $this->db->execute($query, $username, $email)) == false) {
				return false;
			}

			return $result[0];
		}

		public function send_password_link($user, $key) {
			$message = file_get_contents("../extra/reset_password.txt");
			$replace = array(
				"FULLNAME" => $user["fullname"],
				"HOSTNAME" => $_SERVER["SERVER_NAME"],
				"KEY"      => $key);
			foreach ($replace as $key => $value) {
				$message = str_replace("[".$key."]", $value, $message);
			}

			$email = new email("Reset password at ".$_SERVER["SERVER_NAME"], "no-reply@".$_SERVER["SERVER_NAME"]);
			$email->message($message);
			$email->send($user["email"], $user["fullname"]);
		}

		public function password_oke($password) {
			$result = true;

			if ($password["password"] == md5("")) {
				$this->output->add_message("Password can't be empty.");
				$result = false;
			} else if ($password["password"] != $password["repeat"]) {
				$this->output->add_message("Passwords are not the same.");
				$result = false;
			}

			return $result;
		}

		public function save_password($username, $password) {
			if ($username == "") {
				return false;
			} else if (is_false($password["password_hashed"])) {
				$password["password"] = md5($password["password"]);
			}

			$query = "update users set password=%s where username=%s";

			return $this->db->query($query, $password["password"], $username) != false;
		}
	}
?>
Return current item: Banshee PHP Framework