<!--#include file="Admin_Const.asp"-->
<%
if Not Cl.TrueOtherPurview("Template") then
	Admin_ShowErr("<br /><li>您无此操作权限！</li>")
end if
dim info
dim Action,StyleID,SkinID
Action=Trim(request("Action"))
StyleID=Cl.ChkClng(request("StyleID"))
SkinID=Clng(Cl.Cachedata(3,0))
If StyleID=0 Then StyleID=SkinID
Cl.LoadTemplates("")
Response.Write "<html>"
Response.Write Chr(10)	
Response.Write "<head>"
Response.Write Chr(10)	
Response.Write "<meta http-equiv=""Content-Type"" content=""text/html; charset=gb2312"">"
Response.Write Chr(10)	
Response.Write "<title>管理页面</title>"
Response.Write "<link href=""../Skins/Admin_Style.Css"" rel=""stylesheet"" type=""text/css"">"
Response.Write "</head>"
Response.Write "<script src=""../Inc/Js/Admin.js"" type=""text/javascript""></script>"
Response.Write Chr(10)
Response.Write "<body leftmargin=""0"" topmargin=""0"" marginheight=""0"" marginwidth=""0"">"
Response.Write Chr(10)
Response.Write "<table width=""100%"" border=""0"" cellspacing=""1"" cellpadding=""0"" align=center class=""border"">"
Response.Write "<tr>"
Response.Write "<td width=""100%"" class=""title"" align=center colspan=2 height=25><b>网站模板管理<b>"
Response.Write "</td>"
Response.Write "</tr>"
Response.Write "<tr class=tdbg>"
Response.Write "<td colspan=2>"
Response.Write "<p><B><font color='#FF6600'>注意：</font></B><br />①在这里，您可以新建和修改模板，可以编辑网站语言包和风格，可以新建模板页面，操作时请按照相关页面提示完整填写表单信息。<br />②网站当前正在使用的默认模板不能删除<br />③如果修改分模板页面名称或删除分模板页面请在关闭网站之后操作,否则可能会影响网站访问."
Response.Write "</td>"
Response.Write "</tr>"
Response.Write "<tr class=tdbg>"
Response.Write "<td width=20% height=25 align=left>"
Response.Write "<B>模板操作选项</B></td>"
Response.Write "<td width=""80%""><a href=""admin_Template.asp"">模板管理首页</a> | <a href=""admin_Template.asp?action=editcss"">CSS风格管理</a> | <a href=""admin_loadskin.asp"">模板风格导入导出</a> | <select name=D1 onchange=""window.open (this.options[this.selectedIndex].value,'Label','height=700, width=600, toolbar=no, menubar=no, scrollbars=auto, resizable=no, location=no, status=no')"" size=1><option selected value=""../Editor/label/novi/Cl_Index.htm"">配置创力标签</option><option value=""../Editor/label/novi/Cl_Common0.htm"">公共标签(1)</option><option value=""../Editor/label/novi/Cl_Common1.htm"">公共标签(2)</option><option value=""../Editor/label/novi/Cl_SuperAll.htm"">超级标签集</option><option value=""../Editor/label/novi/Cl_Show.htm"">各频道的SHOW</option></select>"
Response.Write "</td>"
Response.Write "</tr>"
Response.Write "</table><br />"
Select Case action
	Case "edit"
		Call Edit() 
	Case "manage"
		If Request("mostyle")="编 辑" Then
			Main()
		ElseIf Request("mostyle") = "删 除" Then
			DelStyle()
		ElseIf Request("mostyle") = "设为默认" Then
			setdefault()
		End If
	Case "saveedit"
		Call Saveedit()
	Case "addmodule"
		addmodule()
	Case "addstyle"
		addstyle()
	Case "rename"
		rename()
	Case "editcss"
		editcss()
	Case "savecss"
		savecss()
	Case "editmain"
		editmain()
	Case "savemain"
		Savemain() 
	Case "ghost"
		ghost()
	Case "delmodule"
		delmodule()
	Case "modulerename"
		modulerename()
	Case Else
		Main()
End Select

