Results 1 to 6 of 6

Thread: Script for Blocking IP Address

  1. #1
    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.

  2. #2
    Join Date
    Apr 2008
    Posts
    1,948

    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.

  3. #3
    Join Date
    May 2008
    Posts
    2,012

    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>

  4. #4
    Join Date
    Apr 2008
    Posts
    2,005

    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>

  5. #5
    Join Date
    May 2008
    Posts
    2,297

    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

  6. #6
    Join Date
    Oct 2005
    Posts
    2,393

    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();
    } ?>

Similar Threads

  1. script to get MAC address info. from DHCP
    By SalemOR97301 in forum Windows Server Help
    Replies: 3
    Last Post: 11-01-2014, 10:14 AM
  2. Replies: 6
    Last Post: 14-04-2012, 06:42 PM
  3. Replies: 3
    Last Post: 12-11-2009, 06:29 PM
  4. Ip address script
    By Catchkuber in forum Software Development
    Replies: 3
    Last Post: 24-02-2009, 09:35 PM
  5. Replies: 2
    Last Post: 14-01-2009, 01:25 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,144,149.05286 seconds with 17 queries