public function routeStartup(Zend_Controller_Request_Abstract $request)
 {
     if (substr($request->getRequestUri(), 0, -1) == $request->getBaseUrl()) {
         $request->setRequestUri($request->getRequestUri() . Zend_Registry::get('parameters')->registry->defaultlanguage . "/");
         $request->setParam("language", Zend_Registry::get('parameters')->registry->defaultlanguage);
     }
 }
예제 #2
0
 /**
  * Locate path alias node
  * @see library/Zend/Controller/Plugin/Zend_Controller_Plugin_Abstract#routeStartup($request)
  * 
  * @param Zend_Controller_Request_Abstract $request
  * @return void
  */
 public function routeShutdown(Zend_Controller_Request_Abstract $request)
 {
     if ($request->getRequestUri() != "/" && ($path = Zoo::getService('path')->findPath($request->getRequestUri()))) {
         $content_service = Zoo::getService('content');
         $request->setActionName($content_service->action);
         $request->setControllerName($content_service->controller);
         $request->setModuleName($content_service->module);
         $request->setParam('id', $path->nid);
     }
 }
예제 #3
0
 public function preDispatch(Zend_Controller_Request_Abstract $request)
 {
     // home page must be excluded from log
     if (strtolower($request->getRequestUri()) === strtolower($this->_request->getBaseUrl() . '/')) {
         return;
     }
     if ($this->_isIncludedInLog($request->getRequestUri())) {
         // add metric
         $this->_addMetric($request->getRequestUri());
     }
 }
예제 #4
0
 public function routeShutdown(Zend_Controller_Request_Abstract $request)
 {
     if ($this->getRequest()->getModuleName() == 'admin') {
         return;
     }
     $uri = $request->getRequestUri();
     if (!($titles = Z_Cache::getInstance()->load('z_titles'))) {
         $table_titles = new Z_Model_Titles();
         $titles = $table_titles->fetchAll(NULL, 'orderid asc');
         Z_Cache::getInstance()->save($titles, 'z_titles');
     }
     foreach ($titles as $title) {
         if (strpos($uri, $title->uri) === 0) {
             if ($title->title_block) {
                 Z_Seo::addTitle($title->title);
             } else {
                 Z_Seo::setTitle($title->title);
             }
             if ($title->description_block) {
                 Z_Seo::addDescription($title->description);
             } else {
                 Z_Seo::setDescription($title->description);
             }
             if ($title->keywords_block) {
                 Z_Seo::addKeywords($title->keywords);
             } else {
                 Z_Seo::setKeywords($title->keywords);
             }
         }
     }
 }
예제 #5
0
 public function postDispatch(Zend_Controller_Request_Abstract $request)
 {
     //		if (Zend_Registry::isRegistered(Tomato_Core_GlobalKey::LOG_REQUEST)
     //			&& Zend_Registry::get(Tomato_Core_GlobalKey::LOG_REQUEST) == false
     //		) {
     //			return;
     //		}
     $objRequestLog = new Model_RequestLog();
     $uri = $request->getRequestUri();
     $agent = $request->getServer('HTTP_USER_AGENT');
     $browserInfo = self::_getBrowserInfo($agent);
     $objRequestLog->insert(array('ip' => $request->getClientIp(), 'agent' => $agent, 'browser' => $browserInfo['browser'], 'version' => $browserInfo['version'], 'platform' => $browserInfo['platform'], 'bot' => self::_getBot($agent), 'uri' => $uri, 'full_url' => $request->getScheme() . '://' . $request->getHttpHost() . '/' . ltrim($uri, '/'), 'refer_url' => $request->getServer('HTTP_REFERER'), 'access_time' => date('Y-m-d H:i:s')));
     //		$log = new Tomato_Modules_Core_Model_RequestLog(
     //			array(
     //				'ip' => $request->getClientIp(),
     //				'agent' => $agent,
     //				'browser' => $browserInfo['browser'],
     //				'version' => $browserInfo['version'],
     //				'platform' => $browserInfo['platform'],
     //				'bot' => self::_getBot($agent),
     //				'uri' => $uri,
     //				'full_url' => $request->getScheme().'://'.$request->getHttpHost().'/'.ltrim($uri, '/'),
     //				'refer_url' => $request->getServer('HTTP_REFERER'),
     //				'access_time' => date('Y-m-d H:i:s'),
     //			)
     //		);
     //		$conn = Tomato_Core_Db_Connection::getMasterConnection();
     //		$gateway = new Tomato_Modules_Core_Model_RequestLogGateway();
     //		$gateway->setDbConnection($conn);
     //		$gateway->create($log);
 }
