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

📄 inc_function.asp

📁 Computer SHOP+DATABASE
💻 ASP
📖 第 1 页 / 共 2 页
字号:
<%
'Ham kiem tra dau nhay don
Function CheckString(s,endChar)    
	pos=InStr(s,"'")
	While pos>0
		s=Mid(s,1,pos)&"'"&Mid(s,pos+1)
		pos=InStr(pos+2,s,"'")
	Wend
	CheckString="'"&s&"'"&endChar
End Function

Function CheckBool(s,endChar)    
	CheckBool=s&endChar
End Function
'-----------------------------------------------------------------
Function CheckSQL(fString)
	fString = replace(fString, ">", "&gt;")
	fString = replace(fString, "<", "&lt;")
	fString = trim(fString)
	fString = Replace(fString, "'", "''")
	CheckSQL = fString
End Function
'-----------------------------------------------------------------
'Ham them cap dau nhay kep bao noi dung chuoi s
Function QuoteStr(s)
	If isNull(s) Then
		QuoteStr=Chr(34)&Chr(34)
	else
		QuoteStr=Chr(34)&CStr(s)&Chr(34)
	End if
End Function
'-----------------------------------------------------------------
Function Check2Quote(s,typefun)
	on Error resume next
	if typefun="encode" then
	s = Replace(s, CHR(34), "&quot;")
	else
	s = Replace(s, "&quot;", CHR(34))
	End if
	Check2Quote=s
End Function
'-----------------------------------------------------------------
'Ham giu nguyen cac gia tri xuong dong
function FormatStr(fString)        
	on Error resume next
	fString = Replace(fString, CHR(13), "")
	fString = Replace(fString, CHR(10) & CHR(10), "</P><P>")
	fString = Replace(fString, CHR(10), "<BR>")
'	fString = Replace(fString, CHR(32), "&nbsp;")
	FormatStr = fString
end function
'-----------------------------------------------------------------
Function GetValue(TableName,NameField,condition)
	GetValue=""
	if isNull(condition) or condition="" then condition="true"
	sql = "SELECT " & NameField & " FROM " & TableName & " WHERE " & condition
	On Error Resume Next
		rsF.Open sql, Conn
		If not rsF.EOF and not rsF.BOF Then GetValue=rsF(Namefield) End If
		rsF.Close
	On Error Goto 0
End Function
'---------------------------------------------------------------
function FormatNum(num)
If num<>"" then
	num=CStr(num)	
	lenStr=Len(num)
	if lenStr=9 then
		num=Left(num,3)&"."&mid(num,3,3)&"."&Right(num,3)
	elseif lenStr>6 and lenStr<9 then
		num=Left(num,lenStr-6)&"."&mid(num,lenStr-6,3)&"."&Right(num,3)
	elseif lenStr=6 then
		num=Left(num,3)&"."&Right(num,3)
	elseif lenStr>3 and lenStr<6 then
		num=Left(num,lenStr-3)&"."&Right(num,3)
	else 'nothing
	End if
End if
	FormatNum=num
end Function
'-----------------------------------------------------------------
Function FormatMoneyStr(numstr)
	numstr=CStr(numstr)
	numstr=Replace(numstr,",",".")
	FormatMoneyStr=numstr
end Function
'-----------------------------------------------------------------
'Ham cat bo khoang trang o dau va cuoi chuoi
Function ConvertNull(varTemp) 
	If IsNull(varTemp) then
		ConvertNull=""
	Else
		ConvertNull=Trim(varTemp)
	End if
End function
'-----------------------------------------------------------------
'Ham kiem tra xem lieu chuoi co phai la mot URL hay ko
'tra lai gia tri neu phai, nguoc lai tra ve gia tri false
Function IsURL(varTemp)
	IsURL=True
	If UCase(Left(Trim(varTemp),6))="HTTP:/" then Exit Function
	If UCase(Left(Trim(varTemp),6))="FILE:/" then Exit Function
	If UCase(Left(Trim(varTemp),8))="MAILTO:/" then Exit Function
	If UCase(Left(Trim(varTemp),5))="FTP:/" then Exit Function
	If UCase(Left(Trim(varTemp),8))="GOPHER:/" then Exit Function
	If UCase(Left(Trim(varTemp),6))="NEWS:/" then Exit Function
	If UCase(Left(Trim(varTemp),7))="HTTPS:/" then Exit Function
	If UCase(Left(Trim(varTemp),8))="TELNET:/" then Exit Function
	If UCase(Left(Trim(varTemp),6))="NNTP:/" then Exit Function
	IsURL=False
End Function
'-----------------------------------------------------------------
Function changeColor(strValue)
	changColor="<Font color=#660033>"&strValue&"</Font>"	
