<html lang="pt">
<head>
<meta name="description" content="Lucas Thompson" />
<title></title><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<? session_start();
include 'cnn.php';
include 'config/conf_extras.php';
include 'config/conf_reset.php';
@$login = $_SESSION['login'];
@$senha = $_SESSION['senha'];
if(!isset($_SESSION['login'])) { echo "Para acessar essa pagina é preciso esta logado!"; }
else{
$vip=mssql_fetch_row(mssql_query("select vip from MEMB_INFO where memb___id='".$login."'"));
?>
</head>

<body>
<h1><strong>Master Reset</strong><br>
</h1>
<form name="form1" method="post" action="">
  <table width="95%" border="0" cellspacing="2" cellpadding="0">
    <tr>
      <td width="20%">Personagem:</td>
      <td width="80%"><label>
        <select name="char" id="char">
          <?
		$Chars = mssql_query("select Name from Character where AccountID='".$login."'");
		for($p=0;$p<mssql_num_rows($Chars);$p++) {
		$Char=mssql_fetch_row($Chars);
		echo '<option value='.$Char[0].'>'.$Char[0].'</option>';
		}
		?>
        </select>
      </label></td>
    </tr>
    <tr>
      <td><label></label></td>
      <td><input name="prossegue" type="submit" class="submit" id="prossegue" value="RESETAO"></td>
    </tr>
  </table>
</form>
<br>
<a href="javascript:history.back(-1);">
<p align="left">&lt;&lt; voltar </p>
</a>
</body>
</html>
<? 
if($_POST['prossegue']) {
$char = $_POST['char'];
$vip=mssql_fetch_row(mssql_query("select vip from memb_info where memb___id='".$login."'"));
$pegadados = mssql_fetch_row(mssql_query("select cLevel,resets from Character where Name='".$char."'"));
$VerificaStatus = mssql_fetch_row(mssql_query("select ConnectStat from MEMB_STAT where memb___id='".$login."'"));
$VerificaChar = mssql_num_rows(mssql_query("select Name from Character where Name='".$char."' and AccountID='".$login."'"));
if($VerificaChar <= 0) { 
echo "<script>alert('Char incorreto'); 
location='javascript:history.back()'</script>"; 
}
elseif($VerificaStatus[0] >= 1){
echo "<script>alert('Desconecte a conta'); 
location='javascript:history.back()'</script>";
}
else{
// -- FREE
if($vip[0] == 0) {
	if($pegadados[0] < $levelmrfree) {
	echo "<script>alert('Você precisa estar no level $levelmrfree para poder resetar'); 
	location='javascript:history.back()'</script>";
	}
	elseif($pegadados[1] < $qtsresets) {
	echo "<script>alert('Você precisa ter $qtsresets para poder dar Master resete'); 
	location='javascript:history.back()'</script>";
	}
	else{
mssql_query("update character set
				clevel=1,
				experience=0,
				leveluppoint=3000,
				resetao=resetao+1,
				resets=15
				gold=gold+$goldsf
				where name='".$char."'");
	echo "<script>alert('$char Efetuou Master Resete com sucesso'); 
	location='javascript:history.back()'</script>";	
	}
}
// - SILVER VIP
if($vip[0] == 1) {
	if($pegadados[0] < $levelmrsvip) {
	echo "<script>alert('Você precisa estar no level $levelmrsvip para poder resetar'); 
	location='javascript:history.back()'</script>";
	}
	elseif($pegadados[1] < $qtsresetsvip) {
	echo "<script>alert('Você precisa ter $qtsresetsvip para poder dar Master resete'); 
	location='javascript:history.back()'</script>";
	}
	else{
mssql_query("update character set
				clevel=1,
				experience=0,
				leveluppoint=6000,
				resetao=resetao+1,
				resets=30
				gold=gold+$goldss
				where name='".$char."'");
	echo "<script>alert('$char Efetuou Master Resete com sucesso'); 
	location='javascript:history.back()'</script>";	
	}
}
// - GOLD VIP
if($vip[0] == 2) {
	if($pegadados[0] < $levelmrgvip) {
	echo "<script>alert('Você precisa estar no level $levelmrgvip para poder resetar'); 
	location='javascript:history.back()'</script>";
	}
	elseif($pegadados[1] < $qtsresetsgold) {
	echo "<script>alert('Você precisa ter $qtsresetsgold para poder dar Master resete'); 
	location='javascript:history.back()'</script>";
	}
	else{
mssql_query("update character set
				clevel=1,
				experience=0,
				leveluppoint=10000,
				resetao=resetao+1,
				resets=60
                where name='".$char."'");
mssql_query("update memb_info set gold=gold+$goldsg where memb___id='".$login."'");
	echo "<script>alert('$char Efetuou Master Resete com sucesso'); 
	location='javascript:history.back()'</script>";	
	}
} }
} }
?>