/** * Creates a single sign on token for the <code>HttpRequest</code> * * @param request <code>HttpServletRequest</code> * @return single sign on token for the request * @exception SSOException if the single sign on token cannot be created. */ public function createSSOTokenFromRequest(array $request) { try { $sid = new SessionID($request); $session = Session::getSession($sid); if ($sid != null) { $cookieMode = $sid->getCookieMode(); // if (debug.messageEnabled()) { // debug.message("cookieMode is :" + cookieMode); // } if ($cookieMode != null) { $session->setCookieMode($cookieMode); } } if ($this->checkIP && !isIPValid($session, $_SERVER['REMOTE_ADDR'])) { throw new Exception("Invalid IP address"); } $ssoToken = new SSOTokenImpl($session); return $ssoToken; } catch (Exception $e) { // if (debug.messageEnabled()) { // debug.message("could not create SSOToken from HttpRequest", e); // } throw new SSOException($e->getMessage()); } }
public function deleteRow($aRowData, $oCriteria) { $oLanguage = LanguagePeer::doSelectOne($oCriteria); if ($oLanguage->getIsDefault()) { throw new LocalizedException('wns.language.delete_default.denied'); } if ($oLanguage->getIsDefaultEdit()) { throw new LocalizedException('wns.language.delete_default.denied'); } if (LanguagePeer::doCount(new Criteria()) < 2) { throw new LocalizedException('wns.language.delete_last.denied'); } $sLanguageId = $oLanguage->getId(); foreach (LanguageObjectQuery::create()->filterByLanguageId($sLanguageId)->find() as $oLanguageObject) { $oHistory = $oLanguageObject->newHistory(); $oHistory->save(); $oLanguageObject->delete(); } $iResult = $oLanguage->delete(); $oReplacementLanguage = LanguageQuery::create()->findOne(); if (AdminManager::getContentLanguage() === $sLanguageId) { AdminManager::setContentLanguage(Settings::getSetting("session_default", AdminManager::CONTENT_LANGUAGE_SESSION_KEY, $oReplacementLanguage->getId())); } if (Session::language() === $sLanguageId) { Session::getSession()->setLanguage(Settings::getSetting("session_default", Session::SESSION_LANGUAGE_KEY, $oReplacementLanguage->getId())); } }
public function view() { config::set('heading', 'БЛОГ'); $params = $this->getParams(); if (isset($params[0])) { $alias = strtolower($params[0]); $this->data['one_blog'] = $this->model->getOneBlogWithComment($alias); } if ($_POST and isset($_POST['id_comm'])) { if (clearData($_POST['id_comm'])) { $id = clearData($_POST['id_comm']); } else { throw new Exception('Введены некорректные данные'); } if (clearData($_POST['text-comm'])) { $text = clearData($_POST['text-comm'], true); } else { throw new Exception('Введены некорректные данные'); } if (clearData($_POST['n_comm'])) { $name = clearData($_POST['n_comm']); } else { throw new Exception('Введены некорректные данные'); } $tableUserId = Session::getSession('id') ? Session::getSession('id') : NULL; $this->model->addComment($id, $text, $name, $tableUserId); Router::redirect($_SERVER['REQUEST_URI']); } }
function defaultAction() { if (is_null(Session::getSession('user'))) { // On renvoit l'URL suivi de login, le Router redirigera sur le ControllerLogin // Comme on envoit pas d'action, l'actionDefault sera utilisée. die(header('Location:/login')); } else { // si on est là, un user est connecté, il sagit maintenant de le diriger en fonction du Profil $O_user = Session::getSession('user'); $S_profile = $O_user->getProfile()->getName(); switch ($S_profile) { case 'admin': //echo 'Vous avez le profil : ' . $S_profile; die(header('Location:/user/paginate/1')); break; case 'operator': die(header('Location:/epi/userlist/' . $O_user->getOperatorId())); // echo 'Vous avez le profil : ' . $S_profile; break; default: die(header('Location:/epi/tonextcheck/')); break; } } }
public function renderFrontend() { $oCriteria = DocumentQuery::create()->filterByDocumentKind('image'); if (!Session::getSession()->isAuthenticated()) { $oCriteria->filterByIsProtected(false); } if ($this->iCategoryId !== null) { $oCriteria->filterByDocumentCategoryId($this->iCategoryId); } $aDocuments = $oCriteria->find(); $sTemplateName = 'helpers/gallery'; try { $oListTemplate = new Template($sTemplateName); foreach ($aDocuments as $i => $oDocument) { $oItemTemplate = new Template($sTemplateName . DocumentListFrontendModule::LIST_ITEM_POSTFIX); $oItemTemplate->replaceIdentifier('model', 'Document'); $oItemTemplate->replaceIdentifier('counter', $i + 1); $oDocument->renderListItem($oItemTemplate); $oListTemplate->replaceIdentifierMultiple('items', $oItemTemplate); } } catch (Exception $e) { $oListTemplate = new Template("", null, true); } return $oListTemplate; }
public function saveData($aSubscriberGroupData) { if ($this->iSubscriberGroupId) { $oSubscriberGroup = SubscriberGroupQuery::create()->findPk($this->iSubscriberGroupId); } else { $oSubscriberGroup = new SubscriberGroup(); $oSubscriberGroup->setCreatedBy(Session::getSession()->getUserId()); $oSubscriberGroup->setCreatedAt(date('c')); } $oSubscriberGroup->setName($aSubscriberGroupData['name']); $oSubscriberGroup->setDisplayName($aSubscriberGroupData['display_name'] == null ? null : $aSubscriberGroupData['display_name']); $this->validate($aSubscriberGroupData); if (!Flash::noErrors()) { throw new ValidationException(); } $oSubscriberGroup->save(); $oResult = new stdClass(); $oResult->id = $oSubscriberGroup->getId(); if ($this->iSubscriberGroupId === null) { $oResult->inserted = true; } else { $oResult->updated = true; } $this->iSubscriberGroupId = $oResult->id; return $oResult; }
public static function run($uri) { self::$router = new Router($uri); self::$db = new DB(config::get('db.host'), config::get('db.name'), config::get('db.user'), config::get('db.password')); Lang::load(self::$router->getLanguage()); if ($_POST and (isset($_POST['username_in']) and isset($_POST['password_in'])) or isset($_POST['exit'])) { $us = new RegisterController(); if (isset($_POST['exit'])) { $us->LogOut(); } else { $us->Login($_POST); } } if (self::$router->getController() == 'admin' and !Session::getSession('root') or self::$router->getController() == 'myblog' and !Session::getSession('id')) { self::$router->setController(Config::get('default_controller')); self::$router->setAction(Config::get('default_action')); Session::setSession('message', 'Отказ в доступе'); } $controller_class = ucfirst(self::$router->getController()) . 'Controller'; $controller_method = strtolower(self::$router->getMethodPrefix() . self::$router->getAction()); $controller_object = new $controller_class(); if (method_exists($controller_object, $controller_method)) { $controller_object->{$controller_method}(); $view_object = new View($controller_object->getData()); $content = $view_object->render(); } else { throw new Exception('Method ' . $controller_method . ' of class ' . $controller_class . ' does not exist'); } $layout = self::$router->getRoute(); $layout_path = VIEWS_PATH . DS . $layout . '.html'; $layout_view_object = new View(compact('content'), $layout_path); echo $layout_view_object->render(); }
protected function __construct() { //Initialize session object. $this->Session = Session::getSession(); //Start page tracking utility. $this->Tracker = Tracker::getTracker(); }
public function saveData($aSubscriberData) { $oSubscriber = SubscriberQuery::create()->findPk($this->iSubscriberId); if ($oSubscriber === null) { $oSubscriber = new Subscriber(); $oSubscriber->setCreatedBy(Session::getSession()->getUserId()); $oSubscriber->setCreatedAt(date('c')); } $oSubscriber->setPreferredLanguageId($aSubscriberData['preferred_language_id']); $oSubscriber->setName($aSubscriberData['name']); $oSubscriber->setEmail($aSubscriberData['email']); $this->validate($aSubscriberData, $oSubscriber); if (!Flash::noErrors()) { throw new ValidationException(); } // Subscriptions foreach ($oSubscriber->getSubscriberGroupMemberships() as $oSubscriberGroupMembership) { $oSubscriberGroupMembership->delete(); } $aSubscriptions = isset($aSubscriberData['subscriber_group_ids']) ? $aSubscriberData['subscriber_group_ids'] : array(); foreach ($aSubscriptions as $iSubscriberGroupId) { $oSubscriberGroupMembership = new SubscriberGroupMembership(); $oSubscriberGroupMembership->setSubscriberGroupId($iSubscriberGroupId); $oSubscriber->addSubscriberGroupMembership($oSubscriberGroupMembership); } return $oSubscriber->save(); }
/** * The render method for the login page type. When on a login page type, this is given the login action as determined by the page type. Can be either null (default), 'password_forgotten', or 'password_reset' (or any other string of which a template "$sLoginType_action_$sAction" exists). * */ public function renderFrontend($sAction = 'login') { $aOptions = @unserialize($this->getData()); $sLoginType = isset($aOptions[self::MODE_SELECT_KEY]) ? $aOptions[self::MODE_SELECT_KEY] : 'login'; $this->oUser = Session::getSession()->getUser(); if ($this->oUser) { $sAction = 'logout'; } $oTemplate = $this->constructTemplate($sLoginType); if ($oTemplate->hasIdentifier('function_template')) { $oFunctionTemplate = null; try { $oFunctionTemplate = $this->constructTemplate("{$sLoginType}_action_{$sAction}"); } catch (Exception $e) { //Fallback to the default function template for the specified action $oFunctionTemplate = $this->constructTemplate("login_action_{$sAction}"); } $oTemplate->replaceIdentifier('function_template', $oFunctionTemplate, null, Template::LEAVE_IDENTIFIERS); } if ($this->oUser && $this->oPage) { $oPage = $this->oPage; if (Session::getSession()->hasAttribute('login_referrer_page')) { $oPage = Session::getSession()->getAttribute('login_referrer_page'); Session::getSession()->resetAttribute('login_referrer_page'); } if (!$this->oPage->getIsProtected() || Session::getSession()->getUser()->mayViewPage($this->oPage)) { $oTemplate->replaceIdentifier('fullname', Session::getSession()->getUser()->getFullName()); $oTemplate->replaceIdentifier('name', Session::getSession()->getUser()->getUsername()); $oTemplate->replaceIdentifier('action', LinkUtil::link(FrontendManager::$CURRENT_NAVIGATION_ITEM->getLink(), null, array('logout' => 'true'))); } else { $oFlash = Flash::getFlash(); $oFlash->addMessage('login.logged_in_no_access'); } } $oTemplate->replaceIdentifier('login_title', TranslationPeer::getString($sAction == 'password_forgotten' ? 'wns.login.password_reset' : 'wns.login')); $sOrigin = isset($_REQUEST['origin']) ? $_REQUEST['origin'] : LinkUtil::linkToSelf(); $oTemplate->replaceIdentifier('origin', $sOrigin); if ($sAction !== 'logout') { $oLoginPage = $this->oPage ? $this->oPage->getLoginPage() : null; $sLink = null; if ($oLoginPage === null) { $sLink = LinkUtil::link('', 'LoginManager'); } else { $sLink = LinkUtil::link($oLoginPage->getFullPathArray()); } $oTemplate->replaceIdentifier('action', $sLink); } if ($sAction === 'login') { $oLoginPage = $this->oPage ? $this->oPage->getLoginPage() : null; $sLink = null; if ($oLoginPage === null) { $sLink = LinkUtil::link(array(), 'LoginManager', array('password_forgotten' => 'true')); } else { $sLink = LinkUtil::link($oLoginPage->getFullPathArray(), null, array('password_forgotten' => 'true')); } $oTemplate->replaceIdentifier('password_forgotten_action', $sLink); } return $oTemplate; }
public function __construct(Page $oPage = null, NavigationItem $oNavigationItem = null, $sLanguageId = null) { parent::__construct($oPage, $oNavigationItem, $sLanguageId); $this->sAction = 'login'; if (isset($_REQUEST['origin']) && !Session::getSession()->hasAttribute('login_referrer')) { Session::getSession()->setAttribute('login_referrer', $_REQUEST['origin']); } }
private static function propertiesFromPage($oPage) { $oUser = Session::getSession()->getUser(); $aResult = $oPage->toArray(); $aResult['UserMayCreateChildren'] = $oUser->mayCreateChildren($oPage); $aResult['UserMayCreateSiblings'] = $oPage->getParent() !== null && $oUser->mayCreateChildren($oPage->getParent()); return $aResult; }
public function getCriteria() { $oQuery = DocumentCategoryQuery::create(); if (!Session::getSession()->getUser()->getIsAdmin() || Settings::getSetting('admin', 'hide_externally_managed_document_categories', true)) { return $oQuery->filterByIsExternallyManaged('false'); } return $oQuery; }
public function writeSessionAttribute($oTemplateIdentifier) { $sValue = Session::getSession()->getAttribute($oTemplateIdentifier->getValue()); if ($oTemplateIdentifier->hasParameter('reset')) { Session::getSession()->resetAttribute($oTemplateIdentifier->getValue()); } return $sValue; }
public function actionStart() { //получаем id игры Session::getSession(); Yii::app()->session['loser'] = GameUtils::USER_LOSER; //переходим на страницу с игрой $this->redirect(array('gamestep/create')); }
public function loadDocumentations() { $sUserLanguage = Session::getSession()->getUser()->getLanguageId(); if (!isset($this->aDocumentations[$sUserLanguage])) { $this->aDocumentations[$sUserLanguage] = $this->getDocumentations($sUserLanguage); } return $this->aDocumentations[$sUserLanguage]; }
public function testQuoteWithInnerDefaultValue() { Session::getSession()->setLanguage('en'); $sTemplateText = <<<EOT {{quoteString=\\{\\{test\\}\\};defaultValue=default}} EOT; $oTemplate = new Template($sTemplateText, null, true); $this->assertSame("default", $oTemplate->render()); }
public function getMetadataForColumn($sColumnIdentifier) { $aResult = array(); if ($sColumnIdentifier === 'key') { $aResult['display_type'] = ListWidgetModule::DISPLAY_TYPE_DATA; } else { $oUser = Session::getSession()->getUser(); $aResult['heading'] = TranslationPeer::getString('wns.settings.sidebar_heading', null, null, array('user_name' => $oUser->getFullName())); } return $aResult; }
public function save(PropelPDO $oConnection = null) { $this->setUpdatedAt(date('c')); if ($this->isNew()) { if (Session::getSession()->isAuthenticated()) { $this->setOwner(Session::getSession()->getUserId()); } $this->setCreatedAt(date('c')); } return parent::save($oConnection); }
public static function getMenu() { self::$menu = Config::get('menu'); if (Session::getSession('login')) { unset(self::$menu['РЕГИСТРАЦИЯ']); self::$menu['МОЙ БЛОГ'] = DEFAULT_PATH . 'myblog/'; } if (Session::getSession('root')) { self::$menu['АДМИНКА'] = DEFAULT_PATH . 'admin/'; } return self::$menu; }
public static function getCategoryOptions() { $oQuery = DocumentCategoryQuery::create()->orderByName(); if (!Session::getSession()->getUser()->getIsAdmin() || Settings::getSetting('admin', 'hide_externally_managed_document_categories', true)) { $oQuery->filterByIsExternallyManaged(false); } $aResult = $oQuery->select(array('Id', 'Name'))->find()->toKeyValue('Id', 'Name'); if (count($aResult) > 0 && !Settings::getSetting('admin', 'list_allows_multiple_categories', true)) { $aResult = array('' => ' ---- ') + $aResult; } return $aResult; }
private function haveAccess() { $O_user = Session::getSession('user'); if ($O_user == null) { Session::setSession('error', 'Vous n\'avez pas les droits pour réaliser cette opération'); // on redirige sur l'url de départ die(header('Location:/')); } elseif ($O_user->getProfile()->getLevel() < 2) { Session::setSession('error', 'Vous n\'avez pas les droits pour réaliser cette opération'); // on redirige sur l'url de départ die(header('Location:/')); } }
/** * session_class * * @access public * @return void */ function session_class() { // check for valid a cookie. if (isset($_COOKIE['auth'])) { $auth = $_COOKIE['auth']; $ip = getenv('REMOTE_ADDR'); $time = strtotime('+2'); $this->_session = Session::getSession($auth, $ip, $time); } if ($this->_session && $this->_session->exists()) { $this->_session->expiration = strtotime('+59 minutes'); $this->_logged = true; } }
public function defaultAction() { $O_epiMapper = new EpiMapper(); $I_nbrEpi = $O_epiMapper->countId(); $I_nbrEpiByUser = $O_epiMapper->countEpiByUser(Session::getSession('user')->getId()); $I_nbrEpiNextCheckByUser = $O_epiMapper->countEpiNextCheckByUser(Session::getSession('user')->getId()); $O_labelMapper = new LabelMapper(); $I_nbrLabel = $O_labelMapper->countId(); $O_categoryMapper = new CategoryMapper(); $I_nbrCategory = $O_categoryMapper->countId(); $O_checkMapper = new CheckMapper(); $I_nbrCheck = $O_checkMapper->countId(); $I_nbrCheckedByUser = $O_checkMapper->countEpiCheckedByUser(Session::getSession('user')->getId()); Buffer::flushBuffer('epi/default', array('nbrEpi' => $I_nbrEpi, 'nbrLabel' => $I_nbrLabel, 'nbrCategory' => $I_nbrCategory, 'nbrCheck' => $I_nbrCheck, 'nbrEpiByUser' => $I_nbrEpiByUser, 'nbrEpiNextCheckByUser' => $I_nbrEpiNextCheckByUser, 'nbrCheckedByUser' => $I_nbrCheckedByUser)); }
public function __construct($aRequestPath) { parent::__construct($aRequestPath); $sSessionKey = Manager::usePath(); $this->oListWidget = Session::getSession()->getArrayAttributeValueForKey(WidgetModule::WIDGET_SESSION_KEY, $sSessionKey); if ($this->oListWidget === null) { throw new Exception('Invalid list widget session key: ' . $sSessionKey); } $this->sWidgetType = $this->oListWidget->getModuleName(); if ($this->oListWidget->getDelegate() instanceof WidgetModule) { $this->sWidgetType = $this->oListWidget->getDelegate()->getModuleName(); } else { if ($this->oListWidget->getDelegate() instanceof CriteriaListWidgetDelegate) { $this->sWidgetType = $this->oListWidget->getDelegate()->getModelName(); } } }
function isSessionActive() { //Instancia de Slim $app = \Slim\Slim::getInstance(); //Iniciamos el ambiente de sesiones //Session::startSession(); session_start(); //Obtenes la sesión activa $s = new Session(); $session = $s->getSession(); //$session = Session::getSession(); if ($session != null) { //Uri a la cual redireccionaremos en caso que una sesión esté activa $action = $app->urlFor('index'); $app->redirect($action); } }
public function __construct($aRequestPath, Page $oJournalPage = null, $aJournalIds = null) { if ($aRequestPath === false) { $this->oJournalPage = $oJournalPage; $this->aJournalIds = $aJournalIds; } else { parent::__construct($aRequestPath); Manager::usePath(); //the “journal” bit $this->oJournalPage = PagePeer::getRootPage()->getPageOfType('journal'); $sLanguageId = Manager::usePath(); if (LanguagePeer::languageIsActive($sLanguageId)) { Session::getSession()->setLanguage($sLanguageId); } } header("Content-Type: application/rss+xml;charset=" . Settings::getSetting('encoding', 'db', 'utf-8')); RichtextUtil::$USE_ABSOLUTE_LINKS = LinkUtil::isSSL(); }
public function Feedback($data) { if (!isset($data['textarea']) or !clearData($data['textarea'])) { return FALSE; } $letter = clearData($data['textarea']); if (Session::getSession('email')) { $mail_text = 'От нашего пользователя: ' . Session::getSession('login') . PHP_EOL . 'e-mail: ' . Session::getSession('email') . PHP_EOL . $letter; } else { if (!isset($data['name_f']) or !clearData($data['name_f']) or !isset($data['email_f']) or !chekEmail($data['email_f'])) { return FALSE; } $username = clearData($data['name_f']); $email = chekEmail($data['email_f']); $mail_text = 'От гостя: ' . $username . PHP_EOL . 'e-mail: ' . $email . PHP_EOL . 'Текст: ' . $letter; } $accept = mail(Config::get('mailbox'), "Feedback - Blog", $mail_text); if ($accept) { return TRUE; } }
public function editMyblog() { if (Session::getSession('id_edit')) { config::set('heading', 'РЕДАКТИРОВАНИЕ'); $id = Session::getSession('id_edit'); $this->data['one_blog'] = $this->model->getOneBlog($id); } else { Session::setSession('error', 'блог с таким идентификатором не найден'); router::redirect(DEFAULT_PATH . 'myblog/'); } if ($_POST and isset($_POST['edit_done']) and clearData($_POST['edit_done']) and clearData($_POST['edit_done_text']) and clearData($_POST['edit_done_topic'])) { $id = clearData($_POST['edit_done']); $text = clearData($_POST['edit_done_text'], true); $topic = clearData($_POST['edit_done_topic']); if ($this->model->editRecord($id, $topic, $text)) { router::redirect($_SERVER['REQUEST_URI']); } else { Session::setSession('error', 'Ошибка в редактировании блога!'); router::redirect($_SERVER['REQUEST_URI']); } } }
public function renderFile() { //Prerequisites Session::getSession()->setLanguage($this->sLanguageId); //Clear index SearchIndexQuery::create()->filterByLanguageId($this->sLanguageId)->delete(); //Spider index $oRootPage = PagePeer::getRootPage(); $this->oRootNavigationItem = PageNavigationItem::navigationItemForPage($oRootPage); $this->spider($this->oRootNavigationItem); //GC gc_enable(); //Update index PreviewManager::setTemporaryManager('FrontendManager'); foreach ($this->aIndexPaths as $aPath) { $bIsIndexed = $this->index($aPath); set_time_limit(30); $this->gc(); $sMessage = $bIsIndexed ? 'Indexed' : 'Skipped'; print "{$sMessage} <code>/" . htmlentities(implode('/', $aPath)) . "</code><br>\n"; } PreviewManager::revertTemporaryManager(); }