Example #1
0
        /// <summary>
        /// A method to get albums path string.
        /// </summary>
        /// <param name="forumPageAttributes">
        /// A page query string cleared from page name.
        /// </param>
        /// <returns>
        /// The string
        /// </returns>
        private string Albums([NotNull] string forumPageAttributes)
        {
            string outstring = string.Empty;

            string userID = forumPageAttributes.Substring(forumPageAttributes.IndexOf("u=") + 2).Substring(0).Trim();

            if (ValidationHelper.IsValidInt(userID))
            {
                if (userID.ToType <int>() == this.UserID)
                {
                    outstring += this.GetText("ACTIVELOCATION", "ALBUMS_OWN").FormatWith();
                }
                else
                {
                    outstring += this.GetText("ACTIVELOCATION", "ALBUMS_OFUSER").FormatWith();
                    outstring +=
                        @"<a href=""{0}"" id=""albumsuserid_{1}"" runat=""server""> {2} </a>".FormatWith(
                            YafBuildLink.GetLink(ForumPages.profile, "u={0}", userID),
                            userID + this.PageContext.PageUserID,
                            HttpUtility.HtmlEncode(UserMembershipHelper.GetUserNameFromID(userID.ToType <long>())));
                }
            }
            else
            {
                outstring += this.GetTextFormatted("ACTIVELOCATION", "ALBUMS").FormatWith();
            }

            return(outstring);
        }
Example #2
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.IsPostBack)
            {
                return;
            }

            var displayName = this.PageContext.BoardSettings.EnableDisplayName
                                  ? UserMembershipHelper.GetDisplayNameFromID(this.PageContext.PageUserID)
                                  : UserMembershipHelper.GetUserNameFromID(this.PageContext.PageUserID);

            this.PageLinks.Clear();
            this.PageLinks.AddLink(this.PageContext.BoardSettings.Name, YafBuildLink.GetLink(ForumPages.forum));
            this.PageLinks.AddLink(
                displayName,
                YafBuildLink.GetLink(ForumPages.profile, "u={0}", this.PageContext.PageUserID, displayName));
            this.PageLinks.AddLink(this.GetText("TITLE"), string.Empty);


            this.Back.Text = this.Get <HttpRequestBase>().QueryString.GetFirstOrDefault("t").IsNotSet()
                                 ? this.GetText("BACK")
                                 : this.GetText("COMMON", "CONTINUE");

            this.BindData();
        }
Example #3
0
        /// <summary>
        /// Bans the user IP Addresses.
        /// </summary>
        private void BanUserIps()
        {
            var allIps = this.GetRepository <BannedIP>().Get(x => x.BoardID == this.PageContext.PageBoardID)
                         .Select(x => x.Mask).ToList();

            // ban user ips...
            var name = UserMembershipHelper.GetDisplayNameFromID(this.CurrentUserId?.ToType <int>() ?? -1);

            if (name.IsNotSet())
            {
                name = UserMembershipHelper.GetUserNameFromID(this.CurrentUserId?.ToType <int>() ?? -1);
            }

            foreach (var ip in this.IPAddresses.Except(allIps).ToList())
            {
                if (!ip.IsSet())
                {
                    continue;
                }

                var linkUserBan = this.Get <ILocalization>().GetTextFormatted(
                    "ADMIN_EDITUSER",
                    "LINK_USER_BAN",
                    this.CurrentUserId,
                    YafBuildLink.GetLink(ForumPages.profile, "u={0}&name={1}", this.CurrentUserId, name),
                    this.HtmlEncode(name));

                this.GetRepository <BannedIP>().Save(null, ip, linkUserBan, this.PageContext.PageUserID);
            }

            // Clear cache
            this.Get <IDataCache>().Remove(Constants.Cache.BannedIP);
        }
Example #4
0
        private string MatchUserBoxAvatar([NotNull] string userBox)
        {
            var filler = string.Empty;
            var rx     = this.GetRegex(Constants.UserBox.Avatar);

            if (!this.PostDeleted)
            {
                var avatarUrl   = this.Get <IAvatars>().GetAvatarUrlForUser(this.UserId);
                var displayName = this.Get <YafBoardSettings>().EnableDisplayName
                                      ? UserMembershipHelper.GetDisplayNameFromID(this.UserId)
                                      : UserMembershipHelper.GetUserNameFromID(this.UserId);

                if (avatarUrl.IsSet())
                {
                    filler =
                        this.Get <YafBoardSettings>().UserBoxAvatar.FormatWith(
                            @"<a href=""{1}"" title=""{2}""><img class=""avatarimage"" src=""{0}"" alt=""{2}"" title=""{2}""  /></a>"
                            .FormatWith(
                                avatarUrl,
                                YafBuildLink.GetLinkNotEscaped(ForumPages.profile, "u={0}&name={1}", this.UserId, displayName),
                                Page.HtmlEncode(
                                    displayName)));
                }
            }

            // replaces template placeholder with actual avatar
            userBox = rx.Replace(userBox, filler);
            return(userBox);
        }