예제 #6
0
 /**
  * @todo: This has nothing to do with the langselector, so maybe move it to its own plugin
  *
  */
 public function postDispatch(Zend_Controller_Request_Abstract $request)
 {
     // Don't save ajax call url's as the last request
     if (!$request->isXmlHttpRequest()) {
         $lastRequest = Zend_Controller_Action_HelperBroker::getStaticHelper('lastRequest');
         $lastRequest->saveRequestUri($request->getRequestUri());
     }
 }
예제 #7
0
 public function preDispatch(Zend_Controller_Request_Abstract $request)
 {
     try {
         Zwe_Model_Page::getThisPage($request->getRequestUri());
     } catch (Exception $E) {
         # Do nothing
     }
 }
예제 #8
0
 public function routeShutdown(Zend_Controller_Request_Abstract $request)
 {
     $navContainer = null;
     $viewRenderer = Zend_Controller_Action_HelperBroker::getExistingHelper('ViewRenderer');
     $viewRenderer->initView();
     $view = $viewRenderer->view;
     $module = $request->getModuleName();
     if ($module == "admin") {
         $navContainerConfig = new Zend_Config_Xml(APPLICATION_PATH . '/modules/admin/navigation.xml', 'nav');
         $navContainer = new Zend_Navigation($navContainerConfig);
         // Load the xml navigation menu
         // check if the database configuration has been set
         if (Shineisp_Main::isReady()) {
             // Adding the configuration menu items
             $configuration = SettingsGroups::getlist();
             $submenu = $navContainer->findOneByLabel('Configuration');
             foreach ($configuration as $id => $item) {
                 $pages[] = array('label' => $item, 'uri' => '/admin/settings/index/groupid/' . $id, 'resource' => 'admin:settings');
             }
             $submenu->addPages($pages);
         }
         // Attach the Zend ACL to the Navigation menu
         $auth = Zend_Auth::getInstance();
         if ($auth) {
             $acl = $auth->getStorage()->read();
             if (is_object($acl)) {
                 Zend_View_Helper_Navigation_HelperAbstract::setDefaultAcl($acl);
                 Zend_View_Helper_Navigation_HelperAbstract::setDefaultRole("administrator");
             }
         }
     } elseif ($module == "default") {
         $navContainerConfig = new Zend_Config_Xml(APPLICATION_PATH . '/modules/default/navigation.xml', 'nav');
         $navContainer = new Zend_Navigation($navContainerConfig);
         // Load the xml navigation menu
         // Attach the Zend ACL to the Navigation menu
         $auth = Zend_Auth::getInstance();
         if ($auth) {
             $acl = $auth->getStorage()->read();
             if (is_object($acl)) {
                 Zend_View_Helper_Navigation_HelperAbstract::setDefaultAcl($acl);
                 Zend_View_Helper_Navigation_HelperAbstract::setDefaultRole("guest");
             }
         }
     }
     if ($navContainer) {
         foreach ($navContainer->getPages() as $page) {
             foreach ($page->getPages() as $subpage) {
                 foreach ($subpage->getPages() as $subsubpage) {
                     $uri = $subsubpage->getHref();
                     if ($uri === $request->getRequestUri()) {
                         $subsubpage->setActive(true);
                     }
                 }
             }
         }
         $view->navigation($navContainer);
     }
 }
예제 #9
0
 /**
  * Predispatch
  *
  * @param Zend_Controller_Request_Abstract $request
  */
 public function preDispatch(Zend_Controller_Request_Abstract $request)
 {
     // Check if user is authenticated
     // [...]
     // Store url before redirecting user to login page
     $flashRedirector = Zend_Controller_Action_HelperBroker::getStaticHelper('FlashRedirector');
     $flashRedirector->setRedirect($request->getRequestUri());
     // Redirect to login page
     // [...]
 }
예제 #10
0
 protected function isNotToRemember(Zend_Controller_Request_Abstract $request)
 {
     if (in_array($request->getControllerName(), $this->_ignoreList)) {
         return true;
     }
     if ($request->getRequestUri() == '/favicon.ico') {
         return true;
     }
     return false;
 }
 /**
  * This plugin validates sessions on pages that require
  *
  * @param Zend_Controller_Request_Abstract $request
  */
 public function preDispatch(Zend_Controller_Request_Abstract $request)
 {
     if (!$this->_isPublicPage($request->getRequestUri())) {
         // if user has not identity, must login first
         if (!Zend_Auth::getInstance()->hasIdentity()) {
             $redirector = Zend_Controller_Action_HelperBroker::getStaticHelper('redirector');
             $redirector->gotoUrl('/portal/index/login/');
         }
     }
 }
