/????/??????/login.asp
ASP | 482 lines | 330 code | 64 blank | 88 comment | 5 complexity | d6944e64e7e37d4c7346c4df8d321584 MD5 | raw file
- <%@ CodePage="936" LCID="2052" %>
- <%
- Response.Buffer = EW_RESPONSE_BUFFER
- %>
- <!--#include file="ewcfg8.asp"-->
- <!--#include file="adminsinfo.asp"-->
- <!--#include file="aspfn8.asp"-->
- <!--#include file="md5.asp"-->
- <!--#include file="userfn8.asp"-->
- <% Session.Timeout = 20 %>
- <%
- Response.Expires = 0
- Response.ExpiresAbsolute = Now() - 1
- Response.AddHeader "pragma", "no-cache"
- Response.AddHeader "cache-control", "private, no-cache, no-store, must-revalidate"
- %>
- <%
- ' Define page object
- Dim login
- Set login = New clogin
- Set Page = login
- ' Page init processing
- Call login.Page_Init()
- ' Page main processing
- Call login.Page_Main()
- %>
- <!--#include file="header_0.asp"-->
- <script language="JavaScript" type="text/javascript">
- <!--
- // Write your client script here, no need to add script tags.
- // To include another .js script, use:
- // ew_ClientScriptInclude("my_javascript.js");
- //-->
- </script>
- <script type="text/javascript">
- <!--
- var login = new ew_Page("login");
- // extend page with ValidateForm function
- login.ValidateForm = function(fobj)
- {
- if (!this.ValidateRequired)
- return true; // ignore validation
- if (!ew_HasValue(fobj.username))
- return ew_OnError(this, fobj.username, ewLanguage.Phrase("EnterUid"));
- if (!ew_HasValue(fobj.password))
- return ew_OnError(this, fobj.password, ewLanguage.Phrase("EnterPwd"));
- // Call Form Custom Validate event
- if (!this.Form_CustomValidate(fobj)) return false;
- return true;
- }
- // extend page with Form_CustomValidate function
- login.Form_CustomValidate =
- function(fobj) { // DO NOT CHANGE THIS LINE!
- // Your custom validation code here, return false if invalid.
- return true;
- }
- // requires js validation
- <% If EW_CLIENT_VALIDATE Then %>
- login.ValidateRequired = true;
- <% Else %>
- login.ValidateRequired = false;
- <% End If %>
- //-->
- </script>
- <p class="aspmaker"><b><%= Language.ProjectPhrase("BodyTitle") %></b></p>
- <% If EW_DEBUG_ENABLED Then Response.Write login.DebugMsg %>
- <% login.ShowMessage %>
- <form action="<%= ew_CurrentPage %>" method="post" onsubmit="return login.ValidateForm(this);">
- <br/><br/><br/>
- <table border="0" cellspacing="0" width="649px" height="430px" align="center" cellpadding="0" style="background-image:url(images/areabg2.jpg);background-repeat:no-Repeat;">
- <tr style="height:130px;">
- <td> </td>
- <td> </td>
- </tr>
- <tr style="height:30px;">
- <td style="padding:20px 0px 0px 50px;color:#ffffff;" align="right"><span class="aspmaker"><%= Language.Phrase("UserName") %> : </span></td>
- <td style="padding:20px 0px 0px 0px;"><span class="aspmaker"><input type="text" name="username" id="username" size="20" value="<%= login.sUsername %>"></span></td>
- </tr>
- <tr style="height:30px;">
- <td style="padding:20px 0px 0px 50px;color:#ffffff;" align="right"><span class="aspmaker"><%= Language.Phrase("Password") %> : </span></td>
- <td style="padding:20px 0px 0px 0px;"><span class="aspmaker"><input type="password" name="password" id="password" size="20"></span></td>
- </tr>
- <tr style="height:60px;color:#ffffff;">
- <td> </td>
- <td><span class="aspmaker">
- <input type="radio" name="rememberme" id="rememberme" value="u"<% If login.sLoginType = "u" Then %> checked="checked"<% End If %>><%= Language.Phrase("SaveUserName") %><br>
- <input type="radio" name="rememberme" id="rememberme" value=""<% If login.sLoginType = "" Then %> checked="checked"<% End If %>><%= Language.Phrase("AlwaysAsk") %><br>
- </span></td>
- </tr>
- <tr style="height:50px;">
- <td colspan="2" align="center"><span class="aspmaker"><input type="submit" name="submit" id="submit" value="<%= ew_BtnCaption(Language.Phrase("Login")) %>"></span><span class="aspmaker">
- <a href="register.asp" style="color:white;"><%= Language.Phrase("Register") %></a>
- </span></td>
- </tr>
- <tr>
- <td> </td>
- <td> </td>
- </tr>
- </table>
- </form>
- <br>
- <p><span class="aspmaker">
- </span></p>
- <script language="JavaScript" type="text/javascript">
- <!--
- // Write your startup script here
- // document.write("page loaded");
- //-->
- </script>
- <!--#include file="footer_0.asp"-->
- <%
- ' Drop page object
- Set login = Nothing
- %>
- <%
- ' -----------------------------------------------------------------
- ' Page Class
- '
- Class clogin
- ' Page ID
- Public Property Get PageID()
- PageID = "login"
- End Property
- ' Page Object Name
- Public Property Get PageObjName()
- PageObjName = "login"
- End Property
- ' Page Name
- Public Property Get PageName()
- PageName = ew_CurrentPage()
- End Property
- ' Page Url
- Public Property Get PageUrl()
- PageUrl = ew_CurrentPage() & "?"
- End Property
- ' Common urls
- Dim AddUrl
- Dim EditUrl
- Dim CopyUrl
- Dim DeleteUrl
- Dim ViewUrl
- Dim ListUrl
- ' Export urls
- Dim ExportPrintUrl
- Dim ExportHtmlUrl
- Dim ExportExcelUrl
- Dim ExportWordUrl
- Dim ExportXmlUrl
- Dim ExportCsvUrl
- ' Inline urls
- Dim InlineAddUrl
- Dim InlineCopyUrl
- Dim InlineEditUrl
- Dim GridAddUrl
- Dim GridEditUrl
- Dim MultiDeleteUrl
- Dim MultiUpdateUrl
- ' Debug Message
- Dim m_DebugMsg
- Public Property Get DebugMsg()
- If m_DebugMsg <> "" Then
- DebugMsg = "<p>" & m_DebugMsg & "</p>"
- Else
- DebugMsg = ""
- End If
- End Property
- Public Property Let DebugMsg(v)
- If m_DebugMsg <> "" Then ' Append
- m_DebugMsg = m_DebugMsg & "<br>" & v
- Else
- m_DebugMsg = v
- End If
- End Property
- ' Message
- Public Property Get Message()
- Message = Session(EW_SESSION_MESSAGE)
- End Property
- Public Property Let Message(v)
- If Session(EW_SESSION_MESSAGE) <> "" Then ' Append
- Session(EW_SESSION_MESSAGE) = Session(EW_SESSION_MESSAGE) & "<br>" & v
- Else
- Session(EW_SESSION_MESSAGE) = v
- End If
- End Property
- ' Show Message
- Public Sub ShowMessage()
- Dim sMessage
- sMessage = Message
- Call Message_Showing(sMessage)
- If sMessage <> "" Then Response.Write "<p><span class=""ewMessage"">" & sMessage & "</span></p>"
- Session(EW_SESSION_MESSAGE) = "" ' Clear message in Session
- End Sub
- ' -----------------------
- ' Validate Page request
- '
- Public Function IsPageRequest()
- IsPageRequest = True
- End Function
- ' -----------------------------------------------------------------
- ' Class initialize
- ' - init objects
- ' - open ADO connection
- '
- Private Sub Class_Initialize()
- StartTimer = Timer ' Init start time
- ' Initialize language object
- Set Language = New cLanguage
- ' Initialize table object
- Set admins = New cadmins
- ' Initialize form object
- Set ObjForm = Nothing
- ' Intialize page id (for backward compatibility)
- EW_PAGE_ID = "login"
- ' Open connection to the database
- Call ew_Connect()
- End Sub
- ' -----------------------------------------------------------------
- ' Subroutine Page_Init
- ' - called before page main
- ' - check Security
- ' - set up response header
- ' - call page load events
- '
- Sub Page_Init()
- Set Security = New cAdvancedSecurity
- ' Global page loading event (in userfn7.asp)
- Call Page_Loading()
- ' Page load event, used in current page
- Call Page_Load()
- End Sub
- ' -----------------------------------------------------------------
- ' Class terminate
- ' - clean up page object
- '
- Private Sub Class_Terminate()
- Call Page_Terminate("")
- End Sub
- ' -----------------------------------------------------------------
- ' Subroutine Page_Terminate
- ' - called when exit page
- ' - clean up ADO connection and objects
- ' - if url specified, redirect to url
- '
- Sub Page_Terminate(url)
- ' Page unload event, used in current page
- Call Page_Unload()
- ' Global page unloaded event (in userfn60.asp)
- Call Page_Unloaded()
- If Not (Conn Is Nothing) Then Conn.Close ' Close Connection
- Set Conn = Nothing
- Set Security = Nothing
- Set ObjForm = Nothing
- ' Go to url if specified
- Dim sRedirectUrl
- sReDirectUrl = url
- Call Page_Redirecting(sReDirectUrl)
- If sReDirectUrl <> "" Then
- If Response.Buffer Then Response.Clear
- Response.Redirect sReDirectUrl
- End If
- End Sub
- '
- ' Subroutine Page_Terminate (End)
- ' ----------------------------------------
- Dim sUsername
- Dim sLoginType
- ' -----------------------------------------------------------------
- ' Page main processing
- '
- Sub Page_Main()
- Dim bValidate, bValidPwd
- Dim sPassword
- Dim sLastUrl
- sLastUrl = Security.LastUrl ' Get Last Url
- If sLastUrl = "" Then sLastUrl = "default.asp"
- If IsLoggingIn() Then
- sUsername = Session(EW_SESSION_USER_PROFILE_USER_NAME)
- sPassword = Session(EW_SESSION_USER_PROFILE_PASSWORD)
- sLoginType = Session(EW_SESSION_USER_PROFILE_LOGIN_TYPE)
- bValidPwd = Security.ValidateUser(sUsername, sPassword, False)
- If bValidPwd Then
- Session(EW_SESSION_USER_PROFILE_USER_NAME) = ""
- Session(EW_SESSION_USER_PROFILE_PASSWORD) = ""
- Session(EW_SESSION_USER_PROFILE_LOGIN_TYPE) = ""
- End If
- Else
- If Not Security.IsLoggedIn() Then Call Security.AutoLogin()
- Call Security.LoadUserLevel() ' Load user level
- If Request.Form <> "" Then
- ' Setup variables
- sUsername = Request.Form("Username")
- sPassword = Request.Form("Password")
- sLoginType = LCase(Request.Form("rememberme"))
- bValidate = ValidateForm(sUsername, sPassword)
- If Not bValidate Then
- Message = gsFormError
- End If
- Session(EW_SESSION_USER_PROFILE_USER_NAME) = sUsername ' Save login user name
- Session(EW_SESSION_USER_PROFILE_LOGIN_TYPE) = sLoginType ' Save login type
- Else
- If Security.IsLoggedIn() Then
- If Message = "" Then Page_Terminate(sLastUrl) ' Return to last accessed page
- End If
- bValidate = False
- ' Restore settings
- sUsername = Request.Cookies(EW_PROJECT_NAME)("username")
- If Request.Cookies(EW_PROJECT_NAME)("autologin") = "autologin" Then
- sLoginType = "a"
- ElseIf Request.Cookies(EW_PROJECT_NAME)("autologin") = "rememberUsername" Then
- sLoginType = "u"
- Else
- sLoginType = ""
- End If
- End If
- bValidPwd = False
- If bValidate Then
- ' Call logging in event
- bValidate = User_LoggingIn(sUsername, sPassword)
- If bValidate Then
- bValidPwd = Security.ValidateUser(sUsername, sPassword, False) ' Manual login
- If Not bValidPwd Then
- If Message = "" Then Message = Language.Phrase("InvalidUidPwd") ' Invalid user id/password
- End If
- Else
- If Message = "" Then Message = Language.Phrase("LoginCancelled") ' Login cancelled
- End If
- End If
- End If
- If bValidPwd Then
- ' Write cookies
- If sLoginType = "a" Then ' Auto login
- Response.Cookies(EW_PROJECT_NAME)("autologin") = "autologin" ' Set up autologin cookies
- Response.Cookies(EW_PROJECT_NAME)("username") = sUsername ' Set up user name cookies
- Response.Cookies(EW_PROJECT_NAME)("password") = ew_Encode(TEAencrypt(sPassword, EW_RANDOM_KEY)) ' Set up password cookies
- ElseIf sLoginType = "u" Then ' Remember user name
- Response.Cookies(EW_PROJECT_NAME)("autologin") = "rememberUsername" ' Set up remember user name cookies
- Response.Cookies(EW_PROJECT_NAME)("username") = sUsername ' Set up user name cookies
- Else
- Response.Cookies(EW_PROJECT_NAME)("autologin") = "" ' Clear autologin cookies
- End If
- Response.Cookies(EW_PROJECT_NAME).Expires = DateAdd("d", EW_COOKIE_EXPIRY_TIME, Date)
- ' Call loggedin event
- Call User_LoggedIn(sUsername)
- Call ew_WriteAuditTrailOnLogInOut(sUsername, Language.Phrase("AuditTrailLogin"))
- Call Page_Terminate(sLastUrl) ' Return to last accessed url
- ElseIf sUsername <> "" And sPassword <> "" Then
- ' Call user login error event
- Call User_LoginError(sUsername, sPassword)
- End If
- End Sub
- ' -----------------------------------------------------------------
- ' Validate form
- '
- Function ValidateForm(usr, pwd)
- ' Initialize
- gsFormError = ""
- ' Check if validation required
- If Not EW_SERVER_VALIDATE Then
- ValidateForm = True
- Exit Function
- End If
- If usr = "" Then
- If gsFormError <> "" Then gsFormError = gsFormError & "<br>"
- gsFormError = gsFormError & Language.Phrase("EnterUid")
- End If
- If pwd = "" Then
- If gsFormError <> "" Then gsFormError = gsFormError & "<br>"
- gsFormError = gsFormError & Language.Phrase("EnterPwd")
- End If
- ' Return validate result
- ValidateForm = (gsFormError = "")
- ' Call Form Custom Validate event
- Dim sFormCustomError
- sFormCustomError = ""
- ValidateForm = ValidateForm And Form_CustomValidate(sFormCustomError)
- If sFormCustomError <> "" Then
- If gsFormError <> "" Then gsFormError = gsFormError & "<br>"
- gsFormError = gsFormError & sFormCustomError
- End If
- End Function
- ' Page Load event
- Sub Page_Load()
- 'Response.Write "Page Load"
- End Sub
- ' Page Unload event
- Sub Page_Unload()
- 'Response.Write "Page Unload"
- End Sub
- ' Page Redirecting event
- Sub Page_Redirecting(url)
- 'url = newurl
- End Sub
- ' Message Showing event
- Sub Message_Showing(msg)
- 'msg = newmsg
- End Sub
- ' User Logging In event
- Function User_LoggingIn(usr, pwd)
- If Not EW_DEBUG_ENABLED Then On Error Resume Next
- ' Enter your code here
- ' To cancel, set return value to False
- User_LoggingIn = True
- End Function
- ' User Logged In event
- Sub User_LoggedIn(usr)
- ' Response.Write "User Logged In"
- End Sub
- ' User Login Error event
- Sub User_LoginError(usr, pwd)
- ' Response.Write "User Login Error"
- End Sub
- ' Form Custom Validate event
- Function Form_CustomValidate(CustomError)
- 'Return error message in CustomError
- Form_CustomValidate = True
- End Function
- End Class
- %>