$param, 'caller' => 'discuzcode'), 'discuzcode'); } $_G['delattach'] = array(); $message = fparsesmiles($message); if(strpos($msglower, 'attach://') !== FALSE) { $message = preg_replace("/attach:\/\/(\d+)\.?(\w*)/i", '', $message); } if(strpos($msglower, 'ed2k://') !== FALSE) { $message = preg_replace("/ed2k:\/\/(.+?)\//", '', $message); } if(strpos($msglower, '[/i]') !== FALSE) { $message = preg_replace("/\s*\[i=s\][\n\r]*(.+?)[\n\r]*\[\/i\]\s*/is", '', $message); } $message = str_replace('[/p]', "\n", $message); $message = str_replace(array( '[/color]', '[/backcolor]', '[/size]', '[/font]', '[/align]', '[b]', '[/b]', '[s]', '[/s]', '[hr]', '[i=s]', '[i]', '[/i]', '[u]', '[/u]', '[list]', '[list=1]', '[list=a]', '[list=A]', "\r\n[*]", '[*]', '[/list]', '[indent]', '[/indent]', '[/float]' ), '', 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", "/\[float=left\]/i", "/\[float=right\]/i" ), '', $message)); if(strpos($msglower, '[/p]') !== FALSE) { $message = preg_replace("/\[p=(\d{1,2}|null), (\d{1,2}|null), (left|center|right)\]/i", "

", $message); $message = str_replace('[/p]', '

', $message); } if(strpos($msglower, '[/quote]') !== FALSE) { $message = preg_replace("/\s?\[quote\][\n\r]*(.+?)[\n\r]*\[\/quote\]\s?/is", '', $message); } if(strpos($msglower, '[/free]') !== FALSE) { $message = preg_replace("/\s*\[free\][\n\r]*(.+?)[\n\r]*\[\/free\]\s*/is", '', $message); } if(isset($_G['cache']['bbcodes'][-$allowbbcode])) { $message = preg_replace($_G['cache']['bbcodes'][-$allowbbcode]['searcharray'], '', $message); } if(strpos($msglower, '[/hide]') !== FALSE) { preg_replace_callback("/\[hide.*?\]\s*(.*?)\s*\[\/hide\]/is", 'followcode_callback_hideattach_1', $message); if(strpos($msglower, '[hide]') !== FALSE) { $message = preg_replace("/\[hide\]\s*(.*?)\s*\[\/hide\]/is", '', $message); } if(strpos($msglower, '[hide=') !== FALSE) { $message = preg_replace("/\[hide=(d\d+)?[,]?(\d+)?\]\s*(.*?)\s*\[\/hide\]/is", '', $message); } } if(strpos($msglower, '[/url]') !== FALSE) { $message = preg_replace_callback("/\[url(=((https?|ftp|gopher|news|telnet|rtsp|mms|callto|bctp|thunder|qqdl|synacast){1}:\/\/|www\.|mailto:)?([^\r\n\[\"']+?))?\](.+?)\[\/url\]/is", 'followcode_callback_fparseurl_152', $message); } if(strpos($msglower, '[/email]') !== FALSE) { $message = preg_replace_callback("/\[email(=([a-z0-9\-_.+]+)@([a-z0-9\-_]+[.][a-z0-9\-_.]+))?\](.+?)\[\/email\]/is", 'followcode_callback_fparseemail_14', $message); } $nest = 0; while(strpos($msglower, '[table') !== FALSE && strpos($msglower, '[/table]') !== FALSE){ $message = preg_replace_callback("/\[table(?:=(\d{1,4}%?)(?:,([\(\)%,#\w ]+))?)?\]\s*(.+?)\s*\[\/table\]/is", 'followcode_callback_fparsetable_123', $message); if(++$nest > 4) break; } if(strpos($msglower, '[/media]') !== FALSE) { $message = preg_replace_callback("/\[media=([\w,]+)\]\s*([^\[\<\r\n]+?)\s*\[\/media\]/is", 'followcode_callback_fparsemedia_12', $message); } if(strpos($msglower, '[/audio]') !== FALSE) { $message = preg_replace_callback("/\[audio(=1)*\]\s*([^\[\<\r\n]+?)\s*\[\/audio\]/is", 'followcode_callback_fparseaudio_2', $message); } if(strpos($msglower, '[/flash]') !== FALSE) { $message = preg_replace_callback("/\[flash(=(\d+),(\d+))?\]\s*([^\[\<\r\n]+?)\s*\[\/flash\]/is", 'followcode_callback_fparseflash_4', $message); } if($parsetype != 1 && strpos($msglower, '[swf]') !== FALSE) { $message = preg_replace_callback("/\[swf\]\s*([^\[\<\r\n]+?)\s*\[\/swf\]/is", 'followcode_callback_bbcodeurl_1', $message); } $flag = $length ? 1 : 0; if($tid) { $extra = "onclick=\"changefeed($tid, $pid, $flag, this)\""; } if(strpos($msglower, '[/img]') !== FALSE) { $message = preg_replace_callback("/\[img\]\s*([^\[\<\r\n]+?)\s*\[\/img\]/is", create_function('$matches', 'return '.intval($allowimg).' ? fparseimg($matches[1], \''.addslashes($extra).'\') : \'\';'), $message); $message = preg_replace_callback("/\[img=(\d{1,4})[x|\,](\d{1,4})\]\s*([^\[\<\r\n]+?)\s*\[\/img\]/is", create_function('$matches', 'return '.intval($allowimg).' ? fparseimg($matches[3], \''.addslashes($extra).'\') : \'\';'), $message); } if($tid && $pid) { $_G['post_attach'] = C::t('forum_attachment_n')->fetch_all_by_id(getattachtableid($tid), 'pid', $pid); foreach($_G['post_attach'] as $aid => $attach) { if(!empty($_G['delattach']) && in_array($aid, $_G['delattach'])) { continue; } $message .= "[attach]$attach[aid][/attach]"; $message = preg_replace("/\[attach\]$attach[aid]\[\/attach\]/i", fparseattach($attach['aid'], $length, $extra), $message, 1); } } if(strpos($msglower, '[/attach]') !== FALSE) { $message = preg_replace("/\[attach\]\s*([^\[\<\r\n]+?)\s*\[\/attach\]/is", '', $message); } $message = clearnl($message); if($length) { $sppos = strpos($message, chr(0).chr(0).chr(0)); if($sppos !== false) { $message = substr($message, 0, $sppos); } $checkstr = cutstr($message, $length, ''); if(strpos($checkstr, '[') && strpos(strrchr($checkstr, "["), ']') === FALSE) { $length = strpos($message, ']', strrpos($checkstr, strrchr($checkstr, "["))); } $message = cutstr($message, $length+1, ' '.lang('space', 'follow_view_fulltext').''); } elseif($allowimg && !empty($extra)) { $message .= '
'.lang('space', 'follow_retract').'
'; } for($i = 0; $i <= $_G['forum_discuzcode']['pcodecount']; $i++) { $code = ''; if(isset($_G['forum_discuzcode']['codehtml'][$i]) && !empty($_G['forum_discuzcode']['codehtml'][$i])) { $code = $_G['forum_discuzcode']['codehtml'][$i]; } elseif(!$length) { if(isset($_G['forum_discuzcode']['audio'][$i]) && !empty($_G['forum_discuzcode']['audio'][$i])) { $code = $_G['forum_discuzcode']['audio'][$i]; } elseif(isset($_G['forum_discuzcode']['video'][$i]) && !empty($_G['forum_discuzcode']['video'][$i])) { $code = $_G['forum_discuzcode']['video'][$i]; } elseif(isset($_G['forum_discuzcode']['media'][$i]) && !empty($_G['forum_discuzcode']['media'][$i])) { $code = $_G['forum_discuzcode']['media'][$i]; } elseif(isset($_G['forum_discuzcode']['image'][$i]) && !empty($_G['forum_discuzcode']['image'][$i])) { $code = $_G['forum_discuzcode']['image'][$i]; } elseif(isset($_G['forum_discuzcode']['attach'][$i]) && !empty($_G['forum_discuzcode']['attach'][$i])) { $code = $_G['forum_discuzcode']['attach'][$i]; } } $message = str_replace("[\tD_$i\t]", $code, $message); } $message = clearnl($message); if(!empty($_GET['highlight'])) { $highlightarray = explode('+', $_GET['highlight']); $sppos = strrpos($message, chr(0).chr(0).chr(0)); if($sppos !== FALSE) { $specialextra = substr($message, $sppos + 3); $message = substr($message, 0, $sppos); } followcode_callback_highlightword_21($highlightarray, 1); $message = preg_replace_callback("/(^|>)([^<]+)(?=<|$)/sU", 'followcode_callback_highlightword_21', $message); $message = preg_replace("/(.*)<\/highlight>/siU", "\\1", $message); if($sppos !== FALSE) { $message = $message.chr(0).chr(0).chr(0).$specialextra; } } unset($msglower); if($length) { $count = 0; $imagecode = $mediacode = $videocode = $audiocode = $mediahtml = ''; for($i = 0; $i <= $_G['forum_discuzcode']['pcodecount']; $i++) { if(isset($_G['forum_discuzcode']['audio'][$i]) && !empty($_G['forum_discuzcode']['audio'][$i])) { $audiocode .= '
  • '.$_G['forum_discuzcode']['audio'][$attachcodei].'
  • '; } elseif(isset($_G['forum_discuzcode']['video'][$i]) && !empty($_G['forum_discuzcode']['video'][$i])) { $videocode .= '
  • '.$_G['forum_discuzcode']['video'][$i].'
  • '; } elseif(isset($_G['forum_discuzcode']['media'][$i]) && !empty($_G['forum_discuzcode']['media'][$i])) { $mediacode .= '
  • '.$_G['forum_discuzcode']['media'][$i].'
  • '; } elseif(isset($_G['forum_discuzcode']['image'][$i]) && !empty($_G['forum_discuzcode']['image'][$i]) && $count < 4) { $imagecode .= '
  • '.$_G['forum_discuzcode']['image'][$i].'
  • '; $count++; } elseif(isset($_G['forum_discuzcode']['attach'][$i]) && !empty($_G['forum_discuzcode']['attach'][$i])) { $attachcode .= '
  • '.$_G['forum_discuzcode']['attach'][$i].'
  • '; } } if(!empty($audiocode)) { $message .= '
    '; } if(!empty($videocode)) { $message .= '
    '; } if(!empty($mediacode)) { $message .= '
    '; } if(!empty($imagecode)) { $message = '
    '.$message; } if(!empty($attachcode)) { $message .= '
    '; } } return $htmlon ? $message : nl2br(str_replace(array("\t", ' ', ' '), ' ', $message)); } function followcode_callback_hideattach_1($matches) { return hideattach($matches[1]); } function followcode_callback_fparseurl_152($matches) { return fparseurl($matches[1], $matches[5], $matches[2]); } function followcode_callback_fparseemail_14($matches) { return fparseemail($matches[1], $matches[4]); } function followcode_callback_fparsetable_123($matches) { return fparsetable($matches[1], $matches[2], $matches[3]); } function followcode_callback_fparsemedia_12($matches) { return fparsemedia($matches[1], $matches[2]); } function followcode_callback_fparseaudio_2($matches) { return fparseaudio($matches[2]); } function followcode_callback_fparseflash_4($matches) { return fparseflash($matches[4]); } function followcode_callback_bbcodeurl_1($matches) { return bbcodeurl($matches[1], ' Flash: {url} '); } function followcode_callback_highlightword_21($matches, $action = 0) { static $highlightarray = array(); if($action == 1) { $highlightarray = $matches; } else { return highlightword($matches[2], $highlightarray, $matches[1]); } } function clearnl($message) { $message = preg_replace("/[\r\n|\n|\r]\s*[\r\n|\n|\r]/i", "\n", $message); $message = preg_replace("/^[\r\n|\n|\r]{1,}/i", "", $message); $message = preg_replace("/[\r\n|\n|\r]{2,}/i", "\n", $message); return $message; } function hideattach($hidestr) { global $_G; preg_match_all("/\[attach\]\s*(.*?)\s*\[\/attach\]/is", $hidestr, $del); foreach($del[1] as $aid) { $_G['delattach'][$aid] = $aid; } } function fparseurl($url, $text, $scheme) { global $_G; $html = ''; if(!$url && preg_match("/((https?|ftp|gopher|news|telnet|rtsp|mms|callto|bctp|thunder|qqdl|synacast){1}:\/\/|www\.)[^\[\"']+/i", trim($text), $matches)) { $url = $matches[0]; $length = 65; if(strlen($url) > $length) { $text = substr($url, 0, intval($length * 0.5)).' ... '.substr($url, - intval($length * 0.3)); } $html = ''.$text.''; } else { $url = substr($url, 1); if(substr(strtolower($url), 0, 4) == 'www.') { $url = 'http://'.$url; } $url = !$scheme ? $_G['siteurl'].$url : $url; $atclass = substr(strtolower($text), 0, 1) == '@' ? ' class="xi2" ' : ''; $html = ''.$text.''; } return fcodedisp($html); } function fparseattach($aid, $length = 0, $extra = '') { global $_G; $html = ''; if(!empty($_G['post_attach']) && !empty($_G['post_attach'][$aid])) { $attach = $_G['post_attach'][$aid]; unset($_G['post_attach'][$attach['aid']]); $attach['url'] = ($attach['remote'] ? $_G['setting']['ftp']['attachurl'] : $_G['setting']['attachurl']).'forum/'; $attach['isimage'] = $attach['isimage'] && !$attach['price'] ? $attach['isimage'] : 0; $attach['refcheck'] = (!$attach['remote'] && $_G['setting']['attachrefcheck']) || ($attach['remote'] && ($_G['setting']['ftp']['hideurl'] || ($attach['isimage'] && $_G['setting']['attachimgpost'] && strtolower(substr($_G['setting']['ftp']['attachurl'], 0, 3)) == 'ftp'))); $rimg_id = random(5).$attach['aid']; if($attach['isimage'] && !$attach['price'] && !$attach['readperm']) { $nothumb = $length ? 0 : 1; $src = $attach['url'].(!$attach['thumb'] ? $attach['attachment'] : getimgthumbname($attach['attachment'])); $html = bbcodeurl($src, ''.$attach['filename'].''); return fcodedisp($html, 'image'); } else { if($attach['price'] || $attach['readperm']) { $html = ''.$attach['filename'].''.sizecount($attach['filesize']).''; } else { require_once libfile('function/attachment'); $aidencode = packaids($attach); $attachurl = "forum.php?mod=attachment&aid=$aidencode"; $html = ''.$attach['filename'].''.sizecount($attach['filesize']).''; } return fcodedisp($html, 'attach'); } } return ''; } function fparseflash($url) { preg_match("/((https?){1}:\/\/|www\.)[^\[\"']+/i", $url, $matches); $url = $matches[0]; if(fileext($url) != 'flv') { $rimg_id = 'swf_'.random(5); $html = bbcodeurl($url, ''.lang('space', 'follow_click_play').''); return fcodedisp($html, 'media'); } else { $url = STATICURL.'image/common/flvplayer.swf?&autostart=true&file='.urlencode($matches[0]); return fmakeflv($url); } } function fparseemail($email, $text) { global $_G; $text = str_replace('\"', '"', $text); $html = ''; if(!$email && preg_match("/\s*([a-z0-9\-_.+]+)@([a-z0-9\-_]+[.][a-z0-9\-_.]+)\s*/i", $text, $matches)) { $email = trim($matches[0]); $html = ''.$email.''; } else { $html = ''.$text.''; } return fcodedisp($html); } function fparsetable($width, $bgcolor, $message) { global $_G; $html = ''; if(strpos($message, '[/tr]') === FALSE && strpos($message, '[/td]') === FALSE) { $rows = explode("\n", $message); $html = '' : '>'); foreach($rows as $row) { $html .= ''; } $html .= '
    '.str_replace(array('\|', '|', '\n'), array('|', '', "\n"), $row).'
    '; } else { if(!preg_match("/^\[tr(?:=([\(\)\s%,#\w]+))?\]\s*\[td([=\d,%]+)?\]/", $message) && !preg_match("/^]*?>\s*]*?>/", $message)) { return str_replace('\\"', '"', preg_replace("/\[tr(?:=([\(\)\s%,#\w]+))?\]|\[td([=\d,%]+)?\]|\[\/td\]|\[\/tr\]/", '', $message)); } if(substr($width, -1) == '%') { $width = substr($width, 0, -1) <= 98 ? intval($width).'%' : '98%'; } else { $width = intval($width); $width = $width ? ($width <= 560 ? $width.'px' : '98%') : ''; } $message = preg_replace_callback("/\[tr(?:=([\(\)\s%,#\w]+))?\]\s*\[td(?:=(\d{1,4}%?))?\]/i", 'fparsetable_callback_parsetrtd_12', $message); $message = preg_replace_callback("/\[\/td\]\s*\[td(?:=(\d{1,4}%?))?\]/i", 'fparsetable_callback_parsetrtd_1', $message); $message = preg_replace_callback("/\[tr(?:=([\(\)\s%,#\w]+))?\]\s*\[td(?:=(\d{1,2}),(\d{1,2})(?:,(\d{1,4}%?))?)?\]/i", 'fparsetable_callback_parsetrtd_1234', $message); $message = preg_replace_callback("/\[\/td\]\s*\[td(?:=(\d{1,2}),(\d{1,2})(?:,(\d{1,4}%?))?)?\]/i", 'fparsetable_callback_parsetrtd_123', $message); $html = '' : '>'). str_replace('\\"', '"', preg_replace("/\[\/td\]\s*\[\/tr\]\s*/i", '', $message) ).'
    '; } return fcodedisp($html); } function fparsetable_callback_parsetrtd_12($matches) { return parsetrtd($matches[1], 0, 0, $matches[2]); } function fparsetable_callback_parsetrtd_1($matches) { return parsetrtd('td', 0, 0, $matches[1]); } function fparsetable_callback_parsetrtd_1234($matches) { return parsetrtd($matches[1], $matches[2], $matches[3], $matches[4]); } function fparsetable_callback_parsetrtd_123($matches) { return parsetrtd('td', $matches[1], $matches[2], $matches[3]); } function fparseaudio($url) { $url = addslashes($url); if(!in_array(strtolower(substr($url, 0, 6)), array('http:/', 'https:', 'ftp://', 'rtsp:/', 'mms://')) && !preg_match('/^static\//', $url) && !preg_match('/^data\//', $url)) { return dhtmlspecialchars($url); } if(fileext($url) == 'mp3') { $randomid = 'music_'.random(3); $html = ''.lang('space', 'follow_click_play').''; return fcodedisp($html, 'audio'); } else { $html = ''.$url.''; return $html; } } function fmakeflv($flv) { $randomid = 'video_'.random(3); $flv = is_array($flv) ? $flv : array('flv' => $flv); if(!preg_match("/^((https?){1}:\/\/|www\.)[^\[\"']+$/i", $flv['flv'])) { return fcodedisp('', 'video'); } if(!empty($flv['imgurl'])) { if(!preg_match("/^((https?){1}:\/\/|www\.)[^\[\"']+$/i", $flv['imgurl'])) { $html = ''; } else { $html = '
    '.lang('space', 'follow_click_play').'
    '; } } else { $html = ''.lang('space', 'follow_click_play').''; } return fcodedisp($html, 'video'); } function fparsemedia($params, $url) { $params = explode(',', $params); $url = addslashes($url); $html = ''; if($flv = parseflv($url, 0, 0)) { return fmakeflv($flv); } if(in_array(count($params), array(3, 4))) { $type = $params[0]; $url = str_replace(array('<', '>'), '', str_replace('\\"', '\"', $url)); switch($type) { case 'mp3': return fparseaudio($url); break; case 'flv': $url = STATICURL.'image/common/flvplayer.swf?&autostart=true&file='.urlencode($url); return fmakeflv($url); break; case 'swf': return fparseflash($url); break; default: $html = ''.$url.''; break; } } return fcodedisp($html, 'media'); } function fparseimg($src, $extra = '') { global $_G; $rimg_id = random(5); $html = bbcodeurl($src, ''); return fcodedisp($html, 'image'); } function fparsesmiles(&$message) { global $_G; static $enablesmiles; if($enablesmiles === null) { $enablesmiles = false; if(!empty($_G['cache']['smilies']) && is_array($_G['cache']['smilies'])) { foreach($_G['cache']['smilies']['replacearray'] AS $key => $smiley) { if(substr($_G['cache']['smilies']['replacearray'][$key], 0, 1) == '<') { break; } $_G['cache']['smilies']['replacearray'][$key] = ''; } $enablesmiles = true; } } $enablesmiles && $message = preg_replace($_G['cache']['smilies']['searcharray'], $_G['cache']['smilies']['replacearray'], $message, $_G['setting']['maxsmilies']); return $message; } ?>