예제 #12
0
 public function routeStartup(Zend_Controller_Request_Abstract $request)
 {
     $robotsPath = PIMCORE_CONFIGURATION_DIRECTORY . "/robots.txt";
     if ($request->getRequestUri() == "/robots.txt") {
         if (is_file($robotsPath)) {
             header("Content-Type: text/plain; charset=utf8");
             echo file_get_contents($robotsPath);
             exit;
         }
     }
 }
예제 #13
0
파일: Auth.php 프로젝트: fredcido/simuweb
 /**
  * @access protected
  * @return void
  */
 protected function _routeNoAuth()
 {
     $this->_auth->clearIdentity();
     $baseUrl = Zend_Controller_Front::getInstance()->getBaseUrl();
     if (!$this->_request->isXMLHttpRequest()) {
         $this->_session->triedroute = str_replace($baseUrl, '', $this->_request->getRequestUri());
     } else {
         $helperBroker = Zend_Controller_Action_HelperBroker::getStaticHelper('json');
         $helperBroker->direct(array('error' => true, 'status' => false, 'logout' => true));
     }
     $this->_setRouter($this->_noAuth);
 }
예제 #14
0
파일: Acl.php 프로젝트: br00k/tnc-web
 public function preDispatch(Zend_Controller_Request_Abstract $request)
 {
     $acl = Zend_Registry::get('acl');
     $auth = Zend_Auth::getInstance();
     // get user role
     $role = $auth->hasIdentity() ? $auth->getIdentity() : 'guest';
     // whitelist web module
     if ($request->getModuleName() == 'web') {
         return;
     }
     if ($role != 'guest') {
         // prevent redirect loop by excluding 'user' controller actions
         if ($auth->getIdentity()->email == 'invalid_email_needs_updating' && $request->getControllerName() != 'user') {
             $flash = Zend_Controller_Action_HelperBroker::getStaticHelper('FlashMessenger');
             $lastRequest = Zend_Controller_Action_HelperBroker::getStaticHelper('lastRequest');
             $redir = Zend_Controller_Action_HelperBroker::getStaticHelper('Redirector');
             $flash->addMessage('Your IdP did not provide a valid email address, please supply one below.');
             $lastRequest->saveRequestUri($request->getRequestUri());
             $redir->setCode(303)->setExit(true)->gotoRoute(array('controller' => 'user', 'action' => 'edit', 'id' => $auth->getIdentity()->user_id), 'main-module');
         }
     }
     // check if ACL resource exists
     if (!$acl->has(ucfirst($request->getControllerName()))) {
         return;
     }
     // check if user is allowed to access resource
     if (!$acl->isAllowed($role, ucfirst($request->getControllerName()), $request->getActionName())) {
         // allow all calls to the rest module
         if ($request->getModuleName() == 'rest') {
             return;
         }
         $lastRequest = Zend_Controller_Action_HelperBroker::getStaticHelper('lastRequest');
         $redir = Zend_Controller_Action_HelperBroker::getStaticHelper('Redirector');
         // save last request in session since this data will be lost after redirect
         // have to call it here because the request URI is saved in postDispatch()
         $lastRequest->saveRequestUri($request->getRequestUri());
         // perform redirect
         $redir->setCode(303)->setExit(true)->gotoRoute(array('controller' => 'error', 'action' => 'noaccess', 'resource' => $acl->get(ucfirst($request->getControllerName()))->getResourceId(), 'privilege' => $request->getActionName()), 'main-module');
     }
 }
예제 #15
0
 public function routeShutdown(Zend_Controller_Request_Abstract $request)
 {
     $viewRenderer = Zend_Controller_Action_HelperBroker::getExistingHelper('ViewRenderer');
     $viewRenderer->initView();
     $view = $viewRenderer->view;
     $container = new Zend_Navigation(Zend_Registry::get('configuration')->navigation);
     foreach ($container->getPages() as $page) {
         $uri = $page->getHref();
         if ($uri === $request->getRequestUri()) {
             $page->setClass('active');
         }
     }
     $view->navigation($container);
 }
