diff options
| author | cassiopc <cassiopc@gmail.com> | 2013-09-02 17:55:20 +0000 |
|---|---|---|
| committer | cassiopc <cassiopc@gmail.com> | 2013-09-02 17:55:20 +0000 |
| commit | 36af2dbc07588b90b89ff6701a8a483228fd87dc (patch) | |
| tree | 199df5612b23d9e76cfd4a31c077a69405eef7fd | |
| parent | e74e7692302f57acccec75bcedc1584e0eadd165 (diff) | |
| download | boca-36af2dbc07588b90b89ff6701a8a483228fd87dc.tar.gz boca-36af2dbc07588b90b89ff6701a8a483228fd87dc.zip | |
adapt site numbers according to remote score file names
| -rw-r--r-- | src/fextdata.php | 9 | ||||
| -rw-r--r-- | src/fscore.php | 9 | ||||
| -rw-r--r-- | src/scoretable.php | 26 |
3 files changed, 29 insertions, 15 deletions
diff --git a/src/fextdata.php b/src/fextdata.php index c0423cc..37e0c9f 100644 --- a/src/fextdata.php +++ b/src/fextdata.php @@ -17,11 +17,12 @@ //////////////////////////////////////////////////////////////////////////////// // Last modified 02/sep/2013 by cassio@ime.usp.br -function scoretransfer($putname) { +function scoretransfer($putname, $localsite) { $ds = DIRECTORY_SEPARATOR; if($ds=="") $ds = "/"; $privatedir = $_SESSION['locr'] . $ds . "private"; if(!is_readable($privatedir . $ds . 'remotescores' . $ds . "otherservers")) return; + $localfile = "score_site" . $localsite . "_" . $localsite . "_x.dat"; $remotesite = @file($privatedir . $ds . 'remotescores' . $ds . "otherservers"); for($i = 0; $i < count($remotesite); $i++) { $sitedata = explode(' ', $remotesite[$i]); @@ -68,7 +69,11 @@ function scoretransfer($putname) { foreach(glob($privatedir . $ds . 'remotescores' . $ds . 'tmp' . $ds . '*.dat') as $file) { @chown($file,"www-data"); @chmod($file,0660); - @rename($file, $privatedir . $ds . 'remotescores' . $ds . basename($file)); + $bn = basename($file); + if($bn == $localfile) + @rename($file, $privatedir . $ds . 'remotescores' . $ds . "score_site" . $localsite . "__y.dat"); + else + @rename($file, $privatedir . $ds . 'remotescores' . $ds . basename($file)); } $zip->close(); LOGError("scoretransfer: download OK"); diff --git a/src/fscore.php b/src/fscore.php index ac60661..df8375d 100644 --- a/src/fscore.php +++ b/src/fscore.php @@ -1,7 +1,7 @@ <?php //////////////////////////////////////////////////////////////////////////////// //BOCA Online Contest Administrator -// Copyright (C) 2003-2012 by BOCA Development Team (bocasystem@gmail.com) +// Copyright (C) 2003-2013 by BOCA Development Team (bocasystem@gmail.com) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -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 02/nov/2012 by cassio@ime.usp.br +// Last modified 03/sep/2013 by cassio@ime.usp.br ////////////////////////////funcoes para placar/////////////////////////////////////////////// function ScoreCMP($a,$b) { @@ -92,14 +92,15 @@ function DBScore($contest, $verifylastmile, $hor=-1, $globalsite='0') { foreach ($scoreitems as $fname) { $namear=explode('_',$fname); $overloadsite=-1; - if(isset($namear[3]) && is_numeric($namear[2])) $overloadsite=$namear[2]; + if(isset($namear[3]) && trim($namear[2]) != '' && 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"); } else { if(is_array($arr)) { if(isset($arr['site'])) { - $site=$arr['site']; //if($overloadsite>0) $site=$overloadsite; + $site=$arr['site']; + if($overloadsite>0) $site=$overloadsite; if(!in_array($site, $whichsites) && !in_array(0,$whichsites)) continue; $fine=1; reset($resp); diff --git a/src/scoretable.php b/src/scoretable.php index 2ed3df7..6efec4a 100644 --- a/src/scoretable.php +++ b/src/scoretable.php @@ -77,9 +77,9 @@ if(!ValidSession()) { $loc = $_SESSION["loc"]; if(!isset($detail)) $detail=true; if(!isset($final)) $final=false; -$scoredelay["admin"] = 2; -$scoredelay["score"] = 30; -$scoredelay["team"] = 30; +$scoredelay["admin"] = 3; +$scoredelay["score"] = 60; +$scoredelay["team"] = 20; $scoredelay["judge"] = 10; $scoredelay["staff"] = 60; $actualdelay = 60; @@ -99,11 +99,13 @@ if(file_exists($scoretmp)) { } if($_SESSION["usertable"]["usertype"]=='score' || $_SESSION["usertable"]["usertype"]=='admin' || (isset($_GET["remote"]) && is_numeric($_GET["remote"]))) { - $privatedir = $_SESSION['locr'] . $ds . "private"; - $remotedir = $_SESSION['locr'] . $ds . "private" . $ds . "remotescores"; - $destination = $remotedir . $ds ."scores.zip"; - if(is_writable($remotedir)) { + $privatedir = $_SESSION['locr'] . $ds . "private"; + $remotedir = $_SESSION['locr'] . $ds . "private" . $ds . "remotescores"; + $destination = $remotedir . $ds ."scores.zip"; + if(is_writable($remotedir)) { if($redo || !is_readable($destination)) { + if(($fp = @fopen($destination . ".lck",'x')) !== false) { + if (($s = DBSiteInfo($_SESSION["usertable"]["contestnumber"],$_SESSION["usertable"]["usersitenumber"])) == null) ForceLoad("index.php"); @@ -129,7 +131,7 @@ if($_SESSION["usertable"]["usertype"]=='score' || $_SESSION["usertable"]["userty $fname = $remotedir . $ds . "score_site" . $localsite . "_" . $localsite . "_x"; // . md5($_SERVER['HTTP_HOST']); @file_put_contents($fname . ".tmp",base64_encode(serialize($data0))); @rename($fname . ".tmp",$fname . ".dat"); - scoretransfer($fname . ".dat"); + scoretransfer($fname . ".dat", $localsite); if(@create_zip($remotedir,glob($remotedir . '/*.dat'),$fname . ".tmp") != 1) { LOGError("Cannot create score zip file"); @@ -138,8 +140,14 @@ if($_SESSION["usertable"]["usertype"]=='score' || $_SESSION["usertable"]["userty } else { @rename($fname . ".tmp",$destination); } + @fclose($fp); + @unlink($destination . ".lck"); + } else { + if(file_exists($destination . ".lck",'x') && filemtime($destination . ".lck",'x') < time() - 180) + @unlink($destination . ".lck"); + } } - } + } } if(isset($_GET["remote"])) { |