2022-06-22 16:08:30 +00:00
<! DOCTYPE html >
2022-10-31 14:47:44 +00:00
<!--
2022-11-03 12:01:08 +00:00
This program is free software : you can redistribute it and / or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation , either version 3 of the License , or ( at your option ) any later version .
2022-10-31 14:47:44 +00:00
This program is distributed in the hope that it will be useful , but WITHOUT ANY WARRANTY ; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the GNU Affero General Public License for more details .
You should have received a copy of the GNU Affero General Public License along with this program . If not , see < https :// www . gnu . org / licenses />.
-->
2022-06-22 16:08:30 +00:00
< html lang = " en " >
< head >
2022-09-30 11:11:42 +00:00
< meta name = " viewport " content = " width=device-width " >
2022-06-22 16:08:30 +00:00
< meta charset = " UTF-8 " >
2022-11-02 13:47:24 +00:00
< meta name = " description " content = " Register for ~vern " >
2022-12-02 13:47:03 +00:00
< link rel = " stylesheet " href = " //gcdn.vern.cc/vernsite/style.css " >
2022-06-23 18:02:32 +00:00
< title > Registration | ~ vern </ title >
2022-06-22 16:08:30 +00:00
</ head >
< body >
2022-11-20 16:04:48 +00:00
<!-- #include file="nav.php" -->
2022-07-07 12:55:22 +00:00
2022-11-20 16:15:36 +00:00
< p >< b > If you can / do not want to share your email for ~ vern registration , please contact an < a href =/ en / admins > admin </ a > so we can create one for you without one </ b ></ p >
2022-06-22 16:08:30 +00:00
< ? php
function sanitize ( $str ) {
$str = trim ( $str );
$str = stripslashes ( $str );
$str = htmlspecialchars ( $str );
2022-06-29 16:02:54 +00:00
$str = str_replace ( " \r " , '' , $str );
2022-06-22 16:08:30 +00:00
return $str ;
}
$success = false ;
2022-11-22 12:18:10 +00:00
$username = $email = $ssh = $reason =
$username_err = $email_err = $ssh_err = $reason_err = '' ;
2022-06-22 16:08:30 +00:00
$username_re = '/^[a-z_][a-z0-9_]{0,30}$/' ;
if ( $_SERVER [ 'REQUEST_METHOD' ] == " POST " ) {
if ( ! empty ( $_POST [ 'username' ])) {
if ( preg_match ( $username_re , $_POST [ 'username' ]) === 1 ) {
2022-09-04 21:08:04 +00:00
if ( ! file_exists ( '/vm/' . $_POST [ 'username' ])) {
2022-06-22 16:08:30 +00:00
if ( ! file_exists ( " /var/tmp/register/ " . sanitize ( $_POST [ 'username' ])))
$username = sanitize ( $_POST [ 'username' ]);
else $username_err = " A request for the username " . $_POST [ 'username' ] . " exists already. Try again later or choose a different username. " ;
}
else $username_err = " Username is already in use " ;
} else {
$username_err = " Invalid username. Username must be a valid GNU/Linux username (match $username_re ) " ;
}
} else {
$username_err = " Username is required " ;
}
if ( ! empty ( $_POST [ 'email' ])) {
if ( filter_var ( sanitize ( $_POST [ 'email' ]), FILTER_VALIDATE_EMAIL )) {
$email = sanitize ( $_POST [ 'email' ]);
} else {
$email_err = " Invalid E-mail " ;
}
} else {
$email_err = " E-mail is required " ;
}
if ( ! empty ( $_POST [ 'ssh' ])) {
2022-10-20 11:58:42 +00:00
$ret = shell_exec ( 'bash -c "ssh-keygen -lf - <<< ' . escapeshellarg ( $_POST [ 'ssh' ]) . ' 2>&1"' );
if ( trim ( $ret ) != " (stdin) is not a public key file. " ) {
2022-06-22 16:08:30 +00:00
$ssh = $_POST [ 'ssh' ];
} else {
$ssh_err = " Not a valid SSH public key " ;
}
unset ( $ret );
} else {
$ssh_err = " Public key is required " ;
}
if ( ! empty ( $_POST [ 'joinreason' ])) {
$reason = $_POST [ 'joinreason' ];
} else {
$reason_err = " Join reason is required " ;
}
2022-12-22 17:15:25 +00:00
if ( empty ( $username_err . $email_err . $ssh_err . $reason_err ) && isset ( $_POST [ 'tos' ]))
2022-06-22 16:08:30 +00:00
$success = true ;
}
if ( ! $success ) {
?>
< div class = h >< h1 id = signup > Sign Up </ h1 > < a aria - hidden = true href = #signup>#signup</a></div>
2022-12-23 02:27:43 +00:00
< p > See the < a href = " //wiki.vern.cc/doku.php?id=guides:register " > wiki page </ a > on how to register .</ p >
2022-06-22 16:08:30 +00:00
< span class = " red " >* Required field </ span >
< form method = " post " action = " <?php echo htmlspecialchars( $_SERVER["PHP_SELF"] ); ?> " >
< p > Username :
< input type = " text " name = " username " >
< span class = " red " >* < ? php echo $username_err ; ?> </span></p>
2022-07-07 13:01:16 +00:00
< p > E - mail ( We need one so we can contact you ) < span class = " red " >* < ? php echo $email_err ; ?> </span>
2022-06-22 16:08:30 +00:00
< input type = " text " name = " email " ></ p >
2023-01-19 12:28:59 +00:00
< p > SSH public keys ( one key per line ) < span class = " red " >* < ? php echo $ssh_err ; ?> </span><br>
2022-06-22 16:08:30 +00:00
< textarea name = " ssh " rows = " 3 " cols = " 50 " ></ textarea ></ p >
< p > Why do you want to join ? < span class = " red " >* < ? php echo $reason_err ; ?> </span><br>
< textarea name = " joinreason " rows = " 8 " cols = " 50 " ></ textarea ></ p >
< p > What services do you want ? ( You can always request an account on one later ) </ p >
< input type = " checkbox " id = " pubnix " name = " pubnix " value = " Pubnix " disabled checked >
2022-09-30 10:54:14 +00:00
< label for = " pubnix " > Pubnix ( Includes E - Mail ) </ label >< br >
2022-06-22 16:08:30 +00:00
< input type = " checkbox " id = " matrix " name = " matrix " value = " Matrix " checked >
< label for = " matrix " > Matrix </ label >< br >
< input type = " checkbox " id = " fedi " name = " fedi " value = " Mastodon " checked >
2022-12-09 09:26:39 +00:00
< label for = " fedi " > Mastodon </ label >< br >
< input type = " checkbox " id = " akkoma " name = " akkoma " value = " Akkoma " checked >
< label for = " akkoma " > Akkoma ( Pleroma Fork ) </ label >< br >
2022-06-22 16:08:30 +00:00
2022-12-09 16:47:09 +00:00
< input type = " checkbox " id = " soju " name = " soju " value = " Soju " checked >
< label for = " soju " > Soju </ label >< br >
2023-01-23 19:24:02 +00:00
< input type = " checkbox " id = " git " name = " git " value = " Forgejo " checked >
< label for = " git " > Forgejo </ label >< br >
2022-06-22 16:08:30 +00:00
2022-12-09 18:10:29 +00:00
< input type = " checkbox " id = " freshrss " name = " freshrss " value = " FreshRSS " checked >
< label for = " freshrss " > FreshRSS </ label >< br >
2023-02-01 02:18:24 +00:00
2023-01-31 19:20:45 +00:00
< input type = " checkbox " id = " miniflux " name = " miniflux " value = " Miniflux " checked >
< label for = " miniflux " > Miniflux </ label >< br >
2022-12-09 18:10:29 +00:00
2022-12-09 18:26:43 +00:00
< input type = " checkbox " id = " penpot " name = " penpot " value = " Penpot " checked >
< label for = " penpot " > Penpot </ label >< br >
2022-09-28 15:08:18 +00:00
< input type = " checkbox " id = " nextcloud " name = " nextcloud " value = " Nextcloud " checked >
< label for = " nextcloud " > Nextcloud </ label >< br >
2022-09-28 14:58:50 +00:00
2022-10-03 18:15:03 +00:00
< input type = " checkbox " id = " peertube " name = " peertube " value = " PeerTube " checked >
< label for = " peertube " > PeerTube </ label >< br >
2022-06-22 16:08:30 +00:00
< input type = " checkbox " id = " xmpp " name = " xmpp " value = " XMPP " checked >
< label for = " xmpp " > XMPP / Jabber </ label >< br >
2022-07-29 21:04:55 +00:00
< input type = " checkbox " id = " xmppo " name = " xmppo " value = " XMPP Onion " >
2022-08-06 02:29:43 +00:00
< label for = " xmppo " > XMPP / Jabber Onion ( Don 't check if you don' t know what it is ) </ label >< br >
2022-07-29 21:04:55 +00:00
< input type = " checkbox " id = " xmppi " name = " xmppi " value = " XMPP I2P " >
2022-08-06 02:29:43 +00:00
< label for = " xmppi " > XMPP / Jabber I2P ( Don 't check if you don' t know what it is ) </ label >< br >
2022-07-29 11:00:29 +00:00
2022-12-22 17:18:36 +00:00
< br >
2022-12-22 17:15:25 +00:00
< input type = " checkbox " id = " tos " name = " tos " value = " I agree to the ToS and Privacy Policy " >
< label for = " tos " > I agree to the < a href =/ en / tos > Terms of Service </ a > and < a href =/ en / privpol > Privacy Policy </ a ></ label >< br >
2022-06-22 16:08:30 +00:00
< br >
< span >< input type = " submit " value = " Submit " style = " width:100px;height:40px;font-size:20px " ></ span >
</ form >< br >
2022-10-25 15:00:17 +00:00
< p > THE SERVICE IS PROVIDED ON AN “AS IS” AND “AS AVAILABLE” BASIS , AND WE DO NOT GUARANTEE THAT THE SERVICE WILL BE AVAILABLE AT ALL TIMES , NOR THE ACCURACY OF THE SERVICE OR ANY MATERIAL PROVIDED BY THE SERVICE OR ON THE ~ VERN WEBSITE . IN NO EVENT SHALL THE ADMINISTRATORS BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER LIABILITY ARISING FROM , OUT OF OR IN CONNECTION WITH THE SERVICE OR THE USE OF OTHER DEALINGS IN THE SERVICE . YOU ARE SOLELY RESPONSIBLE FOR YOUR USE OF THE SERVICE .</ p >
2022-06-22 16:08:30 +00:00
< ? php
} else {
?>
2022-09-28 15:04:05 +00:00
< meta http - equiv = " refresh " content = " 5;url=http://<?php echo htmlspecialchars( $_SERVER['HTTP_HOST'] ); ?> " />
2022-06-22 16:08:30 +00:00
< div class = h >< h1 id = thanks > Thank you for signing up .</ h1 > < a aria - hidden = true href = #thanks>#thanks</a></div>
< p > An admin will review your request , and an e - mail will be sent if your registration is successful .</ p >
2022-11-20 16:15:36 +00:00
< p > You will be redirected back < a href =/ en /> home </ a > in 5 seconds .</ p >
2022-06-22 16:08:30 +00:00
< ? php
if ( isset ( $_POST [ 'matrix' ])) $use_matrix = true ;
if ( isset ( $_POST [ 'fedi' ])) $use_fedi = true ;
2022-12-09 09:26:39 +00:00
if ( isset ( $_POST [ 'akkoma' ])) $use_akkoma = true ;
2022-12-09 16:47:09 +00:00
if ( isset ( $_POST [ 'soju' ])) $use_soju = true ;
2022-06-22 16:08:30 +00:00
if ( isset ( $_POST [ 'git' ])) $use_git = true ;
2022-09-28 15:08:18 +00:00
if ( isset ( $_POST [ 'nextcloud' ])) $use_nc = true ;
2022-12-09 18:10:29 +00:00
if ( isset ( $_POST [ 'freshrss' ])) $use_freshrss = true ;
2023-01-31 19:20:45 +00:00
if ( isset ( $_POST [ 'miniflux' ])) $use_miniflux = true ;
2022-12-09 18:26:43 +00:00
if ( isset ( $_POST [ 'penpot' ])) $use_penpot = true ;
2022-10-03 18:15:03 +00:00
if ( isset ( $_POST [ 'peertube' ])) $use_peertube = true ;
2022-06-22 16:08:30 +00:00
if ( isset ( $_POST [ 'xmpp' ])) $use_xmpp = true ;
2022-07-29 11:00:29 +00:00
if ( isset ( $_POST [ 'xmppo' ])) $use_xmppo = true ;
2022-07-29 21:04:55 +00:00
if ( isset ( $_POST [ 'xmppi' ])) $use_xmppi = true ;
2022-06-22 16:08:30 +00:00
$to = " root@vern.cc " ;
$subject = " New registration request from $username < $email > " ;
$message = " Hello Administrators, \n Someone has requested a membership. Please view the details below and decide if it is worth approving. \n \n SSH keys: \n $ssh\n\nRequested username: $username\nRequested services: Tilde " ;
if ( $use_matrix ) $message .= " , Matrix " ;
if ( $use_fedi ) $message .= " , Mastodon " ;
2022-12-09 09:26:39 +00:00
if ( $use_akkoma ) $message .= " , Akkoma " ;
2022-12-09 16:47:09 +00:00
if ( $use_soju ) $message .= " , Soju " ;
2023-01-23 19:24:02 +00:00
if ( $use_git ) $message .= " , Forgejo " ;
2022-09-28 15:08:18 +00:00
if ( $use_nc ) $message .= " , Nextcloud " ;
2022-12-09 18:10:29 +00:00
if ( $use_freshrss ) $message .= " , FreshRSS " ;
2023-01-31 19:20:45 +00:00
if ( $use_miniflux ) $message .= " , Miniflux " ;
2022-12-09 18:26:43 +00:00
if ( $use_penpot ) $message .= " , Penpot " ;
2022-10-03 18:15:03 +00:00
if ( $use_peertube ) $message .= " , PeerTube " ;
2022-06-22 16:08:30 +00:00
if ( $use_xmpp ) $message .= " , XMPP " ;
2022-07-29 11:00:29 +00:00
if ( $use_xmppo ) $message .= " , XMPP Onion " ;
2022-07-29 21:04:55 +00:00
if ( $use_xmppi ) $message .= " , XMPP I2P " ;
2022-06-22 16:08:30 +00:00
$message .= " . \n Join reason: \n $reason\n\n\nTo accept this request, run this command as root: \n /root/bin/accept $username\nTo deny this request, run this command as root: \n /root/bin/deny $username\n " ;
$contents = " #!/usr/bin/env -S bash -e \n \n # This is the registration script for $username \n # This script was automatically generated by http:// " . $_SERVER [ 'HTTP_HOST' ] . htmlspecialchars ( $_SERVER [ 'PHP_SELF' ]) . " \n \n " ;
2022-11-23 14:55:25 +00:00
$contents .= 'password="$(tr -dc A-Za-z0-9 </dev/urandom | head -c 64)"' . " \n " ;
$contents .= '~/bin/mktuser ' . escapeshellarg ( $username ) . ' "$password"' . " <<< " . escapeshellarg ( $_POST [ 'ssh' ]) . " \n " ;
$contents .= 'echo "$password" > /sshfs/home/' . $username . '/pass && chmod 600 /sshfs/home/' . $username . '/pass && ssh 192.168.122.30 chown ' . escapeshellarg ( $username . ':' . $username ) . ' /sshfs/home/' . $username . '/pass' . " \n \n " ;
if ( $use_matrix ) $contents .= '~/bin/mkmuser ' . escapeshellarg ( $username ) . ' "$password"' . " \n " ;
2022-06-29 13:08:23 +00:00
if ( $use_fedi ) {
$pass_file = '/home/' . $username . '/mastodon-pass' ;
2022-06-30 12:29:19 +00:00
$contents .= 'touch /sshfs' . $pass_file . " \n " ;
2022-06-29 13:08:23 +00:00
$contents .= 'chmod 600 /sshfs' . $pass_file . " \n " ;
2022-06-29 14:33:17 +00:00
$contents .= 'ssh 192.168.122.30 chown ' . escapeshellarg ( $username . ':' . $username ) . ' ' . escapeshellarg ( $pass_file ) . " \n " ;
2022-12-11 08:31:12 +00:00
$contents .= '~/bin/mkfuser ' . escapeshellarg ( $username ) . ' | tee /sshfs' . escapeshellarg ( $pass_file ) . " \n " ;
2022-06-29 13:08:23 +00:00
unset ( $pass_file );
}
2022-12-09 09:26:39 +00:00
if ( $use_akkoma ) $contents .= '~/bin/mkauser ' . escapeshellarg ( $username ) . ' "$password"' . " \n " ;
2022-12-09 16:47:09 +00:00
if ( $use_soju ) $contents .= '~/bin/mksuser ' . escapeshellarg ( $username ) . ' "$password"' . " \n " ;
2022-12-11 08:31:12 +00:00
if ( $use_git ) $contents .= '~/bin/mkguser ' . escapeshellarg ( $username ) . ' "$password"' . " \n " ;
2022-11-23 14:55:25 +00:00
if ( $use_nc ) $contents .= '~/bin/mknuser ' . escapeshellarg ( $username ) . ' "$password"' . " \n " ;
2022-12-09 18:10:29 +00:00
if ( $use_freshrss ) $contents .= '~/bin/mkfruser ' . escapeshellarg ( $username ) . ' "$password"' . " \n " ;
2023-01-31 19:20:45 +00:00
if ( $use_freshrss ) $contents .= '~/bin/mkmfuser ' . escapeshellarg ( $username ) . ' "$password"' . " \n " ;
2022-12-09 18:26:43 +00:00
if ( $use_penpot ) $contents .= '~/bin/mkppuser ' . escapeshellarg ( $username ) . ' "$password"' . " \n " ;
2022-11-23 14:55:25 +00:00
if ( $use_peertube ) $contents .= '~/bin/mkpuser ' . escapeshellarg ( $username ) . ' "$password"' . ' ' . escapeshellarg ( $email ) . " \n " ;
if ( $use_xmpp ) $contents .= '~/bin/mkxuser ' . escapeshellarg ( $username ) . ' "$password"' . " vern.cc \n " ;
if ( $use_xmppo ) $contents .= '~/bin/mkxuser ' . escapeshellarg ( $username ) . ' "$password"' . " vernccvbvyi5qhfzyqengccj7lkove6bjot2xhh5kajhwvidqafczrad.onion \n " ;
if ( $use_xmppi ) $contents .= '~/bin/mkxuser ' . escapeshellarg ( $username ) . ' "$password"' . " verncceu2kgz54wi7r5jatgmx2mqtsh3knxhiy4m5shescuqtqfa.b32.i2p \n " ;
2022-12-02 10:47:29 +00:00
$contents .= " s-nail -vr 'register@vern.cc' -s 'Your ~vern account has been created' -M text/plain " . escapeshellarg ( $email ) . " < <(printf 'Hello %s, \\ nYour membership request on ~vern has been accepted. \\ nYou can now SSH into vern.cc using the public key(s) that you supplied to ~vern. \\ nA global password for all the services you signed up to can be found at ~/pass. If you signed up for Mastodon, password for the account can be found at ~/mastodon-pass \\ n \\ nThank you for being a part of ~vern!' " . escapeshellarg ( $username ) . " ) \n " ;
2022-06-22 16:08:30 +00:00
$contents .= " rm -f $ 0 \n " ;
2022-06-27 07:54:36 +00:00
$contents .= " exit \n \n \n " ;
2022-06-29 16:02:54 +00:00
$contents .= $reason . " \n " ;
2022-06-22 16:08:30 +00:00
$filename = " /var/tmp/register/ " . $username ;
$handle = fopen ( $filename , " w+ " );
chmod ( $filename , 0600 );
unset ( $filename );
fwrite ( $handle , $contents );
fclose ( $handle );
$from = " register@vern.cc " ;
$headers = " From: " . $from . " \n " ;
$headers .= " MIME-Version: 1.0 \n " ;
$headers .= " Content-type: text/plain \n " ;
mail ( $to , $subject , $message , $headers );
}
?>
2022-11-23 11:33:54 +00:00
<!-- #include file="footer.cgi" -->
2022-06-22 16:08:30 +00:00
</ body >
</ html >