找回密码
 注册
广告投放 虚位以待【阿里云】2核2G云新老同享 99元/年,续费同价做网站就用糖果主机-sugarhosts.comJtti.com-新加坡服务器,美国服务器,香港服务器
查看: 375|回复: 8

问一个有关论坛代码的问题

[复制链接]
发表于 2006 年 5 月 4 日 17:56:10 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?注册

×
我使用的PHPBB没有Flash播放、音乐播放的代码,我想知道金光论坛的这种程序的代码能否适用于PHPbb?
如果不能请大家叫我怎么修改CODE?
下面是CODE的源文件:




// global that holds loaded-and-prepared bbcode templates, so we only have to do
// that stuff once.

$bbcode_tpl = null;
// MULTI BBCODE-begin
function Multi_BBCode()
{
        global $template, $lang;

        // DO NOT CHANGE THIS ARRAY
        $hotkeys = array('', 'd', 'e', 'g', 'h', 'j', 'k', 'm', 'n', 'r', 't', 'v', 'x', 'y', 'z', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0');

        //NOTE: the first element of each array must be ''   Add new elements AFTER the ''
        $EMBB_widths = array('','40') ;
        $EMBB_values = array('','intro') ;
        for ($i=1; $i<count($EMBB_values); $i++)
        {
                // load BBcode MODs info
                $val = ($i*2)+16 ;
                $help_lang = ( !empty($lang['bbcode_help'][(strtolower($EMBB_values[$i]))]) ) ? $lang['bbcode_help'][(strtolower($EMBB_values[$i]))] : $lang['bbcode_help'][$EMBB_values[$i]];
                $template->assign_block_vars('MultiBB', array(
                        'KEY' => $hotkeys[$i],
                        'NAME' => "addbbcode$val",
                        'HELP' => sprintf($help_lang, $hotkeys[$i]),
                        'WIDTH' => $EMBB_widths[$i],
                        'VALUE' => $EMBB_values[$i],
                        'STYLE' => "bbstyle($val)")
                );
        }
}
// MULTI BBCODE-end


/**
* Loads bbcode templates from the bbcode.tpl file of the current template set.
* Creates an array, keys are bbcode names like "b_open" or "url", values
* are the associated template.
* Probably pukes all over the place if there's something really screwed
* with the bbcode.tpl file.
*
* Nathan Codding, Sept 26 2001.
*/
function load_bbcode_template()
{
        global $template;
        $tpl_filename = $template->make_filename('bbcode.tpl');
        $tpl = fread(fopen($tpl_filename, 'r'), filesize($tpl_filename));

        // replace \ with \\ and then ' with \'.
        $tpl = str_replace('\\', '\\\\', $tpl);
        $tpl  = str_replace('\'', '\\\'', $tpl);

        // strip newlines.
        $tpl  = str_replace("\n", '', $tpl);

        // Turn template blocks into PHP assignment statements for the values of $bbcode_tpls..
        $tpl = preg_replace('#<!-- BEGIN (.*?) -->(.*?)<!-- END (.*?) -->#', "\n" . '$bbcode_tpls[\'\\1\'] = \'\\2\';', $tpl);

        $bbcode_tpls = array();

        eval($tpl);

        return $bbcode_tpls;
}


/**
* Prepares the loaded bbcode templates for insertion into preg_replace()
* or str_replace() calls in the bbencode_second_pass functions. This
* means replacing template placeholders with the appropriate preg backrefs
* or with language vars. NOTE: If you change how the regexps work in
* bbencode_second_pass(), you MUST change this function.
*
* Nathan Codding, Sept 26 2001
*
*/
function prepare_bbcode_template($bbcode_tpl)
{
        global $lang;

        $bbcode_tpl['olist_open'] = str_replace('{LIST_TYPE}', '\\1', $bbcode_tpl['olist_open']);

        $bbcode_tpl['color_open'] = str_replace('{COLOR}', '\\1', $bbcode_tpl['color_open']);

        $bbcode_tpl['size_open'] = str_replace('{SIZE}', '\\1', $bbcode_tpl['size_open']);

        $bbcode_tpl['quote_open'] = str_replace('{L_QUOTE}', $lang['Quote'], $bbcode_tpl['quote_open']);

        $bbcode_tpl['quote_username_open'] = str_replace('{L_QUOTE}', $lang['Quote'], $bbcode_tpl['quote_username_open']);
        $bbcode_tpl['quote_username_open'] = str_replace('{L_WROTE}', $lang['wrote'], $bbcode_tpl['quote_username_open']);
        $bbcode_tpl['quote_username_open'] = str_replace('{USERNAME}', '\\1', $bbcode_tpl['quote_username_open']);

        $bbcode_tpl['code_open'] = str_replace('{L_CODE}', $lang['Code'], $bbcode_tpl['code_open']);

        $bbcode_tpl['img'] = str_replace('{URL}', '\\1', $bbcode_tpl['img']);

        // We do URLs in several different ways..
        $bbcode_tpl['url1'] = str_replace('{URL}', '\\1', $bbcode_tpl['url']);
        $bbcode_tpl['url1'] = str_replace('{DESCRIPTION}', '\\1', $bbcode_tpl['url1']);

        $bbcode_tpl['url2'] = str_replace('{URL}', 'http://\\1', $bbcode_tpl['url']);
        $bbcode_tpl['url2'] = str_replace('{DESCRIPTION}', '\\1', $bbcode_tpl['url2']);

        $bbcode_tpl['url3'] = str_replace('{URL}', '\\1', $bbcode_tpl['url']);
        $bbcode_tpl['url3'] = str_replace('{DESCRIPTION}', '\\2', $bbcode_tpl['url3']);

        $bbcode_tpl['url4'] = str_replace('{URL}', 'http://\\1', $bbcode_tpl['url']);
        $bbcode_tpl['url4'] = str_replace('{DESCRIPTION}', '\\3', $bbcode_tpl['url4']);

        $bbcode_tpl['email'] = str_replace('{EMAIL}', '\\1', $bbcode_tpl['email']);

        $bbcode_tpl['intro_open'] = str_replace('{L_INTRO}', $lang['Introduction'], $bbcode_tpl['intro_open']);
        define("BBCODE_TPL_READY", true);

        return $bbcode_tpl;
}


/**
* Does second-pass bbencoding. This should be used before displaying the message in
* a thread. Assumes the message is already first-pass encoded, and we are given the
* correct UID as used in first-pass encoding.
*/
function bbencode_second_pass($text, $uid)
{
        global $lang, $bbcode_tpl;
        $text = preg_replace('#(script|about|applet|activex|chrome):#is', "\\1&#058;", $text);

        // pad it with a space so we can distinguish between FALSE and matching the 1st char (index 0).
        // This is important; bbencode_quote(), bbencode_list(), and bbencode_code() all depend on it.
        $text = " " . $text;

        // First: If there isn't a "[" and a "]" in the message, don't bother.
        if (! (strpos($text, "[") && strpos($text, "]")) )
        {
                // Remove padding, return.
                $text = substr($text, 1);
                return $text;
        }

        // Only load the templates ONCE..
        if (!defined("BBCODE_TPL_READY"))
        {
                // load templates from file into array.
                $bbcode_tpl = load_bbcode_template();

                // prepare array for use in regexps.
                $bbcode_tpl = prepare_bbcode_template($bbcode_tpl);
        }
        // [intro] and [/intro] for introduction of hidden contents
        $text = str_replace("[introuid]", $bbcode_tpl['intro_open'], $text);
        $text = str_replace("[/introuid]", $bbcode_tpl['intro_close'], $text);

        //
  1. and
复制代码
for posting code (HTML, PHP, C etc etc) in your posts.
        $text = bbencode_second_pass_code($text, $uid, $bbcode_tpl);

        //
and
for posting replies with quote, or just for quoting stuff.
        $text = str_replace("[quoteuid]", $bbcode_tpl['quote_open'], $text);
        $text = str_replace("[/quote:$uid]", $bbcode_tpl['quote_close'], $text);

        // New one liner to deal with opening quotes with usernames...
        // replaces the two line version that I had here before..
        $text = preg_replace("/\[quote:$uid=\"(.*?)\"\]/si", $bbcode_tpl['quote_username_open'], $text);

        //
    and [list=x] for (un)ordered lists.
            // unordered lists
            $text = str_replace("[list:$uid]", $bbcode_tpl['ulist_open'], $text);
            // li tags
            $text = str_replace("[*:$uid]", $bbcode_tpl['listitem'], $text);
            // ending tags
            $text = str_replace("[/list:u:$uid]", $bbcode_tpl['ulist_close'], $text);
            $text = str_replace("[/list:$uid]", $bbcode_tpl['olist_close'], $text);
            // Ordered lists
            $text = preg_replace("/\[list=([a1]):$uid\]/si", $bbcode_tpl['olist_open'], $text);

            // colours
            $text = preg_replace("/\[color=(\#[0-9A-F]{6}|[a-z]+):$uid\]/si", $bbcode_tpl['color_open'], $text);
            $text = str_replace("[/color:$uid]", $bbcode_tpl['color_close'], $text);

            // size
            $text = preg_replace("/\[size=([1-2]?[0-9]):$uid\]/si", $bbcode_tpl['size_open'], $text);
            $text = str_replace("[/size:$uid]", $bbcode_tpl['size_close'], $text);

            // and for bolding text.
            $text = str_replace("[b:$uid]", $bbcode_tpl['b_open'], $text);
            $text = str_replace("[/b:$uid]", $bbcode_tpl['b_close'], $text);

            // and for underlining text.
            $text = str_replace("[u:$uid]", $bbcode_tpl['u_open'], $text);
            $text = str_replace("[/u:$uid]", $bbcode_tpl['u_close'], $text);

            // and for italicizing text.
            $text = str_replace("[i:$uid]", $bbcode_tpl['i_open'], $text);
            $text = str_replace("[/i:$uid]", $bbcode_tpl['i_close'], $text);

            // Patterns and replacements for URL and email tags..
            $patterns = array();
            $replacements = array();

            //

                                   
    登录/注册后可看大图
    code..
            // This one gets first-passed..
            $patterns[] = "#\[img:$uid\]([^?](?:[^\[]+|\[(?!url))*?)\[/img:$uid\]#i";
            $replacements[] = $bbcode_tpl['img'];

            // matches a xxxx://www.phpbb.com code..
            $patterns[] = "#\[url\]([\w]+?://([\w\#$%&~/.\-;:=,?@\]+]+|\[(?!url=))*?)\[/url\]#is";
            $replacements[] = $bbcode_tpl['url1'];

            // www.phpbb.com code.. (no xxxx:// prefix).
            $patterns[] = "#\[url\]((www|ftp)\.([\w\#$%&~/.\-;:=,?@\]+]+|\[(?!url=))*?)\[/url\]#is";
            $replacements[] = $bbcode_tpl['url2'];

            // phpBB code..
            $patterns[] = "#\[url=([\w]+?://[\w\#$%&~/.\-;:=,?@\[\]+]*?)\]([^?\n\r\t].*?)\[/url\]#is";
            $replacements[] = $bbcode_tpl['url3'];

            // phpBB code.. (no xxxx:// prefix).
            $patterns[] = "#\[url=((www|ftp)\.[\w\#$%&~/.\-;:=,?@\[\]+]*?)\]([^?\n\r\t].*?)\[/url\]#is";
            $replacements[] = $bbcode_tpl['url4'];

            // user@domain.tld code..
            $patterns[] = "#\[email\]([a-z0-9&\-_.]+?@[\w\-]+\.([\w\-\.]+\.)?[\w]+)\[/email\]#si";
            $replacements[] = $bbcode_tpl['email'];

            $text = preg_replace($patterns, $replacements, $text);

            // Remove our padding from the string..
            $text = substr($text, 1);

            return $text;

    } // bbencode_second_pass()
Jgwy.Com - Free Web Hosting Guide & Directory In China since 2001! Jgwy.Net-Jglt.Net
发表于 2006 年 5 月 4 日 17:58:30 | 显示全部楼层
【腾讯云】2核2G云服务器新老同享 99元/年,续费同价
太长,不懂
Jgwy.Com - Free Web Hosting Guide & Directory In China since 2001! Jgwy.Net-Jglt.Net
回复

使用道具 举报

 楼主| 发表于 2006 年 5 月 4 日 18:00:14 | 显示全部楼层
由于论坛的字数限制加上不能上船附件,大家凑合看看吧
Jgwy.Com - Free Web Hosting Guide & Directory In China since 2001! Jgwy.Net-Jglt.Net
回复

使用道具 举报

发表于 2006 年 5 月 4 日 18:12:29 | 显示全部楼层
晕!!!!
Jgwy.Com - Free Web Hosting Guide & Directory In China since 2001! Jgwy.Net-Jglt.Net
回复

使用道具 举报

发表于 2006 年 5 月 4 日 18:52:14 | 显示全部楼层
用过PHPBB,有相关插件的.
Jgwy.Com - Free Web Hosting Guide & Directory In China since 2001! Jgwy.Net-Jglt.Net
回复

使用道具 举报

 楼主| 发表于 2006 年 5 月 4 日 19:07:56 | 显示全部楼层
原帖由 激凸猛男 于 2006-5-4 18:52 发表
用过PHPBB,有相关插件的.


我没找到所以才来的。
Jgwy.Com - Free Web Hosting Guide & Directory In China since 2001! Jgwy.Net-Jglt.Net
回复

使用道具 举报

发表于 2006 年 5 月 4 日 19:16:09 | 显示全部楼层
【腾讯云】2核2G云服务器新老同享 99元/年,续费同价
原帖由 玫铃 于 2006-5-4 19:07 发表


我没找到所以才来的。


http://www.phpbb.com/mods/
Jgwy.Com - Free Web Hosting Guide & Directory In China since 2001! Jgwy.Net-Jglt.Net
回复

使用道具 举报

 楼主| 发表于 2006 年 5 月 4 日 19:21:02 | 显示全部楼层
原来是到官方(英文)去找阿?
Jgwy.Com - Free Web Hosting Guide & Directory In China since 2001! Jgwy.Net-Jglt.Net
回复

使用道具 举报

 楼主| 发表于 2006 年 5 月 4 日 19:28:08 | 显示全部楼层
原帖由 激凸猛男 于 2006-5-4 19:16 发表


http://www.phpbb.com/mods/

不幸的是我下载不了(一个都不行)
Jgwy.Com - Free Web Hosting Guide & Directory In China since 2001! Jgwy.Net-Jglt.Net
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|金光论坛

GMT+8, 2025 年 2 月 2 日 16:42 , Processed in 0.019666 second(s), 19 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表