asp的函數(shù)集[學(xué)練結(jié)合]_第1頁
asp的函數(shù)集[學(xué)練結(jié)合]_第2頁
asp的函數(shù)集[學(xué)練結(jié)合]_第3頁
asp的函數(shù)集[學(xué)練結(jié)合]_第4頁
已閱讀5頁,還剩9頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡介

1、%StartTime=timer()程序執(zhí)行時(shí)間檢測#VIBOVIBOSTUDIO版權(quán)所有Author:ViboEmail:vibo_-ViboASP站點(diǎn)開發(fā)常用函數(shù)庫-OpenDB(vdata_url)-打開數(shù)據(jù)庫getIp()-得到真實(shí)IPgetIPAdress(sip)-查找ip對應(yīng)的真實(shí)地址IP2Num(sip)-限制某段IP地址chkFrom()-防站外提交設(shè)定getsys()-操作系統(tǒng)檢測GetBrowser()-瀏覽器版本檢測GetSearcher()-識別搜索引擎-數(shù)據(jù)過濾-CheckStr(byValChkStr)-檢查無效字符CheckSql()-

2、防止SQL注入U(xiǎn)nCheckStr(Str)-檢查非法sql命令Checkstr(Str)-ASP最新SQL防注入過濾涵數(shù)HTMLEncode(reString)-過濾轉(zhuǎn)換HTML代碼DateToStr(DateTime,ShowType)-日期轉(zhuǎn)換函數(shù)Date2Chinese(iDate)-獲得ASP的中文日期字符串lenStr(str)-計(jì)算字符串長度(字節(jié))CreateArr(str)-生成二維數(shù)組ShowRsArr(rsArr)-用表格顯示記錄集getrows生成的數(shù)組的表結(jié)構(gòu)-外接組件使用函數(shù)-sendMail(to_Email,from_Email,from_Name,mail_S

3、ubject,mail_Body,mail_htmlBody)-Jmail組件發(fā)送郵件-系統(tǒng)檢測函數(shù)-IsValidUrl(url)-檢測網(wǎng)頁是否有效getHTMLPage(filename)-獲取文件內(nèi)容CheckFile(FilePath)-檢查某一文件是否存在CheckDir(FolderPath)-檢查某一目錄是否存在MakeNewsDir(foldername)-根據(jù)指定名稱生成目錄CreateHTMLPage(filename,FileData,C_mode)生成文件CheckBadWord(byValChkStr)-過濾臟字#DimipData_urlipData_url=./I