Example #5
0
        /// <summary>
        /// The Page_ Load Event.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        protected void Page_Load([NotNull] object sender, [NotNull] EventArgs e)
        {
            var userId = Security.StringToIntOrRedirect(this.Request.QueryString.GetFirstOrDefault("u"));

            if (userId != this.PageContext.PageUserID)
            {
                this.MenuHolder.Visible = false;
            }

            if (!this.IsPostBack)
            {
                var displayName = this.PageContext.BoardSettings.EnableDisplayName
                                    ? UserMembershipHelper.GetDisplayNameFromID(userId)
                                    : UserMembershipHelper.GetUserNameFromID(userId);
                this.PageLinks.Clear();
                this.PageLinks.AddLink(this.PageContext.BoardSettings.Name, YafBuildLink.GetLink(ForumPages.forum));
                this.PageLinks.AddLink(
                    displayName,
                    YafBuildLink.GetLink(ForumPages.profile, "u={0}", userId, displayName));
                this.PageLinks.AddLink(this.GetText("TITLE"), string.Empty);
            }

            var thanksInfo = this.GetRepository <Thanks>().ViewAllThanksByUserAsDataTable(userId, this.PageContext.PageUserID);

            this.InitializeThanksList(this.ThanksFromList, ThanksListMode.FromUser, userId, thanksInfo);
            this.InitializeThanksList(this.ThanksToList, ThanksListMode.ToUser, userId, thanksInfo);
        }
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="EventArgs"/> instance containing the event data.</param>
        protected void Page_Load([NotNull] object sender, [NotNull] EventArgs e)
        {
            if (!this.Get <YafBoardSettings>().EnableAlbum)
            {
                YafBuildLink.AccessDenied();
            }

            if (this.Get <HttpRequestBase>().QueryString.GetFirstOrDefault("u") == null)
            {
                YafBuildLink.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 <YafBoardSettings>().EnableDisplayName
                    ? displayName
                    : UserMembershipHelper.GetUserNameFromID(
                    Security.StringToLongOrRedirect(this.Get <HttpRequestBase>().QueryString.GetFirstOrDefault("u"))),
                YafBuildLink.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 #7
0
        /// <summary>
        /// A method to get album path string.
        /// </summary>
        /// <param name="forumPageAttributes">
        /// A page query string cleared from page name.
        /// </param>
        /// <returns>
        /// The string
        /// </returns>
        private string Album([NotNull] string forumPageAttributes)
        {
            string outstring = string.Empty;
            string userID    = forumPageAttributes.Substring(forumPageAttributes.IndexOf("u=") + 2).Trim();

            if (userID.Contains("&"))
            {
                userID = userID.Substring(0, userID.IndexOf("&")).Trim();
            }

            string albumID = forumPageAttributes.Substring(forumPageAttributes.IndexOf("a=") + 2);

            albumID = albumID.Contains("&")
                          ? albumID.Substring(0, albumID.IndexOf("&")).Trim()
                          : albumID.Substring(0).Trim();

            if (ValidationHelper.IsValidInt(userID) && ValidationHelper.IsValidInt(albumID))
            {
                // The DataRow should not be missing in the case
                DataRow dr = LegacyDb.album_list(null, albumID.Trim().ToType <int>()).Rows[0];

                // If album doesn't have a Title, use his ID.
                string albumName = !string.IsNullOrEmpty(dr["Title"].ToString())
                                       ? dr["Title"].ToString()
                                       : dr["AlbumID"].ToString();

                // Render
                if (userID.ToType <int>() != this.UserID)
                {
                    outstring += this.GetText("ACTIVELOCATION", "ALBUM").FormatWith();
                    outstring +=
                        @"<a href=""{0}"" id=""uiseralbumid_{1}"" runat=""server""> {2} </a>".FormatWith(
                            YafBuildLink.GetLink(ForumPages.album, "a={0}", albumID),
                            userID + this.PageContext.PageUserID,
                            HttpUtility.HtmlEncode(albumName));
                    outstring += this.GetText("ACTIVELOCATION", "ALBUM_OFUSER").FormatWith();
                    outstring +=
                        @"<a href=""{0}"" id=""albumuserid_{1}"" runat=""server""> {2} </a>".FormatWith(
                            YafBuildLink.GetLink(ForumPages.profile, "u={0}", userID),
                            userID,
                            HttpUtility.HtmlEncode(UserMembershipHelper.GetUserNameFromID(userID.ToType <long>())));
                }
                else
                {
                    outstring += this.GetText("ACTIVELOCATION", "ALBUM_OWN").FormatWith();
                    outstring +=
                        @"<a href=""{0}"" id=""uiseralbumid_{1}"" runat=""server""> {2} </a>".FormatWith(
                            YafBuildLink.GetLink(ForumPages.album, "a={0}", albumID),
                            userID + this.PageContext.PageUserID,
                            HttpUtility.HtmlEncode(albumName));
                }
            }
            else
            {
                outstring += this.GetText("ACTIVELOCATION", "ALBUM").FormatWith();
            }

            return(outstring);
        }
Example #8
0
        /// <summary>
        /// Bans the user IP Addresses.
        /// </summary>
        private void BanUserIps()
        {
            var usr =
                LegacyDb.UserList(
                    this.PageContext.PageBoardID,
                    this.CurrentUserID.ToType <int?>(),
                    null,
                    null,
                    null,
                    false).FirstOrDefault();

            if (usr != null)
            {
                this.Logger
                .Log(
                    this.PageContext.PageUserID,
                    "YAF.Controls.EditUsersKill",
                    "User {0} was killed by {1}".FormatWith(
                        this.Get <YafBoardSettings>().EnableDisplayName ? usr.DisplayName : usr.Name,
                        this.Get <YafBoardSettings>().EnableDisplayName
                                ? this.PageContext.CurrentUserData.DisplayName
                                : this.PageContext.CurrentUserData.UserName),
                    EventLogTypes.UserSuspended);
            }

            var allIps = this.GetRepository <BannedIP>().ListTyped().Select(x => x.Mask).ToList();

            // ban user ips...
            string name =
                UserMembershipHelper.GetDisplayNameFromID(
                    this.CurrentUserID == null ? -1 : this.CurrentUserID.ToType <int>());

            if (name.IsNotSet())
            {
                name =
                    UserMembershipHelper.GetUserNameFromID(
                        this.CurrentUserID == null ? -1 : this.CurrentUserID.ToType <int>());
            }

            foreach (var ip in this.IPAddresses.Except(allIps).ToList())
            {
                string linkUserBan =
                    this.Get <ILocalization>()
                    .GetText("ADMIN_EDITUSER", "LINK_USER_BAN")
                    .FormatWith(
                        this.CurrentUserID,
                        YafBuildLink.GetLink(ForumPages.profile, "u={0}&name={1}", this.CurrentUserID, name),
                        this.HtmlEncode(name));


                this.GetRepository <BannedIP>().Save(null, ip, linkUserBan, this.PageContext.PageUserID);
            }

            if (this.SuspendUser.Checked && this.CurrentUserID > 0)
            {
                LegacyDb.user_suspend(this.CurrentUserID, DateTime.UtcNow.AddYears(5));
            }
        }
Example #9
0
        /// <summary>
        /// Handles click on save button.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        protected void Save_Click([NotNull] object sender, [NotNull] EventArgs e)
        {
            // go through all roles displayed on page
            for (var i = 0; i < this.UserGroups.Items.Count; i++)
            {
                // get current item
                var item = this.UserGroups.Items[i];

                // get role ID from it
                var roleID = int.Parse(((Label)item.FindControl("GroupID")).Text);

                // get role name
                var roleName = this.GetRepository <Group>().List(boardId: this.PageContext.PageBoardID, groupId: roleID)
                               .FirstOrDefault().Name;

                // is user supposed to be in that role?
                var isChecked = ((CheckBox)item.FindControl("GroupMember")).Checked;

                // save user in role
                this.Get <IDbFunction>().Query.usergroup_save(this.CurrentUserID, roleID, isChecked);

                // empty out access table(s)
                this.GetRepository <Active>().DeleteAll();
                this.GetRepository <ActiveAccess>().DeleteAll();

                // update roles if this user isn't the guest
                if (UserMembershipHelper.IsGuestUser(this.CurrentUserID))
                {
                    continue;
                }

                // get user's name
                var userName = UserMembershipHelper.GetUserNameFromID(this.CurrentUserID);

                // add/remove user from roles in membership provider
                if (isChecked && !RoleMembershipHelper.IsUserInRole(userName, roleName))
                {
                    RoleMembershipHelper.AddUserToRole(userName, roleName);
                }
                else if (!isChecked && RoleMembershipHelper.IsUserInRole(userName, roleName))
                {
                    RoleMembershipHelper.RemoveUserFromRole(userName, roleName);
                }

                // Clearing cache with old permisssions data...
                this.Get <IDataCache>().Remove(Constants.Cache.ActiveUserLazyData.FormatWith(this.CurrentUserID));
            }

            // update forum moderators cache just in case something was changed...
            this.Get <IDataCache>().Remove(Constants.Cache.ForumModerators);

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

            this.BindData();
        }
Example #10
0
        /// <summary>
        /// Handles click on save button.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        protected void Save_Click(object sender, EventArgs e)
        {
            // go through all roles displayed on page
            for (int i = 0; i < this.UserGroups.Items.Count; i++)
            {
                // get current item
                RepeaterItem item = this.UserGroups.Items[i];

                // get role ID from it
                int roleID = int.Parse(((Label)item.FindControl("GroupID")).Text);

                // get role name
                string roleName = string.Empty;
                using (DataTable dt = DB.group_list(this.PageContext.PageBoardID, roleID))
                {
                    foreach (DataRow row in dt.Rows)
                    {
                        roleName = (string)row["Name"];
                    }
                }

                // is user supposed to be in that role?
                bool isChecked = ((CheckBox)item.FindControl("GroupMember")).Checked;

                // save user in role
                DB.usergroup_save(this.CurrentUserID, roleID, isChecked);

                // update roles if this user isn't the guest
                if (!UserMembershipHelper.IsGuestUser(this.CurrentUserID))
                {
                    // get user's name
                    string userName = UserMembershipHelper.GetUserNameFromID(this.CurrentUserID);

                    // add/remove user from roles in membership provider
                    if (isChecked && !RoleMembershipHelper.IsUserInRole(userName, roleName))
                    {
                        RoleMembershipHelper.AddUserToRole(userName, roleName);
                    }
                    else if (!isChecked && RoleMembershipHelper.IsUserInRole(userName, roleName))
                    {
                        RoleMembershipHelper.RemoveUserFromRole(userName, roleName);
                    }

                    // Clearing cache with old permisssions data...
                    this.PageContext.Cache.Remove(YafCache.GetBoardCacheKey(Constants.Cache.ActiveUserLazyData.FormatWith(this.CurrentUserID)));
                }
            }

            // update forum moderators cache just in case something was changed...
            this.PageContext.Cache.Remove(YafCache.GetBoardCacheKey(Constants.Cache.ForumModerators));

            // clear the cache for this user...
            UserMembershipHelper.ClearCacheForUserId(this.CurrentUserID);

            this.BindData();
        }
Example #11
0
        /// <summary>
        /// Add a new syndication person.
        /// </summary>
        /// <param name="userEmail">The email.</param>
        /// <param name="userId">The user Id.</param>
        /// <param name="userName">The user name.</param>
        /// <param name="userDisplayName"> The user dispaly name.</param>
        /// <returns>The SyndicationPerson.</returns>
        public static SyndicationPerson NewSyndicationPerson(string userEmail, long userId, string userName, string userDisplayName)
        {
            string userNameToShow;

            if (YafContext.Current.BoardSettings.EnableDisplayName)
            {
                userNameToShow = userDisplayName.IsNotSet() ? UserMembershipHelper.GetDisplayNameFromID(userId) : userDisplayName;
            }
            else
            {
                userNameToShow = userName.IsNotSet() ? UserMembershipHelper.GetUserNameFromID(userId) : userName;
            }
            return(new SyndicationPerson(userEmail, userNameToShow, YafBuildLink.GetLinkNotEscaped(ForumPages.profile, true, "u={0}", userId)));
        }
Example #12
0
        /// <summary>
        /// Called when the page loads
        /// </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)
        {
            if (this.IsPostBack)
            {
                return;
            }

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

            this.AlbumHeaderLabel.Param0 = this.Get <YafBoardSettings>().EnableDisplayName
                                               ? this.HtmlEncode(umhdn)
                                               : this.HtmlEncode(UserMembershipHelper.GetUserNameFromID(this.UserID));

            this.BindData();

            HttpContext.Current.Session["imagePreviewWidth"]   = this.Get <YafBoardSettings>().ImageAttachmentResizeWidth;
            HttpContext.Current.Session["imagePreviewHeight"]  = this.Get <YafBoardSettings>().ImageAttachmentResizeHeight;
            HttpContext.Current.Session["imagePreviewCropped"] =
                this.Get <YafBoardSettings>().ImageAttachmentResizeCropped;
            HttpContext.Current.Session["localizationFile"] = this.Get <ILocalization>().LanguageFileName;

            // Show Albums Max Info
            if (this.UserID == this.PageContext.PageUserID)
            {
                this.albumsInfo.Text = this.Get <ILocalization>().GetTextFormatted(
                    "ALBUMS_INFO", this.PageContext.NumAlbums, this.PageContext.UsrAlbums);
                if (this.PageContext.UsrAlbums > this.PageContext.NumAlbums)
                {
                    this.AddAlbum.Visible = true;
                }

                this.albumsInfo.Text = this.PageContext.UsrAlbums > 0
                                           ? this.Get <ILocalization>().GetTextFormatted(
                    "ALBUMS_INFO", this.PageContext.NumAlbums, this.PageContext.UsrAlbums)
                                           : this.Get <ILocalization>().GetText("ALBUMS_NOTALLOWED");

                this.albumsInfo.Visible = true;
            }

            if (this.AddAlbum.Visible)
            {
                this.AddAlbum.TextLocalizedPage = "BUTTON";
                this.AddAlbum.TextLocalizedTag  = "BUTTON_ADDALBUM";
            }
        }
Example #13
0
        /// <summary>
        ///   The page load event.
        /// </summary>
        /// <param name = "sender">
        ///   the sender.
        /// </param>
        /// <param name = "e">
        ///   the e.
        /// </param>
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.PageContext.BoardSettings.EnableAlbum)
            {
                YafBuildLink.AccessDenied();
            }

            if (this.Request.QueryString.GetFirstOrDefault("u") == null)
            {
                YafBuildLink.AccessDenied();
            }

            // setup jQuery, LightBox and YAF JS...
            YafContext.Current.PageElements.RegisterJQuery();
            YafContext.Current.PageElements.RegisterJsResourceInclude("yafjs", "js/yaf.js");
            YafContext.Current.PageElements.RegisterJsBlock("toggleMessageJs", JavaScriptBlocks.ToggleMessageJs);

            // lightbox only need if the browser is not IE6...
            if (!UserAgentHelper.IsBrowserIE6())
            {
                YafContext.Current.PageElements.RegisterJsResourceInclude("lightboxjs", "js/jquery.lightbox.min.js");
                YafContext.Current.PageElements.RegisterCssIncludeResource("css/jquery.lightbox.css");
                YafContext.Current.PageElements.RegisterJsBlock("lightboxloadjs", JavaScriptBlocks.LightBoxLoadJs);
            }

            string displayName =
                UserMembershipHelper.GetDisplayNameFromID(
                    Security.StringToLongOrRedirect(this.Request.QueryString.GetFirstOrDefault("u")));

            // Generate the Page Links.

            this.PageLinks.Clear();
            this.PageLinks.AddLink(this.PageContext.BoardSettings.Name, YafBuildLink.GetLink(ForumPages.forum));
            this.PageLinks.AddLink(
                displayName.IsSet()
          ? displayName
          : UserMembershipHelper.GetUserNameFromID(
                    Security.StringToLongOrRedirect(this.Request.QueryString.GetFirstOrDefault("u"))),
                YafBuildLink.GetLink(ForumPages.profile, "u={0}", this.Request.QueryString.GetFirstOrDefault("u")));
            this.PageLinks.AddLink(this.GetText("ALBUMS"), string.Empty);

            // Initialize the Album List control.
            this.AlbumList1.UserID = this.Request.QueryString.GetFirstOrDefault("u").ToType <int>();
        }
