diff options
Diffstat (limited to 'tools/boca-submit-run-aux')
| -rwxr-xr-x | tools/boca-submit-run-aux | 53 |
1 files changed, 36 insertions, 17 deletions
diff --git a/tools/boca-submit-run-aux b/tools/boca-submit-run-aux index a9ff432..1be0945 100755 --- a/tools/boca-submit-run-aux +++ b/tools/boca-submit-run-aux @@ -5,6 +5,10 @@ if [ "$BOCASERVER" == "" -o "$user" == "" -o "$pass" == "" -o "$data" == "" -o " echo "parameters missing in file $1" exit 1 fi +if [ "$problem" == "" -o "$language" == "" ]; then + echo "parameters missing in file $1" + exit 1 +fi for i in uuencode wget tr perl sha256sum cut; do p=`which $i` @@ -17,49 +21,64 @@ for i in uuencode wget tr perl sha256sum cut; do done temp=/tmp/.temp.`date +%s%N`.txt -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` +md=`wget -t 2 -T 5 -S http://$BOCASERVER/boca/index.php -O /dev/null --save-cookies ${temp}.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';'` res=`echo -n $pass | sha256sum - | cut -f1 -d' '` res=`echo -n "${res}${md}" | sha256sum - | cut -f1 -d' '` - wget -t 2 -T 7 "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 + wget -t 2 -T 5 "http://$BOCASERVER/boca/index.php?name=${user}&password=${res}" --load-cookies ${temp}.cookie.txt --keep-session-cookies --save-cookies ${temp}.cookie.txt -O $temp 2>/dev/null >/dev/null grep -qi incorrect $temp if [ $? == 0 ]; then echo "$BOCASERVER: User or password incorrect" rm -f $temp - rm -f /tmp/.cookie.txt + rm -f ${temp}.cookie.txt exit 3 else - echo -n "name=${nom}" > $temp + echo -n "name=`echo $name | perl -MURI::Escape -lne 'print uri_escape($_)'`" > $temp if [ "$uniq" != "" ]; then echo -n "&pastcode=$uniq" >> $temp if [ "$code" != "" ]; then echo -n "&pasthash=$code" >> $temp - if [ "$dateerr" != "" ]; then - echo -n "&pastabs=${dateerr}" - let "dateerr = `date +%s` - $dateerr" - echo -n "&pastval=${dateerr}" + fi + if [ "$dateerr" != "" ]; then + echo -n "&pastabs=${dateerr}" >> $temp + let "dateerr = `date +%s` - $dateerr" + echo -n "&pastval=${dateerr}" >> $temp + if [ -r /root/submissions/code ]; then + code=`cat /root/submissions/code` + res=`echo -n "${code}${uniq}${dateerr}" | sha256sum - | cut -f1 -d' '` + echo -n "&pastvalhash=${res}" >> $temp fi fi fi - - echo -n "&data=" >> $temp - uuencode -m zzzzzzzzzz < $1 | grep -v "begin-base64.*zzzzzzzzzz" | perl -MURI::Escape -lne 'print uri_escape($_)' >> $temp - wget -t 2 -T 7 "http://$BOCASERVER/boca/team/run.php" --load-cookies /tmp/.cookie.txt --keep-session-cookies -O /dev/null --post-file=$temp >${temp}.out 2>/dev/null + echo -n "&problem=`echo $problem | perl -MURI::Escape -lne 'print uri_escape($_)'`" >> $temp + echo -n "&language=`echo $language | perl -MURI::Escape -lne 'print uri_escape($_)'`" >> $temp + echo -n "&data=`echo $data | tr -d ' ' | perl -MURI::Escape -lne 'print uri_escape($_)'`" >> $temp + wget -t 2 -T 5 "http://$BOCASERVER/boca/team/run.php" --load-cookies ${temp}.cookie.txt --keep-session-cookies -O ${temp}.out --post-file=$temp >/dev/null 2>/dev/null res=`tail -n1 ${temp}.out` echo $res | grep -q "RESULT:" if [ "$?" == "0" ]; then - echo "$BOCASERVER : run $uniq dateerr $dateerr : $res" - rm -f "$1" + if [ "$uniq" == "" ]; then + echo "$BOCASERVER : $res" + else + echo "$BOCASERVER : run $uniq dateerr $dateerr : $res" + fi else - echo "$BOCASERVER : run $uniq dateerr $dateerr : error to upload the run, will NOT try again, check details" + if [ "$uniq" == "" ]; then + echo "$BOCASERVER : error to upload the run, will NOT try again, check details" + else + echo "$BOCASERVER : run $uniq dateerr $dateerr : error to upload the run, will NOT try again, check details:" + cat ${temp}.out + fi + rm -f ${temp}.out + exit 4 fi rm -f ${temp}.out fi - rm -f $temp - rm -f /tmp/.cookie.txt + [ -f "$temp" ] && rm -f "$temp" + rm -f ${temp}.cookie.txt else exit 2 fi |