Topic: Building a whitelist into register.php?

I want to build in a whitelist into register.php for a particular forum, so that while the forum itself may remain accessible to the world, registration is limited to people who come in from a specified set of IP addresses.

I could easily achieve this outside of FluxBB by adding this to the .htaccess file in the Fluxbb forum root:

<Files register.php>
order allow, deny

allow from 123.456.789.0/16
allow from 222.222.222.222
allow from 333.333.333.333

ErrorDocument 403 "'Sorry, we blocked you, but if you think 
this was in error contact the admin at admin@myforums.com." 
</Files>

While this is simple and does the job, I would like to see if the same thing could be achieved within register.php, since using .htaccess isn't always ideal.

Is there a way to do so that is as simple as the .htaccess route?

Requirements would include:

- providing a error message to blocked potential registrants;
- the code should be able to handle netmasks like 10.1.0.0/255.255.0.0 and CIDR.

All help appreciated.

Re: Building a whitelist into register.php?

You can ban IP addresses, or ranges of IP address through the admin panel on PunBB. smile

Administration --> Bans --> Click: "Add" but leave "username" blank

Re: Building a whitelist into register.php?

liquidat0r wrote:

You can ban IP addresses, or ranges of IP address through the admin panel on PunBB. smile

Administration --> Bans --> Click: "Add" but leave "username" blank

that would be different though...
He doesn't want to block them, but to only ALLOW them.

I support: FluxBB & Habari

Re: Building a whitelist into register.php?

I think for access controls, the web server is ideal here.

Re: Building a whitelist into register.php?

eternal243 wrote:

He doesn't want to block them, but to only ALLOW them.

Oh, my bad. I didn't read the post properly. smile

Re: Building a whitelist into register.php?

Yep, I just want the restrictions to apply to register.php, not the whole forum.

So far, it looks like the .htaccess option is the best way to go.

From my googling of possible PHP options, it looks like I'd need 40 lines of PHP code to achieve what I can achieve in 2 lines of code in .htaccess, especially when you factor in dealing with CIDR and other netmasking etc etc.