Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read SiteMap

Tags: , , , , ,

Sponsored Links



Script for Blocking IP Address

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 30-12-2009
Member
 
Join Date: Jan 2009
Posts: 74
Script for Blocking IP Address

Hello, I am new in the programming language and wanted to know that can it be possible to block any kind of IP address with the help of any type of script such as Java script or php script or any other. If you know how to write script which will block the IP address as per your requirement. Please give me coding or suggestions regarding the script.
Reply With Quote
  #2  
Old 30-12-2009
Praetor's Avatar
Member
 
Join Date: Apr 2008
Posts: 1,937
Re: Script for Blocking IP Address

You need to first create an array which will give you the IP address which you want to block. Then you will require the IP address of all the visitors of your site. Then just check that array with your recent visitor and for all those block IP address you can provide error page. This will solve your problem. I don't know the coding, but you can make use of this and create your own script.
Reply With Quote
  #3  
Old 30-12-2009
Member
 
Join Date: May 2008
Posts: 1,990
Re: Script for Blocking IP Address

The script below will block the IP address, by redirecting them to another website.
Code:
<script type="text/javascript">
var BannIP=["12.12.12.12", "45.45.45.45"]
var IPadd = '<!--#echo var="REMOTE_ADDR"-->'
var hIP=BannIP.join("|")
hIP=new RegExp(hIP, "i")
if (IPadd.search(hIP)!=-1)
{ 
alert("Your IP has been banned from this site. Redirecting...")
window.location.replace("<website address>")
}
</script>
Reply With Quote
  #4  
Old 30-12-2009
kelfro's Avatar
Member
 
Join Date: Apr 2008
Posts: 1,976
Re: Script for Blocking IP Address

If you want to block someones IP address then you need to use the script below:

Code:
<script language="javascript">
var IPAdd = '<!--#echo var="REMOTE_ADDR"-->'
if (IPAdd == '196.12.15.28') 
{ 
alert("You are not allowed to use this page. ");
if (confirm("Do you want to leave this site"))
{
location.href="<site name>" 
} 
else 
{ 
{
location.href="<site name>" 
}
}
} 
</script>
Reply With Quote
  #5  
Old 30-12-2009
Zecho's Avatar
Member
 
Join Date: May 2008
Posts: 2,267
Re: Script for Blocking IP Address

I don't have any idea about the coding of IP blocker script, but for blocking IP address you can make use of following different script applications:
  1. Antiadbuster Pro 1.00
  2. IPBlocker Lite 1.3
  3. Star Rating System PRO 2.3
  4. Color Picker 1
  5. Perl IP blocker 1.0
  6. PHP IP blocker
  7. AlstraSoft FlyAds Pro 1.02
Reply With Quote
  #6  
Old 30-12-2009
Reegan's Avatar
Member
 
Join Date: Oct 2005
Posts: 2,299
Re: Script for Blocking IP Address

For blocking IP address on your website you need to use the php script below:
Code:
<?php
$deny = array("11.11.11.12", "45.65.98.85", "78.65.98.56");
if (in_array ($_SERVER['REMOTE_ADDR'], $deny)) {
   header("location: <website name to redirect/");
   exit();
} ?>
Reply With Quote
Reply

  TechArena Community > Software > Software Development


Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Script for Blocking IP Address"
Thread Thread Starter Forum Replies Last Post
How to find how many Ids’ I have blocked by blocking an IP address? Damodaran-G Technology & Internet 4 13-07-2011 09:01 AM
What is script Blocking in Antivirus program Victorious mind AntiVirus Software 4 03-02-2011 12:02 PM
Ip address script Catchkuber Software Development 3 24-02-2009 09:35 PM
script to get MAC address info. from DHCP SalemOR97301 Windows Server Help 1 17-09-2008 02:37 AM
netsh script to hard-code IP address Spin Windows Server Help 2 11-05-2008 06:41 PM


All times are GMT +5.5. The time now is 12:12 PM.