?? function.asp
字號(hào):
<%
'*************************************************
'函數(shù)名:gotTopic
'作 用:截字符串,漢字一個(gè)算兩個(gè)字符,英文算一個(gè)字符
'參 數(shù):str ----原字符串
' strlen ----截取長(zhǎng)度
'返回值:截取后的字符串
'*************************************************
function gotTopic(str,strlen)
if str="" then
gotTopic=""
exit function
end if
dim l,t,c, i
str=replace(replace(replace(replace(str," "," "),""",chr(34)),">",">"),"<","<")
l=len(str)
t=0
for i=1 to l
c=Abs(Asc(Mid(str,i,1)))
if c>255 then
t=t+2
else
t=t+1
end if
if t>=strlen then
gotTopic=left(str,i) & "…"
exit for
else
gotTopic=str
end if
next
gotTopic=replace(replace(replace(replace(gotTopic," "," "),chr(34),"""),">",">"),"<","<")
end function
'***********************************************
'函數(shù)名:JoinChar
'作 用:向地址中加入 ? 或 &
'參 數(shù):strUrl ----網(wǎng)址
'返回值:加了 ? 或 & 的網(wǎng)址
'***********************************************
function JoinChar(strUrl)
if strUrl="" then
JoinChar=""
exit function
end if
if InStr(strUrl,"?")<len(strUrl) then
if InStr(strUrl,"?")>1 then
if InStr(strUrl,"&")<len(strUrl) then
JoinChar=strUrl & "&"
else
JoinChar=strUrl
end if
else
JoinChar=strUrl & "?"
end if
else
JoinChar=strUrl
end if
end function
'***********************************************
'過(guò)程名:showpage
'作 用:顯示“上一頁(yè) 下一頁(yè)”等信息
'參 數(shù):sfilename ----鏈接地址
' totalnumber ----總數(shù)量
' maxperpage ----每頁(yè)數(shù)量
' ShowTotal ----是否顯示總數(shù)量
' ShowAllPages ---是否用下拉列表顯示所有頁(yè)面以供跳轉(zhuǎn)。有某些頁(yè)面不能使用,否則會(huì)出現(xiàn)JS錯(cuò)誤。
' strUnit ----計(jì)數(shù)單位
'***********************************************
sub showpage(sfilename,totalnumber,maxperpage,ShowTotal,ShowAllPages,strUnit)
dim n, i,strTemp,strUrl
if totalnumber mod maxperpage=0 then
n= totalnumber \ maxperpage
else
n= totalnumber \ maxperpage+1
end if
strTemp= "<table align='center'><form name='showpages' method='Post' action='" & sfilename & "'><tr><td>"
if ShowTotal=true then
strTemp=strTemp & "共 <b>" & totalnumber & "</b> " & strUnit & " "
end if
strUrl=JoinChar(sfilename)
if CurrentPage<2 then
strTemp=strTemp & "首頁(yè) 上一頁(yè) "
else
strTemp=strTemp & "<a href='" & strUrl & "page=1'>首頁(yè)</a> "
strTemp=strTemp & "<a href='" & strUrl & "page=" & (CurrentPage-1) & "'>上一頁(yè)</a> "
end if
if n-currentpage<1 then
strTemp=strTemp & "下一頁(yè) 尾頁(yè)"
else
strTemp=strTemp & "<a href='" & strUrl & "page=" & (CurrentPage+1) & "'>下一頁(yè)</a> "
strTemp=strTemp & "<a href='" & strUrl & "page=" & n & "'>尾頁(yè)</a>"
end if
strTemp=strTemp & " 頁(yè)次:<strong><font color=red>" & CurrentPage & "</font>/" & n & "</strong>頁(yè) "
strTemp=strTemp & " <b>" & maxperpage & "</b>" & strUnit & "/頁(yè)"
if ShowAllPages=True then
strTemp=strTemp & " 轉(zhuǎn)到:<select name='page' size='1' onchange='javascript:submit()'>"
for i = 1 to n
strTemp=strTemp & "<option value='" & i & "'"
if cint(CurrentPage)=cint(i) then strTemp=strTemp & " selected "
strTemp=strTemp & ">第" & i & "頁(yè)</option>"
next
strTemp=strTemp & "</select>"
end if
strTemp=strTemp & "</td></tr></form></table>"
response.write strTemp
end sub
'********************************************
'函數(shù)名:IsValidEmail
'作 用:檢查Email地址合法性
'參 數(shù):email ----要檢查的Email地址
'返回值:True ----Email地址合法
' False ----Email地址不合法
'********************************************
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
'***************************************************
'函數(shù)名:IsObjInstalled
'作 用:檢查組件是否已經(jīng)安裝
'參 數(shù):strClassString ----組件名
'返回值:True ----已經(jīng)安裝
' False ----沒(méi)有安裝
'***************************************************
Function IsObjInstalled(strClassString)
On Error Resume Next
IsObjInstalled = False
Err = 0
Dim xTestObj
Set xTestObj = Server.CreateObject(strClassString)
If 0 = Err Then IsObjInstalled = True
Set xTestObj = Nothing
Err = 0
End Function
'**************************************************
'函數(shù)名:strLength
'作 用:求字符串長(zhǎng)度。漢字算兩個(gè)字符,英文算一個(gè)字符。
'參 數(shù):str ----要求長(zhǎng)度的字符串
'返回值:字符串長(zhǎng)度
'**************************************************
function strLength(str)
ON ERROR RESUME NEXT
dim WINNT_CHINESE
WINNT_CHINESE = (len("中國(guó)")=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
'**************************************************
'函數(shù)名:SendMail
'作 用:用Jmail組件發(fā)送郵件
'參 數(shù):MailtoAddress ----收信人地址
' MailtoName -----收信人姓名
' Subject -----主題
' MailBody -----信件內(nèi)容
' FromName -----發(fā)信人姓名
' MailFrom -----發(fā)信人地址
' Priority -----信件優(yōu)先級(jí)
'**************************************************
function SendMail(MailtoAddress,MailtoName,Subject,MailBody,FromName,MailFrom,Priority)
on error resume next
Dim JMail
Set JMail=Server.CreateObject("JMAIL.Message")
if err then
SendMail= "<br><li>沒(méi)有安裝JMail組件</li>"
err.clear
exit function
end if
JMail.Charset="gb2312" '郵件編碼
JMail.silent=true
JMail.ContentType = "text/html" '郵件正文格式
JMail.ServerAddress=MailServer '用來(lái)發(fā)送郵件的SMTP服務(wù)器
'如果服務(wù)器需要SMTP身份驗(yàn)證則還需指定以下參數(shù)
JMail.MailServerUserName = MailServerUserName '登錄用戶(hù)名
JMail.MailServerPassWord = MailServerPassword '登錄密碼
JMail.MailDomain = MailDomain '域名(如果用“name@domain.com”這樣的用戶(hù)名登錄時(shí),請(qǐng)指明domain.com
JMail.AddRecipient MailtoAddress,MailtoName '收信人
JMail.Subject=Subject '主題
JMail.HMTLBody=MailBody '郵件正文(HTML格式)
JMail.Body=MailBody '郵件正文(純文本格式)
JMail.FromName=FromName '發(fā)信人姓名
JMail.From = MailFrom '發(fā)信人Email
JMail.Priority=Priority '郵件等級(jí),1為加急,3為普通,5為低級(jí)
JMail.Send(MailServer)
SendMail =JMail.ErrorMessage
JMail.Close
Set JMail=nothing
end function
'****************************************************
'過(guò)程名:WriteErrMsg
'作 用:顯示錯(cuò)誤提示信息
'參 數(shù):無(wú)
'****************************************************
sub WriteErrMsg()
dim strErr
strErr=strErr & "<html><head><title>錯(cuò)誤信息</title><meta http-equiv='Content-Type' content='text/html; charset=gb2312'>" & vbcrlf
strErr=strErr & "<link href='style.css' rel='stylesheet' type='text/css'></head><body>" & vbcrlf
strErr=strErr & "<table cellpadding=2 cellspacing=2 border=0 width=400 class='border' align=center>" & vbcrlf
strErr=strErr & " <tr align='center'><td height='20' class='title'><strong>錯(cuò)誤信息</strong></td></tr>" & vbcrlf
strErr=strErr & " <tr><td height='100' class='tdbg' valign='top'><b>產(chǎn)生錯(cuò)誤的可能原因:</b><br>" & errmsg &"</td></tr>" & vbcrlf
strErr=strErr & " <tr align='center'><td class='title'><a href='javascript:history.go(-1)'><< 返回上一頁(yè)</a></td></tr>" & vbcrlf
strErr=strErr & "</table>" & vbcrlf
strErr=strErr & "</body></html>" & vbcrlf
response.write strErr
end sub
'****************************************************
'過(guò)程名:WriteSuccessMsg
'作 用:顯示成功提示信息
'參 數(shù):無(wú)
'****************************************************
sub WriteSuccessMsg(SuccessMsg)
dim strSuccess
strSuccess=strSuccess & "<html><head><title>成功信息</title><meta http-equiv='Content-Type' content='text/html; charset=gb2312'>" & vbcrlf
strSuccess=strSuccess & "<link href='style.css' rel='stylesheet' type='text/css'></head><body>" & vbcrlf
strSuccess=strSuccess & "<table cellpadding=2 cellspacing=2 border=0 width=400 class='border' align=center>" & vbcrlf
strSuccess=strSuccess & " <tr align='center'><td height='20' class='title'><strong>恭喜你!</strong></td></tr>" & vbcrlf
strSuccess=strSuccess & " <tr><td height='100' class='tdbg' valign='top'><br>" & SuccessMsg &"</td></tr>" & vbcrlf
strSuccess=strSuccess & " <tr align='center'><td class='title'><a href='javascript:history.back()'>【返 回】</a></td></tr>" & vbcrlf
strSuccess=strSuccess & "</table>" & vbcrlf
strSuccess=strSuccess & "</body></html>" & vbcrlf
response.write strSuccess
end sub
%>
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -