麻辣堂|资源主站|开发论坛|在线手册
首页 Apache Linux Java MySQL 注册帮助 
PHP项目开发组是PHP开发资源网于2007组年建成立的项目开发团队,目前核心开发成员有27人, 项目协作成员8名.下设7个开发组,主要承接大/中型网站项目开发任务。

    由于开发任务较多,人员比较紧张,现面向社会招聘全职或者兼职开发人员,不管你是在校大学生,还是全职开发人员,以及SOHO都可以联系本站,我们可以长期合作,并为您带来丰厚的报酬。
  您现在的位置:PHP开发资源网 > 麻辣堂 > 详细资料
待解决
Ubb疑问。高手请进
悬赏分:20 - 2007年08月18日

最近正在开发一个用UBB做的论坛发帖插入表格的插件(DZ) 可是碰到超多的问题。。。看到这里高手很热心。希望能给解答。不胜感激。 dz原版discuzcode.func.php如下

QUOTE:
<?php if(!defined('IN_DISCUZ')) { exit('Access Denied'); } $discuzcodes = array ( 'pcodecount' => -1, 'codecount' => 0, 'codehtml' => '', 'searcharray' => array(), 'replacearray' => array(), 'seoarray' => array ( 0 => '', 1 => $_SERVER['HTTP_HOST'], 2 => $bbname, 3 => $seotitle, 4 => $seokeywords, 5 => $seodescription ) ); if(is_array($_DCACHE['smilies']['replacearray'])) { foreach($_DCACHE['smilies']['replacearray'] as $key => $smiley) { $_DCACHE['smilies']['replacearray'][$key] = ''; } } mt_srand((double)microtime() * 1000000); function attachtag($pid, $aid) { global $language, $postlist, $attachrefcheck, $attachurl; if(isset($postlist[$pid]['attachments'][$aid])) { include_once language('misc'); $attach = $postlist[$pid]['attachments'][$aid]; unset($postlist[$pid]['attachments'][$aid]); $replacement = "

$attach[attachicon] "; if($attach['attachimg']) { $replacement .= "$language[attach_img]: ". ($attach['readperm'] ? ", $language[attach_readperm] $attach[readperm]" : ''). ($attach['description'] ? "[{$attach[description]}]" : ''). " $attach[filename] ($attach[dateline], $attach[attachsize])

". ($attachrefcheck ? "screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt='$language[attach_img_zoom]';}\" onmouseover=\"if(this.resized) this.style.cursor='hand';\" onclick=\"if(!this.resized) {return false;} else {window.open('attachment.php?aid=$attach[aid]');}\" onmousewheel=\"return imgzoom(this);\">" : "screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt='$language[attach_img_zoom]';}\" onmouseover=\"if(this.resized) this.style.cursor='hand';\" onclick=\"if(!this.resized) {return false;} else {window.open('".addslashes("$attachurl/$attach[attachment]")."');}\" onmousewheel=\"return imgzoom(this);\">"); } else { $replacement .= "$language[attach]: ". ($attach['description'] ? "[{$attach[description]}]" : ''). " $attach[filename] ($attach[dateline], $attach[attachsize])
$language[attach_download_count] $attach[downloads]". ($attach['readperm'] ? ", $language[attach_readperm] $attach[readperm]" : ''). "
"; } return $replacement; } else { return ''; } } function censor($message) { global $_DCACHE; require_once(DISCUZ_ROOT.'/forumdata/cache/cache_censor.php'); if($_DCACHE['censor']['banned'] && preg_match($_DCACHE['censor']['banned'], $message)) { showmessage('word_banned'); } else { return empty($_DCACHE['censor']['filter']) ? $message : @preg_replace($_DCACHE['censor']['filter']['find'], $_DCACHE['censor']['filter']['replace'], $message); } } function censormod($message) { global $_DCACHE; require_once(DISCUZ_ROOT.'/forumdata/cache/cache_censor.php'); return $_DCACHE['censor']['mod'] && preg_match($_DCACHE['censor']['mod'], $message); } function creditshide($creditsrequire, $message) { global $language; include_once language('misc'); if($GLOBALS['credits'] < $creditsrequire && !$GLOBALS['forum']['ismoderator']) { return ''.eval("return \"$language[post_hide_credits_hidden]\";").''; } else { return ''.eval("return \"$language[post_hide_credits]\";").'
'. '==============================

'. str_replace('\\"', '"', $message).'

'. '=============================='; } } function codedisp($code) { global $discuzcodes; $discuzcodes['pcodecount']++; $code = htmlspecialchars(str_replace('\\"', '"', preg_replace("/^[\n\r]*(.+?)[\n\r]*$/is", "\\1", $code))); $discuzcodes['codehtml'][$discuzcodes['pcodecount']] = "

$code
"; $discuzcodes['codecount']++; return "[\tDISCUZ_CODE_$discuzcodes[pcodecount]\t]"; } function karmaimg($rate, $ratetimes) { $karmaimg = ''; if($rate && $ratetimes) { $image = $rate > 0 ? 'agree.gif' : 'disagree.gif'; for($i = 0; $i < ceil(abs($rate) / $ratetimes); $i++) { $karmaimg .= ''; } } return $karmaimg; } function parseurl($message) { return preg_match("/\[code\].+?\[\/code\]/is", $message) ? $message : substr(preg_replace( array( "/(?<=[^\]a-z0-9-=\"'\\/])(http:\/\/[a-z0-9\/\-_+=.~!%@?#%&;\\()|]+\.(jpg|gif|png|bmp))/i", "/(?<=[^\]a-z0-9-=\"'\\/])((https?|ftp|gopher|news|telnet|rtsp|mms|callto|ed2k):\/\/|www\.)([a-z0-9\/\-_+=.~!%@?#%&;\\()|]+)/i", "/(?<=[^\]\)a-z0-9\/\-_.~?=:.])([_a-z0-9-+]+(\.[_a-z0-9-+]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4}))/i" ), array( "

", "[url]\\1\\3[/url]", "[email]\\0[/email]" ), ' '.$message), 1); } function discuzcode($message, $smileyoff, $bbcodeoff, $htmlon = 0, $allowsmilies = 1, $allowbbcode = 1, $allowimgcode = 1, $allowhtml = 0, $jammer = 0) { global $discuzcodes, $credits, $tid, $discuz_uid, $highlight, $maxsmilies, $db, $tablepre; if(!$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( "/\s*\[quote\][\n\r]*(.+?)[\n\r]*\[\/quote\]\s*/is", "/\[url\]\s*([url]www.[/url]|https?:\/\/|ftp:\/\/|gopher:\/\/|news:\/\/|telnet:\/\/|rtsp:\/\/|mms:\/\/|callto:\/\/|ed2k:\/\/){1}([^\[\"']+?)\s*\[\/url\]/ie", "/\[url=www.([^\[\"']+?)\](.+?)\[\/url\]/is", "/\[url=(https?|ftp|gopher|news|telnet|rtsp|mms|callto|ed2k){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=([^\[\<]+?)\]/i", "/\[size=([^\[\<]+?)\]/i", "/\[font=([^\[\<]+?)\]/i", "/\[align=([^\[\<]+?)\]/i", "/\s*\[center\][\n\r]*(.+?)[\n\r]*\[\/center\]\s*/is", ); $discuzcodes['replacearray']['bbcode_regexp'] = array( "

\\1
", "cuturl('\\1\\2')", "\\2", "\\3", "\\1@\\2", "\\3", "", "", "", "

", "

\\1
", ); $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_regexp'][] = "/\[payto\]\s*\(seller\)(.*)\(\/seller\)\s*(\(subject\)(.*)\(\/subject\))?\s*(\(body\)(.*)\(\/body\))?\s*(\(gross\)(.*)\(\/gross\))?\s*(\(price\)(.*)\(\/price\))?\s*(\(ordinary_fee\)(.*)\(\/ordinary_fee\))?\s*(\(express_fee\)(.*)\(\/express_fee\))?\s*(\(url\)(.*)\(\/url\))?\s*(\(type\)(.*)\(\/type\))?\s*\[\/payto\]/iesU"; $discuzcodes['replacearray']['bbcode_regexp'][] = "payto('\\1',array('subject'=>'\\3','body'=>'\\5','gross'=>'\\7','price'=>'\\9','ordinary_fee'=>'\\11','express_fee'=>'\\13','url'=>'\\15','type'=>'\\17'))"; $discuzcodes['searcharray']['bbcode_str'] = array( '
', '
', '
', '

', '', '', '', '', '', '', '
    ', '
      ', '
        ', '
          ', '
        1. ', '
' ); $discuzcodes['replacearray']['bbcode_str'] = array( '', '', '', '

', '', '', '', '', '', '', '
    ', '
      ', '
        ', '
          ', '
        1. ', '
' ); } @$message = str_replace($discuzcodes['searcharray']['bbcode_str'], $discuzcodes['replacearray']['bbcode_str'], preg_replace( ($allowbbcode == 2 && $GLOBALS['_DCACHE']['bbcodes'] ? array_merge($discuzcodes['searcharray']['bbcode_regexp'], $GLOBALS['_DCACHE']['bbcodes']['searcharray']) : $discuzcodes['searcharray']['bbcode_regexp']), ($allowbbcode == 2 && $GLOBALS['_DCACHE']['bbcodes'] ? array_merge($discuzcodes['replacearray']['bbcode_regexp'], $GLOBALS['_DCACHE']['bbcodes']['replacearray']) : $discuzcodes['replacearray']['bbcode_regexp']), $message)); if(preg_match("/\[hide=?\d*\].+?\[\/hide\]/is", $message)) { if(stristr($message, '[hide]')) { global $language; include_once language('misc'); $query = $db->query("SELECT pid FROM {$tablepre}posts WHERE tid='$tid' AND authorid='$discuz_uid' LIMIT 1"); if($GLOBALS['forum']['ismoderator'] || $db->result($query, 0)) { $message = preg_replace("/\[hide\]\s*(.+?)\s*\[\/hide\]/is", ''.$language['post_hide_reply'].'
'. '==============================

'. '\\1

'. '==============================', $message); } else { $message = preg_replace("/\[hide\](.+?)\[\/hide\]/is", ''.$language['post_hide_reply_hidden'].'', $message); } } $message = preg_replace("/\[hide=(\d+)\]\s*(.+?)\s*\[\/hide\]/ies", "creditshide(\\1,'\\2')", $message); } } if(!$bbcodeoff && $allowimgcode) { if(empty($discuzcodes['searcharray']['imgcode'])) { $discuzcodes['searcharray']['imgcode'] = array( "/\[swf\]\s*([^\[\<\r\n]+?)\s*\[\/swf\]/ies", "/\[img\]\s*([^\[\<\r\n]+?)\s*\[\/img\]/ies", "/\[img=(\d{1,3})[x|\,](\d{1,3})\]\s*([^\[\<\r\n]+?)\s*\[\/img\]/ies" ); $discuzcodes['replacearray']['imgcode'] = array( "bbcodeurl('\\1', ' Flash: %s ')", "bbcodeurl('\\1', 'screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt=\'Click here to open new window\\nCTRL+Mouse wheel to zoom in/out\';}\" onmouseover=\"if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.style.cursor=\'hand\'; this.alt=\'Click here to open new window\\nCTRL+Mouse wheel to zoom in/out\';}\" onclick=\"if(!this.resized) {return true;} else {window.open(\'%s\');}\" onmousewheel=\"return imgzoom(this);\">')", "bbcodeurl('\\3', '')" ); } $message = preg_replace($discuzcodes['searcharray']['imgcode'], $discuzcodes['replacearray']['imgcode'], $message); } for($i = 0; $i <= $discuzcodes['pcodecount']; $i++) { $message = str_replace("[\tDISCUZ_CODE_$i\t]", $discuzcodes['codehtml'][$i], $message); } if($highlight) { foreach(explode('+', $highlight) as $ret) { if($ret) { $message = preg_replace("/(?<=[\s\"\]>()]|[\x7f-\xff]|^)(".preg_quote($ret, '/').")(([.,:;-?!()\s\"<\[]|[\x7f-\xff]|$))/siU", "\\1\\2", $message); } } } return $htmlon || $allowhtml ? $message : nl2br(str_replace(array("\t", ' ', ' '), array('        ', '   ', '  '), $message)); } function cuturl($url) { $length = 65; $urllink = "'; if(strlen($url) > $length) { $url = substr($url, 0, intval($length * 0.5)).' ... '.substr($url, - intval($length * 0.3)); } $urllink .= $url.''; return $urllink; } function bbcodeurl($url, $tags) { if(!preg_match("/<.+?>/s", $url)) { if(!in_array(strtolower(substr($url, 0, 6)), array('http:/', 'ftp://', 'rtsp:/', 'mms://'))) { $url = 'http://'.$url; } return str_replace('submit', '', sprintf($tags, $url, addslashes($url))); } else { return ' '.$url; } } function jammer() { $randomstr = ''; for($i = 0; $i < mt_rand(5, 15); $i++) { $randomstr .= chr(mt_rand(0, 59)).chr(mt_rand(63, 126)); } if($GLOBALS['thisbg'] == 'altbg1') { $thisbg = ALTBG1; } elseif($GLOBALS['thisbg'] == 'altbg2') { $thisbg = ALTBG2; } else { $thisbg = $GLOBALS['thisbg']; } return mt_rand(0, 1) ? ''.$GLOBALS['discuzcodes']['seoarray'][mt_rand(0, 5)].$randomstr.''."\r\n" : "\r\n".''.$randomstr.$GLOBALS['discuzcodes']['seoarray'][mt_rand(0, 5)].''; } ?>

1。我想插入一个标签[table][/table]直接在$discuzcodes = array上面写 $discuzcode preg_replace("~(\[table.+\[/table\])~iUse", "fetch_html_table('\\1')", $discuzcode); 是失败的...所以至今不知道如何插入新建标签 2。给标签定义内容已经搞定可是想让半角逗号和回车在[table][/table]之间的内容替换为和。在这之外不替换代码。怎么搞定? 不知道我的思路对不对。希望高手不吝赐教。感激不尽!

提问者:mechille   08-18 14:02
答复
路过。。。顺便帮顶:)
回答者:玉米づ冰冻可乐 - 瓦岗村民 8-22 09:10
我也来回答:
不管你有没有帮助我们,瓦岗寨8万村民将感谢你。。。。。

为防止灌水,您需要计算一道数学题: 答案:
27 + 93 = ? 请将计算结果填在上面

 
[]
©2007 PhpRes.COM