Welcome Guest, Not a member yet? Register   Sign In
Protecting certain functions in controller form being used by user directly
#1

[eluser]bleu[/eluser]
The are certain functions in my controllers that I do not want people to have access to.

I may want only one main function to be accessed in that controller through the browser.

The other functions should be accessed by that main function in that controller only

How can I achieve that

Example: controller/function1 should be able to be accessed by the browser other functions should be accessed by function1(i.e. function2,function3 should be accessed by function1)
#2

[eluser]soupli[/eluser]
You could use the controllers _remap() function:
http://ellislab.com/codeigniter/user-gui...#remapping

or choose to use URI Routing:
http://ellislab.com/codeigniter/user-gui...uting.html
#3

[eluser]PhilTem[/eluser]
You could also use what is mentioned in the user's guide about private functions.
#4

[eluser]InsiteFX[/eluser]
Code:
function _name()  // CI private

private function name()

protected function name()
#5

[eluser]bleu[/eluser]
[quote author="InsiteFX" date="1333366144"]
Code:
function _name()  // CI private

private function name()

protected function name()
[/quote]

what is difference between ci private and php private?
#6

[eluser]PhilTem[/eluser]
PHP private is private in terms of object visibility. CI private is only in terms of URI. Any method defined public but starting with an underscore won't be accessible by any user
Code:
public function _not_publicly_accessible()
since this is what CI's designed to see as private.

If you defined any method with visibility private/protected, it won't however be accessible by the CI super-object, too. But that's because it can't call
Code:
$controller->protected_method()
which is due to the visibility restrictions PHP provides.
#7

[eluser]bleu[/eluser]
[quote author="PhilTem" date="1333373638"]PHP private is private in terms of object visibility. CI private is only in terms of URI. Any method defined public but starting with an underscore won't be accessible by any user
Code:
public function _not_publicly_accessible()
since this is what CI's designed to see as private.

If you defined any method with visibility private/protected, it won't however be accessible by the CI super-object, too. But that's because it can't call
Code:
$controller->protected_method()
which is due to the visibility restrictions PHP provides.[/quote]

Thanks




Theme © iAndrew 2016 - Forum software by © MyBB