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
| <?php
function BBtags($t) {
$t = preg_replace("!\[(/?[bius])\]!mi","<$1>",$t);
$t = preg_replace("!\[url\](.+)\[/url\]!Ui","<a href=\"$1\" target=\"_blank\">$1</a>",$t);
$t = preg_replace("!\[mail\](.+)\[/mail\]!Ui","<a href=\"mailto:$1\" target=\"_blank\">$1</a>",$t);
$t = preg_replace("!\[url=([^\]]+)\](.+)\[/url\]!Ui","<a href=\"$1\" target=\"_blank\">$2</a>",$t);
$t = preg_replace("!\[img\](.+)\[/img\]!Ui","<img src=\"$1\" alt=\"\" border=\"0\">",$t);
$t = preg_replace("!\[color=([^\]]+)\]!mi","<font style=\"color: $1;\">",$t);
$t = preg_replace("!\[size=([^\]]+)\]!mi","<font style=\"font-size: $1px;\">",$t);
$t = preg_replace("!\[/(?:color|size)\]!i","</font>",$t);
$t = preg_replace("!\[list\](.+)\[/list\]!Umis","<ul type=\"square\">$1</ul>",$t);
$t = preg_replace("!\[li\](.+)\[/li\]!Umis","<li>$1</li>",$t);
$t = preg_replace("!\[center\](.+)\[/center\]!Umis","<div style=\"text-align:center\">$1</div>",$t);
$t = preg_replace("!\[left\](.+)\[/left\]!Ui","<div style=\"text-align:left\">$1</div>",$t);
$t = preg_replace("!\[right\](.+)\[/right\]!Ui","<div style=\"text-align:right\">$1</div>",$t);
$t = str_replace("[float=right]", "<div style=\"float:right;margin:10px;\">", $t);
$t = str_replace("[float=left]", "<div style=\"float:left;margin:10px;\">", $t);
$t = str_replace("[/float]", "</div>", $t);
$t = preg_replace("!\[quote=([^\]]+)\](.+)\[/quote\]!Ui","<table class=\"bb_quote_table\"><tr><td>  <b>Citation : $1</b></td></tr><tr><td class=\"bb_quote_text\">$2</td></tr></table>",$t);
$t = preg_replace("!\[code\](.+)\[/code\]!Umis","<table class=\"bb_code_table\"><tr><td>  <b>Code :</b></td></tr><tr><td class=\"bb_code_text\">$1</td></tr></table>",$t);
$t = str_replace("\n","<br />",$t);
$t = str_replace("\t"," ",$t);
return $t;
}
?> |
Partager