Sub Main()
	Dim NowOpenTemplate,styname,Rs
	Set Rs=Cl.Execute("Select StyleName From Cl_Style where Id="&SkinID&"")
	styname=rs(0)
	Rs.Close
	Response.Write "<table width=""100%"" border=""0"" cellspacing=""1"" cellpadding=""0"" align=center class=""border"">"
	Response.Write "<tr>"
	Response.Write "<td width=""100%"" class=""title"" align=center colspan=2 height=25>当前网站默认模板是("&styname&")"
	Response.Write "</td>"
	Response.Write "</tr>"
	Response.Write "<tr class=tdbg>"
	Response.Write "<form method=post action=""?action=manage"">"
	Response.Write "<td height=40 align=left>"
	Response.Write "请选择相关模板： "
	
	'Cl.DelCahe("Templateslist")

	'利用系统缓存数据取得所有模板名称和ID
	Dim Templateslist
	Cl.Name="Templateslist"
	If Cl.ObjIsEmpty() Then Cl.ReloadTemplateslist()
	Templateslist= Cl.Value
	Templateslist=split(Templateslist,"@@@")

	Response.Write "<select name=""StyleID"" size=1>"
	For i=0 to UBound(Templateslist)
		Templateslist(i)=split(Templateslist(i),"|||")
		Response.Write "<option value="""&Templateslist(i)(0)&""""
		If CLng(Templateslist(i)(0)) = CLng(StyleID) Then
			Response.Write " selected"
			NowOpenTemplate=Templateslist(i)(1)
		End If 
		Response.Write ">"&Templateslist(i)(1)&"</option>"
	Next 
	Response.Write "</select>"
	Response.Write "&nbsp;&nbsp;"
	Response.Write "<input type=submit value=""编 辑"" name=""mostyle"">&nbsp;&nbsp;"
	Response.Write "<input type=submit value=""删 除"" name=""mostyle"">&nbsp;&nbsp;"
	Response.Write "<input type=submit value=""设为默认"" name=""mostyle"">"
	Response.Write "<br /><br /><b><font color='#FF6600'>说明：</font></b>删除操作将删除该模板所有数据，慎用。"
	Response.Write "</td>"
	Response.Write "</FORM>"
	Response.Write "<FORM METHOD=POST ACTION=""?action=addmodule"">"
	Response.Write "<td class=tdbg height=25 align=left>"
	Response.Write "新建模板分模块：&nbsp;"
	Response.Write "<input type=text size=25 name=""StylemoduleName"">&nbsp;&nbsp;"
	Response.Write "<input type=submit name=submit value=""添 加""> "
	Response.Write "</td>"
	Response.Write "</FORM>"
	Response.Write "</tr>"
	Response.Write "<tr>"
	Response.Write "<td class=""title"" align=center height=25 colspan=2>"
	Response.Write NowOpenTemplate&"－－模板资源管理</td></tr><tr><td height=25 class=tdbg colspan=2>"
	Response.Write "通常来说，分模块就是网站中每个频道的风格模板，括号中是字段名，字段的命名规则为：module_模块名"
	Response.Write "</td>"
	Response.Write "</tr>"
	Set Rs=Cl.Execute("Select top 1 * From Cl_Style ")
	For i= 2 to Rs.Fields.Count-1
		'If i> 12 Then
		'	Response.Write "<form method=post action=""?action=modulerename"">"
		'End If
		Response.Write "<tr class='tdbg' onmouseout=""this.style.backgroundColor=''"" onmouseover=""this.style.backgroundColor='#cccccc'"" style='padding: 0px 2px;'>"
		Response.Write "<td height=25 align=left>"
		Response.Write "<li>"
		Select Case i
			'Case 2
				'Response.Write "当前模板CSS设置<a href=#>"
			Case 2
				Response.Write "当前模板主模块<a href=#>"
			Case Else 
				Response.Write "当前模板分模块<a href=#>"
		End Select
		'If i> 12 Then
		'	Response.Write "</a>&nbsp;&nbsp;module_"
		'	Response.Write "<input type=text size=15 name=newmodulename value="&Replace(Rs(i).Name,"module_","")&">&nbsp;&nbsp;"
		'	Response.Write "<input type=hidden size=15 name=oldmodulename value="&Replace(Rs(i).Name,"module_","")&">"		
		'	Response.Write "<input type=submit value=""分模块改名"" name=""mo"" title=""修改名称后提交"">"
		'Else
			Response.Write "("&Rs(i).Name&")</a>&nbsp;&nbsp;"		
		'End If	
		Response.Write "</td>"
		Response.Write "<td height=""25"" align=""left"">"
		If i>1 Then 
			Response.Write "编辑该模块："
			Response.Write "<a href=""?action=edit&stype=1&module="
			Response.Write Rs(i).Name
			Response.Write "&StyleID="
			Response.Write StyleID
			Response.Write """>语言包</a> <a href=""?action=edit&stype=1&module="					
			Response.Write Rs(i).Name
			Response.Write "&StyleID="
			Response.Write StyleID
			Response.Write "#new""><font color=""#0066CC"">新</font></a> | <a href=""?action=edit&stype=2&module="
			Response.Write Rs(i).Name
			Response.Write "&StyleID="
			Response.Write StyleID
			Response.Write """>图片</a> <a href=""?action=edit&stype=2&module="
			Response.Write Rs(i).Name
			Response.Write "&StyleID="
			Response.Write StyleID
			Response.Write "#new"""
			Response.Write "><font color=""#0066CC"">新</font></a> | <a href=""?action=edit&stype=3&module="
			Response.Write Rs(i).Name
			Response.Write "&StyleID="
			Response.Write StyleID
			Response.Write """>界面风格</a> <a href=""?action=edit&stype=3&module="
			Response.Write Rs(i).Name
			Response.Write "&StyleID="
			Response.Write StyleID
			Response.Write "#new""><font color=""#0066CC"">新</font></a>"
			If i=2 Then 
				Response.Write " | <a href=""?action=editmain&stype=2&StyleID="&StyleID&""">基本设置</a>"
			End If
		'ElseIf i=2 Then
			'Response.Write "编辑该模块："
			'Response.Write "<a href=""?action=editcss&StyleID="&StyleID&""">修改CSS样式</a>"	 
		End If
		'If i>12 Then 
		'	Response.Write "&nbsp;&nbsp;<a href=""?action=delmodule&StylemoduleName="&Rs(i).Name&""" title=""注意，删除后不可恢复"">删除模块</a>"		
		'End If
		Response.Write "</td>"
		Response.Write "</tr>"
		'If i>12 Then
		'	Response.Write "</form>" 
		'End If
	Next
	Response.Write "</table><br />"
	Response.Write "<table width=""100%"" border=""0"" cellspacing=""1"" cellpadding=""0"" align=center class=""border"">"
	Response.Write "<tr>"
	Response.Write "<td width=""100%"" class=""title"" colspan=2 height=25>网站模板管理"
	Response.Write "</td>"
	Response.Write "</tr>"
	Response.Write "<tr>"
	Response.Write "<FORM METHOD=POST ACTION=""?action=addstyle"">"
	Response.Write "<td class=tdbg height=40 align=left width=45% >"
	Response.Write "新建模板：&nbsp;"
	Response.Write "<input type=text size=25 name=""StyleName"">&nbsp;&nbsp;"
	Response.Write "<input type=submit value=""添 加"" name=""mostyle"">"
	Response.Write "<br /><br /><b><font color='#FF6600'>说明：</font></b>新建模板将把当前网站默认模版数据复制到新的模板中"
	Response.Write "</td>"
	Response.Write "</FORM>"
	Response.Write "<FORM METHOD=POST ACTION=""?action=ghost"">"
	Dim sTempStyle, sTempModule
	For i=0 to UBound(Templateslist)
		sTempStyle = sTempStyle & "<option value="""&Templateslist(i)(0)&""""
		If CLng(Templateslist(i)(0)) = CLng(StyleID) Then 
			sTempStyle = sTempStyle & " selected"
		End If 
		sTempStyle = sTempStyle & ">"&Templateslist(i)(1)&"</option>"
	Next
	For i=2 to Rs.Fields.Count-1
		sTempModule = sTempModule & "<option value="&i&">模板（"&Rs(i).Name&"）</option>"
	Next
	Response.Write "<td class=tdbg height=25 align=left>源 模 板："
	Response.Write "<select name=""OlDStyleID"" size=1>"
	Response.Write sTempStyle
	Response.Write "</select>"
	'==================
	Response.Write "<select name=""OlDStyleName"" size=1>"
	Response.Write "<option value=0 selected>所有分模块</option>"
	Response.Write sTempModule
	Response.Write "</select>"
	'==================
	Response.Write "<br />目标模板："
	Response.Write "<select name=""newStyleID"" size=1>"
	Response.Write sTempStyle
	Response.Write "</select>"
	Response.Write "<select name=""newStyleName"" size=1>"
	Response.Write "<option value=0 selected>所有分模块</option>"
	Response.Write sTempModule
	Response.Write "</select>"

	Response.Write "&nbsp;&nbsp;<input type=submit name=submit value=""模板克隆"">"
	Response.Write "<br /><br /><b><font color='#FF6600'>说明：</font></b>模板克隆将用源模版数据覆盖目标模板中的所有数据"
	Response.Write "</td>"
	Response.Write "</FORM>"
	Response.Write "</tr>"
	Response.Write "<tr>"
	Response.Write "<FORM METHOD=POST ACTION=""?action=rename"">"
	Response.Write "<td class=tdbg height=25 align=left ColSpan=2>"
	Response.Write "将模板：<select name=""StyleID"" size=1>"
	Response.Write sTempStyle
	Response.Write "</select>"
	Response.Write "&nbsp;&nbsp;"
	Response.Write "改名为：<input type=text size=20 name=""StyleName"" value="""
	Response.Write """>&nbsp;&nbsp;"
	Response.Write "<input type=submit name=submit value=""修 改"">"
	Response.Write "</td>"
	Response.Write "</FORM>"
	'Response.Write "<td class=tdbg height=25 align=left>"
	'Response.Write "&nbsp;"
	'Response.Write "</td>"
	Response.Write "</tr>"
	Response.Write "<tr>"
	Response.Write "<FORM METHOD=POST ACTION=""?action=delmodule"">"
	Response.Write "<td class=tdbg height=25 align=left ColSpan=2>"
	Response.Write "将模块：<select name=""moduleName"" size=1>"
	Response.Write "<option value="""" selected>请选择相应分模块</option>"
	For i=13 to Rs.Fields.Count-1
		Response.Write "<option value="""&Rs(i).Name&""">"&Rs(i).Name&"</option>"
	Next
	Response.Write "</select>"
	Response.Write "&nbsp;&nbsp;"
	Response.Write "<input type=submit name=submit value=""删 除"">"
	Response.Write "</td>"
	Response.Write "</FORM>"
	Response.Write "</tr>"
	Response.Write "</table>"
	Rs.Close
	Set Rs=Nothing
End Sub
Sub Edit()

	Dim module,mystr
	Dim TempStr,TemplateStr,stype
	Dim TempStyleHelp,StyleHelpValue
	stype=Cl.checkStr(request("stype"))
	module=Cl.checkStr(request("module"))
	If Not IsNumeric(stype) Then 
		Errmsg=ErrMsg + "<br /><li>错误的样式参数"
		Admin_ShowErr(ErrMsg)
	End If
	If Not IsTruemodule(module) Then
		Errmsg=ErrMsg + "<br /><li>要编辑的页面模板字段尚未建立。"
		Admin_ShowErr(ErrMsg)
	End If

	'从数据库中取出对应项目的帮助文本
	Set Rs=Cl.Execute("Select ID,StyleName,"&module&" From Cl_StyleHelp where ID=1")
	TempStr=Split(Rs(2),"@@@")
	Select Case stype
		Case 1
			TempStyleHelp=Split(TempStr(1),"|||")
		Case 2
			TempStyleHelp=Split(TempStr(2),"|||")
		Case 3
			TempStyleHelp=Split(TempStr(0),"|||")
	End Select
	'从数据库中取出对应项目内容
	Set Rs=Cl.Execute("Select ID,StyleName,"&module&" From Cl_Style Where id="&StyleID)
	TempStr=Split(Rs(2),"@@@")
	Select Case stype
		Case 1  '语言包
			TemplateStr=Split(TempStr(1),"|||")
		Case 2  '图片 
			TemplateStr=Split(TempStr(2),"|||")
		Case 3  '界面风格 
			TemplateStr=Split(TempStr(0),"|||")
	End Select

	Response.Write "<table width=""100%"" border=""0"" cellspacing=""1"" cellpadding=""0"" align=center class=""border"">"
	Response.Write "<form name=""Template"" action=""?action=saveedit&module="&module&"&stype="&stype&"&StyleID="&StyleID&""" method=post>"
	Response.Write "<tr>"
	Response.Write "<td width=""100%"" class=""title"" align=center colspan=3 height=25>"
	Response.Write Rs(1)
	Response.Write "--模块("
	Response.Write module
	Response.Write ")"
	Response.Write "<input Type=""hidden"" name=""ntstudio"" value=""OK!"">"
	Select Case stype
		Case 1
			Response.Write "语言包"
			mystr="Template.Strings"
			If module="main_style" Then mystr="Cl.lanstr"
		Case 2
			Response.Write "图片资源"
			mystr="Template.pic"
			If module="main_style" Then mystr="Cl.mainpic"
		Case 3
			Response.Write "界面风格"
			mystr="Template.html"
			If module="main_style" Then mystr="Cl.mainhtml"
	End Select
	
	Response.Write "管理</td></tr>"
	If TemplateStr(Ubound(TemplateStr))="" Then TemplateStr(Ubound(TemplateStr))="del"
	For i=0 To Ubound(TemplateStr)
		If i<ubound(TempStyleHelp) Then
			StyleHelpValue=TempStyleHelp(i)
		Else
			StyleHelpValue="//"
		End IF
		Response.Write "<tr class=tdbg><td width=20% height=40 align=left>"
		Response.Write mystr&"("&i&")"
		Response.Write "<br />(<a href=""Http://Www.Aspoo.Cn/ClSysTem/Templates_Load.Asp?Module="&module&"&stype="&stype&"&Txt="&i&"""  title=""点这里获取这部分模板的官方数据,以便还原！"" target=""_blank""><font color=#0000ff>查看官方数据</font></a>)"
		Response.Write "</td>"
		Response.Write "<td width=80% height=25 align=left>"
		Select Case stype
			Case 1
				If LenB(TemplateStr(i))>70 Then
				Response.Write "<textarea name=""TemplateStr"" id=""t"&i&"""  cols=""85"" rows=""3"">"
				Response.Write server.HTMLEncode(TemplateStr(i))
				Response.Write "</textarea>"
				Else
				Response.Write "<input Type=""text"" name=""TemplateStr"" id=""t"&i&""" value="""
				Response.Write server.htmlencode(TemplateStr(i))
				Response.Write """ size=50>"
				End If
				Response.Write "<INPUT TYPE=""hidden"" NAME=""ReadME"" id=""r"&i&""" value="""&StyleHelpValue&""">"
			Case 2
				Response.Write "<input Type=""text"" name=""TemplateStr"" id=""t"&i&""" value="""
				Response.Write server.htmlencode(TemplateStr(i))
				Response.Write """ size=50> "
				If server.htmlencode(TemplateStr(i))<>"" And (Instr(server.htmlencode(TemplateStr(i)),".gif") or Instr(server.htmlencode(TemplateStr(i)),".jpg")) Then Response.Write "<img src="&server.htmlencode(Replace(Replace(TemplateStr(i),"{%PicUrl%}",Cl.Web_PicUrl),"{%webdir%}",Cl.WebDir))&"  border=0>"
				Response.Write "<INPUT TYPE=""hidden"" NAME=""ReadME"" id=""r"&i&""" value="""&StyleHelpValue&""">"
			Case 3
				If module="main_style" And i=0 Then 
					Response.Write "<INPUT TYPE=""hidden"" NAME=""ReadME"" id=""r"&i&""" value="""&StyleHelpValue&""">"
					Response.Write "<input type=hidden name=""TemplateStr"" value="""
					Response.Write server.htmlencode(TemplateStr(i))
					Response.Write """>"
					Response.Write "此字段属于基本设置，  <a href=""?action=editmain&stype=2&StyleID="&StyleID&""">点这里修改基本设置</a>"
					'Response.Write "</td><td class=tdbg>"
				Else
					Response.Write "说明：<input type=""text"" NAME=""ReadME"" id=""r"&i&""" size=66 value="""&server.HTMLEncode(StyleHelpValue)&""">&nbsp;&nbsp;"
					Response.Write "<a href=""javascript:admin_Size(-5,'t"&i&"')""><img src=""images/minus.gif"" unselectable=""on"" border=0 align=""absmiddle""></a><a href=""javascript:admin_Size(5,'t"&i&"')""><img src=""images/plus.gif"" unselectable=""on"" border=0 align=""absmiddle""></a>&nbsp;&nbsp;"
					Response.Write "<a href=""Admin_Templates_Editor.asp?StyleID="&Styleid&"&module="&module&"&txtRun="&i&""" target=_blank><img src=images/EditPic.gif title=""点击编辑！"" align=""absmiddle"" border=0></a>"
					Response.Write "<br /><textarea name=""TemplateStr"" id=""t"&i&""" cols=""85"" rows=""5"">"
					Response.Write server.htmlencode(TemplateStr(i))
					Response.Write "</textarea>"

				End If
				'Response.Write "<INPUT TYPE=""hidden"" NAME=""ReadME"" id=""r"&i&""" value="""&StyleHelpValue&""">"
			End Select
		Response.Write "</td></tr>"
	Next
	Response.Write "<tr class=tdbg><td height=""25"" align=""center"" colspan=""3"">"
	Response.Write "</td></tr>"
	Response.Write "<tr class=tdbg><td height=""25"" align=""center"" colspan='3'>"
	Response.Write "<input type=""submit"" name=""B1"" value=""修 改"">"
	Response.Write "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"
	Response.Write "<input type=""reset"" name=""Submit"" value=""重 填"">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"
	Response.Write "</td></tr>"
	Response.Write "<tr class=tdbg>"
	Response.Write "<td colspan=3>"
	Response.Write "<br /><li>模板编辑规则：如果想清除该字段，请在对应的文本框中输入""del""，那么模板数据的序号就会前移。"
	Response.Write "<br /><li>如果不想改变模板数据的序号,仅把该项目的数据清空,则只需要把内容清空。"
	Response.Write "<br /></td></tr>"
	Response.Write "</form>"
	Response.Write "</table>"
	Rs.Close
	Set Rs=Nothing
