
<%
option explicit
response.buffer=true
%>
<!--#include file="../inc/Conn.asp"-->
<!--#include file="Inc/Admin.Asp"-->
<!--#include file="inc/function.asp"-->
<!--#include file="../inc/ubbcode.asp"-->
<%
PurviewValue="Admin_Skin"
If not CheckAdmin(PurviewValue) then
Response.Write("<script language=""JavaScript"">alert(""越权操作!"");history.go(-1);")
response.end
End If
%>
<%

dim rs, sql
dim Action,SkinID
Action=trim(request("Action"))
SkinID=trim(request("SkinID"))
%>
<script src="inc/admin.js" type="text/javascript"></script>
<!-- #include file="Inc/Head.asp" -->
<table width="600" border="0" align="center" cellpadding="0" cellspacing="1" class="border">
  <tr class="topbg"> 
    <td class="topbg" height="30" colspan="2" align="center">配 
      色 模 板 管 理</td>
  </tr>
  <tr class="tdbg"> 
    <td width="70" height="30" class="tdbgl">管理导航：</td>
    <td><a href="Admin_Skin.asp">配色模板管理首页</a> | <a href="Admin_Skin.asp?Action=Add">添加配色模板</a> 
      | <a href="Admin_Skin.asp?Action=Export">配色模板导出</a> | <a href="Admin_Skin.asp?Action=Import">配色模板导入</a></td>
  </tr>
</table>
<%
select case Action
	case "Add","Modify"
		call ShowSkinSet()
	case "SaveAdd"
		call SaveAdd()
	case "SaveModify"
		call SaveModify()
	case "Set"
		call SetDefault()
	case "Del"
		call DelSkin()
	case "Export"
		call Export()
	case "DoExport"
		call DoExport()
	case "Import"
		call Import()
	case "Import2"
		call Import2()		
	case "DoImport"
		call DoImport()
	case else
		call main()
end select
if FoundErr=True then
	call WriteErrMsg()
end if
call CloseConn()

sub main()
	sql="select * from Skin"
	Set rs=Server.CreateObject("Adodb.RecordSet")
	rs.Open sql,conn,1,1
%>
<form name="form1" method="post" action="Admin_Skin.asp">
<table width="600" border="0" align="center" cellpadding="0" cellspacing="1" class="border">
  <tr  class="title">
    <td width="32" align="center" class="Title">选择</td>
    <td width="31" align="center" class="Title">ID</td>
    <td width="95" height="22" align="center" class="Title"> 模板名称</td>
    <td width="129" align="center" class="Title">效果图</td>
    <td width="64" align="center" class="Title">设计者</td>
    <td width="82" align="center" class="Title">模板类型</td>
    <td width="131" height="22" align="center" class="Title"> 操作</td>
  </tr>
  <%if not(rs.bof and rs.eof) then
  do while not rs.EOF %>
  <tr  class="tdbg" onMouseOver="this.style.backgroundColor='#BFDFFF'" onMouseOut="this.style.backgroundColor=''">
    <td width="32" align="center"><input type="radio" value="<%=rs("SkinID")%>" <%if rs("IsDefault")=true then response.write " checked"%> name="SkinID"></td>
    <td width="31" align="center"><%=rs("SkinID")%></td>
    <td align="center"><%=rs("SkinName")%></td>
    <td width="129" align="center"><%response.write "<a href='Admin_Skin.asp?Action=Prview&SkinID=" & rs("SkinID") & "' title='点此查看原始效果图'><img src='" & rs("PicUrl") & "' width=100 height=30 border=0></a>"%></td>
    <td width="64" align="center"><%response.write "<a href='mailto:" & rs("DesignerEmail") & "' title='设计者信箱：" & rs("DesignerEmail") & vbcrlf & "设计者主页：" & rs("DesignerHomepage") & "'>" & rs("DesignerName") & "</a>"%></td>
    <td width="82" align="center"><%if rs("DesignType")=1 then response.write "用户自定义" else response.write "系统提供"%></td>
    <td width="131" align="center"><%
	response.write "<a href='Admin_Skin.asp?Action=Modify&SkinID=" & rs("SkinID") & "'>修改模板设置</a>&nbsp;"
	if rs("DesignType")=1 and rs("IsDefault")=False then
		response.write "<a href='Admin_Skin.asp?Action=Del&SkinID=" & rs("SkinID") & "' onClick=""return confirm('确定要删除此配色模板吗？删除此配色模板后原使用此配色模板的文章将改为使用系统默认配色模板。');"">删除模板</a>"
	else
		response.write "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"
	end if
	%>
    </td>
  </tr>
  <%
		rs.MoveNext
   	loop
  %>
  <tr  class="tdbg">
    <td colspan="7" align="center"><input name="Action" type="hidden" id="Action" value="Set">
        <input type="submit" name="Submit" value="将选中的模板设为默认模板"></td>
  </tr>
  <%end if%>
