<%
'conn_string = "Driver={MySQL ODBC 3.51 Driver};;Server=localhost;Port=3306;Database=premis2;Uid=root;Pwd=root"
Set conn = Server.CreateObject("ADODB.Connection")
On Error resume next
conn.Open(conn_string)
'set tb = Server.CreateObject("ADODB.Recordset")
'tb.open "select * from web_bloqueo", conn, 2, 3
'if tb("bloqueo") = "S" then response.Redirect("bloqueo.asp")
'tb.close
'set tb=nothing
conn.close
set conn=nothing
%>
<%
Session("login") = "NO"
Session("usuario") = ""
Session("requiere")=""
%>
<%
if request.Form() <> "" then
'conn_string = "Driver={MySQL ODBC 3.51 Driver};;Server=localhost;Port=3306;Database=premis2;Uid=root;Pwd=root"
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open(conn_string)
set tb = Server.CreateObject("ADODB.Recordset")
tb.open "select * from web_usuarios where usuario = '" & request.Form("usuario") & "' and (clave = '" & request.Form("clave") & "' or clave = '')", conn, 2, 3
if tb.eof = true then
mensaje = "Login incorrecto"
tb.close
tb.open "select * from web_usuarios where usuario = '" & request.Form("usuario") & "'", conn, 2, 3
if tb.eof = false then
conn.execute "update web_usuarios set intentos = intentos + 1 where id = " & tb.fields("id")
conn.execute "update web_usuarios set clave_bloqueada = 'SI' where intentos >= 3"
entrar = "NO"
end if
entrar = "NO"
end if
if tb.eof = false then
greg = cdate(date)
Dim Dia
Dim Mes
Dim Ano
Dim Z
Dim B
Dia = Day(greg)
Mes = Month(greg)
Ano = Year(greg)
Z = (4712 + Ano) * 365.25
If Z = Int(Z) Then Z = Z - 1 Else Z = Int(Z)
If (Ano <= 1583 Or (Ano = 1582 And (Mes > 10 Or (Mes = 10 And Dia >= 15)))) And Ano <= 1700 Then Z = Z - 10
If 1701 <= ano And Ano <= 1800 Then Z = Z - 11
If 1801 <= ano And ano <= 1900 Then Z = Z - 12
If 1901 <= ano And ano <= 2100 Then Z = Z - 13
If 2101 <= ano And ano <= 2200 Then Z = Z - 14
B = CDate(greg) - Dia - CDate("31/12/" & ano - 1)
rfj1 = Z + B + Dia
greg = cdate(tb.fields("clave_vence"))
Dia = Day(greg)
Mes = Month(greg)
Ano = Year(greg)
Z = (4712 + Ano) * 365.25
If Z = Int(Z) Then Z = Z - 1 Else Z = Int(Z)
If (Ano <= 1583 Or (Ano = 1582 And (Mes > 10 Or (Mes = 10 And Dia >= 15)))) And Ano <= 1700 Then Z = Z - 10
If 1701 <= ano And Ano <= 1800 Then Z = Z - 11
If 1801 <= ano And ano <= 1900 Then Z = Z - 12
If 1901 <= ano And ano <= 2100 Then Z = Z - 13
If 2101 <= ano And ano <= 2200 Then Z = Z - 14
B = CDate(greg) - Dia - CDate("31/12/" & ano - 1)
rfj2 = Z + B + Dia
greg = dateadd("m",1,date)
Dia = Day(greg)
Mes = Month(greg)
Ano = Year(greg)
Z = (4712 + Ano) * 365.25
If Z = Int(Z) Then Z = Z - 1 Else Z = Int(Z)
If (Ano <= 1583 Or (Ano = 1582 And (Mes > 10 Or (Mes = 10 And Dia >= 15)))) And Ano <= 1700 Then Z = Z - 10
If 1701 <= ano And Ano <= 1800 Then Z = Z - 11
If 1801 <= ano And ano <= 1900 Then Z = Z - 12
If 1901 <= ano And ano <= 2100 Then Z = Z - 13
If 2101 <= ano And ano <= 2200 Then Z = Z - 14
B = CDate(greg) - Dia - CDate("31/12/" & ano - 1)
rfjvence = Z + B + Dia
if rfj1 => rfj2 and tb("clave_vencida") = "NO" then
mensaje = "
La clave está vencida, ingrese una nueva clave para continuar
La misma sera guardada como clave de acceso al sistema de reservas"
'tb.fields("clave_vencida")="SI"
conn.execute "update web_usuarios set clave = '', clave_vencida = 'SI' where id = " & tb.fields("id")
Session("login") = "NO"
Session("usuario") = ""
Session("requiere")=""
entrar = "NO"
end if
if tb.fields("clave_bloqueada") ="SI" then
mensaje = "
La clave está bloqueada por 3 intentos de Login fallidos, comuniquese con Premys Car"
Session("login") = "NO"
Session("usuario") = ""
Session("requiere")=""
entrar = "NO"
end if
if tb("clave") & "" = "" then entrar = "SI"
if tb.fields("clave_vencida")="SI" then
mensaje = "
La clave está vencida, ingrese una nueva clave para continuar
La misma sera guardada como clave de acceso al sistema de reservas"
'tb.fields("clave_vencida")="SI"
conn.execute "update web_usuarios set clave = '', clave_vencida = 'SI' where id = " & tb.fields("id")
Session("login") = "NO"
Session("usuario") = ""
Session("requiere")=""
entrar = "NO"
end if
if tb.fields("clave") & "" ="" and tb.fields("clave_vencida")="SI" then
conn.execute "update web_usuarios set clave = '" & request.Form("clave") & "', clave_vence = '" & dateadd("m",1,date) & "', clave_vencej=" & rfjvence & ", clave_vencida = 'NO' where id = " & tb.fields("id")
entrar = "SI"
end if
'RESPONSE.Write(tb.fields("id"))
set tb = Server.CreateObject("ADODB.Recordset")
tb.open "select * from web_usuarios where usuario = '" & request.Form("usuario") & "' and clave = '" & request.Form("clave") & "'", conn, 2, 3
if tb.eof=false then
if entrar <> "NO" then
Session("usuario") = request.Form("usuario")
Session("pasajero") = tb.fields("apellido") & ""
Session("pasajero2") = ""
if tb.fields("nombre") & "" <> "" then
Session("pasajero2") = tb.fields("nombre") & ""
Session("coma") = ", "
else
Session("pasajero2") = ""
Session("coma") = ""
end if
response.cookies("cod_cliente") = tb.fields("cod_cliente")
response.cookies("empresa") = tb.fields("empresa")
Session("categoria") = ucase(tb("categoria"))
if tb("categoria")="COORDINADOR" then Session("requiere")="N"
conn.execute "update web_usuarios set ultimologin = '" & date() & " " & time() & "', intentos = 0 where id = " & tb.fields("id")
if tb.fields("clave") & "" = "" then
response.Redirect("verifica.asp?id=" & tb.fields("id"))
else
Session("login") = "SI"
if ucase(Session("categoria"))="COORDINADOR" then
response.Redirect("vercoord.asp")
else
response.Redirect("indexbt.asp")
end if
end if
end if
else
mensaje = "Login incorrecto"
end if
end if
tb.close
set tb=nothing
conn.close
set conn=nothing
end if
%>
<%=mensaje%>