End Sub
Sub SaveEdit()
	If Request("ntstudio")<>"OK!" Then
		Errmsg=ErrMsg + "<br /><li>您提交了非法数据"
		Admin_ShowErr(ErrMsg)
		Exit Sub
	End If
	Dim module
	Dim TempStr,TemplateStr,stype
	Dim TempStyleHelp,StyleHelpValue
	stype=Cl.checkStr(request("stype"))
	module=Cl.checkStr(request("module"))

	If Not IsNumeric(stype) Then
		Errmsg=ErrMsg + "<br /><li>错误的样式参数"
		Admin_ShowErr(ErrMsg)
	End If
	If Not IsTruemodule(module) Then
		Errmsg=ErrMsg + "<br /><li>要编辑的页面模板字段尚未建立。"
		Admin_ShowErr(ErrMsg)
	End If
	'提取表单中的数据
	TemplateStr=""

	For Each TempStr in Request.form("TemplateStr")
		If LCase(TempStr)<>"del" Then 
			TemplateStr=TemplateStr&Replace(TempStr,"|||","")&"|||"
		End If
	Next
	TemplateStr=Cl.checkStr(Replace(TemplateStr,"@@@",""))

	If Trim(TemplateStr)="" Then 
		TemplateStr="|||"
	End If

	'提取表单中的数据
	StyleHelpValue=""
	For Each TempStyleHelp in Request.form("ReadME")
		'If TempStyleHelp<>"" Then 
		StyleHelpValue=StyleHelpValue&TempStyleHelp&"|||"
		'End If
	Next
	If Trim(StyleHelpValue)="" Then 
		StyleHelpValue="|||"
	Else
		StyleHelpValue=Cl.checkStr(StyleHelpValue)
	End If

	Set Rs=Cl.Execute("Select ID,StyleName,"&module&" From Cl_Style Where ID="&StyleID)
	TempStr=Split(Rs(2),"@@@")
	Select Case stype
		Case 1
			TemplateStr=Cl.checkStr(TempStr(0))&"@@@"&TemplateStr&"@@@"&TempStr(2)
		Case 2
			TemplateStr=Cl.checkStr(TempStr(0))&"@@@"&TempStr(1)&"@@@"&TemplateStr
		Case 3
			TemplateStr=TemplateStr&"@@@"&TempStr(1)&"@@@"&TempStr(2)
	End Select

	Set Rs=Cl.Execute("Select ID,StyleName,"&module&" From Cl_StyleHelp Where ID=1")
	'TempStr=Split(Rs(2),"@@@")
	'增加对模版判断，如果出错则用上面注释语句恢复
	if instr(Rs(2),"@@@")<=0 then
		TempStr=Split("|||@@@|||@@@|||","@@@")
	else
		TempStr=Split(Rs(2),"@@@")
	end if
	Select Case stype
		Case 1
			StyleHelpValue=TempStr(0)&"@@@"&StyleHelpValue&"@@@"&TempStr(2)
		Case 2
			StyleHelpValue=TempStr(0)&"@@@"&TempStr(1)&"@@@"&StyleHelpValue
		Case 3
			StyleHelpValue=StyleHelpValue&"@@@"&TempStr(1)&"@@@"&TempStr(2)
	End Select
	Rs.close:Set Rs=Nothing
	Cl.Execute("update Cl_Style set "&module&"='"&TemplateStr&"' Where ID="&StyleID)
	Cl.Execute("update Cl_StyleHelp set "&module&"='"&StyleHelpValue&"' Where ID=1")
	'更新缓存。
	Cl.DelCahe(module&StyleID)
	If InStr(Lcase(module),"main_style")>0 Then
		Cl.DelCahe("Main_Style" & StyleID)
	End If
	Cl.SaveAdminLog
	Select Case stype
	Case 1
		Response.Write Cl.ShowSuc(module&"语言包修改成功!  <a href='admin_Template.asp?StyleID="&StyleID&"'><< <b>返回模板首页</b></a>")
	Case 2
		Response.Write Cl.ShowSuc(module&"图片资源修改成功!  <a href='admin_Template.asp?StyleID="&StyleID&"'><< <b>返回模板首页</b></a>")
	Case 3
		Response.Write Cl.ShowSuc(module&"界面风格修改成功!  <a href='admin_Template.asp?StyleID="&StyleID&"'><< <b>返回模板首页</b></a>")
	End Select
