Ver Mensaje Individual
  #6 (permalink)  
Antiguo 05/05/2008, 09:50
Avatar de farra
farra
 
Fecha de Ingreso: marzo-2008
Ubicación: Aqui estoy
Mensajes: 574
Antigüedad: 18 años, 7 meses
Puntos: 20
De acuerdo Re: ¿como detener inyeccion sql?

eso que pusiste ahi, no es una inyeccion sql ni ataques xss....
es simplemente meter codigo html en tu pagina... y se elimina muy facilmente...

con esta funcion:

htmlentities();


funcion de dreamweaver modificada:
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 
htmlentities($theValue);   /// aca esta la modificacion...
} 
} 
y listo! tambien te va a protejer de ataques xss...