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

$sujet = htmlentities ($_POST["sujet"]);
$receveur = $_POST["receveur"];
$planete_receveur = $_POST["planete_receveur"];
$texte = htmlentities ($_POST["message"]);

$bbcode= array (
"/\[b\](.+?)\[\/b\]/si",
"/\[i\](.+?)\[\/i\]/si",
"/\[u\](.+?)\[\/u\]/si",
"/\[url=(.+?)\](.+?)\[\/url\]/si",
"/\[img\](.+?)\[\/img\]/si",

);
$htmlcode= array (
"<b>$1</b>",
"<i>$1</i>",
"<u>$1</u>",
"<a href='$1'>$2</a>",
"<img src='$1'>"
);
$texte=preg_replace($bbcode,$htmlcode,$texte);

$texte=preg_replace('!\[color=(red|green|blue)\](.+)\[/color\]!isU', "<span style='color:$1'>$2</span>", $texte); //couleur
$texte=preg_replace('!\[align=(left|center|right)\](.+)\[/align\]!isU', "<div align='$1'>$2</div>", $texte); //aligner

$texte=nl2br($texte);

$requete = 'INSERT INTO matgraph_mp VALUES ("","non",now(),"'.$idlogin.'","'.$receveur.'","'.$planete_receveur.'","'.$planete.'","'.$sujet.'","'.$texte.'")';
$resultat = db_mysql_Query($requete)or die('erreur sql<br>'.$requete.'<br>'.mysql_error());
echo '<script language="javascript" type="text/javascript">
<!--
window.location.replace("mp_lire.php");
-->
</script>';
  
?>