function smarty_modifier_bbcode2html($message) { $preg = array('/(?<!\\\\)\\[b(?::\\w+)?\\](.*?)\\[\\/b(?::\\w+)?\\]/si' => "<span style=\"font-weight:bold\">\\1</span>", '/(?<!\\\\)\\[i(?::\\w+)?\\](.*?)\\[\\/i(?::\\w+)?\\]/si' => "<span style=\"font-style:italic\">\\1</span>", '/(?<!\\\\)\\[u(?::\\w+)?\\](.*?)\\[\\/u(?::\\w+)?\\]/si' => "<span style=\"text-decoration:underline\">\\1</span>", '/(?<!\\\\)\\[center(?::\\w+)?\\](.*?)\\[\\/center(?::\\w+)?\\]/si' => "<div style=\"text-align:center\">\\1</div>", '/(?<!\\\\)\\[email(?::\\w+)?\\](.*?)\\[\\/email(?::\\w+)?\\]/si' => "<a href=\"mailto:\\1\" class=\"bb-email\">\\1</a>", '/(?<!\\\\)\\[email(?::\\w+)?=(.*?)\\](.*?)\\[\\/email(?::\\w+)?\\]/si' => "<a href=\"mailto:\\1\" class=\"bb-email\">\\2</a>", '/(?<!\\\\)\\[url(?::\\w+)?\\]www\\.(.*?)\\[\\/url(?::\\w+)?\\]/si' => "<a href=\"http://www.\\1\" target=\"_blank\" class=\"bb-url\">\\1</a>", '/(?<!\\\\)\\[url(?::\\w+)?\\](.*?)\\[\\/url(?::\\w+)?\\]/si' => "<a href=\"\\1\" target=\"_blank\" class=\"bb-url\">\\1</a>", '/(?<!\\\\)\\[url(?::\\w+)?=(.*?)?\\](.*?)\\[\\/url(?::\\w+)?\\]/si' => "<a href=\"\\1\" target=\"_blank\" class=\"bb-url\">\\2</a>", '/(?<!\\\\)\\[quote(?::\\w+)?\\](.*?)\\[\\/quote(?::\\w+)?\\]/si' => "<div>Quote:<div class=\"bb-quote\">\\1</div></div>", '/(?<!\\\\)\\[quote(?::\\w+)?=(?:"|"|\')?(.*?)["\']?(?:"|"|\')?\\](.*?)\\[\\/quote\\]/si' => "<div>Quote \\1:<div class=\"bb-quote\">\\2</div></div>", '/(?<!\\\\)(?:\\s*<br\\s*\\/?>\\s*)?\\[\\*(?::\\w+)?\\](.*?)(?=(?:\\s*<br\\s*\\/?>\\s*)?\\[\\*|(?:\\s*<br\\s*\\/?>\\s*)?\\[\\/?list)/si' => "\n<li class=\"bb-listitem\">\\1</li>", '/(?<!\\\\)(?:\\s*<br\\s*\\/?>\\s*)?\\[\\/list(:(?!u|o)\\w+)?\\](?:<br\\s*\\/?>)?/si' => "\n</ul>", '/(?<!\\\\)(?:\\s*<br\\s*\\/?>\\s*)?\\[\\/list:u(:\\w+)?\\](?:<br\\s*\\/?>)?/si' => "\n</ul>", '/(?<!\\\\)(?:\\s*<br\\s*\\/?>\\s*)?\\[\\/list:o(:\\w+)?\\](?:<br\\s*\\/?>)?/si' => "\n</ol>", '/(?<!\\\\)(?:\\s*<br\\s*\\/?>\\s*)?\\[list(:(?!u|o)\\w+)?\\]\\s*(?:<br\\s*\\/?>)?/si' => "\n<ul class=\"bb-list-unordered\">", '/(?<!\\\\)(?:\\s*<br\\s*\\/?>\\s*)?\\[list:u(:\\w+)?\\]\\s*(?:<br\\s*\\/?>)?/si' => "\n<ul class=\"bb-list-unordered\">", '/(?<!\\\\)(?:\\s*<br\\s*\\/?>\\s*)?\\[list:o(:\\w+)?\\]\\s*(?:<br\\s*\\/?>)?/si' => "\n<ol class=\"bb-list-ordered\">", '/(?<!\\\\)(?:\\s*<br\\s*\\/?>\\s*)?\\[list(?::o)?(:\\w+)?=1\\]\\s*(?:<br\\s*\\/?>)?/si' => "\n<ol class=\"bb-list-ordered,bb-list-ordered-d\">", '/(?<!\\\\)(?:\\s*<br\\s*\\/?>\\s*)?\\[list(?::o)?(:\\w+)?=i\\]\\s*(?:<br\\s*\\/?>)?/s' => "\n<ol class=\"bb-list-ordered,bb-list-ordered-lr\">", '/(?<!\\\\)(?:\\s*<br\\s*\\/?>\\s*)?\\[list(?::o)?(:\\w+)?=I\\]\\s*(?:<br\\s*\\/?>)?/s' => "\n<ol class=\"bb-list-ordered,bb-list-ordered-ur\">", '/(?<!\\\\)(?:\\s*<br\\s*\\/?>\\s*)?\\[list(?::o)?(:\\w+)?=a\\]\\s*(?:<br\\s*\\/?>)?/s' => "\n<ol class=\"bb-list-ordered,bb-list-ordered-la\">", '/(?<!\\\\)(?:\\s*<br\\s*\\/?>\\s*)?\\[list(?::o)?(:\\w+)?=A\\]\\s*(?:<br\\s*\\/?>)?/s' => "\n<ol class=\"bb-list-ordered,bb-list-ordered-ua\">", '/\\\\(\\[\\/?\\w+(?::\\w+)*\\])/' => "\\1", '/\\n/' => "<br>"); $message = smiley_replace($message); $message = preg_replace(array_keys($preg), array_values($preg), $message); return $message; }
while ($row = $db->sql_fetchrow($result)) { if ($row['msg_text'] == NULL) { // We already converted this post to the new style BBcode, skip this post. continue; } // // Nathan's bbcode2 conversion // // undo 1.2.x encoding.. $row['msg_text'] = bbdecode(stripslashes($row['msg_text'])); $row['msg_text'] = undo_make_clickable($row['msg_text']); $row['msg_text'] = str_replace("<BR>", "\n", $row['msg_text']); // make a uid $uid = make_bbcode_uid(); // do 2.x first-pass encoding.. $row['msg_text'] = smiley_replace($row['msg_text']); $row['msg_text'] = bbencode_first_pass($row['msg_text'], $uid); $checksig = preg_replace('/\\[addsig\\]$/', '', $row['msg_text']); $enable_sig = strlen($checksig) == strlen($row['msg_text']) ? 0 : 1; if (preg_match("/^(.*?)\n-----------------\n.*\$/is", $checksig, $matches)) { $checksig = $matches[1]; $enable_sig = 1; } $row['msg_text'] = $checksig; $row['msg_status'] = $row['msg_status'] == 1 ? PRIVMSGS_READ_MAIL : PRIVMSGS_NEW_MAIL; // Subject contains first 60 characters of msg, remove any BBCode tags $subject = addslashes(strip_tags(substr($row['msg_text'], 0, 60))); $subject = preg_replace("/\\[.*?\\:(([a-z0-9]:)?){$uid}.*?\\]/si", "", $subject); $row['msg_text'] = addslashes($row['msg_text']); $sql = "INSERT INTO " . PRIVMSGS_TEXT_TABLE . " (privmsgs_text_id, privmsgs_bbcode_uid, privmsgs_text)\n\t\t\t\t\t\tVALUES ('" . $row['msg_id'] . "', '{$uid}', '" . $row['msg_text'] . "')"; query($sql, "Couldn't insert PrivMsg text into " . PRIVMSGS_TEXT_TABLE . " table msg_id " . $row['msg_id']);