Ver Mensaje Individual
  #9 (permalink)  
Antiguo 26/07/2008, 04:22
Avatar de Adler
Adler
Colaborador
 
Fecha de Ingreso: diciembre-2006
Mensajes: 4.671
Antigüedad: 18 años, 3 meses
Puntos: 126
Respuesta: Limitar cajas de texto para evitar injection SQL

Cita:
Iniciado por Shiryu_Libra Ver Mensaje
seria mejor si utilizaran las funciones por separado, para motivos de depuracion
Si aún continuas queriendo integrar ambas funciones a pesar de lo que comenta el sensei ,prueba así

Código PHP:
function ValidaDatos(Nombre,ValorDefecto'nombre es el login y valordefecto "".  
  if not ActiveFile_SeUsa then
    if (Request.Form(Nombre) <> "") then
        ValidaDatos = Request.Form(Nombre)
      else
        if (Request.QueryString(Nombre) <> "") then
            ValidaDatos = Request.QueryString(Nombre)
        else
            ValidaDatos = ValorDefecto
        End if
      End if
    else ' 
se está usando el ActiveFile
      
if not ActiveFile_YaSubido then
        ValidaDatos 
ValorDefecto
      
else
      
dim iencontradostr
        encontrado 
false
 str 
Nombre
        str 
replace(str,"x","j")
        
str replace(str,"  "," ")
        
str replace(str,"=","")
        
str replace(str,"'","")
        
str replace(str,"""""","")
        
str replace(str," or ","")
        
str replace(str," and ","")
        
str replace(str,"(","")
        
str replace(str,")","")
        
str replace(str,"<","")
        
str replace(str,">","")
        
str replace(str,"having ","")
        
str replace(str,"group by","")
        
str replace(str,"union select sum","")
        
str replace(str,"union select min","")
        
str replace(str,"--","")
        
str replace(str,"select ","")
        
str replace(str,"insert ","")
        
str replace(str,"update ","")
        
str replace(str,"delete ","")
        
str replace(str,"drop ","")
        
str replace(str,"-shutdown",""
      for 
1 to nActiveFile_Vars
        
if ActiveFile_Vars(1,i) = str then  <-esto para que sirve???
          
ValidaDatos ActiveFile_Vars(2,i)
          
encontrado true
        end 
if
      
next
      
if not encontrado then
          ValidaDatos 
ValorDefecto
      end 
if
      
end if
    
end if
End Function 
Suerte
__________________
Los formularios se envían/validan con un botón Submit
<input type="submit" value="Enviar" style="background-color:#0B5795; font:bold 10px verdana; color:#FFF;" />