public function getPath($key) { $tmpPath = DS . 'tmp' . DS . 'imgincache' . DS . $key; if (defined('IMGIN_CACHE_DIR')) { $tmpPath = IMGIN_CACHE_DIR . DS . $key; } cleardir(dirname($tmpPath)); return $this->createObject($key, $tmpPath); }
function onedit() { $id = isset($this->get[2]) ? $this->get[2] : $this->post['id']; if (isset($this->post['submit'])) { $name = trim($this->post['name']); $categorydir = ''; $cid = 0; $category1 = $this->post['category1']; $category2 = $this->post['category2']; $category3 = $this->post['category3']; if ($category3) { $cid = $category3; } else { if ($category2) { $cid = $category2; } else { if ($category1) { $cid = $category1; } } } $_ENV['category']->update_by_id($id, $name, $categorydir, $cid); cleardir(TIPASK_ROOT . '/data/cache'); //清除缓存文件 $this->post['cid'] ? $this->onview($this->post['cid']) : $this->ondefault(); } else { $category = $this->category[$id]; $item = $category; $selectedarray = array(); for ($grade = $category['grade']; $grade > 1; $grade--) { $selectedarray[] = $item['pid']; $item = $this->category[$item['pid']]; } list($category1, $category2, $category3) = array_reverse($selectedarray); $categoryjs = $_ENV['category']->get_js(); include template('editcategory', 'admin'); } }
function scoretransfer($putname, $localsite) { $ds = DIRECTORY_SEPARATOR; if ($ds == "") { $ds = "/"; } if (is_readable('/etc/boca.conf')) { $pif = parse_ini_file('/etc/boca.conf'); $bocaproxy = @trim($pif['proxy']); if (substr($bocaproxy, 0, 6) != 'tcp://') { $bocaproxy = 'tcp://' . $bocaproxy; } $bocaproxylogin = @trim($pif['proxylogin']); $bocaproxypass = @trim($pif['proxypassword']); if ($bocaproxylogin != "") { $bocaproxypass = base64_encode($bocaproxylogin . ":" . $bocaproxypass); } } else { $bocaproxy = ""; $bocaproxypass = ""; } $privatedir = $_SESSION['locr'] . $ds . "private"; if (!is_readable($privatedir . $ds . 'remotescores' . $ds . "otherservers")) { return; } $localfile = "score_site" . $localsite . "_" . $localsite . "_x.dat"; $remotesite = @file($privatedir . $ds . 'remotescores' . $ds . "otherservers"); $contest = $_SESSION["usertable"]["contestnumber"]; if ($contest != '' && ($ct = DBContestInfo($contest)) != null) { if (trim($ct['contestmainsiteurl']) != '') { $tmp = explode(' ', $ct['contestmainsiteurl']); if (count($tmp) == 3) { $remotesite[count($remotesite)] = $ct['contestmainsiteurl']; } } } for ($i = 0; $i < count($remotesite); $i++) { $sitedata = explode(' ', $remotesite[$i]); if (count($sitedata) < 3) { continue; } $siteurl = $sitedata[0]; if (strpos($siteurl, '#') !== false) { continue; } LOGError("scoretransfer: found site {$siteurl}"); if (substr($siteurl, 0, 7) != 'http://') { $siteurl = 'http://' . $siteurl; } $urldiv = '/'; if (substr($siteurl, strlen($siteurl) - 1, 1) == '/') { $urldiv = ''; } // LOGError("url=" .$siteurl . $urldiv . "index.php?getsessionid=1"); $sess = @file_get_contents($siteurl . $urldiv . "index.php?getsessionid=1"); // LOGError("sess=$sess pass="******" hash=" . myhash(trim($sitedata[2]))); $user = trim($sitedata[1]); $res = myhash(myhash(trim($sitedata[2])) . $sess); // LOGError("url=" . $siteurl . $urldiv . "index.php?name=${user}&password=${res}&action=scoretransfer"); $opts = array('http' => array('method' => 'GET', 'request_fulluri' => true, 'header' => 'Cookie: PHPSESSID=' . $sess)); if ($bocaproxy != "") { $opts['http']['proxy'] = $bocaproxy; } if ($bocapass != "") { $opts['http']['header'] .= "\r\nProxy-Authorization: Basic " . $bocapass; } $context = stream_context_create($opts); $ok = @file_get_contents($siteurl . $urldiv . "index.php?name={$user}&password={$res}&action=scoretransfer", 0, $context); // LOGError("ok=" . $ok); if (substr($ok, strlen($ok) - strlen('SCORETRANSFER OK'), strlen('SCORETRANSFER OK')) == 'SCORETRANSFER OK') { $res = @file_get_contents($siteurl . $urldiv . "scoretable.php?remote=-42", 0, $context); @file_put_contents($privatedir . $ds . 'remotescores' . $ds . 'tmp.zip', $res); if (is_readable($privatedir . $ds . 'remotescores' . $ds . 'tmp.zip')) { $zip = new ZipArchive(); if ($zip->open($privatedir . $ds . 'remotescores' . $ds . 'tmp.zip') === true) { cleardir($privatedir . $ds . 'remotescores' . $ds . 'tmp'); @mkdir($privatedir . $ds . 'remotescores' . $ds . 'tmp'); $zip->extractTo($privatedir . $ds . 'remotescores' . $ds . 'tmp'); foreach (glob($privatedir . $ds . 'remotescores' . $ds . 'tmp' . $ds . '*.dat') as $file) { @chown($file, "www-data"); @chmod($file, 0660); $bn = basename($file); if ($bn == $localfile) { @rename($file, $privatedir . $ds . 'remotescores' . $ds . "score_site" . $localsite . "__y.dat"); } else { @rename($file, $privatedir . $ds . 'remotescores' . $ds . basename($file)); } } $zip->close(); LOGError("scoretransfer: download OK"); } else { LOGError("scoretransfer: download failed (2)"); } cleardir($privatedir . $ds . 'remotescores' . $ds . 'tmp'); @unlink($privatedir . $ds . 'remotescores' . $ds . 'tmp.zip'); } else { LOGError("scoretransfer: download failed (3)"); } } else { LOGError("scoretransfer: download failed (1)"); } if (is_readable($putname)) { $data = @file_get_contents($putname); $data_url = http_build_query(array('data' => $data)); $opts = array('http' => array('method' => 'POST', 'request_fulluri' => true, 'header' => 'Cookie: PHPSESSID=' . $sess . "\r\nContent-Type: application/x-www-form-urlencoded", 'content' => $data_url)); if ($bocaproxy != "") { $opts['http']['proxy'] = $bocaproxy; } if ($bocapass != "") { $opts['http']['header'] .= "\r\nProxy-Authorization: Basic " . $bocapass; } $context = stream_context_create($opts); $s = @file_get_contents($siteurl . $urldiv . "site/putfile.php", 0, $context); if (strpos($s, 'SCORE UPLOADED OK') !== false) { LOGError("scoretransfer: upload OK"); } else { LOGError("scoretransfer: upload failed (" . $s . ")"); } } break; } }
function server_update_points($server) { global $no_ranking_clusters; mysql_select_db(dbname($server)); file_put('data/calc-stat.dat', 'Berechnung von Server $server ...'); ignore_user_abort(0); $clusters = array(); // Alle Datensätze zurcksetzen, // damit es bei herrenlosen PCs keine falschen Anzeigen gibt: #db_query('UPDATE pcs SET owner_name=\'\', owner_points=0, owner_cluster=0, owner_cluster_code=\'\';'); $current = 0; $u_result = db_query('SELECT * FROM users'); $total = mysql_num_rows($u_result); while ($user = mysql_fetch_assoc($u_result)) { $current++; $upoints = 0; if ($current % 100 == 0) { file_put('data/calc-stat.dat', 'Berechnung von Server ' . $server . ' ... ' . $current . ' / ' . $total); } $pc_result = db_query('SELECT * FROM pcs WHERE owner=\'' . mysql_escape_string($user['id']) . '\';'); $pc_cnt = mysql_num_rows($pc_result); while ($pc = mysql_fetch_assoc($pc_result)) { processupgrades($pc); $pcpoints = getpcpoints($pc, 'bydata'); db_query('UPDATE pcs SET points=\'' . mysql_escape_string($pcpoints) . '\' WHERE id=\'' . mysql_escape_string($pc['id']) . '\';'); $upoints += $pcpoints; } #reset($pcs); #foreach($pcs As $pcid): #$sql='UPDATE pcs SET owner_points=$upoints,owner_name=\''.mysql_escape_string($user['name']).'\' '; #$cluster=getcluster($user['cluster']); #if($cluster!==false) { # $sql.=',owner_cluster='.mysql_escape_string($cluster['id']).', owner_cluster_code=\''.mysql_escape_string($cluster['code']).'\' '; #} #$sql.='WHERE id=\''.mysql_escape_string($pcid).'\''; #db_query($sql); #endforeach; $c = $user['cluster']; if ($c != '' && $c != 0) { #$r=db_query('SELECT id FROM clusters WHERE id=\''.mysql_escape_string($c).'\' LIMIT 1'); #if(mysql_num_rows($r)>0) { $clusters['c' . $c]['points'] += $upoints; $clusters['c' . $c]['members'] += 1; $clusters['c' . $c]['pcs'] += $pc_cnt; #} } if (is_noranKINGuser($user['id']) == false && $user['id'] != 6249 && $user['id'] != 19061) { $rank[$user['id'] . ';' . $user['name'] . ';' . $user['cluster']] = $upoints; } else { db_query('UPDATE users SET points=\'' . mysql_escape_string($upoints) . '\',rank=\'0\' WHERE id=\'' . mysql_escape_string($user['id']) . '\';'); } } #$pcinfo=gettableinfo('pcs',dbname($server)); #file_put('data/_server'.$server.'/pc-count.dat', $pcinfo['Rows']); file_put('data/_server' . $server . '/user-count.dat', mysql_num_rows($u_result)); ignore_user_abort(0); file_put('data/calc-stat.dat', 'Berechnung von Server ' . $server . ' ... Berechnung abgeschlossen: Schreiben in DB ...'); arsort($rank); db_query('TRUNCATE TABLE rank_users'); # Tabelle leeren #$platz=0; while (list($dat, $points) = each($rank)) { #$platz++; $dat = explode(';', $dat); $dat[2] = (int) $dat[2]; db_query('INSERT INTO rank_users VALUES(0, ' . mysql_escape_string($dat[0]) . ', \'' . mysql_escape_string($dat[1]) . '\', ' . mysql_escape_string($points) . ', ' . mysql_escape_string($dat[2]) . ');'); db_query('UPDATE users SET points=' . mysql_escape_string($points) . ', rank=' . mysql_insert_id() . ' WHERE id=' . mysql_escape_string($dat[0]) . ' LIMIT 1;'); } #file_put('data/_server'.$server.'/rank-user-count.dat', count($rank)); db_query('TRUNCATE TABLE rank_clusters'); # Tabelle leeren unset($b); settype($b, 'array'); while (list($bez, $val) = each($clusters)) { $b[$bez] = $clusters[$bez]['points']; } arsort($b); unset($c); settype($c, 'array'); while (list($bez, $val) = each($b)) { $c[$bez]['points'] = $val; $c[$bez]['pcs'] = $clusters[$bez]['pcs']; $c[$bez]['members'] = $clusters[$bez]['members']; } while (list($bez, $dat) = each($c)) { $bez = substr($bez, 1); $av_p = round($dat['points'] / $dat['members'], 2); $av_pcs = round($dat['pcs'] / $dat['members'], 2); // SUCCESS RATE CALCULATION START $cluster = getcluster($bez); $total = $cluster['srate_total_cnt']; $scnt = $cluster['srate_success_cnt']; $ncnt = $cluster['srate_noticed_cnt']; if ($total > 0) { $psucceeded = $scnt * 100 / $total; $pnoticed = $ncnt * 100 / $total; // Erfolg ist gut und zählt 75% // Bemerkt ist schlecht (deshalb 100-$pnoticed) und zählt 25% $srate = $psucceeded * 0.75 + (100 - $pnoticed) * 0.25; } else { $srate = 0; } // SUCCESS RATE CALCULATION END if ($bez != $no_ranking_clusters) { db_query('INSERT INTO rank_clusters VALUES(0,\'' . mysql_escape_string($bez) . '\',\'' . mysql_escape_string($dat['members']) . '\',\'' . mysql_escape_string($dat['points']) . '\',\'' . mysql_escape_string($av_p) . '\',\'' . mysql_escape_string($dat['pcs']) . '\',\'' . mysql_escape_string($av_pcs) . '\',\'' . mysql_escape_string($srate) . '\');'); } db_query('UPDATE clusters SET points=\'' . mysql_escape_string($dat['points']) . '\',rank=\'' . mysql_insert_id() . '\' WHERE id=\'' . mysql_escape_string($bez) . '\' LIMIT 1;'); } file_put('data/calc-stat.dat', 'Gleich fertig!!!'); cleardir('data/_server' . $server . '/usrimgs'); }
$config = "<?php \r\ndefine('DB_HOST', '" . DB_HOST . "');\r\n"; $config .= "define('DB_USER', '" . DB_USER . "');\r\n"; $config .= "define('DB_PW', '" . DB_PW . "');\r\n"; $config .= "define('DB_NAME', '" . DB_NAME . "');\r\n"; $config .= "define('DB_CHARSET', '" . DB_CHARSET . "');\r\n"; $config .= "define('DB_TABLEPRE', '" . DB_TABLEPRE . "');\r\n"; $config .= "define('DB_CONNECT', 0);\r\n"; $config .= "define('TIPASK_CHARSET', '" . TIPASK_CHARSET . "');\r\n"; $config .= "define('TIPASK_VERSION', '2.0Beta');\r\n"; $config .= "define('TIPASK_RELEASE', '20120322');\r\n"; $fp = fopen(TIPASK_ROOT . '/config.php', 'w'); fwrite($fp, $config); fclose($fp); cleardir(TIPASK_ROOT . '/data/cache'); cleardir(TIPASK_ROOT . '/data/view'); cleardir(TIPASK_ROOT . '/data/tmp'); echo "<font color='red'>升级说明:请登录到tipask后台,重新更改一下用户组权限,还有其他一些新特性!</font><br />"; echo "升级完成,请删除本升级文件,更新缓存以便完成升级,如果后台登录不进去,请直接删除data/view 目录下的所有.tpl文件,<font color='red'>切记需要保留view目录</font>"; } function createtable($sql, $dbcharset) { $type = strtoupper(preg_replace("/^\\s*CREATE TABLE\\s+.+\\s+\\(.+?\\).*(ENGINE|TYPE)\\s*=\\s*([a-z]+?).*\$/isU", "\\2", $sql)); $type = in_array($type, array('MYISAM', 'HEAP')) ? $type : 'MYISAM'; return preg_replace("/^\\s*(CREATE TABLE\\s+.+\\s+\\(.+?\\)).*\$/isU", "\\1", $sql) . (mysql_get_server_info() > '4.1' ? " ENGINE={$type} default CHARSET={$dbcharset}" : " TYPE={$type}"); } function runquery($query) { global $db; $query = str_replace("\r", "\n", str_replace('ask_', DB_TABLEPRE, $query)); $expquery = explode(";\n", $query); foreach ($expquery as $sql) {
if (is_readable($fnam)) { @unlink($dir . $ds . "input" . $ds . $file); $file = basename($file, ".link"); @copy($fnam, $dir . $ds . "input" . $ds . $file); } else { echo "Failed to read input files from link indicated in the ZIP -- please check the problem package\n"; DBGiveUpRunAutojudging($contest, $site, $number, $ip, "error: problem package file is invalid (11) or missing files on the autojudge"); $errp = 1; break; } } $ex = escapeshellcmd($script) . " " . escapeshellarg($basename) . " " . escapeshellarg($dir . $ds . "input" . $ds . $file) . " " . escapeshellarg(trim($limits[$basename][$run["extension"]][0])) . " " . escapeshellarg(trim($limits[$basename][$run["extension"]][1])) . " " . escapeshellarg(trim($limits[$basename][$run["extension"]][2])) . " " . escapeshellarg(trim($limits[$basename][$run["extension"]][3])); $ex .= " >stdout 2>stderr"; chdir($dir); if (file_exists($dir . $ds . 'tmp')) { cleardir($dir . $ds . 'tmp'); } mkdir($dir . $ds . 'tmp', 0777); @chown($dir . $ds . 'tmp', "nobody"); if (is_readable($dir . $ds . $basename)) { @copy($dir . $ds . $basename, $dir . $ds . 'tmp' . $ds . $basename); @chown($dir . $ds . 'tmp' . $ds . $basename, "nobody"); @chmod($dir . $ds . 'tmp' . $ds . $basename, 0755); } if (is_readable($dir . $ds . 'run.jar')) { @copy($dir . $ds . 'run.jar', $dir . $ds . 'tmp' . $ds . 'run.jar'); @chown($dir . $ds . 'tmp' . $ds . 'run.jar', "nobody"); @chmod($dir . $ds . 'tmp' . $ds . 'run.jar', 0755); } if (is_readable($dir . $ds . 'run.exe')) { @copy($dir . $ds . 'run.exe', $dir . $ds . 'tmp' . $ds . 'run.exe');
function DBLogOut($contest, $site, $user, $isadmin = false) { $c = DBConnect(); $r = DBExec($c, "update usertable set usersession='',usersessionextra='', updatetime=" . time() . ", " . "userlastlogout=" . time() . " where usernumber={$user} and " . "contestnumber={$contest} and usersitenumber={$site}", "DBLogOut(update user)"); if ($isadmin) { list($clockstr, $clocktime) = siteclock(); if ($clocktime < -600) { DBExec($c, "update contesttable set contestunlockkey='' where contestnumber={$contest}", "DBLogOut(update contest)"); DBExec($c, "update problemtable set problemfullname='', problembasefilename='' where problemfullname !~ '(DEL)' and contestnumber={$contest}", "DBLogOut(update problems)"); $ds = DIRECTORY_SEPARATOR; if ($ds == "") { $ds = "/"; } $dir = $_SESSION["locr"] . $ds . "private" . $ds . "problemtmp" . $ds; foreach (glob($dir . '*') as $file) { cleardir($file, false, true); } } } LOGLevel("User {$user} (contest={$contest},site={$site}) logged out.", 2); }
function cleardir($dir, $forceclear = false) { if (!is_dir($dir)) { return; } $directory = dir($dir); while ($entry = $directory->read()) { $filename = $dir . '/' . $entry; if (is_file($filename)) { @unlink($filename); } elseif (is_dir($filename) && $forceclear && $entry != '.' && $entry != '..') { chmod($filename, 0777); cleardir($filename, $forceclear); rmdir($filename); } } $directory->close(); }
function oncache() { $tplchecked = $datachecked = false; if (isset($this->post['submit'])) { if (isset($this->post['type'])) { if (in_array('tpl', $this->post['type'])) { $tplchecked = true; cleardir(TIPASK_ROOT . '/data/view'); } if (in_array('data', $this->post['type'])) { $datachecked = true; cleardir(TIPASK_ROOT . '/data/cache'); } $message = '缓存更新成功!'; } else { $tplchecked = $datachecked = false; $message = '没有选择缓存类型!'; $type = 'errormsg'; } } include template('setting_cache', 'admin'); }
$pluginbase = new pluginbase($db); $pluginbase->install('hdapi'); $pluginbase->install('ucenter'); */ if (mysql_error()) { $str = "<SPAN class=err>" . $strtip . ' ' . mysql_error() . "</span>"; $nextAccess = 0; $extend .= '{W}' . $strtip . ' ' . mysql_error() . "\n"; } if ($nextAccess == 1) { $str = "<div id=\"tips\">{$lang['stepSetupDelInstallDirTip']}</div>"; $str .= "<div id=\"wrapper_1\"><div class=\"col\"><br />{$strcretip} {$msg}<br /></div></div>"; } if ($nextAccess == 1) { @cleardir(HDWIKI_ROOT . '/data/view'); @cleardir(HDWIKI_ROOT . '/data/cache'); @forceMkdir(HDWIKI_ROOT . '/data/attachment'); @forceMkdir(HDWIKI_ROOT . '/data/backup'); @forceMkdir(HDWIKI_ROOT . '/data/cache'); @forceMkdir(HDWIKI_ROOT . '/data/db_backup'); @forceMkdir(HDWIKI_ROOT . '/data/logs'); @forceMkdir(HDWIKI_ROOT . '/data/tmp'); @forceMkdir(HDWIKI_ROOT . '/data/view'); @forceMkdir(HDWIKI_ROOT . '/data/momo'); } } } break; case 6: //云搜索 clode_register_install();
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; }
$str .= "\n"; file_put_contents($dir . $ds . 'description' . $ds . 'problem.info', $str); if ($name && $name1) { @copy($temp, $dir . $ds . 'input' . $ds . 'file1'); @unlink($temp); @copy($temp1, $dir . $ds . 'output' . $ds . 'file1'); @unlink($temp1); } else { @unlink($tfile); cleardir($dir); ob_end_flush(); MSGError('Could not read problem input/output files'); ForceLoad('problem.php'); } $ret = create_zip($dir, glob($dir . $ds . '*'), $dir . '.zip'); cleardir($dir); if ($ret <= 0) { @unlink($tfile); @unlink($dir . '.zip'); ob_end_flush(); MSGError('Could not write to zip file'); ForceLoad('problem.php'); } $str = file_get_contents($dir . '.zip'); @unlink($dir . '.zip'); @unlink($tfile); header("Expires: " . gmdate("D, d M Y H:i:s") . " GMT"); header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); header("Cache-Control: no-cache, must-revalidate"); header("Pragma: no-cache"); header("Content-transfer-encoding: binary\n");
$runfile = $runfile . 'N' . "\n"; } } } $ds = DIRECTORY_SEPARATOR; if ($ds == "") { $ds = "/"; } if (isset($_SESSION['locr'])) { $webcastdir = $_SESSION['locr'] . $ds . 'private' . $ds . 'webcast'; $webcastparentdir = $_SESSION['locr'] . $ds . 'private'; } else { $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>";
$sql = file_get_contents($sqlite_sqlfile); $sql = str_replace("\r\n", "\n", $sql); runquery($sql); } $datasql = file_get_contents($datasqlfile); runquery($datasql); $sql = $db->insert('#@nav', array('type' => 0, 'name' => lang('home'), 'url' => 'default', 'sort' => '100')); $db->query($sql); $sql = $db->insert('#@nav', array('type' => 0, 'name' => lang('tags'), 'url' => 'tags', 'sort' => '100')); $db->query($sql); $sql = $db->insert('#@nav', array('type' => 0, 'name' => lang('category'), 'url' => 'category', 'sort' => '100')); $db->query($sql); showjsmessage(lang('install_data_sql') . lang('succeed')); cleardir(ROOTDIR . 'cache/data'); cleardir(ROOTDIR . 'cache/templates'); cleardir(ROOTDIR . 'cache/tmp'); $db->insert('#@users', array('user_name' => $username, 'user_nicename' => $username, 'user_pass' => md5($password), 'create_time' => time())); if ($db->query()) { $userid = $db->insertid(); $db->insert('#@usermeta', array('userid' => $userid, 'meta_key' => 'email', 'meta_value' => $email)); $db->query(); showjsmessage(lang('create_admin_account') . lang('succeed')); } else { showjsmessage(lang('create_admin_account') . lang('failed')); } $siteurl = rtrim($siteurl, '/') . '/'; $mdl_setting = loader::model('setting'); $mdl_setting->set_conf('system.version', MPIC_VERSION); $mdl_setting->set_conf('system.installed_time', time()); $mdl_setting->set_conf('system.gravatar_url', 'http://www.gravatar.com/avatar/{idstring}?rating=G&size=48&d=mm'); $mdl_setting->set_conf('system.enable_auto_update', true);