public function before() { $userAccess = new UserAccess(); if (!$userAccess->isSupport()) { if ($this->request->isAjax()) { die('{ "ok" : false, "msg" : "Access denied" }'); } else { Header::redirect(URL::baseUrl() . '/login'); } } try { $pkSupportUserAccess = array('id_support_user' => $_SESSION['support_user']['id_user']); $supportUserAccess = $this->orm->support_user_access[$pkSupportUserAccess]; if (!$supportUserAccess['maintain_user']) { $view = View::instance(); $view->message = 'Access denied'; $view->render('error'); die; } } catch (Exception $e) { $view = View::instance(); $view->message = 'Error occurred'; $view->render('error'); die; } }
public function get_index() { $view = View::instance(); try { if (isset($_SESSION['client_user'])) { $chat = $this->orm->chat[$_SESSION['client_user']['id_chat']]; if ($chat['closed']) { unset($_SESSION['client_user']); } elseif ($chat['id_support_user']) { Header::redirect(URL::baseUrl() . '/conversation'); } else { Header::redirect(URL::baseUrl() . '/client/wait'); } } $param = $this->orm->param(); $param->select('value'); $param->where('name', 'STATUS'); $supportStatus = $param->fetch(); $supportUser = $this->orm->support_user(); $supportUser->where('active', 1); $supportUser->and('online', 1); $supportOnlineCount = $supportUser->count('id_support_user'); if ($supportStatus['value'] == 1 && $supportOnlineCount > 0) { $view->render('form-client'); } else { $view->render('offline'); } } catch (Exception $e) { $view->render('offline'); } }
public function before() { $userAccess = new UserAccess(); if (!$userAccess->isSupport()) { if ($this->request->isAjax()) { die('{ "ok" : false, "msg" : "Access denied" }'); } else { Header::redirect(URL::baseUrl() . '/login'); } } }
public function setUp() { parent::setUp(); I18n::setLanguage(''); Session::destroy(); if ($s = UserSession::get()) { $s->delete(); } Session::$site = 'http://www.test.info/'; Session::$referrer = 'http://www.test.info/some/part/of/the/site'; unlink(COORG_TEST_CONFIG); copy(COORG_TEST_CONFIG_CLEAN, COORG_TEST_CONFIG); $config = new Config(COORG_TEST_CONFIG); $config->set('site/title', 'The Site'); $config->set('defaultLanguage', ''); CoOrg::init($config, 'app', 'plugins'); CoOrgSmarty::clearAll(); Header::$redirect = '__none__'; }
public function get_signOut() { try { $idUser = @$_SESSION['support_user']['id_user']; if ($idUser) { $this->orm->support_user[$idUser]->update(array('online' => 0, 'typing' => 0, 'last_activity' => new NotORM_Literal('NOW()'))); } if (isset($_SESSION['support_user']) && count($_SESSION) == 1) { unset($_SESSION['support_user']); session_unset(); session_destroy(); } else { unset($_SESSION['support_user']); } Header::redirect(URL::baseUrl() . '/login'); } catch (Exception $e) { $view = View::instance(); $view->render('error'); } }
public function get_index() { try { $idChat = @$this->request->get('id', FILTER_VALIDATE_INT); $userChat = new UserChat($this->orm, $idChat); if (!$userChat->isValid()) { if ($userChat->isSupport()) { Header::redirect(URL::baseUrl() . '/login'); } else { Header::redirect(URL::baseUrl()); } } $this->orm->{$userChat->table}[$userChat->idUser]->update(array('typing' => 0, 'last_activity' => new NotORM_Literal('NOW()'))); $userChat->talkingTo()->sex = str_replace(array('M', 'F'), array('male', 'female'), $userChat->talkingTo()->sex); # Get the chat messages # ------------------------------------------------------------------ $chatMessage = $this->orm->chat_message(); $chatMessage->select('id_chat_message, created, message, sent_by'); $chatMessage->where('id_chat', $userChat->idChat); $chatMessage->order('id_chat_message ASC'); $messages = array(); $format = new DateTimeFormat(); $format->setSupHtmlSuffix(true); foreach ($chatMessage as $message) { $format->setValue($message['created']); $messages[] = array('who' => $userChat->type == $message['sent_by'] ? 'me' : 'you', 'id_chat_message' => $message['id_chat_message'], 'message' => nl2br(htmlspecialchars($message['message'])), 'datetime' => $format->format()); } $view = View::instance(); $view->idChat = $userChat->idChat; $view->messages = $messages; $view->talkingTo = $userChat->talkingTo(); $view->render('conversation'); } catch (Exception $e) { $view = View::instance(); $view->render('error'); } }
public static function redirect($to) { $args = func_get_args(); self::$redirect = CoOrg::createURL($args); }
/** * redirect * If headers is not sent add status header and redirects * * @param string $url * @param int $status */ public static function redirect($url = '/', $status = 302) { Header::redirect($url, $status); }
<?php require dirname(__FILE__) . '/__init__.php'; Rhaco::import('generic.Flow'); Rhaco::import('network.http.Header'); $flow = new Flow(); if (!$flow->isVariable('id')) { Header::redirect(Rhaco::url()); } $db = new DbUtil(Event::connection()); if ($flow->isPost() && $flow->isVariable('pass')) { $participant = $db->get(new Participant($flow->getVariable('id'))); if (Variable::istype('Participant', $participant) && $participant->hash === $flow->getVariable('pass')) { $db->delete($participant); Header::redirect(Rhaco::url()); } } $flow->setVariable('hatena', Rhaco::obj('HatenaSyntax', array('headlevel' => 4, 'id' => 'event_description'))); $flow->write('cancel.html');
public function __construct($uri) { Header::redirect($uri); exit; }
function upload() { if ($this->isPost() && $this->isFile('stage')) { $file = $this->getFile('stage'); $src = mb_convert_encoding(file_get_contents($file->tmp), 'utf-8', 'Shift_JIS,EUC-JP,UTF-8'); if (SimpleTag::setof($tag, $src, 'body', true)) { foreach ($tag->getIn('applet') as $applet) { if ($applet->getParameter('code') != 'MasaoConstruction') { continue; } $gamedata = array(); foreach ($applet->getIn('param') as $param) { $gamedata[$param->getParameter('name')] = array('name' => $param->getParameter('name'), 'value' => $param->getParameter('value')); } if (empty($gamedata)) { break; } $stage = $this->dbUtil->insert($this->toObject(new Stage())); if (!Variable::istype('Stage', $stage)) { break; } $_images = array('title', 'ending', 'gameover', 'pattern', 'chizu'); foreach ($_images as $k) { if (!isset($gamedata[sprintf("filename_%s", $k)])) { continue; } $gamedata[sprintf("filename_%s", $k)] = array('name' => sprintf("filename_%s", $k), 'value' => 'images/' . $k . '.gif'); if ($this->isFile('img_' . $k)) { $image = $this->getFile('img_' . $k); $img_info = getimagesize($image->tmp); if ($img_info[2] != IMAGETYPE_GIF) { continue; } $filename = Rhaco::path(sprintf('images/%s_%d.gif', $k, $stage->id)); if (move_uploaded_file($image->tmp, $filename)) { $gamedata[sprintf("filename_%s", $k)] = array('name' => sprintf("filename_%s", $k), 'value' => sprintf("images/%s_%d.gif", $k, $stage->getId())); } } } FileUtil::write(Rhaco::path(sprintf('stages/%d.apif', $stage->id)), serialize($gamedata)); Header::redirect(Rhaco::url()); Rhaco::end(); } } } return $this->parser('upload.html'); }
public function redirectOnSuccess($commentOn) { Header::redirect('blog/show', $commentOn->year, $commentOn->month, $commentOn->day, $commentOn->ID); }
/** * Validates the user session to allow or deny access * * @access private * @return void */ private function validateSession() { if (!UserAccess::isClient()) { if ($this->request->isAjax()) { die('{ "ok" : false, "msg" : "Access denied" }'); } else { Header::redirect(URL::baseUrl()); } } }
protected function redirectOnSuccess($from) { Header::redirect($from); }
/** * Handles POST data while AJAX request. * It works like {Controller::handlePOST} and signaatures will be checked unless * form is on the current page and <code>no_check</code> attribute is not specified. * * Typical use-case of this function is posting form with javascript with * <code>$(form).serialize()</code> method or <code>ajaxSubmit</code> from * jquert.form plugin. * * Instead of redirects, like in <code>Controller::handlePOST()</code> * method, <code>exit()</code> calls will be used. * * Another difference is that no "save form values and show error boxes" sequence * is used. If some checker of validator error are present, <code>exit()</code> * will terminate futher form processing. * * Additionally, unlike <code>Controller::handlePOST</code>, handler methods could specify * <code>responce_string</code> to return status of form processing. It will be echo'ed at once. * * @param null * @return null */ protected function handlePOST() { $this->trigger("BeforeHandlePOST", $this); if ($this->post->isEmpty()) { Header::redirect(requestURI(true), Header::SEE_OTHER); } $formid = null; WidgetLoader::load("WForm"); list($formid) = explode(":", $this->post->{WForm::signature_name}); if (!empty($formid) && !in_array($formid, $this->no_check_forms)) { $this->trigger("BeforeCheckSignature", $this); if (!$this->checkSignature($this->post->{WForm::signature_name})) { exit("Error while checking POST data 1"); } POSTErrors::flushErrors(); $this->trigger("BeforeCheckByRules", array(&$this->post, $this->post->{WForm::signature_name})); POSTChecker::checkByRules($this->post->{WForm::signature_name}, $this->checker_rules, $this->checker_messages); POSTChecker::checkFiles($this->post->{WForm::signature_name}, $this->file_rules, $this->checker_messages); if (POSTErrors::hasErrors()) { //Header::redirect(requestURI(true), Header::SEE_OTHER); exit("Error while checking POST data 2"); } $this->trigger("BeforeCallHandlers", array($this, &$formid)); try { DataUpdaterPool::callCheckers($formid); } catch (CheckerException $e) { exit("Error " . $e->getMessage() . " in widget " . $e->getWidgetName); } DataUpdaterPool::callHandlers($formid); DataUpdaterPool::callFinalize($formid); } else { try { DataUpdaterPool::callCheckers($formid); } catch (CheckerException $e) { exit("Error " . $e->getMessage() . " in widget " . $e->getWidgetName); } DataUpdaterPool::callHandlers($formid); DataUpdaterPool::callFinalize($formid); } $this->trigger("AfterHandlePOST", $this); if (isset($this->response_string)) { $this->trigger("AfterHeadBodyTailResponce", array($this, &$this->response_string)); echo $this->response_string; } }