Registration is working

This commit is contained in:
Neale Pickett 2015-04-12 09:16:48 -06:00
parent dcc99528a8
commit c0f0893ba5
6 changed files with 79 additions and 18 deletions

View File

@ -52,5 +52,12 @@
<li>lua</li> <li>lua</li>
</ul> </ul>
</section> </section>
<nav>
<ul>
<li><a href="register.html">Register</a></li>
<li><a href="puzzles.html">Puzzles</a></li>
<li><a href="scoreboard.html">Scoreboard</a></li>
</ul>
</nav>
</body> </body>
</html> </html>

View File

@ -3,10 +3,10 @@
# Change to CTF_BASE # Change to CTF_BASE
cd ${CTF_BASE:-.} cd ${CTF_BASE:-.}
for i in $(seq 5); do for i in $(seq 5); do
[ -d packages ] && break [ -f assigned.txt ] && break
cd .. cd ..
done done
if ! [ -d packages ]; then if ! [ -f assigned.txt ]; then
cat <<EOF cat <<EOF
Content-type: text/html Content-type: text/html
@ -17,7 +17,7 @@ fi
# Read CGI parameters # Read CGI parameters
param () { param () {
ret=$(echo "$QUERY_STRING" | tr '=&' ' \n' | awk -v "k=$1" '($1==k) {print $2;}') ret=$(echo "$QUERY_STRING" | awk -F '=' -v 'RS=&' -v "k=$1" '($1==k) {print $2;}')
ret=$(busybox httpd -d "$ret" || echo "$ret") ret=$(busybox httpd -d "$ret" || echo "$ret")
echo "$ret" echo "$ret"
} }
@ -30,26 +30,40 @@ Content-type: text/html
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<title>Team Registration</title> <meta charset="UTF-8">
<link rel="stylesheet" href="ctf.css" type="text/css"> <title>Team Registration</title>
</head> <link rel="stylesheet" href="css/style.css" type="text/css">
<body> </head>
<h1>Team Registration</h1> <body>
<h1>Team Registration</h1>
<section>
EOF EOF
if [ -z "$hash" ] || [ -z "$team" ]; then if [ -z "$hash" ] || [ -z "$team" ]; then
echo "<h2>Oops!</h2>"
echo "<p>Empty field, cannot complete request</p>" echo "<p>Empty field, cannot complete request</p>"
elif ! grep -q "^$hash$" assigned.txt; then elif ! grep -q "^$hash$" assigned.txt; then
echo "<h2>Oops!</h2>"
echo "<p>That hash has not been assigned.</p>" echo "<p>That hash has not been assigned.</p>"
elif [ -f state/teams/names/$hash ]; then elif [ -f state/teams/$hash ]; then
echo "<h2>Oops!</h2>"
echo "<p>That hash has already been registered.</p>" echo "<p>That hash has already been registered.</p>"
else else
printf "%s" "$team" > state/teams/names/$hash printf "%s" "$team" > state/teams/$hash
echo "<h2>Success!</h2>"
echo "<p>Okay, your team has been named and you may begin using your hash!</p>" echo "<p>Okay, your team has been named and you may begin using your hash!</p>"
fi fi
cat <<EOF cat <<EOF
</body> </section>
<nav>
<ul>
<li><a href="register.html">Register</a></li>
<li><a href="puzzles.html">Puzzles</a></li>
<li><a href="scoreboard.html">Scoreboard</a></li>
</ul>
</nav>
</body>
</html> </html>
EOF EOF

View File

@ -8,14 +8,22 @@
<h1>Team Registration</h1> <h1>Team Registration</h1>
<section> <section>
<h2>Register Your Team</h2>
<p> <p>
Before you can use a token, you must choose a team name. Before you can use a token, you must choose a team name.
You can only do this once per token, You can only do this once,
so make sure it's the team name you actually want. so make sure it's the team name you actually want.
Staff are unable to make changes to team names. Staff are unable to make changes to team names.
</p> </p>
<p>
If somebody on your team has already registered your hash,
you don't need to do it again.
</p>
<form method="get" action="register.cgi"> <form method="get" action="register.cgi">
<label>Team Hash (Token):</label> <label>Team Hash:</label>
<input type="text" name="h"> <input type="text" name="h">
<br> <br>
<label>Team Name:</label> <label>Team Name:</label>
@ -24,5 +32,12 @@
<input type="submit" value="Register"> <input type="submit" value="Register">
</form> </form>
</section> </section>
<nav>
<ul>
<li><a href="register.html">Register</a></li>
<li><a href="puzzles.html">Puzzles</a></li>
<li><a href="scoreboard.html">Scoreboard</a></li>
</ul>
</nav>
</body> </body>
</html> </html>

View File

@ -105,5 +105,12 @@
while the organizers struggle to get things back up. while the organizers struggle to get things back up.
</p> </p>
</section> </section>
<nav>
<ul>
<li><a href="register.html">Register</a></li>
<li><a href="puzzles.html">Puzzles</a></li>
<li><a href="scoreboard.html">Scoreboard</a></li>
</ul>
</nav>
</body> </body>
</html> </html>

17
install
View File

@ -37,17 +37,27 @@ cc () {
fi fi
} }
web () {
target=$DESTDIR/www/${1#*/}
if older $target $1; then
echo "WEB $1"
mkdir -p $(dirname $target)
cp $1 $target
fi
}
cgi () { cgi () {
target=$DESTDIR/www/$(basename $1 .c) target=$DESTDIR/www/$(basename $1 .c)
if older $target $@; then if older $target $@; then
mkdir -p $(dirname $target) mkdir -p $(dirname $target)
src=$1; shift src=$1; shift
echo "CC $src" echo "CGI $src"
gcc -Wall -Werror -o $target $@ src/common.c $src gcc -Wall -Werror -o $target $@ src/common.c $src
fi fi
} }
setup() { setup() {
[ -d $DESTDIR/state ] && return
echo "SETUP" echo "SETUP"
for i in points.new points.tmp teams; do for i in points.new points.tmp teams; do
dir=$DESTDIR/state/$i dir=$DESTDIR/state/$i
@ -56,7 +66,7 @@ setup() {
done done
>> $DESTDIR/state/points.log >> $DESTDIR/state/points.log
if ! [ -f $DESTDIR/assigned.txt ]; then if ! [ -f $DESTDIR/assigned.txt ]; then
hd </dev/urandom | awk '{print $3 $4 $5 $6;}' | head -n 100 > assigned.txt hd </dev/urandom | awk '{print $3 $4 $5 $6;}' | head -n 100 > $DESTDIR/assigned.txt
fi fi
} }
@ -72,6 +82,7 @@ fi
mkdir -p $DESTDIR || exit 1 mkdir -p $DESTDIR || exit 1
setup
git ls-files | while read fn; do git ls-files | while read fn; do
case "$fn" in case "$fn" in
install|.*) install|.*)
@ -79,7 +90,7 @@ git ls-files | while read fn; do
doc/*) doc/*)
;; ;;
html/*) html/*)
copy $fn web $fn
;; ;;
bin/*) bin/*)
copy $fn copy $fn

View File

@ -201,7 +201,14 @@ cgi_head(char *title)
void void
cgi_foot() cgi_foot()
{ {
printf("\n</section></body></html>\n"); printf("\n</section>\n");
printf("<nav><ul>\n");
printf("<li><a href="register.html">Register</a></li>\n");
printf("<li><a href="puzzles.html">Puzzles</a></li>\n");
printf("<li><a href="scoreboard.html">Scoreboard</a></li>\n");
printf("</ul></nav>\n");
printf("</body></html>\n");
} }
void void