<%
'**************************************
'* 最后更新 2012-11-26 by 56770.Kingdge
'* Copyright www.56770.com
'**************************************
Class Cache_Tpl
	Private p_objFSO,p_Items,p_Item_dim,p_objStm,p_RegExp,p_Check,p_LangTxt,p_LangFile,p_LangName,p_LangPath
	Private p_EnCodeing,p_Lebi_Variable,p_CacheExt,p_Lebi_Variablepath,p_CachePath,p_Template,p_Main_Block
	Public Property Let CacheExt(Value)
		If Not IsNull(Value) And Value <> "" Then p_CacheExt = Value
	End Property

	Public Property Let EnCodeing(Value)
		If Not IsNull(Value) And Value <> "" Then p_EnCodeing = Value
	End Property

	Public Property Let CachePath(Value)
		If Not IsNull(Value) And Value <> "" Then p_CachePath = Value
	End Property

	Public Property Let Template(Value)
		If Not IsNull(Value) And Value <> "" Then p_Template = Value
	End Property

	Public Property Let VarExt(Value)
		If Not IsNull(Value) And Value <> "" Then p_Lebi_Variable = Value
	End Property

	Public Property Let LangTxt(Value)
		If Not IsNull(Value) And Value <> "" Then p_LangTxt = Value
	End Property

	Public Property Let LangFile(Value)
		If Not IsNull(Value) And Value <> "" Then p_LangFile = Value
	End Property

	Public Property Let LangName(Value)
		If Not IsNull(Value) And Value <> "" Then p_LangName = Value
	End Property

	Public Property Let LangPath(Value)
		If Not IsNull(Value) And Value <> "" Then p_LangPath = Value
	End Property

	Public Property Let Assign(KeyName,KeyValue)
		If IsNull(KeyValue) Then
			p_Items(KeyName) = ""
		Else
			p_Items(KeyName) = KeyValue
		End If
	End Property

	Public Property Get Assign(KeyName)
		If p_Items.Exists(KeyName) Then
			Item = p_Items(KeyName)
		Else
			Call Error("Get item value error.<br>No such item key ""<b>" & KeyName & "</b>"".")
		End If
	End Property

	rem	<-{ variable 中加入 dim 变量 2008-5-13 by 56770.WangLei
	Public Property Let Assign_Dim(KeyName,KeyValue)
		If IsNull(KeyValue) Then
			p_Item_dim(KeyName) = ""
		Else
			p_Item_dim(KeyName) = KeyValue
		End If
	End Property

	Public Property Get Assign_Dim(KeyName)
		If p_Item_dim.Exists(KeyName) Then
			Item = p_Item_dim(KeyName)
		Else
			Call Error("Get item value error.<br>No such item key ""<b>" & KeyName & "</b>"".")
		End If
	End Property
	rem	}->

	Private Sub Class_Initialize()
		Set p_objFSO		= Server.CreateObject("Scripting.FileSystemObject")
		Set p_Items			= Server.CreateObject("Scripting.Dictionary")
		Set p_Item_dim		= Server.CreateObject("Scripting.Dictionary")
		Set p_objStm		= Server.CreateObject("ADODB.Stream")
		Set p_RegExp		= New RegExp
		p_Items.CompareMode	= vbTextCompare
		p_Item_dim.CompareMode	= vbTextCompare
			p_Lebi_Variable		= ".variable"
			p_CacheExt		= ".asp"
			p_EnCodeing		= "utf-8"
			p_Lebi_Variablepath	= "../include/Lebi_Variable/"
			p_Template		= "./"
			p_Main_Block	= ""
			p_CachePath     ="../"
			p_Check = "1"
			p_LangFile = ""
			p_LangTxt = ""
			p_LangName = "中文"
			p_LangPath = ""
	End Sub

	Private Sub Class_Terminate()
			p_Items.RemoveAll()
			p_Item_dim.RemoveAll()
		Set p_RegExp	= Nothing
		Set p_objStm	= Nothing
		Set p_Items		= Nothing
		Set p_Item_dim	= Nothing
		Set p_objFSO	= Nothing
	End Sub

	Public Sub Load(template,strFile,strFilename)
		Dim TemplatePath,TemplateContent,NewEshop_url
		TemplatePath = strFilename
		If Not IsExist(TemplatePath) Then TemplatePath = p_Template & strFilename
		TemplateContent	= LoadTextFile(strFile)
		rem 将[[替换为单引号 2007-4-1 by 56770.kingdge
		TemplateContent = Replace(TemplateContent,"[[","'")
		TemplateContent = Replace(TemplateContent,"&#180;","'")
		If Eshop_url = "/" Then 
				TemplateContent = Replace(TemplateContent,"/pic/","pic/")
		Else
				NewEshop_url = Right(Eshop_url,Len(Eshop_url)-1)
				TemplateContent = Replace(TemplateContent,Eshop_url &"pic/",NewEshop_url &"pic/")
		End If 
		TemplateContent = Include(template,strFilename,TemplateContent)
		p_Main_Block = Tpl_Splits(TemplateContent)
	End Sub

	Private Function Tpl_Splits(strBlock)
		If strBlock = "" Then Exit Function
		Dim strContent,strValue
		strContent = strBlock
		Dim objRegExp,objValue
		p_RegExp.ignorecase = True
		p_RegExp.global = True
		p_RegExp.pattern = "{\[(.+?)\]}"
		Set objRegExp = p_RegExp.Execute(strContent)
			For Each objValue In objRegExp
			strValue	= Replace(Replace(objValue.value,"{[","<%"),"]}","%\>")
				strContent	= Replace(strContent,objValue.value,strValue)
			Next
		Set objRegExp = Nothing

		p_RegExp.ignorecase = True
		p_RegExp.global = True
		p_RegExp.pattern = "{\$(.+?)\}"
		Set objRegExp = p_RegExp.Execute(strContent)
			For Each objValue In objRegExp
				strValue	= Replace(Replace(objValue.value,"{$","<%="),"}","%\>")
				strContent	= Replace(strContent,objValue.value,strValue)
			Next
		Set objRegExp = Nothing
		strContent = Replace(Replace(strContent,"<$","<%"),"$>","%\>")
		Tpl_Splits = Tpl_Format(strContent)
	End Function

	Public Sub DisPlay(template,strFile,strFilename)
		Dim FileName:FileName	= p_LangPath & strFilename
		If (Not IsExist(FileName & p_CacheExt)) Or IsUpdate(Filename) Then
			Call Load(template,strFile,Filename)
			Call CreateFolder(p_Lebi_Variablepath)
			Call CreateFolder(Filename)
			Dim strInclude:strInclude = Lebi_Variable(template,strFile,Filename)
			Call CreateTextFile(FileName,strInclude&p_Main_Block,1)
		Else
			Server.Transfer(FileName & p_CacheExt)
		End If
	End Sub

	Private Function Lebi_Variable(template,strFile,strFilename)
		Dim FileName:FileName	= strFilename
		Dim arrItems,arrItem_dim,I,strTemp,Fatherpath
		strTemp = "<%'------------- 以下变量由56770 Eshop网上开店系统（www.56770.com）自动生成 --------------" & vbcrlf
		arrItems = p_Items.Keys
		For I = 0 To p_Items.Count -1
			strTemp = strTemp & arrItems(I) & "		= """ & p_Items.Item(arrItems(I)) & """" & vbcrlf
		Next
		arrItem_dim = p_Item_dim.Keys
		For I = 0 To p_Item_dim.Count -1
			strTemp = strTemp & "Dim "& arrItem_dim(I) &" : "& arrItem_dim(I) & "		= """ & p_Item_dim.Item(arrItem_dim(I)) & """" & vbcrlf
		Next

		strTemp = strTemp & "%\>" & vbcrlf
		If InStr(FileName,"/")>0 Then
				For i = 0 To UBound(Split(FileName,"/"))-1
						Fatherpath = Fatherpath & "../"
				Next
		Else
				Fatherpath = ""
		End If
		Lebi_Variablename = Replace(Replace(Filename,"/",""),".asp","")
		Lebi_Variable = "<!--#include file="""& Fatherpath &"connshop.asp""-->"&vbcrlf
		Lebi_Variable = Lebi_Variable &"<%'本文件由56770 Eshop网上开店系统（www.56770.com）自动生成，请勿直接修改" & vbcrlf
		Lebi_Variable = Lebi_Variable &"Dim LangTxt,LangName,LangPath : LangTxt = """& p_LangTxt &""" : LangName = """& p_LangName &""" : LangPath = """& p_LangPath &"""%\>"&vbcrlf
		Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"include/Config"& p_LangTxt &".Inc""-->"&vbcrlf
		Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"API/Cls_Api.asp""-->"&vbcrlf
		Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"include/Lebi_Db_cls.asp""-->"&vbcrlf
		Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"include/Lebi_CC.asp""-->"&vbcrlf
		Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"include/Lebi_Cache_cls.asp""-->"&vbcrlf
		Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"include/Lebi_Cache.asp""-->"&vbcrlf
		Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"include/Lebi_LangInfo.asp""-->"&vbcrlf
		Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"include/Lebi_Lang/"& p_LangFile &"""-->"&vbcrlf
		Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"include/Lebi_Main.asp""-->"&vbcrlf
		Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"include/Lebi_Function.asp""-->"&vbcrlf
		Call CreateTextFile(Lebi_Variablename & p_Lebi_Variable,strTemp,0)
		Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath & Replace(p_Lebi_Variablepath,"../","") & Lebi_Variablename & p_Lebi_Variable & """-->"&vbcrlf
		If Trim(LCase(FileName)) = p_LangPath &"default.asp" Then
				Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"include/Lebi_Item/Item_default.asp""-->"&vbcrlf
		ElseIf InStr(LCase(FileName),"comp.asp") > 0 Then
				Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"include/Lebi_Item/Item_comp.asp""-->"&vbcrlf
		ElseIf InStr(LCase(FileName),"category/default") > 0 Or InStr(LCase(FileName),"mulu.asp") > 0 Then
				Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"include/Lebi_Item/Item_category.asp""-->"&vbcrlf
		ElseIf InStr(LCase(FileName),"new/default.asp") > 0 Or InStr(LCase(FileName),"newproduct.asp") > 0 Then
				Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"include/Lebi_page_cls.asp""-->"&vbcrlf
				Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"include/Lebi_Item/Item_new.asp""-->"&vbcrlf
		ElseIf InStr(LCase(FileName),"recom/default.asp") > 0 Or InStr(LCase(FileName),"recom.asp") > 0 Then
				Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"include/Lebi_page_cls.asp""-->"&vbcrlf
				Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"include/Lebi_Item/Item_recom.asp""-->"&vbcrlf
		ElseIf InStr(LCase(FileName),"sale/default.asp") > 0 Or InStr(LCase(FileName),"tjia.asp") > 0 Then
				Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"include/Lebi_page_cls.asp""-->"&vbcrlf
				Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"include/Lebi_Item/Item_sale.asp""-->"&vbcrlf
		ElseIf InStr(LCase(FileName),"gift/default.asp") > 0 Or InStr(LCase(FileName),"gift.asp") > 0 Then
				Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"include/Lebi_page_cls.asp""-->"&vbcrlf
				Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"include/Lebi_Item/Item_gift.asp""-->"&vbcrlf
		ElseIf InStr(LCase(Eshop_url & FileName),Eshop_url & "news/default.asp") > 0 Or InStr(LCase(FileName),"zhuanti.asp") > 0 Then
				Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"include/Lebi_page_cls.asp""-->"&vbcrlf
				Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"include/Lebi_Item/Item_news_fn.asp""-->"&vbcrlf
				Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"include/Lebi_Item/Item_news.asp""-->"&vbcrlf
		ElseIf InStr(LCase(FileName),"news/list/") > 0 Then
				Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"include/Lebi_Item/Item_news_fn.asp""-->"&vbcrlf
				Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"include/Lebi_Item/Item_news_list.asp""-->"&vbcrlf
		ElseIf InStr(LCase(Eshop_url & FileName),Eshop_url & "news/") > 0 Then
				Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"include/Lebi_page_cls.asp""-->"&vbcrlf
				Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"include/Lebi_Item/Item_news_fn.asp""-->"&vbcrlf
				Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"include/Lebi_Item/Item_news_class.asp""-->"&vbcrlf
		ElseIf InStr(LCase(FileName),"help.asp") > 0 Then
				Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"include/Lebi_Item/Item_help.asp""-->"&vbcrlf
				Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"include/Lebi_page_cls.asp""-->"&vbcrlf
'				Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"include/Lebi_Item/Item_help_class.asp""-->"&vbcrlf
'				Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"include/Lebi_Item/Item_help_class_fn.asp""-->"&vbcrlf
		ElseIf InStr(LCase(FileName),"help/default") > 0 Then
				Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"include/Lebi_Item/Item_help.asp""-->"&vbcrlf
		ElseIf InStr(LCase(FileName),"help/class/") > 0 Then
				Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"include/Lebi_page_cls.asp""-->"&vbcrlf
				Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"include/Lebi_Item/Item_help_class.asp""-->"&vbcrlf
				Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"include/Lebi_Item/Item_help_class_fn.asp""-->"&vbcrlf
		ElseIf InStr(LCase(FileName),"help/system/") > 0 Then
				Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"include/Lebi_Item/Item_system.asp""-->"&vbcrlf
		ElseIf InStr(LCase(FileName),"book/default") > 0 Or InStr(LCase(FileName),"book.asp") > 0 Then
				Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"include/Lebi_page_cls.asp""-->"&vbcrlf
				Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"include/Lebi_Item/Item_book.asp""-->"&vbcrlf
		ElseIf InStr(LCase(FileName),"book/post.asp") > 0 Then
				Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"include/Lebi_Item/Item_book_post.asp""-->"&vbcrlf
		ElseIf InStr(LCase(FileName),"link/") > 0 Or InStr(LCase(FileName),"links.asp") > 0 Then
				Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"include/Lebi_Item/Item_links.asp""-->"&vbcrlf
		ElseIf InStr(LCase(FileName),"link/post.asp") > 0 Then
				Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"include/Lebi_Item/Item_links_post.asp""-->"&vbcrlf
		ElseIf InStr(LCase(FileName),"message/error.asp") > 0 Then
				Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"include/Lebi_Item/Item_error.asp""-->"&vbcrlf
		ElseIf InStr(LCase(FileName),"message/success.asp") > 0 Then
				Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"include/Lebi_Item/Item_success.asp""-->"&vbcrlf
		ElseIf InStr(LCase(FileName),"user/default") > 0 Then
				Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"include/Lebi_page_cls.asp""-->"&vbcrlf
				Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"plus/md5pay.asp""-->"&vbcrlf
				Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"plus/alipay_payto.asp""-->"&vbcrlf
				Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"include/Lebi_email_cls.asp""-->"&vbcrlf
				Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"include/Lebi_Item/Item_user.asp""-->"&vbcrlf
		ElseIf InStr(LCase(FileName),"user/reg.asp") > 0 Then
				Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"include/Lebi_Item/Item_reg.asp""-->"&vbcrlf
		ElseIf InStr(LCase(FileName),"user/login.asp") > 0 Then
				Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"include/Lebi_Item/Item_login.asp""-->"&vbcrlf
		ElseIf InStr(LCase(FileName),"user/regok.asp") > 0 Then
				Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"union/config.asp""-->"&vbcrlf
				Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"include/Lebi_md5.asp""-->"&vbcrlf
				Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"include/Lebi_email_cls.asp""-->"&vbcrlf
				Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"include/Lebi_Item/Item_regok.asp""-->"&vbcrlf
		ElseIf InStr(LCase(FileName),"user/cklogin.asp") > 0 Then
				Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"include/Lebi_md5.asp""-->"&vbcrlf
				Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"include/Lebi_Item/Item_cklogin.asp""-->"&vbcrlf
		ElseIf InStr(LCase(FileName),"user/check.asp") > 0 Then
				Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"include/Lebi_md5.asp""-->"&vbcrlf
				Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"include/Lebi_Item/Item_reg_check.asp""-->"&vbcrlf
		ElseIf InStr(LCase(FileName),"user/pay.asp") > 0 Then
				Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"plus/md5pay.asp""-->"&vbcrlf
				Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"plus/alipay_payto.asp""-->"&vbcrlf
				Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"include/Lebi_Item/Item_user_pay.asp""-->"&vbcrlf
		ElseIf InStr(LCase(FileName),"user/post.asp") > 0 Then
				Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"include/Lebi_md5.asp""-->"&vbcrlf
				Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"include/Lebi_Item/Item_user_post.asp""-->"&vbcrlf
		ElseIf InStr(LCase(FileName),"user/html/userlogin.asp") > 0 Then
				Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"include/Lebi_Item/Item_Html_UserLogin.asp""-->"&vbcrlf
		ElseIf InStr(LCase(FileName),"basket/shipment.asp") > 0 Then
				Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"include/Lebi_page_cls.asp""-->"&vbcrlf
				Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"include/Lebi_Item/Item_shipment.asp""-->"&vbcrlf
		ElseIf InStr(LCase(FileName),"basket/default.asp") > 0 Then
				Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"include/Lebi_Item/Item_basket.asp""-->"&vbcrlf
		ElseIf InStr(LCase(FileName),"basket/cash.asp") > 0 Then
				Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"include/Lebi_Item/Item_cash.asp""-->"&vbcrlf
		ElseIf InStr(LCase(FileName),"basket/cashsave.asp") > 0 Then
				Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"union/config.asp""-->"&vbcrlf
				Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"plus/md5pay.asp""-->"&vbcrlf
				Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"plus/alipay_payto.asp""-->"&vbcrlf
				Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"include/Lebi_email_cls.asp""-->"&vbcrlf
				Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"include/Lebi_Item/Item_cashsave.asp""-->"&vbcrlf
		ElseIf InStr(LCase(FileName),"basket/cashview.asp") > 0 Then
				Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"include/Lebi_Item/Item_cashview.asp""-->"&vbcrlf
		ElseIf InStr(LCase(FileName),"basket/post.asp") > 0 Then
				Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"include/Lebi_Item/Item_basket_post.asp""-->"&vbcrlf
		ElseIf InStr(LCase(FileName),"basket/pay.asp") > 0 Then
				Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"plus/md5pay.asp""-->"&vbcrlf
				Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"include/Lebi_Item/Item_pay.asp""-->"&vbcrlf
		ElseIf InStr(LCase(FileName),"basket/paymoney.asp") > 0 Then
				Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"include/Lebi_Item/Item_basket_paymoney.asp""-->"&vbcrlf
		ElseIf InStr(LCase(FileName),"basket/print.asp") > 0 Then
				Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"include/Lebi_Item/Item_basket_print.asp""-->"&vbcrlf
		ElseIf InStr(LCase(FileName),"search/list/") > 0 Or InStr(LCase(FileName),"searchshop.asp") > 0 Then
				Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"include/Lebi_page_cls.asp""-->"&vbcrlf
				Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"include/Lebi_Item/Item_searchshop.asp""-->"&vbcrlf
		ElseIf InStr(LCase(FileName),"search/order.asp") > 0 Then
				Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"plus/md5pay.asp""-->"&vbcrlf
				Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"plus/alipay_payto.asp""-->"&vbcrlf
				Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"include/Lebi_Item/Item_search_order.asp""-->"&vbcrlf
		ElseIf InStr(LCase(FileName),"search/") > 0 Then
				Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"include/Lebi_Item/Item_search.asp""-->"&vbcrlf
		ElseIf InStr(LCase(FileName),"unite/show/default.asp") > 0 Then  ' WangLei 2008-2-14 捆绑促销
				Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"include/Lebi_page_cls.asp""-->"&vbcrlf
				Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"plus/md5pay.asp""-->"&vbcrlf
				Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"include/Lebi_Item/Item_showproduct_u.asp""-->"&vbcrlf
				Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"include/Lebi_other.asp""-->"&vbcrlf
		ElseIf InStr(LCase(FileName),"unite/default.asp") > 0 Then  ' WangLei 2008-1-12 捆绑促销
				Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"include/Lebi_page_cls.asp""-->"&vbcrlf
				Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"include/Lebi_Item/Item_unite.asp""-->"&vbcrlf
		ElseIf InStr(LCase(FileName),"brand/default.asp") > 0 Or InStr(LCase(FileName),"brand.asp") > 0 Then
				Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"include/Lebi_Item/Item_brand.asp""-->"&vbcrlf
				Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"include/Lebi_Item/Item_brand_fn.asp""-->"&vbcrlf
		ElseIf InStr(LCase(FileName),"message/openmsg.asp") > 0 Then
				Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"include/Lebi_Item/Item_OpenMsg.asp""-->"&vbcrlf
		ElseIf InStr(LCase(FileName),"category/rss/default.asp") > 0 Or InStr(LCase(FileName),"rss.asp") > 0 Then
				Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"include/Lebi_Item/Item_rss.asp""-->"&vbcrlf
		ElseIf InStr(LCase(FileName),"product/default") > 0 Or InStr(LCase(FileName),"showproduct.asp") > 0 Then
				Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"include/Lebi_page_cls.asp""-->"&vbcrlf
				Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"plus/md5pay.asp""-->"&vbcrlf
				Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"include/Lebi_Item/Item_showproduct.asp""-->"&vbcrlf
				Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"include/Lebi_other.asp""-->"&vbcrlf
		ElseIf InStr(LCase(FileName),"product/rating/") > 0 Then
				Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"include/Lebi_Item/Item_showrating.asp""-->"&vbcrlf
		ElseIf InStr(LCase(FileName),"product/showpic/default.asp") > 0 Or InStr(LCase(FileName),"showpic.asp") > 0 Then
				Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"include/Lebi_Item/Item_showpic.asp""-->"&vbcrlf
		ElseIf InStr(LCase(FileName),"product/post.asp") > 0 Then
				Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"include/Lebi_Item/Item_showproduct_post.asp""-->"&vbcrlf
		ElseIf InStr(LCase(FileName),"product/html/productinfo.asp") > 0 Then
				Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"include/Lebi_Item/Item_Html_ProductInfo.asp""-->"&vbcrlf
		ElseIf InStr(LCase(FileName),"message/vote.asp") > 0 Then
				Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"include/Lebi_Item/Item_vote.asp""-->"&vbcrlf
		ElseIf InStr(LCase(FileName),"message/writemsg.asp") > 0 Then
				Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"include/Lebi_Item/Item_WriteMsg.asp""-->"&vbcrlf
		ElseIf InStr(LCase(FileName),"category/") > 0 Or InStr(LCase(FileName),"showsort.asp") > 0 Then
				Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"include/Lebi_page_cls.asp""-->"&vbcrlf
				Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"include/Lebi_Item/Item_showsort.asp""-->"&vbcrlf
				Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"include/Lebi_Item/Item_showsort_fn.asp""-->"&vbcrlf
		ElseIf InStr(LCase(FileName),"brand/list") > 0 Then
				Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"include/Lebi_page_cls.asp""-->"&vbcrlf
				Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"include/Lebi_Item/Item_brand.asp""-->"&vbcrlf
				Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"include/Lebi_Item/Item_brand_fn.asp""-->"&vbcrlf
		ElseIf InStr(LCase(FileName),"count.asp") > 0 Then
				Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"include/Lebi_Item/Item_count.asp""-->"&vbcrlf
		End If
		Set Fso=Server.CreateObject("Scripting.FilesystemObject")
		On Error Resume Next
		Set objFolder=fso.GetFolder(server.MapPath("../skins/"& template &"/asp/"))
		Set objFiles=objFolder.Files
		For Each objFile In objFiles
				Lebi_Variable = Lebi_Variable &"<!--#include file="""& Fatherpath &"skins/"& template &"/asp/"& objFile.name &"""-->"&vbcrlf
		Next 
		Set objFolder=Nothing
		Set fso=Nothing
	End Function

	Private Sub Error(String)
		Response.Write("<meta http-equiv=""Content-Type"" content=""text/html; charset=utf-8"" />")
		Response.Write("Error:" & String)
		Response.End
	End Sub

	Private Function Include(template,strFilename,strContent)
		Dim FileName:FileName	= strFilename
		Dim objRegExp,objValue
		p_RegExp.ignorecase = True
		p_RegExp.global = True
		p_RegExp.pattern = "<!--#include(.+?)-->"
		Set objRegExp = p_RegExp.Execute(strContent)
			For Each objValue In objRegExp
				strValue	= LoadHtml(p_Template &"skins/"& template &"/template/"& Replace(Replace(objValue.value,"<!--#include(",""),")-->",""))
				strContent	= Replace(strContent,objValue.value,strValue)
			Next
		Set objRegExp = Nothing
		Include = strContent
	End Function

	Private Function Tags(strType,strTag)
		Dim I1,I2,I3
		I1 = strTag
		I1 = Replace(I1,"&quot;","""")	: I1 = Replace(I1,"&nbsp;"," ")
		I1 = Replace(I1,"&gt;",">")		: I1 = Replace(I1,"&lt;","<")
		I2 = Replace(I1," ","/")		: I2 = Replace(I2,"}","/")
		I3 = LCase(I2)
		Select Case LCase(strType)
			Case "include"
				Dim IncludeFile,strContent
				IncludeFile	= RegExpMid(I3,"=""","""")
				strContent	= Include(LoadTextFile(p_Template&"/"&IncludeFile))
		End Select
		Tags = strContent
	End Function

	Public Function LoadTextFile(strFile)
		LoadTextFile = strFile
	End Function

	Public Function LoadTextFile1(strFile)
		LoadTextFile = ""
		Dim strTempPath,objStm
		strTempPath = Server.MapPath(strFile)
		Set objStm = Server.CreateObject("ADODB.Stream")
			If p_objFso.FileExists(strTempPath) Then
				objStm.charset = p_EnCodeing
				objStm.open
				objStm.LoadFromFile strTempPath
				LoadTextFile = objStm.ReadText
			End If
		Set objStm = Nothing
	End Function

	Private Function IsUpdate(strFile)
		IsUpdate = False
		Dim p_File,p_SourceFileLastModifyTime,p_CacheFileLastModifyTime
		If Not IsExist(strFile & p_CacheExt) Then
			IsUpdate = True
			Exit Function
		End If
	End Function

	Public Sub CreateTextFile(strFile,strContent,filetype)'地址,内容,类型
		On Error Resume Next
		Dim filepath
		If filetype = 1 Then
		        filepath = p_CachePath
		ElseIf filetype = 0 Then
		        filepath = p_Lebi_Variablepath
		End If
		Dim objStm
		Set objStm = Server.CreateObject("ADODB.Stream")
			With objStm
				.type=2
				.open
				.charset = p_EnCodeing
				.position = objStm.Size
				If InStr(strFile,p_Lebi_Variable)>0 Then
				        .writetext = strContent
				Else
				        Dim str_writetext
				        str_writetext = strContent
						If (InStr(str_writetext,"www.56770.com") = 0 Or InStr(str_writetext,"56770") = 0) And filetype <> 2 Then
						        response.End
						End If
				        .writetext = str_writetext
				End if
				.savetofile Server.Mappath(filepath & strFile),2
				.close
			End With
		Set objStm = Nothing
		If Err.Number <> 0 Then	Err.Clear
	End Sub

	Public Sub CreateFolder(strPath)
		On Error Resume Next
		Dim strPaths,strFolders,strFoldersPath,I
		strPaths = Split(strPath,"/")
		For I = 0 To Ubound(strPaths)-1
			If strPaths(I) = ".." Then
				strFolders = strFolders & "../"
			Else
				If strFolders & strPaths(I) <> "" Then
				    'strFolders = "../"
					strFoldersPath = Server.MapPath("../"&strFolders & strPaths(I))
					'*** 如果文件夹不存在就创建 ***
					If p_objFSO.FolderExists(strFoldersPath) = False Then p_objFSO.CreateFolder(strFoldersPath)
					strFolders = strFolders & strPaths(I) & "/"
				Else
					strFolders = "/"
				End If
			End If
		Next
		If Err.Number <> 0 Then	Err.Clear
	End Sub

	Public Function QueryUrl()
		Dim SCRIPT_NAME,QUERY_STRING
		SCRIPT_NAME		= Request.ServerVariables("SCRIPT_NAME")
		QUERY_STRING	= Request.ServerVariables("QUERY_STRING")
		If QUERY_STRING = "" Then
			QueryUrl = SCRIPT_NAME
		Else
			QueryUrl = SCRIPT_NAME & "?" & QUERY_STRING
		End If
	End Function

	Public Function IsExist(strPath)
		On Error Resume Next
		Dim strGetPath
		strGetPath = Server.MapPath(strPath)
		IsExist = p_objFSO.FolderExists(strGetPath)
		If Not IsExist Then IsExist = p_objFSO.FileExists(strGetPath)
		If Err.Number <> 0 Then Err.Clear
	End Function

	Private Function RegExplace(strContent,strTagetContent,strPattern)
		p_RegExp.pattern = strPattern
		p_RegExp.ignorecase = True
		p_RegExp.global = False
		RegExplace = p_RegExp.Replace(strContent,strTagetContent)
	End Function

	Private Function Tpl_Format(strContent)
		p_RegExp.pattern = "(<(script|link|img|input|embed|param|object|base|area|map|table|td|a|form).+?(href|src|background|action|lb-lazyload)=.+?)(.+?\>)"
		p_RegExp.ignorecase = True
		p_RegExp.global = True
		rem 2007-11-5 区分内外部连接URL by 56770.kingdge
		rem 2007-11-6 增加对https的识别 by 56770.kingdge
		Set objRegExp = p_RegExp.Execute(strContent)
			For Each objValue In objRegExp
			    If instr(LCase(objValue.value),"http") = 0 And instr(LCase(objValue.value),"msnim:") = 0 And instr(LCase(objValue.value),"tencent:") = 0 And instr(LCase(objValue.value),"skype:") = 0 And instr(LCase(objValue.value),"wangwang:") = 0 Then
				        strValue	= p_RegExp.Replace(objValue.value,"$1" & p_Template & "$4")
						strContent = Replace(Replace(strContent,objValue.value,strValue),"="""& Eshop_url &"""""","=""""""")
				End If
		Next
		Tpl_Format = strContent
	End Function

	Function RegExpMid(l1,l2,l3)
		Dim I1,I2,I3
		Dim l4,l5,l6,l7,l8
		If Left(l2,1) = Chr(40) And Right(l2,1) = Chr(41) And Left(l3,1) = Chr(40) And Right(l3,1) = Chr(41) Then'正则截取
			Set I1 = New RegExp
				I1.ignorecase = True
				I1.global = False
				I1.pattern = l2&"((.|\n)+?)"&l3
			Set I2 = I1.Execute(l1)
				If I2.Count>0 Then l4=I2.Item(0).value
			Set I2 = Nothing
				I1.pattern = l2
			Set I2 = I1.Execute(l4)
				If I2.Count>0 Then l5=I2.Item(0).value
			Set I2 = Nothing
				I1.pattern = l3
			Set I2 = I1.Execute(l4)
				If I2.Count>0 Then l6=I2.Item(0).value
			Set I2 = Nothing
		Else
			l4 = l1 : l5 = l2 : l6 = l3
		End If
		l7 = InStr(LCase(l4),LCase(l5))
		If l7 = 0 Then Exit Function
		l8 = InStr(LCase(Right(l4,Len(l4)-l7-Len(l5)+1)),LCase(l6))
		If l7>0 And l8>0 Then
			RegExpMid = Trim(Mid(l4,l7+Len(l5),l8-1))
		End If
	End Function

	Function LoadHtml(strFile)
			On Error Resume Next
			Dim strTempPath,objFSO,objStm
			strTempPath = Server.MapPath(strFile)
			Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
			Set objStm = Server.CreateObject("ADODB.Stream")
				If objFso.FileExists(strTempPath) Then
					objStm.charset = "UTF-8"
					objStm.open
					objStm.LoadFromFile strTempPath
					LoadHtml = objStm.ReadText
				End If
			Set objStm = Nothing
			Set objFSO = Nothing
			If Err Then
					Err.Clear
			End If
	End Function
End Class
%>