<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%
'******************************************************************************************
' 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%原创、未引入任何网上代码,对一切抄袭行为、坚决严肃追究法律责任
'******************************************************************************************
Option Explicit

dim starttime,endtime
setStartTime
Const CBTag="<!--FILE CACHE TIME:":Const CETag="-->":Const CDIRNAME="webcache"
const CONN_OBJ_NAME="ADODB.CONNECTION"
const RECORDSET_OBJ_NAME="ADODB.RECORDSET"

dim FSO_OBJ_NAME
	FSO_OBJ_NAME="SCRI"&"PTING.FILES"&"YSTEMOBJECT"

dim STREAM_OBJ_NAME
	STREAM_OBJ_NAME="ADOD"&"B.ST"&"REAM"

dim DICTIONARY_OBJ_NAME
	DICTIONARY_OBJ_NAME="SCRIPTING.DICTIONARY"

dim JPEG_OBJ_NAME
	JPEG_OBJ_NAME="Persits.jpeg"

dim TABLE_PRE
	TABLE_PRE="m_"

Class MainClass
	private className

	Private Sub Class_Initialize
		className=""
	End Sub

	Public Function createObject(byval classStr)
		className=classStr
		classname=replace(classname,".","_")
		Execute("set createObject=new "&classname)
	End Function

	Private Sub Class_Terminate()
		
	End Sub
End Class


Class MainClass_DB
	public dbConn,dbRs,isConnect,fetchCount,tablepre
	private connStr,vqueryCount,vdbType
	private errid,errdes

	Private Sub Class_Initialize
		isConnect=false:vqueryCount=0:fetchCount=0
	End Sub

	Public Property Get queryCount
		queryCount=vqueryCount
	End Property

	Public Property Let dbType(byval pType)
		if pType="sql" then vdbType=pType  else vdbType="acc"
	End Property

	Private Sub getConnStr()
		if vdbType="sql" then
			tablepre=ifthen(tableuser<>"",tableuser&".","")&TABLE_PRE:connStr="Provider=Sqloledb;Data Source="&databaseServer&";Initial Catalog="&databaseName&";User ID="&databaseUser&";Password="&databasePwd&";"
		elseif vdbType="acc" then
			tablepre=TABLE_PRE:connStr="Provider=Microsoft.Jet.OLEdb.4.0;Data Source="&server.mappath(accessFilePath)
		end if
	End Sub

	Public Sub connect()
		getConnStr
		if isObject(dbConn)=false or isConnect=false then
			On Error Resume Next
			set dbConn=server.CreateObject(CONN_OBJ_NAME)
			dbConn.open connStr
			isConnect=true
			if Err then errid=Err.number:errdes=Err.description:Err.Clear:dbConn.close:set dbConn=nothing:isConnect=false:echoErr err_dbconect,errid,errdes
		end if
	End Sub

	Function db(byval sqlStr,byval sqlType)
		if not isConnect=true then connect
		On Error Resume Next
		sqlStr=replace(sqlStr,"{pre}",tablepre)
		'echo sqlStr&"<br>"
		select case sqlType
			case "execute"
				set db=dbConn.execute(sqlStr)
			case "records1"
				set db=server.CreateObject(RECORDSET_OBJ_NAME)
				db.open sqlStr,dbConn,1,1
			case "records3"
				set db=server.CreateObject(RECORDSET_OBJ_NAME)
				db.open sqlStr,dbConn,3,3
			case "array"
				set dbRs=server.CreateObject(RECORDSET_OBJ_NAME)
				dbRs.open sqlStr,dbConn,1,1
				if not dbRs.eof then
					if fetchCount=0 then  db=dbRs.getRows() else db=dbRs.getRows(fetchCount)
				end if
				dbRs.close:set dbRs=nothing
		end select
		vqueryCount=vqueryCount+1
		if Err then
			'echo sqlStr&"<br>"
			errid=Err.number:errdes=Err.description:Err.Clear:dbConn.close:set dbConn=nothing:isConnect=false
			echoErr err_rsopen,errid,errdes
		end if
	End Function

	Public Sub Class_Terminate()
		if isObject(dbRs) then set dbRs=nothing
		if isConnect then dbConn.close:set dbConn=nothing:isConnect=false
	End Sub
End Class



Class MainClass_Cache
	Public continueTime,vcacheFlag 
	Private v_cacheName,cacheData,cacheNum

	Private Sub Class_Initialize()
		continueTime=clng(cacheTime)
		vcacheFlag=cacheFlag
		cacheNum=200
	End Sub 

	Public Function setCache(ByVal p_cacheName,ByVal p_cacheValue)
		if getCacheNum > cacheNum then clearOtherCache
		on error resume next
		v_cacheName=LCase(p_cacheName)
		If v_cacheName<>"" Then
			cacheData=Application(vcacheFlag&v_cacheName)
			If IsArray(cacheData) Then
				if isObject(p_cacheValue) then set cacheData(0)=p_cacheValue else cacheData(0)=p_cacheValue
				cacheData(1)=Now()
			Else
				ReDim cacheData(1)
				if isObject(p_cacheValue)  then set cacheData(0)=p_cacheValue else cacheData(0)=p_cacheValue
				cacheData(1)=Now()
			End If
			if err then  clearAll : err.clear
			Application.Lock
			Application(vcacheFlag&v_cacheName)=cacheData
			Application.unLock
		Else
			die err_cachename
		End If
	End Function

	Public Function getCache(ByVal p_cacheName)
		on error resume next
		v_cacheName=LCase(p_cacheName)
		If v_cacheName<>"" Then
			cacheData=Application(vcacheFlag&v_cacheName)
			If IsArray(cacheData) Then
				if isObject(cacheData(0)) then set getCache=cacheData(0) else getCache=cacheData(0)
				if err then  clearAll : err.clear
			Else
				die err_cachevalue
			End If
		Else
			die err_cachename
		End If
	End Function 

	Public Function chkCache(ByVal p_cacheName)
		v_cacheName=LCase(p_cacheName)
		chkCache=false
		on error resume next
		cacheData=Application(vcacheFlag&v_cacheName)
		if err then  clearAll : err.clear : Exit Function
		If Not IsArray(cacheData) Then Exit Function
		If Not IsDate(cacheData(1)) Then Exit Function
		If DateDiff("s",CDate(cacheData(1)),Now()) < 60*continueTime Then
			chkCache=true
		End If
	End Function

	Public Sub clearCache(ByVal p_cacheName)
		v_cacheName=LCase(p_cacheName)
		Application.Lock
		Application(vcacheFlag&v_cacheName)=Empty
		Application.unLock
	End Sub

	Public Function havedTime(Byval p_cacheName)
		v_cacheName=LCase(p_cacheName)
		If v_cacheName<>"" Then
			cacheData=Application(vcacheFlag&v_cacheName)
			If IsArray(cacheData) Then
				havedTime=cacheData(1)
			Else
				die err_cachevalue
			End If
		Else
			die err_cachename
		End If
	End Function

	Public Sub clearAll()
		Application.Lock()
		Application.Contents.RemoveAll()
		Application.UnLock()
	end sub

	Public Sub showAllCache()
		dim acon
		echo "缓存对象列表：共"&getCacheNum()&"个:<br>"
		for each acon in Application.Contents
			echo  acon&"<br>"
		next
	End Sub

	Public Function getCacheNum()
		getCacheNum=application.Contents.Count
	End Function

	Public Sub clearOtherCache()
		dim acon,i,otherNum : otherNum=getCacheNum - cacheNum : i=0
		for each acon in Application.Contents
			Application.Lock()
			application.contents.remove(acon)
			Application.UnLock()
			i=i + 1
			if i=otherNum then exit for
		next
	End Sub 
End Class


