What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Skype & Technology » Tech Talk » Blocking an IP

Blocking an IP
Author: Message:
sock
Elite Member
*****

Avatar
Back in White! (with red stripes)

Posts: 1112
Reputation: 31
38 / Male / Flag
Joined: Nov 2002
Status: Away
RE: Blocking an IP
Here's an adaptation of stonesour's ip_check(), with strict proxy support:


<?php
function ip_check()
{
  // Addresses to block
  $block_ip[0] = "64.246.30.37";
  $block_ip[1] = "207.46.249.252";
  $block_ip[2] = "212.143.162.198";

  if (in_array($_SERVER["REMOTE_ADDR"], $block_ip))
    return false;
  if (in_array($_SERVER["HTTP_CLIENT_IP"], $block_ip))
    return false;
  if (isset($_SERVER["HTTP_X_FORWARDED_FOR"])) {
    $proxy = explode(",",$_SERVER["HTTP_X_FORWARDED_FOR"]);
    $proxy = str_replace(" ","",$proxy); $i = 0;
    while ($proxy[$i]) {
      if (in_array($proxy[$i], $block_ip))
        return false;
      $i++;
    }
  }
  return true;
}
?>



This one should also ban people who use standard HTTP proxies... Note that the function returns TRUE if the user is allowed entry, and FALSE if s/he is banned.

Does anyone know how to fill the $block_ip array more efficiently? :p

This post was edited on 04-10-2004 at 08:41 PM by sock.
[Image: patchoulolhaxun7.jpg]
04-10-2004 08:04 PM
Profile E-Mail PM Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
Blocking an IP - by DJeX on 04-09-2004 at 09:45 PM
RE: Blocking an IP - by Digirat on 04-09-2004 at 09:58 PM
RE: Blocking an IP - by sock on 04-10-2004 at 02:27 PM
RE: Blocking an IP - by Wabz on 04-10-2004 at 04:18 PM
RE: Blocking an IP - by DJeX on 04-10-2004 at 04:34 PM
RE: Blocking an IP - by Anubis on 04-10-2004 at 04:37 PM
RE: Blocking an IP - by reisyboy on 04-10-2004 at 04:40 PM
RE: Blocking an IP - by sock on 04-10-2004 at 05:28 PM
RE: Blocking an IP - by Anubis on 04-10-2004 at 05:36 PM
RE: Blocking an IP - by stonesour on 04-10-2004 at 06:43 PM
RE: Blocking an IP - by sock on 04-10-2004 at 08:04 PM
RE: Blocking an IP - by reisyboy on 04-10-2004 at 08:34 PM
RE: Blocking an IP - by CookieRevised on 04-11-2004 at 02:49 AM
RE: Blocking an IP - by DJeX on 04-11-2004 at 03:35 AM


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On