• Downloading from our site will require you to have a paid membership. Upgrade to a Premium Membership from 10$ a month today!

    Dont forget read our Rules! Also anyone caught Sharing this content will be banned. By using this site you are agreeing to our rules so read them. Saying I did not know is simply not an excuse! You have been warned.

Share function bbcode

Admin

Well-Known Member
Staff member
Administrator
Code:
<?php
    function bb_parse($string) {
        $tags = 'b|i|size|color|center|quote|url|img';
        while (preg_match_all('`\[('.$tags.')=?(.*?)\](.+?)\[/\1\]`', $string, $matches)) foreach ($matches[0] as $key => $match) {
            list($tag, $param, $innertext) = array($matches[1][$key], $matches[2][$key], $matches[3][$key]);
            switch ($tag) {
                case 'b': $replacement = "<strong>$innertext</strong>"; break;
                case 'i': $replacement = "<em>$innertext</em>"; break;
                case 'size': $replacement = "<span style=\"font-size: $param;\">$innertext</span>"; break;
                case 'color': $replacement = "<span style=\"color: $param;\">$innertext</span>"; break;
                case 'center': $replacement = "<div class=\"centered\">$innertext</div>"; break;
                case 'quote': $replacement = "<blockquote>$innertext</blockquote>" . $param? "<cite>$param</cite>" : ''; break;
                case 'url': $replacement = '<a href="' . ($param? $param : $innertext) . "\">$innertext</a>"; break;
                case 'img':
                    list($width, $height) = preg_split('`[Xx]`', $param);
                    $replacement = "<img src=\"$innertext\" " . (is_numeric($width)? "width=\"$width\" " : '') . (is_numeric($height)? "height=\"$height\" " : '') . '/>';
                break;
                case 'video':
                    $videourl = parse_url($innertext);
                    parse_str($videourl['query'], $videoquery);
                    if (strpos($videourl['host'], 'youtube.com') !== FALSE) $replacement = '<embed src="http://www.youtube.com/v/' . $videoquery['v'] . '" type="application/x-shockwave-flash" width="425" height="344"></embed>';
                    if (strpos($videourl['host'], 'google.com') !== FALSE) $replacement = '<embed src="http://video.google.com/googleplayer.swf?docid=' . $videoquery['docid'] . '" width="400" height="326" type="application/x-shockwave-flash"></embed>';
                break;
            }
            $string = str_replace($match, $replacement, $string);
        }
        return $string;
    }
?>
 

Facebook Comments

Similar threads
Thread starter Title Forum Replies Date
Admin eBay Search function - code updated vBulletin Add-ons 0
Admin Hướng dẫn fix lỗi Deprecated: Function ereg() is deprecated PHP 0
Admin Share đoạn function đếm giờ PHP 0
N Help Lỗi deprecated: function ereg() is deprecated in PHP 3
boy94 Hướng dẫn auto wap/web wmp bằng cách dùng function auto All Shared Scripts 0
Admin Bot chatbox full function (chatbox có chức năng bot) cho vbb 4.x.x Add-ons 2
Admin Khắc phục lỗi touch() [function.touch] và unlink() [function.unlink] với wordpress kh Wordpress 1
Admin [OzzModz] Post Number BBCode Xenforo 0
Admin Yilmaz - Blinking Text BBcode vB5 Add-ons 0
Admin How to convert bbcode hide hack from [Aayush] Hide Hack v1 to Editor & BB Code Manager Xenforo 0
Admin [thread] and [post] BBCode xenforo 2 Xenforo 0
D Xin BBCode Spoiler Jquery With AnimateScroll Xenforo 0
S Help Hỏi về BBcode Thảo luận wap việt 10
H Share code chuyển mã html sang bbcode All Shared Scripts 0
T Share Hướng dẫn mod auto hình ảnh không dùng bbcode [img] cho johncms Johncms 0
H Hỏi Code không cho sử dụng BBCode cho john cms Johncms 0
Admin Spoiler For Hide Links From Guests MOD or BBCode Vbb tutorial 0
P Share Mod Bbcode Get Clip Xvideos By Teenclub.info Johncms 0
Admin Hướng dẫn tạo bbcode theo dõi youtube cho vbb mọi phiên bản Vbb tutorial 0
Admin vt.Lai Zing BBCode 1.0 - Play nhạc của zing bằng trình player pro có link download Add-ons 0
Admin Share code get bbcode ảnh từ photo.tamtay.vn Mã nguồn wap 0
Admin BBCode: Embed Aparat Videos in posts Vbulletin 0
Admin Hướng dẫn thêm các nút bbcode cho wblib HTML & CSS 0
Admin BBCode Embed Tune.pk Videos in your forum Vbb tutorial 1
Admin Let me google that for you BBCode Vbb tutorial 1
Admin Share mod import ảnh qua bbcode cho johncms Johncms 2
Admin Share bbcode you cho chữ kí cho johncms Johncms 0
Admin Share bbcode chụp ảnh online cho johncms Johncms 0
Admin Share bbcode xem video từ xvideo ver 2 cho vbb 3.8.x, 4.0.x, 4.2.x Vbulletin 0
Admin Share bbcode xem video từ xvideo cho vbb 3.8.x, 4.0.x, 4.2.x Vbulletin 1
Admin Editor BBcode Tags to embed EditArea code editor in posts Add-ons 0
Admin Bbcode soundcloud cho vbb Vbulletin 1
Admin BBCode: Embed PDF Files (No JavaScript/No iFrames) (BB Code) Vbulletin 0
Admin Hướng dẫn tạo bbcode xem tập tin pdf online cho vbb Vbb tutorial 0
djdungcuty Share Share bbcode xem pdf cho JohnCMS Johncms 1
Admin Party Vibe Radio BBcode Vbb 4.2.1 Vbulletin 0
Admin Share bbcode zippyshare cho xenforo Xenforo 0
Admin Bbcode link dofollow or nofollow Vbulletin 0
Admin JunoDownloads BBcode Vbulletin 0
Admin Share code phân tích bbcode Mã nguồn web 0
Admin Having Music Player in post with BBcode (Hope You Enjoy) Vbb tutorial 0
Admin Rifthead.com Tooltips/BBCode for RIFT Vbulletin 0
Admin Spotify BBCode Add-ons 0
Admin Share bbcode vbb full link nhaccuatui Vbulletin 0
Admin Kickstarter/IndieGoGo Widget BBcode Vbulletin 0
Admin Hướng dẫn fix bbcode [text] cho johncms Johncms 0
Admin Hướng dẫn sửa lỗi bbcode youtube khi conver từ vbb sang xenforo Xenforo 0
Admin Bbcode hiển thị form google docs Vbulletin 0
H Nút thanks sử dung như thế nào bbcode nút thanks Ý tưởng, góp ý, sáng kiến mới của thành viên 3
djdungcuty BBCode JohnCMS NhanhNao.Mobi Johncms 5

Similar threads

New posts New threads New resources

Back
Top