blob: fcaffaaf37f458ab7ed0aa23c7db96a3ea23bfb9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
#!/bin/bash
[ -x /etc/icpc/bocaserver.sh ] && . /etc/icpc/bocaserver.sh
if [ "$BOCASERVER" == "" ]; then
echo "This computer has no configured BOCA server. Ask an admin to update /etc/icpc/bocaserver.sh (usually resetting everything is an easy way)"
exit 1
fi
[ -x /etc/icpc/bocaservers.sh ] && . /etc/icpc/bocaservers.sh
if [ "$BOCASERVERS" == "" ]; then
BOCASERVERS=$BOCASERVER
else
BOCASERVERS="$BOCASERVER;$BOCASERVER"
fi
for i in uuencode wget tr perl sha256sum cut; do
p=`which $i`
if [ -x "$p" ]; then
echo -n ""
else
echo "$i" not found
exit 1
fi
done
temp=/tmp/.temp.`date +%s%N`.txt
if [ "$1" == "" ]; then
echo "Usage: $0 USER PASSWORD PROBLEM LANGUAGE FILE"
echo ""
echo "where USER is your username"
echo "PASSWORD is your password"
echo "FILE is your submission file"
echo "PROBLEM and LANGUAGE are according to defined in BOCA"
exit 1
fi
if [ -r "$5" ]; then
nom=`echo -n "$5" | perl -MURI::Escape -lne 'print uri_escape($_)'`
for BOCASERVER in `echo $BOCASERVERS | cut -d';'`; do
md=`wget -t 2 -T 7 -S http://$BOCASERVER/boca/index.php -O /dev/null --save-cookies /tmp/.cookie.txt --keep-session-cookies 2>&1 | grep PHPSESS | tail -n1`
echo "$md" | grep -q PHPSESS
if [ "$?" == "0" ]; then
md=`echo $md | cut -f2 -d'=' | cut -f1 -d';'`
user=$1
pass=$2
res=`echo -n $pass | sha256sum - | cut -f1 -d' '`
res=`echo -n "${res}${md}" | sha256sum - | cut -f1 -d' '`
wget "http://$BOCASERVER/boca/index.php?name=${user}&password=${res}" --load-cookies /tmp/.cookie.txt --keep-session-cookies --save-cookies /tmp/.cookie.txt -O $temp 2>/dev/null >/dev/null
grep -qi incorrect $temp
if [ $? == 0 ]; then
echo "$BOCASERVER: User or password incorrect"
else
echo -n "name=${nom}&data=" > $temp
uuencode -m zzzzzzzzzz < $1 | grep -v "begin-base64.*zzzzzzzzzz" | perl -MURI::Escape -lne 'print uri_escape($_)' >> $temp
wget "http://$BOCASERVER/boca/team/getfile.php" --load-cookies /tmp/.cookie.txt --keep-session-cookies -O /dev/null --post-file=$temp >/dev/null 2>/dev/null
fi
rm -f $temp
rm -f /tmp/.cookie.txt
else
echo "$BOCASERVER: time-out - this will automatically retry soon, you should not worry"
echo "BOCASERVER=$BOCASERVER" > $temp
echo "user=$user" >> $temp
echo "pass=$pass" >> $temp
echo "name=${nom}" >> $temp
echo -n "data=" >> $temp
uuencode -m zzzzzzzzzz < "$5" | grep -v "begin-base64.*zzzzzzzzzz" | perl -MURI::Escape -lne 'print uri_escape($_)' >> $temp
echo "" >> $temp
boca-submit-run-root $temp
fi
done
else
echo "file $1 not found/readable"
fi
|