<?php
function info_compte($id){
	global $user_rg;
	echo "<div id=\"$id\" style=\"display:none;border:1px solid grey;\">";
	$query="SELECT * FROM matgraph_users WHERE id='".$id."' AND id=idjoueur AND password!='no'";
	$sql=mysql_query($query) or die("Erreur MySQL : ".mysql_error());
	$num=mysql_num_rows($sql);
	if($num>1){
		echo "<font color='FF0000'>Problème : ".$num." joueurs ont le même login</font>";
	}else{
		$row=mysql_fetch_array($sql);
		ereg ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})", $row['date'], $thetime);
		$time = mktime($thetime[4],$thetime[5],$thetime[6],$thetime[2],$thetime[3],$thetime[1]);
		echo '<table align="center" style="font-size:9pt;">
			<tr><td align="right">Email d\'inscription : </td><td>'.$row['mail'].'</td></tr>
			<tr><td align="right">Statut : </td><td>';
		if($time<(time()-15*60)){
			echo '<font color="#FF0000">Offline</font></td></tr>'; 
		}elseif($time<(time()-5*60)){
			$temps_sec=time()-$time;
			$temps_min=floor($temps_sec/60);
			$temps_sec2=$temps_sec-($temps_min*60);
			echo '<font color="#FFFF33">Offline ( depuis '.$temps_min.' min '.$temps_sec2.' sec)</font></td></tr>';
		}else{
			echo '<font color="#33FF33">Online</font></td></tr>';
		}
		echo '<tr><td align="right">Dernière IP :</td><td>';
		$query="SELECT ip FROM matgraph_ip WHERE idlogin='".$row['idjoueur']."'";
		$sql=mysql_query($query);
		list($ip)=mysql_fetch_array($sql);
		echo $ip."</td></tr>"
			.'<tr><td align="right" style="vertical-align:top;">Multi-compte : </td><td>';
		$query1="SELECT joueur1,joueur2 FROM matgraph_multi WHERE (joueur1='".$row['idjoueur']."' OR joueur2='".$row['idjoueur']."') AND (joueur1!='0' AND joueur2!='0')";
		$sql1=mysql_query($query1) or die("Erreur MySQL : ".mysql_error());
		$num1=mysql_num_rows($sql1);
		$nom_multi=array();
		if($num1==0){
			echo "Pas de multi en cours";
		}else{
			echo "Multi entre :";
			while($resultat=mysql_fetch_array($sql1)){
				$req=mysql_query("SELECT login FROM matgraph_users WHERE idjoueur='".$resultat[0]."'");
				list($nom1)=mysql_fetch_array($req);
				$req=mysql_query("SELECT login FROM matgraph_users WHERE idjoueur='".$resultat[1]."'");
				list($nom2)=mysql_fetch_array($req);
				echo "<br>".$nom1."<-->".$nom2;
				$req=mysql_query("SELECT id FROM matgraph_autoriser WHERE (joueur1='".$resultat[0]."' AND joueur2='".$resultat[1]."') OR (joueur1='".$resultat[1]."' AND joueur2='".$resultat[2]."') ");
				$nombre=mysql_num_rows($req);
				if($nombre>0){
					echo "(autorisé)";
				}else{
					echo "(non autorisé)";
				}
			}
		}
		echo '<tr><td align="right">Eppz : </td><td>'.floor($row['eppz']).'</td></tr>
			<tr><td align="right">Soldats : </td><td>'.$row['mili_nbre'].'</td></tr>
			<tr><td align="right" style="vertical-align:top;">Place des planètes occupées : </td><td>';
		$query2="SELECT planete,galaxi,system,position FROM matgraph_users WHERE idjoueur='".$id."' ORDER BY galaxi,system,position ASC";
		$req=mysql_query($query2) or die("Erreur MySQL : ".mysql_error());
		while($row=mysql_fetch_array($req)){
			echo $row[1].":".$row[2].":".$row[3]." - ".$row[0]."<br>";
		}
		echo "</td></tr>
		<tr><td colspan='2' style=\"text-align:center;\"><a href='Nom_de_planete' onclick=\"AfficherPage('index.php?page=joueur&amp;editer_pl=".$id."','result');return false;\">Editer nom des planètes</a>&nbsp;||&nbsp;<a href='Mot_de_passe' onclick=\"AfficherPage('index.php?page=joueur&amp;editer_mdp=".$id."','result');return false;\">Editer le mot de passe</a>";
		if($user_rg>0){
			echo "&nbsp;||&nbsp;<a href='Editer_log_mail' onclick=\"AfficherPage('index.php?page=joueur&amp;editer_log_mail=".$id."','result');return false;\">Editer le login et/ou l'adresse email</a>";
		}
		echo "&nbsp;||&nbsp;<a href='Mode_Suppression' onclick=\"AfficherPage('index.php?page=joueur&amp;suppression=true&amp;id=".$id."','result');return false;\">Mode Suppression</a>&nbsp;||&nbsp;<a href='Mode_Pause' onclick=\"AfficherPage('index.php?page=joueur&amp;pause=true&amp;id=".$id."','result');return false;\">Mode Pause</a><br/><div id=\"result\" style=\"text-align:center;\"></div>";
		echo"</td></tr>
		</table>";
	}
	echo "</div>";	
}

