<!--#include file="../inc/config.asp"-->
<!--#include file="../inc/conn.asp"-->
<!-- #include file="inc/Session.asp" -->
<!-- #include file="inc/checkrole.asp" -->
<%
'''''''''''''''''''''''''''''''''''''''''''''''
call checkPrevilege(Session("Name"),"p02")
'''''''''''''''''''''''''''''''''''''''''''''''
BeginTime=Timer
const recpage=20
dim i,classid,currentpage,n,p,countsql,newssql
if not isempty(request("classid")) then 
	classid=Cint(request("classid"))
else
	classid=0
end if
if not isempty(request("page")) then 
	currentpage=request("page")
else 
	currentpage=1
end if
'获得大类
dim first
set rs=server.CreateObject("adodb.recordset")
rs.open "select id,title from catalogs where parentid=0 order by id asc",conn,3,1
if not rs.eof then
	first=rs.GetRows()
else	
end if
rs.close
set rs=nothing

Function getcatalogs(parentid,str)
	Dim Sql,rstemp,TemptempStr,tempStr	
	tempStr=str&"&nbsp;"
	sql="select id,title from catalogs where parentid="&parentid
	Set rstemp = Conn.Execute(Sql)
	do while Not rstemp.Eof
		catalogIdStr=rstemp(0)
		catalogTitleStr=rstemp(1)
		
		getcatalogs = getcatalogs &"<option value="&catalogIdStr&">│"&tempStr&"└"&catalogTitleStr&"</option>"&Chr(10)
		getcatalogs = getcatalogs & getcatalogs(catalogIdStr,tempStr)
		rstemp.MoveNext
	loop	
	rstemp.close
	Set rstemp = Nothing
End Function
Function getcatalogoption()
	dim ret
	ret=""
	for i=0 to ubound(first,2)
		ret=ret&"<option value="&first(0,i)&">├"&first(1,i)&"</option>"&Chr(10)
    	ret=ret&getcatalogs(first(0,i),"")
	next
	getcatalogoption=ret
end Function
%>
<html>
<head>
<title>新闻管理</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style type="text/css">
<!--
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
	background-color: #FFFFFF;
	font-size:12px;
}
-->
</style>
<link href="cs.css" rel="stylesheet" type="text/css">
<script language="javascript">
function goto(frm)
{
	var gourl ="news_manage.asp?classid=<%=classid%>&";
	gourl += "page=" + (frm.page.value);
     var hid=parseInt(frm.hid.value);
	 if(parseInt(frm.page.value)>hid||frm.page.value<=0){
	 alert("错误！请确定你输入的数字在1-"+hid+"之间");
	 return false;
	 }
	window.location.href(gourl);
}</script>
<script language="JavaScript" type="text/JavaScript">

function ConfirmDel()
{
   if(confirm("确认删除？并且不能恢复！确定要删除此信息吗？"))
     return true;
   else
     return false;
	 
}
</script>
<style type="text/css">
<!--
.style1 {
	color: #FFFFFF;
	font-weight: bold;
}
form{margin:0;}
-->
</style>
</head>

<body>
<table width="100%"  border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td><iframe src="right_top.htm" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" height="30" width="100%"></iframe></td>
  </tr>
