Example #1
0
 public static function forgot($uEmail)
 {
     global $database;
     $sAttempt = User::check_attempts("forgot password");
     if (is_array($sAttempt)) {
         return $sAttempt;
     }
     $sAttempt = User::add_attempt("forgot password");
     if ($sResult = $database->CachedQuery("SELECT * FROM accounts WHERE `email_address` = :EmailAddress", array('EmailAddress' => $uEmail))) {
         $sForgotCode = random_string(60);
         $sUser = new User($sResult->data[0]["id"]);
         $sUser->uForgot = $sForgotCode;
         $sUser->InsertIntoDatabase();
         $sVariable = array("email" => urlencode($sUser->sEmailAddress), "forgot_code" => urlencode($sForgotCode));
         $sSend = Core::SendEmail($sUser->sEmailAddress, "Feathur Forgot Password", "forgot", $sVariable);
     }
     if (!is_array($sSend)) {
         return $sResult = array("content" => "Check your email for an activation link.", "type" => "succesbox");
     } else {
         return $sResult = array("content" => $sSend["content"], "type" => "alertbox");
     }
 }
Example #2
0
    if (empty($_POST['email']) || !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) {
        flash_error("You did not enter a valid e-mail address.");
    } elseif (User::CheckIfEmailExists($_POST['email'])) {
        flash_error("The e-mail address you entered is already in use. Did you <a href=\"/forgot-password\">forget your password</a>?");
    }
    if (empty($_POST['password']) || strlen($_POST['password']) < 8) {
        flash_error("You did not enter a valid password. Your password has to be at least 8 characters.");
    } elseif (empty($_POST['password2']) || $_POST['password'] != $_POST['password2']) {
        flash_error("The passwords you entered did not match.");
    }
    if (!empty($_POST['displayname']) && User::CheckIfDisplayNameExists($_POST['displayname'])) {
        flash_error("The (display) name you entered is already in use. Please pick a different name. You can also just use your nickname!");
    }
    if (count(get_errors(false)) == 0) {
        $sUser = new User(0);
        $sUser->uUsername = $_POST['username'];
        $sUser->uDisplayName = !empty($_POST['displayname']) ? $_POST['displayname'] : $_POST['username'];
        $sUser->uPassword = $_POST['password'];
        $sUser->uEmailAddress = $_POST['email'];
        $sUser->uActivationKey = random_string(16);
        $sUser->GenerateSalt();
        $sUser->GenerateHash();
        $sUser->InsertIntoDatabase();
        send_mail($_POST['email'], "Please confirm your registration at ReDonate.", NewTemplater::Render("email/signup.txt", $locale->strings, array("confirmation-url" => "http://redonate.net/confirm/{$sUser->sEmailAddress}/{$sUser->sActivationKey}/", "name" => $sUser->uDisplayName)), NewTemplater::Render("email/layout.html", $locale->strings, array("contents" => NewTemplater::Render("email/signup.html", $locale->strings, array("confirmation-url" => "http://redonate.net/confirm/{$sUser->sEmailAddress}/{$sUser->sActivationKey}/", "name" => $sUser->sDisplayName)))));
        $sPageContents = NewTemplater::Render("signup/success", $locale->strings, array());
        $sPageTitle = "Thanks for signing up!";
        return;
    }
}
$sPageContents = NewTemplater::Render("signup/form", $locale->strings, array());
$sPageTitle = "Sign up";