public function findAll() { $ret = array(); if ($handle = opendir(config::getFilename("data/contests/"))) { while (false !== ($file = readdir($handle))) { $info = pathinfo($file); if (!isset($info['extension']) || $info['extension'] != 'xml') { continue; } $name = $info['filename']; $contest = Contest::factory($name); if ($contest) { array_push($ret, $contest); } } closedir($handle); } return $ret; }
public function codeHighlight($source, $lang) { Zend_Loader::loadFile("geshi.php", array(config::getFilename("geshi/"), "/usr/share/php-geshi"), true); if ($lang == "cpp") { $lang = "C++"; } if ($lang == "gcj") { $lang = "Java"; } if (!class_exists("GeSHi")) { return "<!-- GeSHi disabled --> <pre>" . htmlspecialchars($source) . "</pre>"; } $geshi = new GeSHi($source, $lang); $geshi->set_header_type(GESHI_HEADER_PRE_TABLE); $geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS); $geshi->set_overall_class("geshi"); $code = $geshi->parse_code(); return $code; }
public function indexAction() { $page = $this->getRequest()->get("page"); $contest = Contest::factory(webconfig::getContestId()); if (!$contest) { return; } $xp = $contest->getXPath(); $res = $xp->query("/contest/frontend/page[@id='{$page}']/@href"); $href = $res->item(0)->nodeValue; if (substr($href, 0, 5) == "http:" or substr($href, 0, 6) == "https:") { $this->_redirect($href); } $file = config::getFilename("data/contests/" . $res->item(0)->nodeValue); if (!is_file($file)) { echo "Please edit '{$file}' to view this page."; } else { echo file_get_contents($file); } }
public function indexAction() { $this->_helper->layout->disableLayout(); $this->_helper->viewRenderer->setNoRender(); $file = $this->_request->get("file"); $details = pathinfo($file); $path = $details['dirname']; $filename = "public." . $details['basename']; $finalFile = config::getFilename("data/" . $path . "/{$filename}"); if (is_file($finalFile)) { $response = $this->getResponse(); $response->setHeader('Cache-Control', 'public', true)->setHeader('Content-Description', 'File Transfer', true)->setHeader('Content-Type', $this->getContentType($details['extension']), true)->setHeader('Content-Transfer-Encoding', 'binary', true)->setBody(file_get_contents($finalFile)); $response->sendResponse(); //$this->setResponse($response); return; } echo "File not found"; /* else send a 404 error */ $response = $this->getResponse(); $response->setHttpResponseCode(404); }
public function fileAction() { if (!$this->validateProblemAccess()) { return; } $prob = $this->_request->get("probid"); $this->_helper->layout->disableLayout(); $this->_helper->viewRenderer->setNoRender(); $file = $this->_request->get("file"); if (strstr($file, "/") || strstr($file, "\\")) { $this->_forward("illegal", "error"); return; } $details = pathinfo($file); $contentType = $this->getContentType($details['extension']); if (empty($contentType)) { $this->_forward("illegal", "error"); return; } $finalFile = config::getFilename("data/problems/{$prob}/{$file}"); if (is_file($finalFile)) { $response = $this->getResponse(); $response->setHeader('Cache-Control', 'public', true)->setHeader('Content-Description', 'File Transfer', true)->setHeader('Content-Type', $contentType, true)->setHeader('Content-Transfer-Encoding', 'binary', true)->setBody(file_get_contents($finalFile)); return; } echo "File ({$finalFile}, {$contentType}) not found"; /* else send a 404 error */ $response = $this->getResponse(); $response->setHttpResponseCode(404); }