<?	
include ('config.php');



$datefin =  strftime("%Y-%m-%d %H:%M:%S", time() - 432000 );


// MP :
$sql5 = "SELECT * FROM matgraph_mp WHERE date < '$datefin'";
$res5 = mysql_query($sql5)or die('erreur sql<br>'.$sql5.'<br>'.mysql_error());
if ($num5 >0) {
  While ( $row5 = mysql_fetch_array($res5) ) {

		$sql4 = "INSERT INTO `matgraph_mp_log` ( `id` , `lu` , `date` , `envoyeur` , `receveur` , `planete_receveur` , `planete_envoyeur` , `sujet` , `message` )
		VALUES (
		'$row5[id]', '$row5[lu]' , '$row5[date]' , '$row5[envoyeur]' , '$row5[receveur]' , '$row5[planete_receveur]' , '$row5[planete_envoyeur]' , '".addslashes($row5[sujet])."' , '".addslashes($row5[message])."'
		)";
		
		$res4 = mysql_query($sql4)or die('erreur sql<br>'.$sql4.'<br>'.mysql_error());
		
	}
}

$sql4 = "DELETE FROM matgraph_mp WHERE date < '$datefin'";
$res4 = mysql_query($sql4)or die('erreur sql<br>'.$sql4.'<br>'.mysql_error());


// msg ally :
$sql4 = "DELETE FROM matgraph_msgally WHERE date < '$datefin'";
$res4 = mysql_query($sql4)or die('erreur sql<br>'.$sql4.'<br>'.mysql_error());


// bataille :
$sql4 = "DELETE FROM matgraph_bataille WHERE date < '$datefin'";
$res4 = mysql_query($sql4)or die('erreur sql<br>'.$sql4.'<br>'.mysql_error());


//espio :
$sql4 = "DELETE FROM matgraph_espio1 WHERE date < '$datefin'";
$res4 = mysql_query($sql4)or die('erreur sql<br>'.$sql4.'<br>'.mysql_error());


//Contre espio :
$sql4 = "DELETE FROM matgraph_contreespio WHERE date < '$datefin'";
$res4 = mysql_query($sql4)or die('erreur sql<br>'.$sql4.'<br>'.mysql_error());


//Autre msg :

$sql5 = "SELECT * FROM matgraph_msg WHERE date < '$datefin'";
$res5 = mysql_query($sql5)or die('erreur sql<br>'.$sql5.'<br>'.mysql_error());
if ($num5 >0) {
  While ( $row5 = mysql_fetch_array($res5) ) {

		$sql4 = "INSERT INTO `matgraph_msg_log` ( `id` , `date` , `lu` , `receveur` , `sujet` , `msg` )
		VALUES (
		'$row5[id]', '$row5[date]', '$row5[lu]', '$row5[receveur]', '".addslashes($row5[sujet])."', '".addslashes($row5[msg])."'
		)";
		
		$res4 = mysql_query($sql4)or die('erreur sql<br>'.$sql4.'<br>'.mysql_error());
		
	}
}

$sql4 = "DELETE FROM matgraph_msg WHERE date < '$datefin'";
$res4 = mysql_query($sql4)or die('erreur sql<br>'.$sql4.'<br>'.mysql_error());

// vide codes allopass
$sql4 = "DELETE FROM matgraph_codes2";
$res4 = mysql_query($sql4)or die('erreur sql<br>'.$sql4.'<br>'.mysql_error());

$sql4 = "DELETE FROM matgraph_codes2_log_achat";
$res4 = mysql_query($sql4)or die('erreur sql<br>'.$sql4.'<br>'.mysql_error());


echo "<br><div align=\"center\"> Suppression effectuée";
?>