1. Read remote url.
var url ='<!--#echo var="REMOTE_HOST"-->';
2. Enter list of additional url
var additional_url = ["http://www.abc.com"];
3. Create a regular expression string.
var handleurl = additional_url.join("|");
handleurl = new RegExp(handleurl, "i");
4. Check condition whether remote url is in list
if (url.search(handleurl)!=-1)
alert("done")
else
alert("Unauthorized access");
Showing posts with label javascript. Show all posts
Showing posts with label javascript. Show all posts
Saturday, January 17, 2009
Validate user IP address using javascript
1. Read user IP address.
var ip = '<!--#echo var="REMOTE_ADDR"-->'
2. Enter list of allowed ips
var allowed_ips = ["11.11.11.11","22.22.22.22"]
3. Create a regular expression string.
var handleips = allowed_ips.join("|")
handleips = new RegExp(handleips, "i")
4. Check condition whether user IP address is in allowed list
if (ip.search(handleips)!=-1)
alert("done")
else
alert("Unauthorized access");
var ip = '<!--#echo var="REMOTE_ADDR"-->'
2. Enter list of allowed ips
var allowed_ips = ["11.11.11.11","22.22.22.22"]
3. Create a regular expression string.
var handleips = allowed_ips.join("|")
handleips = new RegExp(handleips, "i")
4. Check condition whether user IP address is in allowed list
if (ip.search(handleips)!=-1)
alert("done")
else
alert("Unauthorized access");
Subscribe to:
Posts (Atom)