<%
'******************************************************************************************
' Software name: Max(马克斯) Content Management System
' Version:4.0
' Web: http://www.maxcms.net
' Author: 石头(maxcms2008@qq.com),yuet,长明,酒瓶
' Copyright (C) 2005-2009 马克斯官方 版权所有
' 法律申明：MaxCMS程序所有代码100%原创、未引入任何网上代码,对一切抄袭行为、坚决严肃追究法律责任
'******************************************************************************************
'警告:如没有必要请禁止 调用 执行VB脚本 或 execute 函数 默认为禁止(true)有效防止非法脚本的执行
'禁止采集脚本通过execute执行VBSCRIPT: 禁止设为true 允许设为false
Dim tConn,tQuery,tDic,tTypeDic,gHttpObj:tConn=null:Const BANVBSCRIPT = true:Const TEMPDATABASEFILENAME="tempdata.mdb":Const ESCDIR = "escript/":Const ESCACHEDIR = "cache/":Const ESMODELDIR = "model/":Const ISDEBUG = false:Dim initStep:initStep=1:Function Object():SET Object = Server.CreateObject(DICTIONARY_OBJ_NAME):Object.CompareMode=1:End Function:Sub SetEScriptEngine(Byval VarName):VarName=addcslashes(VarName):execute("SET "&VarName&"=new TEScriptEngine:SET "&VarName&".Self="&VarName&":"&VarName&".this(0)="""&VarName&""""):End Sub:Class TEScriptEngine:Public Self:Private fFile,eEscript,fEscript,fENV,fRegFun,fthisVarName,fUserEfun,fMode:Private m_l2Power(30),m_lOnBits(30),m_l_inited:Private curFunHas,fUFReturn,isLoadDLL:Private Sub Class_Initialize():curFunHas=array():SET fENV = Object():SET fRegFun = Object():SET fUserEfun=Object():fthisVarName="":fMode=2:isLoadDLL=false:m_l_inited=false:Initialize:End Sub:Private Sub Class_Terminate():fENV.RemoveAll():fRegFun.RemoveAll():fUserEfun.RemoveAll():SET fENV = nothing:SET fRegFun = nothing:SET fUserEfun=nothing:End Sub:Private Sub InitBits:if m_l_inited<>true then:dim i:m_l2Power(0)=1:for i=1 to 30:m_l2Power(i)=m_l2Power(i-1)*2:m_lOnBits(i-1)=m_l2Power(i)-1:next:m_lOnBits(0)=1:m_lOnBits(30)=m_l2Power(30)*2-1:end if:End Sub:Public Sub Print(ByVal Str):if fMode<>2 AND ISDEBUG<>true then:echo Str:end if:End Sub:Public Sub Initialize:Dim t,i,FuncHas,Has:fENV.RemoveAll:fRegFun.RemoveAll:fUserEfun.RemoveAll:ReDim curFunHas(-1):fEscript="":eEscript="":FuncHas="HTTP读文件=GetHttpFile;HTTP读文本文件=GetHttpTextFile;":FuncHas = FuncHas&"删除变量=delete;执行VB脚本=l10O;execute=l10O;终止输出=die;调试输出=Print;类型名=typename;类型值=VarType;执行=CallEFun;返回=return;是组数组=isArray;是对象=isObject;":FuncHas = FuncHas&"取函数指针=GetEFunPointer;如果真=ifthen;载入动态链接库=LoadDLLFile;":FuncHas = FuncHas&"解释绝对网址=l111;生成批量地址=l11O;替换特殊链接=l1O0;替换特殊链接组=l11l;获得下次执行时间=getNextRunTime;":FuncHas = FuncHas&"电影入库=lO0O;智能归类=l1l1;分类ID到名称=ClassID2Name;过滤字典=l1Ol;":FuncHas = FuncHas&"设置=SET;创建对象=Object;创建影片信息类=Object;创建采集进程=GatHerProcess;创建映象文件=CreateMappingFile;释放映象文件=FreeMappingFile;":FuncHas = FuncHas&"字节集到文本=bytesToStr;寻找文本B=instrB;取节集长度=lenB;取节集左边=leftB;取节集右边=rightB;取字集中间=MidB;字符B=ChrB;字符W=ChrW;取代码B=AscB;取代码W=AscW;":FuncHas = FuncHas&"到文本=CStr;删全部空=TrimAll;文本比较=StrComp;取文本长度=len;取文本左边=left;取文本右边=right;取文本中间=mid;截取文本中间=StrSlice;截取文本中间B=StrSliceB;截取文本中间I=StrSliceI;字符=chr;取代码=asc;寻找文本位置=jsIndexOf;寻找文本=InStr;倒找文本=InStrRev;到大写=UCase;到小写=LCase;":FuncHas = FuncHas&"删首空=LTrim;删尾空=RTirm;删首尾空=trim;文本替换=Replace;HTML编码=HTMLEncode;取空白文本=space;取重复文本=String;分割文本=split;分割文本段=StrSplits;":FuncHas = FuncHas&"规则替换=RegReplace;规则搜索=RegExpExec;规则匹配数=RegMatchesCount;删除HTML代码=l1O1;URL编码=URLEncode;":FuncHas = FuncHas&"是数组=isArray;创建数组=Array;数组到文本=Join;取数组成员数=Ubound;加入成员=l0O;弹出成员=l0l;弹出首成员=l10;移除数组重复值=l0lO;数组顺序颠倒=l0ll;":FuncHas = FuncHas&"是初始化=isEmpty;是空=isNull;是数字=isNumeric;到数字=Str2Num;到数值=CDbl;到整数=CInt;到长整数=CLng;到短整数=CSng;取十六进制文本=Hex;取八进制文本=Oct;递增=l1O;递减=lO0;先递增=l11;先递减=l1l;四舍五入=Round;取随机数=Random;":FuncHas = FuncHas&"是日期=IsDate;取时间=time;取系统时间=now;取日期=Date;取年份=Year;取月份=Month;取日=day;取星期几=Weekday;取小时=Hour;取分钟=Minute;取秒=Second;":FuncHas = FuncHas&"到时间=CDate;增减时间=DateAdd;取时间间隔=DateDiff;取时间部分=DatePart;Dateserial=Dateserial;到日期=Datevalue;TimeSerial=TimeSerial":Has=split(FuncHas,";"):for i=0 to UBound(Has):if Has(i)<>"" then:t=split(Has(i),"="):fRegFun.item(t(0))=t(1):fRegFun.item(t(1))=t(1):end if:next:eConst("真")=true:eConst("假")=false:eConst("空")=Empty:eConst("开启")=true:eConst("关闭")=false:eConst("换行符")=vbcrlf:eConst("进程标识ID")=0:eConst("演示模式")=0:eConst("不执行")=1:eConst("执行模式")=2:eConst("年份")="yyyy":eConst("季度")="q":eConst("月份")="m":eConst("日")="d":eConst("小时")="h":eConst("分钟")="n":eConst("秒")="s":eConst("星期几")="w":eConst("临时库")=0:eConst("直接入库")=1:eConst("所有HTML标签")="SCRIPT|STYLE|*":eConst("标题过滤")=0:eConst("剧情过滤")=1:End Sub:Public Function LShift(lValue, iShiftBits):InitBits:if iShiftBits = 0 then:LShift = lValue:exit function:end if:if iShiftBits = 31 then:LShift = ifthen(lValue And 1,&H80000000,0):exit function:end if:if iShiftBits < 0 Or iShiftBits > 31 then:Err.Raise 6:end if:LShift = ifthen((lValue And m_l2Power(31 - iShiftBits)),((lValue And m_lOnBits(31 - (iShiftBits + 1))) * m_l2Power(iShiftBits)) Or &H80000000,((lValue And m_lOnBits(31 - iShiftBits)) * m_l2Power(iShiftBits))):End Function:Public Function RShift(lValue, iShiftBits):InitBits:if iShiftBits = 0 then:RShift = lValue:exit function:end if:if iShiftBits = 31 then:RShift = ifthen(lValue And &H80000000,1,0):exit function:end if:if iShiftBits < 0 Or iShiftBits > 31 then:Err.Raise 6:end if:RShift = (lValue And &H7FFFFFFE) \ m_l2Power(iShiftBits):if (lValue And &H80000000) then:RShift = (RShift Or (&H40000000 \ m_l2Power(iShiftBits - 1))):end if:End Function:Private Function GetVBFuncName(ByVal FunKey):Dim tFunKey,b:tFunKey=UCase(FunKey):b=fUserEFun.Exists(FunKey):if jsIndexOf("|XVAL|ECONST|CALL|EXIT|CALLEFUN|","|"&tFunKey&"|")=-1 AND not b AND not fRegFun.Exists(FunKey) then:throw 1245,"函数未注册："&FunKey:end if:GetVBFuncName=ifthen(b,FunKey,fRegFun(FunKey)):End Function:Public Sub SETxVal(ByVal name,ByVal val):if not fENV.Exists(name) AND UBound(curFunHas)>-1 then:dim tFn:tFn=curFunHas(UBound(curFunHas))&".":if not fENV.Exists(tFn) then:SET fENV.item(tFn)=Object():end if:SET tFn=fENV.item(tFn):if tFn.Exists(name) then:SET tFn.item(name)=nothing:end if:SET tFn.item(name)=val:else:if fENV.Exists(name) then:SET fENV.item(name)=nothing:end if:SET fENV.item(name)=val:end if:End Sub:Public Property LET aVal(ByVal name,Byval iIndex,ByVal val):dim x:if not fENV.Exists(name) AND UBound(curFunHas)>-1 then:dim tFn:tFn=curFunHas(UBound(curFunHas))&".":if not fENV.Exists(tFn) then:SET fENV.item(tFn)=Object():end if:SET tFn=fENV.item(tFn):l0O1 x,tFn.item(name):if isObject(x) then:x(iIndex)=val:exit Property:end if:if not isArray(x) then:throw 1298,"类型不匹配":end if:if UBound(x)<iIndex then:throw 1298,"超出下标界限":else:x(iIndex)=val:tFn.item(name)=x:end if:else:l0O1 x,fENV.item(name):if isObject(x) then:x(iIndex)=val:exit property:end if:if not isArray(x) then:throw 1298,"类型不匹配":end if:if UBound(x)<iIndex then:throw 1298,"超出下标界限":else:x(iIndex)=val:fENV.item(name)=x:end if:end if:End Property:Public Default Property GET xVal(ByVal name):dim dm,ENV:if UBound(curFunHas)>-1 then:dm=curFunHas(UBound(curFunHas))&".":end if:if fENV.Exists(dm) then:l0O1 ENV,fENV.item(dm):if isObject(ENV) then:if ENV.Exists(name) then:l0O1 xVal,ENV.item(name):exit Property:end if:end if:end if:l0O1 xVal,IfThen(fENV.Exists(name),fENV.item(name),""):End Property:Public Property LET xVal(ByVal name,ByVal val):if isString(val) then:val=replace(replace(val,"\r",chr(13)),"\n",chr(10)):end if:if not fENV.Exists(name) AND UBound(curFunHas)>-1 then:dim tFn:tFn=curFunHas(UBound(curFunHas))&".":if not fENV.Exists(tFn) then:SET fENV.item(tFn)=Object():end if:SET tFn=fENV.item(tFn):if Not tFn.Exists(name) then:tFn.add name,val:else:tFn.item(name)=val:end if:else:if Not fENV.Exists(name) then:fENV.add name,val:else:fENV.item(name)=val:end if:end if:End Property:Public Property SET xVal(ByVal name,ByVal val):SETxVal name,val:End Property:Public Property GET eConst(ByVal name):eConst=IfThen(fENV.Exists("#"&name),fENV.item("#"&name),""):End Property:Public Property LET eConst(ByVal name,ByVal val):if Not fENV.Exists("#"&name) then:fENV.add "#"&name,val:else:throw 2263,"非法赋值:#"&name:end if:End Property:Private Sub delete(ByVal name):if UBound(curFunHas)>-1 then:dim tFn:tFn=curFunHas(UBound(curFunHas))&".":if fENV.Exists(tFn) then:SET tFn=fENV.item(tFn):if tFn.Exists(name) then:tFn.Remove(name):Exit Sub:end if:end if:end if:if fENV.Exists(name) then:fENV.Remove(name):end if:End Sub:Public Property Get this(ByVal FuncName):this=fThisVarName&ifThen(FuncName<>"","."&FuncName,""):End Property:Public Property Let this(ByVal Key,ByVal Val):if fThisVarName="" then:fThisVarName=Val:end if:End Property:Public Sub l0O(ByVal name,ByVal value):Dim x:x=xVal(name):Push x,value:xVal(name)=x:End Sub:Public Function l0l(ByVal name):Dim x:x=xVal(name):l0l=Pop(x):xVal(name)=x:End Function:Public Function l10(ByVal name):Dim x:x=xVal(name):l10=UnShift(x):xVal(name)=x:End Function:Public Function l1O(ByVal name):if jsIndexOf(name,"#")<>-1 then:throw 2281,"非法赋值:"&name:end if:if UCASE(typeName(name))="INTEGER" then:l1O=iInc(name):else:l1O=xVal(name):xVal(name)=xVal(name)+1:end if:End Function:Public Function l11(ByVal name):if jsIndexOf(name,"#")<>-1 then:throw 2291,"非法赋值:"&name:end if:if UCASE(typeName(name))="INTEGER" then:l11=iInc(name):else:xVal(name)=xVal(name)+1:l11=xVal(name):end if:End Function:Public Function lO0(ByVal name):if jsIndexOf(name,"#")<>-1 then:throw 2300,"非法赋值:"&name:end if:if UCASE(typeName(name))="INTEGER" then:lO0=iDec(name):else:lO0=xVal(name):xVal(name)=xVal(name)-1:end if:End Function:Public Function l1l(ByVal name):if jsIndexOf(name,"#")<>-1 then:throw 2309,"非法赋值:"&name:end if:if UCASE(typeName(name))="INTEGER" then:l1l=iDec(name):else:xVal(name)=xVal(name)-1:l1l=xVal(name):end if:End Function:Public Function BitOR(ByRef var1,ByRef var2):if isNull(var1) OR isEmpty(var1) OR var1="" OR var1=0 then:BitOR=var2:else:BitOR=var1:end if:End Function:Public Sub throw(ByVal num,ByVal description):if mode=1 then:err.clear:exit sub:end if:on Error Resume Next:dim pos:pos=xVal("ESCRIPTPOS"):num=hex(num):num=LCASE(Ifthen(len(num)<3,left("000",3-len(num))&num,num)):description="MaxCMS 采集脚本解释引擎 采集脚本错误 '800a"&num&"'<br><br>行："&(pos+1)&"<br>错误："&description&"<br>语句：":description=description&"<font color=red>"&HTMLencode(trim(eEscript(pos)))&"</font>":description=description&"<br>"&ESCDIR&fFile:echo description:response.end:Err.clear:End Sub:Public Function ParseVal2(ByVal ESBlack,ByVal QF,ByVal QA,ByVal QS,ByVal Q1):ParseVal2="xVal("""&Q1&""")":End Function:Private Function l010(ByVal ESBlack):l010=RegReplace(ESBlack,"/#([a-zA-Z\u4e00-\u9fa5][\w\u4e00-\u9fa5\.]*)/g","eConst"):End Function:Public Function ParseOperator(ByVal ESBlack,ByVal Var,ByVal op,ByVal Var2):ParseOperator=Var&"="&Var&" "&op&" "&Var2:End Function:Public Function ParseOperator2(ByVal ESBlack,ByVal Var,ByVal op,ByVal Var2):SELECT CASE op:CASE "^":ParseOperator2=Var&" XOR "&Var2:CASE "%":ParseOperator2=Var&" MOD "&Var2:CASE "|":ParseOperator2="BitOR("&Var&","&Var2&")":CASE "<<":ParseOperator2="LShift("&Var&","&Var2&")":CASE ">>":ParseOperator2="RShift("&Var&","&Var2&")":END SELECT:End Function:Public Function ParseVal(ByVal ESBlack):ParseVal=RegReplaceE(ESBlack,"/([a-zA-Z\u4e00-\u9fa5][\w\u4e00-\u9fa5\.\_]*)\s?(\(.+\))|(\"".*?\"")|([a-zA-Z\u4e00-\u9fa5][\w\u4e00-\u9fa5\.\_]*)/g",array("",this("l1"),"",this("ParseStr"),this("ParseVal2"))):ParseVal=Replace(Replace(Replace(Replace(ParseVal,"&&"," AND "),"||"," OR "),"==","="),"!=","<>"):End Function:Public Function replaceQuot(Byval m0,Byval m1,Byval m2,Byval m3,Byval m4,Byval m5,Byval m6,Byval m7):replaceQuot=m1&m5&Replace(Replace(stripcslashes(Replace(RegReplace(m2&m6,"/\\([\'\\\/])/ig","$1"),"\""","""""")),"\r\n","""&vbcrlf&"""),"#","""&Chr(35)&""")&m3&m7&m4:End Function:Public Function ll1(Byval Str):Str=regReplaceE(Str,"/(\"")(.*?)(\"")(,)|(\"")(.*?)(\"")\s*$/g",array(this("replaceQuot"))):ll1=RegReplace(Str,"/([^\\])\\\""/g","$1"""""):End Function:Public Function ParseStr(ByVal ESBlack):ParseStr=ll1(ESBlack):End Function:Public Function l0(ByVal ESBlack):l0=RegReplaceE(ll1(ESBlack),"/([a-zA-Z\u4e00-\u9fa5][\w\u4e00-\u9fa5\.\_]*)\s?(\(.+\))|(\"".*\"")|(.+)/g",array("",this("l1"),"",this("ParseStr"),this("l000"))):End Function:Public Function l1(ByVal ESBlack,ByVal FuncName,ByVal Arg):if fUserEfun.Exists(FuncName) then:l1 = "CallEFun("""&FuncName&""",array"&l0(Arg)&")":else:if JsIndexOf(FuncName,".")<>-1 then:FuncName=ParseVal(FuncName):else:FuncName=GetVBFuncName(FuncName):end if:l1 = FuncName&l0(Arg):end if:End Function:Public Function l000(ByVal ESBlack):l000=RegReplaceE(ESBlack,"/([a-zA-Z\u4e00-\u9fa5][\w\u4e00-\u9fa5\.\_]*)\s?(\(.*\))|(\"".*\"")|(.+)/g",array("",this("l1"),"",this("ParseStr"),this("ParseVal"))):End Function:Public Function l110(ByVal ESBlack,Byval Q1,Byval Q2,ByVal Q3):Q1=UCase(Q1):if Q1="IF" then:l110="IF "&ParseVal(Q2)&" THEN":exit function:end if:l110=ifthen(Q1="FOR","FOR "&l000(Q2)&" TO "&ParseVal(Q3),vbcrlf&"DO WHILE "&l000(Q2)):End Function:Private Function l1OO(ByVal Escript):Escript=RegReplace(Escript,"/\s*否则如果\s*\((.+)\)/ig",vbcrlf&"ELSEIF $1 THEN"):Escript=RegReplace(Escript,"/\s*否则/ig",vbcrlf&"ELSE"):Escript=RegReplace(Escript,"/\s*如果\s*\((.+)\)/ig",vbcrlf&"IF $1 THEN"):Escript=RegReplaceE(Escript,"/(IF) (.+) THEN/ig",array("",this("l110"))):l1OO=RegReplace(Escript,"/\s*结束\s*如果/ig",vbcrlf&"END IF"):End Function:Private Function l001(ByVal Escript):dim i,sLins:sLins=Split(Escript,vbcrlf):dim rg,rg2,ms,sTo:sTo=array():SET rg=jsRegExp("/计数循环\s*\(\s*([a-zA-Z\u4e00-\u9fa5][^;]+)\s*;\s*([^;]+)\s*;\s*([^;)]+)\s*\)/i"):SET rg2=jsRegExp("/结束\s*计数循环/i"):for i=0 to UBound(sLins):if rg.test(sLins(i)) then:SET ms=rg.Execute(sLins(i)).item(0):Push sTo,ms.SubMatches(2):if jsIndexOf(ms.SubMatches(2),"-")=-1 AND jsIndexOf(ms.SubMatches(2),"+")=-1 then:throw 1532,"语法错误："&ms.value:end if:sLins(i)=ms.SubMatches(0)&vbcrlf&"当真("&ms.SubMatches(1)&")":else:if rg2.test(sLins(i)) then:sLins(i)=Pop(sTo)&vbcrlf&"结束当真":end if:end if:next:Escript=Join(sLins,vbcrlf):l001=RegReplace(Escript,"/退出\s*计数循环/ig","退出当真"):End Function:Private Function l00O(ByVal Escript):Escript=RegReplaceE(Escript,"/\s*(循环|当真)\s*\((.+)\)/ig",array("",this("l110"))):Escript=RegReplace(Escript,"/\s*退出\s*(循环|当真)/ig",vbcrlf&"EXIT DO"):l00O=RegReplace(Escript,"/\s*结束\s*(循环|当真)/ig",vbcrlf&"LOOP"):End Function:Private Function l00l(ByVal ESBlack):if jsRegExp("/^\s*(\+\+)([a-zA-Z\u4e00-\u9fa5][\w\u4e00-\u9fa5\.\_]*)|^\s*([a-zA-Z\u4e00-\u9fa5][\w\u4e00-\u9fa5\.\_]*)(\+\+)|\s*(\bDO WHILE\b|\bLOOP\b|\bFOR\b|\bNEXT\b|\bIF\b|\bELSEIF\b|\bELSE\b|\bEND IF\b|\bEXIT\b)/i").test(ESBlack) then:l00l=ESBlack:exit Function:end if:Dim vbs,ms:ms=jsRegExpExec(ESBlack,"/^\s*([a-zA-Z\u4e00-\u9fa5][\w\u4e00-\u9fa5\.\_]*)\s?(\(.*\))/g"):if UBound(ms)>0 then:vbs="Call "&l1(ms(0),ms(1),ms(2)):l00l=vbs:exit Function:end if:ms=jsRegExpExec(ESBlack,"/^\s*([a-zA-Z\u4e00-\u9fa5][\w\u4e00-\u9fa5\.\_]*)\s+([a-zA-Z\u4e00-\u9fa5][\w\u4e00-\u9fa5\.\_]*)(.*)/g"):if UBound(ms)>0 then:ms(1)=GetVBFuncName(ms(1)):if UCASE(ms(1))="CALLEFUN" then:if trim(ms(3)) <> "" then:ms(3)=RegReplace(ms(3),"/\((.*)\)/i","$1"):end if:vbs="Call "&ms(1)&"("&l0(chr(34)&ms(2)&chr(34)&",Array("&ms(3)&"))"):else:if UCASE(ms(1))="SET" then:vbs="SET Self.xVal("""&ms(2)&""")="&l000(RegReplace(ms(3),"/\s*=\s*(.+)/i","$1")):else:vbs="Call "&ms(1)&"("""&ms(2)&""")":end if:end if:l00l=vbs:exit Function:end if:ms=jsRegExpExec(ESBlack,"/(#)?([a-zA-Z\u4e00-\u9fa5][\w\u4e00-\u9fa5\.\_]*)\s*\=\s*(.+)/g"):if UBound(ms)>0 then:vbs=ms(1)&"xVal("""&ms(2)&""")="&l000(ms(3)):l00l=vbs:exit Function:end if:ms=jsRegExpExec(ESBlack,"/(#)?([a-zA-Z\u4e00-\u9fa5][\w\u4e00-\u9fa5\.\_]*)\[([\w\u4e00-\u9fa5\.\_\(\)\""]+)\](\s*\=\s*(.+))?/ig"):if UBound(ms)>0 then:vbs=ms(1)&"aVal("""&ms(2)&""","&l000(ms(3))&")"&ifthen(ms(5)<>Empty,"="&l000(ms(5)),""):l00l=vbs:exit Function:end if:End Function:Public Function ParseDeUserFun(ByVal ESBlack,ByVal F1,ByVal Arg1,ByVal qt,ByVal F2,ByVal Arg2):ParseDeUserFun=ESBlack:End Function:Public Function ParseBlack(ByVal Escript,ByVal BE,ByVal ESC,ByVal EN,ByVal sLine):Dim i,tk,BL:BL=ifthen(sLine<>"",array(sLine),Split(ESC,chr(13)&chr(10))):tk=Join(fUserEfun.keys,"|"):for i=0 to UBound(BL):BL(i)=l010(l00l(BL(i))):next:ParseBlack=BE&Join(BL,chr(13)&chr(10))&EN:End Function:Private Function ParseEFuncBlack(ByVal Escript):ParseEFuncBlack=RegReplaceE(Escript,"/([a-zA-Z\u4e00-\u9fa5][\w\u4e00-\u9fa5\.\_]*\s*\(.*\)\{)([\w\W]+?)(\}[\r\n|\;])|(.+)/g",array(this("ParseBlack"))):End Function:Private Sub ParseEScript():fEscript=l00O(l001(l1OO(fEscript))):fEscript=RegReplaceE(fEscript,"/([^\s]+)\s*([\+\-\*\/\\\^\%\&]|>>|<<)=\s*([^\s]+)/g",array("",this("ParseOperator"))):fEscript=ParseEFuncBlack(fEscript):End Sub:Private Function IsValid():IsValid=False:on Error resume next:execute("IsValid=isObject("&this("")&")"):End Function:Public Sub lO1(ByVal eScript,Byval Funcname,Byval Arg,Byval EBlack):if jsRegExp("/(^\s*,)|(\s*,$)|(,\s*,)|,\s*\d+|^\s*\d+/i").test(Arg) then:throw 1516,"定义函数失败,参数名不正确："&Funcname&"("&Arg&")":end if:fUserEfun(Funcname)=array(Arg,EBlack):End Sub:Public Sub lOO(ByVal eScript,Byval Funcname,Byval Arg,Byval EBlack):if jsRegExp("/(^\s*,)|(\s*,$)|(,\s*,)|,\s*\d+|^\s*\d+/i").test(Arg) then:throw 1516,"定义函数失败,参数名不正确："&Funcname&"("&Arg&")":end if:fUserEfun(Funcname)=array(Arg,EBlack):End Sub:Public Sub return(ByRef Val):l0O1 fUFReturn,Val:Err.Raise 200:End Sub:Public Function CallEFun(ByVal FuncName,ByVal Arg):Push curFunHas,FuncName:if not fUserEfun.Exists(FuncName) then:throw 1518,"函数未定义："&Funcname:else:on Error Resume Next:xVal("arguments")=Arg:dim E,i,Q:E=fUserEfun(FuncName):Q=split(E(0),","):for i=0 to UBound(Q):if isObject(Arg(i)) then:CALL SETxVal(trim(Q(i)),Arg(i)):else:xVal(trim(Q(i)))=Arg(i):end if:next:Err.Clear:execute(E(1)):if err.number>0 then:if err.number = 200 then:err.clear:l0O1 CallEFun,fUFReturn:else:throw err.number,err.description:end if:end if:end if:if fENV.Exists(FuncName&".") then:fENV.item(FuncName&".").RemoveAll():fENV.Remove(FuncName&"."):end if:Pop curFunHas:End Function:Public Function GetEFunPointer(Byval eFunName):GetEFunPointer=this("CallEFun")&"("""&eFunName&""",array([arguments]))":End Function:Public Sub lOl():fEscript=RegReplaceE(fEscript,"/\""(.+)\""/g",array("addcslashes")):fEscript=RegReplace(fEscript,"/\/\*([\w\W]+?)\*\//g",""):fEscript=RegReplace(fEscript,"/([^\r\n]*)\s*\/\/([^\r\n]*)/g","$1"):fEscript=RegReplace(fEscript,"/^\s*\'([^\r\n]*)/g",""):fEscript=RegReplace(fEscript,"/[\r\n]+/g",chr(13)&chr(10)):fEscript=trim(stripcslashes(fEscript)):End Sub:Public Sub ll0(ByVal eScript):if not IsValid then:throw 1526,"EScriptEngine.this内部引用变量名无效":end if:eScript=RegReplace(trim(eScript),"/\\\r\n/g","\\r\n"):if eScript="" then:exit sub:end if:dim i,sLins:sLins=split(RegReplace(eScript,"/(\s+$)/ig",""),vbcrlf):for i=0 to UBound(sLins):if trim(sLins(i))<>"" then:sLins(i)="ESCRIPTPOS="&i&vbcrlf&sLins(i):end if:next:fEscript = Join(sLins,vbcrlf)&vbcrlf:lOl:Call RegReplaceE(fEscript,"/([a-zA-Z\u4e00-\u9fa5][\w\u4e00-\u9fa5\.\_]*)\s*\((.*)\)\{([\w\W]+?)\}[\r\n|\;]/ig",array(this("lO1"))):ParseEScript():fEscript=RegReplace(fEscript,"/(l0O|l0l|l10|GetEFunPointer)(\()xVal\((\""([a-zA-Z\u4e00-\u9fa5][\w\u4e00-\u9fa5\.\_]*)\"")\)/ig","$1$2$3"):fEscript=RegReplace(fEscript,"/(xVal\(\"")?([a-zA-Z\u4e00-\u9fa5][\w\u4e00-\u9fa5\.\_]*)(\""\))?\+\+/ig","l1O(""$2"")"):fEscript=RegReplace(fEscript,"/\+\+(xVal\(\"")?([a-zA-Z\u4e00-\u9fa5][\w\u4e00-\u9fa5\.\_]*)(\""\))?/ig","l11(""$2"")"):fEscript=RegReplace(fEscript,"/(\""\))\[([^\]]+)\]/g","$1($2)"):dim rg:i=0:SET rg=jsRegExp("/(\d+|[a-zA-Z][\w]*\s*\(\""[a-zA-Z\u4e00-\u9fa5][\w\u4e00-\u9fa5\.\_]*\""\))\s*(>>|<<|%|\|)\s*(\d+|[a-zA-Z][\w]*\s*\(\""[a-zA-Z\u4e00-\u9fa5][\w\u4e00-\u9fa5\.\_]*\""\))/ig"):do while rg.test(fEscript) AND i<2000:i=i+1:fEscript=RegReplaceE(fEscript,rg,Array(this("ParseOperator2"))):loop:rg.Pattern="(\"".*)\s+MOD\s+(.+\"")":i=0:do while rg.test(fEscript) AND i<2000:i=i+1:fEscript=rg.replace(fEscript,"$1%$2"):loop:rg.Pattern="(xVal\("")([a-zA-Z\u4e00-\u9fa5][\w\u4e00-\u9fa5\_]*)\.([a-zA-Z\u4e00-\u9fa5][\w\u4e00-\u9fa5\_]*)(""\))":fEscript=rg.replace(fEscript,"$1$2$4.$3"):rg.Pattern="(xVal\(""ESCRIPTPOS""\)\s*=\s*\d+)[\r\n]+(xVal\(""ESCRIPTPOS""\)\s*=\s*\d+)":fEscript=rg.replace(fEscript,"$2"):rg.Pattern="(\s*$)":cacheEScript(rg.replace(Replace(fEscript,vbcrlf,chr(10)),"")):End Sub:Private Sub cacheEScript(ByVal Escript):Dim Hd:Hd="/*"&vbcrlf&"CACHETIME: "&getFileTime(l01O)&vbcrlf&"FILEMD5: "&md5(Len(Escript),16)&vbcrlf&"*/"&vbcrlf&vbcrlf:if not createTextFile(Hd&Escript,l011,"gb2312") then:die "错误：创建或写入“"&l011&"”缓存文件失败，请检查目录(读/写)权限，检查空间是不是满了":end if:End Sub:Private Function l011:l011=ENGINEDIR&ESCACHEDIR&fFile&".es":End Function:Private Function l01O:if isLoadDLL=true then:l01O=ENGINEDIR&ESMODELDIR&fFile:else:l01O=ENGINEDIR&ESCDIR&fFile:end if:End Function:Private Function l01l():l01l="":if isExistFile(l011) then:l01l=loadFile(l011):end if:End Function:Private Sub l01():dim i,sLins:sLins=trim(RegReplaceE(fEscript,"/([a-zA-Z\u4e00-\u9fa5][\w\u4e00-\u9fa5\.\_]*)\s*\((.*)\)\{([\w\W]+?)\}[\r\n|\;]/ig",array(this("lOO")))):on Error Resume Next:execute(sLins):if err.number>0 then:throw err.number,err.description:end if:End Sub:Private Sub l00(ByVal eFile):if mode<0 OR mode>3 then:throw 1799,"无效的执行模式 可选值: 0=演示模式 1=只读配置变量 2=执行模式 3=强制执行":end if:fENV.item("#当前模式")=mode:Dim es,Path:fFile=eFile:es=l01l:Path=l01O:if not isLoadDLL then:fENV.item("#进程标识ID")=fFile:end if:Dim bool,CACHETIME,FILDMD5:CACHETIME=trim(StrSlice(es,"CACHETIME: ",vbcrlf)):FILDMD5=StrSlice(es,"FILEMD5: ",vbcrlf):es=trim(jsSlice(es,jsIndexOf(es,vbcrlf&vbcrlf)+3,0)):if not isExistFile(Path) then:die "采集脚本不存在: "&Path:end if:if ISDEBUG OR es="" OR FILDMD5<>MD5(Len(es),16) OR NOT isDate(CACHETIME) then:bool=true:else:if CDate(CACHETIME)<>CDate(getFileTime(Path)) then:bool=true:end if:end if:eEscript=RegReplace(LoadFile(Path),"/(\s+$)/ig",""):if bool=true then:delFile ENGINEDIR&ESCACHEDIR&eFile&".es":delFile ENGINEDIR&ESCACHEDIR&eFile&".ec":ll0(eEscript):else:fEscript=es:end if:eEscript=split(eEscript,vbcrlf):Call l01():End Sub:Public Sub execEScript(ByVal eFile):if fENV.count>0 then:Initialize():end if:isLoadDLL=false:l00(eFile):End Sub:Public Sub LoadDLLFile(ByVal eFile):if mode<>1 then:isLoadDLL=true:l00(eFile):end if:End Sub:Public Property LET mode(Byval Val):if not IsNumeric(Val) then:die "无效的执行模式 可选值: 0=演示模式 1=只读配置变量 2=执行模式 3=强制执行":else:fMode=Val:fENV.item("#当前模式")=Val:end if:End Property:Public Property GET mode():mode=fMode:End Property:Function addcslashes(ByVal str):addcslashes=RegReplace(str,"/([\""])/ig","\$1"):End Function:End Class:Function l0O1(ByRef Var,ByVal Val):if isObject(val) then:if isObject(Var) then:SET Var=nothing:end if:SET Var=Val:SET l0O1=Val:else:Var=Val:l0O1=Val:end if:End Function:Function l0OO(ByVal var1,ByVal var2):if typename(var1)<>typename(var2) then:l0OO=false:exit function:end if:if typename(var1)="Object" then:l0OO=var1 is var2:exit function:end if:if typename(var1)="Variant()" then:l0OO=join(var1,"$")=join(var2,"$"):else:l0OO=var1=var2:end if:End Function:Function Random():Randomize():Random=Rnd:End Function:Sub Push(ByRef Arr,ByRef Val):on Error resume next:Dim l:l=UBound(Arr)+1:l=ifthen(err,0,l):ReDim Preserve Arr(l):if isObject(Val) then:SET Arr(l)=Val:else:Arr(l)=Val:end if:End Sub:Function Pop(ByRef Arr):dim l:l=UBound(Arr):on Error resume next:l0O1 Pop,Arr(l):ReDim Preserve Arr(l-1):End Function:Function unShift(ByRef Arr):dim i,t:t=array():on Error resume next:l0O1 unShift,Arr(0):For i=1 to UBound(Arr):Push t,Arr(i):Next:ReDim Arr(-1):Arr=t:End Function:Function concat(ByVal Arr1,ByVal Arr2):dim i:for i=0 to Ubound(Arr2):Push Arr1,Arr2(i):next:concat = Arr1:End Function:Function Splice(ByRef Arr,ByVal Start,ByVal Length):Splice=jsSplice(Arr,Start,Length,null):End Function:Function jsSplice(ByRef Arr,ByVal Start,ByVal Length,ByVal arg):Dim ret,i,t,al,iEnd:iEnd=Start+Length:al=Ubound(Arr):t=array():ret=array():for i=Start to iEnd-1:Push ret,Arr(i):next:for i=iEnd to al:Push t,Arr(i):next:ReDim Preserve Arr(Start-1):if IsArray(arg) then:for i=0 to UBound(arg):Push Arr,arg(0):next:end if:for i=0 to UBound(t):Push Arr,t(i):next:jsSplice=ret:End Function:Function l0lO(ByVal arr):dim i,j,ret,bol:ret=array():for i=0 to UBound(arr):bol=true:for j=UBound(ret) to 0 step -1:if l0OO(arr(i),ret(j)) then:bol=false:exit for:end if:next:if bol then:Push ret,arr(i):end if:next:l0lO=ret:End Function:Function l0ll(ByVal arr):dim i,ret:ret=array():for i=UBound(arr) to 0 step -1:Push ret,arr(i):next:l0ll=ret:End Function:Function getFileTime(Byval Path):Path=Server.MapPath(Path):if objFso.FileExists(Path) then:Dim f:SET f=objFso.getFile(Path):getFileTime=f.DateLastModified:SEt f=nothing:else:getFileTime="N/A":end if:End Function:Function jsCharAt(ByVal Str,ByVal iIndex):jsCharAt=jsSubstr(Str,iIndex,1):End Function:Function jsCharAtCode(ByVal Str,ByVal iIndex):jsCharAtCode=Asc(jsSubstr(Str,iIndex,1)):End Function:Function jsIndexOf(ByVal Str,ByVal substr):Dim Pos:Pos=inStr(chr(0)&Str,substr):jsIndexOf=IfThen(Pos=0,-1,Pos-1):End Function:Function jsSubstr(ByVal Str,ByVal Start,ByVal Length):jsSubstr=Mid(Str,Start+1,IfThen(Length<0,0,Length)):End Function:Function jsSlice(ByVal Str,ByVal Start,ByVal iEnd):jsSlice=jsSubstr(Str,Start,IfThen(iEnd<1,len(Str)+iEnd,iEnd-1)):End Function:Function isString(ByVal Val):isString=typename(Val)="String":End Function:Function isBool(ByVal Val):isBool=typename(Val)="Boolean":End Function:Function IfThen(ByVal Bool, Byval A,ByVal B):if Bool then:l0O1 IfThen,A:else:l0O1 IfThen,B:end if:End Function:Dim gRegExp:gRegExp=null:Function getGRegExp(ByVal Pattern):if typename(gRegExp) <> "RegExp" then:SET gRegExp=new RegExp:end if:SetRegExpAttribute gRegExp,jsPattern(Pattern):SET getGRegExp=gRegExp:End Function:Sub SetRegExpAttribute(ByRef oRegExp,ByVal aAtt):dim e,pattern:pattern=aAtt(0):e=" "&aAtt(1):with oRegExp:.IgnoreCase=inStr(e,"i")>0:.Global=inStr(e,"g")>0:.Multiline=inStr(e,"m")>0:.Pattern=pattern:end with:End Sub:Function jsPattern(ByVal Pattern):Dim rp,mt:rp=InstrRev(Pattern,"/"):mt=right(Pattern,len(Pattern)-rp):Pattern=Mid(Pattern,2,rp-2):jsPattern=array(Pattern,mt):End Function:Function jsRegExp(ByVal Pattern):SET jsRegExp=new RegExp:SetRegExpAttribute jsRegExp,jsPattern(Pattern):End Function:Function jsRegExpExec(ByVal Str,ByVal Pattern):jsRegExpExec=array():on Error resume next:Dim i,m:SET m=getGRegExp(Pattern).execute(Str).item(0):jsRegExpExec=array(m.value):for i=0 to m.submatches.count-1:Push jsRegExpExec,m.submatches(i):next:End Function:Function RegExpExec(ByVal Str,ByVal Pattern):Dim i,m,ms:RegExpExec=array():on Error resume next:SET ms=getGRegExp(Pattern).execute(Str):for each m in ms:for i=0 to m.submatches.count-1:Push RegExpExec,m.submatches(i):next:next:End Function:Function RegMatchesCount(ByVal Str,ByVal Pattern):RegMatchesCount=getGRegExp(Pattern).execute(Str).count:End Function:Function RegReplace(ByVal Str, ByVal Pattern, ByVal rStr):on Error resume next:if Str="" then:RegReplace="":exit function:end if:Dim rg,m,ms:SET rg=getGRegExp(Pattern):if rg.test(Str) then:RegReplace=rg.Replace(Str,rStr):else:RegReplace=Str:end if:End Function:Function RegReplaceE(ByVal Str, ByVal Pattern, ByVal FuncHas):if Str="" then:RegReplaceE="":exit function:end if:Dim rg,i,m,ms,tFuncHas:if isObject(Pattern) then:SET rg=Pattern:else:SET rg=jsRegExp(Pattern):end if:if rg.test(Str) then:if isObject(FuncHas) then:SET tFuncHas=FuncHas:else:SET tFuncHas=Object():if isArray(FuncHas) then:for i=0 to UBound(FuncHas):tFuncHas("$"&i)=FuncHas(i):next:end if:end if:dim tStr,tmp,arg,Pos,pStart,pEnd,Func,tFunc:SET ms=rg.Execute(Str):Pos=0:tStr=Str:Func="":for each m in ms:arg=array(m.value):Func="":tmp="":for i=0 to m.submatches.count-1:Push arg,m.submatches(i):if Func="" then:tFunc=tFuncHas("$"&(i+1)):if m.submatches(i)<>"" AND tFunc<>Empty then:Func=tFunc:end if:end if:next:Func=IfThen(Func="",trim(tFuncHas("$0")),Func):if Func<>"" then:if UCASE(Func)="NOREPLACE" then:tmp=arg(0):else:tmp=l101(Func,arg):end if:end if:pStart=Pos+jsIndexOf(jsSlice(tStr,Pos,0),arg(0))-1:pEnd=pStart+len(arg(0)):tStr=jsSubstr(tStr,0,pStart)&tmp&jsSlice(tStr,pEnd,0):Pos=pStart+len(tmp):next:RegReplaceE=tStr:else:RegReplaceE=Str:end if:SET rg=nothing:End Function:Function l100(ByVal FunName, ByVal Arg):dim i,vbCall,result:vbCall="":FunName=RegReplace(FunName,"/\'\(\)\,\:/g",""):if isArray(Arg)  then:For i=0 to Ubound(Arg):vbCall=vbCall & IfThen(vbCall<>"",", ","") & "Arg("&i&")":Next:else:vbCall=Arg:end if:execute("result="&FunName&"("&vbCall&")"):l100=result:End Function:Function l101(ByVal FunName, ByVal Arg):Dim i,result:i=0:result="":on Error resume next:result=l100(FunName,Arg):if err.number=0 then:l101=result:exit function:end if:if err.number=450 then:err.clear:l101=l100(FunName,null):Dim nArg:nArg=array():do while err.number=450 AND i<100:i=i+1:Push nArg,UnShift(Arg):l101=l100(FunName,nArg):if err.number<>450 then:exit do:end if:loop:end if:if err.number>1000 AND err.number<3000 then:die err.description:end if:err.clear:End Function:Function addcslashes(ByVal str):addcslashes=RegReplace(str,"/([\(\)\[\]\""\'\.\?\+\-\*\/\\\^\$])/ig","\$1"):End Function:Function stripcslashes(ByVal str):stripcslashes=RegReplace(str,"/\\([\(\)\[\]\""\'\.\?\+\-\*\/\\\^\$])/ig","$1"):End Function:Function TrimAll(ByVal Str):TrimAll=regReplace(Str,"/(\s*)/g",""):End Function:Function Trim(ByVal Str):Trim=regReplace(Str,"/(^\s*)|(\s*$)/g",""):End Function:Function LTrim(ByVal Str):LTrim=regReplace(Str,"/(^\s*)/g",""):End Function:Function RTrim(ByVal Str):RTrim=regReplace(Str,"/(\s*$)/g",""):End Function:Function TEST_HTTP_REFERER():on error resume next:if isBool(Application("TEST_HTTP_REFERER")) then:TEST_HTTP_REFERER=Application("TEST_HTTP_REFERER"):exit function:end if:if GetForm("FUNC", "get")<>"" then:die Request.ServerVariables("ALL_HTTP"):else:TEST_HTTP_REFERER=jsIndexOf(GetHttpTextFile("http://res.maxcms.net/out_all_http/?action=TEST_HTTP_REFERER&FUNC=true","gbk"),"HTTP_REFERER")<>-1:Application("TEST_HTTP_REFERER")=TEST_HTTP_REFERER:end if:err.clear:End Function:Function StrComp(ByVal Str1,ByVal Str2,ByVal bool):Str1=IfThen(CBool(bool)<>true,UCase(Str1),Str1):Str2=IfThen(CBool(bool)<>true,UCase(Str2),Str2):StrComp=IfThen(Str1>Str2,1,IfThen(Str1<Str2,-1,0)):End Function:Function StrSliceI(ByVal Str,ByVal sStr,ByVal eStr):if sStr&eStr="" then:StrSliceI="":exit function:end if:Dim iPos:iPos=JsIndexOf(Str,sStr):StrSliceI="":if iPos=-1 then:exit function:end if:iPos=ifthen(sStr<>"",iPos+Len(sStr),1):StrSliceI=jsSubstr(Str,iPos-1,JsIndexOf(jsSlice(Str,iPos,0),eStr)):End Function:Function StrSlice(ByVal Str,ByVal sStr,ByVal eStr):if sStr&eStr="" then:StrSlice="":exit function:end if:Dim tStr,iPos:tStr=UCase(Str):iPos=JsIndexOf(tStr,UCase(sStr)):StrSlice="":if iPos=-1 then exit function:end if:iPos=ifthen(sStr<>"",iPos+Len(sStr),1):StrSlice=jsSubstr(Str,iPos-1,JsIndexOf(jsSlice(tStr,iPos-1,0),UCase(eStr))-1):End Function:Function StrSliceB(ByVal Str,ByVal sStr,ByVal eStr):if sStr&eStr="" then:StrSliceB=Str:exit function:end if:Dim tStr,iPos:tStr=UCase(Str):iPos=JsIndexOf(tStr,UCase(sStr)):StrSliceB="":if iPos=-1 then:exit function:end if:iPos=ifthen(sStr<>"",iPos+Len(sStr),1):StrSliceB=jsSubstr(Str,iPos-1,InstrRev(jsSlice(tStr,iPos,0),UCase(eStr))):End Function:Function StrSplits(ByVal Str,ByVal sStr,ByVal eStr):StrSplits=RegExpExec(Str,"/"&addcslashes(sStr)&"([\w\W]+?)"&addcslashes(eStr)&"/ig"):End Function:Function l10O(ByVal vbscript):if BANVBSCRIPT then:echo "安全保护提示: 系统禁止执行VB脚本":response.end:else:execute(vbscript):end if:End Function:Function HTMLEncode(ByVal HTMLStr):HTMLEncode = Server.HTMLEncode(HTMLStr):End Function:Function GetHttpFile(ByVal url):url=Replace(""&url,"&amp;","&"):if not isObject(gHttpObj) then:SET gHttpObj=tryXmlHttp():end if:gHttpObj.open "GET",url,False:gHttpObj.setRequestHeader "referer",RegReplace(url,"/(https?\:\/\/\w+)((\.\w+)*(:\d+)?)\/.*/i","$1$2"):gHttpObj.send:GetHttpFile=gHttpObj.responseBody:End Function:Function GetHttpTextFile(ByVal url,ByVal charset):GetHttpTextFile=bytesToStr(GetHttpFile(url),ifThen(charset<>"",charset,"gbk")):End Function:Function l111(ByVal Links,ByVal currUrl):Links=ifthen(isArray(Links),Links,Array(Links)):on Error Resume Next:Dim t,H,i,j,k,rg,ab,qt,Pb,siteUrl:SET rg=jsRegExp("/^\s*[\/\\]/i"):SET ab=jsRegExp("/^http:\/\//i"):SET qt=jsRegExp("/\\([\\\/])/ig"):currUrl=qt.replace(trim(currUrl),"/"):siteUrl=RegReplace(currUrl,"/(https?\:\/\/)((\w+)(\.\w+)*(:\d+)?)\/.*/i","$1$2"):currUrl=replace(currUrl,siteUrl,""):for i=0 to Ubound(Links):H=CStr(Links(i)):if not ab.test(H) then:if rg.test(H) then:Links(i)=siteUrl&H:else:j=UBound(split(H,"../"))+1:t=Split(currUrl,"/"):k=Ubound(t)+1:j=ifthen(j<k,k-j,0)-1:ReDim Preserve t(j):Links(i)=siteUrl&Join(t,"/")&"/"&RegReplace(H,"/([\.]{2}\/)/g",""):end if:end if:next:l111=Links:SET rg=nothing:SET ab=nothing:SET pb=nothing:SET qt=nothing:End Function:Function iDec(ByRef Var):iDec=Var:Var=Var-1:End Function:Function iDec2(ByRef Var):Var=Var-1:iDec=Var:End Function:Function iInc(ByRef Var):iInc=Var:Var=Var+1:End Function:Function iInc2(ByRef Var):Var=Var+1:iInc=Var:End Function:Function Str2Num(ByVal sNum):if not isNumeric(sNum) then:Str2Num=0:exit function:end if:dim x:x=CDBL(sNum):if jsIndexOf(sNum,".")<>-1 OR (x<-2147483647 AND x>2147483647) then:Str2Num=CDbl(sNum):exit function:end if:if x>-32768 AND x<32768 then:Str2Num=CInt(sNum):else:Str2Num=CLng(sNum):end if:End Function:Function l11O(ByVal Url,Byval ValStr, ByVal iStart, ByVal iEnd, ByVal Order):dim i,ret():if Order = true then:for i=iEnd to iStart step -1:Push ret,Replace(Url,ValStr,i):next:else:for i=iStart to iEnd:Push ret,Replace(Url,ValStr,i):next:end if:l11O=ret:End Function:Function l1O0(ByVal sLink,ByVal fLink,ByVal rLink):Dim t,i:t=split(fLink,"[变量]"):if UBound(t)<1 then:l1O0=sLink:else:rLink=join(split(rLink,"[变量]"),"$1"):For i=0 to UBound(t):t(i)=addcslashes(t(i)):Next:l1O0=RegReplace(sLink,"/"&Join(t,"([\w\W]+)")&"/ig",rLink):end if:End Function:Function l11l(ByVal aLinks,ByVal fLink,ByVal rLink):Dim t,i:t=split(fLink,"[变量]"):if UBound(t)<1 then:l11l=aLinks:else:rLink=Join(split(rLink,"[变量]"),"$1"):For i=0 to UBound(t):t(i)=addcslashes(t(i)):Next:fLink=Join(t,"([\w\W]+)"):for i=0 to UBound(aLinks):aLinks(i)=RegReplace(aLinks(i),"/"&fLink&"/ig",rLink):next:l11l=aLinks:end if:End Function:Function l1O1(ByVal Str,ByVal cHas):Str=""&Str:if cHas="" OR Str="" then:l1O1=Cstr(Str):exit function:end if:Dim i:cHas=split(trimall(UCASE(cHas)),"|"):for i=0 to UBound(cHas):SELECT CASE cHas(i):CASE "TABLE":Str=RegReplace(Str,"/<\/?(table|thead|tbody|tr|th|td).*>/ig",""):CASE "OBJECT":Str=RegReplace(Str,"/<\/?(object|param|embed).*>/ig",""):CASE "SCR"&"IPT":Str=RegReplace(Str,"/<scr"&"ipt.*>[\w\W]+?<\/scr"&"ipt>/ig",""):Str=RegReplace(Str,"/on[\w]+=[\'\""].+?[\'\""](\s|>)/ig","$1"):CASE "STYLE":Str=RegReplace(Str,"/<style.*>[\w\W]+?<\/style>/ig",""):CASE "CLASS":Str=RegReplace(Str,"/\sclass=.+?(\s|>)/ig",""):CASE "*":Str=Replace(Replace(RegReplace(Str,"/<.*?>/ig",""),"<","&lt;"),">","&gt;"):CASE ELSE:Str=RegReplace(Str,"/<\/?"&addcslashes(cHas(i))&".*?>/ig",""):End SELECT:next:l1O1=Replace(Str,"&nbsp;"," "):End Function:Function ConnectTempDataBase:dim tPath:tPath=accessFilePath:accessFilePath=ENGINEDIR&TEMPDATABASEFILENAME:SET ConnectTempDataBase=mainClassobj.createObject("MainClass.DB"):ConnectTempDataBase.dbType="acc":ConnectTempDataBase.connect():accessFilePath=tPath:End Function:Function LoadWord():LoadWord="":End Function:Function filterQuote(Byval Str):filterQuote=replace(""&Str,"'",""):End Function:Function l1Ol(Byval Str,ByVal rCol):dim i:Str=""&Str:if Str="" then:l1Ol=Str:exit function:end if:if NOT IsArray(tDic) then:if NOT isObject(tConn) then:SET tConn=ConnectTempDataBase():end if:tDic=tConn.db("SELECT rColumn,uesMode,sFind,sReplace,sStart,sEnd FROM {pre}fWord WHERE Flag=true","array"):end if:if IsArray(tDic) then:for i=0 to UBound(tDic,2):if tDic(0,i)=rCol then:if tDic(1,i)=1 then:if tDic(4,i)&tDic(5,i) <> "" then:Str=RegReplace(Str,"/"&addcslashes(tDic(4,i))&"([\w\W]+?)"&addcslashes(tDic(5,i))&"/ig",tDic(3,i)):end if:else:if tDic(2,i)<>"" then:Str=replace(Str,tDic(2,i),tDic(3,i)):end if:end if:end if:next:end if:l1Ol=Str:End Function:Function ClassID2Name(ByVal iClsID):if NOT isObject(tTypeDic) then:dim t,i:SET tTypeDic=Object():t = conn.db("select m_id,m_name from {pre}type order by m_id asc","array"):if IsArray(t) then:for i=0 to UBound(t,2):tTypeDic(CStr(t(0,i)))=t(1,i):next:end if:end if:ClassID2Name=tTypeDic(CStr(iClsID)):End Function:Function gatherIntoLibTransfer(Byval data,Byval str,Byval typeset):dim transtr,str1,str2,str1Array,str2Array,m,n,j,k,x:str1=trim(data):str2=trim(str):if str1<>"" and str2<>"" then:select case typeset:case 0:str1Array=split(str1,"$$$"):str2Array=split(str2,"$$$"):m=ubound(str1Array):n=ubound(str2Array):for k=0 to n:x=findIsExistFrom(str1Array,split(str2Array(k),"$$")(0)):if isNum(x) then:str1Array(x)=str2Array(k):else:transtr=transtr&str2Array(k)&"$$$":end if:next:for j=0 to m:transtr=transtr&str1Array(j)&"$$$":next:transtr = trimOuterStr(transtr,"$$$"):case 1:transtr=str&"$$$"&data:case 2:transtr=data&"$$$"&str:case 3:transtr=str:end select:else:transtr=ifthen(str1<>"",str1,str2):end if:gatherIntoLibTransfer=transtr:End Function:Function findIsExistFrom(array1,from):dim i,m:m=ubound(array1):findIsExistFrom="":for i=0 to m:if trim(split(array1(i),"$$")(0))=trim(from) then:findIsExistFrom=i:Exit Function:end if:next:End Function:Function l1l1(ByVal sClsName,ByVal mName):dim i,aTitle,Q_WHERE,tRs,kPre:sClsName=filterQuote(trim(sClsName)):mName=filterQuote(l1Ol(trim(mName),0)):Q_WHERE=array():kPre="SG.":l1l1=0:if sClsName="" AND mName="" then:exit function:end if:if NOT isObject(tQuery) then:SET tQuery=Object():end if:if tQuery.Exists(kPre&sClsName) then:l1l1=tQuery(kPre&sClsName):exit function:end if:if tQuery.Exists(kPre&mName) then:l1l1=tQuery(kPre&mName):exit function:end if:if NOT isObject(tConn) then:SET tConn=ConnectTempDataBase():end if:if sClsName<>"" then:SET tRs=tConn.db("SELECT TOP 1 sysClsID FROM {pre}cls WHERE clsName='"&sClsName&"'","execute"):if not tRs.eof then:l1l1=tRs("sysClsID"):end if:tRs.Close:SET tRs=Nothing:end if:if l1l1>0 then:tQuery(kPre&sClsName)=l1l1:exit function:end if:aTitle=split(mName,"/"):for i=0 to UBound(aTitle):if not isNULL(aTitle(i)) then:Push Q_WHERE,"'/'+m_name+'/' LIKE '%/"&aTitle(i)&"/%'":end if:next:if Ubound(Q_WHERE)>-1 then:Q_WHERE=Join(Q_WHERE," OR "):SET tRs=tConn.db("SELECT TOP 1 m_type FROM {pre}tempdata WHERE "&Q_WHERE,"execute"):if not tRs.eof then:l1l1=tRs("m_type"):end if:tRs.Close:SET tRs=Nothing:if l1l1=0 then:SET tRs=Conn.db("SELECT TOP 1 m_type FROM {pre}data WHERE "&Q_WHERE,"execute"):if not tRs.eof then:l1l1=tRs("m_type"):end if:tRs.Close:SET tRs=Nothing:end if:end if:if l1l1=0 AND sClsName<>"" then:SET tRs=Conn.db("SELECT TOP 1 m_id FROM {pre}type WHERE m_name='"&sClsName&"' OR m_name LIKE '"&sClsName&"%'","execute"):if not tRs.eof then:l1l1=tRs("m_id"):end if:tRs.Close:SET tRs=Nothing:end if:tQuery(kPre&mName)=l1l1:End Function:Function repairStr(vstr,formstr):dim regExpObj : set regExpObj= new RegExp : regExpObj.ignoreCase = true : regExpObj.Global = true : regExpObj.Pattern = "[\s\S]+?\$[\s\S]+?\$[\s\S]+?":dim mystr,i,j : j=1:vstr=""&vstr:vstr = replace(vstr,chr(10),""):vstr = split(vstr,chr(13)):for i = 0  to ubound(vstr):if not(isnul(vstr(i))) then:if regExpObj.Test(vstr(i)) = false then :regExpObj.Pattern = "[\s\S]+?\$[\s\S]+?":if regExpObj.Test(vstr(i)) = true then :mystr = mystr&trim(vstr(i))&"$"&formstr&chr(13)&chr(10):else:mystr = mystr&"第"&j&"集$"&trim(vstr(i))&"$"&formstr&chr(13)&chr(10):end if :regExpObj.Pattern = "[\s\S]+?\$[\s\S]+?\$[\s\S]+?":else :mystr = mystr&trim(vstr(i))&chr(13)&chr(10):end if :j=j+1:end if :next:repairStr = mystr:set regExpObj =nothing:End Function:Function repairUrlForm(vstr,formstr):dim strlen,formlen,str,fstr,rstr,i :str = split(trimOuterStr(vstr,","),", ") : strlen = ubound(str):fstr = split(trimOuterStr(formstr,","),", ") : formlen  = ubound(fstr):if strlen <> formlen then :die "未为每个数据选择数据来源":else:for i=0 to strlen:if  trim(str(i))<>"" then:rstr = rstr&repairStr(str(i),getReferedId(fstr(i)))&", ":else:rstr = rstr&", ":end if:next:end if:repairUrlForm = trimOuterStr(rstr,", "):End Function:Function replaceSpecial(Byval str):replaceSpecial=replaceStr(str,"'",""""):End Function:Function repairDownUrl(vstr,formstr):dim strlen,formlen,str,fstr,rstr,i:str = split(trimOuterStr(vstr,","),", ") : strlen = ubound(str):fstr = split(trimOuterStr(formstr,","),", ") : formlen  = ubound(fstr):if strlen <> formlen then:die "未为每个下载项选择数据来源":else:for i=0 to strlen:if  trim(str(i))<>"" then:rstr = rstr&repairStr(str(i),"down")&", " else rstr = rstr&", ":end if:next:end if:repairDownUrl = trimOuterStr(rstr,", "):End Function:Function transferUrl(Byval fromStr,Byval playStr):dim fromLen,playLen,fromArray,playArray,i,resultStr:if isNul(fromStr) and isNul(playStr) then:transferUrl="":exit function:end if:fromStr=replaceStr(fromStr,"$$","") : playStr=replaceStr(replaceStr(playStr,"#",""),"$$",""):playStr=replaceStr(playStr,chr(10),""):playStr=replaceStr(playStr,chr(13),"#"):playStr=trimOuterStr(playStr,"#"):fromStr=trimOuterStr(fromStr,",") : playStr=trimOuterStr(playStr,",") :fromArray=split(fromStr,", ") : fromLen=ubound(fromArray):playArray=split(playStr,", ") : playLen=ubound(playArray):if fromLen<>playLen then:die "来源或者地址没有填写完整":end if:if fromLen=0 then:transferUrl=trim(fromArray(0))&"$$"&trim(playArray(0)):exit function:end if:for i=0 to fromLen:if not isNul(fromArray(i)) and  not isNul(playArray(i))  then:resultStr=trim(resultStr)&trim(fromArray(i))&"$$"&trim(trimOuterStr(playArray(i),"#"))&"$$$":else:if isNul(fromArray(i)) and not isNul(playArray(i)) then:die "来源没有填写完整":end if:end if :next:transferUrl=trimOuterStr(resultStr,"$$$"):End Function:Function lO0O(ByVal mdCls,ByVal iMode,ByVal eMode):dim l,Q_WHERE,dConn,tRs,sql,tablename,hFid,tFid,i,aTitle,moviesrcs,partnames,playfrom:Q_WHERE=array():if UCASE(typename(mdCls)) <>"DICTIONARY" then:Err.Raise 13,"","类型不匹 第一个参数请传递 由 创建影片信息类() 返回的值":exit Function:end if:iMode=Str2Num(iMode):eMode=Str2Num(eMode):hFid=Array("来自","影片地址数组","分集名数组","来源","名称","演员","分类ID","分类名","日期","地区","备注","图片","介绍","连载状态","初始点击数","关键字","初始顶次数","年份","标题颜色","星级","主题ID","专题ID","语言","导演"):tFid=Array("from","moviesrcs","partnames","playfrom","name","actor","type","typename","addtime","publisharea","note","pic","des","state","hit","keyword","digg","publishyear","color","commend","tread","topic","lang","director"):dim mCls:SET mCls=Object():for i=0 to UBound(tFid):if mdCls.Exists(hFid(i)) then:mCls(tFid(i))=mdCls(hFid(i)):else:if mdCls.Exists(tFid(i)) then:mCls(tFid(i))=mdCls(tFid(i)):end if:end if:next:playfrom= replace(replace(filterQuote(mCls("playfrom")),"#",""),"$",""):mCls.Remove("playfrom"):mCls("name")= replace(replace(filterQuote(replace(trim(mCls("name")),"\","/")),"[","【"),"]","】"):if not isNumeric(mCls("type")) then:mCls("type")=l1l1(mCls("type"),mCls("name")):end if:tFid=Array("typename","from","addtime","publisharea","note","pic","des","color","keyword"):for i=0 to UBound(tFid):if mCls.Exists(tFid(i)) then:mCls(tFid(i)) = trim(mCls(tFid(i))):end if:next:tFid=Array("state","hit","digg","publishyear","tread","topic","commend"):for i=0 to UBound(tFid):if mCls.Exists(tFid(i)) then:mCls(tFid(i)) = Str2Num(mCls(tFid(i))):end if:next:if mCls.Exists("actor") then:mCls("actor") = RegReplace(trim(mCls("actor")),"/\s+/g",","):if computeStrLen(mCls("actor"))>250 then:mCls("actor")=getStrByLen(mCls("actor"),250):end if:end if:if computeStrLen(mCls("name"))>115 then:mCls("name")=getStrByLen(mCls("name"),115):end if:if computeStrLen(mCls("typename"))>50 then:mCls("typename")=getStrByLen(mCls("typename"),50):end if:if eMode<2 then:lO0O=true:exit function:end if:aTitle=split(mCls("name"),"/"):for i=0 to UBound(aTitle):if not isNULL(aTitle(i)) then:Push Q_WHERE,"'/'+m_name+'/' LIKE '%/"&aTitle(i)&"/%'":end if:next:if Ubound(Q_WHERE)=-1 then:lO0O=false:exit function:end if:Q_WHERE=Join(Q_WHERE," OR "):if iMode=1 AND Str2Num(mCls("type"))<>0 then:tablename="{pre}data":SET dConn=conn:else:if NOT isObject(tConn) then:SET tConn=ConnectTempDataBase():end if:iMode=0:tablename="{pre}tempdata":Q_WHERE=ifthen(not isNull(mCls("from")),"m_from='"&mCls("from")&"' OR ","")&Q_WHERE:SET dConn=tConn:end if:if iMode<>0 then:mCls.remove("from"):mCls.remove("typename"):else:mCls("inbase")=0:end if:moviesrcs=mCls("moviesrcs"):mCls.remove("moviesrcs"):partnames=mCls("partnames"):mCls.remove("partnames"):if isArray(moviesrcs) then:l=UBound(moviesrcs):if l<>-1 then:if isArray(partnames) then:if UBound(partnames)<>l then:ReDim Preserve partnames(l):end if:for i=0 to l:moviesrcs(i)=ifthen(jsIndexOf(moviesrcs(i),"$")=-1,Replace(""&partnames(i),",","")&"$"&moviesrcs(i),moviesrcs(i)):next:end if:moviesrcs = repairUrlForm(join(moviesrcs,vbcrlf),playfrom):else:moviesrcs = "":end if:else:moviesrcs=ifthen(not isNULL(moviesrcs),moviesrcs,""):end if:if moviesrcs<>"" then:mCls("playdata")= transferUrl(playfrom,moviesrcs):end if:mCls("enname")=MoviePinYin(mCls("name")):mCls("letter")=Left(mCls("enname"),1):SET tRs=dConn.db("SELECT TOP 1 m_id,m_playdata,m_state,m_type,m_pic FROM "&tablename&" WHERE "&Q_WHERE,"execute"):if tRs.eof then:sql="INSERT INTO "&tablename&" "&lO0l(mCls,0):else:Dim ADDSET:ADDSET="":if gatherSet<>4 then:if mCls.Exists("state") then:ADDSET=",m_state="&ifthen(mCls("state")>tRs("m_state"),mCls("state"),tRs("m_state")):mCls.remove("state"):end if:if mCls.Exists("note") then:ADDSET=ADDSET&",m_note='"&filterQuote(mCls("note"))&"'":mCls.remove("note"):end if:if mCls.Exists("inbase") then:ADDSET=ADDSET&",m_inbase=0":mCls.remove("inbase"):end if:mCls("type")=ifthen(tRs("m_type")<>0,tRs("m_type"),Str2Num(mCls("type"))):if mCls.Exists("pic") AND trim(""&tRs("m_pic"))="" then:ADDSET=ADDSET&",m_pic='"&filterQuote(mCls("pic"))&"'":mCls.remove("pic"):end if:end if:select case gatherSet:case 0,1,2,3:mCls("playdata") = gatherIntoLibTransfer(tRs("m_playdata"),mCls("playdata"),gatherSet):sql="UPDATE "&tablename&" SET m_name='"&filterQuote(mCls("name"))&"',m_type="&Str2Num(mCls("type"))&",m_playdata='"&filterQuote(mCls("playdata"))&"'"&ifthen(isDate(mCls("addtime")),",m_addtime='"&mCls("addtime")&"'","")&ADDSET&" WHERE m_id="&tRs("m_id"):case 4:sql="INSERT INTO "&tablename&" "&lO0l(mCls,0):case 5:mCls.remove("hit"):mCls.remove("playdata"):sql="UPDATE "&tablename&" SET "&lO0l(mCls,1)&ADDSET&" WHERE m_id="&tRs("m_id"):end select:end if:tRs.close : SET tRs=nothing:dConn.db sql,"execute":End Function:Function lO0l(ByVal mCls,ByVal iType):Dim i,Keys,Vals:Keys=mCls.Keys:Vals=array():for i=0 to UBound(Keys):if Keys(i)<>"type" AND Keys(i)<>"hit" AND Keys(i)<>"state" AND Keys(i)<>"digg" AND Keys(i)<>"tread" AND Keys(i)<>"publishyear" AND Keys(i)<>"commend" AND Keys(i)<>"wrong" AND Keys(i)<>"topic" then:Push Vals,"'"&filterQuote(mCls(Keys(i)))&"'":else:Push Vals,mCls(Keys(i)):end if:Keys(i)=trim("m_"&filterQuote(Keys(i))):next:if iType=0 then:lO0l="("&Join(Keys,", ")&")VALUES("&Join(Vals,", ")&")":else:for i=0 to UBound(Keys):Vals(i)=Keys(i)&"="&Vals(i):next:lO0l = Join(Vals,", "):end if:End Function:Function getNextRunTime(ByVal dHas,ByVal hHas):Dim i,D,H,DL,HL,M,dd,hh,nd,nh:dd=Str2Num(Day(now)):hh=Str2Num(Hour(now)):nd=false:nh=false:M=0:if trim(dHas)="" OR trim(hHas)="" then:getNextRunTime="N/A":exit Function:end if:D=split(trimAll(dHas),","):H=split(trimAll(hHas),","):DL=UBound(D):HL=UBound(H):for i=0 to HL:if Str2Num(H(i))>HH then:nh=H(i):exit for:end if:next:if l0OO(nh,false) AND HL<>-1 then:nh=H(0):else:dd=dd-1:end if:for i=0 to DL:if Str2Num(D(i))>dd then:nd=D(i):exit for:end if:next:if l0OO(nd,false) AND DL<>-1 then:M=M+1:nd=D(0):end if:getNextRunTime=Year(now)&"-"&Month(now)+M&"-"&nd&" "&nh&":00:00":End Function:Function GatherTask():SET GatherTask=New TGatherTask:End Function:Class TGatherTask:Private fDATA,fEvent:Private Sub Class_Initialize():SET fEvent=Object():redim fDATA(-1):End Sub:Private Sub Class_Terminate():SET fEvent=nothing:End Sub:Private Sub add2(Byval url):dim i:url=trim(url):for i=0 to UBound(fDATA):if not isString(url) OR fDATA(i)=url then:exit Sub:end if:next:if url<>"" AND url<>Empty then:Push fDATA,url:end if:End Sub:Public Sub add(ByVal vUrl):dim i:if isArray(vUrl) then:for i=0 to UBound(vUrl):add2 vUrl(i):next:else:add2 vUrl:end if:End Sub:Public Function PopURL():if UBound(fDATA)<>-1 then:PopURL=unShift(fDATA):else:PopURL=Empty:end if:End Function:Public Function getUrls():getUrls = fDATA:End Function:Public Function Count():Count=UBound(fDATA)+1:End Function:Public Property LET onSuccess(ByVal OnFunName):fEvent.item("ONSUCCESS")=OnFunName:End Property:Public Property GET onSuccess():onSuccess=fEvent.item("ONSUCCESS"):End Property:Public Sub success(vHTML,vUrl):if NOT onSuccess=Empty then:execute("CALL "&Replace(onSuccess,"[arguments]","vHTML, vUrl")):end if:End Sub:Public Sub error(num,msg,url):if NOT onError=Empty then:execute("CALL "&Replace(onError,"[arguments]","num, msg, url")):end if:End Sub:Public Property LET onError(ByVal OnFunName):fEvent.item("ONERROR")=OnFunName:End Property:Public Property GET onError():onError=fEvent.item("ONERROR"):End Property:End Class:Function GatHerProcess(ByVal ID,ByVal Mode):SET GatHerProcess=New TGatHerProcess:SET GatHerProcess.this=GatHerProcess:GatHerProcess.id=ID:GatHerProcess.mode = Mode:if initStep>1 then:GatHerProcess.fStep = initStep:end if:End Function:Class TGatHerProcess:Public Charset,this,fStep,NextRunTime,Count:Private prefix,fENV,fInit,Inited,fonprogress,foncomplete,fID,fMode,fMFile,fPos,fItemSize,fIgnoreCount,fStartTime:Private Sub Class_Initialize():prefix="TGATHERPROCESS.":SET fENV = Object():Inited=false:fMode=false:fStep=1:fonprogress=Empty:foncomplete=Empty:fPos=0:Count=0:fItemSize=1:fIgnoreCount=0:fStartTime="":End Sub:Private Sub Class_Terminate():End Sub:Private Sub writeCache(ByVal mode):on error resume next:dim i,t,keys,b:OpenMFile:keys=fENV.keys:b=false:for i=0 to UBound(keys):t=fENV(keys(i)).getUrls:if UBound(t)>-1 then:b=true:fMFile.item(keys(i))=t:else:fMFile.remove(keys(i)):end if:if mode=true then:fENV.remove(keys(i)):end if:next:fMFile.item("GT_INITED")=b:fMFile.item("GT_POS")=readPos:fMFile.item("GT_STARTTIME")=startTime:fMFile.item("GT_COUNT")=Count:fMFile.item("GT_ITEMSIZE")=fItemSize:fMFile.item("GT_IGNORECOUNT")=fIgnoreCount:fMFile.SaveToFile():if err then err.clear:end if:End Sub:Private Sub readCache():if Inited then:exit sub:end if:OpenMFile:if fMFile.item("GT_INITED")=true then:dim i,keys:keys=fENV.keys:for i=0 to UBound(keys):if fMFile.Exists(keys(i)) then:fENV.item(keys(i)).add(fMFile.item(keys(i))):end if:next:startTime=fMFile.item("GT_STARTTIME"):writePos fMFile.item("GT_POS"):Count=Str2Num(fMFile.item("GT_COUNT")):fItemSize=Str2Num(fMFile.item("GT_ITEMSIZE")):fIgnoreCount=Str2Num(fMFile.item("GT_IGNORECOUNT")):Inited=true:end if:End Sub:Private Sub OpenMFile():if not isObject(fMFile) then:SET fMFile = New TMappingFile:fMFile.isCache=true:fMFile.open fID,false:end if:End Sub:Private Function readPos():readPos=fPos:End Function:Private Sub writePos(Byval Val):fPos=Str2Num(Val):End Sub:Public Property GET itemSize():itemSize=fItemSize:End Property:Public Property LET itemSize(ByVal iSize):if iSize<>fItemSize AND fItemSize<>1 then:fIgnoreCount=fIgnoreCount+(fItemSize-iSize):end if:if iSize>fItemSize then:fItemSize=iSize:end if:End Property:Public Property GET startTime():startTime=fStartTime:End Property:Public Property LET StartTime(Byval Val):fStartTime=Val:End Property:Public Function CreateTask():dim i:i=CStr(fENV.Count):SET CreateTask=GatHerTask():SET fENV.item(i)=CreateTask:End Function:Public Property LET ID(ByVal val):fID=val:End Property:Public Property GET ID():ID=fID:End Property:Public Property LET onprogress(ByVal OnFunName):fonprogress=OnFunName:End Property:Public Property GET onprogress():onprogress=fonprogress:End Property:Public Sub progress(url):writePos readPos+1:if mode>=2 then:writeCache(false):end if:if NOT onprogress=Empty then:execute("CALL "&Replace(onprogress,"[arguments]","fIgnoreCount,readPos,url")):end if:End Sub:Public Property LET oncomplete(ByVal OnFunName):foncomplete=OnFunName:End Property:Public Property GET oncomplete():oncomplete=foncomplete:End Property:Public Sub complete():if NOT oncomplete=Empty then:execute("CALL "&Replace(oncomplete,"[arguments]","")):end if:CreateTextFile ifthen(isDate(NextRunTime),NextRunTime,"N/A"),ENGINEDIR&ESCACHEDIR&fID&".lock","gb2312":End Sub:Public Property LET Init(ByVal FunName):fInit=FunName:if not isExistFile(ENGINEDIR&ESCDIR&fID) then:die "无效的 进程.ID 必需值 #进程标识ID":end if:if l0OO(mode,false) then:die "未设置执行模式 进程.mode 必需值(#当前模式)":end if:if mode=1 then:exit Property:end if:if mode>=2 then:readCache:end if:if mode<>0 AND mode<>3 AND isDate(NextRunTime) then:if DateDiff("n",now(),NextRunTime)>0 then:exit Property:end if:end if:if NOT Inited AND NOT fInit=Empty then:execute("CALL "&Replace(fInit,"[arguments]","this")):end if:if NOT Inited then:writePos(0):end if:Start():if mode>=2 then:writeCache(true):end if:End Property:Public Property GET Init():Init=fInit:End Property:Public Property LET mode(Byval Val):dim msg:msg="进程.mode 无效的执行模式 可选值: #当前模式 #演示模式 #不执行 #执行模式":if not IsNumeric(Val) then:die msg:end if:if Val<0 OR Val > 3 then:die msg:else:fMode=Val:end if:End Property:Public Property GET mode():mode=fMode:End Property:Private Sub Start():On Error Resume Next:if fENV.count<1 then:exit Sub:end if:dim item,Url,Keys,Key:Keys=fENV.Keys:Url=Empty:do while true:Key=Pop(Keys):if Key<>Empty then:SET item=fENV.item(key):Url=item.PopUrl:end if:if Url<>Empty OR UBound(Keys)=-1 then:exit do:end if:loop:if Url=Empty then:exit Sub:end if:progress(Url):Dim txt:txt=GetHttpTextFile(Url,Charset):if err.number=0 then:item.success txt,Url:else:item.error err.number,err.description,Url:err.clear:end if:if mode=0 then:fENV.Remove(key):end if:SET item=nothing:if mode<>0 then:dim i,items,count:items=fENV.items:count=0:for i=0 to UBound(items):if isObject(items(i)) then:count=count+items(i).count:end if:next:if count=0 then:complete:end if:end if:if iDec(fStep)>1 OR mode=0 then:Start():end if:End Sub:Public Sub ExitRun(ByVal Msg):Msg=ifThen(Msg="","采集完成",Msg):if Msg<>"" then:echo "<script>alert('"&addcslashes(Msg)&"');location.href='?ChildDir="&StrSliceB(fID,"","/")&"';</script>":end if:End Sub:End Class:Function CreateMappingFile(ByVal MarkID):SET CreateMappingFile=New TMappingFile:CreateMappingFile.open MarkID,false:End Function:Sub FreeMappingFile(ByVal MarkID):CreateMappingFile(MarkID).RemoveAll:End Sub:Function Max(ByVal Num1,ByVal Num2):Max=ifthen(Str2Num(Num1)>Str2Num(Num2),Num1,Num2):End Function:Class TMappingFile:Public isCache:Private fENV,fOpened,fPath,fFName,oRg,aRg,dRg,sRg,bRg,fSuffix:Private Sub Class_Initialize():SET fENV=Object():fOpened=false:fPath=ENGINEDIR&ESCACHEDIR:fSuffix=".map":isCache=false:SET oRg=jsRegExp("/^\s*\{([\w\W]*)\}/i"):SET aRg=jsRegExp("/^\s*\[([\w\W]*)\]/i"):SET dRg=jsRegExp("/^\s*([\-\+\.0-9]+).*/i"):SET sRg=jsRegExp("/^\s*\""(.*)\""/i"):SET bRg=jsRegExp("/^\s*(true|false)[,\s!=]?.*/i"):End Sub:Private Sub Class_Terminate():SaveToFile:fENV.Removeall():SET fENV=Nothing:End Sub:Private Function getPath():if isCache then:getPath=fPath&fFName&".ec":else:getPath=StrSliceB(fPath&fFName,"",".")&fSuffix:end if:end function:Public Sub Open(ByVal MarkID,ByVal bMode):if not isExistFile(ENGINEDIR&ESCDIR&MarkID) then:die "无效的 进程.ID 必需值 #进程标识ID":end if:fFName=MarkID:fOpened=true:if bMode = false then:if isExistFile(getPath) then:on error resume next:SET fENV=nothing:l0O1 fENV,l10l(LoadFile(getPath)):if err.number>0 then:delFile getPath:die "映象文件已损坏: "&getPath:end if:end if:end if:End Sub:Private Function l1l0(ByVal x):dim sChr,eChr,isStr,sLen,iPos,iCount:x=LTrim(x):iPos=0:iCount=0:isStr=false:if x="" then:l1l0="":exit function:end if:if dRg.test(x) then:iPos=Len(dRg.Replace(x,"$1")):else:if bRg.test(x) then:iPos=Len(bRg.Replace(x,"$1")):else:sLen=len(x):do while iPos<sLen:sChr=jsCharAt(x,iPos):iPos=iPos+1:if sChr = "{" OR sChr = "[" then:iCount=iCount+1:else:if sChr = "}" OR sChr = "]" then:iCount=iCount-1:if iCount=0 then:exit do:end if:else:if sChr="""" OR sChr="'" then:isStr=iPos=1:iPos=iPos+1:do while iPos<sLen:iPos=iPos+InStr(jsSlice(x,iPos,0),sChr)-1:eChr=jsCharAt(x,iPos):iPos=iPos+1:if sChr=eChr AND jsCharAt(x,iPos-2)<>"\" then:exit do:end if:loop:if isStr then:exit do:end if:end if:end if:end if:loop:end if:end if:l1l0=array(jsSubstr(x,0,iPos),jsSlice(x,iPos,0)):End Function:Private Function l0O0(ByVal x):Dim key,t,fs:SET t = Object():SET l0O0=t:do while true:fs=l1l0(x):key=l10l(fs(0)):x=jsSlice(fs(1),jsIndexOf(fs(1),":"),0):fs=l1l0(x):t(key)=l10l(fs(0)):if fs(1)="" then:exit do:else:x=jsSlice(LTrim(fs(1)),1,0):end if:loop:End Function:Private Function l0l1(ByVal x):dim fs:l0l1 = Array():do while true:fs=l1l0(x):Push l0l1,l10l(fs(0)):if fs(1)="" then:exit do:else:x=jsSlice(LTrim(fs(1)),1,0):end if:loop:End Function:Private Function l10l(ByVal x):if oRg.test(x) then:SET l10l = l0O0(StrSliceB(x,"{","}")):exit function:end if:if aRg.test(x) then:l10l = l0l1(StrSliceB(x,"[","]")):exit function:end if:if dRg.test(x) then:l10l=Str2Num(x):exit function:end if:if sRg.test(x) then:l10l=Replace(StrSliceB(x,"""",""""),"\""",""""):exit function:end if:if bRg.test(x) then:l10l=CBool(x):end if:End Function:Private Function l0Ol(ByVal x):on error resume next:dim i:if isObject(x) then:if UCASE(typename(x)) = "DICTIONARY" then:Dim Keys,ValTxt,key:Keys=x.keys:for i=0 to UBound(Keys):key = Replace(Replace(Replace(Keys(i),"""","\"""),vbcrlf,"\r\n"),"","\t"):ValTxt = l0Ol(x.item(Keys(i))):Keys(i)=ifthen(not isString(key) AND isNumeric(key),key,""""&key&"""")&": "&ifthen(ValTxt<>"",ValTxt,""""""):next:l0Ol="{"&join(Keys,",")&"}":else:l0Ol="Object":end if:exit function:end if:if isArray(x) then:for i=0 to UBound(x):x(i)=l0Ol(x(i)):next:l0Ol="["&Join(x,",")&"]":exit function:end if:if isNumeric(x) then:l0Ol= x:exit function:end if:if isBool(x) then:l0Ol= ifthen(x=true,"true","false"):else:l0Ol= """"&Replace(x,"""","\""")&"""":end if:End Function:Private Function toString():toString=l0Ol(fENV):End Function:Public Sub SaveToFile():if not fOpened then:exit Sub:end if:if fENV.Count=0 then:delFile getPath:else:if not CreateTextFile(toString,getPath,"gb2312") then:die "创建或写入“"&getPath&"”映象文件失败，请检查目录(读/写)权限，检查空间是不是满了":end if:end if:End Sub:Public Sub Remove(ByVal Key):fENV.Remove(Key):End Sub:Public Sub RemoveAll():fENV.RemoveAll:End Sub:Public Default Property GET Item(ByVal Key):Item=fENV(Key):End Property:Public Property LET Item(ByVal Key,ByVal Val):fENV(Key)=Val:End Property:Public Function Exists(ByVal keyName):Exists=fENV.Exists(keyName):End Function:Public Property GET Items():Items=fENV.Items:End Property:Public Property GET Keys():Keys=fENV.Keys:End Property:Public Function Count():Count=fENV.Count:End Function:End Class%>