Example #14
0
        /// <summary>
        /// Gets the valid username.
        /// </summary>
        /// <param name="username">The username.</param>
        /// <param name="password">The password.</param>
        /// <returns>
        /// The get valid login.
        /// </returns>
        protected virtual string GetValidUsername(string username, string password)
        {
            if (username.Contains("@") && this.Get <MembershipProvider>().RequiresUniqueEmail)
            {
                // attempt Email Login
                var realUsername = this.Get <MembershipProvider>().GetUserNameByEmail(username);

                if (realUsername.IsSet() && this.Get <MembershipProvider>()
                    .ValidateUser(realUsername, password))
                {
                    return(realUsername);
                }
            }

            // Standard user name login
            if (this.Get <MembershipProvider>().ValidateUser(username, password))
            {
                return(username);
            }

            // display name login...
            if (!this.Get <BoardSettings>().EnableDisplayName)
            {
                return(null);
            }

            // Display name login
            var id = this.Get <IUserDisplayName>().GetId(username);

            if (id.HasValue)
            {
                // get the username associated with this id...
                var realUsername = UserMembershipHelper.GetUserNameFromID(id.Value);

                // validate again...
                if (this.Get <MembershipProvider>().ValidateUser(realUsername, password))
                {
                    return(realUsername);
                }
            }

            // no valid login -- return null
            return(null);
        }
Example #15
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 userId =
                Security.StringToLongOrRedirect(this.Get <HttpRequestBase>().QueryString.GetFirstOrDefault("u"));

            var user = UserMembershipHelper.GetMembershipUserById(userId);

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

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

            var displayName = UserMembershipHelper.GetDisplayNameFromID(userId);

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

            // Initialize the Album List control.
            this.AlbumList1.UserID = userId.ToType <int>();
        }
Example #16
0
        /// <summary>
        /// Called when the page loads
        /// </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)
        {
            if (this.IsPostBack)
            {
                return;
            }

            this.IconHeader.Param0 = this.HtmlEncode(
                this.Get <BoardSettings>().EnableDisplayName
                    ? UserMembershipHelper.GetDisplayNameFromID(this.UserID)
                    : UserMembershipHelper.GetUserNameFromID(this.UserID));

            this.BindData();

            HttpContext.Current.Session["localizationFile"] = this.Get <ILocalization>().LanguageFileName;

            // Show Albums Max Info
            if (this.UserID == this.PageContext.PageUserID)
            {
                this.albumsInfo.Text = this.Get <ILocalization>().GetTextFormatted(
                    "ALBUMS_INFO", this.PageContext.NumAlbums, this.PageContext.UsrAlbums);
                if (this.PageContext.UsrAlbums > this.PageContext.NumAlbums)
                {
                    this.AddAlbum.Visible = true;
                }

                this.albumsInfo.Text = this.PageContext.UsrAlbums > 0
                                           ? this.Get <ILocalization>().GetTextFormatted(
                    "ALBUMS_INFO", this.PageContext.NumAlbums, this.PageContext.UsrAlbums)
                                           : this.Get <ILocalization>().GetText("ALBUMS_NOTALLOWED");

                this.albumsInfo.Visible = true;
            }

            if (!this.AddAlbum.Visible)
            {
                return;
            }

            this.AddAlbum.TextLocalizedPage = "BUTTON";
            this.AddAlbum.TextLocalizedTag  = "BUTTON_ADDALBUM";
        }
Example #17
0
        /// <summary>
        /// The Page_ Load Event.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        protected void Page_Load([NotNull] object sender, [NotNull] EventArgs e)
        {
            var userID = (int)Security.StringToLongOrRedirect(this.Request.QueryString.GetFirstOrDefault("u"));

            if (!this.IsPostBack)
            {
                this.PageLinks.Clear();
                this.PageLinks.AddLink(this.PageContext.BoardSettings.Name, YafBuildLink.GetLink(ForumPages.forum));
                this.PageLinks.AddLink(
                    this.PageContext.BoardSettings.EnableDisplayName
            ? UserMembershipHelper.GetDisplayNameFromID(userID) : UserMembershipHelper.GetUserNameFromID(userID),
                    YafBuildLink.GetLink(ForumPages.profile, "u={0}", userID));
                this.PageLinks.AddLink(this.GetText("TITLE"), string.Empty);
            }

            DataTable thanksInfo = LegacyDb.user_viewallthanks(userID, this.PageContext.PageUserID);

            this.InitializeThanksList(this.ThanksFromList, ThanksListMode.FromUser, userID, thanksInfo);
            this.InitializeThanksList(this.ThanksToList, ThanksListMode.ToUser, userID, thanksInfo);
        }
