<?	
include ('logue.php'); 
include ('entete2.php');
include ('entete.php');
include ('ressource.php');
include ('chantiercalcul.php');
//include ('placevaisseaux.php');
include ('siege.php');

$sql2 = "SELECT robo_lvl,chantier_lvl,hangarfer_lvl,hangarfer_evolution,hangaror_lvl,hangaror_evolution,hangarada_lvl,hangarada_evolution,hangaror_lvl,hangarura_lvl,hangarura_evolution,labo_lvl,labo_evolution,fer_energie,or_energie,ada_energie,ura_energie,exfer_energie,exor_energie,central_energie FROM matgraph_users WHERE id='$planete' ";
$res2 = db_mysql_Query($sql2)or die('erreur sql<br>'.$sql2.'<br>'.mysql_error());
$row2 = mysql_fetch_array($res2); 


echo"<script language=\"javascript\">

function chrono(jours,heures,minutes,secondes,champs) {

  if (secondes > 0) {
    secondes--;
  }
  else {
    secondes = 59;

    if (minutes > 0) {
      minutes--;
    }
    else {
      minutes = 59;

      if (heures > 0) {
        heures--;
        jours--;
      }
      else {
        heures = 23;
      }
    }
  }

  if ( minutes == 59 && secondes == 59 && heures == 23 ) {
    window.history.go(0);
     }
  else {
    seconde = secondes;
    minute = minutes;
    text = '';
    if (jours > 0) {
      text +=jours + 'j ';
    }
    if (heures > 0) {
      text +=heures + 'h ';
    }
    if (minutes < 10) {
      minute = '0' + minutes;
    }
    if (seconde < 10) {
      seconde = '0' + secondes;
    }
      text +=minute + 'm ' + seconde + 's';

  document.getElementById('ligne_' + champs).innerHTML = 'Temps restant : <font color=#800000>'+ text +'</font>';
  setTimeout(\"chrono(\" + jours + \",\" + heures + \",\" + minutes + \",\" + secondes + \",'\" + champs + \"')\", 1000);
         }
    }
</script>

<style type=\"text/css\">
<!--
img {
border:0;
}
A {
	COLOR: #9999ff; TEXT-DECORATION: none
}
A:hover {
	COLOR: #ff9900; TEXT-DECORATION: none
}

.objet_name{
	color:#B9C6FF;
	font-size:12px;
	text-align:center;
}
.objet_level{
	color:#FF4F65;
	font-size:12px;
}
.Categorie {
	color: #CCCCCC;
	font-size:14px;
	
}

.Categorie:first-letter /* La première lettre de chaque paragraphe */
{
   font-weight: bold; /* En gras */
   font-size: 15px; /* Ecrit légèrement plus gros que la normale */
   color:#666666; /* En bleu */
}
.objet_construc{
 font-size:14px;
 text-align:center;
}
-->
</style>
<script src=\"Js_module/overlib.js\" type=text/javascript></script>
<style type=text/css>.Style1 {
	COLOR:#FF0000;
}
.Style2 {
	COLOR: #ff0000
}
.Style3 {
	COLOR: #00cc00
}
.Style4 {
	COLOR: #999999
}
.Style5 {
	COLOR: #3399ff
}
.Style6 {
	COLOR: #ffff00
}
A.menulink {
	BORDER-RIGHT: #111111 1px solid; BORDER-TOP: #111111 1px solid; FONT-SIZE: 11px; BORDER-LEFT: #111111 1px solid; WIDTH: 150px; COLOR: #00cc00; BORDER-BOTTOM: #111111 1px solid; FONT-FAMILY: Verdana; TEXT-DECORATION: none
}
A.menulink:hover {
	BORDER-RIGHT: #111111 1px solid; BORDER-TOP: #111111 1px solid; BORDER-LEFT: #111111 1px solid; COLOR: #00cc00; BORDER-BOTTOM: #111111 1px solid; BACKGROUND-COLOR: #111111
}
A.menulink2 {
	BORDER-RIGHT: #111111 1px solid; BORDER-TOP: #111111 1px solid; FONT-SIZE: 11px; BORDER-LEFT: #111111 1px solid; WIDTH: 150px; COLOR: #ff3300; BORDER-BOTTOM: #111111 1px solid; FONT-FAMILY: Verdana; TEXT-DECORATION: none
}
A.menulink2:hover {
	BORDER-RIGHT: #111111 1px solid; BORDER-TOP: #111111 1px solid; BORDER-LEFT: #111111 1px solid; BORDER-BOTTOM: #111111 1px solid; BACKGROUND-COLOR: #111111
}
INPUT {
	BORDER-RIGHT: #7e7e7e 1px solid; BORDER-TOP: #7e7e7e 1px solid; BORDER-LEFT: #7e7e7e 1px solid; COLOR: white; BORDER-BOTTOM: #7e7e7e 1px solid; FONT-FAMILY: 'trebuchet ms',sans-serif; BACKGROUND-COLOR: #222222
}
TEXTAREA {
	BORDER-RIGHT: #7e7e7e 1px solid; BORDER-TOP: #7e7e7e 1px solid; BORDER-LEFT: #7e7e7e 1px solid; COLOR: white; BORDER-BOTTOM: #7e7e7e 1px solid; FONT-FAMILY: 'trebuchet ms',sans-serif; BACKGROUND-COLOR: #000000
}
SELECT {
	COLOR: white; BACKGROUND-COLOR: #000000
}
OPTION {
	COLOR: white; BACKGROUND-COLOR: #000000
}
</style>";
echo"<div align=\"center\"><form name=\"colo\" method=\"post\" action=\"colonie.php\" target=\"_parent\">
<table align=\"center\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
   <tr>
     <td width=\"100\" rowspan=\"2\" valign=\"middle\">
       <div align=\"center\">
         <input name=\"page\" value=\"" . $PHP_SELF . "\" type=\"hidden\" id=\"page\">
         <select name=\"idcolo\" onchange=submit()>";
include ('colo2.php'); 
$sql = "SELECT techinfra_lvl FROM matgraph_users WHERE id='$dataid[id]'";
$res = db_mysql_Query($sql)or die('erreur sql<br>'.$sql.'<br>'.mysql_error());
$row = mysql_fetch_array($res); 
// techinfra
if ($row[techinfra_lvl] =="0") {
$techinfra_lvl = "0";
}
else {
$techinfra_lvl = $row[techinfra_lvl];
}
// chantier
if ($row2[chantier_lvl] =="0") {
$chantier_lvl = "0";
}
else {
$chantier_lvl = $row2[chantier_lvl];
}
if($techinfra_lvl >= 1 && $chantier_lvl >= 1){
echo"<form action=\"creer.php\" method=\"post\" target=\"_parent\">
  <p align=\"center\">Infrastructure : 
    <select name=\"infra\" id=\"infra\">";
	if($techinfra_lvl >=1 && $chantier_lvl >= 1){echo"<option value=\"400\">Infrastructure du X-301</option>";}
      if($techinfra_lvl >=2 && $chantier_lvl >= 2){echo"<option value=\"9000\">Infrastructure du Cargo Teltak</option>";}
      if($techinfra_lvl >=4 && $chantier_lvl >= 4){echo"<option value=\"15000\">Infrastructure de la Navette Bedrosienne</option>";}
      if($techinfra_lvl >=5 && $chantier_lvl >= 5){echo"<option value=\"25000\">Infrastructure du Prométhé</option>";}
      if($techinfra_lvl >=7 && $chantier_lvl >= 7){echo"<option value=\"75000\">Infrastructure du Vaisseau Amiral Goa'ulds</option>";}
      if($techinfra_lvl >=10 && $chantier_lvl >= 10){echo"<option value=\"150000\">Infrastructure du Vaisseau mére Asgaard</option>";}
    echo"</select>
</p>
  <p align=\"center\">
    <input name=\"creer.php\" type=\"submit\" id=\"creer.php\" value=\"Envoyer\">
</p>
</form>"; } 
else {
if($chantier_lvl < 1){
echo"Vous devez developper votre chantier spatial avant de pouvoir créer un vaisseau."; }
else{
echo"Vous devez develloper la technologie infrastructure avant de pouvoir créer un vaisseau."; }}
$sql9 = "SELECT chantier_lvl FROM matgraph_users WHERE id = '$planete' ORDER BY id ASC";
$res9 = db_mysql_Query($sql9) or die('Erreur SQL!<br>'.$sql9.'<br>'.mysql_error());
$row9 = mysql_fetch_array($res9); 

function premiertd($name,$nbre) {

echo"<td  style=\"BACKGROUND-COLOR:#4D4D4D\" class=\"objet_name\"> ".stripslashes($name)." (<span class=\"objet_level\">$nbre</span>)</td>";

}

function deuxiemetd($name,$nbre,$img,$description,$etime,$newwfer_ressource,$newwor_ressource,$newwada_ressource,$newwura_ressource,$Depense2_fer,$Depense2_or,$Depense2_ada,$Depense2_ura,$Depense_fer,$Depense_or,$Depense_ada,$Depense_ura) {

echo"<td style=\"width:120px\"> <a href=\"#\" onMouseOver=\"return overlib('<table border=\'0\' cellspacing=\'0\' cellpadding=\'0\' width=\'332px\'> <tr> <td class=black background=\'imgs/tip/topleft.png\' width=\'6\' height=\'6\'></td> <td class=black background=\'imgs/tip/top.png\' height=\'6\'></td> <td class=black background=\'imgs/tip/topright.png\' width=\'6\' height=\'6\'></td> </tr> <tr> <td class=black background=\'imgs/tip/left.png\' width=\'6\'></td> <td class=black background=\'imgs/tip/middle.png\' heigh=\'500\'> <table background=\'imgs/tip/middle.png\' border=\'0\' style=\'border-collapse:collapse;font-size: 12px;width:320px\'> <tr> <td class=black background=\'imgs/tip/middle.png\' colspan=\'2\'><strong>$name</strong> ($nbre) </td> </tr> <tr> <td class=black background=\'imgs/tip/middle.png\'><img src=\'imgs/$img.gif\' alt=\'$name\' width=\'80\' height=\'80\'></td> <td class=black background=\'imgs/tip/middle.png\'>$description</td> </tr> <tr style=\'text-align:center;\'> <td class=black background=\'imgs/tip/middle.png\'><span style=\'color:#FF0000\'><strong>$etime</strong></span></td> <td class=black background=\'imgs/tip/middle.png\'><strong>"; if(!empty($Depense2_fer)) { echo" <br> Fer : "; if($newwfer_ressource < ($Depense2_fer)){ echo"<span style=\'color:#FF0000\'>$Depense_fer</span>"; } else { echo"$Depense_fer"; }} if(!empty($Depense2_or)) { echo" <br> Or : "; if($newwor_ressource < ($Depense2_or)){ echo"<span style=\'color:#FF0000\'>$Depense_or</span>"; } else { echo"$Depense_or"; }} if(!empty($Depense2_ada)) { echo" <br> Cristal : "; if($newwada_ressource < ($Depense2_ada)){ echo"<span style=\'color:#FF0000\'>$Depense_ada</span>"; } else { echo"$Depense_ada"; }} if(!empty($Depense2_ura)) { echo" <br> Naquadah : "; if($newwura_ressource < ($Depense2_ura)){ echo"<span style=\'color:#FF0000\'>$Depense_ura</span>"; } else { echo"$Depense_ura"; }} echo"</strong> </td> </tr> </table> </td>	<td class=\'black\' background=\'imgs/tip/right.png\' width=\'6\'></td> </tr> <tr> <td class=black background=\'imgs/tip/bottomleft.png\' width=\'6\' height=\'6\'></td> <td class=black background=\'imgs/tip/bottom.png\' height=\'6\'></td> <td class=black background=\'imgs/tip/bottomright.png\' width=\'6\' height=\'6\'></td>	</tr>	</table>')\" onMouseOut=\"return nd()\"> <img src=\"imgs/vaisseaux/"; if ($newwfer_ressource >= ($Depense2_fer) && $newwor_ressource >= ($Depense2_or) && $newwada_ressource >= ($Depense2_ada) && $newwura_ressource >= ($Depense2_ura)) { echo $img; } else { echo $img."_d"; } echo".jpg\" alt=\"$name\" width=\"120\" height=\"120\"></a></td>";

}


function troisiemetd($newwfer_ressource,$newwor_ressource,$newwada_ressource,$newwura_ressource,$Depense2_fer,$Depense2_or,$Depense2_ada,$Depense2_ura,$timedefense2) {

echo"<td>"; if ($newwfer_ressource < ($Depense2_fer) || $newwor_ressource < ($Depense2_or) || $newwada_ressource < ($Depense2_ada) || $newwura_ressource < ($Depense2_ura) || $timedefense2 != "-1") { echo"-"; } else { echo"<form action=\"constructionspe.php\" method=\"post\" target=\"_parent\"> <p> <input name=\"nombre_def\" type=\"text\" id=\"nombre_def\" size=\"3\"> <input name=\"typedef\" type=\"hidden\" value=\"$typedef\"> <input type=\"submit\" name=\"Submit\" value=\"Lancer\"> </p> </form>"; } echo"</td>";
								

}

echo"<table width=\"596px\" border=\"0\" style=\"border-collapse:collapse;\">
              <tr>
                <td colspan=\"5\" style=\"BACKGROUND-COLOR: #222222\" class=\"Categorie\">Vaisseaux</td>
              </tr>";
$i = 0;
$req = "SELECT * FROM matgraph_vaisseaux WHERE iduser = $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) ) {
$id=$row[id];
if ($chantier_lvl >= $row[chantier_lvl]){
$i++;

$esecevo = "";
$etimeevo = "";
$eminevo="";
$ehourevo="";
$edayevo="";

$temps = (round(($row[fer] / 4)* $siege_temps_evolution *(bcpow(0.9, $row9[chantier_lvl],3))));
$etimeevo = $temps;
$eminevo = $etimeevo / 60;

if ( floor($eminevo) != $eminevo )
  $esecevo = floor( ($eminevo - floor( $eminevo )) * 60);

  if ( $eminevo > 60 ) {

    $ehourevo = floor( $eminevo / 60 );
    $eminevo = $eminevo - ( 60 * $ehourevo );

    if ( $ehourevo > 24 ) {
      $edayevo = floor( $ehourevo / 24);
      $ehourevo = $ehourevo - ( 24 * $edayevo );
    }

  }

$etimeevo ="";

if (!empty($edayevo) )
  $etimeevo.="$edayevo j ";

if (!empty($ehourevo) )
  $etimeevo.="$ehourevo h ";

if ($eminevo != 0)
  $etimeevo.= floor($eminevo)." min. ";

if (!empty($esecevo) ) 
  $etimeevo.="$esecevo sec. ";
  
$sql2 = "SELECT nbre FROM matgraph_nbrevaisseaux WHERE vaisseau='$row[id]' AND planete='$planete'";
$res2 = db_mysql_Query($sql2)or die('erreur sql<br>'.$sql2.'<br>'.mysql_error());
$num2 = mysql_num_rows($res2);
if ( $num2 > 0 ) {
  While ( $row2 = mysql_fetch_array($res2) )
  {
		$nbre_vaisseau=$row2[nbre];
	}
}
else
{
	$requete = "INSERT INTO matgraph_nbrevaisseaux VALUES ('','$idlogin', '$planete', '$row[id]', '0')";
	$resultat = db_mysql_Query($requete)or die('erreur sql<br>'.$requete.'<br>'.mysql_error());
	$nbre_vaisseau = 0 ;
}


$fer = number_format($row[fer], 0, ',', ' ');
$or = number_format($row[orr], 0, ',', ' ');
$ada = number_format($row[ada], 0, ',', ' ');
$ura = number_format($row[ura], 0, ',', ' ');
$arme = number_format($row[arme], 0, ',', ' ');
$coque = number_format($row[coque], 0, ',', ' ');
$bouclier = number_format($row[bouclier], 0, ',', ' ');
$vitesse = number_format($row[vitesse], 2, ',', ' ');
$place = number_format($row[place], 0, ',', ' ');

if($row[chantier_lvl] == "1") {
$besoin_place = 25 ; }
if($row[chantier_lvl] == "2") {
$besoin_place = 5 ; }
if($row[chantier_lvl] == "4") {
$besoin_place = 50 ; }
if($row[chantier_lvl] == "5") {
$besoin_place = 60 ; }
if($row[chantier_lvl] == "7") {
$besoin_place = 100 ; }
if($row[chantier_lvl] == "10") {
$besoin_place = 250 ; }

if(($place_vaisseaux - $besoin_place) > 0) {
$besoin_place = 1; }
else {
$besoin_place = -1; }


$premiertd.= "<td  style=\"BACKGROUND-COLOR:#4D4D4D\" class=\"objet_name\"> $row[nom] (<span class=\"objet_level\">$nbre_vaisseau</span>)</td>";
$deuxiemetd.= "<td style=\"width:120px\"> <a href=\"#\" onMouseOver=\"return overlib('<table border=\'0\' cellspacing=\'0\' cellpadding=\'0\' width=\'332px\'> <tr> <td class=black background=\'imgs/tip/topleft.png\' width=\'6\' height=\'6\'></td> <td class=black background=\'imgs/tip/top.png\' height=\'6\'></td> <td class=black background=\'imgs/tip/topright.png\' width=\'6\' height=\'6\'></td> </tr> <tr> <td class=black background=\'imgs/tip/left.png\' width=\'6\'></td> <td class=black background=\'imgs/tip/middle.png\' heigh=\'500\'> <table background=\'imgs/tip/middle.png\' border=\'0\' style=\'border-collapse:collapse;font-size: 12px;width:320px\'> <tr> <td class=black background=\'imgs/tip/middle.png\' colspan=\'2\'><strong>$row[nom]</strong> ($nbre_vaisseau) </td> </tr> <tr> <td class=black background=\'imgs/tip/middle.png\'><img src=\'imgs/vaisseaux/$row[img].jpg\' alt=\'$name\' width=\'80\' height=\'80\'></td> <td class=black background=\'imgs/tip/middle.png\'>$row[description] <br><br>Puissance de feux : $arme<br>Coque : $coque<br>Bouclier : $bouclier<br>Vitesse : $vitesse <br>Fret : $place </td> </tr> <tr style=\'text-align:center;\'> <td class=black background=\'imgs/tip/middle.png\'><span style=\'color:#FF0000\'><strong>$etimeevo</strong></span></td> <td class=black background=\'imgs/tip/middle.png\'><strong>"; if(!empty($row[fer])) { $deuxiemetd.= "<br> Fer : "; if($newwfer_ressource < ($row[fer])){ $deuxiemetd.="<span style=\'color:#FF0000\'>$fer</span>"; } else { $deuxiemetd.="$fer"; }} if(!empty($row[orr])) { $deuxiemetd.=" <br> Or : "; if($newwor_ressource < ($or)){ $deuxiemetd.="<span style=\'color:#FF0000\'>$or</span>"; } else { $deuxiemetd.="$or"; }} if(!empty($row[ada])) { $deuxiemetd.=" <br> Cristal : "; if($newwada_ressource < ($row[ada])){ $deuxiemetd.="<span style=\'color:#FF0000\'>$ada</span>"; } else { $deuxiemetd.="$ada"; }} if(!empty($row[ura])) { $deuxiemetd.=" <br> Naquadah : "; if($newwura_ressource < ($row[ura])){ $deuxiemetd.="<span style=\'color:#FF0000\'>$ura</span>"; } else { $deuxiemetd.="$ura"; }} $deuxiemetd.="</strong> </td> </tr> </table> </td>	<td class=\'black\' background=\'imgs/tip/right.png\' width=\'6\'></td> </tr> <tr> <td class=black background=\'imgs/tip/bottomleft.png\' width=\'6\' height=\'6\'></td> <td class=black background=\'imgs/tip/bottom.png\' height=\'6\'></td> <td class=black background=\'imgs/tip/bottomright.png\' width=\'6\' height=\'6\'></td>	</tr>	</table>')\" onMouseOut=\"return nd()\"> <img src=\"imgs/vaisseaux/"; if ($newwfer_ressource >= ($row[fer]) && $newwor_ressource >= ($row[orr]) && $newwada_ressource >= ($row[ada]) && $newwura_ressource >= ($row[ura])) { $deuxiemetd.= $row[img]; } else { $deuxiemetd.= $img."_d"; } $deuxiemetd.=".jpg\" alt=\"$name\" width=\"120\" height=\"120\"></a></td>";
$troisiemetd.="<td>"; if ($newwfer_ressource < ($row[fer]) || $newwor_ressource < ($row[orr]) || $newwada_ressource < ($row[ada]) || $newwura_ressource < ($row[ura])) { $troisiemetd.="-"; } else { $troisiemetd.="<form action=\"constructionvaisseaux.php\" method=\"post\" target=\"_parent\"> <p> <input name=\"nombre_vaisseaux\" type=\"text\" id=\"nombre_vaisseaux\" size=\"3\"> <input name=\"id\" type=\"hidden\" value=\"$row[id]\"> <input type=\"submit\" name=\"Submit\" value=\"Lancer\"> </p> </form>"; } $troisiemetd.="</td>";



if($i == 5)
{
echo "<tr> $premiertd </tr>
              <tr style=\"text-align:center\">
              $deuxiemetd </tr>
              <tr style=\"text-align:center;BACKGROUND-COLOR: #222222\">
			  $troisiemetd
              </tr>
			  ";
unset($premiertd);	
unset($deuxiemetd);	
unset($troisiemetd);			  
}
			  
if ((($i/5) == ceil($i/5) && $i !== "5") || ($i == $num))
{
echo"
              <tr>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
              </tr>
			  <tr>
			  $premiertd </tr>
              <tr style=\"text-align:center\">
              $deuxiemetd </tr>
              <tr style=\"text-align:center;BACKGROUND-COLOR: #222222\">
			  $troisiemetd 
			  </tr>
              <tr>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
              </tr>";
unset($premiertd);	
unset($deuxiemetd);	
unset($troisiemetd);

}

	
	
/*
echo "<br><table width=\"618\" border=\"0\" cellspacing=\"0\" cellpadding=\"2\" bordercolor=\"#000000\" style=\"font-family:trebuchet ms,sans-serif; font-size: 9pt ;\">
  <tr style =\"background-color:#222222;\">
<form name=\"suprimer\" method=\"post\" action=\"vaisseau_del.php\" target=\"_parent\">    <input type=\"hidden\" name=\"id\" value=\"$row[id]\">  
    <td colspan=\"2\"><div align=\"center\"><font align=right><input name=\"image\" type=\"image\" src=\"imgs/del.gif\" align=\"right\" width=\"25\"  Style=\"border:0px solid #7E7E7E;\"></font></form>
<form name=\"edit\" method=\"post\" action=\"chantier_changename.php\" target=\"_parent\">    <input type=\"hidden\" name=\"id\" value=\"$row[id]\">  
    <div align=\"center\"><font align=right><input name=\"image\" type=\"image\" src=\"imgs/edit.gif\" align=\"right\" width=\"25\"  Style=\"border:0px solid #7E7E7E;\"></font> 
    </form><b>$row[nom] </b> ($nbre_vaisseau) 
    </div></td>
  </tr>
  <tr>
    <td width=\"150\"><img src=\"imgs/vaisseaux/$row[img].jpg\" width=\"150\" height=\"130\"></td>
    <td valign=\"top\">$row[description] <br>
      <br>
      Co&ucirc;t : Fer : <b>$fer</b> ; Or : <b>$or</b> ; Cristal : <b>$ada</b> ; Naquadah : <b>$ura</b><br>
Puissance de feux : <b>$arme</b> ; Coque : <b>$coque</b> ; Bouclier : <b>$bouclier</b> ; Vitesse : <b>$vitesse</b><br>
Fret : <b>$place</b> ; Temps de construction : <b>$etimeevo</b></td>
  </tr>
  <tr style =\"background-color:#111111;\">";
if ($timechantier2 == "-1") {
	echo"<form action=\"constructionvaisseaux.php\" method=\"post\" target=\"_parent\"><td align=\"center\" height=\"35\" colspan=\"2\">";

if ($newwfer_ressource < $row[fer] | $newwor_ressource < $row[orr] | $newwada_ressource < $row[ada] | $newwura_ressource < $row[ura]){
	echo"Pas assez de ressources"; } else {
	echo"
  <p>
    <input name=\"nombre_vaisseaux\" type=\"text\" id=\"nombre_vaisseaux\" size=\"3\">
	<input name=\"id\" type=\"hidden\" value=\"$row[id]\">
    <input type=\"submit\" name=\"Submit\" value=\"Lancer\">
  </p>"; }
  //}
echo"</td></form>"; }
else { echo"<td align=\"center\" height=\"20\" colspan=\"2\"><p class=\"Style2\">- Indisponible -</p></td>"; }
	echo"</tr>
 </table>";*/
}
  }

}

echo"</table>";
/////////////////////////////////////////////
$req = "SELECT findeconstruction FROM matgraph_constructionvaisseaux WHERE proprietaire='$planete' ORDER BY id ASC limit 1";
$res = db_mysql_Query($req);
$num = mysql_num_rows($res);
if ($num >0) {
  While ( $row = mysql_fetch_array($res) ) {
  
$esecevo4 = "";
$etimeevo4 = "";
$eminevo4="";
$ehourevo4="";
$edayevo4="";

$tempsfin2 =  $row[findeconstruction] - time();
$tempsevo4lution = $tempsfin2;
$eminevo4 = $tempsevo4lution / 60;

if ( floor($eminevo4) != $eminevo4 )
  $esecevo4 = floor( ($eminevo4 - floor( $eminevo4 )) * 60);

  if ( $eminevo4 > 60 ) {

    $ehourevo4 = floor( $eminevo4 / 60 );
    $eminevo4 = $eminevo4 - ( 60 * $ehourevo4 );

    if ( $ehourevo4 > 24 ) {
      $edayevo4 = floor( $ehourevo4 / 24);
      $ehourevo4 = $ehourevo4 - ( 24 * $edayevo4 );
    }

  }

$tempsevo4lution ="";

if (empty($edayevo4) )
  $edayevo4 = 0;

if (empty($ehourevo4) )
  $ehourevo4 = 0;

if (empty($esecevo4) ) 
  $esecevo4 = 0;
  
$emin2evo4 = floor($eminevo4) ;
$nom1="evo41";
$tempsevo4lution1 = "<body onLoad=chrono($edayevo4,$ehourevo4,$emin2evo4,$esecevo4,'$nom1')>
<span id=\"ligne_$nom1\">Temps restant pour la première construction : $edayevo4:$ehourevo4:$emin2evo4:$esecevo4</span>";
echo"<br>$tempsevo4lution1<br>"; }}

$req = "SELECT * FROM matgraph_constructionvaisseaux WHERE findeconstruction > ".time()." AND proprietaire='$planete' ";
$res = db_mysql_Query($req) or die('erreur sql<br>'.$req.'<br>'.mysql_error());
$num = mysql_num_rows($res);
if ($num >0) {
echo"<br><select name=\"select\" size=\"5\">";
}
$req = "SELECT * FROM matgraph_constructionvaisseaux WHERE findeconstruction > ".time()." AND proprietaire='$planete' 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) ) {
$sql2 = "SELECT nom FROM matgraph_vaisseaux WHERE id='$row[nom]'";
$res2 = db_mysql_Query($sql2)or die('erreur sql<br>'.$sql2.'<br>'.mysql_error());
$row2 = mysql_fetch_array($res2); 
  echo"<option value=\"$row2[nom]\">$row2[nom]</option>";
  	}
}
$req = "SELECT * FROM matgraph_constructionvaisseaux WHERE findeconstruction > ".time()." AND proprietaire='$planete' ";
$res = db_mysql_Query($req) or die('erreur sql<br>'.$req.'<br>'.mysql_error());
$num = mysql_num_rows($res);
if ($num >0) {
echo"</select>";
}
$req = "SELECT * FROM matgraph_constructionvaisseaux WHERE findeconstruction > ".time()." AND proprietaire='$planete' ";
$res = db_mysql_Query($req);
$num = mysql_num_rows($res);
if ($num >0) {


$sql = "SELECT findeconstruction FROM matgraph_constructionvaisseaux WHERE proprietaire = '$planete' ORDER BY findeconstruction desc";
$res = db_mysql_Query($sql) or die('Erreur SQL!<br>'.$sql.'<br>'.mysql_error());

$dertemps = mysql_result($res, 0);

$esectechcoque = "";
$etimetechcoque = "";
$emintechcoque="";
$ehourtechcoque="";
$edaytechcoque="";

$tempsfin =  $dertemps - time();
$etimetechcoque = $tempsfin;
$emintechcoque = $etimetechcoque / 60;

if ( floor($emintechcoque) != $emintechcoque )
  $esectechcoque = floor( ($emintechcoque - floor( $emintechcoque )) * 60);

  if ( $emintechcoque > 60 ) {

    $ehourtechcoque = floor( $emintechcoque / 60 );
    $emintechcoque = $emintechcoque - ( 60 * $ehourtechcoque );

    if ( $ehourtechcoque > 24 ) {
      $edaytechcoque = floor( $ehourtechcoque / 24);
      $ehourtechcoque = $ehourtechcoque - ( 24 * $edaytechcoque );
    }

  }

$etimetechcoque ="";

if (!empty($edaytechcoque) )
  $etimetechcoque.="$edaytechcoque j ";

if (!empty($ehourtechcoque) )
  $etimetechcoque.="$ehourtechcoque h ";

if ($emintechcoque != 0)
  $etimetechcoque.= floor($emintechcoque)." min. ";

if (!empty($esectechcoque) ) 
  $etimetechcoque.="$esectechcoque sec. ";
echo"<br><br>Temps total restant : $etimetechcoque"; }


/*
	$req = "SELECT vaisseau, planete, nbre FROM matgraph_nbrevaisseaux WHERE user = '$idlogin'" ;
	$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) )
		{
			// Calcul le score des vaisseaux non mobilisés
			$sql2 = "SELECT fer, orr, ada, ura FROM matgraph_vaisseaux WHERE id = '$row[vaisseau]'" ;
			$res2 = db_mysql_Query($sql2) or die('Erreur SQL! <br>' . $sql2 . '<br>' . mysql_error()) ;
			$row2 = mysql_fetch_array($res2) ;
			$Score_vaisseau += ( ( $row2['fer'] + $row2['orr'] + $row2['ada'] + $row2['ura'] ) * $row['nbre'] ) ;

			// Calcul le score des vaisseaux mobilisés
			$sql_6 = "SELECT nombre FROM matgraph_mobil WHERE iddepart = '$row[planete]' AND idvaisseau = '$row[vaisseau]' " ;
			$res_6 = db_mysql_Query($sql_6) or die('erreur sql<br>' . $sql_6 . '<br>' . mysql_error()) ;
			While ($row_6 = mysql_fetch_array($res_6) )
			{
				$Score_vaisseau += ( ( $row2['fer'] + $row2['orr'] + $row2['ada'] + $row2['ura'] ) * $row_6['nombre'] ) ;
			}
		}
	}
	
	$req = "SELECT mili_nbre FROM matgraph_users WHERE idjoueur = '$idlogin'" ;
	$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) )
		{
		$Score_soldats += ($row[mili_nbre]/5000) ;
		}
	}
	
	$pts_flotte = $Score_vaisseau + $Score_soldats;
	$req_UPDATE = "UPDATE matgraph_users SET pts_flotte = '$pts_flotte' WHERE id = '$idlogin'" ;
	$maj=db_mysql_Query($req_UPDATE) or die('Erreur SQL! <br>' . $req_UPDATE . '<br>' . mysql_error()) ;
	
	*/
mysql_close($connect);

echo'<br><br><br>';
include 'zap.php';
?>