% Response.expires = 0 Response.expiresabsolute = Now() - 1 Response.addHeader "pragma", "no-cache" Response.addHeader "cache-control", "private" Response.addHeader "cache-control", "no-cache" Response.addHeader "cache-control", "no-store" Response.CacheControl = "no-cache" %> <% ' User levels Const ewAllowAdd = 1 Const ewAllowDelete = 2 Const ewAllowEdit = 4 Const ewAllowView = 8 Const ewAllowList = 8 Const ewAllowSearch = 8 Const ewAllowAdmin = 16 If Request.Form("submit") <> "" Then bValidPwd = False ' Setup variables sUserId = Request.Form("userid") sPassWd = Request.Form("passwd") If ((UCase("root") = UCase(sUserId)) And (UCase("root") = UCase(sPassWd))) Then bValidPwd = True Session("enciezacontrol_SysAdmin") = 1 ' System Administrator Session("enciezacontrol_status_UserID") = -1 ' System Administrator Session("enciezacontrol_status_UserLevel") = -1 ' System Administrator End If If Not bValidPwd Then Set conn = Server.CreateObject("ADODB.Connection") conn.open xDb_Conn_Str sSql = "SELECT * FROM `empresas`" sSql = sSql & " WHERE `usuario` = '" & AdjustSql(sUserId) & "'" Set rs = conn.Execute(sSql) If Not rs.Eof Then If UCase(rs("Contrasena")) = UCase(sPassWd) Then Session("enciezacontrol_status_User") = rs("usuario") Session("enciezacontrol_SysAdmin") = 0 ' non System Administrator Session("enciezacontrol_status_UserID") = rs("idempresa") Session("enciezacontrol_status_UserLevel") = CInt(rs("nivel")) If Session("enciezacontrol_status_UserLevel") = -1 Then ' Administrator Session("enciezacontrol_status_UserID") = -1 End If Call SetUpUserLevel() bValidPwd = True End If End If rs.Close Set rs = Nothing conn.Close Set conn = Nothing End If If bValidPwd Then Call SetUpUserLevel() ' Write cookies If Request.Form("rememberme") <> "" Then Response.Cookies("enciezacontrol")("userid") = sUserId Response.Cookies("enciezacontrol").Expires = Date + 365 ' Change the expiry date of the cookies here End If Session("enciezacontrol_status") = "login" Response.Redirect "default.asp" Else Session("ewmsg") = "ID de usuario o contraseña Incorrecto" End If End If '------------------------------------------------------------------------------- ' Function SetUpUserLevel ' - Set Up User Level Security ' arrSecurity: ' ---------------------------------- ' | | "table1" | "table2" | ... ' ---------------------------------- ' | "level1" | n | n | ' ---------------------------------- ' | "level2" | n | n | ' ---------------------------------- ' ... Sub SetUpUserLevel() ' Declare Security Table - m User Levels x n Tables Dim arrSecurity(1, 9) arrSecurity(0,1) = "empresas" ' Table Name If Session("enciezacontrol_status_UserLevel") = -1 Then Session("empresas_menuitem") = True End If arrSecurity(1,0) = "Usuario" ' User Level Name arrSecurity(1,1) = 12 ' User Level Security If Session("enciezacontrol_status_UserLevel") = 1 Then Session("empresas_menuitem") = CBool(12 And ewAllowList) End If arrSecurity(0,2) = "escaparate" ' Table Name If Session("enciezacontrol_status_UserLevel") = -1 Then Session("escaparate_menuitem") = True End If arrSecurity(1,2) = 13 ' User Level Security If Session("enciezacontrol_status_UserLevel") = 1 Then Session("escaparate_menuitem") = CBool(13 And ewAllowList) End If arrSecurity(0,3) = "ofertasempleo" ' Table Name If Session("enciezacontrol_status_UserLevel") = -1 Then Session("ofertasempleo_menuitem") = True End If arrSecurity(1,3) = 0 ' User Level Security If Session("enciezacontrol_status_UserLevel") = 1 Then Session("ofertasempleo_menuitem") = CBool(0 And ewAllowList) End If arrSecurity(0,4) = "demandasempleo" ' Table Name If Session("enciezacontrol_status_UserLevel") = -1 Then Session("demandasempleo_menuitem") = True End If arrSecurity(1,4) = 0 ' User Level Security If Session("enciezacontrol_status_UserLevel") = 1 Then Session("demandasempleo_menuitem") = CBool(0 And ewAllowList) End If arrSecurity(0,5) = "presupuesto" ' Table Name If Session("enciezacontrol_status_UserLevel") = -1 Then Session("presupuesto_menuitem") = True End If arrSecurity(1,5) = 0 ' User Level Security If Session("enciezacontrol_status_UserLevel") = 1 Then Session("presupuesto_menuitem") = CBool(0 And ewAllowList) End If arrSecurity(0,6) = "tablageneral" ' Table Name If Session("enciezacontrol_status_UserLevel") = -1 Then Session("tablageneral_menuitem") = True End If arrSecurity(1,6) = 0 ' User Level Security If Session("enciezacontrol_status_UserLevel") = 1 Then Session("tablageneral_menuitem") = CBool(0 And ewAllowList) End If arrSecurity(0,7) = "favoritas" ' Table Name If Session("enciezacontrol_status_UserLevel") = -1 Then Session("favoritas_menuitem") = True End If arrSecurity(1,7) = 0 ' User Level Security If Session("enciezacontrol_status_UserLevel") = 1 Then Session("favoritas_menuitem") = CBool(0 And ewAllowList) End If arrSecurity(0,8) = "callejero" ' Table Name If Session("enciezacontrol_status_UserLevel") = -1 Then Session("callejero_menuitem") = True End If arrSecurity(1,8) = 0 ' User Level Security If Session("enciezacontrol_status_UserLevel") = 1 Then Session("callejero_menuitem") = CBool(0 And ewAllowList) End If arrSecurity(0,9) = "sector" ' Table Name If Session("enciezacontrol_status_UserLevel") = -1 Then Session("sector_menuitem") = True End If arrSecurity(1,9) = 0 ' User Level Security If Session("enciezacontrol_status_UserLevel") = 1 Then Session("sector_menuitem") = CBool(0 And ewAllowList) End If Session("ewSecurity") = arrSecurity ' Save Security Table End Sub %>
Página Conexión
<% If Session("ewmsg") <> "" Then %><%= Session("ewmsg") %>
<% Session("ewmsg") = "" ' Clear message End If %>