Example #18
0
        /// <summary>
        /// A method to get profile path string.
        /// </summary>
        /// <param name="forumPageAttributes">
        /// The forum page attributes.
        /// </param>
        /// <returns>
        /// The profile.
        /// </returns>
        private string Profile([NotNull] string forumPageAttributes)
        {
            var outstring = string.Empty;
            var userId    = forumPageAttributes.Substring(forumPageAttributes.IndexOf("u=", StringComparison.Ordinal) + 2);

            userId = userId.Contains("&") ? userId.Substring(0, userId.IndexOf("&", StringComparison.Ordinal)).Trim() : userId.Substring(0).Trim();

            if (ValidationHelper.IsValidInt(userId.Trim()))
            {
                if (userId.ToType <int>() != this.UserID)
                {
                    var displayName =
                        HttpUtility.HtmlEncode(UserMembershipHelper.GetDisplayNameFromID(userId.ToType <long>()));

                    if (displayName.IsNotSet())
                    {
                        displayName = HttpUtility.HtmlEncode(UserMembershipHelper.GetUserNameFromID(userId.ToType <long>()));
                    }

                    outstring += this.GetText("ACTIVELOCATION", "PROFILE_OFUSER").FormatWith();
                    outstring +=
                        @"<a href=""{0}""  id=""profileuserid_{1}"" title=""{2}"" alt=""{2}"" runat=""server""> {3} </a>"
                        .FormatWith(
                            YafBuildLink.GetLink(ForumPages.profile, "u={0}&name={1}", userId, displayName),
                            userId + this.PageContext.PageUserID,
                            this.GetText("COMMON", "VIEW_USRPROFILE"),
                            HttpUtility.HtmlEncode(displayName));
                }
                else
                {
                    outstring += this.GetText("ACTIVELOCATION", "PROFILE_OWN").FormatWith();
                }
            }
            else
            {
                outstring += this.GetText("ACTIVELOCATION", "PROFILE").FormatWith();
            }

            return(outstring);
        }
Example #19
0
        /// <summary>
        /// The ban user ips.
        /// </summary>
        private void BanUserIps()
        {
            var ips    = IPAddresses;
            var allIps = DB.bannedip_list(PageContext.PageBoardID, null).GetColumnAsList <string>("Mask").ToList();

            // remove all IPs from ips if they already exist in allIps...
            ips.RemoveAll(allIps.Contains);

            // ban user ips...
            string name = UserMembershipHelper.GetDisplayNameFromID(this.CurrentUserID == null? -1: (int)this.CurrentUserID);

            if (string.IsNullOrEmpty(name))
            {
                name = UserMembershipHelper.GetUserNameFromID(this.CurrentUserID == null ? -1 : (int)this.CurrentUserID);
            }

            IPAddresses.ForEach(x => DB.bannedip_save(null, PageContext.PageBoardID, x,
                                                      @"User <a id=""usr{0}"" href=""{1}"">{2}</a>  is banned by IP".FormatWith(this.CurrentUserID, YafBuildLink.GetLink(ForumPages.profile, "u={0}", this.CurrentUserID), this.HtmlEncode(name)), this.PageContext.PageUserID));

            // clear cache of banned IPs for this board
            PageContext.Cache.Remove(YafCache.GetBoardCacheKey(Constants.Cache.BannedIP));
        }
Example #20
0
        /// <summary>
        /// A method to get albums path string.
        /// </summary>
        /// <param name="forumPageAttributes">
        /// A page query string cleared from page name.
        /// </param>
        /// <returns>
        /// The string
        /// </returns>
        private string Albums([NotNull] string forumPageAttributes)
        {
            string outstring;

            var userId = forumPageAttributes.Substring(forumPageAttributes.IndexOf("u=", StringComparison.Ordinal) + 2).Substring(0).Trim();

            if (ValidationHelper.IsValidInt(userId))
            {
                if (userId.ToType <int>() == this.UserID)
                {
                    outstring = this.GetText("ACTIVELOCATION", "ALBUMS_OWN").FormatWith();
                }
                else
                {
                    var displayName =
                        HttpUtility.HtmlEncode(UserMembershipHelper.GetDisplayNameFromID(userId.ToType <long>()));

                    if (displayName.IsNotSet())
                    {
                        displayName = HttpUtility.HtmlEncode(UserMembershipHelper.GetUserNameFromID(userId.ToType <long>()));
                    }

                    outstring =
                        @"{3}<a href=""{0}"" id=""albumsuserid_{1}"" runat=""server""> {2} </a>".FormatWith(
                            YafBuildLink.GetLink(ForumPages.profile, "u={0}&name={1}", userId, displayName),
                            userId + this.PageContext.PageUserID,
                            HttpUtility.HtmlEncode(displayName),
                            this.GetText("ACTIVELOCATION", "ALBUMS_OFUSER"));
                }
            }
            else
            {
                outstring = this.GetTextFormatted("ACTIVELOCATION", "ALBUMS").FormatWith();
            }

            return(outstring);
        }
