diff options
| author | Cassio de Campos <cassiopc@gmail.com> | 2017-10-16 22:00:53 +0000 |
|---|---|---|
| committer | Cassio de Campos <cassiopc@gmail.com> | 2017-10-16 22:00:53 +0000 |
| commit | 8cfd459f7d9b80754d47a00d7f0d5c15f0e88b04 (patch) | |
| tree | 13ee6665801ba0a9837502655b2acd0225ff95b5 /src/admin | |
| parent | 47145dc8e4493e8faba21e82a6377a993fe93d8d (diff) | |
| download | boca-8cfd459f7d9b80754d47a00d7f0d5c15f0e88b04.tar.gz boca-8cfd459f7d9b80754d47a00d7f0d5c15f0e88b04.zip | |
forced transfer
Diffstat (limited to 'src/admin')
| -rw-r--r-- | src/admin/transfer.php | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/src/admin/transfer.php b/src/admin/transfer.php new file mode 100644 index 0000000..718c33a --- /dev/null +++ b/src/admin/transfer.php @@ -0,0 +1,75 @@ +<?php +//////////////////////////////////////////////////////////////////////////////// +//BOCA Online Contest Administrator +// 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 +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// 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 16/oct/2017 by cassio@ime.usp.br +require 'header.php'; + +$ds = DIRECTORY_SEPARATOR; +if($ds=="") $ds = "/"; + +$privatedir = $_SESSION['locr'] . $ds . "private"; +$remotedir = $_SESSION['locr'] . $ds . "private" . $ds . "remotescores"; +$destination = $remotedir . $ds ."scores.zip"; +if(is_writable($remotedir)) { + if(($fp = @fopen($destination . ".lck",'x')) !== false) { + + if (($s = DBSiteInfo($_SESSION["usertable"]["contestnumber"],$_SESSION["usertable"]["usersitenumber"])) == null) + ForceLoad("index.php"); + + $level=$s["sitescorelevel"]; + $data0 = array(); + if($level>0) { + list($score,$data0) = DBScoreSite($_SESSION["usertable"]["contestnumber"], + $_SESSION["usertable"]["usersitenumber"], 0, -1); + } + $ct=DBGetActiveContest(); + $localsite=$ct['contestlocalsite']; + $fname = $privatedir . $ds . "score_localsite_" . $localsite . "_x"; // . md5($_SERVER['HTTP_HOST']); + @file_put_contents($fname . ".tmp",base64_encode(serialize($data0))); + @rename($fname . ".tmp",$fname . ".dat"); + + $data0 = array(); + if($level>0) { + list($score,$data0) = DBScoreSite($_SESSION["usertable"]["contestnumber"], + $_SESSION["usertable"]["usersitenumber"], 1, -1); + } + $ct=DBGetActiveContest(); + $localsite=$ct['contestlocalsite']; + $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", $localsite); + + 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 { + @rename($fname . ".tmp",$destination); + } + @fclose($fp); + + getMainXML($_SESSION["usertable"]["contestnumber"]); + + @unlink($destination . ".lck"); + } else { + if(file_exists($destination . ".lck") && filemtime($destination . ".lck") < time() - 180) + @unlink($destination . ".lck"); + } +} + +?> |