<!--#Include file="html_Common.Asp"-->
<!--#Include file="html_Template.Asp"-->
<!--#Include file="html_To.Asp"-->
<%
'生成静态Function方法
dim ExplainJS, ConstJs
dim regExpObj, strDictionary, match, matches, matchfield, matchesfield, loopStr, loopstrTotal
dim datafrom, sqlid, taxis
dim idCount, Pagec, Pages, newTotalPage '==信息总数，当前页，分页，总页数

ExplainJS = "<script>window.location.replace('/Maintain.html')</script>"
If mStatus and MobileJump Then
	ConstJs = ConstJs & "<script>if(navigator.platform.indexOf('Win32')<0){window.location.replace('/" & mFolder & "'+window.location.pathname)}</script>"
End If
If EnableCopy Then
	ConstJs = ConstJs & "<style type='text/css' media='screen'>body{ -moz-user-select:none; -webkit-user-select:none;}</style>" & vbCrLf
	ConstJs = ConstJs & "<script type='text/javascript'>" & vbCrLf
	ConstJs = ConstJs & "document.onselectstart=function(e){return false;}" & vbCrLf
	ConstJs = ConstJs & "document.oncontextmenu=function(e){return false;}" & vbCrLf
	ConstJs = ConstJs & "</script>" & vbCrLf
End If