Example #21
0
        /// <summary>
        /// The on pre render.
        /// </summary>
        /// <param name="e">
        /// The e.
        /// </param>
        protected override void OnPreRender(EventArgs e)
        {
            if (this.PageContext.IsGuest)
            {
                this.ShowHideIgnoredUserPost.Visible = false;
                this.MessageRow.CssClass             = "collapse show";
            }
            else if (this.Get <IUserIgnored>().IsIgnored(this.PostData.UserId))
            {
                this.MessageRow.CssClass             = "collapse";
                this.ShowHideIgnoredUserPost.Visible = true;
            }
            else if (!this.Get <IUserIgnored>().IsIgnored(this.PostData.UserId))
            {
                this.MessageRow.CssClass = "collapse show";
            }

            this.Edit.Visible = this.Edit2.Visible =
                !this.PostData.PostDeleted && this.PostData.CanEditPost && !this.PostData.IsLocked;
            this.Edit.NavigateUrl = this.Edit2.NavigateUrl = BuildLink.GetLinkNotEscaped(
                ForumPages.PostMessage,
                "m={0}",
                this.PostData.MessageId);
            this.MovePost.Visible     =
                this.Move.Visible     = this.PageContext.ForumModeratorAccess && !this.PostData.IsLocked;
            this.MovePost.NavigateUrl = this.Move.NavigateUrl = BuildLink.GetLinkNotEscaped(
                ForumPages.MoveMessage,
                "m={0}",
                this.PostData.MessageId);
            this.Delete.Visible = this.Delete2.Visible =
                !this.PostData.PostDeleted && this.PostData.CanDeletePost &&
                !this.PostData.IsLocked;

            this.Delete.NavigateUrl = this.Delete2.NavigateUrl = BuildLink.GetLinkNotEscaped(
                ForumPages.DeleteMessage,
                "m={0}&action=delete",
                this.PostData.MessageId);
            this.UnDelete.Visible     = this.UnDelete2.Visible = this.PostData.CanUnDeletePost && !this.PostData.IsLocked;
            this.UnDelete.NavigateUrl = this.UnDelete2.NavigateUrl = BuildLink.GetLinkNotEscaped(
                ForumPages.DeleteMessage,
                "m={0}&action=undelete",
                this.PostData.MessageId);

            this.Quote.Visible                      = this.Quote2.Visible =
                this.Reply.Visible                  =
                    this.ReplyFooter.Visible        =
                        this.QuickReplyLink.Visible =
                            !this.PostData.PostDeleted && this.PostData.CanReply &&
                            !this.PostData.IsLocked;

            if (!this.PostData.PostDeleted && this.PostData.CanReply &&
                !this.PostData.IsLocked)
            {
                this.ContextMenu.Attributes.Add(
                    "data-url",
                    BuildLink.GetLinkNotEscaped(
                        ForumPages.PostMessage,
                        "t={0}&f={1}",
                        this.PageContext.PageTopicID,
                        this.PageContext.PageForumID));

                this.ContextMenu.Attributes.Add(
                    "data-quote",
                    this.GetText("COMMON", "SELECTED_QUOTE"));
            }

            this.ContextMenu.Attributes.Add(
                "data-search",
                this.GetText("COMMON", "SELECTED_SEARCH"));

            if (!this.PageContext.IsMobileDevice)
            {
                this.Quote.Text       = this.GetText("BUTTON_QUOTE_TT");
                this.ReplyFooter.Text = this.GetText("REPLY");
            }

            this.MultiQuote.Visible = !this.PostData.PostDeleted && this.PostData.CanReply && !this.PostData.IsLocked;

            this.Quote.NavigateUrl = this.Quote2.NavigateUrl = BuildLink.GetLinkNotEscaped(
                ForumPages.PostMessage,
                "t={0}&f={1}&q={2}",
                this.PageContext.PageTopicID,
                this.PageContext.PageForumID,
                this.PostData.MessageId);

            this.Reply.NavigateUrl = this.ReplyFooter.NavigateUrl = BuildLink.GetLinkNotEscaped(
                ForumPages.PostMessage,
                "t={0}&f={1}",
                this.PageContext.PageTopicID,
                this.PageContext.PageForumID);

            if (this.MultiQuote.Visible)
            {
                this.MultiQuote.Attributes.Add(
                    "onclick",
                    $"handleMultiQuoteButton(this, '{this.PostData.MessageId}', '{this.PostData.TopicId}')");

                BoardContext.Current.PageElements.RegisterJsBlockStartup(
                    "MultiQuoteButtonJs",
                    JavaScriptBlocks.MultiQuoteButtonJs);
                BoardContext.Current.PageElements.RegisterJsBlockStartup(
                    "MultiQuoteCallbackSuccessJS",
                    JavaScriptBlocks.MultiQuoteCallbackSuccessJs);

                var icon = new Icon {
                    IconName = "quote-left", IconNameBadge = "plus"
                };

                this.MultiQuote.Text = this.PageContext.IsMobileDevice
                                           ? icon.RenderToString()
                                           : $"{icon.RenderToString()}&nbsp;{this.GetText("BUTTON_MULTI_QUOTE")}";

                this.MultiQuote.ToolTip = this.GetText("BUTTON_MULTI_QUOTE_TT");
            }

            if (this.Get <BoardSettings>().EnableUserReputation)
            {
                this.AddReputationControls();
            }

            if (this.Edit.Visible || this.Delete.Visible || this.MovePost.Visible)
            {
                this.ManageDropPlaceHolder.Visible = true;
            }
            else
            {
                this.ManageDropPlaceHolder.Visible = false;
            }

            BoardContext.Current.PageElements.RegisterJsBlockStartup(
                "asynchCallFailedJs",
                "function CallFailed(res){console.log(res);  }");

            this.FormatThanksRow();

            this.ShowIpInfo();

            this.panMessage.CssClass = "col";

            var userId = this.PostData.UserId;

            var avatarUrl   = this.Get <IAvatars>().GetAvatarUrlForUser(userId);
            var displayName = this.Get <BoardSettings>().EnableDisplayName
                                  ? UserMembershipHelper.GetDisplayNameFromID(userId)
                                  : UserMembershipHelper.GetUserNameFromID(userId);

            if (avatarUrl.IsSet())
            {
                this.Avatar.Visible       = true;
                this.Avatar.AlternateText = displayName;
                this.Avatar.ToolTip       = displayName;
                this.Avatar.ImageUrl      = avatarUrl;
            }
            else
            {
                this.Avatar.Visible = false;
            }

            // report post
            if (this.Get <IPermissions>().Check(this.Get <BoardSettings>().ReportPostPermissions) &&
                !this.PostData.PostDeleted)
            {
                if (!this.PageContext.IsGuest && this.PageContext.User != null)
                {
                    this.ReportPost.Visible = this.ReportPost2.Visible = true;

                    this.ReportPost.NavigateUrl = this.ReportPost2.NavigateUrl = BuildLink.GetLinkNotEscaped(
                        ForumPages.ReportPost,
                        "m={0}",
                        this.PostData.MessageId);
                }
            }

            // mark post as answer
            if (!this.PostData.PostDeleted && !this.PageContext.IsGuest && this.PageContext.User != null &&
                this.PageContext.PageUserID.Equals(this.DataRow["TopicOwnerID"].ToType <int>()) &&
                !this.PostData.UserId.Equals(this.PageContext.PageUserID))
            {
                this.MarkAsAnswer.Visible = true;

                if (this.PostData.PostIsAnswer)
                {
                    this.MarkAsAnswer.TextLocalizedTag  = "MARK_ANSWER_REMOVE";
                    this.MarkAsAnswer.TitleLocalizedTag = "MARK_ANSWER_REMOVE_TITLE";
                    this.MarkAsAnswer.Icon      = "minus-square";
                    this.MarkAsAnswer.IconColor = "text-danger";
                }
                else
                {
                    this.MarkAsAnswer.TextLocalizedTag  = "MARK_ANSWER";
                    this.MarkAsAnswer.TitleLocalizedTag = "MARK_ANSWER_TITLE";
                    this.MarkAsAnswer.Icon      = "check-square";
                    this.MarkAsAnswer.IconColor = "text-success";
                }
            }

            if (this.ReportPost.Visible == false && this.MarkAsAnswer.Visible == false &&
                this.ReportPost.Visible == false &&
                this.ManageDropPlaceHolder.Visible == false)
            {
                this.ToolsHolder.Visible = false;
            }

            if (this.ThanksDataLiteral.Visible == false &&
                this.Thank.Visible == false &&
                this.Quote.Visible == false && this.MultiQuote.Visible == false)
            {
                this.Footer.Visible = false;
            }

            base.OnPreRender(e);
        }
Example #22
0
        /// <summary>
        /// the page load event.
        /// </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)
        {
            if (!this.Get <YafBoardSettings>().EnableAlbum)
            {
                YafBuildLink.AccessDenied();
            }

            if (this.IsPostBack)
            {
                return;
            }

            var sigData = this.GetRepository <User>().AlbumsDataAsDataTable(
                this.PageContext.PageUserID,
                YafContext.Current.PageBoardID);

            var usrAlbumsAllowed = sigData.GetFirstRowColumnAsValue <int?>("UsrAlbums", null);

            var albumSize = this.GetRepository <UserAlbum>().CountUserAlbum(this.PageContext.PageUserID);
            int userID;

            switch (this.Get <HttpRequestBase>().QueryString.GetFirstOrDefault("a"))
            {
            // A new album is being created. check the permissions.
            case "new":

                // Is album feature enabled?
                if (!this.Get <YafBoardSettings>().EnableAlbum)
                {
                    YafBuildLink.AccessDenied();
                }

                // Has the user created maximum number of albums?
                if (usrAlbumsAllowed.HasValue && usrAlbumsAllowed > 0)
                {
                    // Albums count. If we reached limit then we go to info page.
                    if (usrAlbumsAllowed > 0 && albumSize >= usrAlbumsAllowed)
                    {
                        YafBuildLink.RedirectInfoPage(InfoMessage.AccessDenied);
                    }
                }

                /* if (this.Get<YafBoardSettings>().AlbumsMax > 0 &&
                 *                  albumSize[0] > this.Get<YafBoardSettings>().AlbumsMax - 1)
                 *        {
                 *            YafBuildLink.RedirectInfoPage(InfoMessage.AccessDenied);
                 *        }*/
                userID = this.PageContext.PageUserID;
                break;

            default:
                userID = this.GetRepository <UserAlbum>().List(
                    Security.StringToIntOrRedirect(
                        this.Get <HttpRequestBase>().QueryString.GetFirstOrDefault("a")))
                         .FirstOrDefault().UserID;

                if (userID != this.PageContext.PageUserID)
                {
                    YafBuildLink.AccessDenied();
                }

                break;
            }

            var displayName = YafContext.Current.Get <YafBoardSettings>().EnableDisplayName
                                  ? UserMembershipHelper.GetDisplayNameFromID(userID)
                                  : UserMembershipHelper.GetUserNameFromID(userID);

            // Add the page links.
            this.PageLinks.AddRoot();
            this.PageLinks.AddLink(
                displayName,
                YafBuildLink.GetLink(ForumPages.profile, "u={0}&name={1}", userID.ToString(), displayName));
            this.PageLinks.AddLink(
                this.GetText("ALBUMS"),
                YafBuildLink.GetLink(ForumPages.albums, "u={0}", userID.ToString()));
            this.PageLinks.AddLink(this.GetText("TITLE"), string.Empty);

            this.BindData();

            var usrAlbumImagesAllowed = sigData.GetFirstRowColumnAsValue <int?>("UsrAlbumImages", null);

            // Has the user uploaded maximum number of images?
            // vzrus: changed for DB check The default number of album images is 0. In the case albums are disabled.
            if (usrAlbumImagesAllowed.HasValue && usrAlbumImagesAllowed > 0)
            {
                if (this.List.Items.Count >= usrAlbumImagesAllowed)
                {
                    this.uploadtitletr.Visible = false;
                    this.selectfiletr.Visible  = false;
                }
                else
                {
                    this.uploadtitletr.Visible = true;
                    this.selectfiletr.Visible  = true;
                }

                this.imagesInfo.Text = this.GetTextFormatted(
                    "IMAGES_INFO",
                    this.List.Items.Count,
                    usrAlbumImagesAllowed,
                    this.Get <YafBoardSettings>().AlbumImagesSizeMax / 1024);
            }
            else
            {
                this.uploadtitletr.Visible = false;
                this.selectfiletr.Visible  = false;
            }
        }
