<?php
function bbcode($text)
{
$smilies = array(
":)" => "<img src=\").gif\" border=\"0\" alt=\"\" />", // :)
":D" => "<img src=\"D.gif\" border=\"0\" alt=\"\" />", // :D
":(" => "<img src=\"(.gif\" border=\"0\" alt=\"\" />", // :(
":'(" => "<img src=\"(2.gif\" border=\"0\" alt=\"\" />", // :'(
"xD" => "<img src=\"xd.gif\" border=\"0\" alt=\"\" />", // xD
":P" => "<img src=\"p.gif\" border=\"0\" alt=\"\" />", // :P
"-.-" => "<img src=\"-.gif\" border=\"0\" alt=\"\" />", // -.-
":S" => "<img src=\"s.gif\" border=\"0\" alt=\"\" />" // :S
);
$regexp = array(
"/\(.+)\[\/url\]/iU" => "<a href=\"http://$2\" target=\"_blank\">$3</a>", // [url=]
"/\[url\](http:\/\/)?(.+)\[\/url\]/iU" => "<a href=\"http://$2\" target=\"_blank\">$2</a>", //
"/\[img\](http:\/\/)?(.+)\[\/img\]/iU" => "<img src=\"http://$2\" border=\"0\" alt=\"\" />", //
"/\[email\]([a-z0-9\.-_]+@[a-z0-9]+\.[a-z0-9]+)\[\/email\]/iU" => "<a href=\"mailto:$1\">$1</a>", // [email][/email]
"/\[b\](.+)\[\/b\]/iU" => "<strong>$1</strong>", //
"/\[s\](.+)\[\/s\]/iU" => "<del>$1</del>", // [s][/s]
"/\[i\](.+)\[\/i\]/iU" => "<em>$1</em>", //
"/\[u\](.+)\[\/u\]/iU" => "<ins>$1</ins>", //
"/\[hr\]/iU" => "<hr />", // [hr]
"/\[quote\](.+)\[\/quote\]/iU" => "<p><strong>Citat:</strong> \"$1\"</p>", // [quote][/quote]
"/\[quote=(.+)\](.+)\[\/quote\]/iU" => "<p><strong>$1 skrev:</strong> \"$2\"</p>", // [quote=][/quote]
"/\[blink\](.+)\[\/blink\]/iU" => "<span style=\"text-decoration: blink;\">$1</span>", // [blink][/blink]
"/\[marquee\](.+)\[\/marquee\]/iU" => "<marquee>$1</marquee>", // [marquee][/marquee]
"/\[center\](.+)\[\/center\]/iU" => "<div style=\"text-align: center;\">$1</div>", //
"/\[right\](.+)\[\/right\]/iU" => "<div style=\"text-align: right;\">$1</div>", //
"/\[left\](.+)\[\/left\]/iU" => "<div style=\"text-align: left;\">$1</div>", //
"/\[color=darkred\](.+)\[\/color\]/iU" => "<span style=\"color: darkred;\">$1</span>",
"/\[color=red\](.+)\[\/color\]/iU" => "<span style=\"color: red;\">$1</span>",
"/\[color=orange\](.+)\[\/color\]/iU" => "<span style=\"color: orange;\">$1</span>",
"/\[color=brown\](.+)\[\/color\]/iU" => "<span style=\"color: brown;\">$1</span>",
"/\[color=darkred\](.+)\[\/yellow\]/iU" => "<span style=\"color: yellow;\">$1</span>",
"/\[color=green\](.+)\[\/color\]/iU" => "<span style=\"color: green;\">$1</span>",
"/\[color=olive\](.+)\[\/color\]/iU" => "<span style=\"color: olive;\">$1</span>",
"/\[color=cyan\](.+)\[\/color\]/iU" => "<span style=\"color: cyan;\">$1</span>",
"/\[color=blue\](.+)\[\/color\]/iU" => "<span style=\"color: blue;\">$1</span>",
"/\[color=darkblue\](.+)\[\/color\]/iU" => "<span style=\"color: darkblue;\">$1</span>",
"/\[color=indigo\](.+)\[\/color\]/iU" => "<span style=\"color: indigo;\">$1</span>",
"/\[color=violet\](.+)\[\/color\]/iU" => "<span style=\"color: violet;\">$1</span>",
"/\[color=white\](.+)\[\/color\]/iU" => "<span style=\"color: white;\">$1</span>",
"/\[color=black\](.+)\[\/color\]/iU" => "<span style=\"color: black;\">$1</span>",
"/\[size=1\](.+)\[\/size\]/iU" => "<span style=\"font-size: 18px;\">$1</span>",
"/\[size=2\](.+)\[\/size\]/iU" => "<span style=\"font-size: 24px;\">$1</span>",
"/\[size=3\](.+)\[\/size\]/iU" => "<span style=\"font-size: 32px;\">$1</span>",
"/\[size=4\](.+)\[\/size\]/iU" => "<span style=\"font-size: 48px;\">$1</span>",
"/\[size=\-1\](.+)\[\/size\]/iU" => "<span style=\"font-size: 12px;\">$1</span>",
"/\[size=\-2\](.+)\[\/size\]/iU" => "<span style=\"font-size: 10px;\">$1</span>",
"/\[youtube\](.+)\[\/youtube\]/iU" => "<object width=\"425\" height=\"344\"><param name=\"movie\" value=\"http://www.youtube.com/v/$1\"></param><param name=\"allowFullScreen\" value=\"true\"></param><embed src=\"http://www.youtube.com/v/$1\" type=\"application/x-shockwave-flash\" allowfullscreen=\"true\" width=\"425\" height=\"344\"></embed></object>", // [youtube][/youtube]
"/\[code\](.+)\[\/code\]/eiU" => "highlight_string(\"$1\", true)" // [ code ][ /code ]
);
foreach ($regexp as $regexps => $regexp_replacements)
{
$text = preg_replace($regexps, $regexp_replacements, $text);
}
foreach ($smilies as $smilies2 => $smilies_replacements)
{
$text = str_ireplace($smilies2, $smilies_replacements, $text);
}
return $text;
}
?>
:P :P
muup.... cuma share doank .. :P :P :P