Hello,
Can you guys tell me what I am doing wrong here?
I downloaded the following script and tried to modify it, but It doesn't work. I am trying to figure out why I can't get it right..
On this line -- > $bmode = 2; . The initial options were 0 or 1. I modified the following
--------------------------
----------
----------
----------
----------
----------
----------
----------
---
$blockmsg = "<br/><br/><br/><p><center
>You have been Blocked for guestbook abuse.<br/> <br/><br/><a href=\"
http://www.whatever.com\">Click here for more information</a></center></
p>";
It was an array. I didn't like that because for every ip that I enter in it has it's own message. I want just one default message to be displayed for all the blocked ip's
--------------------------
----------
----------
----------
----------
----------
----------
----------
-----
if ($bmode == 2) {
if ($REMOTE_ADDR == $blockip[$y] || ($brange == $blockip[$y])) {
echo '$blockmsg';
} else {
$allow="Yes";
}
}
What my thoughts were here was that I used the same one that the developer used for 1 but added just an echo statement to echo $blockmsg. It won't work correctly though.. Please help.. I was hoping that I could do this myself, but I guess not..
--------------------------
----------
----------
----------
----------
----------
----------
----------
-----
Full Script..
<?
// Copyright (c) 2003-2004 Robert Murdock (robert@darpac.com)
// ALL RIGHTS RESERVED
// Mode. If you set this to 1 then you will BLOCK IPS in the blockip array.
// If set to 0, then you will be ALLOW ONLY IP's in the blockip array.
// Addenum by Dan Kelly. If set to 2 then only primary message will show.
$bmode = 2;
// Note: if you are blocking a range (2.2.x) Make sure you put the
// trailing . (period/dot) at the end or it may cause issues
// with good ip ranges.
//
// $block ip is the IP of the person that you wish to block.
// You can add as many IP's as needed but keep the same format.
// The last IP will not need a ',' after it. The others will.
//
// Example:
//
// $blockip = array("1.1.1.1",
// "2.2.2.2",
// "3.3."
// );
$blockip = array("1.1.1.1",
"2.2.2.2.",
"3.3.3.3",
"209.164.239.146",
);
// $blockmsg is the message the user will see if they are blocked.
//
// Example:
//
// $blockmsg = array("1.1.1.1 Blocked for guestbook abuse.",
// "209.164.239.146 Blocked for guestbook abuse.",
// "3.3.3.3 We are temporarily down.",
// );
$blockmsg = "<br/><br/><br/><p><center
>You have been Blocked for guestbook abuse.<br/> <br/><br/><a href=\"
http://www.fbi.gov\">Click here for more information</a></center></
p>";
// Nothing to change below this line ------------------
$x = count($blockip);
for ($y = 0; $y < $x; $y++) {
$brange = substr($REMOTE_ADDR, 0, strlen($blockip[$y]));
if ($bmode == 1) {
if ($REMOTE_ADDR == $blockip[$y] || ($brange == $blockip[$y])) {
exit($blockmsg[$y]);
} else {
$allow="Yes";
}
}
if ($bmode == 0) {
if ($REMOTE_ADDR == $blockip[$y] || ($brange == $blockip[$y])) {
// return(1);
$allow="Yes";
}
}
}
if ($bmode == 2) {
if ($REMOTE_ADDR == $blockip[$y] || ($brange == $blockip[$y])) {
echo '$blockmsg';
} else {
$allow="Yes";
}
}
if ($allow != "Yes") exit($blockmsg);
?>