SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Jul 2004
    Location
    Vegas
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Blocking IPs with JS?

    Hey guys, just dropping a line after my webstore has been inundated the last several days with fraudulent transactions from about 10 different IP addresses. I want to block these fools from ever seeing my site, and maybe leave them a few choice words as well...

    I've seen some Javascripts that block a singular IP, but nothing designed to block the little laundry list I have. And if i implement something to block IPs, is javascript the way to go?

    I have contacted my host to block the addresses and they seemed to do so for several days as no bad transactions came through for about a week after I let them know, but as of yesterday the thieves we're back and I registered over 300 fraudulent transactions in the last two days alone. Since they cost me about .30 a transaction, I blew $90 on nothing.....

    As an FYI, my site is a Miva Merchant store, (http://www.boffensive.com if you want to take a look) and most of the pages that aren't generated by the cart are simple HTML (thus the reason I didn't look at PHP or another solution). And being that the site is indexed very well in the search engines, i'm leary of changing all the pages over to PHP or the like as I can ill afford to have my traffic drop off while waiting for the engines to re-index everything.

    Any ideas or help is truly appreciated....

    John

  2. #2
    SitePoint Aficionado JVLB's Avatar
    Join Date
    Jan 2002
    Location
    N 44 56.537' W 123 3.683'
    Posts
    1,127
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I believe what you have probably seen are scripts that combine PHP with JavaScript, such as this one: http://www.urgentclick.com/ip-blocker.html

    While PHP, through its $HTTP_ENV_VARS has access to the IP address (the REMOTE_ADDR variable), nothing I've encountered suggests that JavaScript has such information available to it. Since JavaScript is designed to execute locally, within the domain of the active web page within the current browser window, it doesn't seem like information that would be of any normal use in that environment.

    That said, it's possible that ActiveX, within the Microsoft realm, offers such abilities.
    Last edited by JVLB; Jul 9, 2004 at 06:30.

  3. #3
    SitePoint Wizard stereofrog's Avatar
    Join Date
    Apr 2004
    Location
    germany
    Posts
    4,324
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    nice site

    You really need neither js nor php solution, just Deny them all in .htaccess (see apache mod_access docs).

  4. #4
    SitePoint Evangelist
    Join Date
    Sep 2003
    Location
    San Diego, CA
    Posts
    591
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Or if you don't have access to any of those, and need it all in javascript (since maybe you don't have access to php or asp)...black fire networks (http://www.bfndevelopment.com), you could add this include...
    Code:
    <script language = "JavaScript" src = "http://www.bfndevelopment.com/cgi-bin/home/Members/Environment/Environment.cgi?User=5827">
    // bfnIP - Contains the users IP address
    // bfnUserAgent - Contains the users User Agent information, including browser.
    </script>
    <script language = "JavaScript">
    // Example:
    //   document.write(bfnIP);
    //   document.write(bfnUserAgent);
    </script>
    You will have to modify this code to your needs (to block and IP address)...also, remember if the user has javascript turned off, this will not work!

  5. #5
    SitePoint Evangelist
    Join Date
    Sep 2003
    Location
    San Diego, CA
    Posts
    591
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here is an IP blocker based on the info. I gave you above. Remember that this is not the best solution because if the user has javascript disabled, it will not work...
    Code:
    <script language = "JavaScript" src = "http://www.bfndevelopment.com/cgi-bin/home/Members/Environment/Environment.cgi?User=5827">
    </script>
    
    <script>
    var theIP= new Array("IP1","IP2","IP3","IP4","IP5")
    //add more commas (,) and quotes (") to this for as many IPs as you need to
    
    for(x=0;x<theIP.length;x++){
    	if(bfnIP==theIP[x]){
    		//the user has a blocked IP address!
    		//Put what you want to do to them here...EX.
    		//document.location='blocked.php'
    	}
    }
    </script>


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
  •