echo"
<script type=\"text/javascript\">
function aff_div(id){
	var div_aff=document.getElementById(id);
	if(div_aff.style.display=='none'){
		div_aff.style.display='block';
	}else{
		div_aff.style.display='none';
	};
};
</script>
<script type=\"text/javascript\" src=\"include/ajax.js\"></script>";


$nom_rechercher = $_POST["nom_rechercher"];
$type = $_POST["type"];

$form ="<div align='center'><h3>Rechercher</h3></div><br><form action=\"index.php?action=rechercher\" method=\"post\" name=\"form1\" target=\"_parent\">
  <table width=\"618\" border=\"0\" cellspacing=\"0\" cellpadding=\"2\" bordercolor=\"#000000\" style=\"font-family:trebuchet ms,sans-serif; font-size: 9pt ;\" align=\"center\">
    <tr style =\"background-color:#222222;\">
      <td width=\"264\">Rechercher : 
      <input name=\"nom_rechercher\" type=\"text\" id=\"nom_rechercher\">      </td>
      <td width=\"265\">Dans :
        <select name=\"type\">
          <option value=\"joueur\">Nom du joueurs</option>
          <option value=\"planete\">Nom de la plan&egrave;te</option>
          <option value=\"ally\">Nom de l'alliance</option>
          <option value=\"tag\">Tag de l'alliance</option>
		  <option value=\"id\">Identifiant d'un joueur</option>
		  <option value=\"email\">Mail d'inscription d'un joueur</option>
              </select></td>
      <td width=\"81\"><input type=\"submit\" name=\"Submit\" value=\"Rechercher\"></td>
    </tr>
  </table>
</form><br/>";

if(empty($nom_rechercher)) {
	echo"$form"; 
	echo "</div></table>";
	exit; 
}

