<!--#include file="../Inc/Consts.inc" -->
<!--#include file="CheckAdmin.Asp"-->
<!--#Include File="Inc/Class_Setting.Asp"-->
<!--#include file="../Inc/common.Asp" -->
<!--#include file="Inc/function.asp"-->
<!--#Include File="XML.Asp"-->
<%Function CheckObjInstalled(strClassString)
	On Error Resume Next
	Dim Temp
	Err = 0
	Dim TmpObj
	Set TmpObj = Server.CreateObject(strClassString)
	Temp = Err
	IF Temp = 0 OR Temp = -2147221477 Then
		CheckObjInstalled=true
	ElseIF Temp = 1 OR Temp = -2147221005 Then
		CheckObjInstalled=false
	End IF
	Err.Clear
	Set TmpObj = Nothing
	Err = 0
End Function
'*************************************
'判断服务器Microsoft.XMLDOM
'*************************************
Function getXMLDOM
	On Error Resume Next
	Dim Temp
	getXMLDOM="Microsoft.XMLDOM"
	Err = 0
	Dim TmpObj
	Set TmpObj = Server.CreateObject(getXMLDOM)
	Temp = Err
    IF Temp = 1 OR Temp = -2147221005 Then
		getXMLDOM="Msxml2.DOMDocument.5.0"
	End IF
	Err.Clear
	Set TmpObj = Nothing
	Err = 0
end function

'*************************************
'判断服务器MSXML2.ServerXMLHTTP
'*************************************
Function getXMLHTTP
	On Error Resume Next
	Dim Temp
	getXMLHTTP="MSXML2.ServerXMLHTTP"
	Err = 0
	Dim TmpObj
	Set TmpObj = Server.CreateObject(getXMLHTTP)
	Temp = Err
    IF Temp = 1 OR Temp = -2147221005 Then
		getXMLHTTP="Msxml2.ServerXMLHTTP.5.0"
	End IF
	Err.Clear
	Set TmpObj = Nothing
	Err = 0
end function
'----------- 获得路径的文件信息 ----------------------------
function getPathList(pathName)
 dim FSO,ServerFolder,getInfo,getInfos,tempS
 getInfo=""
		Set FSO=Server.CreateObject("Scripting.FileSystemObject")
		
		Set ServerFolder=FSO.GetFolder(Server.MapPath(pathName))
			Dim ServerFolderList,ServerFolderEvery
			Set ServerFolderList=ServerFolder.SubFolders
			tempS=""
			For Each ServerFolderEvery IN ServerFolderList
                getInfo=getInfo&tempS&ServerFolderEvery.Name
                tempS="*"
			Next
            getInfo=getInfo&"|"
			Dim ServerFileList,ServerFileEvery
			Set ServerFileList=ServerFolder.Files
			tempS=""
			For Each ServerFileEvery IN ServerFileList
                getInfo=getInfo&tempS&ServerFileEvery.Name
                tempS="*"
			Next
	Set FSO=Nothing
	getInfos=split(getInfo,"|")
	getPathList=getInfos
end function

'----------- 获取文件信息 ----------------------------
function getFileInfo(FileName)
 dim FSO,File,FileInfo(3)
 Set FSO=Server.CreateObject("Scripting.FileSystemObject")
 if FSO.FileExists(Server.MapPath(FileName)) then
   Set File=FSO.GetFile(Server.MapPath(FileName))
   FileInfo(0)=File.Size
   if FileInfo(0)/1000>1 then 
     FileInfo(0)=int(FileInfo(0)/1000)&" KB"
    else
     FileInfo(0)=FileInfo(0)&" Bytes"
   end if
   FileInfo(1)=lcase(right(FileName,4))
   FileInfo(2)=File.DateCreated
   FileInfo(3)=File.Type 
 end if
   getFileInfo=FileInfo
 Set FSO=Nothing
end function
Function FileExist(FilePath) '判断是否存在文件
  FileExist=false
  Dim FSO
  Set FSO=Server.CreateObject("Scripting.FileSystemObject")
  FilePath=Server.MapPath(FilePath)
  IF FSO.FileExists(FilePath) Then FileExist=true
end Function
 dim SkinFolders,SkinFolder
  SkinFolders=split(getPathList("../templates")(0),"*")
  Dim U
Set U = New Cls_Setting

Dim JumpUrl
JumpUrl = "manage_skins.Asp"
If Request("Act") = "UpDate" Then
	If Not U.Update() Then Alert U.LastError,JumpUrl Else Alert "",JumpUrl
