<center>	<table cellpadding="5" cellspacing="0"><tr>
<?php 
error_reporting(E_ERROR | E_WARNING | E_PARSE);

$tten_number="1";			// Количество отоброжаемых игроков в топе. Если 0 - отображает 10 человек, 1 - 50 человек, 3 - 100 человек.
$tten_level="1";			// Показывать (1) непоказывать (0) уровень
$tten_pk="1";				// Показывать (1) непоказывать (0) ПК
$tten_pvp="1";				// Показывать (1) непоказывать (0) ПвП
$tten_karma="1";			// Показывать (1) непоказывать (0) Карму

	if (!$link)
	{
		echo "Could Not Connect";
		die('Could not connect: ' . mysql_error());
	}		
	if (!mysql_select_db($L2JBS_config['mysql_db'],$link))
	{
		die('Could not change to L2J database: ' . mysql_error());
	}



	echo "<table border=\"0\" cellpadding=\"3\" cellspacing=\"0\" class=\"blanktab\"><tr>";

	if ($gmintopten)
	{	$sql = "select char_name, level, karma, pvpkills, pkkills, sex, clanid, onlinetime from characters ";	}
	else
	{	$sql = "select char_name, level, karma, pvpkills, pkkills, sex, clanid, onlinetime from characters where accesslevel = 0 ";	}
	if ($sort == "karma")
	{	$sql = $sql . "order by karma DESC ";	}
	elseif ($sort == "pvp")
	{	$sql = $sql . "order by pvpkills DESC ";	}
	elseif ($sort == "pk")
	{	$sql = $sql . "order by pkkills DESC ";	}
	elseif ($sort == "time")
	{	$sql = $sql . "order by onlinetime DESC ";	}
	else
	{	$sql = $sql . "order by exp DESC ";	}
	if ($tten_number == 0)
	{	$sql = $sql . "limit 10";	}
	elseif ($tten_number == 1)
	{	$sql = $sql . "limit 50";	}
	else
	{	$sql = $sql . "limit 100";	}
	$result = mysql_query($sql,$link);
	$count = 0;
	if ($result)
	{	$count = mysql_num_rows($result);	}
	

	echo "<td width=20% ><p ><b><center>Имя чара</p></td>";
	if ($tten_level)
	{	echo "<td width=15% ><p ><b><center>Уровень<a href=\"index.php?id=topten&sort=lvl\" ><img src=\"module/sortbut.gif\" width=\"21\" height=\"12\" border=\"0\"></a></p></td>";	}
	echo "<td width=20% ><p ><center><b>Клан</p></td>";
	if ($tten_pk)
	{	echo "<td width=10% ><p ><center><b>PK<a href=\"index.php?id=topten&sort=pk\" ><img src=\"module/sortbut.gif\" width=\"21\" height=\"12\" border=\"0\"></a></p></td>";	}
	if ($tten_pvp)
	{	echo "<td width=10% ><p ><center><b>PvP<a href=\"index.php?id=topten&sort=pvp\" ><img src=\"module/sortbut.gif\" width=\"21\" height=\"12\" border=\"0\"></a></p></td>";	}
	if ($tten_karma)
	{	echo "<td width=15% ><p ><center><b>Карма<a href=\"index.php?id=topten&sort=karma\" ><img src=\"module/sortbut.gif\" width=\"21\" height=\"12\" border=\"0\"></a></p></td>";	}
	if ($tten_time)
	{	echo "<td width=10% ><p ><center><b>Время онлайна<a href=\"index.php?id=topten&sort=time\" ><img src=\"module/sortbut.gif\" width=\"21\" height=\"12\" border=\"0\"></a></p></td>";	}
	echo "</tr>";
	$i=0;
	while ($i < $count)
	{
		$char_clan = mysql_result($result,$i,"clanid");
		$char_sex= mysql_result($result,$i,"sex");
		$char_name = mysql_result($result,$i,"char_name");
		$char_lvl= mysql_result($result,$i,"level");
		$karma = mysql_result($result,$i,"karma");
		$pvp = mysql_result($result,$i,"pvpkills");
		$pk = mysql_result($result,$i,"pkkills");
		$ontime = mysql_result($result,$i,"onlinetime");
		echo "<tr>";echo "<td ><p ><center><b>";
		if ($char_sex==0) { echo"<font color=#8080FF>$char_name</font>"; } 
		else { echo"<font color=#FF8080>$char_name</font>"; } echo"</p></td>";
		if ($tten_level)
		{	echo "<td ><p ><center>$char_lvl</p></td>";	}
		$clan_name = "&nbsp;";
		$sql = "select clan_name from clan_data where clan_id = '$char_clan'";
		$result2 = mysql_query($sql,$link);
		if ($result2)
		{	if (mysql_num_rows($result2))
			{	$clan_name = mysql_result($result2,0,"clan_name");	}
		}
		echo "<td ><p ><center>$clan_name</p></td>";	

		if ($tten_pk)
		{	echo "<td ><p ><center><font color=red><b>$pk</p></td>";	}
		if ($tten_pvp)
		{	echo "<td ><p ><center><font color=000000><b>$pvp</p></td>";	}
		if ($tten_karma)
		{	echo "<td ><p ><center>$karma</p></td>";	}
		if ($tten_time)
		{	
			$onlinetime = onlinetime($ontime);
			echo "<td ><p >$onlinetime</p></td>";	
		}
		echo "</tr>";
		$i++;
	}
	echo "</table></center>";
?>