예제 #16
0
 public function routeStartup(Zend_Controller_Request_Abstract $request)
 {
     $uri = $request->getRequestUri();
     $uri = preg_replace('~^' . ZUPAL_BASEURL . '~', '', $uri);
     if (preg_match('~^/mb/artist/([^/?]+)~', $uri, $match)) {
         $key = $match[1];
         if (is_numeric($key)) {
             $artist = new Zupal_Musicbrainz_Artist($key);
             $key = $artist->gid;
         }
         error_log(__METHOD__ . ': ' . $key);
         $request->setRequestUri(ZUPAL_BASEURL . '/media/musicbrainz/data/type/artist/gid/' . $key);
     }
 }
예제 #17
0
 /**
  * Create standard display vars for each view
  */
 public function preDispatch(Zend_Controller_Request_Abstract $request)
 {
     $controller_name = $request->getControllerName();
     $action_name = $request->getActionName();
     // redirect to facebook after share callback
     $url = $request->getRequestUri();
     if (strpos($url, '/fb-redirect') !== false) {
         $r = Zend_Controller_Action_HelperBroker::getStaticHelper('redirector');
         $r->gotoUrl('http://facebook.com')->redirectAndExit();
     }
     // add <head> code for all global pages
     $this->view->custom_head = Zend_Registry::get('config')->get('global_head') ? Zend_Registry::get('config')->get('global_head') : '';
     // global javascript vars
     $this->view->php_controller = $controller_name;
     $this->view->php_action = $action_name;
     // view perspective
     $this->view->view_perspective = 'global_view';
     // offset infinite scroll - for bots crawling without js
     if (isset($_GET['scroll_offset'])) {
         $scroll_offset = (int) $_GET['scroll_offset'];
         $this->view->post_page_number = $scroll_offset + 1;
     }
     // background image
     $this->view->app_background_image = Zend_Registry::get('config')->background;
     // for logged in users
     if (Zend_Auth::getInstance()->hasIdentity()) {
         // notifications
         $Notifications = new Application_Model_Notifications();
         $notifications_count = $Notifications->getUnreadNotificationsCount();
         $this->view->notifications_count = $notifications_count;
         $this->view->addScriptPath(APPLICATION_PATH . '/views/scripts/');
         $notifications_html = $this->view->render('/partial/notifications_popover.phtml');
         $this->view->notifications_html = $notifications_html;
         // new messages count
         $Messages = new Application_Model_Messages();
         $new_messages_count = $Messages->getMessagesCount(false, true);
         $this->view->new_messages_count = $new_messages_count;
     } else {
         // skip on ajax validator
         if ($action_name == 'validateformajax') {
             return;
         }
         $this->loginFormsLoader($request);
     }
     // attach app sidebar box
     Zend_Registry::get('hooks')->attach('hook_view_sidebar', 20, function () {
         echo Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer')->view->render('/_sidebar/apps.phtml');
     });
     return;
 }
예제 #18
0
 /**
  * Initialise the navigation system
  *
  * (non-PHPdoc)
  * @see Zend_Controller_Plugin_Abstract::preDispatch()
  */
 public function preDispatch(Zend_Controller_Request_Abstract $request)
 {
     // Get the view to populate the navigation and logged_in status
     $view = Zend_Controller_Action_HelperBroker::getExistingHelper('ViewRenderer')->view;
     $view->logged_in = Zend_Auth::getInstance()->hasIdentity();
     // If we are on the error controller, return immediately to prevent
     // any database errors happening on error page
     if ($request->controller == "error") {
         return;
     }
     $nav = array();
     if ($view->logged_in) {
         // Always add home link
         $nav[] = array("label" => "Home", "id" => "home-link", "uri" => "/home");
         // If we're in a project, add in the things you can do
         if ($project_slug = $request->getParam("project")) {
             $projects = new GD_Model_ProjectsMapper();
             $project = $projects->getProjectBySlug($project_slug);
             if ($project instanceof GD_Model_Project) {
                 $nav[] = array("label" => "History", "id" => "deployments-link", "uri" => "/project/{$project_slug}/history");
                 $nav[] = array("label" => "Configs", "id" => "configs-link", "uri" => "/project/{$project_slug}/configs");
                 $nav[] = array("label" => "Settings", "id" => "settings-link", "uri" => "/project/{$project_slug}/settings");
                 $nav[] = array("label" => "Deploy", "id" => "deploy-link", "uri" => "/project/{$project_slug}/deploy");
             }
         } else {
             $nav[] = array("label" => "Profile", "id" => "profile-link", "uri" => "/profile");
             // Get the logged in user - if they're an admin, add the admin
             // menu
             $user = GD_Auth_Database::GetLoggedInUser();
             if ($user->isAdmin()) {
                 $nav[] = array("label" => "Admin", "id" => "admin-link", "uri" => "/admin");
             }
         }
     } else {
         $nav[] = array("label" => "Login", "id" => "login-link", "uri" => "/auth/login");
     }
     // Create a Zend_Navigation object from the above array
     $nav = new Zend_Navigation($nav);
     $view->navigation($nav);
     // This finds out if the current URL matches one of the menu items
     // and sets the active page if it does.
     $uri = $request->getRequestUri();
     $page = $view->navigation()->findOneBy("uri", $uri);
     if ($page) {
         $page->setActive();
     }
 }
