$line) {
$fsk_line = explode(' ',trim($line));
$fsk[] = $fsk_line[1];
}
$sk = explode(' ',trim($sshkey));
return in_array($sk[1], $fsk);
}
$message = '';
if (isset($_REQUEST["username"]) && isset($_REQUEST["email"])) {
$email = $_REQUEST["email"];
$mailTo = 'hostmaster@envs.net';
$mailFrom = "$email";
$mailSubject = 'Signup User Space - envs.net';
$headers[] = 'MIME-Version: 1.0';
$headers[] = 'Content-type: text/plain; charset=utf-8';
$headers[] = "From: $mailFrom";
//$headers[] = "Cc: $mailFrom";
$name = trim($_REQUEST["username"]);
if ($name == "")
$message .= "
fill in your desired username\n";
else {
if (strlen($name) < 2)
$message .= "username is too short (2 character min)\n";
if (strlen($name) > 32)
$message .= "username too long (32 character max)\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";
}
$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);
}
}
$interest = $_REQUEST["interest"];
if ($interest == "")
$message .= "explain why you're interested so we can make sure you're a real human being\n";
else {
if (strlen($interest) < 50)
$message .= "interests explanation is too short (50 character min)\n";
}
$sshkey = trim($_REQUEST["sshkey"]);
if ($sshkey == "")
$message .= "ssh pubkey required: please submit the public key.\n";
elseif (substr($sshkey, 0, 4) !== "ssh-" && substr($sshkey, 0, 3) !== "sk-" && substr($sshkey, 0, 5) !== "ecdsa")
$message .= "ssh pubkey looks not correct.\n";
else {
if ($name != "" && $email != "") {
if (forbidden_sshkey($sshkey)) {
$message .= "your sshkey is banned!\n";
add_ban_info($name, $email);
}
}
}
if ($_REQUEST["c_age"] == "")
$message .= "you must be at least 16 years old to use this service.\n";
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 '
Sent 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 {
?>