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

echo '<SCRIPT LANGUAGE="JavaScript" type="text/javascript" SRC="Js_module/Infobulle.js"></SCRIPT>' ;
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}
</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');
$galaxi2 = htmlentities ($_POST["galaxi2"]);
$system2 = htmlentities ($_POST["system2"]);

//// 1

unset($ally);
if(empty($galaxi2) OR empty($system2)) {
  $sql = "SELECT galaxi,system FROM matgraph_users WHERE id='$planete'";
  $res = db_mysql_Query($sql)or die('erreur sql<br>'.$sql.'<br>'.mysql_error());
  $row = mysql_fetch_array($res);
  $galaxi2 = $row["galaxi"];
  $system2 = $row["system"]; 
}



?>
<!--------------------------->
<div style="visibility: hidden; display: none;">
<div align="center">
<br><br><br>
<table width="560" 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">1</div></td>
    <form name="lire1" id="lire1" method="post" action="ally_voir.php" target="_blank" width="618">

	<input type="hidden" name="id" value="">
    <td><div align="center"> libre</div></td></form>
    <form name="galaxi1" method="post" action="mp_envoi.php" target="_parent">
  <input name="idreceveur" type="hidden" value="">
  <input name="loginreceveur" type="hidden" value="">
  <input name="galaxi" type="hidden" value="1">
  <input name="system" type="hidden" value="1">
  <input name="position" type="hidden" value="1">

  <td width="61"><div align="center">&nbsp;</div></td></form>
  <form name="galaxi1" method="post" action="espio1_envoi.php" target="_parent">
  <input name="galaxi" type="hidden" value="1">
  <input name="system" type="hidden" value="1">
  <input name="position" type="hidden" value="1">
   <td width="21"><div align="center">&nbsp;</div></td></form>
  </tr>
    <tr>
    <td><div align="center">2</div></td>

    <form name="lire2" id="lire2" method="post" action="ally_voir.php" target="_blank" width="618">
	<input type="hidden" name="id" value="">
	<td><div align="center"> J'aime pas les bots</div></td></form>
	    <form name="galaxi2" method="post" action="mp_envoi.php" target="_parent">
  <input name="idreceveur" type="hidden" value="">
  <input name="loginreceveur" type="hidden" value="">
  <input name="galaxi" type="hidden" value="1">
  <input name="system" type="hidden" value="1">

  <input name="position" type="hidden" value="2">
  <td width="61"><div align="center">&nbsp;</div></td></form>
  <form name="galaxi2" method="post" action="espio1_envoi.php" target="_parent">
  <input name="galaxi" type="hidden" value="1">
  <input name="system" type="hidden" value="1">
  <input name="position" type="hidden" value="2">
   <td width="21"><div align="center">&nbsp;</div></td></form>
  </tr>
    <tr style ="background-color:#222222;">

    <td><div align="center">3</div></td>
    <form name="lire3" id="lire3" method="post" action="ally_voir.php" target="_blank" width="618">
	<input type="hidden" name="id" value="49">
    <td><div align="center">  J'aime pas les bots</div></td></form>
    <form name="galaxi3" method="post" action="mp_envoi.php" target="_parent">
  <input name="idreceveur" type="hidden" value="">

  <input name="loginreceveur" type="hidden" value="">
  <input name="galaxi" type="hidden" value="1">
  <input name="system" type="hidden" value="1">
  <input name="position" type="hidden" value="3">
  <td width="61"><div align="center">&nbsp;</div></td></form>
  <form name="galaxi3" method="post" action="espio1_envoi.php" target="_parent">
  <input name="galaxi" type="hidden" value="1">
  <input name="system" type="hidden" value="1">
  <input name="position" type="hidden" value="3">

   <td width="21"><div align="center">&nbsp;</div></td></form>
  </tr>
    <tr>
    <td><div align="center">4</div></td>
    <form name="lire4" id="lire4" method="post" action="ally_voir.php" target="_blank" width="618">
	<input type="hidden" name="id" value="49">
    <td><div align="center"> J'aime pas les bots</div></td></form>

    <form name="galaxi4" method="post" action="mp_envoi.php" target="_parent">
  <input name="idreceveur" type="hidden" value="">
  <input name="loginreceveur" type="hidden" value="">
  <input name="galaxi" type="hidden" value="1">
  <input name="system" type="hidden" value="1">
  <input name="position" type="hidden" value="4">
  <td width="61"><div align="center">&nbsp;</div></td></form>
  <form name="galaxi4" method="post" action="espio1_envoi.php" target="_parent">
  <input name="galaxi" type="hidden" value="1">

  <input name="system" type="hidden" value="1">
  <input name="position" type="hidden" value="4">
   <td width="21"><div align="center">&nbsp;</div></td></form>
  </tr>
   <tr style ="background-color:#222222;">
    <td><div align="center">5</div></td>
    <form name="lire5" id="lire5" method="post" action="ally_voir.php" target="_blank" width="618">
	<input type="hidden" name="id" value="49">

    <td><div align="center"> J'aime pas les bots</div></td></form>
    <form name="galaxi5" method="post" action="mp_envoi.php" target="_parent">
  <input name="idreceveur" type="hidden" value="">
  <input name="loginreceveur" type="hidden" value="">
  <input name="galaxi" type="hidden" value="1">
  <input name="system" type="hidden" value="1">
  <input name="position" type="hidden" value="5">

  <td width="61"><div align="center">&nbsp;</div></td></form>
  <form name="galaxi5" method="post" action="espio1_envoi.php" target="_parent">
  <input name="galaxi" type="hidden" value="1">
  <input name="system" type="hidden" value="1">
  <input name="position" type="hidden" value="5">
   <td width="21"><div align="center">&nbsp;</div></td></form>
  </tr>
  <tr>
    <td><div align="center">6</div></td>

    <form name="lire6" id="lire6" method="post" action="ally_voir.php" target="_blank" width="618">
	<input type="hidden" name="id" value="">
    <td><div align="center"> J'aime pas les bots</div></td></form>
    <form name="galaxi6" method="post" action="mp_envoi.php" target="_parent">
  <input name="idreceveur" type="hidden" value="">
  <input name="loginreceveur" type="hidden" value="">
  <input name="galaxi" type="hidden" value="1">
  <input name="system" type="hidden" value="1">

  <input name="position" type="hidden" value="6">
  <td width="61"><div align="center">&nbsp;</div></td></form>
  <form name="galaxi6" method="post" action="espio1_envoi.php" target="_parent">
  <input name="galaxi" type="hidden" value="1">
  <input name="system" type="hidden" value="1">
  <input name="position" type="hidden" value="6">
   <td width="21"><div align="center">&nbsp;</div></td></form>
  </tr>
    <tr style ="background-color:#222222;">

    <td><div align="center">7</div></td>
    <form name="lire7" id="lire7" method="post" action="ally_voir.php" target="_blank" width="618">
	<input type="hidden" name="id" value="">
    <td><div align="center"> J'aime pas les bots</div></td></form>
    <form name="galaxi7" method="post" action="mp_envoi.php" target="_parent">
  <input name="idreceveur" type="hidden" value="">
  <input name="loginreceveur" type="hidden" value="">

  <input name="galaxi" type="hidden" value="1">
  <input name="system" type="hidden" value="1">
  <input name="position" type="hidden" value="7">
  <td width="61"><div align="center">&nbsp;</div></td></form>
  <form name="galaxi7" method="post" action="espio1_envoi.php" target="_parent">
  <input name="galaxi" type="hidden" value="1">
  <input name="system" type="hidden" value="1">
  <input name="position" type="hidden" value="7">
   <td width="21"><div align="center">&nbsp;</div></td></form>

  </tr>
    <tr>
    <td><div align="center">8</div></td>
    <form name="lire8" id="lire8" method="post" action="ally_voir.php" target="_blank" width="618">
	<input type="hidden" name="id" value="">
    <td><div align="center"> J'aime pas les bots</div></td></form>
    <form name="galaxi8" method="post" action="mp_envoi.php" target="_parent">

  <input name="idreceveur" type="hidden" value="">
  <input name="loginreceveur" type="hidden" value="">
  <input name="galaxi" type="hidden" value="1">
  <input name="system" type="hidden" value="1">
  <input name="position" type="hidden" value="8">
  <td width="61"><div align="center">&nbsp;</div></td></form>
  <form name="galaxi8" method="post" action="espio1_envoi.php" target="_parent">
  <input name="galaxi" type="hidden" value="1">
  <input name="system" type="hidden" value="1">

  <input name="position" type="hidden" value="8">
   <td width="21"><div align="center">&nbsp;</div></td></form>
  </tr>
    <tr style ="background-color:#222222;">
    <td><div align="center">9</div></td>
    <form name="lire9" id="lire9" method="post" action="ally_voir.php" target="_blank" width="618">
	<input type="hidden" name="id" value="">
    <td><div align="center"> J'aime pas les bots</div></td></form>

    <form name="galaxi9" method="post" action="mp_envoi.php" target="_parent">
  <input name="idreceveur" type="hidden" value="">
  <input name="loginreceveur" type="hidden" value="">
  <input name="galaxi" type="hidden" value="1">
  <input name="system" type="hidden" value="1">
  <input name="position" type="hidden" value="9">
  <td width="61"><div align="center">&nbsp;</div></td></form>
  <form name="galaxi9" method="post" action="espio1_envoi.php" target="_parent">
  <input name="galaxi" type="hidden" value="9">

  <input name="system" type="hidden" value="1">
  <input name="position" type="hidden" value="9">
   <td width="21"><div align="center">&nbsp;</div></td></form>
  </tr>
    <tr>
    <td><div align="center">10</div></td>
    <form name="lire10" id="lire10" method="post" action="ally_voir.php" target="_blank" width="618">
	<input type="hidden" name="id" value="">

    <td><div align="center"> J'aime pas les bots</div></td></form>
    <form name="galaxi10" method="post" action="mp_envoi.php" target="_parent">
  <input name="idreceveur" type="hidden" value="">
  <input name="loginreceveur" type="hidden" value="">
  <input name="galaxi" type="hidden" value="1">
  <input name="system" type="hidden" value="1">
  <input name="position" type="hidden" value="10">
  <td width="61"><div align="center">&nbsp;</div></td></form>

  <form name="galaxi10" method="post" action="espio1_envoi.php" target="_parent">
  <input name="galaxi" type="hidden" value="1">
  <input name="system" type="hidden" value="1">
  <input name="position" type="hidden" value="10">
   <td width="21"><div align="center">&nbsp;</div></td></form>
  </tr>
