<!--#include file="../conn.asp"-->
<!--#include file="admin_check.asp"-->
<!--#include file="../inc/Function.asp"-->
<%
Response.Buffer = True 
Response.Expires = -1
Response.ExpiresAbsolute = Now() - 1 
Response.Expires = 0 
Response.CacheControl = "no-cache"
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<title>管理页面</title>
<link id="maincss" rel="stylesheet" href="images/css/admin_style_<%= AdminSkin %>.css" type="text/css" media="all" />
<style type="text/css">
<!--
ul {
	margin: 0px;
	padding: 0px;
}
span {
	font-family: "宋体";
}
-->
</style>
<script language="javascript">
function showImages()
{
  if(i.style.display=='none')
  {
  i.style.display='block';
  f.src="Images/Folder/folderopen.gif";
  }
  else
  {
  i.style.display='none';
  f.src="Images/Folder/folderclosed.gif";
  }
}
</script>
</head>
<body leftmargin="0" bottommargin="0" rightmargin="0" topmargin="5" marginheight="0" marginwidth="0" bgcolor="#DDEEFF">
<table class="tableBorder" cellspacing="1" cellpadding="2" width="96%" align="center" border="0">
  <tr>
	<th height="25" align="left">模板管理</th>
  </tr>
  <tr>
    <td class="TableRow1"><a href="admin_Template.asp">模板选择</a> | <a href="admin_TempModi.asp?action=default">当前模板管理</a></td>
  </tr>
</table><br>
<%
opendb
Dim action
action=Trim(Request.QueryString("action"))

Dim TemD
Set TemD = Server.CreateObject("KwAsk.TempModi")
select case action
  case "showfile"
    call ShowFile()
  case "modisave"
    call modisave()
  case else
    call main()
end select
Set TemD=Nothing

closedb

Sub ModiSave()
    Dim FileContent,Path
	FileContent=Trim(Request.Form("filecontent"))
	Path=Trim(Request.Form("path"))
	Path=Server.MapPath(Path)
	Call TemD.BuildFile(Path,filecontent)
	Call SendMsg("模板修改成功！")
	Response.Write("<script>setTimeout(""history.go(-2)"",2000);</scr"&"ipt>")
End Sub

Sub ShowFile()
Dim Path,FileName,Fext
Path=Trim(Request.QueryString("path"))
FileName=Trim(Request.QueryString("filename"))
Fext=Trim(Request.QueryString("fext"))
%>
<table class="tableBorder" cellspacing="1" cellpadding="2" width="96%" align="center" border="0">
  <tr>
	<th height="25" align="left">模板文件查看修改</th>
  </tr>
<%
IF Fext="html" or Fext="xml" or Fext="css" Then
%>
<form action="?action=modisave" method="post">
  <input name="path" type="hidden" value="<%= Path&FileName %>">
  <tr>
    <td align="center" class="TableRow1">
    <textarea name="filecontent" cols="126" rows="36" id="filecontent"><%=server.HTMLEncode( TemD.ReadTemplate(Path&FileName) )%></textarea>    </td>
  </tr>
  <tr>
    <td align="center" class="TableRow1"><input type="submit" name="button" id="button" value="修改模板">
      &nbsp; <input type="button" name="button2" id="button2" value="返回上页" onClick="history.go(-1);"></td>
  </tr>
</form>
<%
ElseIF Fext="jpg" or Fext="gif" Then
%>
  <tr>
    <td align="center" class="TableRow1"><img src="<%= Path&FileName %>"></td>
  </tr>
  <tr>
    <td align="center" class="TableRow1"><input type="button" name="button2" id="button2" value="返回上页" onClick="history.go(-1);"></td>
  </tr>
<%
Else
%>
  <tr>
    <td align="center" class="TableRow1"><img src="images/filetype_other.gif"></td>
  </tr>
  <tr>
    <td align="center" class="TableRow1"><input type="button" name="button2" id="button2" value="返回上页" onClick="history.go(-1);"></td>
  </tr>
<%
End IF
%>
</table>
<%
End Sub

Sub main()
Dim rs,SkinPath
if action="default" then
   set rs=conn.execute("select SkinPath from "&predb&"system where id=1")
   SkinPath=rs(0)
   set rs=nothing
else
   SkinPath=Trim(Request.QueryString("path"))
