<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="admin.asp"-->
<!--#include file="../inc/conn.asp"-->
<!--#include file="../inc/function.asp"-->
<!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 language="javascript" src="style/js.js"></script>
<%if request("add")=1 or request("add")=2 then%>
<script charset="utf-8" src="../inc/editor/kindeditor.js"></script>
<script charset="utf-8" src="../inc/editor/lang/zh_CN.js"></script>
<script type="text/javascript" src="style/js.js"></script>
<script type="text/javascript">
var editor;
  KindEditor.ready(function(K) {
  editor = K.create('textarea[name="content"]', {
  allowFileManager : true
  });
});

function addItem(pic)//添加到下拉列表
{ 
 var optionObj = document.createElement("OPTION");
 var addpic="<img src='/"+ pic +"' id='aa' />"
 document.getElementById('piclist').options.add(optionObj);
 optionObj.innerText = pic;
 optionObj.value = pic;
}
</script>
<%end if%>
</head>

<body id="page">
<h2 class="title">单页管理</h2>
<%'//发布单页
if request("action")=1 then
if trim(request("root"))<>"" then root=replace(request("root"),"/","")&"/"
set rs=server.CreateObject("adodb.recordset")
sql="select * from cw_pages"
rs.open sql,conn,1,3
rs.addnew
rs("title")=request("title")
rs("content")=request("content")
rs("pic")=request("lpic")
rs("html")=replace(request("html"),".html","")&".html"
rs("keyword")=request("keyword")
rs("description")=request("description")
rs("root")=root
rs("temp")=request("temp")
rs.update
id=rs("id")
rs.close
set rs=nothing
call c_pages(id,1)    
response.Write("<script>var url='cw_pages.asp'; setTimeout('location.href=(url)',2000)</script>")
response.End()
end if

'//修改单页
if request("action")=2 then
if trim(request("root"))<>"" then root=replace(request("root"),"/","")&"/"
set rs=server.CreateObject("adodb.recordset")
sql="select * from cw_pages where id="&request("id")&""
rs.open sql,conn,1,3
rs("title")=request("title")
rs("content")=request("content")
rs("pic")=request("lpic")
rs("html")=replace(request("html"),".html","")&".html"
rs("keyword")=request("keyword")
rs("description")=request("description")
rs("root")=root
rs("temp")=request("temp")
rs.update
rs.close
set rs=nothing
call c_pages(request("id"),1)     
response.Write("<script>var url='cw_pages.asp'; setTimeout('location.href=(url)',2000)</script>")
response.End()
end if
'批量操作
if request("action")=3 then
  select case request("sub")
   case 1
     set dl=server.CreateObject("adodb.recordset")
	 dlq="select * from cw_pages where id in("&request("id")&")"
	 dl.open dlq,conn,1,3
	 if not dl.eof then
	 do while not dl.eof
	 pic=Get_ImgSrc(dl("content"),1)
	 T_count=checkthechar(",",pic)'//取得*号出现的次数
     if T_count>0 then
       T_fg=split(pic,",")'//对Tags进行分割
	    for i=0 to T_count
          if T_fg(i)<>"" then  cw_del(T_fg(i))'删除图片
	    next
     end if
	 html=cf_root&dl("root")&dl("html")
	 if html<>"" then cw_del(html)'删除静态文件
	 dl.delete
	 dl.movenext
	 loop
	 response.Write("<script>alert('删除成功!')</script>")  
	 dl.close
	 set dl=nothing
	 end if
   case 2
	 call c_pages(request("id"),1)
	 response.Write("<script>var url='cw_pages.asp'; setTimeout('location.href=(url)',2000)</script>")
     response.End()
  end select
end if
%>
<table width="99%" border="0" align="center" class="line_table">
  <tr>
    <td height="20">&nbsp;网站后台管理 &gt;&gt; <a href="cw_pages.asp">单页管理</a>&nbsp;&nbsp;&nbsp;&nbsp;【<a href="cw_pages.asp?add=1" style="color:#FF0000">添加单页</a>】</td>
  </tr>
