 <? session_start();
include 'cnn.php';
@$login = $_SESSION['login'];
@$senha = $_SESSION['senha'];
if(!isset($_SESSION['login'])) { echo "Para acessar essa página é preciso esta logado!"; }
else{
$Gms = mssql_fetch_row(mssql_query("select painelgm from memb_info where memb___id='".$login."'"));
if($Gms[0] <= 0) { echo "Você não faz parte da administração"; }
else{ ?>
<html>

<head>
<SCRIPT language=JavaScript>
var message="";
function clickIE()
{
    if (document.all)
    {
        (message);
        return false;
    }
}
function clickNS(e)
{
    if(document.layers||(document.getElementById&&!document.all))
    {
        if (e.which==2||e.which==3)
        {
            (message);
            return false;
        }
    }
}
if (document.layers)
{
    document.captureEvents(Event.MOUSEDOWN);
    document.onmousedown=clickNS;
}
else
{
    document.onmouseup=clickNS;
    document.oncontextmenu=clickIE;
}
document.oncontextmenu=new Function("return false")
</SCRIPT>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

</head>

<body>

  <h2>Premiar </h2>
    <br>
          Para dar Medalha troque o "0" pelo número de medalhas que você vai dar,<BR>
          obs: os outro campos deixe como está.
<blockquote>

<?   	$VerificaChar = mssql_num_rows(mssql_query("select * from character where name='".$char."'"));
		 $Query = mssql_query("SELECT ourotop,pratatop,bronzetop,ouroduelo,prataduelo,bronzeduelo,ouroevento,prataevento,bronzeevento from Character Where Name = '$char'");
  for($i=0;$i<mssql_num_rows($Query);$i++) {
  $medalha = mssql_fetch_row($Query); } ?>
  
  
  
<form name="banchar" method="post" action="">
  <table width="244" border="0">
    <tr>
      <td width="47">CHAR:</td>
      <td width="175">
        <input type="text" name="char">
    </td>
      <td width="8">&nbsp;</td>
          </tr>
          <tr>
      <td width="47">&nbsp;</td>
       <td width="8"></td>
    </tr>
       <tr>
      <td width="47">&nbsp;</td>
       <td width="8">MEDALHAS TOP M.T</td>
    </tr>
    <tr>
      <td><div align="center"><img src="images/ouro.gif" ></div></td>
      <td><input name="ourotop" type="text" class="forms"
                                            id="ourotop" size="2" maxlength="2" value="0"></td>
       </tr>
       
       <tr>
      <td><div align="center"><img src="images/prata.gif"></div></td>
      <td><input name="pratatop" type="text" class="forms"
                                            id="pratatop" size="2" maxlength="2" value="0"></td>
       </tr>
       
       <tr>
      <td><div align="center"><img src="images/bronze.gif"></div></td>
      <td><input name="bronzetop" type="text" class="forms"
                                            id="bronzetop" size="2" maxlength="2" value="0"></td>
       </tr>
       
       
       
           <tr>
      <td width="47">&nbsp;</td>
       <td width="8">MEDALHAS DUELO</td>
    </tr>
    <tr>
      <td><div align="center"><img src="images/ouro.gif" ></div></td>
      <td><input name="ouroduelo" type="text" class="forms"
                                            id="ouroduelo" size="2" maxlength="2" value="0"></td>
       </tr>

       <tr>
      <td><div align="center"><img src="images/prata.gif"></div></td>
      <td><input name="prataduelo" type="text" class="forms"
                                            id="prataduelo" size="2" maxlength="2" value="0"></td>
       </tr>

       <tr>
      <td><div align="center"><img src="images/bronze.gif"></div></td>
      <td><input name="bronzeduelo" type="text" class="forms"
                                            id="bronzeduelo" size="2" maxlength="2" value="0"></td>
       </tr>
       
       
       
             <tr>
      <td width="47">&nbsp;</td>
       <td width="8">MEDALHAS EVENTO</td>
    </tr>
    <tr>
      <td><div align="center"><img src="images/ouro.gif" ></div></td>
      <td><input name="ouroevento" type="text" class="forms"
                                            id="ouroevento" size="2" maxlength="2" value="0"></td>
       </tr>

       <tr>
      <td><div align="center"><img src="images/prata.gif"></div></td>
      <td><input name="prataevento" type="text" class="forms"
                                            id="prataevento" size="2" maxlength="2" value="0"></td>
       </tr>

       <tr>
      <td><div align="center"><img src="images/bronze.gif"></div></td>
      <td><input name="bronzeevento" type="text" class="forms"
                                            id="bronzeevento" size="2" maxlength="2" value="0"></td>
       </tr>
       
       
       
       
        <tr>
      <td>&nbsp;</td>
      <td><input name="acao" type="radio" value="2" checked>
        Premiar</td>
      <td>&nbsp;</td>
    </tr>

    <tr>
      <td>&nbsp;</td>
      <td><font color="#FFFFFF" size="1" face="Verdana, Arial, Helvetica, sans-serif">
        <input type="submit" name="prossegue" id="prossegue" value="Premiar">
      </font></td>
      <td>&nbsp;</td>
    </tr>
  </table>
  <? } }?>
  <?PHP
if($_POST['prossegue']) {
$char     = stripslashes($_POST['char']);

$ourotop     = stripslashes($_POST['ourotop']);
$pratatop     = stripslashes($_POST['pratatop']);
$bronzetop     = stripslashes($_POST['bronzetop']);
$ouroduelo     = stripslashes($_POST['ouroduelo']);
$prataduelo     = stripslashes($_POST['prataduelo']);
$bronzeduelo     = stripslashes($_POST['bronzeduelo']);
$ouroevento    = stripslashes($_POST['ouroevento']);
$prataevento     = stripslashes($_POST['prataevento']);
$bronzeevento     = stripslashes($_POST['bronzeevento']);

$acao     = stripslashes($_POST['acao']);


if (empty($ourotop) || empty($pratatop) || empty($bronzetop) || empty($ouroduelo) || empty($prataduelo) || empty($bronzeduelo) || empty($ouroevento) || empty($prataevento) || empty($bronzeevento) || empty($acao) || empty($char) )
{
    ?>
  <script>
      window.location='index.php?go=medalhas';
    </script>
  <?PHP
}
else
{
    $sql_name_check = mssql_query("SELECT Name FROM Character WHERE Name='$char'");
    $name_check = mssql_num_rows($sql_name_check);
            if ($name_check <= 0)
            {
                ?>
  <script>
                    window.alert("ERRO: CHAR nÃ£o existe.");
                    window.location='index.php?go=medalhas';
                </script>
  <?PHP
                }
                else
                {
                    if ($acao == 2)
                    {
                     mssql_query("UPDATE Character SET
                     
							     ourotop=$medalha[0]+$ourotop,
							     pratatop=$medalha[1]+$pratatop,
							     bronzetop=$medalha[2]+$bronzetop,
							     
							     ouroduelo=$medalha[3]+$ouroduelo,
							     prataduelo=$medalha[4]+$prataduelo,
							     bronzeduelo=$medalha[5]+$bronzeduelo,
							     
							     ouroevento=$medalha[6]+$ouroevento,
							     prataevento=$medalha[7]+$prataevento,
							     bronzeevento=$medalha[8]+$bronzeevento
							     
                                    WHERE Name='$char'");
	echo "<script>alert('$char premiado com sucesso');
	location='javascript:history.back()'</script>";	

                        ?>
  <?PHP
              }
         }
    }
}
?>
</form>
</blockquote>

</body> 
</html>
