Welcome Guest, Not a member yet? Register   Sign In
Writing Admin/User/Public controllers to insure authentication
#31

(This post was last modified: 01-27-2015, 03:29 AM by edjon2000. Edit Reason: updated last part of post )

Hi Everyone,

Been a while since I logged into the now moved codeigniter forums, hope the new owners take care of our codeigniter Wink

I have several sites using codeigniter 2.2.0 all upgraded gradually from 1.x.x something, I think it was and I noticed the ops question about separating out say an admin section and a public section, in my case, I had this same problem, and after trawling through various forums, stack overflow and watching numerous videos, I came up with a sort of combination of everything which I crystallised(yes I know, it's not a typo, I am from the UK) down to a few basic concepts, I use a MY_Controller which I have located in my /application/core/ directory where I set a few basic parameters and then use a Frontend_Controller and a Backend_Controller both located in my /application/libraries/ directory, the Frontend_Controller is used for anything public facing, and the Backend_Controller is used for anything that requires some kind of authentication e.g. Admin, Members, etc, and this is where I handle logging in and authentication using Ion_Auth or something similar, both the Frontend and Backend Controller extends MY_Controller, which in turn extends CI_Controller, I find that this approach nicely segregates out delicate information from public information, so, from here any other controllers for my sites either extends from Frontend_Controller for say public site pages, or Backend_Controller for admin, registration, members, utility type pages.

Oh, and to avoid all those pesky include or require statements, I use a pre-loader of sorts to load the MY_xxx, Frontend and Backend Controllers into my application which I have appended to my /application/config/config.php file.

-------------------------------------------------------------------------------------------------------------------------------------------
As an aside I recently updated my PHP version to 5.6.3 which has thrown up an unusual PHP notice problem related to /system/core/Common.php on line 257 it produces the error message:-

A PHP Error was encountered

Severity: Notice

Message: Only variable references should be returned by reference

Filename: core/Common.php

Line Number: 257

It took me a while to find a solution for this and thanks to a post on the old archived codeigniter forums back at ellis labs
I was able to solve the problem by changing line 257 from:-

PHP Code:
return $_config[0] =& $config

to:-

PHP Code:
$_config[0] =& $config;
return 
$_config[0]; 

I hope that this may help anyone else that has come across the same problem, I personally hate to hack the codeigniter system code but was not able to override it in the normal way using a similar named file in my /application/core/ directory any ideas about that would be greatly appreciated.
-------------------------------------------------------------------------------------------------------------------------------------------
Mods if you feel that this part of my post should be moved to its own thread as it does not directly relate to the ops question please feel free to do so

Edit... It seems that this particular PHP Notice issue has been fixed in CodeIgniter 2.2.1

edjon2000.
Reply


Messages In This Thread
RE: Writing Admin/User/Public controllers to insure authentication - by edjon2000 - 01-26-2015, 04:56 PM



Theme © iAndrew 2016 - Forum software by © MyBB