Web Connect How To : Show Me the Code!

 LAFOX Home How URL Maps to Code  LAFOX Design Oveview  Framework Extensions 
*Speakerlogin.prg #INCLUDE WCONNECT.H ************************************************************* DEFINE CLASS SpeakerLogin AS rbPage ************************************************************* ********************************************************************** ** Page() - PUBLIC - ** show a blank login page for user input ********************************************************************** PROCEDURE Page ** IF the speaker was already logged in ** then take him to the logged in page IF This.AlreadyLoggedIn() This.Redirect('SpeakerLoggedIn.Page') ELSE This.ShowLoginPage() ENDIF ENDPROC &&Page HIDDEN Function AlreadyLoggedIn Return NOT EMPTY(SessionVars.Globals.Get("SpeakerID", [])) ENDFUNC HIDDEN FUNCTION ShowLoginPage() ** Blank Data Object This.oData = This.DataObject() && Blank Data Object from a dummy table ** LoginFragment - with standard menu This.Content = This.MergeToString("SpeakerLoginFragment.htm") ** Merge the page and send back to user This.PageTitle = "Speaker Login" This.Merge("TemplatePage.htm") ENDFUNC FUNCTION DataObject(P1,P2,P3) ** dummy data object - blank SELECT SPACE(30) as FirstName, SPACE(30) as LastName, SPACE(10) As SpeakerID, SPACE(100) as email, SPACE(20) as password FROM (Site.MemberPath+"Member.dbf") INTO CURSOR qResult SCATTER NAME loData USE IN (SELECT("qResult")) RETURN loData ENDFUNC ********************************************************************** ** Submit() - PUBLIC - ** Speaker submits login page ********************************************************************** Procedure Submit() ** Read the form This.oData = This.ReadForm("speaker","speakerid") IF UPPER(Request.Form("btnSubmit")) == UPPER([EMail My Password to Me]) This.MailPassword() ELSE This.Login() ENDIF ENDPROC && Submit ************************************************************* ** Helper Functions Below ************************************************************* ********************************************************** ** Login() ********************************************************** HIDDEN Function Login LOCAL lcPassword STORE [] TO lcPassword IF NOT This.ValidatePassword(This.oData.Email, This.oData.Password, This.oData) ** Show Login.Page with error message This.AddError([Your name or password not found ] + "<br>"+ ; [Try "Email My Password" button<br>]+; [Or Click on "Email to WebMaster" link below]) This.Content = This.MergeToString("SpeakerLoginFragment.htm") This.Merge("TemplatePage.htm") ELSE SessionVars.Globals.Set("SpeakerID", This.oData.SpeakerID) SessionVars.Globals.Set("SpeakerFirstName", This.oData.FirstName) SessionVars.Globals.Set("SpeakerLastName", This.oData.LastName) This.Redirect("SpeakerLoggedIn.Page") ENDIF ENDFUNC && Login ********************************************************** ** MailPassword() ********************************************************** HIDDEN Function MailPassword LOCAL lcPassword, lcMessage STORE [] TO lcUserLevel, lcPassword, lcMessage IF This.GetPassword(This.oData.Email, @lcPassword) ** Email password to user lcMessage = [Your Password is ]+lcPassword; Server.SendMail("mail.bricksoftware.com",; Site.SiteName + [ Automated Response], ; "Website@"+Site.SiteName+[.org] ,; This.oData.Email, ; [], ; Site.SiteName+ [ Speakers Password] , ; lcMessage) ** Web Page - let them know we sent it This.WaitWindow("Password Mailed to You!", "/Home.Page.fox?SessionID=_71Y1DVSEW") ELSE ** Show Login.Page again with error message This.PageTitle = "Login" This.AddError("Sorry!<br>Email not found<br>Please try again<br>or contact WebMaster") This.Content = This.MergeToString("LoginFragment.htm") This.Merge("TemplatePage.htm") ENDIF ENDFUNC && Login ** Returns .T. if email and password matches a speaker HIDDEN FUNCTION ValidatePassword(tcEmail, tcPassword, toData) This.Openandselect("Speaker") ** look in beginner speaker and maintopic speaker emails tcEmail = UPPER(PADR(tcEmail,LEN(Speaker.Email))) tcPassword = UPPER(PADR(tcPassword,LEN(Speaker.Password))) DO CASE CASE SEEK(tcEmail,"Speaker","email") AND (tcPassword == Password) toData.SpeakerID = SpeakerID toData.LastName = LastName toData.FirstName = FirstName RETURN .T. OTHERWISE RETURN .F. ENDCASE ENDFUNC ** Returns .T. if email matches a speaker HIDDEN FUNCTION GetPassword(tcEmail, tcPassword) This.Openandselect("Speaker") ** look in beginner speaker and maintopic speaker emails tcEmail = UPPER(PADR(tcEmail,LEN("Speaker.Email"))) DO CASE CASE SEEK(tcEmail,"Speaker","EMail") tcPassword = Password RETURN .T. OTHERWISE RETURN .F. ENDCASE ENDFUNC ENDDEFINE &&
csCodeParser v0.9 stats: 155 lines in 0.01 seconds.