<p>取得IP地址<br />
*******************************************************************<br />
Function Userip()<br />
Dim GetClientIP<br />
如果客户端用了代理服务器,则应该用ServerVariables("HTTP_X_FORWARDED_FOR")方法<br />
GetClientIP = Request.ServerVariables("HTTP_X_FORWARDED_FOR")<br />
If GetClientIP = "" or isnull(GetClientIP) or isempty(GetClientIP) Then<br />
如果客户端没用代理,应该用Request.ServerVariables("REMOTE_ADDR")方法<br />
GetClientIP = Request.ServerVariables("REMOTE_ADDR")<br />
end if<br />
Userip = GetClientIP<br />
End function<br />
<br />
*******************************************************************<br />
转换IP地址<br />
*******************************************************************<br />
function cip(sip)<br />
tip=cstr(sip)<br />
sip1=left(tip,cint(instr(tip,".")-1))<br />
tip=mid(tip,cint(instr(tip,".")+1))<br />
sip2=left(tip,cint(instr(tip,".")-1))<br />
tip=mid(tip,cint(instr(tip,".")+1))<br />
sip3=left(tip,cint(instr(tip,".")-1))<br />
sip4=mid(tip,cint(instr(tip,".")+1))<br />
cip=cint(sip1)*256*256*256+cint(sip2)*256*256+cint(sip3)*256+cint(sip4)<br />
end function<br />
<br />
*******************************************************************<br />
弹出对话框<br />
*******************************************************************<br />
Sub alert(message)<br />
message = replace(message,"","\")<br />
Response.Write ("<script>alert(" & message & ")</script>")<br />
End Sub<br />
<br />
*******************************************************************<br />
返回上一页,一般用在判断信息提交是否完全之后<br />
*******************************************************************<br />
Sub GoBack()<br />
Response.write ("<script>history.go(-1)</script>")<br />
End Sub<br />
<br />
*******************************************************************<br />
重定向另外的连接<br />
*******************************************************************<br />
Sub Go(url)<br />
Response.write ("<script>location.href(" & url & ")</script>")<br />
End Sub<br />
*******************************************************************<br />
我比较喜欢将以上三个结合起来使用<br />
*******************************************************************<br />
Function Alert(message,gourl)<br />
message = replace(message,"","\")<br />
If gourl="-1" then<br />
Response.Write ("<script language=javascript>alert(" & message & ");history.go(-1)</script>")<br />
Else<br />
Response.Write ("<script language=javascript>alert(" & message & ");location=" & gourl &"</script>")<br />
End If<br />
Response.End()<br />
End Function<br />
*******************************************************************<br />
指定秒数重定向另外的连接<br />
*******************************************************************<br />
sub GoPage(url,s)<br />
s=s*1000<br />
Response.Write "<SCRIPT LANGUAGE=JavaScript>"<br />
Response.Write "window.setTimeout("&chr(34)&"window.navigate("&url&")"&chr(34)&","&s&")"<br />
Response.Write "</script>"<br />
end sub<br />
<br />
*******************************************************************<br />
判断数字是否整形<br />
*******************************************************************<br />
function isInteger(para)<br />
on error resume next<br />
dim str<br />
dim l,i<br />
if isNUll(para) then<br />
isInteger=false<br />
exit function<br />
end if<br />
str=cstr(para)<br />
if trim(str)="" then<br />
isInteger=false<br />
exit function<br />
end if<br />
l=len(str)<br />
for i=1 to l<br />
if mid(str,i,1)>"9" or mid(str,i,1)<"0" then<br />
isInteger=false<br />
exit function<br />
end if<br />
next<br />
isInteger=true<br />
if err.number<>0 then err.clear<br />
end function<br />
<br />
*******************************************************************<br />
获得文件扩展名<br />
*******************************************************************<br />
function GetExtend(filename)<br />
dim tmp<br />
if filename<>"" then<br />
tmp=mid(filename,instrrev(filename,".")+1,len(filename)-instrrev(filename,"."))<br />
tmp=LCase(tmp)<br />
if instr(1,tmp,"asp")>0 or instr(1,tmp,"php")>0 or instr(1,tmp,"php3")>0 or instr(1,tmp,"aspx")>0 then<br />
getextend="txt"<br />
else<br />
getextend=tmp<br />
end if<br />
else<br />
getextend=""<br />
end if<br />
end function<br />
<br />
*----------------------------------------------------------------------------<br />
* 函数:CheckIn<br />
* 描述:检测参数是否有SQL危险字符<br />
* 参数:str要检测的数据<br />
* 返回:FALSE:安全 TRUE:不安全<br />
* 作者:<br />
* 日期:<br />
*----------------------------------------------------------------------------<br />
function CheckIn(str)<br />
if instr(1,str,chr(39))>0 or instr(1,str,chr(34))>0 or instr(1,str,chr(59))>0 then<br />
CheckIn=true<br />
else<br />
CheckIn=false<br />
end if<br />
end function<br />
<br />
*----------------------------------------------------------------------------<br />
* 函数:HTMLEncode<br />
* 描述:过滤HTML代码<br />
* 参数:--<br />
* 返回:--<br />
* 作者:<br />
* 日期:<br />
*----------------------------------------------------------------------------<br />
function HTMLEncode(fString)<br />
if not isnull(fString) then<br />
fString = replace(fString, ">", ">")<br />
fString = replace(fString, "<", "<")<br />
<br />
fString = Replace(fString, CHR(32), "")<br />
fString = Replace(fString, CHR(9), "")<br />
fString = Replace(fString, CHR(34), """)<br />
fString = Replace(fString, CHR(39), "'")<br />
fString = Replace(fString, CHR(13), "")<br />
fString = Replace(fString, CHR(10) & CHR(10), "</p>
<p></p>
<p>")<br />
fString = Replace(fString, CHR(10), "<br />
")<br />
<br />
HTMLEncode = fString<br />
end if<br />
end function<br />
<br />
*----------------------------------------------------------------------------<br />
* 函数:HTMLcode<br />
* 描述:过滤表单字符<br />
* 参数:--<br />
* 返回:--<br />
* 作者:<br />
* 日期:<br />
*----------------------------------------------------------------------------<br />
function HTMLcode(fString)<br />
if not isnull(fString) then<br />
fString = Replace(fString, CHR(13), "")<br />
fString = Replace(fString, CHR(10) & CHR(10), "</p>
<p>")<br />
fString = Replace(fString, CHR(34), "")<br />
fString = Replace(fString, CHR(10), "<br />
")<br />
HTMLcode = fString<br />
end if<br />
end function</p>