2011-03-08 23:06:21 -07:00
|
|
|
#! /bin/sh -e
|
|
|
|
|
2013-06-07 21:05:26 -06:00
|
|
|
# Change to CTF_BASE
|
|
|
|
cd ${CTF_BASE:-.}
|
|
|
|
for i in $(seq 5); do
|
2015-04-12 09:16:48 -06:00
|
|
|
[ -f assigned.txt ] && break
|
2013-06-07 21:05:26 -06:00
|
|
|
cd ..
|
|
|
|
done
|
2015-04-12 09:16:48 -06:00
|
|
|
if ! [ -f assigned.txt ]; then
|
2013-06-07 21:05:26 -06:00
|
|
|
cat <<EOF
|
|
|
|
Content-type: text/html
|
|
|
|
|
|
|
|
Cannot find CTF_BASE
|
|
|
|
EOF
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Read CGI parameters
|
2013-02-04 22:34:45 -07:00
|
|
|
param () {
|
2015-04-12 09:16:48 -06:00
|
|
|
ret=$(echo "$QUERY_STRING" | awk -F '=' -v 'RS=&' -v "k=$1" '($1==k) {print $2;}')
|
2013-02-04 22:34:45 -07:00
|
|
|
ret=$(busybox httpd -d "$ret" || echo "$ret")
|
2013-02-05 23:03:10 -07:00
|
|
|
echo "$ret"
|
2013-02-04 22:34:45 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
team=$(param n)
|
|
|
|
hash=$(param h | tr -dc 0-9a-f)
|
2011-03-08 23:06:21 -07:00
|
|
|
|
|
|
|
cat <<EOF
|
|
|
|
Content-type: text/html
|
|
|
|
|
|
|
|
<!DOCTYPE html>
|
|
|
|
<html>
|
2015-04-12 09:16:48 -06:00
|
|
|
<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>
|
2011-03-08 23:06:21 -07:00
|
|
|
EOF
|
|
|
|
|
2013-02-05 23:07:35 -07:00
|
|
|
if [ -z "$hash" ] || [ -z "$team" ]; then
|
2015-04-12 09:16:48 -06:00
|
|
|
echo "<h2>Oops!</h2>"
|
2013-02-05 23:07:35 -07:00
|
|
|
echo "<p>Empty field, cannot complete request</p>"
|
2015-04-10 16:37:21 -06:00
|
|
|
elif ! grep -q "^$hash$" assigned.txt; then
|
2015-04-12 09:16:48 -06:00
|
|
|
echo "<h2>Oops!</h2>"
|
2013-02-05 23:06:45 -07:00
|
|
|
echo "<p>That hash has not been assigned.</p>"
|
2015-04-12 09:16:48 -06:00
|
|
|
elif [ -f state/teams/$hash ]; then
|
|
|
|
echo "<h2>Oops!</h2>"
|
2013-02-05 23:06:45 -07:00
|
|
|
echo "<p>That hash has already been registered.</p>"
|
2011-03-08 23:06:21 -07:00
|
|
|
else
|
2015-04-12 09:16:48 -06:00
|
|
|
printf "%s" "$team" > state/teams/$hash
|
|
|
|
echo "<h2>Success!</h2>"
|
2013-02-05 23:06:45 -07:00
|
|
|
echo "<p>Okay, your team has been named and you may begin using your hash!</p>"
|
2011-03-08 23:06:21 -07:00
|
|
|
fi
|
2013-02-04 22:34:45 -07:00
|
|
|
|
2011-03-08 23:06:21 -07:00
|
|
|
cat <<EOF
|
2015-04-12 09:16:48 -06:00
|
|
|
</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>
|
2011-03-08 23:06:21 -07:00
|
|
|
</html>
|
|
|
|
EOF
|