<%
'//过滤非法的SQL字符
Function ReplaceBadChar(strChar)
    If strChar = "" Or IsNull(strChar) Then
        ReplaceBadChar = ""
        Exit Function
    End If
    Dim strBadChar, arrBadChar, tempChar, i
    strBadChar = "+,',--,%,^,&,?,(,),<,>,[,],{,},/,\,;,:," & Chr(34) & "," & Chr(0) & ""
    arrBadChar = Split(strBadChar, ",")
    tempChar = strChar
    For i = 0 To UBound(arrBadChar)
        tempChar = Replace(tempChar, arrBadChar(i), "")
    Next
    tempChar = Replace(tempChar, "@@", "@")
    ReplaceBadChar = tempChar
End Function

'//检测是否外部提交数据
Function Chk_Post()
	Dim Server_V1,Server_V2		
	Server_V1=Cstr(Request.ServerVariables("HTTP_REFERER"))
	Server_V2=Cstr(Request.ServerVariables("SERVER_NAME"))		
	If Mid(Server_V1,8,Len(Server_V2))<>Server_V2 Then
		response.redirect "default.asp"
		response.End 
	End If 
End Function

'//检测是否频繁操作
Function Chk_Time(KeepTime)
	If session("KEEP_TIME")="" Then  
		session("KEEP_TIME")=Now
	Else  
		If DateDiff("s",session("KEEP_TIME"),Now)<=KEEP_TIME Then  
			response.write "<script type='text/javascript'>alert('请勿频繁操作');history.go(-1);</script>"
			response.End
		End If
		session("KEEP_TIME")=Now 
	End If
	session.timeout=KeepTime
End Function

'//获取来访用户IP
Function GetIP()
	Dim Ip,Tmp
	Dim i,IsErr
	IsErr=False
	Ip=Request.ServerVariables("REMOTE_ADDR")
	If Len(Ip)<=0 Then Ip=Request.ServerVariables("HTTP_X_ForWARDED_For")		
	If Len(Ip)>15 Then 
		IsErr=True
	Else
		Tmp=Split(Ip,".")
		If Ubound(Tmp)=3 Then 
			For i=0 To Ubound(Tmp)
				If Len(Tmp(i))>3 Then IsErr=True
			Next
		Else
			IsErr=True
		End If
	End If
	If IsErr Then 
		GetIP="1.1.1.1"
	Else
		GetIP=Ip
	End If
End Function

'//检测敏感字符串(以,号隔开);返回:True(含有敏感词)/False
Function BadWord(str,BadWordList)
	BadWord=False
	Dim arrBadWord
		arrBadWord=Split(BadWordList,",",-1,1)
	Dim regEx
	Set regEx=New RegExp
	regEx.IgnoreCase = True   
	regEx.Global = True
	Dim Match
	Dim I
	For I=0 To UBound(arrBadWord)
		If arrBadWord(I)<>"" Then
			regEx.Pattern=arrBadWord(I)
			Set Match=regEx.Execute(str)
			If Match.Count Then
				BadWord=True
				Exit For
			End If
		End If
	Next
End Function

'//分页
Function PageBar(pages,page)
	If page>1 Then
		response.write "<a href=""?page=1"">1</a>..."		
	Else
		response.write "<strong>1</strong>..."
	End If
	Dim p,pp,n,i
		p=page-5
		pp=pages-1
		If p<2 Then p=2          
	For n=p To pp
		i=i+1            
		If n=page Then
			response.write "<strong>"&n&"</strong> "
		Else
			response.write " <a href=""?page="&n&""">"&n&"</a> " 
		End If       
		If i>=11 Then Exit For             
	Next
	If page<pages Then
		response.write "...<a href=""?page="&pages&""">"&pages&"</a>"	
	Else 		
		response.write "...<strong>"&pages&"</strong>"
	End If
End Function
%>