<!--#include file="../Conn.asp"-->
<!--#include file="../Cache/QvodCms.Admin.asp"-->
<!--#include file="../Cache/QvodCms.Class.asp"-->
<!--#include file="../Include/QvodCms.Md5.asp"-->
<!--#include file="../Include/QvodCms.Security.asp"-->
<!--#include file="../Include/QvodCms.QqConnect.asp"-->
<!--#include file="../Include/QvodCms.Fun.asp"-->
<!--#include file="../Include/QvodCms.Cache.asp"-->
<!--#include file="../Include/QvodCms.Fso.asp"-->
<%
Call OpenConn():Call setStartTime()	
Dim regEx,Match,Matches

    Sub regExMatch()'开始执行的语句
		Set regEx = New RegExp   '建立正则表达式
		regEx.IgnoreCase = True  '设置是否区分字符大小写
		regEx.Global = True      '设置全局可用性
	End Sub
	
	Sub Close_Terminate()'类结束
		Set regExpObj = nothing
		Set strDictionary = nothing
	End Sub
		
	Public Function OpenSkin(Byval MoBan_Path)
		Content = GetSkinCache(MoBan_Path)
		Content = ReplaceStr(Content,"@SiteHeader@",GetSkinCache(Config(0)&"Skin/"&Config(12)&"/"&AdminId(12)&"header.html"))
		Content = ReplaceStr(Content,"@SiteFooter@",GetSkinCache(Config(0)&"Skin/"&Config(12)&"/"&AdminId(12)&"footer.html"))		
	End Function
		
	Function OpenAll(Content)
	    regExMatch()
		Content = ReplaceStr(Content,"@InstallDir@",Config(0))
		Content = ReplaceStr(Content,"@SiteName@",Config(8))
		Content = ReplaceStr(Content,"@SiteUrl@",Config(9))
		Content = ReplaceStr(Content,"@Email@",Config(18))	
		Content = ReplaceStr(Content,"@KeyWord@",Config(15))
		Content = ReplaceStr(Content,"@Description@",Config(16))
		Content = ReplaceStr(Content,"@Skin@",Config(12))
		Content = ReplaceStr(Content,"@Copyright@",Config(13))
		Content = ReplaceStr(Content,"@Tong@",Config(14))
		Content = ReplaceStr(Content,"@BeiAn@",AdminId(11))
		Content = ReplaceStr(Content,"@QvodCmsPlayer@","<script language=""javascript"" type=""text/javascript"" src="""&Config(0)&"Js/QvodCms.Js.js""></script>")
		Content = ReplaceStr(Content,"@Css@","<link href="""&Config(0)&"skin/"&Config(12)&"/style.css"" rel=""stylesheet"" type=""text/css"" />")
		Content = ReplaceStr(Content,"@QvodChannel@","qvodcha://"&Config(8)&"|http://"&Config(9)&"/Channel.xml")
		Content = ReplaceStr(Content,"@QvodAdd@","qvodadd://"&Config(8)&"|http://"&Config(9)&"/")
		Content = ReplaceStr(Content,"@Titele@",Config(8))
		'
		Content=ReplaceStr(Content,"@PingLink@",PingLink("ABCDEFG"))
	    Content=ReplaceStr(Content,"@Today@",Config(0)&"today.html")
	    Content=ReplaceStr(Content,"@Top@",Config(0)&"top.html")	
		'
		regEx.Pattern = "\@ClassShu\(([\s\S]*?)\)@"
		Set Matches = regEx.Execute(Content)
		For Each Match In Matches
		Content=ReplaceStr(Content,Match.value,GetTongJi(Cint(Match.SubMatches(0))))
		Next:Set matches = Nothing
		'
		regEx.Pattern = "@Link\((.*?)\)@([\s\S]*?)@\/Link@"
		Set Matches = regEx.Execute(Content)
		For Each Match In Matches
		Content=ReplaceStr(Content,Match.value,GetFriend(QvodCms_CLng(Match.SubMatches(0)),Match.SubMatches(1)))
		Next:Set matches = Nothing
		'
		regEx.Pattern = "@Menu\((.*?)\)@([\s\S]*?)@\/Menu@"
		Set Matches = regEx.Execute(Content)
		For Each Match In Matches
		Content=ReplaceStr(Content,Match.value,GetMenu(Match.SubMatches(0),Match.SubMatches(1)))
		Next:Set matches = Nothing
		Close_Terminate()										
	End Function
		
			Public Function GetTongJi(str)
		If str=0 Then'所有
			Set Shu=Conn.Execute("select count(name_id) from qvodcms_name")
		ElseIf str=999 Then'今日
			If Config(1)="SQL" Then
			Set Shu=Conn.Execute(" select count(name_id) from qvodcms_name where datediff(d,data_lastdate,getdate())=0 ")
			Else
			Set Shu=Conn.Execute(" select count(*) from qvodcms_name where datediff('d',data_lastdate,now())=0 ")
			End If
		Else
		    If str=-1 Then str=QvodCms_CLng(List_Id)
			Set Shu=Conn.execute(" select count(name_id) from qvodcms_name where (class_id="&str&" or class_id in (select class_id from qvodcms_class where class_bigid="&str&")) ")
		End If
		GetTongJi=Shu(0)
		Set Shu=Nothing
	End Function
	
	Public Function GetFriend(strtype,strlist)
	    Dim Friend_I,Friend_Html,Lits_Html,Where_Link,Cache_Friend:Friend_I=0:Friend_Html="":Cache_Friend="Cache_Friend"
		If Cint(Config(19))=1 and CacheObj.ChkCache(Cache_Friend) Then'开启缓存+有缓存
			 Friend_Html = CacheObj.GetCache(Cache_Friend)
		Else
		    If strtype=1 Then Where_Link="where link_typeid=1" Else Where_Link="where link_typeid=0"
			Set rs = Conn.Execute("Select * from qvodcms_link "&Where_Link&" order by link_orderid asc")
			If Not(rs.bof And rs.eof) Then
			Do while not rs.eof
			Friend_I=Friend_I+1
			Lits_Html=ReplaceStr(strlist,"@LinkI@",Friend_I)
			Lits_Html=ReplaceStr(Lits_Html,"@LinkName@",rs("link_name"))
			Lits_Html=ReplaceStr(Lits_Html,"@LinkUrl@",rs("link_url"))
			Lits_Html=ReplaceStr(Lits_Html,"@LinkLogo@",rs("link_logo"))
			Lits_Html=ReplaceStr(Lits_Html,"@LinkIntro@",rs("link_about"))
			Friend_Html=Friend_Html&Lits_Html
			rs.movenext
			Loop
			End If
			rs.close:Set rs=nothing
			CacheObj.SetCache Cache_Friend,FriendLink'写入友链缓存
		End If
		GetFriend=Friend_Html
	End Function
	
	Public Function GetMenu(strtype,strlist)
		Dim Menu_I,Menu_Html,Lits_Html,Class_bigid,WhereStr:Menu_I=0:Menu_Html=""
		If Not isNum(strtype) Then GetMenu=err_menu:Exit Function	
		Set rs = Conn.Execute("Select * from qvodcms_class where class_id in("&strtype&") and class_orderid>0 order by class_orderid asc")
		If Not(rs.bof And rs.eof) Then
			Do while not rs.eof
			Menu_I=Menu_I+1
			Lits_Html=ReplaceStr(strlist,"@MenuI@",Menu_I)
			Lits_Html=ReplaceStr(Lits_Html,"@MenuId@",rs("class_id"))
			Lits_Html=ReplaceStr(Lits_Html,"@MenuName@",rs("class_name"))
			Lits_Html=ReplaceStr(Lits_Html,"@MenuEnName@",rs("class_dir"))
			Lits_Html=ReplaceStr(Lits_Html,"@MenuUrl@",GetListLink(rs("class_id")))
			If Instr(Lits_Html,"@MenuCss@")>0 Then
				If List_Id=rs("class_id") Then 
				Lits_Html=ReplaceStr(Lits_Html,"@MenuCss@","Current")
				Else
				Lits_Html=ReplaceStr(Lits_Html,"@MenuCss@","")
				End If
			End If
			Menu_Html=Menu_Html&Lits_Html
			rs.movenext
			Loop
		End If
		rs.close:Set rs=nothing
		GetMenu=Menu_Html
	End Function

	
Dim SiteHeader,SiteFooter,Css,CacheObj
Set CacheObj = New QvodCms_Cache
Reurl=Request.ServerVariables("Http_Referer")'来源地址
SiteHeader=GetSkinCache(Config(0)&"Skin/"&Config(12)&"/"&AdminId(12)&"header.html")
SiteFooter=GetSkinCache(Config(0)&"Skin/"&Config(12)&"/"&AdminId(12)&"footer.html")
Css="<link href="""&Config(0)&"skin/"&Config(12)&"/images/style.css"" rel=""stylesheet"" type=""text/css"" />"
Call OpenAll(SiteHeader):Call OpenAll(SiteFooter)
%>



