<p>取得IP地址<br /> *******************************************************************<br /> Function Userip()<br /> Dim GetClientIP<br /> 如果客户端用了代理服务器,则应该用ServerVariables(&quot;HTTP_X_FORWARDED_FOR&quot;)方法<br /> GetClientIP = Request.ServerVariables(&quot;HTTP_X_FORWARDED_FOR&quot;)<br /> If GetClientIP = &quot;&quot; or isnull(GetClientIP) or isempty(GetClientIP) Then<br /> 如果客户端没用代理,应该用Request.ServerVariables(&quot;REMOTE_ADDR&quot;)方法<br /> GetClientIP = Request.ServerVariables(&quot;REMOTE_ADDR&quot;)<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,&quot;.&quot;)-1))<br /> tip=mid(tip,cint(instr(tip,&quot;.&quot;)+1))<br /> sip2=left(tip,cint(instr(tip,&quot;.&quot;)-1))<br /> tip=mid(tip,cint(instr(tip,&quot;.&quot;)+1))<br /> sip3=left(tip,cint(instr(tip,&quot;.&quot;)-1))<br /> sip4=mid(tip,cint(instr(tip,&quot;.&quot;)+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,&quot;&quot;,&quot;\&quot;)<br /> Response.Write (&quot;<script>alert(" & message & ")</script>&quot;)<br /> End Sub<br /> <br /> *******************************************************************<br /> 返回上一页,一般用在判断信息提交是否完全之后<br /> *******************************************************************<br /> Sub GoBack()<br /> Response.write (&quot;<script>history.go(-1)</script>&quot;)<br /> End Sub<br /> <br /> *******************************************************************<br /> 重定向另外的连接<br /> *******************************************************************<br /> Sub Go(url)<br /> Response.write (&quot;<script>location.href(" & url & ")</script>&quot;)<br /> End Sub<br /> *******************************************************************<br /> 我比较喜欢将以上三个结合起来使用<br /> *******************************************************************<br /> Function Alert(message,gourl)<br /> message = replace(message,&quot;&quot;,&quot;\&quot;)<br /> If gourl=&quot;-1&quot; then<br /> Response.Write (&quot;<script language=javascript>alert(" & message & ");history.go(-1)</script>&quot;)<br /> Else<br /> Response.Write (&quot;<script language=javascript>alert(" & message & ");location=" & gourl &"</script>&quot;)<br /> End If<br /> Response.End()<br /> End Function<br /> *******************************************************************<br /> 指定秒数重定向另外的连接<br /> *******************************************************************<br /> sub GoPage(url,s)<br /> s=s*1000<br /> Response.Write &quot;<SCRIPT LANGUAGE=JavaScript>"<br /> Response.Write "window.setTimeout("&chr(34)&"window.navigate("&url&")"&chr(34)&","&s&")"<br /> Response.Write "</script>&quot;<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)=&quot;&quot; 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)&gt;&quot;9&quot; or mid(str,i,1)&lt;&quot;0&quot; then<br /> isInteger=false<br /> exit function<br /> end if<br /> next<br /> isInteger=true<br /> if err.number&lt;&gt;0 then err.clear<br /> end function<br /> <br /> *******************************************************************<br /> 获得文件扩展名<br /> *******************************************************************<br /> function GetExtend(filename)<br /> dim tmp<br /> if filename&lt;&gt;&quot;&quot; then<br /> tmp=mid(filename,instrrev(filename,&quot;.&quot;)+1,len(filename)-instrrev(filename,&quot;.&quot;))<br /> tmp=LCase(tmp)<br /> if instr(1,tmp,&quot;asp&quot;)&gt;0 or instr(1,tmp,&quot;php&quot;)&gt;0 or instr(1,tmp,&quot;php3&quot;)&gt;0 or instr(1,tmp,&quot;aspx&quot;)&gt;0 then<br /> getextend=&quot;txt&quot;<br /> else<br /> getextend=tmp<br /> end if<br /> else<br /> getextend=&quot;&quot;<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))&gt;0 or instr(1,str,chr(34))&gt;0 or instr(1,str,chr(59))&gt;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, &quot;&gt;&quot;, &quot;&gt;&quot;)<br /> fString = replace(fString, &quot;&lt;&quot;, &quot;&lt;&quot;)<br /> <br /> fString = Replace(fString, CHR(32), &quot;&quot;)<br /> fString = Replace(fString, CHR(9), &quot;&quot;)<br /> fString = Replace(fString, CHR(34), &quot;&quot;&quot;)<br /> fString = Replace(fString, CHR(39), &quot;&#39;&quot;)<br /> fString = Replace(fString, CHR(13), &quot;&quot;)<br /> fString = Replace(fString, CHR(10) &amp; CHR(10), &quot;</p> <p></p> <p>&quot;)<br /> fString = Replace(fString, CHR(10), &quot;<br /> &quot;)<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), &quot;&quot;)<br /> fString = Replace(fString, CHR(10) &amp; CHR(10), &quot;</p> <p>&quot;)<br /> fString = Replace(fString, CHR(34), &quot;&quot;)<br /> fString = Replace(fString, CHR(10), &quot;<br /> &quot;)<br /> HTMLcode = fString<br /> end if<br /> end function</p>
返回顶部 留言