#INCLUDE WCONNECT.H
DEFINE CLASS Login AS rbPage
FUNCTION PAGE
STORE .NULL. TO This.oData
This.oData = THIS.DataObject("Member","MemberID",[-1])
THIS.Content = THIS.MergeToString("LoginFragment.htm")
THIS.PageTitle = "Login"
THIS.Merge("TemplatePage.htm")
ENDFUNC
PROCEDURE Submit()
This.oData = THIS.ReadForm("Member","MemberID")
IF UPPER(REQUEST.FORM("btnSubmit")) == UPPER([EMail My Password to Me])
THIS.MailPassword
ELSE
THIS.Login
ENDIF
ENDPROC
HIDDEN FUNCTION Login
LOCAL lcUserLevel, lcMemberID
STORE [] TO lcUserLevel, lcMemberID
lcUserLevel = THIS.GetUserLevel(This.oData.eMail, This.oData.PASSWORD, @lcMemberID)
IF (lcUserLevel == "NOT FOUND") OR (lcUserLevel == "BAD PASSWORD")
THIS.AddError(lcUserLevel + "<br>"+ ;
[Try "Email My Password" BUTTON<br>]+;
[OR CLICK ON "Email to WebMaster" LINK below])
THIS.Content = THIS.MergeToString("LoginFragment.htm")
THIS.PageTitle = "Login Again"
THIS.Merge("TemplatePage.htm")
ELSE
SessionVars.Globals.SET("UserType", lcUserLevel)
SessionVars.Globals.SET("MemberID", lcMemberID)
THIS.Redirect("LoggedIn.Page")
ENDIF
ENDFUNC
HIDDEN FUNCTION MailPassword
LOCAL lcPassword, lcMessage
STORE [] TO lcPassword, lcMessage
IF THIS.GetPasswordFromEmail(This.oData.eMail, @lcPassword)
lcMessage = [Your Password is ] + lcPassword + CRLF+;
[You can CHANGE PASSWORD BY choosing "Edit My Profile" AFTER You are logged IN.]
SERVER.SendMail("mail.bricksoftware.com",;
Site.SiteName + [ Automated Response], ;
"WebMaster@"+Site.SiteName+[.org] ,;
This.oData.eMail, ;
[], ;
Site.SiteName+ [ Password] , ;
lcMessage)
THIS.WaitWindow("Password Mailed to You!<br>"+ ;
[You can CHANGE PASSWORD BY choosing "Edit My Password" AFTER You are logged IN.],;
"/Home.Page.fox?SessionID=_71Y1DVSEW")
ELSE
THIS.AddError("Sorry!<br>Email not found<br>Please try again<br>or contact WebMaster")
THIS.Content = THIS.MergeToString("LoginFragment.htm")
THIS.PageTitle = "Login"
THIS.Merge("TemplatePage.htm")
ENDIF
ENDFUNC
HIDDEN FUNCTION GetUserLevel(tcEmail, tcPassword, tcMemberID) AS STRING
THIS.OpenAndSelect("Member")
tcEmail = UPPER(PADR(tcEmail,LEN(Member.eMail)))
tcPassword = UPPER(PADR(tcPassword,LEN(Member.PASSWORD)))
LOCATE FOR UPPER(eMail) = tcEmail
IF FOUND()
tcMemberID = MemberID
ENDIF
DO CASE
CASE UPPER(eMail) = tcEmail AND (NOT (UPPER(PASSWORD) = tcPassword))
RETURN "BAD PASSWORD"
CASE FOUND() AND EMPTY(MemberType)
RETURN "USER"
CASE FOUND() AND NOT EMPTY(MemberType)
RETURN UPPER(ALLTRIM(MemberType))
OTHERWISE
RETURN "NOT FOUND"
ENDCASE
ENDFUNC
HIDDEN FUNCTION GetPasswordFromEmail(tcEmail, tcPassword)
THIS.OpenAndSelect("Member")
tcEmail = UPPER(PADR(tcEmail,LEN(Member.eMail)))
LOCATE FOR UPPER(eMail) = tcEmail
IF FOUND() AND NOT EMPTY(tcEmail)
tcPassword = PASSWORD
RETURN .T.
ELSE
RETURN .F.
ENDIF
ENDFUNC
ENDDEFINE
csCodeParser v0.9 stats: 176 lines in 0.01 seconds.