summaryrefslogtreecommitdiffstats
path: root/static/volunteer
diff options
context:
space:
mode:
authorrsiddharth <s@ricketyspace.net>2019-05-22 22:10:30 -0400
committerrsiddharth <s@ricketyspace.net>2019-05-22 22:10:30 -0400
commit9b82967f2fa3b8ffa3372b46e08035d99625bcec (patch)
tree3bb104add79542c3386789e44080985d63f7ae14 /static/volunteer
parent8395b98858f72c5d6c6d86236b9e25780d897c59 (diff)
Add static/volunteer/submit.
Diffstat (limited to 'static/volunteer')
-rw-r--r--static/volunteer/submit/ack.html46
-rw-r--r--static/volunteer/submit/index.php65
2 files changed, 111 insertions, 0 deletions
diff --git a/static/volunteer/submit/ack.html b/static/volunteer/submit/ack.html
new file mode 100644
index 0000000..454cb8b
--- /dev/null
+++ b/static/volunteer/submit/ack.html
@@ -0,0 +1,46 @@
+<!--#include virtual="/includes/html-open.html"-->
+
+<!--#include virtual="/includes/header-open.html"-->
+<title>Submit &mdash; Volunteer &mdash; Free Software Foundation India</title>
+<!--#include virtual="/includes/header-close.html"-->
+
+<!--#include virtual="/includes/body-open.html"-->
+<!--#include virtual="/includes/navbar.html"-->
+
+<div class="container main">
+ <section class="section">
+ <div class="content">
+ <header>
+ <h1>Volunteer</h1>
+ </header>
+
+ <div class="columns">
+ <div class="column is-three-fifths">
+
+ <?php if ($result['ok']) { ?>
+ <p>Thank you! We'll get back to you soon.</p>
+ <?php } else { ?>
+ <p>Oops! There were some issues:</p>
+
+ <ul>
+ <?php foreach ($result['errors'] as $e) { ?>
+ <li><?=$e?></li>
+ <?php } ?>
+ </ul>
+
+ <a class="button is-link" href="/volunteer">Try again</a>
+ <?php } ?>
+
+
+ </div> <!-- end column -->
+ </div> <!-- end columns -->
+
+ </div>
+ </section>
+
+</div>
+
+<!--#include virtual="/includes/footer.html"-->
+<!--#include virtual="/includes/js.html"-->
+<!--#include virtual="/includes/body-close.html"-->
+<!--#include virtual="/includes/html-close.html"-->
diff --git a/static/volunteer/submit/index.php b/static/volunteer/submit/index.php
new file mode 100644
index 0000000..732e031
--- /dev/null
+++ b/static/volunteer/submit/index.php
@@ -0,0 +1,65 @@
+<?php
+
+/**
+ *
+ * SPDX-License-Identifier: ISC
+ *
+ * Copyright © 2019 Free Software Foundation of India.
+ *
+ */
+
+function to() {
+ return 's@cygnus.ricketyspace.net';
+}
+
+function email_valid($e) {
+ if (preg_match('/([\w.-]+)@([\w.-]+)/', $e)) {
+ return true;
+ }
+ return false;
+}
+
+function send($n, $e, $m) {
+ $p = $n . ' <' . $e . '>';
+ return mail(to(),
+ $p . ' wants to volunteer for FSF India',
+ 'Per says:' . PHP_EOL . PHP_EOL . $m
+ );
+}
+
+function em_fw($t) {
+ return preg_replace('/^(\w+)( .+)/', '<strong>$1</strong>$2', $t);
+}
+
+function post() {
+ $n = $_POST['name'];
+ $e = $_POST['email'];
+ $m = $_POST['msg'];
+
+ $errors = [];
+ if (empty($n)) {
+ $errors[] = em_fw('Name is required');
+ }
+ if (!email_valid($e)) {
+ $errors[] = em_fw('Email is invalid');
+ }
+ if (empty($m)) {
+ $errors[] = em_fw('Message is required');
+ }
+
+ $sok = true;
+ if (empty($error)) {
+ $sok = send($n, $e, $m);
+ }$sok = false;
+ if (!$sok) {
+ $errors[] = 'Unable to process your submission.';
+ }
+
+ return [
+ 'ok' => empty($errors) && $sok,
+ 'errors' => $errors
+ ];
+}
+
+$result = post();
+include(__DIR__ . '/ack.html');