Announcement

Collapse
No announcement yet.

IP Banning script using PHP

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

  • IP Banning script using PHP

    I'm hoping a PHP guru can help me with this question. I am having a script written in PHP so that I can IP ban access to my website. What is the best way to do this? How does Vbulletin do it?

  • #2
    Why not just use htaccess?
    Steve Machol, former vBulletin Customer Support Manager (and NOT retired!)
    Change CKEditor Colors to Match Style (for 4.1.4 and above)

    Steve Machol Photography


    Mankind is the only creature smart enough to know its own history, and dumb enough to ignore it.


    Comment


    • #3
      Steve,

      Is this what Vbulletin incorporates? the reason I ask is that I've found VBulletin to work very well in keeping people out who i want kept out. I also want to be able to ban certain email accounts ( like all hotmail ) also.


      Originally posted by Steve Machol
      Why not just use htaccess?

      Comment


      • #4
        No, vB has it's own code. However it only works on vB - not anything else on your site. If you want the block to be specific to your whole site, then use htaccess.
        Steve Machol, former vBulletin Customer Support Manager (and NOT retired!)
        Change CKEditor Colors to Match Style (for 4.1.4 and above)

        Steve Machol Photography


        Mankind is the only creature smart enough to know its own history, and dumb enough to ignore it.


        Comment


        • #5
          PHP Code:
          // Banned Users
          $banlist['ip'] = array ('');
          $banlist['host'] = array ('');
          $banlist['name'] = array ('');
          $banlist['email'] = array ('');   
          function 
          banned ($banarray$against)  {
           global 
          $domainurl;
           foreach (
          $banarray as $cban) {
            
          $regexp str_replace ('.''\\.'$cban);
            
          $regexp str_replace ('*''.+'$regexp);
            if (
          ereg ("^$regexp$"$against)) {
             echo 
          "<html>\n";
             echo 
          "<header>\n";
             echo 
          "<title>++ You Are Banned ++</title>\n";
             echo 
          "</header>\n";
             echo 
          "<body>\n";
             echo 
          "<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>\n";
             echo 
          "<div align=\"center\"><b><font size=\"3\">";
             echo 
          "Sorry You Could Not Access This Site.<br>You Have Been Ban By The Administrator.";
             echo 
          "</font></b></div>";
             echo 
          "</body>\n";
             echo 
          "</html>\n";
             exit;
            }
           }
           return;
          }
          banned ($banlist['ip'], $ip_address);
          banned ($banlist['host'], gethostbyaddr($ip_address));
          banned ($banlist['name'], $HTTP_COOKIE_VARS["comment_author"]);
          banned ($banlist['email'], trim($HTTP_COOKIE_VARS["comment_author_email"])); 
          Here is come code although u need to edit the file manually. Hope it do helps a little

          Comment

          widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
          Working...
          X