<%
' +----------------------------------------------------------------------
' | KCMS [ 启点在线网站管理系统 ]
' | Copyright (c) 2018 http://www.kelvinvt.com All rights reserved.
' | Licensed ( http://www.kelvinvt.com )
' | Author: kelvinvt <kelvinvt@qq.com>
' +----------------------------------------------------------------------
dim zhl:set zhl= new Class_Template
'模板处理类
Class Class_Template
	public ZContent,TempFile,indexZhl,cateZhl,contentZhl,LanguagePath,LAlias
	public redirectURL,CacheFolder,CacheFile,htmlFile,htmlFilename,htmlFolder
	public isBizUser,isContentExist,isContentDetail,isGoodsDetail,isShopCart
	public echoRunInfo,iflabel,labelStr,labelArr
	private match,matches,oAttrDict,zCateData,zDictArray,oFMatche,oFMatches,ZReg,oRs,zVar
	private aContentCateArray,aGoodsCateArray,sTempString,aDataArray,aTempArray,iDataCount,iL,iIsGoodsTag
	private sLoopPre,sLoopStr,sLoopSuf,sLoopSQL,sDBTable
	private sFields,sSQL,sWhere
	private sRule,sRule2,sRule3,ListLabel,PageLabel,sFieldRule,oAttrs,Pagelist,Lenpage,strPagelist
	private sPreHtml,sSufHtml,sLoopHtml,sLoops,sLoopTotal
	private sField,sFName,sFAttr,userstr,searchkeys,searchtype,cookiekeys
	private sIf,sThen,sThen1,sElse1,sElseIf,sElseIfThen
	private ifFlag,elseIfFlag,ReStr,elseIfArr,elseIfSubArr,elseIfArrLen,ElseLen
	private TemplatePath,TemplateFilePath,Locationpath,pluginspath
	private topsid,upsid,sortname,sortenname,S_template,C_template,S_Folder,C_Folder,S_fileName,C_FileName,pagetitle,pagekey,pagedesc,sorturl,CPageName,stype,stypename
	Private Sub Class_Initialize()
		echoRunInfo   = False
		LAlias=zset.Alias
		LanguagePath=zset.LPath
		Set ZReg        = new RegExp
		ZReg.ignoreCase = True
		ZReg.Global     = True
		Set zCateData   = Server.CreateObject("Scripting.Dictionary")
		Set zDictArray = Server.CreateObject("Scripting.Dictionary")
		set zVar = Server.CreateObject("Scripting.Dictionary")
	End Sub
	private sub class_terminate()
		set zCateData  = nothing
		set zDictArray = nothing
		set ZReg       = nothing
		set zVar       = nothing		
	end sub	
	
    Public Property get sortid()
        sortid = sid
    End Property
	
    Public Property get contentid()
        contentid = id
    End Property
	
    Public Property get pagenumber()
        pagenumber = page
    End Property
	
	public property get runTime()
		runTime = parseRuntime(Timer()-Run_time)
	end property
	
	Function Template_Int()
		TemplatePath	=sitepath &"template/pc/"& zset.PcTemplate		
		TemplateFilePath = sitepath &"template/pc/"&zset.PcTemplate&zset.PchtmlPath	
		Locationpath="<a href='"&sitePath&"'>"&str_index&"</a>"
		CacheFolder =sitepath&CachePath
		htmlFolder  =sitepath&htmlDir
		pluginspath =sitepath&"plugins/"
	End Function	
	
	Function LoadSortTemplatePath(str)
		if sid>0 then
			dim rs		
			set	rs=dbsql("select sid,S_tid,S_pid,S_name,S_enname,S_Template,C_Template,S_Folder,C_Folder,S_FileName,C_FileName,S_Title,S_Key,S_Desc,S_URL,S_type,Model_Name from [dbpre]sort,[dbpre]Model where S_type = Model_type and sid="&sid)
			if not rs.eof then
			topsid=rs("S_tid")
			upsid=rs("S_pid")
			stype=rs("S_type")
			stypename=rs("Model_Name")
			sortname=rs("S_name")
			sortenname=rs("S_enname")
			S_template=rs("S_Template")
			C_template=rs("C_Template")
			S_Folder=rs("S_Folder")
			C_Folder=rs("C_Folder")
			S_FileName=rs("S_FileName")
			C_FileName=rs("C_FileName")
			pagetitle=rs("S_Title")
			pagekey=rs("S_Key")
			pagedesc=repkong(rs("S_Desc"))
			sorturl=rs("S_URL")
			closers rs		
			S_FileName=replacestr(repnul(S_FileName), "{sid}", sid)	
			S_FileName=replacestr(S_FileName, "{page}", page)
			C_FileName=replacestr(C_FileName, "{page}", page)
			C_FileName=replacestr(C_FileName, "{sid}", sid)	
			C_FileName=replacestr(C_FileName, "{id}", Id)		
			  if str="list" then				
				  TempFile		= iif(isfile(TemplateFilePath&S_template),TemplateFilePath&S_template,TemplateFilePath&"list.html") '模板路径
				  CacheFolder	= CacheFolder&"list/"				  
				  CacheFile 	= CacheFolder&Cachepre&sid&"_"&page&".html"	'缓存文件路径	'缓存文件路径
				  htmlFolder	= htmlFolder&S_Folder
				  htmlFile		= htmlFolder&S_FileName&".html"	'生成静态路径
			  elseif str="news" then
				  TempFile  	= iif(isfile(TemplateFilePath&C_template),TemplateFilePath&C_template,TemplateFilePath&"content.html") '模板路径
				  CacheFolder	= CacheFolder&"news/"				 
				  CacheFile  	= CacheFolder&Cachepre&sid&"_"&Id&"_"&page&".html"	'缓存文件路径	'缓存文件路径mlFile   = ""	'生成静态路径
				  htmlFolder	= htmlFolder&C_Folder
				  htmlFile  	= htmlFolder&C_FileName&".html"	'生成静态路径
			  elseif str="about" then
				  TempFile  	= iif(isfile(TemplateFilePath&S_template),TemplateFilePath&S_template,TemplateFilePath&"about.html") '模板路径
				  CacheFolder 	= CacheFolder&"about/"				
				  CacheFile  	= CacheFolder&Cachepre&sid&"_"&page&".html"	'缓存文件路径	'缓存文件路径
				  htmlFolder	= htmlFolder&S_Folder
				  htmlFile  	= htmlFolder&S_FileName&".html"	'生成静态路径
				  id=sid
			  end if
			else
				goto404 str_none
			end if	 
		end if
		If showsql Then echop TempFile &"<hr>"	&CacheFolder &"<hr>"	&CacheFile &"<hr>"	&htmlFolder &"<hr>"	&htmlFile &"<hr>"	
	End Function
	  
	'生成[网站首页]静态页面
	Function Run_index()
		sid=0 : topsid=0
		Call Template_Int()	
		TempFile   = TemplateFilePath&"index.html" '模板路径
		CacheFile  = CacheFolder&Cachepre&"index.html"	'缓存文件路径
		htmlFile   = sitepath&"index.html"	'生成静态路径			
		'call parseHTML()
		if (runMode=1 or runMode=3)and not(isNul(htmlFile)) then
			if Checkhtml(htmlFile) then
				aspgo htmlFile
			else
				call LoadParse()		 
				call LoadlistParse
				call SaveFile(htmlFile,ZContent)
				aspgo htmlFile
			end if
		elseif iscache=1 and not(isNul(CacheFile)) then
				if CheckCache(CacheFile) then					
					ZContent = getHtmlCache(CacheFile)
					zhl.show()
				else
					call LoadParse()
					call LoadlistParse
					call SaveFile(CacheFile,ZContent)	
					zhl.show()			
				end if
		else
			call LoadParse()
			call LoadlistParse
			zhl.show()		
		end if	
	End Function
	
	'生成[单页]静态页面
	Function Run_about(sid,page)		
		dim rs,content,sql
		Call Template_Int()
		Call LoadSortTemplatePath("about")		
		'call parseHTML()
		if (runMode=1 or runMode=3)and not(isNul(htmlFile)) then
			if Checkhtml(htmlFile) then
				aspgo htmlFile
			else
				call LoadParse()
				call Parseabout()
				call LoadlistParse	
				call SaveFile(htmlFile,ZContent)
				aspgo htmlFile
			end if
		elseif iscache=1 and not(isNul(CacheFile)) then
				if CheckCache(CacheFile) then					
					ZContent = getHtmlCache(CacheFile)
					zhl.show()
				else
					call LoadParse()
					call Parseabout()
					call LoadlistParse
					newFolder CacheFolder		
					call SaveFile(CacheFile,ZContent)
					zhl.show()
				end if
		else
			call LoadParse()
			call Parseabout()
			call LoadlistParse
			zhl.show()
		end if			
	End Function
		
	'生成[品牌]页面
	Function Run_brand(id,page)
		dim rs,content,sql,filename,B_Template
		Call Template_Int()		
		B_Template=dbselect("[dbpre]brand","B_Template","bid="&id&"")		
		TempFile=iif(isfile(TemplateFilePath&B_Template),TemplateFilePath&B_Template,TemplateFilePath&"brand.html") '模板路径			
		if (runMode=1 or runMode=3)then
			filename=dbselect("[dbpre]brand","B_filename","bid="&id&"")
			if not isnul(filename) then
				FileName	=	replacestr(FileName, "{page}", page)
				htmlFile	=	htmlFolder&"brand/"&FileName&".html"
			else
				htmlFile	=	htmlFolder&"brand/"&id&"_"&page&".html"
			end if
			if Checkhtml(htmlFile) then
				aspgo htmlFile
			else
				call LoadParse()
				call Parsebrand()
				call LoadlistParse	
				call SaveFile(htmlFile,ZContent)
				aspgo htmlFile
			end if
		elseif iscache=1 and not(isNul(CacheFile)) then
			CacheFile	=	CacheFolder&"brand/"&id&"_"&page&".html"
				if CheckCache(CacheFile) then					
					ZContent = getHtmlCache(CacheFile)
					zhl.show()
				else
					call LoadParse()
					call Parsebrand()
					call LoadlistParse
					newFolder CacheFolder		
					call SaveFile(CacheFile,ZContent)
					zhl.show()
				end if
		else
			call LoadParse()
			call Parsebrand()
			call LoadlistParse
			zhl.show()
		end if	
	End Function
	
	'生成内容页]静态页面
	Function Run_content(Location,sid,id,page)
		dim rs,content,sql,gid,mm,m
		if sid=0 then		
			goto404 "内容ID有误"
		else
			gid=dbselect("[dbpre]content","C_GID","CID="&id)
		end if
		if page=0 then page=1
		Call Template_Int()		
		Call LoadSortTemplatePath("news")
		
		if gid>4 then 
				call LoadParse()
				if cint(getsession("gid"))>=isnum(gid) then				
					call ParseCcontentid()
				else
					zcontent=replacestr(zcontent,"[news:title]","此内容需登录，或您的会员级别不够")
					zcontent=replacestr(zcontent,"[news:content]","<script language='javascript' src='"&sitepath&"user/user.asp'></script>")
					Zcontent=replaceStr(Zcontent,"[news:id]",ID)
					Zcontent=replaceStr(Zcontent,"[news:prev]",getprev(sid,ID,1))
					Zcontent=replaceStr(Zcontent,"[news:prevlink]",getprev(sid,ID,2))
					Zcontent=replaceStr(Zcontent,"[news:prevtitle]",getprev(sid,ID,3))
					Zcontent=replaceStr(Zcontent,"[news:prevpic]",getprev(sid,ID,4))
					Zcontent=replaceStr(Zcontent,"[news:prevclass]",getprev(sid,ID,5))
					Zcontent=replaceStr(Zcontent,"[news:next]",getnext(sid,ID,1))
					Zcontent=replaceStr(Zcontent,"[news:nextlink]",getnext(sid,ID,2))
					Zcontent=replaceStr(Zcontent,"[news:nexttitle]",getnext(sid,ID,3))
					Zcontent=replaceStr(Zcontent,"[news:nextpic]",getnext(sid,ID,4))
					Zcontent=replaceStr(Zcontent,"[news:nextclass]",getnext(sid,ID,5))
					Zreg.Pattern = "\[news:([\s\S]+?)\]"
			 		set mm = Zreg.Execute(zcontent)					
					For Each m in mm
						zcontent=regExpReplace(zcontent,"\[news:([\s\S]+?)\]","")	
					next	
				end if
				call LoadlistParse
				zhl.show()
				exit function
		end if					
		if (runMode=1 or runMode=3)and not(isNul(htmlFile))then
			if Checkhtml(htmlFile) then
				aspgo htmlFile
			else
				call LoadParse()	
				call ParseCcontentid()	
				if not isnul(CPageName) then  htmlFile = htmlFolder&CPageName&".html"	
				call LoadlistParse	
				call SaveFile(htmlFile,ZContent)
				aspgo htmlFile
			end if
		elseif iscache=1 and not(isNul(CacheFile)) then
				if CheckCache(CacheFile) then					
					ZContent = getHtmlCache(CacheFile)
					zhl.show()
				else
					call LoadParse()
					call ParseCcontentid()
					call LoadlistParse
					call SaveFile(CacheFile,ZContent)	
					zhl.show()
				end if
		else
				call LoadParse()
				call ParseCcontentid()
				call LoadlistParse
				zhl.show()
		end if			
	End Function	

	
	'生成[tag]页面
	Function Run_tag(tag,page)
		dim rs,content,sql
		Call Template_Int()
		 TempFile   = TemplateFilePath&"taglist.html" '模板路径
		call LoadParse()
		call LoadlistParse
		zhl.show()
	End Function
	
	'生成[列表页]静态页面
	Function Run_list(Location,sid,page)		
		dim rs,content,sql
		Call Template_Int()
		Call LoadSortTemplatePath("list")		
		if Location="screen" then		
			call LoadParse()
			call LoadlistParse		
			zhl.show()
		else
			if (runMode=1 or runMode=3)and not(isNul(htmlFile)) then		
				if Checkhtml(htmlFile) then
					aspgo htmlFile				
				else
					call LoadParse()			
					call LoadlistParse	
					call SaveFile(htmlFile,ZContent)
					aspgo htmlFile
				end if		
			elseif iscache=1 and not(isNul(CacheFile)) then
					if CheckCache(CacheFile) then					
						ZContent = getHtmlCache(CacheFile)
						zhl.show()
					else
						call LoadParse()
						call LoadlistParse
						call SaveFile(CacheFile,ZContent)	
						zhl.show()			
					end if
			else
				call LoadParse()
				call LoadlistParse			
				zhl.show()
			end if
		end if
	End Function
	
	Function Run_gbook()
		if sid=0 then sid=isnum(dbselect("[dbpre]sort","sid","S_Type='gbook'"))		
		Call Template_Int()	
		if sid>0 then
			LoadSortTemplatePath("")
		else
			goto404"留言功能未启用"
		end if
		 TempFile   = TemplateFilePath&"gbook.html" '模板路径
		call LoadParse()
		call LoadlistParse			
		zhl.show()
	End Function
	
	Function Run_form(id)
		if id=0 then id=dbselect("[dbpre]FormField","TableID","Formonoff=1 order by FormID asc")
		Call Template_Int()	
		if id=0 then goto404"没有找到有效的表单"		
		 TempFile   = sitepath&"plug/diyform/html/formpc.html" '模板路径
		if isnum(sid)>0 then topsid=dbselect("[dbpre]sort","S_tid","sid="&sid&"") else topsid=0
		call LoadParse()
		call diyform(id)
		call LoadlistParse			
		zhl.show()
	End Function
   
	Function Run_other(Location,id,page)
		Call Template_Int()	
		 TempFile   = TemplateFilePath&Location&".html" '模板路径
		call LoadParse()
		call LoadlistParse			
		zhl.show()
	End Function
	'生成[搜索结果]静态页面
	Function Run_search(Location,sid,page)
		dim rs,content,sql
		searchkeys=enhtml(getform("keys","both"))	
		if not isnul(searchkeys) then setcookie "searchkeys",searchkeys else searchkeys=getcookie("searchkeys")	
		searchtype=enhtml(getform("type","both"))	
		if not isnul(searchtype) then setcookie "searchtype",searchtype else searchtype=getcookie("searchtype")	
		addcookie "cookiekeys",searchkeys&"|"&searchtype
		Call Template_Int()
		TempFile   = TemplateFilePath&"search.html" '模板路径
		call LoadParse()	
		call LoadlistParse
		zhl.show()
	End Function	
	
	'基础解析
	public sub LoadParse()		
	ZContent = loadFile(TempFile)
	call ParseTopAndFoot()	
	call ParseGlobal()	'底层基础
	end sub
	
	'扩展解析
	public sub LoadlistParse()
	call parseDBLoop()	'列表循环
	call parseDBLoop()	'列表循环
	call parseAdLoop()	'广告	
	call ParseLabels()	'自定义标签	
	call Parsepics()	'相册
	call LoadplugLoop()
	call parsehidestr()	'隐藏*
	call parseleftstr()	'左侧截取
	call parseformatDate()	'格式化时间	
	call parsecounts()	'统计数量
	call parseDBLoop()	'列表循环	
	call parseIf("")	'解析判断
	
	end sub

	'解析头和尾
	Public Function ParseTopAndFoot()
		'on error resume next
		if ifstrin(zcontent,"{cms:template ") then 			
		  Dim FileName,thisLink
		  ZReg.Pattern = "{cms:template ?(src=|file=|=)([\s\S]*?)\}"
		  Set Matches = ZReg.Execute(ZContent)
		  if matches.count>0 then
		  For Each Match in Matches
			  FileName = Match.SubMatches(1)	
			  ZContent  = replaceStr(ZContent,Match.Value,loadFile(TemplateFilePath&FileName))
		  Next
		  call ParseTopAndFoot()
		  end if
		end if		
		if ifstrin(zcontent,"{cms:top}") then ZContent =replaceStr(ZContent,"{cms:top}",loadFile(TemplateFilePath&"head.html"))
		if ifstrin(zcontent,"{cms:end}") then ZContent = replaceStr(ZContent,"{cms:end}",loadFile(TemplateFilePath&"foot.html"))
		if ifstrin(zcontent,"{cms:head}") then ZContent =replaceStr(ZContent,"{cms:head}",loadFile(TemplateFilePath&"head.html"))
		if ifstrin(zcontent,"{cms:foot}") then ZContent = replaceStr(ZContent,"{cms:foot}",loadFile(TemplateFilePath&"foot.html"))

		if ifstrin(zcontent,"{cms:left}") then ZContent = replaceStr(ZContent,"{cms:left}",loadFile(TemplateFilePath&"left.html"))
		if ifstrin(zcontent,"{cms:right}") then  ZContent = replaceStr(ZContent,"{cms:right}",loadFile(TemplateFilePath&"right.html"))
		if ifstrin(zcontent,"{cms:baidumap}") then  ZContent = replaceStr(ZContent,"{cms:baidumap}",loadFile(pluginspath&"baidumap.html"))
		if ifstrin(zcontent,"{cms:js}") then  ZContent = replaceStr(ZContent,"{cms:js}",loadFile(pluginspath&"js.html"))
		if wapmark=1 and runMode=1 then 
			 ZContent=replacestr(ZContent,"</head>","<script type='text/javascript'> if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)){window.location ="""&getURL("wap")&""";}</script></head>")		
		end if
	End Function
	
	'解析全局标签
	Public Function ParseGlobal()
	
		if ifstrin(ZContent,"{cms:qqkf") then
		dim qqkf1,qqkf2,qqkf3
			qqkf1=loadfile(sitepath&"plugins/qqkf/qqkf1.html")
			qqkf2=loadfile(sitepath&"plugins/qqkf/qqkf2.html")
			qqkf3=loadfile(sitepath&"plugins/qqkf/qqkf3.html")
			ZContent = replaceStr(ZContent,"{cms:qqkf1}",qqkf1)
			ZContent = replaceStr(ZContent,"{cms:qqkf2}",qqkf2)	
			ZContent = replaceStr(ZContent,"{cms:qqkf3}",qqkf3)	
		end if
		
		ZContent = replaceStr(ZContent,"{cms:nowtime}",now())
		ZContent = replaceStr(ZContent,"{cms:version}",cms_version)
		ZContent = replaceStr(ZContent,"{cms:siteurl}",zset.siteurl)
		ZContent = replaceStr(ZContent,"{cms:wapurl}",zset.sitewapurl)
		ZContent = replaceStr(ZContent,"{cms:sitepath}",sitePath)
		ZContent = replaceStr(ZContent,"{cms:plugpath}",pluginspath)		
		ZContent = replaceStr(ZContent,"{cms:help}",decode(SiteHelp))	
		ZContent = replaceStr(ZContent,"{cms:logo}",zset.sitePcLogo)	
		ZContent = replaceStr(ZContent,"{cms:pclogo}",zset.sitePcLogo)
		ZContent = replaceStr(ZContent,"{cms:waplogo}",zset.siteWapLogo)
		ZContent = replaceStr(ZContent,"{cms:weixin}",zset.weixin)
		ZContent = replaceStr(ZContent,"{cms:copyright}",decode(zset.Copyright))
		ZContent = replaceStr(ZContent,"{cms:adminPath}",decode(sitepath&adminPath))
		ZContent = replaceStr(ZContent,"{cms:sitename}",zset.SiteTitle)		
		ZContent = replaceStr(ZContent,"{cms:sitetitle}",zset.SiteTitle)
		ZContent = replaceStr(ZContent,"{cms:sitekeys}",zset.sitekeys)
		dim  i,sitekeyslink,keyslink
		if ifstrin(zset.sitekeys,",") then
		  sitekeyslink=split(zset.sitekeys,",")
		  for i=0 to ubound(sitekeyslink)
			 keyslink=keyslink&"<a href='"&zset.siteurl&"' target='_blank'>"&sitekeyslink(i)&"</a>"
		  next
		  	ZContent = replaceStr(ZContent,"{cms:sitekeyslink}",keyslink)
		else
			ZContent = replaceStr(ZContent,"{cms:sitekeyslink}","<a href='"&zset.siteurl&"'">zset.sitekeys&"</a>")
		end if
		ZContent = replaceStr(ZContent,"{cms:sitedesc}",zset.sitedesc)
		ZContent = replaceStr(ZContent,"{cms:sitetitle2}",zset.additionTitle)
		ZContent = replaceStr(ZContent,"{cms:statisticalcode}",decode(zset.statisticalCode))	
		ZContent = replaceStr(ZContent,"{cms:siteicp}",zset.companyICP)	
		ZContent = replaceStr(ZContent,"{cms:company}",zset.companyName)			
		ZContent = replaceStr(ZContent,"{cms:baidupoint1}",zset.companyMapPoint)	
		ZContent = replaceStr(ZContent,"{cms:baidupoint2}",replacestr(zset.companyMapPoint,",","|"))	
		ZContent = replaceStr(ZContent,"{cms:postcode}",zset.companyPostCode)		
		ZContent = replaceStr(ZContent,"{cms:mobile}",zset.companyMobile)	
		ZContent = replaceStr(ZContent,"{cms:fax}",zset.companyFax)			
		ZContent = replaceStr(ZContent,"{cms:tempath}",replacestr(TemplatePath,"//","/"))
		ZContent = replaceStr(ZContent,"{cms:id}",repnul(ID))		
		dim qqs,qq1,qqkfs,tels
		ZContent = replaceStr(ZContent,"{cms:qq}",zset.qq)
		if ifstrin(zset.qq,"|") then
			qqs = split(zset.qq,"|")
			qq1=qqs(0)
			for i=0 to ubound(qqs)			
			ZContent = replaceStr(ZContent,"{cms:qq"&i+1&"}",qqs(i))
			qqkfs=qqkfs&"<li><a target='_blank' href='http://wpa.qq.com/msgrd?v=3&amp;uin="&qqs(i)&"&amp;site=qq&amp;menu=yes' class='qq_link'><img border='0' src='http://wpa.qq.com/pa?p=2:"&qqs(i)&":51' alt='点击这里给我发消息' title='点击这里给我发消息'></a></li>"		
			next
		else
			qqkfs="<li><a target='_blank' href='http://wpa.qq.com/msgrd?v=3&amp;uin="&zset.qq&"&amp;site=qq&amp;menu=yes' class='qq_link'><img border='0' src='http://wpa.qq.com/pa?p=2:"&zset.qq&":51' alt='点击这里给我发消息' title='点击这里给我发消息'></a></li>"		
			qq1=zset.qq
			ZContent = replaceStr(ZContent,"{cms:qq1}",zset.qq)
		end if	
		ZContent = replaceStr(ZContent,"{cms:email}",zset.companyEmail)		
		if ifstrin(zset.companyEmail,"|") then
			qqs = split(zset.companyEmail,"|")
			for i=0 to ubound(qqs)			
			ZContent = replaceStr(ZContent,"{cms:email"&i+1&"}",qqs(i))		
			next
		else
			ZContent = replaceStr(ZContent,"{cms:email1}",zset.companyEmail)	
		end if	
		ZContent = replaceStr(ZContent,"{cms:contact}",zset.companycontact)	
		if ifstrin(zset.companycontact,"|") then
			qqs = split(zset.companycontact,"|")
			for i=0 to ubound(qqs)			
			ZContent = replaceStr(ZContent,"{cms:contact"&i+1&"}",qqs(i))		
			next
		else
			ZContent = replaceStr(ZContent,"{cms:contact1}",zset.companycontact)	
		end if	
		
		if ifstrin(zset.companyAddress,"|") then
			qqs = split(zset.companyAddress,"|")
			for i=0 to ubound(qqs)			
			ZContent = replaceStr(ZContent,"{cms:address"&i+1&"}",qqs(i))		
			next
			ZContent = replaceStr(ZContent,"{cms:address}",qqs(0))	
		else
			ZContent = replaceStr(ZContent,"{cms:address}",zset.companyAddress)		
			ZContent = replaceStr(ZContent,"{cms:address1}",zset.companyAddress)	
		end if	
		
		ZContent = replaceStr(ZContent,"{cms:tel}",zset.companyTel)	
		if ifstrin(zset.companyTel,"|") then
			qqs = split(zset.companyTel,"|")
			for i=0 to ubound(qqs)			
			ZContent = replaceStr(ZContent,"{cms:tel"&i+1&"}",qqs(i))	
			tels=tels&"<li>"&qqs(i)&"</li>"
			next	
		else
			ZContent = replaceStr(ZContent,"{cms:tel1}",zset.companyTel)	
		end if	
		if isnul(tels) then tels=zset.companyTel
		
		if isnul(topsid) then sid=-1 : upsid=-1 : topsid=-1
		ZContent = replaceStr(ZContent,"{cms:sid}",isnum(sid))
		ZContent = replaceStr(ZContent,"{cms:psid}",isnum(upsid))
		if topsid=0 then
		  ZContent = replaceStr(ZContent,"{cms:tsid}",0)	
		  Zcontent=replaceStr(Zcontent,"{cms:tsname}","首页")
		  Zcontent=replaceStr(Zcontent,"{cms:tsenname}","Home")		
		elseif  topsid<0 then  
		  ZContent = replaceStr(ZContent,"{cms:tsid}",-1)	
		  Zcontent=replaceStr(Zcontent,"{cms:tsname}","")
		  Zcontent=replaceStr(Zcontent,"{cms:tsenname}","")		
		else
		ZContent = replaceStr(ZContent,"{cms:tsid}",topsid)	
		dim data : data=dbload("[dbpre]sort","S_Name,S_enname","","Sid="&topsid&"","")
		  if ubound(data)>=0 then
			Zcontent=replaceStr(Zcontent,"{cms:tsname}",data(0,0))
			Zcontent=replaceStr(Zcontent,"{cms:tsenname}",data(1,0))
		  else
			Zcontent=replaceStr(Zcontent,"{cms:tsname}","")
			Zcontent=replaceStr(Zcontent,"{cms:tsenname}","")
		  end if
		end if
			ZContent = replaceStr(ZContent,"{cms:keys}",searchkeys)
		if act="search" or Location="search" then
        	ZContent = replaceStr(ZContent,"{cms:type}",searchtype)	
			ZContent = replaceStr(ZContent,"{cms:typename}",getform("typename","both"))	
			Zcontent = replaceStr(Zcontent,"{cms:location}",Locationpath&" > 搜索结果 > 关键词："&getform("keys","both"))
		end if
		if Location="tag" then
			sortenname	=	getform("tag","both")			
			sortname	=	dbselect("[dbpre]tag","t_name","t_enname='"&sortenname&"' and t_onoff=1")	
			if isnul(sortname) then sortname=sortenname
			pagetitle	=	sortname
			Zcontent = replaceStr(Zcontent,"{cms:location}",Locationpath&" > Tag结果 > 关键词："&sortname)    	
		end if
		if isnul(stype) then	ZContent = replaceStr(ZContent,"{cms:type}",repnul(Location))
		cookiekeys=repnul(getcookie("cookiekeys"))
		'echop cookiekeys
		dim cookiekey,keyi,keyj,types
		if ifstrin(cookiekeys,",") then
			keyi = split(cookiekeys,",")
			for i=0 to ubound(keyi)
				if len(keyi(i))>2 then 
				  keyj = split(keyi(i),"|")		
				  if not isnul(keyj(1)) then types  ="&type="&keyj(1) else types=""
				  cookiekey=cookiekey&"<a href='/search/?keys="&keyj(0)&types&"'>"&keyj(0)&"</a>"
				end if
			next
			ZContent = replaceStr(ZContent,"{cms:searchkeys}",cookiekey)
		else
			ZContent = replaceStr(ZContent,"{cms:searchkeys}",cookiekeys)	
		end if

		ZContent = replaceStr(ZContent,"{cms:keys}","")		
		ZContent = replaceStr(ZContent,"{cms:type}",repnul(stype))
		ZContent = replaceStr(ZContent,"{cms:typename}",repnul(stypename))
		Zcontent = replaceStr(Zcontent,"{cms:location}",Locationpath&getTopType(sid))	
		ZContent = replaceStr(ZContent,"{cms:sname}",repnul(sortname))
		ZContent = replaceStr(ZContent,"{cms:senname}",repnul(sortenname))
		ZContent = replaceStr(ZContent,"{cms:pagetitle}",repnul(pagetitle))
		ZContent = replaceStr(ZContent,"{cms:pagekeys}",repnul(pagekey))
		ZContent = replaceStr(ZContent,"{cms:pagedesc}",repnul(pagedesc))	
		if not isnul(getsession("uid")) then
		  ZContent = replaceStr(ZContent,"{cms:usergid}",isnum(getsession("gid")))
		  ZContent = replaceStr(ZContent,"{cms:userid}",isnum(getsession("uid")))
		  ZContent = replaceStr(ZContent,"{cms:username}",repnul(getsession("username")))
		  ZContent = replaceStr(ZContent,"{cms:truename}",repnul(iif(isnul(getcookie("truename")),getsession("username"),getcookie("truename"))))
		  ZContent = replaceStr(ZContent,"{cms:useremail}",repnul(getcookie("useremail")))
		  ZContent = replaceStr(ZContent,"{cms:userqq}",repnul(getcookie("userqq")))
		  ZContent = replaceStr(ZContent,"{cms:gname}",repnul(getcookie("gname")))
		  ZContent = replaceStr(ZContent,"{cms:usertel}",repnul(iif(isnul(getcookie("usertel")),getcookie("usermobile"),getcookie("usertel"))))
		  ZContent = replaceStr(ZContent,"{cms:usermobile}",repnul(getcookie("usermobile")))
		else
		  ZContent = replaceStr(ZContent,"{cms:usergid}","0")
		  ZContent = replaceStr(ZContent,"{cms:userid}","0")
		  ZContent = replaceStr(ZContent,"{cms:username}","")
		  ZContent = replaceStr(ZContent,"{cms:truename}","匿名")
		  ZContent = replaceStr(ZContent,"{cms:useremail}","")
		  ZContent = replaceStr(ZContent,"{cms:userqq}","")
		  ZContent = replaceStr(ZContent,"{cms:gname}","")
		  ZContent = replaceStr(ZContent,"{cms:usertel}","")
		  ZContent = replaceStr(ZContent,"{cms:usermobile}","")		
		end if
		if ifstrin("content,tag",Location) then
		Zcontent=replaceStr(Zcontent,"{cms:link}",sitepath&Location&"/"&linkmark&sid&"_"&id&siteExt)
		elseif ifstrin("about,list",Location) then
		Zcontent=replaceStr(Zcontent,"{cms:link}",sitepath&stype&"/"&linkmark&sid&"_"&page&siteExt)
		else
		Zcontent=replaceStr(Zcontent,"{cms:link}",replace(geturl(""),"index.asp","?"))
		end if
		ZContent = replaceStr(ZContent,"{cms:qqkfs}",qqkfs)
		ZContent = replaceStr(ZContent,"{cms:tels}",tels)
		ZContent = replaceStr(ZContent,"{cms:userface}",getcookie("userface"))
		ZContent = replaceStr(ZContent,"{cms:act}",iif(act="",Location,act))
		ZContent = replaceStr(ZContent,"{cms:userlogin}","<script language='javascript' src='"&sitepath&"user/user.asp'></script>")		
		ZContent = replaceStr(ZContent,"{cms:gbookform}","<script language='javascript' src='"&sitepath&"gbook/gbook.asp'></script>")		
		ZContent = replaceStr(ZContent,"{cms:openlogin}","onclick=""layer.open({ type: 2,area: ['1000px', '600px'],  content:'"&sitepath&"user/',end:function(){location.reload();}})"")")
		ZContent = replaceStr(ZContent,"{cms:languagepath}",sitepath)
		ZContent = replaceStr(ZContent,"{cms:actmark}",actmark)		
	End Function
	
					
	'文章循环列表
	public function parseDBLoop()
		'on error resume next
		dim listname,listtype,listloop,listArr,fieldArr,sperStrs
		dim sql,whereType,whereSort,whereStr,whereTime,ispage,orderStr
		dim Z_sid,Z_title,Z_type,Z_num,Z_nonum,Z_id,Z_nosid,Z_notid,Z_order,Z_desc,Z_asc,Z_time,Z_brand,Z_where,Z_pagesize,Z_postion,Z_tag,Z_user
		dim customStr,Custom,spec,infolen
		dim rs,numPerPage,allRecordset,allPage,loopstrNew,i,ii,namelen,title,brandid
		dim mm,m,fieldName,FieldAttr,fieldNameArr,loopstrTotal,timestyle,targetblank
		ListLabel   = "\{cms:([a-zA-Z0-9_]*)\s+(.+?)\}([\s\S]*?)\{/cms:\1}"	
		PageLabel	= "\{list:page([\s\S]*?)\}"			
		ZReg.pattern = ListLabel
		set matches  = ZReg.execute(Zcontent)
		if matches.count>0 then
		for each match in matches			
			listname = match.subMatches(0)
			listtype=match.subMatches(1)
			listloop=match.subMatches(2)
			set listArr=parseArr(listtype)
			whereStr="":whereType="":whereSort="":whereTime="":orderStr=""
			Z_sid		=	listArr("sid")		:	if not isnul(Z_sid) then if not(ifnum(Z_sid) or ifstrin(Z_sid,",")) then  die "模板中有无效的参数：sid="&Z_sid
			Z_nosid		=	listArr("nosid")	:	if not isnul(Z_nosid) then if not(ifnum(Z_nosid) or ifstrin(Z_nosid,",")) then  die "模板中有无效的参数：nosid="&Z_nosid
			Z_postion	=	listArr("postion")
			Z_title		=	listArr("title")
			Z_type		=	listArr("type")	
			Z_num		=	listArr("num")		:	if isNul(Z_num) 	then Z_num ="top 10 " else Z_num ="top "&isnum(Z_num)&""
			Z_nonum		=	listArr("nonum")	:	if not ifnum(Z_nonum)  and not isnul(Z_nonum) then  die "模板中有无效参数：nonum="&Z_nonum	
			Z_id		=	listArr("id")
			Z_notid		=	listArr("noid")		
			Z_asc		=	listArr("asc")	
            if Z_asc="desc" or Z_asc="1" or isnul(Z_asc) then 
               Z_desc="desc" 
                Z_asc="asc" 
            elseif Z_asc="asc" or Z_asc="0" then
               Z_desc="asc" 
                Z_asc="desc"	
            end if	
			Z_where		=	listArr("where")	:	if not isNul(Z_where)	then Z_where=replacestr(replacestr(replacestr(Z_where,":","="),"+"," and "),"|"," or ") : whereStr=whereStr&" and "&Z_where
			Z_pagesize	=	listArr("size")		:	if not isnul(Z_pagesize) then ispage=1 : Z_num=""	 else ispage=0
			Z_brand		=	listArr("brand")
			Z_order		=	listArr("order")
			Z_time		=	listArr("time")
			Z_user		=	listArr("user")			
			set listtype = nothing		
			if listname="list" or listname="content" or  listname="search" or  listname="taglist" then
			if not ifstrin("all,about,news,down,product,photo,case,job,video,brand,gbook,links",Z_type) and not isnul(Z_type) then die "模板中标签中有无效参数：type="&Z_type
				orderStr =" order by IsTop "&Z_desc&",isgood "&Z_desc&",C_order "&Z_asc&",C_AddTime "&Z_desc&",CID "&Z_desc
				select case Z_order           
				  case "id" : orderStr =" order by CID "&Z_desc
				  case "visits" : orderStr =" order by C_Visits "&Z_desc&",CID "&Z_desc
				  case "time" : orderStr =" order by C_AddTime "&Z_desc&",CID "&Z_desc
				  case "price" : orderStr =" order by zprice "&Z_asc&",CID "&Z_desc
				  case "rnd" :	Randomize()   : 	orderStr =" order BY Rnd("&-1*(Int(1000*Rnd)+1)&"*cid)"	
				  case "istop" : orderStr =" and IsTop=1 "&orderStr
				  case "notop" : orderStr =" and IsTop=0 "&orderStr
				  case "isgood" : orderStr =" and Isgood=1 "&orderStr
				  case "nogood" : orderStr =" and Isgood=0 "&orderStr
				  case "ispic" : orderStr =" and ispic=1 "&orderStr
				  case "nopic" : orderStr =" and ispic=0 "&orderStr
				  case "issell" : orderStr =" and issell=1 "&orderStr
				  case "nosell" : orderStr =" and issell=0 "&orderStr
				  case "isoffer" : orderStr =" and isoffer=1 "&orderStr
				  case "nooffer" : orderStr =" and isoffer=0 "&orderStr
				end select
			end if
			
			select case listname
				'---内容循环参数---
				case "list","content"
				  if not isNul(Z_sid) 	then 
				  	if ifstrin(Z_sid,"，") then Z_sid=replacestr(Z_sid,"，",",")
				 	if ifstrin(Z_sid,",") then
				  		 whereSort="and C_sid in ("&Z_sid&")"
				 	else
						whereSort="and  ','+S_path+',' like '%,"&Z_sid&",%'"
				 	end if
				  end if
				  if not isNul(Z_nosid) 	then
					if ifstrin(Z_nosid,"，") then Z_nosid=replacestr(Z_nosid,"，",",")
					  if ifstrin(Z_nosid,",") then
						   whereSort="and C_sid not in ("&Z_nosid&")"
					  else				  
						   whereSort="and  ','+S_path+',' not like '%,"&Z_nosid&",%'"
					  end if
					end if
				  if not isNul(Z_type) 	then whereType="and C_Type='"&Z_type&"'"
				  if not isNul(Z_title) 	then whereType="and C_Title like'%"&Z_title&"%'"
				  if isnum(Z_nonum) 	then whereStr=whereStr&"and CID not in (select top "&Z_nonum&" CID from [dbpre]content where C_OnOff=1 "&whereType&whereSort&whereTime&whereStr&orderStr&")"
				  if not isNul(Z_id) 		then whereStr=whereStr&"and CID in ("&Z_id&")"
				  if not isNul(Z_notid) 	then whereStr=whereStr&"and CID not in ("&Z_notid&")"	
				  if not isNul(Z_brand)		then whereStr=whereStr&"and C_Brand = '"&Z_brand&"' "	
				if not isnul(Z_time) then
					if dbType=1 then
						select case Z_time
							case "day" : whereTime=" and  DateDiff(d,C_AddTime,'"&sqltime&"')=0"
							case "week" : whereTime=" and  DateDiff(ww,C_AddTime,'"&sqltime&"')=0"
							case "month" : whereTime=" and  DateDiff(m,C_AddTime,'"&sqltime&"')=0"
							case else : whereTime=""
						end select
					else
						select case Z_time
							case "day" : whereTime=" and  DateDiff('d',C_AddTime,'"&sqltime&"')=0"
							case "week" : whereTime=" and  DateDiff('w',C_AddTime,'"&sqltime&"')=0"
							case "month" : whereTime=" and  DateDiff('m',C_AddTime,'"&sqltime&"')=0"
							case else : whereTime=""
						end select
					end if
				end if				
				if isscreen=1 then wherestr=wherestr&screensql
				if isorderby=1  then 
					if not isnul(ordersql) then orderstr=ordersql
				end if
				if isNul(Z_user) then
				sql="select "&Z_num&" a.*,S_Folder,S_GID,C_Folder,C_FileName,S_Name,S_enname from [dbpre]Content as a,cms_Sort as b where sid=C_sid "&whereType&whereSort&whereTime&whereStr&" and C_OnOff=1 "&orderStr
				else
				sql="select "&Z_num&" a.*,S_Folder,S_GID,C_Folder,C_FileName,S_Name,S_enname from [dbpre]Content as a,cms_Sort as b where sid=C_sid "&whereType&whereSort&whereTime&whereStr&"and C_Title2 ='"&Z_user&"' and C_OnOff<2 "&orderStr
				end if				
				sperStrs=conn.exec("select custom from [dbpre]content_custom where customOnOff=1 and customType not in('about','brand','gbook') Order by customOrder Asc,customID", "arr")		
				'---内容循环参数---
			  case "search"
				  dim keys,searchcol,key_type,searchstr,searchcoli,searchcols
					  searchcol	=	getform("searchcol","post")	
					  if isnul(searchcol) then searchcol=getcookie("searchcol") else setcookie"searchcol",searchcol
					  if ifstrin(searchcol,",") then
						  searchstr=""												
							searchcols=split(searchcol,",")			
							for each searchcoli in searchcols
							  if not isnul(searchcoli) then
								  if isColin("[dbpre]content",searchcoli)  then  searchstr=searchstr&" or "&searchcoli&" like '%"&searchkeys&"%'"	else die "自定义搜索字段"&searchcoli&"数据库中不存在"							
							   end if
							next		
					  elseif not isnul(searchcol) then
						  if isColin("[dbpre]content",searchcol)  then  searchstr=" or "&searchcol&" like '%"&searchkeys&"%'" else die "自定义搜索字段"&searchcol&"数据库中不存在"							
					  end if				
					  keys		=	searchkeys		:	if not isnul(keys) then 		wherestr=" and (C_Title like '%"&keys&"%'"&searchstr&")"
					  key_type	=	searchtype
					  if not isnul(key_type) then	
					  	if dbType =0 then whereType=" and instr(',"&key_type&",',','&C_Type&',')"  else  whereType=" and CHARINDEX(','+C_Type+',',',"&key_type&",')>0" 
					  end if
				  if isnul(wherestr) then wherestr=" and 1=2"
				  sql="select "&Z_num&" a.*,S_Folder,S_GID,C_Folder,C_FileName,S_Name,S_enname from [dbpre]Content as a,cms_Sort as b where sid=C_sid and  C_OnOff=1"&wherestr&whereSort&whereType&orderStr
				  'echop sql
				  sperStrs=conn.exec("select custom from [dbpre]content_custom where customOnOff=1  and customType not in('about','brand','gbook') Order by customOrder Asc,customID", "arr")
				  '---TAG循环参数---
				case "taglist"
					if dbType =0 then whereStr="and instr(','&C_tag&',',',"&sortname&",')" else whereStr="and CHARINDEX(',"&sortname&",',','+C_tag+',')>0" 
					if not isNul(Z_type) 	then whereType="and C_Type='"&Z_type&"'"
				 	if not isNul(Z_sid) 	then whereSort="and  ','+S_path+',' not like '%,"&Z_sid&",%'"
					sql="select "&Z_num&" a.*,S_Folder,S_GID,C_Folder,C_FileName,S_Name,S_enname from [dbpre]Content as a,cms_Sort as b where sid=C_sid and  C_OnOff=1"&wherestr&whereType&orderStr
					sperStrs=conn.exec("select custom from [dbpre]content_custom where customOnOff=1  and customType not in('about','brand','gbook') Order by customOrder Asc,customID", "arr")		
				'---TAG循环参数---	
						
				'---单页循环参数---
				case "aboutlist"
					if isNul(Z_sid) then die "{cms:"&listname&"}标签中未找到SID，请修改模板"
						if ifstrin(Z_sid,",") then
							Z_num=ubound(split(Z_sid,","))+1
						 	whereSort="A_sid in ("&Z_sid&") and"						 
						else
							Z_num=1
							whereSort="A_sid ="&Z_sid&" and"		
						end if
				sql ="select top "&Z_num&" * from [dbpre]about where  "&whereSort&" A_OnOff=1 order by a_Order "&Z_asc&",AID "&Z_asc&""
				sperStrs=conn.exec("select custom from [dbpre]content_custom where customOnOff=1 and customType ='about' Order by customOrder Asc,customID desc","arr")	
				'---单页循环参数---
				
				'---品牌循环参数---
				case "brandlist"
				if not isNul(Z_brand)	then whereStr=whereStr&"B_name = '"&Z_brand&"' and"
				if not isNul(z_type)	then whereStr=whereStr&"B_type = '"&z_type&"' and"
				sql ="select "&Z_num&" * from [dbpre]brand where  "&whereStr&" B_OnOff=1 order by B_Order "&Z_asc&",BID "&Z_asc&""		
				sperStrs=conn.exec("select custom from [dbpre]content_custom where customOnOff=1 and customType = 'brand' Order by customOrder Asc,customID desc","arr")
				'---品牌循环参数--
				
				'---留言循环参数---
				case "gbook"
				sql="select  "&Z_num&" * from [dbpre]Gbook  where  G_OnOff=1 and lid="&zset.lid&"  order by G_Order "&Z_asc&",GID "&Z_desc&""		
				sperStrs=conn.exec("select custom from [dbpre]content_custom where customOnOff=1 and customType = 'gbook' Order by customOrder Asc,customID desc","arr")
				'---留言循环参数---
											
				'---分类信息循环--					
				case "sort","type" 		
					if isNul(Z_sid) then die "{cms:"&listname&"}标签中未找到SID，请修改模板"
						if ifstrin(Z_sid,",") then
							Z_num=ubound(split(Z_sid,","))+1
						 	whereSort="sid in ("&Z_sid&")"						 
						else
							Z_num=1
							whereSort="sid ="&Z_sid&""		
						end if
						sql="select  top "&Z_num&" * from [dbpre]Sort where "&whereSort&" order by s_Order "&Z_asc&",SID "&Z_asc&""
						whereSort=""
				'---分类信息循环-				
				
				'---友链循环参数---
				case "linklist" 
					if Z_type="pic" then whereStr=" L_Type='pic' and"
					if Z_type="text" then whereStr=" L_Type='text' and"
					if not isnul(Z_postion) then  whereStr=" L_CID="&Z_postion&" and"
					sql="select  "&Z_num&" * from [dbpre]Links  where "&whereStr&" L_OnOff=1 order by L_Order "&Z_asc&",LID "&Z_asc&""			
				'---友链循环参数---
				
				'---幻灯循环参数---
				case "slidelist"
					if isnul(Z_type) then Z_type="A"
					whereStr=" SlideClass='"&Z_type&"' and "
					sql="select  "&Z_num&" * from [dbpre]slide  where "&whereStr&" slideOnOff=1 order by slideOrder "&Z_asc&",slideID "&Z_asc&""					
				'---幻灯循环参数---				
					
				'---TAG循环参数---
				case "tag"					
					if not isNul(Z_type) and Z_type<>"all" then whereStr="T_type ='"&Z_type&"' and" else whereStr=""
					if dbType =0 then 
					   	sql ="select "&Z_num&" TID,T_Name,T_enName,(select count(0) from [dbpre]content where C_OnOff=1 and instr(','&C_tag&',',','&[a.T_Name]&',')) as tagcount from [dbpre]tag as a where  "&whereStr&" T_OnOff=1 order by T_Order "&Z_asc&",tid  "&Z_asc&""
					 else  
					   	sql ="select "&Z_num&" TID,T_Name,T_enName,(select count(0) from [dbpre]content where C_OnOff=1 and CHARINDEX(','+a.T_Name+',',','+C_tag+',')>0) as tagcount from [dbpre]tag as a where  "&whereStr&" T_OnOff=1 order by T_Order "&Z_asc&",tid  "&Z_asc&""
					 end if
				'---TAG循环参数---	
				
				case else
				'---栏目循环参数---
				  if ifstrin(listname,"navlist")  then 
				  if isnul(Z_type) and 	isnul(Z_sid) and isnul(Z_postion)  then die "{cms:"&listname&"}导航标签中未找到type=或sid=或postion=，请修复"
					if Z_type="all" or isnul(Z_type) then whereStr="and S_PID=0"  else  whereStr="and S_PID=0 and S_Type ='"&Z_type&"'"
					if not isnul(Z_nosid) then
						if ifstrin(Z_nosid,",") then 
							whereStr=whereStr&" and sid not in ("&Z_nosid&")"
						else
							whereStr=whereStr&" and sid <>"&Z_nosid
						end if
					end if
					if not isnul(Z_sid) then
						if ifstrin(Z_sid,",") then 
							whereStr=" and sid in ("&Z_sid&")"
						else
							whereStr=" and S_PID ="&Z_sid
						end if
					end if
					if not isnul(Z_postion) then whereStr=" and S_postion like '%"&Z_postion&"%'"
					sql = "select  "&Z_num&" SID,S_name,S_LID,S_TID,S_PID,S_Order,S_Type,S_postion,S_enname,S_URL,S_Level,S_AddTime,S_EditTime,S_Title,S_Key,S_Desc,S_Path,S_Pic,S_Template,C_Template,S_Folder,C_Folder,S_FileName,C_FileName,S_OnOff,S_GID,S_Exc,IsComment,s_ico,S_other1,S_other2 from [dbpre]Sort where S_OnOff=1 "&whereStr&" order by S_Order "&z_asc&",sid "&z_asc
				  end if
				'---栏目循环参数---
			end Select
			whereSort=""
			Zreg.Pattern = Pagelabel			
			set Pagelist = Zreg.Execute(Zcontent)
			 set rs =dbsqlr1(sql)
			 if err then die sql
			 loopstrTotal = ""
			 if ispage=1 then
			 if rs.pagecount>0 then
			 	numPerPage = isnum(Z_pagesize)
				if numPerPage>rs.recordcount then numPerPage=rs.recordcount			
				if page=0 then page=1	else page=isnum(page)			
				rs.pagesize =numPerPage
				allRecordset = rs.recordcount 
				 allPage= rs.pagecount
				if page>allPage then aspgo sitepath&Location&"/"&linkmark&sid&"_"&allpage&".html"
				 rs.absolutepage = page	
				if page=allPage then numPerPage=allRecordset-numPerPage*(allPage-1)			
				For Each m in Pagelist
				   Lenpage = parseArr(m.SubMatches(0))("len")
				   dim stylepage : stylepage= parseArr(m.SubMatches(0))("style")
				   if isNul(Lenpage) then Lenpage = 5 else Lenpage = cint(Lenpage)
				   if isNul(stylepage) then stylepage = 1
			 		if sid=0 then
					if isnul(z_sid) and not isnul(z_type) then sid=dbselect("[dbpre]sort","sid","S_Type='"&z_type&"' and S_PID=0 and S_OnOff=1") else sid=z_sid
					end if
				 strPagelist = "<link rel='stylesheet' type='text/css' href='"&pluginspath&"pagesize/pagesize"&stylepage&".css'/><div id='pagesize'>"&getpageNumber(page,Lenpage,allPage,listname,sid,geturl("arr"))&"</div>"	
				 zcontent = ReplaceStr(zcontent,m.value,strPagelist)	
				next			 
			  else				
				zcontent = regExpReplace(zcontent,Pagelabel,"")		
			  end if
		    elseif rs.recordcount>0 then
				numPerPage= rs.recordcount
			end if
			if rs.recordcount>0 then	
				Zreg.Pattern = "\["&listname&":([\s\S]+?)\]"
			 	set mm = Zreg.Execute(listloop)	
				  for i = 1 to numPerPage				  
				  	loopstrNew=listloop
					  For Each m in mm
						  fieldNameArr = regExpReplace(m.SubMatches(0),"[\s]+",chr(32))
						  fieldNameArr = trim(fieldNameArr)
						  ii = instr(fieldNameArr,chr(32))
						  if  ii > 0 then 
							  fieldName = left(fieldNameArr,ii - 1)
							  FieldAttr =	right(fieldNameArr,len(fieldNameArr) - ii)
						  else
							  fieldName = fieldNameArr
							  FieldAttr =	""
						  end if
						  
							loopstrNew=ReplaceStr(loopstrNew,"["&listname&":i]",i)
							loopstrNew=ReplaceStr(loopstrNew,"["&listname&":j]",i-1)
							loopstrNew=ReplaceStr(loopstrNew,"["&listname&":id]",rs(0))
							if FieldName="title" or FieldName="name" then
								infolen = parseArr(FieldAttr)("len")
								title=iif(isnum(infolen),leftStr(repnul(rs(1)),infolen),repnul(rs(1)))
								loopstrNew=ReplaceStr(loopstrNew,m.value,title)	
								loopstrNew=ReplaceStr(loopstrNew,"["&listname&":title]",rs(1))							
								loopstrNew=ReplaceStr(loopstrNew,"["&listname&":name]",rs(1))
							end if
						select case listname
						case "list","content","search","taglist"
					' --内容循环开始 --
						  Select Case FieldName						  	
							Case "sql"	:	loopstrNew=ReplaceStr(loopstrNew,m.value,sql)		
							Case "sid"	:	loopstrNew=ReplaceStr(loopstrNew,m.value,rs("C_SID"))			
							Case "color"	:	loopstrNew=ReplaceStr(loopstrNew,m.value,repnul(rs("C_color")))								
							Case "title2"	:	loopstrNew=ReplaceStr(loopstrNew,m.value,repnul(rs("C_Title2")))
							Case "pic"	:	loopstrNew=ReplaceStr(loopstrNew,m.value,iif(isnul(rs("C_pic")),sitepath&"images/nopic.gif",rs("C_pic")))
							Case "pic1"	:	loopstrNew=ReplaceStr(loopstrNew,m.value,sitepath&uploadpath&"images/"&rs(0)&"_1.jpg")
							Case "pic2"	:	loopstrNew=ReplaceStr(loopstrNew,m.value,sitepath&uploadpath&"images/"&rs(0)&"_2.jpg")	
							Case "spic"	:	loopstrNew=ReplaceStr(loopstrNew,m.value,iif(isnul(rs("C_pic")),sitepath&"images/nopic.gif",sitepath&uploadpath&"images/"&rs(0)&".jpg"))
							Case "pics"	:	loopstrNew=ReplaceStr(loopstrNew,m.value,getsplitlink(rs("C_picsurl"),rs("C_picsname"),"pic"))
							Case "down"	:	loopstrNew=ReplaceStr(loopstrNew,m.value,getsplitlink(rs("C_DownUrl"),rs("C_DownName"),"down"))
							Case "downurl"	:	loopstrNew=ReplaceStr(loopstrNew,m.value,endstr(repnul(rs("C_DownUrl")),","))
							Case "downname"	:	loopstrNew=ReplaceStr(loopstrNew,m.value,endstr(repnul(rs("C_DownName")),","))
							Case "brand"	:	loopstrNew=ReplaceStr(loopstrNew,m.value,repnul(rs("C_Brand")))
							Case "brandlink"
							if not isnul(rs("C_Brand")) then 
								brandid=dbselect("[dbpre]brand","bid","B_Name='"&rs("C_Brand")&"'") 
								loopstrNew=ReplaceStr(loopstrNew,m.value,iif(isnul(brandid),"",sitepath&"brand/"&linkmark&brandid&"_1"&siteExt))								
							else
								loopstrNew=ReplaceStr(loopstrNew,m.value,"")						
							end if
							Case "sname"	:	loopstrNew=ReplaceStr(loopstrNew,m.value,repnul(rs("S_Name")))
							Case "senname"	:	loopstrNew=ReplaceStr(loopstrNew,m.value,repnul(rs("S_enname")))	
							Case "slink"	:	loopstrNew=ReplaceStr(loopstrNew,m.value,getSortLink(rs("c_Type"),rs("C_sid"),"",rs("s_Folder"),"",rs("S_GID"),""))	
							Case "visits"	:	loopstrNew=ReplaceStr(loopstrNew,m.value,isnum(rs("C_Visits")))
							Case "star"		:	loopstrNew=ReplaceStr(loopstrNew,m.value,isnum(rs("C_Star")))
							Case "istop"	:	loopstrNew=ReplaceStr(loopstrNew,m.value,isnum(rs("istop")))
							Case "isgood"	:	loopstrNew=ReplaceStr(loopstrNew,m.value,isnum(rs("isgood")))
							Case "Ispic"	:	loopstrNew=ReplaceStr(loopstrNew,m.value,isnum(rs("Ispic")))
							Case "isoffer"	:	loopstrNew=ReplaceStr(loopstrNew,m.value,isnum(rs("isoffer")))
							Case "issell"	:	loopstrNew=ReplaceStr(loopstrNew,m.value,isnum(rs("issell")))		
							Case "tag"		:	loopstrNew=ReplaceStr(loopstrNew,m.value,gettaglink(rs("c_tag"),""))				
							Case "link"	:loopstrNew=ReplaceStr(loopstrNew,m.value,getContentLink(rs("C_sid"),rs("CID"),rs("S_Folder"),rs("C_GID"),rs("C_Folder"),rs("C_FileName"),rs("C_link"),rs("C_pagename"),rs("C_Type")))	
							if ifstrin(rs("C_link"),"http://") then targetblank="target='_blank'" else targetblank=""
							case "target"	: loopstrNew = ReplaceStr(loopstrNew,m.value,targetblank)								
							case "date"		: loopstrNew = ReplaceStr(loopstrNew,m.value,repnul(rs("C_AddTime")))
							case "onoff"	: loopstrNew = ReplaceStr(loopstrNew,m.value,rs("C_onoff"))
							case "state"	: loopstrNew = ReplaceStr(loopstrNew,m.value,iif(rs("C_onoff")=1,"正常","审核中"))
							case "desc"		: loopstrNew = ReplaceStr(loopstrNew,m.value,repnul(rs("C_PageDesc")))
							case "info"	: loopstrNew = ReplaceStr(loopstrNew,m.value,decode(rs("C_Content")))
							case "content"
								infolen = parseArr(FieldAttr)("len") : if isNul(infolen) then infolen = 500 else infolen=cint(infolen)
								loopstrNew = replacestr(loopstrNew,m.value,leftStr(dropHtml(decode(replacestr(rs("C_Content"),"{list:page}",""))),infolen))
							end select
							if isarray(sperStrs) then
								for each spec in sperStrs
								'die listname&spec&rs(spec)
									if ifstrin(spec,"price") then
									loopstrNew=ReplaceStr(loopstrNew,"["&listname&":"&spec&"]",getmoney(rs(spec)))
									else
									loopstrNew=ReplaceStr(loopstrNew,"["&listname&":"&spec&"]",decode(repnul(rs(spec))))
									end if
								next
							end if						
						  closers sperStrs
					' --内容循环结束 --
						case "sort","type"
							Select Case FieldName
							case "link"	:	loopstrNew =replacestr(loopstrNew,m.value,getSortLink(rs("s_Type"),rs("sid"),rs("s_Url"),rs("s_Folder"),rs("s_FileName"),rs("S_GID"),rs("S_Exc")))						
							if ifstrin(rs("s_Url"),"http://") then targetblank="target='_blank'" else targetblank=""
							case "target"	: loopstrNew=ReplaceStr(loopstrNew,m.value,targetblank)
							case "Level"	: loopstrNew = ReplaceStr(loopstrNew,m.value,rs("S_Level"))	
							case "type"	: loopstrNew = ReplaceStr(loopstrNew,m.value,repnul(rs("S_Type")))	
							case "pid"	: loopstrNew = ReplaceStr(loopstrNew,m.value,rs("S_PID"))	
							case "tid"	: loopstrNew = ReplaceStr(loopstrNew,m.value,rs("S_TID"))	
							case "pic"	: loopstrNew = ReplaceStr(loopstrNew,m.value,repnul(rs("S_pic")))
							case "ico"	: loopstrNew = ReplaceStr(loopstrNew,m.value,repnul(rs("S_ico")))
							case "other1"	: loopstrNew = ReplaceStr(loopstrNew,m.value,repnul(rs("S_other1")))
							case "other2"	: loopstrNew = ReplaceStr(loopstrNew,m.value,repnul(rs("S_other2")))
							case "entitle","enname"
							infolen = parseArr(FieldAttr)("len")
							title=iif(isnum(infolen),leftStr(repnul(rs("S_enname")),infolen),repnul(rs("S_enname")))
							loopstrNew=ReplaceStr(loopstrNew,m.value,title)	
							case "keys"	: loopstrNew = ReplaceStr(loopstrNew,m.value,repnul(rs("S_Key")))	
							case "desc"
							if not isnul(rs("S_Desc")) then
								infolen = parseArr(FieldAttr)("len") : if isNul(infolen) then infolen = 500 else infolen=cint(infolen)
								loopstrNew = replacestr(loopstrNew,m.value,leftStr(dropHtml(rs("S_Desc")),infolen)&"...")								
							end if			
							case "date"		: loopstrNew = ReplaceStr(loopstrNew,m.value,repnul(rs("S_AddTime")))							
							end select
							
						case "aboutlist"
							Select Case FieldName
							case "sql"		: loopstrNew = ReplaceStr(loopstrNew,m.value,sql)	
							case "visits"	: loopstrNew = ReplaceStr(loopstrNew,m.value,isnum(rs("A_Visits")))								
							case "keys"	: loopstrNew = ReplaceStr(loopstrNew,m.value,repnul(rs("A_Key")))	
							case "link"	: loopstrNew = ReplaceStr(loopstrNew,m.value,sitepath&"about/"&linkmark&rs("A_Sid")&"_1"&siteExt)	
							case "desc"
							if not isnul(rs("A_desc")) then
								loopstrNew = replacestr(loopstrNew,m.value,dropHtml(rs("A_desc")))
							else
								loopstrNew = replacestr(loopstrNew,m.value,leftstr(dropHtml(decode(rs("A_Content"))),255))		
							end if										
							case "pic"	: loopstrNew = ReplaceStr(loopstrNew,m.value,repnul(rs("A_pic")))
							case "pics"	: loopstrNew = ReplaceStr(loopstrNew,m.value,repnul(rs("A_picsurl")))
							case "picsname"	: loopstrNew = ReplaceStr(loopstrNew,m.value,repnul(rs("A_picsname")))
							case "entitle","enname"
								infolen = parseArr(FieldAttr)("len")
								title=iif(isnum(infolen),leftStr(repnul(rs("A_enname")),infolen),repnul(rs("A_enname")))
								loopstrNew=ReplaceStr(loopstrNew,m.value,title)	
							case "date"		: loopstrNew = ReplaceStr(loopstrNew,m.value,repnul(rs("A_AddTime")))
							case "content"
								infolen = parseArr(FieldAttr)("len") : if isNul(infolen) then infolen = 500 else infolen=cint(infolen)
								loopstrNew = replacestr(loopstrNew,m.value,leftStr(dropHtml(decode(replacestr(rs("A_Content"),"{list:page}",""))),infolen))
							case "info"	: loopstrNew = ReplaceStr(loopstrNew,m.value,decode(rs("A_Content")))
							end select
							if isarray(sperStrs) then
								for each spec in sperStrs
									loopstrNew=ReplaceStr(loopstrNew,"["&listname&":"&spec&"]",decode(repnul(rs(spec))))									
								next
							end if						
						  closers sperStrs
							
				' --品牌循环开始 --
						case "brandlist" 
							'die sql
							Select Case FieldName
							case "sql"		: loopstrNew = ReplaceStr(loopstrNew,m.value,sql)	
							case "visits"	: loopstrNew = ReplaceStr(loopstrNew,m.value,isnum(rs("B_Visits")))			
							case "entitle"		: loopstrNew = ReplaceStr(loopstrNew,m.value,repnul(rs("B_enname")))	
							case "link"	: loopstrNew = ReplaceStr(loopstrNew,m.value,sitepath&"brand/"&linkmark&rs("Bid")&"_1"&siteExt)		
							case "url"	: loopstrNew = ReplaceStr(loopstrNew,m.value,repnul(rs("B_url")))			
							case "pic"	: loopstrNew = ReplaceStr(loopstrNew,m.value,repnul(rs("B_pic")))
							case "pics"	: loopstrNew = ReplaceStr(loopstrNew,m.value,repnul(rs("B_picsurl")))	
							case "picsname"	: loopstrNew = ReplaceStr(loopstrNew,m.value,repnul(rs("B_picsname")))							
							case "desc"	: loopstrNew = replacestr(loopstrNew,m.value,repnul(rs("B_Desc")))						
							case "date"		: loopstrNew = ReplaceStr(loopstrNew,m.value,repnul(rs("B_AddTime")))	
							case "info"	: loopstrNew = ReplaceStr(loopstrNew,m.value,decode(rs("B_Content")))
							case "content"
								infolen = parseArr(FieldAttr)("len") : if isNul(infolen) then infolen = 500 else infolen=cint(infolen)
								loopstrNew = replacestr(loopstrNew,m.value,leftStr(dropHtml(decode(replacestr(rs("B_Content"),"{list:page}",""))),infolen))
							end select	
							if isarray(sperStrs) then
								for each spec in sperStrs
									loopstrNew=ReplaceStr(loopstrNew,"["&listname&":"&spec&"]",decode(repnul(rs(spec))))									
								next
							end if						
						  closers sperStrs
							
				' --品牌循环开始 --	
				' --tag循环开始 --
						case "tag" 
							Select Case FieldName
							case "link"	: loopstrNew = ReplaceStr(loopstrNew,m.value,sitepath&"tag/?tag="&rs("T_enName"))
							case "num"	: loopstrNew = ReplaceStr(loopstrNew,m.value,rs("tagcount"))									
							end select	
				' --tag循环开始 --	
				' --留言循环开始 --
						case "gbook" 
							dim face: face= ""							
							if repnul(rs("G_UID"))>0 then face=dbselect("[dbpre]user","face","uid="&rs("G_uid")&"") else face=""
						  Select Case FieldName
							case "gname"	: loopstrNew = ReplaceStr(loopstrNew,m.value,repnul(rs("G_name")))	
							case "email"	: loopstrNew = ReplaceStr(loopstrNew,m.value,repnul(rs("G_email")))
							case "ip"		: loopstrNew = ReplaceStr(loopstrNew,m.value,repnul(rs("G_IP")))
							case "tel"		: loopstrNew = ReplaceStr(loopstrNew,m.value,repnul(rs("G_tel")))
							case "date"		: loopstrNew = ReplaceStr(loopstrNew,m.value,repnul(rs("G_Time")))	
							case "info"	: loopstrNew = ReplaceStr(loopstrNew,m.value,decode(rs("G_Content")))
							case "content"
								infolen = parseArr(FieldAttr)("len") : if isNul(infolen) then infolen = 500 else infolen=cint(infolen)
								loopstrNew = replacestr(loopstrNew,m.value,leftStr(dropHtml(decode(rs("G_Content"))),infolen))
							case "ronoff"	: loopstrNew = ReplaceStr(loopstrNew,m.value,isnum(rs("R_OnOff")))	
							case "uid"	: loopstrNew = ReplaceStr(loopstrNew,m.value,isnum(rs("G_UID")))
							case "face"		: loopstrNew = ReplaceStr(loopstrNew,m.value,iif(isnul(face),sitepath&"images/face/noface.png",sitepath&"images/face/"&face))
							  if isarray(sperStrs) then
								for each spec in sperStrs
									loopstrNew=ReplaceStr(loopstrNew,"["&listname&":"&spec&"]",decode(repnul(rs(spec))))									
								next
							  end if						
						 	 closers sperStrs
						  end select
							if rs("R_OnOff") =1 then
								Select Case FieldName
								case "rname"	: loopstrNew = ReplaceStr(loopstrNew,m.value,repnul(rs("R_name")))								
								case "rdate"	: loopstrNew = ReplaceStr(loopstrNew,m.value,repnul(rs("R_Time")))									
								case "rcontent"	: loopstrNew = ReplaceStr(loopstrNew,m.value,decode(rs("R_Content")))
								end select
							else
								Select Case FieldName
								case "rname"	: loopstrNew = ReplaceStr(loopstrNew,m.value,"")							
								case "rdate"	: loopstrNew = ReplaceStr(loopstrNew,m.value,"")			  
								case "rcontent" : loopstrNew = ReplaceStr(loopstrNew,m.value,"")							
								end select
							end if
							
						
				' --留言循环开始 --						
				' --友情循环开始 --
						case "linklist" 
							Select Case FieldName
							  case "link"	: loopstrNew = ReplaceStr(loopstrNew,m.value,rs("L_URL"))		
							  case "pic"	: loopstrNew = ReplaceStr(loopstrNew,m.value,rs("L_pic"))
							  case "content"	: loopstrNew = ReplaceStr(loopstrNew,m.value,decode(rs("L_Desc")))								
							end select	
				' --友情循环开始 --
				' --幻灯循环开始 --
						case "slidelist"
							Select Case FieldName
							  case "title1"	: loopstrNew = ReplaceStr(loopstrNew,m.value,rs("Slidetitle1"))		
							  case "title2"	: loopstrNew = ReplaceStr(loopstrNew,m.value,rs("Slidetitle2"))	
							  case "link"	: loopstrNew = ReplaceStr(loopstrNew,m.value,rs("SlideLink"))		
							  case "pic"	: loopstrNew = ReplaceStr(loopstrNew,m.value,rs("SlideImg"))
							  case "width"	: loopstrNew = ReplaceStr(loopstrNew,m.value,rs("SlideWidth"))
							  case "height"	: loopstrNew = ReplaceStr(loopstrNew,m.value,rs("SlideHeight"))
							  case "content"	: loopstrNew = ReplaceStr(loopstrNew,m.value,decode(rs("SlideContent")))		
							end select	
				' --幻灯循环结束 --		
		
				' --导航循环开始 --
						 case else	
						 if ifstrin(listname,"navlist")  then
							Select Case FieldName
							case "link"	:	loopstrNew =replacestr(loopstrNew,m.value,getSortLink(rs("s_Type"),rs("sid"),rs("s_Url"),rs("s_Folder"),rs("s_FileName"),rs("S_GID"),rs("S_Exc")))	
							if ifstrin(rs("s_Url"),"http://") then targetblank="target='_blank'" else targetblank=""
							case "target"	: loopstrNew=ReplaceStr(loopstrNew,m.value,targetblank)
							case "type"	: loopstrNew=ReplaceStr(loopstrNew,m.value,rs("s_Type"))
							case "sql"	: loopstrNew = ReplaceStr(loopstrNew,m.value,sql)
							case "pic"	: loopstrNew = ReplaceStr(loopstrNew,m.value,repnul(rs("S_pic")))	
							case "ico"	: loopstrNew = ReplaceStr(loopstrNew,m.value,repnul(rs("S_ico")))	
							case "other1"	: loopstrNew = ReplaceStr(loopstrNew,m.value,repnul(rs("S_other1")))	
							case "other2"	: loopstrNew = ReplaceStr(loopstrNew,m.value,repnul(rs("S_other2")))		
							case "sid"	: loopstrNew = ReplaceStr(loopstrNew,m.value,rs("sid"))		
							case "tsid"	: loopstrNew = ReplaceStr(loopstrNew,m.value,rs("s_tid"))		
							case "psid"	: loopstrNew = ReplaceStr(loopstrNew,m.value,rs("s_pid"))	
							case "stitle"	: loopstrNew = ReplaceStr(loopstrNew,m.value,rs("S_Title"))	
							case "keys"	: loopstrNew = ReplaceStr(loopstrNew,m.value,rs("S_Key"))	
							case "desc"	: loopstrNew = ReplaceStr(loopstrNew,m.value,rs("S_Desc"))		
							case "entitle","enname"
							infolen = parseArr(FieldAttr)("len")
							title=iif(isnum(infolen),leftStr(repnul(rs("S_enname")),infolen),repnul(rs("S_enname")))
							loopstrNew=ReplaceStr(loopstrNew,m.value,title)	
							case "num"	:	loopstrNew=ReplaceStr(loopstrNew,m.value,dbcount("[dbpre]sort","S_PID="&rs("sid")&" and s_onoff=1"))	
							end select
							end if
				' --导航循环结束 --
						end select						
					next
					loopstrTotal = loopstrTotal & loopstrNew
					if not rs.eof then rs.movenext
				next
			else				
			' loopstrTotal="未找到匹配内容" 
			end if	
			closers rs
			set matches = nothing
			zcontent = replace(zcontent,match.value,loopstrTotal)
		next 
		end if
		
	end function
	
	
	'解析自定义标签内容模块
	Public Function ParseLabels()
		on error resume next

		If Not(IfStrIn(ZContent,"{/label}")) 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,iflabelField,infolen,desc
		dim m,namelen,deslen,m_des
		iflabel="{label:([\s\S]+?)}([\s\S]*?){/label}"
		iflabelField="\[label:([\s\S]+?)\]"
		ZReg.Pattern=iflabel
		Set Matches = ZReg.Execute(ZContent)
		For Each Match in Matches
			labelAttrLinklist=match.SubMatches(0)
			loopstrLinklist=match.SubMatches(1)
			linkArray=conn.Exec("SELECT Label_title,Label_entitle,Label_pic,Label_desc,Label_content,Label_addtime from [dbpre]Labels WHERE Label_Name='"&labelAttrLinklist&"'AND Label_OnOff=1","arr")
			if not isarray(linkArray) then  vnum=-1  else vnum=ubound(linkArray,2)
			ZReg.Pattern=iflabelField
			set matchesfield=ZReg.Execute(loopstrLinklist)
			loopstrTotal=""
			for i=0 to vnum
				loopstrLinklistNew=loopstrLinklist
				for each matchfield in matchesfield
					fieldNameAndAttr=regExpReplace(matchfield.SubMatches(0),"[\s]+",chr(32))
					fieldNameAndAttr=trim(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"
							loopstrLinklistNew=replaceStr(loopstrLinklistNew,matchfield.value,repnul(linkArray(0,i)))
						case "entitle"
							loopstrLinklistNew=replaceStr(loopstrLinklistNew,matchfield.value,repnul(linkArray(1,i)))
						case "pic"
							loopstrLinklistNew=replaceStr(loopstrLinklistNew,matchfield.value,repnul(linkArray(2,i)))								
						case "desc"
							loopstrLinklistNew=replaceStr(loopstrLinklistNew,matchfield.value,repnul(linkArray(3,i)))
						case "content"							
							loopstrLinklistNew=replaceStr(loopstrLinklistNew,matchfield.value,decode(repnul(linkArray(4,i))))							
						case "date"
							loopstrLinklistNew=replaceStr(loopstrLinklistNew,matchfield.value,repnul(linkArray(5,i)))
					end select
				next
				loopstrTotal=loopstrTotal&loopstrLinklistNew
			next
			closers rs
			set matchesfield=nothing
			Zcontent=replaceStr(Zcontent,match.value,loopstrTotal)
			zCateData.removeAll
		next
		set matches=nothing		
	End Function
	
	Function Parsepics()
		on error resume next
		If Not(IfStrIn(ZContent,"{/pics}")) Then Exit Function
		dim rs,sql,img,imgs,title,titles,labelRule,labelRuleField,match,matches
		dim a_id,b_id,c_id,m_num,num,loopstrNew,i
		a_id = empty	:	b_id = empty	:	c_id = empty
		
		labelRule="{pics:([\s\S]*?)}([\s\S]*?){/pics}"
		Zreg.Pattern=labelRule
		set matches=Zreg.Execute(ZContent)			
		for each match in matches
			loopstrNew = ""
			num = 0		
			a_id = parseArr(match.SubMatches(0))("aid")
			b_id = parseArr(match.SubMatches(0))("bid")
			c_id = parseArr(match.SubMatches(0))("cid")
			m_num = parseArr(match.SubMatches(0))("num")	:	m_num=isnum(m_num)
			if m_num=0 then m_num = 100			
		    if not(isnul(a_id) and isnul(b_id) and isnul(c_id)) then
			  if not isnul(a_id) then sql = "select A_picsurl,A_picsname from [dbpre]about where aid=" & a_id
			  if not isnul(b_id) then sql = "select B_picsurl,B_picsname from [dbpre]brand where bid=" & b_id
			  if not isnul(c_id) then sql = "select C_picsurl,C_picsname from [dbpre]Content where cid=" & c_id			
				  set rs = dbsqlr1(sql)		
				  if not rs.eof then
					  img=rs(0)
					  title=rs(1)
				  end if				 
				  closers rs
				  set rs = nothing						
				  imgs = split(img,",")	
				  titles=split(title&",,,,,,,",",")	
				  for i = 0 to ubound(imgs)	 				  	 
				  	if not isnul(imgs(i)) then						
					  loopstrNew = loopstrNew & match.SubMatches(1)
					  loopstrNew =  replace(loopstrNew,"[pics:pic]",repkong(imgs(i)))
					  loopstrNew =  replace(loopstrNew,"[pics:name]",repkong(titles(i)))
					  loopstrNew =  replace(loopstrNew,"[pics:title]",repkong(titles(i)))
					  loopstrNew = replace(loopstrNew,"[pics:i]",i+1)
					  loopstrNew = replace(loopstrNew,"[pics:j]",i)	
					 end if			 	
				  next				 
			  ZContent=replaceStr(ZContent,match.value,loopstrNew)
			end if
		next
	End Function

	'解析if
	Public Function parseIf(str)
		on error resume next
		if not ifStrin(Zcontent,"{if"&str&":") then Exit Function
		dim mif,matchesIf,strIf,strThen,strThen1,strElse1,iflabel2,iflabel3
		dim ifFlag,ElseArray,ElseIfSubArray,ElseArrayLen,ReStr,ElseLen,strElseIf,strElseIfThen,elseIfFlag
		iflabel="{if"&str&":([\s\S]+?)}([\s\S]*?){end\s+if"&str&"}"
		iflabel2="{elseif"&str&""
		iflabel3="{else"&str&"}"
		elseIfFlag=false
		Zreg.Pattern=iflabel
		set matchesIf=Zreg.Execute(Zcontent)
		for each mif in matchesIf 

			strIf=mif.SubMatches(0):strThen=mif.SubMatches(1)
			if instr(strThen,iflabel2)>0 then
				ElseArray=split(strThen,iflabel2)
				ElseArrayLen=ubound(ElseArray)
				ElseIfSubArray=split(ElseArray(ElseArrayLen),iflabel3)
				ReStr=ElseIfSubArray(1)
				Execute("if "&strIf&" then ReStr=ElseArray(0)")
				for ElseLen=1 to ElseArrayLen-1
					strElseIf=getSubStrByFromAndEnd(ElseArray(ElseLen),":","}","")
					strElseIfThen=getSubStrByFromAndEnd(ElseArray(ElseLen),"}","","start")
					Execute("if "&strElseIf&" then ReStr=strElseIfThen")
					Execute("if "&strElseIf&" then elseIfFlag=true else  elseIfFlag=false")
					if elseIfFlag then exit for
				next
				Execute("if "&getSubStrByFromAndEnd(ElseIfSubArray(0),":","}","")&" then ReStr=getSubStrByFromAndEnd(ElseIfSubArray(0),""}"","""",""start""):elseIfFlag=true")
				Zcontent=replace(Zcontent,mif.value,ReStr)
			else 
				if instr(strThen,"{else"&str&"}")>0 then 
					strThen1=split(strThen,iflabel3)(0)
					strElse1=split(strThen,iflabel3)(1)
					Execute("if "&strIf&" then ifFlag=true else ifFlag=false")
					if err then die "判断标签有误请修正<br>"&strIf
					if ifFlag then Zcontent=replace(Zcontent,mif.value,strThen1) else Zcontent=replace(Zcontent,mif.value,strElse1)
				else						
					Execute("if "&strIf&" then ifFlag=true else ifFlag=false")
					if err then die "判断标签有误请修正<br>"&strIf
					if ifFlag then Zcontent=replace(Zcontent,mif.value,strThen) else Zcontent=replace(Zcontent,mif.value,"")
				end if
			end if
			elseIfFlag=false
		next
		set matchesIf=nothing			
		if ifStrin(Zcontent,"{if1:") then parseIf("1") else Exit Function
		if ifStrin(Zcontent,"{if2:") then parseIf("2") else Exit Function
		if ifStrin(Zcontent,"{if3:") then parseIf("3") else Exit Function
		if ifStrin(Zcontent,"{if4:") then parseIf("4") else Exit Function
		if ifStrin(Zcontent,"{if5:") then parseIf("5") else Exit Function		
	End Function
	
	'解析时间字段
	Public Function parseformatDate()
		if not ifStrin(Zcontent,"{formatdate:") then Exit Function
		dim Lenpage,labelRule,labelRuleField,matches,match,str,num
		labelRule = "{formatdate:([\s\S]*?)}"
		Zreg.Pattern = labelRule
		set matches = Zreg.Execute(Zcontent)
		for each match in matches
			labelRuleField=match.SubMatches(0)
			if ifstrin(labelRuleField,",") then 
				str=split(labelRuleField,",")(0) 
				num=split(labelRuleField,",")(1) 
			else
				str=labelRuleField
				num=1
			end if
			Zcontent=replaceStr(Zcontent,match.value,formatDate(str,num))
		next
	End Function
	
	'解析左侧截取字符
	Public Function parseleftstr()
		if not ifStrin(Zcontent,"{leftstr:") then Exit Function
		dim Lenpage,labelRule,labelRuleField,matches,match,str,num
		labelRule = "{leftstr:([\s\S]*?)}"
		Zreg.Pattern = labelRule
		set matches = Zreg.Execute(Zcontent)
		for each match in matches
			labelRuleField=match.SubMatches(0)
			if ifstrin(labelRuleField,",") then 
			str=split(labelRuleField,",")(0) 
			num=split(labelRuleField,",")(1) 
			else
			str=labelRuleField
			num=10
			end if
			Zcontent=replaceStr(Zcontent,match.value,leftStr(str,num))
		next
	End Function
	
	'解析隐藏字符
	Public Function parsehidestr()
		if not ifStrin(Zcontent,"{hidestr:") then Exit Function
		dim Lenpage,labelRule,labelRuleField,matches,match,str,num
		labelRule = "{hidestr:([\s\S]*?)}"
		Zreg.Pattern = labelRule
		set matches = Zreg.Execute(Zcontent)
		for each match in matches
			labelRuleField=match.SubMatches(0)
			if ifstrin(labelRuleField,",") then 
			str=split(labelRuleField,",")(0) 
			num=split(labelRuleField,",")(1) 
			else
			str=labelRuleField
			num=3
			end if
			Zcontent=replaceStr(Zcontent,match.value,hidestr(str,num))
		next
	End Function

	'解析统计数量{count:sid,5},{count:brand,小米},{count:tag,小米}
	Public Function parsecounts()
		on error resume next
		if not ifStrin(Zcontent,"{count:") then Exit Function
		dim Lenpage,labelRule,labelRuleField,matches,match,str,id,num
		labelRule = "{count:([\s\S]*?)}"
		Zreg.Pattern = labelRule
		set matches = Zreg.Execute(Zcontent)
		for each match in matches
			labelRuleField=match.SubMatches(0)
			if ifstrin(labelRuleField,",") then 
				str=split(labelRuleField,",")(0) 
				id=split(labelRuleField,",")(1) 
				select case str
					case "sort" :	num=dbcount("[dbpre]content,[dbpre]sort","C_OnOff=1 and sid=C_sid and  ','+S_path+',' like '%,"&id&",%'")
					case "brand" :	num=dbcount("[dbpre]content","C_OnOff=1 and C_Brand ='"&id&"'")
					case "tag" :	num=dbcount("[dbpre]content","C_OnOff=1 and C_Tag like '%"&id&"%'")
					case "sql"
						num=dbsql(id)(0)
						if err then echo "统计标签中的sql语句不正确："&id
				end select
			else
				num=""
			end if
			if num=0 then num=""
			Zcontent=replaceStr(Zcontent,match.value,num)
		next
	End Function
	
	'解析广告
	Public Function parseAdLoop()
		if not ifstrin(Zcontent,"{cms:ad") then Exit Function
		dim Lenpage,TypeId,strPagelist,lsize,rsObj,labelRule,labelRuleField,labelRulePagelist,matches,match,labelStr,loopStr,labelArr,lorder,orderStr,sperStrs,spec,sperStr,title,whereStr,AdArray,loopstrAd,arri,arrl,loopstrAdpf,loopstrAddl,loopstrAdtc,i,a,b,c

		labelRule = "{cms:ad([\s\S]*?)}"
		Zreg.Pattern = labelRule
		set matches = Zreg.Execute(Zcontent)
		loopstrad=""
		for each match in matches
			whereStr=chr(32)&"adOnOff=1 and adID="&match.SubMatches(0)
			adArray=conn.Exec("select adName,adClass,adImg,adLink,adWidth,adHeight,adStime,adEtime,adContent from [dbpre]Ad  where "&whereStr&"","arr")
			'die "select adName,adClass,adImg,adLink,adWidth,adHeight,adStime,adEtime,adContent from [dbpre]Ad  where "&whereStr&""
			if isarray(adArray) then
				a=cdate(now())
				b=cdate(adArray(6,0))
				c=cdate(adArray(7,0))
				if datediff("s",b,a)>0 and datediff("s",a,c)>0 then				
					loopstrad=loadfile(sitepath&"plugins/ad/"&adArray(1,0)&"/index.html")
 					  loopstrad=replace(loopstrad,"[title]",repnul(adArray(0,0)))
					  loopstrad=replace(loopstrad,"[width]",repnul(adArray(4,0)))
					  loopstrad=replace(loopstrad,"[height]",repnul(adArray(5,0)))
					  loopstrad=replace(loopstrad,"[pic]",repnul(adArray(2,0)))
					  loopstrad=replace(loopstrad,"[link]",repnul(adArray(3,0)))
					  loopstrad=replace(loopstrad,"[content]",repnul(adArray(8,0)))	
				zcontent=replaceStr(zcontent,match.value,loopstrad)				 
				end if
			end if
			zcontent=replaceStr(zcontent,match.value,"")
		next
	End Function
	
	'解析单页模板
	Function Parseabout()	
		'on error resume next
		dim sql,rs,aboutcontent,sperStrs,spec
		if sid=0 then sid=id
		sql="select * from [dbpre]about a, cms_Sort b where A_sid=sid and S_OnOff=1 and sid="&sid
		set rs=dbsql(sql)
		if rs.eof then	goto404("单页内容不存在或未审核，请确认")		
		Zcontent=replaceStr(Zcontent,"[about:id]",rs("AID"))		
		Zcontent=replaceStr(Zcontent,"[about:link]",sitepath&"about/"&linkmark&rs("A_SID")&"_1"&siteExt)
		Zcontent=replaceStr(Zcontent,"{cms:link}",sitepath&"about/"&linkmark&rs("A_SID")&"_1"&siteExt)
		Zcontent=replaceStr(Zcontent,"[about:name]",repnul(rs("S_name")))	
		Zcontent=replaceStr(Zcontent,"[about:enname]",repnul(rs("S_enname")))
		Zcontent=replaceStr(Zcontent,"[about:title]",repnul(rs("A_Name")))
		Zcontent=replaceStr(Zcontent,"[about:entitle]",repnul(rs("A_enName")))
		Zcontent=replaceStr(Zcontent,"[about:desc]",repnul(rs("A_Desc")))		
		Zcontent=replaceStr(Zcontent,"[about:order]",repnul(rs("A_order")))		
		Zcontent=replaceStr(Zcontent,"{cms:psid}",rs("S_pid"))		
		Zcontent=replaceStr(Zcontent,"{cms:sid}",sid)		
		Zcontent=replaceStr(Zcontent,"{cms:sname}",rs("S_Name"))
		Zcontent=replaceStr(Zcontent,"{cms:senname}",repnul(rs("S_enname")))
		Zcontent=replaceStr(Zcontent,"{cms:tsid}",rs("S_tid"))		
		Zcontent=replaceStr(Zcontent,"[about:pagetitle]",repnul(rs("A_name")))
		Zcontent=replaceStr(Zcontent,"[about:pagekeys]",iif(isnul(rs("A_Key")),Zset.sitekeys,rs("A_Key")))	
		Zcontent=replaceStr(Zcontent,"[about:pagedesc]",iif(isnul(rs("A_Desc")),Zset.sitedesc,replacestr(rs("A_Desc"),"</br>","")))
		Zcontent=replaceStr(Zcontent,"[about:date]",repnul(rs("A_addtime")))
		Zcontent=replaceStr(Zcontent,"[about:edate]",repnul(rs("A_EditTime")))
		Zcontent=replaceStr(Zcontent,"[about:visits]","<script src="""&sitePath&"inc/cms_Visits.asp?Aid="&rs("aid")&"""></script>"&repnul(rs("A_Visits")))
		Zcontent=replaceStr(Zcontent,"[about:pic]",repnul(rs("A_PIC")))
		Zcontent=replaceStr(Zcontent,"[about:pics]",repnul(rs("A_picsurl")))
		Zcontent=replaceStr(Zcontent,"[about:picsname]",repnul(rs("A_picsname")))
		aboutcontent=replacekey(decode(rs("A_content")))
		sperStrs=conn.exec("select custom from [dbpre]content_custom where customOnOff=1 and customType='about'  Order by customID Asc", "arr")			
		if isarray(sperStrs) then
			for each spec in sperStrs
				Zcontent=ReplaceStr(Zcontent,"[about:"&spec&"]",repnul(decode(rs(spec))))
			next
		end if		
	    closers sperStrs
		closers rs
		if ifStrin(aboutcontent,"{list:page}") then	
			dim parr,j,tempArr,pageStr
			tempArr=split(aboutcontent,"{list:page}")
			parr=ubound(tempArr)+1
			page=isnum(page)
			if parr=0 then parr=1
			dim htmlfilename,htmlPath
			htmlfilename=""&linkmark&sid
			pageStr=""
			if Page<1 then Page=1 : end if
			if Page>parr then Page=parr : aspgo sitepath&"about/"&linkmark&sid&"_"&parr&".html"
			pagestr="<link rel='stylesheet' type='text/css' href='"&pluginspath&"pagesize/pagesize1.css'/><div id='pagesize'>"&getpageNumber(Page,5,parr,"about",sid,htmlfilename)&"</div>"						
			Zcontent=replaceStr(Zcontent,"[about:content]",tempArr(Page-1)+pageStr)
			Parseabout=Zcontent
		else 
			Zcontent=replaceStr(Zcontent,"[about:content]",aboutcontent)
			Parseabout=Zcontent
		end if
	End Function
	
		'解析品牌模板
	Function Parsebrand()	
		on error resume next
		dim sql,rs,brandcontent,sperStrs,spec
		sql="select * from [dbpre]brand where B_onOff=1 and bid="&id
		set rs=dbsql(sql)
		if rs.eof then 	goto404("品牌内容不存在或未审核，请确认")	
		Zcontent=replaceStr(Zcontent,"[brand:id]",repnul(rs("BID")))			
		Zcontent=replaceStr(Zcontent,"[brand:link]",sitepath&"brand/"&linkmark&rs("BID")&"_1"&siteExt)
		Zcontent=replaceStr(Zcontent,"{cms:link}",sitepath&"brand/"&linkmark&rs("BID")&"_1"&siteExt)
		Zcontent=replaceStr(Zcontent,"[brand:pagetitle]",repnul(rs("B_Name")))
		Zcontent=replaceStr(Zcontent,"[brand:pagekey]",iif(isnul(rs("B_Key")),Zset.sitekeys,rs("B_Key")))	
		Zcontent=replaceStr(Zcontent,"[brand:desc]",repnul(rs("B_Desc")))
		Zcontent=replaceStr(Zcontent,"[brand:pagedesc]",iif(isnul(rs("B_Desc")),Zset.sitedesc,rs("B_Desc")))
		Zcontent=replaceStr(Zcontent,"[brand:entitle]",repnul(rs("B_enname")))	
		Zcontent=replaceStr(Zcontent,"[brand:title]",repnul(rs("B_Name")))
		Zcontent=replaceStr(Zcontent,"[brand:name]",repnul(rs("B_Name")))
		Zcontent=replaceStr(Zcontent,"[brand:date]",repnul(rs("B_addtime")))
		Zcontent=replaceStr(Zcontent,"[brand:pic]",iif(isnul(rs("B_PIC")),sitePath&"Images/nopic.gif",rs("B_PIC")))
		Zcontent=replaceStr(Zcontent,"[brand:pics]",repnul(rs("B_picsUrl")))
		Zcontent=replaceStr(Zcontent,"[brand:picsname]",repnul(rs("B_picsName")))
		Zcontent=replaceStr(Zcontent,"[brand:url]",repnul(rs("B_URL")))
		Zcontent=replaceStr(Zcontent,"[brand:visits]","<script src="""&sitePath&"inc/cms_Visits.asp?bid="&rs("bID")&"""></script>"&repnul(rs("B_Visits")))
		Zcontent=replaceStr(Zcontent,"[brand:content]",replacekey(decode(repnul(rs("B_content")))))		
		sperStrs=conn.exec("select custom from [dbpre]content_custom where customOnOff=1 and customType='brand'  Order by customID Asc", "arr")			
		if isarray(sperStrs) then
			for each spec in sperStrs
				Zcontent=ReplaceStr(Zcontent,"[brand:"&spec&"]",repnul(decode(rs(spec))))
			next
		end if		
	    closers sperStrs
		closers rs
		Parsebrand=Zcontent
	End Function

'解析内容详细页
	Public Function ParseCcontentid()
	dim sql,i,TempArray,FieldType,contentLink,sperStrs
	Dim CID,Csid, LanguageID, GroupID, Exclusive, Title, Title2, TitleColor, IsOutLink, OutLink, Author, ContentSource, Contentnew, C_OnOff, IsTop, IsRecommend, IsPic, IsHeadline, IsFeatured, ContentOrder, IsGenerated, Visits, AddTime, newspics, pic, PageTitle, Pagekeys, PageDesc, C_PageName, spec, EditTime,IsComment,Star,SortType,SortURL,S_Folder,SortFileName,SortName,sortenname,C_Folder,C_FileName,SortTemplate,ParentID,Topsid,newscontent,Brand,brandid,tagenname,productpics,ContentTag
	if not isnul(id) then	
	sql="select *,S_name,S_enname,S_PID,S_TID,S_Pic,S_ico,S_other1,S_other2 from [dbpre]Content,cms_Sort where sid=C_SID and CID="&id
		Dim rs : Set rs = dbsqlr1(sql)
		if rs.eof then 	goto404("内容页面不存在，请确认")	
		C_OnOff=rs("C_OnOff")	
		Title2=rs("C_Title2")
		if C_OnOff<>1 and isnul(getsession("adminid")) and Title2<>getsession("username") then	goto404("此内容未审核")	
			CID=id
			LanguageID=rs("C_LID")
			Csid=rs("C_sid")
			GroupID=rs("C_GID")			
			Title=rs("C_Title")			
			TitleColor=rs("C_Color")
			OutLink=rs("C_Link")
			Brand=rs("C_Brand")
			ContentTag=rs("C_Tag")
			Contentnew=decode(rs("C_Content"))
			IsTop=rs("IsTop")		
			Ispic=rs("Ispic")		
			IsHeadline=rs("Isgood")			
			ContentOrder=rs("C_Order")		
			Visits=rs("C_Visits")		
			AddTime=rs("C_AddTime")	
			pic=rs("C_pic")	:	if isnul(pic) then pic=sitePath&"images/nopic.gif"
			Zcontent=replacestr(Zcontent,"[news:pics]",getsplitlink(rs("C_picsurl"),rs("C_picsname"),"pic"))	
			Zcontent=ReplaceStr(Zcontent,"[news:down]",getsplitlink(rs("C_DownUrl"),rs("C_DownName"),"down"))	
			Zcontent=ReplaceStr(Zcontent,"[news:downurl]",endstr(repnul(rs("C_DownUrl")),","))
			Zcontent=ReplaceStr(Zcontent,"[news:downname]",endstr(repnul(rs("C_DownName")),","))		
			
			PageTitle=rs("C_pageTitle")
			Pagekeys=rs("C_pageKey")		
			PageDesc=rs("C_PageDesc")
			CPageName=rs("C_PageName")	
			Star=rs("C_Star")		
			Zcontent=ReplaceStr(Zcontent,"[news:id]",CID)
			Zcontent=ReplaceStr(Zcontent,"[news:gid]",repnul(GroupID))
			
			Zcontent=ReplaceStr(Zcontent,"[news:sname]",repnul(rs("S_name")))
			Zcontent=ReplaceStr(Zcontent,"[news:senname]",repnul(rs("S_enname")))
			Zcontent=ReplaceStr(Zcontent,"[news:sid]",repnul(Csid))
			Zcontent=ReplaceStr(Zcontent,"[news:slink]",getSortLink(rs("c_Type"),Csid,rs("s_Url"),rs("s_Folder"),rs("s_FileName"),rs("S_GID"),rs("S_Exc")))
			Zcontent=ReplaceStr(Zcontent,"[news:psid]",repnul(rs("S_PID")))
			Zcontent=ReplaceStr(Zcontent,"[news:tsid]",repnul(rs("S_TID")))
			Zcontent=ReplaceStr(Zcontent,"[news:spic]",repnul(rs("S_Pic")))
			Zcontent=ReplaceStr(Zcontent,"[news:sico]",repnul(rs("S_ico")))
			Zcontent=ReplaceStr(Zcontent,"[news:sother1]",repnul(rs("S_other1")))
			Zcontent=ReplaceStr(Zcontent,"[news:sother2]",repnul(rs("S_other2")))
			
			Zcontent=ReplaceStr(Zcontent,"[news:title]",iif(C_OnOff<>1,"[未审核]"&Title,Title))
			Zcontent=ReplaceStr(Zcontent,"[news:titlecolor]",repnul(TitleColor))
			Zcontent=ReplaceStr(Zcontent,"[news:brand]",repnul(Brand))
			if ifstrin(Zcontent,"[news:brandlink]") and not isnul(Brand) then			
				brandid=dbselect("[dbpre]brand","bid","B_Name='"&Brand&"'") 
				Zcontent=ReplaceStr(Zcontent,"[news:brandlink]",iif(isnul(Brand),"",sitepath&"brand/"&linkmark&brandid&"_1"&siteExt))	
			else
				Zcontent=ReplaceStr(Zcontent,"[news:brandlink]","")	
			end if		
			
			Zcontent=ReplaceStr(Zcontent,"[news:date]",repnul(Addtime))
			Zcontent=ReplaceStr(Zcontent,"[news:visits]","<script src="""&sitePath&"inc/cms_Visits.asp?cid="&CID&"""></script>")
			Zcontent=ReplaceStr(Zcontent,"[news:tag]",gettaglink(ContentTag,""))
			productpics="<script type='text/javascript' src='"&pluginspath&"productpics/smoothproducts.min.js'></script><link rel='stylesheet' href='"&pluginspath&"productpics/smoothproducts.css'><div class='sp-loading'><img src='"&pluginspath&"productpics/loading.gif' alt=''>载入中</div><div class='sp-wrap'>"&newspics&"</div><script type='text/javascript'>$(window).load(function() {$('.sp-wrap').smoothproducts();});</script>"      
			
			Zcontent=ReplaceStr(Zcontent,"[news:productpics]",repnul(productpics))
			Zcontent=ReplaceStr(Zcontent,"[news:istop]",repnul(rs("istop")))
			Zcontent=ReplaceStr(Zcontent,"[news:ispic]",repnul(rs("IsPic")))
			Zcontent=ReplaceStr(Zcontent,"[news:isgood]",repnul(rs("Isgood")))
			Zcontent=ReplaceStr(Zcontent,"[news:isoffer]",repnul(rs("isoffer")))
			Zcontent=ReplaceStr(Zcontent,"[news:issell]",repnul(rs("issell")))
			contentLink=getContentLink(Csid,CID,S_Folder,GroupID,C_Folder,C_FileName,outlink,CPageName,rs("C_type"))
			Zcontent=ReplaceStr(Zcontent,"[news:link]",contentLink)
			Zcontent=ReplaceStr(Zcontent,"{cms:link}",contentLink)	
			Zcontent=ReplaceStr(Zcontent,"[news:desc]",iif(isnul(PageDesc),left(dropHtml(rs("C_Content")),100),PageDesc))
			Zcontent=ReplaceStr(Zcontent,"[news:pic]",iif(isnul(pic),sitePath&"images/nopic.gif",pic))	
			Zcontent=ReplaceStr(Zcontent,"[news:spic]",iif(isnul(pic),sitepath&"images/nopic.gif",sitepath&uploadpath&"images/"&cid&".jpg"))			
			Zcontent=ReplaceStr(Zcontent,"[news:pagetitle]",iif(isnul(PageTitle),Title,PageTitle))	
			Zcontent=ReplaceStr(Zcontent,"[news:pagekeys]",iif(isnul(Pagekeys),zset.sitekeys,Pagekeys))	
			Zcontent=ReplaceStr(Zcontent,"[news:pagedesc]",iif(isnul(pagedesc),zset.sitedesc,replacestr(pagedesc,"</br>","")))
			
				
			Zcontent=replaceStr(Zcontent,"[news:prev]",getprev(sid,CID,1))
			Zcontent=replaceStr(Zcontent,"[news:prevlink]",getprev(sid,CID,2))
			Zcontent=replaceStr(Zcontent,"[news:prevtitle]",getprev(sid,CID,3))
			Zcontent=replaceStr(Zcontent,"[news:prevpic]",getprev(sid,CID,4))
			Zcontent=replaceStr(Zcontent,"[news:prevclass]",getprev(sid,CID,5))
			Zcontent=replaceStr(Zcontent,"[news:next]",getnext(sid,CID,1))
			Zcontent=replaceStr(Zcontent,"[news:nextlink]",getnext(sid,CID,2))
			Zcontent=replaceStr(Zcontent,"[news:nexttitle]",getnext(sid,CID,3))
			Zcontent=replaceStr(Zcontent,"[news:nextpic]",getnext(sid,CID,4))
			Zcontent=replaceStr(Zcontent,"[news:nextclass]",getnext(sid,CID,5))
		sperStrs=conn.exec("select custom from [dbpre]content_custom where customOnOff=1  and customType not in('about','brand','gbook') Order by customOrder Asc,customID", "arr")			
		if isarray(sperStrs) then
			for each spec in sperStrs
				Zcontent=ReplaceStr(Zcontent,"[news:"&spec&"]",repnul(decode(rs(spec))))
			next
		end if		
	    closers sperStrs
	  closers rs
	  newscontent=replacekey(Contentnew)
		if ifStrin(newscontent,"{list:page}") then	
			dim parr,j,tempArr,pageStr
			tempArr=split(newscontent,"{list:page}")
			parr=ubound(tempArr)+1
			page=isnum(page)
			if parr=0 then parr=1
			dim htmlfilename,htmlPath
			htmlfilename=""&linkmark&sid&"_"&id
			pageStr=""
			if Page<1 then Page=1 : end if
			if Page>parr then Page=1
			pagestr="<link rel='stylesheet' type='text/css' href='"&pluginspath&"pagesize/pagesize1.css'/><div id='pagesize'>"&getpageNumber(Page,5,parr,"news",sid,htmlfilename)&"</div>"						
			Zcontent=replaceStr(Zcontent,"[news:content]",tempArr(Page-1)+pageStr)
			ParseCcontentid=Zcontent
		else 
			Zcontent=replaceStr(Zcontent,"[news:content]",replacekey(newscontent))
			ParseCcontentid=Zcontent
		end if
	end if	
	End Function
	
	public function show()	
	Zcontent=replace(Zcontent,"{cms:sitepath}",sitepath)
	if sitepath<>"/" then Zcontent=replace(Zcontent,"/upload",sitepath&"upload")
	echo gzip(Zcontent)
	if showtime=1 then echo "<span class='runtime'>执行时间"& runTime &"&#31186</span>"
	end function
	
	Function getprev(sid,id,i_type)
		on error resume next
		dim linkStr,rs	
		linkStr=""
		set rs=dbsql("select top 1 CID,C_Title,S_Folder,C_GID,C_Folder,C_FileName,C_link,C_PageName,S_Type,C_pic from [dbpre]Content as a,cms_Sort as b where C_sid=sid and C_OnOff=1 and CID<"&Id&" and C_sid="&sid&" order by CID desc")
		if not rs.eof then 
			select case i_type	
				case 1	
					linkStr="<a class='newsprev' title='"&str_prevcontent&" "&rs(1)&"' href='"&getContentLink(sid,rs("CID"),rs("S_Folder"),rs("C_GID"),rs("C_Folder"),rs("C_FileName"),rs("C_Link"),rs("C_PageName"),rs("S_Type"))&"'>"&rs(1)&"</a>"
				case 2
					linkStr=getContentLink(sid,rs("CID"),rs("S_Folder"),rs("C_GID"),rs("C_Folder"),rs("C_FileName"),rs("C_Link"),rs("C_PageName"),rs("S_Type"))
				case 3
					linkStr=rs(1)
				case 4
					linkStr=iif(isnul(rs("C_pic")),sitepath&"images/nopic.gif",rs("C_pic"))
				case 5
					linkStr="newsprev"
				case else
					linkStr=""
			end select
		else
			select case i_type	
				case 1	
					linkStr="<span class='nolink'>"&str_no&str_prevcontent&"</span>"
				case 2
					linkStr="javascript:void(0)"
				case 3
					linkStr=str_no&str_prevcontent
				case 4
					linkStr=sitepath&"images/nopic.gif"
				case 5
					linkStr="noprev"
				case else
					linkStr=""
			end select
		end if
		closers rs
		getprev = linkStr		
	End Function 
		
	Function getnext(sid,id,i_type)
		on error resume next
		dim linkStr,rs
		linkStr=""
		set rs=dbsql("select top 1 CID,C_Title,S_Folder,C_GID,C_Folder,C_FileName,C_link,C_PageName,S_Type,C_pic from [dbpre]Content as a,cms_Sort as b where C_sid=sid and C_OnOff=1 and CID>"&Id&" and C_sid="&sid&" order by CID asc")
		if not rs.eof then 
			select case i_type	
				case 1	
					linkStr="<a class='newsnext'  title='"&str_nextcontent&" "&rs(1)&"' href='"&getContentLink(sid,rs("CID"),rs("S_Folder"),rs("C_GID"),rs("C_Folder"),rs("C_FileName"),rs("C_link"),rs("C_PageName"),rs("S_Type"))&"'>"&rs(1)&"</a>"
				case 2
					linkStr=getContentLink(sid,rs("CID"),rs("S_Folder"),rs("C_GID"),rs("C_Folder"),rs("C_FileName"),rs("C_link"),rs("C_PageName"),rs("S_Type"))
				case 3
					linkStr=rs(1)
				case 4
					linkStr=iif(isnul(rs("C_pic")),sitepath&"images/nopic.gif",rs("C_pic"))
				case 5
					linkStr="newsnext"
				case else
					linkStr=""
			end select
		else
			select case i_type	
				case 1	
					linkStr="<span class='nolink'>"&str_no&str_nextcontent&"</span>"
				case 2
					linkStr="javascript:void(0)"
				case 3
					linkStr=str_no&str_nextcontent
				case 4
					linkStr=sitepath&"images/nopic.gif"
				case 5
					linkStr="nonext"
				case else
					linkStr=""
			end select
		end if
		closers rs
		getnext = linkStr		
	End Function 
		
	
	'获取面包屑
	Function getTopType(sid)	
		on error resume next
		if sid>0 then
			Dim tempStr,rs
			set rs = dbsqlr1("select S_PID,S_Name,S_Type,sid,S_Url,S_Folder,S_FileName,S_GID,S_Exc from [dbpre]Sort where sid="&sid&"")
			tempStr=tempStr&" > <a href="""&getSortLink(rs("S_Type"),rs("sid"),rs("S_Url"),rs("S_Folder"),rs("S_FileName"),rs("S_GID"),rs("S_Exc"))&""">"&rs("S_Name")&"</a>"
			if rs("S_PID")<>0 then tempStr=getTopType(rs("S_PID"))&tempStr
			closers rs
			getTopType=tempStr
		end if
	End Function 
	
	'获取Tag标签链接
	Function gettaglink(str,val)	
	dim data,i,strs,active,ins
	  if isnul(str) then gettaglink="" : exit function
	  if dbType=1 then ins="CHARINDEX(rtrim(T_Name),'"&str&"')>0 and" else ins="instr(',"&str&",',','&T_Name&',') and"
		data=dbload("[dbpre]tag","tid,t_name,T_enName","",""&ins&" T_OnOff=1","T_order asc,tid desc")
		if ubound(data)>=0 then
			for i=0 to  ubound(data,2)
				 if data(1,i)=val then active="active" else active=""
				 strs=strs&" <a href='"&sitepath&"tag/?tag="&data(2,i)&"' target='_blank' class='taglink  "&active&"'>"&data(1,i)&"</a>"
			next
		end if
		gettaglink=strs 
	end function
	
	'获取导航栏链接
	Function getSortLink(sortType, Sid, sortUrl, sortFolder, sortFileName, GroupID, Exclusive)	
		on error resume next
		sortFolder=replacestr(repnul(sortFolder), "{path}", sitePath)	
		sortFileName=replacestr(repnul(sortFileName), "{sid}", Sid)	
		sortFileName=replacestr(sortFileName, "{page}", "1")	
		sortUrl=replacestr(repnul(sortUrl), "{path}", sitePath)		
		dim abouturl,listurl,urlname
		if isnul(sortUrl) then
		 select case sortType
			case "about" : 	listurl=sitePath&"about/"&linkmark&Sid&"_1"&siteExt	
			case "brand" : 	listurl=sitePath&"brandlist/"&linkmark&Sid&"_1"&siteExt			
			case else	:	listurl=sitePath&"list/"&linkmark&Sid&"_1"&siteExt
		  end select
		else
		 	if sortType="links" then
				if checkstr(sortUrl,"url") then listurl=sortUrl else listurl=replacestr(sitePath&sortUrl,"//","/")
			else
				if runMode=1 then sortUrl=sitePath&"go/?"&sortUrl else  sortUrl=sitePath&linkmark&sortUrl
				listurl=sortUrl
			end if
		end if
		getSortLink=listurl
	End Function
	
	Function getContentLink(Byval sid,Byval Id,Byval SortFolder,Byval GroupID,Byval ContentFolder,Byval ContentFileName,Byval outlink,Byval pageFileName,Byval SortType)
		on error resume next		
		ContentFolder=replacestr(ContentFolder, "{path}", sitePath)	
		ContentFileName=replacestr(ContentFileName, "{sid}", sid)	
		ContentFileName=replacestr(ContentFileName, "{id}", Id)	
		ContentFileName=replacestr(ContentFileName, "{page}", "1")	
		dim contenturl
		contenturl=sitePath&SortType&"/"&linkmark
		dim linkStr,rs
		if isnul(GroupID) or isnull(GroupID) then GroupID=0
		if not isnul(outlink) then
			getContentLink=outlink
		elseif not isnul(PageFileName) then
			getContentLink=contenturl&PageFileName&siteExt
		else
			getContentLink=contenturl&sid&"_"&Id&siteExt
		end if
	End Function
End Class	
		'获取当前页面的相对网站路径
	function getPagePath()
		dim NowPath,Modeltype
		NowPath=getNowPagePath	:	NowPath=replacestr(replacestr(NowPath,"go/",""),"index.asp?","")
		if ifstrin(NowPath,"/") then
			getPagePath=split(NowPath,"/")(1)
		else
			getPagePath=""
		end if		
	end function	

'获得循环列表分页信息
	  Function getpageNumber(Byval NowPage,Byval Lenpage,Byval allPages,Byval linkType,Byval sid, Byval UrlStr)
	  dim pageNumber,pagesStr,i,pageNumberInfo,firstPageLink,prePagelink,nextPagelink,endPageLink,p,jumppagelink,NowPagestr,StartPages,beginPage,EndPage,strPageNumber,newStr
	  'if ifstrin("list,content,about",linkType) and isnul(sid) then goto404 "分页中未获得分类"	  
	  allPages=iif(isnum(allPages)>0,isnum(allPages),1)					
	  NowPage=iif(ifnum(NowPage),isnum(NowPage),1)	:	NowPage=iif(NowPage > allPages,allPages,NowPage)		'当前页码
	  Lenpage=iif(ifnum(Lenpage),isnum(Lenpage),5)	:	Lenpage=iif(Lenpage > allPages,allPages,Lenpage)		'截取字段
			'总页码
	  linkType=iif(isnul(linkType),"list",linkType)														'列表类型
	  StartPages=	iif(Lenpage mod 2=0, Lenpage / 2,clng(Lenpage / 2) - 1) 
	  newStr= replacestr(cleft(UrlStr,"."),sid&"_"&page,"")
  'echop "NowPage:"&NowPage&"<br>"&"Lenpage:"&Lenpage&"<br>"&"allPages:"&allPages&"<br>"&"linkType:"&linkType&"<br>"&"sid:"&sid&"<br>"&"UrlStr:"&UrlStr&"StartPages:"&StartPages
	  if NowPage - StartPages < 1 then	
		  beginPage = 1 : EndPage = Lenpage
	  elseif NowPage - StartPages + Lenpage > allPages  then
		  beginPage = allPages - Lenpage + 1 : EndPage = allPages
	  else 
		  beginPage = NowPage - StartPages : EndPage = NowPage - StartPages + Lenpage - 1
	  end if	  
	  for pagenumber = beginPage  to  EndPage
		  if pagenumber=NowPage then
			  strPageNumber=strPageNumber&"<span class='active'>"&pagenumber&"</span>"			
		  else
			select case linkType			 
			case "list","gbook","tag"  	
 				if Location="brand" then
				  		  strPageNumber=strPageNumber&"<a href='"&sitepath&"brand/"&linkmark&id&"_"&pagenumber&siteExt&"'>"&pagenumber&"</a>" 	
				  elseif Location="screen" then
				  		  strPageNumber=strPageNumber&"<a href='"&linkmark&UrlStr&sid&"_"&pagenumber&siteExt&"'>"&pagenumber&"</a>" 	
				  else			
						  strPageNumber=strPageNumber&"<a href='"&sitepath&linkType&"/?"&sid&"_"&pagenumber&siteExt&"'>"&pagenumber&"</a>" 					
				  end if  
			case "about","news"		
					strPageNumber=strPageNumber&"<a href='"&sitepath&linkType&"/"&UrlStr&"_"&pagenumber&siteExt&"'>"&pagenumber&"</a>" 	
			case "search"
				  dim stype,keys
				  stype=filterPara(getForm("type","both"))
				  keys=filterPara(getForm("keys","both"))
				  strPageNumber=strPageNumber&"<a href='"&linkmark&pagenumber&siteExt&"'>"&pagenumber&"</a>"	
			case "taglist"	
				  strPageNumber=strPageNumber&"<a href='"&linkmark&"tag="&tag&"&page="&pagenumber&"'>"&pagenumber&"</a>"	
			case else
				  if sid="" then
					  strPageNumber=strPageNumber&"<a href="""&linkmark&UrlStr&"_"&pagenumber&siteExt&""">"&pagenumber&"</a>"
				  else
						strPageNumber=strPageNumber&"<a href="""&linkmark&sid&"_"&pagenumber&siteExt&""">"&pagenumber&"</a>"
				  end if
			  end select
		  end if	
	  next	
  
		if NowPage=1 then  
			firstPageLink="<span class='nolink'>"&str_home&"</span>" : prePagelink="<span class='nolink'>"&str_pre&"</span>"
		else
		select case linkType	
			case "list" ,"gbook","tag"
			 	if Location="brand" then  
					firstPageLink="<a href='"&sitepath&"brand/"&linkmark&id&"_1"&siteExt&"'>"&str_home&"</a>" : prePagelink="<a href='"&sitepath&"brand/"&linkmark&id&"_"&NowPage-1&siteExt&"'>"&str_pre&"</a>"		
				elseif Location="screen" then
					firstPageLink="<a href='"&sitepath&linkmark&UrlStr&sid&"_1"&siteExt&"'>"&str_home&"</a>" : prePagelink="<a href='"&linkmark&UrlStr&sid&"_"&NowPage-1&siteExt&"'>"&str_pre&"</a>"
				elseif Location="tag" then
					firstPageLink="<a href='"&sitepath&linkmark&UrlStr&"'>"&str_home&"</a>" : prePagelink="<a href='"&linkmark&UrlStr&"&page="&NowPage-1&"'>"&str_pre&"</a>"
				else				
					firstPageLink="<a href='"&sitepath&linkType&"/?"&sid&"_1"&siteExt&"'>"&str_home&"</a>" : prePagelink="<a href='"&sitepath&linkType&"/?"&sid&"_"&NowPage-1&siteExt&"'>"&str_pre&"</a>"					
				end if	
			case "about","news"
			 	firstPageLink="<a href='"&sitepath&linkType&"/"&UrlStr&"_1"&siteExt&"'>"&str_home&"</a>" : prePagelink="<a href='"&sitepath&linkType&"/"&UrlStr&"_"&NowPage-1&siteExt&"'>"&str_pre&"</a>"						
			case "search" 
				firstPageLink="<a href='"&linkmark&"1'"&siteExt&">"&str_home&"</a>" : prePagelink="<a href='"&linkmark&NowPage-1&siteExt&"'>"&str_pre&"</a>"				
			case "taglist" 
				firstPageLink="<a href='"&linkmark&"tag="&tag&"&page=1'>"&str_home&"</a>" : prePagelink="<a href='"&linkmark&"tag="&tag&"&page="&NowPage-1&"'>"&str_pre&"</a>"						
			case else 	
				firstPageLink="<a href='&page=1'>"&str_home&"</a>" : if NowPage>2 then prePagelink="<a href='&page="&NowPage-1&"'>"&str_pre&"</a>" : else prePagelink="<a href='&page=1'>"&str_pre&"</a>"					
			 end select
		end if 
		if NowPage>=allPages then 
			nextPagelink="<span class='nolink'>"&Str_next&"</span>" : endPageLink="<span class='nolink'>"&str_end&"</span>"
		else
		select case linkType	
			case "list" ,"gbook","tag"
				  if Location="brand" then  
					 nextPagelink="<a href='"&sitepath&"brand/"&linkmark&id&"_"&NowPage+1&siteExt&"'>"&Str_next&"</a>"  : endPageLink="<a href='"&sitepath&"brand/"&linkmark&id&"_"&allPages&siteExt&"'>"&str_end&"</a>"				
				  elseif Location="screen" then
					nextPagelink="<a href='"&linkmark&UrlStr&sid&"_"&NowPage+1&siteExt&"'>"&Str_next&"</a>" : endPageLink="<a href='"&UrlStr&sid&"_"&allPages&siteExt&"'>"&str_end&"</a>"	
				  elseif Location="tag" then
					nextPagelink="<a href='"&linkmark&UrlStr&"&page="&NowPage+1&"'>"&str_home&"</a>" : prePagelink="<a href='"&linkmark&UrlStr&"&page="&allPages&"'>"&str_pre&"</a>"
				  else				
					 nextPagelink="<a href='"&sitepath&linkType&"/?"&sid&"_"&NowPage+1&siteExt&"'>"&Str_next&"</a>"  : endPageLink="<a href='"&sitepath&linkType&"/?"&sid&"_"&allPages&siteExt&"'>"&str_end&"</a>"				
				  end if	
			case "about","news"	
				nextPagelink="<a href='"&sitepath&linkType&"/"&UrlStr&"_"&NowPage+1&siteExt&"'>"&Str_next&"</a>"  : endPageLink="<a href='"&sitepath&linkType&"/"&UrlStr&"_"&allPages&siteExt&"'>"&str_end&"</a>"		
			case "search" 
				nextPagelink="<a href='"&linkmark&NowPage+1&siteExt&"'>"&Str_next&"</a>" : endPageLink="<a href='"&linkmark&allPages&siteExt&"'>"&str_end&"</a>"	
			case "taglist" 
				nextPagelink="<a href='"&linkmark&"tag="&tag&"&page="&NowPage+1&"'>"&Str_next&"</a>" : endPageLink="<a href='"&linkmark&"tag="&tag&"&page="&allPages&"'>"&str_end&"</a>"					
			case else 
				nextPagelink="<a href='&page="&NowPage+1&"'>"&Str_next&"</a>" : endPageLink="<a href='&page"&allPages&"'>"&str_end&"</a>"
			 end select
		end if
		if allPages>lenpage  then
		pageNumberInfo=firstPageLink&prePagelink&strPageNumber&nextPagelink&endPageLink
		else
		pageNumberInfo=prePagelink&strPageNumber&nextPagelink
		end if	
		getpageNumber=pageNumberInfo
	End Function
	
%>