Class MainClass_Template
	Public content,allPages,currentPage,currentType
	Private cacheName,labelRule,regExpObj,strDictionary

	Public Sub Class_Initialize()
		set regExpObj= new RegExp
		regExpObj.ignoreCase=true
		regExpObj.Global=true
		set strDictionary=server.CreateObject(DICTIONARY_OBJ_NAME)
	End Sub

	Public Sub Class_Terminate()
		set regExpObj=nothing
		set strDictionary=nothing
	End Sub

	Public Function load(Byval filePath)
		cacheName="template_"&filePath
		if(clng(cacheStart)=1) then
			if (cacheObj.chkCache(cacheName)) then  content=cacheObj.getCache(cacheName) else content=loadFile(filePath):cacheObj.setCache cacheName,content
		else
			content=loadFile(filePath)
		end if
	End Function

	Public Function parseSelf()
		if not isExistStr(content,"{self:") then Exit Function
		dim matches,match,labelName,selfLabelArray,selfLabelLen,sql,singleAttrKey,singleAttrValue
		sql="select m_name,m_content from {pre}selflabel"
		labelRule="{self:([\s\S]+?)}"
		if cacheStart=1  then
			if (not cacheObj.chkCache("array_allselflabel_name_content")) then selfLabelArray=conn.db(sql,"array") : cacheObj.setCache "array_allselflabel_name_content",selfLabelArray else  selfLabelArray=cacheObj.getCache("array_allselflabel_name_content")
		else
			selfLabelArray=conn.db(sql,"array")
		end if
		if isArray(selfLabelArray) then 
			for selfLabelLen=0 to ubound(selfLabelArray,2)
				singleAttrKey=selfLabelArray(0,selfLabelLen)
				singleAttrValue=decodeHtml(selfLabelArray(1,selfLabelLen))
				dim singleLength : singleLength=Ubound(split(singleAttrValue,"$$$"))
				randomize : dim singleNum : singleNum=clng((singleLength)*rnd)
				if singleLength>0 then
					singleAttrValue=split(singleAttrValue,"$$$")(singleNum)
				end if 
				if not strDictionary.Exists(singleAttrKey) then strDictionary.add singleAttrKey,singleAttrValue  else  strDictionary(singleAttrKey)=singleAttrValue
			next
		end if
		regExpObj.Pattern=labelRule
		set matches=regExpObj.Execute(content)
		for each match in matches
			labelName=trim(match.SubMatches(0))
			if strDictionary.Exists(labelName) then  content=replace(content,match.value,strDictionary(labelName))
		next
		strDictionary.RemoveAll
		set matches=nothing
	End Function

	Public Function parseTopAndFoot()
		dim tp:tp="/"&sitePath&"template/"&defaultTemplate&"/"&templateFileFolder&"/"
		content=replaceStr(content,"{maxcms:top}",loadFileOnCache("template_",tp&"head.html")) 
		content=replaceStr(content,"{maxcms:foot}",loadFileOnCache("template_",tp&"foot.html"))
		if isExistStr(content,"{maxcms:load ") then
			Dim x,matches,match:regExpObj.Pattern="{maxcms:load([\s\S]+?)}"
			set matches=regExpObj.Execute(content)
			for each match in matches
				x=trim(match.SubMatches(0)):if isExistFile(tp&x) then content=replace(content,match.value,loadFileOnCache("template_",tp&x))
			next
			set matches=nothing
		end if
		content=replaceStr(content,"images/","/"&sitePath&"template/"&defaultTemplate&"/images/")
		if gbookStart=0 then
			content=replaceStr(content,"{maxcms:gbook}","")
		else
			content=replaceStr(content,"{maxcms:gbook}","<a href=""/{maxcms:sitepath}gbook.asp"" target=""_blank""  >留言</a>")
		end if 
	End Function

	Public Function parseGlobal()
		if isExistStr(content,"{maxcms:letterlist}") then content=replaceStr(content,"{maxcms:letterlist}",getletterlist)
		if isExistStr(content,"{maxcms:indexlink}") then content=replaceStr(content,"{maxcms:indexlink}",getIndexLink)
		if isExistStr(content,"{maxcms:topiclink}") then content=replaceStr(content,"{maxcms:topiclink}",getTopicIndexLink(1))
		if isExistStr(content,"{maxcms:newslink}") then content=replaceStr(content,"{maxcms:newslink}",getNewsIndexLink())
		content=replaceStr(content,"{maxcms:siteurl}",siteUrl)
		content=replaceStr(content,"{maxcms:sitepath}",sitePath)
		content=replaceStr(content,"{maxcms:adfolder}",siteAd)
		content=replaceStr(content,"{maxcms:sitename}",siteName)
		
		content=replaceStr(content,"{maxcms:copyright}",decodeHtml(copyRight))
		content=replaceStr(content,"{maxcms:sitedes}",decodeHtml(siteDes))
		content=replaceStr(content,"{maxcms:sitevisitjs}",siteVisiteJs)
		content=replaceStr(content,"{maxcms:sitenotice}",decodeHtml(siteNotice))
		'content=replaceStr(content,"{maxcms:sitekeywords}",getKeywordsList(siteKeyWords,""))
		content=replaceStr(content,"{maxcms:sitekeywords}",sitekeywords)
		if isExistStr(content,"{maxcms:allcount}") then content=replaceStr(content,"{maxcms:allcount}",getDataCount("all"))
		if isExistStr(content,"{maxcms:daycount}") then content=replaceStr(content,"{maxcms:daycount}",getDataCount("day"))
		if gbookStart=0 then content=replaceStr(content,"{maxcms:gbook}","") else content=replaceStr(content,"{maxcms:gbook}","<a href=""/"&sitePath&"gbook.asp"" target=""_blank""  >留言</a>")
		parseSlide:parseMaxHistory
		if runMode="static" then content=replaceStr(content,"{maxcms:runinfo}","")
	End Function

	Public Function parseAttr(Byval attr)
		dim attrStr,attrArray,attrDictionary,i,singleAttr,singleAttrKey,singleAttrValue
		attrStr=regExpReplace(attr,"[\s]+",chr(32))
		attrStr=trimOuter(attrStr)
		attrArray=split(attrStr,chr(32)):strDictionary.removeall()
		for i=0 to ubound(attrArray)
			singleAttr=split(attrArray(i),chr(61))
			singleAttrKey= singleAttr(0) : singleAttrValue= singleAttr(1)
			if not strDictionary.Exists(singleAttrKey) then strDictionary.add singleAttrKey,singleAttrValue  else  strDictionary(singleAttrKey)=singleAttrValue
		next
		set parseAttr=strDictionary
	End Function

	Public Function regExpReplace(contentstr,patternstr,replacestr)
		regExpObj.Pattern=patternstr
		regExpReplace=regExpObj.replace(contentstr,replacestr)
	End Function

	Public Function parseAreaList()
		if not isExistStr(content,"{maxcms:arealist") then Exit Function
		dim matches,match,matchesVideolist,matchVideolist,totalStrAreaList,singleStrAreaList
		dim labelAttrArealist,loopStrArealist,currentAreaType,areaType,areaTypeArray
		dim labelAttrVideolist,labelVideolist,labelRuleVideolist,videoListStr
		dim i,j,sql,typeStr,letHas,tagHas,TS,m,x:typeStr="":TS=getTypeLists():j=getTypeIndex("m_upid"):m=getTypeIndex("m_id")
		labelRule="{maxcms:arealist([\s\S]*?)}([\s\S]*?){/maxcms:arealist}"
		labelRuleVideolist="{maxcms:videolist([\s\S]*?)}([\s\S]*?){/maxcms:videolist}"
		for i=0 to UBound(TS,2)
			if ""&TS(j,i)="0" then
				if typeStr="" then
					typeStr=TS(m,i)
				else
					typeStr=typeStr&","&TS(m,i)
				end if
			end if
		next
		regExpObj.Pattern=labelRule:set matches=regExpObj.Execute(content)
		for each match in matches
			if typeStr<>"" then
				labelAttrArealist=match.SubMatches(0)
				loopStrArealist=match.SubMatches(1)
				Set x=parseAttr(labelAttrArealist):areaType=x("areatype"):letHas=x("arealetter"):tagHas=x("tag"):Set x=nothing
				if not isNul(letHas) then areaType="letter"
				if isNul(areaType) then areaType="all"
				if areaType="letter" then
					if isNul(letHas) OR letHas="all" then letHas="A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z"
					letHas=Split(letHas,",")
					for j=0 to UBound(letHas)
						if letHas(j)<>"" then
							singleStrAreaList=loopStrArealist
							singleStrAreaList=replaceStr(singleStrAreaList,"[arealist:i]",j+1)
							singleStrAreaList=replaceStr(singleStrAreaList,"[arealist:typename]",letHas(j))
							if isExistStr(singleStrAreaList,"[arealist:count]") then
								singleStrAreaList=replaceStr(singleStrAreaList,"[arealist:count]",conn.db("SELECT COUNT(*) FROM {pre}data WHERE m_letter='"&letHas(j)&"'","execute")(0))
							end if
							singleStrAreaList=replaceStr(singleStrAreaList,"[arealist:link]","/"&sitepath&"search.asp?searchtype=4&searchword="&letHas(j))
							regExpObj.Pattern=labelRuleVideolist
							set matchesVideolist=regExpObj.Execute(singleStrAreaList)
							for each matchVideolist in matchesVideolist
								videoListStr=replaceStr(matchVideolist.value,"arealetter",letHas(j))
								videoListStr=replaceStr(videoListStr,"areatype","all")
								singleStrAreaList=replaceStr(singleStrAreaList,matchVideolist.value,videoListStr)
							next
							set matchesVideolist=nothing
							totalStrAreaList=totalStrAreaList&singleStrAreaList
						end if
					next
				elseif areaType="tag" then
					if isNul(tagHas) then tagHas="all"
					tagHas=Split(tagHas,",")
					for j=0 to UBound(tagHas)
						if tagHas(j)<>"" then
							singleStrAreaList=loopStrArealist
							singleStrAreaList=replaceStr(singleStrAreaList,"[arealist:i]",j+1)
							singleStrAreaList=replaceStr(singleStrAreaList,"[arealist:typename]",tagHas(j))
							if isExistStr(singleStrAreaList,"[arealist:count]") then
								singleStrAreaList=replaceStr(singleStrAreaList,"[arealist:count]",conn.db("SELECT COUNT(*) FROM {pre}data WHERE m_name LIKE '%"&tagHas(j)&"%' OR m_actor like '%"&tagHas(j)&"%' OR  m_director like '%"&tagHas(j)&"%'","execute")(0))
							end if
							singleStrAreaList=replaceStr(singleStrAreaList,"[arealist:link]","/"&sitepath&"search.asp?searchtype=6&searchword="&Server.URLEncode(tagHas(j)))
							regExpObj.Pattern=labelRuleVideolist
							set matchesVideolist=regExpObj.Execute(singleStrAreaList)
							for each matchVideolist in matchesVideolist
								videoListStr=replaceStr(matchVideolist.value,"areatag",tagHas(j))
								videoListStr=replaceStr(videoListStr,"areatype","all")
								singleStrAreaList=replaceStr(singleStrAreaList,matchVideolist.value,videoListStr)
							next
							set matchesVideolist=nothing
							totalStrAreaList=totalStrAreaList&singleStrAreaList
						end if
					next
				else
					if areaType="all" then:areaTypeArray=split(typeStr,","):else:areaTypeArray=split(areaType,","):end if
					for j=0 to ubound(areaTypeArray)
						currentAreaType=areaTypeArray(j)
						if not isNum(currentAreaType) then die err_areaList
						m=getTypeNameTemplateArrayOnCache(currentAreaType) : if m="" OR m=",," then Exit For
						singleStrAreaList=loopStrArealist
						singleStrAreaList=replaceStr(singleStrAreaList,"[arealist:i]",j+1)
						singleStrAreaList=replaceStr(singleStrAreaList,"[arealist:typename]",Split(m,",")(0))
						if isExistStr(singleStrAreaList,"[arealist:count]") then
							singleStrAreaList=replaceStr(singleStrAreaList,"[arealist:count]",getNumPerType(currentAreaType))
						end if
						singleStrAreaList=replaceStr(singleStrAreaList,"[arealist:link]",getTypeLink(currentAreaType))
						regExpObj.Pattern=labelRuleVideolist
						set matchesVideolist=regExpObj.Execute(singleStrAreaList)
						for each matchVideolist in matchesVideolist
							videoListStr=replaceStr(matchVideolist.value,"arealetter","all")
							videoListStr=replaceStr(videoListStr,"areatype",currentAreaType)
							singleStrAreaList=replaceStr(singleStrAreaList,matchVideolist.value,videoListStr)
						next
						set matchesVideolist=nothing
						totalStrAreaList=totalStrAreaList&singleStrAreaList
					next
				end if
			else
				totalStrAreaList=""
			end if
			content=replaceStr(content,match.value,totalStrAreaList)
			totalStrAreaList=""
		next
		set matches=nothing
	End Function

	Public Function parseVideoList()
		if not isExistStr(content,"{maxcms:videolist") then Exit Function
		dim match,matches,matchfield,matchesfield
		dim labelAttrVideolist,loopstrVideoList,loopstrVlistNew,loopstrTotal,attrDictionary
		dim vnum,vorder,vtype,vtopic,vtime,vstart,vstate,vcommend,vletter,vid
		dim fieldName,fieldAttr,fieldNameAndAttr,fieldAttrLen
		dim i,labelRuleField,field_des,field_playdata,n,ni:n=0:ni=1
		dim namelen,attrval,actorlen,deslen,timestyle,videoTime,colornamelen,m_colorname,m_des,m_color,m_note,notelen,m_name,m_actor
		dim m,sql,orderStr,whereType,whereLetter,whereTopic,whereTime,whereStr,videoListArray,whereState,whereCommend,whereId,vtypeArray,vtypeI,vtypeStr,vtypeArrayLen,playlink_str
		labelRule="{maxcms:videolist([\s\S]*?)}([\s\S]*?){/maxcms:videolist}"
		labelRuleField="\[videolist:([\s\S]+?)\]"
		regExpObj.Pattern=labelRule
		set matches=regExpObj.Execute(content)
		for each match in matches
			labelAttrVideolist=match.SubMatches(0)
			loopstrVideoList=match.SubMatches(1)
			if isExistStr(loopstrVideoList,"[videolist:des") then field_des="m_des" else field_des="0"
			if isExistStr(loopstrVideoList,"[videolist:from]") then field_playdata="m_playdata" else  field_playdata="0"
			set attrDictionary=parseAttr(labelAttrVideolist)
			vnum=attrDictionary("num") : vorder=attrDictionary("order") : vletter=attrDictionary("letter"):vtype=attrDictionary("type") : vtopic=attrDictionary("topic") : vtime=attrDictionary("time") : vstart=attrDictionary("start") : vstate=attrDictionary("state") : vcommend=attrDictionary("commend") : vid=attrDictionary("id")
			if isNul(vnum) then vnum=10 else vnum=clng(vnum)
			if isNul(vorder) AND isNul(vid) then vorder="time"
			if isNul(vorder) then vorder="id"
			select case vorder
				case "id" : orderStr =" order by m_id desc"
				case "hit","hot" : orderStr =" order by m_hit desc"
				case "dayhit" : orderStr =" order by m_dayhit desc"
				case "weekhit" : orderStr =" order by m_weekhit desc"
				case "monthhit" : orderStr =" order by m_monthhit desc"
				case "time" : orderStr =" order by m_addtime desc"
				case "commend" : orderStr =" order by m_commend desc"
				case "digg" : orderStr =" order by m_digg desc"
				case "score" : orderStr =" order by m_score desc"
				case "random"
				if databaseType=0 then
					dim rndNum:randomize() : rndNum=int(1000*rnd)+1   : orderStr =" order by rnd( -1*"&rndNum&" * m_id)"
				else
					orderStr=" order by newid() desc"
				end if
			end select
			if isNul(vtype) then vtype="all"
			vtypeStr=""
			if vtype <> "all" then
				if vtype="current" then
					vtypeStr=getTypeIdOnCache(currentTypeId)
				else
					if instr(vtype,",")>0 then
						vtypeArray=split(vtype,","):vtypeArrayLen=ubound(vtypeArray)
						for vtypeI=0 to  vtypeArrayLen
							vtypeStr=vtypeStr&getTypeIdOnCache(vtypeArray(vtypeI))&","
						next
						vtypeStr=trimOuterStr(vtypeStr,",")
					else
						vtypeStr=getTypeIdOnCache(vtype)
					end if
				end if
				if InStr(vtypeStr,",")>0 then:whereType=" and m_type in ("&vtypeStr&") ":else:whereType=" and m_type="&vtypeStr:end if
			else
				whereType=""
			end if
			if not Isnul(vletter) AND vletter<>"all" then whereLetter=" and m_letter ='"&UCase(vletter)&"' " else whereLetter=""
			if not Isnul(vid) AND vid<>"all" then
				if InStr(vid,",")>0 then:whereId=" and m_id IN ("&vid&") ":else:whereId=" and m_id="&vid:end if
			else
				whereId=""
			end if
			if IsNum(vstate) then
				whereState=" and m_state>="&Clng(vstate)
			elseif vstate="series" then
				whereState=" and m_state>0"
			else
				whereState=""
			end if
			if not isNul(vcommend) then
				select case trim(vcommend)
					case "all" : whereCommend=" and  m_commend>0"
					case else
						if instr(vcommend,",")>0 then whereCommend=" and m_commend in("&vcommend&")" else whereCommend=" and m_commend ="&vcommend
				end select
			else
				whereCommend=""
			end if
			if not isNul(vtopic) then
				select case trim(vtopic)
					case "all" : whereTopic=" and m_topic>0"
					case "current" : whereTopic=" and m_topic="&currentTopicId
					case else
						if instr(vtopic,",")>0 then whereTopic=" and m_topic in("&vtopic&")" else whereTopic=" and m_topic ="&vtopic
				end select
			else
				whereTopic=""
			end if
			if databaseType = 0 then
				select case vtime
					case "day" : whereTime=" and  DateDiff('d',m_addtime,#"&now()&"#)=0"
					case "week" : whereTime=" and  DateDiff('d',m_addtime,#"&now()&"#)<7"
					case "month" : whereTime=" and  DateDiff('d',m_addtime,#"&now()&"#)<31"
					case else : whereTime=""
				end select
			else
				select case vtime
					case "day" : whereTime=" and  DateDiff(d,m_addtime,'"&now()&"')=0"
					case "week" : whereTime=" and  DateDiff(d,m_addtime,'"&now()&"')<7"
					case "month" : whereTime=" and  DateDiff(d,m_addtime,'"&now()&"')<31"
					case else : whereTime=""
				end select
			end if 
			whereStr=Replace(" where m_recycle=0"&whereType&whereLetter&whereTopic&whereTime&whereState&whereCommend&whereId,"where  and ","where ")
			'if trim(whereStr)="where" then whereStr=""
			if not isNul(vstart) then  vstart=clng(vstart) else vstart=1
			n=vstart-1 : vnum=vnum+vstart-1
			set attrDictionary=nothing
			sql="select top "&vnum+1&" m_id,m_name,m_type,m_state,m_pic,m_hit,m_actor,"&field_des&",m_topic,m_color,m_addtime,m_publishyear,m_publisharea ,m_commend,"&field_playdata&",m_note,m_letter,m_keyword,m_digg,m_tread,m_enname,m_datetime,m_director,m_lang,m_score from {pre}data "&whereStr&orderStr
			conn.fetchCount=vnum:videoListArray=conn.db(sql,"array"):conn.fetchCount=0
			regExpObj.Pattern=labelRuleField
			set matchesfield=regExpObj.Execute(loopstrVideoList)
			loopstrTotal=""
			if isArray(videoListArray) then vnum=ubound(videoListArray,2) else vnum=-1
			for i=n to vnum
				loopstrVlistNew=loopstrVideoList
				for each matchfield in matchesfield
					fieldNameAndAttr=regExpReplace(matchfield.SubMatches(0),"[\s]+",chr(32))
					fieldNameAndAttr=trimOuter(fieldNameAndAttr)
					m=instr(fieldNameAndAttr,chr(32))
					if m > 0 then 
						fieldName=left(fieldNameAndAttr,m - 1)
						fieldAttr =	right(fieldNameAndAttr,len(fieldNameAndAttr) - m)
					else
						fieldName=fieldNameAndAttr
						fieldAttr =	""
					end if
					select case fieldName
						case "id"
							loopstrVlistNew=replaceStr(loopstrVlistNew,matchfield.value,videoListArray(0,i))
						case "typeid"
							loopstrVlistNew=replaceStr(loopstrVlistNew,matchfield.value,videoListArray(2,i))
						case "letter"
							loopstrVlistNew=replaceStr(loopstrVlistNew,matchfield.value,videoListArray(16,i))
						case "name"
							m_name=videoListArray(1,i):namelen=parseAttr(fieldAttr)("len")
							if not isNul(namelen) and len(m_name)>clng(namelen) then m_name=left(m_name,clng(namelen)-1)&".."
							loopstrVlistNew=replaceStr(loopstrVlistNew,matchfield.value,m_name)
						case "colorname"
							m_color=videoListArray(9,i):m_name=videoListArray(1,i):colornamelen=parseAttr(fieldAttr)("len")
							if not isNul(colornamelen) and len(m_name)>clng(colornamelen) then  m_name=left(m_name,clng(colornamelen)-1)&".."
							if not(isnul(m_color)) then m_name="<font color="&m_color&">"&m_name&"</font>"
							loopstrVlistNew=replaceStr(loopstrVlistNew,matchfield.value,m_name)
						case "note"
							m_note=videoListArray(15,i) : notelen=parseAttr(fieldAttr)("len")
							if not isNul(notelen) and len(m_note) > clng(notelen) then m_note=left(m_note,clng(notelen)-1)&".."
							loopstrVlistNew=replaceStr(loopstrVlistNew,matchfield.value,m_note)
						case "actor"
							m_actor=videoListArray(6,i) : actorlen=parseAttr(fieldAttr)("len")
							if not isNul(actorlen) and len(m_actor) > clng(actorlen) then m_actor=left(m_actor,clng(actorlen)-1)&".."
							loopstrVlistNew=replaceStr(loopstrVlistNew,matchfield.value,getKeywordsList(m_actor," "))
						case "des"
							m_des=filterStr(decodeHtml(videoListArray(7,i)),"html"):deslen=parseAttr(fieldAttr)("len")
							if isNul(deslen) then deslen=200
							if len(m_des) > clng(deslen) then  m_des=left(m_des,clng(deslen)-1)&".."
							loopstrVlistNew=replaceStr(loopstrVlistNew,matchfield.value,m_des)
						case "time"
							videoTime=videoListArray(10,i):timestyle=parseAttr(fieldAttr)("style") : if isNul(timestyle) then timestyle="mm-dd"
							dim monthDayTime : monthDayTime=right("00"&month(videoTime),2)&"-"&right("00"&day(videoTime),2)
							select case timestyle
								case "yyyy-mm-dd"
									loopstrVlistNew=replaceStr(loopstrVlistNew,matchfield.value,year(videoTime)&"-"&monthDayTime)
								case "yy-mm-dd"
									loopstrVlistNew=replaceStr(loopstrVlistNew,matchfield.value,right(year(videoTime),2)&"-"&monthDayTime)
								case "yyyy-m-d"
									loopstrVlistNew=replaceStr(loopstrVlistNew,matchfield.value,year(videoTime)&"-"&month(videoTime)&"-"&day(videoTime))
								case else
									loopstrVlistNew=replaceStr(loopstrVlistNew,matchfield.value,monthDayTime)
							end select
						case "i"
							loopstrVlistNew=replaceStr(loopstrVlistNew,matchfield.value,i+1)
						case "n"
							loopstrVlistNew=replaceStr(loopstrVlistNew,matchfield.value,ni)
						case "typename"
							loopstrVlistNew=replaceStr(loopstrVlistNew,matchfield.value,Split(getTypeNameTemplateArrayOnCache(clng(videoListArray(2,i))),",")(0))
						case "typelink"
							loopstrVlistNew=replaceStr(loopstrVlistNew,matchfield.value,getTypeLink(videoListArray(2,i)))
						case "link"
							loopstrVlistNew=replaceStr(loopstrVlistNew,matchfield.value,getContentLink(videoListArray(2,i),videoListArray(0,i),videoListArray(20,i),videoListArray(21,i),"link"))
						case "playlink"
							if isAlertWin=1 then playlink_str="javascript:openWin('"&getPlayLink2(videoListArray(2,i),videoListArray(0,i),videoListArray(20,i),videoListArray(21,i),0,0)&"',"&(alertWinW+10)&","&(alertWinH+55)&",250,100,1)" else playlink_str=getPlayLink2(videoListArray(2,i),videoListArray(0,i),videoListArray(20,i),videoListArray(21,i),0,0)
							loopstrVlistNew=replaceStr(loopstrVlistNew,matchfield.value,playlink_str)
						case "pic"
							if not isNul(videoListArray(4,i)) then 
								if instr(videoListArray(4,i),"http://")>0 then 
									loopstrVlistNew=replaceStr(loopstrVlistNew,matchfield.value,videoListArray(4,i))
								else
									loopstrVlistNew=replaceStr(loopstrVlistNew,matchfield.value,"/"&sitePath&videoListArray(4,i))
								end if
							else
								loopstrVlistNew=replaceStr(loopstrVlistNew,matchfield.value,"/"&sitePath&"pic/nopic.gif")
							end if
						case "hit"
							loopstrVlistNew=replaceStr(loopstrVlistNew,matchfield.value,videoListArray(5,i))
						case "state"
							loopstrVlistNew=replaceStr(loopstrVlistNew,matchfield.value,videoListArray(3,i))
						case "publishtime"
							loopstrVlistNew=replaceStr(loopstrVlistNew,matchfield.value,videoListArray(11,i))
						case "publisharea"
							loopstrVlistNew=replaceStr(loopstrVlistNew,matchfield.value,videoListArray(12,i))
						case "commend"
							loopstrVlistNew=replaceStr(loopstrVlistNew,matchfield.value,videoListArray(13,i))
						'??????,??????
						case "commendPosition"
							loopstrVlistNew=replaceStr(loopstrVlistNew,matchfield.value,(videoListArray(13,i)*13-430))
						case "from"
							loopstrVlistNew=replaceStr(loopstrVlistNew,matchfield.value,replaceStr(getFromStr(videoListArray(14,i)),"播客CC","FLV高清"))
						case "keyword"
							loopstrVlistNew=replaceStr(loopstrVlistNew,matchfield.value,getKeywordsList(videoListArray(17,i)," "))
						case "digg"
							loopstrVlistNew=replaceStr(loopstrVlistNew,matchfield.value,videoListArray(18,i))
						case "tread"
							loopstrVlistNew=replaceStr(loopstrVlistNew,matchfield.value,videoListArray(19,i))
						case "director"
							loopstrVlistNew=replaceStr(loopstrVlistNew,matchfield.value,getKeywordsList(videoListArray(22,i)," "))
						case "lang"
							loopstrVlistNew=replaceStr(loopstrVlistNew,matchfield.value,CInt(videoListArray(23,i)/1024))
						case "score"
							loopstrVlistNew=replaceStr(loopstrVlistNew,matchfield.value,videoListArray(24,i))
						case "detailscore"
							if videoListArray(18,i) = 0 then
								loopstrVlistNew=replaceStr(loopstrVlistNew,matchfield.value,0)
							else
								loopstrVlistNew=replaceStr(loopstrVlistNew,matchfield.value,cint(videoListArray(24,i)/videoListArray(18,i)))
							end if

							
					end select
					strDictionary.removeAll
				next
				loopstrTotal=loopstrTotal&loopstrVlistNew:ni=ni+1
			next
			set matchesfield=nothing
			content=replaceStr(content,match.value,loopstrTotal)
			strDictionary.removeAll
		next
		set matches=nothing
	End Function

	Public Function parsePageList(ByVal typeId,ByVal currentPage,ByRef totalPages,ByVal pageListType)
		dim matchChannel,matchesChannel,loopstrChannel,loopstrTotal,attrChannel,attrDictionary,loopstrChannelNew
		dim labelRuleField,field_des,field_playdata
		dim vsize,vorder,vtype,vtypeArray
		dim i,m,sql,rsObj,orderStr,whereStr,sql1,esql
		dim matchfield,matchesfield,fieldNameAndAttr,fieldName,fieldAttr
		dim namelen,actorlen,deslen,timestyle,videoTime,colornamelen,m_colorname,m_des,m_color,m_note,notelen,m_actor,m_name
		dim matchPagelist,matchesPagelist,labelRulePagelist,lenPagelist,strPagelist,playlink_str
		labelRule="{maxcms:"&pageListType&"list([\s\S]*?)}([\s\S]*?){/maxcms:"&pageListType&"list}"
		labelRuleField="\["&pageListType&"list:([\s\S]+?)\]"
		labelRulePagelist="\["&pageListType&"list:pagenumber([\s\S]*?)\]"
		if isExistStr(content,"["&pageListType&"list:des") then field_des="m_des" else  field_des="0"
		if isExistStr(content,"["&pageListType&"list:from]") then field_playdata="m_playdata" else  field_playdata="0"
		regExpObj.Pattern=labelRule
		set matchesChannel=regExpObj.Execute(content):sql1="select m_id,m_name,m_type,m_state,m_pic,m_hit,m_actor,"&field_des&",m_topic,m_color,m_addtime,m_publishyear,m_publisharea,m_commend,"&field_playdata&",m_note,m_keyword,m_digg,m_tread,m_enname,m_datetime,m_director,m_lang,m_score,m_shotimg from {pre}data "
		for each matchChannel in matchesChannel
			attrChannel=matchChannel.SubMatches(0)
			loopstrChannel=matchChannel.SubMatches(1)
			set attrDictionary=parseAttr(attrChannel)
			vsize=clng(attrDictionary("size")) : vorder=attrDictionary("order")
			if isNul(vsize) then vsize=12 
			if isNul(vorder) then vorder="time"
			select case vorder
				case "id" : orderStr =" order by m_id desc"
				case "hit","hot" : orderStr =" order by m_hit desc"
				case "dayhit" : orderStr =" order by m_dayhit desc"
				case "weekhit" : orderStr =" order by m_weekhit desc"
				case "monthhit" : orderStr =" order by m_monthhit desc"
				case "time" : orderStr =" order by m_addtime desc"
				case "commend" : orderStr =" order by m_commend desc"
				case "digg" : orderStr =" order by m_digg desc"
				case "score" : orderStr =" order by m_score desc"
				case "letter" : orderstr=" order by m_letter asc"
			end select
			select case pageListType
				case "channel"
					sql=sql1&"where m_recycle=0 AND m_type in ("&typeId&")"&orderStr
				case "search"
					esql=EscapeSql(searchword)
					select case clng(searchType)
						case -1 : whereStr=" where m_recycle=0 AND (m_name like '%"&esql&"%' OR m_actor like '%"&esql&"%' OR  m_director like '%"&esql&"%')"
						case 0 : whereStr=" where m_recycle=0 AND m_name like '%"&esql&"%'"
						case 1 : whereStr=" where m_recycle=0 AND (m_actor like '%"&esql&"%' OR m_director like '%"&esql&"%')"
						case 2 : whereStr=" where m_recycle=0 AND m_publisharea like '%"&esql&"%'"
						case 3 : whereStr=" where m_recycle=0 AND m_publishyear like '%"&esql&"%'"
						case 4 : whereStr=" where m_recycle=0 AND m_letter='"&UCase(searchword)&"'"
						case 5 : whereStr=" where m_recycle=0 AND m_lang like '%"&esql&"%'"
					end select
					if Cstr(searchword)="" then whereStr=" where 1=2"
				sql=sql1&whereStr&orderStr
				case "topicpage"
					sql=sql1&"where m_recycle=0 AND m_topic="&typeId&orderStr
				case "customvideo"
					vtype=attrDictionary("type"):totalPages=attrDictionary("maxpage")
					if isNum(totalPages) then totalPages=Clng(totalPages) else totalPages=0
					if vtype <> "all" then
						if vtype="current" then
							vtype=getTypeIdOnCache(currentTypeId)
						else
							if instr(vtype,",")>0 then
								vtypeArray=split(vtype,",")
								for i=0 to ubound(vtypeArray)
									vtype=vtype&getTypeIdOnCache(vtypeArray(i))&","
								next
								vtype=trimOuterStr(vtype,",")
							else
								vtype=getTypeIdOnCache(vtype)
							end if
						end if
						if InStr(vtype,",")>0 then:whereStr=" and m_type in ("&vtype&") ":else:whereStr=" and m_type="&vtype:end if
					else
						whereStr=""
					end if
					sql=sql1&"where m_recycle=0"&whereStr&orderStr
			end select
			set attrDictionary=nothing:regExpObj.Pattern=labelRuleField
			set matchesfield=regExpObj.Execute(loopstrChannel)
			set rsObj=conn.db(sql,"records1")
			if rsObj.eof then
				if pageListType="channel" then
					loopstrTotal=channellistInfo(0)
				elseif pageListType="search" then
					loopstrTotal=searchlistInfo(0)&searchword&searchlistInfo(1)
				elseif pageListType="topicpage" then
					loopstrTotal=topicpageInfo(0)
				end if
				totalPages=0
			else
				rsObj.pagesize=vsize
				if totalPages>rsObj.pagecount or pageListType<>"customvideo" then totalPages=rsObj.pagecount
				if clng(currentPage)>totalPages then currentPage=totalPages
				rsObj.absolutepage=currentPage
				loopstrTotal=""			
				for i=1 to vsize
					loopstrChannelNew=loopstrChannel
					for each matchfield in matchesfield
						fieldNameAndAttr=regExpReplace(matchfield.SubMatches(0),"[\s]+",chr(32))
						fieldNameAndAttr=trimOuter(fieldNameAndAttr)
						m=instr(fieldNameAndAttr,chr(32))
						if m > 0 then 
							fieldName=left(fieldNameAndAttr,m - 1)
							fieldAttr =	right(fieldNameAndAttr,len(fieldNameAndAttr) - m)
						else
							fieldName=fieldNameAndAttr
							fieldAttr =	""
						end if
						select case fieldName
							case "id"
								loopstrChannelNew=replaceStr(loopstrChannelNew,matchfield.value,rsObj(0))
							case "typeid"
								loopstrChannelNew=replaceStr(loopstrChannelNew,matchfield.value,rsObj(2))
							case "name"
								m_name=rsObj(1):namelen=parseAttr(fieldAttr)("len")
								if not isNul(namelen) and len(m_name)>clng(namelen) then m_name=left(m_name,clng(namelen)-1)&".."
								loopstrChannelNew=replaceStr(loopstrChannelNew,matchfield.value,m_name)
							case "colorname"
								m_color=rsObj(9):m_name=rsObj(1):colornamelen=parseAttr(fieldAttr)("len")
								if not isNul(colornamelen) and len(m_name)>clng(colornamelen) then  m_name=left(m_name,clng(colornamelen)-1)&".."
								if not(isnul(m_color)) then m_name="<font color="&m_color&">"&m_name&"</font>"
								loopstrChannelNew=replaceStr(loopstrChannelNew,matchfield.value,m_name)
							case "note"
								m_note=rsObj(15) : notelen=parseAttr(fieldAttr)("len")
								if not isNul(notelen)  and len(m_note) > clng(notelen)  then m_note=left(m_note,clng(notelen)-1)&".."
								loopstrChannelNew=replaceStr(loopstrChannelNew,matchfield.value,m_note)
							case "actor"
								m_actor=rsObj(6) : actorlen=parseAttr(fieldAttr)("len")
								if not isNul(actorlen) and len(m_actor) > clng(actorlen)  then m_actor=left(m_actor,clng(actorlen)-1)&".."
								loopstrChannelNew=replaceStr(loopstrChannelNew,matchfield.value,m_actor)
							case "des"
								m_des=filterStr(decodeHtml(rsObj(7)),"html"):deslen=parseAttr(fieldAttr)("len")
								if isNul(deslen) then deslen=200
								if len(m_des) > clng(deslen) then  m_des=left(m_des,clng(deslen)-1)&".."
								loopstrChannelNew=replaceStr(loopstrChannelNew,matchfield.value,m_des)
							case "time"
								videoTime=rsObj(10):timestyle=parseAttr(fieldAttr)("style"):if isNul(timestyle) then timestyle="mm-dd"
								dim monthDayTime : monthDayTime=right("00"&month(videoTime),2)&"-"&right("00"&day(videoTime),2)
								select case timestyle
									case "yyyy-mm-dd"
										loopstrChannelNew=replaceStr(loopstrChannelNew,matchfield.value,year(videoTime)&"-"&monthDayTime)
									case "yy-mm-dd"
										loopstrChannelNew=replaceStr(loopstrChannelNew,matchfield.value,right(year(videoTime),2)&"-"&monthDayTime)
									case "yyyy-m-d"
										loopstrChannelNew=replaceStr(loopstrChannelNew,matchfield.value,year(videoTime)&"-"&month(videoTime)&"-"&day(videoTime))
									case else
										loopstrChannelNew=replaceStr(loopstrChannelNew,matchfield.value,monthDayTime)
								end select
							case "i"
								loopstrChannelNew=replaceStr(loopstrChannelNew,matchfield.value,i)
							case "typename"
								loopstrChannelNew=replaceStr(loopstrChannelNew,matchfield.value,Split(getTypeNameTemplateArrayOnCache(rsObj(2)),",")(0))
							case "typelink"
								loopstrChannelNew=replaceStr(loopstrChannelNew,matchfield.value,getTypeLink(rsObj(2)))
							case "link"
								loopstrChannelNew=replaceStr(loopstrChannelNew,matchfield.value,getContentLink(rsObj(2),rsObj(0),rsObj(19),rsObj(20),"link"))
							case "playlink"
								if isAlertWin=1 then playlink_str="javascript:openWin('"&getPlayLink2(rsObj(2),rsObj(0),rsObj(19),rsObj(20),0,0)&"',"&(alertWinW+10)&","&(alertWinH+55)&",250,100,1)" else playlink_str=getPlayLink2(rsObj(2),rsObj(0),rsObj(19),rsObj(20),0,0)
								loopstrChannelNew=replaceStr(loopstrChannelNew,matchfield.value,playlink_str)
							case "pic"
								if not isNul(rsObj(4)) then
									if instr(rsObj(4),"http://")>0 then
										loopstrChannelNew=replaceStr(loopstrChannelNew,matchfield.value,rsObj(4))
									else
										loopstrChannelNew=replaceStr(loopstrChannelNew,matchfield.value,"/"&sitePath&rsObj(4))
									end if
								else
									loopstrChannelNew=replaceStr(loopstrChannelNew,matchfield.value,"/"&sitePath&"pic/nopic.gif")
								end if
							case "hit"
								loopstrChannelNew=replaceStr(loopstrChannelNew,matchfield.value,rsObj(5))
							case "state"
								loopstrChannelNew=replaceStr(loopstrChannelNew,matchfield.value,rsObj(3))
							case "publishtime"
								loopstrChannelNew=replaceStr(loopstrChannelNew,matchfield.value,rsObj(11))
							case "publisharea"
								loopstrChannelNew=replaceStr(loopstrChannelNew,matchfield.value,rsObj(12))
							case "commend"
								loopstrChannelNew=replaceStr(loopstrChannelNew,matchfield.value,rsObj(13))
							case "commendPosition"
								loopstrChannelNew=replaceStr(loopstrChannelNew,matchfield.value,(rsObj(13)*13-430))
							case "from"
								loopstrChannelNew=replaceStr(loopstrChannelNew,matchfield.value,replaceStr(getFromStr(rsObj(14)),"播客CC","FLV高清"))
							case "keyword"
								loopstrChannelNew=replaceStr(loopstrChannelNew,matchfield.value,getKeywordsList(rsObj(16)," "))
							case "digg"
								loopstrChannelNew=replaceStr(loopstrChannelNew,matchfield.value,rsObj(17))
							case "tread"
								loopstrChannelNew=replaceStr(loopstrChannelNew,matchfield.value,rsObj(18))
							case "director"
								loopstrChannelNew=replaceStr(loopstrChannelNew,matchfield.value,rsObj(21))
							case "lang"
								loopstrChannelNew=replaceStr(loopstrChannelNew,matchfield.value,CInt(rsObj(22)/1024))
							case "score"
								loopstrChannelNew=replaceStr(loopstrChannelNew,matchfield.value,rsObj(23))
							case "scorePosition"
								loopstrChannelNew=replaceStr(loopstrChannelNew,matchfield.value,(rsObj(23)*13-430))
							case "shotimg"
							    loopstrChannelNew=replaceStr(loopstrChannelNew,matchfield.value,rsObj(24))
						end select
						strDictionary.removeAll
					next
					loopstrTotal=loopstrTotal&loopstrChannelNew
					rsObj.movenext
					if rsObj.eof then exit for
				next
			end if
			content=replace(content,matchChannel.value,loopstrTotal)
			regExpObj.Pattern=labelRulePagelist
			set matchesPagelist=regExpObj.Execute(content)
			for each matchPagelist in matchesPagelist
				if totalPages=0 then
					content=replace(content,matchPagelist.value,"")
				else
					lenPagelist=parseAttr(matchPagelist.SubMatches(0))("len")
					if isNul(lenPagelist) then lenPagelist=10 else lenPagelist=clng(lenPagelist)
					strPagelist=pageNumberLinkInfo(currentPage,lenPagelist,totalPages,pageListType,rsObj.recordcount)
					content=replace(content,matchPagelist.value,strPagelist)
				end if
			next
			set matchesPagelist=nothing
			set matchesfield=nothing
			strDictionary.removeAll
		next
		set matchesChannel=nothing
	End Function

	Public Function getMenuArray(ByVal sId,ByVal m,ByVal by)
		if by="news" then
			getMenuArray=getMenuByArray(sId,m,getNewsTypeLists())
		else
			getMenuArray=getMenuByArray(sId,m,getTypeLists())
		end if
	End Function
	
	Public Function getMenuByArray(ByVal sId,ByVal m,ByVal ary)
		Dim i,j,k,l,h,vnum,rsArray,typeArray:vnum=-1:typeArray=ary:j=getTypeIndex("m_id"):k=getTypeIndex("m_name"):l=getTypeIndex("m_upid"):h=getTypeIndex("m_hide")
		if m="m_id" then:m=j:else:m=l:end if
		for i=0 to UBound(typeArray,2)
			if InStr(" ,"&sId&",",","&typeArray(m,i)&",")>0 AND ""&typeArray(h,i)="0" then
				vnum=vnum+1
				if not isArray(rsArray) then
					Redim rsArray(2,vnum)
				else
					Redim preserve rsArray(2,vnum)
				end if
				rsArray(0,vnum)=typeArray(k,i)
				rsArray(1,vnum)=typeArray(j,i)
				rsArray(2,vnum)=typeArray(l,i)
			end if
		next
		getMenuByArray=rsArray
	End Function

	Public Function parseMenuList(str)
		dim match,matches,matchfield,matchesfield
		dim labelAttrMenulist,loopstrMenulist,loopstrMlistNew,loopstrTotal
		dim att,vtype,vnum,vby,curUpId,curUpIdStr,curUpIdStrArray
		dim fieldName,fieldAttr,fieldNameAndAttr,fieldAttrLen,tlink
		dim i,labelRuleField
		dim m,rsArray,rsFlag
		labelRule="{maxcms:"&str&"menulist([\s\S]*?)}([\s\S]*?){/maxcms:"&str&"menulist}"
		labelRuleField="\["&str&"menulist:([\s\S]+?)\]"
		regExpObj.Pattern=labelRule
		set matches=regExpObj.Execute(content)
		for each match in matches
			loopstrTotal=""
			labelAttrMenulist=match.SubMatches(0)
			loopstrMenulist=match.SubMatches(1)
			Set att=parseAttr(labelAttrMenulist):vtype=att("type"):vby=att("by"):Set att=nothing
			if isNul(vtype) then vtype="top"
			select case vtype
				case "top"
					rsFlag="top":rsArray=getMenuArray("0","m_upid",vby)
					if isArray(rsArray) then:vnum=UBound(rsArray,2):else:vnum=-1:end if
				case "son"
					rsFlag="son"
					if vby="news" then:curUpIdStr=getNewsTypeNameTemplateArrayOnCache(clng(currentTypeId)):else:curUpIdStr=getTypeNameTemplateArrayOnCache(clng(currentTypeId)):end if
					curUpIdStrArray=split(curUpIdStr,",")
					if ubound(curUpIdStrArray)>=2 then curUpId=trim(curUpIdStrArray(2)) else curUpId=-444
					if curUpId="" then curUpId=0
					if clng(curUpId)<>0 then
						rsArray=getMenuArray(curUpId,"m_upid",vby)
					else
						rsArray=getMenuArray(trim(currentTypeId),"m_upid",vby)
					end if
					if isArray(rsArray) then:vnum=UBound(rsArray,2):else:vnum=-1:end if
				case "all"
					rsFlag="all" : vnum=-1 : loopstrTotal=getAllMenuListOnCache(0,vby)
				case else
					vtype=split(vtype,",")
					for i=0 to ubound(vtype)
						vtype(i)=trim(vtype(i))
						if not isnum(vtype(i)) then die channellistInfo(1)
					next
					vtype=Join(vtype,",")
					if isNul(str) then
						rsArray=getMenuArray(vtype,"m_id",vby)
					else
						rsArray=getMenuArray(vtype,"m_upid",vby)
					end if
					if isArray(rsArray) then:vnum=UBound(rsArray,2):else:vnum=-1:end if
			end select
			regExpObj.Pattern=labelRuleField
			set matchesfield=regExpObj.Execute(loopstrMenulist)
			for i=0 to vnum
				loopstrMlistNew=loopstrMenulist
				if vby="news" then
					tlink=getNewsTypeLink(rsArray(1,i))
				else
					tlink=getTypeLink(rsArray(1,i))
				end if
				for each matchfield in matchesfield
					fieldNameAndAttr=regExpReplace(matchfield.SubMatches(0),"[\s]+",chr(32))
					fieldNameAndAttr=trimOuter(fieldNameAndAttr)
					m=instr(fieldNameAndAttr,chr(32))
					if m > 0 then 
						fieldName=left(fieldNameAndAttr,m - 1)
						fieldAttr =	right(fieldNameAndAttr,len(fieldNameAndAttr) - m)
					else
						fieldName=fieldNameAndAttr
						fieldAttr =	""
					end if
					select case fieldName
						case "i"
							loopstrMlistNew=replaceStr(loopstrMlistNew,matchfield.value,i+1)
						case "typeid"
							loopstrMlistNew=replaceStr(loopstrMlistNew,matchfield.value,rsArray(1,i))
						case "typename"
							loopstrMlistNew=replaceStr(loopstrMlistNew,matchfield.value,rsArray(0,i))
						case "upid"
							loopstrMlistNew=replaceStr(loopstrMlistNew,matchfield.value,rsArray(2,i))
						case "link"
							loopstrMlistNew=replaceStr(loopstrMlistNew,matchfield.value,tlink)
						case "length"
							loopstrMlistNew=replaceStr(loopstrMlistNew,matchfield.value,vnum+1)
						'??,????
					end select
				next
				loopstrTotal=loopstrTotal&loopstrMlistNew
			next
			set matchesfield=nothing
			content=replaceStr(content,match.value,loopstrTotal)
			strDictionary.removeAll
		next
		set matches=nothing
		if isExistStr(content,"{maxcms:smallmenulist") then parseMenuList "small" else Exit Function
	End Function

	Public Function parseTopicList()
		if not isExistStr(content,"{maxcms:topiclist") then Exit Function
		dim match,matches,matchfield,matchesfield
		dim labelAttrTopiclist,loopstrTopiclist,loopstrTopiclistNew,loopstrTotal
		dim vtid,vnum,vstart,attr,n,ni:n=0:ni=1
		dim fieldName,fieldAttr,fieldNameAndAttr,fieldAttrLen
		dim i,labelRuleField
		dim m,rsArray,rsFlag,whereTopic
		labelRule="{maxcms:topiclist([\s\S]*?)}([\s\S]*?){/maxcms:topiclist}"
		labelRuleField="\[topiclist:([\s\S]+?)\]"
		regExpObj.Pattern=labelRule
		set matches=regExpObj.Execute(content)
		for each match in matches
			loopstrTotal=""
			labelAttrTopiclist=match.SubMatches(0)
			loopstrTopiclist=match.SubMatches(1)
			SET attr=parseAttr(labelAttrTopiclist):vtid=attr("id"):vnum=attr("num"):vstart=attr("start")
			if isNul(vtid) then vtid="all"
			if isNul(vnum) then vnum=10 else vnum=clng(vnum)
			if not isNul(vstart) then  vstart=clng(vstart) else vstart=1
			select case trim(vtid)
				case "all" : whereTopic=""
				case else
					if instr(vtid,",")>0 then whereTopic=" where m_id in("&vtid&")" else whereTopic=" where m_id ="&vtid
			end select
			n=vstart-1 : vnum=vnum+vstart-1
			rsArray=conn.db("select top "&vnum&" m_name,m_id,m_pic,m_enname,m_des from {pre}topic "&whereTopic&" order by m_sort asc","array")
			if isArray(rsArray) then vnum=ubound(rsArray,2)  else  vnum=-1
			regExpObj.Pattern=labelRuleField
			set matchesfield=regExpObj.Execute(loopstrTopiclist)
			for i=n to vnum
				loopstrTopiclistNew=loopstrTopiclist
				for each matchfield in matchesfield
					fieldNameAndAttr=regExpReplace(matchfield.SubMatches(0),"[\s]+",chr(32))
					fieldNameAndAttr=trimOuter(fieldNameAndAttr)
					m=instr(fieldNameAndAttr,chr(32))
					if m > 0 then 
						fieldName=left(fieldNameAndAttr,m - 1)
						fieldAttr =	right(fieldNameAndAttr,len(fieldNameAndAttr) - m)
					else
						fieldName=fieldNameAndAttr
						fieldAttr =	""
					end if
					select case fieldName
						case "i"
							loopstrTopiclistNew=replaceStr(loopstrTopiclistNew,matchfield.value,i+1)
						case "n"
							loopstrTopiclistNew=replaceStr(loopstrTopiclistNew,matchfield.value,ni)
						case "id"
							loopstrTopiclistNew=replaceStr(loopstrTopiclistNew,matchfield.value,rsArray(1,i))
						case "name"
							loopstrTopiclistNew=replaceStr(loopstrTopiclistNew,matchfield.value,rsArray(0,i))
						case "count"
							loopstrTopiclistNew=replaceStr(loopstrTopiclistNew,matchfield.value,conn.db("select count(*) from {pre}data where m_topic="&rsArray(1,i),"execute")(0))
						case "pic"
							if not isNul(rsArray(2,i)) then 
								if instr(rsArray(2,i),"http://")>0 then 
									loopstrTopiclistNew=replaceStr(loopstrTopiclistNew,matchfield.value,rsArray(2,i))
								else
									loopstrTopiclistNew=replaceStr(loopstrTopiclistNew,matchfield.value,"/"&sitePath&"pic/zt/"&rsArray(2,i))
								end if
							else
								loopstrTopiclistNew=replaceStr(loopstrTopiclistNew,matchfield.value,"/"&sitePath&"pic/nopic.gif")
							end if
						case "link"
							loopstrTopiclistNew=replaceStr(loopstrTopiclistNew,matchfield.value,getTopicPageLink(rsArray(1,i),1,rsArray(3,i)))
						case "des"
							dim deslen,m_des:m_des=decodeHtml(rsArray(4,i)):deslen=parseAttr(fieldAttr)("len")
							if isNul(deslen) then deslen=200
							if len(m_des) > clng(deslen) then  m_des=left(m_des,clng(deslen)-1)&".."
							loopstrTopiclistNew=replaceStr(loopstrTopiclistNew,matchfield.value,m_des)
					end select
				next
				loopstrTotal=loopstrTotal&loopstrTopiclistNew:ni=ni+1
			next
			set matchesfield=nothing:SET attr=nothing
			content=replaceStr(content,match.value,loopstrTotal)
			strDictionary.removeAll
		next
		set matches=nothing
	End Function

	Public Function parseTopicIndex(currentPage,totalPages)
		if not isExistStr(content,"{maxcms:topicindexlist") then Exit Function
		dim match,matches,matchfield,matchesfield,matchesPagelist,strPagelist
		dim labelAttrTopiclist,loopstrTopiclist,loopstrTopiclistNew,loopstrTotal,labelRulePagelist,matchPagelist
		dim vsize
		dim fieldName,fieldAttr,fieldNameAndAttr,fieldAttrLen,lenPagelist
		dim i,labelRuleField
		dim m,rsObj,rsFlag
		labelRule="{maxcms:topicindexlist([\s\S]*?)}([\s\S]*?){/maxcms:topicindexlist}"
		labelRuleField="\[topicindexlist:([\s\S]+?)\]"
		labelRulePagelist="\[topicindexlist:pagenumber([\s\S]*?)\]"
		regExpObj.Pattern=labelRule
		set matches=regExpObj.Execute(content)
		for each match in matches
			loopstrTotal=""
			labelAttrTopiclist=match.SubMatches(0)
			loopstrTopiclist=match.SubMatches(1)
			vsize=clng(parseAttr(labelAttrTopiclist)("size"))
			set rsObj=conn.db("select m_name,m_id,m_pic,m_enname,m_des from {pre}topic order by m_sort asc","records1")
			if rsObj.eof then
				loopstrTotal=topicpageInfo(0)
			else
				rsObj.pagesize=vsize
				if clng(currentPage)>clng(rsObj.pagecount) then currentPage=rsObj.pagecount
				rsObj.absolutepage=currentPage:loopstrTotal=""
				regExpObj.Pattern=labelRuleField
				set matchesfield=regExpObj.Execute(loopstrTopiclist)
				for i=1 to vsize
					loopstrTopiclistNew=loopstrTopiclist
					for each matchfield in matchesfield
						fieldNameAndAttr=regExpReplace(matchfield.SubMatches(0),"[\s]+",chr(32))
						fieldNameAndAttr=trimOuter(fieldNameAndAttr)
						m=instr(fieldNameAndAttr,chr(32))
						if m > 0 then
							fieldName=left(fieldNameAndAttr,m - 1)
							fieldAttr =	right(fieldNameAndAttr,len(fieldNameAndAttr) - m)
						else
							fieldName=fieldNameAndAttr
							fieldAttr =	""
						end if
						select case fieldName
							case "i"
								loopstrTopiclistNew=replaceStr(loopstrTopiclistNew,matchfield.value,i+1)
							case "name"
								loopstrTopiclistNew=replaceStr(loopstrTopiclistNew,matchfield.value,rsObj(0))
							case "count"
								loopstrTopiclistNew=replaceStr(loopstrTopiclistNew,matchfield.value,conn.db("select count(*) from {pre}data where m_topic="&rsObj(1),"execute")(0))
							case "pic"
								if not isNul(rsObj(2)) then
									if instr(rsObj(2),"http://")>0 then 
										loopstrTopiclistNew=replaceStr(loopstrTopiclistNew,matchfield.value,rsObj(2))
									else
										loopstrTopiclistNew=replaceStr(loopstrTopiclistNew,matchfield.value,"/"&sitePath&"pic/zt/"&rsObj(2))
									end if
								else
									loopstrTopiclistNew=replaceStr(loopstrTopiclistNew,matchfield.value,"/"&sitePath&"pic/nopic.gif")
								end if
							case "link"
								loopstrTopiclistNew=replaceStr(loopstrTopiclistNew,matchfield.value,getTopicPageLink(rsObj(1),1,rsObj(3)))
							case "des"
								dim deslen,m_des:m_des=decodeHtml(rsObj(4)):deslen=parseAttr(fieldAttr)("len")
								if isNul(deslen) then deslen=200
								if len(m_des) > clng(deslen) then  m_des=left(m_des,clng(deslen)-1)&".."
								loopstrTopiclistNew=replaceStr(loopstrTopiclistNew,matchfield.value,m_des)
						end select
					next
					loopstrTotal=loopstrTotal&loopstrTopiclistNew
					rsObj.movenext
					if rsObj.eof then exit for
				next
				set matchesfield=nothing
			end if
			content=replaceStr(content,match.value,loopstrTotal)
			regExpObj.Pattern=labelRulePagelist
			set matchesPagelist=regExpObj.Execute(content)
			for each matchPagelist in matchesPagelist
				if rsObj.pagecount=0 then
					content=replace(content,matchPagelist.value,"")
				else
					lenPagelist=parseAttr(matchPagelist.SubMatches(0))("len")
					if isNul(lenPagelist) then lenPagelist=10 else lenPagelist=clng(lenPagelist)
					strPagelist=pageNumberLinkInfo(currentPage,lenPagelist,rsObj.pagecount,"topicindex",rsObj.recordcount)
					content=replace(content,matchPagelist.value,strPagelist)
				end if
			next 
			set matchesPagelist=nothing:rsObj.close:set rsObj=nothing
		next
		set matches=nothing
	End Function

	Public Function parseLinkList()
		if not isExistStr(content,"{maxcms:linklist") then Exit Function
		dim match,matches,matchfield,matchesfield
		dim labelAttrLinklist,loopstrLinklist,loopstrLinklistNew,loopstrTotal
		dim vtype,vnum,whereStr,linkArray
		dim fieldName,fieldAttr,fieldNameAndAttr,fieldAttrLen
		dim i,labelRuleField
		dim m,namelen,deslen,m_des
		labelRule="{maxcms:linklist([\s\S]*?)}([\s\S]*?){/maxcms:linklist}"
		labelRuleField="\[linklist:([\s\S]+?)\]"
		regExpObj.Pattern=labelRule
		set matches=regExpObj.Execute(content)
		for each match in matches
			labelAttrLinklist=match.SubMatches(0)
			loopstrLinklist=match.SubMatches(1)
			vtype=parseAttr(labelAttrLinklist)("type")
			if isNul(vtype) then vtype="font"
			select case vtype
				case "font" : whereStr=chr(32)&"m_type='font'"&chr(32)
				case "pic" : whereStr=chr(32)&"m_type='pic'"&chr(32)
				case else : whereStr=chr(32)&"m_type='font'"&chr(32)
			end select
			linkArray=conn.db("select m_name,m_pic,m_url,m_des from {pre}link  where "&whereStr&" order by m_sort asc","array")
			if not isarray(linkArray) then  vnum=-1  else vnum=ubound(linkArray,2)
			regExpObj.Pattern=labelRuleField
			set matchesfield=regExpObj.Execute(loopstrLinklist)
			loopstrTotal=""
			for i=0 to vnum
				loopstrLinklistNew=loopstrLinklist
				for each matchfield in matchesfield
					fieldNameAndAttr=regExpReplace(matchfield.SubMatches(0),"[\s]+",chr(32))
					fieldNameAndAttr=trimOuter(fieldNameAndAttr)
					m=instr(fieldNameAndAttr,chr(32))
					if m > 0 then 
						fieldName=left(fieldNameAndAttr,m - 1)
						fieldAttr =	right(fieldNameAndAttr,len(fieldNameAndAttr) - m)
					else
						fieldName=fieldNameAndAttr
						fieldAttr =	""
					end if
					select case fieldName
						case "name"
							namelen=parseAttr(fieldAttr)("len") : if isNul(namelen) then namelen=8 else namelen=clng(namelen)
							loopstrLinklistNew=replaceStr(loopstrLinklistNew,matchfield.value,left(linkArray(0,i),namelen))
						case "link"
							loopstrLinklistNew=replaceStr(loopstrLinklistNew,matchfield.value,linkArray(2,i))
						case "pic"
							loopstrLinklistNew=replaceStr(loopstrLinklistNew,matchfield.value,linkArray(1,i))
						case "des"
							m_des=decodeHtml(linkArray(3,i)):deslen=parseAttr(fieldAttr)("len")
							if isNul(deslen) then deslen=100
							if len(m_des) > clng(deslen) then  m_des=left(m_des,clng(deslen)-1)&".."
							loopstrLinklistNew=replaceStr(loopstrLinklistNew,matchfield.value,m_des)
						case "i"
							loopstrLinklistNew=replaceStr(loopstrLinklistNew,matchfield.value,i+1)
					end select
				next
				loopstrTotal=loopstrTotal&loopstrLinklistNew
			next
			set matchesfield=nothing
			content=replaceStr(content,match.value,loopstrTotal)
			strDictionary.removeAll
		next
		set matches=nothing
	End Function

	Public Function parsePlayList(ByVal typeid,ByVal dataId,ByVal enname,ByVal sDate,ByVal playORdownData,ByVal str)
		if not isExistStr(content,"{playpage:playlist") and not isExistStr(content,"{playpage:downlist") then Exit Function
		dim match,matches,matchfield,matchesfield
		dim loopstrPlaylist,loopstrPlaylistNew,loopstrTotal
		dim vtype,playRsArray,playDataArray,singlePlayData,vnum,videoFrom,videoUrl
		dim fieldName,fieldAttr,fieldNameAndAttr
		dim i,labelRuleField,i_2,PlayerIntroArray:PlayerIntroArray=getPlayerIntroArrayOnCache(str)
		dim m,videoFromStr,videoFromCount,whereStr,n,urlStr,playerInfoStr,playerSingleInfoArray
		labelRule="{playpage:"&str&"list\s*}([\s\S]*?){/playpage:"&str&"list}"
		labelRuleField="\["&str&"list:([\s\S]+?)\]"
		'whereStr =chr(32)&"m_id="&dataId&chr(32)
		regExpObj.Pattern=labelRule
		set matches=regExpObj.Execute(content)
		for each match in matches
			loopstrPlaylist=match.SubMatches(0)
			'playRsArray=conn.db("select m_type,m_"&str&"data from {pre}data where "&whereStr,"array")
			'playDataArray=getPlayurlArray(playRsArray(1,0))
			if IsFromSort=1 then playORdownData=ResetFromSort(playORdownData)
			playDataArray=getPlayurlArray(playORdownData)
			vnum=ubound(playDataArray)
			regExpObj.Pattern=labelRuleField
			set matchesfield=regExpObj.Execute(loopstrPlaylist)
			i_2=0:loopstrTotal=""
			for i=0 to vnum
				singlePlayData=split(playDataArray(i),"$$") : videoFrom=i : videoUrl=singlePlayData(1)
				playerInfoStr=getPlayerIntroOnCache(str,singlePlayData(0))
				if isExistStr(playerInfoStr,"__maxcc__") then
					playerSingleInfoArray=split(playerInfoStr,"__maxcc__")
					loopstrPlaylistNew=loopstrPlaylist
					if playerSingleInfoArray(1)="1" then
						i_2=i_2+1
						for each matchfield in matchesfield
							fieldNameAndAttr=regExpReplace(matchfield.SubMatches(0),"[\s]+",chr(32))
							fieldNameAndAttr=trimOuter(fieldNameAndAttr)
							m=instr(fieldNameAndAttr,chr(32))
							if m > 0 then
								fieldName=left(fieldNameAndAttr,m - 1)
								fieldAttr =	right(fieldNameAndAttr,len(fieldNameAndAttr) - m)
							else
								fieldName=fieldNameAndAttr
								fieldAttr =	""
							end if
							select case fieldName
								case "from"
									loopstrPlaylistNew=replace(replace(loopstrPlaylistNew,matchfield.value,singlePlayData(0)),"播客CC","FLV高清")
								case "intro"
									loopstrPlaylistNew=replace(loopstrPlaylistNew,matchfield.value,playerSingleInfoArray(0))
								case "link"
									urlStr=getPlayUrlList(videoFrom,videoUrl,typeid,dataId,enname,sDate,str,parseAttr(fieldAttr)("target"),"normal")
									loopstrPlaylistNew=replace(loopstrPlaylistNew,matchfield.value,urlStr)
								case "i"
									loopstrPlaylistNew=replace(loopstrPlaylistNew,matchfield.value,i_2)
								case "url"
									urlStr=getPlayUrlList(videoFrom,videoUrl,typeid,dataId,enname,sDate,str,parseAttr(fieldAttr)("target"),"kuaiwan")
									loopstrPlaylistNew=replace(loopstrPlaylistNew,matchfield.value,urlStr)
							end select
						next
					else
						loopstrPlaylistNew=""
					end if
				else
					loopstrPlaylistNew=""
				end if
				loopstrTotal=loopstrTotal&loopstrPlaylistNew
			next
			set matchesfield=nothing
			content=replace(content,match.value,loopstrTotal)
			content=replace(content,"{playpage:"&str&"listlen}",i_2)
			strDictionary.removeAll
		next
		set matches=nothing
	End Function

	Public Function parseNews(ByVal vid,ByVal title,ByVal color,ByVal txt,ByVal addtime)
		dim labelRule,matchfield ,matches , fieldNameAndAttr , m , fieldName ,fieldAttr,x,y,z
		labelRule="{news:([\s\S]+?)}"
		regExpObj.Pattern=labelRule
		set matches=regExpObj.Execute(content)
		for each matchfield in matches
			fieldNameAndAttr=regExpReplace(matchfield.SubMatches(0),"[\s]+",chr(32))
			fieldNameAndAttr=trimOuter(fieldNameAndAttr)
			m=instr(fieldNameAndAttr,chr(32))
			if m > 0 then 
			fieldName=left(fieldNameAndAttr,m - 1)
				fieldAttr =	right(fieldNameAndAttr,len(fieldNameAndAttr) - m)
			else
				fieldName=fieldNameAndAttr
				fieldAttr =	""
			end if
			select case fieldName
				case "title"
					x=title:y=parseAttr(fieldAttr)("len")
					if not isNul(y) and len(x) > clng(y) then  x=left(x,clng(y)-1)&".."
					content=replaceStr(content,matchfield.value,x)
				case "colortitle"
					x=title:y=parseAttr(fieldAttr)("len"):if not isNul(y) and len(x)>clng(y) then x=left(x,clng(y)-1)&".."
					y=color:if not(isnul(y)) then:x="<font color="&y&">"&x&"</font>":end if:content=replaceStr(content,matchfield.value,x)
				case "content"
					x=decodeHtml(txt):y=parseAttr(fieldAttr)("len")
					if not isNul(y) and len(x)>clng(y) then x=left(x,clng(y)-1)&".."
					content=replaceStr(content,matchfield.value,x)
				case "addtime","time"
					x=addtime:y=parseAttr(fieldAttr)("style"):if isNul(x) then x="mm-dd"
					select case y
						case "yyyy-mm-dd"
							content=replaceStr(content,matchfield.value,year(x)&"-"&Right("00"&month(x),2)&"-"&right("00"&day(x),2))
						case "yy-mm-dd"
							content=replaceStr(content,matchfield.value,right(year(x),2)&"-"&Right("00"&month(x),2)&"-"&right("00"&day(x),2))
						case "yyyy-m-d"
							content=replaceStr(content,matchfield.value,year(x)&"-"&month(x)&"-"&day(x))
						case else
							content=replaceStr(content,matchfield.value,Right("00"&month(x),2)&"-"&right("00"&day(x),2))
					end select
			end select
		next
		set matches=nothing
	End Function

	Public Function parseNewsList()
		if not isExistStr(content,"{maxcms:newslist") then Exit Function
		dim match,matches,matchfield,matchesfield
		dim labelAttrVideolist,loopstrVideoList,loopstrVlistNew,loopstrTotal,attrDictionary
		dim vnum,vorder,vtype,vtopic,vtime,vstart,vstate,vcommend,vletter,vid,avid
		dim fieldName,fieldAttr,fieldNameAndAttr,fieldAttrLen
		dim i,labelRuleField,field_des,n,ni:n=0:ni=1
		dim namelen,attrval,actorlen,deslen,timestyle,videoTime,colornamelen,m_colorname,m_des,m_color,m_note,notelen,m_name,m_actor
		dim m,sql,orderStr,whereType,whereLetter,whereTopic,whereTime,whereStr,videoListArray,whereCommend,whereId,whereVid,vtypeArray,vtypeI,vtypeStr,vtypeArrayLen,playlink_str
		labelRule="{maxcms:newslist([\s\S]*?)}([\s\S]*?){/maxcms:newslist}"
		labelRuleField="\[newslist:([\s\S]+?)\]"
		regExpObj.Pattern=labelRule
		set matches=regExpObj.Execute(content)
		for each match in matches
			labelAttrVideolist=match.SubMatches(0)
			loopstrVideoList=match.SubMatches(1)
			if isExistStr(loopstrVideoList,"[newslist:des") OR isExistStr(loopstrVideoList,"[newslist:content") then field_des="m_content" else field_des="0"
			set attrDictionary=parseAttr(labelAttrVideolist)
			vnum=attrDictionary("num"):vorder=attrDictionary("order"):vletter=attrDictionary("letter"):vtype=attrDictionary("type"):vtopic=attrDictionary("topic"):vtime=attrDictionary("time"):vcommend=attrDictionary("commend"):vid=attrDictionary("id"):avid=attrDictionary("vid")
			if isNul(vnum) then vnum=10 else vnum=clng(vnum)
			if isNul(vorder) AND isNul(vid) then vorder="time"
			if isNul(vorder) then vorder="id"
			select case vorder
				case "id":orderStr =" order by m_id desc"
				case "hit":orderStr =" order by m_hit desc"
				case "dayhit":orderStr =" order by m_dayhit desc"
				case "weekhit":orderStr =" order by m_weekhit desc"
				case "monthhit":orderStr =" order by m_monthhit desc"
				case "time":orderStr =" order by m_addtime desc"
				case "commend":orderStr =" order by m_commend desc"
				case "digg" : orderStr =" order by m_digg desc"
				case "score" : orderStr =" order by m_score desc"
				case "random"
				if databaseType=0 then
					dim rndNum:randomize():rndNum=int(1000*rnd)+1  :orderStr =" order by rnd( -1*"&rndNum&" * m_id)"
				else
					orderStr=" order by newid() desc"
				end if
			end select
			if isNul(vtype) then vtype="all"
			vtypeStr=""
			if vtype <> "all" then
				if vtype="current" then
					vtypeStr=getNewsTypeIdOnCache(currentTypeId)
				else
					if instr(vtype,",")>0 then
						vtypeArray=split(vtype,","):vtypeArrayLen=ubound(vtypeArray)
						for vtypeI=0 to  vtypeArrayLen
							vtypeStr=vtypeStr&getNewsTypeIdOnCache(vtypeArray(vtypeI))&","
						next
						vtypeStr=trimOuterStr(vtypeStr,",")
					else
						vtypeStr=getNewsTypeIdOnCache(vtype)
					end if
				end if
				if InStr(vtypeStr,",")>0 then:whereType=" and m_type in ("&vtypeStr&") ":else:whereType=" and m_type="&vtypeStr:end if
			else
				whereType=""
			end if
			if not Isnul(vletter) AND vletter<>"all" then whereLetter=" and m_letter ='"&UCase(vletter)&"' " else whereLetter=""
			if not Isnul(vid) AND vid<>"all" then
				if InStr(vid,",")>0 then:whereId=" and m_id IN ("&vid&") ":else:whereId=" and m_id="&vid:end if
			else
				whereId=""
			end if
			if not Isnul(avid) AND avid<>"all" then
				if InStr(avid,",")>0 then:whereVid=" and m_vid IN ("&avid&") ":else:whereVid=" and m_vid="&vid:end if
			else
				whereVid=""
			end if
			if not isNul(vcommend) then
				select case trim(vcommend)
					case "all":whereCommend=" and  m_commend>0"
					case else
						if instr(vcommend,",")>0 then whereCommend=" and m_commend in("&vcommend&")" else whereCommend=" and m_commend ="&vcommend
				end select
			else
				whereCommend=""
			end if
			if not isNul(vtopic) then
				select case trim(vtopic)
					case "all" : whereTopic=" and m_topic>0"
					case "current" : whereTopic=" and m_topic="&currentTopicId
					case else
						if instr(vtopic,",")>0 then whereTopic=" and m_topic in("&vtopic&")" else whereTopic=" and m_topic ="&vtopic
				end select
			else
				whereTopic=""
			end if
			if databaseType = 0 then
				select case vtime
					case "day" : whereTime=" and  DateDiff('d',m_addtime,#"&now()&"#)=0"
					case "week" : whereTime=" and  DateDiff('d',m_addtime,#"&now()&"#)<7"
					case "month" : whereTime=" and  DateDiff('d',m_addtime,#"&now()&"#)<31"
					case else : whereTime=""
				end select
			else
				select case vtime
					case "day" : whereTime=" and  DateDiff(d,m_addtime,'"&now()&"')=0"
					case "week" : whereTime=" and  DateDiff(d,m_addtime,'"&now()&"')<7"
					case "month" : whereTime=" and  DateDiff(d,m_addtime,'"&now()&"')<31"
					case else : whereTime=""
				end select
			end if
			whereStr=Replace(" where m_recycle=0"&whereType&whereLetter&whereTopic&whereTime&whereCommend&whereId&whereVid,"where  and ","where ")
			'if trim(whereStr)="where" then whereStr=""
			if not isNul(vstart) then  vstart=clng(vstart) else vstart=1
			n=vstart-1 : vnum=vnum+vstart-1
			set attrDictionary=nothing
			sql="select top "&vnum+1&" m_id,m_title,m_type,m_vid,m_pic,m_hit,m_author,"&field_des&",m_topic,m_color,m_addtime,m_from,m_outline,m_commend,m_letter,m_keyword,m_digg,m_tread,m_entitle,m_datetime,m_note from {pre}news "&whereStr&orderStr
			conn.fetchCount=vnum:videoListArray=conn.db(sql,"array"):conn.fetchCount=0
			regExpObj.Pattern=labelRuleField
			set matchesfield=regExpObj.Execute(loopstrVideoList)
			loopstrTotal=""
			if isArray(videoListArray) then vnum=ubound(videoListArray,2) else vnum=-1
			for i=n to vnum
				loopstrVlistNew=loopstrVideoList
				for each matchfield in matchesfield
					fieldNameAndAttr=regExpReplace(matchfield.SubMatches(0),"[\s]+",chr(32))
					fieldNameAndAttr=trimOuter(fieldNameAndAttr)
					m=instr(fieldNameAndAttr,chr(32))
					if m > 0 then 
						fieldName=left(fieldNameAndAttr,m - 1)
						fieldAttr =	right(fieldNameAndAttr,len(fieldNameAndAttr) - m)
					else
						fieldName=fieldNameAndAttr
						fieldAttr =	""
					end if
					select case fieldName
						case "id"
							loopstrVlistNew=replaceStr(loopstrVlistNew,matchfield.value,videoListArray(0,i))
						case "typeid"
							loopstrVlistNew=replaceStr(loopstrVlistNew,matchfield.value,videoListArray(2,i))
						case "letter"
							loopstrVlistNew=replaceStr(loopstrVlistNew,matchfield.value,videoListArray(14,i))
						case "title","name"
							m_name=videoListArray(1,i):namelen=parseAttr(fieldAttr)("len")
							if not isNul(namelen) and len(m_name)>clng(namelen) then m_name=left(m_name,clng(namelen)-1)&".."
							loopstrVlistNew=replaceStr(loopstrVlistNew,matchfield.value,m_name)
						case "colortitle","colorname"
							m_color=videoListArray(9,i):m_name=videoListArray(1,i):colornamelen=parseAttr(fieldAttr)("len")
							if not isNul(colornamelen) and len(m_name)>clng(colornamelen) then  m_name=left(m_name,clng(colornamelen)-1)&".."
							if not(isnul(m_color)) then m_name="<font color="&m_color&">"&m_name&"</font>"
							loopstrVlistNew=replaceStr(loopstrVlistNew,matchfield.value,m_name)
						case "outline"
							m_note=videoListArray(12,i) : notelen=parseAttr(fieldAttr)("len")
							if not isNul(notelen) and len(m_note) > clng(notelen) then m_note=left(m_note,clng(notelen)-1)&".."
							loopstrVlistNew=replaceStr(loopstrVlistNew,matchfield.value,m_note)
						case "author"
							m_actor=videoListArray(6,i) : actorlen=parseAttr(fieldAttr)("len")
							if not isNul(actorlen) and len(m_actor) > clng(actorlen) then m_actor=left(m_actor,clng(actorlen)-1)&".."
							loopstrVlistNew=replaceStr(loopstrVlistNew,matchfield.value,getKeywordsList(m_actor," "))
						case "content","des"
							m_des=filterStr(decodeHtml(videoListArray(7,i)),"html"):deslen=parseAttr(fieldAttr)("len")
							if isNul(deslen) then deslen=200
							if len(m_des) > clng(deslen) then  m_des=left(m_des,clng(deslen)-1)&".."
							loopstrVlistNew=replaceStr(loopstrVlistNew,matchfield.value,m_des)
						case "addtime","time"
							videoTime=videoListArray(10,i):timestyle=parseAttr(fieldAttr)("style") : if isNul(timestyle) then timestyle="mm-dd"
							dim monthDayTime : monthDayTime=right("00"&month(videoTime),2)&"-"&right("00"&day(videoTime),2)
							select case timestyle
								case "yyyy-mm-dd"
									loopstrVlistNew=replaceStr(loopstrVlistNew,matchfield.value,year(videoTime)&"-"&monthDayTime)
								case "yy-mm-dd"
									loopstrVlistNew=replaceStr(loopstrVlistNew,matchfield.value,right(year(videoTime),2)&"-"&monthDayTime)
								case "yyyy-m-d"
									loopstrVlistNew=replaceStr(loopstrVlistNew,matchfield.value,year(videoTime)&"-"&month(videoTime)&"-"&day(videoTime))
								case else
									loopstrVlistNew=replaceStr(loopstrVlistNew,matchfield.value,monthDayTime)
							end select
						case "i"
							loopstrVlistNew=replaceStr(loopstrVlistNew,matchfield.value,i+1)
						case "n"
							loopstrVlistNew=replaceStr(loopstrVlistNew,matchfield.value,ni)
						case "typename"
							loopstrVlistNew=replaceStr(loopstrVlistNew,matchfield.value,Split(getNewsTypeNameTemplateArrayOnCache(clng(videoListArray(2,i))),",")(0))
						case "typelink"
							loopstrVlistNew=replaceStr(loopstrVlistNew,matchfield.value,getNewsTypeLink(videoListArray(2,i)))
						case "newslink","link"
							loopstrVlistNew=replaceStr(loopstrVlistNew,matchfield.value,getNewsArticleLink(videoListArray(2,i),videoListArray(0,i),videoListArray(18,i),videoListArray(19,i),"link"))
						case "pic"
							if not isNul(videoListArray(4,i)) then 
								if instr(videoListArray(4,i),"http://")>0 then 
									loopstrVlistNew=replaceStr(loopstrVlistNew,matchfield.value,videoListArray(4,i))
								else
									loopstrVlistNew=replaceStr(loopstrVlistNew,matchfield.value,"/"&sitePath&videoListArray(4,i))
								end if
							else
								loopstrVlistNew=replaceStr(loopstrVlistNew,matchfield.value,"/"&sitePath&"pic/nopic.gif")
							end if
						case "hit"
							loopstrVlistNew=replaceStr(loopstrVlistNew,matchfield.value,videoListArray(5,i))
						case "vid"
							loopstrVlistNew=replaceStr(loopstrVlistNew,matchfield.value,videoListArray(3,i))
						case "from"
							loopstrVlistNew=replaceStr(loopstrVlistNew,matchfield.value,videoListArray(11,i))
						case "commend"
							loopstrVlistNew=replaceStr(loopstrVlistNew,matchfield.value,videoListArray(13,i))
						case "commendPosition"
							loopstrVlistNew=replaceStr(loopstrVlistNew,matchfield.value,(videoListArray(13,i)*13-430))
						case "keyword"
							loopstrVlistNew=replaceStr(loopstrVlistNew,matchfield.value,getKeywordsList(videoListArray(15,i)," "))
						case "digg"
							loopstrVlistNew=replaceStr(loopstrVlistNew,matchfield.value,videoListArray(16,i))
						case "tread"
							loopstrVlistNew=replaceStr(loopstrVlistNew,matchfield.value,videoListArray(17,i))
						case "note"
							loopstrVlistNew=replaceStr(loopstrVlistNew,matchfield.value,parseNewsNote(videoListArray(20,i)))
					end select
					strDictionary.removeAll
				next
				loopstrTotal=loopstrTotal&loopstrVlistNew:ni=ni+1
			next
			set matchesfield=nothing
			content=replaceStr(content,match.value,loopstrTotal)
			strDictionary.removeAll
		next
		set matches=nothing
	End Function

	Public Function parseNewsPartList(typeId,currentPage,totalPages,pageListType)
		dim matchChannel,matchesChannel,loopstrChannel,loopstrTotal,attrChannel,attrDictionary,loopstrChannelNew
		dim labelRuleField,field_des,field_playdata
		dim vsize,vorder
		dim i,m,sql,rsObj,orderStr,whereStr,sql1,esql
		dim matchfield,matchesfield,fieldNameAndAttr,fieldName,fieldAttr
		dim namelen,actorlen,deslen,timestyle,videoTime,colornamelen,m_colorname,m_des,m_color,m_note,notelen,m_actor,m_name
		dim matchPagelist,matchesPagelist,labelRulePagelist,lenPagelist,strPagelist,playlink_str
		labelRule="{maxcms:"&pageListType&"list([\s\S]*?)}([\s\S]*?){/maxcms:"&pageListType&"list}"
		labelRuleField="\["&pageListType&"list:([\s\S]+?)\]"
		labelRulePagelist="\["&pageListType&"list:pagenumber([\s\S]*?)\]"
		if isExistStr(content,"["&pageListType&"list:des") OR isExistStr(content,"["&pageListType&"list:content") then field_des="m_content" else  field_des="0"
		regExpObj.Pattern=labelRule
		set matchesChannel=regExpObj.Execute(content):sql1="select m_id,m_title,m_type,m_vid,m_pic,m_hit,m_author,"&field_des&",m_topic,m_color,m_addtime,m_from,m_outline,m_commend,m_letter,m_keyword,m_digg,m_tread,m_entitle,m_datetime,m_note from {pre}news "
		for each matchChannel in matchesChannel
			attrChannel=matchChannel.SubMatches(0)
			loopstrChannel=matchChannel.SubMatches(1)
			set attrDictionary=parseAttr(attrChannel)
			vsize=clng(attrDictionary("size")) : vorder=attrDictionary("order")
			if isNul(vsize) then vsize=12 
			if isNul(vorder) then vorder="time"
			select case vorder
				case "id" : orderStr =" order by m_id desc"
				case "hit" : orderStr =" order by m_hit desc"
				case "dayhit" : orderStr =" order by m_dayhit desc"
				case "weekhit" : orderStr =" order by m_weekhit desc"
				case "monthhit" : orderStr =" order by m_monthhit desc"
				case "time" : orderStr =" order by m_addtime desc"
				case "commend" : orderStr =" order by m_commend desc"
				case "digg" : orderStr =" order by m_digg desc"
				case "score" : orderStr =" order by m_score desc"
				case "letter" : orderstr=" order by m_letter asc"
			end select
			set attrDictionary=nothing
			select case pageListType
				case "newspage"
					sql=sql1&"where m_recycle=0 AND m_type in ("&typeId&")"&orderStr
				case "newssearch"
					esql=EscapeSql(searchword)
					select case clng(searchType)
						case -1 : whereStr=" where m_recycle=0 AND m_title like '%"&esql&"%' or m_keyword like '%"&esql&"%'"
						case 0 : whereStr=" where m_recycle=0 AND m_title like '%"&esql&"%'"
						case 1 : whereStr=" where m_recycle=0 AND m_author like '%"&esql&"%'"
						case 2 : whereStr=" where m_recycle=0 AND m_from like '%"&esql&"%'"
						case 3 : whereStr=" where m_recycle=0 AND m_outline like '%"&esql&"%'"
						case 4 : whereStr=" where m_recycle=0 AND m_letter='"&UCase(searchword)&"'"
					end select
					if Cstr(searchword)="" then whereStr=" where 1=2"
				sql=sql1&whereStr&orderStr
				case "newstopicpage"
					sql=sql1&"where m_recycle=0 AND m_topic="&typeId&orderStr
				end select
				regExpObj.Pattern=labelRuleField
			set matchesfield=regExpObj.Execute(loopstrChannel)
			set rsObj=conn.db(sql,"records1")
			if rsObj.eof then
				if pageListType="newspage" then
					loopstrTotal=channellistInfo(0)
				elseif pageListType="newssearch" then
					loopstrTotal=searchlistInfo(0)&searchword&searchlistInfo(1)
				elseif pageListType="newstopicpage" then
					loopstrTotal=topicpageInfo(0)
				end if
			else
				rsObj.pagesize=vsize
				if clng(currentPage)>clng(rsObj.pagecount) then currentPage=rsObj.pagecount				
				rsObj.absolutepage=currentPage
				loopstrTotal=""			
				for i=1 to vsize
					loopstrChannelNew=loopstrChannel
					for each matchfield in matchesfield
						fieldNameAndAttr=regExpReplace(matchfield.SubMatches(0),"[\s]+",chr(32))
						fieldNameAndAttr=trimOuter(fieldNameAndAttr)
						m=instr(fieldNameAndAttr,chr(32))
						if m > 0 then 
							fieldName=left(fieldNameAndAttr,m - 1)
							fieldAttr =	right(fieldNameAndAttr,len(fieldNameAndAttr) - m)
						else
							fieldName=fieldNameAndAttr
							fieldAttr =	""
						end if
						select case fieldName
							case "id"
								loopstrChannelNew=replaceStr(loopstrChannelNew,matchfield.value,rsObj(0))
							case "typeid"
								loopstrChannelNew=replaceStr(loopstrChannelNew,matchfield.value,rsObj(2))
							case "title","name"
								m_name=rsObj(1):namelen=parseAttr(fieldAttr)("len")
								if not isNul(namelen) and len(m_name)>clng(namelen) then m_name=left(m_name,clng(namelen)-1)&".."
								loopstrChannelNew=replaceStr(loopstrChannelNew,matchfield.value,m_name)
							case "colortitle","colorname"
								m_color=rsObj(9):m_name=rsObj(1):colornamelen=parseAttr(fieldAttr)("len")
								if not isNul(colornamelen) and len(m_name)>clng(colornamelen) then  m_name=left(m_name,clng(colornamelen)-1)&".."
								if not(isnul(m_color)) then m_name="<font color="&m_color&">"&m_name&"</font>"
								loopstrChannelNew=replaceStr(loopstrChannelNew,matchfield.value,m_name)
							case "outline"
								m_note=rsObj(12) : notelen=parseAttr(fieldAttr)("len")
								if not isNul(notelen)  and len(m_note) > clng(notelen)  then m_note=left(m_note,clng(notelen)-1)&".."
								loopstrChannelNew=replaceStr(loopstrChannelNew,matchfield.value,m_note)
							case "author"
								m_actor=rsObj(6) : actorlen=parseAttr(fieldAttr)("len")
								if not isNul(actorlen) and len(m_actor) > clng(actorlen)  then m_actor=left(m_actor,clng(actorlen)-1)&".."
								loopstrChannelNew=replaceStr(loopstrChannelNew,matchfield.value,m_actor)
							case "content","des"
								m_des=filterStr(decodeHtml(rsObj(7)),"html"):deslen=parseAttr(fieldAttr)("len")
								if isNul(deslen) then deslen=200
								if len(m_des) > clng(deslen) then  m_des=left(m_des,clng(deslen)-1)&".."
								loopstrChannelNew=replaceStr(loopstrChannelNew,matchfield.value,m_des)
							case "addtime","time"
								videoTime=rsObj(10):timestyle=parseAttr(fieldAttr)("style"):if isNul(timestyle) then timestyle="mm-dd"
								dim monthDayTime:monthDayTime=right("00"&month(videoTime),2)&"-"&right("00"&day(videoTime),2)
								select case timestyle
									case "yyyy-mm-dd"
										loopstrChannelNew=replaceStr(loopstrChannelNew,matchfield.value,year(videoTime)&"-"&monthDayTime)
									case "yy-mm-dd"
										loopstrChannelNew=replaceStr(loopstrChannelNew,matchfield.value,right(year(videoTime),2)&"-"&monthDayTime)
									case "yyyy-m-d"
										loopstrChannelNew=replaceStr(loopstrChannelNew,matchfield.value,year(videoTime)&"-"&month(videoTime)&"-"&day(videoTime))
									case else
										loopstrChannelNew=replaceStr(loopstrChannelNew,matchfield.value,monthDayTime)
								end select
							case "i"
								loopstrChannelNew=replaceStr(loopstrChannelNew,matchfield.value,i)
							case "typename"
								loopstrChannelNew=replaceStr(loopstrChannelNew,matchfield.value,Split(getNewsTypeNameTemplateArrayOnCache(rsObj(2)),",")(0))
							case "typelink"
								loopstrChannelNew=replaceStr(loopstrChannelNew,matchfield.value,getNewsTypeLink(rsObj(2)))
							case "newslink","link"
								loopstrChannelNew=replaceStr(loopstrChannelNew,matchfield.value,getNewsArticleLink(rsObj(2),rsObj(0),rsObj(18),rsObj(19),"link"))
							case "pic"
								if not isNul(rsObj(4)) then
									if instr(rsObj(4),"http://")>0 then
										loopstrChannelNew=replaceStr(loopstrChannelNew,matchfield.value,rsObj(4))
									else
										loopstrChannelNew=replaceStr(loopstrChannelNew,matchfield.value,"/"&sitePath&rsObj(4))
									end if
								else
									loopstrChannelNew=replaceStr(loopstrChannelNew,matchfield.value,"/"&sitePath&"pic/nopic.gif")
								end if
							case "hit"
								loopstrChannelNew=replaceStr(loopstrChannelNew,matchfield.value,rsObj(5))
							case "vid"
								loopstrChannelNew=replaceStr(loopstrChannelNew,matchfield.value,rsObj(3))
							case "commend"
								loopstrChannelNew=replaceStr(loopstrChannelNew,matchfield.value,rsObj(13))
							case "commendPosition"
								loopstrChannelNew=replaceStr(loopstrChannelNew,matchfield.value,(rsObj(13)*13-430))
							case "from"
								loopstrChannelNew=replaceStr(loopstrChannelNew,matchfield.value,rsObj(11))
							case "keyword"
								loopstrChannelNew=replaceStr(loopstrChannelNew,matchfield.value,getKeywordsList(rsObj(15)," "))
							case "digg"
								loopstrChannelNew=replaceStr(loopstrChannelNew,matchfield.value,rsObj(16))
							case "tread"
								loopstrChannelNew=replaceStr(loopstrChannelNew,matchfield.value,rsObj(17))
							case "note"
								loopstrChannelNew=replaceStr(loopstrChannelNew,matchfield.value,parseNewsNote(rsObj(20)))
						end select
						strDictionary.removeAll
					next
					loopstrTotal=loopstrTotal&loopstrChannelNew
					rsObj.movenext
					if rsObj.eof then exit for
				next
			end if
			content=replace(content,matchChannel.value,loopstrTotal)
			regExpObj.Pattern=labelRulePagelist
			set matchesPagelist=regExpObj.Execute(content)
			for each matchPagelist in matchesPagelist
				if rsObj.pagecount=0 then
					content=replace(content,matchPagelist.value,"")
				else
					lenPagelist=parseAttr(matchPagelist.SubMatches(0))("len")
					if isNul(lenPagelist) then lenPagelist=10 else lenPagelist=clng(lenPagelist)
					strPagelist=pageNumberLinkInfo(currentPage,lenPagelist,rsObj.pagecount,pageListType,rsObj.recordcount)
					content=replace(content,matchPagelist.value,strPagelist)
				end if
			next 
			set matchesPagelist=nothing
			set matchesfield=nothing
			strDictionary.removeAll
		next
		set matchesChannel=nothing
	End Function

	Private Sub parseSlide()
		dim slideStr,slideStr2,slidew,slideh,x
		slideStr="{maxcms:slide"
		if isExistStr(content,slideStr) then
			slideStr2=getSubStrByFromAndEnd(content,slideStr,"}",""):set x=parseAttr(slideStr2)
			slidew=x("width"):slideh=x("height")
			if isNul(slidew) then slidew=400
			if isNul(slideh) then slideh=280
			content=replaceStr(content,slideStr&slideStr2&"}","<script>loadSlide('"&slidew&"','"&slideh&"',sitePath)</script>")
			Set x=nothing
		end if
	End Sub

	Private Sub parseMaxHistory()
		dim x,y,w,h,i,q,c
		content=replaceStr(content,"{maxcms:showhistory}","<a href=""javascript:void(0)"" onclick=""$MH.showHistory(1);"">我的观看历史</a>")
		x="{maxcms:maxhistory"
		if isExistStr(content,x) then
			y=getSubStrByFromAndEnd(content,x,"}",""):set q=parseAttr(y)
			w=q("width"):h=q("height"):i=q("num"):c=q("class")
			if isNul(w) then w=960
			if isNul(h) then h=170
			if isNul(i) then i=10
			content=replaceStr(content,x&y&"}","<script type=""text/javascript"" src=""/"&sitepath&"js/max_history.js""></script><script type=""text/javascript"">$MH.limit="&i&";$MH.WriteHistoryBox("&w&","&h&",'"&c&"');$MH.recordHistory({name:'{playpage:name}',link:'{playpage:url}',pic:'{playpage:pic}'})</script>")
			Set q=nothing
		end if
	End Sub

	Public Function paresPreNextVideo(dataid,typeFlag,vtype)
		dim nextid , lastid , nextname, nextenname, nextdatetime ,lastname,lastenname, lastdatetime,mystr,preNextLabel:preNextLabel="{playpage:prenext}"
		if not isExistStr(content,preNextLabel) then  Exit Function
		dim rs :set rs=conn.db("select top 1 m_id as nextid ,m_name as nextname,m_enname AS nextenname,m_datetime AS nextdatetime from {pre}data where m_type="&vtype&" and m_recycle=0 and m_id<"&dataId&" order by m_id desc ","records1")
		if rs.eof and rs.bof then nextid= 0 else nextid=rs("nextid"):nextname=rs("nextname"):nextenname=rs("nextenname"):nextdatetime=rs("nextdatetime")
		set rs=conn.db("select top 1 m_id as lastid,m_name  as lastname,m_enname AS lastenname,m_datetime AS lastdatetime from {pre}data where m_type="&vtype&" and m_recycle=0 and m_id>"&dataId&" order by m_id asc ","records1")
		if rs.eof and rs.bof then lastid= 0  else lastid=rs("lastid"):lastname=rs("lastname"):lastenname=rs("lastenname"):lastdatetime=rs("lastdatetime")
		rs.close
		set rs=nothing
		if typeFlag="parse_play_" then
			if lastid = 0 then mystr = "<span>上一篇:没有了</span> " else mystr = "<span>上一篇:<a href="&getPlayLink2(vtype,lastid,lastenname,lastdatetime,0,0)&">"&lastname&"</a></span> "
			if nextid = 0 then  mystr = mystr&"<span>下一篇:没有了</span>" else mystr = mystr&"<span>下一篇:<a href="&getPlayLink2(vtype,nextid,nextenname, nextdatetime,0,0)&">"&nextname&"</a></span>"
		else 
			if lastid = 0 then  mystr = "<span>上一篇:没有了</span> " else mystr = "<span>上一篇:<a href="&getContentLink(vtype,lastid,lastenname,lastdatetime,"link")&">"&lastname&"</a></span> "
			if nextid = 0 then  mystr = mystr&"<span>下一篇:没有了</span>" else mystr = mystr&"<span>下一篇:<a href="&getContentLink(vtype,nextid,nextenname, nextdatetime,"link")&">"&nextname&"</a></span>"
		end if 
		content=replaceStr(content,preNextLabel,mystr)
	End Function

	Public Function paresPreNextNews(dataid,vtype)
		dim nextid , lastid , nextname, nextenname, nextdatetime ,lastname,lastenname, lastdatetime,mystr,preNextLabel:preNextLabel="{news:prenext}"
		if not isExistStr(content,preNextLabel) then  Exit Function
		dim rs :set rs=conn.db("select top 1 m_id as nextid ,m_title as nextname,m_entitle AS nextenname,m_datetime AS nextdatetime from {pre}news where m_type="&vtype&" and m_recycle=0 and m_id<"&dataId&" order by m_id desc ","records1")
		if rs.eof and rs.bof then nextid= 0 else nextid=rs("nextid"):nextname=rs("nextname"):nextenname=rs("nextenname"):nextdatetime=rs("nextdatetime")
		set rs=conn.db("select top 1 m_id as lastid,m_title  as lastname,m_entitle AS lastenname,m_datetime AS lastdatetime from {pre}news where m_type="&vtype&" and m_recycle=0 and m_id>"&dataId&" order by m_id asc ","records1")
		if rs.eof and rs.bof then lastid= 0  else lastid=rs("lastid"):lastname=rs("lastname"):lastenname=rs("lastenname"):lastdatetime=rs("lastdatetime")
		rs.close
		set rs=nothing
		if lastid = 0 then  mystr = "<span>上一篇:没有了</span> " else mystr = "<span>上一篇:<a href="&getNewsArticleLink(vtype,lastid,lastenname,lastdatetime,"link")&">"&lastname&"</a></span> "
		if nextid = 0 then  mystr = mystr&"<span>下一篇:没有了</span>" else mystr = mystr&"<span>下一篇:<a href="&getNewsArticleLink(vtype,nextid,nextenname, nextdatetime,"link")&">"&nextname&"</a></span>"
		content=replaceStr(content,preNextLabel,mystr)
	End Function

	Public Function parsePlayPageSpecial()
		content=replace(content,"{playpage:mark}","<script>markVideo({playpage:id},{playpage:diggnum},{playpage:treadnum},{playpage:scorenum});</script>")
		content=replace(content,"{playpage:digg}","<span id=""digg_num"">{playpage:diggnum}</span><a href=""javascript:void(0)"" onclick=""diggVideo({playpage:id},'digg_num')"">顶一下</a>")
		content=replace(content,"{playpage:tread}","<span id=""tread_num"">{playpage:treadnum}</span><a href=""javascript:void(0)"" onclick=""treadVideo({playpage:id},'tread_num')"">踩一下</a>")
		content=replace(content,"{playpage:reporterr}","<a href=""javascript:void(0)"" onclick=""reportErr({playpage:id})"">报 错</a>")
		'????
		content=replace(content,"{playpage:comment}","<div  id=""comment_list"">评论加载中..</div><script>viewComment(""/"&sitepath&"comment.asp?id={playpage:id}"","""")</script>")
		content=replace(content,"{playpage:hit}","<span id=""hit"">加载中</span><script>getVideoHit('{playpage:id}')</script>")
	End Function

	Public Function parseNewsPageSpecial()
		content=replace(content,"{news:mark}","<script>markNews({news:id},{news:diggnum},{news:treadnum},{news:scorenum});</script>")
		content=replace(content,"{news:digg}","<span id=""digg_num"">{news:diggnum}</span><a href=""javascript:void(0)"" onclick=""diggNews({news:id},'digg_num')"">顶一下</a>")
		content=replace(content,"{news:tread}","<span id=""tread_num"">{news:treadnum}</span><a href=""javascript:void(0)"" onclick=""treadNews({news:id},'tread_num')"">踩一下</a>")
		content=replace(content,"{news:comment}","<div  id=""comment_list"">评论加载中..</div><script>viewComment(""/"&sitepath&"comment.asp?id={news:id}"",""news"")</script>")
		content=replace(content,"{news:hit}","<span id=""hit"">加载中</span><script>getNewsHit('{news:id}')</script>")
	End Function

	Public Function parseIf()
		if not isExistStr(content,"{if:") then Exit Function
		dim matchIf,matchesIf,strIf,strThen,strThen1,strElse1,labelRule2,labelRule3
		dim ifFlag,elseIfArray,elseIfSubArray,elseIfArrayLen,resultStr,elseIfLen,strElseIf,strElseIfThen,elseIfFlag
		labelRule="{if:([\s\S]+?)}([\s\S]*?){end\s+if}":labelRule2="{elseif":labelRule3="{else}":elseIfFlag=false
		regExpObj.Pattern=labelRule
		set matchesIf=regExpObj.Execute(content)
		for each matchIf in matchesIf 
			strIf=matchIf.SubMatches(0):strThen=matchIf.SubMatches(1)
			if instr(strThen,labelRule2)>0 then
				elseIfArray=split(strThen,labelRule2):elseIfArrayLen=ubound(elseIfArray):elseIfSubArray=split(elseIfArray(elseIfArrayLen),labelRule3)
				resultStr=elseIfSubArray(1)
				Execute("if "&strIf&" then resultStr=elseIfArray(0)")
				for elseIfLen=1 to elseIfArrayLen-1
					strElseIf=getSubStrByFromAndEnd(elseIfArray(elseIfLen),":","}","")
					strElseIfThen=getSubStrByFromAndEnd(elseIfArray(elseIfLen),"}","","start")
					Execute("if "&strElseIf&" then resultStr=strElseIfThen")
					Execute("if "&strElseIf&" then elseIfFlag=true else  elseIfFlag=false")
					if elseIfFlag then exit for
				next
				Execute("if "&getSubStrByFromAndEnd(elseIfSubArray(0),":","}","")&" then resultStr=getSubStrByFromAndEnd(elseIfSubArray(0),""}"","""",""start""):elseIfFlag=true")
				content=replace(content,matchIf.value,resultStr)
			else 
				if instr(strThen,"{else}")>0 then 
					strThen1=split(strThen,labelRule3)(0)
					strElse1=split(strThen,labelRule3)(1)
					Execute("if "&strIf&" then ifFlag=true else ifFlag=false")
					if ifFlag then content=replace(content,matchIf.value,strThen1) else content=replace(content,matchIf.value,strElse1)
				else
					Execute("if "&strIf&" then ifFlag=true else ifFlag=false")
					if ifFlag then content=replace(content,matchIf.value,strThen) else content=replace(content,matchIf.value,"")
				end if
			end if
			elseIfFlag=false
		next
		set matchesIf=nothing
	End Function
End Class



Class MainClass_DataList
	Public primaryField,tableStr
	Public orderStr,whereStr,dataSortType,fieldsStr,dataPageSize,dataCurrentPage
	Public recordsCount,pagesCount
	private tempTableCount,sqlstr,topCount,whereStr2,whereStr3
	private m,n
	
	Public Sub Class_Initialize
		 dataSortType="desc"
	End Sub

	Public Sub Class_Terminate

	End Sub

	Public Function getDataList()
		dim order
		if isNul(dataPageSize) then dataPageSize=100 else dataPageSize=clng(dataPageSize)
		if not isNul(whereStr) then whereStr= " where "&whereStr else whereStr=""
		if isNul(tableStr) then die err_table
		if isNul(fieldsStr) then fieldsStr=" * "  else  fieldsStr=" "&fieldsStr&" "
		if not isNul(orderStr) then order=" order by "&orderStr&" "&dataSortType  else order=" "
		sqlstr="select top "&dataPageSize&fieldsStr&" from "&tableStr&" "&whereStr&order
		getDataList=conn.db(sqlstr,"array")
	End Function

	Public Function getPageList()
		dim order
		if isNul(dataPageSize) then dataPageSize=30 else dataPageSize=clng(dataPageSize)
		if not isNul(whereStr) then whereStr2=" where "&whereStr : whereStr3=" and "&whereStr else whereStr2="":whereStr3=""
		'die "select count(*) from "&tableStr&whereStr2
		recordsCount=conn.db("select count(*) from "&tableStr&whereStr2,"array")(0,0)
		m=recordsCount mod dataPageSize
		n=int(recordsCount / dataPageSize)
		if m=0 then pagesCount=n else pagesCount=n + 1  
		if isNul(primaryField) then die err_primarykey
		if isNul(tableStr) then die err_table
		if isNul(orderStr) then orderStr=primaryField
		if isNul(fieldsStr) then fieldsStr=" * "  else  fieldsStr=" "&fieldsStr&" "
		if dataCurrentPage > pagesCount   then dataCurrentPage=pagesCount
		if isNul(dataCurrentPage)  then 
			dataCurrentPage=1 
		else 
			if dataCurrentPage <= 0 then dataCurrentPage=1 else dataCurrentPage=clng(dataCurrentPage)
		end if
		order=" "&orderStr&" "&dataSortType 
		if dataSortType="desc" then
			if dataCurrentPage=1 then 
				sqlstr="select top "&dataPageSize&fieldsStr&" from "&tableStr&" "&whereStr2&" order by "&order
			else
				sqlstr="select top "&dataPageSize&fieldsStr&" from "&tableStr&" where "&primaryField&"<(select min("&primaryField&") from (select top "&(dataCurrentPage - 1) * dataPageSize&" "&primaryField&" from "&tableStr &" "&whereStr2& " order by  "&order&") as temptable)  "& whereStr3& " order by "&order
			end if
		else dataSortType="asc" 
			if dataCurrentPage=1 then 
				sqlstr="select top "&dataPageSize&fieldsStr&" from "&tableStr&" "&whereStr2&" order by "&order
			else
				sqlstr="select top "&dataPageSize&fieldsStr&" from "&tableStr&" where "&primaryField&">(select max("&primaryField&") from (select top "&(dataCurrentPage - 1) * dataPageSize &" "&primaryField&" from "&tableStr &" "& whereStr& " order by  "&order&") as temptable)  "& whereStr3& " order by "&order
			end if
		end if
		getPageList=conn.db(sqlstr,"array")
	End Function