</table>
<form action="news_do.asp" method="post" enctype="application/x-www-form-urlencoded">
<table width="100%"  border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#999999">
  <tr bgcolor="#FF9900">
    <td height="22" colspan="9"><div align="center" class="style1">◆ 文章管理 ◆</div></td>
  </tr>
  <tr bgcolor="#EEEEEE">
    <td width="6%">&nbsp;</td>
    <td width="5%" height="22"><div align="center">ID</div></td>
    <td width="11%"><div align="center">图片</div></td>
    <td width="6%"><div align="center">转向链接</div></td>
    <td width="39%"><div align="center">新闻标题</div></td>
    <td width="13%"><div align="center">添加时间</div></td>
    <td width="4%"><div align="center">审核</div></td>
    <td width="8%"><div align="center">修改</div></td>
    <td width="8%"><div align="center">删除</div></td>
  </tr>
  <!-- 开始按行循环----------------------->
  <%
  		set rs=server.createobject("adodb.recordset")
		if(classid=0) then
			countsql="select count(*) AS co from news"
		else
			countsql="select count(*) AS co from news where classid="&classid
		end if
  		rs.open countsql,conn,3,1
		allrec=rs("co")
		totalpage=int((allrec+recpage-1)/recpage)
		rs.close
		set rs=nothing
		set rs=server.createobject("adodb.recordset")
		if(currentpage=1) then
			if(classid=0) then
				newssql="select top "&recpage&" id,photo,isoutlink,pagepath,title,moditime,checked,classid from news order by id desc"
			else
				newssql="select top "&recpage&" id,photo,isoutlink,pagepath,title,moditime,checked,classid from news where classid="&classid&" order by id desc"
			end if			
		else
			if(classid=0) then
				newssql="select top "&recpage&" id,photo,isoutlink,pagepath,title,moditime,checked,classid from news where id <(select min(id) from (select top "&(recpage*(currentpage-1))&" id from news order by id desc) as t) order by id desc "
			else
				newssql="select top "&recpage&" id,photo,isoutlink,pagepath,title,moditime,checked,classid from news where id <(select min(id) from(select top "&(recpage*(currentpage-1))&" id from news where classid="&classid&" order by id desc) as t) and classid="&classid&" order by id desc "
			end  if
			
		end if
		rs.open newssql,conn,3,1
		if rs.eof or rs.bof then
			response.Write("请先选择左边的分类来显示相应的信息!")
			response.End()
		else
			do while not rs.eof or rs.bof
			'classname=conn.execute("select title from catalogs where id="&rs("classid"))(0)
	%>
  <tr>
    <td bgcolor="#FFFFFF"><div align="center"><input type="checkbox" name="newsid" value=<%=rs("id")%>></div></td>
    <td height="20" bgcolor="#FFFFFF"><div align="center"><%=rs("id")%></div></td>
    <td bgcolor="#FFFFFF"><div align="center">
	<%if rs("photo")<>"" then%>
	<a href="../pic/<%=rs("photo")%>" target="_blank"><img src="../pic/<%=rs("photo")%>" width="39" height="37" border="0"></a>
	<%
	else
		response.Write("没有图片")
	end if
	%>
	</div></td>
    <td bgcolor="#FFFFFF"><div align="center"><%if(rs("isoutlink")=0) then response.Write("否") else response.Write("<font color=""red"">是</font>") end if%></div></td>
    <td bgcolor="#FFFFFF"><div align="left">&nbsp;<a href="<%if(rs("isoutlink")=0) then response.write("/"&rs("pagepath")) else response.write(rs("pagepath")) end if%>" target="_blank"><%=rs("title")%></a></div></td>
    <td bgcolor="#FFFFFF"><div align="center"><%=rs("moditime")%></div></td>
    <td bgcolor="#FFFFFF">
	<div align="center">
	<%
	if(rs("checked")=true) then 
		response.Write("√ ")
	else
		response.Write("×")
	end if
	%>
	</div></td>
    <td bgcolor="#FFFFFF"><div align="center"><a href="news_modi.asp?id=<%=rs("id")%>&classid=<%=rs("classid")%>">修改</a></div></td>
    <td bgcolor="#FFFFFF"><div align="center"><a href="dele.asp?id=<%=rs("id")%>&table=news" onClick="return ConfirmDel()">删除</a></div></td>
  </tr>
  
  <%
    rs.movenext
	  i=i+1
	   if i>=recpage then 
		exit do
	   end if
	  loop
	 end if
	  rs.close
	  set rs=nothing
  %>
  <tr>
    <td height="22" colspan="9" bgcolor="#FFFFFF">
	<table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="42%">
          <div align="right">
            <input class=Button type="button" name="chkall" value="全选" onClick="CheckAll(this.form)">
            <input class=Button type="button" name="chksel" value="反选" onClick="ContraSel(this.form)">
            管理选项：
  <select name="act" onChange="changeAct(this)">
    <option value="0">请选择操作选项↓</option>
    <option value="del" style="background-color:#CCCCCC;">→批量删除</option>
    <option value="top" style="background-color:#CFEAFE;">→批量置顶</option>
    <option value="notTop">→取消置顶</option>
    <option value="recomme" style="background-color:#CFEAFE;">→批量推荐</option>
    <option value="notRecomme">→取消推荐</option>
    <option value="check" style="background-color:#CFEAFE;">→批量审核</option>
    <option value="noCheck">→取消审核</option>
    <option value="remove" style="background-color:#CFEAFE;">→批量移动</option>
  </select>
            </div></td>
        <td width="36%" id="removeContain" style="display:none; ">
          <div align="center">移动至→
            <select name="toCatalogId" id="toCatalogId" size="1">             
			<%
			catalogcache=application(CachePrefix&"_catalogoption_0")
			if(catalogcache="" or isempty(catalogcache) or len(catalogcache)<1) then
  				application.Lock()
				application(CachePrefix&"_catalogoption_0")=getcatalogoption()
				application.UnLock()
				response.Write(application(CachePrefix&"_catalogoption_0"))
			else
				response.Write(catalogcache)
			end if
			%>
                </select>  
 			</div>
          </div></td>
        <td width="22%"><input class=Button type="submit" name="Submit2" value="执行操作" onClick="return confirm('您确定执行该操作吗?')"></td>
      </tr>
    </table>	
  </td>
  </tr>
  <!--按行循环结束------------------------>
