[dokuwiki] Re: Restrict registration to certain IP range

  • From: Myron Turner <turnermm02@xxxxxxx>
  • To: dokuwiki@xxxxxxxxxxxxx
  • Date: Thu, 04 Oct 2007 08:31:33 -0500

Martin Grandrath wrote:
Hello,

On Wed, Oct 03, 2007 at 09:03:08PM -0500, Myron Turner wrote:
I wonder if one solution might be to write a small action plugin
that checks the IP addresses and then to set
$INFO['writable'] = false;

I have to admit that I haven't checked out the plugin mechanism yet.
I thought about checking the visitor's IP address from within the
template file (main.php), but I don't know if or how I can restrict a
user from there.

Furthermore I don't mind people to login and write from outside the
network.  What I like to restrict is the /registration/.

Regards,
Martin


The ACTION_ACT_PREPROCESS event seems to be designed to handle your kind of situation. For instance:

function register(&$controller) {
$controller->register_hook('ACTION_ACT_PREPROCESS', 'BEFORE', $this, 'check_register');
}

function check_register(&$event, $param) {
}

However, in my test the $event->preventDefault() method, called from check_register(), didn't stop the registration from taking place. A solution might be to check the IP address and check that the "do" parameter is "register". Then output your own custom error page with a link back to your dokuwiki site and then call exit. The exit will stop dokuwiki from continuing to process the page and your error message page will appear on the screen instead.

function check_register(&$event, $param) {
       if  bad_IP && do='register'
             output_error_message;
            exit;
}

Myron

--

_____________________
Myron Turner
http://www.room535.org
http://www.bstatzero.org
http://www.mturner.org/XML_PullParser/


--
DokuWiki mailing list - more info at
http://wiki.splitbrain.org/wiki:mailinglist

Other related posts: