Compare commits
4 Commits
d009b6e266
...
57326ec6c5
Author | SHA1 | Date |
---|---|---|
darcy (iris system) | 57326ec6c5 | |
darcy (iris system) | bfdcfd827e | |
darcy (iris system) | 2ba153abac | |
darcy (iris system) | 1914b0d589 |
24
Gemfile.lock
24
Gemfile.lock
|
@ -1,20 +1,20 @@
|
||||||
GEM
|
GEM
|
||||||
remote: https://rubygems.org/
|
remote: https://rubygems.org/
|
||||||
specs:
|
specs:
|
||||||
addressable (2.7.0)
|
addressable (2.8.0)
|
||||||
public_suffix (>= 2.0.2, < 5.0)
|
public_suffix (>= 2.0.2, < 5.0)
|
||||||
colorator (1.1.0)
|
colorator (1.1.0)
|
||||||
concurrent-ruby (1.1.9)
|
concurrent-ruby (1.1.9)
|
||||||
em-websocket (0.5.2)
|
em-websocket (0.5.3)
|
||||||
eventmachine (>= 0.12.9)
|
eventmachine (>= 0.12.9)
|
||||||
http_parser.rb (~> 0.6.0)
|
http_parser.rb (~> 0)
|
||||||
eventmachine (1.2.7)
|
eventmachine (1.2.7)
|
||||||
ffi (1.15.1)
|
ffi (1.15.4)
|
||||||
forwardable-extended (2.6.0)
|
forwardable-extended (2.6.0)
|
||||||
http_parser.rb (0.6.0)
|
http_parser.rb (0.8.0)
|
||||||
i18n (1.8.10)
|
i18n (1.8.11)
|
||||||
concurrent-ruby (~> 1.0)
|
concurrent-ruby (~> 1.0)
|
||||||
jekyll (4.2.0)
|
jekyll (4.2.1)
|
||||||
addressable (~> 2.4)
|
addressable (~> 2.4)
|
||||||
colorator (~> 1.0)
|
colorator (~> 1.0)
|
||||||
em-websocket (~> 0.5)
|
em-websocket (~> 0.5)
|
||||||
|
@ -38,7 +38,7 @@ GEM
|
||||||
kramdown-parser-gfm (1.1.0)
|
kramdown-parser-gfm (1.1.0)
|
||||||
kramdown (~> 2.0)
|
kramdown (~> 2.0)
|
||||||
liquid (4.0.3)
|
liquid (4.0.3)
|
||||||
listen (3.5.1)
|
listen (3.7.0)
|
||||||
rb-fsevent (~> 0.10, >= 0.10.3)
|
rb-fsevent (~> 0.10, >= 0.10.3)
|
||||||
rb-inotify (~> 0.9, >= 0.9.10)
|
rb-inotify (~> 0.9, >= 0.9.10)
|
||||||
mercenary (0.4.0)
|
mercenary (0.4.0)
|
||||||
|
@ -49,19 +49,19 @@ GEM
|
||||||
rb-inotify (0.10.1)
|
rb-inotify (0.10.1)
|
||||||
ffi (~> 1.0)
|
ffi (~> 1.0)
|
||||||
rexml (3.2.5)
|
rexml (3.2.5)
|
||||||
rouge (3.26.0)
|
rouge (3.26.1)
|
||||||
safe_yaml (1.0.5)
|
safe_yaml (1.0.5)
|
||||||
sassc (2.4.0)
|
sassc (2.4.0)
|
||||||
ffi (~> 1.9)
|
ffi (~> 1.9)
|
||||||
terminal-table (2.0.0)
|
terminal-table (2.0.0)
|
||||||
unicode-display_width (~> 1.1, >= 1.1.1)
|
unicode-display_width (~> 1.1, >= 1.1.1)
|
||||||
unicode-display_width (1.7.0)
|
unicode-display_width (1.8.0)
|
||||||
|
|
||||||
PLATFORMS
|
PLATFORMS
|
||||||
ruby
|
x86_64-darwin-17
|
||||||
|
|
||||||
DEPENDENCIES
|
DEPENDENCIES
|
||||||
jekyll
|
jekyll
|
||||||
|
|
||||||
BUNDLED WITH
|
BUNDLED WITH
|
||||||
2.1.4
|
2.2.24
|
||||||
|
|
|
@ -3,6 +3,11 @@ description: neo-tildetel - a PBX for the tildeverse
|
||||||
url: https://tel.tilde.org.nz
|
url: https://tel.tilde.org.nz
|
||||||
baseurl: ''
|
baseurl: ''
|
||||||
|
|
||||||
|
smolcaptcha_url: "https://httpbin.org/status/418"
|
||||||
|
smolcaptcha_client: ""
|
||||||
|
register_hook: "https://httpbin.org/status/418"
|
||||||
|
register_hook_secret: ""
|
||||||
|
|
||||||
kramdown:
|
kramdown:
|
||||||
smart_quotes: apos,apos,quot,quot
|
smart_quotes: apos,apos,quot,quot
|
||||||
typographic_symbols:
|
typographic_symbols:
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
<!DOCTYPE html>
|
{%- if page.php_session -%}<?php
|
||||||
|
session_name("neotildetel");
|
||||||
|
session_start();
|
||||||
|
?>{%- endif -%}<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
.form
|
||||||
|
{
|
||||||
|
width: 100%;
|
||||||
|
margin: 0 0 1rem 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form input:not([type = "checkbox"]),
|
||||||
|
.form select,
|
||||||
|
.form button,
|
||||||
|
.form textarea
|
||||||
|
{
|
||||||
|
display: block;
|
||||||
|
width: 100%;
|
||||||
|
padding: 0.25rem;
|
||||||
|
margin-bottom: 0.5rem;
|
||||||
|
border: 1px solid #000;
|
||||||
|
border-radius: 3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-captcha
|
||||||
|
{
|
||||||
|
margin: 1rem 0;
|
||||||
|
padding: 1rem;
|
||||||
|
border: 1px solid #000;
|
||||||
|
border-radius: 3px;
|
||||||
|
|
||||||
|
.form-captcha-img
|
||||||
|
{
|
||||||
|
display: block;
|
||||||
|
margin: 1rem 0;
|
||||||
|
}
|
||||||
|
}
|
|
@ -18,3 +18,11 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.banner
|
||||||
|
{
|
||||||
|
width: 100%;
|
||||||
|
padding: 0.5rem 1rem;
|
||||||
|
border: 1px solid #000;
|
||||||
|
border-radius: 3px;
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,111 @@
|
||||||
|
---
|
||||||
|
layout: page
|
||||||
|
title: register for tel.tilde.org.nz
|
||||||
|
php_session: true
|
||||||
|
---
|
||||||
|
|
||||||
|
<?php
|
||||||
|
function exit_with_banner(?string $message) {
|
||||||
|
unset($_SESSION['captcha']);
|
||||||
|
|
||||||
|
echo '<div class="banner">';
|
||||||
|
if (!is_null($message)) {
|
||||||
|
echo "An error occurred: {$message}";
|
||||||
|
} else {
|
||||||
|
echo "An unknown error occurred.";
|
||||||
|
}
|
||||||
|
echo '</div>';
|
||||||
|
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 <code>#tildetel</code>");
|
||||||
|
$_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 '<div class="banner">Your registration request was submitted successfully!</div>';
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
?>
|
||||||
|
|
||||||
|
<p>If you had an account on the old <code>tilde.tel</code>, please include your previous number in the message field.</p>
|
||||||
|
|
||||||
|
<form method="POST" class="form">
|
||||||
|
<label for="reg_user">Username:</label>
|
||||||
|
<input id="reg_user" name="user" type="text" placeholder="Username">
|
||||||
|
|
||||||
|
<label for="reg_tilde">Tilde / Pubnix:</label>
|
||||||
|
<input id="reg_tilde" name="tilde" type="text" placeholder="Tilde / Pubnix">
|
||||||
|
|
||||||
|
<label for="reg_msg">Message (optional):</label>
|
||||||
|
<textarea id="reg_msg" name="reg_msg"></textarea>
|
||||||
|
|
||||||
|
<div class="form-captcha">
|
||||||
|
<label for="reg_captcha">What is the answer to the below equation?</label>
|
||||||
|
<img class="form-captcha-img" src="{{ site.smolcaptcha_url }}/render/<?php echo $_SESSION['captcha'] ?>">
|
||||||
|
<input id="reg_captcha" name="captcha" type="text" placeholder="Your answer">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<button class="button" type="submit">
|
||||||
|
Submit registration request
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<?php } ?>
|
|
@ -48,5 +48,6 @@ a
|
||||||
@import 'nav';
|
@import 'nav';
|
||||||
@import 'footer';
|
@import 'footer';
|
||||||
@import 'table';
|
@import 'table';
|
||||||
|
@import 'form';
|
||||||
@import 'utils';
|
@import 'utils';
|
||||||
@import 'index';
|
@import 'index';
|
||||||
|
|
Loading…
Reference in New Issue