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)) {
$user_ip = getUserIpAddr();
$user_info = "$name - $email - $user_ip";
$message .= "your email is banned!\n";
file_put_contents("/var/signups_banned", $user_info.PHP_EOL, FILE_APPEND);
}
}
if ($_REQUEST["interest"] == "")
$message .= "explain why youre interested so we can make sure youre a real human being\n";
if ($_REQUEST["sshkey"] == "" || substr($_REQUEST["sshkey"], 0, 4) !== "ssh-")
$message .= "ssh key required: please submit the public key.\n";
// no validation errors
if ($message == "") {
$sshkey = trim($_REQUEST["sshkey"]);
$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 {
?>
notice: