<!--#include file=../conn.asp-->
<!-- #include file="inc/const.asp" -->
<%Head()
	dim admin_flag
	admin_flag=",23,"
	if not master or instr(","&session("flag")&",",admin_flag)=0 then
		Errmsg=ErrMsg + "<BR><li>本页面为管理员专用，请<a href=../"&LoginUrl&" target=_top>登录</a>后进入。<br><li>您没有管理本页面的权限。"
		Call Ms_error()
	End If
		Main(1)
		Select Case Request("action")
		Case "search"''读取数据列表
		call search()
		Case "edit"
		call edit()
		Case "Toset"''批量操作
		call ToSet()
		Case "fix"
		call per()
		Case Else
		call SIndex()''搜索表单
		End Select
		Main(0)
		Footer()

sub main(Str)
if Str=1 then%>
<table width="95%" border="0" cellspacing="1" cellpadding="3"  align=center class="tableBorder">
  <tr> 
    <th height="23" colspan="8" class="tableHeaderText">文章管理中心</th>
  </tr>
  <tr> 
    <td width="16%" height="24" align="right" class="forumrow">说明：</td>
    <td width="84%" height="24" class="forumrow" colspan=7>
	<li>文章删除管理此操作不可逆；</li>
	<li>审核操作可以选定或者全部进行操作；</li>
	<li>文章属性可以进行推荐、固顶、正常；</li>
	<li>文章操作锁定、屏蔽操作；</li>
	<li>删除评论不可逆，将删除文章下所有评论</li>
	</td>
  </tr>
  <tr> 
    <td height="30" colspan=8 class="forumrow">快捷方式：<a href="Artlist.asp">管理首页</a> 
      | <a href=?action=search&t=1>所有文章</a> | <a href=?action=search&t=2>未 
      审 核</a> | <a href=?action=search&t=3>最新发布</a> | <a href=?action=search&t=4>人气Top100</a> | <a href=?action=search&t=5>24H发表</a></td>
  </tr>
<%
	Else
%>
</table>
<p></p>
<%end if
end sub

sub SIndex()''搜索%>
<form action="?action=search" method=post>
<input type=hidden name="t" value="6"> 
<tr>
<th align=left colspan=8 height=23>高级文章查询</th>
</tr>
<tr>
<td width=20% class=forumrow>注意事项</td>
<td width=80% class=forumrow colspan=7>在记录很多的情况下搜索条件越多查询越慢，请尽量减少查询条件</td>
</tr>
<tr>
<td width=20% class=forumrow>会员姓名</td>
<td width=80% class=forumrow colspan=7><input name="username" type="text" size="20">&nbsp;<input type=checkbox name="like" value="1" checked>
      完整匹配</td>
</tr>
<tr>
<td width=20% class=forumrow>文章标题</td>
<td width=80% class=forumrow colspan=7><input name="title" type="text" size="30">
</td>
</tr>
<tr>
<td width=100% class=forumrow align=center colspan=8><input name="submit" type=submit value="   搜  索   "></td>
</tr>
</form>
<%
end sub

