<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="admin.asp"-->
<!--#include file="../inc/conn.asp"-->
<!--#include file="../inc/function.asp"-->
<%
if session("type")=1 then
   response.Write("<script>alert('Sorry,普通管理员没有权限操作!'); location.href='cw_right.asp'</script>")
end if

if request("act")=3 then
set rs=server.CreateObject("adodb.recordset")
rsq="select * from cw_label where label='"&request("label")&"'"
rs.open rsq,conn,1,3
if not rs.eof then
   response.Write("<script>alert('此标签己经存在，请误重复添加!'); history.back();</script>")
else
rs.addnew
rs("label")=request("label")
rs("content")=request("content")
rs("title")=request("title")
rs.update
end if
rs.close
set rs=nothing
set conn=nothing
response.Write("<script>alert('添加自定义标签成功！'); location.href='cw_label.asp'</script>")
response.End()
end if

if request("act")=5 then
set rs=server.CreateObject("adodb.recordset")
sql="select * from cw_label where label='"&request("label")&"' and id<>"&request("id")
rsq="select * from cw_label where  id="&request("id")&""
rs.open sql,conn,1,1
if not rs.eof then
   response.Write("<script>alert('此标签己经存在，请误重复添加!'); history.back();</script>")
else
rs.close
rs.open rsq,conn,1,3
rs("label")=request("label")
rs("content")=request("content")
rs("title")=request("title")
rs.update
rs.close
end if
set rs=nothing
set conn=nothing
response.Write("<script>alert('标签修改成功!'); location.href='cw_label.asp'</script>")
response.End()
end if

if request("act")=4 then
  conn.execute("delete from cw_label where id="&request("id")&"")
  response.Write("<script>alert('标签删除成功!'); location.href='cw_label.asp'</script>")
  response.End()
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" src="style/js.js"></script>
</head>

<body id="page">
<h2 class="title">自定义标签</h2>
<table width="99%" border="0" align="center" class="nav">
  <tr>
    <td height="20">&nbsp;网站后台管理 &gt;&gt; <a href="cw_label.asp">自定义标签</a>&nbsp;&nbsp;&nbsp;&nbsp;【<a href="cw_label.asp?act=1" style="color:#FF0000">新建标签</a>】</td>
  </tr>
</table>
	<%if request("act")="" then%>
	<table width="99%" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#CCCCCC">
      <tr>
        <td width="6%" align="center" bgcolor="#F0F3F5">ID</td>
        <td width="20%" align="center" bgcolor="#F0F3F5">标签</td>
        <td width="34%" align="center" bgcolor="#F0F3F5">说明</td>
        <td width="18%" align="center" bgcolor="#F0F3F5">管理</td>
      </tr>
      <%
		set rs=server.createobject("adodb.recordset")
sql="select * from cw_label order by id asc"
rs.open sql,conn,1,1
if not rs.eof then
do while not rs.eof
		  %>
      <tr >
        <td align="center" bgcolor="#FFFFFF"><%=rs("id")%></td>
        <td bgcolor="#FFFFFF">&nbsp;&nbsp;{cw_<%=rs("label")%>}</td>
        <td bgcolor="#FFFFFF" >&nbsp;&nbsp;<%=rs("title")%></td>
        <td align="center" bgcolor="#FFFFFF" ><a href="cw_label.asp?act=2&amp;id=<%=rs("id")%>">编辑</a> | <a href="cw_label.asp?id=<%=rs("id")%>&amp;act=4" onclick="return confirm('你确定要删除？')">删除</a></td>
      </tr>
      
      <%
		  rs.movenext
		  loop
		  end if 
		  rs.close
		  set rs=nothing
		  %>
    </table>
	<%end if%>
	<%if request("act")=1 then%>
      <table width="99%" border="0">
	  <form id="form1" name="form1" method="post" onsubmit="return check_label(this)" action="?act=3">
        <tr>
          <td width="15%" align="center">&nbsp;</td>
          <td width="85%"><h3>新建标签</h3></td>
        </tr>
        
        <tr>
          <td align="right">标签：</td>
          <td>CW_
          <input name="label" type="text" id="label" maxlength="20" /> 
          *{cw_about}全局调用模式 </td>
        </tr>
        <tr>
          <td align="right">内容：</td>
          <td><textarea name="content" cols="70" rows="12" id="content"></textarea></td>
        </tr>
        <tr>
          <td align="right">备注：</td>
          <td><input name="title" type="text" id="title" size="60" maxlength="200" /> 
          *只作为后台标注说明 </td>
        </tr>
        <tr>
          <td>&nbsp;</td>
          <td><input name="Submit" type="submit" class="btn" onclick="checkform()" value="添加自定义标签" /></td>
        </tr>
		</form>
    </table>
	<%end if%>
	<%if request("act")=2 then%>
	<%
	if request("id")="" then
	  response.Write("<script>alert('参数错误!'); history.back();</script>")
	end if
	set rs=server.CreateObject("adodb.recordset")
	sql="select * from cw_label where id="&request("id")&""
	rs.open sql,conn,1,1
	if not rs.eof then
	%>
      <table width="99%" border="0">
	  <form id="form1" name="form1" method="post" onsubmit="return check_label(this)" action="?act=5">
        <tr>
          <td width="15%" align="center">&nbsp;</td>
          <td width="85%"><h3>修改标签</h3></td>
        </tr>
        
        <tr>
          <td align="right">标签：</td>
          <td>CW_
          <input name="label" type="text" id="label" value="<%=rs("label")%>" maxlength="20" />
          <input name="id" type="hidden" id="id" value="<%=rs("id")%>" /></td>
        </tr>
        <tr>
          <td align="right">内容：</td>
          <td><textarea name="content" cols="70" rows="12" id="content"><%=rs("content")%></textarea></td>
        </tr>
        <tr>
          <td align="right">备注：</td>
          <td><input name="title" type="text" id="title" value="<%=rs("title")%>" size="60" maxlength="200" /></td>
        </tr>
        <tr>
          <td>&nbsp;</td>
          <td><input name="Submit" type="submit" class="btn" onclick="checkform()" value="修改自定义标签" /></td>
        </tr>
		</form>
    </table>
	<%
	end if
	rs.close
	set rs=nothing
	%>
<%end if%>
<%call closes()%>
</body>
</html>
