Welcome Guest, Not a member yet? Register   Sign In
[resolved] Get controller and function name
#1

[eluser]bas_vdl[/eluser]
Hello, im writing a login module and to check if somebody has acces to a function i'm using a hook. in the hook I was reading the controller and action from the url but this is not secure.

in the following situation http://localhost/welcome/ there is no function in the url so it wil load the index function but $CI->uri->segment(2) remains empty so the page wil be loaded meanwhile the user is not allowed to see the page.

so how can i make sure that i get the loaded controller and funtion without using $CI->uri->segment()

thank you

regards

Bas

EDIT: found it

Code:
<?php
        $router =& load_class('Router');
        
        $controller = strtolower($router->fetch_class());
        $action = strtolower($router->fetch_method());
#2

[eluser]Dam1an[/eluser]
You can also do
Code:
$this->router->class;
$this->router->method;

If I'm not mistake, using rsegment also works as its the routed segment, not the one in the URL




Theme © iAndrew 2016 - Forum software by © MyBB