📄 inc_function.asp
字号:
<%
'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, ">", ">")
fString = replace(fString, "<", "<")
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), """)
else
s = Replace(s, """, 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), " ")
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, "'", "’", 1, -1, 1)
strInputEntry = Replace(strInputEntry, "script", "script", 1, -1, 0)
strInputEntry = Replace(strInputEntry, "SCRIPT", "SCRIPT", 1, -1, 0)
strInputEntry = Replace(strInputEntry, "Script", "Script", 1, -1, 0)
strInputEntry = Replace(strInputEntry, "script", "Script", 1, -1, 1)
strInputEntry = Replace(strInputEntry, "object", "object", 1, -1, 0)
strInputEntry = Replace(strInputEntry, "OBJECT", "OBJECT", 1, -1, 0)
strInputEntry = Replace(strInputEntry, "Object", "Object", 1, -1, 0)
strInputEntry = Replace(strInputEntry, "object", "Object", 1, -1, 1)
strInputEntry = Replace(strInputEntry, "applet", "applet", 1, -1, 0)
strInputEntry = Replace(strInputEntry, "APPLET", "APPLET", 1, -1, 0)
strInputEntry = Replace(strInputEntry, "Applet", "Applet", 1, -1, 0)
strInputEntry = Replace(strInputEntry, "applet", "Applet", 1, -1, 1)
strInputEntry = Replace(strInputEntry, "embed", "embed", 1, -1, 0)
strInputEntry = Replace(strInputEntry, "EMBED", "EMBED", 1, -1, 0)
strInputEntry = Replace(strInputEntry, "Embed", "Embed", 1, -1, 0)
strInputEntry = Replace(strInputEntry, "embed", "Embed", 1, -1, 1)
strInputEntry = Replace(strInputEntry, "event", "event", 1, -1, 0)
strInputEntry = Replace(strInputEntry, "EVENT", "EVENT", 1, -1, 0)
strInputEntry = Replace(strInputEntry, "Event", "Event", 1, -1, 0)
strInputEntry = Replace(strInputEntry, "event", "Event", 1, -1, 1)
strInputEntry = Replace(strInputEntry, "document", "document", 1, -1, 0)
strInputEntry = Replace(strInputEntry, "DOCUMENT", "DOCUMENT", 1, -1, 0)
strInputEntry = Replace(strInputEntry, "Document", "Document", 1, -1, 0)
strInputEntry = Replace(strInputEntry, "document", "Document", 1, -1, 1)
strInputEntry = Replace(strInputEntry, "cookie", "cookie", 1, -1, 0)
strInputEntry = Replace(strInputEntry, "COOKIE", "COOKIE", 1, -1, 0)
strInputEntry = Replace(strInputEntry, "Cookie", "Cookie", 1, -1, 0)
strInputEntry = Replace(strInputEntry, "cookie", "Cookie", 1, -1, 1)
strInputEntry = Replace(strInputEntry, "form", "form", 1, -1, 0)
strInputEntry = Replace(strInputEntry, "FORM", "FORM", 1, -1, 0)
strInputEntry = Replace(strInputEntry, "Form", "Form", 1, -1, 0)
strInputEntry = Replace(strInputEntry, "form", "Form", 1, -1, 1)
strInputEntry = Replace(strInputEntry, "iframe", "iframe", 1, -1, 0)
strInputEntry = Replace(strInputEntry, "IFRAME", "IFRAME", 1, -1, 0)
strInputEntry = Replace(strInputEntry, "Iframe", "Iframe", 1, -1, 0)
strInputEntry = Replace(strInputEntry, "iframe", "iframe", 1, -1, 1)
strInputEntry = Replace(strInputEntry, "textarea", "textarea", 1, -1, 0)
strInputEntry = Replace(strInputEntry, "TEXTAREA", "TEXTAREA", 1, -1, 0)
strInputEntry = Replace(strInputEntry, "Textarea", "Textarea", 1, -1, 0)
strInputEntry = Replace(strInputEntry, "textarea", "Textarea", 1, -1, 1)
strInputEntry = Replace(strInputEntry, "input", "Input", 1, -1, 0)
strInputEntry = Replace(strInputEntry, "Input", "Input", 1, -1, 0)
strInputEntry = Replace(strInputEntry, "INPUT", "Input", 1, -1, 0)
strInputEntry = Replace(strInputEntry, "input", "Input", 1, -1, 1)
'Reformat a few bits
strInputEntry = Replace(strInputEntry, "<STRONG>", "<strong>", 1, -1, 1)
strInputEntry = Replace(strInputEntry, "<strong>", "<strong>", 1, -1, 1)
strInputEntry = Replace(strInputEntry, "</STRONG>", "</strong>", 1, -1, 1)
strInputEntry = Replace(strInputEntry, "</strong>", "</strong>", 1, -1, 1)
strInputEntry = Replace(strInputEntry, "font", "font", 1, -1, 0)
strInputEntry = Replace(strInputEntry, "FONT", "FONT", 1, -1, 0)
strInputEntry = Replace(strInputEntry, "Font", "Font", 1, -1, 0)
strInputEntry = Replace(strInputEntry, "fOnt", "font", 1, -1, 1)
strInputEntry = Replace(strInputEntry, "font", "font", 1, -1, 1)
strInputEntry = Replace(strInputEntry, "mono", "mono", 1, -1, 0)
strInputEntry = Replace(strInputEntry, "MONO", "MONO", 1, -1, 0)
strInputEntry = Replace(strInputEntry, "MOno", "Mono", 1, -1, 0)
strInputEntry = Replace(strInputEntry, "mOno", "mono", 1, -1, 1)
strInputEntry = Replace(strInputEntry, "mono", "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, "<", "<")
strInputEntry = Replace(strInputEntry, ">", ">")
strInputEntry = Replace(strInputEntry, """", "", 1, -1, 1)
strInputEntry = Replace(strInputEntry, "=", "=", 1, -1, 1)
strInputEntry = Replace(strInputEntry, "'", "''", 1, -1, 1)
strInputEntry = Replace(strInputEntry, "select", "select", 1, -1, 1)
strInputEntry = Replace(strInputEntry, "join", "join", 1, -1, 1)
strInputEntry = Replace(strInputEntry, "union", "union", 1, -1, 1)
strInputEntry = Replace(strInputEntry, "where", "where", 1, -1, 1)
strInputEntry = Replace(strInputEntry, "insert", "insert", 1, -1, 1)
strInputEntry = Replace(strInputEntry, "delete", "delete", 1, -1, 1)
strInputEntry = Replace(strInputEntry, "update", "update", 1, -1, 1)
strInputEntry = Replace(strInputEntry, "like", "like", 1, -1, 1)
strInputEntry = Replace(strInputEntry, "drop", "drop", 1, -1, 1)
strInputEntry = Replace(strInputEntry, "create", "create", 1, -1, 1)
strInputEntry = Replace(strInputEntry, "modify", "modify", 1, -1, 1)
strInputEntry = Replace(strInputEntry, "rename", "rename", 1, -1, 1)
strInputEntry = Replace(strInputEntry, "alter", "alter", 1, -1, 1)
strInputEntry = Replace(strInputEntry, "cast", "cast", 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 + -