<? require_once("../configs/adminconn.php");
    require_once("edit5.php");?>
<?
$page=$_GET["page"];
$cid=$_GET["cid"];
$sh=$_GET["sh"];
$id=$_GET["id"];
$del=$_GET["del"];
if($sh!=""){
$sql="update cbody set sh=".$sh." where id in (".$id.")";
if(!mysql_query($sql)){
echo "<script>alert('修改失败！请联系管理员！');window.location.href='edit2.php';</script>";
exit;
}
}
if($del!=""){
$sql="delete from cbody where id in(".$del.")";
if(!mysql_query($sql)){
echo "<script>alert('删除失败！请联系管理员！');window.location.href='edit2.php';</script>";
exit;
}
}
function jc($s2,$sid,$cid,$page){
if($s2==true){
return "<a href=?sh=0&id=".$sid."&cid=".$cid."&page=".$page."><font color=#ff0000>未审</font></a>";
}else{
return "<a href=?sh=1&id=".$sid."&cid=".$cid."&page=".$page."><font color=#0000ff>已审</font></a>";
}

}


$pagesize=15;
if($cid!=""){
$r2=mysql_query("select  count(*) from cbody where cid=".$cid."") or die(mysql_error());
}else{
$r2=mysql_query("select  count(*) from cbody") or die(mysql_error());
}

$zy=mysql_fetch_array($r2);
$numrows=$zy[0];

if($page=="")$page=1;
$offset=$pagesize*($page - 1);

$pages=intval($numrows/$pagesize);
$top="<a href=index.php>全部信息</a>";
if($cid!=""){
$title=icid($cid)." - ";
$top="<a href=?cid=".$cid.">".icid($cid)."</a>";
$sql=mysql_query("select * from cbody where cid=".$cid."  order by id desc limit $offset,$pagesize",$conn) or die(mysql_error());
}elseif($page!=""){
$sql=mysql_query("select * from cbody  order by id desc limit $offset,$pagesize",$conn) or die(mysql_error());
}else{
$sql=mysql_query("select * from cbody  order by id desc limit $offset,$pagesize",$conn) or die(mysql_error());
}


?>
<meta http-equiv="x-ua-compatible" content="ie=7" />
<script>
function selAll()
{

	for(i=0;i<document.form2.id.length;i++)
	{
		if(!document.form2.id[i].checked)
		{
			document.form2.id[i].checked=true;
		}
	}
}
function noSelAll()
{
	for(i=0;i<document.form2.id.length;i++)
	{
		if(document.form2.id[i].checked)
		{
			document.form2.id[i].checked=false;
		}
	}
}
function getCheckboxItem()
{
	var allSel="";
	if(document.form2.id.value) return document.form2.id.value;
	for(i=0;i<document.form2.id.length;i++)
	{
		if(document.form2.id[i].checked)
		{
			if(allSel=="")
				allSel=document.form2.id[i].value;
			else
				allSel=allSel+","+document.form2.id[i].value;
		}
	}
	return allSel;
}

//获得选中其中一个的id
function getOneItem()
{
	var allSel="";
	if(document.form2.id.value) return document.form2.id.value;
	for(i=0;i<document.form2.id.length;i++)
	{
		if(document.form2.id[i].checked)
		{
				allSel = document.form2.id[i].value;
				break;
		}
	}
	return allSel;
}
function delArc(aid){
	var qstr=getCheckboxItem();
	if(aid==0) aid = getOneItem();
	location="edit2.php?aid="+aid+"&action=delArchives&del="+qstr+"";
}
function checkArc(aid){
	var qstr=getCheckboxItem();
	if(aid==0) aid = getOneItem();
	location="edit2.php?sh=0&action=checkArchives&id="+qstr+"&page=<?=$page;?>";
}
function adArc(aid){
	var qstr=getCheckboxItem();
	if(aid==0) aid = getOneItem();
	location="edit2.php?sh=1&action=commendArchives&id="+qstr+"&page=<?=$page;?>";
}
</script>
<style type="text/css">