예제 #19
0
파일: Session.php 프로젝트: roycocup/Tests
 /**
  * routeStartup() - check to see if a session exists versus a given parameter
  *
  * @param  (Zend_Controller_Request_Abstract $request
  * @return void
  */
 public function routeStartup(Zend_Controller_Request_Abstract $request)
 {
     //$request->setParam('ClientId','1');
     $regenerate = false;
     $uri = $request->getRequestUri();
     if (preg_match($this->_regex, $uri, $uriKey)) {
         $sessionKey = $uriKey[1];
         unset($uriKey);
         // OK we have a session ID passed to us by $_GET
         // Check to see if a cookie exists for this user
         if (Showcase_Session::sessionExists()) {
             // Cookie exists, remove the SID param from the request
             $request->setParam('sid', null);
         } else {
             if (false === strpos($_SERVER['HTTP_USER_AGENT'], 'Googlebot')) {
                 Showcase_Session::setSessionKey($sessionKey);
                 // no session for this user
                 // a get query and no session means either they are using an old link
                 // or that they have really high security settings
                 // let's go to the database and see if we can find them
                 $regenerate = true;
                 $sessionId = Showcase_Session::getSessionId($request);
                 // checks database to get the true PHPSESSID
                 if ($sessionId) {
                     // they have a session in the database, set their current session as the existing one
                     // and then regenerate it anyway as a security measure.
                     try {
                         Showcase_Session::setId($sessionId);
                     } catch (Zend_Exception $e) {
                         try {
                             Showcase_Session::destroy(true);
                         } catch (Zend_Exception $e) {
                         }
                     }
                 }
                 unset($sessionId);
                 // this is not a variable you want lying around.  Ever.  Unsetting just to be safe.
             }
         }
         $request->setRequestUri(preg_replace($this->_regex, '', $uri));
     }
     Showcase_Session::start();
     if ($regenerate) {
         Showcase_Session::regenerateId();
     }
 }
예제 #20
0
 /**
  * @param \Zend_Controller_Request_Abstract $request
  */
 public function routeStartup(\Zend_Controller_Request_Abstract $request)
 {
     $conf = \Pimcore\Config::getReportConfig();
     if (!is_null($conf->webmastertools) && isset($conf->webmastertools->sites)) {
         $sites = $conf->webmastertools->sites->toArray();
         if (is_array($sites)) {
             foreach ($sites as $site) {
                 if ($site["verification"]) {
                     if ($request->getRequestUri() == "/" . $site["verification"]) {
                         echo "google-site-verification: " . $site["verification"];
                         exit;
                     }
                 }
             }
         }
     }
 }
예제 #21
0
 public function routeStartup(\Zend_Controller_Request_Abstract $request)
 {
     /** @var $request \Zend_Controller_Request_Http */
     if (!$request->isGet()) {
         return;
     }
     $host = 'http://' . $request->getHttpHost();
     $uri = \Zend_Uri_Http::fromString($host . $request->getRequestUri());
     $query = $uri->getQueryAsArray();
     if (!isset($query['_escaped_fragment_'])) {
         return;
     }
     $path = $uri->getPath() . ltrim($query['_escaped_fragment_'], '/');
     $uri->setPath($path);
     unset($query['_escaped_fragment_']);
     $uri->setQuery($query);
     $request->setRequestUri(str_replace($host, '', $uri->getUri()));
     $request->setPathInfo();
 }
 public function routeStartup(Zend_Controller_Request_Abstract $request)
 {
     $Uri = $request->getRequestUri();
     $Get = null;
     $QuestionMarkPosition = strpos($Uri, '?');
     if (false !== $QuestionMarkPosition) {
         $Get = substr($Uri, $QuestionMarkPosition + 1);
         $Uri = substr($Uri, 0, $QuestionMarkPosition);
     }
     $Extension = null;
     $PointPosition = strrpos($Uri, '.');
     if (false !== $PointPosition) {
         $Extension = substr($Uri, $PointPosition + 1);
         $Uri = substr($Uri, 0, $PointPosition);
     }
     if ($Extension) {
         $request->setRequestUri($Uri . ($Get ? '?' . $Get . "&format={$Extension}" : "?format={$Extension}"));
     }
 }
