?? function.asp
字號:
<%
Class NetCom_Char
' 過濾HTML代碼
Public Function HTMLEncode(fString)
If not isnull(fString) Then
fString = replace(fString, ">", ">")
fString = replace(fString, "<", "<")
fString = Replace(fString, CHR(32), " ")
fString = Replace(fString, CHR(9), " ")
fString = Replace(fString, CHR(34), """)
fString = Replace(fString, CHR(39), "'")
fString = Replace(fString, CHR(13), "")
fString = Replace(fString, CHR(10) & CHR(10), "</P><P> ")
fString = Replace(fString, CHR(10), "<BR> ")
HTMLEncode = fString
End If
End Function
' 過濾表單字符
Public Function HTMLcode(fString)
If not isnull(fString) Then
fString = Replace(fString, CHR(13), "")
fString = Replace(fString, CHR(10) & CHR(10), "</P><P>")
fString = Replace(fString, CHR(10), "<BR>")
HTMLcode = fString
End If
End Function
' 過濾SQL非法字符
Public Function checkStr(str)
If isnull(str) Then
checkStr = ""
Exit Function
End If
checkStr=replace(str,"'","''")
End Function
' 限定數字0-9
Public Function isInt(str)
Dim L,I
isInt=False
If Trim(Str)="" Or IsNull(str) Then Exit Function
str=CStr(Trim(str))
L=Len(Str)
For I=1 To L
If Mid(Str,I,1)>"9" Or Mid(Str,I,1)<"0" Then Exit Function
Next
isInt=True
End Function
' 高亮顯示關鍵字
Public Function ShowBold(str,key)
Dim objRegExp
Set objRegExp= New RegExp
objRegExp.Pattern="("&key&")"
objRegExp.IgnoreCase=True
objRegExp.Global=True
ShowBold=objRegExp.Replace(str,"<font style=""BACKGROUND-COLOR: #ffff00"" color=""#FF0000""><b>$1</b></font>")
End Function
' 過濾字符
Public Function ChkBadWords(BadWords,fString)
Dim bwords,ii
If not(isnull(BadWords) or isnull(fString)) Then
bwords = split(BadWords, "|")
For ii = 0 to ubound(bwords)
fString = Replace(fString, bwords(ii), string(len(bwords(ii)),"*"))
Next
ChkBadWords = fString
End If
End Function
' 截短字符
Public Function CutStr(Str,LenNum)
Dim P_num
Dim I,X
If strLength(Str)<=LenNum Then
Cutstr=Str
Else
P_num=0
X=0
Do While Not P_num > LenNum-2
X=X+1
If Asc(Mid(Str,X,1))<0 Then
P_num=Int(P_num) + 2
Else
P_num=Int(P_num) + 1
End If
Cutstr=Left(Trim(Str),X)&"..."
Loop
End If
End Function
'二級聯動
Public Function CataLog(intClassID,intNClassID)
Dim Result,i
Result="<script language=""JavaScript"">"&vbcrlf
SQL="SELECT Classid,Classname,Flag FROM [Class] WHERE Flag<>0"
Result=Result&"var NCid="&intNClassID&";"&vbcrlf
Set Rs=Conn.Execute(SQL)
If Not (Rs.EOF Or Rs.BOF) Then
i=-1
Do Until Rs.EOF
i=i+1
Result=Result&"arrNList["&i&"] = """&Rs(2)&""""&vbcrlf
i=i+1
Result=Result&"arrNList["&i&"] = """&Rs(1)&""""&vbcrlf
i=i+1
Result=Result&"arrNList["&i&"] = """&Rs(0)&""""&vbcrlf
Rs.MoveNext
Loop
End If
Set Rs=Nothing
Result=Result&"</script>"
Result=Result&"<select onChange=""Kermy_JS('setDynaList(arrNSet)')"" name=""ACid"" id=""ACid"">"&vbcrlf
SQL="SELECT Classid,Classname FROM [Class] WHERE Flag=0"
Set Rs=Conn.Execute(SQL)
If Not (Rs.EOF Or Rs.BOF) Then
Do Until Rs.EOF
If intClassID=Rs(0) Then
Result=Result&"<option value="&Rs(0)&" selected>"&Rs(1)&"</option>"&vbcrlf
Else
Result=Result&"<option value="&Rs(0)&">"&Rs(1)&"</option>"&vbcrlf
End If
Rs.MoveNext
Loop
Else
Result=Result&"<option value=0>暫無任何主類</option>"
End If
Set Rs=Nothing
Result=Result&"</select>"&vbcrlf
Result=Result&"<select name=""NCid"" id=""NCid""></select>"
CataLog=Result
End Function
' 判斷發言是否來自外部
Public Function ChkPost()
Dim server_v1,server_v2
chkpost=False
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
chkpost=False
Else
chkpost=True
End If
End Function
' 分頁函數
Public Function ShowPage(ByRef PageCount,RecordCount,CurrentPage,PageSize,LinkFile)
Dim Retval,J,StartPage,EndPage,Page
If (RecordCount Mod PageSize)=0 Then
PageCount=RecordCount \ PageSize
Else
PageCount=RecordCount \ PageSize+1
End If
If PageCount=0 Then PageCount=1
If CurrentPage="" Then CurrentPage=1 else CurrentPage=CInt(CurrentPage)
Retval=Retval & "<table width='100%' border='0' cellspacing='0' cellpadding='0'>"
Retval=Retval & "<tr>"
Retval=Retval & "<td height='20'>"
If CurrentPage=1 Then
Retval=Retval & "<img src='Images/Home.gif' width='47' height='15' align='absbottom'><img src='Images/Last.gif' width='57' height='15' align='absbottom'>"
Else
Retval=Retval & "<a href='" & LinkFile & "Page=1'><img src='Images/Home.gif' width='47' height='15' border='0' align='absbottom'></a><a href='" & LinkFile & "Page=" & CurrentPage - 1 & "'><img src='Images/Last.gif' width='57' height='15' border='0' align='absbottom'></a>"
End If
If CurrentPage=PageCount Then
Retval=Retval & "<img src='Images/next.gif' width='57' height='15' align='absbottom'><img src='Images/End.gif' width='47' height='15' align='absbottom'>"
Else
Retval=Retval & "<a href='" & LinkFile & "Page=" & CurrentPage + 1 & "'><img src='Images/next.gif' width='57' height='15' border='0' align='absbottom'></a><a href='" & LinkFile & "Page=" & PageCount & "'><img src='Images/End.gif' width='47' height='15' border='0' align='absbottom'></a>"
End if
If RecordCount>0 Then
Retval=Retval & " <font color=#CECECE>["&CurrentPage&"/"&CInt(PageCount)&"]</font>"
End If
Retval=Retval & "<td align='right'>"
StartPage = Page-3
EndPage = Page+3
If StartPage<=0 Then
StartPage=1
ElseIf StartPage>1 Then
Retval=Retval & " <a href='" & LinkFile & "Page=1' style='font-family:webdings' title='首頁' class='SoftMeun'>9</a>"
Retval=Retval & " ... "
End If
If EndPage>PageCount Then EndPage=PageCount
For J = StartPage to EndPage
If J = Page Then
Retval = Retval & " <font color=#999999>[" & J & "]</font>"
Else
Retval = Retval & " <a href='" & LinkFile & "Page=" & J & "' class='SoftMeun'>[" & J & "]</a>"
End If
Next
If EndPage < PageCount Then Retval= Retval & " ... <a href='" & LinkFile & "Page=" & PageCount & "' style='font-family:webdings' title='末頁' class='SoftMeun'>:</a>"
Retval=Retval & "</td>"
Retval=Retval & "</tr>"
Retval=Retval & "</table>"
ShowPage=Retval
End Function
' 檢查Email地址是否正確
Public Function IsValidEmail(email)
Dim names, name, i, c
IsValidEmail = True
names = Split(email, "@")
if UBound(names) <> 1 then
IsValidEmail = False
Exit Function
end if
for each name in names
if Len(name) <= 0 then
IsValidEmail = False
Exit Function
end if
for i = 1 to Len(name)
c = Lcase(Mid(name, i, 1))
if InStr("abcdefghijklmnopqrstuvwxyz_-.", c) <= 0 and not IsNumeric(c) then
IsValidEmail = False
Exit Function
end if
next
if Left(name, 1) = "." or Right(name, 1) = "." then
IsValidEmail = False
Exit Function
end if
next
if InStr(names(1), ".") <= 0 then
IsValidEmail = False
Exit Function
end if
i = Len(names(1)) - InStrRev(names(1), ".")
if i <> 2 and i <> 3 then
IsValidEmail = False
Exit Function
end if
if InStr(email, "..") > 0 then
IsValidEmail = False
end if
End Function
' 計算字符長度
Public Function strLength(str)
ON ERROR RESUME NEXT
dim WINNT_CHINESE
WINNT_CHINESE = (len("jstu")=2)
if WINNT_CHINESE then
dim l,t,c
dim i
l=len(str)
t=l
for i=1 to l
c=asc(mid(str,i,1))
if c<0 then c=c+65536
if c>255 then
t=t+1
end if
next
strLength=t
else
strLength=len(str)
end if
if err.number<>0 then err.clear
End Function
'格式化數字
Public Function FormatNum(Num)
If Len(Num)=1 Then
FormatNum="0"&Num
Else
FormatNum=Num
End If
End Function
End Class
%>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -