From c1e9a742ab8567fc7026a39ea95ae3e95400faf8 Mon Sep 17 00:00:00 2001 From: Cassio de Campos Date: Thu, 19 Oct 2017 14:04:41 +0100 Subject: new features --- src/admin/misc.php | 56 ++++++++++++++++++++++++++---------- src/admin/transfer.php | 77 -------------------------------------------------- src/fextdata.php | 4 +-- 3 files changed, 43 insertions(+), 94 deletions(-) delete mode 100644 src/admin/transfer.php (limited to 'src') diff --git a/src/admin/misc.php b/src/admin/misc.php index 9872f12..3e5df80 100644 --- a/src/admin/misc.php +++ b/src/admin/misc.php @@ -27,28 +27,51 @@ require 'header.php'; document.form1.confirmation.value='confirm'; } } + function conf2() { + if (confirm("Confirm updating BOCA?")) { + if (confirm("This operation will update your BOCA system. Confirm?")) { + document.form1.confirmation.value='confirm'; + } + } + }
  -   +     - +
Not implemented
\n"; +} +$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($doscore) { if (($s = DBSiteInfo($_SESSION["usertable"]["contestnumber"],$_SESSION["usertable"]["usersitenumber"])) == null) ForceLoad("index.php"); - echo "
\n";
+      echo "
\n";
       echo "Building scores\n";
       $level=$s["sitescorelevel"];
       $data0 = array();
@@ -83,14 +106,17 @@ if (isset($_POST["Submit1"]) && $_POST["Submit1"] == "Transfer") {
 	@rename($fname . ".tmp",$destination);
       }
       @fclose($fp);
+    }
+    if($dotransfer) {
       echo "Processing other data\n";
-      getMainXML($_SESSION["usertable"]["contestnumber"]);
+      getMainXML($_SESSION["usertable"]["contestnumber"],10,$dotransferall);
       echo "
\n"; - @unlink($destination . ".lck"); - } else { - if(file_exists($destination . ".lck") && filemtime($destination . ".lck") < time() - 180) - @unlink($destination . ".lck"); } + @unlink($destination . ".lck"); + } else { + if(file_exists($destination . ".lck") && filemtime($destination . ".lck") < time() - 120) + @unlink($destination . ".lck"); + echo "
Transfers locked by other process - try again soon
\n"; } } ?> diff --git a/src/admin/transfer.php b/src/admin/transfer.php deleted file mode 100644 index 7f62326..0000000 --- a/src/admin/transfer.php +++ /dev/null @@ -1,77 +0,0 @@ -. -//////////////////////////////////////////////////////////////////////////////// -//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"); - echo "
\n";
-    echo "Building scores\n";
-    $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");
-    echo "Transferring scores\n";
-    scoretransfer($fname . ".dat", $localsite);
-    echo "Saving scores\n";
-    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);
-    echo "Processing other data\n";
-    getMainXML($_SESSION["usertable"]["contestnumber"]);
-    echo "
\n"; - @unlink($destination . ".lck"); - } else { - if(file_exists($destination . ".lck") && filemtime($destination . ".lck") < time() - 180) - @unlink($destination . ".lck"); - } -} - -?> diff --git a/src/fextdata.php b/src/fextdata.php index 3eae683..468c2d3 100644 --- a/src/fextdata.php +++ b/src/fextdata.php @@ -212,7 +212,7 @@ function scoretransfer($putname, $localsite, $timeo=5) { } -function getMainXML($contest,$timeo=5) { +function getMainXML($contest,$timeo=5,$upd=false) { $ds = DIRECTORY_SEPARATOR; if($ds=="") $ds = "/"; @@ -252,7 +252,7 @@ function getMainXML($contest,$timeo=5) { LOGError("getMainXML: invalid mainsiteurl entry"); return false; } - if(count($sitedata) == 3) { + if(count($sitedata) == 3 || $upd) { $updatetime=0; } else $updatetime=trim($sitedata[3]); -- cgit v1.2.3