Welcome Guest, Not a member yet? Register   Sign In
Entering only from route address
#1

[eluser]Leo78[/eluser]
Hey,

How can I set that only the route addresses will be valid?

I mean for example I have a controller `myclass` and function `myfunction` so I can enter this function via domain.com/myclass/myfunction - that the addresses I want to block, any ideas? because now I have two addresses per page - one from the route and on the original.

Thank you!
#2

[eluser]solid9[/eluser]
Make your function private,
http://ellislab.com/codeigniter/user-gui...ml#private
#3

[eluser]Leo78[/eluser]
Tried it, but the route address doesn't work too (because of the private).
#4

[eluser]solid9[/eluser]
Have you tried if else condition?

You can filter the user origin by using if else.
#5

[eluser]Leo78[/eluser]
Do you mean using $_SERVER and checking each time the address? it's the last solution I want to use, I hoped to find a solution in CI itself, there isn't?
#6

[eluser]solid9[/eluser]
What are you trying make a Login system?
#7

[eluser]PhilTem[/eluser]
If you want to turn methods into private methods DO NOT add a private declaration for the method

Code:
private function hidden() {}
will not work because the method can't be called form the CI super object.
However
Code:
public function _hidden() {}
will work and this method will not be accessible via http://example.com/controller/_hidden.

You need to distinguish between private PHP methods and "private CI methods"
#8

[eluser]Aken[/eluser]
Why do you want to block it in the first place? Unless you link to it in your website, the only way people will ever know it exists is if they guess correctly.
#9

[eluser]Leo78[/eluser]
@PhilTem, Again, I tried it but this option blocks the route too, so it doesn't help me.

[quote author="Aken" date="1351643834"]Why do you want to block it in the first place? Unless you link to it in your website, the only way people will ever know it exists is if they guess correctly.[/quote]

Absolutely right, but I want to prevent this 1% that the user will guess right. Is it possible?
#10

[eluser]CroNiX[/eluser]
post your routes.

If you have a route to bypass a method name in the url like:
Code:
$route['something/(:any)'] = 'controller/your_method/$1';

Then in your controller, you could:

Code:
function your_method($var1)
{
  if ($this->uri->segment(2) == 'your_method')
  {
    //reject as it had the method name in the url, so it wasn't routed
  }
}




Theme © iAndrew 2016 - Forum software by © MyBB