%@LANGUAGE="VBSCRIPT"%>
<%
' *** Edit Operations: declare variables
MM_editAction = CStr(Request("URL"))
If (Request.QueryString <> "") Then
MM_editAction = MM_editAction & "?" & Request.QueryString
End If
' boolean to abort record edit
MM_abortEdit = false
' query string to execute
MM_editQuery = ""
%>
<%
' *** Redirect if username exists
MM_flag="MM_insert"
If (CStr(Request(MM_flag)) <> "") Then
MM_dupKeyRedirect="usuario.asp"
MM_rsKeyConnection=MM_correomy_STRING
MM_dupKeyUsernameValue = CStr(Request.Form("usuario"))
MM_dupKeySQL="SELECT usuario FROM usuarios WHERE usuario='" & MM_dupKeyUsernameValue & "'"
MM_adodbRecordset="ADODB.Recordset"
set MM_rsKey=Server.CreateObject(MM_adodbRecordset)
MM_rsKey.ActiveConnection=MM_rsKeyConnection
MM_rsKey.Source=MM_dupKeySQL
MM_rsKey.CursorType=0
MM_rsKey.CursorLocation=2
MM_rsKey.LockType=3
MM_rsKey.Open
IF Not MM_rsKey.EOF Or Not MM_rsKey.BOF Then
' the username was found - can not add the requested username
MM_qsChar = "?"
If (InStr(1,MM_dupKeyRedirect,"?") >= 1) Then MM_qsChar = "&"
MM_dupKeyRedirect = MM_dupKeyRedirect & MM_qsChar & "requsername=" & MM_dupKeyUsernameValue
Response.Redirect(MM_dupKeyRedirect)
End If
MM_rsKey.Close
End If
%>
<%
'========================================================
'========================================================
'=========== Comencen les meves validacions ============
'========================================================
'========================================================
If (CStr(Request("MM_insert")) <> "") Then
if not Validar then
scriptError
cont = false
else
cont = true
end if
Function Validar ()
Dim sUsuario,sPassword,sCPassword,sNombre,sApellidos,sDireccion,sCp,sCiudad,sProvincia
Dim sDia,sMes,sAno,numCP
Dim vError(20) '16 errores posibles!
Dim bCorrecto 'para indicar al final si hubo o no errores
Dim cont
Dim I
Dim resconta
Dim oER, patron
bCorrecto = True
sUsuario = Trim(Request.Form("usuario"))
sPassword = Trim(Request.Form("password"))
sCPassword = Trim(Request.Form("password2"))
sNombre = Trim(Request.Form("nombre"))
sApellidos = Trim(Request.Form("apellidos"))
sDireccion = Trim(Request.Form("direccion"))
sCp = Trim(Request.Form("cp"))
sCiudad = Trim(Request.Form("ciudad"))
sProvincia = Trim(Request.Form("provincia"))
if Len(sUsuario) = 0 then
'cod.error: 0
vError(0) = True
bCorrecto = False
end if
if not EsValidoMail (sUsuario) then
'cod.error: 1
vError(1) = True
bCorrecto = False
end if
if Len(sPassword) = 0 then
'cod.error: 2
vError(2) = True
bCorrecto = False
end if
if Len(sPassword) < 6 then
'cod.error: 3
vError(3) = True
bCorrecto = False
end if
if Len(sCPassword) = 0 then
'cod.error: 4
vError(4) = True
bCorrecto = False
end if
if sPassword <> sCPassword then
'cod.error: 5
vError(5) = True
bCorrecto = False
end if
if Len(sNombre) = 0 then
'cod.error: 6
vError(6) = True
bCorrecto = False
end if
if Len(sApellidos) = 0 then
'cod.error: 7
vError(7) = True
bCorrecto = False
end if
if Len(sDireccion) = 0 then
'cod.error: 8
vError(8) = True
bCorrecto = False
end if
if Len(sCp) = 0 then
'cod.error: 9
vError(9) = True
bCorrecto = False
end if
if Len(sCiudad) = 0 then
'cod.error: 10
vError(10) = True
bCorrecto = False
end if
if Len(sProvincia) = 0 then
'cod.error: 11
vError(11) = True
bCorrecto = False
end if
if Request.Form("dia") = "" then
'cod.error: 12
vError(12) = True
bCorrecto = False
end if
if Request.Form("mes") = "" then
'cod.error: 13
vError(13) = True
bCorrecto = False
end if
if Request.Form("ano") = "" then
'cod.error: 14
vError(14) = True
bCorrecto = False
end if
if Request.Form("nif") = "" then
'cod.error: 14
vError(16) = True
bCorrecto = False
end if
'resconta = contador_check()
'If resconta = "falten" then
'cod.error: 15
' vError(15) = True
' bCorrecto = False
'end if
'if resconta = "sobren" then
'cod.error: 16
' vError(16) = True
' bCorrecto = False
'end if
' patron = "^[0-9]+$"
' set oER = New RegExp
' oER.Pattern = patron
' oER.IgnoreCase = False
' if not oER.Test(sCP) then
' 'cod.error: 17
' vError(17) = True
' bCorrecto = False
' end if
' set oER = nothing
'Formamos la cadena de errores, si los hay
if not bCorrecto then
'El carácter \n es el carácter de nueva línea en Javascript (y en C...)
strError = "'Hay errores en los datos que acaba de introducir\n"
for I=LBound(vError) to UBound(vError)
if vError(I) = True then
strError = strError & MsgError(I)
end if
next
'Cierro la comilla simple para el Javascript
strError = strError & "'"
end if
Validar = bCorrecto
End Function 'Validar
'======================================================
Function MsgError ( codigo )
'Devuelve un mensaje descriptivo correspondiente al error
select case codigo
case 0
MsgError = "* El campo Usuario no puede estar vacío\n"
case 1
MsgError = "* La dirección de correo electrónico que servirá de usuario no es válida\n"
case 2
MsgError = "* El campo Password no puede estar vacío\n"
case 3
MsgError = "* El Password debe tener al menos 6 caracteres\n"
case 4
MsgError = "* El campo confirmación del Password no puede estar vacío\n"
case 5
MsgError = "* Error al confirmar el password\n"
case 6
MsgError = "* El campo Nombre no puede estar vacío\n"
case 7
MsgError = "* El campo Apellidos no puede estar vacío\n"
case 8
MsgError = "* El campo Direccion no puede estar vacío\n"
case 9
MsgError = "* El campo Cp no puede estar vacío\n"
case 10
MsgError = "* El campo Ciudad no puede estar vacío\n"
case 11
MsgError = "* El campo Provincia no puede estar vacío\n"
case 12
MsgError = "* El campo Dia de naciemiento no puede estar vacío\n"
case 13
MsgError = "* El campo Mes de naciemiento no puede estar vacío\n"
case 14
MsgError = "* El campo Año de naciemiento no puede estar vacío\n"
case 15
MsgError = "* El número de areas de interés es infeerior a 10\n"
case 16
MsgError = "* El número de areas de interés es superior a 15\n"
case 16
MsgError = "* El campo Nif no puede estar vacío\n"
end select
End Function 'MsgError
'========================================================
Sub ScriptError()
'Incluye el script para mostrar los errores en el cliente
Response.Write ("")
End Sub 'ScriptError()
'========================================================
Function EsValidoMail ( mail )
Dim bValido
bValido = True
if Len(mail) < 5 then
'a@a.ti por ejemplo
bValido = False
else
if InStr(1, mail, "@") = 0 then
'No tiene una @
bValido = False
else
if InStr(1, mail, ".") = 0 then
'No tiene un punto
bValido = False
else
if InStr(InStr(1, mail, "@"), mail, ".") < InStr(1, mail, "@") then
'No tiene un punto después de la @
bValido = False
end if
end if
end if
end if
EsValidoMail = bValido
End Function 'EsValidoMail
Function contador_check()
Dim n_check
Dim retorno,sAnimales
n_check = 0
retorno = "correcto"
if Request.Form("a_animales") = "1" then n_check = n_check + 1 end if
if Request.Form("a_astrologia") = "1" then n_check = n_check + 1 end if
if Request.Form("a_cienciaytecno") = "1" then n_check = n_check + 1 end if
if Request.Form("a_internet") = "1" then n_check = n_check + 1 end if
if Request.Form("a_empleo") = "1" then n_check = n_check + 1 end if
if Request.Form("a_formacion") = "1" then n_check = n_check + 1 end if
if Request.Form("a_hardware") = "1" then n_check = n_check + 1 end if
if Request.Form("a_econamiafinan") = "1" then n_check = n_check + 1 end if
if Request.Form("a_cultura") = "1" then n_check = n_check + 1 end if
if Request.Form("a_moda") = "1" then n_check = n_check + 1 end if
if Request.Form("a_multimedia") = "1" then n_check = n_check + 1 end if
if Request.Form("a_ninos") = "1" then n_check = n_check + 1 end if
if Request.Form("a_software") = "1" then n_check = n_check + 1 end if
if Request.Form("a_tele") = "1" then n_check = n_check + 1 end if
if Request.Form("a_arte") = "1" then n_check = n_check + 1 end if
if Request.Form("a_casajardin") = "1" then n_check = n_check + 1 end if
if Request.Form("a_coches") = "1" then n_check = n_check + 1 end if
if Request.Form("a_deportes") = "1" then n_check = n_check + 1 end if
if Request.Form("a_electrodomes") = "1" then n_check = n_check + 1 end if
if Request.Form("a_estetica") = "1" then n_check = n_check + 1 end if
if Request.Form("a_fotografia") = "1" then n_check = n_check + 1 end if
if Request.Form("a_inmobiliaria") = "1" then n_check = n_check + 1 end if
if Request.Form("a_juegos") = "1" then n_check = n_check + 1 end if
if Request.Form("a_medicinasalud") = "1" then n_check = n_check + 1 end if
if Request.Form("a_motos") = "1" then n_check = n_check + 1 end if
if Request.Form("a_musica") = "1" then n_check = n_check + 1 end if
if Request.Form("a_ocio") = "1" then n_check = n_check + 1 end if
if Request.Form("a_telefonia") = "1" then n_check = n_check + 1 end if
if Request.Form("a_viajestur") = "1" then n_check = n_check + 1 end if
if n_check > 15 then
retorno = "sobren"
end if
if n_check < 10 then
retorno = "falten"
end if
contador_check = retorno
End Function
end if
'========================================================
'========================================================
'=========== Comença el programa =======================
'========================================================
'========================================================
%>
<%
' *** Insert Record: set variables
If (CStr(Request("MM_insert")) <> "") and cont = True Then
dim strError
MM_editConnection = MM_correomy_STRING
MM_editTable = "usuarios"
MM_editRedirectUrl = "bienvenido.asp"
MM_fieldsStr = "usuario|value|nif|value|f_pago|value|referidopor|value|hiddenField|value|random|value|password|value|nombre|value|apellidos|value|direccion|value|cp|value|ciudad|value|provincia|value|pais|value|dia|value|mes|value|ano|value|profesion|value|url|value|a_animales|value|a_astrologia|value|a_cienciaytecno|value|a_internet|value|a_empleo|value|a_formacion|value|a_hardware|value|a_econamiafinan|value|a_cultura|value|a_moda|value|a_multimedia|value|a_ninos|value|a_software|value|a_tele|value|a_arte|value|a_casajardin|value|a_coches|value|a_deportes|value|a_electrodomes|value|a_viajestur|value|a_fotografia|value|a_inmobiliaria|value|a_juegos|value|a_medicinasalud|value|a_motos|value|a_musica|value|a_ocio|value|a_telefonia|value|a_estetica|value|radiobutton|value"
MM_columnsStr = "usuario|',none,''|nif|',none,''|f_pago|none,'Y','N'|referidopor|none,none,NULL|fecha_in|',none,NULL|random|',none,''|password|',none,''|nombre|',none,''|apellidos|',none,''|direccion|',none,''|cp|',none,''|ciudad|',none,''|provincia|',none,''|pais|',none,''|dia|none,none,NULL|mes|',none,''|ano|none,none,NULL|profesion|',none,''|url|',none,''|a_animales|none,'Y','N'|a_astrologia|none,'Y','N'|a_cienciaytecno|none,'Y','N'|a_internet|none,'Y','N'|a_empleo|none,'Y','N'|a_formacion|none,'Y','N'|a_hardware|none,'Y','N'|a_econamiafinan|none,'Y','N'|a_cultura|none,'Y','N'|a_moda|none,'Y','N'|a_multimedia|none,'Y','N'|a_ninos|none,'Y','N'|a_software|none,'Y','N'|a_tele|none,'Y','N'|a_arte|none,'Y','N'|a_casajardin|none,'Y','N'|a_coches|none,'Y','N'|a_deportes|none,'Y','N'|a_electrodomes|none,'Y','N'|a_viajestur|none,'Y','N'|a_fotografia|none,'Y','N'|a_inmobiliaria|none,'Y','N'|a_juegos|none,'Y','N'|a_medicinasalud|none,'Y','N'|a_motos|none,'Y','N'|a_musica|none,'Y','N'|a_ocio|none,'Y','N'|a_telefonia|none,'Y','N'|a_estetica|none,'Y','N'|r_notificacion|',none,''"
' create the MM_fields and MM_columns arrays
MM_fields = Split(MM_fieldsStr, "|")
MM_columns = Split(MM_columnsStr, "|")
' set the form values
For i = LBound(MM_fields) To UBound(MM_fields) Step 2
MM_fields(i+1) = CStr(Request.Form(MM_fields(i)))
Next
' append the query string to the redirect URL
If (MM_editRedirectUrl <> "" And Request.QueryString <> "") Then
If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And Request.QueryString <> "") Then
MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
Else
MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
End If
End If
End If
%>
<%
' *** Insert Record: construct a sql insert statement and execute it
If (CStr(Request("MM_insert")) <> "") and cont = True Then
' create the sql insert statement
MM_tableValues = ""
MM_dbValues = ""
For i = LBound(MM_fields) To UBound(MM_fields) Step 2
FormVal = MM_fields(i+1)
MM_typeArray = Split(MM_columns(i+1),",")
Delim = MM_typeArray(0)
If (Delim = "none") Then Delim = ""
AltVal = MM_typeArray(1)
If (AltVal = "none") Then AltVal = ""
EmptyVal = MM_typeArray(2)
If (EmptyVal = "none") Then EmptyVal = ""
If (FormVal = "") Then
FormVal = EmptyVal
Else
If (AltVal <> "") Then
FormVal = AltVal
ElseIf (Delim = "'") Then ' escape quotes
FormVal = "'" & Replace(FormVal,"'","''") & "'"
Else
FormVal = Delim + FormVal + Delim
End If
End If
If (i <> LBound(MM_fields)) Then
MM_tableValues = MM_tableValues & ","
MM_dbValues = MM_dbValues & ","
End if
MM_tableValues = MM_tableValues & MM_columns(i)
MM_dbValues = MM_dbValues & FormVal
Next
MM_editQuery = "insert into " & MM_editTable & " (" & MM_tableValues & ") values (" & MM_dbValues & ")"
If (Not MM_abortEdit) Then
' execute the insert
Set MM_editCmd = Server.CreateObject("ADODB.Command")
MM_editCmd.ActiveConnection = MM_editConnection
MM_editCmd.CommandText = MM_editQuery
MM_editCmd.Execute
MM_editCmd.ActiveConnection.Close
If (MM_editRedirectUrl <> "") Then
Session("ref") = Replace(Afiliarme__MMColParam, "'", "''")
Session("nom_refent") = Request.Form("nombre")
Session("pobla_refent") = Request.Form("ciudad")
Session("usuario_refent") = Request.Form("usuario")
Session("password_refent") = Request.Form("password")
Session("random") = Request.Form("random")
Response.Redirect(MM_editRedirectUrl)
End If
End If
End If
%>
<%
Dim Afiliarme__MMColParam
Afiliarme__MMColParam = "0"
if session("usuario") = "" then
if (Request.QueryString("ref") <> "") then
session("usuario") = Request.QueryString("ref")
else
session("usuario") = 0
end if
end if
%>
<%
set Afiliarme = Server.CreateObject("ADODB.Recordset")
Afiliarme.ActiveConnection = MM_correomy_STRING
Afiliarme.Source = "SELECT id, DATE_FORMAT(sysdate(),'%Y/%m/%d %k:%i:%s') s, substring((RAND()*10000000),1,6) random2, RAND()*10000000 random FROM usuarios WHERE usuario = '" + Replace(session("usuario") , "'", "''") + "'"
Afiliarme.CursorType = 0
Afiliarme.CursorLocation = 2
Afiliarme.LockType = 3
Afiliarme.Open()
Afiliarme_numRows = 0
s1 = Afiliarme.Fields.Item("s").Value
random = Afiliarme.Fields.Item("random").Value
random = Left(random,6)
%>