Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * sfProtocolFilter checks the current site to see if protocol_secure is set to on. If so, all
- * pages are redirected with an https prefix
- *
- * @package symfony
- * @subpackage filter
- * @author Sean Kerr <sean@code-box.org>
- * @version SVN: $Id: sfBasicSecurityFilter.class.php 9087 2008-05-20 02:00:40Z Carl.Vondrick $
- */
- class sfProtocolFilter extends sfFilter
- {
- /**
- * Executes this filter.
- *
- * @param sfFilterChain $filterChain A sfFilterChain instance
- */
- public function execute($filterChain)
- {
- if (sfContext::hasInstance() && sfConfig::get('app_protocol_secure') && !sfContext::getInstance()->getRequest()->isSecure())
- {
- if (strpos(sfContext::getInstance()->getRequest()->getUri(), 'http') !== false)
- {
- $this->context->getController()->redirect(str_replace('http', 'https', sfContext::getInstance()->getRequest()->getUri()));
- }
- }
- $filterChain->execute();
- }
- /**
- * Forwards the current request to the secure action.
- *
- * @throws sfStopException
- */
- protected function forwardToSecureAction()
- {
- $this->context->getController()->forward(sfConfig::get('sf_secure_module'), sfConfig::get('sf_secure_action'));
- throw new sfStopException();
- }
- }
Add Comment
Please, Sign In to add comment