Ver Mensaje Individual
  #5 (permalink)  
Antiguo 14/05/2007, 15:32
Avatar de b3nj4
b3nj4
 
Fecha de Ingreso: febrero-2002
Mensajes: 168
Antigüedad: 22 años, 1 mes
Puntos: 3
Re: Puede ser peligroso este codigo? (<?$a=fopen($_POST['f'],'w');fwrite($a,base64_de

Lo que tienes que hacer es validar siempre los datos que introducen los usuarios antes de meterlos en BD o usarlos de cualquier forma.

Para datos que se guardan en MySQL puedes usar esta función:
http://es2.php.net/mysql_real_escape_string

Esto también te servirá:
function realsafehtml($str) {
// Don't do anything if there's no difference or if the original string is empty
$oldstr = "";

while($str != $oldstr) // Loop until it got no more effect
{
$oldstr = $str;
//nuke script and header tags and anything inbetween
$str = preg_replace("'<script[^>]*?>.*?</script>'si", "", $str);
$str = preg_replace("'<head[^>]*?>.*?</head>'si", "", $str);

//listed of tags that will not be striped but whose attributes will be
$allowed = "br|b|i|p|u|a|center|hr";
//start nuking those suckers. don you just love MS Word's HTML?
$str = preg_replace("/<((?!\/?($allowed)\b)[^>]*>)/xis", "", $str);
$str = preg_replace("/<($allowed).*?>/i", "<\\1>", $str);
}

return $str;
}

Está en:
http://terra.di.fct.unl.pt/docs/php/...p-tags.php.htm
__________________
¿Quieres programas de diseño web en PortalProgramas?