<? session_start();
include 'cnn.php';
include 'estilo.css';
include 'configs/conf_extras.php';
@$login = $_SESSION['login'];
@$senha = $_SESSION['senha'];
if(!isset($_SESSION['login'])) { echo "Para acessar essa pagina é preciso estar logado!"; }
else{
$Gms = mssql_fetch_row(mssql_query("select contagm from memb_info where memb___id='".$login."'"));
if($Gms[0] <= 0) { echo "Você não faz parte da Administração"; }
else{  ?>
<html>
<head>
<SCRIPT language=JavaScript>
var message="";
function clickIE()
{
    if (document.all)
    {
        (message);
        return false;
    }
}
function clickNS(e)
{
    if(document.layers||(document.getElementById&&!document.all))
    {
        if (e.which==2||e.which==3)
        {
            (message);
            return false;
        }
    }
}
if (document.layers)
{
    document.captureEvents(Event.MOUSEDOWN);
    document.onmousedown=clickNS;
}
else
{
    document.onmouseup=clickNS;
    document.oncontextmenu=clickIE;
}
document.oncontextmenu=new Function("return false")
</SCRIPT>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Editar Personagem - Painel ADM</title>
</head>

<body><form name='form1' method='post' action='ir.php?pagina=deletacc&act=deletar'>
	  <table width="520" border="0" cellpadding="0" cellspacing="0">
        <tr>
          <td width="30"><img src="imagens/mu.gif" width="30" height="30"></td>
          <td width="584" background="imagens/mu_back.gif">&nbsp;&nbsp;&nbsp;<strong>DELETAR ACOUNT</strong></td>
        </tr>
      </table>
	  <br><br>
      <table width="215" border="0">
        <tr>
          <td width="72">Login:</td>
          <td width="127"><select name="login" id="login">
          <?
		$Accs = mssql_query("select Memb___id from MEMB_INFO WHERE bloc_code = '0'");
		for($p=0;$p<mssql_num_rows($Accs);$p++) {
		$Acc=mssql_fetch_row($Accs);
		echo '<option value='.$Acc[0].'>'.$Acc[0].'</option>';
		}
		?>
          </select></td>
        </tr>
        <tr>
          <td height="37" colspan="2" align="center"><input name="prossegue" type="submit" class="submit" id="prossegue" value="Deletar"></td>
        </tr>
      </table>
    <br>
</form><? } }?>
</body>
</html>
<?PHP
if ($act == 'deletar') {
	$acc = $_POST['login'];
		
		$checa_acc = mssql_query("SELECT * FROM MEMB_INFO WHERE memb___id='$acc'");
		$checa_stat_acc = mssql_query("SELECT * FROM MEMB_STAT WHERE memb___id='$acc'");
		$checa_stat_login = mssql_fetch_array($checa_stat_acc);
		
		if (empty($acc)) {
			echo "<script>alert('Você esqueceu o Campo Login em Branco.')</script>";
			echo "<script>window.location='ir.php?pagina=deletacc''</script>";
		} elseif (mssql_num_rows($checa_acc) == 0) {
			echo "<script>alert('Este Login não Existe, Por Favor, redigite-o.')</script>";
			echo "<script>window.location='ir.php?pagina=deletacc''</script>";
		} elseif ($acc == $login) {
			echo "<script>alert('Você nao pode Deletar Sua propria Account.')</script>";
			echo "<script>window.location='ir.php?pagina=deletacc''</script>";
		} elseif ($checa_stat_acc['ConnectStat'] == 1) {
			echo "<script>alert('Esta Account Está Conectada no momento.')</script>";
			echo "<script>window.location='ir.php?pagina=deletacc''</script>";
		} else {
	
			mssql_query("DELETE FROM MEMB_INFO WHERE memb___id='$acc'");
			mssql_query("DELETE FROM AccountCharacter WHERE Id='$acc'");
			mssql_query("DELETE FROM Character WHERE AccountID='$acc'");

	echo "<script>alert('Conta $acc foi Deletada com sucesso'); 
	location='javascript:history.back()'</script>";	
	}
}
// by ramonvic
?>