End Function
'-----------------------------------------------------------------
Private Function formatInput(ByVal strInputEntry)

	'Get rid of malicous code in the message
	strInputEntry = Replace(strInputEntry, "'", "&#146;", 1, -1, 1)
	strInputEntry = Replace(strInputEntry, "script", "&#115;cript", 1, -1, 0)
	strInputEntry = Replace(strInputEntry, "SCRIPT", "&#083;CRIPT", 1, -1, 0)
	strInputEntry = Replace(strInputEntry, "Script", "&#083;cript", 1, -1, 0)
	strInputEntry = Replace(strInputEntry, "script", "&#083;cript", 1, -1, 1)
	strInputEntry = Replace(strInputEntry, "object", "&#111;bject", 1, -1, 0)
	strInputEntry = Replace(strInputEntry, "OBJECT", "&#079;BJECT", 1, -1, 0)
	strInputEntry = Replace(strInputEntry, "Object", "&#079;bject", 1, -1, 0)
	strInputEntry = Replace(strInputEntry, "object", "&#079;bject", 1, -1, 1)
	strInputEntry = Replace(strInputEntry, "applet", "&#097;pplet", 1, -1, 0)
	strInputEntry = Replace(strInputEntry, "APPLET", "&#065;PPLET", 1, -1, 0)
	strInputEntry = Replace(strInputEntry, "Applet", "&#065;pplet", 1, -1, 0)
	strInputEntry = Replace(strInputEntry, "applet", "&#065;pplet", 1, -1, 1)
	strInputEntry = Replace(strInputEntry, "embed", "&#101;mbed", 1, -1, 0)
	strInputEntry = Replace(strInputEntry, "EMBED", "&#069;MBED", 1, -1, 0)
	strInputEntry = Replace(strInputEntry, "Embed", "&#069;mbed", 1, -1, 0)
	strInputEntry = Replace(strInputEntry, "embed", "&#069;mbed", 1, -1, 1)
	strInputEntry = Replace(strInputEntry, "event", "&#101;vent", 1, -1, 0)
	strInputEntry = Replace(strInputEntry, "EVENT", "&#069;VENT", 1, -1, 0)
	strInputEntry = Replace(strInputEntry, "Event", "&#069;vent", 1, -1, 0)
	strInputEntry = Replace(strInputEntry, "event", "&#069;vent", 1, -1, 1)
	strInputEntry = Replace(strInputEntry, "document", "&#100;ocument", 1, -1, 0)
	strInputEntry = Replace(strInputEntry, "DOCUMENT", "&#068;OCUMENT", 1, -1, 0)
	strInputEntry = Replace(strInputEntry, "Document", "&#068;ocument", 1, -1, 0)
	strInputEntry = Replace(strInputEntry, "document", "&#068;ocument", 1, -1, 1)
	strInputEntry = Replace(strInputEntry, "cookie", "&#099;ookie", 1, -1, 0)
	strInputEntry = Replace(strInputEntry, "COOKIE", "&#067;OOKIE", 1, -1, 0)
	strInputEntry = Replace(strInputEntry, "Cookie", "&#067;ookie", 1, -1, 0)
	strInputEntry = Replace(strInputEntry, "cookie", "&#067;ookie", 1, -1, 1)
	strInputEntry = Replace(strInputEntry, "form", "&#102;orm", 1, -1, 0)
	strInputEntry = Replace(strInputEntry, "FORM", "&#070;ORM", 1, -1, 0)
	strInputEntry = Replace(strInputEntry, "Form", "&#070;orm", 1, -1, 0)
	strInputEntry = Replace(strInputEntry, "form", "&#070;orm", 1, -1, 1)
	strInputEntry = Replace(strInputEntry, "iframe", "i&#102;rame", 1, -1, 0)
	strInputEntry = Replace(strInputEntry, "IFRAME", "I&#070;RAME", 1, -1, 0)
	strInputEntry = Replace(strInputEntry, "Iframe", "I&#102;rame", 1, -1, 0)
	strInputEntry = Replace(strInputEntry, "iframe", "i&#102;rame", 1, -1, 1)
	strInputEntry = Replace(strInputEntry, "textarea", "&#116;extarea", 1, -1, 0)
	strInputEntry = Replace(strInputEntry, "TEXTAREA", "&#84;EXTAREA", 1, -1, 0)
	strInputEntry = Replace(strInputEntry, "Textarea", "&#84;extarea", 1, -1, 0)
	strInputEntry = Replace(strInputEntry, "textarea", "&#84;extarea", 1, -1, 1)
	strInputEntry = Replace(strInputEntry, "input", "&#073;nput", 1, -1, 0)
	strInputEntry = Replace(strInputEntry, "Input", "&#073;nput", 1, -1, 0)
	strInputEntry = Replace(strInputEntry, "INPUT", "&#073;nput", 1, -1, 0)
	strInputEntry = Replace(strInputEntry, "input", "&#073;nput", 1, -1, 1)

	'Reformat a few bits
	strInputEntry = Replace(strInputEntry, "<STR&#079;NG>", "<strong>", 1, -1, 1)
	strInputEntry = Replace(strInputEntry, "<str&#111;ng>", "<strong>", 1, -1, 1)
	strInputEntry = Replace(strInputEntry, "</STR&#079;NG>", "</strong>", 1, -1, 1)
	strInputEntry = Replace(strInputEntry, "</str&#111;ng>", "</strong>", 1, -1, 1)
	strInputEntry = Replace(strInputEntry, "f&#111;nt", "font", 1, -1, 0)
	strInputEntry = Replace(strInputEntry, "F&#079;NT", "FONT", 1, -1, 0)
	strInputEntry = Replace(strInputEntry, "F&#111;nt", "Font", 1, -1, 0)
	strInputEntry = Replace(strInputEntry, "f&#079;nt", "font", 1, -1, 1)
	strInputEntry = Replace(strInputEntry, "f&#111;nt", "font", 1, -1, 1)
	strInputEntry = Replace(strInputEntry, "m&#111;no", "mono", 1, -1, 0)
	strInputEntry = Replace(strInputEntry, "M&#079;NO", "MONO", 1, -1, 0)
	strInputEntry = Replace(strInputEntry, "M&#079;no", "Mono", 1, -1, 0)
	strInputEntry = Replace(strInputEntry, "m&#079;no", "mono", 1, -1, 1)
	strInputEntry = Replace(strInputEntry, "m&#111;no", "mono", 1, -1, 1)

	'Return
	formatInput = strInputEntry