4、p.mdbResponse.Write(-客戶端信息檢測-&)Response.Write(getsys()&)Response.Write(GetBrowser()&)Response.Write(GetSearcher()&)Response.Write(IP:&getIp()&)Response.Write(來源:&(getIPAdress(GetIp()&)Response.Write()Response.Write(-數(shù)據(jù)提交檢測-&)ifnotchkFromthenResponse.write(請不要從站外提交內(nèi)容!&)Response.endelseResponse.write(

5、本站提交內(nèi)容!&)EndiffunctionOpenDB(vdata_url)-打開數(shù)據(jù)庫使用:Conn=OpenDB(data/data.mdb)Dimvibo_ConnSetvibo_Conn=Server.CreateObject(ADODB.Connection)vibo_Conn.ConnectionString=Provider=Microsoft.Jet.OLEDB.4.0;DataSource=&Server.MapPath(vdata_url)vibo_Conn.OpenOpenDB=vibo_ConnEndFunctionfunctiongetIp()-得到真實(shí)IPuser

6、ip=Request.ServerVariables(HTTP_X_FORWARDED_FOR)Ifuserip=Thenuserip=Request.ServerVariables(REMOTE_ADDR)getIp=useripEndfunctionFunctiongetIPAdress(sip)-查找ip對應(yīng)的真實(shí)地址Dimiparr,iprs,country,cityIfsip=thensip=iparr=split(sip,.)sip=cint(iparr(0)*256*256*256+cint(iparr(1)*256*256+cint(ip

7、arr(2)*256+cint(iparr(3)-1Dimvibo_ipconn_STRINGvibo_ipconn_STRING=Provider=Microsoft.Jet.OLEDB.4.0;DataSource=&Server.MapPath(ipData_url)Setiprs=Server.CreateObject(ADODB.Recordset)iprs.ActiveConnection=vibo_ipconn_STRINGiprs.Source=SelectTop1city,countryFROMaddressWhereip1=&sip&and&sip&IP2Num(192.1

8、68.0.0)anduserIPnumIP2Num(55)thenresponse.write(您的IP被禁止)response.endendifFunctionchkFrom()-防站外提交設(shè)定Dimserver_v1,server_v2,server1,server2chkFrom=Falseserver1=Cstr(Request.ServerVariables(HTTP_REFERER)server2=Cstr(Request.ServerVariables(SERVER_NAME)IfMid(server1,8,len(server2)=server2Thenc

9、hkFrom=TrueEndFunctionifnotchkFromthenResponse.write(請不要從站外提交內(nèi)容!)Response.endEndiffunctiongetsys()-操作系統(tǒng)檢測vibo_soft=Request.ServerVariables(HTTP_USER_AGENT)ifinstr(vibo_soft,WindowsNT5.0)thenmsm=Win2000elseifinstr(vibo_soft,WindowsNT5.1)thenmsm=WinXPelseifinstr(vibo_soft,WindowsNT5.2)thenmsm=Win2003e

10、lseifinstr(vibo_soft,4.0)thenmsm=WinNTelseifinstr(vibo_soft,NT)thenmsm=WinNTelseifinstr(vibo_soft,WindowsCE)thenmsm=WindowsCEelseifinstr(vibo_soft,Windows9)thenmsm=Win9xelseifinstr(vibo_soft,9x)thenmsm=WindowsMEelseifinstr(vibo_soft,98)thenmsm=Windows98elseifinstr(vibo_soft,Windows95)thenmsm=Windows

11、95elseifinstr(vibo_soft,Win32)thenmsm=Win32elseifinstr(vibo_soft,unix)orinstr(vibo_soft,linux)orinstr(vibo_soft,SunOS)orinstr(vibo_soft,BSD)thenmsm=類Unixelseifinstr(vibo_soft,Mac)thenmsm=Macelsemsm=Otherendifgetsys=msmEndFunctionfunctionGetBrowser()-瀏覽器版本檢測dimvibo_softvibo_soft=Request.ServerVariabl

12、es(HTTP_USER_AGENT)Browser=unknownversion=unknownvibo_soft=Mozilla/4.0(compatible;MSIE6.0;WindowsNT5.0;TencentTraveler;.NETCLR1.1.4322)IfLeft(vibo_soft,7)=MozillaThen有此標(biāo)識為瀏覽器vibo_soft=Split(vibo_soft,;)IfInStr(vibo_soft(1),MSIE)0ThenBrowser=MicrosoftInternetExplorerversion=Trim(Left(Replace(vibo_sof

13、t(1),MSIE,),6)ElseIfInStr(vibo_soft(4),Netscape)0ThenBrowser=Netscapetmpstr=Split(vibo_soft(4),/)version=tmpstr(UBound(tmpstr)ElseIfInStr(vibo_soft(4),rv:)0ThenBrowser=Mozillatmpstr=Split(vibo_soft(4),:)version=tmpstr(UBound(tmpstr)IfInStr(version,)0Thentmpstr=Split(version,)version=tmpstr(0)EndIfEn

14、dIfElseIfLeft(vibo_soft,5)=OperaThenvibo_soft=Split(vibo_soft,/)Browser=Mozillatmpstr=Split(vibo_soft(1),)version=tmpstr(0)EndIfIfversionunknownThenDimTmpstr1Tmpstr1=Trim(Replace(version,.,)IfNotIsNumeric(Tmpstr1)Thenversion=unknownEndIfEndIfGetBrowser=Browser&versionEndfunctionfunctionGetSearcher()

15、-識別搜索引擎Dimbotlist,SearcherDimvibo_softvibo_soft=Request.ServerVariables(HTTP_USER_AGENT)Botlist=Google,Isaac,SurveyBot,Baiduspider,ia_archiver,P.Arthur,FAST-WebCrawler,Java,Microsoft-ATL-Native,TurnitinBot,WebGather,Sleipnir,TencentTravelerBotlist=split(Botlist,)Fori=0toUBound(Botlist)IfInStr(vibo_s

16、oft,Botlist(i)0ThenSearcher=Botlist(i)&搜索器IsSearch=TrueExitForEndIfNextIfIsSearchThenGetSearcher=SearcherelseGetSearcher=unknownEndifEndfunction-數(shù)據(jù)過濾-FunctionCheckSql()防止SQL注入Dimsql_injdataSQL_injdata=|and|exec|insert|select|delete|update|count|*|%|chr|mid|master|truncate|char|declareSQL_inj=split(S

17、QL_Injdata,|)IfRequest.QueryStringThenForEachSQL_GetInRequest.QueryStringForSQL_Data=0ToUbound(SQL_inj)ifinstr(Request.QueryString(SQL_Get),Sql_Inj(Sql_DATA)0ThenResponse.Writealert(請不要在參數(shù)中包含非法字符!);history.back(-1)Response.endendifnextNextEndIfIfRequest.FormThenForEachSql_PostInRequest.FormForSQL_Da

18、ta=0ToUbound(SQL_inj)ifinstr(Request.Form(Sql_Post),Sql_Inj(Sql_DATA)0ThenResponse.Writealert(請不要在參數(shù)中包含非法字符!);history.back(-1)Response.endendifnextnextendifEndFunctionFunctionCheckStr(byValChkStr)檢查無效字符DimStr:Str=ChkStrStr=Trim(Str)IfIsNull(Str)ThenCheckStr=ExitFunctionEndIfDimreSetre=newRegExpre.Ig

19、noreCase=Truere.Global=Truere.Pattern=(rn)3,Str=re.Replace(Str,$1$1$1)Setre=NothingStr=Replace(Str,)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,updat

20、e)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)CheckStr=StrEndFunctionFunctionUnCheckStr(Str)檢查非法sql命令Str=Replace(Str,select,select)Str=Replace(Str,j

21、oin,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

22、=Replace(Str,alter,alter)Str=Replace(Str,cast,cast)UnCheckStr=StrEndFunctionFunctionCheckstr(Str)SQL防注入過濾涵數(shù)IfIsnull(Str)ThenCheckStr=ExitFunctionEndIfStr=Replace(Str,Chr(0),1,-1,1)Str=Replace(Str,1,-1,1)Str=Replace(Str,1,-1,1)Str=Replace(Str,script,script,1,-1,0)Str=Replace(Str,SCRIPT,SCRIPT,1,-1,0)

23、Str=Replace(Str,Script,Script,1,-1,0)Str=Replace(Str,script,Script,1,-1,1)Str=Replace(Str,object,object,1,-1,0)Str=Replace(Str,OBJECT,OBJECT,1,-1,0)Str=Replace(Str,Object,Object,1,-1,0)Str=Replace(Str,object,Object,1,-1,1)Str=Replace(Str,applet,applet,1,-1,0)Str=Replace(Str,APPLET,APPLET,1,-1,0)Str=

24、Replace(Str,Applet,Applet,1,-1,0)Str=Replace(Str,applet,Applet,1,-1,1)Str=Replace(Str,)Str=Replace(Str,)Str=Replace(Str,1,-1,1)Str=Replace(Str,=,=,1,-1,1)Str=Replace(Str,1,-1,1)Str=Replace(Str,select,select,1,-1,1)Str=Replace(Str,execute,execute,1,-1,1)Str=Replace(Str,exec,exec,1,-1,1)Str=Replace(St

25、r,join,join,1,-1,1)Str=Replace(Str,union,union,1,-1,1)Str=Replace(Str,where,where,1,-1,1)Str=Replace(Str,insert,insert,1,-1,1)Str=Replace(Str,delete,delete,1,-1,1)Str=Replace(Str,update,update,1,-1,1)Str=Replace(Str,like,like,1,-1,1)Str=Replace(Str,drop,drop,1,-1,1)Str=Replace(Str,create,create,1,-1

26、,1)Str=Replace(Str,rename,rename,1,-1,1)Str=Replace(Str,count,count,1,-1,1)Str=Replace(Str,chr,chr,1,-1,1)Str=Replace(Str,mid,mid,1,-1,1)Str=Replace(Str,truncate,truncate,1,-1,1)Str=Replace(Str,nchar,nchar,1,-1,1)Str=Replace(Str,char,char,1,-1,1)Str=Replace(Str,alter,alter,1,-1,1)Str=Replace(Str,cas

27、t,cast,1,-1,1)Str=Replace(Str,exists,exists,1,-1,1)Str=Replace(Str,Chr(13),1,-1,1)CheckStr=Replace(Str,1,-1,1)EndFunctionFunctionHTMLEncode(reString)過濾轉(zhuǎn)換HTML代碼DimStr:Str=reStringIfNotIsNull(Str)ThenStr=UnCheckStr(Str)Str=Replace(Str,&,&)Str=Replace(Str,)Str=Replace(Str,)Str=Replace(Str,CHR(32),)Str=

28、Replace(Str,CHR(9),)Str=Replace(Str,CHR(9),)Str=Replace(Str,CHR(34),)Str=Replace(Str,CHR(39),)Str=Replace(Str,CHR(13),)Str=Replace(Str,CHR(10),)HTMLEncode=StrEndIfEndFunctionFunctionDateToStr(DateTime,ShowType)日期轉(zhuǎn)換函數(shù)DimDateMonth,DateDay,DateHour,DateMinuteDateMonth=Month(DateTime)DateDay=Day(DateTim

29、e)DateHour=Hour(DateTime)DateMinute=Minute(DateTime)IfLen(DateMonth)2ThenDateMonth=0&DateMonthIfLen(DateDay)12ThenDateHour=DateHour-12DateAMPM=PMElseDateHour=DateHourDateAMPM=AMEndIfIfLen(DateHour)2ThenDateHour=0&DateHourIfLen(DateMinute)2ThenDateMinute=0&DateMinuteDateToStr=Year(DateTime)&-&DateMon

30、th&-&DateDay&DateHour&:&DateMinute&DateAMPMCaseY-m-dH:I:SDimDateSecondDateSecond=Second(DateTime)IfLen(DateHour)2ThenDateHour=0&DateHourIfLen(DateMinute)2ThenDateMinute=0&DateMinuteIfLen(DateSecond)2ThenDateSecond=0&DateSecondDateToStr=Year(DateTime)&-&DateMonth&-&DateDay&DateHour&:&DateMinute&:&Dat

31、eSecondCaseYmdHISDateSecond=Second(DateTime)IfLen(DateHour)2ThenDateHour=0&DateHourIfLen(DateMinute)2ThenDateMinute=0&DateMinuteIfLen(DateSecond)2ThenDateSecond=0&DateSecondDateToStr=Year(DateTime)&DateMonth&DateDay&DateHour&DateMinute&DateSecondCaseymDateToStr=Right(Year(DateTime),2)&DateMonthCasedDateT

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論