if($type == "joueur") {
echo"$form";
//$req = "SELECT id,date,ally,login,planete,galaxi,system,position,mail FROM matgraph_users WHERE id=idjoueur AND login REGEXP '$nom_rechercher' ORDER by login ASC";
$req = "SELECT id,date,ally,login,planete,galaxi,system,position,mail FROM matgraph_users WHERE id=idjoueur AND login LIKE '%$nom_rechercher%' ORDER by login ASC";
$res = mysql_query($req) or die('Erreur SQL! <br>'.$req.'<br>'.mysql_error());
$num = mysql_num_rows($res);
echo"<center>Vous avez obtenu $num résultat(s) à votre recherche :</center><br>";
echo"<table width=\"618\" border=\"0\" cellspacing=\"0\" cellpadding=\"2\" bordercolor=\"#000000\" style=\"font-family:trebuchet ms,sans-serif; font-size: 9pt ;\" align=\"center\">
  <tr style =\"background-color:#222222;\">
  <td align=\"center\"><b>ID : </b></td>
    <td align=\"center\" height=\"40\"><b>Nom : </b></td>
    <td align=\"center\"><b>Planète mère : </b></td>
	<td align=\"center\"><b>Email : </b></td>
	<td align=\"center\"><b>Dernière connection : </b></td>
	<td align=\"center\" width=\"100\"><b>Message : </b></td>
  </tr>";
if ( $num > 0 ) {
$i=1;
  While ( $row = mysql_fetch_array($res) ) {
$ally =""; 
$sql21 = "SELECT tag FROM matgraph_ally WHERE id='$row[ally]'";
$res21 = mysql_query($sql21)or die('erreur sql<br>'.$sql21.'<br>'.mysql_error());
$num21 = mysql_num_rows($res21);
if ($num21 > 0 AND $row[ally] !== "no") {
  While ( $row21 = mysql_fetch_array($res21) ) {
$ally ="$row21[tag]";
}}
$plan1 = "";
if (!empty($ally) )
  $plan1.="<font color=\"FF9933\">[$ally]</font>";
$lire = "lire";
$idform = $lire.$i;
$idform2 = $row[galaxi].$i;
echo"<tr";
// gère le quadrillage du tableau
			if (($i/2) == ceil($i/2))
			{
				echo' style ="background-color:#111111;"' ;
			}
	echo"><td align=\"center\">$row[id]</td>
	<form name=\"$idform\" id=\"$idform\" method=\"post\" action=\"ally/index.php\" target=\"_blank\" width=\"618\">
	<input type=\"hidden\" name=\"id\" value=\"$row[ally]\">
    <td align=\"center\"><a href=\"#\" target=\"_parent\" Onclick=\"document.getElementById('$idform').submit()\">$plan1</a> <a href='#' onclick=\"aff_div('$row[id]');\">$row[login]</a></td></form>
    <td align=\"center\">$row[planete] [$row[galaxi]:$row[system]:$row[position]]</td>
	<td align=\"center\">$row[mail]</td>
	<td align=\"center\">$row[date]</td>
	<form name=\"$idform2\" method=\"post\" action=\"../mp_envoi.php\" target=\"_blank\">  
  <input name=\"idreceveur\" type=\"hidden\" value=\"$row[id]\">
  <input name=\"loginreceveur\" type=\"hidden\" value=\"$row[login]\">
  <input name=\"galaxi\" type=\"hidden\" value=\"$row[galaxi]\">
  <input name=\"system\" type=\"hidden\" value=\"$row[system]\">
  <input name=\"position\" type=\"hidden\" value=\"$row[position]\">
  <td width=\"100\" align=\"center\"><div align=\"center\"><input type=\"image\" src=\"../imgs/msg.gif\" Style=\"border:0px solid #7E7E7E;\"></div></td></form>
  </tr><tr style=\"empty-cell:hide;\"><td colspan=\"6\" align=\"center\">";
  	info_compte($row[id]);
	echo "</td></tr>";
$i++;  
}}
  
echo"</table>";
}

