<!--#Include File="../Plugin/PageCode/PageCode.asp"--><%
'--------------------------------------
'Power By 580Web @2010-2014 f02
'URL:http://www.580Web.Cn/
'EMail:wsok85@qq.com
'QQ:253819801
'版权所有 未经允许不得去除本版权信息
'--------------------------------------
'<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

Class Cls_Template
	Private ListNo,ListNo_Page,ForId,IfId
	Private If1,If2
	Private c_Menu,c_Module,c_Recommend,c_Subject,c_Level,c_Recall,c_Order,c_Count,c_State,c_FriendsType,c_FriendsShowType,c_PicList
	Private c_SiteDir,c_SiteUrl,c_HtmlSuffix,c_ModuleUrl,c_ModuleTarget,c_ViewUrl,c_ViewTarget,c_SubjectUrl
	Private v_ModuleUrl
	Private c_PageSize,c_PageCount,c_RecordCount
	Private c_PageFirst,c_PagePrev,c_PageNext,c_PageLast,c_NavNow
	Private Field_Label,Field_Content
	
'========================常规标签处理===========================	
	'==============================
	'函 数 名：SiteChange
	'作    用：站点参数替换
	'==============================
	Public Function SiteChange(TemplateCode)
	    ForId=1
		c_SiteDir=FullSiteDir
		c_SiteUrl=FullSiteUrl
		c_HtmlSuffix=FullHtmlSuffix
		
		TemplateCode=ReplaceTag(TemplateCode,"{$SiteName$}",Fk_Site_Name)
		TemplateCode=ReplaceTag(TemplateCode,"{$SiteUrl$}",Fk_Site_Url)
		TemplateCode=ReplaceTag(TemplateCode,"{$SiteKeyword$}",Fk_Site_Keyword)
		TemplateCode=ReplaceTag(TemplateCode,"{$SiteDescription$}",Fk_Site_Description)
		TemplateCode=ReplaceTag(TemplateCode,"{$SiteSkin$}",SiteDir&"Skin/"&Fk_Site_Template&"/")
		TemplateCode=ReplaceTag(TemplateCode,"{$SiteDir$}",SiteDir)
		
		'站点设置自定义字段
		Sqlstr="Select Fk_Field_Label From [Fk_Field] Where Fk_Field_Use=1 Order By Fk_Field_Id Asc"
		Rs.Open Sqlstr,Conn,1,1
		While Not Rs.Eof
			Field_Content=FKFun.GetSub(Fk_Site_Field,Rs("Fk_Field_Label")&"_Field_Get:","|Get_Field_Line|","")
			TemplateCode=ReplaceTag(TemplateCode,"{$SiteField_"&Rs("Fk_Field_Label")&"$}",Field_Content)
			Rs.MoveNext
		Wend
		Rs.Close
		
		SiteChange=TemplateCode
	End Function

	'==============================
	'函 数 名：ModuleChange
	'作    用：模块页面标签替换
	'==============================
	Public Function ModuleChange(TemplateCode,t_Id,m_Type)
		Dim Rst,Fk_Module_Name,Fk_Module_LevelList,Fk_Module_Level,Fk_Module_Field,Fk_Module_InfoField,Fk_Module_GBookReply,pageCodeType,pageCodeTypeList
		Dim pTemp
		Set Rst=Server.Createobject("Adodb.RecordSet")
		c_PageSize=Fk_Site_PageSize
		
		Sqlstr="Select Fk_Module_Name,Fk_Module_SubTitle,Fk_Module_Keyword,Fk_Module_Description,Fk_Module_Pic,Fk_Module_Content,Fk_Module_Level,Fk_Module_LevelList,Fk_Module_Menu,Fk_Module_FixedUrl,Fk_Module_Url,Fk_Module_Model,Fk_Module_GBookReply,Fk_Module_Field,Fk_Module_InfoField From [Fk_Module] Where Fk_Module_State=1 And Fk_Module_Id=" & t_Id
		Rs.Open Sqlstr,Conn,1,1
		If Not Rs.Eof Then
			c_ModuleUrl=GetUrl(c_SiteDir,"",Rs("Fk_Module_Url"),"","",1,t_Id,Rs("Fk_Module_FixedUrl"))
			
			Fk_Module_Name=Rs("Fk_Module_Name")
			Fk_Module_LevelList=Rs("Fk_Module_LevelList")
			Fk_Module_Level=Rs("Fk_Module_Level")
			Fk_Module_Field=Rs("Fk_Module_Field")
			Fk_Module_InfoField=Rs("Fk_Module_InfoField")
			Fk_Module_GBookReply=Rs("Fk_Module_GBookReply")
			c_NavNow=t_Id
			
			TemplateCode=ReplaceTag(TemplateCode,"{$ModuleId$}",t_Id)
			TemplateCode=ReplaceTag(TemplateCode,"{$ModuleName$}",Rs("Fk_Module_Name"))
			TemplateCode=ReplaceTag(TemplateCode,"{$ModuleSubTitle$}",Rs("Fk_Module_SubTitle"))
			TemplateCode=ReplaceTag(TemplateCode,"{$ModuleKeyword$}",Rs("Fk_Module_Keyword"))
			TemplateCode=ReplaceTag(TemplateCode,"{$ModuleDescription$}",Rs("Fk_Module_Description"))
			TemplateCode=ReplaceTag(TemplateCode,"{$ModulePic$}",Rs("Fk_Module_Pic"))
			TemplateCode=ReplaceTag(TemplateCode,"{$ModuleUrl$}",GetUrl("",c_SiteUrl,Rs("Fk_Module_Url"),"","",1,t_Id,Rs("Fk_Module_FixedUrl")))
			
			'所在菜单参数替换
			Sqlstr="Select Fk_Menu_Id,Fk_Menu_Name From [Fk_Menu] Where Fk_Menu_Id=" & Rs("Fk_Module_Menu")
			Rst.Open Sqlstr,Conn,1,1
			If Not Rst.Eof Then
				TemplateCode=ReplaceTag(TemplateCode,"{$MenuId$}",Rst("Fk_Menu_Id"))
				TemplateCode=ReplaceTag(TemplateCode,"{$MenuName$}",Rst("Fk_Menu_Name"))
			End If
			Rst.Close
			
			'父栏目参数替换
			If Fk_Module_Level=0 Then
				TemplateCode=ReplaceTag(TemplateCode,"{$ModuleFId$}",0)
				TemplateCode=ReplaceTag(TemplateCode,"{$ModuleFName$}","")
				TemplateCode=ReplaceTag(TemplateCode,"{$ModuleFUrl$}","")
			Else
				Sqlstr="Select Fk_Module_Id,Fk_Module_Name,Fk_Module_Url From [Fk_Module] Where Fk_Module_State=1 And Fk_Module_Id=" & Fk_Module_Level
				Rst.Open Sqlstr,Conn,1,1
				If Not Rst.Eof Then
					TemplateCode=ReplaceTag(TemplateCode,"{$ModuleFId$}",Rst("Fk_Module_Id"))
					TemplateCode=ReplaceTag(TemplateCode,"{$ModuleFName$}",Rst("Fk_Module_Name"))
					TemplateCode=ReplaceTag(TemplateCode,"{$ModuleFUrl$}",c_SiteUrl&Rst("Fk_Module_Url"))
				End If
				Rst.Close
			End If
			
			'信息模块模型部分替换
			If m_Type="info" Then
				TemplateCode=ReplaceTag(TemplateCode,"{$ModuleContent$}",WordChange(Rs("Fk_Module_Content")))
				Sqlstr="Select Fk_Model_Default,Fk_Model_Field From [Fk_Model] Where Fk_Model_Id=" & Rs("Fk_Module_Model")
				Rst.Open Sqlstr,Conn,1,1
				If Not Rst.Eof Then
					ModelField=Rst("Fk_Model_Field")
				Else
					ModelField=""
				End If
				Rst.Close
				TempArr=Split(ModelField,"|FieldList|")
				For Each Temp In TempArr
					If Temp<>"" Then
						Field_Label=t_GetSub(Temp,"Field_Label:","|;|","")
						Field_Content=t_GetSub(Fk_Module_InfoField,Field_Label&"_Field_Get:","|Get_Field_Line|","")
						TemplateCode=ReplaceTag(TemplateCode,"{$ModuleInfoField_"&Field_Label&"$}",Field_Content)
					End If
				Next
			End If
		Else
			Rs.Close
			Call t_ShowErr("页面不存在！",0)
		End If
		Rs.Close
		
		'当前主栏目判断
		If Instr(TemplateCode,"{$NavNow$}")>0 Then
			While Fk_Module_Level>0
				Sqlstr="Select Fk_Module_Id,Fk_Module_Level,Fk_Module_LevelList From [Fk_Module] Where Fk_Module_State=1 And Fk_Module_Id=" & c_NavNow
				Rs.Open Sqlstr,Conn,1,1
				If Not Rs.Eof Then
					Fk_Module_Level=Rs("Fk_Module_Level")
					If Fk_Module_Level>0 Then
						c_NavNow=Rs("Fk_Module_Level")
					End If
				Else
					c_NavNow=-1
					Fk_Module_Level=0
				End If
				Rs.Close
			Wend
			TemplateCode=Replace(TemplateCode,"{$NavNow$}",c_NavNow)
		End If
		
		'菜单项自定义字段
		Sqlstr="Select Fk_Field_Label From [Fk_Field] Where Fk_Field_Use=2 Order By Fk_Field_Id Asc"
		Rs.Open Sqlstr,Conn,1,1
		While Not Rs.Eof
			Field_Content=FKFun.GetSub(Fk_Module_Field,Rs("Fk_Field_Label")&"_Field_Get:","|Get_Field_Line|","")
			TemplateCode=ReplaceTag(TemplateCode,"{$ModuleField_"&Rs("Fk_Field_Label")&"$}",Field_Content)
			Rs.MoveNext
		Wend
		Rs.Close
		
		'面包屑导航
		TemplateCode=Replace(TemplateCode,"{$SiteBreadCrumb$}",ChangeBreadCrumb(Fk_Module_LevelList,c_ModuleUrl,Fk_Module_Name))
		
		'页码参数替换
		If m_Type="viewlist" Or m_Type="gbook" Then
			If m_Type="viewlist" Then
				Sqlstr="Select Fk_View_Id From [Fk_ViewList] Where Fk_View_Show=1 And (Fk_Module_Id="&t_Id&" Or Fk_Module_LevelList Like '%%,"&t_Id&",%%')"
			ElseIf m_Type="gbook" Then
				Sqlstr="Select Fk_GBook_Id From [Fk_GBook] Where Fk_GBook_Module="&t_Id&""
				If Fk_Module_GBookReply=1 Then
					Sqlstr=Sqlstr&" And Fk_GBook_ReIp<>''"
				ElseIf Fk_Module_GBookReply=2 Then
					Sqlstr=Sqlstr&" And (Fk_GBook_ReIp='' Or Fk_GBook_ReIp Is Null)"
				End If
			End If
			Rs.Open Sqlstr,Conn,1,1
			Rs.PageSize=c_PageSize
			c_PageCount=Rs.PageCount
			c_RecordCount=Rs.RecordCount
			Rs.Close
			'独立页码
			c_PageFirst=c_ModuleUrl
			c_PagePrev=c_ModuleUrl&"Index_"&(PageNow-1)&c_HtmlSuffix
			c_PageNext=c_ModuleUrl&"Index_"&(PageNow+1)&c_HtmlSuffix
			c_PageLast=c_ModuleUrl&"Index_"&c_PageCount&c_HtmlSuffix
			If c_PageCount=1 Then
				c_PagePrev="#"
				c_PagePrev="#"
				c_PageNext="#"
				c_PageLast="#"
			ElseIf PageNow>=c_PageCount Then
				c_PagePrev=c_ModuleUrl&"Index_"&(PageNow-1)&c_HtmlSuffix
				c_PageNext="#"
				c_PageLast="#"
			ElseIf PageNow=1 Then
				c_PagePrev="#"
				c_PagePrev="#"
			End If
			TemplateCode=Replace(TemplateCode,"{$PageFirst$}",c_PageFirst)
			TemplateCode=Replace(TemplateCode,"{$PagePrev$}",c_PagePrev)
			TemplateCode=Replace(TemplateCode,"{$PageNext$}",c_PageNext)
			TemplateCode=Replace(TemplateCode,"{$PageLast$}",c_PageLast)
			TemplateCode=Replace(TemplateCode,"{$PageNow$}",PageNow)
			TemplateCode=Replace(TemplateCode,"{$PageCount$}",c_PageCount)
			TemplateCode=Replace(TemplateCode,"{$PageRecordCount$}",c_RecordCount)
			TemplateCode=Replace(TemplateCode,"{$PageSize$}",c_PageSize)
			
			'具体页码
			TempArr=Split(t_RegExpTest("\{\$ModulePageCode\(.*?\)\$\}",TemplateCode),"|-_-|")
			pageCodeTypeList=","
			For Each Temp In TempArr
				If Temp<>"" Then
					pageCodeType=t_GetSub(Temp,"(",")","0")
					If Instr(pageCodeTypeList,","&pageCodeType&",")=0 Then
						If Fk_Site_Html=1 Then
							pTemp=c_ModuleUrl&"&page={mypage}"
						Else
							pTemp=c_ModuleUrl&"Index_{mypage}"&c_HtmlSuffix
						End If
						TemplateCode=Replace(TemplateCode,Temp,getPageCode(pageCodeType,pTemp,PageNow,c_PageCount,c_PageSize,c_RecordCount))
						pageCodeTypeList=pageCodeTypeList&pageCodeType&","
					End If
				End If
			Next
		End If
		
		ModuleChange=TemplateCode
	End Function

	'==============================
	'函 数 名：SearchChange
	'作    用：搜索页面标签替换
	'==============================
	Public Function SearchChange(TemplateCode)
		Dim UrlTemp,pageCodeTypeList,pageCodeType
		c_PageSize=Fk_Site_PageSize
		
		UrlTemp=SiteDir&"Search.asp?Template="&PageTemplate&"&SearchStr="&Server.URLEncode(SearchStr)&"&Page="
		
		TemplateCode=Replace(TemplateCode,"{$SearchStr$}",SearchStr)
		TemplateCode=Replace(TemplateCode,"{$NavNow$}",-1)
		
		'页码参数替换
		Sqlstr="Select Fk_View_Id From [Fk_ViewList] Where Fk_View_Show=1 And Fk_Module_State=1 And Fk_View_Title Like '%%"&SearchStr&"%%'"
		Rs.Open Sqlstr,Conn,1,1
		Rs.PageSize=c_PageSize
		c_PageCount=Rs.PageCount
		c_RecordCount=Rs.RecordCount
		Rs.Close
		'独立页码
		c_PageFirst=UrlTemp&"1"
		c_PagePrev=UrlTemp&(PageNow-1)
		c_PageNext=UrlTemp&(PageNow+1)
		c_PageLast=UrlTemp&c_PageCount
		If c_PageCount=1 Then
			c_PagePrev="#"
			c_PagePrev="#"
			c_PageNext="#"
			c_PageLast="#"
		ElseIf PageNow>=c_PageCount Then
			c_PagePrev=UrlTemp&(PageNow-1)
			c_PageNext="#"
			c_PageLast="#"
		ElseIf PageNow=1 Then
			c_PagePrev="#"
			c_PagePrev="#"
		End If
		TemplateCode=Replace(TemplateCode,"{$PageFirst$}",c_PageFirst)
		TemplateCode=Replace(TemplateCode,"{$PagePrev$}",c_PagePrev)
		TemplateCode=Replace(TemplateCode,"{$PageNext$}",c_PageNext)
		TemplateCode=Replace(TemplateCode,"{$PageLast$}",c_PageLast)
		TemplateCode=Replace(TemplateCode,"{$PageNow$}",PageNow)
		TemplateCode=Replace(TemplateCode,"{$PageCount$}",c_PageCount)
		TemplateCode=Replace(TemplateCode,"{$PageRecordCount$}",c_RecordCount)
		TemplateCode=Replace(TemplateCode,"{$PageSize$}",c_PageSize)
		
		'具体页码
		TempArr=Split(t_RegExpTest("\{\$SearchPageCode\(.*?\)\$\}",TemplateCode),"|-_-|")
		pageCodeTypeList=","
		For Each Temp In TempArr
			If Temp<>"" Then
				pageCodeType=t_GetSub(Temp,"(",")","0")
				If Instr(pageCodeTypeList,","&pageCodeType&",")=0 Then
					TemplateCode=Replace(TemplateCode,Temp,getPageCode(pageCodeType,UrlTemp&"{mypage}",PageNow,c_PageCount,c_PageSize,c_RecordCount))
					pageCodeTypeList=pageCodeTypeList&pageCodeType&","
				End If
			End If
		Next
		
		SearchChange=TemplateCode
	End Function

	'==============================
	'函 数 名：ViewChange
	'作    用：内容页面标签替换
	'==============================
	Public Function ViewChange(TemplateCode,t_Id)
		Dim Rst,Fk_View_Field,Fk_Module_Name,Fk_Module_LevelList,Fk_Module_Level,Fk_Module_Field
		Set Rst=Server.Createobject("Adodb.RecordSet")
		
		Sqlstr="Select Fk_View_Title,Fk_View_Keyword,Fk_View_Description,Fk_View_Pic,Fk_View_PicBig,Fk_View_PicList,Fk_View_Content,Fk_View_FixedUrl,Fk_View_Url,Fk_Module_Model,Fk_View_Field,Fk_View_Time,Fk_Module_Id,Fk_Module_Name,Fk_Module_SubTitle,Fk_Module_Keyword,Fk_Module_Description,Fk_Module_Pic,Fk_Module_FixedUrl,Fk_Module_Url,Fk_Module_Level,Fk_Module_LevelList,Fk_Module_Field From [Fk_ViewList] Where Fk_View_Show=1 And Fk_Module_State=1 And Fk_View_Id=" & t_Id
		Rs.Open Sqlstr,Conn,1,1
		If Not Rs.Eof Then
			c_Module=Rs("Fk_Module_Id")
			
			If Rs("Fk_Module_FixedUrl")<>"" Then
				v_ModuleUrl=Rs("Fk_Module_FixedUrl")
			Else
				v_ModuleUrl=Rs("Fk_Module_Url")
			End If
			
			Fk_View_Field=Rs("Fk_View_Field")

			c_ModuleUrl=GetUrl(c_SiteDir,"",Rs("Fk_Module_Url"),"","",1,t_Id,Rs("Fk_Module_FixedUrl"))
			Fk_Module_Name=Rs("Fk_Module_Name")
			Fk_Module_Level=Rs("Fk_Module_Level")
			Fk_Module_LevelList=Rs("Fk_Module_LevelList")
			Fk_Module_Field=Rs("Fk_Module_Field")
			c_NavNow=Rs("Fk_Module_Id")
			
			TemplateCode=ReplaceTag(TemplateCode,"{$ViewModuleId$}",Rs("Fk_Module_Id"))
			TemplateCode=ReplaceTag(TemplateCode,"{$ModuleId$}",Rs("Fk_Module_Id"))
			TemplateCode=ReplaceTag(TemplateCode,"{$ViewModuleName$}",Rs("Fk_Module_Name"))
			TemplateCode=ReplaceTag(TemplateCode,"{$ModuleName$}",Rs("Fk_Module_Name")) '内容页增加{$ModuleName$}标签，效果与{$ViewModuleName$}一样
			TemplateCode=ReplaceTag(TemplateCode,"{$ViewModuleSubTitle$}",Rs("Fk_Module_SubTitle"))
			TemplateCode=ReplaceTag(TemplateCode,"{$ModuleSubTitle$}",Rs("Fk_Module_SubTitle")) '内容页增加{$ModuleSubTitle$}标签，效果与{$ViewModuleSubTitle$}一样
			TemplateCode=ReplaceTag(TemplateCode,"{$ViewModuleKeyword$}",Rs("Fk_Module_Keyword"))
			TemplateCode=ReplaceTag(TemplateCode,"{$ViewModuleDescription$}",Rs("Fk_Module_Description"))
			TemplateCode=ReplaceTag(TemplateCode,"{$ViewModuleUrl$}",c_ModuleUrl)
			TemplateCode=ReplaceTag(TemplateCode,"{$ViewModulePic$}",Rs("Fk_Module_Pic"))
			
			TemplateCode=ReplaceTag(TemplateCode,"{$ViewId$}",t_Id)
			TemplateCode=ReplaceTag(TemplateCode,"{$ViewTitle$}",Rs("Fk_View_Title"))
			TemplateCode=ReplaceTag(TemplateCode,"{$ViewKeyword$}",Rs("Fk_View_Keyword"))
			TemplateCode=ReplaceTag(TemplateCode,"{$ViewDescription$}",Rs("Fk_View_Description"))
			TemplateCode=ReplaceTag(TemplateCode,"{$ViewPic$}",Rs("Fk_View_Pic"))
			TemplateCode=ReplaceTag(TemplateCode,"{$ViewPicBig$}",Rs("Fk_View_PicBig"))
			TemplateCode=ReplaceTag(TemplateCode,"{$ViewPicList$}",Rs("Fk_View_PicList"))
			TemplateCode=ReplaceTag(TemplateCode,"{$ViewContent$}",WordChange(Rs("Fk_View_Content")))
			TemplateCode=ReplaceTag(TemplateCode,"{$ViewUrl$}",GetUrl("",c_SiteUrl,v_ModuleUrl,Rs("Fk_View_Url"),c_HtmlSuffix,2,t_Id,Rs("Fk_View_FixedUrl")))
			TemplateCode=ReplaceTag(TemplateCode,"{$ViewClick$}","<span id='viewClick'></span>")
			TemplateCode=ReplaceTag(TemplateCode,"{$ViewTime$}",Rs("Fk_View_Time"))
			
			'模型自定义字段替换
			Sqlstr="Select Fk_Model_Default,Fk_Model_Field From [Fk_Model] Where Fk_Model_Id=" & Rs("Fk_Module_Model")
			Rst.Open Sqlstr,Conn,1,1
			If Not Rst.Eof Then
				ModelField=Rst("Fk_Model_Field")
			Else
				ModelField=""
			End If
			Rst.Close
			TempArr=Split(ModelField,"|FieldList|")
			For Each Temp In TempArr
				If Temp<>"" Then
					Field_Label=t_GetSub(Temp,"Field_Label:","|;|","")
					Field_Content=t_GetSub(Fk_View_Field,Field_Label&"_Field_Get:","|Get_Field_Line|","")
					TemplateCode=ReplaceTag(TemplateCode,"{$ViewField_"&Field_Label&"$}",Field_Content)
				End If
			Next
		Else
			Rs.Close
			Call t_ShowErr("页面不存在！",0)
		End If
		Rs.Close
		
		'当前主栏目判断
		If Instr(TemplateCode,"{$NavNow$}")>0 Then
			While Fk_Module_Level>0
				Sqlstr="Select Fk_Module_Id,Fk_Module_Level,Fk_Module_LevelList From [Fk_Module] Where Fk_Module_State=1 And Fk_Module_Id=" & c_NavNow
				Rs.Open Sqlstr,Conn,1,1
				If Not Rs.Eof Then
					Fk_Module_Level=Rs("Fk_Module_Level")
					If Fk_Module_Level>0 Then
						c_NavNow=Rs("Fk_Module_Level")
					End If
				Else
					c_NavNow=-1
					Fk_Module_Level=0
				End If
				Rs.Close
			Wend
			TemplateCode=Replace(TemplateCode,"{$NavNow$}",c_NavNow)
		End If
		
		'菜单项自定义字段
		Sqlstr="Select Fk_Field_Label From [Fk_Field] Where Fk_Field_Use=2 Order By Fk_Field_Id Asc"
		Rs.Open Sqlstr,Conn,1,1
		While Not Rs.Eof
			Field_Content=FKFun.GetSub(Fk_Module_Field,Rs("Fk_Field_Label")&"_Field_Get:","|Get_Field_Line|","")
			TemplateCode=ReplaceTag(TemplateCode,"{$ViewModuleField_"&Rs("Fk_Field_Label")&"$}",Field_Content)
			Rs.MoveNext
		Wend
		Rs.Close
		
		'上一篇
		If Instr(TemplateCode,"{$ViewPrevTitle$}")>0 Or Instr(TemplateCode,"{$ViewPrevUrl$}")>0 Or Instr(TemplateCode,"{$ViewPrevPic$}")>0 Then
			Sqlstr="Select Fk_View_Title,Fk_View_Pic,Fk_View_FixedUrl,Fk_View_Url From [Fk_ViewList] Where Fk_View_Show=1 And Fk_Module_State=1 And Fk_View_Module="&c_Module&" And Fk_View_Id<"&t_Id&" Order By Fk_View_Id Desc"
			Rs.Open Sqlstr,Conn,1,1
			If Not Rs.Eof Then
				TemplateCode=ReplaceTag(TemplateCode,"{$ViewPrevTitle$}",Rs("Fk_View_Title"))
				TemplateCode=ReplaceTag(TemplateCode,"{$ViewPrevUrl$}",GetUrl(c_SiteDir,"",v_ModuleUrl,Rs("Fk_View_Url"),c_HtmlSuffix,2,t_Id,Rs("Fk_View_FixedUrl")))
				TemplateCode=ReplaceTag(TemplateCode,"{$ViewPrevPic$}",Rs("Fk_View_Pic"))
			Else
				TemplateCode=ReplaceTag(TemplateCode,"{$ViewPrevTitle$}","无上一篇")
				TemplateCode=ReplaceTag(TemplateCode,"{$ViewPrevUrl$}","#")
				TemplateCode=ReplaceTag(TemplateCode,"{$ViewPrevPic$}","")
			End If
			Rs.Close
		End If
		
		'下一篇
		If Instr(TemplateCode,"{$ViewNextTitle$}")>0 Or Instr(TemplateCode,"{$ViewNextUrl$}")>0 Or Instr(TemplateCode,"{$ViewNextPic$}")>0 Then
			Sqlstr="Select Fk_View_Title,Fk_View_Pic,Fk_View_FixedUrl,Fk_View_Url From [Fk_ViewList] Where Fk_View_Show=1 And Fk_Module_State=1 And Fk_View_Module="&c_Module&" And Fk_View_Id>"&t_Id&" Order By Fk_View_Id Asc"
			Rs.Open Sqlstr,Conn,1,1
			If Not Rs.Eof Then
				TemplateCode=ReplaceTag(TemplateCode,"{$ViewNextTitle$}",Rs("Fk_View_Title"))
				TemplateCode=ReplaceTag(TemplateCode,"{$ViewNextUrl$}",GetUrl(c_SiteDir,"",v_ModuleUrl,Rs("Fk_View_Url"),c_HtmlSuffix,2,t_Id,Rs("Fk_View_FixedUrl")))
				TemplateCode=ReplaceTag(TemplateCode,"{$ViewNextPic$}",Rs("Fk_View_Pic"))
			Else
				TemplateCode=ReplaceTag(TemplateCode,"{$ViewNextTitle$}","无下一篇")
				TemplateCode=ReplaceTag(TemplateCode,"{$ViewNextUrl$}","#")
				TemplateCode=ReplaceTag(TemplateCode,"{$ViewNextPic$}","")
			End If
			Rs.Close
		End If
		
		'面包屑导航
		TemplateCode=Replace(TemplateCode,"{$SiteBreadCrumb$}",ChangeBreadCrumb(Fk_Module_LevelList,c_ModuleUrl,Fk_Module_Name))

		ViewChange=TemplateCode
	End Function

	'==============================
	'函 数 名：SubjectChange
	'作    用：专题页面标签替换
	'==============================
	Public Function SubjectChange(TemplateCode,t_Id)
		Dim Fk_Subject_Name
		
		Sqlstr="Select Fk_Subject_Name,Fk_Subject_About,Fk_Subject_Pic,Fk_Subject_Dir From [Fk_Subject] Where Fk_Subject_Id=" & t_Id
		Rs.Open Sqlstr,Conn,1,1
		If Not Rs.Eof Then
			Fk_Subject_Name=Rs("Fk_Subject_Name")
			c_SubjectUrl=GetUrl(c_SiteDir,"","Subject/"&Rs("Fk_Subject_Dir")&"/","","",3,t_Id,"")
			
			TemplateCode=ReplaceTag(TemplateCode,"{$SubjectId$}",t_Id)
			TemplateCode=ReplaceTag(TemplateCode,"{$SubjectName$}",Rs("Fk_Subject_Name"))
			TemplateCode=ReplaceTag(TemplateCode,"{$SubjectAbout$}",Rs("Fk_Subject_About"))
			TemplateCode=ReplaceTag(TemplateCode,"{$SubjectPic$}",Rs("Fk_Subject_Pic"))
			TemplateCode=ReplaceTag(TemplateCode,"{$SubjectUrl$}",GetUrl("",c_SiteUrl,"Subject/"&Rs("Fk_Subject_Dir")&"/","","",3,t_Id,""))
			TemplateCode=Replace(TemplateCode,"{$NavNow$}",-1)
		Else
			Rs.Close
			Call t_ShowErr("专题不存在！",0)
		End If
		Rs.Close
		
		'面包屑导航
		TemplateCode=Replace(TemplateCode,"{$SiteBreadCrumb$}","<a href="""&c_SubjectUrl&""" title="""&Fk_Subject_Name&""">"&Fk_Subject_Name&"</a>")

		SubjectChange=TemplateCode
	End Function
	
	'==============================
	'函 数 名：FileChange
	'作    用：模板嵌套文件替换
	'==============================
	Public Function FileChange(TemplateCode)
		Dim TemplateFile
		
		While Instr(TemplateCode,"{$File(")
			TemplateFile=LCase(CutLabelValue(TemplateCode,"{$File(",")$}",""))
			TemplateCode=ReplaceTag(TemplateCode,"{$File("&TemplateFile&")$}",GetTemplate(TemplateFile))
		Wend
		
		FileChange=TemplateCode
	End Function
	
'========================For标签处理===========================	
	
	'==============================
	'函 数 名：NavForChange
	'作    用：菜单FOR替换
	'==============================
	Public Function NavForChange(ChangeHtml,ChangeValue)
		Dim NavTemp,NavChangeHtml
		Dim Rsq
		Set Rsq=Server.Createobject("Adodb.RecordSet")
		
		'回溯处理
		c_Menu=CutLabelValue(ChangeValue,"Menu:",";",0)
		c_Module=CutLabelValue(ChangeValue,"Module:",";",0)
		c_Level=CutLabelValue(ChangeValue,"Level:",";",0)
		c_Recall=CutLabelValue(ChangeValue,"Recall:",";",0)
		If c_Module>0 Then
			While c_Recall<0
				Sqlstr="Select Fk_Module_Level From [Fk_Module] Where Fk_Module_Id="&c_Module&""
				Rs.Open Sqlstr,Conn,1,1
				If Not Rs.Eof Then
					c_Module=Rs("Fk_Module_Level")
					If c_Module=0 Then
						c_Recall=c_Recall+1
					Else
						c_Recall=0
					End If
				Else
					c_Module=0
					c_Recall=0
				End If
				Rs.Close
			Wend
		End If
		
		'菜单FOR嵌套处理
		NavChangeHtml=ChangeHtml
		If Instr(NavChangeHtml,"{$For(Nav,")>0 Then
			NavTemp="{$For(Nav,"&Split(NavChangeHtml,"{$For(Nav,")(1)
			NavTemp=GetFor(NavTemp)
			NavTemp=Replace(NavTemp,Split(NavTemp,")$}")(0)&")$}","",1,1)
			NavTemp=Left(NavTemp,Len(NavTemp)-8)
			NavChangeHtml=Replace(NavChangeHtml,NavTemp,"|$$%%Nav_Sub_Insert%%$$|")
		End If
		
		NavForChange=""
		Sqlstr="Select Fk_Module_Id,Fk_Module_Name,Fk_Module_SubTitle,Fk_Module_Keyword,Fk_Module_Description,Fk_Module_Pic,Fk_Module_Type,Fk_Module_SubColCount,Fk_Module_FixedUrl,Fk_Module_Url,Fk_Module_LinkType,Fk_Module_Link,Fk_Module_Field,Fk_Module_Content From [Fk_Module] Where Fk_Module_State=1 And Fk_Module_MenuShow=1 And Fk_Module_Menu="&c_Menu&" And Fk_Module_Level="&c_Module&" Order By Fk_Module_Order Asc,Fk_Module_Id Asc"
		Rs.Open Sqlstr,Conn,1,1
		ListNo=1
		While Not Rs.Eof
			'跳转模块处理
			If Rs("Fk_Module_Type")=4 Then
				c_ModuleTarget=" target='_blank'"
			Else
				c_ModuleTarget=""
			End If
			If Rs("Fk_Module_Type")=4 And Rs("Fk_Module_LinkType")=0 Then
				c_ModuleUrl=Rs("Fk_Module_Link")
			Else
				c_ModuleUrl=GetUrl(c_SiteDir,"",Rs("Fk_Module_Url"),"","",1,Rs("Fk_Module_Id"),Rs("Fk_Module_FixedUrl"))
			End If
			'中转模块处理
			If Rs("Fk_Module_Type")=5 Then
				Sqlstr="Select Top 1 Fk_Module_Id,Fk_Module_FixedUrl,Fk_Module_Url From [Fk_Module] Where Fk_Module_State=1 And Fk_Module_MenuShow=1 And Fk_Module_Menu="&c_Menu&" And Fk_Module_Level="&Rs("Fk_Module_Id")&" Order By Fk_Module_Order Asc,Fk_Module_Id Asc"
				Rsq.Open Sqlstr,Conn,1,1
				If Not Rsq.Eof Then
					c_ModuleUrl=GetUrl(c_SiteDir,"",Rsq("Fk_Module_Url"),"","",1,Rsq("Fk_Module_Id"),Rsq("Fk_Module_FixedUrl"))
				Else
					c_ModuleUrl="#"
				End If
				Rsq.Close
			End If
			'标签替换
			NavForChange=NavForChange&NavChangeHtml
			NavForChange=ReplaceTag(NavForChange,"{$List.NavNo$}",ListNo)
			NavForChange=ReplaceTag(NavForChange,"{$List.NavId$}",Rs("Fk_Module_Id"))
			NavForChange=ReplaceTag(NavForChange,"{$List.NavName$}",Rs("Fk_Module_Name"))
			NavForChange=ReplaceTag(NavForChange,"{$List.NavSubTitle$}",Rs("Fk_Module_SubTitle"))
			NavForChange=ReplaceTag(NavForChange,"{$List.NavKeyword$}",Rs("Fk_Module_Keyword"))
			NavForChange=ReplaceTag(NavForChange,"{$List.NavDescription$}",Rs("Fk_Module_Description"))
			NavForChange=ReplaceTag(NavForChange,"{$List.NavPic$}",Rs("Fk_Module_Pic"))
			NavForChange=ReplaceTag(NavForChange,"{$List.NavType$}",Rs("Fk_Module_Type"))
			NavForChange=ReplaceTag(NavForChange,"{$List.NavSubColCount$}",Rs("Fk_Module_SubColCount"))
			NavForChange=ReplaceTag(NavForChange,"{$List.NavUrl$}",c_ModuleUrl)
			NavForChange=ReplaceTag(NavForChange,"{$List.NavTarget$}",c_ModuleTarget)
			NavForChange=ReplaceTag(NavForChange,"{$List.NavSub$}",NavSubChange(Rs("Fk_Module_Id"),c_Level))
			NavForChange=ReplaceTag(NavForChange,"{$List.NavContent$}",Rs("Fk_Module_Content"))

			'菜单项自定义字段
			Sqlstr="Select Fk_Field_Label From [Fk_Field] Where Fk_Field_Use=2 Order By Fk_Field_Id Asc"
			Rsq.Open Sqlstr,Conn,1,1
			While Not Rsq.Eof
				Field_Content=FKFun.GetSub(Rs("Fk_Module_Field"),Rsq("Fk_Field_Label")&"_Field_Get:","|Get_Field_Line|","")
				NavForChange=ReplaceTag(NavForChange,"{$List.NavField_"&Rsq("Fk_Field_Label")&"$}",Field_Content)
				Rsq.MoveNext
			Wend
			Rsq.Close

			Rs.MoveNext
			ListNo=ListNo+1
		Wend
		Rs.Close
		
		NavForChange=Replace(NavForChange,"|$$%%Nav_Sub_Insert%%$$|",NavTemp)
	End Function
	
	'==============================
	'函 数 名：NavSubChange
	'作    用：二级菜单替换
	'==============================
	Private Function NavSubChange(gId,gLevel)
		Dim Rst,Rsp
		Set Rst=Server.Createobject("Adodb.RecordSet")
		Set Rsp=Server.Createobject("Adodb.RecordSet")
		
		Sqlstr="Select Fk_Module_Id,Fk_Module_Name,Fk_Module_SubTitle,Fk_Module_Type,Fk_Module_FixedUrl,Fk_Module_Url,Fk_Module_LinkType,Fk_Module_Link From [Fk_Module] Where Fk_Module_State=1 And Fk_Module_MenuShow=1 And Fk_Module_Level="&gId&" Order By Fk_Module_Order Asc,Fk_Module_Id Asc"
		Rst.Open Sqlstr,Conn,1,1
		If Not Rst.Eof Then
			NavSubChange="<ul>" & vbCrLf
			gLevel=gLevel-1
			While Not Rst.Eof
				'跳转模块处理
				If Rst("Fk_Module_Type")=4 Then
					c_ModuleTarget=" target='_blank'"
				Else
					c_ModuleTarget=""
				End If
				If Rst("Fk_Module_Type")=4 And Rst("Fk_Module_LinkType")=0 Then
					c_ModuleUrl=Rst("Fk_Module_Link")
				Else
					c_ModuleUrl=GetUrl(c_SiteDir,"",Rst("Fk_Module_Url"),"","",1,Rst("Fk_Module_Id"),Rst("Fk_Module_FixedUrl"))
				End If
				'中转模块处理
				If Rst("Fk_Module_Type")=5 Then
					Sqlstr="Select Top 1 Fk_Module_Id,Fk_Module_FixedUrl,Fk_Module_Url From [Fk_Module] Where Fk_Module_State=1 And Fk_Module_MenuShow=1 And Fk_Module_Level="&Rst("Fk_Module_Id")&" Order By Fk_Module_Order Asc,Fk_Module_Id Asc"
					Rsp.Open Sqlstr,Conn,1,1
					If Not Rsq.Eof Then
						c_ModuleUrl=GetUrl(c_SiteDir,"",Rsp("Fk_Module_Url"),"","",1,Rsp("Fk_Module_Id"),Rsp("Fk_Module_FixedUrl"))
					Else
						c_ModuleUrl="#"
					End If
					Rsp.Close
				End If
				'标签替换
				NavSubChange=NavSubChange&"<li><a href='"&c_ModuleUrl&"' title='"&Rst("Fk_Module_Name")&"'"&c_ModuleTarget&">"
				NavSubChange=NavSubChange&Rst("Fk_Module_Name")&"</a>"
				If gLevel>0 Then
					NavSubChange=NavSubChange&NavSubChange(Rst("Fk_Module_Id"),gLevel)
				End If
				NavSubChange=NavSubChange&"</li>" & vbCrLf
				Rst.MoveNext
			Wend
			NavSubChange=NavSubChange&"</ul>" & vbCrLf
		End If
		Rst.Close
		Set Rst=Nothing
	End Function
	
	'==============================
	'函 数 名：ViewForChange
	'作    用：内容FOR替换
	'==============================
	Public Function ViewForChange(ChangeHtml,ChangeValue)
		Dim Fk_View_Field
		Dim c_Pic
		c_PageSize=Fk_Site_PageSize
		c_Menu=CutLabelValue(ChangeValue,"Menu:",";",0)
		c_Module=CutLabelValue(ChangeValue,"Module:",";",0)
		c_Recommend=CutLabelValue(ChangeValue,"Recommend:",";",0)
		c_Subject=CutLabelValue(ChangeValue,"Subject:",";",0)
		c_Order=CutLabelValue(ChangeValue,"Order:",";",0)
		c_Count=CutLabelValue(ChangeValue,"Count:",";",0)
		c_Pic=CutLabelValue(ChangeValue,"Pic:",";",0)
		
		If Not IsNumeric(c_Menu) Then
			Call t_ShowErr("viewFor，菜单ID必须是数字！",0)
		End If
		If Not IsNumeric(Replace(c_Module,"+","")) Then
			Call t_ShowErr("viewFor，菜单项ID必须是数字！",0)
		End If

		If IsNumeric(c_Module) Then
			If c_Module>0 Then
				Sqlstr="Select Fk_Module_Id,Fk_Module_Model From [Fk_Module] Where Fk_Module_Id=" & c_Module
				Rs.Open Sqlstr,Conn,1,1
				If Not Rs.Eof Then
					ModelId=Rs("Fk_Module_Model")
				Else
					ModelId=0
				End If
				Rs.Close
				
				Sqlstr="Select Fk_Model_Field From [Fk_Model] Where Fk_Model_Id=" & ModelId
				Rs.Open Sqlstr,Conn,1,1
				If Not Rs.Eof Then
					ModelField=Rs("Fk_Model_Field")
				Else
					ModelField=""
				End If
				Rs.Close
			Else
				ModelField=""
			End If
		Else
			ModelField=""
		End If
		
		
		Sqlstr="Select"
		If c_Count>0 Then
			Sqlstr=Sqlstr&" Top "&c_Count&""
		End If
		Sqlstr=Sqlstr&" Fk_View_Id,Fk_View_Title,Fk_View_Color,Fk_View_Keyword,Fk_View_Description,Fk_View_Pic,Fk_View_PicBig,Fk_View_PicList,Fk_View_Content,Fk_View_FixedUrl,Fk_View_Url,Fk_View_Field,Fk_View_Link,Fk_View_Stick,Fk_View_Click,Fk_View_Time,Fk_Module_Id,Fk_Module_Name,Fk_Module_Type,Fk_Module_LinkType,Fk_Module_Link,Fk_Module_FixedUrl,Fk_Module_Url From [Fk_ViewList] Where Fk_View_Show=1 And Fk_Module_State=1"
		If c_Menu>0 Then
			Sqlstr=Sqlstr&" And Fk_View_Menu="&c_Menu&""
		End If
		If Instr(c_Module,"+")>0 Then
			Sqlstr=Sqlstr&" And Fk_View_Module In ("&Replace(c_Module,"+",",")&")"
			If c_Count=0 Then
				c_Count=10
			End If
		ElseIf c_Module>0 Then
			Sqlstr=Sqlstr&" And (Fk_View_Module="&c_Module&" Or Fk_Module_LevelList Like '%%,"&c_Module&",%%')"
		End If
		If c_Recommend>0 Then
			Sqlstr=Sqlstr&" And Fk_View_Recommend Like '%%"&c_Recommend&"%%'"
		ElseIf c_Recommend=-1 Then
			Sqlstr=Sqlstr&" And Fk_View_Recommend=',,'"
		End If
		If c_Subject>0 Then
			Sqlstr=Sqlstr&" And Fk_View_Subject Like '%%"&c_Subject&"%%'"
		ElseIf c_Subject=-1 Then
			Sqlstr=Sqlstr&" And Fk_View_Subject=',,'"
		End If
		
		If c_Pic<>0 Then
			If c_Pic="-1" Then
				Sqlstr=Sqlstr&" And Fk_View_Pic = ''"
			ElseIf c_Pic="1" Then
				Sqlstr=Sqlstr&" And Fk_View_Pic <> ''"
			End If
		End If
		
		If SearchStr<>"" And c_Count=0 Then
			Sqlstr=Sqlstr&" And Fk_View_Title Like '%%"&SearchStr&"%%'"
		End If
		Select Case c_Order
			Case 1
				Sqlstr=Sqlstr&" Order By Fk_View_Stick Desc,Fk_View_Id Desc"
			Case 2
				Sqlstr=Sqlstr&" Order By Fk_View_Stick Desc,Fk_View_Id Asc"
			Case 3
				Sqlstr=Sqlstr&" Order By Fk_View_Stick Desc,Fk_View_Time Desc,Fk_View_Id Desc"
			Case 4
				Sqlstr=Sqlstr&" Order By Fk_View_Stick Desc,Fk_View_Time Asc,Fk_View_Id Asc"
			Case 5
				Sqlstr=Sqlstr&" Order By Fk_View_Stick Desc,Fk_View_Click Desc,Fk_View_Id Desc"
			Case 6
				Sqlstr=Sqlstr&" Order By Fk_View_Stick Desc,Fk_View_Click Asc,Fk_View_Id Desc"
		End Select
		Rs.Open Sqlstr,Conn,1,1
		If Not Rs.Eof Then
			ListNo=1
			ListNo_Page=(PageNow-1)*c_PageSize+1
			If c_Count=0 Then
				c_Count=c_PageSize
				Rs.PageSize=c_PageSize
				If PageNow>Rs.PageCount Or PageNow<=0 Then
					PageNow=1
				End If
				Rs.AbsolutePage=PageNow
			End If
			While (Not Rs.Eof) And ListNo<c_Count+1
				If Rs("Fk_Module_FixedUrl")<>"" Then
					v_ModuleUrl=Rs("Fk_Module_FixedUrl")
				Else
					v_ModuleUrl=Rs("Fk_Module_Url")
				End If
				If Rs("Fk_Module_Type")=4 And Rs("Fk_Module_LinkType")=0 Then
					c_ModuleUrl=Rst("Fk_Module_Link")
				Else
					c_ModuleUrl=GetUrl(c_SiteDir,"",Rs("Fk_Module_Url"),"","",1,Rs("Fk_Module_Id"),Rs("Fk_Module_FixedUrl"))
				End If
				
				Fk_View_Field=Rs("Fk_View_Field")
				'跳转处理
				If Rs("Fk_View_Link")<>"" Then
					c_ViewUrl=Rs("Fk_View_Link")
					c_ViewTarget=" target='_blank'"
				Else
					c_ViewUrl=GetUrl(c_SiteDir,"",v_ModuleUrl,Rs("Fk_View_Url"),c_HtmlSuffix,2,Rs("Fk_View_Id"),Rs("Fk_View_FixedUrl"))
					c_ViewTarget=""
				End If
				'标签替换
				ViewForChange=ViewForChange&ChangeHtml
				ViewForChange=ReplaceTag(ViewForChange,"{$List.ViewNo$}",ListNo)
				ViewForChange=ReplaceTag(ViewForChange,"{$List.ViewPageNo$}",ListNo_Page)
				ViewForChange=ReplaceTag(ViewForChange,"{$List.ViewModuleId$}",Rs("Fk_Module_Id"))
				ViewForChange=ReplaceTag(ViewForChange,"{$List.ViewModuleName$}",Rs("Fk_Module_Name"))
				ViewForChange=ReplaceTag(ViewForChange,"{$List.ViewModuleUrl$}",c_ModuleUrl)
				
				ViewForChange=ReplaceTag(ViewForChange,"{$List.ViewId$}",Rs("Fk_View_Id"))
				ViewForChange=ReplaceTag(ViewForChange,"{$List.ViewTitle$}",Rs("Fk_View_Title"))
				ViewForChange=ReplaceTag(ViewForChange,"{$List.ViewTitleInColor$}","<span style='color:"&Rs("Fk_View_Color")&";'>"&Rs("Fk_View_Title")&"</span>")
				ViewForChange=ReplaceTag(ViewForChange,"{$List.ViewKeyword$}",Rs("Fk_View_Keyword"))
				ViewForChange=ReplaceTag(ViewForChange,"{$List.ViewDescription$}",Rs("Fk_View_Description"))
				ViewForChange=ReplaceTag(ViewForChange,"{$List.ViewPic$}",Rs("Fk_View_Pic"))
				ViewForChange=ReplaceTag(ViewForChange,"{$List.ViewPicBig$}",Rs("Fk_View_PicBig"))
				ViewForChange=ReplaceTag(ViewForChange,"{$List.ViewPicList$}",Rs("Fk_View_PicList"))
				ViewForChange=ReplaceTag(ViewForChange,"{$List.ViewContent$}",Rs("Fk_View_Content"))
				ViewForChange=ReplaceTag(ViewForChange,"{$List.ViewUrl$}",c_ViewUrl)
				ViewForChange=ReplaceTag(ViewForChange,"{$List.ViewTarget$}",c_ViewTarget)
				ViewForChange=ReplaceTag(ViewForChange,"{$List.ViewStick$}",Rs("Fk_View_Stick"))
				ViewForChange=ReplaceTag(ViewForChange,"{$List.ViewClick$}",Rs("Fk_View_Click"))
				ViewForChange=ReplaceTag(ViewForChange,"{$List.ViewTime$}",Rs("Fk_View_Time"))
				ViewForChange=ReplaceTag(ViewForChange,"{$List.ViewNew$}",DateDiff("d",Rs("Fk_View_Time"),Now()))
				
				'模型字段标签替换
				TempArr=Split(ModelField,"|FieldList|")
				For Each Temp In TempArr
					If Temp<>"" Then
						Field_Label=t_GetSub(Temp,"Field_Label:","|;|","")
						Field_Content=t_GetSub(Fk_View_Field,Field_Label&"_Field_Get:","|Get_Field_Line|","")
						ViewForChange=ReplaceTag(ViewForChange,"{$List.ViewField_"&Field_Label&"$}",Field_Content)
					End If
				Next

				Rs.MoveNext
				ListNo=ListNo+1
				ListNo_Page=ListNo_Page+1
			Wend
		Else
			ViewForChange=""
		End If
		Rs.Close
	End Function
	
	'==============================
	'函 数 名：GBookForChange
	'作    用：内容FOR替换
	'==============================
	Public Function GBookForChange(ChangeHtml,ChangeValue)
		Dim Fk_GBook_Content,Fk_Module_GBookReply
		c_PageSize=Fk_Site_PageSize
		c_Menu=CutLabelValue(ChangeValue,"Menu:",";",0)
		c_Module=CutLabelValue(ChangeValue,"Module:",";",0)
		c_State=CutLabelValue(ChangeValue,"State:",";",0)
		c_Count=CutLabelValue(ChangeValue,"Count:",";",0)
		
		If Not IsNumeric(c_Menu) Then
			Call t_ShowErr("gbookFor，菜单ID必须是数字！",0)
		End If
		If Not IsNumeric(c_Module) Then
			Call t_ShowErr("gbookFor，菜单项ID必须是数字！",0)
		End If

		Sqlstr="Select Fk_Module_Id,Fk_Module_Model,Fk_Module_GBookReply From [Fk_Module] Where Fk_Module_State=1 And Fk_Module_Id=" & c_Module
		Rs.Open Sqlstr,Conn,1,1
		If Not Rs.Eof Then
			ModelId=Rs("Fk_Module_Model")
			Fk_Module_GBookReply=Rs("Fk_Module_GBookReply")
		Else
			Call t_ShowErr("菜单项不存在！",0)
		End If
		Rs.Close
		
		If Fk_Module_GBookReply=3 And c_Count=0 Then
			GBookForChange=""
			Exit Function
		End If
		
		Sqlstr="Select Fk_Model_Field From [Fk_Model] Where Fk_Model_Id=" & ModelId
		Rs.Open Sqlstr,Conn,1,1
		If Not Rs.Eof Then
			ModelField=Rs("Fk_Model_Field")
		Else
			Call t_ShowErr("模型不存在！",0)
		End If
		Rs.Close
		
		Sqlstr="Select"
		If c_Count>0 Then
			Sqlstr=Sqlstr&" Top "&c_Count&""
		Else
			c_State=Fk_Module_GBookReply
		End If
		Sqlstr=Sqlstr&" Fk_GBook_Id,Fk_GBook_Content,Fk_GBook_Time,Fk_GBook_Re,Fk_GBook_ReTime,Fk_Module_Id,Fk_Module_Name,Fk_Module_Url From [Fk_GBookList] Where Fk_Module_State=1 And Fk_GBook_Module="&c_Module&" And Fk_GBook_Show=1"
		If c_State=1 Then
			Sqlstr=Sqlstr&" And Fk_GBook_ReIp<>''"
		ElseIf c_State=2 Then
			Sqlstr=Sqlstr&" And (Fk_GBook_ReIp='' Or Fk_GBook_ReIp Is Null)"
		End If
		Sqlstr=Sqlstr&" Order By Fk_GBook_Id Desc"
		Rs.Open Sqlstr,Conn,1,1
		If Not Rs.Eof Then
			ListNo=1
			ListNo_Page=(PageNow-1)*c_PageSize+1
			If c_Count=0 Then
				c_Count=c_PageSize
				Rs.PageSize=c_PageSize
				If PageNow>Rs.PageCount Or PageNow<=0 Then
					PageNow=1
				End If
				Rs.AbsolutePage=PageNow
			End If
			While (Not Rs.Eof) And ListNo<c_Count+1
				Fk_GBook_Content=Rs("Fk_GBook_Content")
				'标签替换
				GBookForChange=GBookForChange&ChangeHtml
				GBookForChange=ReplaceTag(GBookForChange,"{$List.GBookNo$}",ListNo)
				GBookForChange=ReplaceTag(GBookForChange,"{$List.GBookPageNo$}",ListNo_Page)
				GBookForChange=ReplaceTag(GBookForChange,"{$List.GBookModuleId$}",Rs("Fk_Module_Id"))
				GBookForChange=ReplaceTag(GBookForChange,"{$List.GBookModuleName$}",Rs("Fk_Module_Name"))
				
				GBookForChange=ReplaceTag(GBookForChange,"{$List.GBookId$}",Rs("Fk_GBook_Id"))
				GBookForChange=ReplaceTag(GBookForChange,"{$List.GBookTime$}",Rs("Fk_GBook_Time"))
				If Rs("Fk_GBook_ReTime")<>"" Then
					GBookForChange=ReplaceTag(GBookForChange,"{$List.GBookReply$}","1")
					GBookForChange=ReplaceTag(GBookForChange,"{$List.GBookReplyStr$}",Rs("Fk_GBook_Re"))
					GBookForChange=ReplaceTag(GBookForChange,"{$List.GBookReplyTime$}",Rs("Fk_GBook_ReTime"))
				Else
					GBookForChange=ReplaceTag(GBookForChange,"{$List.GBookReply$}","0")
					GBookForChange=ReplaceTag(GBookForChange,"{$List.GBookReplyStr$}","")
					GBookForChange=ReplaceTag(GBookForChange,"{$List.GBookReplyTime$}","")
				End If
				
				'模型字段标签替换
				TempArr=Split(ModelField,"|FieldList|")
				For Each Temp In TempArr
					If Temp<>"" Then
						Field_Label=FKFun.GetSub(Temp,"Field_Label:","|;|","")
						Field_Content=t_GetSub(Fk_GBook_Content,Field_Label&"|:|","|;|","")
						GBookForChange=ReplaceTag(GBookForChange,"{$List."&Field_Label&"$}",Field_Content)
					End If
				Next

				Rs.MoveNext
				ListNo=ListNo+1
				ListNo_Page=ListNo_Page+1
			Wend
		Else
			GBookForChange=""
		End If
		Rs.Close
	End Function
	
	'==============================
	'函 数 名：FriendsForChange
	'作    用：友情链接FOR替换
	'==============================
	Public Function FriendsForChange(ChangeHtml,ChangeValue)
		c_FriendsType=CutLabelValue(ChangeValue,"FriendsType:",";",0)
		c_FriendsShowType=CutLabelValue(ChangeValue,"FriendsShowType:",";",0)
		c_Count=CutLabelValue(ChangeValue,"Count:",";",0)
		
		Sqlstr="Select"
		If c_Count>0 Then
			Sqlstr=Sqlstr&" Top "&c_Count&""
		End If
		Sqlstr=Sqlstr&" Fk_Friends_Id,Fk_Friends_Name,Fk_Friends_About,Fk_Friends_Url,Fk_Friends_Logo From [Fk_Friends] Where Fk_Friends_FriendsType="&c_FriendsType&""
		If c_FriendsShowType>0 Then
			Sqlstr=Sqlstr&" And Fk_Friends_ShowType="&c_FriendsShowType&""
		End If
		Sqlstr=Sqlstr&" Order By Fk_Friends_Id Desc"
		Rs.Open Sqlstr,Conn,1,1
		If Not Rs.Eof Then
			ListNo=1
			While Not Rs.Eof
				
				FriendsForChange=FriendsForChange&ChangeHtml
				FriendsForChange=ReplaceTag(FriendsForChange,"{$List.FriendsNo$}",ListNo)
				FriendsForChange=ReplaceTag(FriendsForChange,"{$List.FriendsName$}",Rs("Fk_Friends_Name"))
				FriendsForChange=ReplaceTag(FriendsForChange,"{$List.FriendsAbout$}",Rs("Fk_Friends_About"))
				FriendsForChange=ReplaceTag(FriendsForChange,"{$List.FriendsUrl$}",Rs("Fk_Friends_Url"))
				FriendsForChange=ReplaceTag(FriendsForChange,"{$List.FriendsLogo$}",Rs("Fk_Friends_Logo"))

				Rs.MoveNext
				ListNo=ListNo+1
			Wend
		Else
			FriendsForChange=""
		End If
		Rs.Close
	End Function
	
	'==============================
	'函 数 名：SubjectForChange
	'作    用：专题FOR替换
	'==============================
	Public Function SubjectForChange(ChangeHtml,ChangeValue)
		c_Count=CutLabelValue(ChangeValue,"Count:",";",0)
		
		Sqlstr="Select"
		If c_Count>0 Then
			Sqlstr=Sqlstr&" Top "&c_Count&""
		End If
		Sqlstr=Sqlstr&" Fk_Subject_Id,Fk_Subject_Name,Fk_Subject_Pic,Fk_Subject_Dir From [Fk_Subject] Order By Fk_Subject_Id Desc"
		Rs.Open Sqlstr,Conn,1,1
		If Not Rs.Eof Then
			ListNo=1
			While Not Rs.Eof
				
				SubjectForChange=SubjectForChange&ChangeHtml
				SubjectForChange=ReplaceTag(SubjectForChange,"{$List.SubjectNo$}",ListNo)
				SubjectForChange=ReplaceTag(SubjectForChange,"{$List.SubjectName$}",Rs("Fk_Subject_Name"))
				SubjectForChange=ReplaceTag(SubjectForChange,"{$List.SubjectPic$}",Rs("Fk_Subject_Pic"))
				SubjectForChange=ReplaceTag(SubjectForChange,"{$List.SubjectUrl$}",GetUrl(c_SiteDir,"","Subject/"&Rs("Fk_Subject_Dir")&"/","","",3,Rs("Fk_Subject_Id"),""))

				Rs.MoveNext
				ListNo=ListNo+1
			Wend
		Else
			SubjectForChange=""
		End If
		Rs.Close
	End Function
	
	'==============================
	'函 数 名：PicForChange
	'作    用：题图列表FOR替换
	'==============================
	Public Function PicForChange(ChangeHtml,ChangeValue)
		Dim p_Temp,p_TempArr,pArr
		c_PicList=CutLabelValue(ChangeValue,"List:",";",0)

		ListNo=1
		p_TempArr=Split(c_PicList,"|-_-|")
		For Each p_Temp In p_TempArr
			If Instr(p_Temp,"||") Then
				pArr=Split(p_Temp,"||")
				PicForChange=PicForChange&ChangeHtml
				PicForChange=ReplaceTag(PicForChange,"{$List.PicNo$}",ListNo)
				PicForChange=ReplaceTag(PicForChange,"{$List.PicSmall$}",pArr(0))
				PicForChange=ReplaceTag(PicForChange,"{$List.PicBig$}",pArr(1))
				PicForChange=ReplaceTag(PicForChange,"{$List.PicText$}",pArr(2))
				ListNo=ListNo+1
			End If
		Next
	End Function
	
	'==============================
	'函 数 名：FkNumList
	'作    用：循环列表标签操作
	'参    数：
	'BCode  标签内容
	'BPar   标签参数
	'==============================
	Private Function FkNumList(BCode,BPar)
		Dim ListNo
		ListNo=1
		If BPar="" Or Instr(BPar,"/")=0 Then
			Exit Function
		End If
		TempArr=Split(BPar,"/")
		If Not IsNumeric(TempArr(0)) Or Not IsNumeric(TempArr(1)) Then
			Exit Function
		End If
		For ListNo=Clng(TempArr(0)) To Clng(TempArr(1))
			FkNumList=FkNumList&BCode
			FkNumList=Replace(FkNumList,"{$ListNo$}",ListNo)
		Next
	End Function
	
	'==============================
	'函 数 名：FocusForChange
	'作    用：幻灯输出
	'==============================
	Public Function FocusForChange(ChangeHtml,ChangeValue)
		Dim p_Temp,p_TempArr,pArr,FocusID
		FocusID=CutLabelValue(ChangeValue,"FocusID:",";",0)

		Sqlstr="SELECT Fk_Focus_Content FROM [Fk_Focus] Where Fk_Focus_Id="&FocusID
		Rs.Open Sqlstr,Conn,1,1
		If Not Rs.Eof Then
			p_TempArr=Split(Rs("Fk_Focus_Content"),"|FocusList|")
		Else
			Rs.Close
			FocusForChange=""
		End If
		Rs.Close

		ListNo = 1
		For Each p_Temp In p_TempArr
			If Instr(p_Temp,"|;|Focus_Pic:")>0 Then
				FocusForChange=FocusForChange&ChangeHtml
				FocusForChange=ReplaceTag(FocusForChange,"{$List.FocusNo$}",ListNo)
				FocusForChange=ReplaceTag(FocusForChange,"{$List.FocusText$}",FKFun.GetSub(p_Temp,"Focus_Title:","|;|",""))
				FocusForChange=ReplaceTag(FocusForChange,"{$List.FocusPic$}",FKFun.GetSub(p_Temp,"Focus_Pic:","|;|",""))
				FocusForChange=ReplaceTag(FocusForChange,"{$List.FocusUrl$}",FKFun.GetSub(p_Temp,"Focus_Url:","|;|",""))
				ListNo=ListNo+1
			End If
		Next
	End Function
	
	'==============================
	'函 数 名：ChangeBreadCrumb
	'作    用：输出面包屑导航
	'==============================
	Private Function ChangeBreadCrumb(mList,mUrl,mName)
		Dim bTempArr,bTemp,b_ModuleTarget,b_ModuleUrl
		Dim Rsq
		Set Rsq=Server.Createobject("Adodb.RecordSet")

		If Instr(mList,",")>0 Then
			bTempArr=Split(mList,",")
			ChangeBreadCrumb=""
			For Each bTemp In bTempArr
				If bTemp<>"" Then
					Sqlstr="Select Fk_Module_Id,Fk_Module_Name,Fk_Module_SubTitle,Fk_Module_Type,Fk_Module_SubColCount,Fk_Module_FixedUrl,Fk_Module_Url,Fk_Module_LinkType,Fk_Module_Link From [Fk_Module] Where Fk_Module_Id=" & bTemp
					Rs.Open Sqlstr,Conn,1,1
					If Not Rs.Eof Then
						'跳转模块处理
						If Rs("Fk_Module_Type")=4 Then
							b_ModuleTarget=" target=""_blank"""
						Else
							b_ModuleTarget=""
						End If
						If Rs("Fk_Module_Type")=4 And Rs("Fk_Module_LinkType")=0 Then
							b_ModuleUrl=Rs("Fk_Module_Link")
						Else
							b_ModuleUrl=GetUrl(c_SiteDir,"",Rs("Fk_Module_Url"),"","",1,Rs("Fk_Module_Id"),Rs("Fk_Module_FixedUrl"))
						End If
						'中转模块处理
						If Rs("Fk_Module_Type")=5 Then
							Sqlstr="Select Top 1 Fk_Module_Id,Fk_Module_FixedUrl,Fk_Module_Url From [Fk_Module] Where Fk_Module_State=1 And Fk_Module_Level="&Rs("Fk_Module_Id")&" Order By Fk_Module_Order Asc,Fk_Module_Id Asc"
							Rsq.Open Sqlstr,Conn,1,1
							If Not Rsq.Eof Then
								b_ModuleUrl=GetUrl(c_SiteDir,"",Rsq("Fk_Module_Url"),"","",1,Rsq("Fk_Module_Id"),Rsq("Fk_Module_FixedUrl"))
							Else
								b_ModuleUrl="#"
							End If
							Rsq.Close
						End If
						ChangeBreadCrumb=ChangeBreadCrumb&"&nbsp;&nbsp;&raquo;&nbsp;&nbsp;"&"<a href="""&b_ModuleUrl&""" title="""&Rs("Fk_Module_Name")&""""&b_ModuleTarget&">"&Rs("Fk_Module_Name")&"</a>"
					End If
					Rs.Close
				End If
			Next
		End If
		ChangeBreadCrumb=ChangeBreadCrumb&"&nbsp;&nbsp;&raquo;&nbsp;&nbsp;"&"<a href="""&mUrl&""" title="""&mName&""">"&mName&"</a>"
		
		Set Rsq=Nothing
	End Function

'========================其他函数区===========================

	'==============================
	'函 数 名：StringCutChange
	'作    用：字符串截断
	'==============================
	Public Function StringCutChange(ChangeHtml)
		Dim cTempArr,cTemp
		Dim cutStr,cutCount,ChangeStr
		'获取标签
		cTempArr=Split(t_RegExpTest("\{\$StrCut\(\|cutStr\_s\|.*?\|cutStr\_e\|,.*?\)\$\}",ChangeHtml),"|-_-|")
		For Each cTemp In cTempArr
			If cTemp<>"" Then
				'获取截取字符串和截取字数
				cutStr=CutLabelValue(cTemp,"|cutStr_s|","|cutStr_e|","")
				cutCount=CutLabelValue(cTemp,"|cutStr_e|,",")$}",0)
				'清除HTML标签，避免影响页面显示
				If cutStr<>"" Then
					cutStr=t_RemoveHTML(cutStr)
				End If
				'跳过非数字截取
				If IsNumeric(cutCount) Then
					'跳过为空截取
					If cutStr<>"" And cutCount>0 Then
						If Len(cutStr)>cutCount Then
							ChangeStr=Left(cutStr,cutCount)&"..."
						Else
							ChangeStr=cutStr
						End If
					Else
						ChangeStr=""
					End If
				Else
					ChangeStr=cutStr
				End If
				'替换
				ChangeHtml=Replace(ChangeHtml,cTemp,ChangeStr)
			End If
		Next
		StringCutChange=ChangeHtml
	End Function

	'==============================
	'函 数 名：DateTimeChange
	'作    用：时间格式处理
	'==============================
	Public Function DateTimeChange(ChangeHtml)
		Dim cTempArr,cTemp
		Dim dStr,dFormat
		cTempArr=Split(t_RegExpTest("\{\$DateTimeFormat\(.*?,.*?\)\$\}",ChangeHtml),"|-_-|")
		For Each cTemp In cTempArr
			If cTemp<>"" Then
				'获取日期与格式要求
				dStr=CutLabelValue(cTemp,"DateTimeFormat(",",","")
				dFormat=CutLabelValue(cTemp,",",")$}",0)
				'替换
				ChangeHtml=Replace(ChangeHtml,cTemp,DateFormat(dStr,dFormat))
			End If
		Next
		
		DateTimeChange=ChangeHtml
	End Function

	'==============================
	'函 数 名：InfoChange
	'作    用：独立信息处理
	'==============================
	Public Function InfoChange(ChangeHtml)
		Dim cTempArr,cTemp
		Dim dStr,dChangeStr
		cTempArr=Split(t_RegExpTest("\{\$Info\(.*?\)\$\}",ChangeHtml),"|-_-|")
		For Each cTemp In cTempArr
			If cTemp<>"" Then
				'获取数据
				dStr=CutLabelValue(cTemp,"Info(",")","")
				If IsNumeric(dStr) Then
					Sqlstr="Select Fk_Info_Content From [Fk_Info] Where Fk_Info_Id=" & dStr
					Rs.Open Sqlstr,Conn,1,1
					If Not Rs.Eof Then
						dChangeStr=Rs("Fk_Info_Content")
					Else
						dChangeStr=""
					End If
					Rs.Close
				Else
					dChangeStr=""
				End If
				'替换
				ChangeHtml=Replace(ChangeHtml,cTemp,dChangeStr)
			End If
		Next
		
		InfoChange=ChangeHtml
	End Function

	'==============================
	'函 数 名：DateFormat
	'作    用：时间格式化
	'==============================
	Private Function DateFormat(strDate,fstr)
		If IsDate(strDate) Then
			Dim d_i,d_Temp
			d_Temp=Replace(fstr,"yyyy",DatePart("yyyy",strDate))
			d_Temp=Replace(d_Temp,"yy",mid(DatePart("yyyy",strDate),3))
			d_Temp=Replace(d_Temp,"y",DatePart("y",strDate))
			d_Temp=Replace(d_Temp,"w",DatePart("w",strDate))
			d_Temp=Replace(d_Temp,"ww",DatePart("ww",strDate))
			d_Temp=Replace(d_Temp,"q",DatePart("q",strDate))
			d_Temp=Replace(d_Temp,"mm",Iif(Len(DatePart("m",strDate))>1,DatePart("m",strDate),"0"&DatePart("m",strDate)))
			d_Temp=Replace(d_Temp,"dd",Iif(Len(DatePart("d",strDate))>1,DatePart("d",strDate),"0"&DatePart("d",strDate)))
			d_Temp=Replace(d_Temp,"hh",Iif(Len(DatePart("h",strDate))>1,DatePart("h",strDate),"0"&DatePart("h",strDate)))
			d_Temp=Replace(d_Temp,"nn",Iif(Len(DatePart("n",strDate))>1,DatePart("n",strDate),"0"&DatePart("n",strDate)))
			d_Temp=Replace(d_Temp,"ss",Iif(Len(DatePart("s",strDate))>1,DatePart("s",strDate),"0"&DatePart("s",strDate)))
			DateFormat=d_Temp
		Else
			DateFormat=""
		End If
	End Function
	
	'==============================
	'函 数 名：Iif
	'作    用：判断函数
	'==============================
	Private Function Iif(Expression,ReturnTrue,ReturnFalse)
		If Expression=True Then
			Iif=ReturnTrue
		Else
			Iif=ReturnFalse
		End If
	End Function

	'==============================
	'函 数 名：WordChange
	'作    用：站内关键字替换
	'==============================
	Public Function WordChange(ChangeHtml)
		If Not IsNull(ChangeHtml) Then
			Dim Rsw,w_Id
			Set Rsw=Server.Createobject("Adodb.RecordSet")
			
			w_Id=0
			Sqlstr="Select Fk_Word_Id,Fk_Word_Name,Fk_Word_Url,Fk_Word_ReplaceCount From [Fk_Word] Order By Fk_Word_Len Asc,Fk_Word_Id Asc"
			Rsw.Open Sqlstr,Conn,1,1
			While (Not Rsw.Eof And w_Id<1000)
				If Clng(Rsw("Fk_Word_ReplaceCount"))>0 Then
					ChangeHtml=Replace(ChangeHtml,Rsw("Fk_Word_Name"),"<a href="""&Rsw("Fk_Word_Url")&""" target=""_blank"" title="""&Rsw("Fk_Word_Name")&""">"&Rsw("Fk_Word_Name")&"</a>",1,Rsw("Fk_Word_ReplaceCount"))
				Else
					ChangeHtml=Replace(ChangeHtml,Rsw("Fk_Word_Name"),"<a href="""&Rsw("Fk_Word_Url")&""" target=""_blank"" title="""&Rsw("Fk_Word_Name")&""">"&Rsw("Fk_Word_Name")&"</a>")
				End If
				
				w_Id=w_Id+1
				Rsw.MoveNext
			Wend
			Rsw.Close
			
			WordChange=ChangeHtml
			
			Set Rsw=Nothing
		Else
			WordChange=""
		End If
	End Function

	'==============================
	'函 数 名：GetTemplate
	'作    用：获取模板代码
	'==============================
	Public Function GetTemplate(s_FileName)
		If s_FileName="" Then
			GetTemplate=""
			Exit Function
		End If
		If Fk_Site_TemplateDebug=0 Then
			Sqlstr="Select Fk_Template_Name,Fk_Template_Content From [Fk_Template] Where Fk_Template_Name='"&s_FileName&"'"
			Rs.Open Sqlstr,Conn,1,1
			If Not Rs.Eof Then
				GetTemplate=Rs("Fk_Template_Content")
			Else
				Call t_ShowErr("“"&s_FileName&".html”模板未找到！",0)
			End If
			Rs.Close
		Else
			If IsFile(SiteDir&"Skin/"&Fk_Site_Template&"/"&s_FileName&".html") Then
				GetTemplate=ReadTemplateFile(SiteDir&"Skin/"&Fk_Site_Template&"/"&s_FileName&".html")
			Else
				Call t_ShowErr("“"&s_FileName&".html”模板文件不存在！",0)
			End If
		End If
	End Function
	
	'==============================
	'函 数 名：GetUrl
	'作    用：获取链接
	'==============================
	Public Function GetUrl(s_Dir,s_Url,s_MUrl,s_VUrl,s_HtmlSuffix,s_Type,s_Id,s_FixedUrl)
		If Fk_Site_Html=0 Or Fk_Site_Html=2 Or Fk_Site_Html=3 Then
			If s_FixedUrl<>"" Then
				If Instr(s_FixedUrl,".")>0 Then
					GetUrl=s_Url&s_Dir&s_FixedUrl
				Else
					GetUrl=s_Url&s_Dir&s_FixedUrl&s_HtmlSuffix
				End If
			Else
				GetUrl=s_Url&s_Dir&s_MUrl&s_VUrl&s_HtmlSuffix
			End If
		ElseIf Fk_Site_Html=1 Then
			Select Case s_Type
				Case 1
					GetUrl=s_Url&s_Dir&"t=col&id="&s_Id&""
				Case 2
					GetUrl=s_Url&s_Dir&"t=view&id="&s_Id&""
				Case 3
					GetUrl=s_Url&s_Dir&"t=subject&id="&s_Id&""
			End Select
		End If
	End Function
	
	'==============================
	'函 数 名：ReadTemplateFile
	'作    用：读取文件
	'==============================
	Private Function ReadTemplateFile(FilePath)
		Dim objAdoStream
		Set objAdoStream=Server.CreateObject("A"&"dod"&"b.St"&"r"&"eam")
		objAdoStream.Type=2
		objAdoStream.mode=3  
		objAdoStream.charset="utf-8"
		objAdoStream.open 
		objAdoStream.LoadFromFile Server.MapPath(FilePath) 
		ReadTemplateFile=objAdoStream.ReadText 
		objAdoStream.Close
		Set objAdoStream=Nothing
	End Function
	
	'==============================
	'函 数 名：IsFile
	'作    用：检测文件是否存在
	'==============================
	Private Function IsFile(FilePath)
		Dim Fso
		Set Fso=Server.CreateObject("Scri"&"pting.File"&"Sys"&"temObject")
		If (Fso.FileExists(Server.MapPath(FilePath))) Then
			IsFile=True
		Else
			IsFile=False
		End If
		Set Fso=Nothing
	End Function

'========================模板引擎===========================
	'==============================
	'函 数 名：TemplateChange
	'作    用：获取优先处理函数
	'==============================
	Public Function TemplateChange(TemplateCode)
		Dim ForNum,IfNum
		ForNum=Instr(TemplateCode,"{$For")
		IfNum=Instr(TemplateCode,"{$If")
		ForId=1
		While ForNum>0 Or IfNum>0
			If ForNum>0 And IfNum>0 Then
				If ForNum<IfNum Then
					TemplateCode=ForChange(TemplateCode)
				Else
					TemplateCode=IfChange(TemplateCode)
				End If
			ElseIf ForNum>0 Then
				TemplateCode=ForChange(TemplateCode)
			ElseIf IfNum>0 Then
				TemplateCode=IfChange(TemplateCode)
			End If
			ForNum=Instr(TemplateCode,"{$For")
			IfNum=Instr(TemplateCode,"{$If")
		Wend
		If ForNum=0 And IfNum=0 Then
			TemplateCode=StringCutChange(TemplateCode)
			TemplateCode=DateTimeChange(TemplateCode)
			TemplateCode=InfoChange(TemplateCode)
		End If
		TemplateChange=TemplateCode
	End Function

	'==============================
	'函 数 名：ForChange
	'作    用：处理For
	'==============================	
	Private Function ForChange(TemplateCode)
		Dim LabelType,LabelValue,LabelHtml,cHtml
		cHtml=GetFor(TemplateCode)
		LabelType=Split(Split(cHtml,"{$For(")(1),",")(0)
		LabelValue=Split(Split(cHtml,",")(1),")")(0)
		LabelHtml=Right(cHtml,Len(cHtml)-Len("{$For("&LabelType&","&LabelValue&")$}"))
		LabelHtml=Left(LabelHtml,Len(LabelHtml)-8)
		Select Case LabelType
			Case "Nav"
				ForChange=Replace(TemplateCode,cHtml,NavForChange(LabelHtml,LabelValue))
			Case "View"
				ForChange=Replace(TemplateCode,cHtml,ViewForChange(LabelHtml,LabelValue))
			Case "GBook"
				ForChange=Replace(TemplateCode,cHtml,GBookForChange(LabelHtml,LabelValue))
			Case "Friends"
				ForChange=Replace(TemplateCode,cHtml,FriendsForChange(LabelHtml,LabelValue))
			Case "Subject"
				ForChange=Replace(TemplateCode,cHtml,SubjectForChange(LabelHtml,LabelValue))
			Case "Pic"
				ForChange=Replace(TemplateCode,cHtml,PicForChange(LabelHtml,LabelValue))
			Case "NumList"
				ForChange=Replace(TemplateCode,cHtml,FkNumList(LabelHtml,LabelValue))
			Case "Focus"
				ForChange=Replace(TemplateCode,cHtml,FocusForChange(LabelHtml,LabelValue))		
			Case Else
				ForChange=Replace(TemplateCode,cHtml,"")
		End Select
		If ForId="" Then
			ForId=1
		Else
			ForId=ForId+1
		End If
		If ForId>200 Then
			Call t_ShowErr("For循环超量！",2)
		End If
	End Function
	
	'==============================
	'函 数 名：GetFor
	'作    用：获取For字符串
	'==============================	
	Private Function GetFor(TemplateCode)
		Dim i_For,Temp_For,TempArr_For
		Temp_For=Split(TemplateCode,"{$For")(0)
		Temp_For=Replace(TemplateCode,Temp_For,"")
		If Instr(Temp_For,"{$Next$}")>0 Then
			TempArr_For=Split(Temp_For,"{$Next$}")
			GetFor=TempArr_For(0)&"{$Next$}"
			i_For=1
			While GetCount(GetFor,"{$For")<>GetCount(GetFor,"{$Next$}")
				GetFor=GetFor&TempArr_For(i_For)&"{$Next$}"
				i_For=i_For+1
				If i_For>50 Then
					Call t_ShowErr("For嵌套超量！",2)
				End If
			Wend
		Else
			Call t_ShowErr("For标签配对不一致！",2)
		End If
	End Function

	'==============================
	'函 数 名：IfChange
	'作    用：处理If
	'==============================	
	Private Function IfChange(TemplateCode)
		Dim cHtml,cTempArr,cTemp,IfTempArr,cHtmlIf
		Dim CheckValue1,CheckValue2,CheckType
		Dim tryHtml1,tryHtml2
		Dim NestCount
		NestCount=0
		cHtml=GetIf(TemplateCode)
		cHtmlIf=cHtml
		'截取IF嵌套
		If GetCount(cHtml,"{$If")>1 Then
			cTemp=Right(cHtml,Len(cHtml)-5)
			cTemp=Left(cTemp,Len(cTemp)-10)
			
			cTempArr=Split(t_RegExpTest("\{\$If\((.|\n)*?\{\$End If\$\}",cTemp),"|-_-|")
			For Each cTemp In cTempArr
				NestCount=NestCount+1
				If GetCount(cTemp,"{$If")>1 Then
					Call t_ShowErr("系统不支持超过2级IF嵌套！",2)
				End If
				cHtml=Replace(cHtml,cTemp,"{$IfNest_N"&NestCount&"$}")
			Next
		End If
		'参数读取
		IfTempArr=Split(cHtml,",")
		CheckValue1=Split(IfTempArr(0),"(")(1)
		CheckValue2=IfTempArr(1)
		CheckType=Split(IfTempArr(2),")")(0)
		If Instr(cHtml,"{$Else$}")>0 Then
			tryHtml1=t_GetSub(cHtml,CheckType&")$}","{$Else$}","")
			tryHtml2=t_GetSub(cHtml,"{$Else$}","{$End If$}","")
		Else
			tryHtml1=t_GetSub(cHtml,CheckType&")$}","{$End If$}","")
			tryHtml2=""
		End If
		'数字判断转码处理
		If IsNumeric(CheckValue1) And IsNumeric(CheckValue2) Then
			CheckValue1=CDBl(CheckValue1)
			CheckValue2=CDBl(CheckValue2)
		End If
		'嵌套IF转回
		If NestCount>0 Then
			NestCount=0
			For Each cTemp In cTempArr
				NestCount=NestCount+1
				tryHtml1=Replace(tryHtml1,"{$IfNest_N"&NestCount&"$}",cTemp)
				tryHtml2=Replace(tryHtml2,"{$IfNest_N"&NestCount&"$}",cTemp)
			Next
		End If
		Select Case CheckType
			Case ">"
				If CheckValue1>CheckValue2 Then
					IfChange=Replace(TemplateCode,cHtmlIf,tryHtml1)
				Else
					IfChange=Replace(TemplateCode,cHtmlIf,tryHtml2)
				End If
			Case "<"
				If CheckValue1<CheckValue2 Then
					IfChange=Replace(TemplateCode,cHtmlIf,tryHtml1)
				Else
					IfChange=Replace(TemplateCode,cHtmlIf,tryHtml2)
				End If
			Case "="
				If CheckValue1=CheckValue2 Then
					IfChange=Replace(TemplateCode,cHtmlIf,tryHtml1)
				Else
					IfChange=Replace(TemplateCode,cHtmlIf,tryHtml2)
				End If
			Case "<>"
				If CheckValue1<>CheckValue2 Then
					IfChange=Replace(TemplateCode,cHtmlIf,tryHtml1)
				Else
					IfChange=Replace(TemplateCode,cHtmlIf,tryHtml2)
				End If
			Case "<="
				If CheckValue1<=CheckValue2 Then
					IfChange=Replace(TemplateCode,cHtmlIf,tryHtml1)
				Else
					IfChange=Replace(TemplateCode,cHtmlIf,tryHtml2)
				End If
			Case ">="
				If CheckValue1>=CheckValue2 Then
					IfChange=Replace(TemplateCode,cHtmlIf,tryHtml1)
				Else
					IfChange=Replace(TemplateCode,cHtmlIf,tryHtml2)
				End If
			Case "Mod"
				If (CheckValue1 Mod CheckValue2)=0 Then
					IfChange=Replace(TemplateCode,cHtmlIf,tryHtml1)
				Else
					IfChange=Replace(TemplateCode,cHtmlIf,tryHtml2)
				End If
			Case Else
				IfChange=Replace(TemplateCode,cHtmlIf,"")
		End Select
	End Function

	'==============================
	'函 数 名：GetIf
	'作    用：获取If字符串
	'==============================	
	Private Function GetIf(TemplateCode)
		Dim i_If,Temp_If,TempArr_If
		Temp_If=Split(TemplateCode,"{$If")(0)
		Temp_If=Replace(TemplateCode,Temp_If,"")
		If Instr(Temp_If,"{$End If$}")>0 Then
			TempArr_If=Split(Temp_If,"{$End If$}")
			GetIf=TempArr_If(0)&"{$End If$}"
			i_If=1
			While GetCount(GetIf,"{$If")<>GetCount(GetIf,"{$End If$}")
				GetIf=GetIf&TempArr_If(i_If)&"{$End If$}"
				i_If=i_If+1
				If i_If>50 Then
					Call t_ShowErr("If标签配对超限！",2)
				End If
			Wend
		Else
			Call t_ShowErr("If标签配对不一致！",2)
		End If
	End Function

	'==============================
	'函 数 名：GetCount
	'作    用：判断字符串中相同字符的个数
	'==============================	
	Private Function GetCount(Strs,Word)
		Dim N1,N2,N3
		N1=Len(Strs)
		N2=Len(Replace(Strs,Word,""))
		N3=Len(Word)
		GetCount=Clng(((N1-N2)/N3))
	End Function 

	'==============================
	'函 数 名：ReplaceTag
	'作    用：替换标签
	'==============================
	Private Function ReplaceTag(MyStr,MyTag,MyChang)
		If IsNull(MyChang) Then
			ReplaceTag=Replace(MyStr,MyTag,"")
		Else
			ReplaceTag=Replace(MyStr,MyTag,MyChang)
		End If
	End Function

	'==============================
	'函 数 名：CutLabelValue
	'作    用：获取标签参数
	'==============================	
	Private Function CutLabelValue(CutStr,Str1,Str2,DefaultStr)
		If Instr(CutStr,Str1)>0 And Instr(CutStr,Str2)>0 Then
			CutLabelValue=t_HTMLEncode(Split(Split(CutStr,Str1)(1),Str2)(0))
		Else
			CutLabelValue=DefaultStr
		End If
		If IsNumeric(CutLabelValue) Then
			CutLabelValue=CDbl(CutLabelValue)
		End If
	End Function
	
	'==============================
	'函 数 名：RemoveHTML
	'作    用：过滤HTML
	'==============================
	Private Function t_RemoveHTML(strHTML)
        Dim objRegExp, Match, Matches 
        Set objRegExp = New Regexp 
        objRegExp.IgnoreCase = True 
        objRegExp.Global = True 
        objRegExp.Pattern = "<.+?>" 
        Set Matches = objRegExp.Execute(strHTML) 
        For Each Match in Matches 
            strHtml=Replace(strHTML,Match.Value,"") 
        Next 
        objRegExp.Pattern = "&lt;.+?&gt;" 
        Set Matches = objRegExp.Execute(strHTML) 
        For Each Match in Matches 
            strHtml=Replace(strHTML,Match.Value,"") 
        Next 
        objRegExp.Pattern = "\&.+?;" 
        Set Matches = objRegExp.Execute(strHTML) 
        For Each Match in Matches 
            strHtml=Replace(strHTML,Match.Value,"") 
        Next 
        t_RemoveHTML=strHTML 
        Set objRegExp = Nothing 
    End Function

	'==============================
	'函 数 名：t_GetHtmlSuffix
	'作    用：获取后缀
	'==============================
	Private Function t_GetHtmlSuffix(sType)
		Select Case sType
			Case 0
				t_GetHtmlSuffix=".html"
			Case 1
				t_GetHtmlSuffix=".htm"
			Case 2
				t_GetHtmlSuffix=".shtml"
			Case 3
				t_GetHtmlSuffix=".xml"
		End Select
	End Function

	'==============================
	'函 数 名：t_ReplaceTest
	'作    用：正则表达式，替换字符串
	'==============================
	Private Function t_ReplaceTest(patrn,replStr,Str)
		Dim regEx
		Set regEx=New RegExp
		regEx.Pattern=patrn
		regEx.IgnoreCase=True
		regEx.Global=True 
		t_ReplaceTest=regEx.Replace(Str,replStr)
	End Function 

	'==============================
	'函 数 名：t_RegExpTest
	'作    用：正则表达式，获取字符串
	'==============================
	Private Function t_RegExpTest(patrn, strng)
		Dim regEx, Matchs, Matches, RetStr
		Set regEx=New RegExp 
		regEx.Pattern=patrn 
		regEx.IgnoreCase=True
		regEx.Global=True
		Set Matches=regEx.Execute(strng) 
		For Each Matchs in Matches
			RetStr=RetStr & Matchs.Value & "|-_-|"
		Next 
		t_RegExpTest=RetStr 
	End Function 

	'==============================
	'函 数 名：t_GetSub
	'作    用：截取字符串
	'==============================
	Public Function t_GetSub(gStr,gStart,gEnd,gDefault)
		If Instr(gStr,gStart)>0 Then
			t_GetSub=Split(gStr,gStart)(1)
			t_GetSub=Split(t_GetSub,gEnd)(0)
		Else
			t_GetSub=gDefault
		End If
	End Function
	
	'==============================
	'函 数 名：t_HTMLEncode
	'作    用：字符转换
	'==============================
	Private Function t_HTMLEncode(fString)
		If Not IsNull(fString) Then
			fString = Replace(fString, ">", "&gt;")
			fString = Replace(fString, "<", "&lt;")
			fString = Replace(fString, CHR(32), " ")		
			fString = Replace(fString, CHR(34), "&quot;")
			fString = Replace(fString, CHR(39), "&#39;")
			fString = Replace(fString, CHR(9), "&nbsp;")
			fString = Replace(fString, CHR(13), "")
			fString = Replace(fString, CHR(10) & CHR(10), "<p></p>")
			fString = Replace(fString, CHR(10), "<br />")
			t_HTMLEncode = fString
		End If
	End Function
	
	'==============================
	'函 数 名：t_ShowErr
	'作    用：错误提示函数
	'==============================
	Private Function t_ShowErr(ErrStr,ErrType)
		If ErrType=0 Then
			Temp="<!DOCTYPE html PUBLIC ""-//W3C//DTD XHTML 1.0 Transitional//EN"" ""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"">"
			Temp=Temp&"<html xmlns=""http://www.w3.org/1999/xhtml"">"
			Temp=Temp&"<head>"
			Temp=Temp&"<meta http-equiv=""Content-Type"" content=""text/html; charset=utf-8"" />"
			Temp=Temp&"<title>系统提示</title>"
			Temp=Temp&"<style type=""text/css"">"
			Temp=Temp&"body,td,th {font-size: 12px;}"
			Temp=Temp&"body {margin-left:0px;margin-top:50px;margin-right: 0px;margin-bottom: 0px;}"
			Temp=Temp&"#errBox {width:500px;margin:0 auto;border:1px solid #CCC;}"
			Temp=Temp&"#errTitle {border-bottom:1px solid #CCC;line-height:25px;text-align:center;}"
			Temp=Temp&"#errStr {padding:10px;line-height:22px;text-indent:24px;}"
			Temp=Temp&"</style>"
			Temp=Temp&"</head>"
			Temp=Temp&"<body>"
			Temp=Temp&"<div id=""errBox"">"
			Temp=Temp&"	<div id=""errTitle"">系统提示</div>"
			Temp=Temp&"    <div id=""errStr"">"&ErrStr&"</div>"
			Temp=Temp&"</div>"
			Temp=Temp&"</body>"
			Temp=Temp&"</html>"
		ElseIf ErrType=1 Then
			Temp="<div id=""errBox"">"
			Temp=Temp&"	<div id=""errTitle"">系统提示</div>"
			Temp=Temp&"    <div id=""errStr"">"&ErrStr&"</div>"
			Temp=Temp&"</div>"
			Temp=Temp&"</body>"
		End If
		If ErrType=2 Then
			Temp=ErrStr
		End If
		Response.Write(Temp)
		Call t_PageEnd()
	End Function
		
	'==============================
	'函 数 名：t_PageEnd
	'作    用：页面结束
	'==============================
	Private Function t_PageEnd()
		Set Rs=Nothing
		If IsObject(Conn) Then Conn.Close
		Set Conn = Nothing
		Session.CodePage=936
		Response.End()
	End Function
End Class
%>
