<?php
define('EmpireCMSAdmin','1');
require("../class/connect.php");
require("../class/db_sql.php");
require("../class/functions.php");
require("../class/delpath.php");
require("../class/t_functions.php");
require("../class/dpfun.php");
require("../class/writer.php");
require("../data/dbcache/class.php");
require LoadLang("pub/fun.php");
$link=db_connect();
$empire=new mysqlquery();
//验证用户
$lur=is_login();
$logininid=$lur['userid'];
$loginin=$lur['username'];
$loginrnd=$lur['rnd'];
$loginlevel=$lur['groupid'];
$loginadminstyleid=$lur['adminstyleid'];

$zm=$_GET[zm];
$classid=(int)$_GET[classid];

$add1='';
$add2='';
$add='';

//导航
$url='<a href="ListWriter.php">全部作者管理</a>';
if($zm){
	$url.='&nbsp;>&nbsp;首字母为 <b>'.$zm.'</b> 的作者';
	$add1=" wzm='$zm'";
}
if($classid){
	$cn=$empire->fetch1("select classname from {$dbtbpre}enewswriterclass where classid=$classid");
	if($cn[classname]){
		$url.='&nbsp;>&nbsp;'.$cn[classname];
		$add2=' classid='.$classid;
	}
}

if($classid==-1){
	$url.='&nbsp;>&nbsp;未分类作者';
	$add2=' classid=0';
}

if($classid==-2){
	$url.='&nbsp;>&nbsp;<b>0</b>作品的作者';
	$add2=" wbook=''";
}

$enews=$_POST['enews'];
if(empty($enews))
{$enews=$_GET['enews'];}
if($enews=="AddWriter")
{
	AddWriter($_POST,$logininid,$loginin);
}
elseif($enews=="EditWriter")
{
	EditWriter($_POST,$logininid,$loginin);
}
elseif($enews=="DelWriter")
{
	$wid=$_GET['wid'];
	DelWriter($wid,$logininid,$loginin);
}
elseif($enews=="DelBfromW")
{
	$wid=$_GET['wid'];
	$bookid=$_GET['bookid'];
	DelBfromW($wid,$bookid,$logininid,$loginin);
}
elseif($enews=="MvToW")
{
	MvToW($_POST,$logininid,$loginin);
}
elseif($enews=="WriterSet")
{
	WriterSet($_POST,$logininid,$loginin);
}
elseif($enews=="ReWriterOne")
{
	$wid=$_GET['wid'];	
	ReWriterOne($wid);
}
elseif($enews=="ReWriterClassOne")
{
	$classid=$_GET['classid'];	
	ReWriterClassOne($classid);
}
else
{}


$wclass='';
$wsql=$empire->query("select classid,classname from {$dbtbpre}enewswriterclass");
while($wr=$empire->fetch($wsql)){
	$wclass.='<a href="ListWriter.php?classid='.$wr[classid].'&zm='.$zm.'">'.$wr[classname].'</a>';
}



if($add1 || $add2){
	$add=' where ';
}
if($add1 && $add2){
	$add2=' and '.$add2;
}
$add.=$add1.$add2;

//翻页
$start=0;
$page=(int)$_GET['page'];
$page=RepPIntvar($page);
$line=50;//每页显示
$page_line=12;
$offset=$page*$line;
$search="classid=$classid&zm=$zm";
$num=$empire->gettotal("select count(*) as total from {$dbtbpre}enewswriter".$add);//总数
$search.="&totalnum=$num";
$returnpage=page2($num,$line,$page_line,$start,$page,$search);

?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" href="adminstyle/<?=$loginadminstyleid?>/adminstyle.css" type="text/css">
<title>全部分卷管理</title>
<style type="text/css">
	.zm a{padding:0 5px;}
</style>
<script>
function CheckAll(form)
  {
  for (var i=0;i<form.elements.length;i++)
    {
    var e = form.elements[i];
    if (e.name != 'chkall')
       e.checked = form.chkall.checked;
    }
  }

//删除
function delc(wid){
	if(confirm('确认要删除此作者吗？'))
	{
		self.location.href='ListWriter.php?wid='+wid+'&enews=DelWriter';
	}
}

</SCRIPT>
</head>
<body>
<table width="100%" border="0" align="center" cellpadding="3" cellspacing="1">
  <tr> 
    <td width="40%">位置： 
      <?=$url?>
    </td>
    <td width="60%">
		<div align="right" class="emenubutton">
			<a href="../../writer/" target="_blank">预览作者首页</a>
      </div>
	</td>
  </tr>
</table>

<table  width="100%" border="0" align="center" cellpadding="3" cellspacing="1">
  <tr> 
    <td width="40%"> 
      <a href="ReWriter.php?enews=ReWriterIndex" target="_blank">[刷新作者首页]</a>&nbsp;<a href="ReWriter.php?enews=ReWriterClass" target="_blank">[刷新作者分类]</a>&nbsp;<a href="ReWriter.php?enews=ReWriter" target="_blank">[刷新全部作者]</a>&nbsp;<a href="ReWriter.php?enews=Zhengli" target="_blank">[整理全部作者]</a>
    </td>
    <td width="60%">
		<div align="right" class="emenubutton">&nbsp;
        <input type="button" name="Submit6" value="增加作者" onclick="self.location.href='AddWriter.php?enews=AddWriter'">&nbsp;
		<input type="button" name="Submit6" value="分类管理" onclick="self.location.href='ListWriterClass.php'">&nbsp;
		<input type="button" name="Submit6" value="设置" onclick="self.location.href='ListWriterSet.php'">
      </div>
	</td>
  </tr>
