if(isset($_REQUEST["subm1"]))
{
if ( !$userdata['session_logged_in'] )
{
echo '<meta http-equiv="refresh" content="1;url=login.php">';
message_die(GENERAL_MESSAGE, "Session Expired, Please Login<br /><br /><img src=images/progbar.gif height=13 width=200 />");
}
$error_msg='';
if(trim($HTTP_POST_VARS['ip5']) == '' && trim($HTTP_POST_VARS['ip6']) == '' && trim($HTTP_POST_VARS['ip7']) == '' && trim($HTTP_POST_VARS['ip8']) == '')
{
//put ip1 into ip5
//put ip2 into ip6
//put ip3 into ip7
//put ip4 into ip8
}
if (!preg_match('/^[0-9]+$/' , trim($HTTP_POST_VARS['ip8'])) || trim($HTTP_POST_VARS['ip8']) > 255){$error_msg='<br />' . $lang['Err_End_Box'] . '4'.$error_msg;} else { $ip8 = trim($HTTP_POST_VARS['ip8']); $ip8 = $ip8 + 0;}
if (!preg_match('/^[0-9]+$/' , trim($HTTP_POST_VARS['ip7'])) || trim($HTTP_POST_VARS['ip7']) > 255){$error_msg='<br />' . $lang['Err_End_Box'] . '3'.$error_msg;} else { $ip7 = trim($HTTP_POST_VARS['ip7']); $ip7 = $ip7 + 0;}
if (!preg_match('/^[0-9]+$/' , trim($HTTP_POST_VARS['ip6'])) || trim($HTTP_POST_VARS['ip6']) > 255){$error_msg='<br />' . $lang['Err_End_Box'] . '2'.$error_msg;} else { $ip6 = trim($HTTP_POST_VARS['ip6']); $ip6 = $ip6 + 0;}
if (!preg_match('/^[0-9]+$/' , trim($HTTP_POST_VARS['ip5'])) || trim($HTTP_POST_VARS['ip5']) > 255){$error_msg='<br />' . $lang['Err_End_Box'] . '1'.$error_msg;} else { $ip5 = trim($HTTP_POST_VARS['ip5']); $ip5 = $ip5 + 0;}
if (!preg_match('/^[0-9]+$/' , trim($HTTP_POST_VARS['ip4'])) || trim($HTTP_POST_VARS['ip4']) > 255){$error_msg='<br />' . $lang['Err_Start_Box'] . '4'.$error_msg;} else { $ip4 = trim($HTTP_POST_VARS['ip4']); $ip4 = $ip4 + 0;}
if (!preg_match('/^[0-9]+$/' , trim($HTTP_POST_VARS['ip3'])) || trim($HTTP_POST_VARS['ip3']) > 255){$error_msg='<br />' . $lang['Err_Start_Box'] . '3'.$error_msg;} else { $ip3 = trim($HTTP_POST_VARS['ip3']); $ip3 = $ip3 + 0;}
if (!preg_match('/^[0-9]+$/' , trim($HTTP_POST_VARS['ip2'])) || trim($HTTP_POST_VARS['ip2']) > 255){$error_msg='<br />' . $lang['Err_Start_Box'] . '2'.$error_msg;} else { $ip2 = trim($HTTP_POST_VARS['ip2']); $ip2 = $ip2 + 0;}
if (!preg_match('/^[0-9]+$/' , trim($HTTP_POST_VARS['ip1'])) || trim($HTTP_POST_VARS['ip1']) > 255){$error_msg='<br />' . $lang['Err_Start_Box'] . '1'.$error_msg;} else { $ip1 = trim($HTTP_POST_VARS['ip1']); $ip1 = $ip1 + 0;}
if ($error_msg != '')
{
echo '<meta http-equiv="refresh" content="5;url=banlist_moderate.php">';
message_die(GENERAL_MESSAGE, "<span class='rpostbody'>" . $error_msg . "</span><br /><br />You Are Being Redirected Back, Please wait<br /><br /><img src=images/progbar.gif height=13 width=200 />");
}
else
{
$reason = $_REQUEST['reason1'];
if($reason == '1')
{
echo '<meta http-equiv="refresh" content="5;url=banlist_moderate.php">';
message_die(GENERAL_MESSAGE, "<span class='rpostbody'>Error, You Forgot To Select A Reason.</span><br /><br />You Are Being Redirected Back, Please wait<br /><br /><img src=images/progbar.gif height=13 width=200 />");
}
$file = 'c:banlists/pedophiles-list.p2p';
$lines = file($file, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
$lines = implode ("\r\n", $lines); //turn in to string
$pattern = '/(?<info>.*?):(?<startIP>\d{1,3}\.\d{1,3}\.\d{1,3}.\d{1,3})-(?<endIP>\d{1,3}\.\d{1,3}\.\d{1,3}.\d{1,3})/ims';
preg_match_all($pattern, $lines, $matches);
array_walk($matches['info'], 'trim');
$cc=0;
$enterIPstart = $ip1*256*256*256+$ip2*256*256+$ip3*256+$ip4+0;
$enterIPend = $ip5*256*256*256+$ip6*256*256+$ip7*256+$ip8+0;
while($matches['startIP'][$cc])
{
if(ereg("([0-9]{1,3}).([0-9]{1,3}).([0-9]{1,3}).([0-9]{1,3})", $matches['startIP'][$cc],$regs) && ereg("([0-9]{1,3}).([0-9]{1,3}).([0-9]{1,3}).([0-9]{1,3})", $matches['endIP'][$cc],$regs1))
{
$foundIPstart = $regs[1]*256*256*256+$regs[2]*256*256+$regs[3]*256+$regs[4]+0;
$foundIPend = $regs1[1]*256*256*256+$regs1[2]*256*256+$regs1[3]*256+$regs1[4]+0;
}
// check to see if the end ip is lower than the start ip
if ($enterIPstart > $enterIPend)
{
echo '<meta http-equiv="refresh" content="5;url=banlist_moderate.php">';
message_die(GENERAL_MESSAGE, "<span class='rpostbody'>Error, End IP cant be lower than the Start IP.</span><br /><br />You Are Being Redirected Back, Please wait<br /><br /><img src=images/progbar.gif height=13 width=200 />");
}
//check to see if the IP ot a range exists first within the entered range
if ($enterIPstart >= $foundIPstart && $enterIPstart <= $foundIPend || $enterIPend <= $foundIPend && $enterIPend >= $foundIPstart)
{
message_die(GENERAL_MESSAGE, "<span class='rpostbody'>Error, The IP you entered falls within this already banned range. Start IP: ". $matches['startIP'][$cc] ." End IP ". $matches['endIP'][$cc] ."</span><br /><br />Please Click Back!");
}
$cc++;
}
$fa = fopen("c:banlists/pedophiles-list.p2p", "a");
if(! $fa)
{
echo '<meta http-equiv="refresh" content="5;url=banlist_moderate.php">';
message_die(GENERAL_MESSAGE, "<span class='rpostbody'>Error, Failed to find file pedophiles-list.p2p</span><br /><br />You Are Being Redirected Back, Please wait<br /><br /><img src=images/progbar.gif height=13 width=200 />");
}
fwrite($fa, $_REQUEST['reason1'] . ":" . $ip1 . "." . $ip2 . "." . $ip3 . "." . $ip4 . "-" . $ip5 . "." . $ip6 . "." . $ip7 . "." . $ip8 . "\r\n");
fclose($fa);
echo '<meta http-equiv="refresh" content="1;url=banlist_moderate.php">';
message_die(GENERAL_MESSAGE, "<span class='rpostbody'>IP Range Added Successfully!</span><br /><br />You Are Being Redirected Back, Please wait<br /><br /><img src=images/progbar.gif height=13 width=200 />");
}
}