</table></form>
<%
	rs.close
	set rs=nothing
end sub

sub Export()
	sql="select * from Skin"
	Set rs=Server.CreateObject("Adodb.RecordSet")
	rs.Open sql,conn,1,1
%>
<form name="myform" method="post" action="Admin_Skin.asp">
  <table width="600" border="0" align="center" cellpadding="0" cellspacing="1" class="border">
    <tr  class="topbg"> 
      <td height="22" colspan="6" align="center">配色模板导出</td>
    </tr>
    <tr  class="title"> 
      <td width="31" align="center" class="Title">选择</td>
      <td width="52" align="center" class="Title">ID</td>
      <td width="140" height="22" align="center" class="Title"> 模板名称</td>
      <td width="158" align="center" class="Title">效果图</td>
      <td width="104" align="center" class="Title">设计者</td>
      <td width="84" height="22" align="center" class="Title">模板类型</td>
    </tr>
    <%if not(rs.bof and rs.eof) then
  do while not rs.EOF %>
    <tr  class="tdbg" onMouseOver="this.style.backgroundColor='#BFDFFF'" onMouseOut="this.style.backgroundColor=''"> 
      <td width="31" align="center"> 
        <input type="checkbox" value="<%=rs("SkinID")%>" name="SkinID" onClick="unselectall()"></td>
      <td width="52" align="center"><%=rs("SkinID")%></td>
      <td align="center"><%=rs("SkinName")%></td>
      <td width="158" align="center"> 
        <%response.write "<a href='Admin_Skin.asp?Action=Prview&SkinID=" & rs("SkinID") & "' title='点此查看原始效果图'><img src='" & rs("PicUrl") & "' width=100 height=30 border=0></a>"%></td>
      <td width="104" align="center"> 
        <%response.write "<a href='mailto:" & rs("DesignerEmail") & "' title='设计者信箱：" & rs("DesignerEmail") & vbcrlf & "设计者主页：" & rs("DesignerHomepage") & "'>" & rs("DesignerName") & "</a>"%></td>
      <td width="84" align="center"> 
        <%if rs("DesignType")=1 then response.write "用户自定义" else response.write "系统提供"%></td>
    </tr>
    <%
		rs.MoveNext
   	loop
  %>
    <tr  class="tdbg"> 
      <td colspan="6"> 
        <input name="chkAll" type="checkbox" id="chkAll" onclick=CheckAll(this.form) value="checkbox">
        选中所有模板&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;导出选中的模板到数据库： 
        <input name="SkinMdb" type="text" id="SkinMdb" value="Skin/Skin.mdb" size="20" maxlength="50">
        <input type="submit" name="Submit" value="导出">
        <input name="Action" type="hidden" id="Action" value="DoExport"></td>
    </tr>
    <%end if%>
  </table>  
</form>
<SCRIPT language=javascript>
function unselectall()
{
    if(document.myform.chkAll.checked){
	document.myform.chkAll.checked = document.myform.chkAll.checked&0;
    } 	
}

function CheckAll(form)
{
  for (var i=0;i<form.elements.length;i++)
    {
    var e = form.elements[i];
    if (e.Name != "chkAll"&&e.disabled!=true)
       e.checked = form.chkAll.checked;
    }
}
</script>
<%
	rs.close
	set rs=nothing
end sub

sub Import()
%>
<form name="myform" method="post" action="Admin_Skin.asp">
  <table width="600" border="0" align="center" cellpadding="0" cellspacing="1" class="border">
    <tr class="topbg"> 
      <td height="22" align="center">配色模板导入（第一步）</td>
    </tr>
	<tr class="tdbg">
      <td height="100">&nbsp;&nbsp;&nbsp;&nbsp;请输入要导入的模板数据库的文件名： 
        <input name="SkinMdb" type="text" id="SkinMdb" value="Skin/Skin.mdb" size="20" maxlength="50">
        <input name="Submit" type="submit" id="Submit" value=" 下一步 ">
        <input name="Action" type="hidden" id="Action" value="Import2"> </td>
	</tr>
  </table>
</form>
<%
end sub

sub Import2()
	on error resume next
	dim mdbname,tconn,trs
	mdbname=replace(trim(request.form("skinmdb")),"'","")
	if mdbname="" then
		FoundErr=True
		ErrMsg=ErrMsg & "<br><li>请填写导入模版数据库名"
		exit sub
	end if
	
	Set tconn = Server.CreateObject("ADODB.Connection")
	tconn.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(mdbname)
	if err.number<>0 then
		ErrMsg=ErrMsg & "<br><li>数据库操作失败，请以后再试，错误原因：" & err.Description
		err.clear
		exit sub
	end if
	

	sql="select * from Skin"
	Set rs=Server.CreateObject("Adodb.RecordSet")
	rs.Open sql,tconn,1,1
%>
<form name="myform" method="post" action="Admin_Skin.asp">
  <table width="600" border="0" align="center" cellpadding="0" cellspacing="1" class="border">
    <tr  class="topbg"> 
      <td height="22" colspan="6" align="center">配色模板导入（第二步）</td>
    </tr>
    <tr  class="title"> 
      <td width="39" align="center" class="Title">选择</td>
      <td width="41" align="center" class="Title">ID</td>
      <td width="159" height="22" align="center" class="Title"> 模板名称</td>
      <td width="150" align="center" class="Title">效果图</td>
      <td width="100" align="center" class="Title">设计者</td>
      <td width="80" height="22" align="center" class="Title">模板类型</td>
    </tr>
    <%if not(rs.bof and rs.eof) then
  do while not rs.EOF %>
    <tr  class="tdbg" onMouseOver="this.style.backgroundColor='#BFDFFF'" onMouseOut="this.style.backgroundColor=''"> 
      <td width="39" align="center"> 
        <input type="checkbox" value="<%=rs("SkinID")%>" name="SkinID" onClick="unselectall()"></td>
      <td width="41" align="center"><%=rs("SkinID")%></td>
      <td align="center"><%=rs("SkinName")%></td>
      <td width="150" align="center"> 
        <%response.write "<a href='Admin_Skin.asp?Action=Prview&SkinID=" & rs("SkinID") & "' title='点此查看原始效果图'><img src='" & rs("PicUrl") & "' width=100 height=30 border=0></a>"%></td>
      <td width="100" align="center"> 
        <%response.write "<a href='mailto:" & rs("DesignerEmail") & "' title='设计者信箱：" & rs("DesignerEmail") & vbcrlf & "设计者主页：" & rs("DesignerHomepage") & "'>" & rs("DesignerName") & "</a>"%></td>
      <td width="80" align="center"> 
        <%if rs("DesignType")=1 then response.write "用户自定义" else response.write "系统提供"%></td>
    </tr>
    <%
		rs.MoveNext
   	loop
  %>
    <tr  class="tdbg"> 
      <td colspan="6"> 
        <input name="chkAll" type="checkbox" id="chkAll" onclick=CheckAll(this.form) value="checkbox">
        选中所有模板&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <input type="submit" name="Submit" value="导入选中的模板">
        <input name="SkinMdb" type="hidden" id="SkinMdb" value="<%=mdbname%>">
        <input name="Action" type="hidden" id="Action" value="DoImport"></td>
    </tr>
    <%end if%>
  </table>  
</form>
<SCRIPT language=javascript>
function unselectall()
{
    if(document.myform.chkAll.checked){
	document.myform.chkAll.checked = document.myform.chkAll.checked&0;
    } 	
}

function CheckAll(form)
{
  for (var i=0;i<form.elements.length;i++)
    {
    var e = form.elements[i];
    if (e.Name != "chkAll"&&e.disabled!=true)
       e.checked = form.chkAll.checked;
    }
}
</script>
<%
	rs.close
	set rs=nothing
end sub

sub ShowSkinSet()
	if Action="Add" then
		sql="select * from Skin where IsDefault=True"
	elseif Action="Modify" then
		if SkinID="" then
			FoundErr=True
			ErrMsg=ErrMsg & "<br><li>请指定SkinID</li>"
			exit sub
		else
			SkinID=Clng(SkinID)
		end if
		sql="select * from Skin where SkinID=" & SkinID
	end if
	Set rs=Server.CreateObject("Adodb.RecordSet")
	rs.Open sql,conn,1,1
	if rs.bof and rs.eof then
		FoundErr=True
		ErrMsg=ErrMsg & "<br><li>数据库出现错误！</li>"
		rs.close
		set rs=nothing
		exit sub
	end if
	dim Skin_CSS
	Skin_CSS=split(rs("Skin_CSS"),"|||")
%>
<form name="form1" method="post" action="Admin_Skin.asp">
  <table width="600" border="0" align="center" cellpadding="0" cellspacing="1" class="border">
    <tr align="center"  class="title"> 
      <td height="22" colspan="2" class="topbg"> 
        <%if Action="Add" then%>
        添加新配色模板 
        <%else%>
        修改模板设置 
        <%end if%>      </td>
    </tr>
    <tr  class="topbg"> 
      <td height="20" colspan="2" class="Title">配色模板基本信息</td>
    </tr>
    <tr  class="tdbg"> 
      <td width="40%" class="tdbgl">配色模板名称：</td>
      <td> 
        <input name="SkinName" type="text" id="SkinName" value="<%if Action="Modify" then response.write rs("SkinName")%>" size="50" maxlength="50"> 
        <input name="SkinID" type="hidden" id="SkinID" value="<%=SkinID%>"></td>
    </tr>
    <tr  class="tdbg"> 
      <td width="40%" class="tdbgl">配色模板预览图：</td>
      <td> 
        <%if Action="Modify" and rs("DesignType")=0 then%> <input name="PicUrl" type="hidden" id="PicUrl" value="<%=rs("PicUrl")%>"> 
        <%=rs("PicUrl")%> <%else%> <input name="PicUrl" type="text" id="PicUrl" value="<%=rs("PicUrl")%>" size="50" maxlength="100"> 
        <%end if%></td>
    </tr>
    <tr  class="tdbg"> 
      <td width="40%" class="tdbgl">设计者姓名：</td>
      <td> 
        <%if Action="Modify" and rs("DesignType")=0 then%> <input name="DesignerName" type="hidden" id="DesignerName" value="<%=rs("DesignerName")%>"> 
        <%=rs("DesignerName")%> <%else%> <input name="DesignerName" type="text" id="DesignerName" value="<%=rs("DesignerName")%>" size="50" maxlength="30"> 
        <%end if%></td>
    </tr>
    <tr  class="tdbg"> 
      <td width="40%" class="tdbgl">设计者Email：</td>
      <td> 
        <%if Action="Modify" and rs("DesignType")=0 then%> <input name="DesignerEmail" type="hidden" id="DesignerEmail" value="<%=rs("DesignerEmail")%>"> 
        <%=rs("DesignerEmail")%> <%else%> <input name="DesignerEmail" type="text" id="DesignerEmail" value="<%=rs("DesignerEmail")%>" size="50" maxlength="100"> 
        <%end if%></td>
    </tr>
    <tr  class="tdbg"> 
      <td width="40%" class="tdbgl">设计者主页：</td>
      <td> 
        <%if Action="Modify" and rs("DesignType")=0 then%> <input name="DesignerHomepage" type="hidden" id="DesignerHomepage" value="<%=rs("DesignerHomepage")%>"> 
        <%=rs("DesignerHomepage")%> <%else%> <input name="DesignerHomepage" type="text" id="DesignerHomepage" value="<%=rs("DesignerHomepage")%>" size="50" maxlength="100"> 
        <%end if%></td>
    </tr>
    <tr  class="topbg"> 
      <td height="20" colspan="2" class="Title">模板配色设置（修改以下设置必须具备一定网页知识，<font color="#FFFF00">不能使用单引号或双引号，否则会容易造成程序错误</font>）</td>
    </tr>
    <tr  class="tdbg"> 
      <td valign="top" class="tdbgl"><STRONG>CSS样式内容</STRONG></td>
      <td> 
        <textarea name="Skin_CSS" style="width:90%;" rows="30" id="Skin_CSS"><%=rs("Skin_CSS")%></textarea><div align=right style="width:90%;"><a href="javascript:admin_Size(-15,'Skin_CSS')"><img src="image/minus.gif" unselectable=on border=0></a> <a href="javascript:admin_Size(15,'Skin_CSS')"><img src="image/plus.gif" unselectable=on border=0></div></td>
    </tr>
    <tr align="center"> 
      <td  colspan="2"  class="tdbg"> 
        <%if Action="Add" then%> <input name="Action" type="hidden" id="Action" value="SaveAdd"> 
        <input type="submit" name="Submit2" value=" 添 加 "> <%else%> <input name="Action" type="hidden" id="Action" value="SaveModify"> 
        <input type="submit" name="Submit2" value=" 保存修改结果 "> <%end if%> </td>
    </tr>
  </table>
