|
 |
|
 |
08-04-2007, 03:17 PM
|
#16 (permalink)
|
|
Senior Contributor
Join Date: Mar 2005
Posts: 651
|
$ip_from = "192.168.0.0";
vs
$ip_from = "19.216.80.0";
What do both result in after you did str_replace(".","",$ip_from) in both?
And no, don't ask about IPv6 routines!!!!
__________________

UT: Ultra-kill... God like!
|
|
|
08-05-2007, 03:55 PM
|
#17 (permalink)
|
|
Recruit
Join Date: Aug 2007
Posts: 3
|
Quote:
Originally Posted by DJMaze
$ip_from = "192.168.0.0";
vs
$ip_from = "19.216.80.0";
What do both result in after you did str_replace(".","",$ip_from) in both?
And no, don't ask about IPv6 routines!!!!
|
Ahh, didn't think so far.
How about?
PHP Code:
$ip = $_SERVER['REMOTE_ADDR'];
$ip = explode(".",$ip);
$ip_from = "192.168.0.0";
$ip_to = "192.168.255.255";
$ip_from = explode(".",$ip_from);
$ip_to = explode(".",$ip_to);
$a = 0;
while($a <= 3) {
if ($ip[$a] < $ip[$a] || $ip[$a] > $ip_to[$a]) { die("Denied"); }
$a++;
}
|
|
|
08-05-2007, 11:56 PM
|
#18 (permalink)
|
|
Senior Contributor
Join Date: Mar 2005
Posts: 651
|
__________________

UT: Ultra-kill... God like!
|
|
|
10-30-2007, 08:33 PM
|
#19 (permalink)
|
|
Recruit
Join Date: Oct 2007
Posts: 5
|
Quote:
Originally Posted by sde
if you didn't want to use regular expressions, and the IPs in your IP array always started at the beginning of the IP, then you could do something like this:
PHP Code:
<?php
function checkIP($ip_to_match, $ip_array) {
// make sure this is an array before we use foreach
if (is_array($ip_array)) {
// loop through ip array
foreach ($ip_array as $ip) {
// first test if there is a match, then test if the match starts at the beginning
if (strstr($ip_to_match, $ip) && strpos($ip_to_match, $ip)==0) {
return true;
}
}
}
return false;
}
$ban_array = array(
'216.47.55.141',
'72.47.147',
'74.171',
'58'
);
if (checkIP($_SERVER['REMOTE_ADDR'], $ban_array)) {
echo "This page is not accessible.";
exit;
}
?>
|
I'm sorry, this old thread i reply on this time, cause i really need help. So, the code above is work perfectly for me, but there's one option that i looking for. And cause i'm newbie, so can't figure it. I wanna the result is look like :
You ip address xxx.xxx.xxx. has been banned from this site !
So, in the echo syntax i put $ip, so it look like below:
You ip address $ip has been banned from this site !
but it doesn't work, i also change the $ip on message above with $ban_array, and $ip_to_match too...but still doesn't work.
so, what's the syntax i must add into the message? please tell me!
|
|
|
10-31-2007, 06:34 AM
|
#20 (permalink)
|
|
Newbie
Join Date: Jun 2002
Location: Denmark
Posts: 1,694
|
$_server['remote_addr']
|
|
|
11-01-2007, 12:52 PM
|
#21 (permalink)
|
|
Recruit
Join Date: Oct 2007
Posts: 5
|
@redhead
thanks but i got error:
Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/ibenk/public_html/ban.php on line 18
|
|
|
11-02-2007, 07:24 AM
|
#22 (permalink)
|
|
Newbie
Join Date: Jun 2002
Location: Denmark
Posts: 1,694
|
It's case sensitive and should be: $_SERVER['REMOTE_ADDR']
|
|
|
11-09-2007, 11:56 AM
|
#23 (permalink)
|
|
Recruit
Join Date: Oct 2007
Posts: 5
|
sorry for the late reply,
i still got error, and now the error appear in line 28, exactly in :
echo "Your ip address $_SERVER['REMOTE_ADDR'] has been banned from this site !";
|
|
|
05-21-2008, 03:07 AM
|
#24 (permalink)
|
|
Recruit
Join Date: May 2008
Posts: 3
|
a little old but..
Quote:
Originally Posted by ibenk
sorry for the late reply,
i still got error, and now the error appear in line 28, exactly in :
echo "Your ip address $_SERVER['REMOTE_ADDR'] has been banned from this site !";
|
I know this is a little old...well a year old  but shouldn't it be
PHP Code:
echo "Your IP Address " . $_SERVER['REMOTE_ADDR'] . " has been banned from this site !";
That should work, but do not forget to note the dots inbetween....
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -8. The time now is 04:26 AM.
|
Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting
|
 |
|