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

Pages: (2): « First « 1 [ 2 ] Last »
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
reisyboy
Elite Member
*****

Avatar
Messenger Oldie ;-)

Posts: 2107
Reputation: 10
35 / Male / –
Joined: May 2002
RE: Blocking an IP
quote:
Originally posted by sock
quote:

Originally posted by reisyboy
How can you block IP on ur PC? Is it in the HOSTS?


No, that simply acts as DNS cache which overrides DNS lookups on your computer. It can be abused to block access to certain domain names from your PC (by pointing them to localhost or something), but not actual IP addresses. You'd have to use a firewall to do that. 

Ahh right right right, ok well thats good enough for me, i want to restrict certian websites on certian computers (Sisters been asked to by dad) So ill just put the domians i want blocked in her pc's HOSTS
Reisyboy: He is the priest to guide us from evil.. which isn’t working… so we call him Frier Tuck
04-10-2004 08:34 PM
Profile E-Mail PM Web Find Quote Report
CookieRevised
Elite Member
*****

Avatar

Posts: 15519
Reputation: 173
– / Male / Flag
Joined: Jul 2003
Status: Away
RE: Blocking an IP
quote:
Originally posted by anubis_kree_
Couldn't a JavaScript code do the same if PHP is unsupported?
No, you can't in JavaScript. It's useless... Like sock said: the user could disable the javascript and the block is lifted...
Furthermore, JavaScript is client-side... PHP is server-side... You can only block someone/IP's with a server-side language...

This post was edited on 04-11-2004 at 02:51 AM by CookieRevised.
.-= A 'frrrrrrrituurrr' for Wacky =-.
04-11-2004 02:49 AM
Profile PM Find Quote Report
DJeX
Veteran Member
*****

Avatar


Posts: 1138
Reputation: 11
– / Male / –
Joined: Jul 2003
O.P. RE: Blocking an IP
I decided to use .htaccess to block people :mipdodgy:

.htaccess is great!
[Image: top.gif]
04-11-2004 03:35 AM
Profile PM Web Find Quote Report
Pages: (2): « First « 1 [ 2 ] Last »
« Next Oldest Return to Top Next Newest »


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