<html lang="pt">
<head>
<meta name="description" content="Lucas Thompson" />
<title>Mu Site - WEB</title><meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<?
include 'cnn.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>
<div align="left">
  <h1>Resetar</h1><br>

</div>
<blockquote>
<form name="form1" method="post" action="">
    <br>
  <b>Personagem:</b> 
    <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>
  <br>
  <br>
  <input name="prossegue" type="submit" class="submit" id="prossegue" value="RESETAR">
  <br>
</form>
</body>
</html>
<? 
if($_POST['prossegue']) {
$char = $_POST['char'];
$pegadados = mssql_fetch_row(mssql_query("select clevel,money 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('Saia da conta'); 
location='javascript:history.back()'</script>";
}
else{
// -- FREE
if($vip[0] == 0) {
    if($pegadados[0] < $levelfree) {
    echo "<script>alert('Você precisa esta no level $levelfree para resetar'); 
    location='javascript:history.back()'</script>";
    }
    elseif($pegadados[1] < $moneyfree) {
    echo "<script>alert('Você precisa ter $moneyfree de dinheiro para resetar'); 
    location='javascript:history.back()'</script>";
    }
    else{
    mssql_query("update character set clevel=1, money=money-$moneyfree, resets=resets+1 where name='".$char."'");
    echo "<script>alert('$char resetado com sucesso'); 
    location='javascript:history.back()'</script>";    
    }
}

// -- VIP
if($vip[0] == 1) {
    if($pegadados[0] < $levelsvip) {
    echo "<script>alert('Você precisa esta no level $levelsvip para resetar'); 
    location='javascript:history.back()'</script>";
    }
    elseif($pegadados[1] < $moneysvip) {
    echo "<script>alert('Você precisa ter$moneysvip de dinheiro para resetar'); 
    location='javascript:history.back()'</script>";
    }
    else{
    mssql_query("update character set clevel=20, money=money-$moneysvip, resets=resets+1 where name='".$char."'");
    echo "<script>alert('$char resetado com sucesso'); 
    location='javascript:history.back()'</script>";    
    }
}

// -- VIP 2
if($vip[0] == 2) {
    if($pegadados[0] < $levelgvip) {
    echo "<script>alert('Você precisa esta no level $levelgvip para resetar'); 
    location='javascript:history.back()'</script>";
    }
    elseif($pegadados[1] < $moneygvip) {
    echo "<script>alert('Você precisa ter $moneygvip de dinheiro para resetar'); 
    location='javascript:history.back()'</script>";
    }
    else{
    mssql_query("update character set clevel=50, money=money-$moneygvip, resets=resets+1 where name='".$char."'");
    echo "<script>alert('$char resetado com sucesso'); 
    location='javascript:history.back()'</script>";    
    }
}
}
} }
?>
<br>
</blockquote>