<?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\">
<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>";


$sql_dc = "SELECT ip FROM matgraph_ip GROUP BY ip HAVING Count(*) > 1 ORDER BY date_connexion DESC";
$res_dc = mysql_query($sql_dc)or die('erreur sql<br>'.$sql_dc.'<br>'.mysql_error());

while( $row_dc = mysql_fetch_array($res_dc) ) {

	//
	$sql_ip = "SELECT * FROM matgraph_ip WHERE ip = '$row_dc[ip]'";
	$res_ip = mysql_query($sql_ip)or die('erreur sql<br>'.$sql_ip.'<br>'.mysql_error());

	while( $row_ip = mysql_fetch_array($res_ip) ) {

		//login
		$sql_info = "SELECT login,mail FROM matgraph_users WHERE id = $row_ip[idlogin]";
		$res_info = mysql_query($sql_info)or die('erreur sql<br>'.$sql_info.'<br>'.mysql_error());
		$row_info = mysql_fetch_array($res_info);
		
		//ban
		$req_ban = "SELECT * FROM matgraph_banni WHERE login = '".addslashes($row_info[login])."'";
		$res_ban = mysql_query($req_ban) or die('Erreur SQL! <br>'.$req_ban.'<br>'.mysql_error());
		$num_ban = mysql_num_rows($res_ban);

		if ( $num_ban == 0 )
		{
			//autoriser
			$req_autoriser = "SELECT * FROM matgraph_autoriser WHERE joueur1 = '".addslashes($row_info[login])."' OR joueur2 = '".addslashes($row_info[login])."'";
			$res_autoriser = mysql_query($req_autoriser) or die('Erreur SQL! <br>'.$req_autoriser.'<br>'.mysql_error());
			$num_autoriser = mysql_num_rows($res_autoriser);
	
			if ( $num_autoriser > 0 )
			{
				While ( $row_autoriser = mysql_fetch_array($res_autoriser) )
				{
					echo "<font color=\"00CC00\">Connection autorisée entre : $row_autoriser[joueur1] et $row_autoriser[joueur2]</font><br>";
				}
			}
				$sql_info2 = "SELECT date FROM matgraph_users WHERE idjoueur = $row_ip[idlogin] ORDER BY date DESC LIMIT 1";
				$res_info2 = mysql_query($sql_info2)or die('erreur sql<br>'.$sql_info2.'<br>'.mysql_error());
				$row_info2 = mysql_fetch_array($res_info2);
		
				echo "Ip : $row_dc[ip]<br>Joueur : $row_info[login] ($row_info[mail])<br>";
				echo "Browser : $row_ip[browser]<br>Hote : $row_ip[hote]<br>";
				echo "Date connexion : $row_ip[date_connexion] Dernier refresh : $row_info2[date]";
				echo "<br>Ancien login : $row_ip[alogin]<br>Md5 de ce login : ".md5($row_info[login])."<br><br>";
		}
	}
}



?>