Some forums allowed for given subnets onlyWith this snippet you can allow to view given forums for given subnets only
Requested by:
KnopperRequest topic:
http://www.phpbb.com/community/viewtopi ... &t=2157326Screens:User IP not in subnet
Attachment:
forum_id_4_forbidden_false_ip_subnet.png [ 34.41 KiB | Viewed 1758 times ]
User IP in subnet
Attachment:
forum_id_4_forbidden_right_ip_subnet.png [ 53.69 KiB | Viewed 1757 times ]
Instructionopen
viewtopic.php
find
Code:
before add
Code:
$forum_id_arr = array(4,5);
if (isset($forum_id) && ($forum_id !== 0)){
if (in_array($forum_id, $forum_id_arr)){
function ip_in_subnet($ip) {
$source = array("56.41.144.0/20");
foreach ($source as $line) {
list($base, $bits) = explode('/', $line);
list($a, $b, $c, $d) = explode('.', $base);
$i = ($a << 24) + ($b << 16) + ( $c << 8 ) + $d;
$mask = $bits == 0 ? 0: (~0 << (32 - $bits));
$low = $i & $mask;
$high = $i | (~$mask & 0xFFFFFFFF);
list($a, $b, $c, $d) = explode('.', $ip);
$check = ($a << 24) + ($b << 16) + ( $c << 8 ) + $d;
if ($check >= $low && $check <= $high) {
return true;
}
}
return false;
}
if(!isset($_SERVER['HTTP_X_FORWARDED_FOR']))
{
$client_ip = $_SERVER['REMOTE_ADDR'];
}
else
{
$client_ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
}
if(!ip_in_subnet($client_ip))
{
trigger_error('Sorry, no access to this forum from your network.
<br /><a href="javascript:history.back()">Back to last site</a>');
}
}}
- Make settings in both
### CONFIG
Sections - Read comments