Ban Ips And Browsers In Database

Started on the old forum in December 2006 · view the original in the archive · old links redirect here

6 replies · 982 views · started 19 years ago · 1 min read

dirtydevil #1

Ok, I want to basically stop all banned browsers and ips that are already in the database and just echo an error message. I also want to ban anonymous users using anonymouse.org to browse my site. My script is similar to the lavalair script, check if you see any errors in this script because it doesn't work, I can still browse my site with anonymouse.org and banned users can still enter.

The first is a function that comes in core.php that I include in register.php to prevent further registration:

<? function error(){ $browser = mysql_query("SELECT browserm FROM prefix_table"); $ip = mysql_query("SELECT ipadd FROM prefix_table"); while($ip2 = mysql_fetch_array($ip) && $browser2 =(mysql_fetch_array($browser))){ if($REMOTE_ADDR=="$ip2" && $HTTP_USER_AGENT=="$browser2"){ return true; }elseif($HTTP_USER_AGENT=="http://Anonymouse.org/"){ return true; }else{ return false; } } } ?>

And then I use include("core.php"); in register.php and I put the following code in register.php:

<? if(error()) { echo " "; echo "**Sorry, you are banned from our site.** "; echo "<a href=\"index.php\"><img src=\"images/home.gif\" alt=\"*\"/>"; echo "Home</a>"; echo " "; } ?>

Please tell me if you find any errors so I can correct it cause it doesn't work.

Guest #2

CODE$brws2= mysql_fetch_array(mysql_query("SELECT * FROM banned WHERE browser='".$ubr."'")); if ($brws2){ echo "<card id="main" title="Browser Banned">"; echo " "; echo "<img src="images/exit.gif" alt="*"/> "; echo "If u see this this means your browser has been banned from this sites "; echo " "; echo "</card>"; echo "</wml>"; exit(); }

I add this code and my browser banned work no mork anonymouse.org users for me and here is the sql code CODE CREATE TABLE banned ( id int(10) NOT NULL auto_increment, browser varchar(200) NOT NULL default '', PRIMARY KEY (id) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ; INSERT INTO banned VALUES (1, 'http://Anonymouse.org/');

Guest #3

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

<?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

// 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, [url]http://anonymouse.org/[/url] 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

subzero Super moderator Fellow · 3,954 posts #4

i dont get it lmao!!!!! come on work out the code you guys just let in a door way!!

//pick browser tut tut  [url]http://Anonymouse.org//[/url]
$browser = explode ('/', $HTTP_USER_AGENT);
if($browser[0]=="http:")
{
//send them fuckers back where they come from!!//
header ('Location: [url]http://Anonymouse.org/'[/url]);

Visit: Chat4u.mobi - The New Lay Of being a site of your dreams! Visit: WapMasterz Coming Back Soon!


SCRIPTS FOR SALE BY SUBZERO Chat4u Script : coding-talk.com/f28/chat4u-mobi-script-only-150-a-17677/ - > Best Script for your site no other can be hacked by sql or uploaders. FileShare Script : coding-talk.com/f28/file-wap-share-6596/ -> Uploader you will never regret buying yeah it mite be old now but it still seems to own others... _______…

lamar-wap #5

i dont get it lmao!!!!! come on work out the code you guys just let in a door way!!

//pick browser tut tut  http://Anonymouse.org//
$browser = explode ('/', $HTTP_USER_AGENT);
if($browser[0]=="http:")
{
//send them fuckers back where they come from!!//
header ('Location: http://Anonymouse.org/');

haha subzero hehe send them back haha haha....................

subzero Super moderator Fellow · 3,954 posts #6

its true they come and go back where they belong lmao!!

Visit: Chat4u.mobi - The New Lay Of being a site of your dreams! Visit: WapMasterz Coming Back Soon!


SCRIPTS FOR SALE BY SUBZERO Chat4u Script : coding-talk.com/f28/chat4u-mobi-script-only-150-a-17677/ - > Best Script for your site no other can be hacked by sql or uploaders. FileShare Script : coding-talk.com/f28/file-wap-share-6596/ -> Uploader you will never regret buying yeah it mite be old now but it still seems to own others... _______…

lamar-wap #7

its true they come and go back where they belong lmao!!

lol ok subzero hehe send them back now...............

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close