예제 #23
0
 public function preDispatch(Zend_Controller_Request_Abstract $request)
 {
     $updateService = new FFR_Service_Update();
     if ($updateService->currentSchemaVersion('tools') < 4) {
         return;
     }
     $currentUrl = $request->getRequestUri();
     $redirectGateway = new Tools_Model_RedirectGateway();
     if ($requestedPage = $redirectGateway->evaluateURLForRedirect($currentUrl)) {
         $this->_redirector = new Zend_Controller_Action_Helper_Redirector();
         $this->_redirector->setCode((int) $requestedPage->redirect_code)->setExit(true)->setGoToUrl($requestedPage->redirect_target);
         $dateTime = new FFR_View_Helper_DateTime();
         $requestedPage->redirect_count++;
         $requestedPage->redirect_last_source = $currentUrl;
         $requestedPage->redirect_time = $dateTime->dateTime(null, 'YYYY-MM-dd hh:mm:ss');
         $requestedPage->save();
         $this->_redirector->redirectAndExit();
     }
 }
예제 #24
0
 public function preDispatch(Zend_Controller_Request_Abstract $request)
 {
     if (Zend_Auth::getInstance()->hasIdentity() == true) {
         $username = Zend_Auth::getInstance()->getIdentity();
         $request_uri = $request->getRequestUri();
         $params = "username={$username}";
         foreach ($request->getParams() as $k => $v) {
             if ($request->getControllerName() != "error") {
                 $params .= "&{$k}={$v}";
             }
         }
         $usersNs = new Zend_Session_Namespace("members");
         $user_id = $usersNs->userId;
         $date = date("Y-m-d H:i:s");
         $remote_addr = $_SERVER['REMOTE_ADDR'];
         $table_name = "log_" . date("Y_m");
         $INSERT = "INSERT INTO {$table_name} SET \n             request_uri='{$request_uri}',\n             params='{$params}',\n             remote_addr='{$remote_addr}',\n             user_id='{$user_id}',\n             addedon='{$date}';  \n             ";
         $CREATE = " CREATE TABLE IF NOT EXISTS `{$table_name}` (\n              `id` int(14) NOT NULL auto_increment,\n              `request_uri` tinytext NOT NULL,\n              `params` text NOT NULL,\n              `remote_addr` varchar(255) NOT NULL,\n              `user_id` int(11) NOT NULL,\n              `addedon` datetime NOT NULL,\n              PRIMARY KEY  (`id`)\n            ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;";
         $db = Zend_Registry::get('db');
         $db->query($CREATE . $INSERT);
     }
 }
예제 #25
0
 /**
  * Redirect the user to a login controller in case of a error, a optional
  * redirect_to param is set to redirect the user in case of a error
  * 
  * @param Zend_Controller_Request_Abstract $Request
  * @param string $sError
  * @param string $sResource
  */
 private function _redirectToLogin(Zend_Controller_Request_Abstract $Request, $sError)
 {
     $sPreviousPlace = $Request->getRequestUri();
     $aLoginArray = $this->_getLoginAction();
     $Request->setModuleName($aLoginArray['module'])->setControllerName($aLoginArray['controller'])->setActionName($aLoginArray['action'])->setParam('error_message', $sError);
     if (!empty($sPreviousPlace)) {
         $Request->setParam('redirect_to', $sPreviousPlace);
     }
 }
예제 #26
0
파일: Debug.php 프로젝트: lchen01/STEdwards
 /**
  * Create HTML markup for request debugging.
  * 
  * @param Zend_Controller_Request_Abstract $request Request object.
  * @param Zend_Controller_Router_Interface $router Router object.
  * @return string HTML markup.
  */
 private function _getRequestMarkup($request, $router)
 {
     $requestUri = $request->getRequestUri();
     $html = "<h2>Request Data</h2>\n\n<div>Request URI: <em>{$requestUri}</em>" . "</div>\n<div>Params:";
     $reqParams = $request->getParams();
     // Rendering the whole error_handler ArrayObject is annoying and causes
     // errors when request params are later used to assemble routes.
     if (array_key_exists('error_handler', $reqParams)) {
         $errHandler = $reqParams['error_handler'];
         $reqParams['exception'] = (string) $errHandler['exception'];
         $reqParams['exception_type'] = $errHandler['type'];
         unset($reqParams['error_handler']);
     }
     $html .= '<pre>' . print_r($reqParams, true) . '</pre>';
     $html .= "</div>";
     if ($request->isPost()) {
         $html .= "<h2>Post Data</h2>";
         $html .= '<pre>' . print_r($_POST, true) . '</pre>';
     }
     $html .= "<h2>Session Data</h2>";
     $html .= '<pre>' . print_r($_SESSION, true) . '</pre>';
     $html .= "<h2>Server Data</h2>";
     $html .= '<pre>' . print_r($_SERVER, true) . '</pre>';
     $currentRoute = $router->getCurrentRouteName();
     $routes = $router->getRoutes();
     $html .= "<h2>Routing Data</h2>";
     $html .= "<div>Current Route: <strong>{$currentRoute}</strong></div>";
     $html .= "<div>Defined routes:\n\n";
     $html .= "<table><tr><th>Route Name</th><th>Matches Current Request</th><th>Assembled with current params</th></tr>";
     foreach ($routes as $routeName => $route) {
         try {
             $assembledRoute = $route->assemble($reqParams, true, true);
         } catch (Exception $e) {
             $assembledRoute = "Could not assemble: " . $e->getMessage();
         }
         if ($route instanceof Zend_Controller_Router_Route_Chain) {
             $routeIsMatched = $route->match($request);
         } else {
             $routeIsMatched = $route->match($request->getPathInfo());
         }
         $html .= "<tr><td>{$routeName}</td><td>" . ($routeIsMatched ? 'true' : 'false') . "</td><td>{$assembledRoute}</td></tr>";
     }
     $html .= "</table>";
     $html .= "<h2>Cookie Data</h2>";
     $html .= '<pre>' . print_r($_COOKIE, true) . '</pre>';
     return $html;
 }
예제 #27
0
파일: Auth.php 프로젝트: gatorv/gecko_fw1
 protected function _redirectToLogin(Zend_Controller_Request_Abstract $Request)
 {
     $Auth = Zend_Auth::getInstance();
     $Auth->clearIdentity();
     $session = $this->getAuthSession();
     $session->loggedIn = false;
     unset($session->lastTime);
     $sCurrentLocation = $Request->getRequestUri();
     $error = $this->error;
     $originalRequest = clone $Request;
     $Request->setControllerName('login')->setActionName('login')->setModuleName('default')->setParam('original_request', $originalRequest);
     if (!empty($error)) {
         $Request->setParam('error_message', $error);
     }
     if (!empty($sPreviousPlace)) {
         $Request->setParam('redirect_to', $sPreviousPlace);
     }
 }
예제 #28
0
 public function routeStartup(Zend_Controller_Request_Abstract $request)
 {
     $requestUri = $request->getRequestUri();
     $excludePatterns = array();
     // only enable GET method
     if (!$request->isGet()) {
         return $this->disable();
     }
     try {
         $conf = Pimcore_Config::getSystemConfig();
         if ($conf->cache) {
             $conf = $conf->cache;
             if (!$conf->enabled) {
                 return $this->disable();
             }
             if ($conf->lifetime) {
                 $this->setLifetime((int) $conf->lifetime);
             }
             if ($conf->excludePatterns) {
                 $confExcludePatterns = explode(",", $conf->excludePatterns);
                 if (!empty($confExcludePatterns)) {
                     $excludePatterns = $confExcludePatterns;
                 }
             }
             if ($conf->excludeCookie) {
                 $cookies = explode(",", strval($conf->excludeCookie));
                 foreach ($cookies as $cookie) {
                     if (isset($_COOKIE[trim($cookie)])) {
                         return $this->disable();
                     }
                 }
             }
         } else {
             return $this->disable();
         }
     } catch (Exception $e) {
         return $this->disable();
     }
     foreach ($excludePatterns as $pattern) {
         if (preg_match($pattern, $requestUri)) {
             return $this->disable();
         }
     }
     $appendKey = "";
     // this is for example for the image-data-uri plugin
     if ($request->getParam("pimcore_cache_tag_suffix")) {
         $tags = $request->getParam("pimcore_cache_tag_suffix");
         if (is_array($tags)) {
             $appendKey = "_" . implode("_", $tags);
         }
     }
     $this->cacheKey = "output_" . md5(Pimcore_Tool::getHostname() . $requestUri) . $appendKey;
     if ($cacheItem = Pimcore_Model_Cache::load($this->cacheKey, true)) {
         header("X-Pimcore-Cache-Tag: " . $this->cacheKey, true, 200);
         header("X-Pimcore-Cache-Date: " . $cacheItem["date"]);
         foreach ($cacheItem["rawHeaders"] as $header) {
             header($header);
         }
         foreach ($cacheItem["headers"] as $header) {
             header($header['name'] . ': ' . $header['value'], $header['replace']);
         }
         echo $cacheItem["content"];
         exit;
     }
 }
