dirtydevil, that code does work, but ive found that the ipban only works if BOTH the browser AND ip are the same as banned user -- as opposed to just the ip ..
the same applies to the ip search thingy available to mod/admin when viewing user profiles
try this instead -- its similar to what im using at the moment
FUNCTION
Code:
<?php
function bancheck($user_ip,$user_browser){
// collect banned ppls' info
$banned_browser_ip = mysql_fetch_array(mysql_query("SELECT browser FROM prefix_banned_ip"));
$banned_ip = mysql_fetch_array(mysql_query("SELECT ip FROM prefix_banned_ip"));
// check if the ip matches a banned one (contained somewhere within the database)
if($user_ip==$banned_ip[0]){
// if it does, check if the browser matches also
if($user_browser==$banned_browser_ip[0])
{
return 1;
}else{
return 2;
}
else{
return 0;
}
}
//// if the ip address doesn't match, the check if the browser is on the list of disallowed ones
$banned_browser = mysql_fetch_array(mysql_query("SELECT browser FROM prefix_banned_browser"));
elseif($user_browser==$banned_browser[0]){
return 3;
}
?>
THIS STUFF IS CONTAINED WITHIN THE ACTIVE FILE -- eg, index.php or register.php
Code:
// collect user info (can be contained within the function, but i prefer to have it whithin the file that is actually being used
$user_ip = $REMOTE_ADDR;
$user_browser = $HTTP_USER_AGENT;
$ban_code = bancheck($user_ip,$user_browser);
if($ban_code="1"){
//displayed if browser and ip match
echo "This IP range and browser has been banned
";
echo "If you you\'re unlucky enough to share the same IP address and browser as somebody who has been very very naughty, please contact $admin_email so we can offer you a shield.";
}elseif($ban_code="2"){
//displayed if only ip matches
echo "This IP range and browser has been banned
";
echo "If you you\'re unlucky enough to share the same IP address as somebody who has been very very naughty, please contact $admin_email so we can offer you a shield.";
}elseif($ban_code="3"){
//displayed if the brower matches a disallowed one (eg, [Only registered and activated users can see links. Click Here To Register...] or NOKIA etc)
echo "Sorry, you are not allowed to view this site with $banned_browser[0]
";
echo "If there is a problem with this, please contact $admin_email and we will endeavour to assist you how we can.";
}else{
// REST OF PAGE //
// eg .. //
if($action=="register")
{
echo $registration_code;
}
}
?>
btw, sorry about all the annotations -- i hate coding without it if im not going to be looking at the script for a while or im going to give it to somebody else .. saves having to explain what each bit does and makes it easier for you to modify for your own needs
Bookmarks