Ver Mensaje Individual
  #1 (permalink)  
Antiguo 20/10/2009, 12:00
dani_cad
 
Fecha de Ingreso: septiembre-2009
Mensajes: 67
Antigüedad: 14 años, 7 meses
Puntos: 2
Limpiando variables

Hola, necesito "limpiar" el contenido de Get, Post o cookies, genericamente, para darle seguridad a los datos recibidos. Utilizo esta funcion:

function sanitize_vars_fixed() {
foreach ($GLOBALS as $var => $value) {
if (is_array($value)) {
foreach ($value as $i => $j) {
//saca '/'
$j = preg_replace("/\\\\/", "", $j);
// ENT_QUOTES muestra ' escapeadas como html
$GLOBALS[$var][$i] = addslashes(htmlentities($j, ENT_QUOTES));
}
} else {
$value = preg_replace("/\\\\/", "", $value);
$GLOBALS[$var] = addslashes(htmlentities($value, ENT_QUOTES));
}
}
}

Pero usando PHP 5.2.10, me da errores como

[Tue Oct 20 10:45:54 2009] [error] [client 127.0.0.1] PHP Notice:
Array to string conversion in
D:\\sitio\\04sis\\config.php on line 116
[Tue Oct 20 10:45:54 2009] [error] [client 127.0.0.1] PHP Warning:
htmlentities() expects parameter 1 to be string, array given in
D:\\sitio\\04sis\\config.php on line 119
[Tue Oct 20 10:45:54 2009] [error] [client 127.0.0.1] PHP Fatal error:
Cannot use string offset as an array in
D:\\sitio\\04sis\\config.php on line 119

cual puede ser el problema? Alguien tiene una rutina similar que utulice? Estoy iniciando en php. Gracias