<?php
include(dirname(__FILE__)."/require.php");
if($ppurview[10]!=1)
  jump("jump.php?id=25&jump=main.php");
if(!isset($_GET['page']))
  $_GET['page']=0;
if(!isset($_GET['action']))
  $_GET['action']="jin";
$phpcolor->table="bar";
$phpcolor->field="*";
$phpcolor->where="1=1";
$count = $phpcolor->exist(2);
$phpcolor->field="id,barname,ranking,rankings,rankingq,state";
if($_GET["action"]=="zuo")
{
  $phpcolor->where="1=1 order by rankings desc limit ".($_GET['page']*35).",35";
  $page=pages($count,35,$_GET['page'],'rankings','&action=zuo','','0');
}
elseif($_GET["action"]=="qian")
{
  $phpcolor->where="1=1 order by rankingq desc limit ".($_GET['page']*35).",35";
  $page=pages($count,35,$_GET['page'],'rankings','&action=qian','','0');
}
else
{
  $phpcolor->where="1=1 order by ranking desc limit ".($_GET['page']*35).",35";
  $page=pages($count,35,$_GET['page'],'rankings','','','0');
}
$bar=$phpcolor->assignment();
$barrs=count($bar);
$bars=5-$barrs%5;
for($count=0;$count<$barrs;$count++)
{
  if($bar[$count]["rankings"]==0)
  {
    $bar[$count]["upordown"]="1";
    $bar[$count]["baifen"]=ceil($bar[$count]["ranking"]*100);
  }
  elseif($bar[$count]["ranking"]>$bar[$count]["rankings"])
  {
    $bar[$count]["upordown"]="1";
    $bar[$count]["baifen"]=ceil(($bar[$count]["ranking"]-$bar[$count]["rankings"])/$bar[$count]["rankings"]*100);
  }
  else
  {
    $bar[$count]["upordown"]="2";
    $bar[$count]["baifen"]=ceil(($bar[$count]["rankings"]-$bar[$count]["ranking"])/$bar[$count]["rankings"]*100);
  }
  
  if($bar[$count]["rankingq"]==0)
  {
    $bar[$count]["upordowns"]="1";
    $bar[$count]["baifens"]=ceil($bar[$count]["rankings"]*100);
  }
  elseif($bar[$count]["rankings"]>$bar[$count]["rankingq"])
  {
    $bar[$count]["upordowns"]="1";
    $bar[$count]["baifens"]=ceil(($bar[$count]["rankings"]-$bar[$count]["rankingq"])/$bar[$count]["rankingq"]*100);
  }
  else
  {
    $bar[$count]["upordowns"]="2";
    $bar[$count]["baifens"]=ceil(($bar[$count]["rankingq"]-$bar[$count]["rankings"])/$bar[$count]["rankingq"]*100);
  }
  if($bar[$count]["state"]=="3")
    $bar[$count]["state"]="<span style='color:#FFCC00'>不显示排名</span>";
  else
    $bar[$count]["state"]="<span style='color:#00FF00'>显示排名</span>";
}
$paiming=$_GET['page']*35;
$tpl -> assign("bar", $bar);
$tpl -> assign("bars", $bars);
$tpl -> assign("page", $page);
$tpl -> assign("paiming", $paiming);
$tpl -> assign("riqi", $_GET['action']);
$tpl -> display("rankings.htm");
?> 