<?php
require("../class/connect.php");
require("../class/db_sql.php");
require("../data/dbcache/class.php");
require("../member/class/user.php");
require("../class/q_functions.php");
require("../class/dpfun.php");
require LoadLang("pub/fun.php");
$link=db_connect();
$empire=new mysqlquery();
//验证是否登陆
$user=islogin();
$userid=$user['userid'];
$username=$user['username'];

//取得模型id
$bookid=(int)$_GET['bookid'];
//验证书审核状态
$bck=$empire->fetch1("select * from {$dbtbpre}ecms_bookname_index where id=$bookid limit 1");
if(!$bck[checked])
{
	printerror("ErrorUrl","history.go(-1)",1);
}
//验证是否当前用户
$bookname=$empire->fetch1("select * from {$dbtbpre}ecms_bookname where id=$bookid limit 1");
if(!$bookname[ismember] || $bookname[userid]!=$userid || $bookname[username]!=$username)
{
	printerror("ErrorUrl","history.go(-1)",1);
}
esetcookie("qdelinfo","dgcms");
$totalnum=(int)$_GET['totalnum'];
$start=0;
$page=(int)$_GET['page'];
$page=RepPIntvar($page);
$line=25;//每行显示
$page_line=16;
$offset=$page*$line;
$add='';
$search="&mid=$mid";

//审核表
$ecmscheck=(int)$_GET['ecmscheck'];
$addecmscheck='';
$indexchecked=1;
if($ecmscheck)
{
	$search.='&ecmscheck='.$ecmscheck;
	$addecmscheck='&ecmscheck='.$ecmscheck;
	$indexchecked=0;
}
$tbname=$emod_r[$bck[tid]][tbname];
$infotb=ReturnTbname($tbname,$indexchecked);
//显示方式
if($public_r['qlistinfomod'])
{
	$modnum=$empire->gettotal("select count(*) as total from {$dbtbpre}enewsmod where tbname='$tbanme'");
	if($modnum>1)
	{
		$add.=' and ('.ReturnClass($mr['sonclass']).')';
	}
}
//搜索
$sear=$_GET['sear'];
if($sear)
{
	$keyboard=RepPostVar2($_GET['keyboard']);
	$show=$_GET['show'];
	//关键字
	if($keyboard)
	{
		$add.=" and (title like '%$keyboard%')";
	}
	$search.="&sear=1&keyboard=$keyboard&show=$show";
}

//信息表
$totalquery="select count(*) as total from ".$infotb." where bookid='$bookid' ".$add;
if($totalnum<1)
{
	$num=$empire->gettotal($totalquery);//取得总条数
}
else
{
	$num=$totalnum;
}

$mmw='增加章节';



$woinput='<span><a href="AddBookData.php?mid=&enews=MAddInfo&bookid='.$bookid.'" class=submit_btn>'.$mmw.'</a></span>';
$search.="&totalnum=$num";
$returnpage=page1($num,$line,$page_line,$start,$page,$search);






//查询SQL，如果要显示自定义字段记得在SQL里增加查询字段
$query="select * from ".$infotb." where bookid='$bookid' ".$add." order by newstime desc limit $offset,$line";
$sql=$empire->query($query);
//返回头条和推荐级别名称
$ftnr=ReturnFirsttitleNameList(0,0);
$ftnamer=$ftnr['ftr'];
$ignamer=$ftnr['igr'];


$public_diyr['pagetitle']='《'.$bookname[title].'》章节列表';

$url="<a href='../../'>首页</a>&nbsp;>&nbsp;<a href='../member/cp/'>会员中心</a>&nbsp;>&nbsp;<a href='ListInfo.php?mid=$mid".$addecmscheck."'>管理信息</a>&nbsp;(".$mr[qmname].")";
require(ECMS_PATH.'e/template/incfile/header.php');
?>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
        <form name="searchinfo" method="GET" action="ListInfo.php">
    <tr>
            <td width="25%" height="27">
			  <input type="button" target="_blank" name="Submit" value="增加章节" onclick="window.open('AddBookData.php?mid=&enews=AddBd&bookid=<?=$bookid?>','','');">
			  <a href="ListVolume.php?bookid=<?=$bookid?>" target="_blank"><u>分卷管理</u></a>
            </td>
      <td width="75%"><div align="right">&nbsp;搜索： 
          <input name="keyboard" type="text" id="keyboard" value="<?=$keyboard?>">
          <select name="show">
            <option value="0" selected>标题</option>
          </select>
          <input type="submit" name="Submit2" value="搜索">
          <input name="sear" type="hidden" id="sear" value="1">
          <input name="mid" type="hidden" value="<?=$mid?>">
		  <input name="ecmscheck" type="hidden" id="ecmscheck" value="<?=$ecmscheck?>">
        </div></td>
    </tr>
  </form>
