parent
f3121aaf96
commit
dd6f529919
@ -0,0 +1,2 @@ |
||||
AddHandler cgi-script .cgi |
||||
Options +Indexes +ExecCGI |
@ -1,3 +1,3 @@ |
||||
FILES = index.html register.html
|
||||
FILES = index.html register.html register-fail.html register-success.html register.cgi .htaccess
|
||||
RELDIR = opencl/
|
||||
include ../common.mk |
||||
|
@ -0,0 +1,17 @@ |
||||
<?xml version='1.0'?> |
||||
|
||||
<!DOCTYPE cscpage SYSTEM "../csc.dtd"> |
||||
|
||||
<cscpage title="CSC/AMD OpenCL Competition Registration"> |
||||
<header /> |
||||
|
||||
<section title="CSC/AMD OpenCL Competition Registration"> |
||||
<p> |
||||
|
||||
You didn't fill out all required information on the registration form. Please <a href="register">try again</a>. |
||||
|
||||
</p> |
||||
</section> |
||||
|
||||
<footer /> |
||||
</cscpage> |
@ -0,0 +1,17 @@ |
||||
<?xml version='1.0'?> |
||||
|
||||
<!DOCTYPE cscpage SYSTEM "../csc.dtd"> |
||||
|
||||
<cscpage title="CSC/AMD OpenCL Competition Registration"> |
||||
<header /> |
||||
|
||||
<section title="CSC/AMD OpenCL Competition Registration"> |
||||
<p> |
||||
|
||||
Thank you for registering to participate. Your information has been recorded, and we will be contacting you shortly with further instructions. |
||||
|
||||
</p> |
||||
</section> |
||||
|
||||
<footer /> |
||||
</cscpage> |
@ -0,0 +1,41 @@ |
||||
#!/usr/bin/env racket |
||||
#lang racket |
||||
(require srfi/98) |
||||
(require net/uri-codec) |
||||
(require net/smtp) |
||||
|
||||
(define ERROR-HEADER "Location: http://csclub.uwaterloo.ca/opencl/register-fail\n\n") |
||||
(define SUCCESS-HEADER "Location: http://csclub.uwaterloo.ca/opencl/register-success\n\n") |
||||
|
||||
(define (is-user? str) (equal? (list str) (regexp-match #rx"[A-Za-z0-9._]+" str))) |
||||
(define (is-email? str) (equal? (list str) (regexp-match #rx"[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+" str))) |
||||
|
||||
(define required-fields `( (quest . ,is-user?) (email . ,is-email?))) |
||||
(define check-fields '(team open closed)) |
||||
|
||||
(define (identity x) x) |
||||
|
||||
(let* |
||||
((post-data (form-urlencoded->alist (port->string))) |
||||
(required-extract |
||||
(map |
||||
(lambda(x) (let ((e (assoc (car x) post-data))) |
||||
(cond [(false? e) #f] |
||||
[((cdr x) (cdr e)) e] |
||||
[else #f]))) |
||||
required-fields)) |
||||
(check-extract (filter identity (map ((curryr assoc) post-data) check-fields))) |
||||
(filled-out? (andmap identity required-extract))) |
||||
(when (not filled-out?) |
||||
(printf ERROR-HEADER) |
||||
(exit 0)) |
||||
(smtp-send-message |
||||
"caffeine.csclub.uwaterloo.ca" |
||||
"opencl-contest-registration@csclub" |
||||
(list "init512@gmail.com") |
||||
"Subject: Contestant registered!\n\n" |
||||
(list (with-output-to-string |
||||
(lambda() (write (append required-extract check-extract)))))) |
||||
(printf SUCCESS-HEADER) |
||||
(exit 0)) |
||||
|
Loading…
Reference in new issue