Class MainClass
	dim Content
	
	Function Load(Str)
		Content = Str
	End Function

	'========================单页======================
	Function Apage()
		Set regExpObj = New Regexp
		set strDictionary = server.CreateObject("scripting.dictionary")
	
		regExpObj.IgnoreCase = True
		regExpObj.Global = True
		regExpObj.Pattern = "{keyicms:Apage([\s\S]*?)}([\s\S]*?){/keyicms:Apage}"
	
		set matches = regExpObj.Execute(Content)
		for each match in matches
			labelStr = match.SubMatches(0)
			loopStr = match.SubMatches(1)
	
			set labelArr = ParseArr(labelStr)
			lID = labelArr("ID")
			lOrder = labelArr("Order")
	
			If Ke01 = "PC" Then datawhere = " where ViewFlag"
			If Ke01 = "Mobile" Then datawhere = " where MobileFlag"
	
			If not IsNul(lID) Then
				datawhere = datawhere & " and ID="&lID
			End If
	
			datafrom = "keyicms_Apage"
			Set regExpTwo = New Regexp
			regExpTwo.IgnoreCase = True
			regExpTwo.Global = True
			regExpTwo.Pattern = "\[Apage:([\s\S]*?)\]"
			set matchesfield = regExpTwo.Execute(loopStr)
		
			Set rs = server.CreateObject("adodb.recordset")
			sql = "select * from [" & datafrom & "]" & datawhere & taxis
			rs.open sql, Conn, 1, 2
			If rs.eof Then
				loopstrTotal = Keyicms_Lang_ErrMsg(3)
			Else
				loopstrTotal = ""
				do until rs.eof
					If Ke01 = "PC" Then AutoLink = "/" & ApageDir & "/" & rs("ClassSeo") & Separated & rs("ID") & "." & HTMLName
					If Ke01 = "Mobile" Then AutoLink = "/" & mFolder & "/" & ApageDir & "/" & rs("ClassSeo") & Separated & rs("ID") & "." & HTMLName
					nloopstr = loopStr
					for each matchfield in matchesfield
						FieldNameArr = regExpReplace(matchfield.SubMatches(0), "[\s]+", chr(32))
						FieldNameArr = trim(FieldNameArr)
						m = instr(FieldNameArr, chr(32))
						if  m > 0 then 
							FieldName = left(FieldNameArr, m - 1)
							FieldArr = right(FieldNameArr, len(FieldNameArr) - m)
						else
							FieldName = FieldNameArr
							FieldArr = ""
						end if
						Select Case FieldName
							Case "Link"
								nloopstr = replace(nloopstr, matchfield.value, AutoLink)
							Case "ID"
								nloopstr = replace(nloopstr, matchfield.value, rs("ID"))
							Case "ApageName"
								NameLen = ParseArr(FieldArr)("Len") 
								If cInt(NameLen) > 0 Then
									NameLen = cInt(NameLen)
									Title = StrLeft(rs("ApageName"), NameLen)
								Else
									Title = rs("ApageName")
								End If
								nloopstr = replace(nloopstr, matchfield.value, Title)
							Case "UpdateTime"
								Format = ParseArr(FieldArr)("Format")
								nloopstr = replace(nloopstr, matchfield.value, FormatDate(rs("UpdateTime"), Format))
							Case "Content"
								ContLen = ParseArr(FieldArr)("Len")
								If cInt(ContLen) > 0 Then
									ContLen = cInt(ContLen)
									Cont = StrLeft(RemoveHTML(rs("Content")), ContLen)
								Else
									Cont = RemoveHTML(rs("Content"))
								End If
								nloopstr = replace(nloopstr, matchfield.value, Cont)
						End Select
					next
					loopstrTotal = loopstrTotal & nloopstr
					rs.movenext
				loop
				rs.close : set rs = nothing
			End If
			set matchesfield = nothing
			Content = replace(Content, match.value, loopstrTotal)
			strDictionary.removeAll
		next
	End Function

	'=======================信息=======================
	Function KE01_News(SortID)
		Set regExpObj = New Regexp
		set strDictionary = server.CreateObject("scripting.dictionary")
		regExpObj.IgnoreCase = True
		regExpObj.Global = True
		regExpObj.Pattern = "{keyicms:List([\s\S]*?)}([\s\S]*?){/keyicms:List}"

		set matches = regExpObj.Execute(Content)
		If matches.count > 0 Then
			Call NewsContent(True, SortID)
			Content = ShowPage(Content)
		End If
	End Function

	Function NewsList()
		Set regExpObj = New Regexp
		set strDictionary = server.CreateObject("scripting.dictionary")
		regExpObj.IgnoreCase = True
		regExpObj.Global = True
		regExpObj.Pattern = "{keyicms:NewsList([\s\S]*?)}([\s\S]*?){/keyicms:NewsList}"

		set matches = regExpObj.Execute(Content)
		Call NewsContent(False, "")
	End Function

	Sub NewsContent(ListFlag, SortID)
		for each match in matches
			labelStr = match.SubMatches(0)
			loopStr = match.SubMatches(1)

			set labelArr = ParseArr(labelStr)
			lNum = labelArr("Num")
			lPicFlag = labelArr("PicFlag")
			lNoticeFlag = labelArr("NoticeFlag")
			lOrder = labelArr("Order")
			
			If ListFlag Then lSortID = SortID
			If not ListFlag Then lSortID = labelArr("SortID")
			If lSortID = "" Then
				lSortPath = "0,"
			ElseIf lSortID <> "" Then
				sql = "select * from keyicms_NewsSort where ID=" & lSortID
				If Conn.execute(sql).Eof Then
					Content = replace(Content, match.value, "SortID" & Keyicms_Lang_ErrMsg(0))
					Exit Sub
				Else
					lSortPath = Conn.execute(sql)("SortPath")
				End If
			End If
			If IsNul(lSortPath) Then
				dataSortPath = ""
			Else
				dataSortPath = " and Instr(SortPath ,'" & lSortPath & "')>0"
			End If
			
			dim HideSort
			Set rs = server.CreateObject("adodb.recordset")
			rs.open "select * from keyicms_NewsSort Where not ViewFlag" & dataSortPath, Conn, 1, 2
			while not rs.eof
				HideSort = " and not(Instr(SortPath,'" & rs("SortPath") & "')>0) " & HideSort
				rs.movenext
			wend
			rs.close : set rs = nothing

			If Ke01 = "PC" Then datawhere = " where ViewFlag"
			If Ke01 = "Mobile" Then datawhere = " where MobileFlag"
			
			datawhere = datawhere & dataSortPath
			If lPicFlag = "True" Then
				datawhere = datawhere & " and PicFlag"
			ElseIf lPicFlag = "False" Then
				datawhere = datawhere & " and not PicFlag"
			End IF
			If lNoticeFlag = "True" Then
				datawhere = datawhere & " and NoticeFlag"
			ElseIf lNoticeFlag = "False" Then
				datawhere = datawhere & " and not NoticeFlag"
			End IF
		
			If lOrder="AddTime" Then
				taxis = " Order by AddTime Desc"
			ElseIf lOrder="Notice" Then
				taxis = " Order by NoticeFlag Asc, ID Desc"
			Else
				taxis = " Order by ID Desc"
			End If
			
			datafrom = "keyicms_News"
			Pages = lNum
	
			Dim rs, sql
			if Page = "" then Page = 1

			Set rs = server.CreateObject("adodb.recordset")
			sql = "select * from [" & datafrom & "]" & datawhere & HideSort & taxis

			rs.Open sql, Conn, 1, 1
			idCount = rs.recordcount

			If idCount > 0 Then
				If(idCount Mod Pages = 0)Then
					Pagec = Int(idCount / Pages)
				Else
					Pagec = Int(idCount / Pages) + 1
				End If
				rs.Pagesize = Pages
				totalpage = rs.PageCount
				If Page < 1 Then Page = 1
				If Pagec > 0 Then rs.absolutePage = Page
				For j = 1 To rs.Pagesize
					If rs.EOF Then Exit For
					If j = 1 Then
						sqlid = rs("ID")
					Else
						sqlid = sqlid & "," & rs("ID")
					End If
					rs.movenext
				Next
			End If
			rs.close : set rs = nothing

			If idCount > 0 And sqlid <> "" Then
				Set regExpTwo = New Regexp
				regExpTwo.IgnoreCase = True
				regExpTwo.Global = True
				regExpTwo.Pattern = "\[NewsList:([\s\S]*?)\]"
				set matchesfield = regExpTwo.Execute(loopStr)
	
				Set rs = server.CreateObject("adodb.recordset")
				sql = "select * from [" & datafrom & "] where ID in("& sqlid &") " & taxis

				rs.open sql, Conn, 1, 2
				loopstrTotal = ""
				For i = 1 To rs.recordcount
					If Ke01 = "PC" Then AutoLink = "/"&NewsDir & "/" & rs("ClassSeo") & Separated & rs("ID") & "." & HTMLName
					If Ke01 = "Mobile" Then AutoLink = "/" & mFolder & "/"&NewsDir & "/" & rs("ClassSeo") & Separated & rs("ID") & "." & HTMLName
					nloopstr = loopStr
					for each matchfield in matchesfield
						FieldNameArr = regExpReplace(matchfield.SubMatches(0), "[\s]+", chr(32))
						FieldNameArr = trim(FieldNameArr)
						m = instr(FieldNameArr, chr(32))
						if  m > 0 then 
							FieldName = left(FieldNameArr, m - 1)
							FieldArr = right(FieldNameArr, len(FieldNameArr) - m)
						else
							FieldName = FieldNameArr
							FieldArr = ""
						end if
						Select Case FieldName
							Case "i"
								nloopstr = replace(nloopstr, matchfield.value, i)
							Case "Link"
								nloopstr = replace(nloopstr, matchfield.value, AutoLink)
							Case "SortName"
								SortName = Conn.execute("Select * from keyicms_NewsSort where ID=" & rs("SortID"))("SortName")
								nloopstr = replace(nloopstr, matchfield.value, SortName)
							Case "SortID"
								nloopstr = replace(nloopstr, matchfield.value, rs("SortID"))
							Case "ID"
								nloopstr = replace(nloopstr, matchfield.value, rs("ID"))
							Case "NewsName"
								NameLen = ParseArr(FieldArr)("Len") 
								If cInt(NameLen) > 0 Then
									NameLen = cInt(NameLen)
									Title = StrLeft(rs("NewsName"), NameLen)
								Else
									Title = rs("NewsName")
								End If
								nloopstr = replace(nloopstr, matchfield.value, Title)
							Case "Source"
								nloopstr = replace(nloopstr, matchfield.value, changeNull(rs("Source")))
							Case "SmallPic"
								nloopstr = replace(nloopstr, matchfield.value, changeNull(rs("SmallPic")))
							Case "Color"
								nloopstr = replace(nloopstr, matchfield.value, rs("Color"))
							Case "Bold"
								nloopstr = replace(nloopstr, matchfield.value, rs("Bold"))
							Case "Text"
								TextLen = ParseArr(FieldArr)("Len")
								TextLen = cInt(TextLen)
								nloopstr = replace(nloopstr, matchfield.value, StrLeft(rs("Text"), TextLen))
							Case "UpdateTime"
								Format = ParseArr(FieldArr)("Format")
								nloopstr = replace(nloopstr, matchfield.value, FormatDate(rs("UpdateTime"), Format))
							Case "ClickNumber"
								nloopstr = replace(nloopstr, matchfield.value, rs("ClickNumber"))
							Case "Content"
								ContLen = ParseArr(FieldArr)("Len")
								If cInt(ContLen) > 0 Then
									ContLen = cInt(ContLen)
									Cont = StrLeft(RemoveHTML(rs("Content")), ContLen)
								Else
									Cont = RemoveHTML(rs("Content"))
								End If
								nloopstr = replace(nloopstr, matchfield.value, Cont)
						End Select
					next
					loopstrTotal = loopstrTotal & nloopstr
					rs.movenext
				Next
				rs.close : set rs = nothing
				set matchesfield = nothing
				Set regExpTwo = nothing
			Else
				loopstrTotal = Keyicms_Lang_ErrMsg(1)
			End If
			Content = replace(Content, match.value, loopstrTotal)
			strDictionary.removeAll
		next
		set matches = nothing
	End Sub

	'=======================产品=======================
	Function KE01_Product(SortID)
		Set regExpObj = New Regexp
		set strDictionary = server.CreateObject("scripting.dictionary")
		regExpObj.IgnoreCase = True
		regExpObj.Global = True
		regExpObj.Pattern = "{keyicms:List([\s\S]*?)}([\s\S]*?){/keyicms:List}"

		set matches = regExpObj.Execute(Content)
		if matches.count > 0 then
			Call ProdContent(True, SortID)
			Content = ShowPage(Content)
		end if
	End Function

	Function ProductList()
		Set regExpObj = New Regexp
		set strDictionary = server.CreateObject("scripting.dictionary")
		regExpObj.IgnoreCase = True
		regExpObj.Global = True
		regExpObj.Pattern = "{keyicms:ProductList([\s\S]*?)}([\s\S]*?){/keyicms:ProductList}"

		set matches = regExpObj.Execute(Content)
		Call ProdContent(False, "")
	End Function

	Sub ProdContent(ListFlag, SortID)
		for each match in matches
			labelStr = match.SubMatches(0)
			loopStr = match.SubMatches(1)

			set labelArr = ParseArr(labelStr)
			lNum = labelArr("Num")
			lCommendFlag = labelArr("CommendFlag")
			lNewFlag = labelArr("NewFlag")
			lOrder = labelArr("Order")

			If ListFlag Then lSortID = SortID
			If not ListFlag Then lSortID = labelArr("SortID")
			If lSortID = "" Then
				lSortPath = "0,"
			ElseIf lSortID <> "" Then
				sql = "select * from keyicms_ProductSort where ID=" & lSortID
				If Conn.execute(sql).Eof Then
					Content = replace(Content, match.value, "SortID" & Keyicms_Lang_ErrMsg(0))
					Exit Sub
				Else
					lSortPath = Conn.execute(sql)("SortPath")
				End If
			End If
			If IsNul(lSortPath) Then
				dataSortPath = ""
			Else
				dataSortPath = " and Instr(SortPath ,'" & lSortPath & "')>0"
			End If
	
			dim HideSort
			Set rs = server.CreateObject("adodb.recordset")
			rs.open "select * from  [keyicms_ProductSort] Where not ViewFlag" & dataSortPath, Conn, 1, 2
			while not rs.eof
				HideSort = "and not(Instr(SortPath,'" & rs("SortPath") & "')>0) " & HideSort
				rs.movenext
			wend
			rs.close : set rs = nothing
	
			If Ke01 = "PC" Then datawhere = " where ViewFlag"
			If Ke01 = "Mobile" Then datawhere = " where MobileFlag"
			
			datawhere = datawhere & dataSortPath
			If lCommendFlag = "True" Then
				datawhere = datawhere & " and CommendFlag"
			ElseIf lPicFlag = "False" Then
				datawhere = datawhere & " and not CommendFlag"
			End IF
			If lNewFlag = "True" Then
				datawhere = datawhere & " and NewFlag"
			ElseIf lNoticeFlag = "False" Then
				datawhere = datawhere & " and not NewFlag"
			End IF
		
			If lOrder="UpdateTime" Then
				taxis = " Order by UpdateTime Desc"
			ElseIf lOrder="Sequence" Then
				taxis = " Order by Sequence Asc, ID Desc"
			Else
				taxis = " Order by ID Desc"
			End If
	
			datafrom = "keyicms_Product"
			Pages = lNum
	
			Dim rs, sql
			If Page = "" Then Page = 1
			Set rs = server.CreateObject("adodb.recordset")
			sql = "select * from [" & datafrom & "]" & datawhere & HideSort
			rs.Open sql, Conn, 1, 2
			idCount = rs.recordcount
			rs.close : set rs = nothing

			If idCount > 0 Then
				If(idCount Mod Pages = 0)Then
					Pagec = Int(idCount / Pages)
				Else
					Pagec = Int(idCount / Pages) + 1
				End If
				Set rs = server.CreateObject("adodb.recordset")
				sql = "select * from [" & datafrom & "] " & datawhere & HideSort & taxis
				rs.Open sql, Conn, 1, 1
				rs.Pagesize = Pages
				If Page < 1 Then Page = 1
				If Page > Pagec Then Page = Pagec
				If Pagec > 0 Then rs.absolutePage = Page
				For j = 1 To rs.Pagesize
					If rs.EOF Then Exit For
					If j = 1 Then
						sqlid = rs("ID")
					Else
						sqlid = sqlid & "," & rs("ID")
					End If
					rs.movenext
				Next
				rs.close : set rs = nothing
			End If
				
			If idCount > 0 And sqlid <> "" Then
				Set regExpTwo = New Regexp
				regExpTwo.IgnoreCase = True
				regExpTwo.Global = True
				regExpTwo.Pattern = "\[ProductList:([\s\S]*?)\]"
				set matchesfield = regExpTwo.Execute(loopStr)

				Set rs = server.CreateObject("adodb.recordset")
				sql = "select * from [" & datafrom & "] where ID in("& sqlid &") " & taxis
				rs.open sql, Conn, 1, 2
				loopstrTotal = ""
				For i = 1 to rs.recordcount
					If Ke01 = "PC" Then AutoLink = "/" & ProDir & "/" & rs("ClassSeo") & Separated & rs("ID") & "." & HTMLName
					If Ke01 = "Mobile" Then AutoLink = "/" & mFolder & "/" & ProDir & "/" & rs("ClassSeo") & Separated & rs("ID") & "." & HTMLName
					nloopstr = loopStr
					for each matchfield in matchesfield
						FieldNameArr = regExpReplace(matchfield.SubMatches(0), "[\s]+", chr(32))
						FieldNameArr = trim(FieldNameArr)
						m = instr(FieldNameArr, chr(32))
						if  m > 0 then 
							FieldName = left(FieldNameArr, m - 1)
							FieldArr = right(FieldNameArr, len(FieldNameArr) - m)
						else
							FieldName = FieldNameArr
							FieldArr = ""
						end if
						Select Case FieldName
							Case "i"
								nloopstr = replace(nloopstr, matchfield.value, i)
							Case "Link"
								nloopstr = replace(nloopstr, matchfield.value, AutoLink)
							Case "SortName"
								SortName = Conn.execute("Select * from keyicms_ProductSort where ID=" & rs("SortID"))("SortName")
								nloopstr = replace(nloopstr, matchfield.value, SortName)
							Case "SortID"
								nloopstr = replace(nloopstr, matchfield.value, rs("SortID"))
							Case "ID"
								nloopstr = replace(nloopstr, matchfield.value, rs("ID"))
							Case "ProductName"
								NameLen = ParseArr(FieldArr)("Len") 
								If cInt(NameLen) > 0 Then
									NameLen = cInt(NameLen)
									Title = StrLeft(rs("ProductName"), NameLen)
								Else
									Title = rs("ProductName")
								End If
								nloopstr = replace(nloopstr, matchfield.value, Title)
							Case "ProductNo"
								nloopstr = replace(nloopstr, matchfield.value, rs("ProductNo"))
							Case "Maker"
								nloopstr = replace(nloopstr, matchfield.value, rs("Maker"))
							Case "SmallPic"
								nloopstr = replace(nloopstr, matchfield.value, rs("SmallPic"))
							Case "BigPic"
								nloopstr = replace(nloopstr, matchfield.value, rs("BigPic"))
							Case "ClickNumber"
								nloopstr = replace(nloopstr, matchfield.value, rs("ClickNumber"))
							Case "UpdateTime"
								Format = ParseArr(FieldArr)("Format")
								nloopstr = replace(nloopstr, matchfield.value, FormatDate(rs("UpdateTime"), Format))
							Case "Content"
								ContLen = ParseArr(FieldArr)("Len")
								If cInt(ContLen) > 0 Then
									ContLen = cInt(ContLen)
									Cont = StrLeft(RemoveHTML(rs("Content")), ContLen)
								Else
									Cont = RemoveHTML(rs("Content"))
								End If
								nloopstr = replace(nloopstr, matchfield.value, Cont)
						End Select
					next
					loopstrTotal = loopstrTotal & nloopstr
					rs.movenext
				Next
				rs.close : set rs = nothing
				set matchesfield = nothing
			Else
				loopstrTotal = Keyicms_Lang_ErrMsg(1)
			End If
			Content = replace(Content, match.value, loopstrTotal)
			strDictionary.removeAll
		next
		set matches = nothing
	End Sub

	'=====================案例
	Function KE01_Case(SortID)
		Set regExpObj = New Regexp
		set strDictionary = server.CreateObject("scripting.dictionary")
		regExpObj.IgnoreCase = True
		regExpObj.Global = True
		regExpObj.Pattern = "{keyicms:List([\s\S]*?)}([\s\S]*?){/keyicms:List}"

		set matches = regExpObj.Execute(Content)
		if matches.count > 0 then
			Call CaseContent(True, SortID)
			Content = ShowPage(Content)
		end if
	End Function

	Function CaseList()
		Set regExpObj = New Regexp
		set strDictionary = server.CreateObject("scripting.dictionary")
		regExpObj.IgnoreCase = True
		regExpObj.Global = True
		regExpObj.Pattern = "{keyicms:CaseList([\s\S]*?)}([\s\S]*?){/keyicms:CaseList}"

		set matches = regExpObj.Execute(Content)
		Call CaseContent(False, "")
	End Function

	Sub CaseContent(ListFlag, SortID)
		for each match in matches
			labelStr = match.SubMatches(0)
			loopStr = match.SubMatches(1)
			
			set labelArr = ParseArr(labelStr)
			lNum = labelArr("Num")
			lCommendFlag = labelArr("CommendFlag")
			lOrder = labelArr("Order")

			If ListFlag Then lSortID = SortID
			If not ListFlag Then lSortID = labelArr("SortID")
			If lSortID = "" Then
				lSortPath = "0,"
			ElseIf lSortID <> "" Then
				sql = "select * from keyicms_CaseSort where ID=" & lSortID
				If Conn.execute(sql).Eof Then
					Content = replace(Content, match.value, "SortID" & Keyicms_Lang_ErrMsg(0))
					Exit Sub
				Else
					lSortPath = Conn.execute(sql)("SortPath")
				End If
			End If
			If IsNul(lSortPath) Then
				dataSortPath = ""
			Else
				dataSortPath = " and Instr(SortPath ,'" & lSortPath & "')>0"
			End If
	
			dim HideSort
			Set rs = server.CreateObject("adodb.recordset")
			rs.open "select * from  [keyicms_CaseSort] Where not ViewFlag" & dataSortPath, Conn, 1, 2
			while not rs.eof
				HideSort = "and not(Instr(SortPath,'" & rs("SortPath") & "')>0) " & HideSort
				rs.movenext
			wend
			rs.close : set rs = nothing
			
			If Ke01 = "PC" Then datawhere = " where ViewFlag"
			If Ke01 = "Mobile" Then datawhere = " where MobileFlag"
			
			datawhere = datawhere & dataSortPath
			If lCommendFlag = "True" Then
				datawhere = datawhere & " and CommendFlag"
			ElseIf lPicFlag = "False" Then
				datawhere = datawhere & " and not CommendFlag"
			End IF
		
			If lOrder = "UpdateTime" Then
				taxis = " Order by UpdateTime Desc"
			ElseIf lOrder = "Sequence" Then
				taxis = " Order by Sequence Asc, ID Desc"
			Else
				taxis = " Order by ID Desc"
			End If
	
			datafrom = "keyicms_Case"
			Pages = lNum
			
			If Page = "" Then Page = 1
			Dim rs, sql
			Set rs = server.CreateObject("adodb.recordset")
			sql = "select * from [" & datafrom & "]" & datawhere & HideSort
			rs.Open sql, Conn, 1, 2
			idCount = rs.recordcount
			rs.close : set rs = nothing
		
			If idCount > 0 Then
				If(idCount Mod Pages = 0)Then
					Pagec = Int(idCount / Pages)
				Else
					Pagec = Int(idCount / Pages) + 1
				End If
				Set rs = server.CreateObject("adodb.recordset")
				sql = "select * from [" & datafrom & "] " & datawhere & HideSort & taxis
				rs.Open sql, Conn, 1, 1
				rs.Pagesize = Pages
				If Page < 1 Then Page = 1
				If Page > Pagec Then Page = Pagec
				If Pagec > 0 Then rs.absolutePage = Page
				For j = 1 To rs.Pagesize
					If rs.EOF Then Exit For
					If j = 1 Then
						sqlid = rs("ID")
					Else
						sqlid = sqlid & "," & rs("ID")
					End If
					rs.movenext
				Next
				rs.close : set rs = nothing
			End If
				
			Set regExpTwo = New Regexp
			regExpTwo.IgnoreCase = True
			regExpTwo.Global = True
			regExpTwo.Pattern = "\[CaseList:([\s\S]*?)\]"
			set matchesfield = regExpTwo.Execute(loopStr)
		
			If idCount > 0 And sqlid <> "" Then
				Set rs = server.CreateObject("adodb.recordset")
				sql = "select * from [" & datafrom & "] where ID in("& sqlid &") " & taxis
				rs.open sql, Conn, 1, 2
				loopstrTotal = ""
				For i = 1 to rs.recordcount
					If Ke01 = "PC" Then AutoLink = "/" & CaseDir & "/" & rs("ClassSeo") & Separated & rs("ID") & "." & HTMLName
					If Ke01 = "Mobile" Then AutoLink = "/" & mFolder & "/" & CaseDir & "/" & rs("ClassSeo") & Separated & rs("ID") & "." & HTMLName
					nloopstr = loopStr
					for each matchfield in matchesfield
						FieldNameArr = regExpReplace(matchfield.SubMatches(0), "[\s]+", chr(32))
						FieldNameArr = trim(FieldNameArr)
						m = instr(FieldNameArr, chr(32))
						if  m > 0 then 
							FieldName = left(FieldNameArr, m - 1)
							FieldArr = right(FieldNameArr, len(FieldNameArr) - m)
						else
							FieldName = FieldNameArr
							FieldArr = ""
						end if
						Select Case FieldName
							Case "i"
								nloopstr = replace(nloopstr, matchfield.value, i)
							Case "Link"
								nloopstr = replace(nloopstr, matchfield.value, AutoLink)
							Case "SortName"
								SortName = Conn.execute("Select * from keyicms_CaseSort where ID="&rs("SortID"))("SortName")
								nloopstr = replace(nloopstr, matchfield.value, SortName)
							Case "SortID"
								nloopstr = replace(nloopstr, matchfield.value, rs("SortID"))
							Case "ID"
								nloopstr = replace(nloopstr, matchfield.value, rs("ID"))
							Case "CaseName"
								NameLen = ParseArr(FieldArr)("Len") 
								If cInt(NameLen) > 0 Then
									NameLen = cInt(NameLen)
									Title = StrLeft(rs("CaseName"), NameLen)
								Else
									Title = rs("CaseName")
								End If
								nloopstr = replace(nloopstr, matchfield.value, title)
							Case "BigPic"
								nloopstr = replace(nloopstr, matchfield.value, rs("BigPic"))
							Case "UploadPic"
								nloopstr = replace(nloopstr, matchfield.value, rs("UploadPic"))
							Case "UpdateTime"
								Format = ParseArr(FieldArr)("Format")
								nloopstr = replace(nloopstr, matchfield.value, FormatDate(rs("UpdateTime"), Format))
							Case "ClickNumber"
								nloopstr = replace(nloopstr, matchfield.value, rs("ClickNumber"))
							Case "Content"
								ContLen = ParseArr(FieldArr)("Len")
								If cInt(ContLen) > 0 Then
									ContLen = cInt(ContLen)
									Cont = StrLeft(RemoveHTML(rs("Content")), ContLen)
								Else
									Cont = RemoveHTML(rs("Content"))
								End If
								nloopstr = replace(nloopstr, matchfield.value, Cont)
						End Select
					next
					loopstrTotal = loopstrTotal & nloopstr
					rs.movenext
				Next
				rs.close : set rs = nothing
			Else
				loopstrTotal = Keyicms_Lang_ErrMsg(1)
			End If
			set matchesfield = nothing
			Content = replace(Content, match.value, loopstrTotal)
			strDictionary.removeAll
		next
		set matches = nothing
	End Sub
	
	'=====================团队
	Function KE01_Team(SortID)
		Set regExpObj = New Regexp
		set strDictionary = server.CreateObject("scripting.dictionary")
		regExpObj.IgnoreCase = True
		regExpObj.Global = True
		regExpObj.Pattern = "{keyicms:List([\s\S]*?)}([\s\S]*?){/keyicms:List}"

		set matches = regExpObj.Execute(Content)
		if matches.count > 0 then
			Call TeamContent(True, SortID)		
			Content = ShowPage(Content)
		end if
	End Function

	Function TeamList()
		Set regExpObj = New Regexp
		set strDictionary = server.CreateObject("scripting.dictionary")
		regExpObj.IgnoreCase = True
		regExpObj.Global = True
		regExpObj.Pattern = "{keyicms:CaseList([\s\S]*?)}([\s\S]*?){/keyicms:CaseList}"

		set matches = regExpObj.Execute(Content)
		Call TeamContent(False, "")
	End Function

	Sub TeamContent(ListFlag, SortID)
		for each match in matches
			labelStr = match.SubMatches(0)
			loopStr = match.SubMatches(1)
			
			set labelArr = ParseArr(labelStr)
			lNum = labelArr("Num")
			lCommendFlag = labelArr("CommendFlag")
			lOrder = labelArr("Order")

			If ListFlag Then lSortID = SortID
			If not ListFlag Then lSortID = labelArr("SortID")
			If lSortID = "" Then
				lSortPath = "0,"
			ElseIf lSortID <> "" Then
				sql = "select * from keyicms_CaseSort where ID=" & lSortID
				If Conn.execute(sql).Eof Then
					Content = replace(Content, match.value, "SortID" & Keyicms_Lang_ErrMsg(0))
					Exit Sub
				Else
					lSortPath = Conn.execute(sql)("SortPath")
				End If
			End If
			If IsNul(lSortPath) Then
				dataSortPath = ""
			Else
				dataSortPath = " and Instr(SortPath ,'" & lSortPath & "')>0"
			End If
	
			dim HideSort
			Set rs = server.CreateObject("adodb.recordset")
			rs.open "select * from  [keyicms_TeamSort] Where not ViewFlag" & dataSortPath, Conn, 1, 2
			while not rs.eof
				HideSort = "and not(Instr(SortPath,'" & rs("SortPath") & "')>0) " & HideSort
				rs.movenext
			wend
			rs.close : set rs = nothing
			
			If Ke01 = "PC" Then datawhere = " where ViewFlag"
			If Ke01 = "Mobile" Then datawhere = " where MobileFlag"
			
			datawhere = datawhere & dataSortPath
			If lCommendFlag = "True" Then
				datawhere = datawhere & " and CommendFlag"
			ElseIf lPicFlag = "False" Then
				datawhere = datawhere & " and not CommendFlag"
			End IF
		
			If lOrder = "UpdateTime" Then
				taxis = " Order by UpdateTime Desc"
			ElseIf lOrder = "AddTime" Then
				taxis = " Order by AddTime Asc, ID Desc"
			Else
				taxis = " Order by ID Desc"
			End If

			datafrom = "keyicms_Team"
			Pages = lNum
			
			If Page = "" Then Page = 1
			Dim rs, sql
			Set rs = server.CreateObject("adodb.recordset")
			sql = "select * from [" & datafrom & "]" & datawhere & HideSort
			rs.Open sql, Conn, 1, 2
			idCount = rs.recordcount
			rs.close : set rs = nothing
		
			If idCount > 0 Then
				If(idCount Mod Pages = 0)Then
					Pagec = Int(idCount / Pages)
				Else
					Pagec = Int(idCount / Pages) + 1
				End If
				Set rs = server.CreateObject("adodb.recordset")
				sql = "select * from [" & datafrom & "] " & datawhere & HideSort & taxis
				rs.Open sql, Conn, 1, 1
				rs.Pagesize = Pages
				If Page < 1 Then Page = 1
				If Page > Pagec Then Page = Pagec
				If Pagec > 0 Then rs.absolutePage = Page
				For j = 1 To rs.Pagesize
					If rs.EOF Then Exit For
					If j = 1 Then
						sqlid = rs("ID")
					Else
						sqlid = sqlid & "," & rs("ID")
					End If
					rs.movenext
				Next
				rs.close : set rs = nothing
			End If
				
			Set regExpTwo = New Regexp
			regExpTwo.IgnoreCase = True
			regExpTwo.Global = True
			regExpTwo.Pattern = "\[TeamList:([\s\S]*?)\]"
			set matchesfield = regExpTwo.Execute(loopStr)
		
			If idCount > 0 And sqlid <> "" Then
				Set rs = server.CreateObject("adodb.recordset")
				sql = "select * from [" & datafrom & "] where ID in("& sqlid &") " & taxis
				rs.open sql, Conn, 1, 2
				loopstrTotal = ""
				For i = 1 to rs.recordcount
					If Ke01 = "PC" Then AutoLink = "/" & TeamDir & "/" & rs("ClassSeo") & Separated & rs("ID") & "." & HTMLName
					If Ke01 = "Mobile" Then AutoLink = "/" & mFolder & "/" & TeamDir & "/" & rs("ClassSeo") & Separated & rs("ID") & "." & HTMLName
					nloopstr = loopStr
					for each matchfield in matchesfield
						FieldNameArr = regExpReplace(matchfield.SubMatches(0), "[\s]+", chr(32))
						FieldNameArr = trim(FieldNameArr)
						m = instr(FieldNameArr, chr(32))
						if  m > 0 then 
							FieldName = left(FieldNameArr, m - 1)
							FieldArr = right(FieldNameArr, len(FieldNameArr) - m)
						else
							FieldName = FieldNameArr
							FieldArr = ""
						end if
						Select Case FieldName
							Case "i"
								nloopstr = replace(nloopstr, matchfield.value, i)
							Case "Link"
								nloopstr = replace(nloopstr, matchfield.value, AutoLink)
							Case "SortName"
								SortName = Conn.execute("Select * from keyicms_TeamSort where ID="&rs("SortID"))("SortName")
								nloopstr = replace(nloopstr, matchfield.value, SortName)
							Case "SortID"
								nloopstr = replace(nloopstr, matchfield.value, rs("SortID"))
							Case "ID"
								nloopstr = replace(nloopstr, matchfield.value, rs("ID"))
							Case "TeamName"
								NameLen = ParseArr(FieldArr)("Len") 
								If cInt(NameLen) > 0 Then
									NameLen = cInt(NameLen)
									Title = StrLeft(rs("TeamName"), NameLen)
								Else
									Title = rs("TeamName")
								End If
								nloopstr = replace(nloopstr, matchfield.value, title)
							Case "Specialty"
								nloopstr = replace(nloopstr, matchfield.value, rs("Specialty"))
							Case "BigPic"
								nloopstr = replace(nloopstr, matchfield.value, rs("BigPic"))
							Case "UpdateTime"
								Format = ParseArr(FieldArr)("Format")
								nloopstr = replace(nloopstr, matchfield.value, FormatDate(rs("UpdateTime"), Format))
							Case "ClickNumber"
								nloopstr = replace(nloopstr, matchfield.value, rs("ClickNumber"))
							Case "Content"
								ContLen = ParseArr(FieldArr)("Len")
								If cInt(ContLen) > 0 Then
									ContLen = cInt(ContLen)
									Cont = StrLeft(RemoveHTML(rs("Content")), ContLen)
								Else
									Cont = RemoveHTML(rs("Content"))
								End If
								nloopstr = replace(nloopstr, matchfield.value, Cont)
							Case "TeamBrief"
								ContLen = ParseArr(FieldArr)("Len")
								If cInt(ContLen) > 0 Then
									ContLen = cInt(ContLen)
									Cont = StrLeft(RemoveHTML(rs("TeamBrief")), ContLen)
								Else
									Cont = RemoveHTML(rs("TeamBrief"))
								End If
								nloopstr = replace(nloopstr, matchfield.value, Cont)
							Case "Professional"
								ContLen = ParseArr(FieldArr)("Len")
								If cInt(ContLen) > 0 Then
									ContLen = cInt(ContLen)
									Cont = StrLeft(RemoveHTML(rs("Professional")), ContLen)
								Else
									Cont = RemoveHTML(rs("Professional"))
								End If
								nloopstr = replace(nloopstr, matchfield.value, Cont)
						End Select
					next
					loopstrTotal = loopstrTotal & nloopstr
					rs.movenext
				Next
				rs.close : set rs = nothing
			Else
				loopstrTotal = Keyicms_Lang_ErrMsg(1)
			End If
			set matchesfield = nothing
			Content = replace(Content, match.value, loopstrTotal)
			strDictionary.removeAll
		next
		set matches = nothing
	End Sub
	
	'=====================视频
	Function KE01_Video(SortID)
		Set regExpObj = New Regexp
		set strDictionary = server.CreateObject("scripting.dictionary")
		regExpObj.IgnoreCase = True
		regExpObj.Global = True
		regExpObj.Pattern = "{keyicms:List([\s\S]*?)}([\s\S]*?){/keyicms:List}"

		set matches = regExpObj.Execute(Content)
		if matches.count > 0 then
			Call VideoContent(True, SortID)		
			Content = ShowPage(Content)
		end if
	End Function

	Function VideoList()
		Set regExpObj = New Regexp
		set strDictionary = server.CreateObject("scripting.dictionary")
		regExpObj.IgnoreCase = True
		regExpObj.Global = True
		regExpObj.Pattern = "{keyicms:VideoList([\s\S]*?)}([\s\S]*?){/keyicms:VideoList}"

		set matches = regExpObj.Execute(Content)
		Call VideoContent(False, "")
	End Function

	Sub VideoContent(ListFlag, SortID)
		for each match in matches
			labelStr = match.SubMatches(0)
			loopStr = match.SubMatches(1)
			
			set labelArr = ParseArr(labelStr)
			lNum = labelArr("Num")
			lCommendFlag = labelArr("CommendFlag")
			lOrder = labelArr("Order")

			If ListFlag Then lSortID = SortID
			If not ListFlag Then lSortID = labelArr("SortID")
			If lSortID = "" Then
				lSortPath = "0,"
			ElseIf lSortID <> "" Then
				sql = "select * from keyicms_VideoSort where ID=" & lSortID
				If Conn.execute(sql).Eof Then
					Content = replace(Content, match.value, "SortID" & Keyicms_Lang_ErrMsg(0))
					Exit Sub
				Else
					lSortPath = Conn.execute(sql)("SortPath")
				End If
			End If
			If IsNul(lSortPath) Then
				dataSortPath = ""
			Else
				dataSortPath = " and Instr(SortPath ,'" & lSortPath & "')>0"
			End If
	
			dim HideSort
			Set rs = server.CreateObject("adodb.recordset")
			rs.open "select * from  [keyicms_VideoSort] Where not ViewFlag" & dataSortPath, Conn, 1, 2
			while not rs.eof
				HideSort = "and not(Instr(SortPath,'" & rs("SortPath") & "')>0) " & HideSort
				rs.movenext
			wend
			rs.close : set rs = nothing
			
			If Ke01 = "PC" Then datawhere = " where ViewFlag"
			If Ke01 = "Mobile" Then datawhere = " where MobileFlag"
			
			datawhere = datawhere & dataSortPath
			If lCommendFlag = "True" Then
				datawhere = datawhere & " and CommendFlag"
			ElseIf lPicFlag = "False" Then
				datawhere = datawhere & " and not CommendFlag"
			End IF
		
			If lOrder = "UpdateTime" Then
				taxis = " Order by UpdateTime Desc"
			ElseIf lOrder = "AddTime" Then
				taxis = " Order by AddTime Asc, ID Desc"
			Else
				taxis = " Order by ID Desc"
			End If

			datafrom = "keyicms_Video"
			Pages = lNum
			
			If Page = "" Then Page = 1
			Dim rs, sql
			Set rs = server.CreateObject("adodb.recordset")
			sql = "select * from [" & datafrom & "]" & datawhere & HideSort
			rs.Open sql, Conn, 1, 2
			idCount = rs.recordcount
			rs.close : set rs = nothing
		
			If idCount > 0 Then
				If(idCount Mod Pages = 0)Then
					Pagec = Int(idCount / Pages)
				Else
					Pagec = Int(idCount / Pages) + 1
				End If
				Set rs = server.CreateObject("adodb.recordset")
				sql = "select * from [" & datafrom & "] " & datawhere & HideSort & taxis
				rs.Open sql, Conn, 1, 1
				rs.Pagesize = Pages
				If Page < 1 Then Page = 1
				If Page > Pagec Then Page = Pagec
				If Pagec > 0 Then rs.absolutePage = Page
				For j = 1 To rs.Pagesize
					If rs.EOF Then Exit For
					If j = 1 Then
						sqlid = rs("ID")
					Else
						sqlid = sqlid & "," & rs("ID")
					End If
					rs.movenext
				Next
				rs.close : set rs = nothing
			End If
				
			Set regExpTwo = New Regexp
			regExpTwo.IgnoreCase = True
			regExpTwo.Global = True
			regExpTwo.Pattern = "\[VideoList:([\s\S]*?)\]"
			set matchesfield = regExpTwo.Execute(loopStr)
		
			If idCount > 0 And sqlid <> "" Then
				Set rs = server.CreateObject("adodb.recordset")
				sql = "select * from [" & datafrom & "] where ID in("& sqlid &") " & taxis
				rs.open sql, Conn, 1, 2
				loopstrTotal = ""
				For i = 1 to rs.recordcount
					If Ke01 = "PC" Then AutoLink = "/" & VideoDir & "/" & rs("ClassSeo") & Separated & rs("ID") & "." & HTMLName
					If Ke01 = "Mobile" Then AutoLink = "/" & mFolder & "/" & VideoDir & "/" & rs("ClassSeo") & Separated & rs("ID") & "." & HTMLName
					nloopstr = loopStr
					for each matchfield in matchesfield
						FieldNameArr = regExpReplace(matchfield.SubMatches(0), "[\s]+", chr(32))
						FieldNameArr = trim(FieldNameArr)
						m = instr(FieldNameArr, chr(32))
						if  m > 0 then 
							FieldName = left(FieldNameArr, m - 1)
							FieldArr = right(FieldNameArr, len(FieldNameArr) - m)
						else
							FieldName = FieldNameArr
							FieldArr = ""
						end if
						Select Case FieldName
							Case "i"
								nloopstr = replace(nloopstr, matchfield.value, i)
							Case "Link"
								nloopstr = replace(nloopstr, matchfield.value, AutoLink)
							Case "SortName"
								SortName = Conn.execute("Select * from keyicms_VideoSort where ID="&rs("SortID"))("SortName")
								nloopstr = replace(nloopstr, matchfield.value, SortName)
							Case "SortID"
								nloopstr = replace(nloopstr, matchfield.value, rs("SortID"))
							Case "ID"
								nloopstr = replace(nloopstr, matchfield.value, rs("ID"))
							Case "VideoName"
								NameLen = ParseArr(FieldArr)("Len") 
								If cInt(NameLen) > 0 Then
									NameLen = cInt(NameLen)
									Title = StrLeft(rs("VideoName"), NameLen)
								Else
									Title = rs("VideoName")
								End If
								nloopstr = replace(nloopstr, matchfield.value, title)
							Case "BigPic"
								nloopstr = replace(nloopstr, matchfield.value, rs("BigPic"))
							Case "VideoUrl"
								nloopstr = replace(nloopstr, matchfield.value, rs("VideoUrl"))
							Case "UpdateTime"
								Format = ParseArr(FieldArr)("Format")
								nloopstr = replace(nloopstr, matchfield.value, FormatDate(rs("UpdateTime"), Format))
							Case "ClickNumber"
								nloopstr = replace(nloopstr, matchfield.value, rs("ClickNumber"))
							Case "Content"
								ContLen = ParseArr(FieldArr)("Len")
								If cInt(ContLen) > 0 Then
									ContLen = cInt(ContLen)
									Cont = StrLeft(RemoveHTML(rs("Content")), ContLen)
								Else
									Cont = RemoveHTML(rs("Content"))
								End If
								nloopstr = replace(nloopstr, matchfield.value, Cont)
						End Select
					next
					loopstrTotal = loopstrTotal & nloopstr
					rs.movenext
				Next
				rs.close : set rs = nothing
			Else
				loopstrTotal = Keyicms_Lang_ErrMsg(1)
			End If
			set matchesfield = nothing
			Content = replace(Content, match.value, loopstrTotal)
			strDictionary.removeAll
		next
		set matches = nothing
	End Sub
	
	'=================下载
	Function KE01_Download(SortID)
		Set regExpObj = New Regexp
		set strDictionary = server.CreateObject("scripting.dictionary")
		regExpObj.IgnoreCase = True
		regExpObj.Global = True
		regExpObj.Pattern = "{keyicms:List([\s\S]*?)}([\s\S]*?){/keyicms:List}"

		set matches = regExpObj.Execute(Content)
		if matches.count > 0 then
			Call DownContent(True, SortID)		
			Content = ShowPage(Content)
		end if
	End Function

	Function DownList()
		Set regExpObj = New Regexp
		set strDictionary = server.CreateObject("scripting.dictionary")
		regExpObj.IgnoreCase = True
		regExpObj.Global = True
		regExpObj.Pattern = "{keyicms:DownList([\s\S]*?)}([\s\S]*?){/keyicms:DownList}"

		set matches = regExpObj.Execute(Content)
		Call DownContent(False, "")
	End Function

	Sub DownContent(ListFlag, SortID)
		for each match in matches
			labelStr = match.SubMatches(0)
			loopStr = match.SubMatches(1)
			
			set labelArr = ParseArr(labelStr)
			lNum = labelArr("Num")
			lOrder = labelArr("Order")

			If ListFlag Then lSortID = SortID
			If not ListFlag Then lSortID = labelArr("SortID")
			If lSortID = "" Then
				lSortPath = "0,"
			ElseIf lSortID <> "" Then
				sql = "select * from keyicms_NewsSort where ID=" & lSortID
				If Conn.execute(sql).Eof Then
					Content = replace(Content, match.value, "SortID" & Keyicms_Lang_ErrMsg(0))
					Exit Sub
				Else
					lSortPath = Conn.execute(sql)("SortPath")
				End If
			End If
			If IsNul(lSortPath) Then
				dataSortPath = ""
			Else
				dataSortPath = " and Instr(SortPath ,'" & lSortPath & "')>0"
			End If

			dim HideSort
			Set rs = server.CreateObject("adodb.recordset")
			rs.open "select * from  [keyicms_DownSort] Where not ViewFlag" & dataSortPath, Conn, 1, 2
			while not rs.eof
				HideSort = "and not(Instr(SortPath,'" & rs("SortPath") & "')>0) " & HideSort
				rs.movenext
			wend
			rs.close : set rs = nothing
	
			If Ke01 = "PC" Then datawhere = " where ViewFlag"
			If Ke01 = "Mobile" Then datawhere = " where MobileFlag"
			
			datawhere = datawhere & dataSortPath
			If lOrder="UpdateTime" Then
				taxis = " Order by UpdateTime Desc"
			Else
				taxis = " Order by ID Desc"
			End If
	
			datafrom = "keyicms_Download"
			Pages = lNum
			
			If Page = "" Then Page = 1
			Dim rs, sql
			Set rs = server.CreateObject("adodb.recordset")
			sql = "select * from [" & datafrom & "]" & datawhere & HideSort
			rs.Open sql, Conn, 1, 2
			idCount = rs.recordcount
			rs.close : set rs = nothing
		
			If idCount > 0 Then
				If(idCount Mod Pages = 0)Then
					Pagec = Int(idCount / Pages)
				Else
					Pagec = Int(idCount / Pages) + 1
				End If
				Set rs = server.CreateObject("adodb.recordset")
				sql = "select * from [" & datafrom & "] " & datawhere & HideSort & taxis
				rs.Open sql, Conn, 1, 1
				rs.Pagesize = Pages
				If Page < 1 Then Page = 1
				If Page > Pagec Then Page = Pagec
				If Pagec > 0 Then rs.absolutePage = Page
				For j = 1 To rs.Pagesize
					If rs.EOF Then Exit For
					If j = 1 Then
						sqlid = rs("ID")
					Else
						sqlid = sqlid & "," & rs("ID")
					End If
					rs.movenext
				Next
				rs.close : set rs = nothing
			End If
				
			Set regExpTwo = New Regexp
			regExpTwo.IgnoreCase = True
			regExpTwo.Global = True
			regExpTwo.Pattern = "\[DownList:([\s\S]*?)\]"
			set matchesfield = regExpTwo.Execute(loopStr)
		
			If idCount > 0 And sqlid <> "" Then
				Set rs = server.CreateObject("adodb.recordset")
				sql = "select * from [" & datafrom & "] where ID in("& sqlid &") " & taxis
				rs.open sql, Conn, 1, 2
				loopstrTotal = ""
				For i = 1 to rs.recordcount
					If Ke01 = "PC" Then AutoLink = "/"&DownDir & "/" & rs("ClassSeo") & Separated & rs("ID") & "." & HTMLName
					If Ke01 = "Mobile" Then AutoLink = "/" & mFolder & "/"&DownDir & "/" & rs("ClassSeo") & Separated & rs("ID") & "." & HTMLName
					nloopstr = loopStr
					for each matchfield in matchesfield
						FieldNameArr = regExpReplace(matchfield.SubMatches(0), "[\s]+", chr(32))
						FieldNameArr = trim(FieldNameArr)
						m = instr(FieldNameArr, chr(32))
						if  m > 0 then 
							FieldName = left(FieldNameArr, m - 1)
							FieldArr = right(FieldNameArr, len(FieldNameArr) - m)
						else
							FieldName = FieldNameArr
							FieldArr = ""
						end if
						Select Case FieldName
							Case "i"
								nloopstr = replace(nloopstr, matchfield.value, i)
							Case "Link"
								nloopstr = replace(nloopstr, matchfield.value, AutoLink)
							Case "SortName"
								SortName = Conn.execute("Select * from keyicms_DownSort where ID="&rs("SortID"))("SortName")
								nloopstr = replace(nloopstr, matchfield.value, SortName)
							Case "SortID"
								nloopstr = replace(nloopstr, matchfield.value, rs("SortID"))
							Case "ID"
								nloopstr = replace(nloopstr, matchfield.value, rs("ID"))
							Case "DownName"
								NameLen = ParseArr(FieldArr)("Len") 
								If cInt(NameLen) > 0 Then
									NameLen = cInt(NameLen)
									Title = StrLeft(rs("DownName"), NameLen)
								Else
									Title = rs("DownName")
								End If
								nloopstr = replace(nloopstr, matchfield.value, Title)
							Case "FileSize"
								nloopstr = replace(nloopstr, matchfield.value, rs("FileSize"))
							Case "FileUrl"
								nloopstr = replace(nloopstr, matchfield.value, rs("FileUrl"))
							Case "UpdateTime"
								Format = ParseArr(FieldArr)("Format")
								nloopstr = replace(nloopstr, matchfield.value, FormatDate(rs("UpdateTime"), Format))
							Case "ClickNumber"
								nloopstr = replace(nloopstr, matchfield.value, rs("ClickNumber"))
							Case "Content"
								ContLen = ParseArr(FieldArr)("Len")
								If cInt(ContLen) > 0 Then
									ContLen = cInt(ContLen)
									Cont = StrLeft(RemoveHTML(rs("Content")), ContLen)
								Else
									Cont = RemoveHTML(rs("Content"))
								End If
								nloopstr = replace(nloopstr, matchfield.value, Cont)
						End Select
					next
					loopstrTotal = loopstrTotal & nloopstr
					rs.movenext
				Next
				rs.close : set rs = nothing
			Else
				loopstrTotal = Keyicms_Lang_ErrMsg(1)
			End If
			set matchesfield = nothing
			Content = replace(Content, match.value, loopstrTotal)
			strDictionary.removeAll
		next
		set matches = nothing
	End Sub
	
	'==============招聘
	Function KE01_Job()
		Set regExpObj = New Regexp
		set strDictionary = server.CreateObject("scripting.dictionary")
		regExpObj.IgnoreCase = True
		regExpObj.Global = True
		regExpObj.Pattern = "{keyicms:List([\s\S]*?)}([\s\S]*?){/keyicms:List}"

		set matches = regExpObj.Execute(Content)
		if matches.count > 0 then
			Call JobContent()
			Content = ShowPage(Content)
		end if
	End Function

	Function JobList()
		Set regExpObj = New Regexp
		set strDictionary = server.CreateObject("scripting.dictionary")
		regExpObj.IgnoreCase = True
		regExpObj.Global = True
		regExpObj.Pattern = "{keyicms:JobList([\s\S]*?)}([\s\S]*?){/keyicms:JobList}"
		
		set matches = regExpObj.Execute(Content)
		Call JobContent()
	End Function

	Sub JobContent()
		for each match in matches
			labelStr = match.SubMatches(0)
			loopStr = match.SubMatches(1)
			
			set labelArr = ParseArr(labelStr)
			lNum = labelArr("Num")
			lOrder = labelArr("Order")

			If Ke01 = "PC" Then datawhere = " where ViewFlag"
			If Ke01 = "Mobile" Then datawhere = " where MobileFlag"

			If lOrder="UpdateTime" Then
				taxis = " Order by UpdateTime Desc"
			Else
				taxis = " Order by ID Desc"
			End If
	
			datafrom = "keyicms_Job"
			Pages = lNum
			
			If Page = "" Then Page = 1
			Dim rs, sql
			Set rs = server.CreateObject("adodb.recordset")
			sql = "select * from [" & datafrom & "]" & datawhere
			rs.Open sql, Conn, 1, 2
			idCount = rs.recordcount
			rs.close : set rs = nothing
		
			If idCount > 0 Then
				If(idCount Mod Pages = 0)Then
					Pagec = Int(idCount / Pages)
				Else
					Pagec = Int(idCount / Pages) + 1
				End If
				Set rs = server.CreateObject("adodb.recordset")
				sql = "select * from [" & datafrom & "] " & datawhere
				rs.Open sql, Conn, 1, 1
				rs.Pagesize = Pages
				If Page < 1 Then Page = 1
				If Page > Pagec Then Page = Pagec
				If Pagec > 0 Then rs.absolutePage = Page
				For j = 1 To rs.Pagesize
					If rs.EOF Then Exit For
					If j = 1 Then
						sqlid = rs("ID")
					Else
						sqlid = sqlid & "," & rs("ID")
					End If
					rs.movenext
				Next
				rs.close : set rs = nothing
			End If
				
			Set regExpTwo = New Regexp
			regExpTwo.IgnoreCase = True
			regExpTwo.Global = True
			regExpTwo.Pattern = "\[JobList:([\s\S]*?)\]"
			set matchesfield = regExpTwo.Execute(loopStr)

			If idCount > 0 And sqlid <> "" Then
				Set rs = server.CreateObject("adodb.recordset")
				sql = "select * from [" & datafrom & "] where ID in("& sqlid &") " & taxis
				rs.open sql, Conn, 1, 2
				loopstrTotal = ""
				For i = 1 to rs.recordcount
					If Ke01 = "PC" Then AutoLink = "/"&JobDir & "/" & rs("ClassSeo") & Separated & rs("ID") & "." & HTMLName
					If Ke01 = "Mobile" Then AutoLink = "/" & mFolder & "/"&JobDir & "/" & rs("ClassSeo") & Separated & rs("ID") & "." & HTMLName
					nloopstr = loopStr
					for each matchfield in matchesfield
						FieldNameArr = regExpReplace(matchfield.SubMatches(0), "[\s]+", chr(32))
						FieldNameArr = trim(FieldNameArr)
						m = instr(FieldNameArr, chr(32))
						if  m > 0 then 
							FieldName = left(FieldNameArr, m - 1)
							FieldArr = right(FieldNameArr, len(FieldNameArr) - m)
						else
							FieldName = FieldNameArr
							FieldArr = ""
						end if
						Select Case FieldName
							Case "i"
								nloopstr = replace(nloopstr, matchfield.value, i)
							Case "Link"
								nloopstr = replace(nloopstr, matchfield.value, AutoLink)
							Case "ID"
								nloopstr = replace(nloopstr, matchfield.value, rs("ID"))
							Case "JobName"
								NameLen = ParseArr(FieldArr)("Len") 
								If cInt(NameLen) > 0 Then
									NameLen = cInt(NameLen)
									Title = StrLeft(rs("JobName"), NameLen)
								Else
									Title = rs("JobName")
								End If
								nloopstr = replace(nloopstr, matchfield.value, Title)
							Case "JobAddress"
								nloopstr = replace(nloopstr, matchfield.value, rs("JobAddress"))
							Case "JobNumber"
								nloopstr = replace(nloopstr, matchfield.value, rs("JobNumber"))
							Case "Emolument"
								nloopstr = replace(nloopstr, matchfield.value, rs("Emolument"))
							Case "StartDate"
								Format = ParseArr(FieldArr)("Format")
								nloopstr = replace(nloopstr, matchfield.value, FormatDate(rs("StartDate"), Format))
							Case "EndDate"
								Format = ParseArr(FieldArr)("Format")
								nloopstr = replace(nloopstr, matchfield.value, FormatDate(rs("EndDate"), Format))
							Case "UpdateTime"
								Format = ParseArr(FieldArr)("Format")
								nloopstr = replace(nloopstr, matchfield.value, FormatDate(rs("UpdateTime"), Format))
							Case "Requirement"
								ContLen = ParseArr(FieldArr)("Len") 
								If cInt(ContLen) > 0 Then
									ContLen = cInt(ContLen)
									Cont = StrLeft(RemoveHTML(rs("Requirement")), ContLen)
								Else
									Cont = RemoveHTML(rs("Requirement"))
								End If
								nloopstr = replace(nloopstr, matchfield.value, Cont)
							Case "ClickNumber"
								nloopstr = replace(nloopstr, matchfield.value, rs("ClickNumber"))
						End Select
					next
					loopstrTotal = loopstrTotal & nloopstr
					rs.movenext
				Next
				rs.close : set rs = nothing
			Else
				loopstrTotal = Keyicms_Lang_ErrMsg(1)
			End If
			set matchesfield = nothing
			Content = replace(Content, match.value, loopstrTotal)
			strDictionary.removeAll
		next
		set matches = nothing
	End Sub
