<?php
//name
$central_name = "Centrale";
$fission_name = "Centrale énergétique au Naquadah";
$fer_name = "Mine de Fer";
$exfer_name = "Centre d\'extraction du fer";
$or_name = "Mine d\'or";
$exor_name = "Centre d\'extraction d\'or";
$ada_name = "Mine de Cristal";
$ura_name = "Mine de Naquadah";
$robo_name = "Usine Robotique";
$labo_name = "Centre de recherches scientifiques";
$defense_name = "Centre Militaire de Défense Interplanétaire";
$mili_name = "Caserne Militaire";
$chantier_name = "Chantier spatial";
$siege_name = "Siège des Anciens";
$hangarfer_name = "Zone de Stockage du fer";
$hangaror_name = "Zone de Stockage de l\’or";
$hangarada_name = "Zone de Stockage du Cristal";
$hangarura_name = "Cuve de Stockage du Naquadah";
$silo_name = "Temple de Dakara";
$terri_name = "Vaisseau Terraformeur";
$techinfra_name = "Technologie d\'infrastructure des Vaisseaux";
$techenergie_name = "Technologie de maîtrise de l\'Energie";
$techlaser_name = "Technologie de Laser";
$techions_name = "Technologie d\'ions";
$techplasma_name = "Technologie de plasma";
$techordi_name = "Technologie Salle de contrôle";
$techcombustion_name = "Réacteur à combustion";
$techAsgaards_name = "Réacteur Asgard";
$techhyperespace_name = "Technologie des Réacteurs hyperespace";
$techespio1_name = "Technologie Espionnage de Type 1";
$techArmement_name = "Technologie de l\'Armement";
$techBouclier_name = "Technologie Bouclier de protection";
$techcoque_name = "Technologie de renforcement de la coque";
$techproAncien_name = "Technologie \'Les Anciens\'";
$technaqua_name = "Technologie de Naquadah";
$techanti_name = "Technologie Champ Anti-gravité";

/*
function compteur() {
   list($usec, $sec) = explode(' ', microtime());
   return ((float)$usec + (float)$sec);
}
$debut = compteur();
*/
include ('logue.php');
include ('entete2.php');
$placettt = $row[place];
$planetettt = $row[planete];
$planete_img = $row[planete_img];
$placelibre = $row[place] - $row[placepris];

include ('entete.php');
include ('ressource.php');


echo"
<style>
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>
<STYLE TYPE=text/css>
.Style1 {color: #0000FF}
.Style2 {color: #FF0000}
.Style3 {color: #00CC00}
</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');





////////////////
// News 
$reqmmm = "SELECT * FROM matgraph_commentaires ORDER by id = 1 ";
$resmmm = mysql_query($reqmmm) or die('Erreur SQL! <br>'.$reqmmm.'<br>'.mysql_error());
While( $rowmmm = mysql_fetch_array($resmmm) ) {

if($rowmmm[onoff] == 1 OR $rowmmm[onoff] == 'ON' ) {

echo"<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;\">
      <td><div align=\"center\"><strong><u>$rowmmm[titre] : </u></strong></div></td>
    </tr>
    <tr style =\"background-color:#111111;\">
      <td>$rowmmm[texte]</td>
    </tr>
	</table>
	<br>
	";
	}	
}
//
////////////////

////////////////
// affichage div acheter des ressource
	echo "<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;\">
      <td><div align=\"center\"><strong><u>Acheter des ressources : </u></strong></div></td>
    </tr>
    <tr style =\"background-color:#111111;\">
      <td>Cher habitant de l'Univers StarGate, afin de nous aider à financer les serveurs pour l'hébergement des univers de SGU, vous avez désormais la possibilité d'acheter des ressources : <font color=\"FF0000\">100.000</font> d'une ressource, <font color=\"FF0000\">5 EPPZ</font> ou un iris vous protégeant de <font color=\"FF0000\">5 attaques par la porte</font> contre 1 code allopass.
<br><br><div align=center><a href=\"achat.php\" target=\"_parent\"> Effectuer un achat </a><div align=center>
</td>
    </tr>
	</table><br><br>";
//
////////////////
 ?><!-- <br>
<a href="http://www.directivepub.com/tracking/cpc.php?idv=2040&ids=7875&idc=162" title="Directivepub Affiliation" target="_blank"><img src="http://www.directivepub.com/tracking/cpm.php?idv=2040&ids=7875&idc=162" HEIGHT='60'  WIDTH='468' Alt="DirectivePub Affiliation" BORDER="0"></a>
    -->      <br>
         
<?php
/*
echo"<div align=\"center\"><table align=\"center\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
<tr>
<td width=\"40\"><DIV id=\"cligno1\"><strong>/ ! \</strong></DIV></td><td><a href=\"http://www.rof.tonsite.biz/SGU/viewtopic.php?p=1583#1583\" target=\"_blank\"> <b>Message Admins : J - 3  </b></a></td><td width=\"40\" align=\"right\"><DIV id=\"cligno2\"><strong>/ ! \</strong></DIV>
</tr></table><br><br>";
*/

////////////////
// affichage info capteur arrivé/départ flotte
echo"<table width=\"618\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr><td>";
include 'Flotte_voir.php';
echo"</td></tr></table>";
//
////////////////

////////////////
// sql alliance / mp / calcul classement/pts
if($row2[ally] !== "no") {
$req = "SELECT pts FROM matgraph_users WHERE ally='$row2[ally]' ORDER by id ASC";
$res = 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) ) {
	$pts+= ($row[pts]/1000);
  }
}
$requete = "UPDATE matgraph_ally SET pts_ally='$pts' WHERE id='$row2[ally]'";
$resultat = mysql_query($requete)or die('erreur sql<br>'.$requete.'<br>'.mysql_error());
}


$pts = number_format(floor(($row2[pts] / 1000)), 0, ',', ' ');




$reponse  = mysql_query("SELECT pts FROM matgraph_users WHERE id='$dataid[id]'");
$reponse2 = mysql_query("SELECT COUNT(id) FROM matgraph_users WHERE pts>".mysql_result($reponse,0));
$classement=mysql_result($reponse2,0)/*+1*/;

$reqtotal = "SELECT count(*) FROM matgraph_users WHERE id=idjoueur";
$restotal = mysql_query($reqtotal) or die('Erreur SQL! <br>'.$reqtotal.'<br>'.mysql_error());
$rowtotal = mysql_fetch_array($restotal);

$date = date("d-m-Y");
$heure = date("H:i");



// La variable de condition
$liste_id = "(0";

$reqtmpid = "SELECT id FROM matgraph_users WHERE idjoueur = $idlogin";
$restmpid = mysql_query($reqtmpid) or die('Erreur SQL! <br>'.$reqtmpid.'<br>'.mysql_error());
while( $rowtmpid = mysql_fetch_array($restmpid) ) {
	$liste_id = $liste_id." OR receveur = $rowtmpid[id]";
}
$liste_id = $liste_id.")";

$reqmp = "SELECT count(*) FROM matgraph_mp WHERE $liste_id AND lu='non' ORDER BY id DESC";
$resmp = mysql_query($reqmp) or die('Erreur SQL! <br>'.$reqmp.'<br>'.mysql_error());
$rowmp = mysql_fetch_array($resmp);

$reqcontreespio = "SELECT count(*) FROM matgraph_contreespio WHERE $liste_id AND lu='non' ORDER BY id DESC";
$rescontreespio = mysql_query($reqcontreespio) or die('Erreur SQL! <br>'.$reqcontreespio.'<br>'.mysql_error());
$rowcontreespio = mysql_fetch_array($rescontreespio);

$reqespio = "SELECT count(*) FROM matgraph_espio1 WHERE $liste_id AND lu='non' ORDER BY id DESC";
$resespio = mysql_query($reqespio) or die('Erreur SQL! <br>'.$reqespio.'<br>'.mysql_error());
$rowespio = mysql_fetch_array($resespio);


$reqcombat = "SELECT count(*) FROM matgraph_bataille WHERE $liste_id AND lu='non' ORDER BY id DESC";
$rescombat = mysql_query($reqcombat) or die('Erreur SQL! <br>'.$reqcombat.'<br>'.mysql_error());
$rowcombat = mysql_fetch_array($rescombat);


$reqmsg = "SELECT count(*) FROM matgraph_msg WHERE $liste_id AND lu='non' ORDER BY id DESC";
$resmsg = mysql_query($reqmsg) or die('Erreur SQL! <br>'.$reqmsg.'<br>'.mysql_error());
$rowmsg = mysql_fetch_array($resmsg);


$reqmsgally = "SELECT count(*) FROM matgraph_msgally WHERE $liste_id AND lu='non' ORDER BY id DESC";
$resmsgally = mysql_query($reqmsgally) or die('Erreur SQL! <br>'.$reqmsgally.'<br>'.mysql_error());
$rowmsgally = mysql_fetch_array($resmsgally);

$nbremsgfinal = $rowmp['count(*)'] + $rowespio['count(*)'] + $rowcombat['count(*)'] + $rowmsg['count(*)'] + $rowmsgally['count(*)'] + $nbrecombat['count(*)'] + $rowcontreespio['count(*)'];

if($nbremsgfinal != "0") {
echo("<a href=\"mp_lire.php\" target=\"_parent\"><p class=\"Style1\"><div align=\"center\">Vous avez $nbremsgfinal nouveau(x) message(s).</p></div></a>"); }

$req = "SELECT * FROM matgraph_explorer WHERE receveur = $idlogin AND lu='non' ORDER BY id DESC";
$res = mysql_query($req) or die('Erreur SQL! <br>'.$req.'<br>'.mysql_error());
$num = mysql_num_rows($res);
if ( $num > 0 ) {
	echo"<a href=\"commerce.php\" target=\"_parent\"><p class=\"Style1\"><div align=\"center\">Vous avez $num proposition(s) de pacte(s) de la par de :"; 
  While ( $row = mysql_fetch_array($res) ) {
		$sql3 = "SELECT login,galaxi,system,position FROM matgraph_users WHERE id='$row[planete_envoyeur]' limit 1";
		$res3 = mysql_query($sql3)or die('erreur sql<br>'.$sql3.'<br>'.mysql_error());
		$row3 = mysql_fetch_array($res3);
		echo" $row3[login] ([$row3[galaxi]:$row3[system]:$row3[position]]) ";
	}
	echo".</p></div></a>";
}
////////////////
// affichage points/classement
echo"<div align=\"center\"><table width=\"638\"  border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
  <tr style =\"background-color:#222222;\">
    <td width=\"171\">Points : </td>
    <td align=\"center\" colspan=\"2\">$pts </td>
  </tr>
  <tr>
    <td>Classement : </td>
    <td align=\"center\" colspan=\"2\">".$classement." / ".$rowtotal['count(*)']."</td>
  </tr>";
//
////////////////

////////////////
// affichage bat/recherche en cours
echo '<body onload="reloaded();reloaded2();">';
$query="SELECT * FROM matgraph_users WHERE id='".$planete."'";
$sql=mysql_query($query) or die('Erreur MySQl :'.mysql_error());
$row=mysql_fetch_array($sql);
$evolution=0;
foreach($row as $cle=>$valeur){
	if(ereg('_evolution',$cle) && $valeur!='0000-00-00 00:00:00' && !ereg('tech',$cle)){
		$construction=str_replace('_evolution','',$cle);
		$evolution=1;
		$temps_constr=$valeur;
	}
	if(ereg('_destruction',$cle) && $valeur!='0000-00-00 00:00:00'){
		$construction=str_replace('_des','',$cle);
		$evolution=2;
		$temps_destruct=$valeur;
	}
}
if($evolution!=0){
	ereg ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})", $temps_constr, $thetime);
	$tps = mktime($thetime[4],$thetime[5],$thetime[6],$thetime[2],$thetime[3],$thetime[1]);
	$etps= -(time() - $tps);
	echo "<tr style =\"background-color:#222222;\">
    <td>Bâtiments : </td>
    <td align=\"center\" colspan=\"2\">".stripslashes(${$construction.'_name'})." (". ($row[$construction.'_lvl'] + 1).")&nbsp;&nbsp;<span id=\"constr_".$construction."\"></span><input id=\"lanceurCh\" value=\"".$etps.":constr_".$construction.";\" type=\"hidden\"></td>
  </tr>";
}else{
	echo "<tr style =\"background-color:#222222;\">
    <td>Bâtiments : </td>
    <td align=\"center\" colspan=\"2\">Aucune construction en cours</td>
  </tr>";
}
$query="SELECT * FROM matgraph_users WHERE id='".$idlogin."' AND idjoueur=id";
$sql=mysql_query($query) or die('Erreur MySQl :'.mysql_error());
$row=mysql_fetch_array($sql);
$evolution=0;
foreach($row as $cle=>$valeur){
	if(ereg('_evolution',$cle) && $valeur!='0000-00-00 00:00:00' && ereg('tech',$cle)){
		$construction=str_replace('_evolution','',$cle);
		$evolution=1;
		$temps_constr=$valeur;
	}
}
if($evolution==1){
	ereg ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})", $temps_constr, $thetime);
	$tps = mktime($thetime[4],$thetime[5],$thetime[6],$thetime[2],$thetime[3],$thetime[1]);
	$etps= -(time() - $tps);
	echo "<tr>
    <td>Technologies : </td>
    <td align=\"center\" colspan=\"2\">".stripslashes(${$construction.'_name'})." (". ($row[$construction.'_lvl'] + 1).")&nbsp;&nbsp;<span id=\"constr_".$construction."\"></span><input id=\"lanceurCh2\" value=\"".$etps.":constr_".$construction.";\" type=\"hidden\"></td>
  </tr>";
}else{
	echo "<tr>
    <td>Technologies : </td>
    <td align=\"center\" colspan=\"2\">Aucune recherche en cours</td>
  </tr>";
}
//
////////////////