End Sub

Function IsTruemodule(module)
	IsTruemodule=False
	If module<>"" Then 
		module=LCase(Trim(module))
		Dim myrs
		Set Myrs=Cl.Execute("Select top 1 * From Cl_Style")
		For i= 2 to MyRs.Fields.Count-1
			If LCase( myrs(i).name)=module Then
				 IsTruemodule=True
				 Exit For
			End If
		Next
	End If
End Function

Sub DelStyle()
	If StyleID=SkinID Then
		Errmsg=ErrMsg + "<br /><li>本模板是默认模版，不允许删除。"
		Admin_ShowErr(ErrMsg)
	    exit sub
	End If
	Dim RsStyle
	Set RsStyle=Cl.Execute("Select top 1 * from Cl_Channel where StyleID="&Clng(StyleID)&"")
	If Not (RsStyle.bof and RsStyle.eof) Then
		Errmsg=ErrMsg + "<br /><li>本模板正在使用中，不允许删除。"
		Admin_ShowErr(ErrMsg)
		Set RsStyle=Nothing
	    exit sub
	End If
	Set RsStyle=Nothing
	Cl.Execute("delete * from Cl_Style Where ID="&StyleID&"")
	Cl.DelCahe("Templateslist")'删除模板列表缓存
	Cl.SaveAdminLog
	Response.Write Cl.ShowSuc("成功删除了一个模板。 <a href='admin_Template.asp?StyleID="&StyleID&"'><< <b>返回模板首页</b></a>")
End Sub

Sub setdefault()
	Cl.Execute("update Cl_Setup set Web_StyleID="&StyleID&",Web_CssID=0")	
	Cl.DelCahe("setup")'删除默认模板ID缓存
	Cl.SaveAdminLog
	Response.Write Cl.ShowSuc("已经设置模板为默认模版。 <a href='admin_Template.asp?StyleID="&StyleID&"'><< <b>返回模板首页</b></a>")
End Sub