</form>
<%
	rs.close
	set rs=nothing
end sub
%>
<!-- #include file="Inc/Foot.asp" -->
<%
sub SaveAdd()
	call CheckSkin()
	if FoundErr=True then exit sub
	
	sql="select top 1 * from Skin"
	Set rs=Server.CreateObject("Adodb.RecordSet")
	rs.Open sql,conn,1,3
	rs.addnew
	rs("IsDefault")=False
	rs("DesignType")=1
	call SaveSkin()
	rs.close
	set rs=nothing
	call WriteSuccessMsg("成功添加新的配色模板："& trim(request("SkinName")))
	Call GetCreateIndex	
end sub

sub SaveModify()
	
	if SkinID="" then
		FoundErr=True
		ErrMsg=ErrMsg & "<br><li>请指定SkinID</li>"
	else
		SkinID=Clng(SkinID)
	end if
	call CheckSkin()
	if FoundErr=True then exit sub
	
	sql="select * from Skin where SkinID=" & SkinID
	Set rs=Server.CreateObject("Adodb.RecordSet")
	rs.Open sql,conn,1,3
	if rs.bof and rs.eof then
		FoundErr=True
		ErrMsg=ErrMsg & "<br><li>找不到指定的配色模板！</li>"
	else
		call SaveSkin()
		call WriteSuccessMsg("保存配色模板设置成功！")
	end if
	rs.close
	set rs=nothing
	Call GetCreateIndex
end sub

sub SetDefault()
	if SkinID="" then
		FoundErr=True
		ErrMsg=ErrMsg & "<br><li>请指定SkinID</li>"
		exit sub
	else
		SkinID=Clng(SkinID)
	end if
	conn.execute("update Skin set IsDefault=False where IsDefault=True")
	conn.execute("update Skin set IsDefault=True where SkinID=" & SkinID)
	Response.Cookies("MSCom")("Skinid")=SkinID
	call WriteSuccessMsg("成功将选定的模板设置为默认模板")
	Call GetCreateIndex
end sub

sub CheckSkin()
	if trim(request("SkinName"))="" then
		FoundErr=True
		ErrMsg=ErrMsg & "<br><li>模板名称不能为空！</li>"
	end if
	if trim(request("PicUrl"))="" then
		FoundErr=True
		ErrMsg=ErrMsg & "<br><li>模板预览图地址不能为空！</li>"
	end if
	if trim(request("DesignerName"))="" then
		FoundErr=True
		ErrMsg=ErrMsg & "<br><li>模板设计者姓名不能为空！</li>"
	end if
	if trim(request("DesignerEmail"))="" then
		FoundErr=True
		ErrMsg=ErrMsg & "<br><li>模板设计者邮箱不能为空！</li>"
	end if
end sub

sub SaveSkin()
	rs("SkinName")=trim(request("SkinName"))
	rs("PicUrl")=trim(request("PicUrl"))
	rs("DesignerName")=trim(request("DesignerName"))
	rs("DesignerEmail")=trim(request("DesignerEmail"))
	rs("DesignerHomePage")=trim(request("DesignerHomepage"))
	dim Skin_CSS
		Skin_CSS= request("Skin_CSS")
	rs("Skin_CSS")=Skin_CSS
	rs.update
	Call GetCreateIndex
end sub

sub DelSkin()
	if SkinID="" then
		FoundErr=True
		ErrMsg=ErrMsg & "<br><li>请指定SkinID</li>"
		exit sub
	else
		SkinID=Clng(SkinID)
	end if
	sql="select * from Skin where SkinID=" & SkinID
	Set rs=Server.CreateObject("Adodb.RecordSet")
	rs.Open sql,conn,1,3
	if rs.bof and rs.eof then
		FoundErr=True
		ErrMsg=ErrMsg & "<br><li>找不到指定的配色模板！</li>"
	else
		if rs("DesignType")=0 then
			FoundErr=True
			ErrMsg=ErrMsg & "<br><li>不能删除系统自带的模板！</li>"
		elseif rs("IsDefault")=True then
			FoundErr=True
			ErrMsg=ErrMsg & "<br><li>当前模板为默认模板，不能删除。请先将默认模板改为其他模板后再来删除此模板。</li>"
		end if
	end if
	if FoundErr=True then
		rs.close
		set rs=nothing
		exit sub
	end if
	rs.delete
	rs.update
	rs.close
	set rs=nothing
	dim trs
	set trs=conn.execute("select SkinID from Skin where IsDefault=True")
	set trs=nothing
	call WriteSuccessMsg("成功删除选定的模板。并将使用此模板的栏目和文章改为使用默认模板。")
	Call GetCreateIndex	
