function discuzcode($message, $smileyoff, $bbcodeoff, $htmlon = 0, $allowsmilies = 1, $allowbbcode = 1, $allowimgcode = 1, $allowhtml = 0, $jammer = 0, $parsetype = '0', $authorid = '0', $allowmediacode = '0', $pid = 0, $lazyload = 0, $pdateline = 0, $first = 0) { global $_G; static $authorreplyexist; if ($pid && strpos($message, '[/password]') !== FALSE) { if ($authorid != $_G['uid'] && !$_G['forum']['ismoderator']) { $message = preg_replace("/\\s?\\[password\\](.+?)\\[\\/password\\]\\s?/ie", "parsepassword('\\1', \$pid)", $message); if ($_G['forum_discuzcode']['passwordlock'][$pid]) { return ''; } } else { $message = preg_replace("/\\s?\\[password\\](.+?)\\[\\/password\\]\\s?/ie", "", $message); $_G['forum_discuzcode']['passwordauthor'][$pid] = 1; } } if ($parsetype != 1 && !$bbcodeoff && $allowbbcode && (strpos($message, '[/code]') || strpos($message, '[/CODE]')) !== FALSE) { $message = preg_replace("/\\s?\\[code\\](.+?)\\[\\/code\\]\\s?/ies", "codedisp('\\1')", $message); } $msglower = strtolower($message); $htmlon = $htmlon && $allowhtml ? 1 : 0; if (!$htmlon) { $message = dhtmlspecialchars($message); } else { $message = preg_replace("/<script[^\\>]*?>(.*?)<\\/script>/i", '', $message); } if ($_G['setting']['plugins']['func'][HOOKTYPE]['discuzcode']) { $_G['discuzcodemessage'] =& $message; $param = func_get_args(); hookscript('discuzcode', 'global', 'funcs', array('param' => $param, 'caller' => 'discuzcode'), 'discuzcode'); } if (!$smileyoff && $allowsmilies) { $message = parsesmiles($message); } if ($_G['setting']['allowattachurl'] && strpos($msglower, 'attach://') !== FALSE) { $message = preg_replace("/attach:\\/\\/(\\d+)\\.?(\\w*)/ie", "parseattachurl('\\1', '\\2', 1)", $message); } if ($allowbbcode) { if (strpos($msglower, 'ed2k://') !== FALSE) { $message = preg_replace("/ed2k:\\/\\/(.+?)\\//e", "parseed2k('\\1')", $message); } } if (!$bbcodeoff && $allowbbcode) { if (strpos($msglower, '[/url]') !== FALSE) { $message = preg_replace("/\\[url(=((https?|ftp|gopher|news|telnet|rtsp|mms|callto|bctp|thunder|qqdl|synacast){1}:\\/\\/|www\\.|mailto:)?([^\r\n\\[\"']+?))?\\](.+?)\\[\\/url\\]/ies", "parseurl('\\1', '\\5', '\\2')", $message); } if (strpos($msglower, '[/email]') !== FALSE) { $message = preg_replace("/\\[email(=([a-z0-9\\-_.+]+)@([a-z0-9\\-_]+[.][a-z0-9\\-_.]+))?\\](.+?)\\[\\/email\\]/ies", "parseemail('\\1', '\\4')", $message); } $nest = 0; while (strpos($msglower, '[table') !== FALSE && strpos($msglower, '[/table]') !== FALSE) { $message = preg_replace("/\\[table(?:=(\\d{1,4}%?)(?:,([\\(\\)%,#\\w ]+))?)?\\]\\s*(.+?)\\s*\\[\\/table\\]/ies", "parsetable('\\1', '\\2', '\\3')", $message); if (++$nest > 4) { break; } } $message = str_replace(array('[/color]', '[/backcolor]', '[/size]', '[/font]', '[/align]', '[b]', '[/b]', '[s]', '[/s]', '[hr]', '[/p]', '[i=s]', '[i]', '[/i]', '[u]', '[/u]', '[list]', '[list=1]', '[list=a]', '[list=A]', "\r\n[*]", '[*]', '[/list]', '[indent]', '[/indent]', '[/float]'), array('</font>', '</font>', '</font>', '</font>', '</div>', '<strong>', '</strong>', '<strike>', '</strike>', '<hr class="l" />', '</p>', '<i class="pstatus">', '<i>', '</i>', '<u>', '</u>', '<ul>', '<ul type="1" class="litype_1">', '<ul type="a" class="litype_2">', '<ul type="A" class="litype_3">', '<li>', '<li>', '</ul>', '<blockquote>', '</blockquote>', '</span>'), preg_replace(array("/\\[color=([#\\w]+?)\\]/i", "/\\[color=((rgb|rgba)\\([\\d\\s,]+?\\))\\]/i", "/\\[backcolor=([#\\w]+?)\\]/i", "/\\[backcolor=((rgb|rgba)\\([\\d\\s,]+?\\))\\]/i", "/\\[size=(\\d{1,2}?)\\]/i", "/\\[size=(\\d{1,2}(\\.\\d{1,2}+)?(px|pt)+?)\\]/i", "/\\[font=([^\\[\\<]+?)\\]/i", "/\\[align=(left|center|right)\\]/i", "/\\[p=(\\d{1,2}|null), (\\d{1,2}|null), (left|center|right)\\]/i", "/\\[float=left\\]/i", "/\\[float=right\\]/i"), array("<font color=\"\\1\">", "<font style=\"color:\\1\">", "<font style=\"background-color:\\1\">", "<font style=\"background-color:\\1\">", "<font size=\"\\1\">", "<font style=\"font-size:\\1\">", "<font face=\"\\1\">", "<div align=\"\\1\">", "<p style=\"line-height:\\1px;text-indent:\\2em;text-align:\\3\">", "<span style=\"float:left;margin-right:5px\">", "<span style=\"float:right;margin-left:5px\">"), $message)); if ($pid && !defined('IN_MOBILE')) { $message = preg_replace("/\\s?\\[postbg\\]\\s*([^\\[\\<\r\n;'\"\\?\\(\\)]+?)\\s*\\[\\/postbg\\]\\s?/ies", "parsepostbg('\\1', '{$pid}')", $message); } else { $message = preg_replace("/\\s?\\[postbg\\]\\s*([^\\[\\<\r\n;'\"\\?\\(\\)]+?)\\s*\\[\\/postbg\\]\\s?/is", "", $message); } if ($parsetype != 1) { if (strpos($msglower, '[/quote]') !== FALSE) { $message = preg_replace("/\\s?\\[quote\\][\n\r]*(.+?)[\n\r]*\\[\\/quote\\]\\s?/is", tpl_quote(), $message); } if (strpos($msglower, '[/free]') !== FALSE) { $message = preg_replace("/\\s*\\[free\\][\n\r]*(.+?)[\n\r]*\\[\\/free\\]\\s*/is", tpl_free(), $message); } } if (!defined('IN_MOBILE')) { if (strpos($msglower, '[/media]') !== FALSE) { $message = preg_replace("/\\[media=([\\w,]+)\\]\\s*([^\\[\\<\r\n]+?)\\s*\\[\\/media\\]/ies", $allowmediacode ? "parsemedia('\\1', '\\2')" : "bbcodeurl('\\2', '<a href=\"{url}\" target=\"_blank\">{url}</a>')", $message); } if (strpos($msglower, '[/audio]') !== FALSE) { $message = preg_replace("/\\[audio(=1)*\\]\\s*([^\\[\\<\r\n]+?)\\s*\\[\\/audio\\]/ies", $allowmediacode ? "parseaudio('\\2', 400)" : "bbcodeurl('\\2', '<a href=\"{url}\" target=\"_blank\">{url}</a>')", $message); } if (strpos($msglower, '[/flash]') !== FALSE) { $message = preg_replace("/\\[flash(=(\\d+),(\\d+))?\\]\\s*([^\\[\\<\r\n]+?)\\s*\\[\\/flash\\]/ies", $allowmediacode ? "parseflash('\\2', '\\3', '\\4');" : "bbcodeurl('\\4', '<a href=\"{url}\" target=\"_blank\">{url}</a>')", $message); } } else { if (strpos($msglower, '[/media]') !== FALSE) { $message = preg_replace("/\\[media=([\\w,]+)\\]\\s*([^\\[\\<\r\n]+?)\\s*\\[\\/media\\]/is", "[media]\\2[/media]", $message); } if (strpos($msglower, '[/audio]') !== FALSE) { $message = preg_replace("/\\[audio(=1)*\\]\\s*([^\\[\\<\r\n]+?)\\s*\\[\\/audio\\]/is", "[media]\\2[/media]", $message); } if (strpos($msglower, '[/flash]') !== FALSE) { $message = preg_replace("/\\[flash(=(\\d+),(\\d+))?\\]\\s*([^\\[\\<\r\n]+?)\\s*\\[\\/flash\\]/is", "[media]\\4[/media]", $message); } } if ($parsetype != 1 && $allowbbcode < 0 && isset($_G['cache']['bbcodes'][-$allowbbcode])) { $message = preg_replace($_G['cache']['bbcodes'][-$allowbbcode]['searcharray'], $_G['cache']['bbcodes'][-$allowbbcode]['replacearray'], $message); } if ($parsetype != 1 && strpos($msglower, '[/hide]') !== FALSE && $pid) { if ($_G['setting']['hideexpiration'] && $pdateline && (TIMESTAMP - $pdateline) / 86400 > $_G['setting']['hideexpiration']) { $message = preg_replace("/\\[hide[=]?(d\\d+)?[,]?(\\d+)?\\]\\s*(.*?)\\s*\\[\\/hide\\]/is", "\\3", $message); $msglower = strtolower($message); } if (strpos($msglower, '[hide=d') !== FALSE) { $message = preg_replace("/\\[hide=(d\\d+)?[,]?(\\d+)?\\]\\s*(.*?)\\s*\\[\\/hide\\]/ies", "expirehide('\\1','\\2','\\3', {$pdateline})", $message); $msglower = strtolower($message); } if (strpos($msglower, '[hide]') !== FALSE) { if ($authorreplyexist === null) { if (!$_G['forum']['ismoderator']) { if ($_G['uid']) { $authorreplyexist = C::t('forum_post')->fetch_pid_by_tid_authorid($_G['tid'], $_G['uid']); } } else { $authorreplyexist = TRUE; } } if ($authorreplyexist) { $message = preg_replace("/\\[hide\\]\\s*(.*?)\\s*\\[\\/hide\\]/is", tpl_hide_reply(), $message); } else { $message = preg_replace("/\\[hide\\](.*?)\\[\\/hide\\]/is", tpl_hide_reply_hidden(), $message); $message = '<script type="text/javascript">replyreload += \',\' + ' . $pid . ';</script>' . $message; } } if (strpos($msglower, '[hide=') !== FALSE) { $message = preg_replace("/\\[hide=(\\d+)\\]\\s*(.*?)\\s*\\[\\/hide\\]/ies", "creditshide(\\1,'\\2', {$pid}, {$authorid})", $message); } } } if (!$bbcodeoff) { if ($parsetype != 1 && strpos($msglower, '[swf]') !== FALSE) { $message = preg_replace("/\\[swf\\]\\s*([^\\[\\<\r\n]+?)\\s*\\[\\/swf\\]/ies", "bbcodeurl('\\1', ' <img src=\"'.STATICURL.'image/filetype/flash.gif\" align=\"absmiddle\" alt=\"\" /> <a href=\"{url}\" target=\"_blank\">Flash: {url}</a> ')", $message); } if (defined('IN_MOBILE') && !defined('TPL_DEFAULT') && !defined('IN_MOBILE_API')) { $allowimgcode = false; } $attrsrc = !IS_ROBOT && $lazyload ? 'file' : 'src'; if (strpos($msglower, '[/img]') !== FALSE) { $message = preg_replace(array("/\\[img\\]\\s*([^\\[\\<\r\n]+?)\\s*\\[\\/img\\]/ies", "/\\[img=(\\d{1,4})[x|\\,](\\d{1,4})\\]\\s*([^\\[\\<\r\n]+?)\\s*\\[\\/img\\]/ies"), $allowimgcode ? array("parseimg(0, 0, '\\1', " . intval($lazyload) . ", " . intval($pid) . ", 'onmouseover=\"img_onmouseoverfunc(this)\" " . ($lazyload ? "lazyloadthumb=\"1\"" : "onload=\"thumbImg(this)\"") . "')", "parseimg('\\1', '\\2', '\\3', " . intval($lazyload) . ", " . intval($pid) . ")") : ($allowbbcode ? array(!defined('IN_MOBILE') ? "bbcodeurl('\\1', '<a href=\"{url}\" target=\"_blank\">{url}</a>')" : "bbcodeurl('\\1', '')", !defined('IN_MOBILE') ? "bbcodeurl('\\3', '<a href=\"{url}\" target=\"_blank\">{url}</a>')" : "bbcodeurl('\\3', '')") : array("bbcodeurl('\\1', '{url}')", "bbcodeurl('\\3', '{url}')")), $message); } } for ($i = 0; $i <= $_G['forum_discuzcode']['pcodecount']; $i++) { $message = str_replace("[\tDISCUZ_CODE_{$i}\t]", $_G['forum_discuzcode']['codehtml'][$i], $message); } unset($msglower); if ($jammer) { $message = preg_replace("/\r\n|\n|\r/e", "jammer()", $message); } if ($first) { if (helper_access::check_module('group')) { $message = preg_replace("/\\[groupid=(\\d+)\\](.*)\\[\\/groupid\\]/i", lang('forum/template', 'fromgroup') . ': <a href="forum.php?mod=forumdisplay&fid=\\1" target="_blank">\\2</a>', $message); } else { $message = preg_replace("/(\\[groupid=\\d+\\].*\\[\\/groupid\\])/i", '', $message); } } return $htmlon ? $message : nl2br(str_replace(array("\t", ' ', ' '), array(' ', ' ', ' '), $message)); }
function discuzcode($message, $smileyoff, $bbcodeoff, $htmlon = 0, $allowsmilies = 1, $allowbbcode = 1, $allowimgcode = 1, $allowhtml = 0, $jammer = 0, $parsetype = '0', $authorid = '0', $allowmediacode = '0', $pid = 0) { global $_G; static $authorreplyexist; if ($parsetype != 1 && !$bbcodeoff && $allowbbcode && (strpos($message, '[/code]') || strpos($message, '[/CODE]')) !== FALSE) { $message = preg_replace("/\\s?\\[code\\](.+?)\\[\\/code\\]\\s?/ies", "codedisp('\\1')", $message); } $msglower = strtolower($message); $htmlon = $htmlon && $allowhtml ? 1 : 0; if (!$htmlon) { $message = dhtmlspecialchars($message); } if (!$smileyoff && $allowsmilies) { $message = parsesmiles($message); } if ($_G['setting']['allowattachurl'] && strpos($msglower, 'attach://') !== FALSE) { $message = preg_replace("/attach:\\/\\/(\\d+)\\.?(\\w*)/ie", "parseattachurl('\\1', '\\2')", $message); } if ($allowbbcode) { if (strpos($msglower, 'ed2k://') !== FALSE) { $message = preg_replace("/ed2k:\\/\\/(.+?)\\//e", "parseed2k('\\1')", $message); } } if (!$bbcodeoff && $allowbbcode) { if (strpos($msglower, '[/url]') !== FALSE) { $message = preg_replace("/\\[url(=((https?|ftp|gopher|news|telnet|rtsp|mms|callto|bctp|thunder|synacast){1}:\\/\\/|www\\.|mailto:)?([^\\s\\[\"']+?))?\\](.+?)\\[\\/url\\]/ies", "parseurl('\\1', '\\5', '\\2')", $message); } if (strpos($msglower, '[/email]') !== FALSE) { $message = preg_replace("/\\[email(=([a-z0-9\\-_.+]+)@([a-z0-9\\-_]+[.][a-z0-9\\-_.]+))?\\](.+?)\\[\\/email\\]/ies", "parseemail('\\1', '\\4')", $message); } $nest = 0; while (strpos($msglower, '[table') !== FALSE && strpos($msglower, '[/table]') !== FALSE) { $message = preg_replace("/\\[table(?:=(\\d{1,4}%?)(?:,([\\(\\)%,#\\w ]+))?)?\\]\\s*(.+?)\\s*\\[\\/table\\]/ies", "parsetable('\\1', '\\2', '\\3')", $message); if (++$nest > 4) { break; } } $message = str_replace(array('[/color]', '[/size]', '[/font]', '[/align]', '[b]', '[/b]', '[s]', '[/s]', '[hr]', '[/p]', '[i=s]', '[i]', '[/i]', '[u]', '[/u]', '[list]', '[list=1]', '[list=a]', '[list=A]', "\r\n[*]", '[*]', '[/list]', '[indent]', '[/indent]', '[/float]'), array('</font>', '</font>', '</font>', '</p>', '<strong>', '</strong>', '<strike>', '</strike>', '<hr class="l" />', '</p>', '<i class="pstatus">', '<i>', '</i>', '<u>', '</u>', '<ul>', '<ul type="1" class="litype_1">', '<ul type="a" class="litype_2">', '<ul type="A" class="litype_3">', '<li>', '<li>', '</ul>', '<blockquote>', '</blockquote>', '</span>'), preg_replace(array("/\\[color=([#\\w]+?)\\]/i", "/\\[color=(rgb\\([\\d\\s,]+?\\))\\]/i", "/\\[size=(\\d{1,2}?)\\]/i", "/\\[size=(\\d{1,2}(\\.\\d{1,2}+)?(px|pt)+?)\\]/i", "/\\[font=([^\\[\\<]+?)\\]/i", "/\\[align=(left|center|right)\\]/i", "/\\[p=(\\d{1,2}|null), (\\d{1,2}), (left|center|right)\\]/i", "/\\[float=(left|right)\\]/i"), array("<font color=\"\\1\">", "<font style=\"color:\\1\">", "<font size=\"\\1\">", "<font style=\"font-size: \\1\">", "<font face=\"\\1 \">", "<p align=\"\\1\">", "<p style=\"line-height: \\1px; text-indent: \\2em; text-align: \\3;\">", "<span style=\"float: \\1;\">"), $message)); if ($parsetype != 1) { if (strpos($msglower, '[/quote]') !== FALSE) { $message = preg_replace("/\\s?\\[quote\\][\n\r]*(.+?)[\n\r]*\\[\\/quote\\]\\s?/is", tpl_quote(), $message); } if (strpos($msglower, '[/free]') !== FALSE) { $message = preg_replace("/\\s*\\[free\\][\n\r]*(.+?)[\n\r]*\\[\\/free\\]\\s*/is", tpl_free(), $message); } } if (strpos($msglower, '[/media]') !== FALSE) { $message = preg_replace("/\\[media=([\\w,]+)\\]\\s*([^\\[\\<\r\n]+?)\\s*\\[\\/media\\]/ies", $allowmediacode ? "parsemedia('\\1', '\\2')" : "bbcodeurl('\\2', '<a href=\"{url}\" target=\"_blank\">{url}</a>')", $message); } if (strpos($msglower, '[/audio]') !== FALSE) { $message = preg_replace("/\\[audio(=1)*\\]\\s*([^\\[\\<\r\n]+?)\\s*\\[\\/audio\\]/ies", $allowmediacode ? "parseaudio('\\2', 400, '\\1')" : "bbcodeurl('\\2', '<a href=\"{url}\" target=\"_blank\">{url}</a>')", $message); } if (strpos($msglower, '[/flash]') !== FALSE) { $message = preg_replace("/\\[flash(=(\\d+),(\\d+))?\\]\\s*([^\\[\\<\r\n]+?)\\s*\\[\\/flash\\]/ies", $allowmediacode ? "parseflash('\\2', '\\3', '\\4');" : "bbcodeurl('\\4', '<a href=\"{url}\" target=\"_blank\">{url}</a>')", $message); } if ($parsetype != 1 && $allowbbcode < 0 && isset($_G['cache']['bbcodes'][-$allowbbcode])) { $message = preg_replace($_G['cache']['bbcodes'][-$allowbbcode]['searcharray'], $_G['cache']['bbcodes'][-$allowbbcode]['replacearray'], $message); } if ($parsetype != 1 && strpos($msglower, '[/hide]') !== FALSE && $pid) { if (strpos($msglower, '[hide]') !== FALSE) { if ($authorreplyexist === null) { $posttable = getposttablebytid($_G['tid']); $authorreplyexist = !$_G['forum']['ismoderator'] ? DB::result_first("SELECT pid FROM " . DB::table($posttable) . " WHERE tid='{$_G['tid']}' AND " . ($_G['uid'] ? "authorid='{$_G['uid']}'" : "authorid=0 AND useip='{$_G['clientip']}'") . " LIMIT 1") : TRUE; } if ($authorreplyexist) { $message = preg_replace("/\\[hide\\]\\s*(.+?)\\s*\\[\\/hide\\]/is", tpl_hide_reply(), $message); } else { $message = preg_replace("/\\[hide\\](.+?)\\[\\/hide\\]/is", tpl_hide_reply_hidden(), $message); $message .= '<script type="text/javascript">replyreload += \',\' + ' . $pid . ';</script>'; } } if (strpos($msglower, '[hide=') !== FALSE) { $message = preg_replace("/\\[hide=(\\d+)\\]\\s*(.+?)\\s*\\[\\/hide\\]/ies", "creditshide(\\1,'\\2', {$pid})", $message); } } } if (!$bbcodeoff) { if ($parsetype != 1 && strpos($msglower, '[swf]') !== FALSE) { $message = preg_replace("/\\[swf\\]\\s*([^\\[\\<\r\n]+?)\\s*\\[\\/swf\\]/ies", "bbcodeurl('\\1', ' <img src=\"'.STATICURL.'image/filetype/flash.gif\" align=\"absmiddle\" alt=\"\" /> <a href=\"{url}\" target=\"_blank\">Flash: {url}</a> ')", $message); } if (strpos($msglower, '[/img]') !== FALSE) { $message = preg_replace(array("/\\[img\\]\\s*([^\\[\\<\r\n]+?)\\s*\\[\\/img\\]/ies", "/\\[img=(\\d{1,4})[x|\\,](\\d{1,4})\\]\\s*([^\\[\\<\r\n]+?)\\s*\\[\\/img\\]/ies"), $allowimgcode ? array("bbcodeurl('\\1', '<img src=\"{url}\" onload=\"thumbImg(this)\" alt=\"\" />')", "parseimg('\\1', '\\2', '\\3')") : array("bbcodeurl('\\1', '<a href=\"{url}\" target=\"_blank\">{url}</a>')", "bbcodeurl('\\3', '<a href=\"{url}\" target=\"_blank\">{url}</a>')"), $message); } } for ($i = 0; $i <= $_G['forum_discuzcode']['pcodecount']; $i++) { $message = str_replace("[\tDISCUZ_CODE_{$i}\t]", $_G['forum_discuzcode']['codehtml'][$i], $message); } if (!empty($_G['gp_highlight'])) { $highlightarray = explode('+', $_G['gp_highlight']); $sppos = strrpos($message, chr(0) . chr(0) . chr(0)); if ($sppos !== FALSE) { $specialextra = substr($message, $sppos + 3); $message = substr($message, 0, $sppos); } $message = preg_replace(array("/(^|>)([^<]+)(?=<|\$)/sUe", "/<highlight>(.*)<\\/highlight>/siU"), array("highlight('\\2', \$highlightarray, '\\1')", "<strong><font color=\"#FF0000\">\\1</font></strong>"), $message); if ($sppos !== FALSE) { $message = $message . chr(0) . chr(0) . chr(0) . $specialextra; } } unset($msglower); if ($jammer) { $message = preg_replace("/\r\n|\n|\r/e", "jammer()", $message); } return $htmlon ? $message : nl2br(str_replace(array("\t", ' ', ' '), array(' ', ' ', ' '), $message)); }
function discuzcode($message, $smileyoff, $bbcodeoff, $htmlon = 0, $allowsmilies = 1, $allowbbcode = 1, $allowimgcode = 1, $allowhtml = 0, $jammer = 0, $parsetype = '0', $authorid = '0', $allowmediacode = '0', $pid = 0) { global $discuzcodes, $credits, $tid, $discuz_uid, $highlight, $maxsmilies, $db, $tablepre, $hideattach, $allowattachurl; if($parsetype != 1 && !$bbcodeoff && $allowbbcode && (strpos($message, '[/code]') || strpos($message, '[/CODE]')) !== FALSE) { $message = preg_replace("/\s?\[code\](.+?)\[\/code\]\s?/ies", "codedisp('\\1')", $message); } $msglower = strtolower($message); //$htmlon = $htmlon && $allowhtml ? 1 : 0; if(!$htmlon) { $message = $jammer ? preg_replace("/\r\n|\n|\r/e", "jammer()", dhtmlspecialchars($message)) : dhtmlspecialchars($message); } if(!$smileyoff && $allowsmilies && !empty($GLOBALS['_DCACHE']['smilies']) && is_array($GLOBALS['_DCACHE']['smilies'])) { if(!$discuzcodes['smiliesreplaced']) { foreach($GLOBALS['_DCACHE']['smilies']['replacearray'] AS $key => $smiley) { $GLOBALS['_DCACHE']['smilies']['replacearray'][$key] = '<img src="images/smilies/'.$GLOBALS['_DCACHE']['smileytypes'][$GLOBALS['_DCACHE']['smilies']['typearray'][$key]]['directory'].'/'.$smiley.'" smilieid="'.$key.'" border="0" alt="" />'; } $discuzcodes['smiliesreplaced'] = 1; } $message = preg_replace($GLOBALS['_DCACHE']['smilies']['searcharray'], $GLOBALS['_DCACHE']['smilies']['replacearray'], $message, $maxsmilies); } if($allowattachurl && strpos($msglower, 'attach://') !== FALSE) { $message = preg_replace("/attach:\/\/(\d+)\.?(\w*)/ie", "parseattachurl('\\1', '\\2')", $message); } if(!$bbcodeoff && $allowbbcode) { if(strpos($msglower, '[/url]') !== FALSE) { $message = preg_replace("/\[url(=((https?|ftp|gopher|news|telnet|rtsp|mms|callto|bctp|ed2k|thunder|synacast){1}:\/\/|www\.|mailto:)([^\s\[\"']+?))?\](.+?)\[\/url\]/ies", "parseurl('\\1', '\\5')", $message); } if(strpos($msglower, '[/email]') !== FALSE) { $message = preg_replace("/\[email(=([a-z0-9\-_.+]+)@([a-z0-9\-_]+[.][a-z0-9\-_.]+))?\](.+?)\[\/email\]/ies", "parseemail('\\1', '\\4')", $message); } $message = str_replace(array( '[/color]', '[/size]', '[/font]', '[/align]', '[b]', '[/b]', '[s]', '[/s]', '[hr]', '[/p]', '[i=s]', '[i]', '[/i]', '[u]', '[/u]', '[list]', '[list=1]', '[list=a]', '[list=A]', '[*]', '[/list]', '[indent]', '[/indent]', '[/float]' ), array( '</font>', '</font>', '</font>', '</p>', '<strong>', '</strong>', '<strike>', '</strike>', '<hr class="solidline" />', '</p>', '<i class="pstatus">', '<i>', '</i>', '<u>', '</u>', '<ul>', '<ul type="1" class="litype_1">', '<ul type="a" class="litype_2">', '<ul type="A" class="litype_3">', '<li>', '</ul>', '<blockquote>', '</blockquote>', '</span>' ), preg_replace(array( "/\[color=([#\w]+?)\]/i", "/\[size=(\d+?)\]/i", "/\[size=(\d+(\.\d+)?(px|pt|in|cm|mm|pc|em|ex|%)+?)\]/i", "/\[font=([^\[\<]+?)\]/i", "/\[align=(left|center|right)\]/i", "/\[p=(\d{1,2}), (\d{1,2}), (left|center|right)\]/i", "/\[float=(left|right)\]/i" ), array( "<font color=\"\\1\">", "<font size=\"\\1\">", "<font style=\"font-size: \\1\">", "<font face=\"\\1 \">", "<p align=\"\\1\">", "<p style=\"line-height: \\1px; text-indent: \\2em; text-align: \\3;\">", "<span style=\"float: \\1;\">" ), $message)); $nest = 0; while(strpos($msglower, '[table') !== FALSE && strpos($msglower, '[/table]') !== FALSE){ $message = preg_replace("/\[table(?:=(\d{1,4}%?)(?:,([\(\)%,#\w ]+))?)?\]\s*(.+?)\s*\[\/table\]/ies", "parsetable('\\1', '\\2', '\\3')", $message); if(++$nest > 4) break; } if($parsetype != 1) { if(strpos($msglower, '[/quote]') !== FALSE) { $message = preg_replace("/\s?\[quote\][\n\r]*(.+?)[\n\r]*\[\/quote\]\s?/is", tpl_quote(), $message); } if(strpos($msglower, '[/free]') !== FALSE) { $message = preg_replace("/\s*\[free\][\n\r]*(.+?)[\n\r]*\[\/free\]\s*/is", tpl_free(), $message); } } if(strpos($msglower, '[/media]') !== FALSE) { $message = preg_replace("/\[media=([\w,]+)\]\s*([^\[\<\r\n]+?)\s*\[\/media\]/ies", $allowmediacode ? "parsemedia('\\1', '\\2')" : "bbcodeurl('\\2', '<a href=\"%s\" target=\"_blank\">%s</a>')", $message); } if($allowmediacode && strpos($msglower, '[/audio]') !== FALSE) { $message = preg_replace("/\[audio\]\s*([^\[\<\r\n]+?)\s*\[\/audio\]/ies", "parseaudio('\\1')", $message); } if($allowmediacode && strpos($msglower, '[/flash]') !== FALSE) { $message = preg_replace("/\[flash\]\s*([^\[\<\r\n]+?)\s*\[\/flash\]/is", "<script type=\"text/javascript\" reload=\"1\">document.write(AC_FL_RunContent('width', '550', 'height', '400', 'allowNetworking', 'internal', 'allowScriptAccess', 'never', 'src', '\\1', 'quality', 'high', 'bgcolor', '#ffffff', 'wmode', 'transparent', 'allowfullscreen', 'true'));</script>", $message); } if($parsetype != 1 && $allowbbcode == 2 && $GLOBALS['_DCACHE']['bbcodes']) { $message = preg_replace($GLOBALS['_DCACHE']['bbcodes']['searcharray'], $GLOBALS['_DCACHE']['bbcodes']['replacearray'], $message); } if($parsetype != 1 && strpos($msglower, '[/hide]') !== FALSE) { if(strpos($msglower, '[hide]') !== FALSE) { if($GLOBALS['authorreplyexist'] === '') { $GLOBALS['authorreplyexist'] = !$GLOBALS['forum']['ismoderator'] ? $db->result_first("SELECT pid FROM {$tablepre}posts WHERE tid='$tid' AND ".($discuz_uid ? "authorid='$discuz_uid'" : "authorid=0 AND useip='$GLOBALS[onlineip]'")." LIMIT 1") : TRUE; } if($GLOBALS['authorreplyexist']) { $message = preg_replace("/\[hide\]\s*(.+?)\s*\[\/hide\]/is", tpl_hide_reply(), $message); } else { $message = preg_replace("/\[hide\](.+?)\[\/hide\]/is", tpl_hide_reply_hidden(), $message); $message .= '<script type="text/javascript">replyreload += \',\' + '.$pid.';</script>'; } } if(strpos($msglower, '[hide=') !== FALSE) { $message = preg_replace("/\[hide=(\d+)\]\s*(.+?)\s*\[\/hide\]/ies", "creditshide(\\1,'\\2', $pid)", $message); } } } if(!$bbcodeoff) { if($parsetype != 1 && strpos($msglower, '[swf]') !== FALSE) { $message = preg_replace("/\[swf\]\s*([^\[\<\r\n]+?)\s*\[\/swf\]/ies", "bbcodeurl('\\1', ' <img src=\"images/attachicons/flash.gif\" align=\"absmiddle\" alt=\"\" /> <a href=\"%s\" target=\"_blank\">Flash: %s</a> ')", $message); } if(strpos($msglower, '[/img]') !== FALSE) { $message = preg_replace(array( "/\[img\]\s*([^\[\<\r\n]+?)\s*\[\/img\]/ies", "/\[img=(\d{1,4})[x|\,](\d{1,4})\]\s*([^\[\<\r\n]+?)\s*\[\/img\]/ies" ), $allowimgcode ? array( "bbcodeurl('\\1', '<img src=\"%s\" onload=\"thumbImg(this)\" alt=\"\" />')", "parseimg('\\1', '\\2', '\\3')" ) : array( "bbcodeurl('\\1', '<a href=\"%s\" target=\"_blank\">%s</a>')", "bbcodeurl('\\3', '<a href=\"%s\" target=\"_blank\">%s</a>')" ), $message); } } for($i = 0; $i <= $discuzcodes['pcodecount']; $i++) { $message = str_replace("[\tDISCUZ_CODE_$i\t]", $discuzcodes['codehtml'][$i], $message); } if($highlight) { $highlightarray = explode('+', $highlight); $sppos = strrpos($message, chr(0).chr(0).chr(0)); if($sppos !== FALSE) { $specialextra = substr($postlist[$firstpid]['message'], $sppos + 3); $message = substr($message, 0, $sppos); } $message = preg_replace(array("/(^|>)([^<]+)(?=<|$)/sUe", "/<highlight>(.*)<\/highlight>/siU"), array("highlight('\\2', \$highlightarray, '\\1')", "<strong><font color=\"#FF0000\">\\1</font></strong>"), $message); if($sppos !== FALSE) { $message = $message.chr(0).chr(0).chr(0).$specialextra; } } unset($msglower); return $htmlon ? $message : nl2br(str_replace(array("\t", ' ', ' '), array(' ', ' ', ' '), $message)); }
function discuzcode($message, $smileyoff, $bbcodeoff, $htmlon = 0, $allowsmilies = 1, $allowbbcode = 1, $allowimgcode = 1, $allowhtml = 0, $jammer = 0, $parsetype = '0', $authorid = '0', $allowmediacode = '0', $pid = 0) { global $discuzcodes, $credits, $tid, $discuz_uid, $highlight, $maxsmilies, $db, $tablepre, $hideattach; if ($parsetype != 1 && !$bbcodeoff && $allowbbcode && (strpos($message, '[/code]') || strpos($message, '[/CODE]')) !== FALSE) { $message = preg_replace("/\\s*\\[code\\](.+?)\\[\\/code\\]\\s*/ies", "codedisp('\\1')", $message); } $msglower = strtolower($message); $htmlrule = 0; if ($htmlrule) { $htmlon = $htmlon && $allowhtml ? 1 : 0; } if (!$htmlon) { $message = $jammer ? preg_replace("/\r\n|\n|\r/e", "jammer()", dhtmlspecialchars($message)) : dhtmlspecialchars($message); } if (!$smileyoff && $allowsmilies && !empty($GLOBALS['_DCACHE']['smilies']) && is_array($GLOBALS['_DCACHE']['smilies'])) { if (!$discuzcodes['smiliesreplaced']) { foreach ($GLOBALS['_DCACHE']['smilies']['replacearray'] as $key => $smiley) { $GLOBALS['_DCACHE']['smilies']['replacearray'][$key] = '<img src="images/smilies/' . $GLOBALS['_DCACHE']['smileytypes'][$GLOBALS['_DCACHE']['smilies']['typearray'][$key]]['directory'] . '/' . $smiley . '" smilieid="' . $key . '" border="0" alt="" />'; } $discuzcodes['smiliesreplaced'] = 1; } $message = preg_replace($GLOBALS['_DCACHE']['smilies']['searcharray'], $GLOBALS['_DCACHE']['smilies']['replacearray'], $message, $maxsmilies); } if (!$bbcodeoff && $allowbbcode) { if (strpos($msglower, '[/url]') !== FALSE) { $message = preg_replace("/\\[url(=((https?|ftp|gopher|news|telnet|rtsp|mms|callto|bctp|ed2k|thunder|synacast){1}:\\/\\/|www\\.)([^\\[\"']+?))?\\](.+?)\\[\\/url\\]/ies", "parseurl('\\1', '\\5')", $message); } if (strpos($msglower, '[/email]') !== FALSE) { $message = preg_replace("/\\[email(=([a-z0-9\\-_.+]+)@([a-z0-9\\-_]+[.][a-z0-9\\-_.]+))?\\](.+?)\\[\\/email\\]/ies", "parseemail('\\1', '\\4')", $message); } $message = str_replace(array('[/color]', '[/size]', '[/font]', '[/align]', '[b]', '[/b]', '[i=s]', '[i]', '[/i]', '[u]', '[/u]', '[list]', '[list=1]', '[list=a]', '[list=A]', '[*]', '[/list]', '[indent]', '[/indent]', '[/float]'), array('</font>', '</font>', '</font>', '</p>', '<strong>', '</strong>', '<i class="pstatus">', '<i>', '</i>', '<u>', '</u>', '<ul>', '<ul type="1" class="litype_1">', '<ul type="a" class="litype_2">', '<ul type="A" class="litype_3">', '<li>', '</ul>', '<blockquote>', '</blockquote>', '</span>'), preg_replace(array("/\\[color=([#\\w]+?)\\]/i", "/\\[size=(\\d+?)\\]/i", "/\\[size=(\\d+(\\.\\d+)?(px|pt|in|cm|mm|pc|em|ex|%)+?)\\]/i", "/\\[font=([^\\[\\<]+?)\\]/i", "/\\[align=(left|center|right)\\]/i", "/\\[float=(left|right)\\]/i"), array("<font color=\"\\1\">", "<font size=\"\\1\">", "<font style=\"font-size: \\1\">", "<font face=\"\\1 \">", "<p align=\"\\1\">", "<span style=\"float: \\1;\">"), $message)); $nest = 0; while (strpos($msglower, '[table') !== FALSE && strpos($msglower, '[/table]') !== FALSE) { $message = preg_replace("/\\[table(?:=(\\d{1,4}%?)(?:,([\\(\\)%,#\\w ]+))?)?\\]\\s*(.+?)\\s*\\[\\/table\\]/ies", "parsetable('\\1', '\\2', '\\3')", $message); if (++$nest > 4) { break; } } if ($parsetype != 1) { if (strpos($msglower, '[/quote]') !== FALSE) { $message = preg_replace("/\\s*\\[quote\\][\n\r]*(.+?)[\n\r]*\\[\\/quote\\]\\s*/is", tpl_quote(), $message); } if (strpos($msglower, '[/free]') !== FALSE) { $message = preg_replace("/\\s*\\[free\\][\n\r]*(.+?)[\n\r]*\\[\\/free\\]\\s*/is", tpl_free(), $message); } } if (strpos($msglower, '[/media]') !== FALSE) { $message = preg_replace("/\\[media=([\\w,]+)\\]\\s*([^\\[\\<\r\n]+?)\\s*\\[\\/media\\]/ies", $allowmediacode ? "parsemedia('\\1', '\\2')" : "bbcodeurl('\\2', '<a href=\"%s\" target=\"_blank\">%s</a>')", $message); } if ($parsetype != 1 && $allowbbcode == 2 && $GLOBALS['_DCACHE']['bbcodes']) { $message = preg_replace($GLOBALS['_DCACHE']['bbcodes']['searcharray'], $GLOBALS['_DCACHE']['bbcodes']['replacearray'], $message); } if ($parsetype != 1 && strpos($msglower, '[/hide]') !== FALSE) { if (strpos($msglower, '[hide]') !== FALSE) { $query = $db->query("SELECT pid FROM {$tablepre}posts WHERE tid='{$tid}' AND " . ($discuz_uid ? "authorid='{$discuz_uid}'" : "authorid=0 AND useip='{$GLOBALS['onlineip']}'") . " LIMIT 1"); if ($GLOBALS['forum']['ismoderator'] || ($apid = $db->result($query, 0))) { $message = preg_replace("/\\[hide\\]\\s*(.+?)\\s*\\[\\/hide\\]/is", tpl_hide_reply(), $message); $hideattach[$apid] = 0; } else { $message = preg_replace("/\\[hide\\](.+?)\\[\\/hide\\]/is", tpl_hide_reply_hidden(), $message); $message .= '<script type="text/javascript">replyreload += \',\' + ' . $pid . ';</script>'; $hideattach[$pid] = 0; } } if (strpos($msglower, '[hide=') !== FALSE) { $message = preg_replace("/\\[hide=(\\d+)\\]\\s*(.+?)\\s*\\[\\/hide\\]/ies", "creditshide(\\1,'\\2', {$pid})", $message); } } } if (!$bbcodeoff) { if ($parsetype != 1 && strpos($msglower, '[swf]') !== FALSE) { $message = preg_replace("/\\[swf\\]\\s*([^\\[\\<\r\n]+?)\\s*\\[\\/swf\\]/ies", "bbcodeurl('\\1', ' <img src=\"images/attachicons/flash.gif\" align=\"absmiddle\" alt=\"\" /> <a href=\"%s\" target=\"_blank\">Flash: %s</a> ')", $message); } if (strpos($msglower, '[/img]') !== FALSE) { $message = preg_replace(array("/\\[img\\]\\s*([^\\[\\<\r\n]+?)\\s*\\[\\/img\\]/ies", "/\\[img=(\\d{1,4})[x|\\,](\\d{1,4})\\]\\s*([^\\[\\<\r\n]+?)\\s*\\[\\/img\\]/ies"), $allowimgcode ? array("bbcodeurl('\\1', '<img src=\"%s\" onload=\"thumbImg(this)\" alt=\"\" />')", "bbcodeurl('\\3', '<img width=\"\\1\" height=\"\\2\" src=\"%s\" border=\"0\" alt=\"\" />')") : array("bbcodeurl('\\1', '<a href=\"%s\" target=\"_blank\">%s</a>')", "bbcodeurl('\\3', '<a href=\"%s\" target=\"_blank\">%s</a>')"), $message); } } for ($i = 0; $i <= $discuzcodes['pcodecount']; $i++) { $message = str_replace("[\tDISCUZ_CODE_{$i}\t]", $discuzcodes['codehtml'][$i], $message); } if ($highlight) { $highlightarray = explode('+', $highlight); $message = preg_replace(array("/(^|>)([^<]+)(?=<|\$)/sUe", "/<highlight>(.*)<\\/highlight>/siU"), array("highlight('\\2', \$highlightarray, '\\1')", "<strong><font color=\"#FF0000\">\\1</font></strong>"), $message); } unset($msglower); return $htmlon ? $message : nl2br(str_replace(array("\t", ' ', ' '), array(' ', ' ', ' '), $message)); }
function discuzcode($message, $smileyoff, $bbcodeoff, $htmlon = 0, $allowsmilies = 1, $allowbbcode = 1, $allowimgcode = 1, $allowhtml = 0, $jammer = 0, $parsetype = '0', $authorid = '0', $allowmediacode = '0', $pid = 0) { global $discuzcodes, $credits, $tid, $discuz_uid, $highlight, $maxsmilies, $db, $tablepre, $hideattach; if ($parsetype != 1 && !$bbcodeoff && $allowbbcode) { $message = preg_replace("/\\s*\\[code\\](.+?)\\[\\/code\\]\\s*/ies", "codedisp('\\1')", $message); } if (!$htmlon && !$allowhtml) { $message = $jammer ? preg_replace("/\r\n|\n|\r/e", "jammer()", dhtmlspecialchars($message)) : dhtmlspecialchars($message); } if (!$smileyoff && $allowsmilies && !empty($GLOBALS['_DCACHE']['smilies']) && is_array($GLOBALS['_DCACHE']['smilies'])) { $message = preg_replace($GLOBALS['_DCACHE']['smilies']['searcharray'], $GLOBALS['_DCACHE']['smilies']['replacearray'], $message, $maxsmilies); } if (!$bbcodeoff && $allowbbcode) { if (empty($discuzcodes['searcharray'])) { $discuzcodes['searcharray']['bbcode_regexp'] = array("/\\[url\\]\\s*(www.|https?:\\/\\/|ftp:\\/\\/|gopher:\\/\\/|news:\\/\\/|telnet:\\/\\/|rtsp:\\/\\/|mms:\\/\\/|callto:\\/\\/|bctp:\\/\\/|ed2k:\\/\\/|thunder:\\/\\/|synacast:\\/\\/){1}([^\\[\"']+?)\\s*\\[\\/url\\]/ie", "/\\[url=www.([^\\[\"']+?)\\](.+?)\\[\\/url\\]/is", "/\\[url=(https?|ftp|gopher|news|telnet|rtsp|mms|callto|bctp|ed2k|thunder|synacast){1}:\\/\\/([^\\[\"']+?)\\](.+?)\\[\\/url\\]/is", "/\\[email\\]\\s*([a-z0-9\\-_.+]+)@([a-z0-9\\-_]+[.][a-z0-9\\-_.]+)\\s*\\[\\/email\\]/i", "/\\[email=([a-z0-9\\-_.+]+)@([a-z0-9\\-_]+[.][a-z0-9\\-_.]+)\\](.+?)\\[\\/email\\]/is", "/\\[color=([#\\w]+?)\\]/i", "/\\[size=(\\d+?)\\]/i", "/\\[size=(\\d+(\\.\\d+)?(px|pt|in|cm|mm|pc|em|ex|%)+?)\\]/i", "/\\[font=([^\\[\\<]+?)\\]/i", "/\\[align=(left|center|right)\\]/i", "/\\[float=(left|right)\\]/i"); $discuzcodes['replacearray']['bbcode_regexp'] = array("cuturl('\\1\\2')", "<a href=\"http://www.\\1\" target=\"_blank\">\\2</a>", "<a href=\"\\1://\\2\" target=\"_blank\">\\3</a>", "<a href=\"mailto:\\1@\\2\">\\1@\\2</a>", "<a href=\"mailto:\\1@\\2\">\\3</a>", "<font color=\"\\1\">", "<font size=\"\\1\">", "<font style=\"font-size: \\1\">", "<font face=\"\\1 \">", "<p align=\"\\1\">", "<span style=\"float: \\1;\">"); $discuzcodes['searcharray']['bbcode_regexp'][] = "/\\[table(?:=(\\d{1,4}%?)(?:,([\\(\\)%,#\\w ]+))?)?\\]\\s*(.+?)\\s*\\[\\/table\\]/ies"; $discuzcodes['replacearray']['bbcode_regexp'][] = "parsetable('\\1', '\\2', '\\3')"; $discuzcodes['searcharray']['bbcode_regexp'][] = "/\\[table(?:=(\\d{1,4}%?)(?:,([\\(\\)%,#\\w ]+))?)?\\]\\s*(.+?)\\s*\\[\\/table\\]/ies"; $discuzcodes['replacearray']['bbcode_regexp'][] = "parsetable('\\1', '\\2', '\\3')"; if ($parsetype != 1) { $discuzcodes['searcharray']['bbcode_regexp'][] = "/\\s*\\[quote\\][\n\r]*(.+?)[\n\r]*\\[\\/quote\\]\\s*/is"; $discuzcodes['searcharray']['bbcode_regexp'][] = "/\\s*\\[free\\][\n\r]*(.+?)[\n\r]*\\[\\/free\\]\\s*/is"; $discuzcodes['replacearray']['bbcode_regexp'][] = tpl_quote(); $discuzcodes['replacearray']['bbcode_regexp'][] = tpl_free(); } $discuzcodes['searcharray']['bbcode_regexp'] = array_merge($discuzcodes['searcharray']['bbcode_regexp'], $discuzcodes['searcharray']['bbcode_regexp']); $discuzcodes['replacearray']['bbcode_regexp'] = array_merge($discuzcodes['replacearray']['bbcode_regexp'], $discuzcodes['replacearray']['bbcode_regexp']); $discuzcodes['searcharray']['bbcode_str'] = array('[/color]', '[/size]', '[/font]', '[/align]', '[b]', '[/b]', '[i]', '[/i]', '[u]', '[/u]', '[list]', '[list=1]', '[list=a]', '[list=A]', '[*]', '[/list]', '[indent]', '[/indent]', '[/float]'); $discuzcodes['replacearray']['bbcode_str'] = array('</font>', '</font>', '</font>', '</p>', '<strong>', '</strong>', '<i>', '</i>', '<u>', '</u>', '<ul>', '<ul type="1">', '<ul type="a">', '<ul type="A">', '<li>', '</ul>', '<blockquote>', '</blockquote>', '</span>'); } $discuzcodes['searcharray']['bbcode_regexp'][] = "/\\[media=(\\w{1,4}),(\\d{1,4}),(\\d{1,4}),(\\d)\\]\\s*([^\\[\\<\r\n]+?)\\s*\\[\\/media\\]/ies"; if ($allowmediacode) { $discuzcodes['replacearray']['bbcode_regexp'][] = "parsemedia('\\1', \\2, \\3, \\4, '\\5')"; } else { $discuzcodes['replacearray']['bbcode_regexp'][] = "bbcodeurl('\\5', '<a href=\"%s\" target=\"_blank\">%s</a>')"; } @($message = str_replace($discuzcodes['searcharray']['bbcode_str'], $discuzcodes['replacearray']['bbcode_str'], preg_replace($parsetype != 1 && $allowbbcode == 2 && $GLOBALS['_DCACHE']['bbcodes'] ? array_merge($discuzcodes['searcharray']['bbcode_regexp'], $GLOBALS['_DCACHE']['bbcodes']['searcharray']) : $discuzcodes['searcharray']['bbcode_regexp'], $parsetype != 1 && $allowbbcode == 2 && $GLOBALS['_DCACHE']['bbcodes'] ? array_merge($discuzcodes['replacearray']['bbcode_regexp'], $GLOBALS['_DCACHE']['bbcodes']['replacearray']) : $discuzcodes['replacearray']['bbcode_regexp'], $message))); if ($parsetype != 1 && preg_match("/\\[hide=?\\d*\\].+?\\[\\/hide\\]/is", $message)) { if (stristr($message, '[hide]')) { $query = $db->query("SELECT pid FROM {$tablepre}posts WHERE tid='{$tid}' AND " . ($discuz_uid ? "authorid='{$discuz_uid}'" : "authorid=0 AND useip='{$GLOBALS['onlineip']}'") . " LIMIT 1"); if ($GLOBALS['forum']['ismoderator'] || ($apid = $db->result($query, 0))) { $message = preg_replace("/\\[hide\\]\\s*(.+?)\\s*\\[\\/hide\\]/is", tpl_hide_reply(), $message); $hideattach[$apid] = 0; } else { $message = preg_replace("/\\[hide\\](.+?)\\[\\/hide\\]/is", tpl_hide_reply_hidden(), $message); $hideattach[$pid] = 1; } } $message = preg_replace("/\\[hide=(\\d+)\\]\\s*(.+?)\\s*\\[\\/hide\\]/ies", "creditshide(\\1,'\\2', {$pid})", $message); } } if (!$bbcodeoff) { $message = preg_replace(array($parsetype != 1 ? "/\\[swf\\]\\s*([^\\[\\<\r\n]+?)\\s*\\[\\/swf\\]/ies" : "//", "/\\[img\\]\\s*([^\\[\\<\r\n]+?)\\s*\\[\\/img\\]/ies", "/\\[img=(\\d{1,4})[x|\\,](\\d{1,4})\\]\\s*([^\\[\\<\r\n]+?)\\s*\\[\\/img\\]/ies"), $allowimgcode ? array($parsetype != 1 ? "bbcodeurl('\\1', ' <img src=\"images/attachicons/flash.gif\" align=\"absmiddle\" alt=\"\" /> <a href=\"%s\" target=\"_blank\">Flash: %s</a> ')" : "", "bbcodeurl('\\1', '<img src=\"%s\" border=\"0\" onclick=\"zoom(this)\" onload=\"attachimg(this, \\'load\\')\" alt=\"\" />')", "bbcodeurl('\\3', '<img width=\"\\1\" height=\"\\2\" src=\"%s\" border=\"0\" alt=\"\" />')") : array($parsetype != 1 ? "bbcodeurl('\\1', ' <img src=\"images/attachicons/flash.gif\" align=\"absmiddle\" alt=\"\" /> <a href=\"%s\" target=\"_blank\">Flash: %s</a> ')" : "", "bbcodeurl('\\1', '<a href=\"%s\" target=\"_blank\">%s</a>')", "bbcodeurl('\\3', '<a href=\"%s\" target=\"_blank\">%s</a>')"), $message); } for ($i = 0; $i <= $discuzcodes['pcodecount']; $i++) { $message = str_replace("[\tDISCUZ_CODE_{$i}\t]", $discuzcodes['codehtml'][$i], $message); } if ($highlight) { $highlightarray = explode('+', $highlight); $message = preg_replace('#(^|>)([^<]+)(?=<|$)#sUe', "highlight('\\2', \$highlightarray, '\\1', 0)", $message); } return $htmlon || $allowhtml ? $message : nl2br(str_replace(array("\t", ' ', ' '), array(' ', ' ', ' '), $message)); }