<!--#include file="MainClass.asp"-->
<!-- #include file="engine/escript.cls.asp" -->
<%
'******************************************************************************************
' 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%原创、未引入任何网上代码,对一切抄袭行为、坚决严肃追究法律责任
'******************************************************************************************
if UCASE(getForm("action","get"))="TEST_HTTP_REFERER" then:TEST_HTTP_REFERER:die "":end if
if isAllowAutoGather<>1 then:die " ":end if
Const ENGINEDIR="engine/":Server.scripttimeout=600
Dim gES:SetEScriptEngine("gES"):gES.mode=1:initStep=1
Dim playerArray,downArray:playerArray = getPlayerKinds("playerKinds.xml")
Dim cPath,ePath:cPath=ENGINEDIR&ESCACHEDIR:ePath=Replace(ENGINEDIR&ESCDIR,"\","/")

RunEScript ePath

Sub RunEScript(ByVal sDir)
	Dim i,folderlist,fileList,fileNum,filename,fileAttr,lastExecTime,NextExecTime:sDir=Replace(Replace(sDir,"\","/"),"//","/"):fileList=getFileList(sDir):fileNum=UBound(fileList)
	if trim(fileList(0))<>"" then
		for i=0 to fileNum
			fileAttr=split(fileList(i),","):filename=Replace(Replace(fileAttr(4),"//","/"),ePath,"")
			if isExistFile(cPath&filename&".es") then
				gES.execEScript(filename)
				if gES("是否启用")=true then
					if isExistFile(cPath&filename&".lock") then
						NextExecTime=LoadFile(cPath&filename&".lock")
						if isDate(NextExecTime) then
							if DateDiff("s",now(),NextExecTime)<0 then
								DelFile cPath&filename&".lock":ExeC(filename)
								die ""
							end if
						end if
					elseif trim(gES("定时日段")&gES("定时时段"))<>"" then
						ExeC(filename)
						die ""
					end if
				end if
			else
				gES("是否启用")=false:gES("定时日段")="":gES("定时时段")=""
			end if
		next
	end if
	folderlist = getFolderlist(sDir)
	if trim(folderlist(0))<>"" then
		for i=0 to UBound(folderlist)
			RunEScript(Split(folderlist(i),",")(4))
		next
	end if
End Sub

Function ExeC(ByVal filename)
	Conn.Class_terminate
	if not IsObject(gES) then SetEScriptEngine("gES")
	gES.mode=2:gES.execEScript(filename)
End Function

Function getPlayerKinds(xmlfile)
	dim xmlobj,nodeLen,i
	set xmlobj = mainClassobj.createObject("MainClass.Xml")
	xmlobj.load xmlfile,"xmlfile"
	nodeLen = xmlobj.getNodeLen("playerkinds/player")
	redim playerArray(nodeLen-1)
	for i=0 to nodeLen-1
			playerArray(i)=xmlobj.getAttributes("playerkinds/player","flag",i)&"__"&xmlobj.getAttributes("playerkinds/player","des",i)
			'die playerArray(i)
	next
	set xmlobj = nothing
    getPlayerKinds = playerArray
End Function

Function  getDownKinds(xmlfile)
	dim xmlobj,nodeLen,i
	set xmlobj = mainClassobj.createObject("MainClass.Xml")
	xmlobj.load xmlfile,"xmlfile"
	nodeLen = xmlobj.getNodeLen("downkinds/source")
	redim downArray(nodeLen-1)
	for i=0 to nodeLen-1
			downArray(i)=xmlobj.getAttributes("downkinds/source","flag",i)&"__"&xmlobj.getAttributes("downkinds/source","des",i)
	next
	set xmlobj = nothing
    getDownKinds = downArray
End Function

Function getReferedId(str)
	getReferedId = ""
	if instr(str,"土豆高清")>0 then getReferedId = "hd_tudou": exit function
	if instr(str,"新浪高清")>0 then getReferedId = "hd_iask": exit function
	if instr(str,"搜狐高清")>0 then getReferedId = "hd_sohu": exit function
	if instr(str,"天线高清")>0 then getReferedId = "hd_openv": exit function
	if instr(str,"56高清")>0 then getReferedId = "hd_56": exit function
	if instr(str,"56")>0 then getReferedId = "56": exit function
	if instr(str,"优酷")>0 then getReferedId = "youku": exit function
	if instr(str,"土豆")>0 then getReferedId = "tudou": exit function
	if instr(str,"搜狐")>0 then getReferedId = "sohu": exit function
	if instr(str,"新浪")>0 then getReferedId = "iask": exit function
	if instr(str,"六间房")>0 then getReferedId = "6rooms": exit function
	if instr(str,"qq")>0 then getReferedId = "qq": exit function
	if instr(str,"youtube")>0 then getReferedId = "youtube": exit function
	if instr(str,"17173")>0 then getReferedId = "17173": exit function
	if instr(str,"ku6视频")>0 then getReferedId = "ku6": exit function
	if instr(str,"FLV")>0 then getReferedId = "flv": exit function
	if instr(str,"SWF")>0 then getReferedId = "swf": exit function
	if instr(str,"real")>0 then getReferedId = "real": exit function
	if instr(str,"media")>0 then getReferedId = "media": exit function
	if instr(str,"qvod")>0 then getReferedId = "qvod": exit function
	if instr(str,"ppstream")>0 then getReferedId = "pps": exit function
	if instr(str,"迅播高清")>0 then getReferedId = "gvod": exit function
	if instr(str,"远古高清")>0 then getReferedId = "wp2008": exit function
	if instr(str,"ppvod高清")>0 then getReferedId = "ppvod": exit function
	if instr(str,"PVOD")>0 then getReferedId = "pvod": exit function
	if instr(str,"播客CC")>0 then getReferedId = "cc": exit function
	if instr(str,"皮皮影音")>0 then getReferedId = "pipi": exit function
	if instr(str,"激动")>0 then getReferedId = "joy": exit function
	if instr(str,"奇艺")>0 then getReferedId = "qiyi": exit function
End Function

Function isAllowAutoGather()
	isAllowAutoGather=0:on error resume next:isAllowAutoGather=Cint(AllowAutoGather)
End Function
die " "
%>