diff options
| author | Cassio de Campos <cassiopc@gmail.com> | 2018-08-24 19:08:09 +0000 |
|---|---|---|
| committer | Cassio de Campos <cassiopc@gmail.com> | 2018-08-24 19:08:09 +0000 |
| commit | c8994053b1ff9ccf47b532be6567c0f7f33f5f3c (patch) | |
| tree | 3377c9e4bd71ab5f8cd4e1a33e701e17575d803c | |
| parent | 9a5387bd2637cdc9fb0496d094e503e484be10e9 (diff) | |
| download | boca-c8994053b1ff9ccf47b532be6567c0f7f33f5f3c.tar.gz boca-c8994053b1ff9ccf47b532be6567c0f7f33f5f3c.zip | |
fixed typos, back some required files
| -rw-r--r-- | src/fcontest.php | 2 | ||||
| -rw-r--r-- | src/frun.php | 15 | ||||
| -rw-r--r-- | src/judge/clar.php | 2 | ||||
| -rw-r--r-- | src/judge/team.php | 2 | ||||
| -rw-r--r-- | src/scoretable.php | 7 | ||||
| -rw-r--r-- | src/team/header.php | 2 | ||||
| -rw-r--r-- | src/team/run.php | 2 | ||||
| -rw-r--r-- | tools/boca-submit-log | 66 | ||||
| -rw-r--r-- | tools/cron-boca-fixssh | 1 | ||||
| -rw-r--r-- | tools/cron-boca-log | 1 | ||||
| -rw-r--r-- | tools/cron-boca-submit | 1 | ||||
| -rw-r--r-- | tools/tst.php | 11 |
12 files changed, 87 insertions, 25 deletions
diff --git a/src/fcontest.php b/src/fcontest.php index e61631b..9989931 100644 --- a/src/fcontest.php +++ b/src/fcontest.php @@ -125,7 +125,7 @@ CREATE TABLE \"sitetimetable\" ( $r = DBexec($c, "CREATE INDEX \"sitetimesite_index\" ON \"sitetimetable\" USING btree ". "(\"contestnumber\" int4_ops, \"sitenumber\" int4_ops)", "DBCreateSiteTimeTable(create site_index)"); } -// begin; update answertable set updatetime=EXTRACT(EPOCH FROM now()); +// begin; update answertable set updatetime=EXTRACT(EPOCH FROM now()); select * from answertable; // begin; update langtable set updatetime=EXTRACT(EPOCH FROM now()); select * from langtable; // begin; update problemtable set updatetime=EXTRACT(EPOCH FROM now()); select * from problemtable; diff --git a/src/frun.php b/src/frun.php index 473c4a5..bc9dc2f 100644 --- a/src/frun.php +++ b/src/frun.php @@ -359,13 +359,14 @@ function DBGetRunToAnswerC($number,$site,$contest,$chief) { "r.runnumber=$number"; if ($chief != 1) { $sql .= " and (r.runstatus='openrun' or " . - "(r.runstatus='judged+' and r.runjudge is NULL) or " . - "((r.runstatus='judging' or r.runstatus='judged+') and " . - " (r.runjudge1 is null or r.runjudge2 is null or " . - " ((r.runjudge1=" . $_SESSION["usertable"]["usernumber"] . " and " . - " r.runjudgesite1=" . $_SESSION["usertable"]["usersitenumber"] . ") or " . - " (r.runjudge2=" . $_SESSION["usertable"]["usernumber"] . " and " . - " r.runjudgesite2=" . $_SESSION["usertable"]["usersitenumber"] . ")))))"; + "(r.runstatus='judged+' and r.runjudge is NULL) or " . + "((r.runstatus='judging' or r.runstatus='judged+') and " . + " (r.runjudge1 is null or " . + " (r.runjudge2 is null)" . // " and (" . $_SESSION["usertable"]["usernumber"] . ">=120000 or r.runjudge1>=120000))" . + " or ((r.runjudge1=" . $_SESSION["usertable"]["usernumber"] . " and " . + " r.runjudgesite1=" . $_SESSION["usertable"]["usersitenumber"] . ") or " . + " (r.runjudge2=" . $_SESSION["usertable"]["usernumber"] . " and " . + " r.runjudgesite2=" . $_SESSION["usertable"]["usersitenumber"] . ")))))"; $tx = "Judge"; } else $tx = "Chief"; $r = DBExec ($c, $sql . " for update", "DBGetRunToAnswerC(get run/prob/lang for update)"); diff --git a/src/judge/clar.php b/src/judge/clar.php index a5d56ce..ee120ab 100644 --- a/src/judge/clar.php +++ b/src/judge/clar.php @@ -49,7 +49,7 @@ $clar = DBOpenClarsInSites($_SESSION["usertable"]["contestnumber"], $s["sitejudg for ($i=0; $i<count($clar); $i++) { echo " <tr>\n"; - if (strpos($clar[$i]["status"], "answered") === false) + if (strpos($clar[$i]["status"], "answered") === false) // && strpos($_SESSION["usertable"]['username'], "setter") !== false) echo " <td nowrap><a href=\"claredit.php?clarnumber=".$clar[$i]["number"]."&clarsitenumber=".$clar[$i]["site"] . "\">" . $clar[$i]["number"] . "</td>\n"; else diff --git a/src/judge/team.php b/src/judge/team.php index 745380a..13e3e4e 100644 --- a/src/judge/team.php +++ b/src/judge/team.php @@ -75,7 +75,7 @@ $redo = TRUE; if(!isset($_SESSION['forceredo']) || $_SESSION['forceredo']==false) { $actualdelay = 30; if(file_exists($runtmp)) { - if(isset($strtmp) || (($strtmp = file_get_contents($runtmp,FALSE,NULL,-1,1000000)) !== FALSE)) { + if(isset($strtmp) || (($strtmp = file_get_contents($runtmp,FALSE,NULL,0,1000000)) !== FALSE)) { list($d) = sscanf($strtmp,"%*s %d"); if($d > time() - $actualdelay) { $conf=globalconf(); diff --git a/src/scoretable.php b/src/scoretable.php index 3f785f3..2010bc1 100644 --- a/src/scoretable.php +++ b/src/scoretable.php @@ -91,7 +91,7 @@ if($ds=="") $ds = "/"; $scoretmp = $_SESSION["locr"] . $ds . "private" . $ds . "scoretmp" . $ds . $_SESSION["usertable"]["usertype"] . '-' . $_SESSION["usertable"]["username"] . ".php"; $redo = TRUE; if(file_exists($scoretmp)) { - if(($strtmp = file_get_contents($scoretmp,FALSE,NULL,-1,100000)) !== FALSE) { + if(($strtmp = file_get_contents($scoretmp,FALSE,NULL,0,5000000)) !== FALSE) { list($d) = sscanf($strtmp,"%*s %d"); if($d > time() - $actualdelay) { $redo = FALSE; @@ -398,11 +398,14 @@ if($redo) { if(isset($conf['doenc']) && $conf['doenc']) $strtmp = "<!-- " . time() . " --> <?php exit; ?>\n" . encryptData($strtmp,$conf["key"],false); else $strtmp = "<!-- " . time() . " --> <?php exit; ?>\n" . $strtmp; - if(file_put_contents($scoretmp, $strtmp,LOCK_EX)===FALSE) { + $randnum = session_id() . "_" . rand(); + if(file_put_contents($scoretmp . "_" . $randnum, $strtmp,LOCK_EX)===FALSE) { if($_SESSION["usertable"]["usertype"] == 'admin') { MSGError("Cannot write to the score cache file -- performance might be compromised"); } LOGError("Cannot write to the ".$_SESSION["usertable"]["usertype"]."-score cache file -- performance might be compromised"); + } else { + @rename($scoretmp . "_" . $randnum, $scoretmp); } $conf=globalconf(); if(isset($conf['doenc']) && $conf['doenc']) diff --git a/src/team/header.php b/src/team/header.php index ec7352a..c02166b 100644 --- a/src/team/header.php +++ b/src/team/header.php @@ -60,7 +60,7 @@ $runtmp = $_SESSION["locr"] . $ds . "private" . $ds . "runtmp" . $ds . "run-cont "-site". $_SESSION["usertable"]["usersitenumber"] . "-user" . $_SESSION["usertable"]["usernumber"] . ".php"; $doslow=true; if(file_exists($runtmp)) { - if(($strtmp = file_get_contents($runtmp,FALSE,NULL,-1,1000000)) !== FALSE) { + if(($strtmp = file_get_contents($runtmp,FALSE,NULL,0,1000000)) !== FALSE) { $postab=strpos($strtmp,"\t"); $conf=globalconf(); $strcolors = decryptData(substr($strtmp,$postab+1,strpos($strtmp,"\n")-$postab-1),$conf['key'],''); diff --git a/src/team/run.php b/src/team/run.php index 10e7c76..32c0d25 100644 --- a/src/team/run.php +++ b/src/team/run.php @@ -291,7 +291,7 @@ $redo = TRUE; if(!isset($_SESSION['forceredo']) || $_SESSION['forceredo']==false) { $actualdelay = 15; if(file_exists($runtmp)) { - if(isset($strtmp) || (($strtmp = file_get_contents($runtmp,FALSE,NULL,-1,1000000)) !== FALSE)) { + if(isset($strtmp) || (($strtmp = file_get_contents($runtmp,FALSE,NULL,0,1000000)) !== FALSE)) { list($d) = sscanf($strtmp,"%*s %d"); if($d > time() - $actualdelay) { $conf=globalconf(); diff --git a/tools/boca-submit-log b/tools/boca-submit-log new file mode 100644 index 0000000..836225e --- /dev/null +++ b/tools/boca-submit-log @@ -0,0 +1,66 @@ +#!/bin/bash + +if [ "`id -u`" != "0" ]; then + echo "Must be run as root" + exit 1 +fi +if [[ ! -e /etc/bocaip ]] ; then + BOCASERVER=50.116.19.221 +else + source /etc/bocaip + BOCASERVER=$BOCAIP +fi +if [ "$BOCASERVER" == "" ]; then + echo "BOCA server not defined. Aborting" + exit 1 +fi + +for zcount in 1 2 3 4 5 6; do + +grep "session opened for user root" /var/log/auth.log |grep -v cron:session | grep -v systemd:session | tail -n 100 > /root/.logroot.tmp +[ -f /root/.logroot ] || touch /root/.logroot +diff /root/.logroot /root/.logroot.tmp > /root/.logroot.diff 2>/dev/null +res=$? +if [ "$res" != "0" ]; then + 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=/root/.temp.`date +%s%N`.txt + md=`wget -4 --no-check-certificate -t 2 -T 5 -S https://$BOCASERVER/boca/logexternal.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=`cat /root/submissions/code 2>/dev/null` + res=`echo -n "${res}${md}" | sha256sum - | cut -f1 -d' '` + + echo -n "comp=`cat /root/submissions/comp`" > $temp + echo -n "&code=$res" >> $temp + echo -n "&data=" >> $temp + grep "^>" /root/.logroot.diff | uuencode -m zzzzzzzzzz | grep -v "begin-base64.*zzzzzzzzzz" | perl -MURI::Escape -lne 'print uri_escape($_)' >> $temp + + wget -4 --no-check-certificate -t 2 -T 5 "https://$BOCASERVER/boca/logexternal.php" --load-cookies ${temp}.cookie.txt --keep-session-cookies --save-cookies ${temp}.cookie.txt -O ${temp}.out --post-file=$temp >/dev/null 2>/dev/null + rm -f $temp + rm -f ${temp}.cookie.txt + grep -qi incorrect ${temp}.out + res=$? + rm ${temp}.out + if [ "$res" == "0" ]; then + echo "$BOCASERVER: User or password incorrect" + exit 3 + fi + else + echo "$BOCASERVER: connection failed" + exit 2 + fi +fi +mv /root/.logroot.tmp /root/.logroot +[ "$zcount" == "6" ] || sleep 8 +done + +exit 0 diff --git a/tools/cron-boca-fixssh b/tools/cron-boca-fixssh new file mode 100644 index 0000000..ac7b597 --- /dev/null +++ b/tools/cron-boca-fixssh @@ -0,0 +1 @@ +* * * * * root /usr/sbin/boca-fixssh >>/var/log/boca-fixssh.out 2>>/var/log/boca-fixssh.err diff --git a/tools/cron-boca-log b/tools/cron-boca-log new file mode 100644 index 0000000..d1a27bc --- /dev/null +++ b/tools/cron-boca-log @@ -0,0 +1 @@ +* * * * * root /usr/sbin/boca-submit-logroot >>/var/log/boca-submit-logroot.out 2>>/var/log/boca-submit-logroot.err diff --git a/tools/cron-boca-submit b/tools/cron-boca-submit new file mode 100644 index 0000000..5fda786 --- /dev/null +++ b/tools/cron-boca-submit @@ -0,0 +1 @@ +*/2 * * * * root /usr/bin/boca-submit-run-cron >>/var/log/bocacron.out 2>>/var/log/bocacron.err diff --git a/tools/tst.php b/tools/tst.php deleted file mode 100644 index 38f5fd0..0000000 --- a/tools/tst.php +++ /dev/null @@ -1,11 +0,0 @@ -<?php - -header('Content-type: image/png'); - -$smile=imagecreatefrompng("../images/balloon4.png"); -imageSaveAlpha($smile, true); -$kek=imagecolorallocate($smile,0,0,255); -imagefill($smile,12,25,$kek); -imagepng($smile); - -?> |