Topic: Limit IP range for registrations?

Hi

this would work for me to combat spam. I have a new zealand local community based forum (http://www.riverstonelounge.co.nz/forums), and only people who live in wellington, NZ would be interested in this forum.

Can I limit the ip range for registrations. The functionality is already there in the form of banning ip ranges. Can the code/table be added to the system? I am only starting out with php, so I could not do it without help.

Thanks

Re: Limit IP range for registrations?

While I don't have time to make a full mod/admin plugin for this right now, I just wrote the following for you. Just add ranges to the $pun_allow_ip_ranges array (the first 3 blocks of the IP's you want to allow). The drawback by not having a admin plugin is that you'll have to manually add IP's directly to the register.php file when you want to add/remove allowed addresses, but I hope it helps you out a little smile

Just open ./register.php and find on line 41:

require PUN_ROOT.'lang/'.$pun_user['language'].'/prof_reg.php';

Add after:

/**
 * - Limit allowed IP ranges during registration -
 *
 * Step 1:
 *
 * Array of allowed IP ranges. I'm using only the first 3 blocks here, so if you
 * need to be more specific you'll have to change the regex in step #2. Just add
 * addresses in the same way as I've written the example IP's.
 */

$pun_allow_ip_ranges = array(
    '127.0.0',
    '192.168.1'
);

/**
 * Step 2:
 *
 * Get the first 3 blocks from the users IP address, and capture it into the
 * $user_ip variable, then check if it is within the allowed range. If we can't
 * get the users IP address for whatever reason, we will also exit with a
 * "bad request" message.
 */

if( preg_match('#(\d{1,3}\.\d{1,3}\.\d{1,3})\.\d{1,3}#', get_remote_address(), $user_ip) ) {
    if( !in_array($user_ip[1], $pun_allow_ip_ranges) )
        message($lang_common['No permission']);
} else {
    message($lang_common['Bad request']);
}

Re: Limit IP range for registrations?

Wow. Thanks so much. I'll give it a try this morning.