Ok, here you are, i think tis is the one that i downloaded form here..
(Edited for 5 times)
Sorry for doing this, but i dont know how to
quote the whole..
[code]
<?php
// -------------------------------------------------------------
//
// $Id: ---- $
//
// FILENAME : index.php
// STARTED : Sat Feb 13, 2001
// COPYRIGHT : ÂÂÂ © 2001, 2005 phpBB Group
// WWW :
http://www.phpbb.com/// LICENCE : GPL vs2.0 [ see /docs/COPYING ]
//
// -------------------------------------------------------------
if ( !defined('IN_PHPBB') )
{
die("Hacking attempt");
}
define("BBCODE_UID_LEN", 10);
// global that holds loaded-and-prepared bbcode templates, so we only have to do
// that stuff once.
$bbcode_tpl = null;
/**
* 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, $current_template_path;
$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['quote_post_open'] = str_replace('{L_QUOTE}', $lang['Quote'], $bbcode_tpl['quote_post_open']);
$temp_url = append_sid('show_post.php?p=\1');
$bbcode_tpl['quote_post_open'] = str_replace('{U_VIEW_POST}', '<a>' . $lang['View_post'] . '</a>', $bbcode_tpl['quote_post_open']);
$bbcode_tpl['quote_username_post_open'] = str_replace('{L_QUOTE}', $lang['Quote'], $bbcode_tpl['quote_username_post_open']);
$bbcode_tpl['quote_username_post_open'] = str_replace('{L_WROTE}', $lang['wrote'], $bbcode_tpl['quote_username_post_open']);
$bbcode_tpl['quote_username_post_open'] = str_replace('{USERNAME}', '\1', $bbcode_tpl['quote_username_post_open']);
$temp_url = append_sid('show_post.php?p=\2');
$bbcode_tpl['quote_username_post_open'] = str_replace('{U_VIEW_POST}', '<a>' . $lang['View_post'] . '</a>', $bbcode_tpl['quote_username_post_open']);
$bbcode_tpl['code_open'] = str_replace('{L_CODE}', $lang['Code'], $bbcode_tpl['code_open']);
$bbcode_tpl['php_open'] = str_replace('{L_PHP}', $lang['PHPCode'], $bbcode_tpl['php_open']); // PHP MOD
$bbcode_tpl['img'] = str_replace('{URL}', '\1', $bbcode_tpl['img']);
$bbcode_tpl['imgrel'] = str_replace('{URL}', '\1', $bbcode_tpl['imgrel']);
$bbcode_tpl['theme'] = str_replace('{URL}', $current_template_path . '/\1', $bbcode_tpl['theme']);
//BBCode Search Mod
$bbcode_tpl['search'] = str_replace('{KEYWORD}', '\1', $bbcode_tpl['search']);
// LEFT-RIGHT-start
$bbcode_tpl['left'] = str_replace('{URL}', '\1', $bbcode_tpl['left']);
$bbcode_tpl['right'] = str_replace('{URL}', '\1', $bbcode_tpl['right']);
$bbcode_tpl['themeleft'] = str_replace('{URL}', $current_template_path . '/\1', $bbcode_tpl['themeleft']);
$bbcode_tpl['themeright'] = str_replace('{URL}', $current_template_path . '/\1', $bbcode_tpl['themeright']);
$bbcode_tpl['relleft'] = str_replace('{URL}', '\1', $bbcode_tpl['relleft']);
$bbcode_tpl['relright'] = str_replace('{URL}', '\1', $bbcode_tpl['relright']);
// LEFT-RIGHT-end
// 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['acronym_open'] = str_replace('{DESCRIPTION}', '\1', $bbcode_tpl['acronym_open']);
$bbcode_tpl['google'] = ''' . $bbcode_tpl['google'] . ''';
$bbcode_tpl['google'] = str_replace('{STRING}', "' . str_replace('"', '"', '\1') . '", $bbcode_tpl['google']);
$bbcode_tpl['google'] = str_replace('{QUERY}', "' . urlencode(str_replace('"', '"', '\1')) . '", $bbcode_tpl['google']);
global $userdata;
$bbcode_tpl['you'] = str_replace('{YOU}', '"' . $userdata['username'] . '"', $bbcode_tpl['you']);
// bbcode_box Mod
$bbcode_tpl['align_open'] = str_replace('{ALIGN}', '\1', $bbcode_tpl['align_open']);
$bbcode_tpl['stream'] = str_replace('{URL}', '\1', $bbcode_tpl['stream']);
$bbcode_tpl['ram'] = str_replace('{URL}', '\1', $bbcode_tpl['ram']);
$bbcode_tpl['marq_open'] = str_replace('{MARQ}', '\1', $bbcode_tpl['marq_open']);
$bbcode_tpl['table_open'] = str_replace('{TABLE}', '\1', $bbcode_tpl['table_open']);
$bbcode_tpl['cell_open'] = str_replace('{CELL}', '\1', $bbcode_tpl['cell_open']);
$bbcode_tpl['web'] = str_replace('{URL}', '\1', $bbcode_tpl['web']);
$bbcode_tpl['flash'] = str_replace('{WIDTH}', '\1', $bbcode_tpl['flash']);
$bbcode_tpl['flash'] = str_replace('{HEIGHT}', '\2', $bbcode_tpl['flash']);
$bbcode_tpl['flash'] = str_replace('{URL}', '\3', $bbcode_tpl['flash']);
$bbcode_tpl['video'] = str_replace('{URL}', '\3', $bbcode_tpl['video']);
$bbcode_tpl['video'] = str_replace('{WIDTH}', '\1', $bbcode_tpl['video']);
$bbcode_tpl['video'] = str_replace('{HEIGHT}', '\2', $bbcode_tpl['video']);
$bbcode_tpl['font_open'] = str_replace('{FONT}', '\1', $bbcode_tpl['font_open']);
$bbcode_tpl['poet_open'] = str_replace('{POET}', '\1', $bbcode_tpl['poet_open']);
// bbcode_box Mod
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);
}
// [code] and [/code] for posting code (HTML, PHP, C etc etc) in your posts.
$text = bbencode_second_pass_code($text, $uid, $bbcode_tpl);
// PHP MOD
// /*php and /php*/ for posting PHP code in your posts.
$text = bbencode_second_pass_php($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);
// opening a quote with an pre-defined post entry
$text = preg_replace("/
+)"]/si", $bbcode_tpl['quote_post_open'], $text);
// opening a username quote with an pre-defined post entry
$text = preg_replace("/
*)"?);p=(?:"?([0-9]+)"?)]/si", $bbcode_tpl['quote_username_post_open'], $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);
// acronym
$text = preg_replace("/[acronym:$uid="(.*?)"]/si", $bbcode_tpl['acronym_open'], $text);
$text = str_replace("[/acronym:$uid]", $bbcode_tpl['acronym_close'], $text);
//
and [list type=x] for (un)ordered lists.
// unordered lists
$text = str_replace("", $bbcode_tpl['ulist_open'], $text);
// li tags
$text = str_replace("- ", $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("/[list type=([a1])]/si", $bbcode_tpl['olist_open'], $text);
// colors
$text = preg_replace("/[color=(#[0-9A-F]{6}|[a-z]+)]/si", $bbcode_tpl['color_open'], $text);
$text = str_replace("[/color]", $bbcode_tpl['color_close'], $text);
// size
$text = preg_replace("/[size=99px]/si", $bbcode_tpl['size_open'], $text);
$text = str_replace("[/size]", $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);
// [sup] and [/sup] pour les textes en exposant.
$text = str_replace("[sup:$uid]", $bbcode_tpl['sup_open'], $text);
$text = str_replace("[/sup:$uid]", $bbcode_tpl['sup_close'], $text);
// [sub] and [/sub] pour les textes en indice.
$text = str_replace("[sub:$uid]", $bbcode_tpl['sub_open'], $text);
$text = str_replace("[/sub:$uid]", $bbcode_tpl['sub_close'], $text);
// [strike] and [/strike] for barring text.
$text = str_replace("[strike:$uid]", $bbcode_tpl['strike_open'], $text);
$text = str_replace("[/strike:$uid]", $bbcode_tpl['strike_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();
// [img]image_url_here[/img] code..
// This one gets first-passed..
//-- mod : profile cp ------------------------------------------------------------------------------
//-- add
global $userdata;
if (!$userdata['user_viewimg'])
{
$text = str_replace("[img]", "", $text);
$text = str_replace("[/img]", "", $text);
$text = str_replace("[img=left:$uid]", "", $text);
$text = str_replace("[img=right:$uid]", "", $text);
$text = str_replace("[imgrel:$uid]", "", $text);
$text = str_replace("[/imgrel:$uid]", "", $text);
$text = str_replace("[imgrel=left:$uid]", "", $text);
$text = str_replace("[imgrel=right:$uid]", "", $text);
$text = str_replace("[theme:$uid]", "", $text);
$text = str_replace("[theme=left:$uid]", "", $text);
$text = str_replace("[theme=right:$uid]", "", $text);
$text = str_replace("[/theme:$uid]", "", $text);
}
//-- fin mod : profile cp --------------------------------------------------------------------------
$patterns[] = "#[img]([^?](?:[^[]+|[(?!url))*?)[/img]#i";
$replacements[] = $bbcode_tpl['img'];
//BBCode Search Mod
$patterns[] = "#[search:$uid](.*?)[/search:$uid]#si";
$replacements[] = $bbcode_tpl['search'];
$patterns[] = "#[theme:$uid](.*?)[/theme:$uid]#si";
$replacements[] = $bbcode_tpl['theme'];
$patterns[] = "#[imgrel:$uid](.*?)[/imgrel:$uid]#si";
$replacements[] = $bbcode_tpl['img'];
// LEFT-RIGHT-start
// [img=left]image_url_here[/img] code..
$patterns[] = "#[img=left:$uid](.*?)[/img]#si";
$replacements[] = $bbcode_tpl['left'];
// [img=right]image_url_here[/img] code..
$patterns[] = "#[img=right:$uid](.*?)[/img]#si";
$replacements[] = $bbcode_tpl['right'];
// [imgrel=left]image_url_here[/imgrel] code..
$patterns[] = "#[imgrel=left:$uid](.*?)[/imgrel:$uid]#si";
$replacements[] = $bbcode_tpl['relleft'];
// [img=right]image_url_here[/img] code..
$patterns[] = "#[imgrel=right:$uid](.*?)[/imgrel:$uid]#si";
$replacements[] = $bbcode_tpl['relright'];
// [img=left]image_url_here[/img] code..
$patterns[] = "#[theme=left:$uid](.*?)[/theme:$uid]#si";
$replacements[] = $bbcode_tpl['themeleft'];
// [img=right]image_url_here[/img] code..
$patterns[] = "#[theme=right:$uid](.*?)[/theme:$uid]#si";
$replacements[] = $bbcode_tpl['themeright'];
// LEFT-RIGHT-end
// matches a
xxxx://www.phpbb.com code..
$patterns[] = "#[url]([w]+?://([w#$%&~/.-;:=,?@]+]+|[(?!url=))*?)[/url]#is";
$replacements[] = $bbcode_tpl['url1'];
//
http://www.phpbb.com code.. (no xxxx:// prefix).
$patterns[] = "#[url]((www|ftp).([w#$%&~/.-;:=,?@]+]+|[(?!url=))*?)[/url]#is";
$replacements[] = $bbcode_tpl['url2'];
// [url=xxxx]phpBB[/url] code..
$patterns[] = "#[url=([w]+?]+]*?)]([^?nrt].*?)[/url]#is";
$replacements[] = $bbcode_tpl['url3'];
//
phpBB code.. (no xxxx] = "#[url=((www|ftp).[w#$%&~/.-;]+]*?)]([^?nrt].*?)[/url]#is";
$replacements[] = $bbcode_tpl['url4'];
//
user@domain.tld code..
$patterns[] = "#[email]([a-z0-9&-_.]+?@[w-]+.([w-.]+.)?[w]+)[/email]#si";
$replacements[] = $bbcode_tpl['email'];
// [google]string for search[/google] code..
$patterns[] = "#[google](.*?)[/google]#ise";
$replacements[] = $bbcode_tpl['google'];
// [you] - inserts the name of the person viewing the post
$patterns[] = "#[you]#ise";
$replacements[] = $bbcode_tpl['you'];
// bbcode_box Mod
// [fade] and [/fade] for faded text.
$text = str_replace("[fade:$uid]", $bbcode_tpl['fade_open'], $text);
$text = str_replace("[/fade:$uid]", $bbcode_tpl['fade_close'], $text);
// real
$patterns[] = "#[ram:$uid](.*?)[/ram:$uid]#si";
$replacements[] = $bbcode_tpl['ram'];
// sound
$patterns[] = "#[stream:$uid](.*?)[/stream:$uid]#si";
$replacements[] = $bbcode_tpl['stream'];
//web
$patterns[] = "#[web:$uid](.*?)[/web:$uid]#si";
$replacements[] = $bbcode_tpl['web'];
// [flash width= height= loop= ] and [/flash] code..
$patterns[] = "#[flash width=([0-6]?[0-9]?[0-9]) height=([0-4]?[0-9]?[0-9]):$uid](.*?)[/flash:$uid]#si";
$replacements[] = $bbcode_tpl['flash'];
// [flash width= height= loop= ] and [/flash] code..
$patterns[] = "#[video width=([0-6]?[0-9]?[0-9]) height=([0-4]?[0-9]?[0-9]):$uid](.*?)[/video:$uid]#si";
$replacements[] = $bbcode_tpl['video'];
$text = preg_replace($patterns, $replacements, $text);
// align
$text = preg_replace("/[align=(left|right|center|justify):$uid]/si", $bbcode_tpl['align_open'], $text);
$text = str_replace("[/align:$uid]", $bbcode_tpl['align_close'], $text);
// marquee
$text = preg_replace("/[marq=(left|right|up|down):$uid]/si", $bbcode_tpl['marq_open'], $text);
$text = str_replace("[/marq:$uid]", $bbcode_tpl['marq_close'], $text);
// table
$text = preg_replace("/[table=(.*?):$uid]/si", $bbcode_tpl['table_open'], $text);
$text = str_replace("[/table:$uid]", $bbcode_tpl['table_close'], $text);
// cell
$text = preg_replace("/[cell=(.*?):$uid]/si", $bbcode_tpl['cell_open'], $text);
$text = str_replace("[/cell:$uid]", $bbcode_tpl['cell_close'], $text);
// center
$text = preg_replace("/[center:$uid]/si", $bbcode_tpl['center_open'], $text);
$text = str_replace("[/center:$uid]", $bbcode_tpl['center_close'], $text);
// font
$text = preg_replace("//si", $bbcode_tpl['font_open'], $text);
$text = str_replace("[/font:$uid]", $bbcode_tpl['font_close'], $text);
// poet
$text = preg_replace("/[poet(.*?):$uid]/si", $bbcode_tpl['poet_open'], $text);
$text = str_replace("[/poet:$uid]", $bbcode_tpl['poet_close'], $text);
//[hr]
$text = str_replace("[hr:$uid]", $bbcode_tpl['hr'], $text);
// bbcode_box Mod
$text = preg_replace($patterns, $replacements, $text);
// Remove our padding from the string..
$text = substr($text, 1);
return $text;
} // bbencode_second_pass()
// Need to initialize the random numbers only ONCE
mt_srand( (double) microtime() * 1000000);
function make_bbcode_uid()
{
// Unique ID for this message..
$uid = dss_rand();
$uid = substr($uid, 0, BBCODE_UID_LEN);
return $uid;
}
function bbencode_first_pass($text, $uid)
{
// 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;
// [code] and [/code] for posting code (HTML, PHP, C etc etc) in your posts.
$text = bbencode_first_pass_pda($text, $uid, '[code]', '[/code]', '', true, '');
// PHP MOD
// /*php and /php*/ for posting PHP code in your posts.
$text = bbencode_first_pass_pda($text, $uid, '/*php ', ' /php*/', '', true, '');
//
and
for posting replies with quote, or just for quoting stuff.
$text = bbencode_first_pass_pda($text, $uid, '
', '
', '', false, '');
$text = bbencode_first_pass_pda($text, $uid, '/[quote=(".*?")]/is', '
', '', false, '', "
");
//
and
for posting replies with quote, or just for quoting stuff with an pre-defined post entry
$text = bbencode_first_pass_pda($text, $uid, '/[quote=p=\\"([0-9]+)\\"]/is', '
', '', false, '', "
");
$text = bbencode_first_pass_pda($text, $uid, '/[quote=\\"(.*?)\\";p=\\"([0-9]+)\\"]/is', '
', '', false, '', "
");
$text = bbencode_first_pass_pda($text, $uid, '/[quote=\\"(.*?)\\"]/is', '
', '', false, '', "[quote]");
// [acronym] and [/acronym]
$text = bbencode_first_pass_pda($text, $uid, '/[acronym=(".*?")]/is', '[/acronym]', '', false, '', "[acronym:$uid=\1]");
//
and [list type=x] for (un)ordered lists.
$open_tag = array();
$open_tag[0] = "";
// unordered..
$text = bbencode_first_pass_pda($text, $uid, $open_tag, "
", "
", false, 'replace_listitems');
$open_tag[0] = "[list type=decimal]";
$open_tag[1] = "
";
// ordered.
$text = bbencode_first_pass_pda($text, $uid, $open_tag, "
", "[/list]", false, 'replace_listitems');
// [color] and [/color] for setting text color
$text = preg_replace("#[color=(#[0-9A-F]{6}|[a-z-]+)](.*?)[/color]#si", "[color=\1]\2[/color]", $text);
// [size] and [/size] for setting text size
$text = preg_replace("#[size=99px]\2[/size]", $text);
//
and for bolding text.
$text = preg_replace("#
(.*?)#si", "
\1", $text);
// [sup] and [/sup] pour les textes en exposant.
$text = preg_replace("#[sup](.*?)[/sup]#si", "[sup:$uid]\1[/sup:$uid]", $text);
// [sub] and [/sub] pour les textes en indice.
$text = preg_replace("#[sub](.*?)[/sub]#si", "[sub:$uid]\1[/sub:$uid]", $text);
// [strike] and [/strike] for barring text.
$text = preg_replace("#[strike](.*?)[/strike]#si", "[strike:$uid]\1[/strike:$uid]", $text);
//
and for underlining text.
$text = preg_replace("#
(.*?)#si", "
\1", $text);
//
and for italicizing text.
$text = preg_replace("#
(.*?)#si", "
\1", $text);
// [img]image_url_here[/img] code..
$text = preg_replace("#[img]((http|ftp|https|ftps)://)([^%20?&=#"nrt<]*?(.(jpg|jpeg|gif|png)))[/img]#sie", "'[img]\1'%20.%20str_replace('%20',%20'%20',%20'\3')%20.%20'[/img]'", $text);
//BBCode Search Mod
$text = preg_replace("#[search](.*?)[/search]#si", "[search:$uid]\1[/search:$uid]", $text);
$text = preg_replace("#[theme]([^ ?&=#"nrt<]*?)[/theme]#sie", "'[theme:$uid]\1' . str_replace(' ', '%20', '\3') . '[/theme:$uid]'", $text);
$text = preg_replace("#[theme=left]([^ ?&=#"nrt<]*?)[/theme]#sie", "'[theme=left:$uid]\1' . str_replace(' ', '%20', '\3') . '[/theme:$uid]'", $text);
$text = preg_replace("#[theme=right]([^ ?&=#"nrt<]*?)[/theme]#sie", "'[theme=right:$uid]\1' . str_replace(' ', '%20', '\3') . '[/theme:$uid]'", $text);
$text = preg_replace("#[imgrel]([^ ?&=#"nrt<]*?)[/imgrel]#sie", "'[imgrel:$uid]\1' . str_replace(' ', '%20', '\3') . '[/imgrel:$uid]'", $text);
$text = preg_replace("#[imgrel=left]([^rnt<"]*?)[/imgrel]#sie", "'[imgrel=left:$uid]\1' . str_replace(' ', '%20', '\3') . '[/imgrel:$uid]'", $text);
$text = preg_replace("#[imgrel=right]([^rnt<"]*?)[/imgrel]#sie", "'[imgrel=right:$uid]\1' . str_replace(' ', '%20', '\3') . '[/imgrel:$uid]'", $text);
// LEFT-RIGHT-start
$text = preg_replace("#[img=left]((http|ftp|https|ftps)://)([^rnt<"]*?)[/img]#sie", "'[img=left:$uid]\1' . str_replace(' ', '%20', '\3') . '[/img]'", $text);
$text = preg_replace("#[img=right]((http|ftp|https|ftps)://)([^rnt</img> 0)
{
// There exists a starting tag.
$curr_nesting_depth = sizeof($stack);
// We need to do 2 replacements now.
$match = array_pop($stack);
$start_index = $match['pos'];
$start_tag = $match['tag'];
$start_length = strlen($start_tag);
$start_tag_index = $match['index'];
if ($open_is_regexp)
{
$start_tag = preg_replace($open_tag[$start_tag_index], $open_regexp_replace[$start_tag_index], $start_tag);
}
// everything before the opening tag.
$before_start_tag = substr($text, 0, $start_index);
// everything after the opening tag, but before the closing tag.
$between_tags = substr($text, $start_index + $start_length, $curr_pos - $start_index - $start_length);
// Run the given function on the text between the tags..
if ($use_function_pointer)
{
$between_tags = $func($between_tags, $uid);
}
// everything after the closing tag.
$after_end_tag = substr($text, $curr_pos + $close_tag_length);
// Mark the lowest nesting level if needed.
if ($mark_lowest_level && ($curr_nesting_depth == 1))
{
if ($open_tag[0] == '[code]')
{
$code_entities_match = array('#<code_entities_replace> 0)
{
$match = array_pop($stack);
$curr_pos = $match['pos'];
// bbcode_array_push($stack, $match);
// ++$curr_pos;
}
else
{
$curr_pos = 1;
}
}
else
{
// No matching start tag found. Increment pos, keep going.
++$curr_pos;
}
}
else
{
// No starting tag or ending tag.. Increment pos, keep looping.,
++$curr_pos;
}
}
}
} // while
return $text;
} // bbencode_first_pass_pda()
/**
* Does second-pass bbencoding of the [code] tags. This includes
* running htmlspecialchars() over the text contained between
* any pair of [code] tags that are at the first level of
* nesting. Tags at the first level of nesting are indicated
* by this format: [code] ... [/code]
* Other tags are in this format: [code] ... [/code]
*/
function bbencode_second_pass_code($text, $uid, $bbcode_tpl)
{
global $lang;
$code_start_html = $bbcode_tpl['code_open'];
$code_end_html = $bbcode_tpl['code_close'];
// First, do all the 1st-level matches. These need an htmlspecialchars() run,
// so they have to be handled differently.
$match_count = preg_match_all("#[code](.*?)[/code]#si", $text, $matches);
for ($i = 0; $i < $match_count; $i++)
{
$before_replace = $matches[1][$i];
$after_replace = $matches[1][$i];
// Replace 2 spaces with " " so non-tabbed code indents without making huge long lines.
$after_replace = str_replace(" ", " ", $after_replace);
// now Replace 2 spaces with " " to catch odd #s of spaces.
$after_replace = str_replace(" ", " ", $after_replace);
// Replace tabs with " " so tabbed code indents sorta right without making huge long lines.
$after_replace = str_replace("t", " ", $after_replace);
// now Replace space occurring at the beginning of a line
$after_replace = preg_replace("/^ {1}/m", " ", $after_replace);
$str_to_match = "[code]" . $before_replace . "[/code]";
$replacement = $code_start_html;
$replacement .= $after_replace;
$replacement .= $code_end_html;
$text = str_replace($str_to_match, $replacement, $text);
}
// Now, do all the non-first-level matches. These are simple.
$text = str_replace("[code]", $code_start_html, $text);
$text = str_replace("[/code]", $code_end_html, $text);
return $text;
} // bbencode_second_pass_code()
/**
* PHP MOD
* Original code/function by phpBB Group
* Modified by JW Frazier / Fubonis <
xxxx://yyyy with an HTML <a> tag linking
* to that URL
* - Goes through the given string, and replaces
http://www.xxxx.yyyy[zzzz] with an HTML <a> tag linking
* to
http://www.xxxx.yyyy[/zzzz]
* - Goes through the given string, and replaces xxxx@yyyy with an HTML mailto: tag linking
* to that email address
* - Only matches these 2 patterns either after a space, or at the beginning of a line
*
* Notes: the email one might get annoying - it's easy to make it more restrictive, though.. maybe
* have it require something like <a>xxxx@yyyy.zzzz</a> or such. We'll see.
*/
function make_clickable($text)
{
$text = preg_replace('#(script|about|applet|activex|chrome):#is', "\1:", $text);
// pad it with a space so we can match things at the start of the 1st line.
$ret = ' ' . $text;
// matches an "xxxx://yyyy" URL at the start of a line, or after a space.
// xxxx can only be alpha characters.
// yyyy is anything up to the first space, newline, comma, double quote or <
$ret = preg_replace("#(^|[n ])([w]+?://[w#$%&~/.-;:=,?@[]+]*)#is", "\1<a>\2</a>", $ret);
// matches a "www|ftp.xxxx.yyyy[/zzzz]" kinda lazy URL thing
// Must contain at least 2 dots. xxxx contains either alphanum, or "-"
// zzzz is optional.. will contain everything up to the first space, newline,
// comma, double quote or <.
$ret = preg_replace("#(^|[n ])((www|ftp).[w#$%&~/.-;:=,?@[]+]*)#is", "\1<a>\2</a>", $ret);
// matches an email@domain type address at the start of a line, or after a space.
// Note: Only the followed chars are valid; alphanums, "-", "_" and or ".".
$ret = preg_replace("#(^|[n ])([a-z0-9&-_.]+?)@([w-]+.([w-.]+.)*[w]+)#i", "\1<a>\2@\3</a>", $ret);
// Remove our padding..
$ret = substr($ret, 1);
return($ret);
}
/**
* Nathan Codding - Feb 6, 2001
* Reverses the effects of make_clickable(), for use in editpost.
* - Does not distinguish between "www.xxxx.yyyy" and "http://aaaa.bbbb" type URLs.
*
*/
function undo_make_clickable($text)
{
$text = preg_replace("#<BBCode><a>.*?</a><BBCode>#i", "\1", $text);
$text = preg_replace("#<BBcode><a>.*?</a><BBCode>#i", "\1", $text);
return $text;
}
/**
* Nathan Codding - August 24, 2000.
* Takes a string, and does the reverse of the PHP standard function
* htmlspecialchars().
*/
function undo_htmlspecialchars($input)
{
$input = preg_replace("/>/i", ">", $input);
$input = preg_replace("/</i", "<", $input);
$input = preg_replace("/"/i", """, $input);
$input = preg_replace("/&/i", "&", $input);
return $input;
}
/**
* This is used to change a [*] tag into a [*] tag as part
* of the first-pass bbencoding of [list] tags. It fits the
* standard required in order to be passed as a variable
* function into bbencode_first_pass_pda().
*/
function replace_listitems($text, $uid)
{
$text = str_replace("[*]", "[*]", $text);
return $text;
}
/**
* Escapes the "/" character with "/". This is useful when you need
* to stick a runtime string into a PREG regexp that is being delimited
* with slashes.
*/
function escape_slashes($input)
{
$output = str_replace('/', '/', $input);
return $output;
}
/**
* This function does exactly what the PHP4 function array_push() does
* however, to keep phpBB compatable with PHP 3 we had to come up with our own
* method of doing it.
* This function was deprecated in phpBB 2.0.18
*/
function bbcode_array_push(&$stack, $value)
{
$stack[] = $value;
return(sizeof($stack));
}
/**
* This function does exactly what the PHP4 function array_push() does
* however, to keep phpBB compatable with PHP 3 we had to come up with our own
* method of doing it.
* This function was deprecated in phpBB 2.0.18
*/
function bbcode_array_pop(&$stack)
{
$arrSize = count($stack);
$x = 1;
while(list($key, $val) = each($stack))
{
if($x < count($stack))
{
$tmpArr[] = $val;
}
else
{
$return_val = $val;
}
$x++;
}
$stack = $tmpArr;
return($return_val);
}
//
// Smilies code ... would this be better tagged on to the end of bbcode.php?
// Probably so and I'll move it before B2
//
function smilies_pass($message)
{
static $orig, $repl;
if (!isset($orig))
{
global $db, $board_config, $portal_config, $var_cache;
$orig = $repl = array();
if($portal_config['cache_enabled'])
{
$orig = $var_cache->get('orig2', 86400, 'smilies');
$repl = $var_cache->get('repl2', 86400, 'smilies');
}
if(!$orig)
{
$sql = 'SELECT * FROM ' . SMILIES_TABLE;
if( !$result = $db->sql_query($sql) )
{
message_die(GENERAL_ERROR, "Couldn't obtain smilies data", "", __LINE__, __FILE__, $sql);
}
$smilies = $db->sql_fetchrowset($result);
if (count($smilies))
{
usort($smilies, 'smiley_sort');
}
for ($i = 0; $i <count>save($orig, 'orig2', 'smilies');
$var_cache->save($repl, 'repl2', 'smilies');
}
}
}
if (count($orig))
{
$message = preg_replace($orig, $repl, ' ' . $message . ' ');
$message = substr($message, 1, -1);
}
return $message;
}
function acronym_pass($message)
{
static $orig, $repl;
if( !isset($orig) )
{
global $db, $board_config;
$orig = $repl = array();
$sql = 'SELECT * FROM ' . ACRONYMS_TABLE;
if( !$result = $db->sql_query($sql) )
{
message_die(GENERAL_ERROR, "Couldn't obtain acronyms data", "", __LINE__, __FILE__, $sql);
}
$acronyms = $db->sql_fetchrowset($result);
if( count($acronyms) )
{
usort( $acronyms, 'acronym_sort' );
}
for ($i = 0; $i </acronym> strlen($b['code']) ) ? -1 : 1;
}
function acronym_sort($a, $b)
{
if ( strlen($a['acronym']) == strlen($b['acronym']) )
{
return 0;
}
return ( strlen($a['acronym']) > strlen($b['acronym']) ) ? -1 : 1;
}
?>
[/code]