| 22 | | // get the cool stuff |
|---|
| 23 | | $context = $this->getContext(); |
|---|
| 24 | | $controller = $context->getController(); |
|---|
| 25 | | $request = $context->getRequest(); |
|---|
| | 22 | $disable_sslfilter = sfConfig::get('app_disable_sslfilter'); |
|---|
| | 23 | // execute only once and only if we are not in using a disabled environment |
|---|
| | 24 | if ($this->isFirstCall() |
|---|
| | 25 | && (empty($disable_sslfilter) |
|---|
| | 26 | || (is_scalar($disable_sslfilter) && SF_ENVIRONMENT != $disable_sslfilter) |
|---|
| | 27 | || (is_array($disable_sslfilter) && !in_array(SF_ENVIRONMENT, $disable_sslfilter)) |
|---|
| | 28 | ) |
|---|
| | 29 | ) { |
|---|
| | 30 | // get the cool stuff |
|---|
| | 31 | $context = $this->getContext(); |
|---|
| | 32 | $request = $context->getRequest(); |
|---|
| 31 | | if ($actionInstance->sslAllowed()) |
|---|
| 32 | | { |
|---|
| 33 | | $filterChain->execute(); |
|---|
| | 38 | // get the current action instance |
|---|
| | 39 | $actionEntry = $controller->getActionStack()->getLastEntry(); |
|---|
| | 40 | $actionInstance = $actionEntry->getActionInstance(); |
|---|
| | 41 | |
|---|
| | 42 | // request is SSL secured |
|---|
| | 43 | if ($request->isSecure()) |
|---|
| | 44 | { |
|---|
| | 45 | // but SSL is not allowed |
|---|
| | 46 | if (!$actionInstance->sslAllowed()) |
|---|
| | 47 | { |
|---|
| | 48 | $controller->redirect(str_replace('https', 'http', $request->getUri())); |
|---|
| | 49 | } |
|---|
| | 50 | } |
|---|
| | 51 | // request is not SSL secured, but SSL is required |
|---|
| | 52 | elseif ($actionInstance->sslRequired()) |
|---|
| | 53 | { |
|---|
| | 54 | $controller->redirect(str_replace('http', 'https', $request->getUri())); |
|---|
| | 55 | } |
|---|
| | 56 | } |
|---|