End Class


Class MainClass_Xml
	Public xmlDocument,xmlPath,xmlDomObj,xmlstr
	Private xmlDomVer,xmlFileSavePath

	Public Sub Class_Initialize()
		xmlDomVer=getXmlDomVer()
		createXmlDomObj
	End Sub

	Public Sub Class_Terminate()
		If IsObject(xmlDomObj) Then Set xmlDomObj=Nothing
	End Sub

	Public Function getXmlDomVer()
		dim i,xmldomVersions,xmlDomVersion
		getXmlDomVer=false
		xmldomVersions=Array("Microsoft.2MLDOM","MSXML2.DOMDocument","MSXML2.DOMDocument.3.0","MSXML2.DOMDocument.4.0","MSXML2.DOMDocument.5.0")
		for i=0 to ubound(xmldomVersions)
			xmlDomVersion=xmldomVersions(i)
			if isInstallObj(xmlDomVersion) then getXmlDomVer=xmlDomVersion : Exit Function
		next
	End Function

	Private Sub createXmlDomObj
		set xmlDomObj=server.CreateObject(xmlDomVer)
		xmlDomObj.validateonparse=true 
		xmlDomObj.async=false 
	End Sub

	Public Function load(Byval xml,Byval xmlType)
		dim xmlUrl,xmlfilePath
		select case xmlType 
			case "xmlfile"
				xmlfilePath=server.mappath(xml)   
		 		xmlDomObj.load(xmlfilePath)   
			case "xmldocument"
				xmlUrl=xml
				xmlstr=getRemoteContent(xmlUrl,"text")
				If left(xmlstr, 5) <> "<?xml" then die err_xml else xmlDomObj.loadXML(xmlstr)
			case "transfer"
				xmlUrl=xml
				xmlstr=bytesToStr(getRemoteContent(xmlUrl,"body"),"gbk")
				If left(xmlstr, 5) <> "<?xml" then die err_xml else xmlDomObj.loadXML(xmlstr)
		end select
	End Function

	Public Function isExistNode(nodename)
        dim node
        isExistNode=True
        set node=xmlDomObj.getElementsByTagName(nodename)
        If node.Length=0 Then isExistNode=False : set node=nothing
    End Function

	Public Function getNodeValue(nodename, itemId)
		if isNul(itemId) then  itemId=0
		getNodeValue=xmlDomObj.getElementsByTagName(nodename).Item(itemId).Text
	End Function

	Public Function getNodeLen(nodename)
		getNodeLen=xmlDomObj.getElementsByTagName(nodename).Length
	End Function
	
	Public Function getNodes(nodename)
		Set getNodes=xmlDomObj.getElementsByTagName(nodename)
	End Function
	
	Public Function getNode(nodename, itemId)
		Set getNode=xmlDomObj.getElementsByTagName(nodename).Item(itemId)
	End Function

	Public Function getAttributes(nodeName, attrName, itemId)
	dim xmlAttributes, i
		if isNul(itemId) then  itemId=0
		err.clear:on error resume next
		getAttributes=xmlDomObj.getElementsByTagName(nodeName).Item(itemId).getAttributeNode(attrName).nodevalue
		if err then getAttributes="":err.clear
	End Function

	Public Function getAttributesByNode(node, attrName)
		err.clear:on error resume next
		getAttributesByNode=node.getAttributeNode(attrName).nodevalue
		if err then getAttributesByNode="":err.clear
	End Function

	Public Function setXmlNodeValue(Byval nodename, Byval itemId, Byval str,Byval savePath)
	dim node
		xmlFileSavePath=savePath
		Set node=xmlDomObj.getElementsByTagName(nodename).Item(itemId)
		node.childNodes(0).text=str
		xmlDomObj.save Server.MapPath(xmlFileSavePath)
		set node=nothing
	End Function

End Class

%>
<!--#include file="config.asp"-->
<!--#include file="CommonFun.asp"-->
<!--#include file="lang.asp"-->
<!--#include file="md5.asp"-->
<%
dim mainClassObj
set mainClassObj=New MainClass

dim conn
set conn=mainClassobj.createObject("MainClass.DB") 
conn.dbType=ifthen(databaseType =0,"acc","sql")

dim objFso,objStream
initializeAllObjects

dim cacheObj
set cacheObj=mainClassObj.createObject("MainClass.Cache")
dim currentTypeId : currentTypeId=-444
dim currenttopicid : currenttopicid=-444
dim pageUrlStyle

%>