if($type == "id") {
echo"$form";
$req = "SELECT id,ally,login,planete,galaxi,system,position,mail FROM matgraph_users WHERE id REGEXP '$nom_rechercher' ORDER by login ASC";
$res = mysql_query($req) or die('Erreur SQL! <br>'.$req.'<br>'.mysql_error());
$num = mysql_num_rows($res);
echo"<center>Vous avez obtenu $num résultat(s) à votre recherche :</center><br>";
echo"<table width=\"618\" border=\"0\" cellspacing=\"0\" cellpadding=\"2\" bordercolor=\"#000000\" style=\"font-family:trebuchet ms,sans-serif; font-size: 9pt ;\" align=\"center\">
  <tr style =\"background-color:#222222;\">
  <td align=\"center\"><b>ID : </b></td>
    <td align=\"center\" height=\"40\"><b>Nom : </b></td>
    <td align=\"center\"><b>Planète mère : </b></td>
	<td align=\"center\"><b>Email : </b></td>
	<td align=\"center\" width=\"100\"><b>Message : </b></td>
  </tr>";
if ( $num > 0 ) {
$i=1;
  While ( $row = mysql_fetch_array($res) ) {
$ally =""; 
$sql21 = "SELECT tag FROM matgraph_ally WHERE id='$row[ally]'";
$res21 = mysql_query($sql21)or die('erreur sql<br>'.$sql21.'<br>'.mysql_error());
$num21 = mysql_num_rows($res21);
if ($num21 > 0 AND $row[ally] !== "no") {
  While ( $row21 = mysql_fetch_array($res21) ) {
$ally ="$row21[tag]";
}}
$plan1 = "";
if (!empty($ally) )
  $plan1.="<font color=\"FF9933\">[$ally]</font>";
$lire = "lire";
$idform = $lire.$i;
$idform2 = $row[galaxi].$i;
echo"<tr";
// gère le quadrillage du tableau
			if (($i/2) == ceil($i/2))
			{
				echo' style ="background-color:#111111;"' ;
			}
	echo"><td align=\"center\">$row[id]</td>
	<form name=\"$idform\" id=\"$idform\" method=\"post\" action=\"ally/index.php\" target=\"_blank\" width=\"618\">
	<input type=\"hidden\" name=\"id\" value=\"$row[ally]\">
    <td align=\"center\"><a href=\"#\" target=\"_parent\" Onclick=\"document.getElementById('$idform').submit()\">$plan1</a> <a href='#' onclick=\"aff_div('$row[id]');\">$row[login]</a></td></form>
    <td align=\"center\">$row[planete] [$row[galaxi]:$row[system]:$row[position]]</td>
	<td align=\"center\">$row[mail]</td>
	<form name=\"$idform2\" method=\"post\" action=\"../mp_envoi.php\" target=\"_blank\">  
  <input name=\"idreceveur\" type=\"hidden\" value=\"$row[id]\">
  <input name=\"loginreceveur\" type=\"hidden\" value=\"$row[login]\">
  <input name=\"galaxi\" type=\"hidden\" value=\"$row[galaxi]\">
  <input name=\"system\" type=\"hidden\" value=\"$row[system]\">
  <input name=\"position\" type=\"hidden\" value=\"$row[position]\">
  <td width=\"100\" align=\"center\"><div align=\"center\"><input type=\"image\" src=\"../imgs/msg.gif\" Style=\"border:0px solid #7E7E7E;\"></div></td></form>
  </tr><tr style=\"empty-cell:hide;\"><td colspan=\"6\" align=\"center\">";
  	info_compte($row[id]);
	echo "</td></tr>";
$i++;  
}}
  
echo"</table>";
}