sub search()
strFileName="Artlist.asp?action="&Request("action") & "&t="&request("t")&""
call tumppages()
dim sql
sql = " ID,Username,Title,Comefrom,Ubbs,Hits,Checked,Addtime,Locktopic,Boardid "%>
<tr>
<th colspan=8 align=left height=23>搜索结果</th>
</tr>
<FORM METHOD=POST ACTION="?action=Toset">
<tr align=center height=23>
<td class=forumRowHighlight width="18%"><B>责任编辑</B></td>
<td class=forumRowHighlight width="30%"><B>文章名称</B></td>
<td class=forumRowHighlight width="8%"><B>评论数</B></td>
<td class=forumRowHighlight width="8%"><B>锁定</B></td>
<td class=forumRowHighlight width="18%"><B>发表时间</B></td>
<td class=forumRowHighlight width="6%"><B>状态</B></td>
<td class=forumRowHighlight width="6%"><B>人气</B></td>
<td class=forumRowHighlight><B>操作</B></td>
</tr>
<%dim sqlstr
set rs=server.createobject("adodb.recordset")
Select Case Request("t")
	Case 1
		Sql = "SELECT " & sql & " from Ms_Article ORDER BY ID DESC"
	Case 2
		Sql = "SELECT " & sql & " from Ms_Article where Checked=0 ORDER BY ID DESC"
	case 3
		Sql = "SELECT top 100 " & sql & " from Ms_Article ORDER BY ID DESC"
	case 4
		Sql = "SELECT top 100 " & sql & " from Ms_Article ORDER BY hits DESC"
	case 5
		If IsSqlDataBase=1 Then
		sql="select " & sql & " from Ms_Article where datediff(hour,"&SqlNowString&",EndTime)<=24 order by ID desc"
		else
		sql="select " & sql & " from Ms_Article where datediff('h',"&SqlNowString&",EndTime)<=24 order by ID desc"
		end if
	case 6
	sqlstr=""''搜索开始
		if request("username")<>"" then
			if request("like")=1 then
			sqlstr=" username='"&request("username")&"'"
			else
			sqlstr=" username like '%"&request("username")&"%'"
			end if
		end if
		if request("Title")<>"" then
			if sqlstr<>"" then
			sqlstr=sqlstr & " and Title like '%"&request("Title")&"%'"
			else
			sqlstr=" Title like '%"&request("Title")&"%'"
			end if
		end if
		if sqlstr<>"" then
		Sql = "SELECT  " & sql & "  FROM [Ms_Article] WHERE " & Sqlstr & " ORDER BY ID DESC"
		else
		Response.Write "<tr><td colspan=8 class=forumrow>搜索条件不能都为空。</td></tr>"
		Response.End
		end if			
	case else
		Response.Write "<tr><td colspan=8 class=forumrow>错误的参数。</td></tr>"
		Response.End
	End Select
	rs.Open sql,conn,1,1
if not (rs.eof and rs.bof) then
call rspages()
do while not rs.eof and page_count<Cint(MaxPerPage)%><tr align=center height=23>
<td class=forumrow><a href="admin_user.asp?action=modify&username=<%=rs(1)%>"><%=rs(1)%></a></td>
<td class=forumrow align="left"><a href=../showart.asp?boardid=<%=rs(9)%>&id=<%=rs(0)%> target=_blank><%=rs(2)%></a></td>
<td class=forumrow><%=rs(4)%></td>
<td class=forumrow><%if rs(8)=1 then
response.Write("<font color=red>锁定</font>")
elseif rs(8)=2 then
response.Write("<font color=blue>屏蔽</font>")
else
response.Write("正常")
end if%></td>
<td class=forumrow align="left"><%=rs(7)%></td>
<td class=forumrow><%if rs(6)=0 then
response.Write("<font color=red>未审</font>")
elseif rs(6)=1 then
response.Write("<font color=green>已审</font>")
end if%>
</td>
<td class=forumrow><%=rs(5)%></td>
<td class=forumrow><input type="checkbox" name="id" value="<%=rs(0)%>"></td>
</tr>
<%page_count=page_count+1
  rs.movenext
  loop
  else
  response.Write("<tr><td colspan=8 class=forumrow>暂时数据。</td></tr>")
  end if
  if totalrec>0 then%>
<tr align="center"> 
      <td height="24" colspan="8" class=forumrow><%
		  	call showpage(strFileName)
		  %></td>
    </tr>
<%end if%>
<tr align="center"> 
      <td height="24" colspan="8" class=forumrow align="right"><input type="radio" name="paction" value="1">删除记录
	  <input type="radio" name="paction" value="2">审核操作
	  <select name="chkset">
	  <option value=""></option>
	  <option value=1>选定审核</option>
	  <option value=2>全部审核</option>
	  <option value=3>选定撤消</option>
	  <option value=4>全部撤消</option>　
	  </select>
	  <input type="radio" name="paction" value="3">文章属性
	   <select name="overset1">
	  <option value=""></option>
	  <option value=1>推荐</option>
	  <option value=2>固顶</option>
	  <option value=0>正常</option>
	  </select>
	  <input type="radio" name="paction" value="4">文章操作
	  <select name="overset2">
	  <option value=""></option>
	  <option value=1>锁定</option>
	  <option value=2>屏蔽</option>
	  <option value=0>正常</option>
	  </select>
	   <input type="radio" name="paction" value="5">删除评论
	   
	  全部选定<input type=checkbox value="on" name="chkall" onclick="CheckAll(this.form)"></td>
    </tr>
	<tr align="center"> 
      <td height="24" colspan="8" class=forumRowHighlight><input type=submit name=submit value="执行操作"  onclick="{if(confirm('确定执行操作吗?')){return true;}return false;}"></td>
    </tr>
