<%@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>分类信息 - <%=cf_name%></title>
<link rel="stylesheet" type="text/css" href="images/style.css" />
<script type="text/javascript" src="images/us.js"></script>
</head>

<body>
<!--#include file="top.asp"-->
<div class="con bian">
   <div class="bd_l"><!--#include file="left.asp"--></div>
   <div class="bd_r">
      <div class="title">分类信息</div>
	  <%
'//发布
if request("cmd")="add" then
call cw_yz(60)'发布间隔60S
Call Cw_yzm()
if request("pic")<>"" then
ispic=1
else
ispic=0
end if
set rs=server.CreateObject("adodb.recordset")
sql="select * from cw_info"
rs.open sql,conn,1,3
rs.addnew
rs("title")=trim(request("title"))
rs("content")=replace(request("content"),chr(13),"<br />")
rs("classid")=request("classid")
rs("adddate")=now()
rs("ispass")=info_pass
rs("userid")=session("userid")
rs("pic")=request("pic")
rs("ispic")=ispic
rs("names")=trim(request("names"))
rs("tel")=trim(request("tel"))
rs("email")=trim(request("email"))
rs("qq")=trim(request("qq"))
rs("address")=trim(request("address"))
rs("ip")=Request.ServerVariables("REMOTE_ADDR")
rs("ispass")=info_pass
rs.update
id=rs("id")
rs.close
set rs=nothing
call cw_jf("+",2)
if info_pass=1 then
  call c_show(id,2,"1",0,"cw_info")'生成信息
end if
response.Write("<div class='msg'><h1 class='msg_t'>恭喜您，信息发布成功！</h1></div>")  
response.Write("<script>var url='cw_info.asp?act=list'; setTimeout('location.href=(url)',2000)</script>")
response.End()
end if

'//修改
if request("cmd")="update" then
Call Cw_yzm()
if request("pic")<>"" then
ispic=1
else
ispic=0
end if
set rs=server.CreateObject("adodb.recordset")
sql="select * from cw_info where id="&request("id")&" and userid="&session("userid")
rs.open sql,conn,1,3
pic=rs("pic")
rs("title")=request("title")
rs("content")=replace(request("content"),chr(13),"<br />")
rs("classid")=request("classid")
rs("pic")=request("pic")
rs("ispic")=ispic
rs("names")=request("names")
rs("tel")=request("tel")
rs("email")=request("email")
rs("qq")=trim(request("qq"))
rs("address")=request("address")
rs("ispass")=info_pass
rs.update
rs.close
set rs=nothing
if pic<>request("pic") then ce_del(cf_root&pic)'删除图片
if info_pass=1 then
  call c_show(request("id"),2,"1",0,"cw_info")
end if
response.Write("<div class='msg'><h1 class='msg_t'>恭喜您，信息修改成功！</h1></div>")  
response.Write("<script>var url='cw_info.asp?act=list'; setTimeout('location.href=(url)',2000)</script>")
end if

'//批量操作
if request("cmd")="del" then
	 set dl=server.CreateObject("adodb.recordset")
	 dlq="select * from cw_info where id in("&request("id")&") and userid="&session("userid")
	 dl.open dlq,conn,1,3
	 if not dl.eof then
	   pic=dl("pic")
	   if pic<>"" then cw_del(cf_root&pic)
	   html=cf_root&cw_class("html","cw_info_class",dl("classid"))&dl("id")&".html"
	   if html<>"" then cw_del(html)
	   dl.delete
	 end if
	 dl.close
	 set dl=nothing
	 call cw_jf("-",2)
	 response.Write("<div class='msg'><h1 class='msg_t'>恭喜您，信息删除成功！</h1></div>")  
	 response.Write("<script>var url='cw_info.asp?act=list'; setTimeout('location.href=(url)',2000)</script>")
end if
%>
 <%if request("act")="list" then%>
