public function uploadAction() { if (!$this->_request->isPost()) { $this->_redirect(webconfig::getContestRelativeBaseUrl()); } $auth = Zend_Auth::getInstance(); if (!$auth->hasIdentity()) { $this->_redirect(webconfig::getContestRelativeBaseUrl() . "auth/login"); } $lang = $this->_request->get("lang"); $prob = $this->_request->get("probid"); $source = $_FILES['source']['tmp_name']; if (empty($lang) or empty($prob) or empty($source)) { $this->_redirect(webconfig::getContestRelativeBaseUrl() . "/error/illegal"); return; } $id = UploadSubmission::upload($auth->getIdentity(), $prob, $lang, $source, ProblemTable::get_problem($prob)->owner); if ($id == -1) { $this->view->message = "You are trying to submit the same " . "solution twice!"; } else { if ($id == -2) { $this->view->message = "You have exceeded the submission " . "limit on this problem."; } else { if ($id < 0) { $this->view->message = "Unknown error"; } else { $this->_redirect(webconfig::getContestRelativeBaseUrl() . "submit/success/{$id}"); } } } }
function fixImages() { $dom = new DomDocument(); @$dom->loadXML($this->view->content_html, LIBXML_NOXMLDECL); $xp = new DOMXPath($dom); $xp->registerNamespace('html', 'http://www.w3.org/1999/xhtml'); $url = Zend_Controller_Front::getInstance()->getBaseUrl() . webconfig::getContestRelativeBaseUrl(); $url .= "problems/" . $this->_request->get("probid"); $res = $xp->query("//html:img/@src"); foreach ($res as $node) { $oldImage = $node->nodeValue; /* is this a complete path? */ if (substr($oldImage, 0, 5) == "http:" || substr($oldImage, 0, 6) == "https:" || $oldImage[0] == '/') { continue; } $node->nodeValue = "{$url}/{$oldImage}"; } $this->view->content_html = $dom->saveXML(); }
public function indexAction() { $_user = $this->_request->get("user"); if (webconfig::getContest()->isQueuePrivate()) { $user = User::factory(Zend_Auth::getInstance()->getIdentity()); if (!$user || !$user->isAdmin()) { $this->_forward("privacy", "error", NULL, array()); } } if (empty($_user)) { $this->_redirect(webconfig::getContestRelativeBaseUrl()); } /* fillin information from User XML data */ Zend_Loader::loadClass("UserModel"); $userm = new UserModel(); $user = $userm->getRow($_user); $this->view->username = $user->_username; $this->view->inst = $userm->getInstitute($user); $this->view->name = $userm->getMember($user, 0)->name; }
function logoutAction() { $this->log->info(Zend_Auth::getInstance()->getIdentity() . " has logged off."); Zend_Auth::getInstance()->clearIdentity(); $this->_redirect(webconfig::getContestRelativeBaseUrl()); }
public function update2Action() { $this->view->mode = "update"; try { $this->validate(); } catch (Exception $e) { $this->log->info("Error in updated profile: " . $e->getMessage()); $this->error_message = $e->getMessage(); $this->copyToView(); return; } $this->saveXML(); $this->copyToView(); User::factory($this->user)->setPassword($this->password); $this->_redirect(webconfig::getContestRelativeBaseUrl() . "/profile/profile-update-success"); }