1、ASP功能函数大全ASP功能函数大全在这里给大家献上ASP各种函数功能木块集合,这里几乎包含了常用的ASP函数,对网站开发时有着很大的帮助!%call start()开始执行Function start() call get_rq() 安全过滤 call Appeal() 防小偷程序 call webAgent() 检测客户端End FunctionFunction createRs() dim rsObj set rsObj=server.CreateObject(adodb.recordset) set createRs=rsObjEnd Functionsub showError(str
2、val) response.Write response.Write strval response.Write response.End()end sub转向Sub RedirectUrl(strHttp) Response.write location.href=&strHttp&;End Subsub Alert(sText) Response.write alert( & sText & );end subsub History(iStep) Response.write window.history( & iStep & );End Subsub Funmsg(iStep,sText
3、)Response.Write alert(&sText&);location.href=&iStep&;end sub执行非法提交检测Sub get_rq()dim qs,errc,iiiqs=request.servervariables(query_string)dim nothis(18)nothis(0)=net usernothis(1)=xp_cmdshellnothis(2)=/addnothis(3)=exec%20master.dbo.xp_cmdshellnothis(4)=net localgroup administratorsnothis(5)=selectnoth
4、is(6)=countnothis(7)=ascnothis(8)=charnothis(9)=midnothis(10)=nothis(11)=:nothis(12)=nothis(13)=insertnothis(14)=deletenothis(15)=dropnothis(16)=truncatenothis(17)=fromnothis(18)=and user0errc=falsefor iii= 0 to ubound(nothis) if instr(qs,nothis(iii)0 then errc=true end ifnextif errc then Response.W
5、rite(对不起,非法URL地址请求!) response.Write response.Write response.Write Diggcms系统友情提示: response.Write HTTP 错误 404 -URL地址请求出错 response.Write response.endend ifEnd Sub初始化被过滤的客户端列表Function webAgent() dim strAgentFilter strAgentFilter=webzip|flashget|offline|teleport If ChkAgent(strAgentFilter)=Fa
6、lse Then response.Write 错误 response.End() AddErrCode(1) Call ChkError() End If End Function * 检查浏览站点的客户端 * strAL 屏蔽的客户端标志列表Function ChkAgent(strAL) Dim Agent,iijj ChkAgent=True Agent=Trim(Lcase(Request.Servervariables(HTTP_USER_AGENT) If (Not IsNull(strAL) Then strAL=Split(strAL,|) For iijj=0 To Ubo
7、und(strAL) If Instr(Agent,strAL(iijj)0 Then ChkAgent=False end if Next End IfEnd Function/* 防网站小偷来采摘数据 */function Appeal()Dim AppealNum,AppealCount AppealNum=30 同一IP10秒内请求限制30次 AppealCount=Request.Cookies(AppealCount) If AppealCount= Then response.Cookies(AppealCount)=1 AppealCount=1 response.cookie
8、s(AppealCount).expires=dateadd(s,10,now() Else response.Cookies(AppealCount)=AppealCount+1 response.cookies(AppealCount).expires=dateadd(s,10,now() End If if int(AppealCount)int(AppealNum) then response.Write 描述 response.write 抓取很累,歇一会儿吧!&Website& response.Write response.end End If end function/* 防外
9、部提交 结合Chkpost函数 */function chpost()If Not ChkPost(Website) then response.Write response.Write 系统提示 Response.Write response.Write 返回 response.Write response.Write Diggcms给你最好的 response.Write response.End()end ifEnd function/* 处部提交数据查 */Function ChkPost(web_url)dim Server_V1,Server_V
10、2ChkPost=FalseServer_V1=Cstr(Request.ServerVariables(HTTP_REFERER)Server_V2=Cstr(Request.ServerVariables(SERVER_NAME)- Instr(所有,其中),包括0,否则=0-If Mid(Server_V1,8,Len(Server_V2)Server_V2 or Instr(web_url,Server_V2)=0 Then ChkPost=FalseElse ChkPost=TrueEnd IfEnd Function=文件操作/* 删除文件 */Function DelFile(D
11、elFilePath)On Error Resume NextDelFile= Falseset MyFileObject=Server.CreateOBject(Scripting.FileSystemObject)MyFileObject.DeleteFile&Server.MapPath(&DelFilePath&)&Set MyFileObject= NothingIf 0 = Err or 53 = Err Then DelFile= Trueelse CatchError(&DelFilePath&文件无法删除!)end ifOn Error GoTo 0End Function/
12、* 检查多层目录不存在,则生成 */function CreateDIR(LocalPath) dim patharr,path_level,i,pathtmp,cpath,FileObject on error resume next LocalPath = Server.MapPath(LocalPath) LocalPath = replace(LocalPath,/) set FileObject = server.createobject(Scripting.FileSystemObject) patharr = split(LocalPath,/) path_level = ubo
13、und(patharr) for i = 0 to path_level if i=0 then pathtmp = patharr(0) & / else pathtmp = pathtmp & patharr(i) & / cpath = left(pathtmp,len(pathtmp)-1) if not FileObject.FolderExists(cpath) then FileObject.CreateFolder(cpath) next set FileObject = nothing if err.number0 then CreateDIR = false err.Cle
14、ar else CreateDIR = true end if end function/* cookie编码加密 */Function CodeCookie(Str) Dim i Dim StrRtn For i = Len(Str) To 1 Step -1 StrRtn = StrRtn & AscW(Mid(Str, i, 1) If (i 1) Then StrRtn = StrRtn & a Next CodeCookie = StrRtnEnd Function/*cookie解密 */ Function DecodeCookie(Str) Dim i Dim StrArr, S
15、trRtn StrArr = Split(Str, a) For i = 0 To UBound(StrArr) If IsNumeric(StrArr(i) = True Then StrRtn = ChrW(StrArr(i) & StrRtn Else StrRtn = Str Exit Function End If Next DecodeCookie = StrRtnEnd Function/* * 设置Cookies * vparameter:参数,val:值 */Function SetCookies(vparameter,val)response.Cookies(vparame
16、ter)=valresponse.Cookies(vparameter).Expires=dateadd(H,12,now()End Function/* *读取Cookies */Function GetCookies(vparameter)GetCookies=request.Cookies(vparameter)End Function=安全过滤/* 安全过滤 */Function SafeSql(Str,Flag)SafeSql=StrIf Flag=1 Then If Not IsNumeric(SafeSql) Or Trim(SafeSql)= Then response.Wri
17、te response.Write 描述 Response.Write 参数错误,参数类型应为数值型。当前值是:&Str& response.Write response.Write 好财经给你最好的 Response.End End IfElseIf Flag=2 Then Str =trim(Str) Str = replace(Str, , >) Str = replace(Str, , <) Str=Replace(Str,\) Str=Replace(Str,-,--) Str = Replace(Str, CHR(34), ") 过滤
18、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(S
19、tr, 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 = Repl
20、ace(Str, cast, cast) SafeSql=StrElse response.Write 描述 Response.Write 参数错误SafeSql方法参数在1,2范围内 response.Write response.Write 好财经给你最好的 Response.EndEnd IfEnd Function/* HTML解码函数 */Function HTMLDecode(refStringing) Dim fString fString=refStringing If Not IsNull(fString) Then fString = Replace(fString, &g
21、t;, ) fString = Replace(fString, <, 0 then fString = Replace(fString, CHR(13)&CHR(10), ) 回车换行 end if fString = Replace(fString, select, select) fString = Replace(fString, join, join) fString = Replace(fString, union, union) fString = Replace(fString, where, where) fString = Replace(fString, inser
22、t, insert) fString = Replace(fString, delete, delete) fString = Replace(fString, update, update) fString = Replace(fString, like, like) fString = Replace(fString, drop, drop) fString = Replace(fString, create, create) fString = Replace(fString, modify, modify) fString = Replace(fString, rename, rena
23、me) fString = Replace(fString, alter, alter) fString = Replace(fString, cast, cast) HTMLDecode = fString End If End Function/* 防注入 */Function FunSQL(Str)If Isnull(Str) ThenFunSQL = Exit Function End If Str=trim(Str)Str = Replace(Str,Chr(0), 1, -1, 1)Str = Replace(Str, , ", 1, -1, 1)Str = Replace(Str,>, 1, -1, 1) Str =
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1