</table></div></div>
<!--------------------------->

<br><form name="galaxi" method="post" action="galaxi.php" target="_parent"><div align="center">
  <table width="347" border="0" cellspacing="0" cellpadding="2" bordercolor="#000000" style="font-family:trebuchet ms,sans-serif; font-size: 9pt ;">
    <tr style ="background-color:#222222;">
      <td align="center" width="97">Galaxie : </td>
      <td align="center" width="97">Système Solaire :</td>
    </tr>
<tr>
      <td align="center">
        <input type="submit" value="-" onclick="document.getElementById('galaxi2').value=document.getElementById('galaxi2').value*1 - 1;">
		<input name="galaxi2" id="galaxi2" type="text" value="<?=$galaxi2?>" size="4" maxlength="3">
		<input type="submit" value="+" onclick="document.getElementById('galaxi2').value=document.getElementById('galaxi2').value*1 + 1;">
      </td>
      <td align="center">
	   <input type="submit" value="-" onclick="document.getElementById('system2').value=document.getElementById('system2').value*1 - 1;">
        <input name="system2" id="system2" type="text" value="<?=$system2?>" size="4" maxlength="3">
		<input type="submit" value="+" onclick="document.getElementById('system2').value=document.getElementById('system2').value*1 + 1;">
      </td>
    </tr>
    <tr style ="background-color:#222222;">
      <td colspan="2"><div align="center">
        <input type="submit" name="Submit" value="Voir"></form>
      </div></td>
      </tr>
  </table><br><br><br>
