Forum Moderators: open
I have an open access members based site that is being frequented by a couple of users that abuse the site, and would like to block their access using javasript. I have found a method to accomplish this, but it only allows for an exact IP match, and they are on dynamic ISP's, so I would like to modify my script to block an IP range.
Below is the script I have. How can I modify it to suit my goal?
Thanks!
Chris C.
******************************
<script language="javascript">
var ip = <!--#echo var="REMOTE_ADDR"-->
if (ip <= '24.55.255.255') {
alert("STOP! You are not authorized to access this page!");
alert("Do not attempt to return, or your computer will begin a self-destruct sequence!");
if (confirm("Please leave now Or you will be forceably removed!"))
{location.href="http://www.google.com" } else { ("OK your choice, doesn't matter to me! SeeYa!"); {location.href="http://www.getalife.com" }} }
</script>
*******************************
You can always look at the substrings of any string with javascript, and test them instead of the entire string.
But it's so simple for a user to turn off javascript that this approach is not likely to block your abusers. And if you have any well-behaved users on the same IP range, you'll just alienate them and still have your problem. You really need a server-side solution.
A site search here (top of page) on "block IP address" will return lots of info - mostly in the server-side forums on WebmasterWorld.
[edited by: Key_Master at 5:44 pm (utc) on June 14, 2003]
Thanks to Key_master for providing an answer to my question, and thanks to tedster for the advice.
I have looked at .htacess usage, but my host does not allow that function. (again, a free hosted site) The biggest challenge I have is that both of the offenders have dynamic IP's, so I am at a loss to create a method to block their individual access, without potentially affecting others within their IP block range.
Chris C.