diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/fextdata.php | 52 | ||||
| -rw-r--r-- | src/index.php | 9 | ||||
| -rw-r--r-- | src/scoretable.php | 10 | ||||
| -rw-r--r-- | src/site/index.php | 4 | ||||
| -rw-r--r-- | src/site/putfile.php | 3 | ||||
| -rw-r--r-- | src/version | 2 | ||||
| -rw-r--r-- | src/versionnum.php | 4 |
7 files changed, 71 insertions, 13 deletions
diff --git a/src/fextdata.php b/src/fextdata.php index 2799bec..fe78bb7 100644 --- a/src/fextdata.php +++ b/src/fextdata.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,55 @@ // 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 21/jul/2012 by cassio@ime.usp.br +// Last modified 02/sep/2013 by cassio@ime.usp.br + +function scoretransfer() { + $ds = DIRECTORY_SEPARATOR; + if($ds=="") $ds = "/"; + $privatedir = $_SESSION['locr'] . $ds . "private"; + $remotesite = @file($privatedir . $ds . 'remotescores' . $ds . "otherservers"); + for($i = 0; $i < count($remotesite); $i++) { + $sitedata = explode(' ', $remotesite[$i]); + if(count($sitedata) < 3) continue; + $siteurl = $sitedata[0]; + if(strpos($siteurl,'#') !== false) continue; + if(substr($siteurl,0,7) != 'http://') + $siteurl = 'http://' . $siteurl; + $urldiv='/'; + if(substr($siteurl,length($siteurl)-1,1) == '/') + $urldiv = ''; + + $id = file_get_contents($siteurl . $urldiv . "index.php?getsessionid=1"); + $user = $sitedata[1]; + $res = myhash( myhash ($sitedata[2]) . $id); + $ok = file_get_contents($siteurl . $urldiv . "index.php?name=${user}&password=${res}&action=scoretransfer"); + if($ok == 'OK') { + $opts = array( + 'http' => array( + 'method' => 'GET', + 'header' => 'Cookie: PHPSESSID=' . $sess + ) + ); + $context = stream_context_create($opts); + $res = file_get_contents($siteurl . $urldiv . "scoretable.php?remote=-42", 0, $context); + $zip = new ZipArchive; + if ($zip->open($privatedir . $ds . $run["inputname"]) === true) { + @mkdir($privatedir . $ds . 'remotescores' . $ds . 'tmp'); + cleardir($privatedir . $ds . 'remotescores' . $ds . 'tmp'); + @mkdir($privatedir . $ds . 'remotescores' . $ds . 'tmp'); + $zip->extractTo($privatedir . $ds . 'remotescores' . $ds . 'tmp'); + 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)); + } + $zip->close(); + } + } + break; + } +} + function getMainXML($username,$sess,$pass,$pass2) { $c = DBConnect(); diff --git a/src/index.php b/src/index.php index af55fab..8ffdcd8 100644 --- a/src/index.php +++ b/src/index.php @@ -49,6 +49,11 @@ ob_end_flush(); require_once('version.php'); +if(isset($_GET["getsessionid"])) { + echo session_id(); + exit; +} + ?> <title>BOCA Online Contest Administrator <?php echo $BOCAVERSION; ?> - Login</title> <head> @@ -79,7 +84,9 @@ 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(!isset($_GET['action']) || $_GET['action'] != 'scoretransfer') { + if(isset($_GET['action']) && $_GET['action'] == 'scoretransfer') { + echo "OK"; + } else { if($main && $_SESSION["usertable"]["usertype"] == 'site') { MSGError('Direct login of this user is not allowed'); unset($_SESSION["usertable"]); diff --git a/src/scoretable.php b/src/scoretable.php index ef11ee6..ed24cf1 100644 --- a/src/scoretable.php +++ b/src/scoretable.php @@ -1,7 +1,7 @@ <?php //////////////////////////////////////////////////////////////////////////////// //BOCA Online Contest Administrator -// Copyright (C) 2003-2012 by BOCA System (bocasystem@gmail.com) +// Copyright (C) 2003-2013 by BOCA System (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 updated 02/nov/2012 by cassio@ime.usp.br +//Last updated 02/sep/2013 by cassio@ime.usp.br require_once("db.php"); if(isset($_SESSION["locr"])) @@ -104,6 +104,8 @@ if($_SESSION["usertable"]["usertype"]=='score' || $_SESSION["usertable"]["userty $destination = $remotedir . $ds ."scores.zip"; if(is_writable($remotedir)) { if($redo || !is_readable($destination)) { + scoretransfer(); + if (($s = DBSiteInfo($_SESSION["usertable"]["contestnumber"],$_SESSION["usertable"]["usersitenumber"])) == null) ForceLoad("index.php"); @@ -115,7 +117,7 @@ if($_SESSION["usertable"]["usertype"]=='score' || $_SESSION["usertable"]["userty } $ct=DBGetActiveContest(); $localsite=$ct['contestlocalsite']; - $fname = $privatedir . $ds . "score_localsite_" . $localsite . "_" . md5($_SERVER['HTTP_HOST']); + $fname = $privatedir . $ds . "score_localsite_" . $localsite . "_"; // . md5($_SERVER['HTTP_HOST']); @file_put_contents($fname . ".tmp",base64_encode(serialize($data0))); @rename($fname . ".tmp",$fname . ".dat"); @@ -126,7 +128,7 @@ if($_SESSION["usertable"]["usertype"]=='score' || $_SESSION["usertable"]["userty } $ct=DBGetActiveContest(); $localsite=$ct['contestlocalsite']; - $fname = $remotedir . $ds . "score_site" . $localsite . "_" . $localsite . "_" . md5($_SERVER['HTTP_HOST']); + $fname = $remotedir . $ds . "score_site" . $localsite . "_" . $localsite . "_"; // . md5($_SERVER['HTTP_HOST']); @file_put_contents($fname . ".tmp",base64_encode(serialize($data0))); @rename($fname . ".tmp",$fname . ".dat"); diff --git a/src/site/index.php b/src/site/index.php index 3b066ab..0afc7e4 100644 --- a/src/site/index.php +++ b/src/site/index.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 21/jul/2012 by cassio@ime.usp.br +// Last modified 02/sep/2013 by cassio@ime.usp.br require('header.php'); if(isset($_GET['mainuser']) && isset($_GET['mainpass']) && $_GET['mainuser']!="" && $_GET['mainpass']!="") { $_SESSION['mainuser'] = $_GET['mainuser']; diff --git a/src/site/putfile.php b/src/site/putfile.php index 8a1d89a..6273711 100644 --- a/src/site/putfile.php +++ b/src/site/putfile.php @@ -181,7 +181,8 @@ if(is_writable($_SESSION["locr"] . $remotedir)) { } else { if(@rename($fn, $_SESSION["locr"] . $remotedir . $ds . "score_" . $_SESSION["usertable"]["username"] . - "_" . $_SESSION["usertable"]["usericpcid"] . "_" . md5(getIP()) . ".dat")) + "_" . $_SESSION["usertable"]["usericpcid"] . "_" //. md5(getIP()) + . ".dat")) echo "SCORE UPLOADED OK\n"; else echo "FAILED: UPDATE SCORE ERROR\n"; diff --git a/src/version b/src/version index 56c3c4d..59e2af6 100644 --- a/src/version +++ b/src/version @@ -1 +1 @@ -boca-1.5.2 +boca-1.5.3 diff --git a/src/versionnum.php b/src/versionnum.php index 1da16cb..94f90b7 100644 --- a/src/versionnum.php +++ b/src/versionnum.php @@ -1,5 +1,5 @@ <?php -$BOCAVERSION='boca-1.5.2'; -$YEAR='2012'; +$BOCAVERSION='boca-1.5.3'; +$YEAR='2013'; ?> |