</form>
<%end sub

sub ToSet()''执行操作
dim delid,fixid,Maxnum
response.write "<tr><th colspan=8 height=23 align=left>执行结果</th></tr>"
	if request("paction")="" then
		response.write "<tr><td colspan=8 class=forumrow>请指定相关参数。</td></tr>"
		founderr=true
	end if
	delid=replace(request.form("id"),"'","")
	delid=replace(delid,";","")
	delid=replace(delid,"--","")
	delid=replace(delid,")","")
	fixid=replace(delid,",","")
	fixid=Trim(replace(fixid," ",""))
if not founderr then
		if request("paction")=1 then''删除操作
			Maxnum=ubound(split(delid,","))
			Conn.Execute("delete from Ms_Article where id in ("&delid&")")
			conn.execute("Update Ms_setup set UserArt=UserArt-"&Maxnum&" where Cid=1")
			response.write "<tr><td colspan=8 class=forumrow>删除文章成功。</td></tr>"
		elseif request("paction")=2 then''审核操作
			if Cint(request("chkset"))=1 then
			Conn.Execute("update Ms_Article set Checked=1 where id in ("&delid&")")''审核记录
		response.write "<tr><td colspan=8 class=forumrow>选定审核成功。</td></tr>"
			elseif Cint(request("chkset"))=2 then
			Conn.Execute("update Ms_Article set Checked=1 where Checked=0")''审核记录
		response.write "<tr><td colspan=8 class=forumrow>全部审核成功。</td></tr>"
			elseif Cint(request("chkset"))=3 then
			Conn.Execute("update Ms_Article set Checked=0 where id in ("&delid&")")''撤消记录
		response.write "<tr><td colspan=8 class=forumrow>选定撤消成功。</td></tr>"
			elseif Cint(request("chkset"))=4 then
			Conn.Execute("update Ms_Article set Checked=0 where Checked=1")''撤消记录
		response.write "<tr><td colspan=8 class=forumrow>全部撤消成功。</td></tr>"
			end if
		elseif request("paction")=3 then''文章属性
			if request("overset1")=1 then
			Conn.Execute("update Ms_Article set Istop=1 where id in ("&delid&")")
			response.write "<tr><td colspan=8 class=forumrow>设置推荐成功。</td></tr>"
			elseif request("overset1")=2 then
			Conn.Execute("update Ms_Article set Istop=2 where id in ("&delid&")")
			response.write "<tr><td colspan=8 class=forumrow>设置固顶成功。</td></tr>"
			else
			Conn.Execute("update Ms_Article set Istop=0 where id in ("&delid&")")
			response.write "<tr><td colspan=8 class=forumrow>设置为普通文章。</td></tr>"
			end if
		elseif request("paction")=4 then
			if request("overset2")=1 then
			Conn.Execute("update Ms_Article set Locktopic=1 where id in ("&delid&")")
			response.write "<tr><td colspan=8 class=forumrow>设置锁定成功。</td></tr>"
			elseif request("overset2")=2 then
			Conn.Execute("update Ms_Article set Locktopic=2 where id in ("&delid&")")
			response.write "<tr><td colspan=8 class=forumrow>设置屏蔽成功。</td></tr>"
			else
			Conn.Execute("update Ms_Article set Locktopic=0 where id in ("&delid&")")
			response.write "<tr><td colspan=8 class=forumrow>设置屏蔽成功。</td></tr>"
			end if
		elseif request("paction")=5 then
		Conn.Execute("delete from Ms_Artbbs where ArtID in ("&delid&")")
		Conn.Execute("update Ms_Article set Ubbs=0 where id in ("&delid&")")
		response.write "<tr><td colspan=8 class=forumrow>删除评论成功。</td></tr>"
		else
		response.write "<tr><td colspan=8 class=forumrow>错误的参数。</td></tr>"
		end if
end if
end sub%>