Versie Derk
- Code: Selecteer alles
function add_bbcode($text)
{
$text = stripslashes($text);
$text = htmlspecialchars($text);
// Font dingen:
$text = preg_replace("/\[b\](.+?)\[\/b\]/is",'<b>\1</b>', $text);
$text = preg_replace("/\[u\](.+?)\[\/u\]/is",'<u>\1</u>', $text);
$text = preg_replace("/\[i\](.+?)\[\/i\]/is",'<i>\1</i>', $text);
$text = preg_replace("/\[s\](.+?)\[\/s\]/is",'<s>\1</s>', $text);
$text = preg_replace("/\[img\](.+?)\[\/img\]/is",'<img src="\1" />', $text);
$text = preg_replace("~(\s|^)((?:https?|ftp|irc)://[-a-z0-9+&@#/%?=\~_|!:,.;]*[-a-z0-9+&@#/%=\~_|])\b~si",'\1<a href="\2" target="_blank">\2</a>', $text);
$text = preg_replace("~(\s|^)((?:[a-z][-a-z0-9+&@#/%?=\~_|!:,.;]+)\.(?:[a-z]{2,6}))\b~si",'\1<a href="http://\2" target="_blank">\2</a>', $text);
$text = preg_replace("/\[url=(.+?)\](.+?)\[\/url\]/is",'<a href=\1>\2</a>', $text);
$text = preg_replace("/\[red\](.+?)\[\/red\]/is",'<font color=red>\1</font>', $text);
$text = preg_replace("/\[blue\](.+?)\[\/blue\]/is",'<font color=blue>\1</font>', $text);
$text = preg_replace("/\[green\](.+?)\[\/green\]/is",'<font color=green>\1</font>', $text);
$text = preg_replace("/\[yellow\](.+?)\[\/yellow\]/is",'<font color=yellow>\1</font>', $text);
$text = preg_replace("/\[orange\](.+?)\[\/orange\]/is",'<font color=orange>\1</font>', $text);
return $text;
}
Versie Stef
- Code: Selecteer alles
// BBcode in verwerken:
function add_bbcode($text)
{
$text = stripslashes($text);
$text = htmlsp[code=php]function add_bbcode($text)
{
$text = stripslashes($text);
$text = htmlspecialchars($text);
// Font dingen:
$text = preg_replace("/\[b\](.+?)\[\/b\]/is",'<b>\1</b>', $text);
$text = preg_replace("/\[u\](.+?)\[\/u\]/is",'<u>\1</u>', $text);
$text = preg_replace("/\[i\](.+?)\[\/i\]/is",'<i>\1</i>', $text);
$text = preg_replace("/\[s\](.+?)\[\/s\]/is",'<s>\1</s>', $text);
$text = preg_replace("/\[img\](.+?)\[\/img\]/is",'<img src="\1" />', $text);
$text = preg_replace("~(\s|^)((?:https?|ftp|irc)://[-a-z0-9+&@#/%?=\~_|!:,.;]*[-a-z0-9+&@#/%=\~_|])\b~si",'\1<a href="\2" target="_blank">\2</a>', $text);
$text = preg_replace("~(\s|^)((?:[a-z][-a-z0-9+&@#/%?=\~_|!:,.;]+)\.(?:[a-z]{2,6}))\b~si",'\1<a href="http://\2" target="_blank">\2</a>', $text);
$text = preg_replace("/\[url=(.+?)\](.+?)\[\/url\]/is",'<a href=\1>\2</a>', $text);
$text = preg_replace("/\[red\](.+?)\[\/red\]/is",'<font color=red>\1</font>', $text);
$text = preg_replace("/\[blue\](.+?)\[\/blue\]/is",'<font color=blue>\1</font>', $text);
$text = preg_replace("/\[green\](.+?)\[\/green\]/is",'<font color=green>\1</font>', $text);
$text = preg_replace("/\[yellow\](.+?)\[\/yellow\]/is",'<font color=yellow>\1</font>', $text);
$text = preg_replace("/\[orange\](.+?)\[\/orange\]/is",'<font color=orange>\1</font>', $text);
return $text;
}