function filedownload($oid, $fname, $msg = '') { $cf = globalconf(); $if = rawurlencode(encryptData($fname, session_id() . $cf['key'], false)); $p = myhash($oid . $fname . $msg . session_id() . $cf["key"]); $str = "oid=" . $oid . "&filename=" . $if . "&check=" . $p; if ($msg != '') { $str .= "&msg=" . rawurlencode($msg); } return $str; }
function getMainXML($username, $sess, $pass, $pass2) { $c = DBConnect(); if ($c == null) { return array(false, ""); } $contest = $_SESSION["usertable"]["contestnumber"]; $r = DBExec($c, "select * from contesttable where contestnumber={$contest}"); if (DBnLines($r) == 0) { echo "Unable to find the contest {$contest} in the database.\n"; exit; } $ct = DBRow($r, 0); $localsite = $ct["contestlocalsite"]; $mainsite = $ct["contestmainsite"]; $siteurl = $ct['contestmainsiteurl'] . '/site/get.php'; // if ($mainsite==$localsite) return array(true,""); /* $r = DBExec($c, "select * from sitetable where sitenumber=".$mainsite." and contestnumber=$contest"); if (DBnLines($r)==0) { echo "Unable to find the main site in the database (site=$mainsite, contest=$contest).\n"; exit; } $st = DBRow($r,0); $siteurl = $st["siteip"] . '/site/get.php'; */ if (substr($siteurl, 0, 7) != 'http://') { $siteurl = 'http://' . $siteurl; } if ($sess == '') { // MSGError('session empty'); $s = file_get_contents($siteurl); if ($s === false) { return array(false, '', ''); } // MSGError($s); $t = strtok($s, " \t"); while ($t !== false && substr($t, 0, 8) != '<SESSION' && substr($t, 0, 6) != '<ERROR' && $t != '<OK>' && $t != '<NOTOK>') { echo $t . " "; $t = strtok(" \t"); } if ($t === false) { return array(false, '', ''); } echo $t . " -->\n"; if (substr($t, 0, 8) == '<SESSION') { $id = strtok(" \t"); return array(false, $id, $id); } else { return array(false, '', ''); } } if ($pass == $pass2) { // MSGError('equal'); $opts = array('http' => array('method' => 'GET', 'header' => 'Cookie: PHPSESSID=' . $sess)); $context = stream_context_create($opts); $s = file_get_contents($siteurl . '?name=' . $username . '&password='******'&check=nocheck', 0, $context); } else { $data = encryptData(generateXML($contest), myhash($pass2)); $data_url = http_build_query(array('xml' => $data, 'name' => $username, 'password' => $pass, 'check' => myhash($pass . $pass2))); $opts = array('http' => array('method' => 'POST', 'header' => 'Cookie: PHPSESSID=' . $sess . "\r\nContent-Type: application/x-www-form-urlencoded", 'content' => $data_url)); $context = stream_context_create($opts); $s = file_get_contents($siteurl, 0, $context); } if ($s === false) { return array(false, "", ''); } // MSGError('OPA1: ' . $s); $t = strtok($s, " \t"); while ($t !== false && substr($t, 0, 8) != '<SESSION' && substr($t, 0, 6) != '<ERROR' && $t != '<OK>' && $t != '<NOTOK>') { echo $t . " "; $t = strtok(" \t"); } if ($t === false) { return array(false, '', ''); } echo $t . " -->\n"; if (substr($t, 0, 6) == "<ERROR") { $id = strtok(" \t"); if ($id === false) { return array(false, '', ''); } return array(false, $id, ""); } if (substr($t, 0, 8) == "<SESSION") { $id = strtok(" \t"); if ($id === false) { return array(false, '', ''); } $idextra = strtok(" \t"); if ($idextra === false) { return array(false, '', ''); } // MSGError("id=$id idextra=$idextra"); return array(false, $id, $idextra); } $id = strtok(" \t"); if ($id === false) { return array(false, '', ''); } //MSGError('OPA2: ' . $s); if ($pass2 != '') { $s = decryptData($id, myhash($pass2)); } if (strtoupper(substr($s, 0, 5)) != "<XML>") { return array(false, '', $t); } return array(true, $s, $t); }
$strtmp .= "<br><br><center><b>To submit a program, just fill in the following fields:</b></center>\n" . "<form name=\"form1\" enctype=\"multipart/form-data\" method=\"post\" action=\"" . $runteam . "\">\n" . " <input type=hidden name=\"confirmation\" value=\"noconfirm\" />\n" . " <center>\n" . " <table border=\"0\">\n" . " <tr> \n" . " <td width=\"25%\" align=right>Problem:</td>\n" . " <td width=\"75%\">\n" . " <select name=\"problem\" onclick=\"Arquivo()\">\n"; $prob = DBGetProblems($_SESSION["usertable"]["contestnumber"], $_SESSION["usertable"]["usertype"] == 'judge'); $strtmp .= "<option selected value=\"-1\"> -- </option>\n"; for ($i = 0; $i < count($prob); $i++) { $strtmp .= "<option value=\"" . $prob[$i]["number"] . "\">" . $prob[$i]["problem"] . "</option>\n"; } $strtmp .= "\t </select>\n" . " </td>\n" . " </tr>\n" . " <tr> \n" . " <td width=\"25%\" align=right>Language:</td>\n" . " <td width=\"75%\"> \n" . " <select name=\"language\" onclick=\"Arquivo()\">\n"; $lang = DBGetLanguages($_SESSION["usertable"]["contestnumber"]); $strtmp .= "<option selected value=\"-1\"> -- </option>\n"; for ($i = 0; $i < count($lang); $i++) { $strtmp .= "<option value=\"" . $lang[$i]["number"] . "\">" . $lang[$i]["name"] . "</option>\n"; } $strtmp .= "\t </select>\n" . " </td>\n" . " </tr>\n" . " <tr> \n" . " <td width=\"25%\" align=right>Source code:</td>\n" . " <td width=\"75%\">\n" . "\t <input type=\"file\" name=\"sourcefile\" size=\"40\" onclick=\"Arquivo()\">\n" . " </td>\n" . " </tr>\n" . " </table>\n" . " </center>\n" . " <script language=\"javascript\">\n" . " function conf() {\n" . " if (document.form1.problem.value != '-1' && document.form1.language.value != '-1') {\n" . " if (confirm(\"Confirm submission?\")) {\n" . " document.form1.confirmation.value='confirm';\n" . " }\n" . " } else {\n" . " alert('Invalid problem and/or language');\n" . " }\n" . " }\n" . " </script>\n" . " <center>\n" . " <input type=\"submit\" name=\"Submit\" value=\"Send\" onClick=\"conf()\">\n" . " <input type=\"reset\" name=\"Submit2\" value=\"Clear\">\n" . " </center>\n" . "</form>\n"; } $conf = globalconf(); $strtmp1 = "<!-- " . time() . " --> <?php exit; ?>\t" . encryptData($strcolors, $conf["key"], false) . "\n" . encryptData($strtmp, $conf["key"], false); $randnum = session_id() . "_" . rand(); if (file_put_contents($runtmp . "_" . $randnum, $strtmp1, LOCK_EX) === FALSE) { if (!isset($_SESSION['writewarn'])) { LOGError("Cannot write to the user-run cache file {$runtmp} -- performance might be compromised"); $_SESSION['writewarn'] = true; } } @rename($runtmp . "_" . $randnum, $runtmp); } echo $strtmp; ?> </body> </html>
} } $strtmp .= " <td nowrap>" . $score[$e]["totalcount"] . " (" . $score[$e]["totaltime"] . ")</td>\n"; $strtmp .= " </tr>\n"; $n++; } } $strtmp .= "</table>"; if ($n == 0) { $strtmp .= "<br><center><b><font color=\"#ff0000\">SCOREBOARD IS EMPTY</font></b></center>"; } else { if (!$des) { if ($level > 0) { $strtmp .= "<br><font color=\"#ff0000\">P.S. Problem names are hidden.</font>"; } else { $strtmp .= "<br><font color=\"#ff0000\">P.S. Problem data are hidden.</font>"; } } } $conf = globalconf(); $strtmp = "<!-- " . time() . " --> <?php exit; ?>\n" . encryptData($strtmp, $conf["key"], false); if (file_put_contents($scoretmp, $strtmp, LOCK_EX) === FALSE) { if ($_SESSION["usertable"]["usertype"] == 'admin') { MSGError("Cannot write to the score cache file -- performance might be compromised"); } LOGError("Cannot write to the " . $_SESSION["usertable"]["usertype"] . "-score cache file -- performance might be compromised"); } $conf = globalconf(); $strtmp = decryptData(substr($strtmp, strpos($strtmp, "\n")), $conf["key"]); } echo $strtmp;
echo "=====stderr======\n"; echo file_get_contents('stderr'); echo "\n=====stdout======\n"; echo file_get_contents('stdout'); echo "\n===========\n"; DBGiveUpRunAutojudging($contest, $site, $number, $ip, "error: internal test script failed (" . $file . ")"); $cont = true; break; } } cleardir($dir . $ds . "problemdata"); if ($cont) { continue; } $s = file_get_contents($dir . $ds . $run["inputname"]); file_put_contents($cache . $ds . $run["inputoid"] . "." . $run["inputname"], encryptData($s, $key)); } if (!isset($limits[$basename][$run["extension"]][0]) || !is_numeric($limits[$basename][$run["extension"]][0]) || !isset($limits[$basename][$run["extension"]][1]) || !is_numeric($limits[$basename][$run["extension"]][1]) || !isset($limits[$basename][$run["extension"]][2]) || !is_numeric($limits[$basename][$run["extension"]][2]) || !isset($limits[$basename][$run["extension"]][3]) || !is_numeric($limits[$basename][$run["extension"]][3])) { echo "Failed to find proper limits information for the problem -- please check the problem package\n"; DBGiveUpRunAutojudging($contest, $site, $number, $ip, "error: problem package file is invalid (6)"); continue; } // COMPILATION //# parameters are: //# $1 source_file //# $2 exe_file (default ../run.exe) //# $3 timelimit (optional, limit to run all the repetitions, by default only one repetition) //# $4 maximum allowed memory (in MBytes) $zip = new ZipArchive(); if ($zip->open($dir . $ds . $run["inputname"]) === true) { $zip->extractTo($dir, array("compile" . $ds . $run["extension"]));
<div class="triangle"></div> <div class="container"> <div class=" title"> <h1>Trusted Cloud</h1> </div> <?php if ($_SERVER["REQUEST_METHOD"] == "POST") { $connect = mysql_connect("localhost", "root", "") or die(mysql_error()); mysql_select_db("be") or die("<br><br>no such database found!!!<br><br>"); //count total files to compute IDF $query11 = mysql_query(" SELECT * FROM fileindex ") or die(mysql_error()); $total_documents = mysql_num_rows($query11); $text = $_POST['query']; $startTime = microtime(true); //echo "<b>Entered Query : </b>".$text; $encryptText = encryptData($text); //echo "<b>Encrypted Query : </b>".$encryptText; $query4 = mysql_query("select * from topkresults") or die(mysql_error()); if (mysql_num_rows($query4)) { //table is not empty, delete data $query44 = mysql_query("truncate table topkresults"); } $query7 = mysql_query("select * from topkencryptresults") or die(mysql_error()); if (mysql_num_rows($query7)) { //table is not empty, delete data $query77 = mysql_query("truncate table topkencryptresults"); } if (strlen($text) > 3) { $searchTimeTrustedStart = microtime(true); //break the query into keywords $words = extractCommonWords($text);
echo "\nPasswords mismatch - aborting\n"; exit; } } if (strlen($password2) < 12) { echo "\n\n#\n##\n###\n####\n#####\n###### WARNING: the main password should be really secure - consider using a longer and complicated password\n"; } $password1 = randstr(16); if (is_dir(trim($argv[1]))) { echo "Creating file " . $argv[2] . " from directory/file " . $argv[1] . "\n"; if (($ret = create_zip(trim($argv[1]), glob(trim($argv[1]) . $ds . '*'), trim($argv[2]), true)) > 0) { echo "ZIP Success\n"; } else { echo "ZIP Error {$ret}\n"; } $encdata = encryptData(file_get_contents(trim($argv[2])), '#####' . $password1, false); if ($encdata == '') { $encdata = file_get_contents(trim($argv[2])); } } else { $encdata = encryptData(file_get_contents(trim($argv[1])), '#####' . $password1, true); if ($encdata == '') { $encdata = file_get_contents(trim($argv[1])); } } file_put_contents(trim($argv[2]), $encdata); echo "Output file generated in " . $argv[2] . "\n"; echo "\n\nThe following line is a key that should be appended to a text file with one key per line.\n\n"; echo substr($encdata, 0, 10) . '#####' . encryptData('#####' . $password1, $password2, false) . "\n\n"; echo "Later on, in the admin web interface of BOCA tab Contest, item Contest keys, please select the file with\nall these lines click on update.\n\n"; exit;
function display($filename, $contents) { $displayStartTime = microtime(true); $filesize = filesize("C:\\xampp\\htdocs\\BEPROJECT\\Html\\Text/" . $filename); $aesKey = "Mary has one cat"; /*echo 'FileName = '.$filename.'<br>'; echo 'FileSize(in bytes) = '.$filesize.'<br><br>'; echo '<b><center>Original Data uploaded by client:</center></b><br>'.$contents.'<br><br>';*/ $EncryptedData = encryptData($contents, $filename); /*echo '<b><center>Encrypted Data stored on Cloud: </center></b><br>'.$EncryptedData.'<br>'; $DecryptedData = decryptData($EncryptedData, $filename); echo '<br><b><center>Decrypted Data reterived by client: </center></b><br>'.$DecryptedData;*/ $connect = mysql_connect("localhost", "root", "") or die(mysql_error()); mysql_select_db("be") or die("<br><br>no database found<br><br>"); echo '<br><br>'; /*echo '<b><center>Plain file indexing</b>(for reference only)</center><br>'; $query1 = " select * from fileindex "; $result1 = mysql_query($query1) or die("<br>Query Failed selecting from fileindex ".mysql_error()); $numrows1 = mysql_num_rows($result1); if($numrows1 > 0) { echo "<table border='1' cellspacing='4' cellpadding='4' align='center'>"; echo "<tr><th>ID</th><th>Name</th><th>Size(in KB)</th></tr>"; while($rows1 = mysql_fetch_assoc($result1)) { $id = $rows1['file_id']; $name = $rows1['file_name']; $size = $rows1['file_size']; echo "<tr><td>$id</td><td>$name</td><td>$size</td></tr>"; } echo "</table>"; } else echo "No results found!!!!!";*/ echo ' <center> <br><br><b>Your Access Token</b>(<i>you need to input this token while downloading file</i>!!! : <br> <h4 style="color:red">a:2:{s:1:"t";s:16:"hic55718skyllls1";s:1:"s";s:15:"zfz5wtb8giiaq1t";}</h4> <a href="downloadAccessToken.php">Download Access Token File</a> </center> '; echo '<br><br>'; echo '<b><center>Encrypted file indexing</b>(stored on trusted cloud server)</center><br>'; $query11 = " select * from encryptedfileindex "; $result11 = mysql_query($query11) or die("<br>Query Failed selecting from encryptedfileindex " . mysql_error()); $numrows11 = mysql_num_rows($result11); if ($numrows11 > 0) { echo "<table border='1' cellspacing='4' cellpadding='4' align='center'>"; echo "<tr><th>ID</th><th>Name</th><th>Size(in KB)</th></tr>"; while ($rows11 = mysql_fetch_assoc($result11)) { $id = $rows11['file_id']; $name = $rows11['file_name']; $size = $rows11['file_size']; echo "<tr><td>{$id}</td><td>{$name}</td><td>{$size}</td></tr>"; } echo "</table>"; } else { echo "No results found!!!!!"; } echo '<br><br>'; /*//Decrypting fileindex using aes echo '<b><center>Decrypted file indexing</b></center><br>'; $query111 = " select AES_DECRYPT(file_id, '".$aesKey."') as file_id, AES_DECRYPT(file_name, '".$aesKey."') as file_name, AES_DECRYPT(file_size, '".$aesKey."') as file_size from encryptedfileindex "; $result111 = mysql_query($query111) or die("<br>Query Failed selecting from encryptedfileindex ".mysql_error()); $numrows111 = mysql_num_rows($result111); if($numrows111 > 0) { echo "<table border='1' cellspacing='4' cellpadding='4' align='center'>"; echo "<tr><th>ID</th><th>Name</th><th>Size(in KB)</th></tr>"; while($rows111 = mysql_fetch_assoc($result111)) { $id_decrypt = $rows111['file_id']; $name_decrypt = $rows111['file_name']; $size_decrypt = $rows111['file_size']; echo "<tr><td>$id_decrypt</td><td>$name_decrypt</td><td>$size_decrypt</td></tr>"; } echo "</table>"; } else echo "No results found!!!!!";*/ echo '<br><br>'; /*echo '<b><center>Plain keyword indexing</b>(for reference only)</center><br>'; $query2 = " select * from modifiedindex "; $result2 = mysql_query($query2) or die("<br>Query Failed selecting from modifiedindex ".mysql_error()); $numrows2 = mysql_num_rows($result2); if($numrows2 > 0) { echo "<table border='1' cellspacing='4' cellpadding='4' align='center'>"; echo "<tr><th>ID</th><th>Keyword</th><th>Frequency</th><th>Term_Frequency</th></tr>"; while($rows2 = mysql_fetch_assoc($result2)) { $id = $rows2['file_id']; $keyword = $rows2['keyword']; $frequency = $rows2['frequency']; $term_freq = $rows2['term_frequency']; echo "<tr><td>$id</td><td>$keyword</td><td>$frequency</td><td>$term_freq</td></tr>"; } echo "</table>"; } else echo "No results found!!!!!";*/ echo '<br><br>'; echo '<b><center>Encrypted keyword indexing</b>(stored on trusted cloud server)</center><br>'; $query22 = " select * from encryptedindex "; $result22 = mysql_query($query22) or die("<br>Query Failed selecting from encryptedindex " . mysql_error()); $numrows22 = mysql_num_rows($result22); if ($numrows22 > 0) { echo "<table border='1' cellspacing='4' cellpadding='4' align='center'>"; echo "<tr><th>ID</th><th>Keyword</th><th>Frequency</th><th>Term_Frequency</th></tr>"; while ($rows22 = mysql_fetch_assoc($result22)) { $id = $rows22['file_id']; $keyword = $rows22['keyword']; $frequency = $rows22['frequency']; $term_freq = $rows22['term_frequency']; echo "<tr><td>{$id}</td><td>{$keyword}</td><td>{$frequency}</td><td>{$term_freq}</td></tr>"; } echo "</table>"; } else { echo "No results found!!!!!"; } echo '<br><br>'; /*//Decrypting keyword index using aes echo '<b><center>Decrypted Keyword indexing</b></center><br>'; $query222 = " select AES_DECRYPT(file_id, '".$aesKey."') as file_id, AES_DECRYPT(keyword, '".$aesKey."') as keyword, AES_DECRYPT(frequency, '".$aesKey."') as frequency, AES_DECRYPT(term_frequency, '".$aesKey."') as term_frequency from encryptedindex "; $result222 = mysql_query($query222) or die("<br>Query Failed selecting from encryptedindex ".mysql_error()); $numrows222 = mysql_num_rows($result222); if($numrows222 > 0) { echo "<table border='1' cellspacing='4' cellpadding='4' align='center'>"; echo "<tr><th>ID</th><th>Keyword</th><th>Frequency</th><th>Term_Frequency</th></tr>"; while($rows222 = mysql_fetch_assoc($result222)) { $id = $rows222['file_id']; $keyword = $rows222['keyword']; $frequency = $rows222['frequency']; $term_freq = $rows222['term_frequency']; echo "<tr><td>$id</td><td>$keyword</td><td>$frequency</td><td>$term_freq</td></tr>"; } echo "</table>"; } else echo "No results found!!!!!";*/ echo '<br><br>'; $displayEndTime = microtime(true); $totalDisplayTime = $displayEndTime - $displayStartTime; $_SESSION['displayText_time'] = $totalDisplayTime; }
if (count($scores) == 0 || count($scores) == 1 && !is_numeric($scores[0])) { $scores = array($fromsite); } $judges = explode(",", $siteinfo['sitejudging']); if (count($judges) == 0 || count($judges) == 1 && !is_numeric($judges[0])) { $judges = array($fromsite); } $scores = array_unique(array_merge($scores, $judges)); if (in_array(0, $scores)) { $scores = null; } $xml = generateXML($_SESSION["usertable"]["contestnumber"], $localsite, $scores, $reduced); if (isset($_POST['nopassword']) && $_POST['nopassword'] == 'true') { echo $xml; } else { echo rawurlencode($_POST['challenge']) . " " . encryptData($xml, $_POST['password']); } exit; } } ob_end_flush(); ?> <br> <body onload="document.form1.name.focus()"> <script language="JavaScript" src="../sha256.js"></script> <script language="JavaScript"> function computeHASH() { var passHASH; if(document.form1.password.value == '') { document.form1.nopassword.value = 'true';
function addContinuationsEntry($nextmode, $data = array(), $duration = SECINWEEK, $deleteFromSelf = 1, $multicall = 1, $repeatProtect = 0) { global $user, $mode, $inContinuation, $continuationid; if ($repeatProtect) { $data['______parent'] = $continuationid; } $serdata = serialize($data); $contid = md5($mode . $nextmode . $serdata . $user['id']); $serdata = mysql_escape_string($serdata); $expiretime = unixToDatetime(time() + $duration); $query = "SELECT id, " . "parentid " . "FROM continuations " . "WHERE id = '{$contid}' AND " . "userid = {$user['id']}"; $qh = doQuery($query, 101); if ($row = mysql_fetch_assoc($qh)) { # update expiretime $query = "UPDATE continuations " . "SET expiretime = '{$expiretime}' " . "WHERE id = '{$contid}' AND " . "userid = {$user['id']}"; doQuery($query, 101); } else { if (!$inContinuation) { $parent = 'NULL'; } else { $parent = "'{$continuationid}'"; } if ($deleteFromSelf || !$inContinuation) { $deletefromid = $contid; $parent = 'NULL'; } else { $query = "SELECT deletefromid " . "FROM continuations " . "WHERE id = '{$continuationid}' AND " . "userid = {$user['id']}"; $qh = doQuery($query, 101); if (!($row = mysql_fetch_assoc($qh))) { abort(108); } $deletefromid = $row['deletefromid']; } $query = "INSERT INTO continuations " . "(id, " . "userid, " . "expiretime, " . "frommode, " . "tomode, " . "data, " . "multicall, " . "parentid, " . "deletefromid) " . "VALUES " . "('{$contid}', " . "{$user['id']}, " . "'{$expiretime}', " . "'{$mode}', " . "'{$nextmode}', " . "'{$serdata}', " . "{$multicall}, " . "{$parent}, " . "'{$deletefromid}')"; doQuery($query, 101); } $salt = generateString(8); $now = time(); $data = "{$salt}:{$contid}:{$user['id']}:{$now}"; $edata = encryptData($data); $udata = urlencode($edata); return $udata; }
function DBGetFullProblemData($contestnumber, $freeproblems = false) { $c = DBConnect(); DBExec($c, "begin work", "GetFullProblemData"); $r = DBExec($c, "select p.problemnumber as number, p.problemname as name, p.problemfullname as fullname, " . "p.problembasefilename as basefilename, p.fake as fake, " . "p.problemcolor as color, p.problemcolorname as colorname, " . "p.probleminputfilename as inputfilename, p.probleminputfile as inputoid, p.probleminputfilehash as inputhash " . " from problemtable as p " . "where p.contestnumber={$contestnumber} order by p.problemnumber", "DBGetFullProblemData(get problem)"); // and p.problemfullname !~ '(DEL)' $n = DBnlines($r); if ($n == 0) { LOGLevel("No problems defined in the database ({$contestnumber})", 1); } $cf = globalconf(); $a = array(); $ds = DIRECTORY_SEPARATOR; if ($ds == "") { $ds = "/"; } for ($i = 0; $i < $n; $i++) { $a[$i] = array_merge(array(), DBRow($r, $i)); if (strpos($a[$i]['fullname'], '(DEL)') !== false) { continue; } $nn = $a[$i]['number']; $ptmp = $_SESSION["locr"] . $ds . "private" . $ds . "problemtmp" . $ds . "contest" . $contestnumber . "-problem" . $nn; $ck = myshorthash(''); if (is_readable($ptmp . ".hash")) { $ck = trim(file_get_contents($ptmp . ".hash")); } if ($ck != $a[$i]['inputhash']) { @unlink($ptmp . ".name"); @unlink($ptmp . ".hash"); $a[$i]['basefilename'] = ''; $a[$i]['descfilename'] = ''; $a[$i]['fullname'] = ''; } if ($freeproblems && $a[$i]['fake'] != 't') { if (is_readable($ptmp . ".name")) { $a[$i]['descfilename'] = trim(file_get_contents($ptmp . ".name")); if ($a[$i]['descfilename'] != '') { $a[$i]['descoid'] = -1; } } else { @unlink($ptmp . ".name"); @unlink($ptmp . ".hash"); $randnum = session_id() . "_" . rand(); $dir = $ptmp . '-' . $randnum; @mkdir($dir, 0770, true); $failed = 0; if (($ret = DB_lo_export($contestnumber, $c, $a[$i]["inputoid"], $dir . $ds . "tmp.zip")) === false) { LogError("FreeProblems: Unable to read problem package from database (problem={$nn}, contest={$contestnumber})"); $failed = 1; } if (!$failed) { $zip = new ZipArchive(); if ($zip->open($dir . $ds . "tmp.zip") === true) { $zip->extractTo($dir); $zip->close(); if (($info = @parse_ini_file($dir . $ds . "description" . $ds . 'problem.info')) === false) { $failed = 2; } if (!$failed) { $descfile = ''; if (isset($info['descfile'])) { $descfile = trim(sanitizeText($info['descfile'])); } $basename = trim(sanitizeText($info['basename'])); $fullname = trim(sanitizeText($info['fullname'])); if ($basename == '' || $fullname == '') { $failed = 3; } } } else { $failed = 4; } if (!$failed) { @mkdir($ptmp); if ($descfile != '') { if (file_put_contents($ptmp . $ds . $descfile, encryptData(file_get_contents($dir . $ds . "description" . $ds . $descfile), $cf['key']), LOCK_EX) === FALSE) { $failed = 5; } if (!$failed) { file_put_contents($ptmp . ".name", $ptmp . $ds . $descfile); file_put_contents($ptmp . ".hash", $a[$i]['inputhash']); if (is_readable($ptmp . ".name")) { $a[$i]['descfilename'] = trim(file_get_contents($ptmp . ".name")); if ($a[$i]['descfilename'] != '') { $a[$i]['descoid'] = -1; } } } } else { @unlink($ptmp . ".name"); @unlink($ptmp . ".hash"); } if (!$failed) { DBExec($c, "update problemtable set problemfullname='{$fullname}', problembasefilename='{$basename}' where problemnumber={$nn} and contestnumber={$contestnumber}", "DBGetFullProblemData(free problem)"); $a[$i]['basefilename'] = $basename; $a[$i]['fullname'] = $fullname; } } } if ($failed) { $a[$i]['basefilename'] = ''; $a[$i]['descfilename'] = ''; @unlink($ptmp . ".name"); @unlink($ptmp . ".hash"); DBExec($c, "update problemtable set problemfullname='', problembasefilename='' where problemnumber={$nn} and contestnumber={$contestnumber}", "DBGetFullProblemData(unfree problem)"); if ($failed != 4) { LogError("Failed to unzip problem package (failcode={$failed}, problem={$nn}, contest={$contestnumber})"); if ($failed == 1) { $a[$i]['fullname'] = '(ERROR READING FROM DATABASE, OR DIRECTORY PERMISSION PROBLEM)'; } else { $a[$i]['fullname'] = '(PROBLEM PACKAGE SEEMS INVALID)'; } } else { if ($ret == 1) { $a[$i]['fullname'] = '(PROBABLY ENCRYPTED FILE)'; } if ($ret == 2) { $a[$i]['fullname'] = '(FILE IS NOT A ZIP)'; } } } cleardir($dir, false, true); } } } DBExec($c, "commit", "GetFullProblemData"); return $a; }
} $tasks = explode(",", $siteinfo['sitetasking']); if (count($tasks) == 0 || count($tasks) == 1 && !is_numeric($tasks[0])) { $tasks = array($fromsite); } } else { echo "<!-- <ERROR9> " . session_id() . " " . session_id() . " -->\n"; exit; } if (isset($_POST) && 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); $ac = array(); $ac['SITEREC'] = array('site' => $fromsite, 'sitenumber' => 0, 'number' => 0, 'sitename' => 0, 'siteip' => 0, 'siteduration' => 0, 'sitelastmileanswer' => 0, 'sitelastmilescore' => 0, 'siteautoend' => 0, 'siteactive' => 0, 'sitescorelevel' => 0, 'sitepermitlogins' => 0, 'siteautojudge' => 0, 'sitenextuser' => 0, 'sitenextclar' => 0, 'sitenextrun' => 0, 'sitenexttask' => 0, 'sitemaxtask' => 0, 'sitechiefname' => 0, 'updatetime' => 0); $ac['SITETIME'] = array('site' => $fromsite, 'number' => 0, 'start' => 0, 'enddate' => 0, 'updatetime' => 0); $ac['USERREC'] = array('site' => $fromsite, 'user' => 0, 'number' => 0, 'username' => 0, 'usericpcid' => 0, 'userfull' => 0, 'userdesc' => 0, 'type' => 0, 'enabled' => 0, 'multilogin' => 0, 'userip' => 0, 'userlastlogin' => 0, 'userlastlogout' => 0, 'permitip' => 0, 'updatetime' => 0); $ac['CLARREC'] = array('site' => $judges, 'user' => 0, 'number' => 0, 'problem' => 0, 'question' => 0, 'clarnumber' => 0, 'clardate' => 0, 'clardatediff' => 0, 'clardatediffans' => 0, 'claranswer' => 0, 'clarstatus' => 0, 'clarjudge' => 0, 'clarjudgesite' => 0, 'updatetime' => 0); $ac['RUNREC'] = array('site' => $judges, 'user' => 0, 'number' => 0, 'runnumber' => 0, 'problem' => 0, 'lang' => 0, 'filename' => 0, 'filepath' => 0, 'rundate' => 0, 'rundatediff' => 0, 'rundatediffans' => 0, 'runanswer' => 0, 'runstatus' => 0, 'runjudge' => 0, 'runjudgesite' => 0, 'runjudge1' => 0, 'runjudgesite1' => 0, 'runanswer1' => 0, 'runjudge2' => 0, 'runjudgesite2' => 0, 'runanswer2' => 0, 'autoip' => 0, 'autobegindate' => 0, 'autoenddate' => 0, 'autoanswer' => 0, 'autostdout' => 0, 'autostderr' => 0, 'updatetime' => 0); $ac['TASKREC'] = array('site' => $tasks, 'user' => 0, 'desc' => 0, 'number' => 0, 'tasknumber' => 0, 'color' => 0, 'colorname' => 0, 'updatetime' => 0, 'filename' => 0, 'filepath' => 0, 'sys' => 0, 'status' => 0, 'taskdate' => 0, 'taskdatediff' => 0, 'taskdatediffans' => 0, 'taskstaffnumber' => 0, 'taskstaffsite' => 0); if (importFromXML($s, $ac, $_SESSION["usertable"]["contestnumber"])) { echo "<!-- <OK> -->"; } else { echo "<!-- <NOTOK> -->"; } } $xml = generateXML($_SESSION["usertable"]["contestnumber"], 0, $scores); echo encryptData($xml, myhash($_SESSION["usertable"]["userpassword"])); } else { echo "<!-- <ERROR3> " . session_id() . " " . session_id() . " -->\n"; }
/** * map转换string,按新规范加密 * * @param * $customerInfo */ function getCustomerInfoStrNew($customerInfo) { $encryptedInfo = array(); foreach ($customerInfo as $key => $value) { if ($key == 'phoneNo' || $key == 'cvn2' || $key == 'expired') { //if ($key == 'phoneNo' || $key == 'cvn2' || $key == 'expired' || $key == 'certifTp' || $key == 'certifId') { $encryptedInfo[$key] = $customerInfo[$key]; unset($customerInfo[$key]); } } if (count($encryptedInfo) != 0) { $encryptedInfo = createLinkString($encryptedInfo, false, false); $encryptedInfo = encryptData($encryptedInfo, SDK_ENCRYPT_CERT_PATH); $customerInfo['encryptedInfo'] = $encryptedInfo; } return base64_encode("{" . createLinkString($customerInfo, false, false) . "}"); }
echo $p->t("lvplan/persoenlicherLvPlan"); ?> </a><br><br> </td><td valign="top"> <?php if (!defined('CIS_LVPLAN_EXPORT_ANZEIGEN') || CIS_LVPLAN_EXPORT_ANZEIGEN) { echo ' <h2>' . $p->t('lvplan/persoenlichenAbonnieren') . '</h2> <div> <a class="Item" href="../../../cms/content.php?content_id=' . $p->t('dms_link/lvplanSyncFAQ') . '" target="_blank">' . $p->t('lvplan/anleitungLVPlanSync') . '</a> <br>'; echo '<ul>'; $caldavurl = APP_ROOT . 'webdav/lvplan.php/calendars/' . $uid . '/LVPlan-' . $uid; echo '<li><a class="Item" href="' . $caldavurl . '">' . $p->t('lvplan/caldavURL') . '</a></li>'; echo '<li><a class="Item" href="' . APP_ROOT . 'webdav/lvplan.php/principals/' . $uid . '">' . $p->t('lvplan/caldavURLMac') . '</a></li>'; echo '<li><a class="Item" href="' . APP_ROOT . 'webdav/google.php?cal=' . encryptData($uid, LVPLAN_CYPHER_KEY) . '&' . microtime(true) . '">' . $p->t('lvplan/googleURL') . '</a></li>'; echo '</ul>'; echo ' </div>'; } echo ' </td></tr> <tr> <td width="30%"> <h2>' . $p->t("lvplan/saalplan") . '</h2> </td> <td>'; if (!defined('CIS_LVPLAN_PERSONENAUSWAHL_ANZEIGEN') || CIS_LVPLAN_PERSONENAUSWAHL_ANZEIGEN) { echo '<h2>' . $p->t("lvplan/lektorInStudentIn") . '</h2>'; } echo '
$webcastdir = $locr . $ds . 'private' . $ds . 'webcast'; $webcastparentdir = $locr . $ds . 'private'; } cleardir($webcastdir); @mkdir($webcastdir); if (is_writable($webcastdir)) { file_put_contents($webcastdir . $ds . 'runs', $runfile); file_put_contents($webcastdir . $ds . 'contest', $contestfile); file_put_contents($webcastdir . $ds . 'version', $versionfile); file_put_contents($webcastdir . $ds . 'time', $timefile); if (@create_zip($webcastparentdir, array('webcast'), $webcastdir . ".tmp") != 1) { LOGError("Cannot create score webcast.tmp file"); MSGError("Cannot create score webcast.tmp file"); } else { $cf = globalconf(); file_put_contents($webcastdir . ".tmp", encryptData(file_get_contents($webcastdir . ".tmp"), $cf["key"], false)); @rename($webcastdir . ".tmp", $webcastdir . '.zip'); } echo "<br><br><br><center>"; echo "<a href=\"{$locr}/filedownload.php?" . filedownload(-1, $webcastdir . '.zip') . "\">CLICK TO DOWNLOAD</a>"; echo "</center>"; } else { LOGError('Error creating the folder for the ZIP file: ' . $webcastdir); MSGError('Error creating the folder for the ZIP file: ' . $webcastdir); ForceLoad("../index.php"); } echo "<br><br><br>\n"; echo "<br><br><br>\n"; echo "<br><br><br>\n"; echo "<br><br><br>\n"; echo "<br><br><br>\n";