Skip to content

Instantly share code, notes, and snippets.

@lucasff
Created June 23, 2014 16:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lucasff/8ab67ce859d52294dd09 to your computer and use it in GitHub Desktop.
Save lucasff/8ab67ce859d52294dd09 to your computer and use it in GitHub Desktop.
SSL Component for CakePHP 1.3
<?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