Example #1
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            if (User == null)
            {
                YafBuildLink.AccessDenied();
            }

            if (!IsPostBack)
            {
                Send.Text  = GetText("SEND");
                From.Text  = PageContext.User.UserName;
                Email.Text = PageContext.User.Email;

                // get user data...
                MembershipUser user = UserMembershipHelper.GetMembershipUserById(UserID);

                if (user == null)
                {
                    YafBuildLink.AccessDenied(/*No such user exists*/);
                }

                string displayName = UserMembershipHelper.GetDisplayNameFromID(UserID);

                PageLinks.AddLink(PageContext.BoardSettings.Name, YafBuildLink.GetLink(ForumPages.forum));
                PageLinks.AddLink(!string.IsNullOrEmpty(displayName) ? displayName : user.UserName, YafBuildLink.GetLink(ForumPages.profile, "u={0}", UserID));
                PageLinks.AddLink(GetText("TITLE"), "");

                // get full user data...
                CombinedUserDataHelper userData = new CombinedUserDataHelper(user, UserID);

                ViewState ["to"] = userData.Profile.ICQ;
                Status.Src       = "http://web.icq.com/whitepages/online?icq={0}&img=5".FormatWith(userData.Profile.ICQ);
            }
        }
Example #2
0
        /// <summary>
        /// The page_ load.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        protected void Page_Load([NotNull] object sender, [NotNull] EventArgs e)
        {
            if (this.User == null)
            {
                YafBuildLink.AccessDenied();
            }

            if (!this.IsPostBack)
            {
                // get user data...
                MembershipUser user = UserMembershipHelper.GetMembershipUserById(this.UserID);

                if (user == null)
                {
                    YafBuildLink.AccessDenied(/*No such user exists*/);
                }

                string displayName = UserMembershipHelper.GetDisplayNameFromID(this.UserID);

                this.PageLinks.AddLink(this.PageContext.BoardSettings.Name, YafBuildLink.GetLink(ForumPages.forum));
                this.PageLinks.AddLink(
                    this.PageContext.BoardSettings.EnableDisplayName
             ? displayName : user.UserName,
                    YafBuildLink.GetLink(ForumPages.profile, "u={0}", this.UserID));
                this.PageLinks.AddLink(this.GetText("TITLE"), string.Empty);

                // get full user data...
                var userData = new CombinedUserDataHelper(user, this.UserID);

                this.Msg.NavigateUrl   = "aim:goim?screenname={0}&message=Hi.+Are+you+there?".FormatWith(userData.Profile.AIM);
                this.Buddy.NavigateUrl = "aim:addbuddy?screenname={0}".FormatWith(userData.Profile.AIM);
            }
        }
Example #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (User == null)
            {
                YafBuildLink.AccessDenied();
            }

            if (!IsPostBack)
            {
                // get user data...
                MembershipUser user = UserMembershipHelper.GetMembershipUserById(UserID);

                if (user == null)
                {
                    YafBuildLink.AccessDenied(/*No such user exists*/);
                }

                string displayName = UserMembershipHelper.GetDisplayNameFromID(UserID);

                PageLinks.AddLink(PageContext.BoardSettings.Name, YafBuildLink.GetLink(ForumPages.forum));
                PageLinks.AddLink(!string.IsNullOrEmpty(displayName) ? displayName : user.UserName, YafBuildLink.GetLink(ForumPages.profile, "u={0}", UserID));
                PageLinks.AddLink(GetText("TITLE"), "");

                // get full user data...
                CombinedUserDataHelper userData = new CombinedUserDataHelper(user, UserID);

                Msg.NavigateUrl = "msnim:chat?contact={0}".FormatWith(userData.Profile.MSN);
                //Msg.Attributes.Add( "onclick", "return skypeCheck();" );
                Img.Src = "http://messenger.services.live.com/users/{0}/presenceimage".FormatWith(userData.Profile.MSN);
            }
        }
        /// <summary>
        /// The btn reset password_ click.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        protected void btnResetPassword_Click([NotNull] object sender, [NotNull] EventArgs e)
        {
            // reset password...
            try
            {
                MembershipUser user = UserMembershipHelper.GetMembershipUserById(this.CurrentUserID.Value);

                if (user != null)
                {
                    // reset the password...
                    user.UnlockUser();
                    string newPassword = user.ResetPassword();

                    // email a notification...
                    var passwordRetrieval = new YafTemplateEmail("PASSWORDRETRIEVAL");

                    string subject =
                        this.Get <ILocalization>().GetText("RECOVER_PASSWORD", "PASSWORDRETRIEVAL_EMAIL_SUBJECT").FormatWith(
                            this.PageContext.BoardSettings.Name);

                    passwordRetrieval.TemplateParams["{username}"]  = user.UserName;
                    passwordRetrieval.TemplateParams["{password}"]  = newPassword;
                    passwordRetrieval.TemplateParams["{forumname}"] = this.Get <YafBoardSettings>().Name;
                    passwordRetrieval.TemplateParams["{forumlink}"] = "{0}".FormatWith(YafForumInfo.ForumURL);

                    passwordRetrieval.SendEmail(new MailAddress(user.Email, user.UserName), subject, true);

                    this.PageContext.AddLoadMessage(this.Get <ILocalization>().GetText("ADMIN_EDITUSER", "MSG_PASS_RESET"));
                }
            }
            catch (Exception x)
            {
                this.PageContext.AddLoadMessage("Exception: {0}".FormatWith(x.Message));
            }
        }
Example #5
0
        /// <summary>
        /// The page_ load.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        protected void Page_Load([NotNull] object sender, [NotNull] EventArgs e)
        {
            if (this.User == null)
            {
                YafBuildLink.AccessDenied();
            }

            if (!this.IsPostBack)
            {
                // get user data...
                MembershipUser user = UserMembershipHelper.GetMembershipUserById(this.UserID);

                if (user == null)
                {
                    YafBuildLink.AccessDenied(/*No such user exists*/);
                }

                string displayName = UserMembershipHelper.GetDisplayNameFromID(this.UserID);

                this.PageLinks.AddLink(this.PageContext.BoardSettings.Name, YafBuildLink.GetLink(ForumPages.forum));
                this.PageLinks.AddLink(this.PageContext.BoardSettings.EnableDisplayName
            ?  displayName : user.UserName,
                                       YafBuildLink.GetLink(ForumPages.profile, "u={0}", this.UserID));
                this.PageLinks.AddLink(this.GetText("TITLE"), string.Empty);

                // get full user data...
                var userData = new CombinedUserDataHelper(user, this.UserID);

                this.Img.Src         = "http://opi.yahoo.com/online?u={0}&m=g&t=2".FormatWith(userData.Profile.YIM);
                this.Msg.NavigateUrl =
                    "http://edit.yahoo.com/config/send_webmesg?.target={0}&.src=pg".FormatWith(userData.Profile.YIM);
            }
        }
Example #6
0
        /// <summary>
        /// Handles the Load event of the Page control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void Page_Load([NotNull] object sender, [NotNull] EventArgs e)
        {
            this.PageContext.QueryIDs = new QueryStringIDHelper("u", true);

            DataTable dt = LegacyDb.user_list(this.PageContext.PageBoardID, this.CurrentUserID, null);

            if (dt.Rows.Count != 1)
            {
                return;
            }

            DataRow userRow = dt.Rows[0];

            // do admin permission check...
            if (!this.PageContext.IsHostAdmin && this.IsUserHostAdmin(userRow))
            {
                // user is not host admin and is attempted to edit host admin account...
                YafBuildLink.AccessDenied();
            }

            if (this.IsPostBack)
            {
                return;
            }

            this.PageLinks.AddRoot();
            this.PageLinks.AddLink(
                this.GetText("ADMIN_ADMIN", "Administration"), YafBuildLink.GetLink(ForumPages.admin_admin));

            this.PageLinks.AddLink(this.GetText("ADMIN_USERS", "TITLE"), YafBuildLink.GetLink(ForumPages.admin_users));

            var userName = this.Get <YafBoardSettings>().EnableDisplayName
                               ? userRow["DisplayName"].ToString()
                               : userRow["Name"].ToString();

            var header = this.GetText("ADMIN_EDITUSER", "TITLE").FormatWith(userName);

            this.Header.Text = this.Header2.Text = header;

            // current page label (no link)
            this.PageLinks.AddLink(
                header,
                string.Empty);

            this.Page.Header.Title = "{0} - {1} - {2}".FormatWith(
                this.GetText("ADMIN_ADMIN", "Administration"),
                this.GetText("ADMIN_USERS", "TITLE"),
                this.GetText("ADMIN_EDITUSER", "TITLE").FormatWith(userName));

            // do a quick user membership sync...
            MembershipUser user = UserMembershipHelper.GetMembershipUserById(this.CurrentUserID);

            // update if the user is not Guest
            if (!this.IsGuestUser)
            {
                RoleMembershipHelper.UpdateForumUser(user, this.PageContext.PageBoardID);
            }

            this.EditUserTabs.DataBind();
        }
Example #7
0
        /// <summary>
        /// The page_ load.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        protected void Page_Load([NotNull] object sender, [NotNull] EventArgs e)
        {
            if (this.User == null)
            {
                YafBuildLink.AccessDenied();
            }

            if (!this.IsPostBack)
            {
                // get user data...
                MembershipUser user = UserMembershipHelper.GetMembershipUserById(this.UserID);

                if (user == null)
                {
                    YafBuildLink.AccessDenied(/*No such user exists*/);
                }

                string displayName = UserMembershipHelper.GetDisplayNameFromID(this.UserID);

                this.PageLinks.AddLink(this.PageContext.BoardSettings.Name, YafBuildLink.GetLink(ForumPages.forum));
                this.PageLinks.AddLink(
                    this.PageContext.BoardSettings.EnableDisplayName
             ? displayName : user.UserName,
                    YafBuildLink.GetLink(ForumPages.profile, "u={0}", this.UserID));
                this.PageLinks.AddLink(this.GetText("TITLE"), string.Empty);

                // get full user data...
                var userData = new CombinedUserDataHelper(user, this.UserID);

                this.Msg.NavigateUrl = "skype:{0}?call".FormatWith(userData.Profile.Skype);
                this.Msg.Attributes.Add("onclick", "return skypeCheck();");
                this.Img.Src = "http://mystatus.skype.com/bigclassic/{0}".FormatWith(userData.Profile.Skype);
            }
        }
Example #8
0
        /// <summary>
        /// Handles the Click event of the Send control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        protected void Send_Click([NotNull] object sender, [NotNull] EventArgs e)
        {
            try
            {
                // get "to" user...
                var toUser = UserMembershipHelper.GetMembershipUserById(this.UserId);

                // send it...
                this.Get <ISendMail>()
                .Send(
                    new MailAddress(this.PageContext.User.Email, this.PageContext.User.UserName),
                    new MailAddress(toUser.Email.Trim(), toUser.UserName.Trim()),
                    new MailAddress(this.PageContext.BoardSettings.ForumEmail, this.PageContext.BoardSettings.Name),
                    this.Subject.Text.Trim(),
                    this.Body.Text.Trim());

                // redirect to profile page...
                YafBuildLink.Redirect(ForumPages.profile, false, "u={0}", this.UserId);
            }
            catch (Exception x)
            {
                this.Logger.Log(this.PageContext.PageUserID, this, x);

                this.PageContext.AddLoadMessage(this.PageContext.IsAdmin ? x.Message : this.GetText("ERROR"));
            }
        }
Example #9
0
        protected void btnResetPassword_Click(object sender, EventArgs e)
        {
            // reset password...
            try
            {
                MembershipUser user = UserMembershipHelper.GetMembershipUserById(CurrentUserID.Value);

                if (user != null)
                {
                    // reset the password...
                    user.UnlockUser();
                    string newPassword = user.ResetPassword();

                    // email a notification...
                    YafTemplateEmail passwordRetrieval = new YafTemplateEmail("PASSWORDRETRIEVAL");

                    string subject = this.PageContext.Localization.GetText("RECOVER_PASSWORD", "PASSWORDRETRIEVAL_EMAIL_SUBJECT").FormatWith(this.PageContext.BoardSettings.Name);

                    passwordRetrieval.TemplateParams["{username}"]  = user.UserName;
                    passwordRetrieval.TemplateParams["{password}"]  = newPassword;
                    passwordRetrieval.TemplateParams["{forumname}"] = PageContext.BoardSettings.Name;
                    passwordRetrieval.TemplateParams["{forumlink}"] = "{0}".FormatWith(YafForumInfo.ForumURL);

                    passwordRetrieval.SendEmail(new System.Net.Mail.MailAddress(user.Email, user.UserName), subject, true);

                    PageContext.AddLoadMessage("User Password Reset and Notification Email Sent");
                }
            }
            catch (Exception x)
            {
                PageContext.AddLoadMessage("Exception: " + x.Message);
            }
        }
Example #10
0
        /// <summary>
        /// Handles the Load event of the Page control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        protected void Page_Load([NotNull] object sender, [NotNull] EventArgs e)
        {
            if (this.User == null || !this.Get <YafBoardSettings>().AllowEmailSending)
            {
                YafBuildLink.AccessDenied();
            }

            if (this.IsPostBack)
            {
                return;
            }

            // get user data...
            var user = UserMembershipHelper.GetMembershipUserById(this.UserId);

            if (user == null)
            {
                YafBuildLink.AccessDenied(/*No such user exists*/);
            }
            else
            {
                var displayName = UserMembershipHelper.GetDisplayNameFromID(this.UserId);

                this.PageLinks.AddRoot();
                this.PageLinks.AddLink(
                    this.PageContext.BoardSettings.EnableDisplayName ? displayName : user.UserName,
                    YafBuildLink.GetLink(
                        ForumPages.profile,
                        "u={0}&name={1}",
                        this.UserId,
                        this.PageContext.BoardSettings.EnableDisplayName ? displayName : user.UserName));
                this.PageLinks.AddLink(this.GetText("TITLE"), string.Empty);
            }
        }