</table>

  <table width="100%" border="0" align="center" cellpadding="3" cellspacing="1" class="tableborder">
    <tr class="header">
      <td height="25">按条件显示
        <input name=enews type=hidden id="enews" value=AddWriterClass>
      </td>
    </tr>
    <tr> 
      <td height="25" bgcolor="#FFFFFF">
	  <div class="zm">分类:<?=$wclass?><a href="ListWriter.php?classid=-1&zm=<?=$zm?>">未分类</a><a href="ListWriter.php?zm=<?=$zm?>">全部分类</a><a href="ListWriter.php?classid=-2&zm=<?=$zm?>">0作品</a></div>
      </td>
    </tr>
	<tr> 
      <td height="25" bgcolor="#FFFFFF"><div class="zm">字母:
	  <a href="ListWriter.php?classid=<?=$classid?>&zm=A">A</a>
	  <a href="ListWriter.php?classid=<?=$classid?>&zm=B">B</a>
	  <a href="ListWriter.php?classid=<?=$classid?>&zm=C">C</a>
	  <a href="ListWriter.php?classid=<?=$classid?>&zm=D">D</a>
	  <a href="ListWriter.php?classid=<?=$classid?>&zm=E">E</a>
	  <a href="ListWriter.php?classid=<?=$classid?>&zm=F">F</a>
	  <a href="ListWriter.php?classid=<?=$classid?>&zm=G">G</a>
	  <a href="ListWriter.php?classid=<?=$classid?>&zm=H">H</a>
	  <a href="ListWriter.php?classid=<?=$classid?>&zm=I">I</a>
	  <a href="ListWriter.php?classid=<?=$classid?>&zm=J">J</a>
	  <a href="ListWriter.php?classid=<?=$classid?>&zm=K">K</a>
	  <a href="ListWriter.php?classid=<?=$classid?>&zm=L">L</a>
	  <a href="ListWriter.php?classid=<?=$classid?>&zm=M">M</a>
	  <a href="ListWriter.php?classid=<?=$classid?>&zm=N">N</a>
	  <a href="ListWriter.php?classid=<?=$classid?>&zm=O">O</a>
	  <a href="ListWriter.php?classid=<?=$classid?>&zm=P">P</a>
	  <a href="ListWriter.php?classid=<?=$classid?>&zm=Q">Q</a>
	  <a href="ListWriter.php?classid=<?=$classid?>&zm=R">R</a>
	  <a href="ListWriter.php?classid=<?=$classid?>&zm=S">S</a>
	  <a href="ListWriter.php?classid=<?=$classid?>&zm=T">T</a>
	  <a href="ListWriter.php?classid=<?=$classid?>&zm=W">W</a>
	  <a href="ListWriter.php?classid=<?=$classid?>&zm=X">X</a>
	  <a href="ListWriter.php?classid=<?=$classid?>&zm=Y">Y</a>
	  <a href="ListWriter.php?classid=<?=$classid?>&zm=Z">Z</a>
	  <a href="ListWriter.php?classid=<?=$classid?>&zm=">全部</a>
	  </div>
      </td>
    </tr>
  </table>
<br>
<table width="100%" border="0" align="center" cellpadding="3" cellspacing="1" class="tableborder">
  	<tr class="header"> 
      <td width="10%" height="25"><div align="center">WID</div></td>
	  <td width="10%" height="25"> <div align="center">首字母</div></td>
	  <td width="20%" height="25"> <div align="center">作者姓名</div></td>
	  <td width="10%" height="25"> <div align="center">作者等级</div></td>
	  <td width="10%" height="25"> <div align="center">作品数量</div></td>
      <td width="10%" height="25"> <div align="center">分类</div></td>
      <td width="30%" height="25"> <div align="center">操作</div></td>
    </tr>

<?
$sql=$empire->query("select * from {$dbtbpre}enewswriter ".$add." order by wid desc limit $offset,$line");
while($r=$empire->fetch($sql)){
$b=$empire->fetch1("select classname,filename from {$dbtbpre}enewswriterclass where classid=$r[classid] limit 1");
if($b[classname]){
	$bn='<a href="'.$public_r[newsurl].'writer/'.$b[filename].'.html" target="_blank">'.$b[classname].'</a>';
}else{
	$bn='暂无分类';
}
$wbnum=WBNum($r[wid]);
?>  <tr  bgcolor="#FFFFFF" onmouseout="this.style.backgroundColor='#ffffff'" onmouseover="this.style.backgroundColor='#E2E9EA'">
      <td height="25"><div align="center"><?=$r[wid]?><input type=hidden name=wid[] value="<?=$r[wid]?>"></div></td>
	  <td height="25"> <div align="center"><?=$r[wzm]?></div></td>
	  <td height="25"> <div align="center"><a href="<?=$public_r[newsurl].'writer/'.$r[wid]?>" target="_blank"><?=$r[wname]?></a></div></td>
	  <td height="25"> <div align="center"><?=$r[isgood]?></div></td>
	  <td height="25"> <div align="center"><?=$wbnum?></div></td>
      <td height="25"> <div align="center"><?=$bn?></div></td>
      <td height="25"> <div align="center"><a href="ListWriterBooks.php?wid=<?=$r[wid]?>">[作品管理]</a> <a href="ListWriter.php?enews=ReWriterOne&wid=<?=$r[wid]?>">[刷新]</a> | <a href="ReWriter.php?enews=ZhengliOne&wid=<?=$r[wid]?>">[整理]</a> | <a href="AddWriter.php?enews=EditWriter&wid=<?=$r[wid]?>">修改</a> | <a href='#e' onclick=delc(<?=$r[wid]?>)>删除</a></div></td>
	</tr>
<?
}
?>
    <tr bgcolor="#FFFFFF"> 
      <td colspan=7 height="30"> 
      <?=$returnpage?>
      </td>
    </tr>

</table>

<?
db_close();
$empire=null;
?>