ASP功能函数大全.docx
- 文档编号:5849982
- 上传时间:2023-01-01
- 格式:DOCX
- 页数:87
- 大小:47.43KB
ASP功能函数大全.docx
《ASP功能函数大全.docx》由会员分享,可在线阅读,更多相关《ASP功能函数大全.docx(87页珍藏版)》请在冰豆网上搜索。
ASP功能函数大全
ASP功能函数大全
在这里给大家献上ASP各种函数功能木块集合,这里几乎包含了常用的ASP函数,对网站开发时有着很大的帮助!
<%
callstart()
'开始执行
Functionstart()
callget_rq()'安全过滤
'callAppeal()'防小偷程序
callwebAgent()'检测客户端
EndFunction
FunctioncreateRs()
dimrsObj
setrsObj=server.CreateObject("adodb.recordset")
setcreateRs=rsObj
EndFunction
subshowError(strval)
response.Write" 1solid#0099FF;width: 500px;height: 250px;"">" response.Writestrval response.Write"
response.End()
endsub
'转向
SubRedirectUrl(strHttp)
Response.write"
EndSub
subAlert(sText)
Response.write"
endsub
subHistory(iStep)
Response.write""
EndSub
subFunmsg(iStep,sText)
Response.Write""
endsub
'执行非法提交检测
Subget_rq()
dimqs,errc,iii
qs=request.servervariables("query_string")
dimnothis(18)
nothis(0)="netuser"
nothis
(1)="xp_cmdshell"
nothis
(2)="/add"
nothis(3)="exec%20master.dbo.xp_cmdshell"
nothis(4)="netlocalgroupadministrators"
nothis(5)="select"
nothis(6)="count"
nothis(7)="asc"
nothis(8)="char"
nothis(9)="mid"
nothis(10)="'"
nothis(11)=":
:
"
nothis(12)=""""
nothis(13)="insert"
nothis(14)="delete"
nothis(15)="drop"
nothis(16)="truncate"
nothis(17)="from"
nothis(18)="anduser>0"
errc=false
foriii=0toubound(nothis)
ifinstr(qs,nothis(iii))<>0then
errc=true
endif
next
iferrcthen
'Response.Write("对不起,非法URL地址请求!
")
response.Write"
response.Write" 1pxsolid#CCCCCC;width: 600px;height: 25px;padding: 5px;padding-left: 15px;'>" response.Write" 14px'>Diggcms系统友情提示: response.Write" HTTP错误404-URL地址请求出错 response.Write"
"
"
response.end
endif
EndSub
'初始化被过滤的客户端列表
FunctionwebAgent()
dimstrAgentFilter
strAgentFilter="webzip|||flashget|||offline|||teleport"
IfChkAgent(strAgentFilter)=FalseThen
response.Write"错误"
response.End()
'AddErrCode
(1)
'CallChkError()
EndIf
EndFunction
'*检查浏览站点的客户端
'*strAL——屏蔽的客户端标志列表
FunctionChkAgent(strAL)
DimAgent,iijj
ChkAgent=True
Agent=Trim(Lcase(Request.Servervariables("HTTP_USER_AGENT")))
If(NotIsNull(strAL))Then
strAL=Split(strAL,"|||")
Foriijj=0ToUbound(strAL)
IfInstr(Agent,strAL(iijj))>0Then
ChkAgent=False
endif
Next
EndIf
EndFunction
'/*
'防网站小偷来采摘数据
'*/
functionAppeal()
DimAppealNum,AppealCount
AppealNum=30'同一IP10秒内请求限制30次
AppealCount=Request.Cookies("AppealCount")
IfAppealCount=""Then
response.Cookies("AppealCount")=1
AppealCount=1
response.cookies("AppealCount").expires=dateadd("s",10,now())
Else
response.Cookies("AppealCount")=AppealCount+1
response.cookies("AppealCount").expires=dateadd("s",10,now())
EndIf
ifint(AppealCount)>int(AppealNum)then
response.Write" 350px'>" response.write" 14px'>抓取很累,歇一会儿吧! response.Write"" response.end EndIf endfunction '/* '防外部提交 '结合Chkpost函数 '*/ functionchpost() IfNotChkPost(Website)then response.Write" response.Write" 350px'>" Response.Write" 14px'>" response.Write" response.Write"" response.Write" 1pxsolid#CCCCCC;width: 235px;height: 25px;padding: 5px;padding-left: 15px;'>
response.Write""
response.End()
endif
Endfunction
'/*
'处部提交数据查
'*/
FunctionChkPost(web_url)
dimServer_V1,Server_V2
ChkPost=False
Server_V1=Cstr(Request.ServerVariables("HTTP_REFERER"))
Server_V2=Cstr(Request.ServerVariables("SERVER_NAME"))
''--------------------------------------------
''Instr(所有,其中),包括>0,否则=0
''--------------------------------------------
IfMid(Server_V1,8,Len(Server_V2))<>Server_V2orInstr(web_url,Server_V2)=0Then
ChkPost=False
Else
ChkPost=True
EndIf
EndFunction
'========================================================文件操作
'/*
'删除文件
'*/
FunctionDelFile(DelFilePath)
OnErrorResumeNext
DelFile=False
setMyFileObject=Server.CreateOBject("Scripting.FileSystemObject")
MyFileObject.DeleteFile""&Server.MapPath(""&DelFilePath&"")&""
SetMyFileObject=Nothing
If0=Error53=ErrThen
DelFile=True
else
CatchError(""&DelFilePath&"文件无法删除!
")
endif
OnErrorGoTo0
EndFunction
'/*
'检查多层目录不存在,则生成
'*/
functionCreateDIR(LocalPath)
dimpatharr,path_level,i,pathtmp,cpath,FileObject
onerrorresumenext
LocalPath=Server.MapPath(LocalPath)
LocalPath=replace(LocalPath,"\","/")
setFileObject=server.createobject("Scripting.FileSystemObject")
patharr=split(LocalPath,"/")
path_level=ubound(patharr)
fori=0topath_level
ifi=0thenpathtmp=patharr(0)&"/"elsepathtmp=pathtmp&patharr(i)&"/"
cpath=left(pathtmp,len(pathtmp)-1)
ifnotFileObject.FolderExists(cpath)thenFileObject.CreateFolder(cpath)
next
setFileObject=nothing
iferr.number<>0then
CreateDIR=false
err.Clear
else
CreateDIR=true
endif
endfunction
'/*
'cookie编码加密
'*/
FunctionCodeCookie(Str)
Dimi
DimStrRtn
Fori=Len(Str)To1Step-1
StrRtn=StrRtn&AscW(Mid(Str,i,1))
If(i<>1)ThenStrRtn=StrRtn&"a"
Next
CodeCookie=StrRtn
EndFunction
'/*
'cookie解密
'*/
FunctionDecodeCookie(Str)
Dimi
DimStrArr,StrRtn
StrArr=Split(Str,"a")
Fori=0ToUBound(StrArr)
IfIsNumeric(StrArr(i))=TrueThen
StrRtn=ChrW(StrArr(i))&StrRtn
Else
StrRtn=Str
ExitFunction
EndIf
Next
DecodeCookie=StrRtn
EndFunction
'/*
'*设置Cookies
'*vparameter:
参数,val:
值
'*/
FunctionSetCookies(vparameter,val)
response.Cookies(vparameter)=val
response.Cookies(vparameter).Expires=dateadd("H",12,now())
EndFunction
'/*
'* 读取Cookies
'*/
FunctionGetCookies(vparameter)
GetCookies=request.Cookies(vparameter)
EndFunction
'============================================================安全过滤
'/*
'安全过滤
'*/
FunctionSafeSql(Str,Flag)
SafeSql=Str
IfFlag=1Then
IfNotIsNumeric(SafeSql)OrTrim(SafeSql)=""Then
'response.Write"
response.Write" 350px'>" Response.Write" 14px'>参数错误,参数类型应为数值型。 "&Str&"" response.Write"" response.Write" 1pxsolid#CCCCCC;width: 235px;height: 25px;padding: 5px;padding-left: 15px;'>
当前值是:
Response.End
EndIf
ElseIfFlag=2Then
Str=trim(Str)
Str=replace(Str,">",">")
Str=replace(Str,"<","<")
Str=Replace(Str,"\","\")
Str=Replace(Str,"--","--")
Str=Replace(Str,CHR(34),""")'过滤''
Str=Replace(Str,CHR(39),"'")'过滤'
'Str=Replace(Str,CHR(13)&CHR(10),"
")'回车换行
Str=Replace(Str,CHR(42),"*")'“*”
Str=Replace(Str,CHR(44),",")'“,”
Str=Replace(Str,"select","select")
Str=Replace(Str,"join","join")
Str=Replace(Str,"union","union")
Str=Replace(Str,"where","where")
Str=Replace(Str,"insert","insert")
Str=Replace(Str,"delete","delete")
Str=Replace(Str,"update","update")
Str=Replace(Str,"like","like")
Str=Replace(Str,"drop","drop")
Str=Replace(Str,"create","create")
Str=Replace(Str,"modify","modify")
Str=Replace(Str,"rename","rename")
Str=Replace(Str,"alter","alter")
Str=Replace(Str,"cast","cast")
SafeSql=Str
Else
response.Write" 350px'>" Response.Write" 14px'>参数错误SafeSql方法参数在1,2范围内" response.Write"" response.Write" 1pxsolid#CCCCCC;width: 235px;height: 25px;padding: 5px;padding-left: 15px;'>