////////////////
// affichage DEFCON
if($row2[ally] !== "no") {

$sqlally2 = "SELECT defcon FROM matgraph_ally WHERE id='$row2[ally]'";
$resally2 = mysql_query($sqlally2)or die('erreur sql<br>'.$sqlally2.'<br>'.mysql_error());
$rowally2 = mysql_fetch_array($resally2);
if($rowally2[defcon] == "5") { $defcon = "<font color=\"009900\">Niveau 5 : Préparation normale en temps de paix.</font>"; }
if($rowally2[defcon] == "4") { $defcon = "<font color=\"999933\">Niveau 4 : Renseignement accru et mesures de sécurité renforcées.</font>"; }
if($rowally2[defcon] == "3") { $defcon = "<font color=\"FFFF00\">Niveau 3 : Accroissement de la préparation des forces.</font>"; }
if($rowally2[defcon] == "2") { $defcon = "<font color=\"FF9900\">Niveau 2 : Accroissement supplémentaire dans la préparation des forces, mais inférieure à la préparation maximale.</font>"; }
if($rowally2[defcon] == "1") { $defcon = "<font color=\"FF0000\">Niveau 1 : Etat de guerre !! Préparation maximale des forces.</font>"; }
echo"<tr style =\"background-color:#222222;\">
    <td>DEFCON : </td>
    <td align=\"center\" colspan=\"2\">$defcon</td>
  </tr>"; 
}
//
////////////////

////////////////
//img planete
echo"<tr>
    <td colspan=\"3\">&nbsp;</td>
  </tr>
  <tr>
    <td width=\"200\" colspan=\"2\" align=\"center\" valign=\"middle\"><img src=\"imgs/planete/$planete_img.jpg\" width=\"200\" height=\"200\"></td>
    <td><div align=\"center\">";
//
////////////////

////////////////
// affichage des colonies
echo"<table width=\"204\"  border=\"0\" cellspacing=\"2\" cellpadding=\"0\">
<tr>";
$reqimg1 = "SELECT id,planete,planete_img FROM matgraph_users WHERE idjoueur='$dataid[id]' ORDER BY id ASC";
$resimg1 = mysql_query($reqimg1) or die('Erreur SQL! <br>'.$reqimg1.'<br>'.mysql_error());
$numimg1 = mysql_num_rows($resimg1);
if ( $numimg1 > 0 )
{
  $i=1;
  While ( $rowimg1 = mysql_fetch_array($resimg1) ) {
if($i == 1 || $i == 2 || $i == 3 || $i == 4 )	{

echo"<td align=\"center\">$rowimg1[planete]
	<br>
	<form name=\"colo\" method=\"post\" action=\"colonies.php\" target=\"_parent\">
		<input name=\"idcolo\" type=\"hidden\" id=\"idcolo\" value=\"$rowimg1[id]\">
		<input name=\"page\" value=\"apercu\" type=\"hidden\" id=\"page\">
		<INPUT type=\"image\" src=\"imgs/planete/$rowimg1[planete_img].jpg\" title=\"$evolution\" width=\"100\" height=\"100\" onClick=\"submit()\">
	</form>
</td>"; }
  $i++;}
}
echo"</tr>
<tr>";
$reqimg2 = "SELECT id,planete,planete_img FROM matgraph_users WHERE idjoueur='$dataid[id]' ORDER BY id ASC";
$resimg2 = mysql_query($reqimg2) or die('Erreur SQL! <br>'.$reqimg2.'<br>'.mysql_error());
$numimg2 = mysql_num_rows($resimg2);
if ( $numimg2 > 0 )
{
  $i=1;
  While ( $rowimg2 = mysql_fetch_array($resimg2) ) {
if($i == 5 || $i == 6 || $i == 7 || $i == 8)	{

echo"<form name=\"colo\" method=\"post\" action=\"colonies.php\" target=\"_parent\"><input name=\"idcolo\" type=\"hidden\" id=\"idcolo\" value=\"$rowimg2[id]\"><input name=\"page\" value=\"apercu\" type=\"hidden\" id=\"page\"><td align=\"center\">$rowimg2[planete]<br><INPUT type=\"image\" src=\"imgs/planete/$rowimg2[planete_img].jpg\" title=\"$evolution\" width=\"100\" height=\"100\" onClick=\"submit()\"></td></form>"; }
  $i++;}
}
echo"</tr>
<tr>";
$reqimg3 = "SELECT id,planete,planete_img FROM matgraph_users WHERE idjoueur='$dataid[id]' ORDER BY id ASC";
$resimg3 = mysql_query($reqimg3) or die('Erreur SQL! <br>'.$reqimg3.'<br>'.mysql_error());
$numimg3 = mysql_num_rows($resimg3);
if ( $numimg3 > 0 )
{
  $i=1;
  While ( $rowimg3 = mysql_fetch_array($resimg3) ) {
if($i == 9 || $i == 10 || $i == 11 || $i == 12)	{

echo"<form name=\"colo\" method=\"post\" action=\"colonies.php\" target=\"_parent\"><input name=\"idcolo\" type=\"hidden\" id=\"idcolo\" value=\"$rowimg3[id]\"><input name=\"page\" value=\"apercu\" type=\"hidden\" id=\"page\"><td align=\"center\">$rowimg3[planete]<br><INPUT type=\"image\" src=\"imgs/planete/$rowimg3[planete_img].jpg\" title=\"$evolution\" width=\"100\" height=\"100\" onClick=\"submit()\"></td></form>"; }
  $i++;}
}
echo"</tr>
</table>";
//
////////////////

////////////////
//affichage action supprimer/rennomer
echo"</div></td>
  </tr>
  <tr style =\"background-color:#222222;\">
    <td>Planete : </td>
    <td align=\"center\" colspan=\"2\">$planetettt (<a href=\"changename.php\" target=\"_parent\">Changer de nom</a>";
if($planete !== $idlogin) { echo" - <a href=\"colo_del.php\" target=\"_parent\">Supprimer</a>"; } echo")</td>
  </tr>
  <tr>
    <td>Place disponible sur la planete : </td>
    <td align=\"center\" colspan=\"2\">$placelibre / $placettt</td>
  </tr>";
//
////////////////

////////////////
// date et fete saint
echo"
  <tr>
    <td colspan=\"3\"><div align=\"center\">Nous sommes le $date et il est $heure</div></td>
  </tr>
  <tr style =\"background-color:#222222;\">
    <td colspan=\"3\"><div align=\"center\">Saint :


<script language=\"JavaScript\" src=\"jssants.js\"></script></div></td>
</tr>
</table>";
//
////////////////
echo'<br><br><head>';


////////////////
// panneau admin
$req = "SELECT * FROM matgraph_axxadmin WHERE idjoueur = $idlogin";
$res = mysql_query($req) or die('Erreur SQL! <br>'.$req.'<br>'.mysql_error());
$num = mysql_num_rows($res);
if ( $num > 0 ) {
echo "<br><a href=\"admin234/\" target=\"_blank\"> <b>Panneau d'administration</b></a><br><br>"; }
//
////////////////

mysql_close($connect);

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