Exemplo n.º 1
0
        private static List <ContactFormMessage> LoadListFromReader(IDataReader reader)
        {
            List <ContactFormMessage> contactFormMessageList = new List <ContactFormMessage>();

            try
            {
                while (reader.Read())
                {
                    ContactFormMessage contactFormMessage = new ContactFormMessage();
                    contactFormMessage.rowGuid              = new Guid(reader["RowGuid"].ToString());
                    contactFormMessage.siteGuid             = new Guid(reader["SiteGuid"].ToString());
                    contactFormMessage.moduleGuid           = new Guid(reader["ModuleGuid"].ToString());
                    contactFormMessage.email                = reader["Email"].ToString();
                    contactFormMessage.userName             = reader["Url"].ToString();
                    contactFormMessage.subject              = reader["Subject"].ToString();
                    contactFormMessage.message              = reader["Message"].ToString();
                    contactFormMessage.createdUtc           = Convert.ToDateTime(reader["CreatedUtc"]);
                    contactFormMessage.createdFromIpAddress = reader["CreatedFromIpAddress"].ToString();
                    contactFormMessage.userGuid             = new Guid(reader["UserGuid"].ToString());
                    contactFormMessageList.Add(contactFormMessage);
                }
            }
            finally
            {
                reader.Close();
            }

            return(contactFormMessageList);
        }
        public string GetCallbackResult()
        {
            if (callbackArg.Length != 36) return string.Empty;

            Guid messageGuid = new Guid(callbackArg);
            ContactFormMessage message = new ContactFormMessage(messageGuid);
            return SecurityHelper.SanitizeHtml(message.Message);
        }
Exemplo n.º 3
0
 /// <summary>
 /// Compares 2 instances of ContactFormMessage.
 /// </summary>
 public static int CompareByMessage(ContactFormMessage contactFormMessage1, ContactFormMessage contactFormMessage2)
 {
     return(contactFormMessage1.Message.CompareTo(contactFormMessage2.Message));
 }
Exemplo n.º 4
0
 /// <summary>
 /// Compares 2 instances of ContactFormMessage.
 /// </summary>
 public static int CompareBySubject(ContactFormMessage contactFormMessage1, ContactFormMessage contactFormMessage2)
 {
     return(contactFormMessage1.Subject.CompareTo(contactFormMessage2.Subject));
 }
Exemplo n.º 5
0
 /// <summary>
 /// Compares 2 instances of ContactFormMessage.
 /// </summary>
 public static int CompareByUserName(ContactFormMessage contactFormMessage1, ContactFormMessage contactFormMessage2)
 {
     return(contactFormMessage1.UserName.CompareTo(contactFormMessage2.UserName));
 }
Exemplo n.º 6
0
 /// <summary>
 /// Compares 2 instances of ContactFormMessage.
 /// </summary>
 public static int CompareByEmail(ContactFormMessage contactFormMessage1, ContactFormMessage contactFormMessage2)
 {
     return(contactFormMessage1.Email.CompareTo(contactFormMessage2.Email));
 }