</table></form>
<table width="100%" height="20"  border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td><form name="form1" method="post" action="" style="margin:0 0 0 0">
          <div align="center">
            <%n=currentpage+1
p=currentpage-1
if p>0then
response.write("["&"<a href='news_manage.asp?classid="&classid&"&page="&cstr(p)&"'>上一页</a>]&nbsp;&nbsp;&nbsp;")
else response.write("上一页&nbsp;&nbsp;&nbsp;")
end if 
if (n-1)*recpage>=allrec then 
response.write("下一页" )
else
response.Write("["&"<a href='news_manage.asp?classid="&classid&"&page="&cstr(n)&"'>下一页</a>]")
end if
response.write("&nbsp;共"&allrec&"条&nbsp;")
response.Write("&nbsp;共"&totalpage&"页&nbsp;")
response.Write("&nbsp;第"&currentpage&"页&nbsp;")
%>
            <input type="hidden" name="hid" value="<%=totalpage%>">
&nbsp;&nbsp;跳至
<input name="page" type="text" size="5" onKeyPress="if (event.keyCode < 48 || event.keyCode > 57) event.returnValue = false;" onChange="goto(this.form)" style="border:1px solid #000000;height:18px ">
          页
          <input type="button" name="Button22" value="Go->" style="font-size:12px ;border:1px solid #000000;height:18px ">
          </div>
    </form></td>
  </tr>
</table>
<script language="javascript">
function CheckAll(form) {  
	for (var i=0;i<form.elements.length;i++)  {  
		var e = form.elements[i];  
		if (e.name != 'chkall')  
		e.checked = true // form.chkall.checked;  
	}  
} 
 
function ContraSel(form) {
	for (var i=0;i<form.elements.length;i++){
		var e = form.elements[i];
		if (e.name != 'chkall')
		e.checked=!e.checked;
	}
}
function changeAct(obj){
	var actType=obj.options[obj.selectedIndex].value;
	if(actType=="remove"){
		document.getElementById("removeContain").style.display="block";
	}
	else{
		document.getElementById("removeContain").style.display="none";
	}
}
</script>
</body>
</html>
<%
call connclose()
%>
执行时间：<%=CStr(FormatNumber((Timer-BeginTime)*1000,2))& "毫秒"%>