Ban Ips And Browsers In Database

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Ban Ips And Browsers In Database

    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
    <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;http://Anonymouse.org/&#39;);
    </div>

    Comment


      #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
      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, [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

      Comment


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


        Code:
        //pick browser tut tut  [url]http://Anonymouse.org//[/url]
        $browser = explode (&#39;/&#39;, $HTTP_USER_AGENT);
        if($browser[0]=="http:")
        {
        //send them ****ers back where they come from!!//
        header (&#39;Location: [url]http://Anonymouse.org/&#39;[/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...
        _______
        Info & Tips
        php.net
        w3schools.com

        Comment


          #5
          i dont get it lmao!!!!! come on work out the code you guys just let in a door way!!
          Code:
          //pick browser tut tut  [url]http://Anonymouse.org//[/url]
          $browser = explode (&#39;/&#39;, $HTTP_USER_AGENT);
          if($browser[0]=="http:")
          {
          //send them ****ers back where they come from!!//
          header (&#39;Location: [url]http://Anonymouse.org/&#39;[/url]);
          [/b]
          haha subzero hehe send them back haha haha....................

          Comment


            #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...
            _______
            Info & Tips
            php.net
            w3schools.com

            Comment


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

              Comment

              Working...
              X