<?	
$datefin =  strftime("%Y-%m-%d", time());

// MP :
$sqlxx = "SELECT idlogin FROM matgraph_suppression WHERE date < '".$datefin."' ";
$resxx = mysql_query($sqlxx)or die('erreur sql<br>'.$sqlxx.'<br>'.mysql_error());
$numxx = mysql_num_rows($resxx);
if ($numxx > 0) {
  While ( $rowxx = mysql_fetch_array($resxx) ) {
  	$id=$rowxx[idlogin];

	$req = "SELECT id FROM matgraph_users WHERE idjoueur = $id ORDER by id ASC";
	$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) ) {
	  
	$sql4 = "DELETE FROM matgraph_users WHERE id = $row[id]";
	$res4 = mysql_query($sql4)or die('erreur sql<br>'.$sql4.'<br>'.mysql_error());
	
	}}
	
	$req = "SELECT id FROM matgraph_vaisseaux WHERE iduser = $id ORDER by id ASC";
	$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) ) {
	  
	$sql4 = "DELETE FROM matgraph_vaisseaux WHERE iduser = $row[id]";
	$res4 = mysql_query($sql4)or die('erreur sql<br>'.$sql4.'<br>'.mysql_error());
	
	}}
	
	$req = "SELECT id FROM matgraph_ally_recrut WHERE idjoueur = $id ORDER by id ASC";
	$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) ) {
	  
	$sql4 = "DELETE FROM matgraph_ally_recrut WHERE idjoueur = $row[id]";
	$res4 = mysql_query($sql4)or die('erreur sql<br>'.$sql4.'<br>'.mysql_error());
	
	}}
	
	$req = "SELECT id FROM matgraph_commerce WHERE joueur1 = $id ORDER by id ASC";
	$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) ) {
	  
	$sql4 = "DELETE FROM matgraph_commerce WHERE id = $row[id]";
	$res4 = mysql_query($sql4)or die('erreur sql<br>'.$sql4.'<br>'.mysql_error());
	
	}}
	
	$req = "SELECT id FROM matgraph_commerce WHERE joueur2 = $id ORDER by id ASC";
	$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) ) {
	  
	$sql4 = "DELETE FROM matgraph_commerce WHERE id = $row[id]";
	$res4 = mysql_query($sql4)or die('erreur sql<br>'.$sql4.'<br>'.mysql_error());
	
	}}
	
	$req = "SELECT id FROM matgraph_bataille WHERE receveur = $id ORDER by id ASC";
	$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) ) {
	  
	$sql4 = "DELETE FROM matgraph_bataille WHERE id = $row[id]";
	$res4 = mysql_query($sql4)or die('erreur sql<br>'.$sql4.'<br>'.mysql_error());
	
	}}
	
	$req = "SELECT id FROM matgraph_contreespio WHERE receveur = $id ORDER by id ASC";
	$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) ) {
	  
	$sql4 = "DELETE FROM matgraph_contreespio WHERE id = $row[id]";
	$res4 = mysql_query($sql4)or die('erreur sql<br>'.$sql4.'<br>'.mysql_error());
	
	}}
	
	$req = "SELECT id FROM matgraph_espio1 WHERE receveur = $id ORDER by id ASC";
	$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) ) {
	  
	$sql4 = "DELETE FROM matgraph_espio1 WHERE id = $row[id]";
	$res4 = mysql_query($sql4)or die('erreur sql<br>'.$sql4.'<br>'.mysql_error());
	
	}}
	
	$req = "SELECT id FROM matgraph_espio2 WHERE idjoueur = $id OR idespionner = $id ORDER by id ASC";
	$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) ) {
	  
	$sql4 = "DELETE FROM matgraph_espio2 WHERE id = $row[id]";
	$res4 = mysql_query($sql4)or die('erreur sql<br>'.$sql4.'<br>'.mysql_error());
	
	}}
	
	$req = "SELECT id FROM matgraph_explorer WHERE receveur = $id OR envoyeur = $id ORDER by id ASC";
	$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) ) {
	  
	$sql4 = "DELETE FROM matgraph_explorer WHERE id = $row[id]";
	$res4 = mysql_query($sql4)or die('erreur sql<br>'.$sql4.'<br>'.mysql_error());
	
	}}
	
	$req = "SELECT id FROM matgraph_idjoueur WHERE idjoueur = $id ORDER by id ASC";
	$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) ) {
	  
	$sql4 = "DELETE FROM matgraph_idjoueur WHERE id = $row[id]";
	$res4 = mysql_query($sql4)or die('erreur sql<br>'.$sql4.'<br>'.mysql_error());
	
	}}
	
	$req = "SELECT id FROM matgraph_mp WHERE receveur = $id OR envoyeur = $id ORDER by id ASC";
	$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) ) {
	  
	$sql4 = "DELETE FROM matgraph_mp WHERE id = $row[id]";
	$res4 = mysql_query($sql4)or die('erreur sql<br>'.$sql4.'<br>'.mysql_error());
	
	}}
	
	$req = "SELECT id FROM matgraph_msg WHERE receveur = $id ORDER by id ASC";
	$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) ) {
	  
	$sql4 = "DELETE FROM matgraph_msg WHERE id = $row[id]";
	$res4 = mysql_query($sql4)or die('erreur sql<br>'.$sql4.'<br>'.mysql_error());
	
	}}
	
	$req = "SELECT id FROM matgraph_msgally WHERE receveur = $id ORDER by id ASC";
	$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) ) {
	  
	$sql4 = "DELETE FROM matgraph_msgally WHERE id = $row[id]";
	$res4 = mysql_query($sql4)or die('erreur sql<br>'.$sql4.'<br>'.mysql_error());
	
	}}
	
	$req = "SELECT id FROM matgraph_nbrevaisseaux WHERE user = $id ORDER by id ASC";
	$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) ) {
	  
	$sql4 = "DELETE FROM matgraph_nbrevaisseaux WHERE id = $row[id]";
	$res4 = mysql_query($sql4)or die('erreur sql<br>'.$sql4.'<br>'.mysql_error());
	
	}}
	
	$requete = "DELETE FROM matgraph_suppression WHERE idlogin=$id";
	$resultat = mysql_query($requete)or die('erreur sql<br>'.$requete.'<br>'.mysql_error());

}
}

?>