if($type == "planete") {
echo"$form";
$req = "SELECT id,idjoueur,ally,login,planete,galaxi,system,position,mail FROM matgraph_users WHERE planete REGEXP '$nom_rechercher' ORDER by login ASC";
$res = mysql_query($req) or die('Erreur SQL! <br>'.$req.'<br>'.mysql_error());
$num = mysql_num_rows($res);
echo"<center>Vous avez obtenu $num résultat(s) à votre recherche :</center><br>";
echo"<table width=\"618\" border=\"0\" cellspacing=\"0\" cellpadding=\"2\" bordercolor=\"#000000\" style=\"font-family:trebuchet ms,sans-serif; font-size: 9pt ;\" align=\"center\">
  <tr style =\"background-color:#222222;\">
  <td align=\"center\"><b>ID : </b></td>
      <td align=\"center\"><b>Planète : </b></td>
	  <td align=\"center\"><b>Email : </b></td>
    <td align=\"center\" height=\"40\"><b>Nom : </b></td>
	<td align=\"center\" width=\"100\"><b>Message : </b></td>
  </tr>";
if ( $num > 0 ) {
$i=1;
  While ( $row = mysql_fetch_array($res) ) {
  
$sql22 = "SELECT ally FROM matgraph_users WHERE id='$row[idjoueur]'";
$res22 = mysql_query($sql22)or die('erreur sql<br>'.$sql22.'<br>'.mysql_error());
$row22 = mysql_fetch_array($res22);
$ally =""; 
$sql21 = "SELECT tag FROM matgraph_ally WHERE id='$row22[ally]'";
$res21 = mysql_query($sql21)or die('erreur sql<br>'.$sql21.'<br>'.mysql_error());
$num21 = mysql_num_rows($res21);
if ($num21 > 0 AND $row22[ally] !== "no") {
  While ( $row21 = mysql_fetch_array($res21) ) {
$ally ="$row21[tag]";
}}
$plan1 = "";
if (!empty($ally) )
  $plan1.="<font color=\"FF9933\">[$ally]</font>";
$lire = "lire";
$idform = $lire.$i;
$idform2 = $row[galaxi].$i;
echo"<tr";
// gère le quadrillage du tableau
			if (($i/2) == ceil($i/2))
			{
				echo' style ="background-color:#111111;"' ;
			}
	echo"><td align=\"center\">$row[id]</td>
	<td align=\"center\">$row[planete] [$row[galaxi]:$row[system]:$row[position]]</td>
	<td align=\"center\">$row[mail]</td>
	<form name=\"$idform\" id=\"$idform\" method=\"post\" action=\"ally/index.php\" target=\"_blank\" width=\"618\">
	<input type=\"hidden\" name=\"id\" value=\"$row[ally]\">
    <td align=\"center\"><a href=\"#\" target=\"_parent\" Onclick=\"document.getElementById('$idform').submit()\">$plan1</a><a href='#' onclick=\"aff_div('$row[id]');\">$row[login]</a></td></form>
   <form name=\"$idform2\" method=\"post\" action=\"../mp_envoi.php\" target=\"_parent\">  
  <input name=\"idreceveur\" type=\"hidden\" value=\"$row[id]\">
  <input name=\"loginreceveur\" type=\"hidden\" value=\"$row[login]\">
  <input name=\"galaxi\" type=\"hidden\" value=\"$row[galaxi]\">
  <input name=\"system\" type=\"hidden\" value=\"$row[system]\">
  <input name=\"position\" type=\"hidden\" value=\"$row[position]\">
  <td width=\"100\" align=\"center\"><div align=\"center\"><input type=\"image\" src=\"../imgs/msg.gif\" Style=\"border:0px solid #7E7E7E;\"></div></td></form>
  </tr><tr style=\"empty-cell:hide;\"><td colspan=\"6\" align=\"center\">";
  	info_compte($row[id]);
	echo "</td></tr>";
$i++;  
}}
  
echo"</table>";
}

if($type == "ally") {
echo"$form";
$req = "SELECT id,tag,nom,pts_ally FROM matgraph_ally WHERE nom REGEXP '$nom_rechercher' ORDER by nom ASC";
$res = mysql_query($req) or die('Erreur SQL! <br>'.$req.'<br>'.mysql_error());
$num = mysql_num_rows($res);
echo"<center>Vous avez obtenu $num résultat(s) à votre recherche :</center><br>";
echo"<table width=\"618\" border=\"0\" cellspacing=\"0\" cellpadding=\"2\" bordercolor=\"#000000\" style=\"font-family:trebuchet ms,sans-serif; font-size: 9pt ;\" align=\"center\">
  <tr style =\"background-color:#222222;\">
  <td align=\"center\"><b>ID : </b></td>
      <td align=\"center\"><b>Nom : </b></td>
    <td align=\"center\" height=\"40\"><b>Tag : </b></td>
	<td align=\"center\"><b>Nombres de membres : </b></td>
	<td align=\"center\"><b>Nombres de points : </b></td>
  </tr>";
if ( $num > 0 ) {
$i=1;
  While ( $row = mysql_fetch_array($res) ) {

$pts = number_format($row[pts_ally] / 1000, 0, ',', ' ');

$req33 = "SELECT id FROM matgraph_users WHERE ally='$row[id]'";
$res33 = mysql_query($req33) or die('Erreur SQL! <br>'.$req33.'<br>'.mysql_error());
$num33 = mysql_num_rows($res33);

$ally =""; 
$sql21 = "SELECT tag FROM matgraph_ally WHERE id='$row[id]'";
$res21 = mysql_query($sql21)or die('erreur sql<br>'.$sql21.'<br>'.mysql_error());
$num21 = mysql_num_rows($res21);
if ($num21 > 0 AND $row[ally] !== "no") {
  While ( $row21 = mysql_fetch_array($res21) ) {
$ally ="$row21[tag]";
}}
$plan1 = "";
if (!empty($ally) )
  $plan1.="<font color=\"FF9933\">[$ally]</font>";
$lire = "lire";
$idform = $lire.$i;

echo"<tr";
// gère le quadrillage du tableau
			if (($i/2) == ceil($i/2))
			{
				echo' style ="background-color:#111111;"' ;
			}
	echo"><td align=\"center\">$row[id]</td>
	<td align=\"center\">$row[nom]</td>
	<form name=\"$idform\" id=\"$idform\" method=\"post\" action=\"ally/index.php\" target=\"_blank\" width=\"618\">
	<input type=\"hidden\" name=\"id\" value=\"$row[id]\">
    <td align=\"center\"><a href=\"#\" target=\"_parent\" Onclick=\"document.getElementById('$idform').submit()\">$plan1</a></td></form>
	<td align=\"center\">$num33</td>
	<td align=\"center\">$pts</td>

  </tr>";
$i++;  
}}
  
echo"</table>";
}

