<? session_start();
include 'cnn.php';
@$login = $_SESSION['login'];
@$senha = $_SESSION['senha'];
if(!isset($_SESSION['login'])) { echo "Para acessar essa pagina  preciso esta logado!"; }
else{
$Gms = mssql_fetch_row(mssql_query("select painelgm from memb_info where memb___id='".$login."'"));
if($Gms[0] <= 0) { echo "Voce nao faz parte da Administrao"; }
else{ ?>
<h1>Desbanir Personagem</h1>
<form name="banchar" method="post" action="">
<div class="quadros">
<label>Personagem</label>
<select name="char" id="char" class="submit">
<?
$Chars = mssql_query("select Name from Character WHERE CtlCode = '1'");
for($p=0;$p<mssql_num_rows($Chars);$p++) {
$Char=mssql_fetch_row($Chars);
echo '<option value='.$Char[0].'>'.$Char[0].'</option>';
}
?>
</select>
<br />
<br />
<label><input name="acao" type="radio" value="2" /> Desbanir</label>
<br />
<br />
<input type="submit" name="prossegue" id="prossegue" class="submit" value="Desbanir"/>
<? } }?>
  <?PHP
if($_POST['prossegue']) {
$char     = stripslashes($_POST['char']);
$acao     = stripslashes($_POST['acao']);

if (empty($char) || empty($acao))
{
    ?>
  <script>
    window.alert("ERRO: campos em branco.");
    window.location='?go=painel/desbanchar';
    </script>
  <?PHP
}
else
{
    $sql_name_check = mssql_query("SELECT Name FROM Character WHERE Name='$char'");
    $name_check = mssql_num_rows($sql_name_check);
            if ($name_check <= 0)
            {
                ?>
  <script>
                    window.alert("ERRO: CHAR no existe.");
                    window.location='?go=painel/desbanchar';
                </script>
  <?PHP
                }
                else
                {
                    if ($acao == 2)
                    {
                     mssql_query("UPDATE Character SET
								 CtlCode = '0',
								 blocpor= '',
								 motivobloc= '',
								 diasdesbloc='0'
                                    WHERE Name='$char'");
	echo "<script>alert('$char desbloquiado com sucesso'); 
	location='javascript:history.back()'</script>";	

                        ?>

  <?PHP
                    }
                }
			}
		}
?>
</div>
</form>