Registration is working

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

View File

@ -52,5 +52,12 @@
<li>lua</li>
</ul>
</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>

View File

@ -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 <<EOF
Content-type: text/html
@ -17,7 +17,7 @@ fi
# Read CGI parameters
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")
echo "$ret"
}
@ -30,26 +30,40 @@ Content-type: text/html
<!DOCTYPE html>
<html>
<head>
<title>Team Registration</title>
<link rel="stylesheet" href="ctf.css" type="text/css">
</head>
<body>
<h1>Team Registration</h1>
<head>
<meta charset="UTF-8">
<title>Team Registration</title>
<link rel="stylesheet" href="css/style.css" type="text/css">
</head>
<body>
<h1>Team Registration</h1>
<section>
EOF
if [ -z "$hash" ] || [ -z "$team" ]; then
echo "<h2>Oops!</h2>"
echo "<p>Empty field, cannot complete request</p>"
elif ! grep -q "^$hash$" assigned.txt; then
echo "<h2>Oops!</h2>"
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>"
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>"
fi
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>
EOF

View File

@ -8,14 +8,22 @@
<h1>Team Registration</h1>
<section>
<h2>Register Your Team</h2>
<p>
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.
</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">
<label>Team Hash (Token):</label>
<label>Team Hash:</label>
<input type="text" name="h">
<br>
<label>Team Name:</label>
@ -24,5 +32,12 @@
<input type="submit" value="Register">
</form>
</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>

View File

@ -105,5 +105,12 @@
while the organizers struggle to get things back up.
</p>
</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>

17
install
View File

@ -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 </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
}
@ -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

View File

@ -201,7 +201,14 @@ cgi_head(char *title)
void
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