if($type == "tag") {
echo"$form";
$req = "SELECT id,tag,nom,pts_ally FROM matgraph_ally WHERE tag REGEXP '$nom_rechercher' ORDER by tag ASC";
$res = mysql_query($req) or die('Erreur SQL! <br>'.$req.'<br>'.mysql_error());
$num = mysql_num_rows($res);
echo"<center>Vous avez obtenu $num résultat(s) à votre recherche :</center><br>";
echo"<table width=\"618\" border=\"0\" cellspacing=\"0\" cellpadding=\"2\" bordercolor=\"#000000\" style=\"font-family:trebuchet ms,sans-serif; font-size: 9pt ;\" align=\"center\">
  <tr style =\"background-color:#222222;\">
  <td align=\"center\"><b>ID : </b></td>
  	<td align=\"center\" height=\"40\"><b>Tag : </b></td>
    <td align=\"center\"><b>Nom : </b></td>
    <td align=\"center\"><b>Nombres de membres : </b></td>
	<td align=\"center\"><b>Nombres de points : </b></td>
  </tr>";
if ( $num > 0 ) {
$i=1;
  While ( $row = mysql_fetch_array($res) ) {

$pts = number_format($row[pts_ally] / 1000, 0, ',', ' ');

$req33 = "SELECT id FROM matgraph_users WHERE ally='$row[id]'";
$res33 = mysql_query($req33) or die('Erreur SQL! <br>'.$req33.'<br>'.mysql_error());
$num33 = mysql_num_rows($res33);

$ally =""; 
$sql21 = "SELECT tag FROM matgraph_ally WHERE id='$row[id]'";
$res21 = mysql_query($sql21)or die('erreur sql<br>'.$sql21.'<br>'.mysql_error());
$num21 = mysql_num_rows($res21);
if ($num21 > 0 AND $row[ally] !== "no") {
  While ( $row21 = mysql_fetch_array($res21) ) {
$ally ="$row21[tag]";
}}
$plan1 = "";
if (!empty($ally) )
  $plan1.="<font color=\"FF9933\">[$ally]</font>";
$lire = "lire";
$idform = $lire.$i;

echo"<tr";
// gère le quadrillage du tableau
			if (($i/2) == ceil($i/2))
			{
				echo' style ="background-color:#111111;"' ;
			}
	echo"><td align=\"center\">$row[id]</td>
	<form name=\"$idform\" id=\"$idform\" method=\"post\" action=\"ally/index.php\" target=\"_blank\" width=\"618\">
	<input type=\"hidden\" name=\"id\" value=\"$row[id]\">
    <td align=\"center\"><a href=\"#\" target=\"_parent\" Onclick=\"document.getElementById('$idform').submit()\">$plan1</a></td></form>
	<td align=\"center\">$row[nom]</td>
	<td align=\"center\">$num33</td>
	<td align=\"center\">$pts</td>

  </tr>";
$i++;  
}}
  
echo"</table>";
}
if($type == "email") {
echo"$form";
$req = "SELECT id,date,ally,login,planete,galaxi,system,position,mail FROM matgraph_users WHERE id=idjoueur AND mail LIKE '%$nom_rechercher%' ORDER by login ASC";
$res = mysql_query($req) or die('Erreur SQL! <br>'.$req.'<br>'.mysql_error());
$num = mysql_num_rows($res);
echo"<center>Vous avez obtenu $num résultat(s) à votre recherche :</center><br>";
echo"<table width=\"618\" border=\"0\" cellspacing=\"0\" cellpadding=\"2\" bordercolor=\"#000000\" style=\"font-family:trebuchet ms,sans-serif; font-size: 9pt ;\" align=\"center\">
  <tr style =\"background-color:#222222; align:center;\">
  <td align=\"center\"><b>ID : </b></td>
    <td align=\"center\" height=\"40\"><b>Nom : </b></td>
    <td align=\"center\"><b>Planète mère : </b></td>
	<td align=\"center\"><b>Email : </b></td>
	<td align=\"center\"><b>Dernière connection : </b></td>
	<td align=\"center\" width=\"100\"><b>Message : </b></td>
  </tr>";
if ( $num > 0 ) {
$i=1;
  While ( $row = mysql_fetch_array($res) ) {
$ally =""; 
$sql21 = "SELECT tag FROM matgraph_ally WHERE id='$row[ally]'";
$res21 = mysql_query($sql21)or die('erreur sql<br>'.$sql21.'<br>'.mysql_error());
$num21 = mysql_num_rows($res21);
if ($num21 > 0 AND $row[ally] !== "no") {
  While ( $row21 = mysql_fetch_array($res21) ) {
$ally ="$row21[tag]";
}}
$plan1 = "";
if (!empty($ally) )
  $plan1.="<font color=\"FF9933\">[$ally]</font>";
$lire = "lire";
$idform = $lire.$i;
$idform2 = $row[galaxi].$i;
echo"<tr";
// gère le quadrillage du tableau
			if (($i/2) == ceil($i/2))
			{
				echo' style ="background-color:#111111;"' ;
			}
	echo"><td align=\"center\">$row[id]</td>
	<form name=\"$idform\" id=\"$idform\" method=\"post\" action=\"ally/index.php\" target=\"_blank\" width=\"618\">
	<input type=\"hidden\" name=\"id\" value=\"$row[ally]\">
    <td align=\"center\"><a href=\"#\" target=\"_parent\" Onclick=\"document.getElementById('$idform').submit()\">$plan1</a> <a href='#' onclick=\"aff_div('$row[id]');\">$row[login]</a>
	</td></form>
    <td align=\"center\">$row[planete] [$row[galaxi]:$row[system]:$row[position]]</td>
	<td align=\"center\">$row[mail]</td>
	<td align=\"center\">$row[date]</td>
	<form name=\"$idform2\" method=\"post\" action=\"../mp_envoi.php\" target=\"_blank\">  
  <input name=\"idreceveur\" type=\"hidden\" value=\"$row[id]\">
  <input name=\"loginreceveur\" type=\"hidden\" value=\"$row[login]\">
  <input name=\"galaxi\" type=\"hidden\" value=\"$row[galaxi]\">
  <input name=\"system\" type=\"hidden\" value=\"$row[system]\">
  <input name=\"position\" type=\"hidden\" value=\"$row[position]\">
  <td width=\"100\" align=\"center\"><div align=\"center\"><input type=\"image\" src=\"../imgs/msg.gif\" Style=\"border:0px solid #7E7E7E;\"></div></td></form>
  </tr><tr style=\"empty-cell:hide;\"><td colspan=\"6\" align=\"center\">";
  	info_compte($row[id]);
	echo "</td></tr>";
$i++;  
}}
  
echo"
</table>";
}
echo "
<br><br>";
?>
