aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcassiopc <cassiopc@gmail.com>2012-10-22 16:50:03 +0000
committercassiopc <cassiopc@gmail.com>2012-10-22 16:50:03 +0000
commitdf477b322c071d81ea06ad972a36ea9f30cdc34f (patch)
tree77dad3b53ed879e65b22f24f880592a12e5dbad0
parent9e75d473525446d0961a7567bcb8a1e672949df8 (diff)
downloadboca-df477b322c071d81ea06ad972a36ea9f30cdc34f.tar.gz
boca-df477b322c071d81ea06ad972a36ea9f30cdc34f.zip
update sendscore.sh to cope with new version. Fix password update and hexsub
-rwxr-xr-xboca-1.5.1/doc/Teams.tsv16
-rw-r--r--boca-1.5.1/src/admin/user.php17
-rw-r--r--boca-1.5.1/src/fscore.php3
-rw-r--r--boca-1.5.1/src/hex.php4
-rw-r--r--boca-1.5.1/src/index.php18
-rw-r--r--boca-1.5.1/src/scoretable.php8
-rw-r--r--boca-1.5.1/src/site/putfile.php3
-rw-r--r--boca-1.5.1/tools/icpc.etc.tgzbin9583 -> 9553 bytes
-rwxr-xr-xboca-1.5.1/tools/sendscore.sh10
9 files changed, 48 insertions, 31 deletions
diff --git a/boca-1.5.1/doc/Teams.tsv b/boca-1.5.1/doc/Teams.tsv
index c7b73e1..40476a1 100755
--- a/boca-1.5.1/doc/Teams.tsv
+++ b/boca-1.5.1/doc/Teams.tsv
@@ -1,9 +1,9 @@
File_Version 1
-null 1488 2115 The Goodfellas Universidade de São Paulo - Escola de Artes, Ciências e Humanidades EACH-USP BRA
-null 1487 2115 FODUVA Universidade de São Paulo - Escola de Artes, Ciências e Humanidades EACH-USP BRA
-null 1486 2115 Multi-thread Simultâneo (MTS) Universidade de São Paulo - Escola de Artes, Ciências e Humanidades EACH-USP BRA
-null 1485 2115 SWR Universidade de São Paulo - Escola de Artes, Ciências e Humanidades EACH-USP BRA
-null 1484 2115 USP Lost Universidade de São Paulo - Escola de Artes, Ciências e Humanidades EACH-USP BRA
-null 1483 2501 UFRN-1 Universidade Federal do Rio Grande do Norte UFRN BRA
-null 1482 2504 ineficiente Universidade Federal de Santa Catarina UF Santa Catarina BRA
-null 1481 2115 Gargamel's team Universidade Federal de Santa Catarina UF Santa Catarina BRA
+null 1488 1 The Goodfellas Universidade de São Paulo - Escola de Artes, Ciências e Humanidades EACH-USP BRA
+null 1487 2 FODUVA Universidade de São Paulo - Escola de Artes, Ciências e Humanidades EACH-USP BRA
+null 1486 2 Multi-thread Simultâneo (MTS) Universidade de São Paulo - Escola de Artes, Ciências e Humanidades EACH-USP BRA
+null 1485 2 SWR Universidade de São Paulo - Escola de Artes, Ciências e Humanidades EACH-USP BRA
+null 1484 2 USP Lost Universidade de São Paulo - Escola de Artes, Ciências e Humanidades EACH-USP BRA
+null 1483 1 UFRN-1 Universidade Federal do Rio Grande do Norte UFRN BRA
+null 1482 3 ineficiente Universidade Federal de Santa Catarina UF Santa Catarina BRA
+null 1481 1 Gargamel's team Universidade Federal de Santa Catarina UF Santa Catarina BRA
diff --git a/boca-1.5.1/src/admin/user.php b/boca-1.5.1/src/admin/user.php
index 5e07930..adde9db 100644
--- a/boca-1.5.1/src/admin/user.php
+++ b/boca-1.5.1/src/admin/user.php
@@ -57,7 +57,8 @@ if (isset($_POST["username"]) && isset($_POST["userfullname"]) && isset($_POST["
} else {
if ($_POST["passwordn1"] == $_POST["passwordn2"]) {
$param['pass'] = bighexsub(htmlspecialchars($_POST["passwordn1"]),$a['userpassword']);
- DBNewUser($param);
+ if($param['user'] != 1000)
+ DBNewUser($param);
}
else MSGError ("Passwords don't match.");
}
@@ -103,8 +104,12 @@ else if (isset($_FILES["importfile"]) && isset($_POST["Submit"]) && $_FILES["imp
$param['contest']=$_SESSION["usertable"]["contestnumber"];
if($_SESSION["usertable"]["usersitenumber"] == $param['site'] || $main)
- if(DBNewUser($param))
+ if($param['usernumber'] != 1000 && DBNewUser($param)) {
$oklines++;
+ } else {
+ unset($userlist[$param['site'] . '-' . $param['usernumber']]);
+ break;
+ }
}
}
MSGError($oklines . ' users included/updated successfully');
@@ -130,8 +135,12 @@ else if (isset($_FILES["importfile"]) && isset($_POST["Submit"]) && $_FILES["imp
$param['pass']=myhash($userlist[$param['site'] . '-' . $param['usernumber']]);
$param['contest']=$_SESSION["usertable"]["contestnumber"];
if($_SESSION["usertable"]["usersitenumber"] == $param['site'] || $main)
- if(DBNewUser($param))
+ if($param['usernumber'] != 1000 && DBNewUser($param)) {
$oklines++;
+ } else {
+ unset($userlist[$param['site'] . '-' . $param['usernumber']]);
+ break;
+ }
}
}
MSGError($oklines . ' users included/updated successfully');
@@ -163,7 +172,7 @@ else if (isset($_FILES["importfile"]) && isset($_POST["Submit"]) && $_FILES["imp
}
$param['contest']=$_SESSION["usertable"]["contestnumber"];
if($_SESSION["usertable"]["usersitenumber"] == $param['site'] || $main)
- DBNewUser($param);
+ if($param['usernumber'] != 1000) DBNewUser($param);
}
}
}
diff --git a/boca-1.5.1/src/fscore.php b/boca-1.5.1/src/fscore.php
index 7b59561..efc4858 100644
--- a/boca-1.5.1/src/fscore.php
+++ b/boca-1.5.1/src/fscore.php
@@ -86,6 +86,9 @@ function DBScore($contest, $verifylastmile, $hor=-1, $globalsite='0') {
if($ds=="") $ds = "/";
$probs=DBGetProblems($contest); $nprobs=count($probs);
foreach (glob($_SESSION['locr'] . $ds . "private" .$ds . "remotescores" . $ds . "score*.dat") as $fname) {
+ $namear=explode('_',$fname);
+ $overloadsite=-1;
+ if(isset($namear[3]) && is_numeric($namear[2])) $overloadsite=$namear[2];
$fc=file_get_contents($fname);
if(($arr = unserialize(base64_decode($fc)))===false) {
LOGError("File " . sanitizeText($fname) . " is not compatible");
diff --git a/boca-1.5.1/src/hex.php b/boca-1.5.1/src/hex.php
index 0d80b1d..4fa4c16 100644
--- a/boca-1.5.1/src/hex.php
+++ b/boca-1.5.1/src/hex.php
@@ -141,8 +141,8 @@ function bighexsub ($hex1, $hex2) {
$r += 16;
$sobra = 1;
} else $sobra = 0;
-
- $resultado = dechex($r) . $resultado;
+ if($x > 0 || dechex($r) != '0')
+ $resultado = dechex($r) . $resultado;
}
return $sinal . $resultado;
}
diff --git a/boca-1.5.1/src/index.php b/boca-1.5.1/src/index.php
index db904c7..af55fab 100644
--- a/boca-1.5.1/src/index.php
+++ b/boca-1.5.1/src/index.php
@@ -79,15 +79,17 @@ if(function_exists("globalconf") && function_exists("sanitizeVariables")) {
if(($ct = DBContestInfo($_SESSION["usertable"]["contestnumber"])) == null)
ForceLoad("index.php");
if($ct["contestlocalsite"]==$ct["contestmainsite"]) $main=true; else $main=false;
- if($main && $_SESSION["usertable"]["usertype"] == 'site') {
- MSGError('Direct login of this user is not allowed');
- unset($_SESSION["usertable"]);
- ForceLoad("index.php");
- exit;
+ if(!isset($_GET['action']) || $_GET['action'] != 'scoretransfer') {
+ if($main && $_SESSION["usertable"]["usertype"] == 'site') {
+ MSGError('Direct login of this user is not allowed');
+ unset($_SESSION["usertable"]);
+ ForceLoad("index.php");
+ exit;
+ }
+ echo "<script language=\"JavaScript\">\n";
+ echo "document.location='" . $_SESSION["usertable"]["usertype"] . "/index.php';\n";
+ echo "</script>\n";
}
- echo "<script language=\"JavaScript\">\n";
- echo "document.location='" . $_SESSION["usertable"]["usertype"] . "/index.php';\n";
- echo "</script>\n";
exit;
}
}
diff --git a/boca-1.5.1/src/scoretable.php b/boca-1.5.1/src/scoretable.php
index 574b700..dcfc7a6 100644
--- a/boca-1.5.1/src/scoretable.php
+++ b/boca-1.5.1/src/scoretable.php
@@ -95,7 +95,7 @@ if(file_exists($scoretmp)) {
}
}
-if($_SESSION["usertable"]["usertype"]=='score' || (isset($_GET["remote"]) && is_numeric($_GET["remote"]))) {
+if($_SESSION["usertable"]["usertype"]=='score' || $_SESSION["usertable"]["usertype"]=='admin' || (isset($_GET["remote"]) && is_numeric($_GET["remote"]))) {
$remotedir = $_SESSION['locr'] . $ds . "private" . $ds . "remotescores";
$destination = $remotedir . $ds ."scores.zip";
if(is_writable($remotedir)) {
@@ -115,10 +115,12 @@ if($_SESSION["usertable"]["usertype"]=='score' || (isset($_GET["remote"]) && is_
@file_put_contents($fname . ".tmp",base64_encode(serialize($data0)));
@rename($fname . ".tmp",$fname . ".dat");
- if(@create_zip($remotedir,glob($remotedir . '/*.dat'),$destination)!==true) {
+ if(@create_zip($remotedir,glob($remotedir . '/*.dat'),$fname . ".tmp") != 1) {
LOGError("Cannot create score zip file");
+ if(@create_zip($remotedir,array(),$fname . ".tmp") == 1)
+ @rename($fname . ".tmp",$destination);
} else {
- @create_zip($remotedir,array(),$destination);
+ @rename($fname . ".tmp",$destination);
}
}
}
diff --git a/boca-1.5.1/src/site/putfile.php b/boca-1.5.1/src/site/putfile.php
index d320a1a..3155bd8 100644
--- a/boca-1.5.1/src/site/putfile.php
+++ b/boca-1.5.1/src/site/putfile.php
@@ -163,7 +163,8 @@ if(is_writable($_SESSION["locr"] . $remotedir)) {
fwrite($fout,$total,10000000);
fclose($fout);
- if(@rename($fn, $_SESSION["locr"] . $remotedir . $ds . "score_" . $_SESSION["usertable"]["username"] . "_" . md5(getIP()) . ".dat"))
+ if(@rename($fn, $_SESSION["locr"] . $remotedir . $ds . "score_" . $_SESSION["usertable"]["username"] .
+ "_" . $_SESSION["usertable"]["usericpcid"] . "_" . md5(getIP()) . ".dat"))
echo "SCORE UPLOADED OK\n";
else
echo "FAILED: UPDATE SCORE ERROR\n";
diff --git a/boca-1.5.1/tools/icpc.etc.tgz b/boca-1.5.1/tools/icpc.etc.tgz
index 4151601..6a4f09f 100644
--- a/boca-1.5.1/tools/icpc.etc.tgz
+++ b/boca-1.5.1/tools/icpc.etc.tgz
Binary files differ
diff --git a/boca-1.5.1/tools/sendscore.sh b/boca-1.5.1/tools/sendscore.sh
index 371c8d2..72393c3 100755
--- a/boca-1.5.1/tools/sendscore.sh
+++ b/boca-1.5.1/tools/sendscore.sh
@@ -15,7 +15,7 @@
# // You should have received a copy of the GNU General Public License
# // along with this program. If not, see <http://www.gnu.org/licenses/>.
# ////////////////////////////////////////////////////////////////////////////////
-# last modified 10/jul/2012 by cassio@ime.usp.br
+# last modified 22/oct/2012 by cassio@ime.usp.br
if [ "$1" == "" -o "$2" == "" -o "$3" == "" -o "$4" == "" ]; then
echo "Usage $0 <scorefile> <BOCAaddress> <user> <password> [<PC2site>]"
@@ -32,7 +32,7 @@ if [ "$5" != "" ]; then
pc2=$5
fi
-for i in wget tr perl md5sum cut; do
+for i in wget tr perl shasum cut; do
p=`which $i`
if [ -x "$p" ]; then
echo -n ""
@@ -44,9 +44,9 @@ done
if [ -r "$1" ]; then
md=`wget -S -T3 -t3 $BOCASERVER/index.php -O /dev/null --save-cookies /tmp/.cookie.txt --keep-session-cookies 2>&1 | grep PHPSESS | tail -n1 | cut -f2 -d'=' | cut -f1 -d';'`
-res=`echo -n $pass | md5sum - | cut -f1 -d' '`
-res=`echo -n "${res}${md}" | md5sum - | cut -f1 -d' '`
-wget -T3 -t3 "$BOCASERVER/index.php?name=${user}&password=${res}" --load-cookies /tmp/.cookie.txt --keep-session-cookies --save-cookies /tmp/.cookie.txt -O /tmp/.temp.txt 2>/dev/null >/dev/null
+res=`echo -n $pass | shasum -a 256 - | cut -f1 -d' '`
+res=`echo -n "${res}${md}" | shasum -a 256 - | cut -f1 -d' '`
+wget -T3 -t3 "$BOCASERVER/index.php?name=${user}&password=${res}&action=scoretransfer" --load-cookies /tmp/.cookie.txt --keep-session-cookies --save-cookies /tmp/.cookie.txt -O /tmp/.temp.txt 2>/dev/null >/dev/null
grep -qi incorrect /tmp/.temp.txt
if [ $? == 0 ]; then
echo User or password incorrect