用ASP实现在特定的时段或对特定访问者开放

在某些情况下,你有可能想要将自己的主页或某一页面只在特定的时段下开放,或者只对特定的访问者开放,这时利用ASP技术可以轻松搞定。不信???且听我一一到来。
首先,将你要限制的页面另存为*.asp,注意千万要将所有联接此页面文件超级联接的URL改为"http://..../*.asp"。
然后,在文件的开头加入以下代码,注意要在

1<html>标记之前。   

@ language=Vbscript

response.buffer=true
if time &lt; #8:00:00# and time &gt; #23:00:00# then

1Sorry!开放时间为上午8:00至晚上11:00。   
2Click <a href="http://location">here</a> to home page!   

response.end
else
response.clear
end if

1<html>   
2.....   
3如果你只想让特定的访问者访问,可将if语句改为如下:   
4if not request.ServerVariables("REMOTE_HOST")="特定的访问者的主机名" then或if not request.ServerVariables("REMOTE_ADDR")="特定的访问者的主机IP地址" then最后,存盘,上传(废话!)。如此你的主页就具有了开放的限制条件,什么???你主页存放的服务器不支持ASP技术,我强烈建议你换一个支持ASP的窝。</html></html>
Published At
Categories with Web编程
Tagged with
comments powered by Disqus