Sub addmodule()
	Dim StylemoduleName
	StylemoduleName=Cl.checkStr(request("StylemoduleName"))
	If StylemoduleName="" Then 
		Errmsg=ErrMsg + "<br /><li>请填写字段名称"
		Admin_ShowErr(ErrMsg)
		exit sub
	End If
	StylemoduleName="module_"&StylemoduleName
	If IsTruemodule(StylemoduleName) Then 
		Errmsg=ErrMsg + "<br /><li>您要创建的模板字段已经存在。"
		Admin_ShowErr(ErrMsg)
		exit sub
	End If
	Cl.Execute("alter table Cl_Stylehelp add "&StylemoduleName&" text Null default'|||@@@|||@@@|||@@@|||'")
	Cl.Execute("Update Cl_Stylehelp Set "&StylemoduleName&"='|||@@@|||@@@|||@@@|||'")
	Cl.Execute("alter table Cl_Style add "&StylemoduleName&" text Null default'|||@@@|||@@@|||@@@|||'")
	Cl.Execute("Update Cl_Style Set "&StylemoduleName&"='|||@@@|||@@@|||@@@|||'")
	Cl.SaveAdminLog
	Response.Write Cl.ShowSuc("新页面模板创建成功! <a href='admin_Template.asp?StyleID="&StyleID&"'><< <b>返回模板首页</b></a>")
End Sub

Sub addstyle()
	Dim StyleName
	StyleName=Cl.checkStr(Request("stylename"))
	If Trim(StyleName)="" Then Admin_ShowErr("<br /><li>请输入模板名称。")
	Set Rs=Cl.Execute("select * From [Cl_Style] where ID="&StyleID&"")
	Dim StyleFields,StyleValues,Fields
	Fields=Rs.Fields.Count-1
	Redim StyleFields(Fields)
	Redim StyleValues(Fields)
	StyleFields(1)	= "StyleName"
	StyleValues(1)	= StyleName
	For i= 2 to Fields
		StyleFields(i)	= Rs(i).Name
		StyleValues(i)	= Cl.checkStr(Rs(i))
	Next
	Rs.Close : Set Rs=Nothing
	Set Rs=Server.CreateObject("Adodb.RecordSet")
	OpenConn : rs.Open "Select Top 1 * From [Cl_Style]",Conn,1,3
	Rs.addnew
	for i=1 to Ubound(StyleFields)
		Rs(StyleFields(i))	= StyleValues(i)
	next
	Rs.update
	Rs.Close : Set Rs=Nothing
	'sql="insert into [Cl_Style] ("&StyleFields&") values ("&StyleValues&")"
	'Cl.Execute(SQL)
	Cl.DelCahe("Templateslist")'删除模板列表缓存
	Cl.SaveAdminLog
	Response.Write Cl.ShowSuc("新模板创建成功! <a href='admin_Template.asp?StyleID="&StyleID&"'><< <b>返回模板首页</b></a>")
End Sub
Sub modulerename()
	Dim oldmodulename,newmodulename
	oldmodulename=Cl.checkStr(request("oldmodulename"))
	newmodulename=Cl.checkStr(request("newmodulename"))
	If LCase(newmodulename)=LCase(oldmodulename) Then
		Errmsg=ErrMsg + "<br /><li>你没有更改名称"
		Admin_ShowErr(ErrMsg)
	End If
	If newmodulename="" Then
		Errmsg=ErrMsg + "<br /><li>新名称不能为空"
		Admin_ShowErr(ErrMsg)
	End If
	If OLDmodulename="" Then
		Errmsg=ErrMsg + "<br /><li>您提交的数据是错误的."
		Admin_ShowErr(ErrMsg)
	End If
	oldmodulename="module_"&oldmodulename
	newmodulename="module_"&newmodulename
	If Not IsTruemodule(oldmodulename) Then 
		Errmsg=ErrMsg + "<br /><li>要改名的字段不存在。"
		Admin_ShowErr(ErrMsg)
	End If
	If IsTruemodule(newmodulename) Then 
		Errmsg=ErrMsg + "<br /><li>字段名称"&newmodulename&"已经被占用."
		Admin_ShowErr(ErrMsg)
	End If
		Dim Fieldslist
		Set Rs=Cl.Execute("select * from Cl_Style")
		Fieldslist="id"
		For i= 1 to Rs.Fields.Count-1
			If LCase(Rs(i).name)<> LCase (oldmodulename) Then 
				Fieldslist=Fieldslist&","&Rs(i).name
			Else
				Fieldslist=Fieldslist&","&Rs(i).name&" as "& newmodulename
			End If
		Next
		Set Rs=Nothing
		'复制有用数据到临时表	
		Cl.Execute("Select "&Fieldslist&" into Cl_tempatble From Cl_Style")
		'删除原有表
		Cl.Execute("Drop table Cl_Style")
		'再把临时表中的数据复制过来.
		Cl.Execute("Select * into Cl_Style From Cl_tempatble ")
		'删除临时表
		Cl.Execute("Drop table Cl_tempatble")
		'复制有用数据到临时表	
		Cl.Execute("Select "&Fieldslist&" into Cl_tempatble From Cl_Stylehelp")
		'删除原有表
		Cl.Execute("Drop table Cl_Stylehelp")
		'再把临时表中的数据复制过来.
		Cl.Execute("Select * into Cl_Stylehelp From Cl_tempatble ")
		'删除临时表
		Cl.Execute("Drop table Cl_tempatble")
	Cl.SaveAdminLog
	Response.Write Cl.ShowSuc("成功把 "&oldmodulename&" 字段改名为 "&newmodulename&"")
End Sub
Sub rename()
	Dim stylename
	stylename=Cl.checkStr(Request("stylename"))
	If Trim(stylename)=""  Then 
		Errmsg=ErrMsg + "<br /><li>修改名称请输入新的模板名称。"
		Admin_ShowErr(ErrMsg)
	End If
	Cl.Execute("update Cl_Style set StyleName='"&StyleName&"' where id="&StyleID&"")
	Cl.DelCahe("Templateslist")'删除模板列表缓存
	Cl.SaveAdminLog
	Response.Write Cl.ShowSuc("模板名修改成功! <a href='admin_Template.asp?StyleID="&StyleID&"'><< <b>返回模板首页</b></a>")
End Sub
'//编辑修改CSS模板
'CSS风格名称@@@CSS风格内容@@@CSS风格图片包路径	（用@@@分类，用|||分隔内容.）
Sub EditCss()
Dim CssName,CssContent,CssPicUrl,MainStyleName,k,CssCount
Dim TempCssStyle,LockID
'Set Rs=Cl.Execute("Select Web_CSS,StyleName From Cl_Style Where ID="&StyleID)
	TempCssStyle=Split(Server.htmlencode(Cl.CacheData(15,0)),"@@@")
	'MainStyleName=Rs(1)
'Rs.close

CssName=Split(TempCssStyle(0),"|||")	'CSS风格名称
CssCount=Ubound(CssName)
If Ubound(TempCssStyle)<1 Then
Redim CssContent(CssCount)
Else
CssContent=Split(TempCssStyle(1),"|||")	'CSS风格内容
End If
If Ubound(TempCssStyle)<2 Then
Redim CssPicUrl(CssCount)
Else
CssPicUrl=Split(TempCssStyle(2),"|||")	'CSS风格图片包路径
End IF

Response.Write "<table width=""100%"" border=""0"" cellspacing=""1"" cellpadding=""2"" align=center class=""border"">"
Response.Write "<tr>"
Response.Write "<td width=""100%"" class=""title"" colspan=2 height=25>CSS样式管理"
Response.Write "</td></tr></table>"
%>
<script language="JavaScript" type="text/javascript">
<!--
function EditCss(n)
{
	var trid=document.getElementsByName('CssTR');
	 for (var i=0;i<trid.length;i++)    {
		if (i!=n){
		trid[i].style.display="none";
		}
	   }
	EditTextarea.style.display = '';
	document.cssform.CssContent.value = document.cssform.CssBody[n].value;
	document.cssform.TempID.value = n;
	document.cssform.CssEdit[n].disabled=true;
}

function DllData(n){
	if (document.cssform.DelCss[n].checked==true){
	document.cssform.CssName[n].value = '计划将其删除...';
	document.cssform.CssBody[n].disabled = true;
	document.cssform.CssPicUrl[n].disabled = true;
	document.cssform.CssEdit[n].disabled=true;
	}else{
	document.cssform.CssName[n].value = '请重新输入新的风格名称!!';
	document.cssform.CssBody[n].disabled = false;
	document.cssform.CssPicUrl[n].disabled = false;
	document.cssform.CssEdit[n].disabled=false;
	}
}

