玫铃 发表于 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:", $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);
        }
        // and for introduction of hidden contents
        $text = str_replace("", $bbcode_tpl['intro_open'], $text);
        $text = str_replace("", $bbcode_tpl['intro_close'], $text);

        // 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("", $bbcode_tpl['quote_open'], $text);
        $text = str_replace("", $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("/\/si", $bbcode_tpl['quote_username_open'], $text);

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

        // colours
        $text = preg_replace("/\{6}|+):$uid\]/si", $bbcode_tpl['color_open'], $text);
        $text = str_replace("", $bbcode_tpl['color_close'], $text);

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

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

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

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

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

        // image_url_here code..
        // This one gets first-passed..
        $patterns[] = "#\([^?](?:[^\[]+|\[(?!url))*?)\#i";
        $replacements[] = $bbcode_tpl['img'];

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

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

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

        // phpBB code.. (no xxxx:// prefix).
        $patterns[] = "#\+]*?)\]([^?\n\r\t].*?)\#is";
        $replacements[] = $bbcode_tpl['url4'];

        // user@domain.tld code..
        $patterns[] = "#\(+?@[\w\-]+\.([\w\-\.]+\.)?[\w]+)\#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()

华山三少 发表于 2006 年 5 月 4 日 17:58:30

太长,不懂

玫铃 发表于 2006 年 5 月 4 日 18:00:14

由于论坛的字数限制加上不能上船附件,大家凑合看看吧

nuet 发表于 2006 年 5 月 4 日 18:12:29

晕!!!!

激凸猛男 发表于 2006 年 5 月 4 日 18:52:14

用过PHPBB,有相关插件的.

玫铃 发表于 2006 年 5 月 4 日 19:07:56

原帖由 激凸猛男 于 2006-5-4 18:52 发表
用过PHPBB,有相关插件的.

我没找到所以才来的。

激凸猛男 发表于 2006 年 5 月 4 日 19:16:09

原帖由 玫铃 于 2006-5-4 19:07 发表


我没找到所以才来的。

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

玫铃 发表于 2006 年 5 月 4 日 19:21:02

原来是到官方(英文)去找阿?

玫铃 发表于 2006 年 5 月 4 日 19:28:08

原帖由 激凸猛男 于 2006-5-4 19:16 发表


http://www.phpbb.com/mods/
不幸的是我下载不了(一个都不行)
页: [1]
查看完整版本: 问一个有关论坛代码的问题