Example #23
0
        /// <summary>
        /// Called when the page loads
        /// </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)
        {
            if (this.IsPostBack)
            {
                return;
            }

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

            this.AlbumHeaderLabel.Param0 = this.Get <YafBoardSettings>().EnableDisplayName
                                               ? this.HtmlEncode(umhdn)
                                               : this.HtmlEncode(UserMembershipHelper.GetUserNameFromID(this.UserID));

            this.BindData();

            HttpContext.Current.Session["imagePreviewWidth"]   = this.Get <YafBoardSettings>().ImageAttachmentResizeWidth;
            HttpContext.Current.Session["imagePreviewHeight"]  = this.Get <YafBoardSettings>().ImageAttachmentResizeHeight;
            HttpContext.Current.Session["imagePreviewCropped"] =
                this.Get <YafBoardSettings>().ImageAttachmentResizeCropped;
            HttpContext.Current.Session["localizationFile"] = this.Get <ILocalization>().LanguageFileName;

            // Show Albums Max Info
            if (this.UserID == this.PageContext.PageUserID)
            {
                this.albumsInfo.Text = this.Get <ILocalization>().GetTextFormatted(
                    "ALBUMS_INFO", this.PageContext.NumAlbums, this.PageContext.UsrAlbums);
                if (this.PageContext.UsrAlbums > this.PageContext.NumAlbums)
                {
                    this.AddAlbum.Visible = true;
                }

                this.albumsInfo.Text = this.PageContext.UsrAlbums > 0
                                           ? this.Get <ILocalization>().GetTextFormatted(
                    "ALBUMS_INFO", this.PageContext.NumAlbums, this.PageContext.UsrAlbums)
                                           : this.Get <ILocalization>().GetText("ALBUMS_NOTALLOWED");

                this.albumsInfo.Visible = true;
            }

            // vzrus: used if someone moderates usuful if a moderation is implemented

            /* else
             * {
             *  DataTable sigData = LegacyDb.user_getalbumsdata(this.PageContext.PageUserID, YafContext.Current.PageBoardID);
             *  DataTable usrAlbumsData = LegacyDb.user_getalbumsdata(this.PageContext.PageUserID, YafContext.Current.PageBoardID);
             *  var allowedAlbums = usrAlbumsData.GetFirstRowColumnAsValue<int?>("UsrAlbums", null);
             *  var numAlbums = usrAlbumsData.GetFirstRowColumnAsValue<int?>("NumAlbums", null);
             *
             *  if (allowedAlbums.HasValue && allowedAlbums > 0 && numAlbums < allowedAlbums)
             *  {
             *      this.AddAlbum.Visible = true;
             *  }
             *
             *  this.albumsInfo.Visible = false;
             * } */

            if (this.AddAlbum.Visible)
            {
                this.AddAlbum.Text = this.Get <ILocalization>().GetText("BUTTON", "BUTTON_ADDALBUM");
            }
        }
Example #24
0
        /// <summary>
        /// Do thanks row formatting.
        /// </summary>
        private void FormatThanksRow()
        {
            if (!this.Get <BoardSettings>().EnableThanksMod)
            {
                return;
            }

            if (this.PostData.PostDeleted || this.PostData.IsLocked)
            {
                return;
            }

            // Register Javascript
            var addThankBoxHTML =
                this.PageContext.IsMobileDevice ?
                "'<a class=\"btn btn-link\" href=\"javascript:addThanks(' + response.MessageID + ');\" onclick=\"jQuery(this).blur();\" title=' + response.Title + '><span><i class=\"fas fa-heart text-danger fa-fw\"></i></span></a>'" :
                "'<a class=\"btn btn-link\" href=\"javascript:addThanks(' + response.MessageID + ');\" onclick=\"jQuery(this).blur();\" title=' + response.Title + '><span><i class=\"fas fa-heart text-danger fa-fw\"></i>&nbsp;' + response.Text + '</span></a>'";

            var removeThankBoxHTML =
                this.PageContext.IsMobileDevice ?
                "'<a class=\"btn btn-link\" href=\"javascript:removeThanks(' + response.MessageID + ');\" onclick=\"jQuery(this).blur();\" title=' + response.Title + '><span><i class=\"far fa-heart fa-fw\"></i></a>'" :
                "'<a class=\"btn btn-link\" href=\"javascript:removeThanks(' + response.MessageID + ');\" onclick=\"jQuery(this).blur();\" title=' + response.Title + '><span><i class=\"far fa-heart fa-fw\"></i>&nbsp;' + response.Text + '</span></a>'";

            var thanksJs = "{0}{1}{2}".Fmt(
                JavaScriptBlocks.AddThanksJs(removeThankBoxHTML),
                Environment.NewLine,
                JavaScriptBlocks.RemoveThanksJs(addThankBoxHTML));

            this.PageContext.PageElements.RegisterJsBlockStartup("ThanksJs", thanksJs);

            this.Thank.Visible = this.PostData.CanThankPost && !this.PageContext.IsGuest &&
                                 this.Get <BoardSettings>().EnableThanksMod;

            if (this.DataRow.Field <bool>("IsThankedByUser"))
            {
                this.Thank.NavigateUrl = $"javascript:removeThanks({this.DataRow["MessageID"]});";

                if (!this.PageContext.IsMobileDevice)
                {
                    this.Thank.Text = this.GetText("BUTTON_THANKSDELETE");
                }

                this.Thank.TitleLocalizedTag = "BUTTON_THANKSDELETE_TT";
                this.Thank.Icon         = "heart";
                this.Thank.IconCssClass = "far";
            }
            else
            {
                this.Thank.NavigateUrl = $"javascript:addThanks({this.DataRow["MessageID"]});";

                if (!this.PageContext.IsMobileDevice)
                {
                    this.Thank.Text = this.GetText("BUTTON_THANKS");
                }

                this.Thank.TitleLocalizedTag = "BUTTON_THANKS_TT";
                this.Thank.Icon         = "heart";
                this.Thank.IconCssClass = "fas";
                this.Thank.IconColor    = "text-danger";
            }

            var thanksNumber = this.DataRow["MessageThanksNumber"].ToType <int>();

            if (thanksNumber == 0)
            {
                return;
            }

            var username = this.HtmlEncode(
                this.Get <BoardSettings>().EnableDisplayName
                    ? UserMembershipHelper.GetDisplayNameFromID(this.PostData.UserId)
                    : UserMembershipHelper.GetUserNameFromID(this.PostData.UserId));

            var thanksLabelText = thanksNumber == 1
                                      ? this.Get <ILocalization>().GetTextFormatted("THANKSINFOSINGLE", username)
                                      : this.Get <ILocalization>().GetTextFormatted(
                "THANKSINFO",
                thanksNumber,
                username);

            this.ThanksDataLiteral.Text = $@"<a class=""btn btn-sm btn-link thanks-popover"" 
                           data-toggle=""popover"" 
                           data-trigger=""click hover""
                           data-html=""true""
                           title=""{thanksLabelText}"" 
                           data-content=""{this.FormatThanksInfo(this.DataRow["ThanksInfo"].ToString()).ToJsString()}"">
                           <i class=""fa fa-heart"" style=""color:#e74c3c""></i>&nbsp;+{thanksNumber}
                  </a>";

            this.ThanksDataLiteral.Visible = true;
        }