<table width="97%" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#CCCCCC" >
            <tr>
        <td width="6%" align="center" bgcolor="#F0F3F5">序号</td>
        <td width="48%" align="center" bgcolor="#F0F3F5">标题</td>
        <td width="12%" align="center" bgcolor="#F0F3F5">分类</td>
		<td width="10%" align="center" bgcolor="#F0F3F5">状态</td>
        <td width="12%" align="center" bgcolor="#F0F3F5">管理</td>
      </tr>
    <%
		set rs1=server.CreateObject("adodb.recordset")
		sql="select * from cw_info where userid="&session("userid")&" order by id desc"
		rs1.open sql,conn,1,1
		if not rs1.eof then
		sj=1'序号
		         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				
		%>
      <tr>
        <td align="center" bgcolor="#FFFFFF"><%=sj%></td>
        <td bgcolor="#FFFFFF">&nbsp;<a href='<%=cf_root&cw_class("html","cw_info_class",rs1("classid"))&rs1("id")&".html"%>' target="_blank"><%=rs1("title")%></a></td>
        <td align="center" bgcolor="#FFFFFF" ><%=cw_class("title","cw_info_class",rs1("classid"))%></td>
		<td align="center" bgcolor="#FFFFFF" ><%if rs1("ispass")=0 then%><span class="nopass">待审核</span><%else%><span class="ispass">己审核</span><%end if%></td>
		<td align="center" bgcolor="#FFFFFF" ><a href="cw_info.asp?act=update&id=<%=rs1("id")%>" style="color:#009900">编辑</a> | <a href="cw_info.asp?id=<%=rs1("id")%>&cmd=del" onclick="return confirm('你确定要删除？')" style="color:#FF0000">删除</a></td>
      </tr>
	      <%
		  sj=sj+1
		 rs1.MoveNext
 		next
		end if
		else
		  response.Write("<td colspan=6 align=center bgcolor=#FFFFFF>Hi,你还没有发布分类信息，<a href='cw_info.asp?act=add'>点此去发布&gt;&gt;</a></td>")
		end if
		rs1.close
		set rs1=nothing
		%>
      <tr >
        <td colspan="5" align="center" bgcolor="#FFFFFF"><!--#include file="cw_page.asp"--></td>
      </tr>
    </table>
<%end if%>
<%if request("act")="update" then%>
	<%
set rr=server.CreateObject("adodb.recordset")
rq="select * from cw_info where id="&request("id")&""
rr.open rq,conn,1,1
if rr("userid")<>session("userid") then response.write("<script>alert('非法操作！');parent.admin()</script>")
%>
<table width="100%" border="0">
<form method="post" name="form1" action="cw_info.asp" onsubmit="return check_info(this)">  
  <tr>
    <td width="100"  align="right">信息标题：</td>
    <td><input name="title" type="text" id="title" value="<%=rr("title")%>" size="60" /></td>
  </tr>
  <tr>
    <td  align="right">所属分类：</td>
    <td>
	<select name="classid" id="classid">
	<%
	set rf=server.CreateObject("adodb.recordset")
	rfq="select * from cw_info_class where followid=0 order by ordnum asc,id asc"
	rf.open rfq,conn,1,1
	if not rf.eof then
	do while not rf.eof 
	set rs=server.CreateObject("adodb.recordset")
	rsq="select * from cw_info_class where followid="&rf("id")&" order by ordnum asc,id asc"
	rs.open rsq,conn,1,1
		if rs.recordcount>0 then
	%>
	<optgroup label="<%=rf("title")%>" style="color:#FF0000"></optgroup>
	<%
	else
	%>
	<option value="<%=rf("id")%>" <%if rr("classid")=rf("id") then%>selected="selected"<%end if%>>&nbsp;&nbsp;<%=rf("title")%></option>
	<%
	end if
	if not rs.eof then
	do while not rs.eof
	set rq=server.CreateObject("adodb.recordset")
	rqq="select * from cw_info_class where followid="&rs("id")&" order by ordnum asc,id asc"
	rq.open rqq,conn,1,1	
	if rq.recordcount>0 then
	%>
	<optgroup label="<%=rs("title")%>" style="color:#FF0000"></optgroup>
	<%else%>
	<option value="<%=rs("id")%>" <%if rr("classid")=rs("id") then%>selected="selected"<%end if%>>&nbsp;&nbsp;<%=rs("title")%></option>
	<%
	end if
	if not rq.eof then
	do while not rq.eof
	%>
	<option value="<%=rq("id")%>" <%if rr("classid")=rq("id") then%>selected="selected"<%end if%>>&nbsp;&nbsp;&nbsp;&nbsp;<%=rq("title")%></option>
	<%
		rq.movenext
		loop
		end if
		rq.close
		set rq=nothing	
	rs.movenext
	loop
	end if
	rs.close
	set rs=nothing
	  rf.movenext
	  loop
	  end if
	  rf.close
	  set rf=nothing
	  %>
    </select></td>
  </tr> 
  <tr>
    <td  align="right">信息内容：</td>
    <td><textarea name="content" cols="80" rows="15" id="content"><%=replace(rr("content"),"<br />",chr(13))%></textarea></td>
  </tr>
  <tr>
    <td  align="right">缩 略 图：</td>
    <td><input type="text" name="pic" id="pic" value="<%=rr("pic")%>" readonly="" size="40"  /><iframe src="../inc/upload.asp?lei=5&pid=pic&fid=fm" frameborder="0" width="400" height="25" scrolling="No" id="fm" style="display:none"></iframe> <button onclick="document.getElementById('pic').style.display='none';document.getElementById('fm').style.display='inline';document.getElementById('s1').style.display='none'" id="s1" style="cursor:pointer;">上传图片</button></td>
  </tr>   
   <tr>
    <td  align="right">联系人：</td>
    <td><input name="names" type="text" id="names" value="<%=rr("names")%>" />
      &nbsp;&nbsp;联系电话：
        <input name="tel" type="text" id="tel" value="<%=rr("tel")%>" /></td>
  </tr>
  <tr>
    <td  align="right">E-Mail：</td>
    <td><input name="email" type="text" id="email" value="<%=rr("email")%>" />
      &nbsp;&nbsp;联系 Q Q：
        <input name="qq" type="text" id="qq" value="<%if rr("qq")=0 then%><%else%><%=rr("qq")%><%end if%>" /></td>
  </tr>
  <tr>
    <td  align="right">联系地址：</td>
    <td><input name="address" type="text" id="address" value="<%=rr("address")%>" size="60" /></td>
  </tr>
  <tr>
    <td  align="right">验 证 码：</td>
    <td><input name="yzm" type="text" id="yzm" size="10" /> <img src="../inc/code.asp" width="80" height="25" alt="看不清单击刷新" onclick="this.src='../inc/code.asp?' + Math.random();" style="cursor:pointer" align="absmiddle" title="单击刷新验证码" /></td>
  </tr>
  <tr>
    <td  align="right">&nbsp;</td>
    <td><input name="Submit3" type="submit" class="btn" value="修改信息" />
      <input name="id" type="hidden" id="id" value="<%=rr("id")%>" />
      <input name="cmd" type="hidden" id="cmd" value="update" /></td>
  </tr>
  </form>
</table>
  <%
  rr.close
  set rr=nothing
  %>
<%end if%>
<%if request("act")="add" then%>
<table width="99%" border="0">
<form method="post" name="form1" action="cw_info.asp" onsubmit="return check_info(this)">  
  <tr>
    <td width="100"  align="right">信息标题：</td>
    <td><input name="title" type="text" id="title" size="60" /></td>
  </tr>
  <tr>
    <td  align="right">所属分类：</td>
    <td>
	<select name="classid" id="classid">
	<option value="">&nbsp;&nbsp;请选择</option>
	<%
	set rf=server.CreateObject("adodb.recordset")
	rfq="select * from cw_info_class where followid=0 order by ordnum asc,id asc"
	rf.open rfq,conn,1,1
	if not rf.eof then
	do while not rf.eof 
	set rs=server.CreateObject("adodb.recordset")
	rsq="select * from cw_info_class where followid="&rf("id")&" order by ordnum asc,id asc"
	rs.open rsq,conn,1,1	
	if rs.recordcount>0 then
	if not rs.eof then
	%>
	<optgroup label="<%=rf("title")%>" style="color:#FF0000"></optgroup>
	<%
	else
	%>
	<option value="<%=rf("id")%>">&nbsp;&nbsp;<%=rf("title")%></option>
	<%
	end if
	do while not rs.eof
	set rq=server.CreateObject("adodb.recordset")
	rqq="select * from cw_info_class where followid="&rs("id")&" order by ordnum asc,id asc"
	rq.open rqq,conn,1,1	
	if rq.recordcount>0 then
	%>
	<optgroup label="<%=rs("title")%>" style="color:#FF0000"></optgroup>
	<%else%>
	<option value="<%=rs("id")%>">&nbsp;&nbsp;<%=rs("title")%></option>
	<%
	end if
	if not rq.eof then
	do while not rq.eof
	%>
	<option value="<%=rq("id")%>">&nbsp;&nbsp;&nbsp;&nbsp;<%=rq("title")%></option>
	<%
		rq.movenext
		loop
		end if
		rq.close
		set rq=nothing	
	rs.movenext
	loop
	end if
	rs.close
	set rs=nothing
	  rf.movenext
	  loop
	  end if
	  rf.close
	  set rf=nothing
	  %>
    </select></td>
  </tr>      
  <tr>
    <td  align="right">信息内容：</td>
    <td><textarea name="content" cols="80" rows="15" id="content" ></textarea></td>
  </tr> 
  <tr>
    <td  align="right">缩 略 图：</td>
    <td><input type="text" name="pic" id="pic" value="" readonly="" size="40" style="display:none"  /><iframe src="../inc/upload.asp?lei=5&pid=pic&fid=fm" frameborder="0" width="400" height="25" scrolling="No" id="fm"></iframe></td>
  </tr>  
  <tr>
    <td  align="right">联 系 人：</td>
    <td><input name="names" type="text" id="names" value="<%=session("names")%>" />
      &nbsp;&nbsp;联系电话：<input name="tel" type="text" id="tel" value="<%=session("tel")%>" /></td>
  </tr>
  <tr>
    <td  align="right">E-Mail：</td>
    <td><input name="email" type="text" id="email" value="<%=session("email")%>" />
      &nbsp;&nbsp;联系 Q Q：<input name="qq" type="text" id="qq" value="<%=session("qq")%>" /></td>
  </tr>
  <tr>
    <td  align="right">联系地址：</td>
    <td><input name="address" type="text" id="address" size="60" value="<%=session("address")%>" /></td>
  </tr>
  <tr>
    <td  align="right">验 证 码：</td>
    <td><input name="yzm" type="text" id="yzm" size="10" /> <img src="../inc/code.asp" width="80" height="25" alt="看不清单击刷新" onclick="this.src='../inc/code.asp?' + Math.random();" style="cursor:pointer" align="absmiddle" title="单击刷新验证码" /></td>
  </tr>
  <tr>
    <td  align="right">&nbsp;</td>
    <td><input name="Submit3" type="submit" class="btn" value="发布信息" />
      <input name="cmd" type="hidden" id="cmd" value="add" /></td>
  </tr>
  </form>
</table>
<%end if%>

   </div>
   <div class="clear"></div>
</div>
<div class="line"></div>
<!--#include file="foot.asp"-->
<%
call closes()
%>
</body>
</html>
