<code>//Start hooks//app/config/config.php$config[' enable_hooks '] =TRUE;//Hooks Configuration///app/config/hooks.php$hook[' Post_controller_constructor '] [] =Array( ' function ' = ' check_ssl ', ' filename ' = ' ssl.php ', ' filepath ' = ' hooks ', );//Plugin Authoring//app/hooks/ssl.phpfunctionCheck_ssl () {$CI=&get_instance ();$class=$CI->router->Fetch_class ();$method=$CI->router->Fetch_method ();$ssl=$CI->config->item (' Ssl_class_method '); $partial=$CI->config->item (' No_ssl_class_method '); if(In_array($class.‘ /‘.$method,$ssl)){ //Force_ssl (); $CI=&get_instance (); $CI->config->config[' base_url '] =Str_replace(' HTTP//', ' https://',$CI->config->config[' Base_url ']); if($_server[' Server_port ']! = 443) Redirect ($CI->uri->uri_string ());}Else if(In_array($class.‘ /‘.$method,$partial)){ return; } Else{ //Unforce_ssl $CI=&get_instance (); $CI->config->config[' base_url '] =Str_replace(' https://', '/HTTP ',$CI->config->config[' Base_url ']); if($_server[' server_port '] = = 443) Redirect ($CI->uri->uri_string ()); }}//config configuration requires a class method//app/config/config.php with HTTPS$config[' ssl_class_method '] =Array( ' U_class/a_method ', ' v_class/b_method ', ' w_class/c_method ', ' X_class/d_method ', ); //enforcing the use of SSL$config[' no_ssl_class_method '] =Array();//force not to use SSL</code>
CI Frame hook Hooks