<% ' ' Filename: Login.asp ' Generated with CodeCharge 2.0.7 ' ASP 2.0 & Templates.ccp build 11/30/2001 ' '------------------------------- ' Login CustomIncludes begin %> <% ' Login CustomIncludes end '------------------------------- '=============================== ' Save Page and File Name available into variables '------------------------------- sFileName = "Login.asp" sTemplateFileName = "Login.html" '=============================== '=============================== ' Login PageSecurity begin ' Login PageSecurity end '=============================== '=============================== ' Login Open Event begin Session.Timeout=480 sHeaderFileName="" ' Login Open Event end '=============================== '=============================== 'Save the name of the form and type of action into the variables '------------------------------- sAction = GetParam("FormAction") sForm = GetParam("FormName") '=============================== ' Login Show begin '=============================== ' Perform the form's action '------------------------------- ' Initialize error variables '------------------------------- sLoginErr = "" '------------------------------- ' Select the FormAction '------------------------------- Select Case sForm Case "Login" LoginAction(sAction) end select '=============================== '=============================== ' Display page '------------------------------- ' Load HTML template for this page '------------------------------- LoadTemplate sAppPath & sTemplateFileName, "main" '------------------------------- ' Load HTML template of Header and Footer '------------------------------- LoadTemplate sHeaderFileName, "Header" '------------------------------- SetVar "FileName", sFileName '------------------------------- ' Step through each form '------------------------------- Menu_Show Login_Show '------------------------------- ' Process page templates '------------------------------- Parse "Header", False Parse "main", False '------------------------------- ' Output the page to the browser '------------------------------- Response.write PrintVar("main") ' Login Show end '------------------------------- ' Destroy all object variables '------------------------------- ' Login Close Event begin ' Login Close Event end cn.Close Set cn = Nothing UnloadTemplate '=============================== '=============================== ' Login Form Action '------------------------------- Sub LoginAction(sAction) sQueryString = GetParam("querystring") sPage = GetParam("ret_page") Select case sAction Case "login" '------------------------------- ' Login Login begin '------------------------------- sLogin = GetParam("Login") sPassword = GetParam("Password") bPassed = CLng(DLookUp("tblUsers", "count(*)", "UserName =" & ToSQL(sLogin, "Text") & " and Password=" & ToSQL(sPassword, "Text"))) '------------------------------- ' Login OnLogin Event begin Session("LoggerName") = DLookUp("tblUsers", "UserName", "UserName =" & ToSQL(sLogin, "Text")) Session("CompanyID") = DLookUP("tblUsers", "UserCompanyID", "UserName =" & ToSQL(sLogin, "Text")) tempcomp = Session("CompanyID") Session("Company") = DLookUp ("tblCompanies", "CompanyName", "CompanyID =" & tempcomp) ' Login OnLogin Event end '------------------------------- if bPassed > 0 then '------------------------------- ' Login and password passed '------------------------------- Session("UserID") = CStr(DLookUp("tblUsers", "userid", "UserName =" & ToSQL(sLogin, "Text") & " and Password=" & ToSQL(sPassword, "Text"))) Session("UserRights") = CLng(DLookUp("tblUsers", "Security", "UserName =" & ToSQL(sLogin, "Text") & " and Password=" & ToSQL(sPassword, "Text"))) cn.Close Set cn = Nothing if not(sPage = request.serverVariables("SCRIPT_NAME")) and not(isEmpty(sPage)) then response.redirect(sPage & "?" & sQueryString) end if response.redirect("Default.asp") else sLoginErr = "Login or Password is incorrect." end if '------------------------------- ' Login Login end '------------------------------- Case "logout" '------------------------------- ' Logout action '------------------------------- '------------------------------- ' Login Logout begin '------------------------------- '------------------------------- ' Login OnLogout Event begin ' Login OnLogout Event end '------------------------------- Session("UserID") = Empty Session("UserRights") = Empty cn.Close Set cn = Nothing if not isEmpty(sPage) then response.redirect(sPage & "?" & sQueryString) response.redirect(sFileName) '------------------------------- ' Login Logout end '------------------------------- End Select End Sub '=============================== '=============================== ' Display Login Form '------------------------------- Sub Login_Show() Dim sFormTitle: sFormTitle = "EPM Clients Login" '------------------------------- ' Login Show begin '------------------------------- '------------------------------- ' Login Open Event begin ' Login Open Event end '------------------------------- SetVar "FormTitle", sFormTitle SetVar "sLoginErr", sLoginErr SetVar "querystring", GetParam("querystring") SetVar "ret_page", GetParam("ret_page") '------------------------------- ' Login BeforeShow Event begin ' Login BeforeShow Event end '------------------------------- if Session("UserID") = "" then '------------------------------- ' User is not logged in '------------------------------- SetVar "LogoutAct", "" SetVar "UserInd", "" SetVar "Login", ToHTML(GetParam("Login")) if sLoginErr = "" then SetVar "LoginError", "" else SetVar "sLoginErr", sLoginErr Parse "LoginError", False End if Parse "LoginAct", false else '------------------------------- ' User logged in '------------------------------- SetVar "LoginError", "" SetVar "LoginAct", "" SetVar "UserID", DLookUp("tblUsers", "UserName", "userid =" & Session("UserID")) Parse "UserInd", False end if Parse "FormLogin", False '------------------------------- ' Login Close Event begin ' Login Close Event end '------------------------------- '------------------------------- ' Login Show end '------------------------------- End Sub '=============================== %>