</table>
<%if request("add")="" then%>
<form action="cw_pages.asp?action=3" method="post" name="form">
<table width="99%" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#CCCCCC">
      <tr>
        <td width="6%" align="center" bgcolor="#F0F3F5">&nbsp;</td>
        <td width="9%" align="center" bgcolor="#F0F3F5">ID</td>
        <td width="42%" align="center" bgcolor="#F0F3F5">标题</td>
	<td width="15%" align="center" bgcolor="#F0F3F5">路径</td>
        <td width="11%" align="center" bgcolor="#F0F3F5">缩略图</td>
        <td width="17%" align="center" bgcolor="#F0F3F5">管理</td>
      </tr>
    <%
		set rs1=server.CreateObject("adodb.recordset")
		sql="select * from cw_pages order by id desc"
		rs1.open sql,conn,1,1
		if not rs1.eof then
		         page_count=15
  				 if Request("page")="" or Request("page")="0" then
   				  page=1
  				 else
    				 page=cint(Request("page"))
  				 End if 
					 totalcount=rs1.RecordCount
   				  totalpage=int(totalcount/page_count+(page_count-1)/page_count)
  				 if page>totalpage then page=totalpage
  				 if rs1.EOF then    
   				  else
   				  for i = 1 to (page-1)*page_count
    				   rs1.MoveNext
   				  Next
   				  if page<totalpage then
    				   psize=page_count
   				  else
   				    psize=totalcount-(page-1)*page_count
   				  End if
   				  for i = 1 to psize
url=cf_root&rs1("root")&rs1("html")

		%>
      <tr>
        <td align="center" bgcolor="#FFFFFF"><input type="checkbox" name="cid" id="cid" value="<%=rs1("id")%>" /></td>
        <td align="center" bgcolor="#FFFFFF"><%=rs1("id")%></td>
        <td bgcolor="#FFFFFF">&nbsp;<a href="<%=url%>" target="_blank"><%=rs1("title")%></a></td>
	<td bgcolor="#FFFFFF">&nbsp;<%=cf_root%><%=rs1("root")%><%=rs1("html")%></td>
        <td align="center" bgcolor="#FFFFFF"><%if rs1("pic")<>"" then%>是<%else%><font color="#CCCCCC">否</font><%end if%></td>
        <td align="center" bgcolor="#FFFFFF" ><a href="cw_pages.asp?action=3&sub=2&id=<%=rs1("id")%>">生成</a> | <a href="cw_pages.asp?add=2&id=<%=rs1("id")%>">编辑</a> | <a href="cw_pages.asp?sub=1&id=<%=rs1("id")%>&action=3" onclick="return confirm('你确定要删除？')">删除</a></td>
      </tr>
	      <%
		  rs1.MoveNext
 		next
		end if
		end if
		rs1.close
		set rs1=nothing
		%>
      <tr >
        <td colspan="6" align="center" bgcolor="#FFFFFF"><!--#include file="../inc/page.asp"--></td>
        </tr>
    </table>
	</form>
	<%end if%>
	<%if request("add")=2 then%>
	<%
