q;
$_SESSION["textcaptchaanswers"] = $textcaptcha->a;
} catch (Exception $ex) {
$captchaquestion = "";
}
$form = new FormBuilder("", "", "", "POST");
$form->setID("signupform");
$form->addInput("username", "", "text", true, null, null, "Username", "fas fa-id-card", 6, 4, 100, "[a-zA-Z0-9]+", $Strings->get("Please enter your username (4-100 characters, alphanumeric).", false));
$form->addInput("password", "", "password", true, null, null, "Password", "fas fa-lock", 6, $SETTINGS['min_password_length'], 255, "", $Strings->build("Your password must be at least {n} characters long.", ["n" => $SETTINGS['min_password_length']], false));
$form->addInput("email", "", "email", false, null, null, "Email", "fas fa-envelope", 6, 5, 255, "", $Strings->get("That email address doesn't look right.", false));
$form->addInput("name", "", "text", true, null, null, "Name", "fas fa-user", 6, 2, 200, "", $Strings->get("Enter your name.", false));
if (!empty($captchaquestion)) {
$form->addInput("textcaptcha", "", "text", true, null, null, "$captchaquestion", "fas fa-robot", 12, 1, 200, "", "");
} else {
$form->addHiddenInput("textcaptcha", "DISABLE" . hash("sha1", hash("md5", date("Ymd"))));
}
$form->addHiddenInput("code", empty($_GET["code"]) ? "" : $_GET["code"]);
$form->addHiddenInput("redirect", empty($_GET["redirect"]) ? "" : $_GET["code"]);
if (!empty($SETTINGS['tos_url'])) {
$form->addInput("agree_tos", "1", "checkbox", true, null, null, "I agree to the terms of service");
}
$form->addHiddenInput("submit", "1");
$form->addButton($Strings->get("Create Account", false), "fas fa-user-plus", null, "submit", "savebtn");
?>
get("Create Account");
} else {
echo $title;
}
?>
generate();
} else {
echo $noformcontent;
}
?>
get("Choose a username.", false));
}
$_POST['username'] = strtolower($_POST['username']);
if (!preg_match("/^[a-z0-9]+$/", $_POST['username'])) {
showHTML($Strings->get("Please enter your username (4-100 characters, alphanumeric).", false));
}
if (User::byUsername($_POST['username'])->exists()) {
showHTML($Strings->get("Username already taken, pick another.", false));
}
if (empty($_POST['password'])) {
showHTML($Strings->get("Choose a password.", false));
}
if (strlen($_POST['password']) < $SETTINGS['min_password_length']) {
showHTML($Strings->build("Your password must be at least {n} characters long.", ["n" => $SETTINGS[min_password_length]], false));
}
require_once __DIR__ . "/../lib/worst_passwords.php";
$passrank = checkWorst500List($_POST['password']);
if ($passrank !== FALSE) {
showHTML($Strings->get("That password is one of the most popular and insecure ever, make a better one.", false));
}
if (!empty($_POST['email']) && !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) {
showHTML($Strings->get("That email address doesn't look right.", false));
}
if (!empty($_POST['email']) && $database->has("accounts", ["email" => strtolower($_POST['email'])])) {
showHTML($Strings->get("That email address is already in use.", false));
}
if (empty($_POST['name'])) {
showHTML($Strings->get("Enter your name.", false));
}
if ($_POST["textcaptcha"] != "DISABLE" . hash("sha1", hash("md5", date("Ymd")))) {
$answer = hash("md5", strtolower($_POST["textcaptcha"]));
$ok = false;
foreach ($_SESSION["textcaptchaanswers"] as $ans) {
if ($ans == $answer) {
$ok = true;
}
}
if (!$ok) {
showHTML($Strings->get("CAPTCHA answer incorrect.", false));
}
}
// Create account
$userid = User::add($_POST['username'], $_POST['password'], $_POST['name'], (filter_var($_POST['email'], FILTER_VALIDATE_EMAIL) ? strtolower($_POST['email']) : null));
$signinstr = $Strings->get("sign in", false);
$redirect = urlencode($_POST["redirect"]);
$code = urlencode($_POST["code"]);
if (!empty($code)) {
showHTML(null, false, <<
END
, $Strings->get("Account Created", false));
} else {
showHTML(null, false, <<
END
, $Strings->get("Account Created", false));
}