2019-07-13 15:01:11 +00:00
|
|
|
<?php
|
2019-07-13 17:34:43 +00:00
|
|
|
// This code is licensed under the AGPL 3 or later by ubergeek (https://tildegit.org/ubergeek)
|
2019-07-13 15:01:11 +00:00
|
|
|
include "../config.php";
|
|
|
|
|
|
|
|
$name = $_GET['contact_name'];
|
|
|
|
$email = $_GET['email_address'];
|
|
|
|
$username = $_GET['username'];
|
2019-07-13 16:14:59 +00:00
|
|
|
$interest = $_GET['interest'];
|
2019-07-13 15:01:11 +00:00
|
|
|
$pubkey = $_GET['pubkey'];
|
|
|
|
$tv = $_GET['tv'];
|
|
|
|
|
2021-03-01 18:27:46 +00:00
|
|
|
// username passed lowercased
|
|
|
|
$username = strtolower($username);
|
|
|
|
|
2021-03-20 03:57:52 +00:00
|
|
|
// strip new line characters from the end
|
|
|
|
$pubkey = trim($pubkey);
|
|
|
|
|
2019-11-12 17:48:17 +00:00
|
|
|
$from = 'From: www-data <www-data@thunix.net>';
|
2019-07-13 17:24:36 +00:00
|
|
|
$destination_addr = "newuser@thunix.net";
|
2019-07-13 15:01:11 +00:00
|
|
|
$subject = "New User Registration";
|
2019-07-13 16:13:02 +00:00
|
|
|
$mailbody = "A new user has tried to register.
|
2019-07-13 15:01:11 +00:00
|
|
|
Username: $username
|
|
|
|
Real Name: $name
|
|
|
|
Email Address: $email
|
|
|
|
Interest: $interest
|
|
|
|
Pubkey: $pubkey";
|
|
|
|
|
|
|
|
// In the future, here, we *should* be able to build a process that
|
|
|
|
// somehow auto-verifies the user, and instead of email, it'll kick off the new user process here
|
2020-05-06 21:00:27 +00:00
|
|
|
|
2021-02-28 01:49:07 +00:00
|
|
|
$user_queue = '/dev/shm/userqueue';
|
|
|
|
|
2020-05-06 21:00:27 +00:00
|
|
|
// Spam attempt
|
2020-05-07 09:57:18 +00:00
|
|
|
$success = 'success1';
|
|
|
|
if ( $tv == "tildeverse" )
|
|
|
|
{
|
|
|
|
// Success!
|
|
|
|
$success = 'success2';
|
2020-05-07 10:03:45 +00:00
|
|
|
|
|
|
|
// Check if username already taken
|
2021-03-01 18:27:46 +00:00
|
|
|
exec("id $username 2>&1", $null, $retval);
|
2020-05-07 10:03:45 +00:00
|
|
|
if($retval == 0)
|
|
|
|
$success = 'success3';
|
2019-07-13 15:01:11 +00:00
|
|
|
|
2020-05-07 11:34:14 +00:00
|
|
|
// Check SSH public key format:
|
|
|
|
exec("echo $pubkey | ssh-keygen -l -f - 2>&1", $null, $retval);
|
|
|
|
if($retval != 0)
|
2020-12-22 19:08:44 +00:00
|
|
|
$success = 'success4';
|
2020-05-07 11:34:14 +00:00
|
|
|
|
2020-05-07 09:57:18 +00:00
|
|
|
if ( $success == "success2" )
|
2021-03-12 16:46:39 +00:00
|
|
|
{
|
2020-05-07 09:57:18 +00:00
|
|
|
mail($destination_addr, $subject, $mailbody, $from);
|
2021-02-28 01:49:07 +00:00
|
|
|
$fp = fopen($user_queue, 'a');
|
2021-03-01 18:27:46 +00:00
|
|
|
fwrite($fp, "'$username','$email','$pubkey'\n");
|
2021-02-28 01:49:07 +00:00
|
|
|
fclose($fp);
|
2021-03-12 16:46:39 +00:00
|
|
|
}
|
2020-05-07 09:57:18 +00:00
|
|
|
}
|
2019-07-13 15:01:11 +00:00
|
|
|
|
2020-05-06 21:00:27 +00:00
|
|
|
header("Location: $site_root/?page=$success");
|
2019-07-13 15:01:11 +00:00
|
|
|
die();
|
|
|
|
|
|
|
|
?>
|