1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
|
<?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';
?>
<br>
<form name="form1" enctype="multipart/form-data" method="post" action="misc.php">
<input type=hidden name="confirmation" value="noconfirm" />
<script language="javascript" type="text/javascript">
function conf() {
if (confirm("Confirm?")) {
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';
}
}
}
</script>
<center>
<input type="submit" name="Submit1" value="Transfer" onClick="conf()">
<input type="submit" name="Submit2" value="Transfer all" onClick="conf()">
<input type="submit" name="Submit3" value="Transfer scores">
<input type="submit" name="Submit4" value="Update BOCA" onClick="conf2()">
</center>
</form>
<?php
$ds = DIRECTORY_SEPARATOR;
if($ds=="") $ds = "/";
$dotransfer=false;
$doscore=false;
$dotransferall=false;
if (isset($_POST["Submit1"]) && $_POST["Submit1"] == "Transfer") {
$dotransfer=true;
$doscore=true;
}
if (isset($_POST["Submit2"]) && $_POST["Submit2"] == "Transfer all") {
$dotransfer=true;
$dotransferall=true;
$doscore=true;
}
if (isset($_POST["Submit3"]) && $_POST["Submit3"] == "Transfer scores") {
$doscore=true;
}
if (isset($_POST["Submit4"]) && $_POST["Submit4"] == "Update BOCA") {
echo "<pre>Not implemented</pre>\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 "<pre>\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);
}
if($dotransfer) {
echo "Processing other data\n";
getMainXML($_SESSION["usertable"]["contestnumber"],10,$dotransferall);
echo "</pre>\n";
}
@unlink($destination . ".lck");
} else {
if(file_exists($destination . ".lck") && filemtime($destination . ".lck") < time() - 120)
@unlink($destination . ".lck");
echo "<pre>Transfers locked by other process - try again soon</pre>\n";
}
}
?>
</body>
</html>
|