<?php

require './include/common.inc.php';
sajax_init();
sajax_export("giverank");
sajax_handle_client_request();
$servlist = array();
$result = $db->query("SELECT id,servername FROM ".TABLE_GAMESERVER." ORDER BY id");
while($r = $db->fetch_array($result))
{
$servlist[] = $r;
}
$head['title'] = "玩家排行榜";
include template('game','rank');
function giverank($id)
{
if (!$id) return "<font color=red>错误的参数</font>";
if(!check_con($id)) return "<font color=red>连接服务器失败，不能获得排行信息！</font>";
$sqldb = real_con($id);
$sqldb->select_db(game_fso($id));
$users = array();
$rs = $sqldb->query("SELECT Name,Level,Exp,Metier,MetierLevel,Gold,Faction,OnlineTime,PK FROM user WHERE deleted=0 ORDER BY Level DESC,Exp DESC,Gold DESC limit 100");
while($r = $sqldb->fetch_array($rs))
{
$r['job'] = getmetiers($r['MetierLevel'],$r['Metier']);
$r['Faction'] = Faction($r['Faction']);
$users[] = $r;
}
foreach($users as $k=>$user)
{
if (+$k >2)
{
$k= ++$k;
}else{
$k='<IMG src="'.HS_PATH.'images/'.++$k.'.gif" border=0>';
}
$bstr .= '<TR><TD style="FONT-WEIGHT: bold; COLOR: #ff0000">'.$k.'</TD><TD  style="FONT-WEIGHT: bold; COLOR: #990000">'.$user[Name].' </TD><TD style="FONT-WEIGHT: bold; COLOR: #ff8900">'.$user[job].' </TD><TD style="FONT-WEIGHT: bold; COLOR: #ff8900">'.$user[Level].'</TD><TD style="FONT-WEIGHT: bold; COLOR: #ff8900">'.$user[Faction].'</TD><TD style="FONT-WEIGHT: bold; COLOR: #ff0000">'.$user[Gold].'</TD></TR>';
}
return '<TABLE class=top_tab style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; WIDTH: 100%; BORDER-COLLAPSE: collapse; BORDER-RIGHT-WIDTH: 0px" cellSpacing=0 cellPadding=0 align=center border=0><TBODY><TR><TD class=tds style="FONT-WEIGHT: bold">排名</TD><TD class=tds style="FONT-WEIGHT: bold">角色名</TD><TD class=tds style="FONT-WEIGHT: bold">职业</TD><TD class=tds style="FONT-WEIGHT: bold">等级</TD><TD class=tds style="FONT-WEIGHT: bold">阵营</TD><TD class=tdm style="FONT-WEIGHT: bold">财富</TD></TR>'.$bstr.'</TBODY></TABLE>';
}
?>