Help, Blocking External IP addresses
Posted: Fri Jan 06, 2006 8:41 am
Hi,
I am trying to create a security script which onyl allows certain IP addresses. Here is my scripts so far;
I get the following errors;
Notice: Undefined offset: 0 in C:\Audit\index.php on line 21
Warning: Cannot modify header information - headers already sent by (output started at C:\Audit\index.php:21) in C:\Audit\index.php on line 28
Warning: Cannot modify header information - headers already sent by (output started at C:\Audit\index.php:21) in C:\Audit\index.php on line 28
I am trying to create a security script which onyl allows certain IP addresses. Here is my scripts so far;
Code: Select all
// Assign user's IP address to $ip variable
$ip = $_SERVER["REMOTE_ADDR"];
// Create array of allowed IP addresses
$ips[1] = '212.123.123.1';
$ips[2] = '212.123.123.2';
$ips[3] = '212.123.123.3';
// Assign $access variable value of zero
$access = 0;
// For loop to run through each array item and get result
for($i = 0; $i < count($ips); $i++) {
// If users IP address is found within IP loop then add 1 to access variable
if ($ip == $ips[$i]){
$access++;
echo $access;
}
// if access variable = 1 then redirect to a website
else{
header("http://www.something.com");
}
// close for loop
}Notice: Undefined offset: 0 in C:\Audit\index.php on line 21
Warning: Cannot modify header information - headers already sent by (output started at C:\Audit\index.php:21) in C:\Audit\index.php on line 28
Warning: Cannot modify header information - headers already sent by (output started at C:\Audit\index.php:21) in C:\Audit\index.php on line 28