End Class

Function KE01_Search(Content, Page, Ke01, QUERY_STRING)
	If Page = "" Then Page = 1
	Set regExpObj = New Regexp
	set strDictionary = server.CreateObject("scripting.dictionary")

	regExpObj.IgnoreCase = True
	regExpObj.Global = True
	regExpObj.Pattern = "{keyicms:Search([\s\S]*?)}([\s\S]*?){/keyicms:Search}"
	set matches = regExpObj.Execute(Content)

  	for each match in matches
		labelStr = match.SubMatches(0)
		loopStr = match.SubMatches(1)

		set labelArr = ParseArr(labelStr)
		lNum = labelArr("Num")
		Pages = lNum

		If Ke01 = "PC" Then Flag = "ViewFlag"
		If Ke01 = "Mobile" Then Flag = "MobileFlag"

		Dim rs, sql
		set rs = server.CreateObject("adodb.recordset")
		rs.open "select * from keyicms_System where ViewFlag Order by DataForm Asc", Conn, 1, 2
		For i = 1 to rs.recordcount
If rs("DataForm") = 1 Then sql = sql & "select '"&rs("DataForm")&"' as DataForm, ID, AddTime, ClassSeo, ApageName as Title   from keyicms_Apage    where "&Flag&" and ApageName   like '%"&key&"%' Order by ID Desc " & " union "
If rs("DataForm") = 2 Then sql = sql & "select '"&rs("DataForm")&"' as DataForm, ID, AddTime, ClassSeo, NewsName as Title    from keyicms_News     where "&Flag&" and NewsName    like '%"&key&"%' Order by ID Desc " & " union "
If rs("DataForm") = 3 Then sql = sql & "select '"&rs("DataForm")&"' as DataForm, ID, AddTime, ClassSeo, ProductName as Title from keyicms_Product  where "&Flag&" and ProductName like '%"&key&"%' Order by ID Desc " & " union "
If rs("DataForm") = 4 Then sql = sql & "select '"&rs("DataForm")&"' as DataForm, ID, AddTime, ClassSeo, CaseName as Title    from keyicms_Case     where "&Flag&" and CaseName    like '%"&key&"%' Order by ID Desc " & " union "
If rs("DataForm") = 5 Then sql = sql & "select '"&rs("DataForm")&"' as DataForm, ID, AddTime, ClassSeo, VideoName as Title    from keyicms_Video where "&Flag&" and VideoName    like '%"&key&"%' Order by ID Desc " & " union "
If rs("DataForm") = 6 Then sql = sql & "select '"&rs("DataForm")&"' as DataForm, ID, AddTime, ClassSeo, DownName as Title    from keyicms_Download where "&Flag&" and DownName    like '%"&key&"%' Order by ID Desc " & " union "
If rs("DataForm") = 7 Then sql = sql & "select '"&rs("DataForm")&"' as DataForm, ID, AddTime, ClassSeo, JobName as Title     from keyicms_Job      where "&Flag&" and JobName     like '%"&key&"%' Order by ID Desc " & " union "
If rs("DataForm") = 8 Then sql = sql & "select '"&rs("DataForm")&"' as DataForm, ID, AddTime, ClassSeo, TeamName as Title    from keyicms_Team     where "&Flag&" and TeamName    like '%"&key&"%' Order by ID Desc " & " union "
	