Example #11
0
        /// <summary>
        /// The page_ load.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        protected void Page_Load([NotNull] object sender, [NotNull] EventArgs e)
        {
            if (this.User == null || !this.PageContext.BoardSettings.AllowEmailSending)
            {
                YafBuildLink.AccessDenied();
            }

            if (!this.IsPostBack)
            {
                // get user data...
                MembershipUser user = UserMembershipHelper.GetMembershipUserById(this.UserID);

                if (user == null)
                {
                    YafBuildLink.AccessDenied(/*No such user exists*/);
                }

                string displayName = UserMembershipHelper.GetDisplayNameFromID(this.UserID);

                this.PageLinks.AddLink(this.PageContext.BoardSettings.Name, YafBuildLink.GetLink(ForumPages.forum));
                this.PageLinks.AddLink(
                    !string.IsNullOrEmpty(displayName) ? displayName : user.UserName,
                    YafBuildLink.GetLink(ForumPages.profile, "u={0}", this.UserID));
                this.PageLinks.AddLink(this.GetText("TITLE"), string.Empty);

                this.Send.Text = this.GetText("SEND");
            }
        }
Example #12
0
        /// <summary>
        /// The send_ click.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        protected void Send_Click([NotNull] object sender, [NotNull] EventArgs e)
        {
            try
            {
                // get "to" user...
                MembershipUser toUser = UserMembershipHelper.GetMembershipUserById(this.UserID);

                // send it...
                this.Get <YafSendMail>().Send(
                    new MailAddress(this.PageContext.User.Email, this.PageContext.User.UserName),
                    new MailAddress(toUser.Email.Trim(), toUser.UserName.Trim()),
                    this.Subject.Text.Trim(),
                    this.Body.Text.Trim());

                // redirect to profile page...
                YafBuildLink.Redirect(ForumPages.profile, "u={0}", this.UserID);
            }
            catch (Exception x)
            {
                DB.eventlog_create(this.PageContext.PageUserID, this, x);
                if (this.PageContext.IsAdmin)
                {
                    this.PageContext.AddLoadMessage(x.Message);
                }
                else
                {
                    this.PageContext.AddLoadMessage(this.GetText("ERROR"));
                }
            }
        }
Example #13
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            if (User == null)
            {
                YafBuildLink.AccessDenied();
            }

            if (!IsPostBack)
            {
                // get user data...
                MembershipUser user = UserMembershipHelper.GetMembershipUserById(UserID);

                if (user == null)
                {
                    YafBuildLink.AccessDenied(/*No such user exists*/);
                }

                string displayName = UserMembershipHelper.GetDisplayNameFromID(UserID);

                PageLinks.AddLink(PageContext.BoardSettings.Name, YafBuildLink.GetLink(ForumPages.forum));
                PageLinks.AddLink(!string.IsNullOrEmpty(displayName) ? displayName : user.UserName, YafBuildLink.GetLink(ForumPages.profile, "u={0}", UserID));
                PageLinks.AddLink(GetText("TITLE"), "");

                // get full user data...
                CombinedUserDataHelper userData = new CombinedUserDataHelper(user, UserID);

                Msg.NavigateUrl   = "aim:goim?screenname={0}&message=Hi.+Are+you+there?".FormatWith(userData.Profile.AIM);
                Buddy.NavigateUrl = "aim:addbuddy?screenname={0}".FormatWith(userData.Profile.AIM);
            }
        }
Example #14
0
        /// <summary>
        /// The btn change password_ click.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        protected void btnChangePassword_Click([NotNull] object sender, [NotNull] EventArgs e)
        {
            if (!this.Page.IsValid)
            {
                return;
            }

            // change password...
            try
            {
                var user = UserMembershipHelper.GetMembershipUserById(this.CurrentUserID.Value);

                if (user == null)
                {
                    return;
                }

                // new password...
                var newPass = this.txtNewPassword.Text.Trim();

                // reset the password...
                user.UnlockUser();
                var tempPass = user.ResetPassword();

                // change to new password...
                user.ChangePassword(tempPass, newPass);

                if (this.chkEmailNotify.Checked)
                {
                    // email a notification...
                    var passwordRetrieval = new YafTemplateEmail("PASSWORDRETRIEVAL");

                    var subject = string.Format(
                        this.Get <ILocalization>().GetText("RECOVER_PASSWORD", "PASSWORDRETRIEVAL_EMAIL_SUBJECT"),
                        this.PageContext.BoardSettings.Name);

                    passwordRetrieval.TemplateParams["{username}"]  = user.UserName;
                    passwordRetrieval.TemplateParams["{password}"]  = newPass;
                    passwordRetrieval.TemplateParams["{forumname}"] = this.Get <YafBoardSettings>().Name;
                    passwordRetrieval.TemplateParams["{forumlink}"] = $"{YafForumInfo.ForumURL}";

                    passwordRetrieval.SendEmail(new MailAddress(user.Email, user.UserName), subject, true);

                    this.PageContext.AddLoadMessage(
                        this.Get <ILocalization>().GetText("ADMIN_EDITUSER", "MSG_PASS_CHANGED_NOTI"));
                }
                else
                {
                    this.PageContext.AddLoadMessage(
                        this.Get <ILocalization>().GetText("ADMIN_EDITUSER", "MSG_PASS_CHANGED"));
                }
            }
            catch (Exception x)
            {
                this.PageContext.AddLoadMessage($"Exception: {x.Message}");
            }
        }
Example #15
0
        /// <summary>
        /// The page_ load.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        protected void Page_Load([NotNull] object sender, [NotNull] EventArgs e)
        {
            if (this.User == null)
            {
                YafBuildLink.AccessDenied();
            }

            if (!this.IsPostBack)
            {
                // get user data...
                var userHe = UserMembershipHelper.GetMembershipUserById(this.UserID);

                var displayNameHe = UserMembershipHelper.GetDisplayNameFromID(this.UserID);

                this.PageLinks.AddLink(this.PageContext.BoardSettings.Name, YafBuildLink.GetLink(ForumPages.forum));
                this.PageLinks.AddLink(
                    this.PageContext.BoardSettings.EnableDisplayName ? displayNameHe : userHe.UserName,
                    YafBuildLink.GetLink(
                        ForumPages.profile,
                        "u={0}&name={1}",
                        this.UserID,
                        this.PageContext.BoardSettings.EnableDisplayName ? displayNameHe : userHe.UserName));
                this.PageLinks.AddLink(this.GetText("TITLE"), string.Empty);

                if (this.UserID == this.PageContext.PageUserID)
                {
                    this.NotifyLabel.Text = this.GetText("SERVERYOU");
                    this.Alert.Type       = MessageTypes.warning;
                }
                else
                {
                    if (userHe == null)
                    {
                        YafBuildLink.AccessDenied(/*No such user exists*/);
                    }

                    // Data for current page user
                    var userMe = UserMembershipHelper.GetMembershipUserById(this.PageContext.PageUserID);

                    // get full user data...
                    var userDataHe = new CombinedUserDataHelper(userHe, this.UserID);
                    var userDataMe = new CombinedUserDataHelper(userMe, this.PageContext.PageUserID);

                    var serverHe = userDataHe.Profile.XMPP
                                   .Substring(userDataHe.Profile.XMPP.IndexOf("@", StringComparison.Ordinal) + 1).Trim();
                    var serverMe = userDataMe.Profile.XMPP
                                   .Substring(userDataMe.Profile.XMPP.IndexOf("@", StringComparison.Ordinal) + 1).Trim();

                    this.NotifyLabel.Text = serverMe == serverHe
                                                ? this.GetTextFormatted("SERVERSAME", userDataHe.Profile.XMPP)
                                                : this.GetTextFormatted("SERVEROTHER", $"http://{serverHe}");

                    this.Alert.Type = MessageTypes.info;
                }
            }
        }
Example #16
0
        /// <summary>
        /// Handles the Load event of the Page control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void Page_Load([NotNull] object sender, [NotNull] EventArgs e)
        {
            this.PageContext.QueryIDs = new QueryStringIDHelper("u", true);

            var dt = this.GetRepository <User>().ListAsDataTable(this.PageContext.PageBoardID, this.CurrentUserId, null);

            if (dt.Rows.Count != 1)
            {
                return;
            }

            var userRow = dt.Rows[0];

            // do admin permission check...
            if (!this.PageContext.IsHostAdmin && this.IsUserHostAdmin(userRow))
            {
                // user is not host admin and is attempted to edit host admin account...
                BuildLink.AccessDenied();
            }

            if (this.IsPostBack)
            {
                return;
            }

            var userName = this.HtmlEncode(this.Get <BoardSettings>().EnableDisplayName
                               ? userRow["DisplayName"].ToString()
                               : userRow["Name"].ToString());

            var header = string.Format(this.GetText("ADMIN_EDITUSER", "TITLE"), userName);

            this.Header.Text = this.Header2.Text = header;

            // current page label (no link)
            this.PageLinks.AddLink(
                header,
                string.Empty);

            this.Page.Header.Title =
                $"{this.GetText("ADMIN_ADMIN", "Administration")} - {this.GetText("ADMIN_USERS", "TITLE")} - {string.Format(this.GetText("ADMIN_EDITUSER", "TITLE"), userName)}";

            // do a quick user membership sync...
            var user = UserMembershipHelper.GetMembershipUserById(this.CurrentUserId);

            // update if the user is not Guest
            if (!this.IsGuestUser)
            {
                RoleMembershipHelper.UpdateForumUser(user, this.PageContext.PageBoardID);
            }

            this.EditUserTabs.DataBind();
        }
        /// <summary>
        /// Reset the User Password
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        protected void btnResetPassword_Click([NotNull] object sender, [NotNull] EventArgs e)
        {
            // reset password...
            try
            {
                var user = UserMembershipHelper.GetMembershipUserById(this.CurrentUserID.Value);

                if (user == null)
                {
                    return;
                }

                // reset the password...
                user.UnlockUser();
                var newPassword = user.ResetPassword();

                var subject = this.GetTextFormatted(
                    "PASSWORDRETRIEVAL_EMAIL_SUBJECT",
                    this.Get <BoardSettings>().Name);
                var logoUrl =
                    $"{BoardInfo.ForumClientFileRoot}{BoardFolders.Current.Logos}/{this.PageContext.BoardSettings.ForumLogo}";
                var themeCss =
                    $"{this.Get<BoardSettings>().BaseUrlMask}{this.Get<ITheme>().BuildThemePath("bootstrap-forum.min.css")}";

                // email a notification...
                var passwordRetrieval = new TemplateEmail("PASSWORDRETRIEVAL_ADMIN")
                {
                    TemplateParams =
                    {
                        ["{username}"]  = user.UserName,
                        ["{password}"]  = newPassword,
                        ["{forumname}"] = this.Get <BoardSettings>().Name,
                        ["{forumlink}"] = BoardInfo.ForumURL,
                        ["{themecss}"]  = themeCss,
                        ["{logo}"]      =
                            $"{this.Get<BoardSettings>().BaseUrlMask}{logoUrl}"
                    }
                };

                passwordRetrieval.SendEmail(new MailAddress(user.Email, user.UserName), subject);

                this.PageContext.AddLoadMessage(
                    this.Get <ILocalization>().GetText("ADMIN_EDITUSER", "MSG_PASS_RESET"),
                    MessageTypes.success);
            }
            catch (Exception x)
            {
                this.PageContext.AddLoadMessage($"Exception: {x.Message}", MessageTypes.danger);
            }
        }
Example #18
0
        /// <summary>
        /// The page_ load.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        protected void Page_Load(object sender, EventArgs e)
        {
            if (User == null)
            {
                YafBuildLink.AccessDenied();
            }

            if (!IsPostBack)
            {
                // get user data...
                MembershipUser userHe = UserMembershipHelper.GetMembershipUserById(this.UserID);

                string displayNameHe = UserMembershipHelper.GetDisplayNameFromID(this.UserID);

                this.PageLinks.AddLink(PageContext.BoardSettings.Name, YafBuildLink.GetLink(ForumPages.forum));
                this.PageLinks.AddLink(!string.IsNullOrEmpty(displayNameHe) ? displayNameHe : userHe.UserName, YafBuildLink.GetLink(ForumPages.profile, "u={0}", this.UserID));
                this.PageLinks.AddLink(GetText("TITLE"), string.Empty);

                if (this.UserID == PageContext.PageUserID)
                {
                    NotifyLabel.Text = GetText("SERVERYOU");
                }
                else
                {
                    if (userHe == null)
                    {
                        YafBuildLink.AccessDenied(/*No such user exists*/);
                    }

                    // Data for current page user
                    MembershipUser userMe = UserMembershipHelper.GetMembershipUserById(PageContext.PageUserID);

                    // get full user data...
                    var userDataHe = new CombinedUserDataHelper(userHe, this.UserID);
                    var userDataMe = new CombinedUserDataHelper(userMe, PageContext.PageUserID);

                    string serverHe = userDataHe.Profile.XMPP.Substring(userDataHe.Profile.XMPP.IndexOf("@") + 1).Trim();
                    string serverMe = userDataMe.Profile.XMPP.Substring(userDataMe.Profile.XMPP.IndexOf("@") + 1).Trim();
                    if (serverMe == serverHe)
                    {
                        NotifyLabel.Text = GetTextFormatted("SERVERSAME", userDataHe.Profile.XMPP);
                    }
                    else
                    {
                        NotifyLabel.Text = GetTextFormatted("SERVEROTHER", "http://" + serverHe);
                    }
                }
            }
        }
Example #19
0
        /// <summary>
        /// The kill_ on click.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        protected void Kill_OnClick(object sender, EventArgs e)
        {
            if (this.BanIps.Checked)
            {
                BanUserIps();
            }

            DeletePosts();

            MembershipUser user = UserMembershipHelper.GetMembershipUserById(CurrentUserID);

            PageContext.AddLoadMessage("User {0} Killed!".FormatWith(user.UserName));

            // update the displayed data...
            BindData();
        }
Example #20
0
        /// <summary>
        /// The kill_ on click.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        protected void Kill_OnClick([NotNull] object sender, [NotNull] EventArgs e)
        {
            if (this.BanIps.Checked)
            {
                this.BanUserIps();
            }

            this.DeletePosts();

            MembershipUser user = UserMembershipHelper.GetMembershipUserById(this.CurrentUserID);

            this.PageContext.AddLoadMessage(this.Get <ILocalization>().GetText("ADMIN_EDITUSER", "MSG_USER_KILLED").FormatWith(user.UserName));

            // update the displayed data...
            this.BindData();
        }
Example #21
0
        /// <summary>
        /// Reports the User
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        protected void Report_OnClick([NotNull] object sender, [NotNull] EventArgs e)
        {
            if (this.Get <YafBoardSettings>().StopForumSpamApiKey.IsNotSet())
            {
                return;
            }

            var user = UserMembershipHelper.GetMembershipUserById(this.CurrentUserID);

            try
            {
                var stopForumSpam = new StopForumSpam();

                if (!stopForumSpam.ReportUserAsBot(this.IPAddresses.FirstOrDefault(), user.Email, user.UserName))
                {
                    return;
                }

                this.PageContext.AddLoadMessage(this.GetText("ADMIN_EDITUSER", "BOT_REPORTED"), MessageTypes.Success);

                this.Logger.Log(
                    this.PageContext.PageUserID,
                    "User Reported to StopForumSpam.com",
                    "User (Name:{0}/ID:{1}/IP:{2}/Email:{3}) Reported to StopForumSpam.com by {4}".FormatWith(
                        user.UserName,
                        this.CurrentUserID,
                        this.IPAddresses.FirstOrDefault(),
                        user.Email,
                        this.Get <YafBoardSettings>().EnableDisplayName
                            ? this.PageContext.CurrentUserData.DisplayName
                            : this.PageContext.CurrentUserData.UserName),
                    EventLogTypes.SpamBotReported);
            }
            catch (Exception exception)
            {
                this.PageContext.AddLoadMessage(
                    this.GetText("ADMIN_EDITUSER", "BOT_REPORTED_FAILED"),
                    MessageTypes.Error);

                this.Logger.Log(
                    this.PageContext.PageUserID,
                    "User (Name{0}/ID:{1}) Report to StopForumSpam.com Failed".FormatWith(
                        user.UserName,
                        this.CurrentUserID),
                    exception);
            }
        }
Example #22
0
        /// <summary>
        /// Handles the Load event of the Page control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        protected void Page_Load([NotNull] object sender, [NotNull] EventArgs e)
        {
            if (!this.Get <BoardSettings>().EnableAlbum)
            {
                BuildLink.AccessDenied();
            }

            if (!this.Get <HttpRequestBase>().QueryString.Exists("u"))
            {
                BuildLink.AccessDenied();
            }

            var user = UserMembershipHelper.GetMembershipUserById(
                Security.StringToLongOrRedirect(this.Get <HttpRequestBase>().QueryString.GetFirstOrDefault("u")));

            if (user == null)
            {
                // No such user exists
                BuildLink.AccessDenied();
            }

            if (user.IsApproved == false)
            {
                BuildLink.AccessDenied();
            }

            var displayName = UserMembershipHelper.GetDisplayNameFromID(
                Security.StringToLongOrRedirect(this.Get <HttpRequestBase>().QueryString.GetFirstOrDefault("u")));

            // Generate the Page Links.
            this.PageLinks.Clear();
            this.PageLinks.AddRoot();
            this.PageLinks.AddLink(
                this.Get <BoardSettings>().EnableDisplayName
                    ? displayName
                    : UserMembershipHelper.GetUserNameFromID(
                    Security.StringToLongOrRedirect(
                        this.Get <HttpRequestBase>().QueryString.GetFirstOrDefault("u"))),
                BuildLink.GetLink(
                    ForumPages.profile,
                    "u={0}",
                    this.Get <HttpRequestBase>().QueryString.GetFirstOrDefault("u")));
            this.PageLinks.AddLink(this.GetText("ALBUMS"), string.Empty);

            // Initialize the Album List control.
            this.AlbumList1.UserID = this.Get <HttpRequestBase>().QueryString.GetFirstOrDefault("u").ToType <int>();
        }
Example #23
0
        /// <summary>
        /// The page_ load.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        protected void Page_Load(object sender, EventArgs e)
        {
            // init ids...
            PageContext.QueryIDs = new QueryStringIDHelper("u", true);

            // this needs to be done just once, not during postbacks
            if (!IsPostBack)
            {
                MembershipUser user     = UserMembershipHelper.GetMembershipUserById(CurrentUserID);
                var            userData = new CombinedUserDataHelper(user, (int)CurrentUserID.Value);

                this.ViewPostsLink.NavigateUrl = YafBuildLink.GetLinkNotEscaped(ForumPages.search, "postedby={0}", !userData.IsGuest ? userData.Membership.UserName : (!userData.DisplayName.IsNotSet() ? userData.DisplayName : userData.UserName));

                // bind data
                BindData();
            }
        }
Example #24
0
        /// <summary>
        /// The page_ load.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        protected void Page_Load(object sender, EventArgs e)
        {
            // we're in the admin section...
            ProfileEditControl.InAdminPages   = true;
            SignatureEditControl.InAdminPages = true;
            AvatarEditControl.InAdminPages    = true;

            PageContext.QueryIDs = new QueryStringIDHelper("u", true);

            DataTable dt = DB.user_list(PageContext.PageBoardID, CurrentUserID, null);

            if (dt.Rows.Count == 1)
            {
                DataRow userRow = dt.Rows[0];

                // do admin permission check...
                if (!PageContext.IsHostAdmin && IsUserHostAdmin(userRow))
                {
                    // user is not host admin and is attempted to edit host admin account...
                    YafBuildLink.AccessDenied();
                }

                if (!IsPostBack)
                {
                    this.PageLinks.AddLink(PageContext.BoardSettings.Name, YafBuildLink.GetLink(ForumPages.forum));
                    this.PageLinks.AddLink("Administration", YafBuildLink.GetLink(ForumPages.admin_admin));
                    this.PageLinks.AddLink("Users", YafBuildLink.GetLink(ForumPages.admin_users));
                    this.PageLinks.AddLink("Edit User \"{0}\"".FormatWith(userRow["Name"].ToString()));

                    // do a quick user membership sync...
                    MembershipUser user = UserMembershipHelper.GetMembershipUserById(CurrentUserID);

                    // update if the user is not Guest
                    if (!IsGuestUser)
                    {
                        RoleMembershipHelper.UpdateForumUser(user, PageContext.PageBoardID);
                    }

                    EditUserTabs.DataBind();
                }
            }
        }
Example #25
0
        /// <summary>
        /// The page_ load.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        protected void Page_Load([NotNull] object sender, [NotNull] EventArgs e)
        {
            if (this.User == null)
            {
                YafBuildLink.AccessDenied();
            }

            if (!this.IsPostBack)
            {
                this.Send.Text  = this.GetText("SEND");
                this.From.Text  = this.PageContext.User.UserName;
                this.Email.Text = this.PageContext.User.Email;

                // get user data...
                MembershipUser user = UserMembershipHelper.GetMembershipUserById(this.UserID);

                if (user == null)
                {
                    YafBuildLink.AccessDenied(/*No such user exists*/);
                }

                string displayName = UserMembershipHelper.GetDisplayNameFromID(this.UserID);

                this.PageLinks.AddLink(this.PageContext.BoardSettings.Name, YafBuildLink.GetLink(ForumPages.forum));
                this.PageLinks.AddLink(
                    this.PageContext.BoardSettings.EnableDisplayName ? displayName : user.UserName,
                    YafBuildLink.GetLink(
                        ForumPages.profile,
                        "u={0}&name={1}",
                        this.UserID,
                        this.PageContext.BoardSettings.EnableDisplayName ? displayName : user.UserName));
                this.PageLinks.AddLink(this.GetText("TITLE"), string.Empty);

                // get full user data...
                var userData = new CombinedUserDataHelper(user, this.UserID);

                this.ViewState["to"] = userData.Profile.ICQ;
                this.Status.Src      = "http://web.icq.com/whitepages/online?icq={0}&img=5".FormatWith(userData.Profile.ICQ);
            }
        }
Example #26
0
        /// <summary>
        /// The page_ load.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        protected void Page_Load([NotNull] object sender, [NotNull] EventArgs e)
        {
            if (this.User == null)
            {
                YafBuildLink.AccessDenied();
            }

            if (!this.IsPostBack)
            {
                // get user data...
                var user = UserMembershipHelper.GetMembershipUserById(this.UserID);

                if (user == null)
                {
                    YafBuildLink.AccessDenied(/*No such user exists*/);
                }

                var displayName = UserMembershipHelper.GetDisplayNameFromID(this.UserID);

                this.PageLinks.AddLink(this.PageContext.BoardSettings.Name, YafBuildLink.GetLink(ForumPages.forum));
                this.PageLinks.AddLink(
                    this.PageContext.BoardSettings.EnableDisplayName ? displayName : user.UserName,
                    YafBuildLink.GetLink(
                        ForumPages.profile,
                        "u={0}&name={1}",
                        this.UserID,
                        this.PageContext.BoardSettings.EnableDisplayName ? displayName : user.UserName));
                this.PageLinks.AddLink(this.GetText("TITLE"), string.Empty);

                // get full user data...
                var userData = new CombinedUserDataHelper(user, this.UserID);

                this.Msg.NavigateUrl = "msnim:chat?contact={0}".FormatWith(userData.Profile.MSN);

                // Msg.Attributes.Add( "onclick", "return skypeCheck();" );
                this.Img.Src = "http://messenger.services.live.com/users/{0}/presenceimage".FormatWith(userData.Profile.MSN);
            }
        }
Example #27
0
        /// <summary>
        /// The page_ load.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        protected void Page_Load([NotNull] object sender, [NotNull] EventArgs e)
        {
            // init ids...
            this.PageContext.QueryIDs = new QueryStringIDHelper("u", true);

            // this needs to be done just once, not during postbacks
            if (this.IsPostBack)
            {
                return;
            }

            MembershipUser user     = UserMembershipHelper.GetMembershipUserById(this.CurrentUserID);
            var            userData = new CombinedUserDataHelper(user, (int)this.CurrentUserID.Value);

            this.ViewPostsLink.NavigateUrl = YafBuildLink.GetLinkNotEscaped(
                ForumPages.search,
                "postedby={0}",
                !userData.IsGuest ? (this.Get <YafBoardSettings>().EnableDisplayName ? userData.DisplayName : userData.UserName)
            : (UserMembershipHelper.GuestUserName));

            // bind data
            this.BindData();
        }
Example #28
0
        /// <summary>
        /// The bind data.
        /// </summary>
        private void BindData()
        {
            MembershipUser user = UserMembershipHelper.GetMembershipUserById(this.UserId);

            if (user == null || user.ProviderUserKey.ToString() == "0")
            {
                // No such user exists or this is an nntp user ("0")
                YafBuildLink.AccessDenied();
            }

            var userData = new CombinedUserDataHelper(user, this.UserId);

            // populate user information controls...
            // Is BuddyList feature enabled?
            if (this.Get <YafBoardSettings>().EnableBuddyList)
            {
                this.SetupBuddyList(this.UserId, userData);
            }
            else
            {
                // BuddyList feature is disabled. don't show any link.
                this.lnkBuddy.Visible    = false;
                this.ltrApproval.Visible = false;
            }

            // Is album feature enabled?
            if (this.Get <YafBoardSettings>().EnableAlbum)
            {
                this.AlbumList1.UserID = this.UserId;
            }
            else
            {
                this.AlbumList1.Dispose();
            }

            var userNameOrDisplayName = this.Get <YafBoardSettings>().EnableDisplayName
                                            ? userData.DisplayName
                                            : userData.UserName;

            this.SetupUserProfileInfo(this.UserId, user, userData, userNameOrDisplayName);

            this.AddPageLinks(userNameOrDisplayName);

            this.SetupUserStatistics(userData);

            this.SetupUserLinks(userData, userNameOrDisplayName);

            this.SetupAvatar(this.UserId, userData);

            this.Groups.DataSource = RoleMembershipHelper.GetRolesForUser(userData.UserName);

            // EmailRow.Visible = PageContext.IsAdmin;
            this.ModerateTab.Visible = this.PageContext.IsAdmin || this.PageContext.IsForumModerator;
            this.ModerateLi.Visible  = this.PageContext.IsAdmin || this.PageContext.IsForumModerator;

            this.AdminUserButton.Visible = this.PageContext.IsAdmin;

            if (this.LastPosts.Visible)
            {
                this.LastPosts.DataSource =
                    LegacyDb.post_alluser(this.PageContext.PageBoardID, this.UserId, this.PageContext.PageUserID, 10)
                    .AsEnumerable();

                this.SearchUser.NavigateUrl = YafBuildLink.GetLinkNotEscaped(
                    ForumPages.search,
                    "postedby={0}",
                    this.Get <YafBoardSettings>().EnableDisplayName ? userData.DisplayName : userData.UserName);
            }

            this.DataBind();
        }
Example #29
0
        /// <summary>
        /// Kills the User
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        protected void Kill_OnClick([NotNull] object sender, [NotNull] EventArgs e)
        {
            var user = UserMembershipHelper.GetMembershipUserById(this.CurrentUserId);

            // Ban User Email?
            if (this.BanEmail.Checked)
            {
                this.GetRepository <BannedEmail>().Save(
                    null,
                    user.Email,
                    $"Email was reported by: {(this.Get<YafBoardSettings>().EnableDisplayName ? this.PageContext.CurrentUserData.DisplayName : this.PageContext.CurrentUserData.UserName)}");
            }

            // Ban User IP?
            if (this.BanIps.Checked && this.IPAddresses.Any())
            {
                this.BanUserIps();
            }

            // Ban User IP?
            if (this.BanName.Checked)
            {
                this.GetRepository <BannedName>().Save(
                    null,
                    user.UserName,
                    $"Name was reported by: {(this.Get<YafBoardSettings>().EnableDisplayName ? this.PageContext.CurrentUserData.DisplayName : this.PageContext.CurrentUserData.UserName)}");
            }

            this.DeleteAllUserMessages();

            if (this.ReportUser.Checked && this.Get <YafBoardSettings>().StopForumSpamApiKey.IsSet() &&
                this.IPAddresses.Any())
            {
                try
                {
                    var stopForumSpam = new StopForumSpam();

                    if (stopForumSpam.ReportUserAsBot(this.IPAddresses.FirstOrDefault(), user.Email, user.UserName))
                    {
                        this.GetRepository <Registry>().IncrementReportedSpammers();

                        this.Logger.Log(
                            this.PageContext.PageUserID,
                            "User Reported to StopForumSpam.com",
                            $"User (Name:{user.UserName}/ID:{this.CurrentUserId}/IP:{this.IPAddresses.FirstOrDefault()}/Email:{user.Email}) Reported to StopForumSpam.com by {(this.Get<YafBoardSettings>().EnableDisplayName ? this.PageContext.CurrentUserData.DisplayName : this.PageContext.CurrentUserData.UserName)}",
                            EventLogTypes.SpamBotReported);
                    }
                }
                catch (Exception exception)
                {
                    this.PageContext.AddLoadMessage(
                        this.GetText("ADMIN_EDITUSER", "BOT_REPORTED_FAILED"),
                        MessageTypes.danger);

                    this.Logger.Log(
                        this.PageContext.PageUserID,
                        $"User (Name{user.UserName}/ID:{this.CurrentUserId}) Report to StopForumSpam.com Failed",
                        exception);
                }
            }

            switch (this.SuspendOrDelete.SelectedValue)
            {
            case "delete":
                if (this.CurrentUserId > 0)
                {
                    // we are deleting user
                    if (this.PageContext.PageUserID == this.CurrentUserId)
                    {
                        // deleting yourself isn't an option
                        this.PageContext.AddLoadMessage(
                            this.GetText("ADMIN_USERS", "MSG_SELF_DELETE"),
                            MessageTypes.danger);
                        return;
                    }

                    // get user(s) we are about to delete
                    using (var dt = this.GetRepository <User>().ListAsDataTable(
                               this.PageContext.PageBoardID,
                               this.CurrentUserId,
                               DBNull.Value))
                    {
                        // examine each if he's possible to delete
                        foreach (DataRow row in dt.Rows)
                        {
                            if (row["IsGuest"].ToType <int>() > 0)
                            {
                                // we cannot delete guest
                                this.PageContext.AddLoadMessage(
                                    this.GetText("ADMIN_USERS", "MSG_DELETE_GUEST"),
                                    MessageTypes.danger);
                                return;
                            }

                            if ((row["IsAdmin"] == DBNull.Value || row["IsAdmin"].ToType <int>() <= 0) &&
                                (row["IsHostAdmin"] == DBNull.Value || row["IsHostAdmin"].ToType <int>() <= 0))
                            {
                                continue;
                            }

                            // admin are not deletable either
                            this.PageContext.AddLoadMessage(
                                this.GetText("ADMIN_USERS", "MSG_DELETE_ADMIN"),
                                MessageTypes.danger);
                            return;
                        }
                    }

                    // all is good, user can be deleted
                    UserMembershipHelper.DeleteUser(this.CurrentUserId.ToType <int>());

                    YafBuildLink.Redirect(ForumPages.admin_users);
                }

                break;

            case "suspend":
                if (this.CurrentUserId > 0)
                {
                    this.GetRepository <User>().Suspend(
                        this.CurrentUserId.ToType <int>(),
                        DateTime.UtcNow.AddYears(5));
                }

                break;
            }

            this.PageContext.AddLoadMessage(
                this.GetTextFormatted("MSG_USER_KILLED", user.UserName),
                MessageTypes.success);

            // update the displayed data...
            this.BindData();
        }
Example #30
0
        /// <summary>
        /// Saves the Updated Profile
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        protected void UpdateProfile_Click([NotNull] object sender, [NotNull] EventArgs e)
        {
            var userName = UserMembershipHelper.GetUserNameFromID(this.currentUserID);

            if (this.HomePage.Text.IsSet())
            {
                // add http:// by default
                if (!Regex.IsMatch(this.HomePage.Text.Trim(), @"^(http|https|ftp|ftps|git|svn|news)\://.*"))
                {
                    this.HomePage.Text = "http://{0}".FormatWith(this.HomePage.Text.Trim());
                }

                if (!ValidationHelper.IsValidURL(this.HomePage.Text))
                {
                    this.PageContext.AddLoadMessage(this.GetText("PROFILE", "BAD_HOME"), MessageTypes.warning);
                    return;
                }

                if (this.UserData.NumPosts < this.Get <YafBoardSettings>().IgnoreSpamWordCheckPostCount)
                {
                    string result;

                    // Check for spam
                    if (this.Get <ISpamWordCheck>().CheckForSpamWord(this.HomePage.Text, out result))
                    {
                        // Log and Send Message to Admins
                        if (this.Get <YafBoardSettings>().BotHandlingOnRegister.Equals(1))
                        {
                            this.Logger.Log(
                                null,
                                "Bot Detected",
                                "Internal Spam Word Check detected a SPAM BOT: (user name : '{0}', user id : '{1}') after the user changed the profile Homepage url to: {2}"
                                .FormatWith(userName, this.currentUserID, this.HomePage.Text),
                                EventLogTypes.SpamBotDetected);
                        }
                        else if (this.Get <YafBoardSettings>().BotHandlingOnRegister.Equals(2))
                        {
                            this.Logger.Log(
                                null,
                                "Bot Detected",
                                "Internal Spam Word Check detected a SPAM BOT: (user name : '{0}', user id : '{1}') after the user changed the profile Homepage url to: {2}, user was deleted and the name, email and IP Address are banned."
                                .FormatWith(userName, this.currentUserID, this.HomePage.Text),
                                EventLogTypes.SpamBotDetected);

                            // Kill user
                            if (!this.PageContext.CurrentForumPage.IsAdminPage)
                            {
                                var user   = UserMembershipHelper.GetMembershipUserById(this.currentUserID);
                                var userId = this.currentUserID;

                                var userIp = new CombinedUserDataHelper(user, userId).LastIP;

                                UserMembershipHelper.DeleteAndBanUser(this.currentUserID, user, userIp);
                            }
                        }
                    }
                }
            }

            if (this.Weblog.Text.IsSet() && !ValidationHelper.IsValidURL(this.Weblog.Text.Trim()))
            {
                this.PageContext.AddLoadMessage(this.GetText("PROFILE", "BAD_WEBLOG"), MessageTypes.warning);
                return;
            }

            if (this.MSN.Text.IsSet() && !ValidationHelper.IsValidEmail(this.MSN.Text))
            {
                this.PageContext.AddLoadMessage(this.GetText("PROFILE", "BAD_MSN"), MessageTypes.warning);
                return;
            }

            if (this.Xmpp.Text.IsSet() && !ValidationHelper.IsValidXmpp(this.Xmpp.Text))
            {
                this.PageContext.AddLoadMessage(this.GetText("PROFILE", "BAD_XMPP"), MessageTypes.warning);
                return;
            }

            if (this.ICQ.Text.IsSet() &&
                !(ValidationHelper.IsValidEmail(this.ICQ.Text) || ValidationHelper.IsNumeric(this.ICQ.Text)))
            {
                this.PageContext.AddLoadMessage(this.GetText("PROFILE", "BAD_ICQ"), MessageTypes.warning);
                return;
            }

            if (this.Facebook.Text.IsSet() && !ValidationHelper.IsValidURL(this.Facebook.Text))
            {
                this.PageContext.AddLoadMessage(this.GetText("PROFILE", "BAD_FACEBOOK"), MessageTypes.warning);
                return;
            }

            if (this.Google.Text.IsSet() && !ValidationHelper.IsValidURL(this.Google.Text))
            {
                this.PageContext.AddLoadMessage(this.GetText("PROFILE", "BAD_GOOGLE"), MessageTypes.warning);
                return;
            }

            string displayName = null;

            if (this.Get <YafBoardSettings>().EnableDisplayName &&
                this.Get <YafBoardSettings>().AllowDisplayNameModification)
            {
                // Check if name matches the required minimum length
                if (this.DisplayName.Text.Trim().Length < this.Get <YafBoardSettings>().DisplayNameMinLength)
                {
                    this.PageContext.AddLoadMessage(
                        this.GetTextFormatted("USERNAME_TOOLONG", this.Get <YafBoardSettings>().DisplayNameMinLength),
                        MessageTypes.warning);

                    return;
                }

                // Check if name matches the required minimum length
                if (this.DisplayName.Text.Length > this.Get <YafBoardSettings>().UserNameMaxLength)
                {
                    this.PageContext.AddLoadMessage(
                        this.GetTextFormatted("USERNAME_TOOLONG", this.Get <YafBoardSettings>().UserNameMaxLength),
                        MessageTypes.warning);

                    return;
                }

                if (this.DisplayName.Text.Trim() != this.UserData.DisplayName)
                {
                    if (this.Get <IUserDisplayName>().GetId(this.DisplayName.Text.Trim()).HasValue)
                    {
                        this.PageContext.AddLoadMessage(
                            this.GetText("REGISTER", "ALREADY_REGISTERED_DISPLAYNAME"),
                            MessageTypes.warning);

                        return;
                    }

                    displayName = this.DisplayName.Text.Trim();
                }
            }

            if (this.UpdateEmailFlag)
            {
                var newEmail = this.Email.Text.Trim();

                if (!ValidationHelper.IsValidEmail(newEmail))
                {
                    this.PageContext.AddLoadMessage(this.GetText("PROFILE", "BAD_EMAIL"), MessageTypes.warning);
                    return;
                }

                var userNameFromEmail = this.Get <MembershipProvider>().GetUserNameByEmail(this.Email.Text.Trim());

                if (userNameFromEmail.IsSet() && userNameFromEmail != userName)
                {
                    this.PageContext.AddLoadMessage(this.GetText("PROFILE", "BAD_EMAIL"), MessageTypes.warning);
                    return;
                }

                if (this.Get <YafBoardSettings>().EmailVerification)
                {
                    this.SendEmailVerification(newEmail);
                }
                else
                {
                    // just update the e-mail...
                    try
                    {
                        UserMembershipHelper.UpdateEmail(this.currentUserID, this.Email.Text.Trim());
                    }
                    catch (ApplicationException)
                    {
                        this.PageContext.AddLoadMessage(
                            this.GetText("PROFILE", "DUPLICATED_EMAIL"),
                            MessageTypes.warning);

                        return;
                    }
                }
            }

            if (this.Interests.Text.Trim().Length > 400)
            {
                this.PageContext.AddLoadMessage(
                    this.GetTextFormatted("FIELD_TOOLONG", this.GetText("CP_EDITPROFILE", "INTERESTS"), 400),
                    MessageTypes.warning);

                return;
            }

            if (this.Occupation.Text.Trim().Length > 400)
            {
                this.PageContext.AddLoadMessage(
                    this.GetTextFormatted("FIELD_TOOLONG", this.GetText("CP_EDITPROFILE", "OCCUPATION"), 400),
                    MessageTypes.warning);

                return;
            }

            this.UpdateUserProfile(userName);

            // vzrus: We should do it as we need to write null value to db, else it will be empty.
            // Localizer currently treats only nulls.
            object language = null;
            object culture  = this.Culture.SelectedValue;
            object theme    = this.Theme.SelectedValue;
            object editor   = this.ForumEditor.SelectedValue;

            if (this.Theme.SelectedValue.IsNotSet())
            {
                theme = null;
            }

            if (this.ForumEditor.SelectedValue.IsNotSet())
            {
                editor = null;
            }

            if (this.Culture.SelectedValue.IsNotSet())
            {
                culture = null;
            }
            else
            {
                foreach (DataRow row in
                         StaticDataHelper.Cultures()
                         .Rows.Cast <DataRow>()
                         .Where(row => culture.ToString() == row["CultureTag"].ToString()))
                {
                    language = row["CultureFile"].ToString();
                }
            }

            // save remaining settings to the DB
            LegacyDb.user_save(
                this.currentUserID,
                this.PageContext.PageBoardID,
                null,
                displayName,
                null,
                this.TimeZones.SelectedValue.ToType <int>(),
                language,
                culture,
                theme,
                editor,
                this.UseMobileTheme.Checked,
                null,
                null,
                null,
                this.DSTUser.Checked,
                this.HideMe.Checked,
                null);

            // vzrus: If it's a guest edited by an admin registry value should be changed
            DataTable dt = LegacyDb.user_list(this.PageContext.PageBoardID, this.currentUserID, true, null, null, false);

            if (dt.HasRows() && dt.Rows[0]["IsGuest"].ToType <bool>())
            {
                LegacyDb.registry_save("timezone", this.TimeZones.SelectedValue, this.PageContext.PageBoardID);
            }

            // clear the cache for this user...)
            this.Get <IRaiseEvent>().Raise(new UpdateUserEvent(this.currentUserID));

            this.Get <IDataCache>().Clear();

            if (!this.PageContext.CurrentForumPage.IsAdminPage)
            {
                YafBuildLink.Redirect(ForumPages.cp_profile);
            }
            else
            {
                this._userData = null;
                this.BindData();
            }
        }