1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
|
function formatage_texte($message) {
$selection_code=mysql_query("SELECT * FROM smiley");
$selection_img=mysql_query("SELECT * FROM smiley");
$non_formate = array(
'/([\w]+:\/\/[\w-?&;#~=\.\/\@]+[\w\/])/i',
'`\[italique\](.+)\[/italique\]`isU',
'`\[gras\](.+)\[/gras\]`isU',
'`\[souligne\](.+)\[/souligne\]`isU',
'`\[barre\](.+)\[/barre\]`isU',
'`\[lien\](.+)\[/lien\]`isU',
'`\[lien url="(.+)"\](.+)\[/lien\]`isU',
'`\[image\](.+)\[/image\]`isU',
'`\[center\](.+)\[/center\]`isU',
'`\[citation\](.+)\[/citation\]`isU',
'`\[citation nom="(.+)"\](.+)\[/citation\]`isU',
'`\[citation lien="(.+)"\](.+)\[/citation\]`isU',
'`\[taille valeur="(.+)"\](.+)\[/taille\]`isU',
'`\[position valeur="(.+)"\](.+)\[/position\]`isU',
'`\[couleur valeur="(.+)"\](.+)\[/couleur\]`isU',
);
while($recap_code = mysql_fetch_assoc($selection_code)) {
$non_formate[] = "`$recap_code[ code ]`isU";
}
$formate = array(
'<a href="$1" target="_blank">$1</a>',
'<em>$1</em>',
'<strong>$1</strong>',
'<u>$1</u>',
'<del>$1</del>',
'<a href="$1" target="_blank">$1</a>',
'<a href="$1" target="_blank">$2</a>',
'<img src="$1" alt="Image utilisateur" />',
'<center>$1</center>',
'<br /><span class="citation">Citation</span><div class="citation2">$1</div>',
'<br /><span class="citation">Citation : $1</span><div class="citation2">$2</div>',
'<br /><span class="citation"><a href="$1">Citation</a></span><div class="citation2">$2</div>',
'<font size="$1">$2</font>',
'<div style="float:$1;">$2</div>',
'<font color="$1">$2</font>',
);
while($recap_img = mysql_fetch_assoc($selection_img)) {
$formate[] = "<img src='img/smiley/$recap_img[img]' />";
}
$message = htmlspecialchars($message);
$message = preg_replace($non_formate, $formate, $message);
$message = nl2br($message);
return $message;
} |
Partager