Else
Call Main_Guide()	
End If
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>自定义页面管理</title>
<link href="Images/Style.Css" rel="stylesheet" type="text/css" />
<link href="Images/Control.Css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="images/ajax.js"></script>
<script type="text/javascript">
 function setSkin(path,Name){ 
		  document.forms[0].otemplatepath.value=path
		  document.forms[0].submit()
  }
 </script> 
</head>
<body>
 <div align="left" style="padding:5px;">
 <%
  Sub Main_Guide()
	%>
	<form name='frm' method='post' action='manage_skins.Asp?Act=UpDate'>
	<div style="display:none">
	<%
	Dim Rs,i,j,Tmp,Tv,Tn,Formset
	Set Rs = DB("Select [templatepath] From ["&Datapre&"_Config]",1)
	if not rs.eof then
	formset = rs(0)
	%>
    <input type="hidden" name="otemplatepath" value="<%=formset%>" />
	<%
	end if			
	Rs.CLose : Set Rs = Nothing
	%>
</div>
<%
End Sub
%>
      <table border="0" cellpadding="2" cellspacing="1" class="TablePanel" width="100%">
        <tr>
	          <td class="TDHead" colspan="2">&nbsp;&nbsp;☆ 界面列表</td>
        </tr>
	 <%
	if CheckObjInstalled(getXMLDOM) and CheckObjInstalled("Scripting.FileSystemObject") then
      dim SkinXML,k,SkinPreview
      k=2
     set SkinXML=new PXML
	 for each SkinFolder in  SkinFolders
	 
      SkinXML.XmlPath="../templates/"&SkinFolder&"/skin.xml"
      SkinXML.open
	  if SkinXML.getError=0 then
	  if k/2=int(k/2) then response.write "<tr>"
	  SkinPreview="images/Control/skin.jpg"
	  if FileExist("../templates/"&SkinFolder&"/Preview.jpg") then SkinPreview="../templates/"&SkinFolder&"/Preview.jpg"
	 %>	
 		<td width="50%" style='border-bottom:1px dotted #ccc'>
 			<div class="<%if Lcase(templatepath)<>Lcase("templates/"&SkinFolder) then response.write ("un")%>selectskin">
 			<img src="<%=SkinPreview%>" alt="" border="0" class="skinimg"/>
 			  <div class="skinDes">
 			  <div style="height:38px;overflow:hidden"><b style="color:#004000"><%=SkinXML.SelectXmlNodeText("SkinName")%></b></div>
 			  <span style="height:16px;overflow:hidden;cursor:default" title="设计者:<%=SkinXML.SelectXmlNodeText("SkinDesigner")%>"><B>设计者:</B> <%=SkinXML.SelectXmlNodeText("SkinDesigner")%></span><br/>
 			  <B>发布时间:</B> <%=SkinXML.SelectXmlNodeText("pubDate")%><br/></div>
		 <%
		    if Lcase(templatepath)=Lcase("templates/"&SkinFolder&"/") then 
			  response.write ("<div class=""cskin""><img src=""images/Control/select.gif"" alt="""" border=""0"" /></div>当前界面")
			 else
			  response.write ("<a href=""javascript:setSkin('templates/"&SkinFolder&"/','"&SkinXML.SelectXmlNodeText("SkinName")&"')"">设置为当前主题</a>")
			end if
		  %>
		  </div>
 		</td>
	<%
	  end if
	 SkinXML.CloseXml
	 if k/2<>int(k/2) then response.write "</tr>"
	 k=k+1
	next
	 if k/2<>int(k/2) then response.write "</tr>"
	
	set SkinXML=nothing
   else
    response.write ("<tr><td colspan=""2"" align=""center""><div style=""background:#ffffe8;border:1px solid #95801c;padding:3px;text-align:left;"">你的系统不支持 <b>"&getXMLDOM&"</b> 或 <b>Scripting.FileSystemObject</b> 只能手动输入Skin的文件夹名称</div>")
    response.write ("<div style=""text-align:left;padding:3px""><b>界面路径:</b> Skins / <input id=""SPath"" type=""text"" size=""16"" class=""text"" value="""+blog_DefaultSkin+"""/> <input type=""button"" value=""保存界面"" class=""button"" style=""margin-bottom:-2px"" onclick=""if (document.getElementById('SPath').value.length>0) {setSkin(document.getElementById('SPath').value,document.getElementById('SPath').value)}else{alert('请输入界面路径!')}""/></div>")
    response.write ("</td></tr>")
   end if
	%>
      </table>

  </form>
  </div>
</body>
</html>