Ver Mensaje Individual
  #6 (permalink)  
Antiguo 04/08/2008, 06:18
Avatar de farra
farra
 
Fecha de Ingreso: marzo-2008
Ubicación: Aqui estoy
Mensajes: 574
Antigüedad: 16 años, 2 meses
Puntos: 20
Respuesta: Evitar el uso de $_GET, $_POST y AJAX

Man, al pedo te vas a complicar tanto... y lo que decis no se puede hacer por que de cualquier forma tenes que pasarle por GET o POST el valor a la variable de sesion... y no es muy buena idea llenar tu server con variables de sesion creo que podria afectar la performance y no creo que quieras eso...

la inseguridad que tienen Get o Post son las inyecciones sql, pero eso es facil de solucionar...

usa esta funcion:
Código PHP:
if (!function_exists("GetSQLValueString")) { 
function 
GetSQLValueString($theValue$theType$theDefinedValue ""$theNotDefinedValue "")  

  
$theValue get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue

  
$theValue function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); 

  switch (
$theType) { 
    case 
"text"
      
$theValue = ($theValue != "") ? "'" $theValue "'" "NULL"
      break;     
    case 
"long"
    case 
"int"
      
$theValue = ($theValue != "") ? intval($theValue) : "NULL"
      break; 
    case 
"double"
      
$theValue = ($theValue != "") ? "'" doubleval($theValue) . "'" "NULL"
      break; 
    case 
"date"
      
$theValue = ($theValue != "") ? "'" $theValue "'" "NULL"
      break; 
    case 
"defined"
      
$theValue = ($theValue != "") ? $theDefinedValue $theNotDefinedValue
      break; 
  } 
  return 
$theValue



Ejemplo de como usar:
Código PHP:

$variable
=GetSQLValueString($_GET['Id'],"int"); 
y listo esta limpia tu variable $_GET['Id']...

esa funcion lo que hace es limpiar la variable GET o POST... con mysql_real_escape_string , stripslashes y get_magic_quotes_gpc y tambien validando el tipo de dato...
__________________
Firma:
Es mas dificil para el mono entender que el hombre desciende de el....

PD: Siempre doy karma al que me da una buena respuesta... ;0)