IP Blocker Script

  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Joined: Dec 20, 2002
  • Posts: 8922
  • Loc: Seattle, WA & Phoenix, AZ
  • Status: Offline

Post July 24th, 2003, 5:46 pm

Through telnet or ssh. Are you on a virtual server or do you have full access to the server?

If you are on a virtual server you might need to get in tough with your host to find out more information on how to look at your error logs, and if they even provide them for you.

Also you may or may not be able to telnet/ssh in depending on your host and if they have that enabled on your account.
Ozzu Hosting - Want your website on a fast server like Ozzu?
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post July 24th, 2003, 5:46 pm

  • Dream4Muse
  • Novice
  • Novice
  • No Avatar
  • Joined: Jul 22, 2003
  • Posts: 18
  • Status: Offline

Post July 24th, 2003, 8:09 pm

That was the problem - I'm not granted access to the error log. Is there a different type of code that I can try instead?
  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Joined: Dec 20, 2002
  • Posts: 8922
  • Loc: Seattle, WA & Phoenix, AZ
  • Status: Offline

Post July 25th, 2003, 12:27 am

You should ask your host if you are allowed to use the Limit directive and/or the ErrorDocument directive. If they say no maybe you can talk them into enabling it. I have a feeling that is why your .htaccess file is not working, because they are not allowing you to override it.
Ozzu Hosting - Want your website on a fast server like Ozzu?
  • Dream4Muse
  • Novice
  • Novice
  • No Avatar
  • Joined: Jul 22, 2003
  • Posts: 18
  • Status: Offline

Post July 25th, 2003, 8:26 pm

My host was far from useful - I'm going to call again on Monday and hope that I get a different person on the phone. However, I was wondering if there's a code out there for this that's in java or some other language that I know I'll be able to use.
  • b_heyer
  • Web Master
  • Web Master
  • User avatar
  • Joined: Jun 15, 2003
  • Posts: 4583
  • Loc: Maryland
  • Status: Offline

Post July 26th, 2003, 8:43 am

How much do you want to block? It IS possible to block a few pages in PHP, but would be somewhat time consuming to redo your whole page.
Pixel Acres V2
  • Dream4Muse
  • Novice
  • Novice
  • No Avatar
  • Joined: Jul 22, 2003
  • Posts: 18
  • Status: Offline

Post July 26th, 2003, 9:18 am

All I need to do is block this person from accessing the index page - if he can't get to that, he won't be able to get to the rest of it because of the (cruddy) design it has. Basically, the only page that he has the url for is the index page.
  • b_heyer
  • Web Master
  • Web Master
  • User avatar
  • Joined: Jun 15, 2003
  • Posts: 4583
  • Loc: Maryland
  • Status: Offline

Post July 26th, 2003, 9:31 am

do you have access to PHP? if so:

Code: [ Select ]
<?
$ip = "$REMOTE_ADDR";
$block[0] = "***.***.***.***";
foreach ($block as $b)
{
  if ($b == $ip)
  {
    $blocked = 1;
  }
}
?>
<HTML>
<BODY>
<? if ($blocked != "")
{
  echo ("<!---");
}
?>
page info
<? if ($blocked != "")
{
  echo("--->");
}
?>
</BODY>
</HTML>
  1. <?
  2. $ip = "$REMOTE_ADDR";
  3. $block[0] = "***.***.***.***";
  4. foreach ($block as $b)
  5. {
  6.   if ($b == $ip)
  7.   {
  8.     $blocked = 1;
  9.   }
  10. }
  11. ?>
  12. <HTML>
  13. <BODY>
  14. <? if ($blocked != "")
  15. {
  16.   echo ("<!---");
  17. }
  18. ?>
  19. page info
  20. <? if ($blocked != "")
  21. {
  22.   echo("--->");
  23. }
  24. ?>
  25. </BODY>
  26. </HTML>


That should do it.
Pixel Acres V2
  • Dream4Muse
  • Novice
  • Novice
  • No Avatar
  • Joined: Jul 22, 2003
  • Posts: 18
  • Status: Offline

Post July 26th, 2003, 9:42 am

I've never used php before, but it's worth a shot. Am I only supposed to be adding in the correct IP address or are there other components of the code that I need to put in? Can I just add this code in the header of the index page or will I have do redo the whole page with php?
  • b_heyer
  • Web Master
  • Web Master
  • User avatar
  • Joined: Jun 15, 2003
  • Posts: 4583
  • Loc: Maryland
  • Status: Offline

Post July 26th, 2003, 10:04 am

basically just fill in the blanks, where the ***'s are put in the IP you wish to ban, then where it says page info is where all the page content goes (you can add a title and head tag as well in the appropriate places). Then resave the page as .php instead of .html.
Pixel Acres V2
  • Dream4Muse
  • Novice
  • Novice
  • No Avatar
  • Joined: Jul 22, 2003
  • Posts: 18
  • Status: Offline

Post July 26th, 2003, 3:47 pm

Thank you so much - the code is working for me. One final question though, is there a place in the code that I can put the error page that I want the user to be redirected to? It's saved on an entirely different domain.

Edit: It looks as if the code is working a bit too well - it's blocking everyone.
  • b_heyer
  • Web Master
  • Web Master
  • User avatar
  • Joined: Jun 15, 2003
  • Posts: 4583
  • Loc: Maryland
  • Status: Offline

Post July 26th, 2003, 5:51 pm

let me see your code.
Pixel Acres V2
  • Dream4Muse
  • Novice
  • Novice
  • No Avatar
  • Joined: Jul 22, 2003
  • Posts: 18
  • Status: Offline

