Hace unas semanas deje un tema y nadie me respondio, no si se porque no tiene solución o bien, no me explique correctamente.
Tengo un problema de recursividad al cual no le encuentro solución; el problema esta en una simple funcion de BBCODE, más precisamente en el tag [citar] (igual al [ quote ] usando por estos foros).
Cuando cito un mensaje normal funciona correctamente, pero cuando tengo que citar un mensaje que YA contenia una cita, esta ultima no la toma como cita...
Cita:
No puedo lograr algo tan simple como eso...
Iniciado por FuLaNo_
hola mundo
Cita:
Iniciado por otro_usuario
hola mundo, otra vez
Aquí dejo TODA la función que estoy utilizando
Código PHP:
function BBcode($texto) {
$texto = SICS($texto);
$_BBcode = array(
':tomate:' => '<img src="img/f_tomate.gif" class="middle" alt="Tomates...">', ':motosierra:' => '<img src="img/f_motosierra.gif" class="middle" alt="Motosierra">', ':guitarrista:' => '<img src="img/f_guitarrista.gif" class="middle" alt="Guitarrista...">', ':fumador:' => '<img src="img/f_fumador.gif" class="middle" alt="Fumador...">', ':bob:' => '<img src="img/f_bob_marley.gif" class="middle" alt="Jamaiquino">', ':ametralladora:' => '<img src="img/f_ametralladora.gif" class="middle" alt="Ametralladora">', ':acade:' => '<img src="img/f_racing.gif" class="middle" alt="Racinguista">', ':academico:' => '<img src="img/f_academico.gif" class="middle" alt="Academico">', '¬¬' => '<img src="img/f_molesto.gif" class="middle" alt="Molesto...">', ':yahoo:' => '<img src="img/f_yahoo.gif" class="middle" alt="Yahoo">', ':arbitro:' => '<img src="img/f_arbitro.gif" class="middle" alt="Expulsado">', ':pelea:' => '<img src="img/f_pelea.gif" class="middle" alt="Pelea">', ':ninja:' => '<img src="img/f_ninja.gif" class="middle" alt="Ninja">', ':ira:' => '<img src="img/f_ira.gif" class="middle" alt="Ira">', ':silva:' => '<img src="img/f_chifla.gif" class="middle" alt="Silvando">', ':box:' => '<img src="img/f_boxing.gif" class="middle" alt="Boxing...">', ':beer:' => '<img src="img/f_birra.gif" class="middle" alt="Cerveza">', ':baba:' => '<img src="img/f_babas.gif" class="middle" alt="Baboso">', ':amor:' => '<img src="img/f_amor.gif" class="middle" alt="amor...">', '[h1]' => '', '[center]' => '', '[/center]' => '', '[right]' => '', '[/right]' => '', '[b]' => '', '[/b]' => '', '[i]' => '', '[/i]' => '', '[u]' => '', '[/u]' => '', '[/color]' => '', '[color=blue]' => '', '[color=green]' => '', '[color=black]' => '', '[color=red]' => '', '[/h1]' => '', '[h2]' => '', '[/h2]' => '', '[h3]' => '', '[/h3]' => '', '[h4]' => '', '[/h4]' => '', '[h5]' => '>', '[/h5]' => '', '[left]' => '', '[/left]' => '', '[t]' => '', '[/t]' => '', '[justify]' => '', '[/justify]' => '', '[title]' => '', '[/title]' => '', '[subtitle]' => '', '[/subtitle]' => '', '[mail]' => '', '[/mail]' => '', ':ouch:' => '<img src="img/f_ouch.gif" class="middle" alt="Ouch">', ':)' => '<img src="img/f_sonrie.gif" class="middle" alt="Sonrie">', ';)' => '<img src="img/f_guino.gif" class="middle" alt="Guiño">', ':D' => '<img src="img/f_risa_gigante.gif" class="middle" alt="Risa gigante">', ':(' => '<img src="img/f_triste.gif" class="middle" alt="Triste">', ':no:' => '<img src="img/f_no_azul.gif" class="middle" alt="no">', ':chau:' => '<img src="img/f_chau.gif" class="middle" alt="Chau!">', ':emocionado:' => '<img src="img/f_saltarin.gif" class="middle" alt="Emocionado">', ':si:' => '<img src="img/f_si.gif" class="middle" alt="Si">', '0_o' => '<img src="img/f_sorprendido.gif" class="middle" alt="Sorprendido">', 'o_0' => '<img src="img/f_ojon.gif" class="middle" alt="Ojon">', ':s' => '<img src="img/f_desconsertado.gif" class="middle" alt="Desconcertado">', ':X' => '<img src="img/f_censurado.gif" class="middle" alt="Censurado">', ':x' => '<img src="img/f_censurado.gif" class="middle" alt="Censurado">', ':zzz:' => '<img src="img/f_dormido.gif" class="middle" alt="zZzZz">', ':?:' => '<img src="img/f_quest.gif" class="middle" alt="?">', ':lol:' => '<img src="img/f_lol.gif" class="middle" alt="">', ':p' => '<img src="img/f_lengua.gif" class="middle" alt="Lengua">', ':P' => '<img src="img/f_lengua.gif" class="middle" alt="Lengua">', ':o' => '<img src="img/f_ooo.gif" class="middle" alt="">', ':O' => '<img src="img/f_ooo.gif" class="middle" alt="">', ':@' => '<img src="img/f_payaso.gif" class="middle" alt="Payaso">', ':yes:' => '<img src="img/f_aprobado.gif" class="middle" alt="Aprobado!">', ':nou:' => '<img src="img/f_desaprobado.gif" class="middle" alt="Desaprobado!">', ':&' => '<img src="img/f_asqueado.gif" class="middle" alt="Asqueado">', ':-(' => '<img src="img/f_lloron.gif" class="middle" alt="Lloron">', ':cool:' => '<img src="img/f_cool.gif" class="middle" alt="Cool">', 'q:|' => '<img src="img/f_policia.gif" class="middle" alt="Policia">', 'X_o' => '<img src="img/f_pirata.gif" class="middle" alt="Pirata">', ':aplausos:' => '<img src="img/f_aplausos.gif" class="middle" alt="Aplausos">', '[/citar]' => '', '[citar]' => '', '[/recitar]' => '', '[recitar]' => ''
);
// Negritas [b]texto[/b]
$texto = preg_replace("`\[b\](.*?)\[/b\]`is", '<span class="font_bold">$1</span>', $texto);
// Italicas [i]texto[/i]
$texto = preg_replace("`\[i\](.*?)\[/i\]`is", '<span class="font_italic">$1</span>', $texto);
// Subrayadas [u]texto[/u]
$texto = preg_replace("`\[u\](.*?)\[/u\]`is", '<span class="font_unde">$1</span>', $texto);
// Tachadas [t]texto[/t]
$texto = preg_replace("`\[t\](.*?)\[/t\]`is", '<span class="font_tach">$1</span>', $texto);
// Texto centrado [center]texto[/center]
$texto = preg_replace("`\[center\](.*?)\[/center\]`is", '<p class="center">$1</p>', $texto);
// Texto izquierda [left]texto[/left]
$texto = preg_replace("`\[left\](.*?)\[/left\]`is", '<p class="left">$1</p>', $texto);
// Texto derecha [right]texto[/right]
$texto = preg_replace("`\[right\](.*?)\[/right\]`is", '<p class="right">$1</p>', $texto);
// Texto justificado [justify]texto[/justify]
$texto = preg_replace("`\[justify\](.*?)\[/justify\]`is", '<p class="justify">$1</p>', $texto);
// Texto justificado [justify]texto[/justify]
$texto = preg_replace("`\[color=(green|red|black|blue|violet|orange|graydark|graylight|cyan|olive|yellow|bluelight|bluedark|pink|greendark)\](.*?)\[/color\]`is", '<span class="color_$1">$2</span>', $texto);
// TAMAÑOS DE TEXTO
// title [title]texto[/title]
$texto = preg_replace("`\[title\](.*?)\[/title\]`is", '<span class="FH1">$1</span>', $texto);
// subtitle [subtitle]texto[/subtitle]
$texto = preg_replace("`\[subtitle\](.*?)\[/subtitle\]`is", '<span class="FSH1">$1</span>', $texto);
// H1 [h1]texto[/h1]
$texto = preg_replace("`\[h1\](.*?)\[/h1\]`is", '<span class="FH1">$1</span>', $texto);
// H2 [h2]texto[/h2]
$texto = preg_replace("`\[h2\](.*?)\[/h2\]`is", '<span class="FH2">$1</span>', $texto);
// H3 [h3]texto[/h3]
$texto = preg_replace("`\[h3\](.*?)\[/h3\]`is", '<span class="FH3">$1</span>', $texto);
// H4 [h4]texto[/h4]
$texto = preg_replace("`\[h4\](.*?)\[/h4\]`is", '<span class="FH4">$1</span>', $texto);
// URL's EXTERNAS
$texto = preg_replace("`\[url\]\s*(.*?)\s*\[/url\]`is", '<a href="$1" target="_blank">$1</a>', $texto);
// URL's EXTERNAS
$texto = preg_replace("`\[url=\s*(.*?)\]\s*(.*?)\s*\[/url\]`is", '<a href="$1" target="_blank">$2</a>', $texto);
// CITAR MENSAJE
$texto = preg_replace("`\[citar\]\s*(.+?)\s*\[/citar\]`is", '<span class="bold">Cita:</span><div class="topic_quote">$1</div>', $texto);
// CITAR MENSAJE
$texto = preg_replace("`\[citar=\s*(.+?)\s*\]\s*(.+?)\s*\[/citar\]`is", '<span class="bold">$1</span> escribió:<div class="topic_quote">$2</div>', $texto);
// CITAR MENSAJE
$texto = preg_replace("`\[recitar=\s*(.+?)\s*\]\s*(.+?)\s*\[/recitar\]`is", '<span class="bold">$1</span> escribió:<div class="topic_requote">$2</div>', $texto);
// CITAR MENSAJE
$texto = preg_replace("`\[recitar\]\s*(.+?)\s*\[/recitar\]`is", '<span class="bold">Cita:</span><div class="topic_requote">$1</div>', $texto);
// MAIL's
$texto = preg_replace("`\[mail\]\s*(.*?)\s*\[/mail\]`is", '<a href="mailto:$1">$1</a>', $texto);
// MAIL's
$texto = preg_replace("`\[mail=\s*(.*?)\]\s*(.*?)\s*\[/mail\]`is", '<a href="mailto:$1">$2</a>', $texto);
// IMAGENES
$texto = preg_replace("`\[img=\s*(.*?)\s*\]`is", '<img src="$1" alt="" />', $texto);
// IMAGENES
$texto = preg_replace("`\[img=\s*(.*?) \s*class=\s*(left|right|none|center|galery)\s*\]\s*(.*?)\s*\[/img\]`is", '<img src="$1" alt="$3" title="$3" class="$2" />', $texto);
// IMAGENES
$texto = preg_replace("`\[img=\s*(.*?) \s*class=\s*(left|right|none|center|galery)\s* ?(.*?)\s*\]\s*(.*?)\s*\[/img\]`is", '<img src="$1" alt="$4" title="$4" class="$2" $3 />', $texto);
// IMAGENES
$texto = preg_replace("`\[img]\s*(.*?)\s*\[/img\]`is", '<img src="$1" alt="" />', $texto);
$tips = array_keys($_BBcode);
$finaltext = str_replace($tips,$_BBcode, $texto);
$finaltext = stripslashes($finaltext);
$finaltext = nl2br($finaltext);
return $finaltext;
}
Código PHP:
$texto = preg_replace("`\[citar=\s*(.+?)\s*\]\s*(.+?)\s*\[/citar\]`is", '<span class="bold">$1</span> escribió:<div class="topic_quote">$2</div>', $texto);
Código PHP:
$texto = preg_replace("`\[citar=\s*(.+?)\s*\]\s*(.+?)\s*\[/citar\]`is", '<span class="bold">$1</span> escribió:<div class="topic_quote">BBcode($2)</div>', $texto);
Por favor necesito su ayuda para terminar con este tema....
Saludos!