2019-07-13 11:01:11 -04:00
|
|
|
<?php
|
|
|
|
|
include "../config.php";
|
|
|
|
|
|
2026-01-09 10:39:50 -07:00
|
|
|
$name = $_GET['contact_name'];
|
|
|
|
|
$email = $_GET['email_address'];
|
|
|
|
|
$username = $_GET['username'];
|
|
|
|
|
$interest = $_GET['interest'];
|
|
|
|
|
$pubkey = $_GET['pubkey'];
|
|
|
|
|
$tv = $_GET['tv'];
|
2019-07-13 11:01:11 -04:00
|
|
|
|
2021-03-01 19:27:46 +01:00
|
|
|
$username = strtolower($username);
|
2026-01-09 10:39:50 -07:00
|
|
|
$pubkey = trim($pubkey);
|
2021-03-01 19:27:46 +01:00
|
|
|
|
2026-01-09 10:39:50 -07:00
|
|
|
$from = 'From: www-data <www-data@thunix.net>';
|
|
|
|
|
$destination_addr = 'newuser@thunix.net';
|
|
|
|
|
$subject = 'New User Registration';
|
2019-07-13 12:13:02 -04:00
|
|
|
$mailbody = "A new user has tried to register.
|
2019-07-13 11:01:11 -04:00
|
|
|
Username: $username
|
|
|
|
|
Real Name: $name
|
|
|
|
|
Email Address: $email
|
|
|
|
|
Interest: $interest
|
|
|
|
|
Pubkey: $pubkey";
|
|
|
|
|
|
2026-01-09 10:39:50 -07:00
|
|
|
$user_queue = '/dev/shm/userqueue';
|
2021-02-27 20:49:07 -05:00
|
|
|
|
2020-05-07 11:57:18 +02:00
|
|
|
$success = 'success1';
|
2026-01-09 10:39:50 -07:00
|
|
|
if ($tv == 'tildeverse') {
|
|
|
|
|
$success = 'success2';
|
|
|
|
|
if (posix_getpwnam($username)) {
|
|
|
|
|
$success = 'success3';
|
|
|
|
|
}
|
|
|
|
|
$valid_key_starts = ['ssh-rsa', 'ssh-dss', 'ecdsa-sha2', 'ssh-ed25519'];
|
|
|
|
|
$key_parts = explode(' ', $pubkey, 3);
|
|
|
|
|
if (!in_array($key_parts[0], $valid_key_starts) || count($key_parts) < 2) {
|
|
|
|
|
$success = 'success4';
|
|
|
|
|
}
|
|
|
|
|
if ($success === 'success2') {
|
|
|
|
|
mail($destination_addr, $subject, $mailbody, $from);
|
|
|
|
|
$fp = fopen($user_queue, 'a');
|
|
|
|
|
fwrite($fp, "'$username','$email','$pubkey'\n");
|
|
|
|
|
fclose($fp);
|
|
|
|
|
$fp2 = fopen('/var/signups', 'a');
|
|
|
|
|
fwrite($fp2, 'makeuser ' . $username . ' ' . $email . ' "' . addslashes($pubkey) . "\"\n");
|
|
|
|
|
fclose($fp2);
|
|
|
|
|
}
|
2020-05-07 11:57:18 +02:00
|
|
|
}
|
2019-07-13 11:01:11 -04:00
|
|
|
|
2020-05-06 23:00:27 +02:00
|
|
|
header("Location: $site_root/?page=$success");
|
2019-07-13 11:01:11 -04:00
|
|
|
die();
|