Welcome Guest, Not a member yet? Register   Sign In
SSL in CodeIgnitor
#2

[eluser]got 2 doodle[/eluser]
extend url helper - create the following file /system/application/helpers/my_url_helper.php

Code:
if (!defined('BASEPATH')) exit('No direct script access allowed');    
/**
* Secure Site URL
*
* Create a local URL based on your secure basepath. Segments can be passed via the
* first parameter either as a string or an array.
*
* @access    public
* @param    string
* @return    string
*/    
if (! function_exists('secure_site_url'))
{
    function secure_site_url($uri = '')
    {
        $CI =& get_instance();
        return $CI->config->secure_site_url($uri);
    }
}
    
// ------------------------------------------------------------------------

/**
* Secure Base URL
*
* Returns the "secure_base_url" item from your config file
*
* @access    public
* @return    string
*/    
if (! function_exists('secure_base_url'))
{
    function secure_base_url()
    {
        $CI =& get_instance();
        return $CI->config->slash_item('secure_base_url');
    }
}
    
// ------------------------------------------------------------------------
/**
* Secure Anchor Link
*
* Creates an anchor based on the local URL.
*
* @access    public
* @param    string    the URL
* @param    string    the link title
* @param    mixed    any attributes
* @return    string
*/    
if (! function_exists('secure_anchor'))
{
    function secure_anchor($uri = '', $title = '', $attributes = '')
    {
      
        $title = (string) $title;
    
        if ( ! is_array($uri))
        {
        
            $secure_url = ( ! preg_match('!^\w+://!i', $uri)) ? secure_site_url($uri) : $uri;
        }
        else
        {
        
            $secure_url = secure_site_url($uri);
        }
    
        if ($title == '')
        {
            $title = $secure_url;
        }

        if ($attributes == '')
        {
            $attributes = ' title="'.$title.'"';
        }
        else
        {
            $attributes = _parse_attributes($attributes);
        }

        return '<a href="'.$secure_url.'">'.$title.'</a>';
    }
}

/**
* Secure Header Redirect
*
* Header redirect in two flavors
*
* @access    public
* @param    string    the URL
* @param    string    the method: location or redirect
* @return    string
*/
if (! function_exists('secure_redirect'))
{
    function secure_redirect($uri = '', $method = 'location')
    {
        switch($method)
        {
            case 'refresh'    : header("Refresh:0;url=".secure_site_url($uri));
                break;
            default            : header("Location: ".secure_site_url($uri));
                break;
        }
        exit;
    }
}

continued in next post


Messages In This Thread
SSL in CodeIgnitor - by El Forum - 11-18-2008, 12:48 PM
SSL in CodeIgnitor - by El Forum - 11-18-2008, 12:49 PM
SSL in CodeIgnitor - by El Forum - 11-18-2008, 12:51 PM
SSL in CodeIgnitor - by El Forum - 11-18-2008, 12:53 PM
SSL in CodeIgnitor - by El Forum - 11-19-2008, 06:54 PM
SSL in CodeIgnitor - by El Forum - 11-20-2008, 09:10 AM
SSL in CodeIgnitor - by El Forum - 12-02-2008, 09:14 AM
SSL in CodeIgnitor - by El Forum - 12-11-2008, 02:16 PM
SSL in CodeIgnitor - by El Forum - 01-12-2009, 06:57 PM
SSL in CodeIgnitor - by El Forum - 01-12-2009, 09:57 PM
SSL in CodeIgnitor - by El Forum - 01-13-2009, 10:04 AM
SSL in CodeIgnitor - by El Forum - 01-17-2010, 08:49 PM
SSL in CodeIgnitor - by El Forum - 02-03-2011, 08:31 AM
SSL in CodeIgnitor - by El Forum - 02-04-2011, 06:19 AM
SSL in CodeIgnitor - by El Forum - 03-10-2011, 12:17 AM



Theme © iAndrew 2016 - Forum software by © MyBB