/** * See if the request the proper security * * @param Zend_Controller_Request_Http $request The request to check * @return boolean */ public function isValid($request) { if (!$request->isSecure()) { $this->_error(self::NOT_SECURE); return false; } return true; }
/** * Overrides match to detect port * * @param Zend_Controller_Request_Http $request * @return array|false */ public function match($request) { if ($this->hasPort()) { // Check that the port matches the route port $host = $request->getHttpHost(); if (preg_match(self::PORT_REGEXP, $host, $m)) { $port = (int) $m[1]; } else { // Assign a default port according to the scheme $port = $request->isSecure() ? 443 : 80; } if ($port !== (int) $this->getPort()) { return false; } } // Default match return parent::match($request); }
/** * Gets the request paths from the specified request object. * * @param Zend_Controller_Request_Http $request * * @return array Keys: basePath, host, protocol, fullBasePath, requestUri */ public static function getRequestPaths(Zend_Controller_Request_Http $request) { $basePath = $request->getBasePath(); if ($basePath === '' || substr($basePath, -1) != '/') { $basePath .= '/'; } $host = $request->getServer('HTTP_HOST'); if (!$host) { $host = $request->getServer('SERVER_NAME'); $serverPort = intval($request->getServer('SERVER_PORT')); if ($serverPort && $serverPort != 80 && $serverPort != 443) { $host .= ':' . $serverPort; } } $protocol = $request->isSecure() ? 'https' : 'http'; $requestUri = $request->getRequestUri(); return array('basePath' => $basePath, 'host' => $host, 'protocol' => $protocol, 'fullBasePath' => $protocol . '://' . $host . $basePath, 'requestUri' => $requestUri, 'fullUri' => $protocol . '://' . $host . $requestUri); }
protected function _initZendX() { $view = new Zend_View(); $website = Zend_Registry::get('website'); $misc = Zend_Registry::get('misc'); $url = preg_replace('~^https?://~', '', $website['url']); $request = new Zend_Controller_Request_Http(); $protocol = $request->getScheme(); $view->addHelperPath('ZendX/JQuery/View/Helper/', 'ZendX_JQuery_View_Helper'); if ($misc['jquery'] == 'local') { $view->jQuery()->setLocalPath($protocol . '://' . $url . 'system/js/external/jquery/jquery.js'); } else { $view->jQuery()->setCdnSsl($request->isSecure())->setVersion($misc['jqversion']); } if ($misc['jqueryui'] == 'local') { $view->jQuery()->setUiLocalPath($protocol . '://' . $url . 'system/js/external/jquery/jquery-ui.js'); } else { $view->jQuery()->setUiVersion($misc['jquversion']); } $viewRenderer = new Zend_Controller_Action_Helper_ViewRenderer($view); Zend_Controller_Action_HelperBroker::addHelper($viewRenderer); }
/** * Check that request uses https protocol if it should. * Function redirects user to correct URL if needed. * * @param Zend_Controller_Request_Http $request * @param string $path * @return void */ protected function _checkShouldBeSecure(Zend_Controller_Request_Http $request, $path = '') { if (!Mage::isInstalled() || $request->getPost()) { return; } if ($this->_shouldBeSecure($path) && !$request->isSecure()) { $url = $this->_getCurrentSecureUrl($request); if ($this->_shouldRedirectToSecure()) { $url = Mage::getSingleton('Mage_Core_Model_Url')->getRedirectUrl($url); } Mage::app()->getFrontController()->getResponse()->setRedirect($url)->sendResponse(); exit; } }