end if
%>
<table class="tableBorder" cellspacing="1" cellpadding="2" width="96%" align="center" border="0">
  <tr>
	<th height="25" align="left">模板目录浏览</th>
  </tr>
  <tr>
    <td class="TableRow1">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td><img src="Images/Folder/Open.gif"></td>
    <td colspan="2"><b><%= SkinPath %> 目录</b></td>
    <td width="126">&nbsp;</td>
    <td width="322">&nbsp;</td>
    </tr>
  <tr>
    <td width="16"><img src="Images/Folder/Node.gif" width="16" height="22"></td>
    <td colspan="2"><span onClick="showImages()" style="cursor:hand;"><img id="f" src="Images/Folder/folderclosed.gif" align="absmiddle"> Images</span></td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    </tr>
<tbody style="display:none" id="i">
<%
IF SkinPath=""Then Response.Redirect("admin_Template.asp")
Dim Fso,sPath,sFilePath,FsoFile,DirFiles,Fext,Nodefile,typefile,i
sPath="../template/"&SkinPath&"/images/"
sFilePath = Server.MapPath(sPath)
Set Fso = Server.CreateObject("Scripting.FileSystemObject")
If Fso.FolderExists(sFilePath) Then
    Set FsoFile = Fso.GetFolder(sFilePath)
	i=0
    For Each DirFiles In FsoFile.Files
	i=i+1
	Fext = InStrRev(DirFiles.Name, ".")
	If Fext < 1 Then Fext = "" Else Fext = Lcase(Mid(DirFiles.Name, Fext + 1))
	IF Fext="html" then
	   typefile="Images/Folder/html.gif"
	ElseIf Fext="jpg" then
	   typefile="Images/Folder/jpg.gif"
	ElseIf Fext="gif" then
	   typefile="Images/Folder/gif.gif"
	ElseIf Fext="xml" then
	   typefile="Images/Folder/xml.gif"
	ElseIf Fext="css" then
	   typefile="Images/Folder/css.gif"
	ElseIf Fext="js" then
	   typefile="Images/Folder/js.gif"
	Else
	   typefile="Images/Folder/other.gif"
	End IF
	IF i=FsoFile.Files.count Then
	   Nodefile="Images/Folder/lastnode.gif"
	Else
	   Nodefile="Images/Folder/Node.gif"
	End IF
%>
  <tr>
    <td><img src="Images/Folder/HR.gif"></td>
    <td width="16"><img src="<%= Nodefile %>"></td>
    <td width="261"><a href="?action=showfile&filename=<%= DirFiles.Name %>&path=<%= sPath %>&fext=<%= Fext %>"><img src="<%= typefile %>" align="absmiddle" border="0"> <%= DirFiles.Name %></a></td>
    <td><%= TemD.GetFileSize(DirFiles.Size) %></td>
    <td>修改时间：<%= DirFiles.DateLastModified %></td>
  </tr>
<%
	Next
	Set FsoFile = Nothing
End IF
Set Fso = Nothing
%>
</tbody>
<%
sPath="../template/"&SkinPath&"/"
sFilePath = Server.MapPath(sPath)
Set Fso = Server.CreateObject("Scripting.FileSystemObject")
If Fso.FolderExists(sFilePath) Then
    Set FsoFile = Fso.GetFolder(sFilePath)
	i=0
    For Each DirFiles In FsoFile.Files
	i=i+1
	Fext = InStrRev(DirFiles.Name, ".")
	If Fext < 1 Then Fext = "" Else Fext = Lcase(Mid(DirFiles.Name, Fext + 1))
	IF Fext="html" then
	   typefile="Images/Folder/html.gif"
	ElseIf Fext="jpg" then
	   typefile="Images/Folder/jpg.gif"
	ElseIf Fext="gif" then
	   typefile="Images/Folder/gif.gif"
	ElseIf Fext="xml" then
	   typefile="Images/Folder/xml.gif"
	ElseIf Fext="css" then
	   typefile="Images/Folder/css.gif"
	ElseIf Fext="js" then
	   typefile="Images/Folder/js.gif"
	Else
	   typefile="Images/Folder/other.gif"
	End IF
	IF i=FsoFile.Files.count Then
	   Nodefile="Images/Folder/lastnode.gif"
	Else
	   Nodefile="Images/Folder/Node.gif"
	End IF
%>
  <tr>
    <td><img src="<%= Nodefile %>"></td>
    <td colspan="2"><a href="?action=showfile&filename=<%= DirFiles.Name %>&path=<%= sPath %>&fext=<%= Fext %>"><img src="<%= typefile %>" align="absmiddle" border="0"> <%= DirFiles.Name %></a></td>
    <td><%= TemD.GetFileSize(DirFiles.Size) %></td>
    <td>修改时间：<%= DirFiles.DateLastModified %></td>
    </tr>
<%
	Next
	Set FsoFile = Nothing
End IF
Set Fso = Nothing
%>
</table>
    </td>
  </tr>
</table>
<%
end sub
%>
<br>
</body>
</html>