function SubmitData(){
	var NewData,UpObject
	var e = document.cssform;
	NewData=e.CssContent.value;
	UpObject=e.TempID.value;
	if (NewData!=''){
		e.CssBody[UpObject].value=NewData;
	}
	for (var i=0;i<e.CssName.length;i++){
		if (e.CssName[i].value == '计划将其删除...' || e.CssName[i].value == ''){
		e.CssName[i].value = '';
		e.CssBody[i].value = '';
		e.CssPicUrl[i].value = '';
		}
	}
}
//-->
</script>
<table width="100%" border="0" cellspacing="1" cellpadding="0" align=center class="border" >
<form action="?action=savecss" method="post" name="cssform" onsubmit="SubmitData();">
<tr class="tdbg">
<td width="10%" align=center>ID</td>
<td width="30%" align=center>名称</td>
<td width="30%" align=center>图片包路径(请以“/”结束)</td>
<td width="20%" align=center>操作</td>
<td width="10%" align=center>删除</td>
</tr>
<tr><td height=1 class="tableBorder1" colspan=5></td></tr>
<%
For k=0 To Ubound(CssName)
%>
<tr Name="CssTR" id="CssTR">
<td class="tdbg" align=center><%=k%></td>
<td class="tdbg" align=center><input type=text value="<%=CssName(k)%>" name="CssName"></td>
<td class="tdbg" align=center>
<%
Response.Write "<input name=""CssPicUrl"" size=30 type=text value="""
if CssPicUrl(k)="" and k<>Ubound(CssName) Then Response.Write "Skins/Default/" Else Response.Write CssPicUrl(k)
Response.Write """>"
%>
</td>
<td class="tdbg" align=center>
<input type="button" value="修改Css内容" name="CssEdit" onclick="EditCss(<%=k%>)">
<div style="display:none">
<textarea name="CssBody" id="CssBody" style="width:0;height=0" rows="0" ><%=CssContent(k)%></textarea>
</div>
</td>
<td class="tdbg" align=center><INPUT TYPE="checkbox" NAME="DelCss" onclick="DllData(<%=k%>)"></td>
</tr>
<%
Next
%>
<tr id="EditTextarea" style="display:none">
<INPUT TYPE="hidden" NAME="TempID">
<td height=400 class="tdbg" colspan=5>
<textarea id="CssContent" style="width:100%" rows="30" ></textarea>
<br />
<a href="javascript:admin_Size(-5,'CssContent')"><img src="images/minus.gif" unselectable="on" border="0"></a> <a href="javascript:admin_Size(5,'CssContent')"><img src="images/plus.gif" unselectable="on" border="0"></a>
</td>
</tr>
<%
Response.Write "<tr><td class=tdbg height=""25"" align=""center"" colspan=5>"
Response.Write "<input type=""submit"" name=""B1"" value=""提 交"">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"
Response.Write "<input type=""button"" value=""返 回"" onclick=""location.reload('admin_Template.asp?action=editcss')"">"
Response.Write "</td></tr>"
%>
</form></table>
<%
End Sub

'//保存修改CSS模板
Sub savecss()
	Dim TempStr,LockID
	Dim TempStr1,TempStr2,TempStr3
	Dim CssName,CssContent,CssPicUrl,TempCssStyle
	Dim strCssName,strCssContent,strCssPicUrl,MakeCssData
	LockID=1

	'提取CSS风格名的数据
	For Each TempStr in Request.Form("CssName")
		If TempStr<>"" Then 
			CssName=CssName&Replace(TempStr,"|||","")&"|||"
		End If
	Next
	'提取图片包的数据
	For Each TempStr in Request.Form("CssPicUrl")
		If TempStr<>"" Then 
			CssPicUrl=CssPicUrl&Replace(TempStr,"|||","")&"|||"
		End If
	Next
	'提取风格内容的数据
	For Each TempStr in Request.Form("CssBody")
		If TempStr<>"" Then 
			CssContent=CssContent&Replace(TempStr,"|||","")&"|||"
		End If
	Next
	CssName=Replace(CssName,"@@@","")
	CssContent=Replace(CssContent,"@@@","")
	CssPicUrl=Replace(CssPicUrl,"@@@","")
	strCssName=Split(CssName,"|||")
	strCssContent=Split(CssContent,"|||")
	strCssPicUrl=Split(CssPicUrl,"|||")
	TempStr1=ubound(strCssName)
	TempStr2=ubound(strCssContent)
	TempStr3=ubound(strCssPicUrl)

	If TempStr1<>TempStr2 or TempStr1<>TempStr3 or TempStr2<>TempStr3 Then
		Errmsg=ErrMsg + "<br /><li>图片路径或Css内容不能为空,若要删除Css风格请选取删除选项 !"
		Admin_ShowErr(ErrMsg)
		Exit Sub 
	End If

	TempCssStyle = CssName &"@@@"& CssContent &"@@@"& CssPicUrl
	TempCssStyle = Cl.checkStr(TempCssStyle)
	if Clng(Cl.CacheData(4,0)) > TempStr3 then
		Cl.Execute("Update Cl_Setup set Web_CssID=0,Web_CSS='"&TempCssStyle&"'")
		Cl.Execute("Update Cl_Channel set CssID=0 where CssID > "&TempStr3&"")
	else
		Cl.Execute("Update Cl_Setup set Web_CSS='"&TempCssStyle&"'")
		Cl.Execute("Update Cl_Channel set CssID="&Clng(Cl.CacheData(4,0))&" where CssID > "&TempStr3&"")
	end if
	Cl.DelCahe("Setup")'删除模板缓存
	Cl.DelCahe("Channel")
	for i=0 to TempStr2-1
		MakeCssData="/*==========CSS名称："&strCssName(i)&"==========*/"
		MakeCssData=MakeCssData & vbNewline & strCssContent(i)
		MakeCssData=Replace(MakeCssData,"{%picurl%}",Cl.WebDir&strCssPicUrl(i))
		MakeCssData=Replace(MakeCssData,"{%webdir%}",Cl.WebDir)
		MakeCssData="/*--Powered by:"& Cl.Web_Version(1) & " " &_
				"CreateDate:"&Now&"--*/" & VbNewLine & MakeCssData & vbNewLine & "/*--Copyright 2006 Aspoo.CN " &_
				".All Rights Reserved--*/"
		MakeCss MakeCssData,Cl.WebDir&"Skins/Css/Css"&i&".Css"
	next
	Cl.SaveAdminLog
	Response.Write Cl.ShowSuc("Css样式修改成功！ <a href='admin_Template.asp?StyleID="&StyleID&"'><< <b>返回模板首页</b></a>")
End Sub

Sub editmain()
	Dim stype,NowEditinfo
	Dim mystr
	stype=Request("stype")
	
	Select Case stype
		Case "1"
			NowEditinfo="语言包"
			mystr="Cl.lanstr"
		Case "2"
			NowEditinfo="基本设置"
			mystr="mainsetting"
		Case "3"
			NowEditinfo="页面顶部表格"
			mystr="mainhtml(1)"
		Case "4"
			NowEditinfo="页面底部表格"
			mystr="mainhtml(3)"
		Case Else
			Errmsg=ErrMsg + "<br /><li>您提交了错误的参数."
			Admin_ShowErr(ErrMsg)	
	End Select
	Set Rs=Cl.Execute("Select Main_Style ,StyleName From Cl_Style Where ID="&StyleID&"")
	Dim TemplateStr
	TemplateStr=Split(server.htmlencode(Rs(0)),"@@@")
	Response.Write "<table width=""100%"" border=""0"" cellspacing=""1"" cellpadding=""0"" align=center class=""border"">"
	Response.Write "<form action=""?action=savemain&stype="&stype&"&StyleID="&StyleID&""" method=post>"
	Response.Write "<tr>"
	Response.Write "<td width=""100%"" class=""title"" align=center colspan=2 height=25>"
	Response.Write Rs(1)
	Response.Write NowEditinfo
	Response.Write "("&mystr&")设置</td></tr>"
	Select Case stype
		Case "1"
			TemplateStr(0)=split(TemplateStr(0),"|||")
			For i=0 to UBound(TemplateStr(0))
				Response.Write "<tr class=tdbg><td height=40 align=""left"" colspan=2>"
				Response.Write mystr&"("&i&")&nbsp;&nbsp;&nbsp;"		
				Response.Write "<input type=text name=""TemplateStr"" value="""&TemplateStr(0)(i)&""" Size=100>"
				Response.Write "</td></tr>"
			Next	
		Case "2"		
			TemplateStr(0)=split(TemplateStr(0),"|||")
			TemplateStr(0)(0)=split(TemplateStr(0)(0),"||")
			Response.Write "<tr class=tdbg><td height=40 align=""center"" colspan=2>"
			Response.Write "<table cellspacing=""1"" cellpadding=""0"" border=""0"" align=""left"" width=""100%""  class=border>"
			Response.Write "<tr class=tdbg>" & _
							"<td width=""300"" align=""right"" >页面基本表格宽度：</td>" & _
							"<td align=""left"" colspan=""3"">" & _
							"<input type=""text"" size=""5"" name=""TemplateStr"" value="""&TemplateStr(0)(0)(0)&""">&nbsp;"&mystr&"(0)" & _
							"</td>" & _
							"</tr>"
			Response.Write "<tr class=tdbg>" & _
							"<td width=""300"" align=""right"" >模版默认CSS风格：</td>" & _
							"<td align=""left"" colspan=""3"">"
			Response.Write "<select name=""TemplateStr"">"
			Dim strTempCss,strCssName
			strTempCss=Split(Cl.CacheData(15,0),"@@@")(0)
			strCssName=Split(strTempCss,"|||")
			for i=0 to ubound(strCssName)-1
				response.write "<option value="""&i&""""
				If i=Cl.ChkClng(TemplateStr(0)(0)(1)) Then response.write " selected"
				response.write ">"&strCssName(i)&"</option>"
			next
			Response.Write "</select>&nbsp;"&mystr&"(1)"
			Response.Write "</td></tr>"
			Dim j,vtitle
			vtitle="0|1|用户名称字体颜色：|用户"&Cl.Web_Setting(28)&"颜色(大于10)：|用户"&Cl.Web_Setting(28)&"颜色(小于10)：|用户剩余天数颜色(大于10)：|用户剩余天数颜色(小于10)：|用户"&Cl.Web_Setting(26)&"颜色(大于10)：|用户"&Cl.Web_Setting(26)&"颜色(小于10)：|短信息颜色(有)：|短信息颜色(无)：|栏目导航字体颜色：|栏目导航字体颜色(指向)："
			vtitle=split(vtitle,"|")
			For j=2 to 12
				'Response.Write "<tr>"
				'Response.Write "<td height=""1"" colspan=""4"" bgcolor=""#6595D6""><td>"
				'Response.Write "</tr>"
				Response.Write "<tr class=tdbg>"
				Response.Write "<td height=""25"" width=""300"" align=""right"" >"&vtitle(j)&"</td>"
				Response.Write "<td width=""20"" bgcolor="""&TemplateStr(0)(0)(j)&"""></td>"
				Response.Write "<td width=""200"" align=""left"">"
				Response.Write "<input type=""text"" size=""10"" value="""&TemplateStr(0)(0)(j)&""" name=""TemplateStr"">"&mystr&"("&j&")"
				Response.Write "</td>"
				Response.Write "<td></td>"
				Response.Write "</tr>"
			Next
			Response.Write "</table>"		
			Response.Write "</td></tr>"
			
		Case "3"
			TemplateStr(2)=split(TemplateStr(2),"|||")
			Response.Write "<tr class=tdbg><td height=40 align=""center"" colspan=2>"
			Response.Write "<textarea name=""TemplateStr"" cols=""130"" rows=""15"">"	
			Response.Write TemplateStr(2)(0)
			Response.Write "</textarea>"
			Response.Write "</td></tr>"
		Case "4"
			TemplateStr(2)=split(TemplateStr(2),"|||")
			Response.Write "<tr class=tdbg><td height=40 align=""center"" colspan=2>"
			Response.Write "<textarea name=""TemplateStr"" cols=""130"" rows=""15"">"	
			Response.Write TemplateStr(2)(2)
			Response.Write "</textarea>"
			Response.Write "</td></tr>"
		Case Else
	End Select
	Response.Write "<tr class=tdbg><td align=""center"" colspan=2>"
	Response.Write "<input type=""reset"" name=""Submit"" value=""重 填"">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"
	Response.Write "<input type=""submit"" name=""B1"" value=""修 改"">"
	Response.Write "</form>"
	Response.Write "</table>"
	Set Rs=Nothing 
End Sub

Sub savemain()
	Dim stype,NowEditinfo,TemplateStr,tempstr,Main_Style
	stype=Request("stype")
	TemplateStr=""
	Set Rs=Cl.Execute("Select Main_Style From Cl_Style Where ID="&StyleID&"")
	Main_Style=Rs(0)
	Set rs=Nothing 
	Main_Style=split(Main_Style,"@@@")
	Select Case stype
		Case "1"
			NowEditinfo="语言包"
			For Each TempStr in Request.form("TemplateStr")
				If TempStr<>"" Then 
					TemplateStr=TemplateStr&TempStr&"|||"
				End If
			Next 
			TemplateStr=TemplateStr&"@@@"&Main_Style(1)&"@@@"&Main_Style(2)&"@@@"&Main_Style(3)
			Exit Sub 
		Case "2"
			NowEditinfo="基本设置"
			For Each TempStr in Request.form("TemplateStr")
				If TempStr<>"" Then
					TemplateStr=TemplateStr&TempStr&"||"
				Else
					TemplateStr=TemplateStr&Chr(1)&"||"
				End If
			Next	
			TemplateStr=Left(TemplateStr,Len(TemplateStr)-2)
			Main_Style(0)=split(Main_Style(0),"|||")
			Dim i
			For i=1 to UBound(Main_Style(0))
				TemplateStr=TemplateStr&"|||"&Main_Style(0)(i)
			Next		
			TemplateStr=TemplateStr&"@@@"&Main_Style(1)&"@@@"&Main_Style(2)'&"@@@"&Main_Style(3)
		Case "3"
			NowEditinfo="HTTP头部分"
			TemplateStr=Request.form("TemplateStr")
			Main_Style(2)=split(Main_Style(2),"|||")
			TemplateStr=Main_Style(0)&"@@@"&Main_Style(1)&"@@@"&TemplateStr&"|||"&Main_Style(2)(1)&"|||"&Main_Style(2)(2)&"|||"&Main_Style(2)(3)&"|||"&Main_Style(2)(4)&"|||"&Main_Style(2)(5)&"|||"&Main_Style(2)(6)&"@@@"&Main_Style(3)
			Exit Sub 
		Case "4"
			NowEditinfo="页面结束部分"
			TemplateStr=Request.form("TemplateStr")
			Main_Style(2)=split(Main_Style(2),"|||")
			TemplateStr=Main_Style(0)&"@@@"&Main_Style(1)&"@@@"&Main_Style(2)(0)&"|||"&Main_Style(2)(1)&"|||"&TemplateStr&"|||"&Main_Style(2)(3)&"|||"&Main_Style(2)(4)&"|||"&Main_Style(2)(5)&"|||"&Main_Style(2)(6)&"@@@"&Main_Style(3)
			Exit Sub 
		Case Else
			Errmsg=ErrMsg + "<br /><li>您提交了错误的参数."
			Admin_ShowErr(ErrMsg)	
	End Select
	TemplateStr=Cl.checkStr(TemplateStr)
	Cl.Execute("Update Cl_Style set Main_Style='"&TemplateStr&"' Where ID="&StyleID&"")
	Cl.DelCahe("Main_Style"&StyleID)
	Cl.SaveAdminLog
	Response.Write Cl.ShowSuc("主模板"&NowEditinfo&"修改成功! <a href='admin_Template.asp?StyleID="&StyleID&"'><< <b>返回模板首页</b></a>")
End Sub

Sub ghost()
	Dim oldStyleID,newStyleID,oldStyleName,newStyleName
	oldStyleID	= Cl.ChkClng(Request("oldStyleID"))
	newStyleID	= Cl.ChkClng(Request("newStyleID"))
	oldStyleName= Cl.ChkClng(Request("oldStyleName"))
	newStyleName= Cl.ChkClng(Request("newStyleName"))
	If newStyleID=0 Or oldStyleID=0 Then
		Admin_ShowErr("<br /><li>参数错误。")
		Exit Sub
	End If
	if oldStyleName > 1 or newStyleName > 1 then
		if oldStyleName=0 then oldStyleName=newStyleName
		if newStyleName=0 then newStyleName=oldStyleName
	else
		If newStyleID =	oldStyleID Then
			Admin_ShowErr("<br /><li>目标模板和源模板不能相同。")
			Exit Sub
		End If
	end if
	Set Rs=Cl.Execute("select * From Cl_Style where ID="&oldStyleID&"")
	If Rs.EOF Or Rs.BOF Then
		Admin_ShowErr("<br /><li>无法取出源模版数据")
		Exit Sub
	End If
	Cl.SaveAdminLog
	If oldStyleName<1 Then
		Dim SQLSTR
		For i= 2 to Rs.Fields.Count-1
			SQLSTR=SQLSTR&Rs(i).Name&"='"&Cl.checkStr(Rs(i))&"'"
			If i<> Rs.Fields.Count-1 Then 
				SQLSTR=SQLSTR&","
			End If
		Next 
		Cl.Execute("Update Cl_Style set "&SQLSTR&" where ID="&newStyleID&" ")
		Cl.DelCahe("head" & newStyleID)
		Cl.DelCahe("StyleName" & newStyleID)
		Cl.DelCahe("Main_Style" & newStyleID)
		Response.Write Cl.ShowSuc("模板克隆成功! <a href='admin_Template.asp?StyleID="&StyleID&"'><< <b>返回模板首页</b></a>")
	Else
		Cl.Execute("Update Cl_Style set "&Rs(newStyleName).Name&"='"&Cl.checkStr(Rs(oldStyleName))&"' where ID="&newStyleID&" ")
		Cl.DelCahe("module_" & Rs(newStyleName).Name & newStyleID)
	    Response.Write Cl.ShowSuc("克隆模板"&Rs(newStyleName).Name&"成功! <a href='admin_Template.asp?StyleID="&StyleID&"'><< <b>返回模板首页</b></a>")
	End If
End Sub 

Sub delmodule()
	Dim moduleName
	moduleName=Cl.checkStr(request("moduleName"))
	If moduleName="" Then 
		Errmsg=ErrMsg + "<br /><li>请填写字段名称"
		Admin_ShowErr(ErrMsg)
	End If
	If Not IsTruemodule(moduleName) Then 
		Errmsg=ErrMsg + "<br /><li>要删除的字段不存在。"
		Admin_ShowErr(ErrMsg)
	End If
	Cl.Execute("Alter Table [Cl_Style] Drop ["&moduleName&"]")
	Cl.Execute("Alter Table [Cl_Stylehelp] Drop ["&moduleName&"]")
	Cl.SaveAdminLog
	Response.Write Cl.ShowSuc("页面模板删除成功！ <a href='admin_Template.asp?StyleID="&StyleID&"'><< <b>返回模板首页</b></a>")
End Sub

Sub MakeCss(MakeData,MakeFileName)
	Err=0
	Dim Fso,Make
	On Error Resume Next
	Set Fso = CreateObject(Trim(Cl.Web_Info(13)))
		Set Make = Fso.CreateTextFile(Server.MapPath(MakeFileName), True)
		Make.Write MakeData
		Set Make = Nothing
	Set Fso = Nothing
	Err=0
End Sub

'<!--
'┌───────────────────────────────────────────────────────┐
'│														 │
'│		CreateLive CMS Version 3.1						 │
'│　　　　　　　　				Powered by Aspoo.CN	 	 │
'│　		　　　　　　　　　　						 │
'│　	邮箱: aspoo@126.com			Info@aspoo.cn　　	 │
'│		ＱＱ: 3315263				596197794			 │
'│		网站: www.aspoo.cn			www.aspoo.com		 │
'│		论坛: bbs.aspoo.cn			bbs.aspoo.com		 │
'│														 │
'│	Copyright (C) 2005 Aspoo.CN All Rights Reserved.	 │
'└───────────────────────────────────────────────────────┘
'-->
%>