set rr=server.CreateObject("adodb.recordset")
rq="select * from cw_pages where id="&request("id")&""
rr.open rq,conn,1,1
%>
<table width="99%" border="0">
<form method="post" name="form1" action="cw_pages.asp?action=2" onsubmit="return check_pages(this)">
  <tr>
    <td width="100" height="20" align="right">页面名称：</td>
    <td><input name="title" type="text" id="title" value="<%=rr("title")%>" size="60" /></td>
  </tr>  
  <tr>
    <td height="20" align="right">页面模板：</td>
    <td><input name="temp" type="text" value="<%=rr("temp")%>" size="40" />
      <input type="button" name="Submit12" value="选择" onclick="Open_w('Cw_temp.asp',320,200,window,document.form1.temp)" /></td>
  </tr>
  <tr>
    <td height="20" align="right">生成设置：</td>
    <td><input name="root" type="text" id="root" value="<%=replace(rr("root"),"/","")%>" size="16" />
      目录
      <input name="html" type="text" id="html" value="<%=replace(rr("html"),".html","")%>" size="16" />
      .html * 填写目录和文件名(不带.html) </td>
  </tr>
  <tr>
    <td height="20" align="right">页面关键词：</td>
    <td><input name="keyword" type="text" id="keyword" value="<%=rr("keyword")%>" size="90" /></td>
  </tr>
  <tr>
    <td height="20" align="right">页面描述：</td>
    <td><textarea name="description" cols="90" rows="4" id="description"><%=rr("description")%></textarea></td>
  </tr>
  <tr>
    <td height="20" align="right">信息内容：</td>
    <td><textarea id="content" name="content" style="width:700px;height:400px;visibility:hidden;"><%=rr("content")%></textarea></td>
  </tr>
  <tr>
    <td height="20" align="right">缩 略 图：</td>
    <td><input name="pic" type="text" id="pic" value="<%=rr("pic")%>" size="40" readonly="" />
      <select name="piclist" id="piclist" onchange="document.getElementById('pic').value=this.value">
      <option value="">请选择缩略图</option>
	  <%=Get_ImgSrc(rr("content"))%>
    </select></td>
  </tr>  
  <tr>
    <td height="20" align="right">&nbsp;</td>
    <td><input name="Submit3" type="submit" class="btn" onclick="checkinfoadd(this.form)" value="确定单页内容"/><input name="id" type="hidden" id="id" value="<%=rr("id")%>" /></td>
  </tr>
  </form>
</table>
  <%
  rr.close
  set rr=nothing
  %>
<%end if%>
<%if request("add")=1 then%>
<table width="99%" border="0">
<form method="post" name="form1" action="cw_pages.asp?action=1" onsubmit="return check_pages(this)">
  
  <tr>
    <td width="100" height="20" align="right">页面名称：</td>
    <td><input name="title" type="text" id="title" size="60" /></td>
  </tr>  
  <tr>
    <td height="20" align="right">分类模板：</td>
    <td><input name="temp" type="text" value="cw_page.html" size="40" />
        <input type="button" name="Submit12" value="选择" onclick="Open_w('Cw_temp.asp',320,200,window,document.form1.temp)" /></td>
  </tr>
  <tr>
    <td height="20" align="right">生成设置：</td>
    <td><input name="root" type="text" id="root" size="16" />
      目录
      <input name="html" type="text" id="html" size="16" />
      .html * 填写目录和文件名(不带.html) </td>
  </tr>
  <tr>
    <td height="20" align="right">页面关键词：</td>
    <td><input name="keyword" type="text" id="keyword" size="90" /></td>
  </tr>
  <tr>
    <td height="20" align="right">页面描述：</td>
    <td><textarea name="description" cols="90" rows="4" id="description"></textarea></td>
  </tr>
  <tr>
    <td height="20" align="right">信息内容：</td>
    <td><textarea id="content" name="content" style="width:700px;height:400px;visibility:hidden;"></textarea></td>
  </tr>
  <tr>
    <td height="20" align="right">缩 略 图：</td>
    <td><input name="pic" type="text" id="pic" size="40" readonly="" />
      <select name="piclist" id="piclist" onchange="document.getElementById('pic').value=this.value">
      <option value="">请选择缩略图</option>
    </select></td>
  </tr>   
  <tr>
    <td height="20" align="right">&nbsp;</td>
    <td><input name="Submit3" type="submit" class="btn" value="发布单页内容"/>
     </td>
  </tr>
  </form>
</table>
<%end if%>
<%
call closes()
%>
</body>
</html>