end sub

sub DoExport()
	on error resume next
	dim mdbname,tconn,trs
	SkinID=replace(SkinID,"'","")
	mdbname=replace(trim(request.form("skinmdb")),"'","")
	if SkinID="" then
		FoundErr=True
		ErrMsg=ErrMsg & "<br><li>请指定要导出的模版</li>"
	end if
	if mdbname="" then
		FoundErr=True
		ErrMsg=ErrMsg & "<br><li>请填写导出模版数据库名"
	end if
	
	if FoundErr=True then
		exit sub
	end if
	
	Set tconn = Server.CreateObject("ADODB.Connection")
	tconn.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(mdbname)
	if err.number<>0 then
		ErrMsg=ErrMsg & "<br><li>数据库操作失败，请以后再试，错误原因：" & err.Description
		err.clear
		exit sub
	end if
	tconn.execute("delete * from Skin")
	set rs=conn.execute("select * from Skin where SkinID in (" & SkinID &")  order by SkinID ")
	set trs=server.CreateObject("adodb.recordset")
	trs.open "select * from Skin",tconn,1,3
	do while not rs.eof
		trs.addnew
		trs("SkinName")=rs("SkinName")
		trs("PicUrl")=rs("PicUrl")
		trs("DesignerName")=rs("DesignerName")
		trs("DesignerEmail")=rs("DesignerEmail")
		trs("DesignerHomePage")=rs("DesignerHomePage")
		trs("Skin_CSS")=rs("Skin_CSS")
		trs("IsDefault")=False
		trs("DesignType")=rs("DesignType")
		trs.update
		rs.movenext
	loop
	trs.close
	set trs=nothing
	rs.close
	set rs=nothing
	tconn.close
	set tconn=nothing
	call WriteSuccessMsg("已经成功将所选中的模板设置导出到指定的数据库中！<br><br>你还需要将Skin文件夹中图片文件一起打包。")
end sub

sub DoImport()
	on error resume next
	dim mdbname,tconn,trs
	SkinID=replace(SkinID,"'","")
	mdbname=replace(trim(request.form("skinmdb")),"'","")
	if SkinID="" then
		FoundErr=True
		ErrMsg=ErrMsg & "<br><li>请指定要导入的模版</li>"
	end if
	if mdbname="" then
		FoundErr=True
		ErrMsg=ErrMsg & "<br><li>请填写导出模版数据库名"
	end if
	
	if FoundErr=True then
		exit sub
	end if
	
	Set tconn = Server.CreateObject("ADODB.Connection")
	tconn.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(mdbname)
	if err.number<>0 then
		ErrMsg=ErrMsg & "<br><li>数据库操作失败，请以后再试，错误原因：" & err.Description
		err.clear
		exit sub
	end if
	
	set rs=tconn.execute(" select * from Skin where SkinID in (" & SkinID &")  order by SkinID")
	set trs=server.CreateObject("adodb.recordset")
	trs.open "select * from Skin",conn,1,3
	do while not rs.eof
		trs.addnew
		trs("SkinName")=rs("SkinName")
		trs("PicUrl")=rs("PicUrl")
		trs("DesignerName")=rs("DesignerName")
		trs("DesignerEmail")=rs("DesignerEmail")
		trs("DesignerHomePage")=rs("DesignerHomePage")
		trs("Skin_CSS")=rs("Skin_CSS")
		trs("IsDefault")=False
		trs("DesignType")=rs("DesignType")
		trs.update
		rs.movenext
	loop
	trs.close
	set trs=nothing
	rs.close
	set rs=nothing
	tconn.close
	set tconn=nothing
	call WriteSuccessMsg("已经成功从指定的数据库中导入选中的模板！<br><br>你还需要将图片文件复制到Skin目录中的相应文件夹中才真正完成导入工作。")
end sub
%>