ASP过滤SQL非法字符并格式化html
作者:wang 日期:2009-10-13
'Jmail邮件发送
Function SendJmail(Email,Topic,MailBody)
Dim JMail
on error resume next
Set JMail = Server.CreateObject("JMail.SMTPMail")
JMail.LazySend = true
JMail.silent = true
JMail.Charset = "gb2312"
JMail.ContentType = "text/html"
JMail.Sender = "wemaster@alibaba.info" '我们网站自己的邮箱
JMail.ReplyTo = "wemaster@alibaba.info" '我们网站自己的邮箱
JMail.SenderName = "阿里爸爸邮件发送"
JMail.Subject = Topic
JMail.SimpleLayout = true
JMail.Body = MailBody
JMail.Priority = 3
JMail.AddRecipient Email
JMail.AddHeader "Originating-IP", GBL_IPAddress
If JMail.Execute() = false Then
SendJmail = 0
Else
SendJmail = 1
End If
JMail.Close
Set JMail = Nothing
End Function
'分页
Function listPages(LinkFile)
if not (rs.eof and rs.bof) then
gopage=currentpage
totalpage=n
blockPage=Int((gopage-1)/10)*10+1
' if instr(linkfile,"?page=")>0 or instr(linkfile,"&page=")>0 then
' pos=instr(linkfile,"page=")-2
' linkfile=left(linkfile,pos)
' end if
If LCase(Request.ServerVariables("HTTPS")) = "off" Then
strTemp = "http://"
Else
strTemp = "https://"
End If
strTemp = strTemp & CheckStr(Request.ServerVariables("SERVER_NAME"))
If Request.ServerVariables("SERVER_PORT") <> 80 Then strTemp = strTemp & ":" & CheckStr(Request.ServerVariables("SERVER_PORT"))
strTemp = strTemp & CheckStr(Request.ServerVariables("URL"))
lenstrTemp=len(strTemp)+1
if instr(left(linkfile,lenstrTemp),"?")>0 then
if blockPage = 1 Then
Response.Write "【←前10页 "
Else
Response.Write("【←前10页 ")
End If
i=1
Do Until i > 10 or blockPage > n
If blockPage=int(gopage) Then
Response.Write("["&blockPage&"]")
Else
Response.Write(" ["&blockPage&"] ")
End If
blockPage=blockPage+1
i = i + 1
Loop
if blockPage > totalpage Then
Response.Write " 后10页→】"
Else
Response.Write(" 后10页→】")
End If
response.write" 直接到第 "
response.write""
response.write" 页
"
else
if blockPage = 1 Then
Response.Write "【←前10页 "
Else
Response.Write("【←前10页 ")
End If
i=1
Do Until i > 10 or blockPage > n
If blockPage=int(gopage) Then
Response.Write("["&blockPage&"]")
Else
Response.Write(" ["&blockPage&"] ")
End If
blockPage=blockPage+1
i = i + 1
Loop
if blockPage > totalpage Then
Response.Write " 后10页→】"
Else
Response.Write(" 后10页→】")
End If
response.write" 直接到第 "
response.write""
response.write" 页
"
End If
Startinfo=((gopage-1)*msg_per_page)+1
Endinfo=gopage*msg_per_page
if Endinfo>totalrec then Endinfo=totalrec
Response.Write(" 共 "&totalrec&" 条信息 当前显示第 "&Startinfo&" - "&Endinfo&" 条 每页 "&msg_per_page&" 条信息 共 "&n&" 页")
end if
End Function
'分页2
Function listPages2(LinkFile)
if not (rs.eof and rs.bof) then
gopage=currentpage
totalpage=n
blockPage=Int((gopage-1)/10)*10+1
If LCase(Request.ServerVariables("HTTPS")) = "off" Then
strTemp = "http://"
Else
strTemp = "https://"
End If
strTemp = strTemp & CheckStr(Request.ServerVariables("SERVER_NAME"))
If Request.ServerVariables("SERVER_PORT") <> 80 Then strTemp = strTemp & ":" & CheckStr(Request.ServerVariables("SERVER_PORT"))
strTemp = strTemp & CheckStr(Request.ServerVariables("URL"))
lenstrTemp=len(strTemp)+1
if instr(left(linkfile,lenstrTemp),"?")>0 then
if blockPage = 1 Then
Response.Write "前10页 "
Else
Response.Write("前10页 ")
End If
i=1
Do Until i > 10 or blockPage > n
If blockPage=int(gopage) Then
Response.Write(""&blockPage&"")
Else
Response.Write(" "&blockPage&" ")
End If
blockPage=blockPage+1
i = i + 1
Loop
if blockPage > totalpage Then
Response.Write " 后10页"
Else
Response.Write(" 后10页")
End If
response.write" 直接到第 "
response.write""
response.write" 页
"
else
if blockPage = 1 Then
Response.Write "【←前10页 "
Else
Response.Write("【←前10页 ")
End If
i=1
Do Until i > 10 or blockPage > n
If blockPage=int(gopage) Then
Response.Write("["&blockPage&"]")
Else
Response.Write(" ["&blockPage&"] ")
End If
blockPage=blockPage+1
i = i + 1
Loop
if blockPage > totalpage Then
Response.Write " 后10页→】"
Else
Response.Write(" 后10页→】")
End If
response.write" 直接到第 "
response.write""
response.write" 页
"
End If
Startinfo=((gopage-1)*msg_per_page)+1
Endinfo=gopage*msg_per_page
if Endinfo>totalrec then Endinfo=totalrec
Response.Write(" 共 "&totalrec&" 条信息 当前显示第 "&Startinfo&" - "&Endinfo&" 条 每页 "&msg_per_page&" 条信息 共 "&n&" 页")
end if
End Function
'判断文件类型是否合格
Function CheckFileExt(FileExt)
Dim ForumUpload,i
ForumUpload="gif,jpg,bmp,jpeg,png"
ForumUpload=Split(ForumUpload,",")
CheckFileExt=False
For i=0 to UBound(ForumUpload)
If LCase(FileExt)=Lcase(Trim(ForumUpload(i))) Then
CheckFileExt=True
Exit Function
End If
Next
End Function
'格式后缀
Function FixName(UpFileExt)
If IsEmpty(UpFileExt) Then Exit Function
FixName = Lcase(UpFileExt)
FixName = Replace(FixName,Chr(0),"")
FixName = Replace(FixName,".","")
FixName = Replace(FixName,"asp","")
FixName = Replace(FixName,"asa","")
FixName = Replace(FixName,"aspx","")
FixName = Replace(FixName,"cer","")
FixName = Replace(FixName,"cdx","")
FixName = Replace(FixName,"htr","")
End Function
'文件Content-Type判断
Function CheckFileType(FileType)
CheckFileType = False
If Left(Cstr(Lcase(Trim(FileType))),6)="image/" Then CheckFileType = True
End Function
%>
Function SendJmail(Email,Topic,MailBody)
Dim JMail
on error resume next
Set JMail = Server.CreateObject("JMail.SMTPMail")
JMail.LazySend = true
JMail.silent = true
JMail.Charset = "gb2312"
JMail.ContentType = "text/html"
JMail.Sender = "wemaster@alibaba.info" '我们网站自己的邮箱
JMail.ReplyTo = "wemaster@alibaba.info" '我们网站自己的邮箱
JMail.SenderName = "阿里爸爸邮件发送"
JMail.Subject = Topic
JMail.SimpleLayout = true
JMail.Body = MailBody
JMail.Priority = 3
JMail.AddRecipient Email
JMail.AddHeader "Originating-IP", GBL_IPAddress
If JMail.Execute() = false Then
SendJmail = 0
Else
SendJmail = 1
End If
JMail.Close
Set JMail = Nothing
End Function
'分页
Function listPages(LinkFile)
if not (rs.eof and rs.bof) then
gopage=currentpage
totalpage=n
blockPage=Int((gopage-1)/10)*10+1
' if instr(linkfile,"?page=")>0 or instr(linkfile,"&page=")>0 then
' pos=instr(linkfile,"page=")-2
' linkfile=left(linkfile,pos)
' end if
If LCase(Request.ServerVariables("HTTPS")) = "off" Then
strTemp = "http://"
Else
strTemp = "https://"
End If
strTemp = strTemp & CheckStr(Request.ServerVariables("SERVER_NAME"))
If Request.ServerVariables("SERVER_PORT") <> 80 Then strTemp = strTemp & ":" & CheckStr(Request.ServerVariables("SERVER_PORT"))
strTemp = strTemp & CheckStr(Request.ServerVariables("URL"))
lenstrTemp=len(strTemp)+1
if instr(left(linkfile,lenstrTemp),"?")>0 then
if blockPage = 1 Then
Response.Write "【←前10页 "
Else
Response.Write("【←前10页 ")
End If
i=1
Do Until i > 10 or blockPage > n
If blockPage=int(gopage) Then
Response.Write("["&blockPage&"]")
Else
Response.Write(" ["&blockPage&"] ")
End If
blockPage=blockPage+1
i = i + 1
Loop
if blockPage > totalpage Then
Response.Write " 后10页→】"
Else
Response.Write(" 后10页→】")
End If
response.write" 直接到第 "
response.write""
response.write" 页
"
else
if blockPage = 1 Then
Response.Write "【←前10页 "
Else
Response.Write("【←前10页 ")
End If
i=1
Do Until i > 10 or blockPage > n
If blockPage=int(gopage) Then
Response.Write("["&blockPage&"]")
Else
Response.Write(" ["&blockPage&"] ")
End If
blockPage=blockPage+1
i = i + 1
Loop
if blockPage > totalpage Then
Response.Write " 后10页→】"
Else
Response.Write(" 后10页→】")
End If
response.write" 直接到第 "
response.write""
response.write" 页
"
End If
Startinfo=((gopage-1)*msg_per_page)+1
Endinfo=gopage*msg_per_page
if Endinfo>totalrec then Endinfo=totalrec
Response.Write(" 共 "&totalrec&" 条信息 当前显示第 "&Startinfo&" - "&Endinfo&" 条 每页 "&msg_per_page&" 条信息 共 "&n&" 页")
end if
End Function
'分页2
Function listPages2(LinkFile)
if not (rs.eof and rs.bof) then
gopage=currentpage
totalpage=n
blockPage=Int((gopage-1)/10)*10+1
If LCase(Request.ServerVariables("HTTPS")) = "off" Then
strTemp = "http://"
Else
strTemp = "https://"
End If
strTemp = strTemp & CheckStr(Request.ServerVariables("SERVER_NAME"))
If Request.ServerVariables("SERVER_PORT") <> 80 Then strTemp = strTemp & ":" & CheckStr(Request.ServerVariables("SERVER_PORT"))
strTemp = strTemp & CheckStr(Request.ServerVariables("URL"))
lenstrTemp=len(strTemp)+1
if instr(left(linkfile,lenstrTemp),"?")>0 then
if blockPage = 1 Then
Response.Write "前10页 "
Else
Response.Write("前10页 ")
End If
i=1
Do Until i > 10 or blockPage > n
If blockPage=int(gopage) Then
Response.Write(""&blockPage&"")
Else
Response.Write(" "&blockPage&" ")
End If
blockPage=blockPage+1
i = i + 1
Loop
if blockPage > totalpage Then
Response.Write " 后10页"
Else
Response.Write(" 后10页")
End If
response.write" 直接到第 "
response.write""
response.write" 页
"
else
if blockPage = 1 Then
Response.Write "【←前10页 "
Else
Response.Write("【←前10页 ")
End If
i=1
Do Until i > 10 or blockPage > n
If blockPage=int(gopage) Then
Response.Write("["&blockPage&"]")
Else
Response.Write(" ["&blockPage&"] ")
End If
blockPage=blockPage+1
i = i + 1
Loop
if blockPage > totalpage Then
Response.Write " 后10页→】"
Else
Response.Write(" 后10页→】")
End If
response.write" 直接到第 "
response.write""
response.write" 页
"
End If
Startinfo=((gopage-1)*msg_per_page)+1
Endinfo=gopage*msg_per_page
if Endinfo>totalrec then Endinfo=totalrec
Response.Write(" 共 "&totalrec&" 条信息 当前显示第 "&Startinfo&" - "&Endinfo&" 条 每页 "&msg_per_page&" 条信息 共 "&n&" 页")
end if
End Function
'判断文件类型是否合格
Function CheckFileExt(FileExt)
Dim ForumUpload,i
ForumUpload="gif,jpg,bmp,jpeg,png"
ForumUpload=Split(ForumUpload,",")
CheckFileExt=False
For i=0 to UBound(ForumUpload)
If LCase(FileExt)=Lcase(Trim(ForumUpload(i))) Then
CheckFileExt=True
Exit Function
End If
Next
End Function
'格式后缀
Function FixName(UpFileExt)
If IsEmpty(UpFileExt) Then Exit Function
FixName = Lcase(UpFileExt)
FixName = Replace(FixName,Chr(0),"")
FixName = Replace(FixName,".","")
FixName = Replace(FixName,"asp","")
FixName = Replace(FixName,"asa","")
FixName = Replace(FixName,"aspx","")
FixName = Replace(FixName,"cer","")
FixName = Replace(FixName,"cdx","")
FixName = Replace(FixName,"htr","")
End Function
'文件Content-Type判断
Function CheckFileType(FileType)
CheckFileType = False
If Left(Cstr(Lcase(Trim(FileType))),6)="image/" Then CheckFileType = True
End Function
%>
评论: 0 | 引用: 0 | 查看次数: 2441
发表评论