Ver Mensaje Individual
  #1 (permalink)  
Antiguo 06/03/2008, 05:15
Avatar de farra
farra
 
Fecha de Ingreso: marzo-2008
Ubicación: Aqui estoy
Mensajes: 574
Antigüedad: 16 años, 1 mes
Puntos: 20
Exclamación seguridad contra inyeccion SQL

una funcion contra la inyeccion sql:

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 
"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;
    case 
"like1":
      
$theValue = ($theValue != "") ? "'%" $theValue "%'" "NULL";
      break;
    case 
"like2":
      
$theValue = ($theValue != "") ? "'" $theValue "%'" "NULL";
      break;
    case 
"like3":
      
$theValue = ($theValue != "") ? "'%" $theValue "'" "NULL";
      break;
  }
  return 
$theValue;
}

quisiera saber si es 100% segura?