<?php
define('EmpireCMSAdmin','1');
require("../../class/connect.php");
require("../../class/db_sql.php");
require("../../class/functions.php");
require("../../class/topfun.php");
require("../../data/dbcache/class.php");
$link=db_connect();
$empire=new mysqlquery();
$editor=2;
//验证用户
$lur=is_login();
$logininid=$lur['userid'];
$loginin=$lur['username'];
$loginrnd=$lur['rnd'];
$loginlevel=$lur['groupid'];
$loginadminstyleid=$lur['adminstyleid'];
//验证权限
CheckLevel($logininid,$loginin,$classid,"public");


$time=time();
$td=mktime(0,0,0,date('m',$time),date('d',$time),date('Y',$time));
$td=(int)$td;


//栏目
$classid=(int)$_GET['classid'];
if($classid)
{
	$and=' and ';
	if($class_r[$classid][islast])
	{
		$where.=$and."classid='$classid'";
	}
	else
	{
		$where.=$and."(".ReturnClass($class_r[$classid][sonclass]).")";
	}
}

$shownum=(int)$_GET['shownum'];
if(!$shownum){
	$shownum=12;
}

$ccsql=$empire->query("select classname,classid from {$dbtbpre}enewsclass order by myorder,classid");
while($ccr=$empire->fetch($ccsql)){
	$xuzh='';
	if($ccr[classid]==$classid){
		$xuzh='selected';
	}
	$class.='<option value="'.$ccr[classid].'" '.$xuzh.' style="background:#99C4E3">|-'.$ccr[classname].'</option>';
}


$query="select * from {$dbtbpre}dongpo_top where time>$td ".$where."  order by hit desc limit $shownum";

?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="adminstyle.css" rel="stylesheet" type="text/css">
<title>阅读风云榜</title>
</head>

<body>

<table width="100%" border="0" align="center" cellpadding="3" cellspacing="1">
  <tr>
    <td>位置：风云榜插件 > 统计数据</td>
  </tr>
</table>
<br>
<table width="100%" border="0" cellspacing="1" cellpadding="3">
<form name="searchform" method="GET" action="view.php">
  <tr>
      <td>
        栏目
		<select name="classid">
			<option value="0">全部栏目</option>
			<?=$class?>
		</select>，
		显示<input type="text" name="shownum" value="<?=$shownum?>" size=3>条
        <input type="submit" name="Submit" value="显示排行"></td>
  </tr>
</form>
</table>
<br>
<table width="100%" border="0" cellspacing="1" cellpadding="3" class="tableborder">
  <tr class="header" height="25"> 
    <td width="8%" align="center">排名</td>
	<td width="50%" align="center">栏目和书名</td>
	<td width="13%" align="center">今日阅读量</td>
	<td width="13%" align="center">昨日阅读量</td>
	<td width="8%" align="center">昨日排名</td>
	<td width="8%" align="center">升降</td>
  </tr>

<?php
$sql=$empire->query($query);
while($r=$empire->fetch($sql))
{
	$v=vsrank($r[classid],$r[id],$where);
	if($v==1){
		$word= '<font color="green">降</font>';
	}elseif($v==2){
		$word= '<font color="gray">平</font>';
	}else{
		$word= '<font color="red">升</font>';
	}
	$n=getnew($r[classid],$r[id]);
	if($n){
		$nw=' <font color="red">新！</font>';
	}else{
		$nw='';
	}
	$yy=rank($r[classid],$r[id],$where,0);
	if($yy==0){
		$yw='无';
	}else{
		$yw=$yy;
	}
?>
  <tr bgcolor="#ffffff">
    <td align="center"><?=rank($r[classid],$r[id],$where,1)?></td>
	<td style="padding:6px; line-height:16px;"><span class="hui">[<?=$class_r[$r[classid]][classname]?>]</span> <?=at($r[classid],$r[id]).$nw?></td>
	<td align="center"><?=$r[hit]?></td>
	<td align="center"><?=get_y($r[classid],$r[id])?></td>
	<td align="center"><?=$yw?></td>
	<td align="center"><?=$word?></td>
  </tr>	
<?
}
?>

</table>
<br>
<table width="100%" border="0" cellspacing="1" cellpadding="3" class="tableborder">
  <tr class="header"> 
    <td height="25">使用说明</td>
  </tr>
  <tr> 
    <td height="25" bgcolor="#FFFFFF">在书籍内容页或章节内容页的页面最底部加上如下代码：<br>
      &lt;script src=&quot;[!--news.url--]e/dongpo/top/index.php?classid=[!--class.id--]&id=[!--id--]&quot;&gt;&lt;/script&gt;<br>
	  调用：
	  用灵动标签调用。</td>
  </tr>
</table>
</body>
</html>
<?php
db_close();
$empire=null;
?>