예제 #1
0
        private void ProcessSignup()
        {
            if (Page.IsValid)
            {
                int AffiliateID = int.Parse(CommonLogic.IIF(CommonLogic.IsInteger(Profile.LATAffiliateID), Profile.LATAffiliateID, "0"));

                String ErrorMsg   = String.Empty;
                String EMailField = EMail.Text.ToLowerInvariant().Trim();
                bool   Editing    = false;
                if (Affiliate.EmailInUse(EMailField))
                {
                    ErrorMsg = "That email address has already been registered.  Please use another email.";
                }

                if (!Regex.IsMatch(EMailField, @"^[a-zA-Z0-9][-\+\w\.]*@([a-zA-Z0-9][\w\-]*\.)+[a-zA-Z]{2,4}$", RegexOptions.Compiled))
                {
                    ErrorMsg = "Invalid email format, please check and try again.";
                }

                if (ErrorMsg.Length == 0)
                {
                    try
                    {
                        StringBuilder sql  = new StringBuilder(2500);
                        String        Name = CommonLogic.FormCanBeDangerousContent("Name");
                        if (Name.Length == 0)
                        {
                            if (FirstName.Text.Length != 0)
                            {
                                Name = (FirstName.Text + " " + LastName.Text).Trim();
                            }
                            else
                            {
                                Name = LastName.Text;
                            }
                        }
                        if (!Editing)
                        {
                            // ok to add them:

                            Password p   = new Password(AffPassword.Text);
                            object   dob = null;
                            if (Localization.ParseNativeDateTime(DateOfBirth.Text) != DateTime.MinValue)
                            {
                                dob = Localization.ParseNativeDateTime(DateOfBirth.Text);
                            }

                            // ok to add them:
                            Affiliate a = Affiliate.CreateAffiliate(CommonLogic.Left(EMailField, 100), p.SaltedPassword, dob, null, "", false, CommonLogic.Left(FirstName.Text, 50), CommonLogic.Left(LastName.Text, 50), CommonLogic.Left(Name, 100), CommonLogic.Left(Company.Text, 50), Address1.Text.Replace("\x0D\x0A", ""), Address2.Text.Replace("\x0D\x0A", ""), Suite.Text, City.Text, State.Text, Zip.Text, Country.Text, Phone.Text, WebSiteName.Text, WebSiteDescription.Text, CommonLogic.Left(URL.Text, 80), (CommonLogic.FormCanBeDangerousContent("TrackingOnly") == "1"), 1, 0, 1, null, null, null, null, null, null, null, false, p.Salt);
                            AffiliateID = a.AffiliateID;
                            if (a != null)
                            {
                                Editing             = true;
                                lblErrorMsg.Visible = false;
                            }
                            else
                            {
                                Editing             = false;
                                lblErrorMsg.Text    = "Unable to create affiliate.";
                                lblErrorMsg.Visible = true;
                            }
                        }
                        else
                        {
                            // ok to update:
                            sql.Append("update Affiliate set ");
                            sql.Append("EMail=" + CommonLogic.SQuote(CommonLogic.Left(EMailField, 100)) + ",");
                            if (AffPassword.Text.Trim().Length != 0)
                            {
                                Password p = new Password(AffPassword.Text);
                                sql.Append("Password="******",");
                                sql.Append("SaltKey=" + p.Salt.ToString() + ",");
                            }
                            sql.Append("IsOnline=" + CommonLogic.IIF(URL.Text.Length == 0, "0", "1") + ",");
                            sql.Append("FirstName=" + CommonLogic.SQuote(CommonLogic.Left(FirstName.Text, 50)) + ",");
                            sql.Append("LastName=" + CommonLogic.SQuote(CommonLogic.Left(LastName.Text, 50)) + ",");
                            sql.Append("Name=" + CommonLogic.SQuote(CommonLogic.Left(Name, 100)) + ",");
                            if (DateOfBirth.Text.Length != 0)
                            {
                                sql.Append("DateOfBirth=" + CommonLogic.SQuote(DateOfBirth.Text) + ",");
                            }
                            if (Company.Text.Length != 0)
                            {
                                sql.Append("Company=" + CommonLogic.SQuote(Company.Text) + ",");
                            }
                            else
                            {
                                sql.Append("Company=NULL,");
                            }
                            if (Address1.Text.Length != 0)
                            {
                                sql.Append("Address1=" + CommonLogic.SQuote(Address1.Text.Replace("\x0D\x0A", "")) + ",");
                            }
                            else
                            {
                                sql.Append("Address1=NULL,");
                            }
                            if (Address2.Text.Length != 0)
                            {
                                sql.Append("Address2=" + CommonLogic.SQuote(Address2.Text.Replace("\x0D\x0A", "")) + ",");
                            }
                            else
                            {
                                sql.Append("Address2=NULL,");
                            }
                            if (Suite.Text.Length != 0)
                            {
                                sql.Append("Suite=" + CommonLogic.SQuote(Suite.Text) + ",");
                            }
                            else
                            {
                                sql.Append("Suite=NULL,");
                            }
                            if (City.Text.Length != 0)
                            {
                                sql.Append("City=" + CommonLogic.SQuote(City.Text) + ",");
                            }
                            else
                            {
                                sql.Append("City=NULL,");
                            }
                            if (State.SelectedValue.Length != 0)
                            {
                                sql.Append("State=" + CommonLogic.SQuote(State.SelectedValue) + ",");
                            }
                            else
                            {
                                sql.Append("State=NULL,");
                            }
                            if (Zip.Text.Length != 0)
                            {
                                sql.Append("Zip=" + CommonLogic.SQuote(Zip.Text) + ",");
                            }
                            else
                            {
                                sql.Append("Zip=NULL,");
                            }
                            if (Country.SelectedValue.Length != 0)
                            {
                                sql.Append("Country=" + CommonLogic.SQuote(Country.SelectedValue) + ",");
                            }
                            else
                            {
                                sql.Append("Country=NULL,");
                            }
                            if (Phone.Text.Length != 0)
                            {
                                sql.Append("Phone=" + CommonLogic.SQuote(AppLogic.MakeProperPhoneFormat(Phone.Text)) + ",");
                            }
                            else
                            {
                                sql.Append("Phone=NULL,");
                            }
                            if (WebSiteName.Text.Length != 0)
                            {
                                sql.Append("WebSiteName=" + CommonLogic.SQuote(WebSiteName.Text) + ",");
                            }
                            else
                            {
                                sql.Append("WebSiteName=NULL,");
                            }
                            if (WebSiteDescription.Text.Length != 0)
                            {
                                sql.Append("WebSiteDescription=" + CommonLogic.SQuote(WebSiteDescription.Text) + ",");
                            }
                            else
                            {
                                sql.Append("WebSiteDescription=NULL,");
                            }
                            if (URL.Text.Length != 0)
                            {
                                String theUrl2 = CommonLogic.Left(URL.Text, 80);
                                if (theUrl2.IndexOf("http://") == -1 && theUrl2.Length != 0)
                                {
                                    theUrl2 = "http://" + theUrl2;
                                }
                                if (theUrl2.Length != 0)
                                {
                                    sql.Append("URL=" + CommonLogic.SQuote(theUrl2));
                                }
                                else
                                {
                                    sql.Append("URL=NULL");
                                }
                            }
                            else
                            {
                                sql.Append("URL=NULL");
                            }
                            sql.Append(" where AffiliateID=" + AffiliateID.ToString());
                            DB.ExecuteSQL(sql.ToString());
                            Editing = true;
                        }
                    }
                    catch
                    {
                        lblErrorMsg.Text = "<p><b>ERROR: There was an unknown error in adding your new account record. Please <a href=\"contactus.aspx\">contact a service representative</a> for assistance.<br/><br/></b></p>";
                    }
                }

                Profile.LATAffiliateID = AffiliateID.ToString();
                lblErrorMsg.Text       = ErrorMsg;

                if (lblErrorMsg.Text.Length == 0)
                {
                    pnlSignedInMsg.Visible  = false;
                    pnlSignUpForm.Visible   = false;
                    pnlBeforeSignup.Visible = false;
                    pnlAfterSignup.Visible  = true;
                    try
                    {
                        // send admin notification:
                        String FormContents = String.Empty;
                        for (int i = 0; i <= Request.Form.Count - 1; i++)
                        {
                            if (!Request.Form.Keys[i].StartsWith("__"))
                            {
                                FormContents += "<b>" + Request.Form.Keys[i] + "</b>=" + Request.Form[Request.Form.Keys[i]] + "<br/>";
                            }
                        }
                        AppLogic.SendMail("" + AppLogic.GetString("AppConfig.AffiliateProgramName", SkinID, ThisCustomer.LocaleSetting) + " New Member Notification", FormContents, true, AppLogic.AppConfig("MailMe_FromAddress"), AppLogic.AppConfig("MailMe_FromName"), AppLogic.AppConfig("AffiliateEMailAddress"), AppLogic.AppConfig("AffiliateEMailAddress"), AppLogic.AppConfig("MailMe_FromAddress"), AppLogic.MailServer());
                    }
                    catch { }

                    lblSignupSuccess.Text    = "CONGRATULATIONS AND WELCOME TO THE " + AppLogic.GetString("AppConfig.AffiliateProgramName", SkinID, ThisCustomer.LocaleSetting).ToUpperInvariant() + " PROGRAM!<br/><br/>Your sign-up was successful.<br/><br/><a href=\"lat_account.aspx\">Click here</a> to go to your " + AppLogic.GetString("AppConfig.AffiliateProgramName", SkinID, ThisCustomer.LocaleSetting) + " Account Page.";
                    pnlSignupSuccess.Visible = true;
                }
            }
            else
            {
                lblErrorMsg.Text += "<br /><br /> Some errors occured trying to create your affiliate account.  Please correct them and try again.<br /><br />";
            }
            GetJavaScriptFunctions();
        }