</table>
<br>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="19%" height="25"<?=$indexchecked==1?' class="header"':' bgcolor="#8A9893"'?>><div align="center"><a href="ListBookData.php?bookid=<?=$bookid?>">已发布(<?=$bck[cknum]?>)</a></div></td>
    <td width="19%"<?=$indexchecked==0?' class="header"':' bgcolor="#8A9893"'?>><div align="center"><a href="ListBookData.php?bookid=<?=$bookid?>&ecmscheck=1">待审核(<? echo $bck[datanum]-$bck[cknum]?>)</a></div></td>
    <td width="23%">&nbsp;</td>
    <td width="27%">&nbsp;</td>
    <td width="6%">&nbsp;</td>
    <td width="6%">&nbsp;</td>
  </tr>
</table>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" class="tableborder">
  <tr class="header"> 
    <td width="34%" height="25"> <div align="center">章节标题</div></td>
	<td width="23%" height="25"> <div align="center">分卷</div></td>
    <td width="20%" height="25"> <div align="center">发布时间</div></td>	
    <td width="6%"><div align="center">审核</div></td>
    <td width="17%" height="25"> 
      <div align="center">操作</div></td>
  </tr>
  <?
	while($r=$empire->fetch($sql))
	{
		//时间
		$newstime=date("Y-m-d H:m:s",$r[newstime]);
		$oldtitle=$r[title];
		$r[title]=stripSlashes(sub($r[title],0,50,false));
		$r[title]=DoTitleFont($r[titlefont],$r[title]);
		if($indexchecked==0)
		{
			$checked='<font color=red>×</font>';
			$titleurl='AddInfo.php?enews=MEditInfo&classid='.$r[classid].'&id='.$r[id].'&mid='.$mid.$addecmscheck;//链接
		}
		else
		{
			$checked='√';
			$titleurl=sys_ReturnBqTitleLink($r);//链接
		}
		$plnum=$r[plnum];//评论个数
		//标题图片
		$showtitlepic="";
		if($r[titlepic])
		{$showtitlepic="<a href='".$r[titlepic]."' title='预览标题图片' target=_blank><img src='../data/images/showimg.gif' border=0></a>";}
		//栏目
		$classname=$class_r[$r[classid]][classname];
		$classurl=sys_ReturnBqClassname($r,9);
		$bclassid=$class_r[$r[classid]][bclassid];
		$br['classid']=$bclassid;
		$bclassurl=sys_ReturnBqClassname($br,9);
		$bclassname=$class_r[$bclassid][classname];
	?>
  <tr bgcolor="#FFFFFF" id=news<?=$r[id]?>> 
    <td height="25"> <div align="left"> &nbsp;
		<?=$showtitlepic?>
        <a href="<?=$titleurl?>" target=_blank title="<?=$oldtitle?>"> 
        <strong><?=$r[title]?></strong> </a>

      </div></td>
    
    <td><div align="center"><?=GetVname($r[vid])?></div></td>
	<td height="25"> <div align="center"><?=$newstime?></div></td>
    <td><div align="center">
        <?=$checked?>
      </div></td>
    <td height="25"><div align="center"><a onclick="window.open('AddBookData.php?enews=EditBd&bookid=<?=$r[bookid]?>&id=<?=$r[id]?>&mid=<?=$mid?><?=$addecmscheck?>','','width=700,height=650,scrollbars=yes,top=70,left=100,resizable=yes');" href='#'>修改</a> | <a href="ecms.php?enews=DelBd&classid=<?=$bck[classid]?>&bookid=<?=$r[bookid]?>&id=<?=$r[id]?>&mid=<?=$mid?><?=$addecmscheck?>" onclick="return confirm('确认要删除?');">删除</a> 
      </div></td>
  </tr>
  <?
	}
	?>
  <tr bgcolor="#FFFFFF"> 
    <td height="25" colspan="5"> 
      <?=$returnpage?> &nbsp;</td>
  </tr>
</table>
<?php
require(ECMS_PATH.'e/template/incfile/footer.php');







db_close();
$empire=null;
?>