Post July 26th, 2003, 6:50 pm

Code: [ Select ]
<?
$ip = "$REMOTE_ADDR";
$block[0] = "67.163.182.222";
foreach ($block as $b)
{
  if ($b == $ip)
  {
    $blocked = 1;
  }
}
?>
<HTML>
<BODY>
<? if ($blocked != "")
{
  echo ("<!---");
}
?>

<style>
<!--
a:link {text-decoration:bold; color:#FFFFFF}
a:visited {text-decoration:italic; color:#FFFFFF}
a:active {text-decoration:none; color:#FFFFFF}a:hover {text-decoration:none; color:#000000}
body{scrollbar-face-color: #ffffff; scrollbar-shadow-color: #ffffff;
scrollbar-highlight-color:#B387A8; scrollbar-3dlight-color:
#ffffff; scrollbar-darkshadow-color: #B387A8;
scrollbar-track-color: #ffffff; scrollbar-arrow-color: #B387A8}
-->
</STYLE>
<body TOPMARGIN=0 LEFTMARGIN=0 MARGINHEIGHT=0 MARGINWIDTH=0 bgcolor="#B387A8">
<br><br><br>
<center>
<script language="javascript">
//<!--
function popup()
{ window.open ("http://members.cox.net/dream4muse/main.html","popup","width=800,height=500,
location=0,menubar=0,resizable=0,scrollbars=0,status=0,titlebar=1,toolbar=0") }
-->
</script>
<a href="javascript:popup()"><img src="rosebkgrnd1btitle.jpg" border=0 alt="Enter"></a>
<br>

<? if ($blocked != "")
{
  echo("--->");
}
?>
</BODY>
</HTML>
  1. <?
  2. $ip = "$REMOTE_ADDR";
  3. $block[0] = "67.163.182.222";
  4. foreach ($block as $b)
  5. {
  6.   if ($b == $ip)
  7.   {
  8.     $blocked = 1;
  9.   }
  10. }
  11. ?>
  12. <HTML>
  13. <BODY>
  14. <? if ($blocked != "")
  15. {
  16.   echo ("<!---");
  17. }
  18. ?>
  19. <style>
  20. <!--
  21. a:link {text-decoration:bold; color:#FFFFFF}
  22. a:visited {text-decoration:italic; color:#FFFFFF}
  23. a:active {text-decoration:none; color:#FFFFFF}a:hover {text-decoration:none; color:#000000}
  24. body{scrollbar-face-color: #ffffff; scrollbar-shadow-color: #ffffff;
  25. scrollbar-highlight-color:#B387A8; scrollbar-3dlight-color:
  26. #ffffff; scrollbar-darkshadow-color: #B387A8;
  27. scrollbar-track-color: #ffffff; scrollbar-arrow-color: #B387A8}
  28. -->
  29. </STYLE>
  30. <body TOPMARGIN=0 LEFTMARGIN=0 MARGINHEIGHT=0 MARGINWIDTH=0 bgcolor="#B387A8">
  31. <br><br><br>
  32. <center>
  33. <script language="javascript">
  34. //<!--
  35. function popup()
  36. { window.open ("http://members.cox.net/dream4muse/main.html","popup","width=800,height=500,
  37. location=0,menubar=0,resizable=0,scrollbars=0,status=0,titlebar=1,toolbar=0") }
  38. -->
  39. </script>
  40. <a href="javascript:popup()"><img src="rosebkgrnd1btitle.jpg" border=0 alt="Enter"></a>
  41. <br>
  42. <? if ($blocked != "")
  43. {
  44.   echo("--->");
  45. }
  46. ?>
  47. </BODY>
  48. </HTML>


Ok, time to laugh at the amateur's mistakes, lol.
  • b_heyer
  • Web Master
  • Web Master
  • User avatar
  • Joined: Jun 15, 2003
  • Posts: 4583
  • Loc: Maryland
  • Status: Offline

Post July 26th, 2003, 8:42 pm

are you ever going to want to block more then one person?
Pixel Acres V2
  • Dream4Muse
  • Novice
  • Novice
  • No Avatar
  • Joined: Jul 22, 2003
  • Posts: 18
  • Status: Offline

Post July 26th, 2003, 9:59 pm

It's highly unlikely that I'll ever need/want to block more than one person.
  • b_heyer
  • Web Master
  • Web Master
  • User avatar
  • Joined: Jun 15, 2003
  • Posts: 4583
  • Loc: Maryland
  • Status: Offline

Post July 27th, 2003, 8:46 am

ok I may ahve made it too complicated then change this:
Code: [ Select ]
<?
$ip = "$REMOTE_ADDR";
$block[0] = "67.163.182.222";
foreach ($block as $b)
{
  if ($b == $ip)
  {
    $blocked = 1;
  }
}
?>
  1. <?
  2. $ip = "$REMOTE_ADDR";
  3. $block[0] = "67.163.182.222";
  4. foreach ($block as $b)
  5. {
  6.   if ($b == $ip)
  7.   {
  8.     $blocked = 1;
  9.   }
  10. }
  11. ?>

into:
Code: [ Select ]
<?
$ip = "$REMOTE_ADDR";
$block = "67.163.182.222";
if ($block == $ip)
{
  $blocked = 1;
}
?>
  1. <?
  2. $ip = "$REMOTE_ADDR";
  3. $block = "67.163.182.222";
  4. if ($block == $ip)
  5. {
  6.   $blocked = 1;
  7. }
  8. ?>
Pixel Acres V2
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post July 27th, 2003, 8:46 am

Post Information

  • Total Posts in this topic: 35 posts
  • Users browsing this forum: No registered users and 126 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.