<? 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 "Você não faz parte da Administração"; }
else{ ?>
<h1>Banir Personagem</h1>
<form name="banchar" method="post" action="">
<div class="quadros">
<label>Personagem</label>
<input name="char" type="text" id="char" class="forms" size="15" maxlength="15">
<label>Administrador:</label>
<input name="admchar" type="text" id="admchar" size="15" maxlength="15" class="submit">
<label>Motivo</label>
<input name="reason" type="text" id="reason" maxlength="20" class="submit">
<label>Dias</label>
<input name="tempo" type="text" id="tempo" maxlength="10" size="10" class="submit">
<br />
<br />
<label><input name="acao" type="radio" value="2" checked> Banir</label>
<br />
<br />
<input type="submit" name="prossegue" id="prossegue" class="submit" value="Banir">
<? } }?>
  <?PHP
if($_POST['prossegue']) {
$char     = stripslashes($_POST['char']);
$acao     = stripslashes($_POST['acao']);
$reason = stripslashes($_POST['reason']);
$bloc_by = stripslashes($_POST['admchar']);
$diasbloc = stripslashes($_POST['tempo']);

if (empty($admchar) || empty($reason) || empty($diasbloc) || empty($char) || empty($acao))
{
    ?>
  <script>
    window.alert("ERRO: campos em branco.");
    window.location='index.php?go=painel/banirchar';
    </script>
  <?PHP
}
else
{
    $sql_name_check = mssql_query("SELECT Name FROM Character WHERE Name='$char'");
    $name_check = mssql_num_rows($sql_name_check);
    $bloc_by  = $admchar;
            if ($name_check <= 0)
            {
                ?>
  <script>
                    window.alert("ERRO: CHAR não existe.");
                    window.location='index.php?go=banirchar';
                </script>
  <?PHP
                }
                else
                {
                    if ($acao == 2)
                    {
                     mssql_query("UPDATE Character SET
								 CtlCode = '1',
								 blocpor='$admchar',
								 databloc=getdate(),
								 motivobloc='$reason',
								 diasdesbloc='$diasbloc'
                                    WHERE Name='$char'");
	echo "<script>alert('$char bloquiado com sucesso'); 
	location='javascript:history.back()'</script>";	

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