End Function

'********************************************
'*** 		 Format SQL input	*****
'********************************************

'Format SQL Query funtion
Private Function formatSQLInput(ByVal strInputEntry)

	If strInputEntry=Null then
		formatSQLInput = ""
	Else
	'Remove malisous charcters from links and images
	strInputEntry = Replace(strInputEntry, "<", "&lt;")
	strInputEntry = Replace(strInputEntry, ">", "&gt;")
	strInputEntry = Replace(strInputEntry, """", "", 1, -1, 1)
	strInputEntry = Replace(strInputEntry, "=", "&#061;", 1, -1, 1)
	strInputEntry = Replace(strInputEntry, "'", "''", 1, -1, 1)
	strInputEntry = Replace(strInputEntry, "select", "sel&#101;ct", 1, -1, 1)
	strInputEntry = Replace(strInputEntry, "join", "jo&#105;n", 1, -1, 1)
	strInputEntry = Replace(strInputEntry, "union", "un&#105;on", 1, -1, 1)
	strInputEntry = Replace(strInputEntry, "where", "wh&#101;re", 1, -1, 1)
	strInputEntry = Replace(strInputEntry, "insert", "ins&#101;rt", 1, -1, 1)
	strInputEntry = Replace(strInputEntry, "delete", "del&#101;te", 1, -1, 1)
	strInputEntry = Replace(strInputEntry, "update", "up&#100;ate", 1, -1, 1)
	strInputEntry = Replace(strInputEntry, "like", "lik&#101;", 1, -1, 1)
	strInputEntry = Replace(strInputEntry, "drop", "dro&#112;", 1, -1, 1)
	strInputEntry = Replace(strInputEntry, "create", "cr&#101;ate", 1, -1, 1)
	strInputEntry = Replace(strInputEntry, "modify", "mod&#105;fy", 1, -1, 1)
	strInputEntry = Replace(strInputEntry, "rename", "ren&#097;me", 1, -1, 1)
	strInputEntry = Replace(strInputEntry, "alter", "alt&#101;r", 1, -1, 1)
	strInputEntry = Replace(strInputEntry, "cast", "ca&#115;t", 1, -1, 1)
	strInputEntry = Replace(strInputEntry, "form", "", 1, -1, 1)

	'Return
	formatSQLInput = strInputEntry
	End if
End Function

function filterChar(ByVal strInputEntry)
	strInputEntry = Replace(strInputEntry, "(", " ", 1, -1, 1)
	strInputEntry = Replace(strInputEntry, ")", " ", 1, -1, 1)
	strInputEntry = Replace(strInputEntry, "*", " ", 1, -1, 1)
	strInputEntry = Replace(strInputEntry, ":", " ", 1, -1, 1)
	strInputEntry = Replace(strInputEntry, "+", " ", 1, -1, 1)
	strInputEntry = Replace(strInputEntry, "=", " ", 1, -1, 1)
	strInputEntry = Replace(strInputEntry, "-", " ", 1, -1, 1)
	strInputEntry = Replace(strInputEntry, "/", " ", 1, -1, 1)
	strInputEntry = Replace(strInputEntry, "\", " ", 1, -1, 1)

⌨️ 快捷键说明

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