禁止几个网通的IP访问我的网站

来源:百度知道 编辑:UC知道 时间:2024/05/26 08:34:51
网站是ASP的,空间的控制面版里没有禁止IP的功能
在网上查了一段代码,放在index.asp后不好用,如下:
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
netscape = (navigator.appName.indexOf("Netscape") != -1);
version4 = (navigator.appVersion.indexOf("4.") != -1);

if (netscape && version4) {
ip = "" + java.net.InetAddress.getLocalHost().getHostAddress();
if (ip.indexOf("235.12") >= -1)
// 这是想要禁止访问的IP例如: 235.12.xxx.xxx

{
alert("You are not permitted to access this site.");
history.go(-1);
}
}
// End -->
</script>
那位朋友帮忙解决一下,先谢了!
这个办法不行
如何用数据库+asp?

<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
if (window.location.host) {
if (window.location.host.indexOf("235.12.") >= -1)
// 这是想要禁止访问的IP例如: 235.12.xxx.xxx
{
alert("You are not permitted to access this site.");
history.go(-1);
}
}
// End -->
</script>
用这种方法其实不安全的,禁用javascript就可以进去了。最好是用数据库+asp。
用asp+access就可以实现了呀。要是你不会的话加我qq也可以。