#!/bin/bash

# CONFIG
#host="localhost"
host=$1
#################


# FLAG
flag=`cat LastFlag`

user=`curl -s http://$host/cgi-bin/webhoster/reg.cgi | grep "UID:" | awk {'print $3'}`
if [ -z $user ]; then
	echo "Error: Got no UserID!"
else
	echo "Got UserID"
	webpage="<html><head><title>private page</title></head><body>Born to flag: $flag </body></html>"
	wget "http://$host/cgi-bin/webhoster/write.cgi?uid=$user&garfield=$webpage" -O HTMLfeedback -q

	echo "Set flag \"$flag\" for UID \"$user\""
	echo $user > LastUserID
	echo "`date +%s` - $user - $flag" >> TimeUserFlagList
fi
