Results 1 to 7 of 7

Thread: Ban Ips And Browsers In Database

  1. #1
    dirtydevil
    Guest

    Default

    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 "</p>";
    }
    ?>

    Please tell me if you find any errors so I can correct it cause it doesn&#39;t work.

  2. #2
    Member
    Join Date
    Mar 2006
    Location
    South-Africa
    Posts
    67
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Default

    <div class='codetop'>CODE</div><div class='codemain' style='height:200px;white-space:pre;overflow:auto'>$brws2= mysql_fetch_array(mysql_query("SELECT * FROM banned WHERE browser=&#39;".$ubr."&#39;"));
    if ($brws2){
    echo "<card id=\"main\" title=\"Browser Banned\">";
    echo "<p align=\"center\">";
    echo "<img src=\"images/exit.gif\" alt=\"*\"/>
    ";
    echo "If u see this this means your browser has been banned from this sites
    ";
    echo "</p>";
    echo "</card>";
    echo "</wml>";
    exit();
    }
    </div>
    I add this code and my browser banned work no mork anonymouse.org users for me and here is the sql code <div class='codetop'>CODE</div><div class='codemain' style='height:200px;white-space:pre;overflow:auto'>
    CREATE TABLE `banned` ( `id` int(10) NOT NULL auto_increment,
    `browser` varchar(200) NOT NULL default &#39;&#39;,
    PRIMARY KEY (`id`)
    ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;
    INSERT INTO `banned` VALUES (1, &#39;[Only registered and activated users can see links. Click Here To Register...]);
    </div>

  3. #3
    Member
    Join Date
    Mar 2006
    Location
    in your dreams :P
    Posts
    84
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Default

    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&#39; 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&#39;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\&#39;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\&#39;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

  4. #4
    Super Moderator subzero's Avatar
    Join Date
    Mar 2006
    Location
    Your Screen.
    Posts
    3,971
    Thanks
    442
    Thanked 379 Times in 180 Posts
    Blog Entries
    7
    Rep Power
    0

    Default

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


    Code:
    //pick browser tut tut  [Only registered and activated users can see links. Click Here To Register...]
    $browser = explode (&#39;/&#39;, $HTTP_USER_AGENT);
    if($browser[0]=="http:")
    {
    //send them ****ers back where they come from!!//
    header (&#39;Location: [Only registered and activated users can see links. Click Here To Register...]);
    Visit: [Only registered and activated users can see links. Click Here To Register...]
    Visit: [Only registered and activated users can see links. Click Here To Register...]
    _______
    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...
    _______
    Info & Tips
    php.net
    w3schools.com

  5. #5
    lamar-wap
    Guest

    Default

    i dont get it lmao!!!!! come on work out the code you guys just let in a door way!!
    Code:
    //pick browser tut tut  [Only registered and activated users can see links. Click Here To Register...]
    $browser = explode (&#39;/&#39;, $HTTP_USER_AGENT);
    if($browser[0]=="http:")
    {
    //send them ****ers back where they come from!!//
    header (&#39;Location: [Only registered and activated users can see links. Click Here To Register...]);
    [/b]
    haha subzero hehe send them back haha haha....................

  6. #6
    Super Moderator subzero's Avatar
    Join Date
    Mar 2006
    Location
    Your Screen.
    Posts
    3,971
    Thanks
    442
    Thanked 379 Times in 180 Posts
    Blog Entries
    7
    Rep Power
    0

    Default

    its true they come and go back where they belong lmao!!
    Visit: [Only registered and activated users can see links. Click Here To Register...]
    Visit: [Only registered and activated users can see links. Click Here To Register...]
    _______
    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...
    _______
    Info & Tips
    php.net
    w3schools.com

  7. #7
    lamar-wap
    Guest

    Default

    its true they come and go back where they belong lmao!![/b]
    lol ok subzero hehe send them back now...............

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

SEO by vBSEO

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19