예제 #29
0
 /**
  * @param \Zend_Controller_Request_Abstract $request
  * @return bool|void
  */
 public function routeStartup(\Zend_Controller_Request_Abstract $request)
 {
     $requestUri = $request->getRequestUri();
     $excludePatterns = array();
     // only enable GET method
     if (!$request->isGet()) {
         return $this->disable();
     }
     // disable the output-cache if browser wants the most recent version
     // unfortunately only Chrome + Firefox if not using SSL
     if (!$request->isSecure()) {
         if (isset($_SERVER["HTTP_CACHE_CONTROL"]) && $_SERVER["HTTP_CACHE_CONTROL"] == "no-cache") {
             return $this->disable("HTTP Header Cache-Control: no-cache was sent");
         }
         if (isset($_SERVER["HTTP_PRAGMA"]) && $_SERVER["HTTP_PRAGMA"] == "no-cache") {
             return $this->disable("HTTP Header Pragma: no-cache was sent");
         }
     }
     try {
         $conf = \Pimcore\Config::getSystemConfig();
         if ($conf->cache) {
             $conf = $conf->cache;
             if (!$conf->enabled) {
                 return $this->disable();
             }
             if (\Pimcore::inDebugMode()) {
                 return $this->disable("in debug mode");
             }
             if ($conf->lifetime) {
                 $this->setLifetime((int) $conf->lifetime);
             }
             if ($conf->excludePatterns) {
                 $confExcludePatterns = explode(",", $conf->excludePatterns);
                 if (!empty($confExcludePatterns)) {
                     $excludePatterns = $confExcludePatterns;
                 }
             }
             if ($conf->excludeCookie) {
                 $cookies = explode(",", strval($conf->excludeCookie));
                 foreach ($cookies as $cookie) {
                     if (!empty($cookie) && isset($_COOKIE[trim($cookie)])) {
                         return $this->disable("exclude cookie in system-settings matches");
                     }
                 }
             }
             // output-cache is always disabled when logged in at the admin ui
             if (isset($_COOKIE["pimcore_admin_sid"])) {
                 return $this->disable("backend user is logged in");
             }
         } else {
             return $this->disable();
         }
     } catch (\Exception $e) {
         \Logger::error($e);
         return $this->disable("ERROR: Exception (see debug.log)");
     }
     foreach ($excludePatterns as $pattern) {
         if (@preg_match($pattern, $requestUri)) {
             return $this->disable("exclude path pattern in system-settings matches");
         }
     }
     $deviceDetector = Tool\DeviceDetector::getInstance();
     $device = $deviceDetector->getDevice();
     $deviceDetector->setWasUsed(false);
     $this->defaultCacheKey = "output_" . md5($request->getHttpHost() . $requestUri);
     $cacheKeys = [$this->defaultCacheKey . "_" . $device, $this->defaultCacheKey];
     $cacheItem = null;
     foreach ($cacheKeys as $cacheKey) {
         $cacheItem = CacheManager::load($cacheKey, true);
         if ($cacheItem) {
             break;
         }
     }
     if (is_array($cacheItem) && !empty($cacheItem)) {
         header("X-Pimcore-Output-Cache-Tag: " . $cacheKey, true, 200);
         header("X-Pimcore-Output-Cache-Date: " . $cacheItem["date"]);
         foreach ($cacheItem["rawHeaders"] as $header) {
             header($header);
         }
         foreach ($cacheItem["headers"] as $header) {
             header($header['name'] . ': ' . $header['value'], $header['replace']);
         }
         echo $cacheItem["content"];
         exit;
     } else {
         // set headers to tell the client to not cache the contents
         // this can/will be overwritten in $this->dispatchLoopShutdown() if the cache is enabled
         $date = new \Zend_Date(1);
         $this->getResponse()->setHeader("Expires", $date->get(\Zend_Date::RFC_1123), true);
         $this->getResponse()->setHeader("Cache-Control", "max-age=0, no-cache", true);
     }
 }
예제 #30
0
파일: Auth.php 프로젝트: fredcido/cenbrap
 /**
  * 
  * @access protected
  * @return void
  */
 protected function _routeNoAuth()
 {
     $path = $this->_request->getRequestUri();
     $session = new Zend_Session_Namespace($this->_config->geral->appid);
     $this->_setRoute($this->_noAuth);
 }