 <!-- #include file="../conn.asp" -->
<!-- #include file="../cls_main.asp" -->
<% MyDbPath = "../"
dim obj
set obj = New admin_template
	call obj.AspInit()
set obj = nothing

Class admin_template

	Private StyleConn, ishion
	Private Sub Class_Initialize()
		Set ishion = New Cls_Main
	End Sub
	Private Sub Class_Terminate()
		Set ishion = Nothing
	End Sub
	Public Sub AspInit()
		Response.Write "<HTML>" & vbCrLf
		Response.Write "<HEAD>" & vbCrLf
		Response.Write "<TITLE>下载管理</TITLE>" & vbCrLf
		Response.Write "<META http-equiv=Content-Type content=""text/html; charset=gb2312"">" & vbCrLf
		Response.Write "<LINK href=""admin.css"" type=text/css rel=stylesheet>" & vbCrLf
		Response.Write "</HEAD>" & vbCrLf
		Response.Write "<BODY leftmargin=""3"" topmargin=""0"">" & vbCrLf
			
			If ishion.adminName = "" Then
				ishion.strMsg = "<li>非法操作：登录超时或你没有以管理员身份登录系统，<a href=""../admin_login.asp"" target=_top>点此进入管理员登录界面</a>。"
				Call ishion.SystemMsg
			ElseIf myPermission() = False Then
				ishion.strMsg = "<li>非法操作：你没有权限进行此项操作，请联系管理员！"
				Call ishion.SystemMsg
			Else
				Call Main
			End If
		Response.Write "</BODY>" & vbCrLf
		Response.Write "</HTML>" & vbCrLf
		
	End Sub
	Function myPermission()
		myPermission = False
		If ishion.checkPermission(ishion.adminName, "11") Then myPermission = True: Exit Function
		If ishion.checkPermission(ishion.adminName, "59") Then myPermission = True: Exit Function
		'If ishion.checkPermission(ishion.adminName,"10") Then myPermission = False
	End Function

	Sub Main()
		Response.Write "<table width=""100%""  border=""0"" cellpadding=""3"" cellspacing=""1"" class=""b1"">" & vbCrLf
		Response.Write "  <tr>" & vbCrLf
		Response.Write "    <td class=""tdbg4"">网站模板管理操作：<A href=""admin_template.asp"">模板管理首页</A> | <a href=""?action=addTemplate"">添加新模板</a> | <a href=""?action=input"">导入模板</a></td>" & vbCrLf
		Response.Write "  </tr>" & vbCrLf
		Response.Write "</table>" & vbCrLf
		Response.Write "<table width=""100%"" height=""3""  border=""0"" cellpadding=""0"" cellspacing=""0"">" & vbCrLf
		Response.Write "  <tr>" & vbCrLf
		Response.Write "    <td></td>" & vbCrLf
		Response.Write "  </tr>" & vbCrLf
		Response.Write "</table>" & vbCrLf
	
		Select Case Trim(Request("action"))
		Case "addTemplate"
			Call addTemplate
		Case "copy"
			Call edit
		Case "edit"
			Call edit
		Case "savecopy"
			Call SaveAdd
		Case "saveedit"
			Call saveedit
		Case "saveadd"
			Call SaveAdd
		Case "edithtml"
			Call editHtml
		Case "saveedithtml"
			Call saveedithtml
		Case "webeditor"
			Call WebEditor
		Case "savewebeditor"
			Call savewebeditor
		Case "isDefault"
			Call isDefault
		Case "del"
			Call del
		Case "output"
			Call Output
		Case "saveinput"
			Call SaveInput
		Case "input"
			Call aInput
		Case "SelectInput"
			Call SelectInput
		Case Else
			Call Reslist
		End Select
	End Sub
	
	Sub Output()
		Dim StyleMdb, StyleID
		If Request.Form("StyleMDB") = "" Then
			ishion.strMsg = "请填写导出的数据库文件名。"
			Call ishion.SystemMsg
			Exit Sub
		Else
			StyleMdb = ishion.checkStr(Request.Form("StyleMDB"))
		End If
		If Request.Form("StyleID") = "" Then
			ishion.strMsg = "请选择要导出的模板。"
			Call ishion.SystemMsg
			Exit Sub
		Else
			StyleID = ishion.checkStr(Request.Form("StyleID"))
		End If
		'On Error Resume Next
		Set StyleConn = Server.CreateObject("ADODB.Connection")
		StyleConn.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(StyleMdb)
		If Err.Number = "-2147467259" Then
			ishion.strMsg = "<li>" & StyleName & "数据库不存在。"
			Call ishion.SystemMsg
			StyleConn.Close
			Set StyleConn = Nothing
			Exit Sub
		End If
		If IsFoundTable("ishion_Style", 1) = False Then
			ishion.strMsg = "<li>" & StyleName & "数据库中找不到指定的数据表。"
			Call ishion.SystemMsg
			StyleConn.Close
			Set StyleConn = Nothing
			Exit Sub
		End If
		
		
		Dim Rs, i
		Set Rs = ishion.Execute("select * from ishion_Style where StyleID in (" & StyleID & ") order by StyleID ")
		If Rs.EOF Or Rs.BOF Then
			ishion.strMsg = "<li>无法取出源模版数据"
			Call ishion.SystemMsg
			StyleConn.Close
			Set StyleConn = Nothing
			Set Rs = Nothing
			Exit Sub
		End If
		
		Dim InsertName, InsertValue
		Do While Not Rs.EOF
		InsertName = ""
		InsertValue = ""
		For i = 1 To Rs.Fields.Count - 1
			InsertName = InsertName & Rs(i).Name
			InsertValue = InsertValue & "'" & ishion.checkStr(Rs(i)) & "'"
			If i <> Rs.Fields.Count - 1 Then
				InsertName = InsertName & ","
				InsertValue = InsertValue & ","
			End If
		Next
		StyleConn.Execute ("insert into [ishion_Style] (" & InsertName & ") values (" & InsertValue & ") ")
		'StyleConn.Execute("Update [Dv_Style] set " & SQLSTR & " where ID=" & SkinMdbID)
		Rs.MoveNext
		Loop
		Rs.Close
		Set Rs = Nothing
		ishion.strMsg = "<li>数据导出成功！"
		Call ishion.SystemMsg
		
	End Sub
	Sub SaveInput()
		Dim StyleMdb, StyleID
		If Request.Form("StyleMDB") = "" Then
			ishion.strMsg = "请填写导出的数据库文件名。"
			Call ishion.SystemMsg
			Exit Sub
		Else
			StyleMdb = ishion.checkStr(Request.Form("StyleMDB"))
		End If
		If Request.Form("StyleID") = "" Then
			ishion.strMsg = "请选择要导出的模板。"
			Call ishion.SystemMsg
			Exit Sub
		Else
			StyleID = ishion.checkStr(Request.Form("StyleID"))
		End If
		'On Error Resume Next
		Set StyleConn = Server.CreateObject("ADODB.Connection")
		StyleConn.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(StyleMdb)
		If Err.Number = "-2147467259" Then
			ishion.strMsg = "<li>" & StyleName & "数据库不存在。"
			Call ishion.SystemMsg
			StyleConn.Close
			Set StyleConn = Nothing
			Exit Sub
		End If
		If IsFoundTable("ishion_Style", 1) = False Then
			ishion.strMsg = "<li>" & StyleName & "数据库中找不到指定的数据表。"
			Call ishion.SystemMsg
			StyleConn.Close
			Set StyleConn = Nothing
			Exit Sub
		End If
		
		
		Dim Rs, i
		Set Rs = StyleConn.Execute("select * from ishion_Style where StyleID in (" & StyleID & ") order by StyleID ")
		If Rs.EOF Or Rs.BOF Then
			ishion.strMsg = "<li>无法取出源模版数据"
			Call ishion.SystemMsg
			StyleConn.Close
			Set StyleConn = Nothing
			Set Rs = Nothing
			Exit Sub
		End If
		
		Dim InsertName, InsertValue
		Do While Not Rs.EOF
		InsertName = ""
		InsertValue = ""
		For i = 1 To Rs.Fields.Count - 1
			InsertName = InsertName & Rs(i).Name
			InsertValue = InsertValue & "'" & ishion.checkStr(Rs(i)) & "'"
			If i <> Rs.Fields.Count - 1 Then
				InsertName = InsertName & ","
				InsertValue = InsertValue & ","
			End If
		Next
		ishion.Execute ("insert into [ishion_Style] (" & InsertName & ") values (" & InsertValue & ") ")
		'StyleConn.Execute("Update [Dv_Style] set " & SQLSTR & " where ID=" & SkinMdbID)
		Rs.MoveNext
		Loop
		Rs.Close
		Set Rs = Nothing
		ishion.strMsg = "<li>数据导入成功！"
		Call ishion.SystemMsg
		
	End Sub
	'校验表名是否存在。TableName=表名，str:0=默认库，1=风格库
	Function IsFoundTable(TableName, str)
		Dim ChkRs
		IsFoundTable = False
		If TableName <> "" Then
		TableName = LCase(Trim(TableName))
			If str = 0 Then
			Set ChkRs = Conn.openSchema(20)
			Else
			Set ChkRs = StyleConn.openSchema(20)
			End If
			Do Until ChkRs.EOF
				If ChkRs("TABLE_TYPE") = "TABLE" Then
					If LCase(ChkRs("TABLE_NAME")) = TableName Then
						IsFoundTable = True
						Exit Function
					End If
				End If
			ChkRs.MoveNext
			Loop
			ChkRs.Close: Set ChkRs = Nothing
		End If
	End Function
	
	Sub isDefault()
		ishion.Execute ("update ishion_Style set isDefault=0")
		ishion.Execute ("update ishion_Style set isDefault=1 where StyleID=" & CLng(Request("StyleID")))
		Call ishion.ReloadTemplates
		Response.Redirect ishion.RefererPage
	End Sub
	Sub del()
		If Trim(Request.QueryString("StyleID")) <> "" Then
			ishion.Execute ("delete from ishion_Style where isDefault=0 and StyleID=" & CLng(Request.QueryString("StyleID")))
		End If
		Response.Redirect ishion.RefererPage
	End Sub
	Sub saveedithtml()
		Dim tempStr, TemplateStr
		tempStr = ""
		TemplateStr = ""
	
		For Each tempStr In Request.Form("content")
			If TemplateStr = "" Then
				TemplateStr = Replace(tempStr, "<!--|||-->", "")
			Else
				If LCase(Trim(tempStr)) <> "end" Then
					TemplateStr = TemplateStr & "<!--|||-->" & Replace(tempStr, "<!--|||-->", "")
				End If
			End If
		Next
			
		If Trim(TemplateStr) = "" Then
			TemplateStr = "<!--|||--><!--|||--><!--|||--><!--|||--><!--|||--><!--|||--><!--|||--><!--|||--><!--|||--><!--|||--><!--|||--><!--|||--><!--|||-->"
		End If
		If Trim(Request.Form("Page")) = "Style_Down_Main" Then
			TemplateStr = Replace(TemplateStr, "{$down_menu}", Down_Menu())
			TemplateStr = Replace(TemplateStr, "{$eng_abc}", Down_Abc(ishion.Setting(78)))
			TemplateStr = Replace(TemplateStr, "{$chs_abc}", Down_Abc(ishion.Setting(79)))
		End If
		If Trim(Request.Form("Page")) = "Style_Cms_Main" Then
			TemplateStr = Replace(TemplateStr, "{$cms_menu}", Cms_Menu())
		End If
		Dim Rs, sql
		If Not IsObject(Conn) Then Call ConnectionDatabase
		Set Rs = Server.CreateObject("adodb.recordset")
		sql = "select " & Trim(Request.Form("Page")) & " from ishion_Style Where StyleID=" & CLng(Request.Form("StyleID"))
		Rs.open sql, Conn, 1, 3
		Rs(Trim(Request.Form("Page"))) = TemplateStr
		Rs.Update
		Rs.Close
		Set Rs = Nothing
		
		'ishion.Execute("update [ishion_Style] set " & Trim(Request.Form("Page")) & "='" & TemplateStr & "' Where StyleID=" & clng(Request.Form("StyleID")))
		Call ishion.ReloadTemplates
		ishion.strMsg = "<li>SaveEditHtml，保存模板操作完成！<li><a href=""?StyleID=" & Request.Form("StyleID") & """>点此返回模板管理首页</a></li>"
		Call ishion.SystemMsg
		TemplateStr = Null
	End Sub
	
	Sub savewebeditor()
		Dim Rs, sql, i, sContent
		For i = 1 To Request("content1").Count
			sContent = sContent & Request("content1")(i)
		Next
		If Trim(Request.Form("Page")) = "Style_Down_Main" Then
			sContent = Replace(sContent, "{$down_menu}", Down_Menu())
			sContent = Replace(sContent, "{$eng_abc}", Down_Abc(ishion.Setting(78)))
			sContent = Replace(sContent, "{$chs_abc}", Down_Abc(ishion.Setting(79)))
		End If
		If Trim(Request.Form("Page")) = "Style_Cms_Main" Then
			sContent = Replace(sContent, "{$down_menu}", Cms_Menu())
		End If
		If Not IsObject(Conn) Then Call ConnectionDatabase
		Set Rs = Server.CreateObject("adodb.recordset")
		sql = "select " & Trim(Request.Form("Page")) & " from ishion_Style Where StyleID=" & CLng(Request.Form("StyleID"))
		Rs.open sql, Conn, 1, 3
		Rs("" & Trim(Request.Form("Page")) & "") = sContent
		Rs.Update
		Rs.Close
		Set Rs = Nothing
		
		'ishion.Execute("update [ishion_Style] set " & Trim(Request.Form("Page")) & "='" & sContent & "' Where StyleID=" & clng(Request.Form("StyleID")))
		Call ishion.ReloadTemplates
		ishion.strMsg = "<li>保存模板操作完成！<li><a href=""?StyleID=" & Request.Form("StyleID") & """>点此返回模板管理首页</a></li>"
		Call ishion.SystemMsg
		sContent = Null
	End Sub
	
	Sub SaveAdd()
		Response.Write "SaveAdd"
		Dim Rs, sql, sContent
		If Not IsObject(Conn) then Call ConnectionDatabase
		Set Rs = Server.CreateObject("adodb.recordset")
		sql = "select * from ishion_Style where (StyleID is null)"
		Rs.open sql, Conn, 1, 3
		Rs.AddNew
		sContent = Replace(Request.Form("Style_Down_Main"), "{$down_menu}", Down_Menu())
		sContent = Replace(sContent, "{$cms_menu}", Cms_Menu())
		sContent = Replace(sContent, "{$eng_abc}", Down_Abc(ishion.Setting(78)))
		sContent = Replace(sContent, "{$chs_abc}", Down_Abc(ishion.Setting(79)))
		Rs("StyleName") = Request.Form("StyleName")
		Rs("Style_Down_Main") = sContent
		Rs("Style_Down_List") = Request.Form("Style_Down_List")
		Rs("Style_Down_Info") = Request.Form("Style_Down_Info")
		Rs("Style_Down_Catalog") = Request.Form("Style_Down_Catalog")
		Rs("Style_Down_New") = Request.Form("Style_Down_New")
		Rs("Style_Down_Top") = Request.Form("Style_Down_Top")
		Rs("Style_Down_Search") = Request.Form("Style_Down_Search")
		Rs("Style_Down_abc") = Request.Form("Style_Down_abc")
		Rs("Style_Down_Comment") = Request.Form("Style_Down_Comment")
		Rs("Style_Cms_Main") = Request.Form("Style_Cms_Main")
		Rs("Style_Cms_List") = Request.Form("Style_Cms_List")
		Rs("Style_Cms_Info") = Request.Form("Style_Cms_Info")
		Rs("Style_Cms_Catalog") = Request.Form("Style_Cms_Catalog")
		Rs("Style_Cms_Search") = Request.Form("Style_Cms_Search")
		Rs("Style_Cms_Comment") = Request.Form("Style_Cms_Comment")
		Rs("DateAndTime") = Now()
		Rs("isDefault") = 0
		Rs.Update
		Rs.Close
		Set Rs = Nothing
		
		ishion.strMsg = "<li>保存模板操作完成！<li><a href=""?action=1"">点此返回模板管理首页</a></li>"
		Call ishion.SystemMsg
	End Sub
	
	Sub saveedit()
		Dim Rs, sql, sContent
		If Not IsObject(Conn) Then Call ConnectionDatabase
		Set Rs = Server.CreateObject("adodb.recordset")
		sql = "select * from ishion_Style where StyleID=" & CLng(Request.Form("StyleID"))
		Rs.open sql, Conn, 1, 3
		sContent = Replace(Request.Form("Style_Down_Main"), "{$down_menu}", Down_Menu())
		sContent = Replace(sContent, "{$cms_menu}", Cms_Menu())
		sContent = Replace(sContent, "{$eng_abc}", Down_Abc(ishion.Setting(78)))
		sContent = Replace(sContent, "{$chs_abc}", Down_Abc(ishion.Setting(79)))
		Rs("StyleName") = Request.Form("StyleName")
		Rs("Style_Down_Main") = sContent
		Rs("Style_Down_List") = Request.Form("Style_Down_List")
		Rs("Style_Down_Info") = Request.Form("Style_Down_Info")
		Rs("Style_Down_Catalog") = Request.Form("Style_Down_Catalog")
		Rs("Style_Down_New") = Request.Form("Style_Down_New")
		Rs("Style_Down_Top") = Request.Form("Style_Down_Top")
		Rs("Style_Down_Search") = Request.Form("Style_Down_Search")
		Rs("Style_Down_abc") = Request.Form("Style_Down_abc")
		Rs("Style_Down_Comment") = Request.Form("Style_Down_Comment")
		Rs("Style_Cms_Main") = Request.Form("Style_Cms_Main")
		Rs("Style_Cms_List") = Request.Form("Style_Cms_List")
		Rs("Style_Cms_Info") = Request.Form("Style_Cms_Info")
		Rs("Style_Cms_Catalog") = Request.Form("Style_Cms_Catalog")
		Rs("Style_Cms_Search") = Request.Form("Style_Cms_Search")
		Rs("Style_Cms_Comment") = Request.Form("Style_Cms_Comment")
		Rs.Update
		Rs.Close
		Set Rs = Nothing
		Call ishion.ReloadTemplates
		ishion.strMsg = "<li>保存模板操作完成！<li><a href=""?StyleID=" & Request.Form("StyleID") & """>点此返回模板管理首页</a></li>"
		Call ishion.SystemMsg
	End Sub
	
	Sub aInput()
		Response.Write "<table width=""100%"" border=""0"" align=""center"" cellpadding=""3"" cellspacing=""1"" class=""b1"">" & vbCrLf
		Response.Write "  <tr class=""tdbg2"">" & vbCrLf
		Response.Write "    <td align=""center""><b>导入模版数据<b></td>" & vbCrLf
		Response.Write "  </tr>" & vbCrLf
		Response.Write "<form action=""admin_template.asp"" method=""post"" name=""addTemplate"">" & vbCrLf
		Response.Write "<input type=""hidden"" Name=""action"" value=""SelectInput"">"
		Response.Write "  <tr class=""tdbg2"">" & vbCrLf
		Response.Write "    <td align=""center"">导入模版数据库名：<input type=""text"" name=""StyleMDB"" size=""30"" value=""Style/Style.mdb""></td>" & vbCrLf
		Response.Write "  </tr>" & vbCrLf
		Response.Write "  <tr class=""tdbg2"">" & vbCrLf
		Response.Write "    <td align=""center""><input type=""submit"" name=""submit"" value="" 下一步 ""></td>" & vbCrLf
		Response.Write "  </tr>" & vbCrLf
		Response.Write "</form>" & vbCrLf
		Response.Write "</table>" & vbCrLf
	
	End Sub
	Sub SelectInput()
		Dim Rs, i
		Dim StyleMdb, StyleID
		If Request.Form("StyleMDB") = "" Then
			ishion.strMsg = "请填写导出的数据库文件名。"
			Call ishion.SystemMsg
			Exit Sub
		Else
			StyleMdb = ishion.checkStr(Request.Form("StyleMDB"))
		End If
		Response.Write "<script language=""JavaScript"">" & vbCrLf
		Response.Write "<!--" & vbCrLf
		Response.Write "function CheckAll(form)  {" & vbCrLf
		Response.Write "  for (var i=0;i<form.elements.length;i++)    {" & vbCrLf
		Response.Write "    var e = form.elements[i];" & vbCrLf
		Response.Write "    if (e.name != 'chkall'){" & vbCrLf
		Response.Write "    e.checked = form.chkall.checked;" & vbCrLf
		Response.Write "    }" & vbCrLf
		Response.Write "   }" & vbCrLf
		Response.Write "  }" & vbCrLf
		Response.Write "//-->" & vbCrLf
		Response.Write "</script>" & vbCrLf
	
		Response.Write "<table width=""100%"" border=""0"" align=""center"" cellpadding=""3"" cellspacing=""1"" class=""b1"">" & vbCrLf
		Response.Write "  <tr class=""tdbg2"">" & vbCrLf
		Response.Write "    <td align=""center""colspan=""5""><b>导入模版数据<b></td>" & vbCrLf
		Response.Write "  </tr>" & vbCrLf
		Response.Write "<form action=""admin_template.asp"" method=""post"" name=""addTemplate"">" & vbCrLf
		Response.Write "<input type=""hidden"" Name=""action"" value=""saveinput"">"
		Response.Write "  <tr class=""tdbg3"">" & vbCrLf
		Response.Write "    <td>ID</td>" & vbCrLf
		Response.Write "    <td>选择</td>" & vbCrLf
		Response.Write "    <td>模板名称</td>" & vbCrLf
		Response.Write "    <td>是否默认</td>" & vbCrLf
		Response.Write "    <td>创建时间</td>" & vbCrLf
		Response.Write "  </tr>" & vbCrLf
		
		'On Error Resume Next
		Set StyleConn = Server.CreateObject("ADODB.Connection")
		StyleConn.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(StyleMdb)
		If Err.Number = "-2147467259" Then
			ishion.strMsg = "<li>" & StyleName & "数据库不存在。"
			Call ishion.SystemMsg
			StyleConn.Close
			Set StyleConn = Nothing
			Exit Sub
		End If
		Set Rs = StyleConn.Execute("select styleID,styleName,isDefault,dateandtime from ishion_style")
			If Rs.EOF And Rs.BOF Then
				Response.Write ("<tr class=""tdbg3""><td colspan=""5"">Sorry！没有找到任何模板。</td></tr>")
			Else
				Do While Not Rs.EOF
				Response.Write "  <tr class=""tdbg3"">" & vbCrLf
				Response.Write "    <td> " & Rs(0) & "</td>" & vbCrLf
				Response.Write "    <td> <input type=""checkbox"" name=""StyleID"" value=""" & Rs(0) & """></td>" & vbCrLf
				If Rs(0) = CLng(Request.QueryString("StyleID")) Then
					Response.Write "    <td><font color=red>" & Rs(1) & "</font></td>" & vbCrLf
				Else
					Response.Write "    <td> " & Rs(1) & "</td>" & vbCrLf
				End If
				Response.Write "    <td> " & Rs(2) & "</td>" & vbCrLf
				Response.Write "    <td> " & Rs(3) & "</td>" & vbCrLf
				Response.Write "  </tr>" & vbCrLf
				Rs.MoveNext
				Loop
			End If
		Set Rs = Nothing
		Response.Write "  <tr class=""tdbg2"">" & vbCrLf
		Response.Write "    <td align=""center""colspan=""5""><input type=checkbox name=chkall value=on onclick=""CheckAll(this.form)"">全选 <input type=""hidden"" name=""StyleMDB"" size=""30"" value=""Style/Style.mdb"">"
		Response.Write " <input type=""submit"" name=""submit"" value="" 开始导入 ""></td>" & vbCrLf
		Response.Write "  </tr>" & vbCrLf
		Response.Write "</form>" & vbCrLf
		Response.Write "</table>" & vbCrLf
		Set StyleConn = Nothing
	End Sub
	Sub Reslist()
		Dim Rs, i
		Response.Write "<script language=""JavaScript"">" & vbCrLf
		Response.Write "<!--" & vbCrLf
		Response.Write "function CheckAll(form)  {" & vbCrLf
		Response.Write "  for (var i=0;i<form.elements.length;i++)    {" & vbCrLf
		Response.Write "    var e = form.elements[i];" & vbCrLf
		Response.Write "    if (e.name != 'chkall'){" & vbCrLf
		Response.Write "    e.checked = form.chkall.checked;" & vbCrLf
		Response.Write "    }" & vbCrLf
		Response.Write "   }" & vbCrLf
		Response.Write "  }" & vbCrLf
		Response.Write "//-->" & vbCrLf
		Response.Write "</script>" & vbCrLf
	
		Response.Write "<table width=""100%"" border=""0"" align=""center"" cellpadding=""3"" cellspacing=""1"" class=""b1"">" & vbCrLf
		Response.Write "  <tr class=""tdbg2"">" & vbCrLf
		Response.Write "    <td align=""center""colspan=""6""><b>网站模板管理<b></td>" & vbCrLf
		Response.Write "  </tr>" & vbCrLf
		Response.Write "<form action=""admin_template.asp"" method=""post"" name=""addTemplate"">" & vbCrLf
		Response.Write "<input type=""hidden"" Name=""action"" value=""output"">"
		Response.Write "  <tr class=""tdbg3"">" & vbCrLf
		Response.Write "    <td>ID</td>" & vbCrLf
		Response.Write "    <td>选择</td>" & vbCrLf
		Response.Write "    <td>模板名称</td>" & vbCrLf
		Response.Write "    <td>是否默认</td>" & vbCrLf
		Response.Write "    <td>创建时间</td>" & vbCrLf
		Response.Write "    <td>管理操作</td>" & vbCrLf
		Response.Write "  </tr>" & vbCrLf
		
		Set Rs = ishion.Execute("select styleID,styleName,isDefault,dateandtime from ishion_style")
			If Rs.EOF And Rs.BOF Then
				Response.Write ("<tr class=""tdbg3""><td colspan=""6"">Sorry！没有找到任何模板，“<a href=""?action=addTemplate"">点此添加新模板</a>”</td></tr>")
			Else
				Do While Not Rs.EOF
				Response.Write "  <tr class=""tdbg3"">" & vbCrLf
				Response.Write "    <td> " & Rs(0) & "</td>" & vbCrLf
				Response.Write "    <td> <input type=""checkbox"" name=""StyleID"" value=""" & Rs(0) & """></td>" & vbCrLf
				If Rs(0) = CLng(Request.QueryString("StyleID")) Then
					Response.Write "    <td><font color=red>" & Rs(1) & "</font></td>" & vbCrLf
				Else
					Response.Write "    <td> " & Rs(1) & "</td>" & vbCrLf
				End If
				Response.Write "    <td> " & Rs(2) & "</td>" & vbCrLf
				Response.Write "    <td> " & Rs(3) & "</td>" & vbCrLf
				Response.Write "    <td> <a href=""?StyleID=" & Rs(0) & """>分模块编辑</a> | " & _
				"<a href=""?action=edit&StyleID=" & Rs(0) & """>整体编辑</a> | " & _
				"<a href=""?action=copy&StyleID=" & Rs(0) & """>复制到新模板</a> | " & _
				"<a href=""?action=isDefault&StyleID=" & Rs(0) & """>设置为默认模板</a> | " & _
				"<a href=""?action=del&StyleID=" & Rs(0) & """ onclick=""{if(confirm('删除后将无法修复，确定吗?')){return true;}return false;}"">删除</a></td>"
				Response.Write "  </tr>" & vbCrLf
				Rs.MoveNext
				Loop
			End If
		Set Rs = Nothing
		Response.Write "  <tr class=""tdbg2"">" & vbCrLf
		Response.Write "    <td align=""center""colspan=""6""><input type=checkbox name=chkall value=on onclick=""CheckAll(this.form)"">全选 导出模板到数据库：<input type=""text"" name=""StyleMDB"" size=""30"" value=""Style/Style.mdb"">"
		Response.Write " <input type=""submit"" name=""submit"" value="" 导 出 ""></td>" & vbCrLf
		Response.Write "  </tr>" & vbCrLf
		Response.Write "</form>" & vbCrLf
		Response.Write "</table>" & vbCrLf
		Response.Write "<table width=""100%"" height=""3""  border=""0"" cellpadding=""0"" cellspacing=""0""><tr><td></td></tr></table>" & vbCrLf
		If Trim(Request("StyleID")) <> "" Then
			Set Rs = ishion.Execute("select * from ishion_Style where StyleID=" & CLng(Request("StyleID")))
		Else
			Set Rs = ishion.Execute("select top 1 * from ishion_Style where isDefault =1")
		End If
		If Not (Rs.EOF And Rs.BOF) Then
			Response.Write "<table width=""100%"" border=""0"" align=""center"" cellpadding=""3"" cellspacing=""1"" class=""b1"">" & vbCrLf
			Response.Write "  <tr class=""tdbg2"">" & vbCrLf
			Response.Write "    <td colspan=""2"" align=""center"">" & Rs("StyleName") & " —— 模板资源管理</td>" & vbCrLf
			Response.Write "  </tr>" & vbCrLf
			For i = 2 To Rs.Fields.Count - 3
				Response.Write "  <tr class=""tdbg3"">" & vbCrLf
				Response.Write "    <td>" & Rs(i).Name & "</td>" & vbCrLf
				Response.Write "    <td>编辑该模块：<a href=""?action=edithtml&Page=" & Rs(i).Name & "&StyleID=" & Rs("StyleID") & """>HTML 方式编辑</a> | " & _
				"<a href=""?action=webeditor&Page=" & Rs(i).Name & "&StyleID=" & Rs("StyleID") & """>可视化方式编辑</a> </td>" & vbCrLf
				Response.Write "  </tr>" & vbCrLf
			Next
			Response.Write "</table>" & vbCrLf
		End If
		Set Rs = Nothing
	End Sub
	
	Sub addTemplate()
		Dim Rs, i
		Response.Write "<table width=""100%"" border=""0"" align=""center"" cellpadding=""3"" cellspacing=""1"" class=""b1"">" & vbCrLf
		Response.Write "  <tr class=""tdbg2"">" & vbCrLf
		Response.Write "    <td colspan=""3"" align=""center"">添加新模板</td>" & vbCrLf
		Response.Write "  </tr>" & vbCrLf
		Response.Write "<form action=""?action=saveadd"" method=""post"" name=""addTemplate"">" & vbCrLf
		Response.Write "<input type=""hidden"" Name=""action"" value=""saveadd"">"
		Set Rs = ishion.Execute("select top 1 * from ishion_style")
		For i = 1 To Rs.Fields.Count - 3
			Response.Write "  <tr class=""tdbg3""><td>" & Rs(i).Name & "</td>" & vbCrLf
			Response.Write "    <td>"
			If i = 1 Then
			Response.Write "<input name=""" & Rs(i).Name & """ type=""text"" value="""" size=""30"" maxlength=""30"">" & vbCrLf
			Else
			Response.Write "<textarea name=""" & Rs(i).Name & """ cols=""80"" rows=""5""></textarea>"
			End If
			Response.Write "</td>" & vbCrLf
			Response.Write "<td>&nbsp;</td>" & vbCrLf
			Response.Write "  </tr>" & vbCrLf
		Next
		Set Rs = Nothing
		Response.Write "  <tr class=""tdbg3"">" & vbCrLf
		Response.Write "    <td>&nbsp;</td>" & vbCrLf
		Response.Write "    <td><input type=""submit"" name=""Submit"" value="" 提交 ""></td>" & vbCrLf
		Response.Write "    <td>&nbsp;</td>" & vbCrLf
		Response.Write "  </tr>" & vbCrLf
		Response.Write "</form>" & vbCrLf
		Response.Write "</table>" & vbCrLf
	End Sub
	
	Sub editHtml()
		Dim Rs, i, arrPage
		Set Rs = ishion.Execute("select StyleName," & Trim(Request.QueryString("Page")) & " from ishion_Style where StyleID=" & CLng(Request("StyleID")))
		arrPage = Split(Rs(1), "<!--|||-->")
		Response.Write "<SCRIPT language=javascript1.2>" & vbCrLf
		Response.Write "// 修改编辑栏高度" & vbCrLf
		Response.Write "function admin_Size(num,objname)" & vbCrLf
		Response.Write "{" & vbCrLf
		Response.Write "    var obj=document.getElementById(objname)" & vbCrLf
		Response.Write "    if (parseInt(obj.rows)+num>=3) {" & vbCrLf
		Response.Write "        obj.rows = parseInt(obj.rows) + num;    " & vbCrLf
		Response.Write "    }" & vbCrLf
		Response.Write "    if (num>0)" & vbCrLf
		Response.Write "    {" & vbCrLf
		Response.Write "        obj.width=""90%"";" & vbCrLf
		Response.Write "    }" & vbCrLf
		Response.Write "}" & vbCrLf
		Response.Write "</SCRIPT>" & vbCrLf
		Response.Write "<table width=""100%""  border=""0"" cellpadding=""3"" cellspacing=""1"" class=""b1"">" & vbCrLf
		Response.Write "<form action=""?action=saveedithtml"" method=""post"" name=""editHtml"">" & vbCrLf
		Response.Write "<input type=""hidden"" Name=""action"" value=""saveedithtml"">"
		Response.Write "<input type=""hidden"" Name=""Page"" value=""" & Trim(Request.QueryString("Page")) & """>"
		Response.Write "<input name=""StyleID"" type=""hidden"" value=""" & CLng(Request("StyleID")) & """>" & vbCrLf
		Response.Write "  <tr>" & vbCrLf
		Response.Write "    <td colspan=""3"" align=""center"" class=""tdbg2"">“" & Rs(0) & "”分页面模板( " & Trim(Request.QueryString("Page")) & " )界面风格管理</td>" & vbCrLf
		Response.Write "  </tr>" & vbCrLf
		For i = 0 To UBound(arrPage)
			Response.Write "  <tr>" & vbCrLf
			Response.Write "    <td class=""tdbg3"" width=""80"">Template(" & i & ")</td>" & vbCrLf
			Response.Write "    <td class=""tdbg3""><textarea name=""content"" id=""t" & i & """ cols=""100"" rows=""6"">" & Server.HTMLEncode(arrPage(i)) & "</textarea></td>" & vbCrLf
			Response.Write "    <td class=""tdbg3"" width=""10%"" valign=""top""><br><a href=""javascript:admin_Size(-5,'t" & i & "')""><img src=""../images/arrow_up.gif"" unselectable=""on"" border=""0""></a><br><br><a href=""javascript:admin_Size(5,'t" & i & "')""><img src=""../images/arrow_down.gif"" unselectable=""on"" border=""0""></a></td>" & vbCrLf
			Response.Write "  </tr>" & vbCrLf
		Next
		Response.Write "  <tr class=""tdbg3"">" & vbCrLf
		Response.Write "    <td>Template(" & i & ")</td>" & vbCrLf
		Response.Write "    <td><textarea name=""content"" id=""t" & i & """ cols=""100"" rows=""3"">End</textarea></td>" & vbCrLf
		Response.Write "    <td>&nbsp;</td>" & vbCrLf
		Response.Write "  </tr>" & vbCrLf
		
		Response.Write "  <tr class=""tdbg3"">" & vbCrLf
		Response.Write "    <td><input type=""reset"" name=""Submit"" value=""重 填""></td>" & vbCrLf
		Response.Write "    <td><input type=""submit"" name=""Submit"" value="" 提交 ""></td>" & vbCrLf
		Response.Write "    <td>&nbsp;</td>" & vbCrLf
		Response.Write "  </tr>" & vbCrLf
		
		Response.Write "</form>" & vbCrLf
		Response.Write "  <tr>" & vbCrLf
		Response.Write "    <td colspan=""3"" class=""tdbg3""><li>模板编辑规则：如果想清除该字段，请在对应的文本框中输入""End""，那么模板数据的序号就会前移。<br><li>如果不想改变模板数据的序号,仅把该项目的数据清空,则只需要把内容清空。</td>" & vbCrLf
		Response.Write "  </tr>" & vbCrLf
		Response.Write "</table>" & vbCrLf
		Set Rs = Nothing
	End Sub
	
	Sub edit()
		Dim Rs, i
		Response.Write "<SCRIPT language=javascript1.2>" & vbCrLf
		Response.Write "// 修改编辑栏高度" & vbCrLf
		Response.Write "function admin_Size(num,objname)" & vbCrLf
		Response.Write "{" & vbCrLf
		Response.Write "    var obj=document.getElementById(objname)" & vbCrLf
		Response.Write "    if (parseInt(obj.rows)+num>=3) {" & vbCrLf
		Response.Write "        obj.rows = parseInt(obj.rows) + num;    " & vbCrLf
		Response.Write "    }" & vbCrLf
		Response.Write "    if (num>0)" & vbCrLf
		Response.Write "    {" & vbCrLf
		Response.Write "        obj.width=""90%"";" & vbCrLf
		Response.Write "    }" & vbCrLf
		Response.Write "}" & vbCrLf
		Response.Write "</SCRIPT>" & vbCrLf
		Response.Write "<table width=""100%"" border=""0"" align=""center"" cellpadding=""3"" cellspacing=""1"" class=""b1"">" & vbCrLf
		Response.Write "  <tr class=""tdbg2"">" & vbCrLf
		If Trim(Request("action")) = "copy" Then
			Response.Write "    <td colspan=""3"" align=""center"">复制到新模板</td>" & vbCrLf
			Response.Write "  </tr>" & vbCrLf
			Response.Write "<form action=""?action=savecopy"" method=""post"" name=""edit"">" & vbCrLf
			Response.Write "<input type=""hidden"" Name=""action"" value=""savecopy"">"
		Else
			Response.Write "    <td colspan=""3"" align=""center"">模板整体编辑</td>" & vbCrLf
			Response.Write "  </tr>" & vbCrLf
			Response.Write "<form action=""?action=saveedit"" method=""post"" name=""edit"">" & vbCrLf
			Response.Write "<input type=""hidden"" Name=""action"" value=""saveedit"">"
		End If
		Response.Write "<input type=""hidden"" Name=""StyleID"" value=""" & CLng(Request("StyleID")) & """>"
		Set Rs = ishion.Execute("select top 1 * from ishion_style where StyleID=" & CLng(Request("StyleID")))
		For i = 1 To Rs.Fields.Count - 3
			Response.Write "  <tr class=""tdbg3""><td>" & Rs(i).Name & "</td>" & vbCrLf
			Response.Write "    <td>"
			If i = 1 Then
			Response.Write "<input name=""" & Rs(i).Name & """ type=""text"" value=""" & Rs(i).Value & """ size=""30"" maxlength=""30"">" & vbCrLf
			Else
			Response.Write "<textarea name=""" & Rs(i).Name & """ cols=""100"" rows=""7"" id=""t" & i & """>" & Server.HTMLEncode(Rs(i).Value) & "</textarea>"
			End If
			Response.Write "</td>" & vbCrLf
			Response.Write "<td valign=""top"" width=""35"">"
			If i <> 1 Then
				Response.Write "<br><a href=""javascript:admin_Size(-5,'t" & i & "')""><img src=""../images/arrow_up.gif"" unselectable=""on"" border=""0""></a><br><br><a href=""javascript:admin_Size(5,'t" & i & "')""><img src=""../images/arrow_down.gif"" unselectable=""on"" border=""0""></a>"
			End If
			Response.Write "</td>" & vbCrLf
			Response.Write "  </tr>" & vbCrLf
		Next
		Set Rs = Nothing
		Response.Write "  <tr class=""tdbg3"">" & vbCrLf
		Response.Write "    <td>&nbsp;</td>" & vbCrLf
		Response.Write "    <td><input type=""submit"" name=""Submit"" value="" 提交 ""></td>" & vbCrLf
		Response.Write "    <td>&nbsp;</td>" & vbCrLf
		Response.Write "  </tr>" & vbCrLf
		Response.Write "</form>" & vbCrLf
		Response.Write "</table>" & vbCrLf
	End Sub
	Sub WebEditor()
		Dim Rs
		Set Rs = ishion.Execute("select StyleName," & Trim(Request.QueryString("Page")) & " from ishion_Style where StyleID=" & CLng(Request("StyleID")))
		Response.Write "<table width=""100%""  border=""0"" cellpadding=""3"" cellspacing=""1"" class=""b1"">" & vbCrLf
		Response.Write "<form action=""?action=savewebeditor"" method=""post"" name=""webeditor"">" & vbCrLf
		Response.Write "<input name=""action"" type=""hidden"" value=""savewebeditor"">" & vbCrLf
		Response.Write "<input type=""hidden"" Name=""Page"" value=""" & Trim(Request.QueryString("Page")) & """>"
		Response.Write "<input name=""StyleID"" type=""hidden"" value=""" & CLng(Request("StyleID")) & """>" & vbCrLf
		Response.Write "  <tr>" & vbCrLf
		Response.Write "    <td align=""center"" class=""tdbg4"">“" & Rs(0) & "”分页面模板( " & Trim(Request.QueryString("Page")) & " )界面风格管理</td>" & vbCrLf
		Response.Write "  </tr>" & vbCrLf
		Response.Write "  <tr>" & vbCrLf
		Response.Write "    <td class=""tdbg3"">模板名称：" & vbCrLf
		Response.Write "      <input name=""StyleName"" type=""text"" id=""StyleName"" value=""" & Rs(0) & """ maxlength=""50""></td>" & vbCrLf
		Response.Write "  </tr>" & vbCrLf
		Response.Write "  <tr>" & vbCrLf
		Response.Write "    <td class=""tdbg3""><textarea name=""content1"" id=""content1"" style=""display:none"">" & Server.HTMLEncode(Rs(1)) & "</textarea>"
		Response.Write "<IFRAME ID=""eWebEditor1"" src=""../ewebeditor/ewebeditor.asp?id=content1&style=s_ishioncn"" frameborder=""0"" scrolling=""no"" width=""790"" height=""450""></IFRAME>"
		
		Response.Write "</td>" & vbCrLf
		Response.Write "  </tr>" & vbCrLf
		Response.Write "  <tr>" & vbCrLf
		Response.Write "    <td class=""tdbg3"">　<input type=""submit"" name=""Submit"" value="" 提 交 ""></td>" & vbCrLf
		Response.Write "  </tr>" & vbCrLf
		Response.Write "</form>" & vbCrLf
		Response.Write "</table>" & vbCrLf
		Set Rs = Nothing
	End Sub
	Function Down_Menu()
		Call ishion.LoadSetting
		Dim Rs, sql, i
		Set Rs = ishion.Execute("select rootID,catalogID,catalogName from ishion_Down_catalog where depth=0 order by orders")
		If Not(Rs.eof and Bof) then
			sql = Rs.GetRows(-1)
			For i = 0 To UBound(sql, 2)
				If i = 0 Then
					Down_Menu = Down_Menu & "<a href=""../" & Replace(Replace(ishion.Setting(72), "{$id}", sql(0, i)), "{$pages}", 1) & """ class=""menu"">" & sql(2, i) & "</a>"
				Else
					Down_Menu = Down_Menu & " | <a href=""../" & Replace(Replace(ishion.Setting(72), "{$id}", sql(0, i)), "{$pages}", 1) & """ class=""menu"">" & sql(2, i) & "</a>"
				End If
			Next
		End If
		Set Rs = nothing
		
	End Function
	Function Cms_Menu()
		Call ishion.LoadSetting
		Dim Rs, sql, i
		Set Rs = ishion.Execute("select rootID,catalogID,catalogName from ishion_Cms_catalog where depth=0 order by orders")
		If Not(Rs.eof and Bof) then
			sql = Rs.GetRows(-1)
			For i = 0 To UBound(sql, 2)
				If i = 0 Then
					Cms_Menu = Cms_Menu & "<a href=""../" & Replace(Replace(ishion.Setting(97), "{$id}", sql(0, i)), "{$pages}", 1) & """ class=""menu"">" & sql(2, i) & "</a>"
				Else
					Cms_Menu = Cms_Menu & " | <a href=""../" & Replace(Replace(ishion.Setting(97), "{$id}", sql(0, i)), "{$pages}", 1) & """ class=""menu"">" & sql(2, i) & "</a>"
				End If
			Next
		End If
		Set Rs = nothing
	End Function
	
	Function Down_Abc(s)
		Call ishion.LoadSetting
		Dim arrAbc, i
		arrAbc = Split(s, ",")
		For i = 0 To UBound(arrAbc)
			If i = 0 Then
				Down_Abc = Down_Abc & "<a href=""../" & Replace(ishion.Setting(74), "{$s}", arrAbc(i)) & """ class=""az"">" & arrAbc(i) & "</a>"
			Else
				Down_Abc = Down_Abc & " - <a href=""../" & Replace(ishion.Setting(74), "{$s}", arrAbc(i)) & """ class=""az"">" & Replace(arrAbc(i), "1", "") & "</a>"
			End If
		Next
	End Function
	Public Sub OnEndPage()
		Response.Write ishion.CopyRight
	End Sub ' OnEndPage


End Class %>

