![Adios](http://static.forosdelweb.com/fdwtheme/images/smilies/adios.gif)
$texto = str_replace("[imagen]","<img src=\"",$texto) ;
$texto = str_replace("[/imagen]","\" border=\"0\">",$texto) ;
aunque agregue <img src=\"\" width=\" no me sale bien, alguien tiene una sugerencia?
Por ahora esto es ok.php
Código PHP:
<?php
include "configuracion.php";
function caritas($texto) {
$texto = str_replace(">D","<img src=\"img/alegre.gif\">", $texto);
$texto = str_replace(":X","<img src=\"img/callado.gif\">", $texto);
$texto = str_replace(">X","<img src=\"img/enojado.gif\">", $texto);
$texto = str_replace(":D","<img src=\"img/feliz.gif\">", $texto);
$texto = str_replace(";)","<img src=\"img/guino.gif\">", $texto);
$texto = str_replace(":P","<img src=\"img/lengua.gif\">", $texto);
$texto = str_replace(":'(","<img src=\"img/llora.gif\">", $texto);
$texto = str_replace(">O","<img src=\"img/grita.gif\">", $texto);
$texto = str_replace(">|","<img src=\"img/mmm.gif\">", $texto);
$texto = str_replace(":o","<img src=\"img/oh.gif\">", $texto);
$texto = str_replace(":|","<img src=\"img/serio.gif\">", $texto);
$texto = str_replace(":)","<img src=\"img/sonrisa.gif\">", $texto);
$texto = str_replace(":$","<img src=\"img/timido.gif\">", $texto);
$texto = str_replace(":(","<img src=\"img/triste.gif\">", $texto);
$texto = str_replace("xD","<img src=\"img/xd.gif\">", $texto);
return $texto;
}
$texto = caritas($texto);
// - - - - - Codigo PHP - - - - - //
if($codigo == "ON") {
if(strstr($texto,"[codigo]")) {
$partes = explode("[codigo]",$texto) ;
$total = count($partes) ;
for($a = 0 ; $a < $total ; $a++) {
$posicion = strpos($partes[$a],"[/codigo]") ;
if(strstr($partes[$a],"[/codigo]")) {
$codigo = substr($partes[$a],0,$posicion) ;
$codigo = html_entity_decode($codigo) ;
$coloreado = highlight_string($codigo,true) ;
$coloreado = str_replace("\r<br />","<br>",$coloreado) ;
$coloreado = "<table width=\"100%\"><tr><td class=\"php_titulo\" align=\"center\">Script</td></tr><tr><td class=\"php_source\">$coloreado</td></tr></table>" ;
$normal = substr($partes[$a],$posicion+9) ;
$partes[$a] = "$coloreado$normal" ;
}
}
$texto = implode("",$partes) ;
}
}
// - - - - - BBCode - - - - - //
if($bbcode == "ON") {
$texto = str_replace("[b]","<b>",$texto) ;
$texto = str_replace("[/b]","</b>",$texto) ;
$texto = str_replace("[u]","<u>",$texto) ;
$texto = str_replace("[/u]","</u>",$texto) ;
$texto = str_replace("[i]","<i>",$texto) ;
$texto = str_replace("[/i]","</i>",$texto) ;
$texto = str_replace("[s]","<s>",$texto) ;
$texto = str_replace("[/s]","</s>",$texto) ;
$texto = str_replace("[color=rojo]","<font color=\"red\">",$texto) ;
$texto = str_replace("[/color]","</font>",$texto) ;
$texto = str_replace("[color=rosa]","<font color=\"pink\">",$texto) ;
$texto = str_replace("[/color]","</font>",$texto) ;
$texto = str_replace("[color=verde]","<font color=\"green\">",$texto) ;
$texto = str_replace("[/color]","</font>",$texto) ;
$texto = str_replace("[centrar]","<center>",$texto) ;
$texto = str_replace("[/centrar]","</center>",$texto) ;
$texto = str_replace("[derecha]","<div align=\"right\">",$texto) ;
$texto = str_replace("[/derecha]","</div>",$texto) ;
$texto = str_replace("[imagen]","<img src=\"",$texto) ;
$texto = str_replace("[/imagen]","\" border=\"0\">",$texto) ;
$texto = str_replace("\r\n","<br>",$texto) ;
$texto = preg_replace("/(?<!<a href=\")((http|ftp)+(s)?:\/\/[^<>\s]+)/i","<a href=\"\\0\" target=\"_blank\">\\0</a>",$texto) ;
};
// - - - - - Censurar - - - - - //
if($censurar == "ON") {
$texto = str_replace("estupido","<s>censurado</s>",$texto);
$texto = str_replace("idiota","<s>censurado</s>",$texto);
};
mysql_connect("localhost","root","password");
mysql_db_query("x","insert into noticias (id,titulo,texto,autor,fecha) values ('$id','$titulo','$texto','$autor','$fecha')");
echo "Datos intertados correctamente<br>
Haz clic <a href=index.php>aqui</a> para ver los resultados";
?>
[codigo]<? $var = "hola";
echo $var; ?>[/codigo]
con comillas dobles o simples, a partir de la primera comilla, todo lo demas hasta antes de [/codigo] lo pone en rojo, donde esta el error?
Basta con poner $texto = htmlentities($texto); para bloquear html mal intencionado?
lo agregue al mismo archivo ok.php y lo que hace es que si agrego una carita sale <img src="img/feliz.gif"> y no la carita, como puedo bloquear el html para los comentarios sin que pase lo de las caritas?
Obviamente $texto es la variable que se procesa desde el <textarea name="texto"> del formulario
También tengo problema con la fecha pero por lo que he visto, hay mucha información de como ponerla, ojalá me tengan un poquito de paciencia