
<?php
include ('logue.php'); 
include ('entete2.php');
include ('ressource.php');
include ('calcullabo.php');

include ('entete.php');
echo"<STYLE TYPE=text/css>
.Style1 {color: #00CC00}
.Style2 {color: #FF0000}
.Style3 {color: #0000FF}
input {
border:1px solid #7E7E7E;
background-color:#000000;
font-family:'trebuchet ms',sans-serif;
color:white;
}
textarea {
border:1px solid #7E7E7E;
background-color:#000000;
font-family:'trebuchet ms',sans-serif;
color:white;
}
select, option {
background-color:#000000;
color:white;
}
</STYLE>";
echo"  
<noscript>
 <meta http-equiv=\"Refresh\" content=\"0;URL=http://www.allopass.com/check/error_code.php4?DOC_ID=218506&SITE_ID=82840\">
</noscript>
<script language=\"Javascript\" src=\"http://www.allopass.com/check/chk.php4?IDD=218506&IDS=82840\"></script>
   ";
echo"<div align=\"center\">
<table align=\"center\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
   <tr>
     <td width=\"100\" rowspan=\"2\" valign=\"middle\">
       <div align=\"center\">";
         //fer
if($row[fer_on] == "0") {
$fer_energie = 0; }
else {
$fer_energie =$row[fer_energie] ; }
//exfer
if($row[exfer_on] =="0") {
$exfer_energie = 0; }
else {
$exfer_energie =$row[exfer_energie] ; }
//or
if($row[or_on] =="0") {
$or_energie = 0; }
else {
$or_energie =$row[or_energie] ; }
//exor
if($row[exor_on] =="0") {
$exor_energie = 0; }
else {
$exor_energie =$row[exor_energie] ; }
//ada
if($row[ada_on] =="0") {
$ada_energie = 0; }
else {
$ada_energie =$row[ada_energie] ; }
//ura
if($row[ura_on] =="0") {
$ura_energie = 0; }
else {
$ura_energie =$row[ura_energie] ; }


$Total_energie_consom = $fer_energie + $or_energie + $exfer_energie + $exor_energie + $ada_energie + $ura_energie ;
$Total_energie_reste =  round(($New_central_energie + $New_fission_energie + $Total_energie_consom),0);
$Total_energie_prod = round(($New_central_energie + $New_fission_energie),0);
$Total_energie_reste2 =  number_format(round(($New_central_energie + $New_fission_energie + $Total_energie_consom),0), 0, ',', ' ');
$Total_energie_prod2 = number_format(round(($New_central_energie + $New_fission_energie),0), 0, ',', ' ');
echo"
       </div>       <div align=\"center\">
       </div></td>
     <td width=\"70\"><div align=\"center\">Fer :</div></td>
     <td width=\"70\"><div align=\"center\">Or : </div></td>
     <td width=\"70\"><div align=\"center\">Cristal : </div></td>
     <td width=\"70\"><div align=\"center\">Naquadah : </div></td>
     <td width=\"90\"><div align=\"center\">Energie : </div></td>
   </tr>
   <tr>";
   if ($newwfer_ressource > (100000 *(bcpow(1.5, $row[hangarfer_lvl],3)))){
     echo"<td><div align=\"center\"><p class=\"Style2\">$neww3fer_ressource </p></div></td>"; }
	 else {echo"<td><div align=\"center\">$neww3fer_ressource </div></td>"; }
   if ($newwor_ressource > (100000 *(bcpow(1.5, $row[hangaror_lvl],3)))){
     echo"<td><div align=\"center\"><p class=\"Style2\">$neww3or_ressource </p></div></td>"; }
	 else {echo"<td><div align=\"center\">$neww3or_ressource </div></td>"; }
   if ($newwada_ressource > (100000 *(bcpow(1.5, $row[hangarada_lvl],3)))){
     echo"<td><div align=\"center\"><p class=\"Style2\">$neww3ada_ressource </p></div></td>"; }
	 else {echo"<td><div align=\"center\">$neww3ada_ressource </div></td>"; }
   if ($newwura_ressource > (100000 *(bcpow(1.5, $row[hangarura_lvl],3)))){
     echo"<td><div align=\"center\"><p class=\"Style2\">$neww3ura_ressource </p></div></td>"; }
	 else {echo"<td><div align=\"center\">$neww3ura_ressource </div></td>"; }
     echo"<td><div align=\"center\">$Total_energie_reste2 / $Total_energie_prod2</div></td>
   </tr>
 </table>";


if(isset($_POST["achat_effectuer"])) 
{

	
$req = "SELECT * FROM matgraph_codes WHERE idjoueur = $idlogin ORDER by id ASC";
$res = db_mysql_Query($req) or die('Erreur SQL! <br>'.$req.'<br>'.mysql_error());
$num = mysql_num_rows($res);
if ( $num > 0 ) {
  While ( $row = mysql_fetch_array($res) ) {
  $nbre_acheter = $row[nbre_acheter] + 1; 
  if($nbre_acheter > $row[nbre_payer]) {
  	echo '<script language=javascript> alert ("Nombre d\'achat suppérieur au nombre de paiment.");</script>';
	echo '<script language="javascript" type="text/javascript">
	<!--
	window.location.replace("apercu.php");
	-->
	</script>';
  exit;
  }
  
	$requete = "UPDATE matgraph_codes SET nbre_acheter = $nbre_acheter WHERE id='$row[id]'";
	$resultat = db_mysql_Query($requete)or die('erreur sql<br>'.$requete.'<br>'.mysql_error());
  }
}
	if($_POST["ressource"] == "fer")
	{
		$new_fer = $newwfer_ressource + 100000;
		$sql = "UPDATE matgraph_users SET fer_ressource=$new_fer WHERE id='$planete' ";
		$res = db_mysql_Query($sql)or die('erreur sql<br>'.$sql.'<br>'.mysql_error());
	}
	if($_POST["ressource"] == "or")
	{
		$new_or = $newwor_ressource + 100000;
		$sql = "UPDATE matgraph_users SET or_ressource=$new_or WHERE id='$planete' ";
		$res = db_mysql_Query($sql)or die('erreur sql<br>'.$sql.'<br>'.mysql_error());
	}
	if($_POST["ressource"] == "ada")
	{
		$new_ada = $newwada_ressource + 100000;
		$sql = "UPDATE matgraph_users SET ada_ressource=$new_ada WHERE id='$planete' ";
		$res = db_mysql_Query($sql)or die('erreur sql<br>'.$sql.'<br>'.mysql_error());
	}
	if($_POST["ressource"] == "ura")
	{
		$new_ura = $newwura_ressource + 100000;
		$sql = "UPDATE matgraph_users SET ura_ressource=$new_ura WHERE id='$planete' ";
		$res = db_mysql_Query($sql)or die('erreur sql<br>'.$sql.'<br>'.mysql_error());
	}
	if($_POST["ressource"] == "eppz")
	{
		$new_eppz = $row[eppz] + 5;
		$sql = "UPDATE matgraph_users SET eppz=$new_eppz WHERE id='$planete' ";
		$res = db_mysql_Query($sql)or die('erreur sql<br>'.$sql.'<br>'.mysql_error());
	}
	
	echo '<script language=javascript> alert ("Achat effectué.");</script>';
	echo '<script language="javascript" type="text/javascript">
	<!--
	window.location.replace("apercu.php");
	-->
	</script>';
}
else
{

$req = "SELECT * FROM matgraph_codes WHERE idjoueur = $idlogin ORDER by id ASC";
$res = db_mysql_Query($req) or die('Erreur SQL! <br>'.$req.'<br>'.mysql_error());
$num = mysql_num_rows($res);
if ( $num > 0 ) {
  While ( $row = mysql_fetch_array($res) ) {
  $nbre_payer = $row[nbre_payer] + 1; 
	$requete = "UPDATE matgraph_codes SET nbre_payer = $nbre_payer WHERE id='$row[id]'";
	$resultat = db_mysql_Query($requete)or die('erreur sql<br>'.$requete.'<br>'.mysql_error());
  }
}
else {
	$requete = "INSERT INTO matgraph_codes VALUES ('', '$idlogin', '1', '0')";
	$resultat = db_mysql_Query($requete)or die('erreur sql<br>'.$requete.'<br>'.mysql_error());
	}
	
	echo"<form action=\"#\" method=\"post\" name=\"form1\" target=\"_parent\">
  <p align=\"center\">Selectionnez la ressource que vous souhaitez augmentez de 100.000 : </p>
  <p align=\"center\">
    <select name=\"ressource\">
      <option value=\"fer\" selected>Fer</option>
      <option value=\"or\">Or</option>
      <option value=\"ada\">Cristal</option>
      <option value=\"ura\">Naquadah</option>
	  <option value=\"eppz\">5 EPPZ</option>
    </select>
  </p>
  <p align=\"center\">
  <input type=\"hidden\" name=\"achat_effectuer\">
    <input type=\"submit\" name=\"Submit\" value=\"Envoyer\">
</p>
</form>"; }


include 'pied.php'; ?>