Example #25
0
        /// <summary>
        /// The update profile_ click.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The e.</param>
        protected void UpdateProfile_Click([NotNull] object sender, [NotNull] EventArgs e)
        {
            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.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();
                }
            }

            string userName = UserMembershipHelper.GetUserNameFromID(this.currentUserID);

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

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

                string 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.Rows.Count > 0 && 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));

            YafContext.Current.Get <IDataCache>().Clear();

            if (!this.adminEditMode)
            {
                YafBuildLink.Redirect(ForumPages.cp_profile);
            }
            else
            {
                this._userData = null;
                this.BindData();
            }
        }
Example #26
0
        /// <summary>
        /// The password recovery 1_ verifying user.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        protected void PasswordRecovery1_VerifyingUser([NotNull] object sender, [NotNull] LoginCancelEventArgs e)
        {
            MembershipUser user = null;

            if (this.PasswordRecovery1.UserName.Contains("@") && this.Get <MembershipProvider>().RequiresUniqueEmail)
            {
                // Email Login
                var username = this.Get <MembershipProvider>().GetUserNameByEmail(this.PasswordRecovery1.UserName);
                if (username != null)
                {
                    user = this.Get <MembershipProvider>().GetUser(username, false);

                    // update the username
                    this.PasswordRecovery1.UserName = username;
                }
            }
            else
            {
                // Standard user name login
                if (this.Get <YafBoardSettings>().EnableDisplayName)
                {
                    // Display name login
                    var id = this.Get <IUserDisplayName>().GetId(this.PasswordRecovery1.UserName);

                    if (id.HasValue)
                    {
                        // get the username associated with this id...
                        var username = UserMembershipHelper.GetUserNameFromID(id.Value);

                        // update the username
                        this.PasswordRecovery1.UserName = username;
                    }

                    user = this.Get <MembershipProvider>().GetUser(this.PasswordRecovery1.UserName, false);
                }
            }

            if (user == null)
            {
                return;
            }

            // verify the user is approved, etc...
            if (user.IsApproved)
            {
                return;
            }

            if (this.Get <YafBoardSettings>().EmailVerification)
            {
                // get the hash from the db associated with this user...
                var checkTyped = this.GetRepository <CheckEmail>().ListTyped(user.Email).FirstOrDefault();

                if (checkTyped != null)
                {
                    // re-send verification email instead of lost password...
                    var verifyEmail = new YafTemplateEmail("VERIFYEMAIL");

                    string subject = this.GetTextFormatted("VERIFICATION_EMAIL_SUBJECT", this.Get <YafBoardSettings>().Name);

                    verifyEmail.TemplateParams["{link}"]      = YafBuildLink.GetLinkNotEscaped(ForumPages.approve, true, "k={0}", checkTyped.Hash);
                    verifyEmail.TemplateParams["{key}"]       = checkTyped.Hash;
                    verifyEmail.TemplateParams["{forumname}"] = this.Get <YafBoardSettings>().Name;
                    verifyEmail.TemplateParams["{forumlink}"] = "{0}".FormatWith(YafForumInfo.ForumURL);

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

                    this.PageContext.LoadMessage.AddSession(
                        this.GetTextFormatted("ACCOUNT_NOT_APPROVED_VERIFICATION", user.Email), MessageTypes.Warning);
                }
            }
            else
            {
                // explain they are not approved yet...
                this.PageContext.LoadMessage.AddSession(this.GetText("ACCOUNT_NOT_APPROVED"), MessageTypes.Warning);
            }

            // just in case cancel the verification...
            e.Cancel = true;

            // nothing they can do here... redirect to login...
            YafBuildLink.Redirect(ForumPages.login);
        }
Example #27
0
        /// <summary>
        /// Do thanks row formatting.
        /// </summary>
        private void FormatThanksRow()
        {
            if (!this.Get <YafBoardSettings>().EnableThanksMod)
            {
                return;
            }

            // Register Javascript
            const string AddThankBoxHTML =
                "'<a class=\"yaflittlebutton\" href=\"javascript:addThanks(' + res.d.MessageID + ');\" onclick=\"jQuery(this).blur();\" title=' + res.d.Title + '><span>' + res.d.Text + '</span></a>'";

            const string RemoveThankBoxHTML =
                "'<a class=\"yaflittlebutton\" href=\"javascript:removeThanks(' + res.d.MessageID + ');\" onclick=\"jQuery(this).blur();\" title=' + res.d.Title + '><span>' + res.d.Text + '</span></a>'";

            var thanksJs =
                this.Get <IScriptBuilder>().CreateStatement().Add(JavaScriptBlocks.AddThanksJs(RemoveThankBoxHTML)).AddLine().Add(JavaScriptBlocks.RemoveThanksJs(AddThankBoxHTML));

            YafContext.Current.PageElements.RegisterJsBlockStartup("ThanksJs", thanksJs);

            this.Thank.Visible = this.PostData.CanThankPost && !this.PageContext.IsGuest &&
                                 this.Get <YafBoardSettings>().EnableThanksMod;

            if (Convert.ToBoolean(this.DataRow["IsThankedByUser"]))
            {
                this.Thank.NavigateUrl       = "javascript:removeThanks({0});".FormatWith(this.DataRow["MessageID"]);
                this.Thank.TextLocalizedTag  = "BUTTON_THANKSDELETE";
                this.Thank.TitleLocalizedTag = "BUTTON_THANKSDELETE_TT";
            }
            else
            {
                this.Thank.NavigateUrl       = "javascript:addThanks({0});".FormatWith(this.DataRow["MessageID"]);
                this.Thank.TextLocalizedTag  = "BUTTON_THANKS";
                this.Thank.TitleLocalizedTag = "BUTTON_THANKS_TT";
            }

            var thanksNumber = this.DataRow["MessageThanksNumber"].ToType <int>();

            if (thanksNumber == 0)
            {
                return;
            }

            var username =
                this.HtmlEncode(
                    this.Get <YafBoardSettings>().EnableDisplayName
                        ? UserMembershipHelper.GetDisplayNameFromID(this.PostData.UserId)
                        : UserMembershipHelper.GetUserNameFromID(this.PostData.UserId));

            var thanksLabelText = thanksNumber == 1
                                  ? this.Get <ILocalization>().GetText("THANKSINFOSINGLE").FormatWith(username)
                                  : this.Get <ILocalization>().GetText("THANKSINFO").FormatWith(thanksNumber, username);

            this.ThanksDataLiteral.Text =
                "<img id=\"ThanksInfoImage{0}\" src=\"{1}\" alt=\"thanks\"  runat=\"server\" />&nbsp;{2}".FormatWith(
                    this.DataRow["MessageID"],
                    this.Get <ITheme>().GetItem("ICONS", "THANKSINFOLIST_IMAGE"),
                    thanksLabelText);

            this.ThanksDataLiteral.Visible = true;

            this.thanksDataExtendedLiteral.Text    = this.FormatThanksInfo(this.DataRow["ThanksInfo"].ToString());
            this.thanksDataExtendedLiteral.Visible = true;
        }
Example #28
0
        /// <summary>
        /// Do thanks row formatting.
        /// </summary>
        private void FormatThanksRow()
        {
            if (!this.Get <YafBoardSettings>().EnableThanksMod)
            {
                return;
            }

            if (this.PostData.PostDeleted || this.PostData.IsLocked)
            {
                return;
            }

            // Register Javascript
            const string AddThankBoxHTML =
                "'<a class=\"yaflittlebutton\" href=\"javascript:addThanks(' + res.d.MessageID + ');\" onclick=\"jQuery(this).blur();\" title=' + res.d.Title + '><span>' + res.d.Text + '</span></a>'";

            const string RemoveThankBoxHTML =
                "'<a class=\"yaflittlebutton\" href=\"javascript:removeThanks(' + res.d.MessageID + ');\" onclick=\"jQuery(this).blur();\" title=' + res.d.Title + '><span>' + res.d.Text + '</span></a>'";

            var thanksJs = JavaScriptBlocks.AddThanksJs(RemoveThankBoxHTML) + Environment.NewLine + JavaScriptBlocks.RemoveThanksJs(AddThankBoxHTML);

            YafContext.Current.PageElements.RegisterJsBlockStartup("ThanksJs", thanksJs);

            this.Thank.Visible = this.PostData.CanThankPost && !this.PageContext.IsGuest &&
                                 this.Get <YafBoardSettings>().EnableThanksMod;

            if (Convert.ToBoolean(this.DataRow["IsThankedByUser"]))
            {
                this.Thank.NavigateUrl       = "javascript:removeThanks({0});".FormatWith(this.DataRow["MessageID"]);
                this.Thank.TextLocalizedTag  = "BUTTON_THANKSDELETE";
                this.Thank.TitleLocalizedTag = "BUTTON_THANKSDELETE_TT";
            }
            else
            {
                this.Thank.NavigateUrl       = "javascript:addThanks({0});".FormatWith(this.DataRow["MessageID"]);
                this.Thank.TextLocalizedTag  = "BUTTON_THANKS";
                this.Thank.TitleLocalizedTag = "BUTTON_THANKS_TT";
            }

            var thanksNumber = this.DataRow["MessageThanksNumber"].ToType <int>();

            if (thanksNumber == 0)
            {
                return;
            }

            var username =
                this.HtmlEncode(
                    this.Get <YafBoardSettings>().EnableDisplayName
                        ? UserMembershipHelper.GetDisplayNameFromID(this.PostData.UserId)
                        : UserMembershipHelper.GetUserNameFromID(this.PostData.UserId));

            var thanksLabelText = thanksNumber == 1
                                  ? this.Get <ILocalization>().GetText("THANKSINFOSINGLE").FormatWith(username)
                                  : this.Get <ILocalization>().GetText("THANKSINFO").FormatWith(thanksNumber, username);

            this.ThanksDataLiteral.Text =
                "<i class=\"fa fa-heart\" style=\"color:#e74c3c\"></i>&nbsp;{0}".FormatWith(thanksLabelText);

            this.ThanksDataLiteral.Visible = true;

            this.thanksDataExtendedLiteral.Text    = this.FormatThanksInfo(this.DataRow["ThanksInfo"].ToString());
            this.thanksDataExtendedLiteral.Visible = true;
        }
