From a701683c7353d9dfaeaf209f7c2e0f03270230aa Mon Sep 17 00:00:00 2001 From: Neale Pickett Date: Sun, 12 Apr 2015 09:16:48 -0600 Subject: [PATCH] Registration is working --- html/credits.html | 7 +++++++ {bin => html}/register.cgi | 38 ++++++++++++++++++++++++++------------ html/register.html | 19 +++++++++++++++++-- html/scoring.html | 7 +++++++ install | 17 ++++++++++++++--- src/common.c | 9 ++++++++- 6 files changed, 79 insertions(+), 18 deletions(-) rename {bin => html}/register.cgi (50%) diff --git a/html/credits.html b/html/credits.html index d0c8756..bea2939 100644 --- a/html/credits.html +++ b/html/credits.html @@ -52,5 +52,12 @@
  • lua
  • + diff --git a/bin/register.cgi b/html/register.cgi similarity index 50% rename from bin/register.cgi rename to html/register.cgi index 23ad37f..65d2781 100755 --- a/bin/register.cgi +++ b/html/register.cgi @@ -3,10 +3,10 @@ # Change to CTF_BASE cd ${CTF_BASE:-.} for i in $(seq 5); do - [ -d packages ] && break + [ -f assigned.txt ] && break cd .. done -if ! [ -d packages ]; then +if ! [ -f assigned.txt ]; then cat < - - Team Registration - - - -

    Team Registration

    + + + Team Registration + + + +

    Team Registration

    +
    EOF if [ -z "$hash" ] || [ -z "$team" ]; then + echo "

    Oops!

    " echo "

    Empty field, cannot complete request

    " elif ! grep -q "^$hash$" assigned.txt; then + echo "

    Oops!

    " echo "

    That hash has not been assigned.

    " -elif [ -f state/teams/names/$hash ]; then +elif [ -f state/teams/$hash ]; then + echo "

    Oops!

    " echo "

    That hash has already been registered.

    " else - printf "%s" "$team" > state/teams/names/$hash + printf "%s" "$team" > state/teams/$hash + echo "

    Success!

    " echo "

    Okay, your team has been named and you may begin using your hash!

    " fi cat < +
    + + EOF diff --git a/html/register.html b/html/register.html index d9cc89c..90bbcec 100644 --- a/html/register.html +++ b/html/register.html @@ -8,14 +8,22 @@

    Team Registration

    +

    Register Your Team

    +

    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. Staff are unable to make changes to team names.

    + +

    + If somebody on your team has already registered your hash, + you don't need to do it again. +

    +
    - +
    @@ -24,5 +32,12 @@
    + diff --git a/html/scoring.html b/html/scoring.html index 563851c..f318f22 100644 --- a/html/scoring.html +++ b/html/scoring.html @@ -105,5 +105,12 @@ while the organizers struggle to get things back up.

    + diff --git a/install b/install index 29afd5c..b662d69 100755 --- a/install +++ b/install @@ -37,17 +37,27 @@ cc () { fi } +web () { + target=$DESTDIR/www/${1#*/} + if older $target $1; then + echo "WEB $1" + mkdir -p $(dirname $target) + cp $1 $target + fi +} + cgi () { target=$DESTDIR/www/$(basename $1 .c) if older $target $@; then mkdir -p $(dirname $target) src=$1; shift - echo "CC $src" + echo "CGI $src" gcc -Wall -Werror -o $target $@ src/common.c $src fi } setup() { + [ -d $DESTDIR/state ] && return echo "SETUP" for i in points.new points.tmp teams; do dir=$DESTDIR/state/$i @@ -56,7 +66,7 @@ setup() { done >> $DESTDIR/state/points.log if ! [ -f $DESTDIR/assigned.txt ]; then - hd assigned.txt + hd $DESTDIR/assigned.txt fi } @@ -72,6 +82,7 @@ fi mkdir -p $DESTDIR || exit 1 +setup git ls-files | while read fn; do case "$fn" in install|.*) @@ -79,7 +90,7 @@ git ls-files | while read fn; do doc/*) ;; html/*) - copy $fn + web $fn ;; bin/*) copy $fn diff --git a/src/common.c b/src/common.c index 6d39628..93001df 100644 --- a/src/common.c +++ b/src/common.c @@ -201,7 +201,14 @@ cgi_head(char *title) void cgi_foot() { - printf("\n\n"); + printf("\n\n"); + printf("\n"); + printf("\n"); + } void