function gf_formatOldPost($str, $postmode = 'html', $mode = '') { global $CONF_FORUM; $oldPost = 0; if ($CONF_FORUM['pre2.5_mode'] != true) { return $str; } if (strstr($str, '<pre class="forumCode">') !== false) { $oldPost = 1; } if (strstr($str, "[code]<code>") !== false) { $oldPost = 1; } if (strstr($str, "<pre>") !== false) { $oldPost = 1; } if (stristr($str, '[code') == false || stristr($str, '[code]<code>') == true) { if (strstr($str, "<pre>") !== false) { $oldPost = 1; } $str = str_replace('<pre>', '[code]', $str); $str = str_replace('</pre>', '[/code]', $str); } $str = str_ireplace("[code]<code>", '[code]', $str); $str = str_ireplace("</code>[/code]", '[/code]', $str); $str = str_replace(array("<br />\r\n", "<br />\n\r", "<br />\r", "<br />\n", "<br>\r\n", "<br>\n\r", "<br>\r", "<br>\n"), '<br' . XHTML . '>', $str); $str = preg_replace("/\\[QUOTE\\sBY=\\s(.+?)\\]/i", "[QUOTE] Quote by \$1:", $str); /* Reformat code blocks - version 2.3.3 and prior */ $str = str_replace('<pre class="forumCode">', '[code]', $str); $str = preg_replace("/\\[QUOTE\\sBY=(.+?)\\]/i", "[QUOTE] Quote by \$1:", $str); $bbcode = new StringParser_BBCode(); $bbcode->setGlobalCaseSensitive(false); // It is impossible to include block level elements in a <p> element. Therefore I fix this. $bbcode->setParagraphHandlingParameters("\n\n", "", ""); if ($postmode == 'text') { $bbcode->addParser(array('block', 'inline', 'link', 'listitem'), 'bbcode_htmlspecialchars'); } if ($CONF_FORUM['use_glfilter'] == 1 && ($postmode == 'html' || $postmode == 'HTML')) { $bbcode->addParser(array('block', 'inline', 'link', 'listitem'), 'gf_checkHTML'); // calls checkHTML on all text blocks } $bbcode->addParser(array('block', 'inline', 'link', 'list', 'listitem'), 'bbcode_oldpost'); $bbcode->addCode('code', 'simple_replace', null, array('start_tag' => '[code]', 'end_tag' => '[/code]'), 'code', array('listitem', 'block', 'inline', 'link'), array()); if ($CONF_FORUM['use_censor']) { $str = COM_checkWords($str); } $str = $bbcode->parse($str); // If we have identified an old post based on the checks above // it is possible that code blocks will have htmlencoded items // we need to reverse that ... if ($oldPost) { if (strstr($str, "\\'") !== false) { $str = stripslashes($str); } $str = str_replace("$", "\$", $str); $str = str_replace("<br />", "\r", $str); $str = str_replace("<br>", "\r", $str); $str = str_replace('&', '&', $str); $str = str_replace(''', '\'', $str); $str = str_replace('"', '"', $str); $str = str_replace('<', '<', $str); $str = str_replace('>', '>', $str); } $str = str_replace('\', '\\', $str); return $str; }