<?php
/*********************/
/*                   */
/*  Version : 5.1.0  */
/*  Author  : RM     */
/*  Comment : 071223 */
/*                   */
/*********************/

echo "<html>\r\n<head>\r\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\" />\r\n<title>Mu Infinite</title>\r\n<link href=\"estilo.css\" rel=\"stylesheet\" type=\"text/css\">\r\n<style type=\"text/css\">\r\n<!--\r\nbody,td,th {\r\n\tfont-size: 14px;\r\n\tfont-family: Arial, Helvetica, sans-serif;\r\n}\r\n.style78 {\r\n\tfont-size: 10px;\r\n\tcolor: #333333;\r\n}\r\n-->\r\n\r\n</style>\r\n<style type=\"text/css\">\r\n<!--\r\n  .formata { /* esta classe é somente \r\n               para formatar a fonte */\r\n  font: 12px arial, verdana, helvetica, sans-serif; \r\n  }\r\n  a.dcontexto{\r\n  position:relative; \r\n  font:12px arial, verdana, helvetica, sans-serif; \r\n  padding:0;\r\n  color:#039;\r\n  text-decoration:none;\r\n  cursor:help; \r\n  z-index:24;\r\n  }\r\n  a.dcontexto:hover{\r\n  background:transparent;\r\n  z-index:25; \r\n  }\r\n  a.dcontexto span{display: none}\r\n  a.dcontexto:hover span{ \r\n  display:block;\r\n  position:absolute;\r\n  width:250px; \r\n  top:2em;\r\n  text-align:justify;\r\n  left:-3em;\r\n  font: 12px arial, verdana, helvetica, sans-serif; \r\n  padding:5px 10px;\r\n  border:1px solid #999;\r\n  background:#e0ffff; \r\n  color:#000;\r\n  }\r\n  -->\r\n</style>\r\n</head>\r\n\r\n<body background=\"../images/preto1.gif\" topmargin=\"0\">\r\n\r\n";
$o = º;
$order = $_POST['order'];
$classe = $_POST['classe'];
$orderby = $_POST['orderby'];
$qt = $_POST['qt'];
if ( !$orderby )
{
    $orderby = "desc";
}
if ( !$order )
{
    $order = "Resets";
    $fimquery = ", cLevel ".$orderby;
}
if ( !$qt )
{
    $qt = 30;
}
if ( $classe )
{
    $andclass = "AND Class=".$classe;
}
if ( $classe == "0_" )
{
    $andclass = "AND Class=0";
}
if ( $classe == "all" )
{
    $andclass = "";
}
if ( $order == "cLevel" )
{
    $order = "cLevel";
    $fimquery = "";
}
if ( $order == "Resetao" )
{
    $order = "Resetao";
    $fimquery = ", Resets ".$orderby;
}
include( "config.php" );
include( "paginator.php" );
$sql = mssql_query( "SELECT count(*) FROM Character WHERE CtlCode=0 ".$andclass."" );
$num_rows = mssql_result( $sql, 0, 0 );
$a =& new paginator( $_GET['page'], $num_rows );
if ( $topnumber == "" )
{
    $topnumber = 30;
}
$a->set_limit( $topnumber );
$a->set_links( 5 );
$limit1 = $a->getrange1( );
$limit2 = $a->getrange2( );
$query = "SELECT TOP ";
$query .= $limit1 + $limit2;
$query .= " Name,Class,cLevel,Strength,Dexterity,Vitality,Energy,LevelUpPoint,CtlCode,Resets,AccountID,Resetao from Character WHERE CtlCode=0 ".$andclass." order by ".$order." ".$orderby.$fimquery;
echo "<div align=\"center\">\r\n  ";
if ( $order == "Name" )
{
    $ordemnome = "selected='selected'";
}
if ( $order == "cLevel" )
{
    $ordemlvl = "selected='selected'";
}
if ( $order == "Strength" )
{
    $ordemforca = "selected='selected'";
}
if ( $order == "Dexterity" )
{
    $ordemagili = "selected='selected'";
}
if ( $order == "Vitality" )
{
    $ordemvida = "selected='selected'";
}
if ( $order == "Energy" )
{
    $ordemernegia = "selected='selected'";
}
if ( $order == "Resets" )
{
    $ordemresets = "selected='selected'";
}
if ( $order == "Resetao" )
{
    $ordemresetao = "selected='selected'";
}
if ( $classe == "all" )
{
    $ordemtudo = "selected='selected'";
}
if ( $classe == "0_" )
{
    $ordemdw = "selected='selected'";
}
if ( $classe == "1" )
{
    $ordemsm = "selected='selected'";
}
if ( $classe == "16" )
{
    $ordemdk = "selected='selected'";
}
if ( $classe == "17" )
{
    $ordembk = "selected='selected'";
}
if ( $classe == "32" )
{
    $ordemfe = "selected='selected'";
}
if ( $classe == "33" )
{
    $ordemme = "selected='selected'";
}
if ( $classe == "48" )
{
    $ordemmg = "selected='selected'";
}
if ( $classe == "64" )
{
    $ordemdl = "selected='selected'";
}
echo "  \t<table width=\"80%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\r\n                  <tr>\r\n                    <td width=\"87\"><div align=\"center\">Ordernar por: </div></td>\r\n                    <td width=\"116\"><div align=\"center\">Classe</div></td>\r\n                    <td width=\"65\"><div align=\"center\">Quantidade</div></td>\r\n                    <td width=\"94\"></td>\r\n                  </tr>\r\n                  <tr height=\"5\">\r\n                    <td></td>\r\n                    <td></td>\r\n                    <td></td>\r\n                    <td></td>\r\n                  </tr>\r\n                  <tr>\r\n\t\t\t\t\t<form name=\"form1\" action=\"?pagina=ranking\" method=\"post\">\r\n                    <td align=\"center\"><select name=\"order\" class=\"rankcampos\">\r\n\t\t\t\t\t\r\n                      <option value=\"Name\" ";
echo $ordemnome;
echo ">Nome</option>\r\n                      <option value=\"cLevel\" ";
echo $ordemlvl;
echo ">Level</option>\r\n                      <option value=\"Strength\" ";
echo $ordemforca;
echo ">For&ccedil;a</option>\r\n                      <option value=\"Dexterity\" ";
echo $ordemagili;
echo ">Agilidade</option>\r\n                      <option value=\"Vitality\" ";
echo $ordemvida;
echo ">Vitalidade</option>\r\n                      <option value=\"Energy\" ";
echo $ordemernegia;
echo ">Energia</option>\r\n                      <option value=\"Resets\" ";
echo $ordemresets;
echo ">Resets</option>\r\n                      <option value=\"Resetao\" ";
echo $ordemresetao;
echo ">Resetao</option>\r\n                    </select>\r\n                      </td>\r\n                    <td align=\"center\"><select name=\"classe\" class=\"rankcampos\">\r\n                      <option value=\"all\" ";
echo $ordemtudo;
echo ">Todas</option>\r\n                      <option value=\"0_\" ";
echo $ordemdw;
echo ">Dark Wizard</option>\r\n                      <option value=\"1\" ";
echo $ordemsm;
echo ">Soul Master</option>\r\n                      <option value=\"16\" ";
echo $ordemdk;
echo ">Dark Knight</option>\r\n                      <option value=\"17\" ";
echo $ordembk;
echo ">Blade Knight</option>\r\n                      <option value=\"32\" ";
echo $ordemfe;
echo ">Fary Elf</option>\r\n                      <option value=\"33\" ";
echo $ordemme;
echo ">Muse Elf</option>\r\n                      <option value=\"48\" ";
echo $ordemmg;
echo ">Magic Gladiator</option>\r\n                      <option value=\"64\" ";
echo $ordemdl;
echo ">Dark Lord</option>\r\n                    </select></td>\r\n\t\t\t\t\t<td align=\"center\"><input type=\"submit\" name=\"Submit\" value=\"Carregar\" class=\"rankcampos\"></td>\r\n                  </tr>\r\n                </table>\r\n  <br>\r\n<table width=\"90%\" border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\">\r\n<tr> \r\n    <td width=\"5%\" align=\"center\" class=\"rankcategoria\">Pos</td>\r\n    <td width=\"20%\" align=\"center\" class=\"rankcategoria\">Personagem</td>\r\n    <td width=\"8%\" align=\"center\" class=\"rankcategoria\">Classe</td>\r\n    <td width=\"7%\" align=\"center\" class=\"rankcategoria\">Level</td>\r\n    <td width=\"9%\" align=\"center\" class=\"rankcategoria\">For&ccedil;a</td>\r\n    <td width=\"9%\" align=\"center\" class=\"rankcategoria\">Agili.</td>\r\n    <td width=\"9%\" align=\"center\" class=\"rankcategoria\">Vida</td>\r\n    <td width=\"9%\" align=\"center\" class=\"rankcategoria\">Energia</td>\r\n    <td width=\"8%\" align=\"center\" class=\"rankcategoria\">Resets</td>\r\n    <td width=\"9%\" align=\"center\" class=\"rankcategoria\">Resetao</td>\r\n    <td width=\"6%\" align=\"center\" class=\"rankcategoria\">Vip</td>\r\n  </tr>\r\n";
$result = mssql_query( $query );
$i = 0;
for ( ; $i < $limit1; ++$i )
{
    $row = mssql_fetch_row( $result );
}
$j = 0;
for ( ; $j < mssql_num_rows( $result ) - $limit1; ++$j )
{
    $row = mssql_fetch_row( $result );
    if ( $row[1] == 0 )
    {
        $row[1] = "DW";
    }
    if ( $row[1] == 1 )
    {
        $row[1] = "SM";
    }
    if ( $row[1] == 16 )
    {
        $row[1] = "DK";
    }
    if ( $row[1] == 17 )
    {
        $row[1] = "BK";
    }
    if ( $row[1] == 32 )
    {
        $row[1] = "Elf";
    }
    if ( $row[1] == 33 )
    {
        $row[1] = "ME";
    }
    if ( $row[1] == 48 )
    {
        $row[1] = "MG";
    }
    if ( $row[1] == 64 )
    {
        $row[1] = "DL";
    }
    $query_check_vip = mssql_query( "SELECT vip FROM MEMB_INFO WHERE memb___id='".$row['10']."'" );
    $check_vip = mssql_fetch_row( $query_check_vip );
    if ( $check_vip[0] == 0 )
    {
        $vip = "<font color='red'><b>N&atilde;o</b></font>";
    }
    if ( $check_vip[0] == 1 )
    {
        $vip = "<font color='#00FF00'><b>Sim</b></font>";
    }
    $rank = $i + $j + 1;
    echo "<tr>\r\n\t<td align=\"left\" class=\"rankresultado\"><b>";
    echo $rank;
    echo $o;
    echo "</b></td>\r\n    <td align=\"left\" class=\"rankresultado\">";
    echo $row[0];
    echo "</td>\r\n    <td align=\"center\" class=\"rankresultado\">";
    echo $row[1];
    echo "</td>\r\n    <td align=\"center\" class=\"rankresultado\">";
    echo $row[2];
    echo "</td>\r\n\t<td align=\"center\" class=\"rankresultado\">";
    echo $row[3];
    echo "</td>\r\n\t<td align=\"center\" class=\"rankresultado\">";
    echo $row[4];
    echo "</td>\r\n\t<td align=\"center\" class=\"rankresultado\">";
    echo $row[5];
    echo "</td>\r\n\t<td align=\"center\" class=\"rankresultado\">";
    echo $row[6];
    echo "</td>\r\n\t<td align=\"center\" class=\"rankresultado\">";
    echo $row[9];
    echo "</td>\r\n\t<td align=\"center\" class=\"rankresultado\">";
    echo $row[11];
    echo "</td>\r\n\t<td align=\"center\" class=\"rankresultado\">";
    echo $vip;
    echo "</td></tr>";
}
echo "     </table>\r\n<br>\r\n";
if ( $a->getcurrent( ) == 1 )
{
    $first = "<font class=\"ranktexto\">Primeira | </font>";
}
else
{
    $first = "<a href=\"".$a->getpagename( )."?pagina=ranking&page=".$a->getfirst( )."\" class=\"rank\">Primeira</a> |";
}
if ( $a->getprevious( ) )
{
    $prev = "<a href=\"".$a->getpagename( )."?pagina=ranking&page=".$a->getprevious( )."\" class=\"rank\">Anterior</a> | ";
}
else
{
    $prev = "<font class=\"ranktexto\">Anterior | </font>";
}
if ( $a->getnext( ) )
{
    $next = "<a href=\"".$a->getpagename( )."?pagina=ranking&page=".$a->getnext( )."\" class=\"rank\">Próxima</a> | ";
}
else
{
    $next = "<font class=\"ranktexto\">Próxima | </font>";
}
if ( $a->getlast( ) )
{
    $last = "<a href=\"".$a->getpagename( )."?pagina=ranking&page=".$a->getlast( )."\" class=\"rank\">Última</a>";
}
else
{
    $last = "<font class=\"ranktexto\">Última</font>";
}
echo "<font class=\"ranktexto\"> de ".$a->getfirstof( )." até ".$a->getsecondof( )." - Total de ".$a->gettotalitems( )." </font>| ";
echo $first." ".$prev." ".$next." ".$last;
echo "<br>";
if ( $a->getprevious( ) )
{
    echo "<a href=\"".$a->getpagename( )."?pagina=ranking&page=".$a->getprevious( )."\" class=\"rank\">Anterior</a> ";
}
$links = $a->getlinkarr( );
$current = $a->getcurrent( );
foreach ( $links as $link )
{
    if ( $link == $current )
    {
        echo " <font class=\"ranktexto\">".$link."</font> ";
    }
    else
    {
        echo "<a href=\"".$a->getpagename( ).( "?pagina=ranking&page=".$link."\" class=\"rank\">" ).$link."</a> ";
    }
}
if ( $a->getnext( ) )
{
    echo "<a href=\"".$a->getpagename( )."?pagina=ranking&page=".$a->getnext( )."\" class=\"rank\">Proxima</a> ";
}
echo "\r\n</body>\r\n</html>";
?>