<table width="560" border="0" cellspacing="0" cellpadding="2" bordercolor="#000000" style="font-family:trebuchet ms,sans-serif; font-size: 9pt ;">
  <?

//$req = "SELECT date,pts,vacance,ally,id,idjoueur,login,planete,galaxi,system,position FROM matgraph_users WHERE galaxi='$galaxi2' AND system = '$system2' ORDER by position ASC";
$req = "SELECT l1.date,l.pts,l.vacance,l.ally,l1.id,l.idjoueur,l.login,l1.planete,l1.galaxi,l1.system,l1.position FROM matgraph_users l,matgraph_users l1 WHERE l1.galaxi='$galaxi2' AND l1.system = '$system2' and l.id = l1.idjoueur ORDER by position ASC";
$res = db_mysql_Query($req)or die('erreur sql<br>'.$req.'<br>'.mysql_error());
$num = mysql_num_rows($res);

$req = "SELECT position,type FROM IA_localisation WHERE galaxie='$galaxi2' AND systeme = '$system2' ORDER by position ASC";
$res2 = db_mysql_Query($req)or die('erreur sql<br>'.$req.'<br>'.mysql_error());
$num2 = mysql_num_rows($res2);
$IApos=0;
if ($num2>0){
  $IA = mysql_fetch_array($res2);
  $IApos=$IA["position"];
  $IAtype=$IA["type"];
}

