From 31e2d517c363bf4d0347ad6e0d997ecccf798d8d Mon Sep 17 00:00:00 2001
From: Neale Pickett
Date: Wed, 7 Oct 2009 15:45:02 -0600
Subject: [PATCH] Make survey record answers
---
Makefile | 3 ++
.../1000000/{submit.cgi => ,submit.cgi} | 10 ++++-
puzzles/survey/1000000/,survey.html | 44 +++++++++++++++++++
puzzles/survey/1000000/index.html | 39 ++--------------
4 files changed, 60 insertions(+), 36 deletions(-)
rename puzzles/survey/1000000/{submit.cgi => ,submit.cgi} (57%)
create mode 100644 puzzles/survey/1000000/,survey.html
diff --git a/Makefile b/Makefile
index 7b71e7a..d644fd8 100644
--- a/Makefile
+++ b/Makefile
@@ -17,6 +17,9 @@ all: ctf.tce
target: $(PYC)
$(INSTALL) -d --mode=0755 --owner=100 $(DESTDIR)/var/lib/ctf
+
+ $(INSTALL) -d --mode=0755 --owner=100 $(DESTDIR)/var/lib/ctf/survey
+
$(INSTALL) -d $(DESTDIR)/var/lib/ctf/disabled
touch $(DESTDIR)/var/lib/ctf/disabled/survey
diff --git a/puzzles/survey/1000000/submit.cgi b/puzzles/survey/1000000/,submit.cgi
similarity index 57%
rename from puzzles/survey/1000000/submit.cgi
rename to puzzles/survey/1000000/,submit.cgi
index 58549a7..39a9a08 100755
--- a/puzzles/survey/1000000/submit.cgi
+++ b/puzzles/survey/1000000/,submit.cgi
@@ -1,6 +1,8 @@
#! /usr/bin/env python3
import cgi
+import time
+import os
f = cgi.FieldStorage()
if f.getfirst('submit'):
@@ -8,7 +10,13 @@ if f.getfirst('submit'):
print()
print('Thanks for filling in the survey.')
print()
- print(dir(f))
+ try:
+ fn = '/var/lib/ctf/survey/%s.%d.%d.txt' % (time.strftime('%Y-%m-%d'), time.time(), os.getpid())
+ o = open(fn, 'w')
+ for k in f.keys():
+ o.write('%s: %r\n' % (k, f.getlist(k)))
+ except IOError:
+ pass
print('The key is:')
print(' quux blorb frotz')
else:
diff --git a/puzzles/survey/1000000/,survey.html b/puzzles/survey/1000000/,survey.html
new file mode 100644
index 0000000..0ed037b
--- /dev/null
+++ b/puzzles/survey/1000000/,survey.html
@@ -0,0 +1,44 @@
+
+
+
+
+ Survey
+
+
+
+
+
+
+
diff --git a/puzzles/survey/1000000/index.html b/puzzles/survey/1000000/index.html
index 2b39091..aa2727d 100644
--- a/puzzles/survey/1000000/index.html
+++ b/puzzles/survey/1000000/index.html
@@ -4,38 +4,7 @@
recieve a key redeemable for ONE MILLION POINTS.
-
+