仓酷云
标题:
ASP教程之ASP过滤SQL不法字符并格局化html代码
[打印本页]
作者:
谁可相欹
时间:
2015-1-16 22:20
标题:
ASP教程之ASP过滤SQL不法字符并格局化html代码
使用cdonts,可以发送、查看邮件,实现webmail的功能。结合wsh,可以实现对nt主机的管理,如nt用户管理、iis虚拟主机设置、exchange邮箱设置等等,就像管理本地机一样方便。sql<%
functionchangechr(str)
changechr=replace(replace(replace(replace(str,"<","<"),">",">"),chr(13),"<br>"),"","")
changechr=replace(replace(replace(replace(changechr,"[sayyes]","<divalign=center><imgsrc="),"
","<b>"),"[red]","<fontcolor=CC0000>"),"[big]","<fontsize=7>")
changechr=replace(replace(replace(replace(changechr,"[/sayyes]","></img></div>"),"
","</b>"),"[/red]","</font>"),"[/big]","</font>")
endfunction
过滤SQL不法字符并格局化html代码
functionReplace_Text(fString)
ifisnull(fString)then
Replace_Text=""
exitfunction
else
fString=trim(fString)
fString=replace(fString,"","")
fString=replace(fString,";",";")
fString=replace(fString,"--","―")
fString=server.htmlencode(fString)
Replace_Text=fString
endif
endfunction
会员公布的各类信息过滤
FunctionReplace_Text(fString)
IfNotIsNull(fString)Then
fString=trim(fString)
fString=replace(fString,";",";")分号过滤
fString=replace(fString,"--","――")--过滤
fString=replace(fString,"%20","")特别字符过滤
fString=replace(fString,"==","")==过滤
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>")
Replace_Text=fString
EndIf
EndFunction
过滤SQL不法字符
FunctioncheckStr(Chkstr)
dimStr:Str=Chkstr
ifisnull(Str)then
checkStr=""
exitFunction
else
Str=replace(Str,"","")
Str=replace(Str,";","")
Str=replace(Str,"--","")
checkStr=Str
endif
EndFunction
检测传送的参数是不是为数字型
FunctionChkrequest(Para)
Chkrequest=False
IfNot(IsNull(Para)OrTrim(Para)=""OrNotIsNumeric(Para))Then
Chkrequest=True
EndIf
EndFunction
检测传送的参数是不是为日期型
FunctionChkrequestdate(Para)
Chkrequestdate=False
IfNot(IsNull(Para)OrTrim(Para)=""OrNotIsDate(Para))Then
Chkrequestdate=True
EndIf
EndFunction
失掉以后页面的地点
FunctionGetUrl()
OnErrorResumeNext
DimstrTemp
IfLCase(Request.ServerVariables("HTTPS"))="off"Then
strTemp="http://"
Else
strTemp="https://"
EndIf
strTemp=strTemp&CheckStr(Request.ServerVariables("SERVER_NAME"))
IfRequest.ServerVariables("SERVER_PORT")80ThenstrTemp=strTemp&":"&CheckStr(Request.ServerVariables("SERVER_PORT"))
strTemp=strTemp&CheckStr(Request.ServerVariables("URL"))
IfTrim(Request.QueryString)""ThenstrTemp=strTemp&"?"&CheckStr(Trim(Request.QueryString))
GetUrl=strTemp
EndFunction
FunctionCheckReferer()反省用户是不是在扫瞄器里输出了本页的地点
DimsReferer,Icheck
CheckReferer=True
sReferer=Request.ServerVariables("HTTP_REFERER")
ServerIP=Request.ServerVariables("LOCAL_ADDR")
Icheck=InStr(sReferer,"ServerIP")
IfIcheck=0Then
CheckReferer=False
EndIf
EndFunction
日期格局化
FunctionFormatDate(DT,tp)
dimY,M,D
Y=Year(DT)
M=month(DT)
D=Day(DT)
ifM<10thenM="0"&M
ifD<10thenD="0"&D
selectcasetp
case1FormatDate=Y&"年"&M&"月"&D&"日"
case2FormatDate=Y&"-"&M&"-"&D
endselect
EndFunction
不同意内部提交数据的选择
FunctionChkPost()
dimHTTP_REFERER,SERVER_NAME
dimserver_v1,server_v2
chkpost=false
SERVER_NAME=CheckStr(Request.ServerVariables("SERVER_NAME"))
HTTP_REFERER=CheckStr(Request.ServerVariables("HTTP_REFERER"))
server_v1=Cstr(HTTP_REFERER)
server_v2=Cstr(SERVER_NAME)
ifmid(server_v1,8,len(server_v2))server_v2then
chkpost=false
else
chkpost=true
endif
EndFunction
机关上传图片文件名随机数
functionMakedownName()
dimfname
fname=now()
fname=replace(fname,"-","")
fname=replace(fname,"","")
fname=replace(fname,":","")
fname=replace(fname,"PM","")
fname=replace(fname,"AM","")
fname=replace(fname,"上午","")
fname=replace(fname,"下战书","")
fname=int(fname)+int((10-1+1)*Rnd+1)
MakedownName=fname
endfunction
Email检测
functionIsValidEmail(email)
dimnames,name,i,c
IsValidEmail=true
names=Split(email,"@")
ifUBound(names)1then
IsValidEmail=false
exitfunction
endif
foreachnameinnames
ifLen(name)<=0then
IsValidEmail=false
exitfunction
endif
fori=1toLen(name)
c=Lcase(Mid(name,i,1))
ifInStr("abcdefghijklmnopqrstuvwxyz_-.",c)<=0andnotIsNumeric(c)then
IsValidEmail=false
exitfunction
endif
next
ifLeft(name,1)="."orRight(name,1)="."then
IsValidEmail=false
exitfunction
endif
next
ifInStr(names(1),".")<=0then
IsValidEmail=false
exitfunction
endif
i=Len(names(1))-InStrRev(names(1),".")
ifi2andi3then
IsValidEmail=false
exitfunction
endif
ifInStr(email,"..")>0then
IsValidEmail=false
endif
endfunction
Jmail邮件发送
FunctionSendJmail(Email,Topic,MailBody)
DimJMail
onerrorresumenext
SetJMail=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.AddRecipientEmail
JMail.AddHeader"Originating-IP",GBL_IPAddress
IfJMail.Execute()=falseThen
SendJmail=0
Else
SendJmail=1
EndIf
JMail.Close
SetJMail=Nothing
EndFunction
分页
FunctionlistPages(LinkFile)
ifnot(rs.eofandrs.bof)then
gopage=currentpage
totalpage=n
blockPage=Int((gopage-1)/10)*10+1
ifinstr(linkfile,"?page=")>0orinstr(linkfile,"&page=")>0then
pos=instr(linkfile,"page=")-2
linkfile=left(linkfile,pos)
endif
IfLCase(Request.ServerVariables("HTTPS"))="off"Then
strTemp="http://"
Else
strTemp="https://"
EndIf
strTemp=strTemp&CheckStr(Request.ServerVariables("SERVER_NAME"))
IfRequest.ServerVariables("SERVER_PORT")80ThenstrTemp=strTemp&":"&CheckStr(Request.ServerVariables("SERVER_PORT"))
strTemp=strTemp&CheckStr(Request.ServerVariables("URL"))
lenstrTemp=len(strTemp)+1
ifinstr(left(linkfile,lenstrTemp),"?")>0then
ifblockPage=1Then
Response.Write"<spandisabled>【←前10页</span>"
Else
Response.Write("<spandisabled>【</span><ahref="&LinkFile&"&page="&blockPage-10&">←前10页</a>")
EndIf
i=1
DoUntili>10orblockPage>n
IfblockPage=int(gopage)Then
Response.Write("<fontcolor=#FF0000>[<b>"&blockPage&"</b>]</font>")
Else
Response.Write("<ahref="&LinkFile&"&page="&blockPage&">["&blockPage&"]</a>")
EndIf
blockPage=blockPage+1
i=i+1
Loop
ifblockPage>totalpageThen
Response.Write"<spandisabled>后10页→】"
Else
Response.Write("<ahref="&LinkFile&"&page="&blockPage&">后10页→</a><spandisabled>】")
EndIf
response.write"间接到第"
response.write"<selectonchange=if(this.options[this.selectedIndex].value!=){location=this.options[this.selectedIndex].value;}>"
fori=1tototalpage
response.write"<optionvalue="&LinkFile&"&page="&i&""
ifi=gopagethenresponse.write"selected"
response.write">"&i&"</option>"
next
response.write"</select>"
response.write"页<Br><Br>"
else
ifblockPage=1Then
Response.Write"<spandisabled>【←前10页</span>"
Else
Response.Write("<spandisabled>【</span><ahref="&LinkFile&"?page="&blockPage-10&">←前10页</a>")
EndIf
i=1
DoUntili>10orblockPage>n
IfblockPage=int(gopage)Then
Response.Write("<fontcolor=#FF0000>[<b>"&blockPage&"</b>]</font>")
Else
Response.Write("<ahref="&LinkFile&"?page="&blockPage&">["&blockPage&"]</a>")
EndIf
blockPage=blockPage+1
i=i+1
Loop
ifblockPage>totalpageThen
Response.Write"<spandisabled>后10页→】"
Else
Response.Write("<ahref="&LinkFile&"?page="&blockPage&">后10页→</a><spandisabled>】")
EndIf
response.write"间接到第"
response.write"<selectonchange=if(this.options[this.selectedIndex].value!=){location=this.options[this.selectedIndex].value;}>"
fori=1tototalpage
response.write"<optionvalue="&LinkFile&"?page="&i&""
ifi=gopagethenresponse.write"selected"
response.write">"&i&"</option>"
next
response.write"</select>"
response.write"页<Br><Br>"
EndIf
Startinfo=((gopage-1)*msg_per_page)+1
Endinfo=gopage*msg_per_page
ifEndinfo>totalrecthenEndinfo=totalrec
Response.Write("共"&totalrec&"条信息以后显现第"&Startinfo&"-"&Endinfo&"条每页"&msg_per_page&"条信息共"&n&"页")
endif
EndFunction
分页2
FunctionlistPages2(LinkFile)
ifnot(rs.eofandrs.bof)then
gopage=currentpage
totalpage=n
blockPage=Int((gopage-1)/10)*10+1
IfLCase(Request.ServerVariables("HTTPS"))="off"Then
strTemp="http://"
Else
strTemp="https://"
EndIf
strTemp=strTemp&CheckStr(Request.ServerVariables("SERVER_NAME"))
IfRequest.ServerVariables("SERVER_PORT")80ThenstrTemp=strTemp&":"&CheckStr(Request.ServerVariables("SERVER_PORT"))
strTemp=strTemp&CheckStr(Request.ServerVariables("URL"))
lenstrTemp=len(strTemp)+1
ifinstr(left(linkfile,lenstrTemp),"?")>0then
ifblockPage=1Then
Response.Write"<spandisabled>前10页</span>"
Else
Response.Write("<ahref="&LinkFile&"&page="&blockPage-10&">前10页</a>")
EndIf
i=1
DoUntili>10orblockPage>n
IfblockPage=int(gopage)Then
Response.Write("<fontcolor=#FF0000><b>"&blockPage&"</b></font>")
Else
Response.Write("<ahref="&LinkFile&"&page="&blockPage&">"&blockPage&"</a>")
EndIf
blockPage=blockPage+1
i=i+1
Loop
ifblockPage>totalpageThen
Response.Write"<spandisabled>后10页"
Else
Response.Write("<ahref="&LinkFile&"&page="&blockPage&">后10页</a><spandisabled>")
EndIf
response.write"间接到第"
response.write"<selectonchange=if(this.options[this.selectedIndex].value!=){location=this.options[this.selectedIndex].value;}>"
fori=1tototalpage
response.write"<optionvalue="&LinkFile&"&page="&i&""
ifi=gopagethenresponse.write"selected"
response.write">"&i&"</option>"
next
response.write"</select>"
response.write"页<Br><Br>"
else
ifblockPage=1Then
Response.Write"<spandisabled>【←前10页</span>"
Else
Response.Write("<spandisabled>【</span><ahref="&LinkFile&"?page="&blockPage-10&">←前10页</a>")
EndIf
i=1
DoUntili>10orblockPage>n
IfblockPage=int(gopage)Then
Response.Write("<fontcolor=#FF0000>[<b>"&blockPage&"</b>]</font>")
Else
Response.Write("<ahref="&LinkFile&"?page="&blockPage&">["&blockPage&"]</a>")
EndIf
blockPage=blockPage+1
i=i+1
Loop
ifblockPage>totalpageThen
Response.Write"<spandisabled>后10页→】"
Else
Response.Write("<ahref="&LinkFile&"?page="&blockPage&">后10页→</a><spandisabled>】")
EndIf
response.write"间接到第"
response.write"<selectonchange=if(this.options[this.selectedIndex].value!=){location=this.options[this.selectedIndex].value;}>"
fori=1tototalpage
response.write"<optionvalue="&LinkFile&"?page="&i&""
ifi=gopagethenresponse.write"selected"
response.write">"&i&"</option>"
next
response.write"</select>"
response.write"页<Br><Br>"
EndIf
Startinfo=((gopage-1)*msg_per_page)+1
Endinfo=gopage*msg_per_page
ifEndinfo>totalrecthenEndinfo=totalrec
Response.Write("共"&totalrec&"条信息以后显现第"&Startinfo&"-"&Endinfo&"条每页"&msg_per_page&"条信息共"&n&"页")
endif
EndFunction
判别文件范例是不是及格
FunctionCheckFileExt(FileExt)
DimForumUpload,i
ForumUpload="gif,jpg,bmp,jpeg,png"
ForumUpload=Split(ForumUpload,",")
CheckFileExt=False
Fori=0toUBound(ForumUpload)
IfLCase(FileExt)=Lcase(Trim(ForumUpload(i)))Then
CheckFileExt=True
ExitFunction
EndIf
Next
EndFunction
格局后缀
FunctionFixName(UpFileExt)
IfIsEmpty(UpFileExt)ThenExitFunction
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","")
EndFunction
文件Content-Type判别
FunctionCheckFileType(FileType)
CheckFileType=False
IfLeft(Cstr(Lcase(Trim(FileType))),6)="image/"ThenCheckFileType=True
EndFunction
%>
SQLServer是基于服务器端的中型的数据库,可以适合大容量数据的应用,在功能上管理上也要比Access要强得多。在处理海量数据的效率,后台开发的灵活性,可扩展性等方面强大。
作者:
若天明
时间:
2015-1-19 09:07
以HTML语言整合(HTML负责界面上,ASP则负责功能上)形成一个B/S(浏览器/服务器)模式的网页程序。
作者:
精灵巫婆
时间:
2015-1-25 21:31
ASP主要是用好六个对象,其实最主要的是用好其中两个:response和request,就可以随心所欲地控制网页变换和响应用户动作了。
作者:
小女巫
时间:
2015-2-4 04:40
掌握asp的特性而且一定要知道为什么。
作者:
分手快乐
时间:
2015-2-9 15:50
ASP主要是用好六个对象,其实最主要的是用好其中两个:response和request,就可以随心所欲地控制网页变换和响应用户动作了。
作者:
深爱那片海
时间:
2015-2-27 09:07
ASP也是这几种脚本语言中最简单易学的开发语言。但ASP也是这几种语言中唯一的一个不能很好支持跨平台的语言。 因为ASP脚本语言非常简单,因此其代码也简单易懂,结合HTML代码,可快速地完成网站的应用程序。
作者:
飘灵儿
时间:
2015-3-9 00:44
我就感觉到ASP和一些常用的数据库编程以及软件工程方面的思想是非常重要的。我现在也在尝试自己做网页,这其中就用到了ASP,我想它的作用是可想而知的。
作者:
若相依
时间:
2015-3-16 19:50
Session:这个存储跟客户端会话过程的数据,默认20分钟失效
作者:
小妖女
时间:
2015-3-23 01:25
学习ASP其实应该上升到如何学习程序设计这种境界,其实学习程序设计又是接受一种编程思想。比如ASP如何学习,你也许在以前的学习中碰到过。以下我仔细给你说几点:
欢迎光临 仓酷云 (http://ckuyun.com/)
Powered by Discuz! X3.2