View Mode: Normal | Article List

得到客户端IP的code

[ 2004-09-08 18:27:52 | Author: zhenhua ]
得到IP地址的方法是<%=Request.ServerVariables("REMOTE_ADDR")%>,如果客户使用的代理服务器,这样就得到了代理服务器的IP,下面是得到真实IP的代码:
function GetIp()
dim realip,proxy
realip = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
proxy = Request.ServerVariables("REMOTE_ADDR")
if realip = "" then
GetIp = proxy
else
GetIp = realip
end if
end function


限制某段IP地址
限制某段IP地址访问网页的一个列子:
function IP2Num(sip)
dim str1,str2,str3,str4
dim num
IP2Num=0
if isnumeric(left(sip,2)) then
str1=left(sip,instr(sip,".")-1)
sip=mid(sip,instr(sip,".")+1)
...

Read More...

ASP/PHP实现主机头多域名转向的方法

[ 2004-09-08 18:24:22 | Author: zhenhua ]
ASP:
1.使用CASE语句,缺点:同一域名即@和www需要两次循环,代码显重复
<%
host=lcase(request.servervariables("HTTP_HOST"))
select CASE host
CASE "www.abc.com"
 response.redirect "index.htm"
CASE "abc.com"
 response.redirect "index.htm"

CASE ELSE
 response.redirect "other.htm"
END select
%>
--------------------------
<%if instr(Request.ServerVariables
("SERVER_NAME"),"kekexi.com")>0 then
response.redirect "index.asp"
else if instr(Request.ServerVariables
("SERVER_NAME"),"4668.com")>0 then
response.redirect "x/index.asp"
...

Read More...