|
|
< >'获取用户真实IP函数<BR>Function GetIP()<BR> GetIP = Request.ServerVariables("HTTP_X_FORWARDED_FOR")<BR> If GetIP = "" Then GetIP = Request.ServerVariables("REMOTE_ADDR")<BR>End Function</P>
< ><BR>'获取完整地址栏地址<BR>Function GetUrl()<BR> GetUrl="<a href='http://"&Request.ServerVariables("SERVER_N' target="_blank" >http://"&Request.ServerVariables("SERVER_N</A> ... .ServerVariables("URL")<BR> If Request.ServerVariables("QUERY_STRING")<>"" Then GetURL=GetUrl&"?"& Request.ServerVariables("QUERY_STRING")<BR>End Function</P>
< >'获取本页文件名<BR>Function SelfName()<BR> SelfName = Mid(Request.ServerVariables("URL"),InstrRev(Request.ServerVariables("URL"),"/")+1)<BR>End Function</P>
< >'获取文件后缀名<BR>Function GetExt(filename)<BR> GetExt = Mid(filename,InstrRev(filename,".")+1)<BR>End Function</P>
< ><BR>'求字符串长度函数<BR>Function GetLength(str)<BR> Dim i,length<BR> For i = 1 to Len(str)<BR> If Asc(Mid(str,i,1))<0 or Asc(Mid(str,i,1))>256 Then<BR> length = length+2<BR> Else<BR> length = length+1<BR> End If<BR> Next<BR> GetLength = length<BR>End Function</P>
< >'过滤不良字符<BR>Function ChkBadWords(fString)<BR> Dim BadWords,bwords,i<BR> BadWords = "我操|操你|操他|你妈的|他妈的|狗|杂种|屄|屌|王八|强奸|做爱|处女|泽民|***|法伦|洪志|法輪"<BR> If Not(IsNull(BadWords) or IsNull(fString)) Then<BR> bwords = Split(BadWords, "|")<BR> For i = 0 to UBound(bwords)<BR> fString = Replace(fString, bwords(i), string(Len(bwords(i)),"*"))<BR> Next<BR> ChkBadWords = fString<BR> End If<BR>End Function</P>
< ><BR>'防止外部提交<BR>Function ChkPost()<BR> Dim URL1,URL2<BR> ChkPost = False<BR> URL1 = Cstr(Request.ServerVariables("HTTP_REFERER"))<BR> URL2 = Cstr(Request.ServerVariables("SERVER_NAME"))<BR> If Mid(URL1,8,Len(URL2))<>URL2 Then<BR> ChkPost = False<BR> Else<BR> ChkPost = True<BR> End If<BR>End Function</P>
< ><BR>'过滤HTML字符函数,这个和我发的转义处理基本一样的。可以参考那个!<BR>Function HTMLEncode(fString)<BR>If Not IsNull(fString) And fString <> "" Then<BR> fString = Replace(fString, ">", "&gt;")<BR> fString = Replace(fString, "<", "&lt;")<BR> fString = Replace(fString, Chr(32), "&nbsp;")<BR> fString = Replace(fString, Chr(9), "&nbsp;&nbsp;")<BR> fString = Replace(fString, Chr(34), "&quot;")<BR> fString = Replace(fString, Chr(39), "&#39;")<BR> fString = Replace(fString, Chr(13), "")<BR> fString = Replace(fString, Chr(10) & Chr(10), "</P>< >")<BR> fString = Replace(fString, Chr(10), "<BR>")<BR> fString = Replace(fString, Chr(255), "&nbsp;")<BR> HTMLEncode = fString<BR>End If<BR>End Function</P>
< ><BR>'清除HTML标记<BR>Function stripHTML(strHTML)<BR> Dim objRegExp,strOutput<BR> Set objRegExp = New Regexp<BR> objRegExp.IgnoreCase = True<BR> objRegExp.Global = True<BR> objRegExp.Pattern = "<.+?>"<BR> strOutput = objRegExp.Replace(strHTML,"")<BR> strOutput = Replace(strOutput, "<","&lt;")<BR> strOutput = Replace(strOutput, ">","&gt;")<BR> stripHTML = strOutput<BR> Set objRegExp = Nothing<BR>End Function</P> |
|