<%
	Class Cls_Template
		Dim reg,ActForTF
		Private tconn
  		Private Sub Class_Initialize()
			Set Reg=New Regexp
			Reg.Ignorecase=True
			Reg.Global=True
		 	ConnectionDatabase
			ActForTF=false
  		End Sub
  		Private Sub Class_Terminate()
 			Set Reg=Nothing
		End Sub
		Function Load(ByVal TemplateContent)
			IF IsNull(TemplateContent) Or Len(TemplateContent)="" Then
				Load="模版没有找到 By Fycms"
 			End IF
			TemplateContent=Loadfile(TemplateContent)
			TemplateContent=variables(TemplateContent)
			TemplateContent=httpLoadfile(TemplateContent)
			TemplateContent=GeneralLabel(TemplateContent)
			TemplateContent=Getcurrent(TemplateContent)
			TemplateContent=GetRequest(TemplateContent)
 			TemplateContent=GetTabForContent(TemplateContent)
 			TemplateContent=GetTabContent(TemplateContent)
			TemplateContent= apiexe(TemplateContent)
			TemplateContent=listclass(TemplateContent)
  			Load=ACTIF("",TemplateContent)
 		End Function 


		 Function GetNavigation()
 			Select Case UCase(Application(fycmsN & "fycms_TCJ_Type"))
				 Case "INDEX" 
					GetNavigation = fycms.GetIndexNavigation(Application(fycmsN & "classid"))
				 Case "FOLDER"        '栏目的位置导航
					GetNavigation = fycms.GetClassNavigation( Application(fycmsN & "classid"))
				 Case "ARTICLECONTENT"     '内容页的位置导航
					GetNavigation = fycms.GetContentNavigation( Application(fycmsN & "classid"))
				 Case "OTHER"'插件导航
					GetNavigation =   "<a href=""" & Application(fycmsN & "link") & """>" & Application(fycmsN & "fycmsTCJ") & "</a>"
				 Case Else
					GetNavigation = ""
			End Select
		 End Function


		Public Function GeneralLabel(TemplateContent)
		 If instr(TemplateContent,"{fy:position}")>0 Then 
				TemplateContent=rep(TemplateContent,"{fy:position}",GetNavigation())
		 End If 

  		 TemplateContent = InStrRep(TemplateContent, "{fy:rnd}",fycms.GetRandomize(10))
  		 TemplateContent = InStrRep(TemplateContent, "{fy:webname}",fycms.fycms_Sys(0))
		 TemplateContent = InStrRep(TemplateContent, "{fy:webtitle}", fycms.fycms_Sys(1))
		 TemplateContent = InStrRep(TemplateContent, "{fy:keywords}", fycms.fycms_Other(1))
		 TemplateContent = InStrRep(TemplateContent, "{fy:description}", fycms.fycms_Other(2))
		 TemplateContent = InStrRep(TemplateContent, "{fy:copyright}", fycms.fycms_Other(0))
		 TemplateContent = InStrRep(TemplateContent, "{fy:url}", fycms.ACTUrl)
		 TemplateContent = InStrRep(TemplateContent, "{fy:siteurl}", fycms.fycms_Sys(2))
		 TemplateContent = InStrRep(TemplateContent, "{fy:dir}", fycms.ActSys)
		 TemplateContent = InStrRep(TemplateContent, "{fy:kf}", Getservice())
		 
 		 TemplateContent = InStrRep(TemplateContent, "{fy:path}", fycms.Domain)
		 TemplateContent = InStrRep(TemplateContent, "{fy:now}", now)
		 TemplateContent = InStrRep(TemplateContent, "{fy:skin}", fycms.NowTheme)
		 TemplateContent = InStrRep(TemplateContent, "{fy:themepath}", fycms.ThisTheme&"/")
 		 TemplateContent = InStrRep(TemplateContent, "{fy:logo}", fycms.fycms_Sys(5))
		 TemplateContent = InStrRep(TemplateContent, "{fy:adminname}", fycms.fycms_Sys(6))
		 TemplateContent = InStrRep(TemplateContent, "{fy:adminmail}", fycms.fycms_Sys(7))
 		 TemplateContent = InStrRep(TemplateContent, "{fy:classid}",Application(fycmsN & "classid"))
 		 TemplateContent = InStrRep(TemplateContent, "{fy:rootid}",fycms.ACT_L(Application(fycmsN & "classid"),11))
 		 TemplateContent = InStrRep(TemplateContent, "{fy:modeid}",Application(fycmsN & "modeid"))
 		 TemplateContent = InStrRep(TemplateContent, "{fy:classname}",fycms.ACT_L(Application(fycmsN & "classid"),2))
		 TemplateContent = InStrRep(TemplateContent, "{fy:classlink}",fycms.DiyClassName(Application(fycmsN & "classid")))
		 If InStr(TemplateContent, "{fy:seotitle}") > 0  Then
			If Trim(fycms.ACT_L(Application(fycmsN & "classid"),25))<>"" Then 
				 TemplateContent = rep(TemplateContent, "{fy:seotitle}",fycms.ACT_L(Application(fycmsN & "classid"),25))
			Else 
				 TemplateContent = rep(TemplateContent, "{fy:seotitle}",fycms.ACT_L(Application(fycmsN & "classid"),2))
			End If 
 		 End If 
 		 TemplateContent = InStrRep(TemplateContent, "{fy:classkeywords}",fycms.ACT_L(Application(fycmsN & "classid"),8))
		 TemplateContent = InStrRep(TemplateContent, "{fy:classdescription}",fycms.ACT_L(Application(fycmsN & "classid"),9))
		 TemplateContent = InStrRep(TemplateContent, "{fy:classpicurl}",fycms.ACT_L(Application(fycmsN & "classid"),26))
		 If Trim(fycms.fycms_Sys(26))<>"" Then 
			 TemplateContent = rep(TemplateContent, "{fy:beian}", "<a href=""http://www.miibeian.gov.cn"" rel=""nofollow"" target=""_blank"">"&fycms.fycms_Sys(26)&"</a>")
		 Else 
			 TemplateContent = rep(TemplateContent, "{fy:beian}", "")
		 End If 
		 TemplateContent = InStrRep(TemplateContent, "{fy:tongji}", fycms.fycms_Sys(27))
  		 TemplateContent = InStrRep(TemplateContent, "{fy:fycms}", "Powered by <A href=""http://www.fycms.com"" target=""_blank"">FYCMS"&fycms.Version&"</a> ")
		 '修改版权的一般哥都是很鄙视的
		 GeneralLabel=TemplateContent
		End Function 
		Function Getcurrent(TemplateContent)'{type:classid="1302474386@---"/}
 			Dim  Match, Matches ,Data_validate,labarr,i
  			Reg.Pattern = "\[type:([\s\S]+?)\]"
   			Set Matches = Reg.Execute(TemplateContent)
			IF Matches.Count>0 Then
				For Each Match In Matches
 					LabArr=GetAttribute(Match.SubMatches(0))
 					If  IsArray(LabArr) Then 
  						For I=0 To Ubound(LabArr)
 							Select Case LabArr(I,0)
								Case "classid":Data_validate= GetClassID(LabArr(I,1)) 
								Case "allclassid":Data_validate= GetClassID(Application(fycmsN & "classid")&LabArr(I,1)) 
							End Select
						Next
					Else 
						Select Case Match.SubMatches(0)
							Case "classid":Data_validate= Application(fycmsN & "classid")
							Case "rootclassid"
								If Trim(fycms.ACT_L(Application(fycmsN & "classid"),11))="0" Then 
									Data_validate=Application(fycmsN & "classid")
								Else 
									Data_validate=fycms.ACT_L(Application(fycmsN & "classid"),11)
								End If 
						 	Case "allclassid":Data_validate=fycms.TempClassID(Application(fycmsN & "classid"),",")
							Case "id":Data_validate= Application(fycmsN & "id")
							Case "modeid"
								If  Application(fycmsN & "modeid")=0 Then Data_validate=1 Else Data_validate=Application(fycmsN & "modeid")
  						End Select
 					End If
 				 	TemplateContent = Replace(TemplateContent, Match.Value,Data_validate)
   				Next
  			End If
 				Getcurrent=TemplateContent
 		End Function 
		Function GetClassID(classid)
  			If InStr(classid,"@")>0 Then 
 				GetClassID=fycms.TempClassID(Split(classid,"@")(0),Split(classid,"@")(1))		
 			Else 
 				GetClassID=fycms.TempClassID(classid,",")		
 			End If 
		End Function 

	    
		Function listclass(TemplateContent)
   			Dim  Match, Matches ,cids,fs,lrs,LabArr
  			Reg.Pattern = "\[list:(.+?)\]"
   			Set Matches = Reg.Execute(TemplateContent)
			IF Matches.Count>0 Then
 				For Each Match In Matches

					Dim i
					LabArr=GetAttribute(Match.SubMatches(0))
 					If  IsArray(LabArr) Then 
						For I=0 To Ubound(LabArr)
							Select Case LabArr(I,0)
								Case "classid":cids=LabArr(I,1)
								Case "field":fs=LabArr(I,1)
							End Select
						Next
 					Else
						fs=Match.SubMatches(0)
 						cids=ChkNumeric(Application(fycmsN & "classid"))
					End If 
 						If cids="0" Then 
							TemplateContent = Replace(TemplateContent, Match.Value,"没找到对应的栏目")
						Else 
								select Case LCase(fs)
									Case "classlink"
										TemplateContent = rep(TemplateContent, Match.Value,fycms.DiyClassName(cids))
									Case Else 
											Set lrs=fycms.actexe("select "&fs&" from class_fy where classid="&cids)
											If Not lrs.eof Then 
												TemplateContent = rep(TemplateContent, Match.Value,lrs(fs))
												lrs.Close
											Else 
												TemplateContent = Replace(TemplateContent, Match.Value,"没找到对应的栏目")
											End If 
								End Select 
						End If 
 
  				Next
  			End If
 				listclass=TemplateContent
 		End Function 


 
		Function variables(TemplateContent)
   			Dim  Match, Matches ,Data_variables,VXML
  			Reg.Pattern = "\[v:(.+?)\]"
   			Set Matches = Reg.Execute(TemplateContent)
			IF Matches.Count>0 Then
 				For Each Match In Matches
 				  If FileExists(server.MapPath(fycms.actsys&fycms.SysThemePath&"/"&fycms.NowTheme&"/variables/"&Match.SubMatches(0)&".xml"))    Then 	
						   Set VXML=fycms.NoAppGetXMLFromFile(server.MapPath(fycms.actsys&fycms.SysThemePath&"/"&fycms.NowTheme&"/variables/"&Match.SubMatches(0)&".xml"))
							If IsObject(VXML) And VXML.readyState=4 Then
								If VXML.parseError.errorCode <> 0 Then 
								Else 
								Data_variables = VXML.documentElement.selectSingleNode("vcontent").text
								End If 
							Set VXML=Nothing
						  End If 
						TemplateContent = Replace(TemplateContent, Match.Value,Data_variables)
					Else 
						TemplateContent = Replace(TemplateContent, Match.Value,"没找到"&Match.SubMatches(0)&"变量")
					End If 
  				Next
  			End If
 				variables=TemplateContent
 		End Function 


		Function GetRequest(TemplateContent)
  			Dim  Match, Matches ,Data_validate,labarr,i,Data_default
			Dim  Data_fun_Arr,Data_fun,TempArr,tempArrstr,f
  			Reg.Pattern = "\[get:([\s\S]+?)\]"
   			Set Matches = Reg.Execute(TemplateContent)
			IF Matches.Count>0 Then
				For Each Match In Matches
 					LabArr=GetAttribute(Match.SubMatches(0))

					If  IsArray(LabArr) Then 
				
  						For I=0 To Ubound(LabArr)
							Select Case LabArr(I,0)
								Case "validate":Data_validate= LabArr(I,1) 
								Case "default":Data_default=LabArr(I,1)
								Case "fun":Data_fun=LabArr(I,1)
							End Select
						Next 
							 
						 
						Data_validate=checkreg(fycms.s(Split(Match.SubMatches(0)," ")(0)),Data_validate)

						If Data_validate=True  Then 
							Data_validate=fycms.s(Split(Match.SubMatches(0)," ")(0))
						Else
							If  Trim(Data_default)<>"" Then 
								Data_validate=Data_default
							Else 
								Data_validate=""
							End If 
						End If 



						If 	Len(Data_fun)>0 Then
							Data_fun_Arr=Split(Data_fun,"@")
							For f=0 To UBound(Data_fun_Arr)
									If InStr(Data_fun_Arr(f),",")>0 Then 
										TempArr=Split(Data_fun_Arr(f),",")
										TempArrstr=Replace(Data_fun_Arr(f),TempArr(0),"")
										 execute("Data_validate="&TempArr(0)&"("""&RemAsp(Data_validate)&""""&TempArrstr&")")
									Else 
 										 execute("Data_validate="&Data_fun_Arr(f)&"("""&RemAsp(Data_validate)&""")")
									End If 
  							Next 
						End If 
 
					Else 
					 
						Data_validate=Rsql(fycms.s(Match.SubMatches(0)))
					End If 
   				 	TemplateContent = Replace(TemplateContent, Match.Value,Data_validate)
						Data_validate="":Data_default=""

  				Next
  			End If
 			 	GetRequest=TemplateContent
 		End Function 
		Function checkreg(requesttitle,chktype)
				chktype=rep(chktype,">","]")
				chktype=rep(chktype,"<","[")
   				checkreg=checkdata(requesttitle,chktype)
  		End Function 
 		Function  checkdata(byval chkstr,byval chktype)
 			Dim  pattern
			Select  Case  cstr(chktype)
			case "1": pattern = "^\d+$"   ' 数字
			case "2": pattern = "^[A-Za-z]+$"   ' 英文
			case "3": pattern = "^[A-Za-z0-9]+$"   ' 由数字和26个英文字母组成的字符串
			case "4": pattern ="[\w\-\.]+@[A-Za-z0-9]+\.(([A-Za-z0-9]{2,4})|([A-Za-z0-9]{2,4}\.[A-Za-z]{2,4}))$"   ' Email地址
			case "5": pattern = "[0-9]d{5}" '邮政编码
			case "6": pattern = "^[0-9\.]+$"  ' 数字,支持小数点
			case "7": pattern = "(^|[^<=""])(http|https)(:(\/\/|\\\\)(([\w\/\\\+\-~`@:%])+\.)+([\w\/\\\.\=\?\+\-~`@\':!%#]|(&amp;)|&)+)"   ' http,https地址
			case "8": pattern = "^[\u0391-\uFFE5]+$"'中文
			case "9": pattern = "^(\d{14}|\d{17})(\d|[xX])$"'身份证
			case "10": pattern="^(0[0-9]{2,3}\-)?([2-9][0-9]{6,7})+(\-[0-9]{1,4})?$" '电话号码.必须要加区号
			case "11" 
 				if  IsDate(chkstr)=false then
					checkdata=false:Exit Function 
				Else 
					checkdata=true:Exit Function 
				End  if
			case "12": pattern = "^(13[0-9]|15[0|1|2|3|6|7|8|9]|18[6|7|8|9])\d{8}$"'验证手机号码 
			case "13": pattern = "^((http|https|ftp):(\/\/|\\\\)(([\w\/\\\+\-~`@:%])+\.)+([\w\/\\\.\=\?\+\-~`@\':!%#]|(&)|&)+|\/([\w\/\\\.\=\?\+\-~`@\':!%#]|(&)|&)+)\.(jpeg|jpg|gif|png|bmp)$"  ' http,https,ftp开头的图片路径,不支持中文
			case "14": pattern = "^\w+\.(\w){1,30}$"  ' 文件名格式,不支持中文
			case "15": pattern = "^[0-9\,\.]+$"  ' 整数,带格式化,如:100,000
			case Else

 				if  chktype="" Then
 					checkdata=true:Exit Function 
				Else 
 					pattern = chktype
				End  if
				 
				 
			End    select
			Dim  reg : set reg = new regexp : reg.ignorecase = true : reg.global = true
			reg.pattern = pattern
			checkdata = reg.test(trim(chkstr))
		End  Function 

		Function GetTabContentPage(TemplateContent,ClassID,PageUrl,ClassPath,IndexHtml,IFMakeHtml,diyfypage)
			if isdebug=0 then On Error Resume Next
 			Dim  LabArr,Match, Matches,jj:jj=1 
			Dim Loopstr,Data_Table,Data_top,Data_Field,Data_Where,Data_Order,Data_CountID
			Dim PageSize,TemplateContents
			Dim ModeID,Data_dbsql
			ModeID=fycms.ACT_L(ClassID,10) 
			'Application(fycmsN & "modeid")=ModeID
	 		Application(fycmsN & "classid")=ClassID
 			TemplateContent=Loadfile(TemplateContent)
 			TemplateContent=variables(TemplateContent)
 			TemplateContent=httpLoadfile(TemplateContent)
			TemplateContent=GeneralLabel(TemplateContent)
			TemplateContent=GetRequest(TemplateContent)
 			TemplateContent=GetTabForContent(TemplateContent)
			TemplateContent=Getcurrent(TemplateContent)
 			TemplateContent=GetTabContent(TemplateContent)
 		 	Dim pagelistfycms:pagelistfycms=Getpagelist("\{pagelist\}([\s\S]+?)\{\/pagelist\}",TemplateContent)
			Dim pi 
		    If RegExists("\{pagelist\}([\s\S]+?)\{\/pagelist\}", TemplateContent) Then	
				TemplateContent=RegReplace(TemplateContent, "\{pagelist\}([\s\S]+?)\{\/pagelist\}", "{{pagelist_www.fycms.com}}")
			End If 
 		  	TemplateContents=TemplateContent
			Reg.Pattern = "\{fypage([\s\S]+?)\}([\s\S]+?)\{\/fypage\}"
  			Set Matches = Reg.Execute(TemplateContent)
  			IF Matches.Count>0 Then
			For Each Match In Matches
  				 Dim I 
 				 LabArr=GetAttribute(Match.SubMatches(0))
 				 Loopstr = Match.SubMatches(1)	  ' innerText
				 Strtemp=Loopstr
  				For I=0 To Ubound(LabArr)
  					Select Case LabArr(I,0)
  						Case "field":Data_field=LabArr(I,1)
						Case "table":Data_table=LabArr(I,1)
						Case "top":Data_top=LabArr(I,1)
						Case "where":Data_where=LabArr(I,1)
						Case "order":Data_order=LabArr(I,1)
						Case "countid":Data_CountID=LabArr(I,1)
						Case "dbsql":Data_dbsql=LabArr(I,1)
					End Select
				Next
				Data_where=rep(Data_where,"`","""")
				Data_where=apiexe(Data_where)
				If len(Data_Table)=0 Or Data_table="#thistable" Then
					If fycms.ACT_C(Application(fycmsN & "modeid"),2)="0" Then 
						Data_table="Article"
					Else 
						Data_Table=fycms.ACT_C(Application(fycmsN & "modeid"),2)
					End If 
				Else 
					If  IsNumeric(Data_Table) Then 
						Data_Table=fycms.ACT_C(Data_Table,2)
					End If 
				End If 
				If len(Data_top)=0 Or Not IsNumeric(Data_top) Then Data_top = 30
				If Len(Data_Field) = 0 Then Data_Field = "*"
				If Len(Data_Where) = 0 Then 
					Data_Where = fycms.GetfieldWhere(Data_Table)
				Else 
					If InStr(Data_Where, "默认条件") > 0  Then 
						 Data_Where=rep(Data_Where,"默认条件",fycms.GetfieldWhere(Data_Table))
					End If 
				
					If InStr(Data_Where, "图片") > 0  Then 
						If   fycms.GetTable(Data_Table)<>"0" Then 
							 Data_Where=rep(Data_Where,"图片","picurl<>''")
						Else 
							 Data_Where=rep(Data_Where,"图片"," 1=1 ")
						End If 
					End If 
 				End If 

				If Len(Data_Order) = 0 Then
					If fycms.GetTable(Data_Table)="1"  and Data_Order="" Then 
						Data_Order = " Order By  IsTop Desc,OrderID desc,ID Desc "
					Else 
						if Data_Order="" then Data_Order =  fycms.GetfieldID(Data_Table)  else Data_Order=" order by "&Data_Order
					End If 
				Else 
					If Data_Order="rnd" Then 
						If DataBaseType="access" Then 
							Randomize
							If IsNumeric(fycms.GetTable(Data_Table)) Then 
								Data_Order = "  Order By rnd(-(ID+" & rnd() & "))"
							Else 
								Data_Order = "  Order By rnd(-("&fycms.GetCountID(Data_Table)&"+" & rnd() & "))"
							End If 
						Else 
							Data_Order ="  Order By newid() "
						End If 
					Else 
						Data_Order = " Order By  "&Data_Order
					End If 
				End If 
				'If Len(Data_Order) = 0 Then Data_Order = " Order By [ID] Desc " Else Data_Order=" Order By "&Data_Order
 				If Len(Data_CountID) = 0 Then Data_CountID = " [ID]  "
				If Len(Data_top) = 0 Then Data_top = 30
				Dim SqlCount,PageCount,rs,rssql,strtemp,ModID,StrT,BackValues,StrData,PageNum
				PageSize = Data_top
 				Dim DataSourceStr,DataSourceType
				Data_dbsql=ChkNumeric(Data_dbsql)
				
				If Data_dbsql<>0 Then 
					DataSourceType=fycms.dbquery(Data_dbsql,1)
					DataSourceStr=fycms.dbquery(Data_dbsql,2)
					if DataSourceType=1 Or DataSourceType=5 Or DataSourceType=6 Then  DataSourceStr=fycms.GetAbsolutePath(DataSourceStr)
					If OpenExtConn(DataSourceType,DataSourceStr)=false Then GetTabContentPage=Replace(TemplateContent, Match.Value,"外部数据库连接出错"):Exit Function
					SqlCount = tconn.execute("select count("&Data_CountID&") from ["&Data_Table&"] Where "&Data_Where&"   ",0,1)(0)
				Else 
					SqlCount = conn.execute("select count("&Data_CountID&") from ["&Data_Table&"] Where "&Data_Where&"   ",0,1)(0)
				End If 
			
  				PageCount = abs(int(-abs(SqlCount/PageSize)))
  				Dim pnum,TempStr
				If  (SqlCount mod PageSize)=0 then
					PageNum = SqlCount \ PageSize
				Else 
					PageNum = SqlCount \ PageSize + 1
				End  If  
 				if len(PageUrl) = 0 or PageUrl = 0 then PageUrl = 1
				If PageUrl>PageCount Then PageUrl=1
				set rs = server.createobject("adodb.recordset")
				rssql = "select "&Data_Field&" from ["&Data_Table&"]  Where "&Data_Where&"  "&Data_order&" "
			
  				If IFMakeHtml=true Then 
					if PageNum=0 Then 

						If RegExists("{eof}([\s\S]+?){/eof}", Strtemp) Then
								Strtemp=labelclear(Strtemp,False)
							Else 
								Strtemp=""
							End If 
						TemplateContent=Replace(TemplateContent, Match.Value,Strtemp)
						TemplateContent=rep(TemplateContent,"{{pagelist_www.fycms.com}}","")
						TemplateContent=apiexe(TemplateContent)
						TemplateContent=ACTIF("",TemplateContent)
						 TemplateContent=listclass(TemplateContent)
						 Call SaveFile(TemplateContent,ClassPath & "index.html")
						Exit Function 
					End If 
					Strtemp=labelclear(Strtemp,True)
  					For pnum=0 To PageNum-1
 						If Data_dbsql=0 Then 
							rs.open rssql,conn,1,1,&h0001
						Else 
							rs.open rssql,tconn,1,1
						End If 
 						rs.absoluteposition=rs.absoluteposition+((abs(PageUrl)-1)*PageSize)
						For  i = 0 to PageSize-1
							 if rs.eof then 
 								If RegExists("{eof}([\s\S]+?){/eof}", Strtemp) Then
									Strtemp=labelclear(Strtemp,False)
								Else 
									Strtemp=""
								End If 
 								Exit  For
							 End If 
							 If i Mod 2 =0 Then ModID=0 Else ModID=1
 							 StrT = InStrRep(Strtemp,"[AutoID0]",i) 
							 StrT = InStrRep(StrT,"[AutoID1]",jj)
							 StrT = InStrRep(StrT,"[AutoID2]",jj+1)
							 StrT = InStrRep(StrT,"[ModID]",ModID)
 					  		 Loopstr=fycms.forlabel(StrT,rs,Data_table)
  							 BackValues=BackValues&Parser_Tags("\{([\s\S]+?)}",Loopstr, Rs,False)
 							 BackValues=apiexe(BackValues)
							 BackValues=ACTIF("",BackValues)
 							 jj=jj+1
							 rs.movenext
 						 Next
   						 tempstrs=tempstrs&pagelist(ModeID,IFMakeHtml,Replace(TemplateContents, Match.Value,BackValues),pagelistfycms,ClassID,rs.RecordCount,ClassPath,PageUrl,PageNum,Data_top,IndexHtml,diyfypage)
						
						
						PageUrl=PageUrl+1
						BackValues=""
						rs.close
 					Next 
 				Else 
  						If Data_dbsql=0 Then 
							rs.open rssql,conn,1,1,&h0001
						Else 
							rs.open rssql,tconn,1,1
						End If 
						
   						if rs.eof or rs.bof Then 
 							If RegExists("{eof}([\s\S]+?){/eof}", Strtemp) Then
								Strtemp=labelclear(Strtemp,False)
							Else 
								Strtemp=""
							End If 
							GetTabContentPage=Replace(TemplateContent, Match.Value,Strtemp)
  							GetTabContentPage=rep(GetTabContentPage,"{{pagelist_www.fycms.com}}","")
							GetTabContentPage=ACTIF("",GetTabContentPage)
							GetTabContentPage=apiexe(GetTabContentPage)
							GetTabContentPage=listclass(GetTabContentPage)
 							Exit Function 
						End If 
 						Strtemp=labelclear(Strtemp,True)
 						rs.absoluteposition=rs.absoluteposition+((abs(PageUrl)-1)*PageSize)
  						For  i = 0 to PageSize-1
							 if rs.eof then exit For
 							 If i Mod 2 =0 Then ModID=0 Else ModID=1
 							 	 StrT = InStrRep(Strtemp,"[AutoID0]",i) 
								 StrT = InStrRep(StrT,"[AutoID1]",jj)
								 StrT = InStrRep(StrT,"[AutoID2]",jj+1)
 								 StrT = InStrRep(StrT,"[ModID]",ModID)
 					  			 Loopstr=fycms.forlabel(StrT,rs,Data_table)
    						     BackValues=BackValues&Parser_Tags("\{([\s\S]+?)}",Loopstr, Rs,False)
								 BackValues=apiexe(BackValues)
								 BackValues=ACTIF("",BackValues)
								 jj=jj+1
								 rs.movenext
						 Next
  						 tempstrs=tempstrs&pagelist(ModeID,IFMakeHtml,Replace(TemplateContents, Match.Value,BackValues),pagelistfycms,ClassID,rs.RecordCount,ClassPath,PageUrl,PageNum,Data_top,IndexHtml,diyfypage)
						 BackValues=""
						 rs.close
 				End If 
  			Next 
				Dim tempstrs
  				GetTabContentPage=tempstrs
 		 		GetTabContentPage= ACTIF("",GetTabContentPage)
 		 		GetTabContentPage= apiexe(GetTabContentPage)
				GetTabContentPage=listclass(GetTabContentPage)
			Else 
  		 		TemplateContent= ACTIF("",TemplateContent)
   		 		TemplateContent= apiexe(TemplateContent)
				 TemplateContent=listclass(TemplateContent)
				GetTabContentPage=TemplateContent
 				If IFMakeHtml=True  Then  Call SaveFile(TemplateContent,ClassPath & "index.html")
			End If
		End Function 
		Public Function pagelist(ModeID,IFMakeHtml,TemplateContent,pagelistfycms,ClassID,PageCount,ClassPath,PageUrl,PageNum,listsize,IndexHtml,diyfypage)
  			 Dim index,HomeLink,FileName,FExt,LinkUrlFileName,FileNamePath
 			  HomeLink = IndexHtml
			  FExt = MID(Trim(IndexHtml), InStrRev(Trim(IndexHtml), ".")) 
			  FileName = Replace(Trim(IndexHtml), FExt, "") 
			  LinkUrlFileName = FileName
 			   If PageUrl = 1 Then
				  FileNamePath=ClassPath&IndexHtml
			   Else
				  FileNamePath=ClassPath&FileName & "_" & PageUrl & FExt
			   End If
  		    TemplateContent = rep(TemplateContent,"{$pagenum}",PageNum)
		    If InStr(TemplateContent,"{{pagelist_www.fycms.com}}") Then 
				If classid="0" Then 
					pagelist = rep(TemplateContent,"{{pagelist_www.fycms.com}}",GetPageStr(ModeID,ClassID,PageCount,ClassPath,PageUrl,pagelistfycms,listsize,diyfypage))
				Else 
					pagelist = rep(TemplateContent,"{{pagelist_www.fycms.com}}",GetPageStr(ModeID,ClassID,PageCount,ClassPath,PageUrl,pagelistfycms,listsize,"0"))
				End If 
			Else 
				pagelist=TemplateContent
			End If 
	
			If IFMakeHtml=True  Then 
 	    		pagelist= apiexe(pagelist)
				pagelist= ACTIF("",pagelist)
				pagelist=listclass(pagelist)
   			Call SaveFile(pagelist,FileNamePath)
			End If 
  		End Function 
  		Function Getpagelist(regx,TemplateContent)
			Dim  Match, Matches 
  			Reg.Pattern = regx
   			Set Matches = Reg.Execute(TemplateContent)
			IF Matches.Count>0 Then
				For Each Match In Matches
 					Getpagelist= Match.SubMatches(0)
 				Next 
 			End if
        End Function 
 		Function GetPageStr(ModeID,ClassID,SqlCount,FilePath,PageUrl,pagelistfycms,listsize,diyfypage)
		 Dim LinkUrlFileName ,actpages,FExt,pagetmp,clngpagecount
		 If SqlCount<=0 Then 	 GetPageStr="no data":Exit Function 
		 If SqlCount="" then
			 clngpagecount=1
		 Else
		  clngpagecount=abs(int(-abs(SqlCount/listsize)))'总页数
		 End If
 		 If PageUrl>clngpagecount Then
		  PageUrl=clngpagecount
		 End If
 		 Dim makepage
		 If ClassID<>"0" And Trim(diyfypage)="0" Then 
			 makepage=fycms.ACT_L(ClassID,28)
			Select Case makepage
				Case "3"
					LinkUrlFileName="list.asp?cid="&ClassID
					actpages="&page="
  				Case "1"
 					LinkUrlFileName=FilePath&"Index"
					actpages="_"
					FExt=".html"
				Case "2"
					dim listrewriteurl,classrewriteurl
 					listrewriteurl=fycms.s("cid")
					classrewriteurl=Content_list_url
					If Instr(classrewriteurl,"{id}") > 0 Then classrewriteurl = Replace(classrewriteurl,"{id}",listrewriteurl)
					If Instr(classrewriteurl,"{classid}") > 0 Then classrewriteurl = Replace(classrewriteurl,"{classid}",listrewriteurl)
					If Instr(classrewriteurl,"{modeid}") > 0 Then classrewriteurl = Replace(classrewriteurl,"{modeid}","([0-9]+)")
					If Instr(classrewriteurl,"{pinyinnum}") > 0 Then classrewriteurl = Replace(classrewriteurl,"{pinyinnum}",listrewriteurl)
					LinkUrlFileName=fycms.domain&classrewriteurl
 					actpages="/"
			End Select 
		Else 
			LinkUrlFileName=diyfypage
			If ClassID<>"0" Then FExt=".html"
		End If 
 		Dim Btn_First:Btn_First=languagerlist(ModeID,"lang_page_index")
		Dim Btn_Prev:Btn_Prev=languagerlist(ModeID,"lang_page_pre")
 		Dim int_prvpage
		Dim index_link,pre_link
  		Dim i,end_page,start_page,pstr
 		If (Application(Cstr(fycmsN & "PageList"))="")   Then
 			If RegExists("\[page\]([\s\S]+?)\[\/page\]", pagelistfycms) Then	
 				pstr=Getpagelist("\[page\]([\s\S]+?)\[\/page\]",pagelistfycms)
				pagelistfycms=RegReplace(pagelistfycms, "\[page\]([\s\S]+?)\[\/page\]", "{{0ad0bd6496255e4341a69164c083ff1f}}")
			End If 
			Application(Cstr(fycmsN & "PageList"))=pstr
		Else 
 			pstr=Application(Cstr(fycmsN & "PageList"))
 		End If 
 	    If RegExists("\[page\]([\s\S]+?)\[\/page\]", pagelistfycms) Then	
	 
			pstr=Getpagelist("\[page\]([\s\S]+?)\[\/page\]",pagelistfycms)
			pagelistfycms=RegReplace(pagelistfycms, "\[page\]([\s\S]+?)\[\/page\]", "{{0ad0bd6496255e4341a69164c083ff1f}}")
	    End If 
 	    If PageUrl=1 Then
 		Else
			  int_prvpage=PageUrl-1
			  Btn_First="<a href="""&LinkUrlFileName&FExt & "" & """>" & Btn_First&"</a>" & VbCrLf
			  If PageUrl=2 Then 
				   Btn_Prev="<a href=""" & LinkUrlFileName& FExt & """>" & Btn_Prev&"</a>" & VbCrLf
			  Else  
				  Btn_Prev="<a href=""" & LinkUrlFileName&actpages& CStr(int_prvpage) & FExt & """>" & Btn_Prev&"</a>" & VbCrLf
			  End If 
		End If
   		start_page=1
		if PageUrl=0 then
			pagetmp=pagetmp&"<span>0</span>" & VbCrLf
		Else 
			if PageUrl>1 then
				start_page=PageUrl
				if (PageUrl<=page_list_num) then
				start_page=1
				end if
				if (PageUrl>page_list_num) then
				start_page=PageUrl-2
				end if
			End  If
 			end_page=start_page+page_list_num
			If  end_page>clngpagecount then
			end_page=clngpagecount
			End  If
			Dim p_temp_str
			'pstr="[page]<a [thispage]  href=""[link]"">[pagename]</a>[/page]"
			For i=start_page to end_page
				p_temp_str=pstr
					   p_temp_str=rep(p_temp_str,"[pagename]",i)
				if i=PageUrl Then
					   p_temp_str=rep(p_temp_str,"[thispage]"," class=""thispage"" ")
					   If i=1 And makepage=1 Then 
						   p_temp_str=rep(p_temp_str,"[link]",LinkUrlFileName& FExt)
					   Else 
						   p_temp_str=rep(p_temp_str,"[link]",LinkUrlFileName&actpages& i& FExt)
					   End If 
				Else
					If i=1 Then 
 					   p_temp_str=rep(p_temp_str,"[thispage]"," ")
					   p_temp_str=rep(p_temp_str,"[link]",LinkUrlFileName& FExt)
					Else 
  					   p_temp_str=rep(p_temp_str,"[thispage]"," ")
					   p_temp_str=rep(p_temp_str,"[link]",LinkUrlFileName&actpages& i & FExt)
					End If 
				End  If
 				pagetmp=pagetmp&p_temp_str
				'p_temp_str=""
			Next
 		End  If
  		Dim Btn_Next:Btn_Next=languagerlist(ModeID,"lang_page_next")
		Dim Btn_Last:Btn_Last=languagerlist(ModeID,"lang_page_last")
		Dim Btn_Next_link,Btn_Last_link
 	    Dim int_Nextpage
		 If PageUrl>=clngpagecount Then
 			 Btn_Next_link="#"
			 Btn_Last_link="#"
 		 Else
		  Int_NextPage=PageUrl+1
 			 Btn_Next_link=LinkUrlFileName&actpages& CStr(int_nextpage) & FExt
			 Btn_Last_link=LinkUrlFileName&actpages& CStr(clngpagecount) & FExt
		 End If
 		Dim selectpage
 		selectpage="<select name='select' onChange='javascript:window.location.href=(this.options[this.selectedIndex].value);'>"
		For  i=1 to clngpagecount
			If  i=1 Then 
 				selectpage=selectpage & "<option value=""" &LinkUrlFileName& FExt & """"
			Else 
				selectpage=selectpage & "<option value=""" &LinkUrlFileName&actpages& CStr(i) & FExt & """"
 			End If 
		If i=PageUrl then
		selectpage=selectpage & " selected=""selected"""
		End if
		selectpage=selectpage & ">"&i&"</option>"
		next
		selectpage=selectpage &"</select>" & VbCrLf
		Dim record_str,listsize_str
		record_str=rep(languagerlist(ModeID,"lang_page_record"),"$record",SqlCount)
		listsize_str=rep(languagerlist(ModeID,"lang_page_listsize"),"$listsize",listsize)
		
		Dim get_page_temp
		get_page_temp=pagelistfycms
		get_page_temp=rep(get_page_temp,"[index]",Btn_First)
		get_page_temp=rep(get_page_temp,"[pre]",Btn_Prev)
		get_page_temp=rep(get_page_temp,"{{0ad0bd6496255e4341a69164c083ff1f}}",pagetmp)
		get_page_temp=rep(get_page_temp,"[next]",Btn_Next)
		get_page_temp=rep(get_page_temp,"[nextpage]",Btn_Next_link)
		get_page_temp=rep(get_page_temp,"[end]",Btn_Last)
		get_page_temp=rep(get_page_temp,"[endlink]",Btn_Last_link)
		get_page_temp=rep(get_page_temp,"[selectpage]",selectpage)
		get_page_temp=rep(get_page_temp,"[record]",record_str)
		get_page_temp=rep(get_page_temp,"[listsize]",listsize_str)
 
 		GetPageStr= get_page_temp
  	 End Function  
 
	Function addCache(ByVal fyCacheName,ByVal vNewValue)
		ReDim Cache_Data(2)
		Cache_Data(0) = vNewValue
		Cache_Data(1) = Now()
		Application.Lock()
		Application(fycmsN&fyCacheName)=Cache_Data
		Application.UnLock()
	End Function
	Function CheckCache(ByVal fyCacheName,ByVal CacheDate)
		CheckCache=False
		Dim CacheData
 		IF IsNull(fyCacheName) Or Len(fyCacheName)=0 Then Exit Function
		CacheData=Application(fycmsN&fyCacheName)
		IF IsEmpty(CacheData) Or Not IsArray(CacheData) Then CheckCache=True:Exit Function
		IF CLng(DateDiff("s",CDate(CacheData(1)),Now()))>=CLng(CacheDate * 60) Then CheckCache=True
	End Function
	Function getcache(ByVal fyCacheName)
		Dim CacheData
		CacheData=Application(fycmsN&fyCacheName)
		IF IsArray(CacheData) Then getcache=CacheData(0) Else getcache=fyCacheName
	End Function

  		Function GetTabContent(TemplateContent)
 			if isdebug=0 then On Error Resume Next
			 
			Dim  Match, Matches,LabArr,Loopstr,Data_table,Data_top,Data_order,BackValues,Data_Field,Data_Where,actsql
			Dim Data_sql,fycms_sql,Data_dbsql,Data_group
			Dim Data_cachename,Data_cachetime
			Reg.Pattern = "\{fycms\}([\s\S]+?)\{\/fycms\}|\{fycms([\s\S]+?)\}([\s\S]+?)\{\/fycms\}"
   			Set Matches = Reg.Execute(TemplateContent)
 			IF Matches.Count>0 Then
			For Each Match In Matches
 				Dim I
 				If Match.SubMatches(0)<>"" Then 
					 Loopstr = Match.SubMatches(0)	  ' innerText
					 Data_cachename = "fycms.2012"
				Else 
 					 LabArr=GetAttribute(Match.SubMatches(1))
					 Data_cachename = md5(Match.SubMatches(1)&Match.SubMatches(2),32)
					 Loopstr = Match.SubMatches(2)	  ' innerText
 				End If 
				If IsArray(LabArr) Then 
						For I=0 To Ubound(LabArr)
							Select Case LabArr(I,0)
								Case "field":Data_field=LabArr(I,1)
								Case "table":Data_table=LabArr(I,1)
								Case "top":Data_top=LabArr(I,1)
								Case "where":Data_where=LabArr(I,1)
								Case "order":Data_order=LabArr(I,1)
								Case "sql":Data_sql=LabArr(I,1)
								Case "dbsql":Data_dbsql=LabArr(I,1)
								Case "group":Data_group=LabArr(I,1)
								Case "cache":Data_cachetime=LabArr(I,1)
							End Select
						Next
				End If 
				Data_where=rep(Data_where,"`","""")
 			If  len(Data_cachetime)>0 Then 
  			 If  CheckCache(Data_cachename&"labelcachename"&Data_cachetime,Data_cachetime) Then 
    						If len(Data_Table)=0 Or Data_table="#thistable" Then
							If fycms.ACT_C(Application(fycmsN & "modeid"),2)="0" Then 
								Data_table="Article"
							Else 
								Data_Table=fycms.ACT_C(Application(fycmsN & "modeid"),2)
							End If 
						Else 
							If  IsNumeric(Data_Table) Then 
								Data_Table=fycms.ACT_C(Data_Table,2)
							End If 
						End If 


						If Len(Data_group) > 0 Then Data_group =" group by "&Data_group
 						If len(Data_top)=0 Or Not IsNumeric(Data_top) Then Data_top = 10
						If Len(Data_Field) = 0 Then Data_Field = "*"
						If Len(Data_Where) = 0 Then 
							Data_Where = fycms.GetfieldWhere(Data_Table)
						Else 
							If InStr(Data_Where, "默认条件") > 0  Then 
								 Data_Where=rep(Data_Where,"默认条件",fycms.GetfieldWhere(Data_Table))
							End If 
						
							If InStr(Data_Where, "图片") > 0  Then 
								If   fycms.GetTable(Data_Table)<>"0" Then 
									 Data_Where=rep(Data_Where,"图片","picurl<>''")
								Else 
									 Data_Where=rep(Data_Where,"图片"," 1=1 ")
								End If 
							End If 
 						End If 
 						If Len(Data_sql)=0 Then  fycms_sql="" Else fycms_sql = " "&Data_sql&" "
 						If Len(Data_Order) = 0 Then
							If fycms.GetTable(Data_Table)="1"  and Data_Order="" Then 
								Data_Order = " Order By  IsTop Desc,OrderID desc,ID Desc "
							Else 
								if Data_Order="" then Data_Order =  fycms.GetfieldID(Data_Table)  else Data_Order=" order by "&Data_Order
							End If 
 						Else 
							If Data_Order="rnd" Then 
								If DataBaseType="access" Then 
									Randomize
									If IsNumeric(fycms.GetTable(Data_Table)) Then 
										Data_Order = "  Order By rnd(-(ID+" & rnd() & "))"
									Else 
										Data_Order = "  Order By rnd(-("&fycms.GetCountID(Data_Table)&"+" & rnd() & "))"
									End If 
								Else 
									Data_Order ="  Order By newid() "
								End If 
							Else 
								Data_Order = " Order By  "&Data_Order
							End If 
						End If 
						
						If Trim(fycms_sql)="" Then 
							actsql="select Top "&Data_top&" "&Data_Field&"   from  "&Data_Table&" Where "&Data_Where&fycms_sql&Data_group&" "&Data_Order&" "
						Else 
							actsql=fycms_sql
						End If 
     				 	BackValues=GetForData(Data_dbsql,"","\{([\s\S]+?)}",Loopstr,Data_Table,actsql,Data_top,false)
						BackValues=listclass(BackValues)
 						addCache Data_cachename&"labelcachename"&Data_cachetime,BackValues
   							  
			Else
  				BackValues= getcache(Data_cachename&"labelcachename"&Data_cachetime)
 			End If 
 				TemplateContent = Replace(TemplateContent, Match.Value,BackValues)
				Data_cachename="":Data_cachetime="":BackValues=""
				Data_Where="":Data_table="":Data_order="":Data_field="":Data_top="":Data_sql="":Data_dbsql="":Data_cachename="":Data_cachetime="":Data_group=""

		Else 
			
 
 		
   						If len(Data_Table)=0 Or Data_table="#thistable" Then
							If fycms.ACT_C(Application(fycmsN & "modeid"),2)="0" Then 
								Data_table="Article"
							Else 
								Data_Table=fycms.ACT_C(Application(fycmsN & "modeid"),2)
							End If 
						Else 
							If  IsNumeric(Data_Table) Then 
								Data_Table=fycms.ACT_C(Data_Table,2)
							End If 
						End If 
 						If len(Data_top)=0 Or Not IsNumeric(Data_top) Then Data_top = 10
						If Len(Data_Field) = 0 Then Data_Field = "*"
						If Len(Data_Where) = 0 Then 
							Data_Where = fycms.GetfieldWhere(Data_Table)
						Else 
							If InStr(Data_Where, "默认条件") > 0  Then 
								 Data_Where=rep(Data_Where,"默认条件",fycms.GetfieldWhere(Data_Table))
							End If 
						
							If InStr(Data_Where, "图片") > 0  Then 
								If   fycms.GetTable(Data_Table)<>"0" Then 
									 Data_Where=rep(Data_Where,"图片","picurl<>''")
								Else 
									 Data_Where=rep(Data_Where,"图片"," 1=1 ")
								End If 
							End If 
 						End If 
 						If Len(Data_sql)=0 Then  fycms_sql="" Else fycms_sql = " "&Data_sql&" "
 						If Len(Data_Order) = 0 Then
							If fycms.GetTable(Data_Table)="1"  and Data_Order="" Then 
								Data_Order = " Order By  IsTop Desc,OrderID desc,ID Desc "
							Else 
								if Data_Order="" then Data_Order =  fycms.GetfieldID(Data_Table)  else Data_Order=" order by "&Data_Order
							End If 
 						Else 
							If Data_Order="rnd" Then 
								If DataBaseType="access" Then 
									Randomize
									If IsNumeric(fycms.GetTable(Data_Table)) Then 
										Data_Order = "  Order By rnd(-(ID+" & rnd() & "))"
									Else 
 										Data_Order = "  Order By rnd(-("&fycms.GetCountID(Data_Table)&"+" & rnd() & "))"
									End If 
								Else 
									Data_Order ="  Order By newid() "
								End If 
							Else 
								Data_Order = " Order By  "&Data_Order
							End If 
						End If 
						
						If Trim(fycms_sql)="" Then 
							actsql="select Top "&Data_top&" "&Data_Field&"   from  "&Data_Table&" Where "&Data_Where&fycms_sql&Data_group&" "&Data_Order&" "
						Else 
							actsql=fycms_sql
						End If 
       				 	BackValues=GetForData(Data_dbsql,"","\{([\s\S]+?)}",Loopstr,Data_Table,actsql,Data_top,false)
						BackValues=listclass(BackValues)
						Data_Where="":Data_table="":Data_order="":Data_field="":Data_top="":Data_sql="":Data_dbsql="":Data_cachename="":Data_cachename="":Data_group=""
 						TemplateContent = Replace(TemplateContent, Match.Value,BackValues)

  
 		End If 
				
	
 			Next 
			End if
  			GetTabContent=TemplateContent
   		End Function 
  
 		Function GetTabForContent(TemplateContent)
			Dim  Match, Matches
 			Dim LabArr,BackValues,Data_cachename,Data_cachetime
		 	Reg.Pattern = "\{fyfor:(.+?)([\s\S]*?)\}([\s\S]+?)\{\/fyfor:\1\}"
 			Set Matches = Reg.Execute(TemplateContent)
			IF Matches.Count>0 Then
				For Each Match In Matches
					LabArr=GetAttribute(Match.SubMatches(1))
					Dim i
					For I=0 To Ubound(LabArr)
						Select Case LabArr(I,0)
							Case "cache":Data_cachetime=LabArr(I,1)
						End Select
					Next
 					Data_cachename = md5(Match.SubMatches(1)&Match.SubMatches(2)&Data_cachetime,32)
 					If  len(Data_cachetime)>0 Then 
						If  CheckCache(Data_cachename&"labelcachename"&Data_cachetime,Data_cachetime) Then 
							BackValues = Getforcache(Match)
							addCache Data_cachename&"labelcachename"&Data_cachetime,BackValues
						Else
							BackValues= getcache(Data_cachename&"labelcachename"&Data_cachetime)
						End If 
					Else 
						BackValues = Getforcache(Match)
					End if
 					TemplateContent = Replace(TemplateContent, Match.Value,BackValues)
		 		    If RegExists("\{fyfor:(.+?)([\s\S]*?)\}([\s\S]+?)\{\/fyfor:\1\}", BackValues) Then	TemplateContent=GetTabForContent(TemplateContent) 
				Next 
			 	Set Matches=Nothing
			End If 
   			GetTabForContent=TemplateContent
   		End Function 


		Function Getforcache(Match)
				Dim  Data_table,Data_top,Data_order,Data_Field,Data_Where,actsql,Data_cachetime
				Dim LabArr,Loopstr,Tagsstr,Data_dbsql,Data_group
				Loopstr = Match.SubMatches(2)	
				Tagsstr= Match.SubMatches(0)
				LabArr=GetAttribute(Getcurrent(Match.SubMatches(1)))
 				Dim i
				For I=0 To Ubound(LabArr)
					Select Case LabArr(I,0)
						Case "field":Data_field=LabArr(I,1)
						Case "table":Data_table=LabArr(I,1)
						Case "top":Data_top=LabArr(I,1)
						Case "where":Data_where=LabArr(I,1)
						Case "order":Data_order=LabArr(I,1)
						Case "dbsql":Data_dbsql=LabArr(I,1)
						Case "group":Data_group=LabArr(I,1)
						Case "cache":Data_cachetime=LabArr(I,1)
					End Select
				Next
					Data_where=rep(Data_where,"`","""")
 					If len(Data_Table)=0 Or Data_table="#thistable" Then
						If fycms.ACT_C(Application(fycmsN & "modeid"),2)="0" Then 
							Data_table="Article"
						Else 
							Data_Table=fycms.ACT_C(Application(fycmsN & "modeid"),2)
						End If 
					Else 
						If  IsNumeric(Data_Table) Then 
							Data_Table=fycms.ACT_C(Data_Table,2)
						End If 
					End If 
 					If len(Data_top)=0 Or Not IsNumeric(Data_top) Then Data_top = 10
					If Len(Data_Field) = 0 Then Data_Field = "*"
					If Len(Data_group) > 0 Then Data_group = "group by "&Data_group
					
					If Len(Data_Where) = 0 Then 
						Data_Where = fycms.GetfieldWhere(Data_Table)
					Else 
						If InStr(Data_Where, "默认条件") > 0  Then 
							 Data_Where=rep(Data_Where,"默认条件",fycms.GetfieldWhere(Data_Table))
						End If 
					
						If InStr(Data_Where, "图片") > 0  Then 
							If   fycms.GetTable(Data_Table)<>"0" Then 
								 Data_Where=rep(Data_Where,"图片","picurl<>''")
							Else 
								 Data_Where=rep(Data_Where,"图片"," 1=1 ")
							End If 
						End If 

					End If 
					Data_Where=Getcurrent(Data_Where)
					If Len(Data_Order) = 0 Then
						If fycms.GetTable(Data_Table)="1"  and Data_Order="" Then 
							Data_Order = " Order By  IsTop Desc,OrderID desc,ID Desc "
						Else 
							if Data_Order="" then Data_Order =  fycms.GetfieldID(Data_Table)  else Data_Order=" order by "&Data_Order
						End If 
					Else 
						If Data_Order="rnd" Then 
							If DataBaseType="access" Then 
								Randomize
								If IsNumeric(fycms.GetTable(Data_Table)) Then 
									Data_Order = "  Order By rnd(-(ID+" & rnd() & "))"
								Else 
									Data_Order = "  Order By rnd(-("&fycms.GetCountID(Data_Table)&"+" & rnd() & "))"
								End If 
							Else 
								Data_Order ="  Order By newid() "
							End If 
						Else 
							Data_Order = " Order By  "&Data_Order
						End If 
					End If 
 					actsql="select Top "&Data_top&" "&Data_Field&"   from  "&Data_Table&" Where "&Data_Where&"  "&Data_Order&" "
					Getforcache=GetForData(Data_dbsql,":"&Tagsstr,"\{@(.+?):"&Tagsstr&"([\s\S]+?)}",Loopstr,Data_Table,actsql,Data_top,true)
					Getforcache=Getcurrent(Getforcache)
					
 		End Function 

 	 
		Function OpenExtConn(DataSourceType,datasourcestr)
		 If DataSourceType=0 Then
		   OpenExtConn=True
		 Else
		 	if isdebug=0 then On Error Resume Next
		    Set tconn = Server.CreateObject("ADODB.Connection")
			tconn.open datasourcestr
			If DataSourceType=7 Then
			 tconn.execute("set names 'gb2312'")
			End If
			If Err Then 
			  Err.Clear
			  Set tconn = Nothing
			   OpenExtConn=False
			Else 
			   OpenExtConn=true
			End If
		 End If
    	End Function

		Public Function GetForData(dbtypeID,tagstr,Tagsstr,StrData,articletable,Actsql,Num,ActForTF) 
		    if isdebug=0 then On Error Resume Next
			Dim Rs,StrT,j,jj:j=1:jj=0
  			Dim Strtemp,ModID,BackValue,DataSourceType
 
			Dim DataSourceStr
 			dbtypeID=ChkNumeric(dbtypeID)
			If dbtypeID<>0 Then  
				DataSourceType=fycms.dbquery(dbtypeID,1)
				DataSourceStr=fycms.dbquery(dbtypeID,2)
 				if DataSourceType=1 Or DataSourceType=5 Or DataSourceType=6 Then  DataSourceStr=fycms.GetAbsolutePath(DataSourceStr)
 			    If OpenExtConn(DataSourceType,DataSourceStr)=false Then GetForData="外部数据库连接出错!":Exit Function
  			    Set Rs=TConn.execute(Actsql)
  			Else 
				Set Rs=fycms.actexe(Actsql)
			End If 
  		    If Err.Number <> 0 Then  GetForData = Err.Description:Exit Function 
  			If Not rs.eof Then 
				StrData=labelclear(StrData,True)
  				For j = 1 To Num
					 If  J Mod 2 =0 Then ModID=0 Else ModID=1
 					 If Rs.Eof Then Exit For  
					 StrT=StrData
 					 StrT = InStrRep(StrT,"[AutoID0]",jj) 
					 StrT = InStrRep(StrT,"[AutoID1]",jj+1)
					 StrT = InStrRep(StrT,"[AutoID2]",jj+2)
					 StrT = InStrRep(StrT,"[AutoID0"&tagstr&"]",jj)
					 StrT = InStrRep(StrT,"[AutoID1"&tagstr&"]",jj+1)
					 StrT = InStrRep(StrT,"[AutoID2"&tagstr&"]",jj+2)
					 StrT = InStrRep(StrT,"[ModID"&tagstr&"]",ModID)
					 StrT = InStrRep(StrT,"[ModID]",ModID)
   			 		 If instr(StrT,"[link"&tagstr&"]")>0 Then StrT = rep(StrT,"[link"&tagstr&"]",fycms.GetInfoUrl(fycms.GetTable(articletable),rs("ClassID"),rs("ID"),rs("ActLink"),rs("FileName"),rs("infopurview"),rs("readpoint"),rs("pinyin")))
 			 		 If instr(1,StrT,"[classlink"&tagstr&"]")>0 Then StrT = rep(StrT,"[classlink"&tagstr&"]",fycms.DiyClassName(rs("ClassID")))

			 		 If instr(1,StrT,"[rootthisclassid]",1)>0 Then 
   						If 	 CStr(fycms.ACT_L(Application(fycmsN & "classid"),11))=CStr(rs("classid")) Then 
 								 StrT = rep(StrT,"[rootthisclassid]","1=1")
   						Else 
 								 StrT = rep(StrT,"[rootthisclassid]","1=0")
 						End If	
 					 End If 

 			 		 If instr(1,StrT,"[thisclassid]",1)>0 Then 
   						If 	 CStr(Application(fycmsN & "classid"))=CStr(rs("classid")) Then 
 								 StrT = rep(StrT,"[thisclassid]","1=1")
   						Else 
 								 StrT = rep(StrT,"[thisclassid]","1=0")
 						End If	
 					 End If 
 			 		 If instr(1,StrT,"[thisid]",1)>0 Then 
  						If 	 CStr(Application(fycmsN & "id"))=CStr(rs("id")) Then 
								 StrT = rep(StrT,"[thisid]","1=1")
  						Else 
								 StrT = rep(StrT,"[thisid]","1=0")
						End If 
					 End If 

					 If instr(1,StrT,"[classname]",1)>0 Then 
						StrT = rep(StrT,"[classname]",fycms.act_L(rs("ClassID"),2))
					 Else 
						StrT = StrT
					 End If 
 
  					' StrT=fycms.forlabel(StrT,rs,articletable)
       				 BackValue = BackValue & Parser_Tags(Tagsstr,StrT, Rs,ActForTF)
					 'BackValue= listclass(BackValue)
					 BackValue= apiexe(BackValue)
  					 BackValue=ACTIF(Tagstr,BackValue)'循环
  					 StrT="":jj=jj+1:Rs.MoveNext
 				Next 
  			 	GetForData=BackValue
 			Else 
 				If RegExists("{eof}([\s\S]+?){/eof}", StrData) Then
				 	GetForData=labelclear(StrData,False)
				Else 
				 	GetForData=""
				End If 
			End If 
 
 		End Function 
 	    Public Function apiexe(Strtemp)
 			Dim Matches,Match
			Reg.Pattern="\[=actexe\(([\s\S]+?)\)\]"
			Reg.IgnoreCase=true 
			Set Matches=Reg.Execute(Strtemp)
			Dim funname,funparameters
			IF Matches.Count>0 Then
				For Each Match In Matches
					 funname= Split(Match.SubMatches(0),",")(0) 
					 funparameters=rep(Match.SubMatches(0),funname&",","")	
 					 Strtemp=Replace(Strtemp,Match.Value,fycms.AEXE(funname,funparameters))
 				Next
 				apiexe=Strtemp
  			Else 
 				apiexe=	Strtemp
 			End If
  			Set Matches=Nothing
 		End Function
	    Public Function labelclear(Strtemp,ifclear)
 			Dim Matches,Match
			Reg.Pattern="{eof}([\s\S]+?){/eof}"
			Set Matches=Reg.Execute(Strtemp)
			IF Matches.Count>0 Then
				For Each Match In Matches
					If ifclear=True    Then 
						labelclear=Replace(Strtemp,Match.Value,"")
					Else 
 						labelclear=Match.SubMatches(0)
					End If 
				Next
			Else
 					labelclear=Strtemp
			End If
 			Set Matches=Nothing
 		End Function 
		Public Function ACTIF(ByVal arrlable,ByVal Content)
		  	if isdebug=0 then On Error Resume Next
  			Dim Matches,Match,TestIf,TestVal,TestFalse,TestTrue
			Reg.Pattern = "\[fy:if"&arrlable&"(.+?)\]([\s\S]*?)\[\/fy:if"&arrlable&"\]"
 			Set Matches=Reg.Execute(Content)
 			IF Matches.Count>0 Then
				For Each Match In Matches
 					TestVal=Split(Match.SubMatches(1), "[else]")
					IF Ubound(TestVal) Then TestTrue=TestVal(0):TestFalse=TestVal(1) Else TestFalse="":TestTrue=Match.SubMatches(1)
 					Execute ("IF "&Match.SubMatches(0)&" Then TestIf = True Else TestIf = False")
  					IF TestIf Then Content=Replace(Content,Match.Value,TestTrue) Else Content=Replace(Content,Match.Value,TestFalse)
					IF Err Then ACTIF= "语句执行错"&Match.SubMatches(0)&"错误提示："&Err.Description:Err.Clear:Exit Function
				Next
			End IF
			ACTIF=Content
			Set Matches=Nothing
 		End Function		
		'上一篇、下一篇
		Function NextArticle(NowID, classID, TypeStr,ModeID,ifs)
			Dim SqlStr
			If Trim(ifs) = "prev" Then
				   SqlStr = " SELECT Top 1 ClassID,ID,ActLink,FileName,infopurview,readpoint,title,pinyin,picurl From  "&fycms.ACT_C(ModeID,2)&"  Where classID=" & Trim(classID) & " And ID<" & NowID & "  And isAccept=0 AND delif=0 and DateDiff(""d"",publishtime," & NowString & ")>=0 Order By ID Desc"
			ElseIf Trim(ifs) = "next" Then
				   SqlStr = " SELECT Top 1 ClassID,ID,ActLink,FileName,infopurview,readpoint,title,pinyin,picurl From  "&fycms.ACT_C(ModeID,2)&"  Where classID=" & Trim(classID) & " And ID>" & NowID & "  And isAccept=0 AND delif=0 and DateDiff(""d"",publishtime," & NowString & ")>=0  Order By ID"
 			Else
				NextArticle = "":Exit Function
			End If
 			 Dim RS:Set RS=fycms.actexe(SqlStr)
	 
			 If RS.EOF  Then
					Select Case TypeStr
						Case "prev"
							NextArticle="没有了"
						Case "next"
							NextArticle="没有了"
						Case "prevtitle"
							NextArticle="没有了"
						Case "nexttitle"
							NextArticle="没有了"
						Case "prevlink"
							NextArticle="javascript:alert('已经是第一页了');"
						Case "nextlink"
							NextArticle="javascript:alert('已经是最后一页');"
						Case "previmg"
							NextArticle=fycms.actsys&"images/nopic.gif"
						Case "nextimg"
							NextArticle=fycms.actsys&"images/nopic.gif"

					End Select 
			 Else
				Select Case TypeStr
					Case "prev","next"
						NextArticle="<a href=""" &fycms.GetInfoUrl(ModeID,Rs(0),Rs(1),Rs(2),Rs(3),Rs(4),Rs(5),Rs(6)) & """ title=""" & delHtml(RS("title")) & """>" & RS("title") & "</a>"
					Case "prevtitle","nexttitle"
						NextArticle=Rs(6)
					Case "prevlink","nextlink"
						NextArticle=fycms.GetInfoUrl(ModeID,Rs(0),Rs(1),Rs(2),Rs(3),Rs(4),Rs(5),Rs(6))
					Case "previmg","nextimg"
						If Trim(rs(8))<>"" Then NextArticle=Rs(8) Else NextArticle=fycms.actsys&"images/nopic.gif"
 				End Select 
 			 End If
 			 RS.Close:Set RS = Nothing
		End Function 
		Function GetContent(ModeID,rs,TemplateContent,ArticleContents)
 			TemplateContent=Loadfile(TemplateContent)
  			TemplateContent=variables(TemplateContent)
 		    ArticleContents=fycms.ReplaceSitelink(ArticleContents)
			TemplateContent=httpLoadfile(TemplateContent)
			TemplateContent=GeneralLabel(TemplateContent)
 			TemplateContent=InStrRep(TemplateContent, "{info:keywords}", rs("keywords"))
  			TemplateContent=InStrRep(TemplateContent, "{info:content}", "<content_www.fycms.com_8445e30e9f2adf86>")
 			TemplateContent=InStrRep(TemplateContent, "{info:id}", rs("id"))
 		     If InStr(TemplateContent, "{info:prev}") > 0  Then 
					 TemplateContent = rep(TemplateContent, "{info:prev}", NextArticle(rs("id"), rs("classid"), "prev",ModeID,"prev"))
			 End If 
 
		     If InStr(TemplateContent, "{info:next}") > 0  Then 
					 TemplateContent = rep(TemplateContent, "{info:next}",  NextArticle(rs("id"), rs("classid"), "next",ModeID, "next"))
			 End If 
 
		     If InStr(TemplateContent, "{info:prevtitle}") > 0  Then 
					 TemplateContent = rep(TemplateContent, "{info:prevtitle}", NextArticle(rs("id"), rs("classid"), "prevtitle",ModeID,"prev"))
			 End If 
 
		     If InStr(TemplateContent, "{info:nexttitle}") > 0  Then 
					 TemplateContent = rep(TemplateContent, "{info:nexttitle}",  NextArticle(rs("id"), rs("classid"), "nexttitle",ModeID, "next"))
			 End If 
 
		     If InStr(TemplateContent, "{info:prevlink}") > 0  Then 
					 TemplateContent = rep(TemplateContent, "{info:prevlink}", NextArticle(rs("id"), rs("classid"), "prevlink",ModeID,"prev"))
			 End If 
 
		     If InStr(TemplateContent, "{info:nextlink}") > 0  Then 
					 TemplateContent = rep(TemplateContent, "{info:nextlink}", NextArticle(rs("id"), rs("classid"), "nextlink",ModeID, "next"))
			 End If 


		     If InStr(TemplateContent, "{info:previmg}") > 0  Then 
					 TemplateContent = rep(TemplateContent, "{info:previmg}", NextArticle(rs("id"), rs("classid"), "previmg",ModeID,"prev"))
			 End If 
 
		     If InStr(TemplateContent, "{info:nextimg}") > 0  Then 
					 TemplateContent = rep(TemplateContent, "{info:nextimg}", NextArticle(rs("id"), rs("classid"), "nextimg",ModeID, "next"))
			 End If 




  			If InStr(TemplateContent, "{info:url}") > 0  Then
				TemplateContent = rep(TemplateContent, "{info:url}", fycms.GetInfoUrlall(ModeID,rs("classid"),rs("id"),rs("actlink"),rs("filename"),rs("infopurview"),rs("readpoint"),rs("pinyin")))
			End If 
 			If InStr(TemplateContent, "{info:hits}") <> 0 Then
			 TemplateContent = rep(TemplateContent, "{info:hits}", "<Script Language=""Javascript"" Src=""" & fycms.Domain & "Plus/fy.Hits.asp?ModeID="&ModeID&"&ID=" & rs("id") & """></Script>")
			End If
  			If InStr(TemplateContent, "{info:commentyes}") > 0  Then'审核通过的评论
 			 TemplateContent = rep(TemplateContent, "{info:commentyes}", "<Script Language=""Javascript"" Src=""" & fycms.Domain & "plus/Comment/Comment.List.asp?Action=CommentYes&ModeID="&ModeID&"&ClassID=" & rs("classid") & "&ID=" & rs("id") & """></Script>")
 			End if

 			If InStr(TemplateContent, "{info:commentcount}") > 0  Then'共多少评论
 			
			 TemplateContent = rep(TemplateContent, "{info:commentcount}", "<Script Language=""Javascript"" Src=""" &  fycms.Domain  & "plus/Comment/Comment.List.asp?Action=CommentCount&ModeID="&ModeID&"&ClassID=" & rs("classid") & "&ID=" & rs("id") & """></Script>")
 			End if
		   If InStr(TemplateContent, "{info:typecomment}")  Then
			 TemplateContent = rep(TemplateContent, "{info:typecomment}", "<Script Language=""Javascript"" Src=""" & fycms.Domain & "plus/Comment/Comment.js.asp?ModeID="&ModeID&"&ClassID=" & rs("classid") & "&ID=" & rs("id") & """></Script>")
		   Else
			TemplateContent = rep(TemplateContent, "{info:typecomment}", "")
		   End If
		   If InStr(TemplateContent, "{info:WriteComment}") > 0 Then
			 TemplateContent = rep(TemplateContent, "{info:WriteComment}", "<Script Language=""Javascript"" Src=""" & fycms.Domain & "plus/Comment/fy.Comment.asp?Action=Write&ModeID="&ModeID&"&ClassID=" & rs("classid") & "&ID=" & rs("id") & """></Script>")
		   Else
			 TemplateContent = rep(TemplateContent, "{info:WriteComment}", "")
		   End If
			TemplateContent=Parser_Tags("\{info:([\s\S]+?)}",TemplateContent, Rs,False)

			TemplateContent=Parser_diy_Tags("\{diyinfo:([\s\S]+?)}",TemplateContent, modeid, Rs("id"))

			TemplateContent= apiexe(TemplateContent)

			TemplateContent=Getcurrent(TemplateContent)
			TemplateContent=GetRequest(TemplateContent)
 			TemplateContent=GetTabForContent(TemplateContent)
 			TemplateContent=GetTabContent(TemplateContent)
 			TemplateContent=listclass(TemplateContent)
 			TemplateContent=ACTIF("",TemplateContent)
			TemplateContent=Replace(TemplateContent, "<content_www.fycms.com_8445e30e9f2adf86>", fycms.Htmljapan(ArticleContents))
			GetContent=TemplateContent
		End Function 




		Public Function Parser_diy_Tags(ByVal AttrName,ByVal Temp, ByVal modeid, ByVal aid)
			Dim Pattern,Match,Matches,Tagsstr,TempData,LabArr,TempStrContent,i
			Dim f,TempArr,TempArrstr,Data_width,Data_height
			Dim Data_fun_Arr,Data_lend,Data_len,Data_fun,Data_Before,Data_After,Data_date,Data_replace,replace_Arr
		     if isdebug=0 then On Error Resume Next
  			 Reg.Pattern =AttrName
			 Pattern=AttrName
			 AttrName=""
  			Set Matches = Reg.Execute(Temp)
			IF Matches.Count>0 Then
 			For Each Match In Matches
      			 	TempData=LTemplate(fycms.actsys&"data/Field/"&ModeID&"/"&md5(modeid&Split(Match.SubMatches(0), " ")(0)&aid,32)&".txt"):LabArr=GetAttribute(Match.SubMatches(0))
					If Err.Number <> 0 Then  TempData=Err.Description
 				If  IsArray(LabArr) Then 
					For I=0 To Ubound(LabArr)
						Select Case Lcase(LabArr(I,0))
							Case "lend":Data_lend=LabArr(I,1) 
							Case "len":Data_len=LabArr(I,1) 
							Case "date":Data_date=LabArr(I,1)
							Case "replace":Data_replace=LabArr(I,1)
							Case "fun":Data_fun=LabArr(I,1)
							Case "userinfo":Data_fun=LabArr(I,1)
							Case "width":Data_width=LabArr(I,1)
							Case "height":Data_height=LabArr(I,1)
 							Case "none"
  								If 	Len(LabArr(I,1))>0    Then
 									If   Trim(TempData)<>""  Then'fuck
 									Else 
										 TempData= LabArr(I,1)
									End If
 								End If
  							Case "after":Data_After=LabArr(I,1)'，在输出值之前插入after属性中指定的内容 
							Case "before":Data_Before=LabArr(I,1)'在输出值之后插入Before属性中指定的内容 
 						End Select
					Next
    				If 	Len(Data_fun)>0 Then
 						Data_fun_Arr=Split(Data_fun,"@")
							For f=0 To UBound(Data_fun_Arr)
									If InStr(Data_fun_Arr(f),",")>0 Then 
										TempArr=Split(Data_fun_Arr(f),",")
										TempArrstr=Replace(Data_fun_Arr(f),TempArr(0),"")
										 execute("TempData="&TempArr(0)&"("""&RemAsp(TempData)&""""&TempArrstr&")")
									Else 
 										 execute("TempData="&Data_fun_Arr(f)&"("""&RemAsp(TempData)&""")")
									End If 
  							Next 
					End If 

					
				 	If 	ChkNumeric(Data_width)>20  And ChkNumeric(Data_height)>20  Then
  					 	TempData=tojpeg(TempData,Data_width,Data_height)
				 	End If 
				 	
					
					If 	Len(Data_len)>0  And Trim(TempData) <> ""  Then
 					 	TempData=GetStrValue(TempData,Data_len,"")
				 	End If 

				 	If 	Len(Data_lend)>0  And Trim(TempData) <> ""  Then
 					 	TempData=GetStrValue(TempData,Data_lend,"1")
				 	End If 

 					If 	Len(Data_Before)>0 Then
  					 	TempData=Data_before&TempData
				 	End If 
 					If 	Len(Data_After)>0 Then
  					 	TempData=TempData&Data_After
				 	End If 
 					If 	Len(Data_replace)>0 Then
				 		replace_Arr=Split(Data_replace,"|")
						If UBound(replace_Arr)>1 Then 
							TempData=rep(TempData,replace_Arr(0),replace_Arr(1))
						Else 
   					 		TempData=rep(TempData,replace_Arr(0),"")
						End If 
 				 	End If 
 					If 	Len(Data_date)>0 Then
   					 	TempData=GetDate(Data_date,TempData)
				 	End If 
				End If 
				TempData=rep(TempData,"{","[file383dc46bb91d4cf9]")
 				TempStrContent = rep(Temp, Match.Value,TempData)
				Data_fun_Arr="":Data_len="":Data_fun="":Data_Before="":Data_After="":Data_date="":Data_replace="":replace_Arr="":Data_width="":Data_height=""
 			Next
				If RegExists(Pattern, TempStrContent) Then TempStrContent=Parser_diy_Tags(Pattern,TempStrContent, Dat,ActForTF)  ' 多次调用
  				Parser_diy_Tags=TempStrContent 
			Else 
  				Parser_diy_Tags=Temp 
			End If 
			 If InStr(Parser_diy_Tags,"[file383dc46bb91d4cf9]")>0 Then Parser_diy_Tags=replace(Parser_diy_Tags,"[file383dc46bb91d4cf9]","{")
 			 IF Err Then TempStrContent= "错误提示："&Err.Description:Err.Clear:Exit Function
      	End Function
 	



















		Function GetdiyContent(rs,TemplateContent,ArticleContents)
 			TemplateContent=Loadfile(TemplateContent)
  			TemplateContent=variables(TemplateContent)
			TemplateContent=httpLoadfile(TemplateContent)
			TemplateContent=GeneralLabel(TemplateContent)
   			TemplateContent=InStrRep(TemplateContent, "{info:content}", "<content_www.fycms.com_8445e30e9f2adf86>")
			TemplateContent=Parser_Tags("\{info:([\s\S]+?)}",TemplateContent, Rs,False)
			TemplateContent= apiexe(TemplateContent)

			TemplateContent=Getcurrent(TemplateContent)
			TemplateContent=GetRequest(TemplateContent)
 			TemplateContent=GetTabForContent(TemplateContent)
 			TemplateContent=GetTabContent(TemplateContent)
 			TemplateContent=listclass(TemplateContent)
 			TemplateContent=ACTIF("",TemplateContent)
			TemplateContent=Replace(TemplateContent, "<content_www.fycms.com_8445e30e9f2adf86>", fycms.Htmljapan(ArticleContents))
			GetdiyContent=TemplateContent
		End Function 

		Function GetUserInfo(TemplateContent,rs)
			TemplateContent=Parser_Tags("\[user:([\s\S]+?)]",TemplateContent, Rs,False)
			GetUserInfo=TemplateContent
		End Function 
 		Function GetnoUserInfo(TemplateContent,rs)
			Dim Matches,Match
  			Reg.Pattern ="\[user:([\s\S]+?)]"
   			Set Matches = Reg.Execute(TemplateContent)
			IF Matches.Count>0 Then
					For Each Match In Matches
    						TemplateContent = Replace(TemplateContent, Match.Value,"")
					Next 
			End If 
			GetnoUserInfo=TemplateContent
		End Function 

		Public Function Parser_Tags(ByVal AttrName,ByVal Temp, ByVal Dat,ByVal ActForTF)
			Dim Pattern,Match,Matches,Tagsstr,TempData,LabArr,TempStrContent,i
			Dim f,TempArr,TempArrstr,Data_width,Data_height
			Dim Data_fun_Arr,Data_lend,Data_len,Data_fun,Data_Before,Data_After,Data_date,Data_replace,replace_Arr
		     if isdebug=0 then On Error Resume Next
  			 Reg.Pattern =AttrName
			 Pattern=AttrName
			 AttrName=""
  			Set Matches = Reg.Execute(Temp)
			IF Matches.Count>0 Then
 			For Each Match In Matches
				If ActForTF=True Then 
   					TempData=Dat(Match.SubMatches(0)):LabArr=GetAttribute(Match.SubMatches(1))
					If Err.Number <> 0 Then  TempData=Err.Description
 				Else 
     			 	TempData=Dat(Split(Match.SubMatches(0), " ")(0)):LabArr=GetAttribute(Match.SubMatches(0))
					If Err.Number <> 0 Then  TempData=Err.Description
				End If 
				If  IsArray(LabArr) Then 
					For I=0 To Ubound(LabArr)
						Select Case Lcase(LabArr(I,0))
							Case "lend":Data_lend=LabArr(I,1) 
							Case "len":Data_len=LabArr(I,1) 
							Case "date":Data_date=LabArr(I,1)
							Case "replace":Data_replace=LabArr(I,1)
							Case "fun":Data_fun=LabArr(I,1)
							Case "userinfo":Data_fun=LabArr(I,1)
							Case "width":Data_width=LabArr(I,1)
							Case "height":Data_height=LabArr(I,1)
 							Case "none"
  								If 	Len(LabArr(I,1))>0    Then
 									If   Trim(TempData)<>""  Then'fuck
 									Else 
										 TempData= LabArr(I,1)
									End If
 								End If
  							Case "after":Data_After=LabArr(I,1)'，在输出值之前插入after属性中指定的内容 
							Case "before":Data_Before=LabArr(I,1)'在输出值之后插入Before属性中指定的内容 
 						End Select
					Next
    				If 	Len(Data_fun)>0 Then
 						Data_fun_Arr=Split(Data_fun,"@")
							For f=0 To UBound(Data_fun_Arr)
									If InStr(Data_fun_Arr(f),",")>0 Then 
										TempArr=Split(Data_fun_Arr(f),",")
										TempArrstr=Replace(Data_fun_Arr(f),TempArr(0),"")
										 execute("TempData="&TempArr(0)&"("""&RemAsp(TempData)&""""&TempArrstr&")")
									Else 
 										 execute("TempData="&Data_fun_Arr(f)&"("""&RemAsp(TempData)&""")")
									End If 
  							Next 
					End If 

					
				 	If 	ChkNumeric(Data_width)>20  And ChkNumeric(Data_height)>20  Then
  					 	TempData=tojpeg(TempData,Data_width,Data_height)
				 	End If 
				 	
					
					If 	Len(Data_len)>0  And Trim(TempData) <> ""  Then
 					 	TempData=GetStrValue(TempData,Data_len,"")
				 	End If 

				 	If 	Len(Data_lend)>0  And Trim(TempData) <> ""  Then
 					 	TempData=GetStrValue(TempData,Data_lend,"1")
				 	End If 

 					If 	Len(Data_Before)>0 Then
  					 	TempData=Data_before&TempData
				 	End If 
 					If 	Len(Data_After)>0 Then
  					 	TempData=TempData&Data_After
				 	End If 
 					If 	Len(Data_replace)>0 Then
				 		replace_Arr=Split(Data_replace,"|")
						If UBound(replace_Arr)>1 Then 
							TempData=rep(TempData,replace_Arr(0),replace_Arr(1))
						Else 
   					 		TempData=rep(TempData,replace_Arr(0),"")
						End If 
 				 	End If 
 					If 	Len(Data_date)>0 Then
   					 	TempData=GetDate(Data_date,TempData)
				 	End If 
				End If 
				TempData=rep(TempData,"{","[file383dc46bb91d4cf9]")
 				TempStrContent = rep(Temp, Match.Value,TempData)
				Data_fun_Arr="":Data_len="":Data_fun="":Data_Before="":Data_After="":Data_date="":Data_replace="":replace_Arr="":Data_width="":Data_height=""
 			Next
				If RegExists(Pattern, TempStrContent) Then TempStrContent=Parser_Tags(Pattern,TempStrContent, Dat,ActForTF)  ' 多次调用
  				Parser_Tags=TempStrContent 
			Else 
  				Parser_Tags=Temp 
			End If 
			 If InStr(Parser_Tags,"[file383dc46bb91d4cf9]")>0 Then Parser_Tags=replace(Parser_Tags,"[file383dc46bb91d4cf9]","{")
 			 IF Err Then TempStrContent= "错误提示："&Err.Description:Err.Clear:Exit Function
      	End Function
 	
 		Public Function RegExists(ByVal Pattern, ByVal TestContent)
			Reg.Pattern = Pattern
			RegExists = Reg.Test(TestContent)
 		End Function
  		Public Function GetAttribute(ByVal lab)
			Dim Arr:Arr=False
			Dim I:I=0
			Dim Matches,Match
			Reg.Pattern="([a-z]+)=\""(.+?)\"""
 			Set Matches=Reg.Execute(lab) 
  			IF Matches.Count Then
				ReDim Arr(Matches.Count-1,1)
				For Each Match In Matches
 					Arr(I,0)=Match.SubMatches(0)
 					Arr(I,1)=Match.SubMatches(1)
					I=I+1
				Next
			End IF
			GetAttribute=Arr
		End Function
		
		Public Function RegReplace(ByVal ReplaceContent, ByVal Pattern, ByVal Replacestr)
			Reg.Pattern = Pattern
			RegReplace = Reg.Replace(ReplaceContent, Replacestr)
		End Function

 

		Public Function Loadfile(ByVal TemplateContent)
		      TemplateContent=RegReplace(TemplateContent, "\[fytpl:(..//)*(.+?)\]", "{file383dc46bb91d4cf9:$2}")
			  'TemplateContent=RegReplace(TemplateContent, "<" & "!--#include file=""(..//)*(.+?)""-->", "{file383dc46bb91d4cf9:$2}")
			  If InStr(TemplateContent, "{file383dc46bb91d4cf9:") > 0 Then
				Dim Match, Matches
				Reg.Pattern = "{file383dc46bb91d4cf9:(.+?)}"
				Set Matches = Reg.Execute(TemplateContent)
				For Each Match In Matches
  				   TemplateContent = Replace(TemplateContent, Match.Value,LoadTemplate(Match.SubMatches(0)))
				Next
			End If
			Loadfile=TemplateContent
		End Function
 		Public Function httpLoadfile(ByVal TemplateContent)
  				Dim Match, Matches
 				Reg.Pattern = "\[fyhttp:*(.+?)\]"
				Set Matches = Reg.Execute(TemplateContent)
				For Each Match In Matches
    				   TemplateContent = Replace(TemplateContent, Match.Value,getHTTPPage(Match.SubMatches(0)))
				Next
 				httpLoadfile=TemplateContent
 				Set Matches=Nothing
		End Function
		Function getHTTPPage(httpurl)
			Dim LabArr,i,Data_file,Data_charset
			Dim httpweb,httpcharset
			LabArr=GetAttribute(httpurl)
 				If  IsArray(LabArr) Then 
					For I=0 To Ubound(LabArr)
						Select Case Lcase(LabArr(I,0))
							Case "file":Data_file=LabArr(I,1) 
							Case "charset":Data_charset=LabArr(I,1)
  						End Select
					Next
 				End If 
				If 	Len(Data_file)>0  And  instr(Data_file,"http://")>0  Then  httpweb=Data_file Else getHTTPPage="网址错误":Exit Function 
				If 	Len(Data_charset)>0 Then  httpcharset=Data_charset Else httpcharset="gb2312"
				Dim Http,ServerConn,j
				For j=0 To 2
  					Set Http=server.createobject("Msxml2.ServerXMLHTTP")
					Http.setTimeouts 5*1000,5*1000,4*1000,10*1000
					Http.open "GET",httpweb,False
					Http.send()
					If Err Then
						Err.Clear
						Set http = Nothing
						ServerConn = False
					else
						ServerConn = true
					End If
					If ServerConn Then
						Exit For
					End If
				next
				If ServerConn = False Then
					getHTTPPage = "下载失败"
					Exit Function
				End If
 				 If http.Status=200 Then
 					getHTTPPage=fycms.BytesToBstr(Http.ResponseBody,httpcharset)
				Else
					getHTTPPage = "下载失败"
				End If
 				Set Http = Nothing
 		End Function
  		Function GetDate(strtemp,StrData)
			If IsDate(StrData) Then
 				If InStr(strtemp, "week") Then strtemp = rep(strtemp, "week", WeekDayName(weekday(StrData)))
				If InStr(strtemp, "yyyy") > 0 Then strtemp = rep(strtemp, "yyyy", Year(StrData))
				If InStr(strtemp, "yy") > 0 Then strtemp = rep(strtemp, "yy", Right(Year(StrData), 2))
				If InStr(strtemp, "mm") > 0 Then strtemp = rep(strtemp, "mm", Right("0" & Month(StrData), 2))
				If InStr(strtemp, "m") > 0 Then strtemp = rep(strtemp, "m", Month(StrData))
				If InStr(strtemp, "dd") > 0 Then strtemp = rep(strtemp, "dd", Right("0" & Day(StrData), 2))
				If InStr(strtemp, "d") > 0 Then strtemp = rep(strtemp, "d", Day(StrData))
				If InStr(strtemp, "hh") > 0 Then strtemp = rep(strtemp, "hh", Right("0" & Hour(StrData), 2))
				If InStr(strtemp, "h") > 0 Then strtemp = rep(strtemp, "h", Hour(StrData))
				If InStr(strtemp, "nn") > 0 Then strtemp = rep(strtemp, "nn", Right("0" & Minute(StrData), 2))
				If InStr(strtemp, "n") > 0 Then strtemp = rep(strtemp, "n", Minute(StrData))
				If InStr(strtemp, "ss") > 0 Then strtemp = rep(strtemp, "ss", Right("0" & Second(StrData), 2))
				If InStr(strtemp, "s") > 0 Then strtemp = rep(strtemp, "s", Second(StrData))
				GetDate=strtemp
			Else 
				GetDate=StrData
			End If 
 		End Function 
  	End Class 
%> 