/*--- 分页用 ---*/
.pagination{clear:both;margin:0 auto;padding:5px 0 10px 0;text-align:center;font-family:Arial}
.pagination a, .pagination a:visited {display:inline;height:22px;border:1px solid #DBDBDB;background:url(/c/bg1.jpg) repeat-x;text-align:center;padding:3px 8px 2px 8px;overflow:hidden;margin:0 4px}
.pagination a:hover {background:#FF9900;border:1px solid #EF6907;color:#FFF}
.pagination .currentpage {padding:3px 8px 2px 8px;height:22px;background:#FF9900;border:1px solid #EF6907;color:#FFF;margin:0 4px}
body,td,th {
	font-size: 12px;
}
body {
	margin-top: 0px;
	margin-left: 30px;
}
.qqcc {
	border: 1px solid #EEEEEE;
	padding:10px;
}
.qqtd {
	border-top-width: 1px;
	border-top-style: solid;
	border-top-color: EEEEEE;
}
</style>
<script type="text/javascript">
<!--
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval("window.location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
//-->
</script>
</head>

<body>


<!-- Copyright ?2005. Spidersoft Ltd -->

<!-- /Copyright ?2005. Spidersoft Ltd -->
<link rel="stylesheet" type="text/css" href="skin/css/base.css">
<meta http-equiv="x-ua-compatible" content="ie=7" />
</div>
</div>
</Div>
</DIV>
<form name="form2">
  <table width="98%" border="0" cellpadding="2" cellspacing="1" bgcolor="#D1DDAA" align="center" style="margin-top:8px">
    <tr bgcolor="#E7E7E7">
      <td height="24" colspan="8" background="skin/images/tbg.gif">&nbsp;分类:
          <select name="jumpMenu" id="jumpMenu" onChange="MM_jumpMenu('parent',this,0)">
            <option value="?all">显示全部</option>
            <?
        $cl=mysql_query("select * from cid where sh=0 order by id desc");
		while($cl2=mysql_fetch_array($cl,MYSQL_NUM)){
		?>
            <option value="?cid=<?=$cl2[0]?>&page=<?=$page?>" <? if($cid==$cl2[0]) echo "selected"?>>
              <?=$cl2[1]?>
            </option>
            <?
          }?>
          </select></td>
    </tr>
    <tr align="center" bgcolor="#FAFAF1" height="22">
      <td width="6%">ID</td>
      <td width="4%">选择</td>
      <td width="28%">文章标题</td>
      <td width="10%">录入时间</td>
      <td width="10%">类目</td>
      <td width="8%">点击</td>
      <td width="6%">审核</td>
      <td width="10%">操作</td>
    </tr>
    <?

while($rs=mysql_fetch_array($sql,MYSQL_NUM)){

?>
    <tr align='center' bgcolor="#FFFFFF" onMouseMove="javascript:this.bgColor='#FCFDEE';" onMouseOut="javascript:this.bgColor='#FFFFFF';" height="22" >
      <td><?=$rs[0];?></td>
      <td><input name="id" type="checkbox" id="id" value="<?=$rs[0];?>" class="np"></td>
      <td align="left"><a href=''><u><a href="../red.php?id=<? echo $rs[0];?>" title=<?=$rs[6];?> target="_blank"><?=$rs[6];?></a></u></a></td>
      <td><?=$rs[3];?></td>
      <td><? echo icid($rs[1]);?></td>
      <td><?=$rs[5];?></td>
      <td><?=jc($rs[4],$rs[0],$cid,$page);?></td>
      <td><a href="edit9.php?id=<?=$rs[0]?>">编辑</a> | <a target="_blank" href="../red.php?id=<?=$rs[0]?>">预览</a> | <a href="?del=<?=$rs[0]?>&cid=<?=$cid?>&page=<?=$page?>">删除</a></td>
    </tr>
    <?
}

?>
    <tr bgcolor="#FAFAF1">
      <td height="28" colspan="8">&nbsp; <a href="javascript:selAll()" class="coolbg">全选</a> <a href="javascript:noSelAll()" class="coolbg">取消</a>  <a href="javascript:checkArc()" class="coolbg">&nbsp;审核&nbsp;</a> <a href="javascript:adArc()" class="coolbg">取消审核</a>  <a href="javascript:delArc(0)" class="coolbg">&nbsp;删除&nbsp;</a> </td>
    </tr>
    
    <tr align="right" bgcolor="#EEF4EA">
      <td height="36" colspan="8" align="center"><!--翻页代码 --><div id="pagebar" class="pagination"></div></td>
    </tr>
  </table>
</form>
<script language="javascript" type="text/javascript">
function QueryString(item){
	var sValue=location.search.match(new RegExp("[\?\&]"+item+"=([^\&]*)(\&?)","i"))
	return sValue?sValue[1]:sValue
}
var count = <?=$numrows?>;
var perpage = <?=$pagesize?>;
var cid = QueryString("cid");
if(cid==null)cid="";
var currentpage = <?=$page?>;
if (currentpage==null){
	currentpage = 1;
}else{
	currentpage = parseInt(currentpage);
}
var pagecount = Math.floor(count/perpage)+1;
var pagestr = "";
var breakpage = 9;
var currentposition = 4;
var breakspace = 2;
var maxspace = 4;
var prevnum = currentpage-currentposition;
var nextnum = currentpage+currentposition;
if(prevnum<1) prevnum = 1;
if(nextnum>pagecount) nextnum = pagecount;
pagestr += (currentpage==1)?'&nbsp;':'<a href="?cid='+cid+'&page='+(currentpage-1)+'">前页</a>';
if(prevnum-breakspace>maxspace){
	for(i=1;i<=breakspace;i++)
		pagestr += '<a href="?cid='+cid+'&page='+i+'">'+i+'</a>';
	pagestr += '<span class="break">...</span>';
	for(i=pagecount-breakpage+1;i<prevnum;i++)
		pagestr += '<a href="?cid='+cid+'&page='+i+'">'+i+'</a>';
}else{
	for(i=1;i<prevnum;i++)
		pagestr += '<a href="?cid='+cid+'&page='+i+'">'+i+'</a>';
}
for(i=prevnum;i<=nextnum;i++){
	pagestr += (currentpage==i)?'<span class="currentpage">'+i+'</span>':'<a href="?cid='+cid+'&page='+i+'">'+i+'</a>';
}
if(pagecount-breakspace-nextnum+1>maxspace){
	for(i=nextnum+1;i<=breakpage;i++)
		pagestr += '<a href="?cid='+cid+'&page='+i+'">'+i+'</a>';
	pagestr += '<span class="break">...</span>';
	for(i=pagecount-breakspace+1;i<=pagecount;i++)
		pagestr += '<a href="?cid='+cid+'&page='+i+'">'+i+'</a>';
}else{
	for(i=nextnum+1;i<=pagecount;i++)
		pagestr += '<a href="?cid='+cid+'&page='+i+'">'+i+'</a>';
}
if (currentpage < pagecount) {
pagestr += (currentpage==pagecount)?'&nbsp;':'<a href="?cid='+cid+'&page='+(currentpage+1)+'">后页</a>';
}
document.getElementById("pagebar").innerHTML = pagestr;
</script>
</body>
</html>
<?
mysql_close();
?>
