📄 function.asp
字号:
else
strTemp="<option value='" & rsClass("ClassID") & "'"
end if
else
strTemp="<option value='" & rsClass("ClassID") & "'"
end if
if CurrentID>0 and rsClass("ClassID")=CurrentID then
strTemp=strTemp & " selected"
end if
strTemp=strTemp & ">"
if tmpDepth>0 then
for i=1 to tmpDepth
strTemp=strTemp & " "
if i=tmpDepth then
if rsClass("NextID")>0 then
strTemp=strTemp & "├ "
else
strTemp=strTemp & "└ "
end if
else
if arrShowLine(i)=True then
strTemp=strTemp & "│"
else
strTemp=strTemp & " "
end if
end if
next
end if
strTemp=strTemp & rsClass("ClassName")
strTemp=strTemp & "</option>"
response.write strTemp
rsClass.movenext
loop
end if
rsClass.close
set rsClass=nothing
end sub
'**************************************************
'软件下载无限分类
'**************************************************
sub SoftClass_Option(ShowType,CurrentID)
if ShowType=0 then
response.write "<option value='0'"
if CurrentID=0 then response.write " selected"
response.write ">无(作为一级下载分类)</option>"
end if
dim rsClass,sqlClass,strTemp,tmpDepth,i
dim arrShowLine(20)
for i=0 to ubound(arrShowLine)
arrShowLine(i)=False
next
sqlClass="Select * From SoftClass order by RootID,OrderID"'RootID根栏目ID,OrderID排序ID
set rsClass=oConn.execute(sqlClass)
if rsClass.bof and rsClass.eof then
response.write "<option value=''>请先添加栏目</option>"
else
do while not rsClass.eof
tmpDepth=rsClass("Depth")'Depth栏目层数
if rsClass("NextID")>0 then'NextID同级的下一个栏目ID
arrShowLine(tmpDepth)=True
else
arrShowLine(tmpDepth)=False
end if
if ShowType=1 then
strTemp="<option value='" & rsClass("ClassID") & "'"
elseif ShowType=2 then
strTemp="<option value='" & rsClass("ClassID") & "'"
elseif ShowType=3 then
if rsClass("Child")>0 then
strTemp="<option value=''"
else
strTemp="<option value='" & rsClass("ClassID") & "'"
end if
elseif ShowType=4 then
if rsClass("Child")>0 then'Child子栏目数
strTemp="<option value=''"
else
strTemp="<option value='" & rsClass("ClassID") & "'"
end if
else
strTemp="<option value='" & rsClass("ClassID") & "'"
end if
if CurrentID>0 and rsClass("ClassID")=CurrentID then
strTemp=strTemp & " selected"
end if
strTemp=strTemp & ">"
if tmpDepth>0 then
for i=1 to tmpDepth
strTemp=strTemp & " "
if i=tmpDepth then
if rsClass("NextID")>0 then
strTemp=strTemp & "├ "
else
strTemp=strTemp & "└ "
end if
else
if arrShowLine(i)=True then
strTemp=strTemp & "│"
else
strTemp=strTemp & " "
end if
end if
next
end if
strTemp=strTemp & rsClass("ClassName")
strTemp=strTemp & "</option>"
response.write strTemp
rsClass.movenext
loop
end if
rsClass.close
set rsClass=nothing
end sub
'**************************************************
'函数名:ReplaceBadChar
'作 用:过滤非法的SQL字符
'参 数:strChar-----要过滤的字符
'返回值:过滤后的字符
'**************************************************
function ReplaceBadChar(strChar)
if strChar="" then
ReplaceBadChar=""
else
ReplaceBadChar=replace(replace(replace(replace(replace(replace(replace(strChar,"'",""),"*",""),"?",""),"(",""),")",""),"<",""),".","")
end if
end function
'**************************************************
'函数名:gotTopic
'作 用:截字符串,汉字一个算两个字符,英文算一个字符
'参 数:str ----原字符串
' strlen ----截取长度
'返回值:截取后的字符串
'**************************************************
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
'**************************************************
'函数名:IsValidEmail
'作 用:检查Email地址合法性
'参 数: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
'------------------检查某一目录是否存在-------------------
Function CheckDir(FolderPath)
dim fso
folderpath=Server.MapPath(".")&"\"&folderpath
Set fso1 = Server.CreateObject("Scripting.FileSystemObject")
If fso.FolderExists(FolderPath) then
'存在
CheckDir = True
Else
'不存在
CheckDir = False
End if
Set fso = nothing
End Function
'-------------根据指定名称生成目录---------
Function MakeNewsDir(foldername)
dim fso,f
Set fso = Server.CreateObject("Scripting.FileSystemObject")
Set f = fso.CreateFolder(foldername)
MakeNewsDir = True
Set fso = nothing
End Function
'**************************************************
'函数名:SendMail
'作 用:用Jmail组件发送邮件
'参 数:MailtoAddress ----收信人地址
' MailtoName -----收信人姓名
' Subject -----主题
' MailBody -----信件内容
' FromName -----发信人姓名
' MailFrom -----发信人地址
' Priority -----信件优先级
'**************************************************
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>没有安装JMail组件</li>"
err.clear
exit function
end if
JMail.Charset="gb2312" '邮件编码
JMail.silent=true
JMail.ContentType = "text/html" '邮件正文格式
'JMail.ServerAddress=nt2003.Site_Setting(18) '用来发送邮件的SMTP服务器
'如果服务器需要SMTP身份验证则还需指定以下参数
JMail.MailServerUserName = nt2003.Site_Setting(19) '登录用户名
JMail.MailServerPassWord = nt2003.Site_Setting(20) '登录密码
JMail.MailDomain = nt2003.Site_Setting(21) '域名(如果用“name@domain.com”这样的用户名登录时,请指明domain.com
JMail.AddRecipient MailtoAddress,MailtoName '收信人
JMail.Subject=Subject '主题
JMail.HMTLBody=MailBody '邮件正文(HTML格式)
JMail.Body=MailBody '邮件正文(纯文本格式)
JMail.FromName=FromName '发信人姓名
JMail.From = MailFrom '发信人Email
JMail.Priority=Priority '邮件等级,1为加急,3为普通,5为低级
JMail.Send(nt2003.site_setting(18))
SendMail =JMail.ErrorMessage
JMail.Close
Set JMail=nothing
end function
%>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -