<?php
include ('logue.php');
include ('entete2.php');
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>-= StarGate Univers =-</title>
<META NAME="TITLE" CONTENT="StarGate Univers" />
<META NAME="AUTHOR" CONTENT="M@tttt34" />
<META NAME="OWNER" CONTENT="matttt.34@laposte.net" />
<META NAME="SUBJECT" CONTENT="jeu de simulation intergalactique en php" />
<META NAME="RATING" CONTENT="jeux" />
<META NAME="DESCRIPTION" CONTENT="StarGate Univers est un jeu de stratégie militaire intergalactique. Vous dirigez une planète et vous devez la développer, militairement et économiquement. Le but est de devenir au plus vite le souverain le plus fort et le plus respecté de l’Univers. Mais il faut aussi le rester !" />
<META NAME="ABSTRACT" CONTENT="StarGate Univers est un jeu de stratégie militaire intergalactique. Vous dirigez une planète et vous devez la développer, militairement et économiquement. Le but est de devenir au plus vite le souverain le plus fort et le plus respecté de l’Univers. Mais il faut aussi le rester !" />
<META NAME="KEYWORDS" CONTENT="sgu,stargate,univers,star,gate,sg1,sgc,atlantis,jeux,jeu,simulation,galaxie,intergalactique,interstellaire,système,solaire,planète,planètes,anciens,ancien,technologies,technologie,ressource,ressources,vaisseaux,vaisseau,spatial,spatiaux,attaque,attaques,defense,defenses,tour,tours,base,bases,game,games,galaxy,system,sun,php,js,javascript" />
<META NAME="REVISIT-AFTER" CONTENT="7 DAYS" />
<META NAME="LANGUAGE" CONTENT="FR" />
<META NAME="COPYRIGHT" CONTENT="2005" />
<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW, NOARCHIVE" />
<LINK REL="SHORTCUT ICON" href="favicon.ico" />
<style type="text/css">
<!--
BODY {
	background-color: #000000;
	margin-left: 0px;
	margin-top: 0px;
	font-family: Times New Roman, Times, serif; 
	font-size: 11pt;
}
-->
</style>
<link rel="stylesheet" type="text/css" href="design.css" />
</head>
<BODY TEXT="#ffffff" LINK="#ffffff" VLINK="#ffffff" ALINK="#ffffff">
<script type="text/javascript" src="Js_module/lign_tr.js"></script>
<script type="text/javascript" src="Js_module/rebours.js"></script>
<script type="text/javascript" src="Js_module/autre.js"></script>
';
$query="SELECT * FROM matgraph_users WHERE idjoueur='".$idlogin."'";
$sql=db_mysql_query($query);
$empire=array();
$planete=array();
while( $row = mysql_fetch_array($sql) ){
	foreach($row as $cle=>$value){
		if(ereg('_lvl',$cle)){
			$empire[str_replace('_lvl','',$cle)][$row['id']]=$value;
		}
		if(ereg('_ressource',$cle)){
			$empire[$cle][$row['id']]=$value;
		}
		if(ereg('def',$cle) && !ereg('defense',$cle) && !ereg('pts',$cle) ){
			$empire[str_replace('def','',$cle)][$row['id']]=$value;
		}
		if(ereg('planete',$cle) || ereg('galaxi',$cle) || ereg('system',$cle) || ereg('position',$cle) || ereg('place',$cle) || ereg('placepris',$cle) || ereg('planete_img',$cle) || ereg('_on',$cle)){
			$empire[$cle][$row['id']]=$value;
		}
	}
	$planete[]=$row['id'];
}
$colspan=count($planete)+'1';
echo "
<table cellspacing='0' cellpadding='0' style=\"font-family:trebuchet ms,sans-serif; font-size: 9pt ;border-color:#000000;\">
<tr align='center'><td colspan='". $colspan ."'><h2><font color='#0066FF'>Empire</font></h2></td></tr>
<tr style =\"background-color:#222222;\">
	<td>Planète(Place libre)</td>";
foreach($planete as $id){
	echo "\n<td align='center'><img src='imgs/planete/".$empire['planete_img'][$id].".jpg' alt='".$empire['planete'][$id]."' width='50' height='50'/><br/>".$empire['planete'][$id]."[".$empire['galaxi'][$id].":".$empire['system'][$id].":".$empire['position'][$id]."] (". ( $empire['place'][$id]-$empire['placepris'][$id] ) .")</td>";
}
echo "
</tr><tr>
	<td><b><font color='#0066FF'>R</font></b>essources</td>";
	foreach($planete as $id){
		echo "\n<td>&nbsp;</td>";
	}
echo "</tr><tr style =\"background-color:#222222;\">
	<td>Fer(Production/h)</td>";
	foreach($planete as $id){
		$prod = floor($empire['fer_on'][$id] * 100 * ( bcpow( 1.18, $empire['fer'][$id],3))) ;
		if($empire['exfer'][$id] >'0'){$prod += ($empire['exfer_on'][$id] * 500 * ( bcpow( 1.2, $empire['exfer'][$id],3))) ;}
		$prod += 20;
		echo "\n<td>".number_format(round($empire['fer_ressource'][$id]),0,',',' ')." (".number_format($prod,0,',',' ').")</td>";
	}
echo "</tr><tr>
	<td>Or(Production/h)</td>";
	foreach($planete as $id){
		$prod = floor($empire['or_on'][$id] * 100 * ( bcpow( 1.18, $empire['or'][$id],3))) ;
		if($empire['exor'][$id] >'0'){$prod += ($empire['exor_on'][$id] * 500 * ( bcpow( 1.2, $empire['exor'][$id],3))) ;}
		$prod += 10;
		echo "\n<td>".number_format(round($empire['or_ressource'][$id]),0,',',' ')." (".number_format($prod,0,',',' ').")</td>";
	}
echo "</tr><tr style =\"background-color:#222222;\">
	<td>Cristal(Production/h)</td>";
	foreach($planete as $id){
		$prod = floor($empire['ura_on'][$id] * 100 * ( bcpow( 1.18, $empire['ura'][$id],3))) ;
		//if($empire['exura'][$id] >'0'){$prod += ($empire['exura_on'][$id] * 500 * ( bcpow( 1.2, $empire['exura'][$id],3))) ;}
		$prod += 5;
		echo "\n<td>".number_format(round($empire['ura_ressource'][$id]),0,',',' ')." (".number_format($prod,0,',',' ').")</td>";
	}
echo "</tr><tr>
	<td>Naquadah(Production/h)</td>";
	foreach($planete as $id){
		$prod = floor($empire['ada_on'][$id] * 100 * ( bcpow( 1.18, $empire['ada'][$id],3))) ;
		//if($empire['exada'][$id] >'0'){$prod += ($empire['exada_on'][$id] * 500 * ( bcpow( 1.2, $empire['exada'][$id],3))) ;}
		$prod += 2;
		echo "\n<td>".number_format(round($empire['ada_ressource'][$id]),0,',',' ')." (".number_format($prod,0,',',' ').")</td>";
	}
echo "
</tr><tr style =\"background-color:#222222;\">
	<td><b><font color='#0066FF'>B</font></b>&acirc;timents</td>";
	foreach($planete as $id){
		echo "\n<td>&nbsp;</td>";
	}
$array_aff=array('central'=>'Centrale','fission'=>'Centrale énérgétique au Naquadah','fer'=>'Mine de Fer','or'=>'Mine d\'or','ura'=>'Mine de Cristal','ada'=>'Mine de Naquadah','exfer'=>'Centre d\'extraction du Fer','exor'=>'Centre d\'extraction d\'Or','hangarfer'=>'Zone de Stockage du Fer','hangaror'=>'Zone de Stockage de l\'Or','hangarura'=>'Zone de Stockage du Cristal','hangarada'=>'Cuve de Stockage du Naquadah','mili'=>'Caserne Militaire','chantier'=>'Chantier Spatial','defense'=>'Centre Militaire de Défense Interplanétaire','silo'=>'Temple de Dakara','robo'=>'Usine Robotique','labo'=>'Centre de Recherches Scientifiques','terri'=>'Vaisseau Terraformeur','siege'=>'Sièges des Anciens','postav'=>'Poste Avancé des Anciens');
$i=0;
foreach($array_aff as $cle=>$valeur){
	echo "\n<tr";
	if(  ($i % 2) == 0 ){
    	echo "";
  	}else{
    	echo " style =\"background-color:#222222;\"";
	}
	echo "><td>".$valeur."</td>";
	foreach($planete as $id){
		echo "<td>".$empire[$cle][$id];
		if($cle=='fer' || $cle=='or' || $cle=='ura' || $cle=='ada' || $cle=='exfer' || $cle=='exor'){
			if($empire[$cle.'_on'][$id]>='0.75'){
				echo " (Marche)";
			}else{
				echo " (Arrêt)";
			}
		}
		echo "</td>";
	}
	echo "</tr>";
	$i++;
}
echo "
</tr><tr style =\"background-color:#222222;\">
	<td><b><font color='#0066FF'>D</font></b>éfenses</td>";
	foreach($planete as $id){
		echo "\n<td>&nbsp;</td>";
	}
$array_def=array('combat'=>'Tourelles de Combat','lasersimple'=>'Tourelle Laser Simple','laserdouble'=>'Double Tourelle Laser','elec'=>'Rayon Tracteur','ions'=>'Mini Satellite à Ions','plasma'=>'Tour à plasma','naqua'=>'Canon au Naquadah','anciens'=>'Satellites des Anciens','drone'=>'Drônes');
$i=0;
foreach($array_def as $cle=>$valeur){
	echo "\n<tr";
	if(  ($i % 2) == 0 ){
    	echo "";
  	}else{
    	echo " style =\"background-color:#222222;\"";
	}
	echo "><td>".$valeur."</td>";
	foreach($planete as $id){
		echo "<td>".$empire[$cle][$id]."</td>";
	}
	echo "</tr>";
	$i++;
}
echo "
</tr><tr style =\"background-color:#222222;\">
	<td><b><font color='#0066FF'>V</font></b>aisseaux</td>";
	foreach($planete as $id){
		echo "\n<td>&nbsp;</td>";
	}
$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());
while( $row = mysql_fetch_array($res) ){
	echo "\n<tr";
	if(  ($i % 2) == 0 ){
    	echo " style =\"background-color:#222222;\"";
  	}else{
    	echo "";
	}
	echo "><td>".$row['nom']."</td>";
	foreach($planete as $id){
		$sql2 = "SELECT nbre FROM matgraph_nbrevaisseaux WHERE vaisseau='".$row['id']."' AND planete='".$id."'";
		$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."', '".$id."', '".$row['id']."', '0')";
			$resultat = db_mysql_Query($requete)or die('erreur sql<br>'.$requete.'<br>'.mysql_error());
			$nbre_vaisseau = 0 ;
		}
		echo "<td>".$nbre_vaisseau."</td>";
	}
	echo "</tr>";
	$i++;
}
echo "\n</table></body></html>";
?>