Example #1
0
function deCodeBB($msg)
{
    $pattern = array();
    $replacement = array();
    $pattern[] = "/<a href=\"mailto:(.+?)\">(.+?)<\\/a>/i";
    $replacement[] = "[email=\\1]\\2[/email]";
    $pattern[] = "/<a href=\"(.+?)\" target=\"(_new|_blank)\"( re[fvl]=\"nofollow\")?>(.+?)<\\/a>/i";
    $replacement[] = "[url=\\1]\\4[/url]";
    $pattern[] = "/<img src=\"(.+?)\" border=\"0\" align=\"(left|right)?\" alt=\"\">/i";
    $replacement[] = "[img\\2]\\1[/img]";
    $pattern[] = "/<blockquote>(.+?)<\\/blockquote>/s";
    $replacement[] = "[blockquote]\\1[/blockquote]";
    $pattern[] = "/<[bB]>(.+?)<\\/[bB]>/s";
    $replacement[] = "[b]\\1[/b]";
    $pattern[] = "/<[iI]>(.+?)<\\/[iI]>/s";
    $replacement[] = "[i]\\1[/i]";
    $pattern[] = "/<[uU]>(.+?)<\\/[uU]>/s";
    $replacement[] = "[u]\\1[/u]";
    $pattern[] = "/<pre>(.+?)<\\/pre>/s";
    $replacement[] = "[code]\\1[/code]";
    $pattern[] = "/<big>(.+?)<\\/big>/s";
    $replacement[] = "[big]\\1[/big]";
    $pattern[] = "/<font color=\"(#[A-F0-9]{6})\">(.+?)<\\/font>/is";
    $replacement[] = '[font\\1]\\2[/font]';
    $msg = preg_replace($pattern, $replacement, $msg);
    $msg = str_replace('<br>', "\n", $msg);
    if (substr_count($msg, '[img\\2]') > 0) {
        $msg = str_replace('[img\\2]', '[img]', $msg);
    }
    if (function_exists('smileThis') and function_exists('getSmilies')) {
        $msg = smileThis(FALSE, TRUE, $msg);
    }
    return $msg;
}
Example #2
0
function deCodeBB($msg)
{
    $pattern = array();
    $replacement = array();
    $pattern[] = "/<!-- nourl -->([^<> \n\r]+?)<!-- \\/nourl -->/i";
    $replacement[] = "[nourl]\\1[/nourl]";
    /* Old [IMG] tag code - without fixed width. */
    $pattern[] = "/<img src=\"([^<> \n\r\\[\\]&]+?)\" alt=\"\" (title=\"\" )?\\/>/i";
    $replacement[] = "[img]\\1[/img]";
    /* New [IMGs] tag code - with fixed width */
    $pattern[] = "/<a href=\"([^<> \n\r\\[\\]&]+?)\" target=\"_blank\"(" . addslashes($GLOBALS['relFollowUrl']) . ")?>[ ]<img src=\"([^<> \n\r\\[\\]]+?)\" alt=\"\" (title=\"\" )?style=\"width:[0-9]+px\" \\/><\\/a>/i";
    $replacement[] = "[imgs]\\3[/imgs]";
    /* [IMGS] tag code - with fixed width and alt */
    $pattern[] = "/<a href=\"([^<> \n\r\\[\\]&]+?)\" target=\"_blank\"(" . addslashes($GLOBALS['relFollowUrl']) . ")?>[ ]<img src=\"([^<> \n\r\\[\\]]+?)\" alt=\"(.+?)\" (title=\"(.+?)\" )?style=\"width:[0-9]+px\" \\/><\\/a>/i";
    $replacement[] = "[imgs=\\3]\\4[/imgs]";
    /* [IMG] tag code - without fixed width, with alt. */
    $pattern[] = "/<img src=\"([^<> \n\r\\[\\]&]+?)\" alt=\"(.+?)\" (title=\"(.+?)\" )?\\/>/i";
    $replacement[] = "[img=\\1]\\2[/img]";
    $pattern[] = "/<a href=\"([^<> \n\r\\[\\]]+?)\" target=\"(_new|_blank)\"" . addslashes($GLOBALS['relFollowUrl']) . ">(.+?)<\\/a>/i";
    $replacement[] = "[url=\\1]\\3[/url]";
    if ($GLOBALS['user_id'] == 1 or isset($GLOBALS['isMod']) and $GLOBALS['isMod'] == 1) {
        $pattern[] = "/<a href=\"([^<> \n\r\\[\\]]+?)\" target=\"(_new|_blank)\">(.+?)<\\/a>/i";
        $replacement[] = "[urlc=\\1]\\3[/url]";
    } else {
        $pattern[] = "/<a href=\"([^<> \n\r\\[\\]]+?)\" target=\"(_new|_blank)\">(.+?)<\\/a>/i";
        $replacement[] = "[url=\\1]\\3[/url]";
    }
    $pattern[] = "/<strong>(.+?)<\\/strong>/is";
    $replacement[] = "[b]\\1[/b]";
    $pattern[] = "/<em>(.+?)<\\/em>/is";
    $replacement[] = "[i]\\1[/i]";
    $pattern[] = "/<[uU]>(.+?)<\\/[uU]>/s";
    $replacement[] = "[u]\\1[/u]";
    $pattern[] = "/<span style=\"color:(#[A-F0-9]{6})\">(.+?)<\\/span>/is";
    $replacement[] = '[font\\1]\\2[/font]';
    $pattern[] = "/<div style=\"text-align:(left|right|center)\">(.+?)<\\/div>/is";
    $replacement[] = '[align\\1]\\2[/align]';
    $pattern[] = '/<div class=\\"quote\\"><div class=\\"quoting\\">(.+?): <\\/div>(.+?)<\\/div>/is';
    $replacement[] = "[quote=\\1]\\2[/quote]\n";
    $pattern[] = '/<div class=\\"quote\\">(.+?)<\\/div>/is';
    $replacement[] = "[quote]\\1[/quote]\n";
    $pattern[] = '/<div class=\\"hl\\">(.+?)<\\/div>/is';
    $replacement[] = "[hl]\\1[/hl]\n";
    $msg = preg_replace($pattern, $replacement, $msg);
    $msg = str_replace('<br />', "\n", $msg);
    if (substr_count($msg, '[img\\2]') > 0) {
        $msg = str_replace('[img\\2]', '[img]', $msg);
    }
    if (function_exists('smileThis')) {
        $msg = smileThis(FALSE, TRUE, $msg);
    }
    return $msg;
}