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

echo "<html>\r\n<script language=\"javascript\" type=\"text/javascript\" src=\"logar/funcoes.js\"></script>\r\n";
$classe = new td_class( );
$mid = $classe->checkcookie( );
$character = $classe->checkcookiechar( );
$nome = $classe->selecionanomedaguild( $character );
$mudarnome = $_POST['mudarnomeok'];
$mudarmsg = $_POST['mudarmsgok'];
$tirar = $_GET['tirar'];
$aaa = $_GET['aaa'];
if ( $mudarnome )
{
    $novo_nome = $_POST['novo_nome'];
    $classe->checacampoembranco( $novo_nome, "Novo Nome" );
    $classe->checacaracteres( $novo_nome );
    $classe->verificaguild( $novo_nome, "gerenciarguild" );
    $classe->verificaultlogado( $mid, $character, "mudar nome da guild" );
    $classe->executatrocanomeguild( $novo_nome, $classe->selecionanomedaguild( $character ) );
}
if ( $mudarmsg )
{
    $nova_msg = $_POST['novo_msg'];
    $classe->checacampoembranco( $nova_msg, "Nova Mensagem" );
    $classe->checacaracterescompra( $nova_msg, "nova mensagem" );
    $classe->verificaultlogado( $mid, $character, "mudar mensagem da guild" );
    $classe->executatrocarmsgguild( $classe->selecionanomedaguild( $character ), $novo_msg );
}
if ( $tirar )
{
    $classe->executatirarcharguild( $classe->selecionanomedaguild( $character ), $tirar );
}
echo "<form name=\"form1\" method=\"post\" action=\"\">\r\n<table width=\"100%\" border=\"0\" cellspacing=\"2\" cellpadding=\"0\" class=\"paineltitulo\">\r\n<tr><td>\r\n<table width=\"100%\" border=\"0\" align=\"center\">\r\n<tr>\r\n<td height=\"22\" align=\"center\" colspan=\"7\" class=\"paineltitulo\">GERENCIAR GUILD</td>\r\n</tr>\r\n<tr>\r\n      <td align=\"center\" colspan=\"7\" class=\"painelchar\"><b>";
echo $nome;
echo "</b> - \r\n  ";
if ( $aaa != ok )
{
    echo "<a href=\"?pagina=painel&acao=09&aaa=ok\" target=\"_self\">[Trocar Nome]</a>";
}
else
{
    echo "<a href='?pagina=painel&acao=09'>X - Fechar</a></td></tr>";
    echo "<form name=\"formnome\" method=\"post\" action=\"\">\r\n\t<tr>\r\n\t<td align=\"center\" colspan=\"2\" class=\"painelchar\">Novo Nome</td><td colspan=\"5\" align='center' class=\"painelchar\">\r\n    <input name=\"novo_nome\" type=\"text\" id=\"novo_nome\" value=\"".$nome."\" maxlength=\"8\">\r\n    <input type=\"submit\" id=\"mudarnomeok\" name=\"mudarnomeok\"  value=\"Mudar\"></form>";
}
echo "</td></tr>\r\n</form>\r\n    <tr>\r\n      <td align=\"center\" colspan=\"2\" class=\"painelchar\">Pontos:</td>\r\n\t    <td align=\"center\" colspan=\"5\" class=\"painelchar\">";
echo $classe->selecionapontosguild( $nome );
echo "</td>\r\n    </tr>\r\n\t    <tr>\r\n      \r\n      <td align=\"center\" colspan=\"2\" class=\"painelchar\">GameMaster:</td>\r\n      <td align=\"center\" colspan=\"5\" class=\"painelchar\">";
echo $character;
echo "</td>\r\n    </tr>\r\n    <tr>\r\n      <td align=\"center\" colspan=\"2\" class=\"painelchar\">Noticia:</td>\r\n\t    <td align=\"center\" colspan=\"5\" class=\"painelchar\">";
echo $classe->selecionamsgguild( $nome );
echo " -   ";
if ( $aaa != msg )
{
    echo "<a href=\"?pagina=painel&acao=09&aaa=msg\">[Trocar Mensagem]</a>";
}
else
{
    echo "<a href=\"?pagina=painel&acao=09\">X - Fechar</a></td></tr>";
    echo "<form name=\"formmsg\" method=\"post\" action=\"\">\r\n\t<tr>\r\n    <td align=\"center\" colspan=\"2\" class=\"painelchar\">Nova Noticia</td><td colspan=\"5\" align='center' class=\"painelchar\">\r\n    <input name=\"novo_msg\" type=\"text\" id=\"novo_msg\" value=\"".$classe->selecionamsgguild( $nome )."\" maxlength=\"60\" size=\"40\"> \r\n    <input type=\"submit\" id=\"mudarmsgok\" name=\"mudarmsgok\"  value=\"Mudar\"></form>";
}
echo "</td></tr>\r\n    <tr>\r\n      <td align=\"center\" colspan=\"2\" class=\"painelchar\">Membros:</td>\r\n\t    <td align=\"center\" colspan=\"5\" class=\"painelchar\">";
echo $classe->selecionaqtosmembrosguild( $nome );
echo " membro</td>\r\n    </tr>\r\n\t    <tr>\r\n      <td align=\"center\" colspan=\"7\" class=\"painelchar\"><b>Membros desta Guild</b></td>\r\n    </tr>\r\n\t    <tr>\r\n      <td width=\"10%\" align=\"center\" class=\"painelchar\">Numero</td>\r\n\t    <td width=\"18%\" align=\"center\" class=\"painelchar\">Nome</td>\r\n\t    <td width=\"16%\" align=\"center\" class=\"painelchar\">Status</td>\r\n\t    <td width=\"10%\" align=\"center\" class=\"painelchar\">Level</td>\r\n\t    <td width=\"10%\" align=\"center\" class=\"painelchar\">Resets</td>\r\n\t\t<td width=\"10%\" align=\"center\" class=\"painelchar\">Reset&atilde;o</td>\r\n\t\t<td width=\"15%\" align=\"center\" class=\"painelchar\">Tirar</td>\r\n\t\t</tr>\r\n\t\t";
$qtos = $classe->selecionaqtosmembrosguild( $nome );
$query = @mssql_query( "SELECT Name, G_Level, Id from GuildMember Where G_Name='".$nome."' order by Name" );
$i = 0;
for ( ; $i < $qtos; ++$i )
{
    $row = mssql_fetch_row( $query );
    $char1 = mssql_query( "SELECT Resets, cLevel, AccountID FROM Character WHERE Name='".$row['0']."'" );
    $char2 = mssql_fetch_row( $char1 );
    $result_conect = mssql_query( "SELECT ConnectStat FROM MEMB_STAT WHERE memb___id='".$char2['2']."'" );
    $status = mssql_fetch_row( $result_conect );
    $query_gameidc = mssql_query( "SELECT * FROM AccountCharacter WHERE GameIDC='".$row['0']."'" );
    $gameidc = mssql_num_rows( $query_gameidc );
    if ( $status[0] == 1 )
    {
        if ( $gameidc != 0 )
        {
            $status1 = "Online";
            $cor = "green";
        }
        else
        {
            $status1 = "Offline";
            $cor = "red";
        }
    }
    if ( $status[0] == 0 )
    {
        $status1 = "Offline";
        $cor = "red";
    }
    $num = $i + 1;
    if ( $row[1] == 0 )
    {
        $tira = "<a OnClick='javascript:TirarGuild(".$row[2].",\"".$row[0]."\")'>Tirar</a>";
    }
    else
    {
        $tira = "GM";
    }
    echo "<tr>\t\r\n\t\t<td align='center' class='painelchar'>".$num."</td>\r\n\t    <td align='center' class='painelchar'>".$row[0]."</td>\r\n\t    <td align='center' class='painelchar'><font color=".$cor.">".$status1."</font></td>\r\n\t    <td align='center' class='painelchar'>".$char2[1]."</td>\r\n\t    <td align='center' class='painelchar'>".$char2[0]."</td>\r\n\t    <td align='center' class='painelchar'>0</td>\r\n\t\t<td align='center' class='painelchar'>".$tira."</td></tr>";
}
echo "</table>\r\n</td>\r\n</tr>\r\n</table>\r\n\r\n\r\n</body>\r\n</html>";
?>
