<? 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>Mudar Classe</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>
<label>Classe:</label>
<select name="novaclasse" id="novaclasse">
<option value="1">Soul Master</option>
<option value="0">Dark Wizard</option>
<option value="16">Dark Knight</option>
<option value="17">Blade Knigh</option>
<option value="32">Elfa</option>
<option value="33" selected>Muse Elfa</option>
<option value="48">Magic Gladiator</option>
<? if($dl==1) { echo '<option value="64">Dark Lord</option>'; }else{ echo''; } ?>
</select>
<input name="prossegue" type="submit" class="submit" id="prossegue" value="Mudar">
</div>
</form>
<? 
if($_POST['prossegue']) {
$nova=$_POST['novaclasse'];
$char=$_POST['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{
switch($nova) {
	case 0: $classefinal  = "Dark Wizard"; 	break;
	case 1: $classefinal  = "Soul Master"; 	break;
	case 16: $classefinal = "Dark knigth"; 	break;
	case 17: $classefinal = "Blade Knight"; break;
	case 32: $classefinal = "Fairy Elf"; 	break;
	case 33: $classefinal = "Muse Elf"; 	break;
	case 48: $classefinal = "M.Gladiator"; 	break;
	case 64: $classefinal = "Dark Lord"; 	break;
}
mssql_query("update character set class='".$nova."' where name='".$char."'");
echo "<script>alert('Classe alterada para $classefinal'); 
location='javascript:history.back()'</script>"; 
}
}
} } 

?>