文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>asp限制IP访问的代码

asp限制IP访问的代码

时间:2010-04-17  来源:mx11

<%
if request.servervariables("remote_addr")<>"127.0.0.1" then
response.write "你的程序没有注册,只能在本地调试,<a href=#>注册</a>"
response.end
end if
%>
<!-
-说明,,可以用request.servervariables("remote_host")服务器端IP是否等于...
或者SERVER_NAME等判断域名,然后看是否一个域名,来限制程序只能一个域名使用
-->
PHP
<?
if($HTTP_SERVER_VARS["REMOTE_ADDR"]!="127.0.0.1"){
echo "你的程序没有注册,只能在本地调试,<a href=#>注册</a>";
exit;
}
?>

asp源码如下:

<%if Request.ServerVariables("SERVER_NAME")="www.vocan.net " then
response.redirect "a/index.asp"
else%>
<%end if%>
<%if Request.ServerVariables("SERVER_NAME")="www.kuroo.net " then
response.redirect "b/index.asp"
else%>
<%end if%>
<%if Request.ServerVariables("SERVER_NAME")="www.c.com " then
response.redirect "c/index.asp"
else%>
使用server.transfer (url) 替代redirect可以提高效率。

<script>  
function   Getdomain(){  
<!--  
DocURL   =   document.URL;  
   
protocolIndex=DocURL.indexOf("://",4);  
   
serverIndex=DocURL.indexOf("/",protocolIndex   +   3);  
   
BeginURL=DocURL.indexOf("#",1)   +   1;  
   
displayresult=DocURL.substring(protocolIndex   +   3   ,serverIndex);  
   
if   (displayresult=="www.a.com")  
{  
      document.write("www.a.com");  
}  
                    else   if   (displayresult=="www.b.com")  
                    {  
                        document.write("www.b.com");  
                    }  
                    else   if   (displayresult=="www.c.com")  
                    {  
                        document.write("www.c.com");  
                    }  
}  
Getdomain();  
//-->  
</script>

相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载