aboutsummaryrefslogtreecommitdiff
path: root/src/site/getsite.php
blob: 9cf490562f52ef9c0c141af66eea7f5779e89b96 (plain)
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
<?php
////////////////////////////////////////////////////////////////////////////////
//BOCA Online Contest Administrator
//    Copyright (C) 2003-2012 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
//    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 modified 25/July/2017 by cassio@ime.usp.br
require('header.php');

header ("Content-transfer-encoding: binary\n");
ob_end_flush();

if(($ct = DBContestInfo($_SESSION["usertable"]["contestnumber"])) == null) {
	echo "<!-- <ERROR4> ".session_id() . " " . session_id() . " -->\n";
	exit;
}
if($ct["contestlocalsite"]==$ct["contestmainsite"]) {
	$fromsite = $_SESSION["usertable"]["usericpcid"];
	LOGLevel("Connection received from site=$fromsite PHPID=".$_COOKIE['PHPSESSID'].",extra=".$_SESSION['usertable']['usersessionextra'].
			 ",session=".session_id().",name=".$getx['name'].", check=".$getx['check'],2);
	if($fromsite != '' && is_numeric($fromsite) && $fromsite > 0) {
	} else {
		echo "<!-- <ERROR9> ".session_id() . " " . session_id() . " -->\n";
		exit;
	}
	if(isset($_POST)) {
	  if(isset($_POST['xml'])) {
//		$fp=fopen('/tmp/aaa',"w"); fwrite($fp,$_POST['xml']); fclose($fp);
		$s = decryptData(rawurldecode($_POST['xml']),myhash($_SESSION["usertable"]["userpassword"]));
//		$fp=fopen('/tmp/aaa1',"w"); fwrite($fp,$s); fclose($fp);


		if(importSiteFromXML($s,$_SESSION["usertable"]["contestnumber"],$fromsite))
			echo "<!-- <OK> -->";
		else
			echo "<!-- <NOTOK> -->";
	  }
	  if(isset($_POST['updatetime']) && is_numeric($_POST['updatetime'])) {
	    $xml = generateSiteXML($_SESSION["usertable"]["contestnumber"],$fromsite,$_POST['updatetime']);
	echo encryptData($xml,myhash($_SESSION["usertable"]["userpassword"]));
} else 
	echo "<!-- <ERROR3> ".session_id() . " " . session_id() . " -->\n";
?>