fill in your desired username\n";
if (strlen($name) > 32)
$message .= "
username too long (32 character max)\n";
if ($name != "" && strlen($name) < 2)
$message .= "username is too short (2 character min)\n";
if (strlen($name) > 1 && !preg_match('/^[a-z][a-z0-9]{1,31}$/', $name))
$message .= "username contains invalid characters (lowercase only, must start with a letter).\n";
if (posix_getpwnam($name) || forbidden_name($name))
$message .= "sorry, the username $name is unavailable\n";
// Check the e-mail address.
$email = trim($_REQUEST["email"]);
$emailconfirm = trim($_REQUEST["emailconfirm"]);
if ($email == "")
$message .= "fill in your email address\n";
else {
if ($email != $emailconfirm)
$message .= "email does not match\n";
elseif (!filter_var($email, FILTER_VALIDATE_EMAIL))
$message .= "invalid email format\n";
elseif ($name != "" && forbidden_email($email)) {
$message .= "your email is banned!\n";
add_ban_info($name, $email);
}
}
if ($_REQUEST["interest"] == "")
$message .= "explain why youre interested so we can make sure youre a real human being\n";
$sshkey = trim($_REQUEST["sshkey"]);
if ($sshkey == "" || substr($sshkey, 0, 4) !== "ssh-")
$message .= "ssh key required: please submit the public key.
"
. "if you don't have a key, don't worry! check out our help page to ssh keys.\n";
else {
if ($sshkey != "" && forbidden_sshkey($sshkey)) {
$message .= "your sshkey is banned!\n";
add_ban_info($name, $email);
}
}
if ($_REQUEST["iagree"] == "")
$message .= "you need to agree to our terms.\n";
// no validation errors
if ($message == "") {
$makeuser = "/usr/local/bin/envs_user_manage add {$_REQUEST["username"]} {$_REQUEST["email"]} \"{$sshkey}\"";
$msgbody = "
username: {$_REQUEST["username"]}
email: {$_REQUEST["email"]}
reason:
{$_REQUEST["interest"]}
$makeuser
";
$mailSent = @mail($mailTo, $mailSubject, $msgbody, implode("\r\n", $headers));
if($mailSent == TRUE) {
// temp. add to forbidden to prevent double signups (cleanup after user creation)
file_put_contents("/var/signups_current", $name.PHP_EOL, FILE_APPEND);
// save signup
file_put_contents("/var/signups", $makeuser.PHP_EOL, FILE_APPEND);
echo '
Send your message successfully!
Please allow up to 24 hours for a response with login instructions!
';
} else {
echo '
something went wrong... :(
please send an email to hostmaster@envs.net with details of what happened.
';
}
} else {
?>