check username only if not emtpy

This commit is contained in:
creme 2020-02-02 12:03:39 +01:00
parent 7c5460b4ff
commit 4ef60ba4b5
Signed by: creme
GPG Key ID: C147C3B7FBDF08D0
1 changed files with 14 additions and 10 deletions

View File

@ -62,24 +62,25 @@ if (isset($_REQUEST["username"]) && isset($_REQUEST["email"])) {
$headers[] = "From: $mailFrom";
//$headers[] = "Cc: $mailFrom";
// Check the name.
$name = trim($_REQUEST["username"]);
if ($name == "")
$message .= "<li>fill in your desired username</li>\n";
else {
if (strlen($name) < 2)
$message .= "<li>username is too short (2 character min)</li>\n";
if (strlen($name) > 32)
$message .= "<li>username too long (32 character max)</li>\n";
if (strlen($name) > 32)
$message .= "<li>username too long (32 character max)</li>\n";
if ($name != "" && strlen($name) < 2)
$message .= "<li>username is too short (2 character min)</li>\n";
if (strlen($name) > 1 && !preg_match('/^[a-z][a-z0-9]{1,31}$/', $name))
$message .= "<li>username contains invalid characters (lowercase only, must start with a letter).</li>\n";
if (strlen($name) > 1 && !preg_match('/^[a-z][a-z0-9]{1,31}$/', $name))
$message .= "<li>username contains invalid characters (lowercase only, must start with a letter).</li>\n";
if (posix_getpwnam($name) || forbidden_name($name))
$message .= "<li>sorry, the username $name is unavailable</li>\n";
}
if (posix_getpwnam($name) || forbidden_name($name))
$message .= "<li>sorry, the username $name is unavailable</li>\n";
// Check the e-mail address.
$email = trim($_REQUEST["email"]);
$emailconfirm = trim($_REQUEST["emailconfirm"]);
if ($email == "")
@ -96,9 +97,11 @@ if (isset($_REQUEST["username"]) && isset($_REQUEST["email"])) {
}
}
if ($_REQUEST["interest"] == "")
$message .= "<li>explain why youre interested so we can make sure youre a real human being</li>\n";
$sshkey = trim($_REQUEST["sshkey"]);
if ($sshkey == "" || substr($sshkey, 0, 4) !== "ssh-")
$message .= "<li>ssh key required: please submit the public key.<br />"
@ -112,6 +115,7 @@ if (isset($_REQUEST["username"]) && isset($_REQUEST["email"])) {
}
}
if ($_REQUEST["iagree"] == "")
$message .= "<li>you need to agree to our terms.</li>\n";