Beispiel #1
0
        public ActionResult Register(RegisterModel model)
        {
            if (Utilities.IsSpamIP(Request.UserHostAddress))
            {
                // they are a duplicate IP and are no being referred by an existing user
                ModelState.AddModelError("", BootBaronLib.Resources.Messages.Invalid + ": " + Messages.Account);
                return View(model);
            }

            // ignore old browsers and duplicate IPs
            if
                (
                Request.Browser.Type == "IE3" ||
                Request.Browser.Type == "IE4" ||
                Request.Browser.Type == "IE5" ||
                Request.Browser.Type == "IE6" ||
                Request.Browser.Type == "IE7" ||
                BlackIPs.IsIPBlocked(Request.UserHostAddress)

                )
            {
                Response.Redirect("http://browsehappy.com/");
                return View();
            }
            else if (!BootBaronLib.Configs.GeneralConfigs.EnableSameIP &&
                UserAccount.IsAccountIPTaken(Request.UserHostAddress) &&
                string.IsNullOrEmpty(model.RefUser))
            {
                // they are a duplicate IP and are no being referred by an existing user
                ModelState.AddModelError("", BootBaronLib.Resources.Messages.Invalid + ": " + Messages.Account);
                return View(model);
            }

            TryUpdateModel(model);

            if (ModelState.IsValid)
            {
                if (!Utilities.IsEmail(model.Email))
                {
                    ModelState.AddModelError("", BootBaronLib.Resources.Messages.IncorrectFormat + ": " + BootBaronLib.Resources.Messages.EMail);
                    return View();
                }
                else if (
                    model.UserName.Trim().Contains(" ") ||
                    model.UserName.Trim().Contains("?") ||
                    model.UserName.Trim().Contains("*") ||
                    model.UserName.Trim().Contains(":") ||
                    model.UserName.Trim().Contains("/") ||
                    model.UserName.Trim().Contains(@"\"))
                {
                    ModelState.AddModelError("", BootBaronLib.Resources.Messages.Invalid + ": " + BootBaronLib.Resources.Messages.UserName);
                    return View();
                }
                else if (model.YouAreID == null)
                {
                    ModelState.AddModelError("", BootBaronLib.Resources.Messages.Invalid + ": " + BootBaronLib.Resources.Messages.YouAre);
                    return View();
                }

                DateTime dt = new DateTime();

                if (!DateTime.TryParse(model.Year
                                + "-" + model.Month + "-" + model.Day, out dt))
                {
                    ModelState.AddModelError("", BootBaronLib.Resources.Messages.Invalid + ": " + BootBaronLib.Resources.Messages.BirthDate);
                    return View();
                }
                else if (DateTime.TryParse(model.Year
                    + "-" + model.Month + "-" + model.Day, out dt))
                {
                    if (Utilities.CalculateAge(dt) < BootBaronLib.Configs.GeneralConfigs.MinimumAge)
                    {
                        ModelState.AddModelError("", BootBaronLib.Resources.Messages.Invalid + ": " + BootBaronLib.Resources.Messages.BirthDate);
                        return View();
                    }
                }

                model.UserName = model.UserName.Replace(" ", string.Empty).Replace(":", string.Empty) /* still annoying errors */;

                // Attempt to register the user
                MembershipCreateStatus createStatus;

                Membership.CreateUser(model.UserName, model.NewPassword, model.Email, "Q", "A", true, out createStatus);

                if (createStatus == MembershipCreateStatus.Success)
                {
                    FormsAuthentication.RedirectFromLoginPage(model.UserName, true);

                    UserAccount ua = new UserAccount(model.UserName);
                    uad = new UserAccountDetail();
                    uad.UserAccountID = ua.UserAccountID;

                    uad.BirthDate = dt;
                    uad.YouAreID = model.YouAreID;
                    uad.DisplayAge = true;
                    uad.DefaultLanguage = Utilities.GetCurrentLanguageCode();

                    if (!string.IsNullOrEmpty(model.RefUser))
                    {
                        UserAccount refUser = new UserAccount(model.RefUser);
                        uad.ReferringUserID = refUser.UserAccountID;
                    }

                    uad.Set();

                    StringBuilder sb = new StringBuilder(100);

                    sb.Append(Messages.Hello);
                    sb.Append(Environment.NewLine);
                    sb.Append(Messages.YourNewAccountIsReadyForUse);
                    sb.Append(Environment.NewLine);
                    sb.Append(Environment.NewLine);
                    sb.Append(Messages.UserName + ": ");
                    sb.Append(ua.UserName);
                    sb.Append(Environment.NewLine);
                    sb.Append(Messages.Password + ": ");
                    sb.Append(model.NewPassword);
                    sb.Append(Environment.NewLine);
                    sb.Append(BootBaronLib.Configs.GeneralConfigs.SiteDomain);

                    Utilities.SendMail(ua.EMail, Messages.YourNewAccountIsReadyForUse, sb.ToString());

                    // see if this is the 1st user
                    UserAccounts recentUsers = new UserAccounts();
                    recentUsers.GetNewestUsers();

                    if (recentUsers.Count == 1)
                    {
                        Role adminRole = new Role(SiteEnums.RoleTypes.admin.ToString());

                        UserAccountRole.AddUserToRole(ua.UserAccountID, adminRole.RoleID);
                    }

                    return RedirectToAction("editprofile", "Account");
                }
                else
                {
                    ModelState.AddModelError("", AccountValidation.ErrorCodeToString(createStatus));
                }
            }

            return View(model);
        }
Beispiel #2
0
        public ActionResult Home()
        {
            if (_mu == null)
            {
                return RedirectToAction("LogOff");
            }

            var uas = new UserAccounts();
            uas.GetNewestUsers();
            ViewBag.NewestUsers = uas.ToUnorderdList;

            _ua = new UserAccount(Convert.ToInt32(_mu.ProviderUserKey));

            ViewBag.CurrentUser = _ua.ToUnorderdListItem;

            var preFilter = new StatusUpdates();

            preFilter.GetStatusUpdatesPageWise(1, PageSize);

            var sus = new StatusUpdates();
            sus.AddRange(
                preFilter.Where(
                    su1 =>
                        !Lib.BOL.BlockedUser.IsBlockingUser(_ua.UserAccountID, su1.UserAccountID)));

            sus.IncludeStartAndEndTags = false;
            ViewBag.StatusUpdateList = string.Format(@"<ul id=""status_update_list_items"">{0}</ul>", sus.ToUnorderdList);

            var suns = new StatusUpdateNotifications();
            suns.GetStatusUpdateNotificationsForUser(_ua.UserAccountID);

            if (suns.Count > 0)
            {
                suns.Sort((p1, p2) => p1.CreateDate.CompareTo(p2.CreateDate));

                ViewBag.Notifications = suns;

                foreach (StatusUpdateNotification sun1 in suns)
                {
                    sun1.IsRead = true;
                    sun1.Update();
                }
            }

            var applauseResult = new StatusUpdates();
            applauseResult.GetMostAcknowledgedStatus(7, SiteEnums.AcknowledgementType.A);
            if (applauseResult.Count > 0)
            {
                ViewBag.MostApplauded = applauseResult;
            }

            var beatDownResult = new StatusUpdate();
            beatDownResult.GetMostAcknowledgedStatus(7, SiteEnums.AcknowledgementType.B);

            bool isAlreadyApplauded = false;

            if (beatDownResult.StatusUpdateID > 0)
            {
                if (applauseResult.Any(ssr1 => beatDownResult.StatusUpdateID == ssr1.StatusUpdateID))
                {
                    isAlreadyApplauded = true;
                }
            }

            if (!isAlreadyApplauded && beatDownResult.StatusUpdateID > 0)
            {
                ViewBag.MostBeatDown = beatDownResult;
            }

            var commentResponse = new StatusUpdate(StatusComments.GetMostCommentedOnStatus(DateTime.UtcNow.AddDays(-7)));

            bool isAlreadyCommented = false;

            foreach (
                StatusUpdate ssr1 in applauseResult.Where(ssr1 => commentResponse.StatusUpdateID == ssr1.StatusUpdateID)
                )
            {
                isAlreadyCommented = true;
            }

            if (!isAlreadyCommented && beatDownResult.StatusUpdateID != commentResponse.StatusUpdateID &&
                commentResponse.StatusUpdateID > 0)
            {
                ViewBag.MostCommented = commentResponse;
            }

            if (TempData["user_error"] != null)
            {
                ViewBag.Error = TempData["user_error"];
            }

            return View();
        }
Beispiel #3
0
        public ActionResult Register(RegisterModel model)
        {
            if (Utilities.IsSpamIP(Request.UserHostAddress))
            {
                ModelState.AddModelError("", Messages.Invalid + @": " + Messages.Account);
                return View(model);
            }

            if
                (
                Request.Browser.Type == "IE3" ||
                Request.Browser.Type == "IE4" ||
                Request.Browser.Type == "IE5" ||
                Request.Browser.Type == "IE6" ||
                Request.Browser.Type == "IE7" ||
                BlackIPs.IsIPBlocked(Request.UserHostAddress)
                )
            {
                Response.Redirect("http://browsehappy.com/");
                return View();
            }

            if (!GeneralConfigs.EnableSameIP && UserAccount.IsAccountIPTaken(Request.UserHostAddress) &&
                string.IsNullOrEmpty(model.RefUser))
            {
                ModelState.AddModelError("", Messages.Invalid + @": " + Messages.Account);
                return View(model);
            }

            TryUpdateModel(model);

            if (!ModelState.IsValid) return View(model);

            if (!Utilities.IsEmail(model.Email))
            {
                ModelState.AddModelError("", Messages.IncorrectFormat + @": " + Messages.EMail);
                return View();
            }
            if (
                model.UserName.Trim().Contains(" ") ||
                model.UserName.Trim().Contains("?") ||
                model.UserName.Trim().Contains("*") ||
                model.UserName.Trim().Contains(":") ||
                model.UserName.Trim().Contains("/") ||
                model.UserName.Trim().Contains(@"\"))
            {
                ModelState.AddModelError("", Messages.Invalid + @": " + Messages.UserName);
                return View();
            }
            if (model.YouAreID == null)
            {
                ModelState.AddModelError("", Messages.Invalid + @": " + Messages.YouAre);
                return View();
            }

            DateTime dt;

            if (!DateTime.TryParse(model.Year
                                   + "-" + model.Month + "-" + model.Day, out dt))
            {
                ModelState.AddModelError("", Messages.Invalid + @": " + Messages.BirthDate);
                return View();
            }
            if (DateTime.TryParse(model.Year
                                  + "-" + model.Month + "-" + model.Day, out dt))
            {
                if (Utilities.CalculateAge(dt) < GeneralConfigs.MinimumAge)
                {
                    ModelState.AddModelError("", Messages.Invalid + @": " + Messages.BirthDate);
                    return View();
                }
            }

            model.UserName = model.UserName.Replace(":", string.Empty);
            model.UserName = model.UserName.Replace(" ", string.Empty);
            model.UserName = model.UserName.Replace(".", string.Empty);

            MembershipCreateStatus createStatus;

            Membership.CreateUser(model.UserName, model.NewPassword, model.Email, "Q", "A", true, out createStatus);

            if (createStatus == MembershipCreateStatus.Success)
            {
                FormsAuthentication.RedirectFromLoginPage(model.UserName, true);

                var ua = new UserAccount(model.UserName);
                _uad = new UserAccountDetail
                {
                    UserAccountID = ua.UserAccountID,
                    BirthDate = dt,
                    YouAreID = model.YouAreID,
                    DisplayAge = true,
                    DefaultLanguage = Utilities.GetCurrentLanguageCode()
                };

                if (!string.IsNullOrEmpty(model.RefUser))
                {
                    var refUser = new UserAccount(model.RefUser);
                    _uad.ReferringUserID = refUser.UserAccountID;
                }

                _uad.Set();

                var sb = new StringBuilder(100);

                sb.Append(Messages.Hello);
                sb.Append(Environment.NewLine);
                sb.Append(Messages.YourNewAccountIsReadyForUse);
                sb.Append(Environment.NewLine);
                sb.Append(Environment.NewLine);
                sb.AppendFormat("{0}: ", Messages.UserName);
                sb.Append(ua.UserName);
                sb.Append(Environment.NewLine);
                sb.Append(GeneralConfigs.SiteDomain);

                _mail.SendMail(AmazonCloudConfigs.SendFromEmail, ua.EMail, Messages.YourNewAccountIsReadyForUse,
                    sb.ToString());

                // see if this is the 1st user
                var recentUsers = new UserAccounts();
                recentUsers.GetNewestUsers();

                if (recentUsers.Count == 1)
                {
                    var adminRole = new Role(SiteEnums.RoleTypes.admin.ToString());

                    UserAccountRole.AddUserToRole(ua.UserAccountID, adminRole.RoleID);
                }

                var dm = new DirectMessage {IsRead = false};
                var communityManager = new UserAccount(SiteDomain.GetSiteDomainValue(
                                                SiteEnums.SiteBrandType.GRTUR,
                                                Utilities.GetCurrentLanguageCode())
                                            .Trim());

                dm.FromUserAccountID = communityManager.UserAccountID;
                dm.ToUserAccountID = ua.UserAccountID;

                sb = new StringBuilder(100);

                sb.Append(SiteDomain.GetSiteDomainValue(
                    SiteEnums.SiteBrandType.GREET,
                    Utilities.GetCurrentLanguageCode()));

                dm.Message = sb.ToString();

                if (communityManager.UserAccountID != 0)
                {
                    dm.CreatedByUserID = communityManager.UserAccountID;
                }

                dm.Create();

                return RedirectToAction("Home", "Account");
            }
            ModelState.AddModelError(string.Empty, AccountValidation.ErrorCodeToString(createStatus));

            return View(model);
        }
Beispiel #4
0
        public ActionResult Index()
        {
            // CONTESTS

            Contest cndss = Contest.GetCurrentContest();
            ContestVideos cvids = new ContestVideos();

            Videos vidsInContest = new Videos();
            BootBaronLib.AppSpec.DasKlub.BOL.Video vid2 = null;

            foreach (ContestVideo cv1 in cvids)
            {
                vid2 = new BootBaronLib.AppSpec.DasKlub.BOL.Video(cv1.VideoID);
                vidsInContest.Add(vid2);
            }

            vidsInContest.Sort(delegate(BootBaronLib.AppSpec.DasKlub.BOL.Video p1, BootBaronLib.AppSpec.DasKlub.BOL.Video p2)
            {
                return p2.PublishDate.CompareTo(p1.PublishDate);
            });

            SongRecords sngrcds3 = new SongRecords();
            SongRecord sng3 = new SongRecord();

            foreach (BootBaronLib.AppSpec.DasKlub.BOL.Video v1 in vidsInContest)
            {
                sng3 = new SongRecord(v1);

                sngrcds3.Add(sng3);
            }

            ViewBag.ContestVideoList = sngrcds3.VideosList();
            ViewBag.CurrentContest = cndss;

            //
            PhotoItems pitms = new PhotoItems();
            pitms.UseThumb = true;
            pitms.ShowTitle = false;
            pitms.GetPhotoItemsPageWise(1, 4);

            ViewBag.PhotoList = pitms.ToUnorderdList;

            Contents cnts = new Contents();
            cnts.GetContentPageWiseAll(1, 3);

            ViewBag.RecentArticles = cnts.ToUnorderdList;

            UserAccounts uas = new UserAccounts();
            uas.GetNewestUsers();
            ViewBag.NewestUsers = uas.ToUnorderdList;

            Videos newestVideos = new Videos();
            newestVideos.GetMostRecentVideos();
            SongRecords newSongs = new SongRecords();
            SongRecord sng1 = null;
            foreach (BootBaronLib.AppSpec.DasKlub.BOL.Video v1 in newestVideos)
            {
                sng1 = new SongRecord(v1);
                newSongs.Add(sng1);
            }

            ViewBag.NewestVideos = newSongs.VideosList();

            BootBaronLib.AppSpec.DasKlub.BOL.Video vid = new BootBaronLib.AppSpec.DasKlub.BOL.Video(BootBaronLib.AppSpec.DasKlub.BOL.Video.RandomVideoIDVideo());

            ViewBag.RandomVideoKey = vid.ProviderKey;

            ///video submit
            MultiProperties addList = null;
            PropertyType propTyp = null;
            MultiProperties mps = null;

            // video typesa
            propTyp = new PropertyType(SiteEnums.PropertyTypeCode.VIDTP);
            mps = new MultiProperties(propTyp.PropertyTypeID);
            mps.Sort(delegate(MultiProperty p1, MultiProperty p2)
            {
                return p1.DisplayName.CompareTo(p2.DisplayName);
            });

            ViewBag.VideoTypes = mps;

            // person types
            propTyp = new PropertyType(SiteEnums.PropertyTypeCode.HUMAN);
            mps = new MultiProperties(propTyp.PropertyTypeID);
            mps.Sort(delegate(MultiProperty p1, MultiProperty p2)
            {
                return p1.DisplayName.CompareTo(p2.DisplayName);
            });

            ViewBag.PersonTypes = mps;

            //// footage types
            propTyp = new PropertyType(SiteEnums.PropertyTypeCode.FOOTG);
            mps = new MultiProperties(propTyp.PropertyTypeID);
            mps.Sort(delegate(MultiProperty p1, MultiProperty p2)
            {
                return p1.DisplayName.CompareTo(p2.DisplayName);
            });
            addList = new MultiProperties();

            ViewBag.FootageTypes = mps;

            return View();
        }