Example #29
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 UpdateProfileClick([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://{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 <BoardSettings>().IgnoreSpamWordCheckPostCount)
                {
                    // Check for spam
                    if (this.Get <ISpamWordCheck>().CheckForSpamWord(this.HomePage.Text, out _))
                    {
                        // Log and Send Message to Admins
                        if (this.Get <BoardSettings>().BotHandlingOnRegister.Equals(1))
                        {
                            this.Logger.Log(
                                null,
                                "Bot Detected",
                                $"Internal Spam Word Check detected a SPAM BOT: (user name : '{userName}', user id : '{this.currentUserId}') after the user changed the profile Homepage url to: {this.HomePage.Text}",
                                EventLogTypes.SpamBotDetected);
                        }
                        else if (this.Get <BoardSettings>().BotHandlingOnRegister.Equals(2))
                        {
                            this.Logger.Log(
                                null,
                                "Bot Detected",
                                $"Internal Spam Word Check detected a SPAM BOT: (user name : '{userName}', user id : '{this.currentUserId}') after the user changed the profile Homepage url to: {this.HomePage.Text}, user was deleted and the name, email and IP Address are banned.",
                                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.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;
            }

            string displayName = null;

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

                    return;
                }

                // Check if name matches the required minimum length
                if (this.DisplayName.Text.Length > this.Get <BoardSettings>().UserNameMaxLength)
                {
                    this.PageContext.AddLoadMessage(
                        this.GetTextFormatted("USERNAME_TOOLONG", this.Get <BoardSettings>().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.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);

            // save remaining settings to the DB
            this.GetRepository <User>().Save(
                this.currentUserId,
                this.PageContext.PageBoardID,
                null,
                displayName,
                null,
                this.UserData.TimeZoneInfo.Id,
                this.UserData.LanguageFile,
                this.UserData.CultureUser,
                this.UserData.ThemeFile,
                this.UserData.TextEditor,
                null,
                null,
                null,
                false,
                this.UserData.IsActiveExcluded,
                null);

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

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

            if (!this.PageContext.CurrentForumPage.IsAdminPage)
            {
                BuildLink.Redirect(ForumPages.cp_profile);
            }
            else
            {
                this.userData = null;
                this.BindData();
            }
        }
        protected void UpdateProfile_Click(object sender, System.EventArgs e)
        {
            if (HomePage.Text.Length > 0 && !HomePage.Text.StartsWith("http://"))
            {
                HomePage.Text = "http://" + HomePage.Text;
            }

            if (MSN.Text.Length > 0 && !General.IsValidEmail(MSN.Text))
            {
                PageContext.AddLoadMessage(PageContext.Localization.GetText("PROFILE", "BAD_MSN"));
                return;
            }
            if (HomePage.Text.Length > 0 && !General.IsValidURL(HomePage.Text))
            {
                PageContext.AddLoadMessage(PageContext.Localization.GetText("PROFILE", "BAD_HOME"));
                return;
            }
            if (Weblog.Text.Length > 0 && !General.IsValidURL(Weblog.Text))
            {
                PageContext.AddLoadMessage(PageContext.Localization.GetText("PROFILE", "BAD_WEBLOG"));
                return;
            }
            if (ICQ.Text.Length > 0 && !General.IsValidInt(ICQ.Text))
            {
                PageContext.AddLoadMessage(PageContext.Localization.GetText("PROFILE", "BAD_ICQ"));
                return;
            }

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

                if (!General.IsValidEmail(newEmail))
                {
                    PageContext.AddLoadMessage(PageContext.Localization.GetText("PROFILE", "BAD_EMAIL"));
                    return;
                }

                if (PageContext.BoardSettings.EmailVerification)
                {
                    string hashinput = DateTime.Now.ToString() + Email.Text + Security.CreatePassword(20);
                    string hash      = FormsAuthentication.HashPasswordForStoringInConfigFile(hashinput, "md5");

                    // Create Email
                    YafTemplateEmail changeEmail = new YafTemplateEmail("CHANGEEMAIL");

                    changeEmail.TemplateParams ["{user}"]      = PageContext.PageUserName;
                    changeEmail.TemplateParams ["{link}"]      = String.Format("{1}{0}\r\n\r\n", YAF.Classes.Utils.YafBuildLink.GetLinkNotEscaped(YAF.Classes.Utils.ForumPages.approve, "k={0}", hash), YafForumInfo.ServerURL);
                    changeEmail.TemplateParams ["{newemail}"]  = Email.Text;
                    changeEmail.TemplateParams ["{key}"]       = hash;
                    changeEmail.TemplateParams ["{forumname}"] = PageContext.BoardSettings.Name;
                    changeEmail.TemplateParams ["{forumlink}"] = YafForumInfo.ForumURL;

                    // save a change email reference to the db
                    YAF.Classes.Data.DB.checkemail_save(CurrentUserID, hash, newEmail);

                    //  send a change email message...
                    changeEmail.SendEmail(new System.Net.Mail.MailAddress(newEmail), PageContext.Localization.GetText("COMMON", "CHANGEEMAIL_SUBJECT"), true);

                    // show a confirmation
                    PageContext.AddLoadMessage(String.Format(PageContext.Localization.GetText("PROFILE", "mail_sent"), Email.Text));
                }
                else
                {
                    // just update the e-mail...
                    UserMembershipHelper.UpdateEmail(CurrentUserID, Email.Text.Trim());
                }
            }

            string userName = UserMembershipHelper.GetUserNameFromID(CurrentUserID);

            YafUserProfile userProfile = PageContext.GetProfile(userName);

            userProfile.Location            = Location.Text.Trim();
            userProfile.Homepage            = HomePage.Text.Trim();
            userProfile.MSN                 = MSN.Text.Trim();
            userProfile.YIM                 = YIM.Text.Trim();
            userProfile.AIM                 = AIM.Text.Trim();
            userProfile.ICQ                 = ICQ.Text.Trim();
            userProfile.Skype               = Skype.Text.Trim();
            userProfile.RealName            = Realname.Text.Trim();
            userProfile.Occupation          = Occupation.Text.Trim();
            userProfile.Interests           = Interests.Text.Trim();
            userProfile.Gender              = Gender.SelectedIndex;
            userProfile.Blog                = Weblog.Text.Trim();
            userProfile.BlogServiceUrl      = WeblogUrl.Text.Trim();
            userProfile.BlogServiceUsername = WeblogUsername.Text.Trim();
            userProfile.BlogServicePassword = WeblogID.Text.Trim();

            userProfile.Save();

            // save remaining settings to the DB
            YAF.Classes.Data.DB.user_save(CurrentUserID, PageContext.PageBoardID, null, null,
                                          Convert.ToInt32(TimeZones.SelectedValue), Language.SelectedValue, Theme.SelectedValue, OverrideDefaultThemes.Checked, null, PMNotificationEnabled.Checked);

            if (!AdminEditMode)
            {
                YAF.Classes.Utils.YafBuildLink.Redirect(YAF.Classes.Utils.ForumPages.cp_profile);
            }
            else
            {
                BindData();
            }
        }