• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

BB CODE in otforum

5mok3

Emporia
Joined
Jan 18, 2009
Messages
1,767
Reaction score
25
Location
California, US
weell i used to use BBcode using PEAR in some of my scripts
but for some reason it didn't work on my otforum
so i tried this code and tried to implemented and it didn't work either
can someone help me?

PHP:
<?php
    function bbcode($text)
    {
        $regexp = array(
            "/\[url=(http:\/\/)?(.+)\](.+)\[\/url\]/iU" => "<a href=\"http://$2\" target=\"_blank\">$3</a>", // [url=][/url] 
            "/\[url\](http:\/\/)?(.+)\[\/url\]/iU" => "<a href=\"http://$2\" target=\"_blank\">$2</a>", // [url][/url] 
            "/\[img\](http:\/\/)?(.+)\[\/img\]/iU" => "<img src=\"http://$2\" border=\"0\" alt=\"\" />", // [img][/img] 
            "/\[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>", // [b][/b] 
            "/\[s\](.+)\[\/s\]/iU" => "<del>$1</del>", // [s][/s] 
            "/\[i\](.+)\[\/i\]/iU" => "<em>$1</em>", // [i][/i] 
            "/\[u\](.+)\[\/u\]/iU" => "<ins>$1</ins>", // [u][/u] 
            "/\[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>", // [center][/center] 
            "/\[right\](.+)\[\/right\]/iU" => "<div style=\"text-align: right;\">$1</div>", // [right][/right] 
            "/\[left\](.+)\[\/left\]/iU" => "<div style=\"text-align: left;\">$1</div>", // [left][/left] 
            "/\[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);
        }
        return $text;
    }
?>
 
Back
Top