class AppController extends Controller {
var $allowedHosts = array('127.0.0.1', '::1', '85.127.249.210');
var $accessDeniedRedirect = ... // Define your action to redirect to
here.
function beforeFilter() {
if (!in_array(env('REMOTE_ADDR'), $this->allowedHosts)) {
$this->redirect($this->accessDeniedRedirect);
die();
}
}
}
That would cover it.
The only thing I have not considered is that you need to allow anyone
access to the $accessDeniedRedirect address.
So you will need a check in or around your if statement in the
beforeFilter there to ensure unrestricted access to whatever you set
$accessDeniedRedirect is set to.
But I will leave that for you to sort out. Can't give you all the
solutions. That would be boring!
Cheers,
Graham
Aurelius wrote:
> Hi!
>
> I Would like to limit the access to a controller function in the same
> way as .htaccess would do it with these lines:
> Order deny,allow
> Deny from all
> Allow from 85.127.249.210
>
> How can I achieve that?
>
> thx
> Aurelius
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---