rs.movenext
		Next
		rs.close : set rs = nothing
		
		SqlArray = split(sql, "union")
		If Ubound(SqlArray) < 0 Then
			loopstrTotal = "未搜索到相关信息"
		Else
			For i = 0 to Ubound(SqlArray) - 1
				If i = 0 Then
					sql = sql & SqlArray(i)
				Else
					sql = sql & " union " & SqlArray(i)
				End If
			Next

			Set rs = server.CreateObject("adodb.recordset")
			sql = "Select * from (" & sql & ") Order by AddTime Desc"
			rs.Open sql, Conn, 1, 2
			idCount = rs.recordcount
			rs.close : set rs = nothing
			If idCount > 0 Then
				If(idCount Mod Pages = 0)Then
					Pagec = Int(idCount / Pages)
				Else
					Pagec = Int(idCount / Pages) + 1
				End If
				Set rs = server.CreateObject("adodb.recordset")
				rs.Open sql, Conn, 1, 1
				rs.Pagesize = Pages
				If Page < 1 Then Page = 1
				If Page > Pagec Then Page = Pagec
				If Pagec > 0 Then rs.absolutePage = Page
				Set regExpTwo = New Regexp
				regExpTwo.IgnoreCase = True
				regExpTwo.Global = True
				regExpTwo.Pattern = "\[Search:([\s\S]*?)\]"
				set matchesfield = regExpTwo.Execute(loopStr)

				loopstrTotal = ""
				For j = 1 To rs.Pagesize
					If rs.eof Then Exit For
					If Ke01 = "PC" Then
						mPath = ""
					Else
						mPath = "/" & mFolder
					End If
	
					nloopstr = loopStr
					for each matchfield in matchesfield
						FieldNameArr = regExpReplace(matchfield.SubMatches(0), "[\s]+", chr(32))
						FieldNameArr = trim(FieldNameArr)
						m = instr(FieldNameArr, chr(32))
						if  m > 0 then 
							FieldName = left(FieldNameArr, m - 1)
							FieldArr = right(FieldNameArr, len(FieldNameArr) - m)
						else
							FieldName = FieldNameArr
							FieldArr = ""
						end if
						Select Case FieldName
							Case "Link"
								SystemDir = Conn.execute("Select * from keyicms_System where DataForm="&rs("DataForm"))("SystemDir")
								AutoLink = mPath&"/"&SystemDir & "/" & rs("ClassSeo") & Separated & rs("ID") & "." & HTMLName
								nloopstr = replace(nloopstr, matchfield.value, AutoLink)
							Case "Title"
								NameLen = ParseArr(FieldArr)("Len") 
								If cInt(NameLen) > 0 Then
									NameLen = cInt(NameLen)
									Title = StrLeft(rs("Title"), NameLen)
								Else
									Title = rs("Title")
								End If
								nloopstr = replace(nloopstr, matchfield.value, Title)
							Case "AddTime"
								Format = ParseArr(FieldArr)("Format")
								nloopstr = replace(nloopstr, matchfield.value, FormatDate(rs("AddTime"), Format))
							Case "Column"
								DataForm = Conn.execute("Select * from keyicms_System where DataForm="&rs("DataForm"))("SeoTitle")
								nloopstr = replace(nloopstr, matchfield.value, DataForm)
						End Select
					next
					loopstrTotal = loopstrTotal & nloopstr
					rs.movenext
				Next
				rs.close : set rs = nothing
			Else
				loopstrTotal = Keyicms_Lang_ErrMsg(4)
			End If
		End If
		set matchesfield = nothing
		Content = replace(Content, match.value, loopstrTotal)
		strDictionary.removeAll
	next
	set matches = nothing
	'Content = ShowPage(Content, idCount, Page, Pagec, Pages)
	KE01_Search = Content
End Function
%>