Skip to content

Instantly share code, notes, and snippets.

@airways
Created March 8, 2012 20:44
Show Gist options
  • Save airways/2003325 to your computer and use it in GitHub Desktop.
Save airways/2003325 to your computer and use it in GitHub Desktop.
Force everything to be over HTTPS
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
// Note: not tested
class Https_ext {
public $settings = array();
public $description = '';
public $docs_url = '';
public $name = 'HTTPS';
public $settings_exist = 'n';
public $version = '1.0';
public function __construct($settings = '')
{
$this->settings = array();
$this->EE =& get_instance();
}
public function activate_extension()
{
$this->EE->db->insert('extensions', $data = array(
'class' => __CLASS__,
'method' => 'register_handler',
'hook' => 'sessions_start',
'settings' => serialize($this->settings),
'version' => $this->version,
'enabled' => 'y'
););
}
public function register_handler()
{
ob_start();
register_shutdown_function('dohttps');
}
function disable_extension()
{
$this->EE->db->where('class', __CLASS__)->delete('extensions');
}
function update_extension($current = '') {
return 0;
}
}
function dohttps() {
$b=str_replace('http://', 'https://', ob_get_contents());
ob_end_clean();
echo $b
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment