%@ Language=VBScript %> <%Option Explicit Response.Expires = -100 Response.CharSet= "ISO-8859-1" Response.Buffer = true %> <% ' Default: try to load cookies if error, empty then redirect to login.asp ' This asp is for ' 0: nothing ' 1: auth users ' 2: add users ' 3: update users ' 4: email password Dim isCookie Dim Mode Mode = Request.QueryString("PM") Session("ProcessMode") = 0 ' Reset the Process Mode if Mode = "" then ' try to load cookies and Auth isCookie = true AuthUser Request.Cookies("PB")("e"), Request.Cookies("PB")("password") elseif Mode = 1 then ' info from login.asp form ' Auth user isCookie = false AuthUser Request.Form("email"), Request.Form("password") elseif Mode = 2 then ' Add user AddUser elseif Mode = 3 then ' Update user This function use GUID as the key as customer may change email address UpdateUser(Session("GUID")) elseif Mode = 4 then ' Email password if isempty(Request.Form("email")) then Response.Redirect("ReqPass.htm") emailpw Request.Form("email") else Session("ProcessMode") = 0 Response.Redirect("Login.asp") end if sub AuthUser(UserEmail, UserPassword) if (UserEmail = "" or Userpassword = "") then Response.Redirect("login.asp") end if Dim oUtility ,oCustData,oCustData2 Dim oCustomers ,oResp dim title,surname,firstname set oUtility = Server.CreateObject("PBUtility.NewCollection") set oCustData = oUtility.NewCollection() oCustData.Add trim(UserEmail), "email" oCustData.Add trim(UserPassword), "password" set oCustomers = Server.CreateObject("PBCustomerSys.Customers") set oResp = oCustomers.Authen(oCustData) if Not oResp("error") then ' No error if oResp("exists") and oResp("passwordvalid") then ' User exists and correct pw set oCustData2 = oResp("custdata") FirstName = oCustData2("firstname") SurName = oCustData2("surname") Title = oCustData2("title") Session("FullName") = Title & " " & FirstName & " " & SurName Session("GUID") = oCustData2("GUID") Session("Email") = oCustData2("Email") Session("Rights") = oCustData2("Rights") Session("Password") = oCustData2("Password") if (isCookie) then Session("useCookies") = 1 else Session("useCookies") = Request.Form("useCookies") end if Session("isAuth") = true set oUtility = Nothing set oCustData = Nothing set oResp = Nothing set oCustomers = Nothing setCookies() Response.Redirect("Sec.asp") else ' User does not exists or incorrect password set oUtility = Nothing set oCustData = Nothing set oResp = Nothing set oCustomers = Nothing if isCookie then Response.Redirect("Login.asp") else Response.Redirect("multiForms.asp?Fun=6") end if end if else ' Error set oUtility = Nothing set oCustData = Nothing set oResp = Nothing set oCustomers = Nothing Response.Redirect("login.asp") end if end sub function AddUser() Dim oUtility Dim oCustData dim oCustData2 Dim oCustomers Dim oResp dim title dim surname dim firstname set oUtility = Server.CreateObject("PBUtility.NewCollection") set oCustData = oUtility.NewCollection() oCustData.Add Request.Form("myPID") ,"myPID" oCustData.Add Request.Form("Email") ,"email" oCustData.Add Request.Form("FirstName") ,"firstname" oCustData.Add Request.Form("SurName") ,"surname" oCustData.Add Request.Form("Middlename") ,"Middlename" oCustData.Add Request.Form("Title") ,"title" oCustData.Add Request.Form("Address1") ,"address1" oCustData.Add Request.Form("Address2") ,"address2" oCustData.Add Request.Form("Company") ,"CompanyName" oCustData.Add Request.Form("State") ,"state" oCustData.Add Request.Form("City") ,"city" oCustData.Add Request.Form("Country") ,"country" oCustData.Add Request.Form("PostCode") ,"postcode" oCustData.Add Request.Form("Web") ,"Web" oCustData.Add Request.Form("Phone") ,"phone" oCustData.Add Request.Form("Mobile") ,"Mobile" oCustData.Add Request.Form("Fax") ,"fax" oCustData.Add Request.Form("WhereHear") & "=" & Request.Form("WhereName") ,"Referal" oCustData.Add Request.Form("myFavourite") ,"myFavourite" 'oCustData.Add Request.Form("Remarks") ,"Remarks" ' Media & Style 'dim numitem 'dim oStyle 'dim oMedia 'set oStyle = oUtility.NewCollection() 'set oMedia = oUtility.NewCollection() 'for numitem = 1 to Request.Form("Style").Count ' oStyle.add Request.Form("Style")(numitem) 'next 'oCustData.add Request.Form("Style").Count, "StyleCount" ' 'for numitem = 1 to Request.Form("Media").Count ' oMedia.add Request.Form("Media")(numitem) 'next 'oCustData.add Request.Form("Media").Count, "MediaCount" 'oCustData.Add oStyle ,"Style" 'oCustData.Add oMedia ,"Media" set oCustomers = Server.CreateObject("PBCustomerSys.Customers") set oResp = oCustomers.RegisterCustomer(oCustData) if Not oResp("error") then ' No error if oResp("exists") then ' User exists Session("isAuth") = false set oUtility = Nothing set oCustData = Nothing set oResp = Nothing set oCustomers = Nothing 'set ostyle = nothing 'set omedia = nothing Response.Redirect("MultiForms.asp?Fun=5") else ' Success set oCustData2 = nothing set oUtility = Nothing set oCustData = Nothing set oResp = Nothing 'set ostyle = nothing 'set omedia = nothing Response.Redirect("MultiForms.asp?Fun=1") end if else ' Error set oUtility = Nothing set oCustData = Nothing set oResp = Nothing set oCustomers = Nothing 'set ostyle = nothing 'set omedia = nothing Response.Redirect("login.asp") end if end function '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' function UpdateUser(GUID) ' Need GUID Dim oUtility Dim oCustData dim oCustData2 Dim oCustomers Dim oResp dim firstname dim surname dim title set oUtility = Server.CreateObject("PBUtility.NewCollection") set oCustData = oUtility.NewCollection() oCustData.Add Request.Form("Email") ,"email" oCustData.Add Request.Form("FirstName") ,"firstname" oCustData.Add Request.Form("SurName") ,"surname" oCustData.Add Request.Form("Middlename") ,"Middlename" oCustData.Add Request.Form("Title") ,"title" oCustData.Add Request.Form("Address1") ,"address1" oCustData.Add Request.Form("Address2") ,"address2" oCustData.Add Request.Form("Company") ,"CompanyName" oCustData.Add Request.Form("Web") ,"Web" oCustData.Add Request.Form("State") ,"state" oCustData.Add Request.Form("Country") ,"country" oCustData.Add Request.Form("City") ,"city" oCustData.Add Request.Form("PostCode") ,"postcode" oCustData.Add Request.Form("Phone") ,"phone" oCustData.Add Request.Form("Mobile") ,"Mobile" oCustData.Add Request.Form("Fax") ,"fax" oCustData.Add Request.Form("WhereHear") & "=" & Request.Form("WhereName"),"Referal" oCustData.Add Request.Form("myFavourite") ,"myFavourite" oCustData.Add Request.Form("myPID") ,"myPID" oCustData.Add GUID , "GUID" ' Use GUID as the key for modify users ' Media & Style 'dim numitem 'dim ostyle 'dim omedia 'set ostyle = oUtility.NewCollection() 'set omedia = oUtility.NewCollection() 'for numitem = 1 to Request.Form("Style").Count ' oStyle.add Request.Form("Style")(numitem) 'next 'oCustData.add Request.Form("Style").Count, "StyleCount" ' 'for numitem = 1 to Request.Form("Media").Count ' oMedia.add Request.Form("Media")(numitem) 'next 'oCustData.add Request.Form("Media").Count, "MediaCount" 'oCustData.Add oStyle ,"Style" 'oCustData.Add oMedia ,"Media" set oCustomers = Server.CreateObject("PBCustomerSys.Customers") set oResp = oCustomers.UpdateCustomer(oCustData) if Not oResp("error") then ' No error if oResp("exists") then ' Email exists set oCustData2 = Nothing set oUtility = Nothing set oCustData = Nothing set oResp = Nothing set oCustomers = Nothing 'set oStyle = nothing 'set oMedia = nothing response.redirect("MultiForms.asp?Fun=5") end if set oCustData2 = oResp("custdata") firstname = oCustData2.item("firstname") SurName = oCustData2("surname") Title = oCustData2("title") Session("FullName") = Title & " " & FirstName & " " & SurName Session("GUID") = oCustData2("GUID") Session("Email") = oCustData2("Email") Session("Rights") = oCustData2("Rights") Session("isAuth") = true setCookies() set oCustData2 = Nothing set oUtility = Nothing set oCustData = Nothing set oResp = Nothing set oCustomers = Nothing 'set oStyle = nothing 'set oMedia = nothing Response.Redirect("UpdatedNotice.asp") else ' Error set oUtility = Nothing set oCustData = Nothing set oResp = Nothing set oCustomers = Nothing 'set oStyle = nothing 'set oMedia = nothing Response.Redirect("register.asp") end if end function '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' function emailpw(UserEmail) Dim oUtility Dim oCustData Dim oCustomers Dim oResp set oUtility = Server.CreateObject("PBUtility.NewCollection") set oCustData = oUtility.NewCollection() oCustData.Add trim(UserEmail), "email" set oCustomers = Server.CreateObject("PBCustomerSys.Customers") oResp = oCustomers.SendPassword(oCustData) if oResp then ' Success set oUtility = Nothing set oCustData = Nothing set oResp = Nothing set oCustomers = Nothing Response.Redirect("PassSent.htm") else ' Error set oUtility = Nothing set oCustData = Nothing set oResp = Nothing set oCustomers = Nothing Response.Redirect("MultiForms.asp?Fun=6") end if end function %>