<? session_start();
include 'cnn.php';
@$login = $_SESSION['login'];
@$senha = $_SESSION['senha'];
if(!isset($_SESSION['login'])) { echo "<strong>Para acessar essa pagina é preciso esta logado</strong>"; }
else{
$vip=mssql_fetch_row(mssql_query("select vip from memb_info where memb___id='".$login."'"));
if($vip[0] == 0) { echo "<strong>Para acessar essa pagina é preciso ser Silver Vip</strong>"; }
else{
?>
<h1>Desbugar Pontos</h1>
<form name="form1" method="post" action="">
<div class="quadros">
<label>Personagem:</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>
<br />
<br />
<input name="prossegue" type="submit" class="submit" id="prossegue" value="Desbugar">
</div>
</form>
<? 
if($_POST['prossegue']) {
$char=$_POST['char'];
$qbug  = mssql_query("select strength, dexterity, vitality, energy from character where name='".$char."' and accountid='".$login."'");
$rbug  = mssql_fetch_row($qbug);
$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('personagem incorreto'); 
location='javascript:history.back()'</script>"; 
}
elseif($VerificaStatus[0] >= 1){
echo "<script>alert('Desconecte a conta'); 
location='javascript:history.back()'</script>";
}
else{
	$str=$rbug[0];
	$agi=$rbug[1];
	$vid=$rbug[2];
	$eng=$rbug[3];
	if($rbug[0] <= 0){$str='500'; }
	if($rbug[1] <= 0){$agi='500'; }
	if($rbug[2] <= 0){$vid='500'; }
	if($rbug[3] <= 0){$eng='500'; }
	if(($rbug[0] >= 1) && ($rbug[1] >= 1) && ($rbug[2] >= 1) && ($rbug[3] >= 1)){
	echo "<script>alert('Não tem nada de errado com $char'); 
	location='javascript:history.back()'</script>"; 
	}
	else{
		mssql_query("update character set strength='$str', 
		dexterity='".$agi."', 
		vitality='".$vid."', 
		energy='".$eng."' 
		where name='".$char."' 
		and accountid='".$login."'");  	
	die("<script>alert('Pontos concertados/desbugados com sucesso'); 
	location='javascript:history.back()'</script>");
		} }
}
} } 

?>