⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 function.asp

📁 于毕业设计与论文以及做课题用-MSK Simulink simulation program for the design and graduation thesis topic, and makin
💻 ASP
字号:
<%
dim CheckString
CheckString="script,iframe,object,Script,IFrame,Object"
'//过滤非法的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

'//字符串是否在[0-9]中(不区分大小写)
Function IsIntChar(str)
	IsIntChar=True
	Dim regEx,Match
	Set regEx=New RegExp
		regEx.Pattern="\D{1,}?"
		regEx.IgnoreCase=True
	Set Match=regEx.Execute(str)
	If Match.Count>=1 Then
		IsIntChar=False
	End If
End Function

'//转换Html关键标签为Html特殊字符串
Function HTMLEncode(str)
	If Not Isnull(str) Then
		str = Replace(str, CHR(13), "")
		str = Replace(str, CHR(10) & CHR(10), "<P></P>")
		str = Replace(str, CHR(10), "<BR>")
		str = replace(str, ">", "&gt;")
		str = replace(str, "<", "&lt;")
		str = replace(str, "&",    "&amp;")
		str = replace(str, " ",    "&nbsp;")
		str = replace(str, """", "&quot;")
		HTMLEncode = str
	End If
End Function

'//截取指定长度字符串
Function CutStr(str,strlen)
	dim l,t,c,m_i
	l=len(str)
	t=0
	for m_i=1 to l
		c=Abs(Asc(Mid(str,m_i,1)))    
		if c>255 then
			t=t+2
		else
			t=t+1
		end if    
		if t>=strlen then
			CutStr=left(str,m_i)&"..."
			exit for
		else
			CutStr=str
		end if
	next
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.write "你的操作已被记录!"
		response.End 
	End If 
End Function

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

'//获取来访用户IP
Function GetIP()
	Dim HX33_WishIP,Tmp
	Dim i,IsErr
	IsErr=False
	HX33_WishIP=Request.ServerVariables("REMOTE_ADDR")
	If Len(HX33_WishIP)<=0 Then Ip=Request.ServerVariables("HTTP_X_ForWARDED_For")		
	If Len(HX33_WishIP)>15 Then 
		IsErr=True
	Else
		Tmp=Split(HX33_WishIP,".")
		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=HX33_WishIP
	End If
End Function

'//检测是否含有禁止字符串(以,号隔开);返回:True(含有违禁字符)/False
'//例:BadWord("你他妈的王八蛋,Fuck You","fuck you,王八蛋,you are pig")
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 lFilterBadHTML(strHTML,strTAGs)
Dim objRegExp,strOutput
  Dim arrTAG,i
  arrTAG=Split(strTAGs,",")
  Set objRegExp = New Regexp
  strOutput=strHTML
  objRegExp.IgnoreCase = True
  objRegExp.Global = True
  For i=0 to UBound(arrTAG)
    objRegExp.Pattern = "<"&arrTAG(i)&"[\s\S]+</"&arrTAG(i)&"*>"
	strOutput = objRegExp.Replace(strOutput,"")
  Next
  Set objRegExp = Nothing
  lFilterBadHTML = strOutput
End Function

%>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -