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); $email = new email("Reset password at " . $_SERVER["SERVER_NAME"], $this->settings->webmaster_email); $email->set_message_fields($replace); $email->message($message); $email->send($user["email"], $user["fullname"]); }
public function send_notification($user) { if (isset($user["id"]) == false) { $type = "created"; } else { $type = "updated"; } if (($message = file_get_contents("../extra/account_" . $type . ".txt")) === false) { return; } $replace = array("USERNAME" => $user["username"], "PASSWORD" => $user["password"], "FULLNAME" => $user["fullname"], "HOSTNAME" => $_SERVER["SERVER_NAME"], "PROTOCOL" => $_SERVER["HTTP_SCHEME"], "TITLE" => $this->settings->head_title); $email = new email("Account " . $type . " at " . $_SERVER["SERVER_NAME"], $this->settings->webmaster_email); $email->set_message_fields($replace); $email->message($message); return $email->send($user["email"], $user["fullname"]); }
public function sign_up($data) { $data = strtr($data, "_-:", "/+="); if (($data = base64_decode($data)) === false) { return false; } $aes = new AES256($this->settings->secret_website_code); if (($data = $aes->decrypt($data)) === false) { return false; } if (($data = json_decode($data, true)) === false) { return false; } if ($data["timestamp"] + HOUR < time()) { return false; } $signature = $data["signature"]; unset($data["signature"]); if ($this->get_signature($data) != $signature) { return false; } if ($this->valid_signup($data) == false) { return false; } $user = array("id" => null, "organisation_id" => 1, "username" => $data["username"], "password" => hash_password($data["password"], $data["username"]), "one_time_key" => null, "status" => USER_STATUS_ACTIVE, "fullname" => $data["fullname"], "email" => $data["email"]); if ($this->db->query("begin") == false) { return false; } if ($this->db->insert("users", $user) == false) { $this->db->query("rollback"); return false; } $user_id = $this->db->last_insert_id; if ($this->db->query("insert into user_role values (%d, %d)", $user_id, USER_ROLE_ID) == false) { $this->db->query("rollback"); return false; } $email = new email("New account registered at " . $_SERVER["SERVER_NAME"], $this->setttings->webmaster_email); $email->set_message_fields(array("FULLNAME" => $data["fullname"], "EMAIL" => $data["email"], "USERNAME" => $data["username"], "HOSTNAME" => $_SERVER["SERVER_NAME"], "IP_ADDR" => $_SERVER["REMOTE_ADDR"])); $email->message(file_get_contents("../extra/account_registered.txt")); $email->send($this->settings->webmaster_email); return $this->db->query("commit") !== false; }