if ($num>0)
$row1 = mysql_fetch_array($res);

for ($i=1;$i<=10;$i++){
//echo ":".$row1["position"] . " ". $i.":";

  if ($num>0 && $row1["position"]==$i) {
      $plan1 = "";
      if($row1["ally"] != "no") {
      $sql21 = "SELECT tag FROM matgraph_ally WHERE id='".$row1["ally"]."'";
      $res21 = db_mysql_Query($sql21)or die('erreur sql<br>'.$sql21.'<br>'.mysql_error());
      $num21 = mysql_num_rows($res21);
      if ($num21 > 0 AND $row1['ally'] !== "no") {
        $row21 = mysql_fetch_array($res21) ;
        $ally =$row21['tag'];
      }
      if (!empty($ally) )
        $plan1.="<a href=\"#\" target=\"_parent\" Onclick=\"document.getElementById('lirea$i').submit()\"><font color=\"FF9933\">[$ally]</font></a> "; 
    }
    $plan1.= $row1['planete'];
    $login1 =" (".$row1['login'].")";
    if($New_pts > $row1['pts']*3.0001) 
      $login1 =" (<font color=\"00CC00\">".$row1['login']."</font>)"; 
    if($New_pts < $row1['pts']/3.0001) 
      $login1 =" (<font color=\"990000\">".$row1['login']."</font>)"; 
    if($row1["vacance"] != "0000-00-00 00:00:00") 
      $login1 =" (<font color=\"0099FF\">".$row1['login']."</font>)"; 
       
    
    $plan1.= $login1;
    ereg ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})", $row1['date'], $thetime);
    $time1 = mktime($thetime[4],$thetime[5],$thetime[6],$thetime[2],$thetime[3],$thetime[1]);
    
    $diftemps1 = time() - $time1;
    $difheure1 = $diftemps1 / 3600;
    if($difheure1 > (24*7*4)) {
      $plan1.= "<font color=\"FF0000\"> \"AFK\"</font>";
    }else {
      if($difheure1 > (24*7*2)) 
        $plan1.= " \"afk\""; 
    }
    if($row1['idjoueur']!="$idlogin"){
      $msg1 = "<input type=\"image\" src=\"imgs/msg.gif\" Style=\"border:0px solid #7E7E7E;\">";
      $espio1 = "<input type=\"image\" src=\"imgs/espio.gif\" Style=\"border:0px solid #7E7E7E;\">";
    }else{
    $msg1 = "&nbsp;";
      $espio1 = "&nbsp;";
    }
  } elseif ($IApos==$i && $IAtype==0){ 
    $plan1 = "<A HREF=\"carrouf.php\"><font color=\"#669933\">Centre commercial</font></a>" ;
    $msg1 = "&nbsp;";
    $espio1 ="&nbsp;";
  } else { $plan1 = "libre" ; $msg1 = "&nbsp;"; $espio1 ="&nbsp;"; }
  unset($ally);
  
  
  $req_ruines = "SELECT fer,orr,ada FROM matgraph_ruines WHERE galaxi='$galaxi2' AND system = '$system2' AND position= '$i' AND (fer + orr + ada) > 0";
  $res_ruines = db_mysql_Query($req_ruines)or die('erreur sql<br>'.$req_ruines.'<br>'.mysql_error());
  $num_ruines = mysql_num_rows($res_ruines);
  $CDR1="";
  if ($num_ruines > 0) {
    $row_ruines = mysql_fetch_array($res_ruines);	
    $CDR1 = "<input type=\"image\" src=\"imgs/CDR.gif\" title=\"Fer : ".$row_ruines['fer']." ; Or : ".$row_ruines['orr']." ; Cristal : ".$row_ruines['ada']."\" Style=\"border:0px solid #7E7E7E;\">";
  }
  if ( ($i % 2) == 0 )
    echo "<tr>";
  else
    echo "<tr style =\"background-color:#222222;\">";
    
  echo "<td><div align=\"center\">$i</div></td>
      <form name=\"lirea$i\" id=\"lirea$i\" method=\"post\" action=\"ally_voir.php\" target=\"_blank\" width=\"618\">
  	<input type=\"hidden\" name=\"id\" value=\"".$row1['ally']."\">
      <td><div align=\"center\">$CDR1 $plan1</div></td></form>
      <form name=\"galaxi$i\" method=\"post\" action=\"mp_envoi.php\" target=\"_parent\">
    <input name=\"idreceveur\" type=\"hidden\" value=\"".$row1['id']."\">
    <input name=\"loginreceveur\" type=\"hidden\" value=\"".$row1['login']."\">
    <input name=\"galaxi\" type=\"hidden\" value=\"$galaxi2\">
    <input name=\"system\" type=\"hidden\" value=\"$system2\">
    <input name=\"position\" type=\"hidden\" value=\"$i\">
    <td width=\"61\"><div align=\"center\">$msg1</div></td></form>
    <form name=\"galaxi$i\" method=\"post\" action=\"espio1_envoi.php\" target=\"_parent\">
    <input name=\"galaxi\" type=\"hidden\" value=\"$galaxi2\">
    <input name=\"system\" type=\"hidden\" value=\"$system2\">
    <input name=\"position\" type=\"hidden\" value=\"$i\">
     <td width=\"21\"><div align=\"center\">$espio1</div></td></form>
    </tr>";
    if ($num>0 && $row1["position"]==$i)
      $row1 = mysql_fetch_array($res);
      
}

?></table></div>

<br>Légendes :
<br><font color="00CC00">Joueur Faible</font> , <font color="990000">Joueur Fort</font> , <font color="0099FF">Joueur en mode pause</font>
<br>"afk" : Joueur absent de puis plus de deux semaines.
<br><font color="FF0000">"AFK"</font> : Joueur absent de puis plus d'un mois.";


