Created
June 23, 2014 16:28
-
-
Save lucasff/8ab67ce859d52294dd09 to your computer and use it in GitHub Desktop.
SSL Component for CakePHP 1.3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class SslComponent extends Object | |
{ | |
var $components = array('RequestHandler'); | |
var $Controller = null; | |
function initialize(&$Controller) | |
{ | |
$this->Controller = $Controller; | |
} | |
function force() | |
{ | |
if (!$this->RequestHandler->isSSL()) { | |
$this->Controller->redirect('https://' . $this->__url(443)); | |
} | |
} | |
function unforce() | |
{ | |
if ($this->RequestHandler->isSSL()) { | |
$this->Controller->redirect('http://' . $this->__url()); | |
} | |
} | |
/** This method updated from John Isaacks **/ | |
function __url() | |
{ | |
return env('SERVER_NAME') . env('REQUEST_URI'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment