public ActionResult SendPassword(string Model, string InvisibleCaptchaValue, string CaptchaValue)
        {
            if (!CaptchaController.IsCaptchaValid(CaptchaValue) || !CaptchaController.IsInvisibleCaptchaValid(InvisibleCaptchaValue))
            {
                ModelState.AddModelError(string.Empty, "Captcha error.");
                return(View());
            }

            if (ModelState.IsValid)
            {
                if (Model != null)
                {
                    Model = Model.Trim();
                }
                User u = _db.Users.FirstOrDefault(r => r.Email == Model);
                if (u == null)
                {
                    ModelState.AddModelError("", LocalizationHelpers.GetLocalResource("~/Views/Account/SendPassword.cshtml", "UsernameIncorrect"));
                }
                else
                {
                    // _db.OutEmails.Add(new OutEmail() { MailTo = Model, Subject = LocalizationHelpers.GetLocalResource("~/Views/Account/SendPassword.cshtml", "EmailTitle"), Body = LocalizationHelpers.GetLocalResource("~/Views/Account/SendPassword.cshtml", "EmailBody").Replace("{0}", u.UserName).Replace("{1}", u.Password) });
                    var messService = new MessageService(_db);
                    messService.SendUserPasswordEmailToUser(u);
                    return(RedirectToAction("SendPasswordSuccess"));
                }
            }
            return(View());
        }
        public ActionResult LogOn(LogOnModel model, string returnUrl, string InvisibleCaptchaValue)
        {
            if (!CaptchaController.IsInvisibleCaptchaValid(InvisibleCaptchaValue))
            {
                ModelState.AddModelError(string.Empty, "Captcha error.");
                return(View());
            }

            if (ModelState.IsValid)
            {
                if (Membership.ValidateUser(model.UserName, model.Password))
                {
                    var u = _db.Users.FirstOrDefault(x => x.UserName == model.UserName);
                    LS.Authorize(u);

                    if (Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1 && returnUrl.StartsWith("/") &&
                        !returnUrl.StartsWith("//") && !returnUrl.StartsWith("/\\"))
                    {
                        return(Redirect(returnUrl));
                    }
                    else
                    {
                        return(RedirectToAction("DomainPage", "Page", new { name = "root" }));
                    }
                }
                else
                {
                    ModelState.AddModelError("", LocalizationHelpers.GetLocalResource("~/Views/Account/LogOn.cshtml", "UsernameIncorrect"));
                }
            }

            return(View(model));
        }
        public ActionResult SendPasswordAjx(string Model, string InvisibleCaptchaValue, string CaptchaValue)
        {
            if (!CaptchaController.IsCaptchaValid(CaptchaValue) || !CaptchaController.IsInvisibleCaptchaValid(InvisibleCaptchaValue))
            {
                ModelState.AddModelError(string.Empty, RP.S("Errors.Common.CaptchaWrong"));
                return(Json(new { result = "error", message = ModelState.Values.Select(x => new { Value = x.Value != null ? x.Value.AttemptedValue : "", errors = x.Errors.Select(y => y.ErrorMessage) }) }));
            }

            if (ModelState.IsValid)
            {
                User u = _db.Users.FirstOrDefault(r => r.Email == Model);
                if (u == null)
                {
                    ModelState.AddModelError("", RP.S("Errors.Account.UserNameIncorrect"));
                    return(Json(new { result = "error", message = ModelState.Values.Select(x => new { Value = x.Value != null ? x.Value.AttemptedValue : "", errors = x.Errors.Select(y => y.ErrorMessage) }) }));
                }
                else
                {
                    var messService = new MessageService(_db);
                    messService.SendUserPasswordEmailToUser(u);
                    ModelState.AddModelError("", RP.S("Info.Account.PasswordSended"));
                    return(Json(new { result = "error", message = ModelState.Values.Select(x => new { Value = x.Value != null ? x.Value.AttemptedValue : "", errors = x.Errors.Select(y => y.ErrorMessage) }) }));
                }
            }
            return(Json(new { result = "error", message = ModelState.Values.Select(x => new { Value = x.Value != null ? x.Value.AttemptedValue : "", errors = x.Errors.Select(y => y.ErrorMessage) }) }));
        }
        public ActionResult _NewsletterAdd(Newsletter n, string InvisibleCaptchaValue)
        {
            if (!CaptchaController.IsInvisibleCaptchaValid(InvisibleCaptchaValue))
            {
                ModelState.AddModelError(string.Empty, "Captcha error.");
                SF.LogError("_NewsletterAdd Captcha error");
                return(Content("Error: Captcha", "text/html"));
            }

            if (ModelState.IsValid)
            {
                n.NewsletterDate = DateTime.Now;
                _db.Newsletters.Add(n);
                _db.SaveChanges();
                SF.AddToNewsletter(n);

                return(Content(RP.GetTextComponent("_NewsletterAdd"), "text/html"));
            }
            else
            {
                SF.LogError("_NewsletterAdd Model not valid");
                return(Content("Error: Model not valid", "text/html"));
            }
        }
Esempio n. 5
0
        public ActionResult FormPage(string InvisibleCaptchaValue, FormCollection formCollection)
        {
            if (!CaptchaController.IsInvisibleCaptchaValid(InvisibleCaptchaValue))
            {
                ModelState.AddModelError(string.Empty, "Captcha error.");
                return(Content("Error: Captcha", "text/html"));
            }

            Contact c = new Contact();

            List <FormField> FormFields = CurrentPage.GetDataFromXML1 <FormField>().OrderBy(r => r.FormFieldOrder).ToList();
            List <FormRool>  FormRools  = CurrentPage.GetDataFromXML2 <FormRool>().OrderBy(r => r.FormRoolOrder).ToList();

            //get name, email and phone
            foreach (Uco.Models.FormField item in FormFields.OrderBy(r => r.FormFieldOrder))
            {
                if (string.IsNullOrEmpty(Request["form_item_" + CurrentPage.ID + "_" + item.FormFieldID.ToString()]))
                {
                    continue;
                }
                string t = Request["form_item_" + CurrentPage.ID + "_" + item.FormFieldID.ToString()];

                if (item.FormFieldType == FormField.FormFildType.Name && string.IsNullOrEmpty(c.ContactName))
                {
                    c.ContactName = t;
                }
                else if (item.FormFieldType == FormField.FormFildType.PhoneNumber && string.IsNullOrEmpty(c.ContactPhone))
                {
                    c.ContactPhone = t;
                }
                else if (item.FormFieldType == FormField.FormFildType.EmailAddress && string.IsNullOrEmpty(c.ContactEmail))
                {
                    c.ContactEmail = t;
                }
                else
                {
                    c.ContactData = c.ContactData + item.FormFieldTitle + ": " + t + "<br />";
                }
            }

            string SendTo = string.Empty;

            //process rools
            foreach (Uco.Models.FormRool item in FormRools.OrderBy(r => r.FormRoolOrder))
            {
                bool MatchingRoolAnd = true;
                bool MatchingRoolOr  = false;
                bool MatchingRun     = false;

                if (!string.IsNullOrEmpty(item.FormRoolItem1) && item.FormRoolItem1 != "null")
                {
                    MatchingRun = true;
                    FormField field = FormFields.FirstOrDefault(r => r.FormFieldTitle.Trim() == item.FormRoolItem1.Trim());
                    if (field == null)
                    {
                        MatchingRoolAnd = false;
                    }
                    else
                    {
                        string FormRoolValue1 = Request["form_item_" + CurrentPage.ID + "_" + field.FormFieldID.ToString()];
                        if (!("," + item.FormRoolValue1 + ",").Contains("," + FormRoolValue1 + ","))
                        {
                            MatchingRoolAnd = false;
                        }
                        else if (item.FormRoolValue1 != FormRoolValue1)
                        {
                            MatchingRoolAnd = false;
                        }
                        else
                        {
                            MatchingRoolOr = true;
                        }
                    }
                }

                if (!string.IsNullOrEmpty(item.FormRoolItem2) && item.FormRoolItem2 != "null")
                {
                    MatchingRun = true;
                    FormField field = FormFields.FirstOrDefault(r => r.FormFieldTitle.Trim() == item.FormRoolItem2.Trim());
                    if (field == null)
                    {
                        MatchingRoolAnd = false;
                    }
                    else
                    {
                        string FormRoolValue2 = Request["form_item_" + CurrentPage.ID + "_" + field.FormFieldID.ToString()];
                        if (!("," + item.FormRoolValue2 + ",").Contains("," + FormRoolValue2 + ","))
                        {
                            MatchingRoolAnd = false;
                        }
                        if (item.FormRoolValue2 != FormRoolValue2)
                        {
                            MatchingRoolAnd = false;
                        }
                        else
                        {
                            MatchingRoolOr = true;
                        }
                    }
                }

                if (!string.IsNullOrEmpty(item.FormRoolItem3) && item.FormRoolItem3 != "null")
                {
                    MatchingRun = true;
                    FormField field = FormFields.FirstOrDefault(r => r.FormFieldTitle.Trim() == item.FormRoolItem3.Trim());
                    if (field == null)
                    {
                        MatchingRoolAnd = false;
                    }
                    {
                        string FormRoolValue3 = Request["form_item_" + CurrentPage.ID + "_" + field.FormFieldID.ToString()];
                        if (!("," + item.FormRoolValue3 + ",").Contains("," + FormRoolValue3 + ","))
                        {
                            MatchingRoolAnd = false;
                        }
                        if (item.FormRoolValue3 != FormRoolValue3)
                        {
                            MatchingRoolAnd = false;
                        }
                        else
                        {
                            MatchingRoolOr = true;
                        }
                    }
                }

                if ((MatchingRun && item.FormRoolAnd && MatchingRoolAnd) || (MatchingRun && !item.FormRoolAnd && MatchingRoolOr))
                {
                    c.RoleDefault = item.FormRoolRole;
                    c.Rool        = item.FormRoolTitle;
                    SendTo        = item.FormRoolEmail;
                    break;
                }
            }
            if (string.IsNullOrEmpty(c.RoleDefault))
            {
                c.RoleDefault = "Admin";
            }

            //get other data
            c.ContactReferal = SF.GetCookie("Referal");
            c.ContactUrl     = "<a target='_blank' href='http://" + Request.ServerVariables["HTTP_HOST"] + Url.Content(CurrentPage.Url) + "'>" + CurrentPage.Title + "</a>";
            c.ContactDate    = DateTime.Now;

            _db.Contacts.Add(c);
            _db.SaveChanges();

            if (string.IsNullOrEmpty(SendTo))
            {
                SendTo = RP.GetCurrentSettings().AdminEmail;
            }

            foreach (string item in SendTo.Split(','))
            {
                if (!SF.isEmail(item.Trim()))
                {
                    continue;
                }

                _db.OutEmails.Add(new OutEmail
                {
                    MailTo  = item.Trim(),
                    Subject = Uco.Models.Resources.SystemModels.ContactMailSubject
                              .Replace("{ID}", c.ID.ToString())
                              .Replace("{HTTP_HOST}", Request.ServerVariables["HTTP_HOST"]),
                    Body = Uco.Models.Resources.SystemModels.ContactMailBody
                           .Replace("{ID}", c.ID.ToString())
                           .Replace("{HTTP_HOST}", Request.ServerVariables["HTTP_HOST"])
                           .Replace("{ContactName}", c.ContactName)
                           .Replace("{ContactEmail}", c.ContactEmail)
                           .Replace("{ContactPhone}", c.ContactPhone)
                           .Replace("{ContactData}", c.ContactData)
                           .Replace("{ContactReferal}", c.ContactReferal)
                           .Replace("{ContactUrl}", c.ContactUrl),
                    TimesSent = 0,
                    LastTry   = DateTime.Now
                });
            }

            _db.SaveChanges();

            if (!string.IsNullOrEmpty(CurrentPage.Text3) && !string.IsNullOrEmpty(c.ContactEmail) && SF.isEmail(c.ContactEmail))
            {
                _db.OutEmails.Add(new OutEmail
                {
                    MailTo  = c.ContactEmail.Trim(),
                    Subject = Uco.Models.Resources.SystemModels.ContactMailSubject
                              .Replace("{HTTP_HOST}", Request.ServerVariables["HTTP_HOST"]),
                    Body = CurrentPage.Text3
                           .Replace("{HTTP_HOST}", Request.ServerVariables["HTTP_HOST"])
                           .Replace("{ContactName}", c.ContactName)
                           .Replace("{ContactEmail}", c.ContactEmail)
                           .Replace("{ContactPhone}", c.ContactPhone)
                           .Replace("{ContactData}", c.ContactData)
                           .Replace("{ContactReferal}", c.ContactReferal)
                           .Replace("{ContactUrl}", c.ContactUrl),
                    TimesSent = 0,
                    LastTry   = DateTime.Now
                });
            }

            return(Content(((FormPage)CurrentPage).Text2, "text/html"));
        }
        public ActionResult _FormAdd(string InvisibleCaptchaValue, int FormID)
        {
            if (!CaptchaController.IsInvisibleCaptchaValid(InvisibleCaptchaValue))
            {
                ModelState.AddModelError(string.Empty, "Captcha error.");
                SF.LogError("_FormAdd Captcha error");
                return(Content("Error: Captcha", "text/html"));
            }

            AbstractPage CurrentPage = _db.FormPages.FirstOrDefault(r => r.ID == FormID);

            if (CurrentPage == null)
            {
                ModelState.AddModelError(string.Empty, "CurrentPage error");
                SF.LogError("_FormAdd CurrentPage error");
                return(Content("Error: CurrentPage error", "text/html"));
            }

            Contact c = new Contact();

            List <FormField> l = CurrentPage.GetDataFromXML1 <FormField>().OrderBy(r => r.FormFieldOrder).ToList();

            foreach (Uco.Models.FormField item in l.OrderBy(r => r.FormFieldOrder))
            {
                if (string.IsNullOrEmpty(Request["form_item_" + item.FormFieldID.ToString()]))
                {
                    continue;
                }
                string t = Request["form_item_" + item.FormFieldID.ToString()];

                if (item.FormFieldType == FormField.FormFildType.Name && string.IsNullOrEmpty(c.ContactName))
                {
                    c.ContactName = t;
                }
                else if (item.FormFieldType == FormField.FormFildType.PhoneNumber && string.IsNullOrEmpty(c.ContactPhone))
                {
                    c.ContactPhone = t;
                }
                else if (item.FormFieldType == FormField.FormFildType.EmailAddress && string.IsNullOrEmpty(c.ContactEmail))
                {
                    c.ContactEmail = t;
                }
                else
                {
                    c.ContactData = c.ContactData + item.FormFieldTitle + ": " + t + "<br />";
                }
            }

            c.ContactReferal = SF.GetCookie("Referal");
            c.ContactUrl     = "<a target='_blank' href='http://" + Request.ServerVariables["HTTP_HOST"] + Request.UrlReferrer.ToString() + "'>" + Request.UrlReferrer.ToString() + "</a>";
            c.ContactDate    = DateTime.Now;

            _db.Contacts.Add(c);
            _db.SaveChanges();

            foreach (string item in RP.GetCurrentSettings().AdminEmail.Split(','))
            {
                if (!SF.isEmail(item.Trim()))
                {
                    continue;
                }

                _db.OutEmails.Add(new OutEmail
                {
                    MailTo  = item.Trim(),
                    Subject = Uco.Models.Resources.SystemModels.ContactMailSubject
                              .Replace("{ID}", c.ID.ToString())
                              .Replace("{HTTP_HOST}", Request.ServerVariables["HTTP_HOST"]),
                    Body = Uco.Models.Resources.SystemModels.ContactMailBody
                           .Replace("{ID}", c.ID.ToString())
                           .Replace("{HTTP_HOST}", Request.ServerVariables["HTTP_HOST"])
                           .Replace("{ContactName}", c.ContactName)
                           .Replace("{ContactEmail}", c.ContactEmail)
                           .Replace("{ContactPhone}", c.ContactPhone)
                           .Replace("{ContactData}", c.ContactData)
                           .Replace("{ContactReferal}", c.ContactReferal)
                           .Replace("{ContactUrl}", c.ContactUrl),
                    TimesSent = 0,
                    LastTry   = DateTime.Now
                });
            }

            _db.SaveChanges();

            return(Content(RP.GetTextComponent("_FormAdd"), "text/html"));
        }
        public ActionResult _SmallFormAdd(ContactSmallForm csf, string InvisibleCaptchaValue)
        {
            if (!CaptchaController.IsInvisibleCaptchaValid(InvisibleCaptchaValue))
            {
                ModelState.AddModelError(string.Empty, "Captcha error.");
                SF.LogError("_SmallFormAdd Captcha error");
                return(Content("Error: Captcha", "text/html"));
            }

            if (ModelState.IsValid)
            {
                Contact c = new Contact();

                c.ContactEmail = csf.ContactEmail;
                c.ContactName  = csf.ContactName;
                c.ContactPhone = csf.ContactPhone;

                c.ContactReferal = SF.GetCookie("Referal");
                string UrlReferrer = UcoString.GetUtf8String(Request.UrlReferrer.ToString());
                c.ContactUrl  = "<a target='_blank' href='" + UrlReferrer + "'>" + UrlReferrer + "</a>";
                c.ContactDate = DateTime.Now;

                _db.Contacts.Add(c);
                _db.SaveChanges();

                foreach (string item in RP.GetCurrentSettings().AdminEmail.Split(','))
                {
                    if (!SF.isEmail(item.Trim()))
                    {
                        continue;
                    }

                    _db.OutEmails.Add(new OutEmail
                    {
                        MailTo  = item.Trim(),
                        Subject = Uco.Models.Resources.SystemModels.ContactMailSubject
                                  .Replace("{ID}", c.ID.ToString())
                                  .Replace("{HTTP_HOST}", Request.ServerVariables["HTTP_HOST"]),
                        Body = Uco.Models.Resources.SystemModels.ContactMailBody
                               .Replace("{ID}", c.ID.ToString())
                               .Replace("{HTTP_HOST}", Request.ServerVariables["HTTP_HOST"])
                               .Replace("{ContactName}", c.ContactName)
                               .Replace("{ContactEmail}", c.ContactEmail)
                               .Replace("{ContactPhone}", c.ContactPhone)
                               .Replace("{ContactData}", c.ContactData)
                               .Replace("{ContactReferal}", c.ContactReferal)
                               .Replace("{ContactUrl}", c.ContactUrl),
                        TimesSent = 0,
                        LastTry   = DateTime.Now
                    });
                }

                _db.SaveChanges();

                return(Content(RP.GetTextComponent("_SmallFormAdd"), "text/html"));
            }
            else
            {
                SF.LogError("_SmallFormAdd Model not valid");
                return(Content("Error: Model not valid", "text/html"));
            }
        }