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

echo"
<BODY TEXT=\"#ffffff\">
<BODY LINK=\"#ffffff\">
<BODY VLINK=\"#ffffff\">
<BODY ALINK=\"#ffffff\">
<body bgcolor=\"#000000\">";

$req = "SELECT * FROM matgraph_users WHERE login='".$_POST[login]."' AND id=idjoueur limit 1";
$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) ) {
		
		echo"<table width=\"400\" border=\"1\" bgcolor=\"#000000\">";
		echo"<tr>
		    <td>Joueur1</td>
		    <td>Joueur2</td>
		    <td>Ressource1</td>
		    <td>Ressource2</td>
		    <td>Envoi1</td>
		    <td>Envoi2</td>
		    <td>Alerte multi</td>
		    <td>Connection multi</td>
		    <td>Nbre ban</td>
		    <td>Nbre passer</td>
		    <td>Lien multi</td>
		  </tr>";
		  
		$req2 = "SELECT * FROM matgraph_multi WHERE joueur1 = $row[id] OR joueur2 = $row[id]";
		$res2 = mysql_query($req2) or die('Erreur SQL! <br>'.$req2.'<br>'.mysql_error());
		$num2 = mysql_num_rows($res2);
		if ( $num2 > 0 ) {
			While ( $row2 = mysql_fetch_array($res2) ) {

				
				$req3 = "SELECT pts,login FROM matgraph_users WHERE id=$row2[joueur1]";
				$res3 = mysql_query($req3) or die('Erreur SQL! <br>'.$req3.'<br>'.mysql_error());
				$row3 = mysql_fetch_array($res3);
				
				$req4 = "SELECT pts,login FROM matgraph_users WHERE id=$row2[joueur2]";
				$res4 = mysql_query($req4) or die('Erreur SQL! <br>'.$req4.'<br>'.mysql_error());
				$row4 = mysql_fetch_array($res4);

				//autoriser
					$req_autoriser = "SELECT * FROM matgraph_autoriser WHERE joueur1 = '".addslashes($row3[login])."' AND joueur2 = '".addslashes($row4[login])."'";
					$req_autoriser2 = "SELECT * FROM matgraph_autoriser WHERE joueur1 = '".addslashes($row4[login])."' AND joueur2 = '".addslashes($row3[login])."'";
					$res_autoriser = mysql_query($req_autoriser) or die('Erreur SQL! <br>'.$req_autoriser.'<br>'.mysql_error());
					$res_autoriser2 = mysql_query($req_autoriser2) or die('Erreur SQL! <br>'.$req_autoriser2.'<br>'.mysql_error());
					$num_autoriser = mysql_num_rows($res_autoriser) + mysql_num_rows($res_autoriser2) ;

		
				UNSET ($push);
				
				if(($row2[ressources1]*10 < $row2[ressources2]) &&  $row3[pts] > $row4[pts] )
				{
					$push = "choper";
				}
				if(($row2[ressources1]*10 > $row2[ressources2]) &&  $row3[pts] < $row4[pts] )
				{
					$push = "choper";
				}
		
				if($num_autoriser > 0)
				{
					echo"<tr>
					<td>"; if($push == "choper") { echo"<font color=\"CC0099\">PUSH : </font>";} echo"<font color=\"00CC00\">$row3[login]</font></td>
					<td><font color=\"00CC00\">$row4[login]</font></td>
					<td><font color=\"FF0000\">$row2[ressources1]</font></td>
					<td><font color=\"FF0000\">$row2[ressources2]</font></td>
					<td>$row2[envoi1]</td>
					<td>$row2[envoi2]</td>
					<td>$row2[alerte_multi]</td>
					<td>$row2[connection_multi]</td>
					<td>$row2[nbre_ban]</td>
					<td>$row2[nbre_passer]</td>
					<td>$row2[lien_multi]</td>
					</tr>";
				}
				else
				{
					echo"<tr>
					<td>"; if($push == "choper") { echo"<font color=\"CC0099\">PUSH : </font>";} echo"$row3[login]</td>
					<td>$row4[login]</td>
					<td>$row2[ressources1]</td>
					<td>$row2[ressources2]</td>
					<td>$row2[envoi1]</td>
					<td>$row2[envoi2]</td>
					<td>$row2[alerte_multi]</td>
					<td>$row2[connection_multi]</td>
					<td>$row2[nbre_ban]</td>
					<td>$row2[nbre_passer]</td>
					<td>$row2[lien_multi]</td>
					</tr>";
				}
			}
		}
	}
}


?>