<?php session_start();

/* LOGIN AREA */

if($_GET["painel"] == true) {
	if(!isset($_SESSION["login"])) {
		echo $bbcode->bbcode('<h1>ACESSO RESTRITO!</h1>   
		<a href="javascript: void(0);" onclick="loading(\'?go=logface\', \'log\');" class="facebookButton">Acessar com o Facebook!</a>
		<div class="or"><span>ou preencha seus dados.</span></div>
		
			<div class="formGroup">
				
				
			</div>
			<div class="formGroup">
				<span class="formGroup-name">Usuario</span>
				<input type="text" name="index_login" id="index_login">
			</div>
			<div class="formGroup">
				<span class="formGroup-name">Senha</span>
				<input type="password" id="index_senha" name="index_senha">
			</div>
			<div class="flex-s-c formGroup-button">
				<a href="javascript: void(0);" onclick="loading(\'?go=rsenha\', \'lgg\');" class="lost-pass">Esqueceu a senha?</a>
				<button class="button-small" name="Logar" id="Logar" onclick="loading(\'?go=painel&painel=true&logar=true\'+\'&index_login=\'+document.getElementById(\'index_login\').value+\'&index_senha=\'+document.getElementById(\'index_senha\').value, \'painel\');">Logar-me.</button>
			</div>
			<div id="log"></div>');
	}
	/* LOGIN AREA REFRESH */
	elseif(!isset($_SESSION["senha"])) {
		echo $bbcode->bbcode('<h1>ACESSO RESTRITO!</h1>   
	<a href="javascript: void(0);" onclick="loading(\'?go=logface\', \'lgg\');" class="facebookButton">Acessar com o Facebook!</a>
		<div class="or"><span>ou preencha seus dados.</span></div>
		
			<div class="formGroup">
				
				
			</div>
			<div class="formGroup">
				<span class="formGroup-name">Usuario</span>
				<input type="text" name="index_login" id="index_login">
			</div>
			<div class="formGroup">
				<span class="formGroup-name">Senha</span>
				<input type="password" id="index_senha" name="index_senha">
			</div>
			<div class="flex-s-c formGroup-button">
				<a href="javascript: void(0);" onclick="loading(\'?go=rsenha\', \'lgg\');" class="lost-pass">Esqueceu a senha?</a>
				<button class="button-small" name="Logar" id="Logar" onclick="loading(\'?go=painel&painel=true&logar=true\'+\'&index_login=\'+document.getElementById(\'index_login\').value+\'&index_senha=\'+document.getElementById(\'index_senha\').value, \'painel\');">Logar-me.</button>
			</div>');
	}
	/* LOGIN AREA REFRESH 2 */
	elseif(!isset($_SESSION["logado"]) == 1) {
		echo $bbcode->bbcode('<h1>ACESSO RESTRITO!</h1>   
		<a href="javascript: void(0);" onclick="loading(\'?go=logface\', \'lgg\');" class="facebookButton">Acessar com o Facebook!</a>
		<div class="or"><span>ou preencha seus dados.</span></div>
		
			<div class="formGroup">
				
				
			</div>
			<div class="formGroup">
				<span class="formGroup-name">Usuario</span>
				<input type="text" name="index_login" id="index_login">
			</div>
			<div class="formGroup">
				<span class="formGroup-name">Senha</span>
				<input type="password" id="index_senha" name="index_senha">
			</div>
			<div class="flex-s-c formGroup-button">
				<a href="javascript: void(0);" onclick="loading(\'?go=rsenha\', \'lgg\');" class="lost-pass">Esqueceu a senha?</a>
				<button class="button-small" name="Logar" id="Logar" onclick="loading(\'?go=painel&painel=true&logar=true\'+\'&index_login=\'+document.getElementById(\'index_login\').value+\'&index_senha=\'+document.getElementById(\'index_senha\').value, \'painel\');">Logar-me.</button>
			</div>');
	}
	elseif(isset($_SESSION["logado"]) == 1) {
	$vip = mssql_fetch_row(mssql_query("select ".colum_vip.",".colum_creditos." from memb_info where memb___id='".$_SESSION["login"]."'"));
		
		$cash = mssql_fetch_row(mssql_query("select cash from memb_info where memb___id='".$_SESSION["login"]."'"));
		
		$cargo = mssql_fetch_row(mssql_query("select cargo from ct_equipe where login='".$_SESSION["login"]."'"));
		
		
		switch($vip[0]) {
			case 0: $typevip = "Free"; break;
			case 1: $typevip = "Vip Silver"; break;
			case 2: $typevip = "Vip Platinum"; break;
			case 3: $typevip = "VIP Ouro"; break;
		}
		if($cargo[0] == 1) {
			$pos = '';
		}
		if($cargo[0] > 1) {
			/* PANEL ADMIN BOTAO */
			$pos = '
				
<div id="admin">
<button class="button-small" onclick="loading(\'?go=paineladmin\', \'conteudo\');  loading(\'?go=closed\', \'clos\'); loading(\'?go=closed\', \'clos2\');">Panel Admin</button>
</div>
';
		}
		if($vip[1] > 1) {
			$day = "dias";
		}
		else {
			$day = "dia";
		}
		/* SESSION LOGADO */
		echo $bbcode->bbcode('<table class="ranking-table">

                        <thead>

                        <tr class="main-tr">

                            <th colspan="2">AUTORIZADO!</th>

                        </tr>

                        </thead>

                        <tbody>

                        <tr>

                            <td style="width:50%;text-align: left;">Logado como: </td>

                            <td style="width:50%;text-align: left;">'.$_SESSION["login"].'</td>
                            
                              <tr>

                            <td style="width:50%;text-align: left;">Assinatura: </td>

                            <td style="width:50%;text-align: left;">'.$typevip.'</td>

                        

                        </tbody>

                    </table>');
		if($vip[0] > 0) {
			echo $bbcode->bbcode('<CENTER>
<div id="conta"><br><br>
<button class="button-small" onclick="loading(\'?go=paineluser\', \'conteudo\'); loading(\'?go=closed\', \'clos\'); loading(\'?go=closed\', \'clos2\');">CPanel User..</button>
<br><br><br>
<button class="button green-button" onclick="loading(\'?go=painel&deslogar=true\', \'painel\');">Deslogar-me.</button>
</CENTER>
    
   ');
		}
		else{
			echo $bbcode->bbcode('<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
  </tr>
  <tr>
    <td>'.$pos.'</td>
  </tr>
  <tr>
    <td>
<div id="conta">
<button class="button-small" onclick="loading(\'?go=paineluser\', \'conteudo\'); loading(\'?go=closed\', \'clos\'); loading(\'?go=closed\', \'clos2\');">CPanel User..</button>
</div>
</div>
  </tr>
  <tr>
    <td><button class="button green-button" onclick="loading(\'?go=painel&deslogar=true\', \'painel\');">Deslogar-me.</button>
    
   </td>
  </tr>
</table>');
		}
	}
if($_GET["logar"] == true) {
$login = $_GET["index_login"];
$senha = $_GET["index_senha"];
if(empty($login) || empty($senha)) {
	echo $bbcode->bbcode('<div class="i_note">Preencha todos os campos.</div>');
	session_destroy();
}
elseif(mssql_num_rows(mssql_query("select * from memb_info where memb___id='".$login."'")) < 1) {
	echo $bbcode->bbcode('<div class="w_note">Este login nao existe.</div>');
	session_destroy();
}
elseif(mssql_num_rows(mssql_query("select * from memb_info where memb__pwd='".$senha."' and memb___id='".$login."'")) < 1) {
	echo $bbcode->bbcode('<div class="i_note">A senha esta incorreta.</div>');
	session_destroy();
}
else {
	$_SESSION["login"] = $login;
	$_SESSION["senha"] = $senha;
	$_SESSION["logado"] = 1;
	header('location: ?go=painel&painel=true');
}
}
}
if($_GET["deslogar"] == true) {
	session_destroy();
	header("location: ?go=painel&painel=true");
}

?>