<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="admin.asp"-->
<!--#include file="../inc/config.asp"-->
<!--#include file="../inc/conn.asp"-->
<!--#include file="../inc/function.asp"-->
<!--#include file="../inc/template.asp"-->
<%
if session("type")=1 then
   response.Write("<script>alert('Sorry,没有权限操作!'); location.href='cw_right.asp'</script>")
end if
%>
<%
if request("paths")="" then
paths=cf_root&"skins/"&cf_skin'当前模板目录
else
paths=request("paths")
end if
path=request("path")
if path="" then path=cf_root&"skins/"&cf_skin

if request("act")=2 then
content=request("content")
files=trim(request("file"))
paths=request("paths")
if right(files,5)=".html" or right(files,4)=".css" or right(files,3)=".js" then
   call cw_html(content,paths,files)
   response.Redirect"cw_skin.asp?paths="&paths&"&path="&request("path")
else
   response.Write("<script>alert('文件格式不允许！');history.back();</script>")
   response.End()
end if
end if

if request("act")=3 then
call cw_del(request("paths")&request("file"))
response.Redirect"cw_skin.asp?paths="&request("paths")&"&path="&request("path")
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=gb2312" />
<title>无标题文档</title>
<link href="style/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
function checkskin(fr)
{
  if (fr.file.value=="")
  {
    alert('名称不能为空!');
	fr.file.focus();
	return false
  }
  if (fr.content.value=="")
  {
    alert('内容不能为空!');
	fr.content.focus();
	return false
  }
   return true
}
</script>
</head>

<body id="page">
<h2 class="title">模板管理</h2>
<table width="99%" border="0" align="center" class="line_table">
  <tr>
    <td height="20">&nbsp;网站后台管理 &gt;&gt; <a href="cw_skin.asp">模板管理</a></td>
  </tr>
</table>
	<%if request("act")="" then%>
	<table width="99%" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#CCCCCC">
	  <tr>
	  <td bgcolor="#FFFFFF" colspan="2"><a href="cw_skin.asp?paths=<%=path%>&pat=<%=path%>"><img src="ext/root.gif" align="absmiddle" />返回上一级</a> <a href="cw_skin.asp">><img src="ext/folder.gif" align="absmiddle" width="25" />返回根目录</a>【<a href="cw_skin.asp?act=4&path=<%=path%>&paths=<%=paths%>" style="color:#FF0000">新建模板</a>】</td>
	  </tr>
      <tr>
	  <td bgcolor="#FFFFFF" colspan="2" class="skins">
		<%'文件夹
Set Fso=CreateObject("Scripting.Filesystemobject")
	Set FsoFolder=Fso.GetFolder(Server.mappath(paths))
	Set Fsocontent=FsoFolder.files
	For Each Fsocount In FsoFolder.Subfolders
%>
		<a href="cw_skin.asp?paths=<%=paths%><%=Fsocount.Name%>/&path=<%=paths%>"><img src="ext/folder.gif" align="absmiddle" /><%=Fsocount.Name%></a>&nbsp;&nbsp;
		 <%next%>
		 </td>
		 <tr>
		 <%
		 i=1
For Each f2 in FsoFolder.files
Select Case Lcase(Right(f2.Name,3))
			Case "htm","tml"
			     picsrc="html"
			Case ".js"
			     picsrc="js"
			Case "bmp","jpg","gif","png","swf","css","txt","asp","vbs","xml","xsl"
			     picsrc=right(f2.name,3)
			Case Else
			picsrc="folder"
End Select
%><td bgcolor="#FFFFFF" >
       <img src="ext/<%=picsrc%>.gif" align="absmiddle" width="25" height="25" /><%=f2.Name%>&nbsp;&nbsp;<%if instr("html,txt,xml,htm,shtml,css,js,",picsrc&",")>0 then%>[<a href="cw_skin.asp?paths=<%=paths%>&file=<%=f2.Name%>&act=1">编辑</a>]<%end if%> [<a href="cw_skin.asp?paths=<%=paths%>&file=<%=f2.Name%>&act=3&path=<%=path%>" onclick="return confirm('你确定要删除吗？')">删除</a>]	   
	   </td>
	   <%if (i mod 2)=0 then%></tr><tr><%end if%>
		 <%
		 i=i+1
		 next
		 %>
	
	  </tr>
	  </table>
	<%end if%>
	<%if request("act")=1 then%>
	<table width="99%" border="0" align="center" cellpadding="0" cellspacing="0">
	<form action="?act=2" method="post" name="form1" id="form1" onsubmit="return checkskin(this)">
	<tr>
	  <td>文件名：
      <input name="file" type="text" id="file" value="<%=request("file")%>" />
      *例：abc.html
      <input name="paths" type="hidden" id="paths" value="<%=request("paths")%>" />
      <input name="path" type="hidden" id="path" value="<%=request("path")%>" /></td>
	</tr>
	<tr>
	   <td><textarea name="content" cols="95" rows="25" id="content"><%=server.HTMLencode(cw_redtemp(request("paths"),request("file")))%></textarea></td>
	</tr>
	<tr><td><input name="sub" type="submit" class="btn" value="修改模板" />
	  <input name="Submit" type="button" class="btn" onclick="history.back();" value="返回" /></td></tr>
	</form>
	</table>
	<%end if%>
  <%if request("act")=4 then%>
	<table width="99%" border="0" align="center" cellpadding="0" cellspacing="0">
	<form action="?act=2" method="post" name="form1" id="form1" onsubmit="return checkskin(this)">
	<tr>
	  <td>文件名：
      <input name="file" type="text" id="file" />
      *例：abc.html
      <input name="paths" type="hidden" id="paths" value="<%=request("paths")%>" /><input name="path" type="hidden" id="path" value="<%=request("path")%>" />
      （支持.html,.css,.js）</td>
	</tr>
	<tr>
	   <td><textarea name="content" cols="95" rows="25" id="content"></textarea></td>
	</tr>
	<tr><td><input name="sub" type="submit" class="btn" value="新建文件" />
	    <input name="Submit" type="button" class="btn" onclick="history.back();" value="返回" /></td></tr>
	</form>
	</table>
	<%end if%>
</body>
</html>
