site/signup.php

43 lines
2.4 KiB
PHP

<?php
exit(); //disable the signup script
include("/var/www/tilde.cafe/inc/header.html");
if($_POST==array()){
?>
<p>We'll contact you when your account is ready.<br/>
Don't want to use email? contact an admin directly<br/>
we're available on IRC at <a href="ircs://irc.libera.chat:6697/tilde.cafe">#tilde.cafe on libera.chat</a> and <a href="ircs://irc.tilde.chat:6697/cafe">#cafe on tilde.chat</a>).</p>
<form method="post">
<p>Username:</p>
<input type="text" name="username" required="required" maxlength="20" width="20ch" pattern="[a-z][-0-9a-z_]{2,}" placeholder="MyUserName"/><br/>
<p>E-mail:</p>
<input style="max-width:100%" type="email" name="email" required="required" minlength="7" maxlength="30" size="30" placeholder="email@example.com"/><br/>
<p>SSH <em>public</em> key (don't have one? check our <a href="https://tilde.cafe/wiki/ssh">wiki</a>):<p>
<!-- maximum length of 400 should allow even 4096-bit rsa keys, with a short comment, more than that is ridiculous -->
<input style="max-width:100%" type="text" name="sshkey" required="required" pattern="ssh-(rsa|(ed25519|ecdsa)(-sk)?) [0-9a-zA-Z+/=]{60,}( .*)?" size="100" placeholder="ssh-ed25519 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA MyUserName@home_pc"/><br/>
<p>Reason (why do you want/need an account?):</p><textarea cols="70" rows="2" name="reason" maxlength="140" required="required"></textarea><br/>
<br/>
<label>I am at least 13 years old, and agree to follow the <a href="https://tilde.cafe/wiki/code-of-conduct" target="_blank">Code of Conduct</a>: <input type="checkbox" value="legal"/></label><br/>
<br/>
<input type="submit" value="Sign Up"/>
</form>
<?php
}else{
$username=$_POST["username"];$email=$_POST["email"];$reason=$_POST["reason"];$sshkey=$_POST["sshkey"];$legal=$_POST["legal"];
$nl="\r\n";
$makeuser="makeuser ".$username." ".$email." \"".$sshkey."\"";
$message="username: ".$username.$nl."email: ".$email.$nl."reason: ".$reason.$nl.$nl.$makeuser;
$sent=mail("sudoers@tilde.cafe","new tilde.cafe signup: $username",$message,"From: signup");
if($sent!=True){
print("error: signup failed to send!");
}else{
print("Signup sent! (signups are usually accepted within 48 hours)");
if(file_exists("/var/signups") and is_writable("/var/signups")){
$varsignups = fopen("/var/signups", "a");
fwrite($varsignups, $makeuser."\n");
fclose($varsignups);
};
};
};
include("/var/www/tilde.cafe/inc/footer.html");
?>