Exemplo n.º 7
0
        private void btnSend_Click(object sender, EventArgs e)
        {
            //Page.Validate("Contact");
            bool isValid = true;
            reqEmail.Validate();
            if (!reqEmail.IsValid) { isValid = false; }
            regexEmail.Validate();
            if (!regexEmail.IsValid) { isValid = false; }

            if ((isValid) && (edMessage.Text.Length > 0))
            {
                if ((config.UseSpamBlocking) && (divCaptcha.Visible))
                {

                    if (!captcha.IsValid) return;
                }

                string subjectPrefix = config.SubjectPrefix;
                if (subjectPrefix.Length == 0)
                {
                    subjectPrefix = Title;
                }

                StringBuilder message = new StringBuilder();
                message.Append(txtName.Text + "<br />");
                message.Append(txtEmail.Text + "<br /><br />");
                message.Append(SiteUtils.ChangeRelativeUrlsToFullyQualifiedUrls(SiteUtils.GetNavigationSiteRoot(), WebUtils.GetSiteRoot(), edMessage.Text));
                message.Append("<br /><br />");
                if (config.AppendIPToMessageSetting)
                {
                    message.Append("HTTP_USER_AGENT: " + Page.Request.ServerVariables["HTTP_USER_AGENT"] + "<br />");
                    message.Append("REMOTE_HOST: " + Page.Request.ServerVariables[WebConfigSettings.RemoteHostServerVariable] + "<br />");
                    message.Append("REMOTE_ADDR: " + SiteUtils.GetIP4Address() + "<br />");
                    message.Append("LOCAL_ADDR: " + Page.Request.ServerVariables["LOCAL_ADDR"] + "<br />");

                }

                Module m = new Module(ModuleId);
                if ((config.KeepMessages) &&(m.ModuleGuid != Guid.Empty))
                {
                    ContactFormMessage contact = new ContactFormMessage();
                    contact.ModuleGuid = m.ModuleGuid;
                    contact.SiteGuid = siteSettings.SiteGuid;
                    contact.Message = message.ToString();
                    contact.Subject = config.SubjectPrefix + ": " + txtSubject.Text;
                    contact.UserName = txtName.Text;
                    contact.Email = txtEmail.Text;
                    contact.CreatedFromIpAddress = SiteUtils.GetIP4Address();

                    if (Request.IsAuthenticated)
                    {
                        SiteUser currentUser = SiteUtils.GetCurrentSiteUser();
                        if (currentUser != null)
                            contact.UserGuid = currentUser.UserGuid;

                    }

                    contact.Save();

                }

                string fromAddress = siteSettings.DefaultEmailFromAddress;
                if (config.UseInputAsFromAddress) { fromAddress = txtEmail.Text; }

                if ((config.EmailAddresses != null) && (config.EmailAddresses.Count > 0))
                {
                    SmtpSettings smtpSettings = SiteUtils.GetSmtpSettings();

                    if ((pnlToAddresses.Visible) && (ddToAddresses.SelectedIndex > -1))
                    {
                        string to = config.EmailAddresses[ddToAddresses.SelectedIndex];
                        try
                        {
                            Email.SendEmail(
                                smtpSettings,
                                fromAddress,
                                txtEmail.Text,
                                to,
                                string.Empty,
                                config.EmailBccAddresses,
                                subjectPrefix + ": " + this.txtSubject.Text,
                                message.ToString(),
                                true,
                                "Normal");

                        }
                        catch (Exception ex)
                        {
                            log.Error("error sending email from address was " + fromAddress + " to address was " + to, ex);
                        }

                    }
                    else
                    {

                        foreach (string to in config.EmailAddresses)
                        {
                            try
                            {
                                Email.SendEmail(
                                    smtpSettings,
                                    fromAddress,
                                    txtEmail.Text,
                                    to,
                                    string.Empty,
                                    config.EmailBccAddresses,
                                    subjectPrefix + ": " + this.txtSubject.Text,
                                    message.ToString(),
                                    true,
                                    "Normal");

                            }
                            catch (Exception ex)
                            {
                                log.Error("error sending email from address was " + fromAddress + " to address was " + to, ex);
                            }

                        }
                    }

                }
                else
                {
                    log.Info("contact form submission received but not sending email because notification email address is not configured.");
                }

                this.lblMessage.Text = ContactFormResources.ContactFormThankYouLabel;
                this.pnlSend.Visible = false;

            }
            else
            {
                if (edMessage.Text.Length == 0)
                {
                    lblMessage.Text = ContactFormResources.ContactFormEmptyMessageWarning;
                }
                else
                {
                    lblMessage.Text = "invalid";
                }

            }

            btnSend.Text = ContactFormResources.ContactFormSendButtonLabel;
            btnSend.Enabled = true;
        }
Exemplo n.º 8
0
 /// <summary>
 /// Compares 2 instances of ContactFormMessage.
 /// </summary>
 public static int CompareByCreatedUtc(ContactFormMessage contactFormMessage1, ContactFormMessage contactFormMessage2)
 {
     return contactFormMessage1.CreatedUtc.CompareTo(contactFormMessage2.CreatedUtc);
 }
        void grdContactFormMessage_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            string arg = e.CommandArgument.ToString();
            if (arg.Length != 36) return;
            Guid messageGuid = new Guid(arg);
            switch (e.CommandName)
            {
                case "remove":
                    ContactFormMessage.Delete(messageGuid);
                    WebUtils.SetupRedirect(this, Request.RawUrl);
                    break;

                case "view":
                default:

                    ContactFormMessage message = new ContactFormMessage(messageGuid);
                    litMessage.Text = SecurityHelper.SanitizeHtml(message.Message);
                    //upMessage.Update();
                    break;

            }
        }
Exemplo n.º 10
0
        private static List<ContactFormMessage> LoadListFromReader(IDataReader reader)
        {
            List<ContactFormMessage> contactFormMessageList = new List<ContactFormMessage>();
            try
            {
                while (reader.Read())
                {
                    ContactFormMessage contactFormMessage = new ContactFormMessage();
                    contactFormMessage.rowGuid = new Guid(reader["RowGuid"].ToString());
                    contactFormMessage.siteGuid = new Guid(reader["SiteGuid"].ToString());
                    contactFormMessage.moduleGuid = new Guid(reader["ModuleGuid"].ToString());
                    contactFormMessage.email = reader["Email"].ToString();
                    contactFormMessage.userName = reader["Url"].ToString();
                    contactFormMessage.subject = reader["Subject"].ToString();
                    contactFormMessage.message = reader["Message"].ToString();
                    contactFormMessage.createdUtc = Convert.ToDateTime(reader["CreatedUtc"]);
                    contactFormMessage.createdFromIpAddress = reader["CreatedFromIpAddress"].ToString();
                    contactFormMessage.userGuid = new Guid(reader["UserGuid"].ToString());
                    contactFormMessageList.Add(contactFormMessage);

                }
            }
            finally
            {
                reader.Close();
            }

            return contactFormMessageList;
        }
Exemplo n.º 11
0
 /// <summary>
 /// Compares 2 instances of ContactFormMessage.
 /// </summary>
 public static int CompareByUserName(ContactFormMessage contactFormMessage1, ContactFormMessage contactFormMessage2)
 {
     return contactFormMessage1.UserName.CompareTo(contactFormMessage2.UserName);
 }
Exemplo n.º 12
0
 /// <summary>
 /// Compares 2 instances of ContactFormMessage.
 /// </summary>
 public static int CompareBySubject(ContactFormMessage contactFormMessage1, ContactFormMessage contactFormMessage2)
 {
     return contactFormMessage1.Subject.CompareTo(contactFormMessage2.Subject);
 }
Exemplo n.º 13
0
 /// <summary>
 /// Compares 2 instances of ContactFormMessage.
 /// </summary>
 public static int CompareByMessage(ContactFormMessage contactFormMessage1, ContactFormMessage contactFormMessage2)
 {
     return contactFormMessage1.Message.CompareTo(contactFormMessage2.Message);
 }
Exemplo n.º 14
0
 /// <summary>
 /// Compares 2 instances of ContactFormMessage.
 /// </summary>
 public static int CompareByEmail(ContactFormMessage contactFormMessage1, ContactFormMessage contactFormMessage2)
 {
     return contactFormMessage1.Email.CompareTo(contactFormMessage2.Email);
 }
Exemplo n.º 15
0
 /// <summary>
 /// Compares 2 instances of ContactFormMessage.
 /// </summary>
 public static int CompareByCreatedUtc(ContactFormMessage contactFormMessage1, ContactFormMessage contactFormMessage2)
 {
     return(contactFormMessage1.CreatedUtc.CompareTo(contactFormMessage2.CreatedUtc));
 }
Exemplo n.º 16
0
 /// <summary>
 /// Compares 2 instances of ContactFormMessage.
 /// </summary>
 public static int CompareByCreatedFromIpAddress(ContactFormMessage contactFormMessage1, ContactFormMessage contactFormMessage2)
 {
     return(contactFormMessage1.CreatedFromIpAddress.CompareTo(contactFormMessage2.CreatedFromIpAddress));
 }
Exemplo n.º 17
0
 /// <summary>
 /// Compares 2 instances of ContactFormMessage.
 /// </summary>
 public static int CompareByCreatedFromIpAddress(ContactFormMessage contactFormMessage1, ContactFormMessage contactFormMessage2)
 {
     return contactFormMessage1.CreatedFromIpAddress.CompareTo(contactFormMessage2.CreatedFromIpAddress);
 }