Guest User

Untitled

a guest
Apr 20th, 2018
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. <?php
  2.  
  3. /**
  4. * sfProtocolFilter checks the current site to see if protocol_secure is set to on. If so, all
  5. * pages are redirected with an https prefix
  6. *
  7. * @package symfony
  8. * @subpackage filter
  9. * @author Sean Kerr <sean@code-box.org>
  10. * @version SVN: $Id: sfBasicSecurityFilter.class.php 9087 2008-05-20 02:00:40Z Carl.Vondrick $
  11. */
  12. class sfProtocolFilter extends sfFilter
  13. {
  14. /**
  15. * Executes this filter.
  16. *
  17. * @param sfFilterChain $filterChain A sfFilterChain instance
  18. */
  19. public function execute($filterChain)
  20. {
  21. if (sfContext::hasInstance() && sfConfig::get('app_protocol_secure') && !sfContext::getInstance()->getRequest()->isSecure())
  22. {
  23. if (strpos(sfContext::getInstance()->getRequest()->getUri(), 'http') !== false)
  24. {
  25. $this->context->getController()->redirect(str_replace('http', 'https', sfContext::getInstance()->getRequest()->getUri()));
  26. }
  27. }
  28. $filterChain->execute();
  29. }
  30.  
  31. /**
  32. * Forwards the current request to the secure action.
  33. *
  34. * @throws sfStopException
  35. */
  36. protected function forwardToSecureAction()
  37. {
  38. $this->context->getController()->forward(sfConfig::get('sf_secure_module'), sfConfig::get('sf_secure_action'));
  39.  
  40. throw new sfStopException();
  41. }
  42. }
Add Comment
Please, Sign In to add comment