Ver Mensaje Individual
  #73 (permalink)  
Antiguo 23/07/2005, 16:46
Avatar de El_Metallick
El_Metallick
 
Fecha de Ingreso: noviembre-2002
Ubicación: Santiago, Chile
Mensajes: 1.718
Antigüedad: 22 años, 6 meses
Puntos: 16
Yo en cuanto a lo de seguridad como dije pondria las funciones de la biblioeca

limpiar.asp
Código:
%
Dim str

function limpiar(strlimpiar,modolimpiar)

	'modolimpiar = 0 prepara strlimpiar para insert 
	'modolimpiar = 1 Prepara strlimpiar para insert evitando, ademas, la entrada de HTML
	'modolimpiar = 2 Prepara strlimpiar para un login y evita sql injection
	
	str = trim(strlimpiar)
	
	Select Case modolimpiar
    Case 0
		str = replace(str,"'","''")
		str = replace(str,"<","&lt;")
		str = replace(str,">","&gt;")
	Case 1
		str = replace(str,"'","''")
		str = replace(str,"<","&lt;")
		str = replace(str,">","&gt;")
		str = replace(str,chr(13),"<br>")
	Case 2
        str = lcase(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","")
    Case Else 
        str = strlimpiar
	End Select

	limpiar = str

end function
%>
eso con unas pocas modificaciones y la otra seria validar.asp tambien algo modificada
Código:
<%
Dim estado_validacion
Dim i
Dim campo

function validar(campo, n_caracteres, numeros, texto)

campo = Lcase(campo)

estado_validacion = true

if numeros = true And texto = true then 
For i = 1 To Len(campo)
If(Mid(campo, i, 1) < "a" Or Mid(campo, i, 1) > "z") And (Mid(campo, i, 1) < "0" Or Mid(campo, i, 1) > "9") then
estado_validacion = false
validar = estado_validacion
exit function
End If 
next

elseif numeros = true And texto = false then
For i = 1 To Len(campo)
If(Mid(campo, i, 1) < "0" Or Mid(campo, i, 1) > "9") then
estado_validacion = false
validar = estado_validacion
exit function
end if
next

elseif numeros = false And texto = true then
For i = 1 To Len(campo)
If(Mid(campo, i, 1) < "a" Or Mid(campo, i, 1) > "z") then
estado_validacion = false
validar = estado_validacion
exit function 
end if
Next
end if

if Len(campo) > n_caracteres OR campo = "" then
estado_validacion = false
validar = estado_validacion
exit function
end if

validar = estado_validacion 

end function
%>
eso saludos
__________________
Haz la guerra en la cama y el amor donde se te de la gana...
El tiempo es el mejor maestro, lo único malo es que te mata...¡¡Aprovecha tu tiempo!!