Ver Mensaje Individual
  #3 (permalink)  
Antiguo 02/07/2006, 08:19
Avatar de ASCENDEDMASTERS
ASCENDEDMASTERS
 
Fecha de Ingreso: julio-2005
Ubicación: Pergamino, Buenos Aires
Mensajes: 302
Antigüedad: 18 años, 9 meses
Puntos: 1
creo que la funcion que andabas buscando son estas (analizalas bien porque copie y pegue tal cual las usan los foros phpbb)

Código:
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);
	}

	// 
Código:
 and
for posting code (HTML, PHP, C etc etc) in your posts. $text = bbencode_second_pass_code($text, $uid, $bbcode_tpl); //
Cita:
and
for posting replies with quote, or just for quoting stuff. $text = str_replace("[quote:$uid]", $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); //[list] 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:o:$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(); // [img]image_url_here[/img] code.. // This one gets first-passed.. $patterns[] = "#\[img:$uid\]([^?].*?)\[/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']; // [email protected] 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() y esta otra, (aca atenes todos los regex tambien 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; //
Código:
 and
for posting code (HTML, PHP, C etc etc) in your posts. $text = bbencode_first_pass_pda($text, $uid, '
Código:
', '
', '', true, ''); //
Cita:
and
for posting replies with quote, or just for quoting stuff. $text = bbencode_first_pass_pda($text, $uid, '
Cita:
', '
', '', false, ''); $text = bbencode_first_pass_pda($text, $uid, '/\
Cita:
Iniciado por \\\\"(.*?)\\\\"\
/is', '
', '', false, '', "[quote:$uid=\\\"\\1\\\"]"); //[list] and[list=x] for (un)ordered lists. $open_tag = array(); $open_tag[0] = "
  • "; // unordered.. $text = bbencode_first_pass_pda($text, $uid, $open_tag, "
", "[/list:u]", false, 'replace_listitems'); $open_tag[0] = "[list=1]"; $open_tag[1] = "
  1. "; // ordered. $text = bbencode_first_pass_pda($text, $uid, $open_tag, "
", "[/list:o]", false, 'replace_listitems'); // [color] and [/color] for setting text color $text = preg_replace("#\[color=(\#[0-9A-F]{6}|[a-z\-]+)\](.*?)\[/color\]#si", "[color=\\1:$uid]\\2[/color:$uid]", $text); // [size] and [/size] for setting text size $text = preg_replace("#\[size=([1-2]?[0-9])\](.*?)\[/size\]#si", "[size=\\1:$uid]\\2[/size:$uid]", $text); // and for bolding text. $text = preg_replace("#\[b\](.*?)\[/b\]#si", "[b:$uid]\\1[/b:$uid]", $text); // and for underlining text. $text = preg_replace("#\[u\](.*?)\[/u\]#si", "[u:$uid]\\1[/u:$uid]", $text); // and for italicizing text. $text = preg_replace("#\[i\](.*?)\[/i\]#si", "[i:$uid]\\1[/i:$uid]", $text); // [img]image_url_here[/img] code.. $text = preg_replace("#\[img\]((http|ftp|https|ftps)://)([^ \?&=\#\"\n\r\t<]*?(\.(jpg|jpeg|gif|png)))\[/img\]#sie", "'[img:$uid]\\1' . str_replace(' ', '%20', '\\3') . '[/img:$uid]'", $text); // Remove our padding from the string.. return substr($text, 1);; } // bbencode_first_pass()
__________________
Dios es la unica fuente de todo bien.

Última edición por ASCENDEDMASTERS; 02/07/2006 a las 08:35