<?php
#------------------------------------------------------#
#                 本程序为zchain.net改编               #
#              zChain留言簿2000多用户版v2.50           #
#------------------------------------------------------#
require "setup.php";
require "core/class_basic_record_file.php";
require "core/class_book_list.php";
require "core/class_message_list.php";

$perpage=20;

if($f_user != ""){$ck_user=$f_user; setcookie("ck_user",$ck_user);}
if($f_pass != ""){$ck_pass=$f_pass; setcookie("ck_pass",$ck_pass);}

if(($admname != $ck_user)||($admpass != $ck_pass)){
 print <<<EOT
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style type="text/css">
TD{FONT-SIZE:9pt}
A{FONT-SIZE:9pt;TEXT-DECORATION:none}
A:hover{FONT-SIZE:9pt;TEXT-DECORATION:underline}
input{font-size:9pt;color:#000080;background-color:'#FFFFFF';padding-top:3px}
</style>
<title>超级用户管理</title>
<script language="JavaScript">
function chksend(){
var send=false;
if(document.reg.f_name.value){
if(document.reg.f_pass.value){
send=true;
}
}
if (send==false){
alert('站长管理用，请勿进入，谢谢！');
}
return send;
}
</script>
</head>
<body background=$imgurl/bg.jpg>
<br><h2 align="center">超级用户管理</h2>
<div align="center"><center>
<form name="reg" action="$cgiurl" method=POST onsubmit="return chksend();">
<table border=1 width=400>
<tr><td width="40%" align=center>超级用户名字：</td>
<td width="60%"><input name="f_user" type="text" size=30 maxlength=10></td></tr>
<tr><td width="40%" align=center>超级用户密码：</td>
<td width="60%"><input name="f_pass" type="password" size=30 maxlength=12></td></tr>
<tr><td align="center"><p><input type="reset" value="重   填" name="B2"></td>
<td align="center"><p><input type="submit" value="提   交" name="B1"></td></tr>
</table></form>
<a href="reg.php">[免费申请]</a><a href="regedit.php">[版主资料修改]</a>[超级用户管理]<a href="list.php">[用户列表]</a>
</a></center></div>
</body></html>
EOT;

 exit;
}

if($action == "killBook"){killBook($f_bookname);exit;}
elseif($action == "review"){review($f_bookname);exit;}
else{

 $oList=new CBookList;
 $oList->open(); 
 $size = $oList->getRecordCount();
 $pages=ceil($size/$perpage);

 print <<<EOT
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style type="text/css"><!--
a:link {  font-family: "宋体", "serif"; font-size: 9pt; color: #004080; text-decoration: none}
a:hover {  color: #004080; text-decoration: underline; background-color: #CCCC99}
a:visited {  text-decoration: none}
body {  font-family: "宋体", "serif"; font-size: 9pt}
td {  font-family: "宋体", "serif"; font-size: 9pt}
input {  font-size: 9pt}
p {  font-size: 9pt}
br {  font-size: 9pt}
tr {  font-size: 9pt}
table {  font-size: 9pt}
--></style>
<title>超级用户管理</title></head>
<body background=$imgurl/bg.jpg>
<br><center><h2>超级用户管理</h2></center>
<center>
<form name="reg" action="$cgiurl">
<input name="action" type="hidden" value="review">
请键入版主的名称：<input type=text name="f_bookname" size=12>
<input type=submit value="确定"></form>
<br>居民数:<font color=#FF0000>$size</font>
<table border=1 width="80%" bordercolorlight=#008000 cellspacing=0 cellpadding=0 bordercolordark=#FFFFFF>
<tr><td background=$imgurl/tablebg.gif width="45%" align="center"><font color=ffffff>{$cginame}名称</font></td>
<td background=$imgurl/tablebg.gif width="10%" align="center"><font color=ffffff>留言数</font></td>
<td background=$imgurl/tablebg.gif width="10%" align="center"><font color=ffffff>版主</font></td>
<td background=$imgurl/tablebg.gif width="20%" align="center"><font color=ffffff>申请时间</font></td>
<td background=$imgurl/tablebg.gif width="15%" align="center"><font color=ffffff>删除此用户</font></td>
</tr>
EOT;

 $oMsgList=new CMessageList;

 if($page == ""){$page=$pages;}
 $firstitem=($page-1)*$perpage;
 $lastitem=$firstitem+$perpage;
 if($lastitem>$size){$lastitem=$size;}
 $oList->moveTo($firstitem);
 for($i=$firstitem; $i<$lastitem; $i++) {
  $oMsgList->open($oList->name);
  $lys = $oMsgList->getRecordCount();
  $oMsgList->close();

   print <<<EOT
<tr><td>　<a href=$gburl?id=$oList->name target=_blank>$oList->title</a><br>$oList->desc</td>
<td align="center"><font color=#FF0000>$lys</font></td>
<td align="center"><a href="mailto:$oList->email">$oList->name</a></td>
<td align="center">$$oList->regtime</td>
<td align="center"><form action=$cgiurl METHOD=POST>
<input type=hidden name=action value=killBook>
<input type=hidden name=f_bookname value=$oList->name>
<input type=submit value=删除></td></form></tr>
EOT;
  $oList->moveNext();
 }
 print "
<tr><td align='center' width='100%' colspan=5 bgcolor=#FFF5E1>
$copyright</td></tr>
<tr><td colspan=5 align=center>
";

 for($i=$pages; $i>=1; $i--){
  if ($page != $i){print "<a href=$cgiurl?page=$i>";}
  print "[$i]";
  if ($page != $i){print "</a>";}
 }
 print "</td></tr></table></center></body></html>";

 $oList->close();
 exit;
}

function killBook($bookname){
 global $imgurl,$cgiurl;

 $oList=new CBookList;
 $oList->open(); 
 if($oList->find($bookname)){$oList->delete();}
 $oList->close();

 print <<<EOT
<html><head>
<style type="text/css">
TD{FONT-SIZE:9pt}
A{FONT-SIZE:9pt;TEXT-DECORATION:none}
A:hover{FONT-SIZE:9pt;TEXT-DECORATION:underline}
input{font-size:9pt;color:#000080;background-color:#FFFFFF;padding-top:3px}
</style></head>
<body background=$imgurl/bg.jpg>
<center>
<br><br><h2>已 经 成 功 删 除 ！</h2><br><br>
<p align=center><a href=$cgiurl?>返回管理菜单</p></a>
</body></html>
EOT;
}

function Review($bookname){
 global $imgurl,$cginame,$cgiurl,$gburl,$copyright;

 $oBooks=new CBookList;
 $oBooks->open();
 if (!$oBooks->find($bookname)){errorview("对不起，此版主没有注册！");}

 print <<<EOT
<HEAD><TITLE>查 看 版 主 $oBooks->title 的 资 料 ！</TITLE></HEAD>
<style type=text/css>
TD{FONT-SIZE:9pt}
A{FONT-SIZE:9pt;TEXT-DECORATION:none}
A:hover{FONT-SIZE:9pt;TEXT-DECORATION:underline}</style>
<body background=$imgurl/bg.jpg>
<br><p class=pt10 align=center><b>版 主 $oBooks->title 的 资 料 ！</b>
<form action=$cgiurl METHOD=POST>
<input type=hidden name=action value=kill>
<input type=hidden name=f_bookname value=$oBooks->name>
<input type=submit value=删除></form>
<p class=pt10 align=center>
<table cellspacing=4 cellpadding=3>
<tr><td class=pt9 bgcolor=#FFF5E1><b>{$cginame}名称：</b></td>
<td class=pt9 align=left bgcolor=#FFF5E1><font color=#FF0000><a href=$gburl?id=$oBooks->name target=_blank>$oBooks->title</font></tr>
<tr><td class=pt9 bgcolor=#FFF5E1><b>注册姓名：</b></td>
<td class=pt9 align=left bgcolor=#FFF5E1><font color=#FF0000>$oBooks->name</font></td></tr>
<tr><td class=pt9 bgcolor=#FFF5E1><b>密码：</b></td>
<td class=pt9 align=left bgcolor=#FFF5E1><font color=#FF0000>$oBooks->pass</font></td></tr>
<tr><td class=pt9 bgcolor=#FFF5E1><b>信箱：</b></td>
<td class=pt9 align=left bgcolor=#FFF5E1><font color=#FF0000><a href=mailto:$oBooks->email>$oBooks->email</a></font></td></tr>
<tr><td class=pt9 bgcolor=#FFF5E1><b>个人主页：</b></td>
<td class=pt9 align=left bgcolor=#FFF5E1><font color=#FF0000><a href=$oBooks->url target=_blank>$oBooks->url</a></font></td></tr>
<tr><td class=pt9 bgcolor=#FFF5E1><b>申请时间：</b></td>
<td class=pt9 align=left bgcolor=#FFF5E1><font color=#FF0000>$oBooks->regtime.</font></td></tr>
</table>
<br>[ <a href=javascript:history.back(-1)>返回上一页</a> ]<br><br>
<table align=center border=1 borderColorDark=#ffffff borderColorLight=#008000 cellPadding=0 cellSpacing=0 width=60%>
<tr><td align=middle width=100%>$copyright</td></tr>
</table>
EOT;

 $oBooks->close();
}
?>