---
layout: page
title: register for neotilde.tel
php_session: true
---
';
if (!is_null($message)) {
echo "An error occurred: {$message}";
} else {
echo "An unknown error occurred.";
}
echo '';
exit;
}
function verify_captcha(string $result): bool {
$ch = curl_init("{{ site.smolcaptcha_url }}/api/verify");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, [
"client" => "{{ site.smolcaptcha_client }}",
"captcha" => $_SESSION['captcha'],
"result" => $result,
]);
$resp = curl_exec($ch);
curl_close($ch);
return ($resp !== null && trim($resp) === "ok");
}
if (!array_key_exists("captcha", $_SESSION) || is_null($_SESSION['captcha'])) {
$ch = curl_init("{{ site.smolcaptcha_url }}/api/generate");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, [
"client" => "{{ site.smolcaptcha_client }}",
]);
$resp = curl_exec($ch);
curl_close($ch);
if ($resp === false) exit_with_banner("CAPTCHA request failed, please alert darcy in #tildetel
");
$_SESSION['captcha'] = $resp;
}
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$form_user = array_key_exists('user', $_POST) ? trim($_POST['user']) : null;
$form_tilde = array_key_exists('tilde', $_POST) ? trim($_POST['tilde']) : null;
$form_msg = array_key_exists('msg', $_POST) ? trim($_POST['msg']) : "(no message)";
if ($form_user === null || $form_user === "" || $form_tilde === null || $form_tilde === "") {
exit_with_banner("A required field was not provided.");
}
$captcha = array_key_exists('captcha', $_POST) ? trim($_POST['captcha']) : "";
if (!verify_captcha($captcha)) {
exit_with_banner("CAPTCHA verification failed");
}
$ch = curl_init("{{ site.register_hook }}");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, [
"secret" => "{{ site.register_hook_secret }}",
"user" => $form_user,
"tilde" => $form_tilde,
"msg" => $form_msg,
]);
$resp = curl_exec($ch);
curl_close($ch);
unset($_SESSION['captcha']);
if (!$resp) {
exit_with_banner("Couldn't submit registration request, please try again");
} else {
echo '
If you had an account on the old tilde.tel
, please include your previous number in the message field.