Gerald excelente. Pero me he realizado porque me quedaban algunas dudas con el código original. Ahí les dejo ambos códigos, el original y el mío modificado para que los revisen y me digan si el equivocado soy yo.
Original
Código PHP:
<?php
function bbcodes ($text) {
// Links para URLs. Formato: [web=http://php-hispano.net]PHPHispano[/web]
$finaltext = eregi_replace("\\[web=([^\\[]*)\\]([^\\[]*)\\[/web\\]", "<a target=\"_blank\" href=\"\\1\">\\2</a>", $text);
// Si no ponen atributos en [web]. Formato: [web]http://PHPHispano.net[/web]
$finaltext = eregi_replace("\\[web\\]([^\\[]*)\\[/web\\]","<a target=\"_blank\" href=\"\\1\">\\1</a>",$finaltext);
/* Este bucle lo hacemos por si ejempo usan u i y b en un solo texto :D */
while($bucle < 5) {
// Para poner linea al texto. Formato: [u]PHPHispano[/u]
$finaltext = eregi_replace("\\[u\\]([^\\[]*)\\[/u\\]","<u>\\1</u>", $finaltext);
// Para poner el text en italic. Formato: [i]PHPHispano[/i]
$finaltext = eregi_replace("\\[i\\]([^\\[]*)\\[/i\\]","<em>\\1</em>", $finaltext);
// Para poner texto en negrita Formato: [b]PHPHispano[/b]
$finaltext = eregi_replace("\\[b\\]([^\\[]*)\\[/b\\]","<strong>\\1</strong>", $finaltext);
$bucle++;
}
// Para centralizar un text. Formato: [center]PHPHispano[/center]
$finaltext = eregi_replace("\\[center\\]([^\\[]*)\\[/center\\]","<center>\\1</center>", $finaltext);
// Pone el texto como una cita. Formato: [cita]La calidad nunca es un accidente; siempre es el resultado de un esfuerzo de la inteligencia[/cita]
$finaltext = eregi_replace("\\[cita\\]([^\\[]*)\\[/cita\\]","\n<div class=\"css_title\">Cita\n<div class=\"css\">\\1</div></div>", $finaltext);
// Sacamos el color al codigo PHP. Formato: [ php ]codigo[/ php ]
preg_match_all ("/(\[)(php)(])(.*)(\[\/php\])/iU", $finaltext, $l);
for ($i=0; $i< count($l[0]); $i++) { $finaltext = str_replace($l[0][$i],phpcojecolor($l[4][$i]),$finaltext); }
// Retorno como queda el bbcode.
return $finaltext;
}
?>
<?
function phpcojecolor ($php) {
ob_start(); // Abirmos el OB
highlight_string($php); // Tiramos el codigo coloreado
$cfinal = ob_get_contents(); // COjo el codigo que tire despues de haber abierto el ob
ob_end_clean(); // Borro el ob para que no se vea en la web
// A continuación hemos hecho uso de una función realizada por Anonimo dueño de la web [url]www.pastebin.com[/url]. Sirve para mostrar información sobre las funciones... [Proximas 7 lineas]
$keycol=ini_get("highlight.keyword");
$manual="http://www.php.net/manual-lookup.php?lang=es&pattern=";
$cfinal=preg_replace(
'{([\w_]+)(\s*</font>)'.
'(\s*<font\s+color="'.$keycol.'">\s*\()}m',
'<a href="'.$manual.'$1" title="Ayuda en PHP.net sobre $1" target="_blank">$1</a>$2$3',
$cfinal);
return "\n<div class=\"css_title\">Código PHP:\n<div class=\"css\">".$cfinal."</div></div>"; // Retorno el codigo PHP Coloreado
}
?>
y este es el que he creado yo. Jeje le he agregado unas cosas para alinear a la derecha, a la izquierda, y justificar. Ahora lo que necesito que me ayuden a realizar porque no se como es cambiar la fuente, el color y el tamaño al igual que lo hace aquí FDW.
modificado
Código PHP:
<?
# Mod: BBCode
function BBCode($text){
# Links para URLs. Formato: [web=http://www.miweb.com]Mi web[/web]
$bbcode = eregi_replace("\\[web=([^\\[]*)\\]([^\\[]*)\\[/web\\]", "<a target=\"_blank\" href=\"\\1\">\\2</a>", $text);
# Si no ponen atributos en [web]. Formato: [web]http://www.miweb.com[/web]
$bbcode = eregi_replace("\\[web\\]([^\\[]*)\\[/web\\]","<a target=\"_blank\" href=\"\\1\">\\1</a>",$text);
# Bucle por si usan [B][U][I] en el mismo texto
while($bucle<5) {
# Para poner linea al texto. Formato: [U]MiWeb[/U]
$bbcode = eregi_replace("\\[u\\]([^\\[]*)\\[/u\\]","<u>\\1</u>",$text);
# Para poner el text en italic. Formato: [I]MiWeb[/I]
$bbcode = eregi_replace("\\[i\\]([^\\[]*)\\[/i\\]","<em>\\1</em>",$text);
# Para poner texto en negrita Formato: [B]MiWeb[/B]
$bbcode = eregi_replace("\\[b\\]([^\\[]*)\\[/b\\]","<strong>\\1</strong>",$text);
$bucle++;
}
# Para centralizar un texto. Formato: [centro] [/centro]
$bbcode = eregi_replace("\\[center\\]([^\\[]*)\\[/center\\]","<div align=center>\\1</div>", $text);
# Para centralizar un texto. Formato: [derecha] [/derecha]
$bbcode = eregi_replace("\\[right\\]([^\\[]*)\\[/right\\]","<div align=right>\\1</div>", $text);
# Para centralizar un texto. Formato: [izquierda] [/izquierda]
$bbcode = eregi_replace("\\[left\\]([^\\[]*)\\[/left\\]","<div align=left>\\1</div>", $text);
# Para centralizar un texto. Formato: [justificado] [/justificado]
$bbcode = eregi_replace("\\[justify\\]([^\\[]*)\\[/justify\\]","<div align=justify>\\1</div>", $text);
# Pone el texto como una cita. Formato: [CITA] [/CITA]
$bbcode = eregi_replace("\\[cita\\]([^\\[]*)\\[/cita\\]","\n<div class=\"css_title\">Cita\n<div class=\"css\">\\1</div></div>", $text);
# Sacamos el color al codigo PHP. Formato: [ PHP ] [ /PHP ]
preg_match_all ("/(\[)(php)(])(.*)(\[\/php\])/iU", $text, $l);
for($i=0; $i< count($l[0]); $i++){
$bbcode = str_replace($l[0][$i],PHPFormat($l[4][$i]),$text);
}
return $bbcode;
}
?>
<?
#Funcion para código PHP
function PHPFormat($php) {
ob_start();
highlight_string($php);
$final = ob_get_contents();
ob_end_clean();
$keycol=ini_get("highlight.keyword");
$manual="http://www.php.net/manual-lookup.php?lang=es&pattern=";
$final=preg_replace('{([\w_]+)(\s*</font>)'.
'(\s*<font\s+color="'.$keycol.'">\s*\()}m',
'<a href="'.$manual.'$1" title="Ayuda en PHP.net sobre $1" target="_blank">$1</a>$2$3',
$final);
return "\n<div class=\"css_title\">Código PHP:\n<div class=\"css\">".$final."</div></div>";
}
?>
Salu2