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
IIS has (crappy) PHP support too... :p


Anyway, this code should work (although .htaccess is a good alternative):


<?php
  $ip = getenv("REMOTE_ADDR");
  $proxy = getenv("HTTP_X_FORWARDED_FOR");
  if ($proxy) {  // HTTP proxy used
    $pos = 0;
    while (($pos < strlen($proxy)) && ($proxy{$pos} != ','))
      $pos++;
    $ip = substr($proxy,0,$pos);
  }
  if ($ip == "1.2.3.4")
    die("Sorry, you are not cool enough to view this page.");
?>



Just change the IP address in red to the one you wish to block. :p If you want to block more than one IP address, you can use || (or) in the IF condition. If you want to block lots of them, you should probably use a better method of matching... Like using an array or something. :-/ Or just use .htaccess. :refuck:

Anyway, you can place the code at the top of the page, or perhaps under the <BODY> tag.

This post was edited on 04-10-2004 at 02:43 PM by sock.
[Image: patchoulolhaxun7.jpg]
04-10-2004 02:27 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