<?php

/* PROGRAMAÇÃO BY: BINHO, FUNDADOR DA CTGAMES - TEAM SOFTWARES */

if($_GET["mostrar"] == true) {
$tipo = $_GET["ranking_tipo"];
$quantidade = $_GET["ranking_quantidade"];
if($tipo == "selecione" || $quantidade == "selecione") {
	echo $bbcode->bbcode('<div class="box_conteudo">Selecione um ranking</div>');
}
elseif($tipo == 'reset') {
			echo $bbcode->bbcode('<div class="box_conteudo"><table width="100%" border="0" align="center" cellpadding="0" cellspacing="2">');
  				$reset = mssql_query("SELECT TOP $quantidade name,imagem,".colum_reset.",class FROM character ORDER BY ".colum_reset." desc");
  				if(mssql_num_rows($reset) <= 0) {
			echo '<tr><td><div class=erro>Nenhum Personagem encontrado</div></td></tr>';
		}
		for($x=0;$x<mssql_num_rows($reset)/5;$x++) {
			echo '<tr>';
		for($i=0;$i<5;$i++) {
			$top = mssql_fetch_row($reset); 
			if($top[2] <= 1) {$score = $top[2].' Reset';} else {$score = $top[2].' Resets';}
			$pos = $pos+1;
			switch($top[3]) {
case 0: $classefinal = "Dark Wizard"; break;
	case 1: $classefinal = "Soul Master"; break;
	case 3: $classefinal = "Grand Master"; break;
	case 16: $classefinal = "Dark Knight"; break;
	case 17: $classefinal = "Blade Knight"; break;
	case 18: $classefinal = "Blade Master"; break;
	case 32: $classefinal = "Fairy Elf"; break;
	case 33: $classefinal = "Muse Elf"; break;
	case 34: $classefinal = "High Elf"; break;
	case 48: $classefinal = "Magic Gladiator"; break;
	case 49: $classefinal = "Duel Master"; break;
	case 50: $classefinal = "Duel Master V2"; break;
	case 64: $classefinal = "Dark Lord"; break;
	case 65: $classefinal = "Lord Emperor"; break;
	case 66: $classefinal = "Emperor V2"; break;
	case 80: $classefinal = "Summoner"; break;
	case 81: $classefinal = "Blood Summoner"; break;
	case 82: $classefinal = "Dimension Master"; break;
	}
			if($pos <= $top) {
				if($top[0] == '') {
						echo '<td></td>';
			}
			else{
    			echo "<td align=\"center\">
					$pos&ordm; Colocado<br />
					<img src=\"images/personagens/".$top[1]."\" width=\"120\" height=\"140\" border=\"0\" /><br />
					Nome: <a href=\"javascript: void(0);\" onclick=\"loading('?go=char&name=".$top[0]."', 'conteudo_mostrar');\">".$top[0]."</a><br />
					Resets: ".$top[2]."<br />
					Classe: ".$classefinal."<br><br><hr></hr>
				</div>
				</td></div>
					  
";
			}
			}
		}
	}
}
elseif($tipo == 'mr') {
			echo $bbcode->bbcode('<div class="box_conteudo"><table width="100%" border="0" align="center" cellpadding="0" cellspacing="2">');
  				$reset = mssql_query("SELECT TOP $quantidade name,imagem,".colum_mreset.",class FROM character ORDER BY ".colum_mreset." desc");
  				if(mssql_num_rows($reset) <= 0) {
			echo '<tr><td><div class=erro>Nenhum Personagem encontrado</div></td></tr>';
		}
		for($x=0;$x<mssql_num_rows($reset)/5;$x++) {
			echo '<tr>';
		for($i=0;$i<5;$i++) {
			$top = mssql_fetch_row($reset); 
			if($top[2] <= 1) {$score = $top[2].' Reset';} else {$score = $top[2].' Resets';}
			$pos = $pos+1;
			switch($top[3]) {
	case 0: $classefinal = "Dark Wizard"; break;
	case 1: $classefinal = "Soul Master"; break;
	case 3: $classefinal = "Grand Master"; break;
	case 16: $classefinal = "Dark Knight"; break;
	case 17: $classefinal = "Blade Knight"; break;
	case 18: $classefinal = "Blade Master"; break;
	case 32: $classefinal = "Fairy Elf"; break;
	case 33: $classefinal = "Muse Elf"; break;
	case 34: $classefinal = "High Elf"; break;
	case 48: $classefinal = "Magic Gladiator"; break;
	case 49: $classefinal = "Duel Master"; break;
	case 50: $classefinal = "Duel Master V2"; break;
	case 64: $classefinal = "Dark Lord"; break;
	case 65: $classefinal = "Lord Emperor"; break;
	case 66: $classefinal = "Emperor V2"; break;
	case 80: $classefinal = "Summoner"; break;
	case 81: $classefinal = "Blood Summoner"; break;
	case 82: $classefinal = "Dimension Master"; break;
	}
			if($pos <= $top) {
				if($top[0] == '') {
						echo '<td></td>';
			}
			else{
    			echo "<td align=\"center\">
					$pos&ordm; Colocado<br />
					<img src=\"images/personagens/".$top[1]."\" width=\"120\" height=\"140\" border=\"0\" /><br />
					Nome: <a href=\"javascript: void(0);\" onclick=\"loading('?go=char&name=".$top[0]."', 'conteudo_mostrar');\">".$top[0]."</a><br />
					MR's: ".$top[2]."<br />
					Classe: ".$classefinal."<br><br><hr></hr>
				</div>
				</td></div>";
			}
			}
		}
	}
}

elseif($tipo == 'chaos') {
			echo $bbcode->bbcode('<div class="box_conteudo"><table width="100%" border="0" align="center" cellpadding="0" cellspacing="2">');
  				$reset = mssql_query("SELECT TOP $quantidade name,".chaos_pt." FROM ".dbo_chaos." ORDER BY ".chaos_pt_semanal." desc");
  				if(mssql_num_rows($reset) <= 0) {
			echo '<tr><td><div class=erro>Nenhum Personagem encontrado</div></td></tr>';
		}
		for($x=0;$x<mssql_num_rows($reset)/5;$x++) {
			echo '<tr>';
		for($i=0;$i<5;$i++) {
			$top = mssql_fetch_row($reset); 
			if($top[2] <= 1) {$score = $top[2].' Reset';} else {$score = $top[2].' Resets';}
			$pos = $pos+1;
			switch($top[3]) {
	case 0: $classefinal = "Dark Wizard"; break;
	case 1: $classefinal = "Soul Master"; break;
	case 3: $classefinal = "Grand Master"; break;
	case 16: $classefinal = "Dark Knight"; break;
	case 17: $classefinal = "Blade Knight"; break;
	case 18: $classefinal = "Blade Master"; break;
	case 32: $classefinal = "Fairy Elf"; break;
	case 33: $classefinal = "Muse Elf"; break;
	case 34: $classefinal = "High Elf"; break;
	case 48: $classefinal = "Magic Gladiator"; break;
	case 49: $classefinal = "Duel Master"; break;
	case 50: $classefinal = "Duel Master V2"; break;
	case 64: $classefinal = "Dark Lord"; break;
	case 65: $classefinal = "Lord Emperor"; break;
	case 66: $classefinal = "Emperor V2"; break;
	case 80: $classefinal = "Summoner"; break;
	case 81: $classefinal = "Blood Summoner"; break;
	case 82: $classefinal = "Dimension Master"; break;
	}
			if($pos <= $top) {
				if($top[0] == '') {
						echo '<td></td>';
			}
			else{
    			echo "<td align=\"center\">
					$pos&ordm; Colocado<br />
					<img src=\"images/personagens/sem_foto.gif\" width=\"120\" height=\"140\" border=\"0\" /><br />
					Nome: <a href=\"javascript: void(0);\" onclick=\"loading('?go=char&name=".$top[0]."', 'conteudo_mostrar');\">".$top[0]."</a><br />
					Score: ".$top[1]."<br />
					Classe: ".$classefinal."<br><br><hr></hr>
				</div>
				</td></div>";
			}
			}
		}
	}
}

elseif($tipo == 'blood') {
			echo $bbcode->bbcode('<div class="box_conteudo"><table width="100%" border="0" align="center" cellpadding="0" cellspacing="2">');
  				$reset = mssql_query("SELECT TOP $quantidade name,".blood_pt." FROM ".dbo_blood." ORDER BY ".blood_pt_semanal." desc");
  				if(mssql_num_rows($reset) <= 0) {
			echo '<tr><td><div class=erro>Nenhum Personagem encontrado</div></td></tr>';
		}
		for($x=0;$x<mssql_num_rows($reset)/5;$x++) {
			echo '<tr>';
		for($i=0;$i<5;$i++) {
			$top = mssql_fetch_row($reset); 
			if($top[2] <= 1) {$score = $top[2].' Reset';} else {$score = $top[2].' Resets';}
			$pos = $pos+1;
			switch($top[3]) {
	case 0: $classefinal = "Dark Wizard"; break;
	case 1: $classefinal = "Soul Master"; break;
	case 3: $classefinal = "Grand Master"; break;
	case 16: $classefinal = "Dark Knight"; break;
	case 17: $classefinal = "Blade Knight"; break;
	case 18: $classefinal = "Blade Master"; break;
	case 32: $classefinal = "Fairy Elf"; break;
	case 33: $classefinal = "Muse Elf"; break;
	case 34: $classefinal = "High Elf"; break;
	case 48: $classefinal = "Magic Gladiator"; break;
	case 49: $classefinal = "Duel Master"; break;
	case 50: $classefinal = "Duel Master V2"; break;
	case 64: $classefinal = "Dark Lord"; break;
	case 65: $classefinal = "Lord Emperor"; break;
	case 66: $classefinal = "Emperor V2"; break;
	case 80: $classefinal = "Summoner"; break;
	case 81: $classefinal = "Blood Summoner"; break;
	case 82: $classefinal = "Dimension Master"; break;
	}
			if($pos <= $top) {
				if($top[0] == '') {
						echo '<td></td>';
			}
			else{
    			echo "<td align=\"center\">
					$pos&ordm; Colocado<br />
					<img src=\"images/personagens/sem_foto.gif\" width=\"120\" height=\"140\" border=\"0\" /><br />
					Nome: <a href=\"javascript: void(0);\" onclick=\"loading('?go=char&name=".$top[0]."', 'conteudo_mostrar');\">".$top[0]."</a><br />
					Score: ".$top[1]."<br />
					Classe: ".$classefinal."<br><br><hr></hr>
				</div>
				</td></div>";
			}
			}
		}
	}
}


elseif($tipo == 'devil') {
			echo $bbcode->bbcode('<div class="box_conteudo"><table width="100%" border="0" align="center" cellpadding="0" cellspacing="2">');
  				$reset = mssql_query("SELECT TOP $quantidade name,".devil_pt." FROM ".dbo_devil." ORDER BY ".devil_pt_semanal." desc");
  				if(mssql_num_rows($reset) <= 0) {
			echo '<tr><td><div class=erro>Nenhum Personagem encontrado</div></td></tr>';
		}
		for($x=0;$x<mssql_num_rows($reset)/5;$x++) {
			echo '<tr>';
		for($i=0;$i<5;$i++) {
			$top = mssql_fetch_row($reset); 
			if($top[2] <= 1) {$score = $top[2].' Reset';} else {$score = $top[2].' Resets';}
			$pos = $pos+1;
			switch($top[3]) {
	case 0: $classefinal = "Dark Wizard"; break;
	case 1: $classefinal = "Soul Master"; break;
	case 3: $classefinal = "Grand Master"; break;
	case 16: $classefinal = "Dark Knight"; break;
	case 17: $classefinal = "Blade Knight"; break;
	case 18: $classefinal = "Blade Master"; break;
	case 32: $classefinal = "Fairy Elf"; break;
	case 33: $classefinal = "Muse Elf"; break;
	case 34: $classefinal = "High Elf"; break;
	case 48: $classefinal = "Magic Gladiator"; break;
	case 49: $classefinal = "Duel Master"; break;
	case 50: $classefinal = "Duel Master V2"; break;
	case 64: $classefinal = "Dark Lord"; break;
	case 65: $classefinal = "Lord Emperor"; break;
	case 66: $classefinal = "Emperor V2"; break;
	case 80: $classefinal = "Summoner"; break;
	case 81: $classefinal = "Blood Summoner"; break;
	case 82: $classefinal = "Dimension Master"; break;
	}
			if($pos <= $top) {
				if($top[0] == '') {
						echo '<td></td>';
			}
			else{
    			echo "<td align=\"center\">
					$pos&ordm; Colocado<br />
					<img src=\"images/personagens/sem_foto.gif\" width=\"120\" height=\"140\" border=\"0\" /><br />
					Nome: <a href=\"javascript: void(0);\" onclick=\"loading('?go=char&name=".$top[0]."', 'conteudo_mostrar');\">".$top[0]."</a><br />
					Score: ".$top[1]."<br />
					Classe: ".$classefinal."<br><br><hr></hr>
				</div>
				</td></div>";
			}
			}
		}
	}
}
elseif($tipo == 'killer') {
			echo $bbcode->bbcode('<div class="box_conteudo"><table width="100%" border="0" align="center" cellpadding="0" cellspacing="2">');
  				$reset = mssql_query("SELECT TOP $quantidade name,imagem,-pkcount,class FROM character ORDER BY -pkcount asc");
  				if(mssql_num_rows($reset) <= 0) {
			echo '<tr><td><div class=erro>Nenhum Personagem encontrado</div></td></tr>';
		}
		for($x=0;$x<mssql_num_rows($reset)/5;$x++) {
			echo '<tr>';
		for($i=0;$i<5;$i++) {
			$top = mssql_fetch_row($reset); 
			if($top[2] <= 1) {$score = $top[2].' Reset';} else {$score = $top[2].' Resets';}
			$pos = $pos+1;
			switch($top[3]) {
	case 0: $classefinal = "Dark Wizard"; break;
	case 1: $classefinal = "Soul Master"; break;
	case 3: $classefinal = "Grand Master"; break;
	case 16: $classefinal = "Dark Knight"; break;
	case 17: $classefinal = "Blade Knight"; break;
	case 18: $classefinal = "Blade Master"; break;
	case 32: $classefinal = "Fairy Elf"; break;
	case 33: $classefinal = "Muse Elf"; break;
	case 34: $classefinal = "High Elf"; break;
	case 48: $classefinal = "Magic Gladiator"; break;
	case 49: $classefinal = "Duel Master"; break;
	case 50: $classefinal = "Duel Master V2"; break;
	case 64: $classefinal = "Dark Lord"; break;
	case 65: $classefinal = "Lord Emperor"; break;
	case 66: $classefinal = "Emperor V2"; break;
	case 80: $classefinal = "Summoner"; break;
	case 81: $classefinal = "Blood Summoner"; break;
	case 82: $classefinal = "Dimension Master"; break;
	}
			if($pos <= $top) {
				if($top[0] == '') {
						echo '<td></td>';
			}
			else{
    			echo "<td align=\"center\">
					$pos&ordm; Colocado<br />
					<img src=\"images/personagens/".$top[1]."\" width=\"120\" height=\"140\" border=\"0\" /><br />
					Nome: <a href=\"javascript: void(0);\" onclick=\"loading('?go=char&name=".$top[0]."', 'conteudo_mostrar');\">".$top[0]."</a><br />
					Killer's: ".$top[2]."<br />
					Classe: ".$classefinal."<br><br><hr></hr>
				</div>
				</td></div>";
			}
			}
		}
	}
}
elseif($tipo == 'pkkiller') {
			echo $bbcode->bbcode('<div class="box_conteudo"><table width="100%" border="0" align="center" cellpadding="0" cellspacing="2">');
  				$reset = mssql_query("SELECT TOP $quantidade name,imagem,pkcount,class FROM character ORDER BY pkcount desc");
  				if(mssql_num_rows($reset) <= 0) {
			echo '<tr><td><div class=erro>Nenhum Personagem encontrado</div></td></tr>';
		}
		for($x=0;$x<mssql_num_rows($reset)/5;$x++) {
			echo '<tr>';
		for($i=0;$i<5;$i++) {
			$top = mssql_fetch_row($reset); 
			if($top[2] <= 1) {$score = $top[2].' Reset';} else {$score = $top[2].' Resets';}
			$pos = $pos+1;
			switch($top[3]) {
case 0: $classefinal = "Dark Wizard"; break;
	case 1: $classefinal = "Soul Master"; break;
	case 3: $classefinal = "Grand Master"; break;
	case 16: $classefinal = "Dark Knight"; break;
	case 17: $classefinal = "Blade Knight"; break;
	case 18: $classefinal = "Blade Master"; break;
	case 32: $classefinal = "Fairy Elf"; break;
	case 33: $classefinal = "Muse Elf"; break;
	case 34: $classefinal = "High Elf"; break;
	case 48: $classefinal = "Magic Gladiator"; break;
	case 49: $classefinal = "Duel Master"; break;
	case 50: $classefinal = "Duel Master V2"; break;
	case 64: $classefinal = "Dark Lord"; break;
	case 65: $classefinal = "Lord Emperor"; break;
	case 66: $classefinal = "Emperor V2"; break;
	case 80: $classefinal = "Summoner"; break;
	case 81: $classefinal = "Blood Summoner"; break;
	case 82: $classefinal = "Dimension Master"; break;
	}
			if($pos <= $top) {
				if($top[0] == '') {
						echo '<td></td>';
			}
			else{
    			echo "<td align=\"center\">
					$pos&ordm; Colocado<br />
					<img src=\"images/personagens/".$top[1]."\" width=\"120\" height=\"140\" border=\"0\" /><br />
					Nome: <a href=\"javascript: void(0);\" onclick=\"loading('?go=char&name=".$top[0]."', 'conteudo_mostrar');\">".$top[0]."</a><br />
					PK Killer's: ".$top[2]."<br />
					Classe: ".$classefinal."<br><br><hr></hr>
				</div>
				</td></div>";
			}
			}
		}
	}
}
elseif($tipo == 'level') {
			echo $bbcode->bbcode('<div class="box_conteudo"><table width="100%" border="0" align="center" cellpadding="0" cellspacing="2">');
  				$reset = mssql_query("SELECT TOP $quantidade name,imagem,clevel,class FROM character ORDER BY clevel desc");
  				if(mssql_num_rows($reset) <= 0) {
			echo '<tr><td><div class=erro>Nenhum Personagem encontrado</div></td></tr>';
		}
		for($x=0;$x<mssql_num_rows($reset)/5;$x++) {
			echo '<tr>';
		for($i=0;$i<5;$i++) {
			$top = mssql_fetch_row($reset); 
			if($top[2] <= 1) {$score = $top[2].' Reset';} else {$score = $top[2].' Resets';}
			$pos = $pos+1;
			switch($top[3]) {
	case 0: $classefinal = "Dark Wizard"; break;
	case 1: $classefinal = "Soul Master"; break;
	case 3: $classefinal = "Grand Master"; break;
	case 16: $classefinal = "Dark Knight"; break;
	case 17: $classefinal = "Blade Knight"; break;
	case 18: $classefinal = "Blade Master"; break;
	case 32: $classefinal = "Fairy Elf"; break;
	case 33: $classefinal = "Muse Elf"; break;
	case 34: $classefinal = "High Elf"; break;
	case 48: $classefinal = "Magic Gladiator"; break;
	case 49: $classefinal = "Duel Master"; break;
	case 50: $classefinal = "Duel Master V2"; break;
	case 64: $classefinal = "Dark Lord"; break;
	case 65: $classefinal = "Lord Emperor"; break;
	case 66: $classefinal = "Emperor V2"; break;
	case 80: $classefinal = "Summoner"; break;
	case 81: $classefinal = "Blood Summoner"; break;
	case 82: $classefinal = "Dimension Master"; break;
	}
			if($pos <= $top) {
				if($top[0] == '') {
						echo '<td></td>';
			}
			else{
    			echo "<td align=\"center\">
					$pos&ordm; Colocado<br />
					<img src=\"images/personagens/".$top[1]."\" width=\"120\" height=\"140\" border=\"0\" /><br />
					Nome: <a href=\"javascript: void(0);\" onclick=\"loading('?go=char&name=".$top[0]."', 'conteudo_mostrar');\">".$top[0]."</a><br />
					Level: ".$top[2]."<br />
					Classe: ".$classefinal."<br><br><hr></hr>
				</div>
				</td></div>";
			}
			}
		}
	}
}
elseif($tipo == 'guilds') {
			echo $bbcode->bbcode('<div class="box_conteudo"><table width="100%" border="0" align="center" cellpadding="0" cellspacing="2">');
  				$reset = mssql_query("SELECT TOP $quantidade g_name,g_mark,g_score FROM guild ORDER BY g_score desc");
  				if(mssql_num_rows($reset) <= 0) {
			echo '<tr><td><div class=erro>Nenhuma Guild encontrada</div></td></tr>';
		}
		for($x=0;$x<mssql_num_rows($reset)/5;$x++) {
			echo '<tr>';
		for($i=0;$i<5;$i++) {
			$top = mssql_fetch_row($reset);
			$logo = urlencode(bin2hex($top[1])); 
			if($top[2] <= 1) {$score = $top[2].' Reset';} else {$score = $top[2].' Resets';}
			$pos = $pos+1;
			switch($top[3]) {
case 0: $classefinal = "Dark Wizard"; break;
	case 1: $classefinal = "Soul Master"; break;
	case 3: $classefinal = "Grand Master"; break;
	case 16: $classefinal = "Dark Knight"; break;
	case 17: $classefinal = "Blade Knight"; break;
	case 18: $classefinal = "Blade Master"; break;
	case 32: $classefinal = "Fairy Elf"; break;
	case 33: $classefinal = "Muse Elf"; break;
	case 34: $classefinal = "High Elf"; break;
	case 48: $classefinal = "Magic Gladiator"; break;
	case 49: $classefinal = "Duel Master"; break;
	case 50: $classefinal = "Duel Master V2"; break;
	case 64: $classefinal = "Dark Lord"; break;
	case 65: $classefinal = "Lord Emperor"; break;
	case 66: $classefinal = "Emperor V2"; break;
	case 80: $classefinal = "Summoner"; break;
	case 81: $classefinal = "Blood Summoner"; break;
	case 82: $classefinal = "Dimension Master"; break;
	}
			if($pos <= $top) {
				if($top[0] == '') {
						echo '<td></td>';
			}
			else{
    			echo "<td align=\"center\">
					$pos&ordm; Colocado<br />
					<img src=\"images/decode.php?decode=".$logo."\" width=\"120\" height=\"140\" border=\"0\" /><br />
					Nome: <a href=\"javascript: void(0);\" onclick=\"loading('?go=guild&g_name=".$top[0]."', 'conteudo_mostrar');\">".$top[0]."</a><br />
					Pontos: ".$top[2]."<br><br><hr></hr>
				</div>
				</td></div>";
			}
			}
		}
	}
}
}

?>