From be2491b093b1f0ca430bede679ecbb670041e483 Mon Sep 17 00:00:00 2001 From: cassio Date: Tue, 2 Jul 2013 09:46:45 +0400 Subject: restructuring of boca's git --- src/system/importxml.php | 245 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 245 insertions(+) create mode 100644 src/system/importxml.php (limited to 'src/system/importxml.php') diff --git a/src/system/importxml.php b/src/system/importxml.php new file mode 100644 index 0000000..5fcaef3 --- /dev/null +++ b/src/system/importxml.php @@ -0,0 +1,245 @@ +. +//////////////////////////////////////////////////////////////////////////////// +// Last modified 05/aug/2012 by cassio@ime.usp.br +//Change list +// 15/June/2011 by cassio@ime.usp.br: created based on import.php + +require('header.php'); +$id = ''; + +if(isset($_POST["Submit"])) { + if(isset($_SESSION["importfile"])) { + $importfile = $_SESSION['importfile']; + } + if (isset($_FILES["importfile"]) && $_FILES["importfile"]["name"]!="") { + $importfile = $_FILES["importfile"]; + } + if(isset($importfile)) { + $_SESSION['importfile'] = $importfile; + + if ($_POST["confirmation"] == "confirm") { + $type=htmlspecialchars($importfile["type"]); + $size=htmlspecialchars($importfile["size"]); + $name=htmlspecialchars($importfile["name"]); + $temp=htmlspecialchars($importfile["tmp_name"]); + if(isset($importfile['filecontent'])) + $ar = $importfile['filecontent']; + else { + if (!is_uploaded_file($temp)) { + IntrusionNotify("file upload problem."); + ForceLoad("../index.php"); + } + if (($ar = file($temp)) === false) { + IntrusionNotify("Unable to open the uploaded file."); + ForceLoad("../index.php"); + } + $ar=implode('',$ar); + $_SESSION['importfile']['filecontent']=$ar; + } + $localsite=0; + if(isset($_POST['localsite']) && is_numeric($_POST['localsite'])) $localsite=$_POST['localsite']; + $acr['CONTESTREC']=array('number'=>-1, + 'name'=>-1, + 'startdate'=>-1, + 'duration'=>-1, + 'lastmileanswer'=>-1, + 'lastmilescore'=>-1, + 'localsite'=>-1, + 'penalty'=>-1, + 'maxfilesize'=>-1, + 'updatetime'=>-1); + if($localsite > 0) + $acr['CONTESTREC']['localsite'] = "" . $localsite; + + $acr['ANSWERREC']=array('number'=>-1, + 'name'=>-1, + 'yes'=>-1, + 'updatetime'=>-1); + $acr['LANGUAGEREC']=array('number'=>-1, + 'name'=>-1, + 'filepath'=>-1, + 'filename'=>-1, + 'comppath'=>-1, + 'compname'=>-1, + 'problemnumber'=>-1, + 'updatetime'=>-1); + $acr['PROBLEMREC']=array('number'=>-1, + 'name'=>-1, + 'fullname'=>-1, + 'basename'=>-1, + 'inputfilename'=>-1, + 'inputfilepath'=>-1, + 'solfilename'=>-1, + 'solfilepath'=>-1, + 'descfilename'=>-1, + 'descfilepath'=>-1, + 'tl'=>-1, + 'colorname'=>-1, + 'color'=>-1, + 'fake'=>-1, + 'updatetime'=>-1); + $acr['SITETIME']=array('site'=>-1, + 'start'=>-1, + 'enddate'=>-1, + 'updatetime'=>-1); + $acr['SITEREC']=array('sitenumber'=>-1, + 'site'=>-1, + 'number'=>-1, + 'sitename'=>-1, + 'siteip'=>-1, + 'siteduration'=>-1, + 'sitelastmileanswer'=>-1, + 'sitelastmilescore'=>-1, + 'sitejudging'=>-1, + 'sitetasking'=>-1, + 'siteautoend'=>-1, + 'siteglobalscore'=>-1, + 'siteactive'=>-1, + 'sitescorelevel'=>-1, + 'sitepermitlogins'=>-1, + 'siteautojudge'=>-1, + 'sitenextuser'=>-1, + 'sitenextclar'=>-1, + 'sitenextrun'=>-1, + 'sitenexttask'=>-1, + 'sitemaxtask'=>-1, + 'sitechiefname'=>-1, + 'updatetime'=>-1); + $acr['USERREC']=array('site'=>-1, + 'user'=>-1, + 'number'=>-1, + 'username'=>-1, + 'updatetime'=>-1, + 'usericpcid'=>-1, + 'userfull'=>-1, + 'userdesc'=>-1, + 'type'=>-1, + 'enabled'=>-1, + 'multilogin'=>-1, + 'userip'=>-1, + 'userlastlogin'=>-1, + 'userlastlogout'=>-1, + 'permitip'=>-1); + + if(strtoupper(substr($ar,0,5)) != '' && isset($_POST['password']) && strlen($_POST['password'])>20) { + echo "
Starting to create the contest
"; + $str = strtok($ar," \n\t"); + $str = strtok(" \n\t"); + $ar = decryptData($str,$_POST['password'],'importxml'); + if(strtoupper(substr($ar,0,5)) != '') { + echo "
Error decrypting file. Import aborted.
"; + echo ""; + exit; + } + } + if(strtoupper(substr($ar,0,5)) == '') { + echo "
File has been loaded.
"; +// echo "
\n$ar
\n"; + if(!importFromXML($ar,$acr,0,$localsite)) + echo "
Error during updating of the local database.
"; + echo ""; + exit; + } + else + $id = rawurldecode(strtok($ar," \n\t")); + } + } +} else { + unset($_POST['localsite']); + unset($_SESSION['importfile']); +} +?> +
+
+
+To import a pre-defined contest, just fill in the import file field.
+
+ + + + +
+ +
+ + + + + +\n"; + } else { +?> + + + + +"; + } else { +?> + + + + + +
Local site number: +"; + } else + echo ""; +?> +
Challenge string:" . $id . "
Import file: + +
Encryption key: + +
+
+ +
+ + +
+
+ + + -- cgit v1.2.3