예제 #1
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<HttpRequestBase>().QueryString.Exists("m") || !this.PageContext.ForumModeratorAccess)
            {
                BuildLink.AccessDenied();
            }

            if (this.IsPostBack)
            {
                return;
            }

            this.PageLinks.AddRoot();

            this.PageLinks.AddLink(
                this.PageContext.PageCategoryName,
                BuildLink.GetLink(ForumPages.forum, "c={0}", this.PageContext.PageCategoryID));
            this.PageLinks.AddForum(this.PageContext.PageForumID);
            this.PageLinks.AddLink(
                this.PageContext.PageTopicName,
                BuildLink.GetLink(ForumPages.Posts, "t={0}", this.PageContext.PageTopicID));

            this.PageLinks.AddLink(this.GetText("MOVE_MESSAGE"));

            this.ForumList.DataSource = this.GetRepository<Forum>().ListAllSortedAsDataTable(
                this.PageContext.PageBoardID,
                this.PageContext.PageUserID);
            this.ForumList.DataTextField = "Title";
            this.ForumList.DataValueField = "ForumID";
            this.DataBind();

            this.ForumList.Items.FindByValue(this.PageContext.PageForumID.ToString()).Selected = true;
            this.ForumList_SelectedIndexChanged(this.ForumList, e);
        }
예제 #2
0
        /// <summary>
        /// The page_ load.
        /// </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.PageContext.ForumModeratorAccess)
            {
                BuildLink.AccessDenied();
            }

            if (!this.PageContext.IsForumModerator || !this.PageContext.IsAdmin)
            {
                this.ModerateUsersHolder.Visible = false;
            }

            if (!this.IsPostBack)
            {
                var showMoved = this.PageContext.BoardSettings.ShowMoved;

                // Ederon : 7/14/2007 - by default, leave pointer is set on value defined on host level
                this.LeavePointer.Checked = showMoved;

                this.trLeaveLink.Visible     = showMoved;
                this.trLeaveLinkDays.Visible = showMoved;

                if (showMoved)
                {
                    this.LinkDays.Text = "1";
                }
            }

            this.PageSize.DataSource     = StaticDataHelper.PageEntries();
            this.PageSize.DataTextField  = "Name";
            this.PageSize.DataValueField = "Value";
            this.PageSize.DataBind();

            this.BindData();
        }
예제 #3
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") ||
                !this.Get <HttpRequestBase>().QueryString.Exists("a"))
            {
                BuildLink.AccessDenied();
            }

            var displayName = this.Get <IUserDisplayName>().GetNameById(this.CurrentUserID);

            var album = this.GetRepository <UserAlbum>().GetById(this.AlbumID);

            // Generate the page links.
            this.PageLinks.Clear();
            this.PageLinks.AddRoot();
            this.PageLinks.AddUser(this.CurrentUserID, displayName);
            this.PageLinks.AddLink(this.GetText("ALBUMS"), BuildLink.GetLink(ForumPages.Albums, "u={0}", this.CurrentUserID));
            this.PageLinks.AddLink(this.GetText("TITLE"), string.Empty);

            // Set the title text.
            this.LocalizedLabel1.Param0 = this.Server.HtmlEncode(displayName);
            this.LocalizedLabel1.Param1 =
                this.Server.HtmlEncode(album.Title);

            // Initialize the Album Image List control.
            this.AlbumImageList1.UserID    = this.CurrentUserID;
            this.AlbumImageList1.UserAlbum = album;

            this.EditAlbums.Visible = this.PageContext.PageUserID == this.CurrentUserID;
        }
예제 #4
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 <HttpRequestBase>().QueryString.Exists("t") || !this.PageContext.ForumReadAccess ||
                !this.PageContext.BoardSettings.AllowEmailTopic)
            {
                BuildLink.AccessDenied();
            }

            if (this.IsPostBack)
            {
                return;
            }

            this.PageContext.PageElements.RegisterJsBlockStartup(
                nameof(JavaScriptBlocks.FormValidatorJs),
                JavaScriptBlocks.FormValidatorJs(this.SendEmail.ClientID));

            this.Subject.Text = this.PageContext.PageTopicName;

            var emailTopic = new TemplateEmail
            {
                TemplateParams =
                {
                    ["{link}"] = BuildLink.GetLink(
                        ForumPages.Posts,
                        true,
                        "t={0}&name={1}",
                        this.PageContext.PageTopicID,
                        this.PageContext.PageTopicName),
                    ["{user}"] = this.Get <IUserDisplayName>().GetName(this.PageContext.User)
                }
            };

            this.Message.Text = emailTopic.ProcessTemplate("EMAILTOPIC");
        }
예제 #5
0
        /// <summary>
        /// The page_ load.
        /// </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.PageContext.ForumModeratorAccess)
            {
                BuildLink.AccessDenied();
            }

            if (!this.PageContext.IsForumModerator || !this.PageContext.IsAdmin)
            {
                this.ModerateUsersHolder.Visible = false;
            }

            if (!this.IsPostBack)
            {
                this.PagerTop.PageSize = 25;

                var showMoved = this.Get <BoardSettings>().ShowMoved;

                // Ederon : 7/14/2007 - by default, leave pointer is set on value defined on host level
                this.LeavePointer.Checked = showMoved;

                this.trLeaveLink.Visible     = showMoved;
                this.trLeaveLinkDays.Visible = showMoved;

                if (showMoved)
                {
                    this.LinkDays.Text = "1";
                }
            }

            this.BindData();
        }
예제 #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)
        {
            if (Config.IsDotNetNuke || this.PageContext.IsAdmin || this.PageContext.IsHostAdmin)
            {
                BuildLink.AccessDenied();
            }

            if (this.IsPostBack)
            {
                return;
            }

            this.CreatePageLinks();

            this.Options.Items.Add(
                new ListItem(
                    $"<strong>{this.GetText("OPTION_SUSPEND_TITLE")}</strong><br />{this.GetText("OPTION_SUSPEND_TEXT")}",
                    "suspend"));
            this.Options.Items.Add(
                new ListItem(
                    $"<strong>{this.GetText("OPTION_DELETE_TITLE")}</strong><br />{this.GetText("OPTION_DELETE_TEXT")}",
                    "delete"));

            this.Options.SelectedIndex = 0;

            this.Cancel.NavigateUrl = BuildLink.GetLink(ForumPages.Account);

            this.DeleteUser.ReturnConfirmText = this.GetText("CONFIRM");
        }
예제 #7
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 <HttpRequestBase>().QueryString.Exists("m") || !this.PageContext.ForumModeratorAccess)
            {
                BuildLink.AccessDenied();
            }

            if (this.IsPostBack)
            {
                return;
            }

            var forumList = this.GetRepository <Forum>().ListAllSortedAsDataTable(
                this.PageContext.PageBoardID,
                this.PageContext.PageUserID);

            this.ForumList.AddForumAndCategoryIcons(forumList);

            this.ForumList.DataTextField  = "Title";
            this.ForumList.DataValueField = "ForumID";
            this.DataBind();

            this.ForumList.Items.FindByValue(this.PageContext.PageForumID.ToString()).Selected = true;
            this.ForumList_SelectedIndexChanged(this.ForumList, e);
        }
예제 #8
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 = this.GetRepository <User>().GetById(this.CurrentUserID);

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

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

            this.PageLinks.Clear();
            this.PageLinks.AddRoot();
            this.PageLinks.AddUser(this.CurrentUserID, this.Get <IUserDisplayName>().GetName(user));
            this.PageLinks.AddLink(this.GetText("ALBUMS"), string.Empty);

            // Initialize the Album List control.
            this.AlbumList1.User = user;
        }
예제 #9
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.StringToIntOrRedirect(this.Get <HttpRequestBase>().QueryString.GetFirstOrDefault("u"));

            var user = this.Get <IAspNetUsersHelper>().GetMembershipUserById(userId);

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

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

            // Initialize the Album List control.
            this.AlbumList1.UserID = userId.ToType <int>();
        }
예제 #10
0
        /// <summary>
        /// Handles the Load event of the AdminPage control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        private void AdminPageLoad([NotNull] object sender, [NotNull] EventArgs e)
        {
            if (!this.IsPostBack)
            {
                this.CreatePageLinks();
            }

            // not admins are forbidden
            if (!this.PageContext.IsAdmin)
            {
                BuildLink.AccessDenied();
            }

            // host admins are not checked
            if (this.PageContext.IsHostAdmin)
            {
                return;
            }

            // Load the page access list.
            var dt = this.GetRepository <AdminPageUserAccess>().List(
                this.PageContext.PageUserID, this.PageContext.ForumPageType.ToString().ToLowerInvariant());

            // Check access rights to the page.
            if (!this.PageContext.ForumPageType.ToString().IsSet() || dt == null || !dt.HasRows())
            {
                BuildLink.RedirectInfoPage(InfoMessage.HostAdminPermissionsAreRequired);
            }
        }
예제 #11
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 (Config.IsDotNetNuke)
            {
                // Not accessible...
                BuildLink.AccessDenied();
            }

            if (!this.Get <BoardSettings>().AllowPasswordChange&&
                !(this.PageContext.IsAdmin || this.PageContext.IsForumModerator))
            {
                // Not accessible...
                BuildLink.AccessDenied();
            }

            if (this.IsPostBack)
            {
                this.ContentBody.CssClass = "card-body was-validated";
                return;
            }

            this.NewPasswordCompare.ToolTip    = this.NewPasswordCompare.ErrorMessage = this.GetText("NO_PASSWORD_MATCH");
            this.NewOldPasswordCompare.ToolTip = this.NewOldPasswordCompare.ErrorMessage = this.GetText("PASSWORD_NOT_NEW");

            this.DataBind();
        }
예제 #12
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)
        {
            if (!this.PageContext.IsHostAdmin)
            {
                BuildLink.AccessDenied();
            }

            if (!this.IsPostBack)
            {
                this.RenderListItems();

                this.BindData();
            }

            this.ServerTimeCorrection.MaxLength = 4;

            this.UserNameMaxLength.MaxLength = 5;

            this.UserNameMaxLength.MaxLength = 3;

            this.PictureAttachmentDisplayTreshold.MaxLength = 11;

            // CheckCache
            this.CheckCache();

            // Hide Some settings if yaf is inside dnn
            this.AvatarSettingsHolder.Visible = !Config.IsDotNetNuke;
            this.SSLSettings.Visible          = !Config.IsDotNetNuke;
            this.BotRegisterCheck.Visible     = !Config.IsDotNetNuke;
            this.LoginSettings.Visible        = !Config.IsDotNetNuke;
        }
예제 #13
0
        /// <summary>
        /// The bind data.
        /// </summary>
        private void BindData()
        {
            var user = this.GetRepository <User>().GetBoardUser(this.UserId);

            if (user == null || user.Item1.ID == 0)
            {
                // No such user exists or this is an nntp user ("0")
                BuildLink.AccessDenied();
            }

            // populate user information controls...
            // Is BuddyList feature enabled?
            if (this.PageContext.BoardSettings.EnableBuddyList)
            {
                this.SetupBuddyList(this.UserId, user);
            }
            else
            {
                // BuddyList feature is disabled. don't show any link.
                this.lnkBuddy.Visible  = false;
                this.BuddyCard.Visible = false;
            }

            var userNameOrDisplayName = this.HtmlEncode(user.Item1.DisplayOrUserName());

            this.SetupUserProfileInfo(user);

            this.AddPageLinks(userNameOrDisplayName);

            this.SetupUserStatistics(user);

            this.SetupUserLinks(user, userNameOrDisplayName);

            this.SetupAvatar(user.Item1);

            var groups = this.GetRepository <UserGroup>().List(user.Item1.ID);

            this.Groups.DataSource = groups;

            this.ModerateTab.Visible = this.PageContext.IsAdmin || this.PageContext.IsForumModerator;

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

            if (this.LastPosts.Visible)
            {
                this.LastPosts.DataSource = this.GetRepository <Message>().GetAllUserMessagesWithAccess(
                    this.PageContext.PageBoardID,
                    this.UserId,
                    this.PageContext.PageUserID,
                    10);

                this.SearchUser.NavigateUrl = BuildLink.GetLink(
                    ForumPages.Search,
                    "postedby={0}",
                    userNameOrDisplayName);
            }

            this.DataBind();
        }
예제 #14
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>().AllowSignatures &&
         !(this.PageContext.IsAdmin || this.PageContext.IsForumModerator))
     {
         BuildLink.AccessDenied();
     }
 }
예제 #15
0
 /// <summary>
 /// Handles the Load event of the ModeratePage 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 ModeratePage_Load([NotNull] object sender, [NotNull] EventArgs e)
 {
     // Only moderators are allowed here
     if (!this.PageContext.IsModeratorInAnyForum)
     {
         BuildLink.AccessDenied();
     }
 }
예제 #16
0
파일: Team.ascx.cs 프로젝트: hnjm/YAFNET
        /// <summary>
        /// The on init.
        /// </summary>
        /// <param name="e">
        /// The e.
        /// </param>
        protected override void OnInit([NotNull] EventArgs e)
        {
            base.OnInit(e);

            if (!this.Get <IPermissions>().Check(this.Get <BoardSettings>().ShowTeamTo))
            {
                BuildLink.AccessDenied();
            }
        }
예제 #17
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)
            {
                BuildLink.AccessDenied();
            }

            if (this.IsPostBack)
            {
                return;
            }

            // get user data...
            var userHe = this.Get <IAspNetUsersHelper>().GetMembershipUserById(this.UserID);

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

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

            var displayNameHe = this.Get <IUserDisplayName>().GetName(this.UserID);

            this.PageLinks.AddRoot();
            this.PageLinks.AddUser(
                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
            {
                // get full user data...
                var userDataHe = this.Get <AspNetUsersHelper>().GetMembershipUserById(this.UserID);

                var serverHe = userDataHe.Profile_XMPP
                               .Substring(userDataHe.Profile_XMPP.IndexOf("@", StringComparison.Ordinal) + 1).Trim();

                var serverMe = this.PageContext.MembershipUser.Profile_XMPP
                               .Substring(this.PageContext.MembershipUser.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;
            }
        }
예제 #18
0
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Init"/> event.
        /// </summary>
        /// <param name="e">An <see cref="T:System.EventArgs"/> object that contains the event data.</param>
        protected override void OnInit([NotNull] EventArgs e)
        {
            this.DoSearch.Click += this.DoSearch_Click;
            base.OnInit(e);

            if (!this.Get <IPermissions>().Check(this.Get <BoardSettings>().ShowHelpTo))
            {
                BuildLink.AccessDenied();
            }
        }
예제 #19
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)
        {
            this.PageContext.QueryIDs = new QueryStringIDHelper("u", true);

            if (!this.PageContext.IsAdmin)
            {
                BuildLink.AccessDenied();
            }

            if (!this.IsPostBack)
            {
                this.rblPasswordResetFunction.Items.Add(
                    new ListItem(
                        this.Get <ILocalization>().GetText("ADMIN_EDITUSER", "PASS_OPTION_RESET"),
                        "reset",
                        true));
                this.rblPasswordResetFunction.Items.Add(
                    new ListItem(this.Get <ILocalization>().GetText("ADMIN_EDITUSER", "PASS_OPTION_CHANGE"), "change"));

                this.rblPasswordResetFunction.SelectedIndex = 0;

                this.btnResetPassword.Text =
                    $"<i class=\"fa fa-sync fa-fw\"></i>&nbsp;{this.GetText("ADMIN_EDITUSER", "RESET_PASS")}";
                this.btnChangePassword.Text =
                    $"<i class=\"fa fa-key fa-fw\"></i>&nbsp;{this.GetText("ADMIN_EDITUSER", "CHANGE_PASS")}";

                this.lblPassRequirements.Text = this.Get <ILocalization>().GetTextFormatted(
                    "PASS_REQUIREMENT",
                    this.Get <MembershipProvider>().MinRequiredPasswordLength,
                    this.Get <MembershipProvider>().MinRequiredNonAlphanumericCharacters);

                this.PasswordValidator.ErrorMessage =
                    this.Get <ILocalization>().GetText("ADMIN_EDITUSER", "ERROR_NEW_PASS");
                this.RequiredFieldValidator1.ErrorMessage =
                    this.Get <ILocalization>().GetText("ADMIN_EDITUSER", "ERROR_CONFIRM_PASS");
                this.CompareValidator1.ErrorMessage =
                    this.Get <ILocalization>().GetText("ADMIN_EDITUSER", "ERROR_PASS_NOTMATCH");

                if (this.Get <MembershipProvider>().EnablePasswordReset)
                {
                    return;
                }

                this.PasswordResetErrorHolder.Visible = true;
                this.btnResetPassword.Enabled         = false;
                this.rblPasswordResetFunction.Enabled = false;
            }
            else
            {
                this.btnResetPassword.Text =
                    $"<i class=\"fa fa-sync fa-fw\"></i>&nbsp;{this.GetText("ADMIN_EDITUSER", "RESET_PASS")}";
                this.btnChangePassword.Text =
                    $"<i class=\"fa fa-exchange fa-fw\"></i>&nbsp;{this.GetText("ADMIN_EDITUSER", "CHANGE_PASS")}";
            }
        }
예제 #20
0
        /// <summary>
        /// The post reply handle reply to topic.
        /// </summary>
        /// <param name="isSpamApproved">
        /// The is Spam Approved.
        /// </param>
        /// <returns>
        /// Returns the Message Id.
        /// </returns>
        protected int PostReplyHandleReplyToTopic(bool isSpamApproved)
        {
            if (!this.PageContext.ForumReplyAccess)
            {
                BuildLink.AccessDenied();
            }

            // Check if Forum is Moderated
            var isForumModerated = false;

            var forumInfo = this.GetRepository <Forum>()
                            .List(this.PageContext.PageBoardID, this.PageContext.PageForumID).FirstOrDefault();

            if (forumInfo != null)
            {
                isForumModerated = this.CheckForumModerateStatus(forumInfo, false);
            }

            // If Forum is Moderated
            if (isForumModerated)
            {
                isSpamApproved = false;
            }

            // Bypass Approval if Admin or Moderator
            if (this.PageContext.IsAdmin || this.PageContext.ForumModeratorAccess)
            {
                isSpamApproved = true;
            }

            var replyTo = this.QuotedMessageId;

            // make message flags
            var messageFlags = new MessageFlags
            {
                IsHtml       = this.forumEditor.UsesHTML,
                IsBBCode     = this.forumEditor.UsesBBCode,
                IsPersistent = this.PostOptions1.PersistentChecked,
                IsApproved   = isSpamApproved
            };

            var messageId = this.GetRepository <Message>().SaveNew(
                this.TopicId,
                this.PageContext.PageUserID,
                this.forumEditor.Text,
                this.User != null ? null : this.From.Text,
                this.Get <HttpRequestBase>().GetUserRealIPAddress(),
                DateTime.UtcNow,
                replyTo,
                messageFlags);

            this.UpdateWatchTopic(this.PageContext.PageUserID, this.PageContext.PageTopicID);

            return(messageId);
        }
예제 #21
0
        /// <summary>
        /// The handle request.
        /// </summary>
        /// <param name="permission">
        /// The permission.
        /// </param>
        public void HandleRequest(ViewPermissions permission)
        {
            var noAccess = true;

            if (!this.Check(permission))
            {
                if (permission == ViewPermissions.RegisteredUsers)
                {
                    if (!Config.AllowLoginAndLogoff && BoardContext.Current.BoardSettings.CustomLoginRedirectUrl.IsSet())
                    {
                        var loginRedirectUrl = BoardContext.Current.BoardSettings.CustomLoginRedirectUrl;

                        if (loginRedirectUrl.Contains("{0}"))
                        {
                            // process for return url..
                            loginRedirectUrl = string.Format(
                                loginRedirectUrl, HttpUtility.UrlEncode(
                                    General.GetSafeRawUrl(BoardContext.Current.Get <HttpRequestBase>().Url.ToString())));
                        }

                        // allow custom redirect...
                        BoardContext.Current.Get <HttpResponseBase>().Redirect(loginRedirectUrl);
                        noAccess = false;
                    }
                    else if (!Config.AllowLoginAndLogoff && Config.IsDotNetNuke)
                    {
                        // automatic DNN redirect...
                        var appPath = HostingEnvironment.ApplicationVirtualPath;
                        if (!appPath.EndsWith("/"))
                        {
                            appPath += "/";
                        }

                        // redirect to DNN login...
                        BoardContext.Current.Get <HttpResponseBase>().Redirect(
                            $"{appPath}Login.aspx?ReturnUrl={HttpUtility.UrlEncode(General.GetSafeRawUrl())}");
                        noAccess = false;
                    }
                    else if (Config.AllowLoginAndLogoff)
                    {
                        BuildLink.Redirect(
                            ForumPages.Login,
                            "ReturnUrl={0}",
                            HttpUtility.UrlEncode(General.GetSafeRawUrl()));
                        noAccess = false;
                    }
                }

                // fall-through with no access...
                if (noAccess)
                {
                    BuildLink.AccessDenied();
                }
            }
        }
예제 #22
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.Get <HttpRequestBase>().QueryString.Exists("t") || !this.PageContext.ForumReadAccess)
            {
                BuildLink.AccessDenied();
            }

            this.ShowToolBar = false;

            if (this.IsPostBack)
            {
                return;
            }

            var showDeleted = false;
            var userId      = 0;

            if (this.Get <BoardSettings>().ShowDeletedMessagesToAll)
            {
                showDeleted = true;
            }

            if (!showDeleted && (this.Get <BoardSettings>().ShowDeletedMessages&&
                                 !this.Get <BoardSettings>().ShowDeletedMessagesToAll ||
                                 this.PageContext.IsAdmin ||
                                 this.PageContext.ForumModeratorAccess))
            {
                userId = this.PageContext.PageUserID;
            }

            var dt = this.GetRepository <Message>().PostListAsDataTable(
                this.PageContext.PageTopicID,
                this.PageContext.PageUserID,
                userId,
                !this.PageContext.IsCrawler ? 1 : 0,
                showDeleted,
                false,
                false,
                DateTimeHelper.SqlDbMinTime(),
                DateTime.UtcNow,
                DateTimeHelper.SqlDbMinTime(),
                DateTime.UtcNow,
                0,
                500,
                2,
                0,
                0,
                false,
                -1);

            this.Posts.DataSource = dt.AsEnumerable();

            this.DataBind();
        }
예제 #23
0
        /// <summary>
        /// Handles 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)
        {
            // only moderators/admins are allowed in
            if (!this.PageContext.ForumModeratorAccess)
            {
                BuildLink.AccessDenied();
            }

            // do not repeat on post-back
            if (this.IsPostBack)
            {
                return;
            }

            // create page links
            this.CreatePageLinks();

            // load localized texts for buttons
            this.FindUsers.Text = this.GetText("FIND");

            // bind data
            this.DataBind();

            // if there is concrete user being handled
            if (!this.Get <HttpRequestBase>().QueryString.Exists("u"))
            {
                return;
            }

            var userForum = this.GetRepository <UserForum>().List(
                this.Get <HttpRequestBase>().QueryString.GetFirstOrDefaultAsInt("u"),
                this.Get <HttpRequestBase>().QueryString.GetFirstOrDefaultAsInt("f").Value).FirstOrDefault();

            if (userForum == null)
            {
                return;
            }

            // set username and disable its editing
            this.UserName.Text = this.PageContext.BoardSettings.EnableDisplayName
                                     ? userForum.Item1.DisplayName
                                     : userForum.Item1.Name;
            this.UserName.Enabled = false;

            // we don't need to find users now
            this.FindUsers.Visible = false;

            // get access mask for this user
            if (this.AccessMaskID.Items.FindByValue(userForum.Item2.AccessMaskID.ToString()) != null)
            {
                this.AccessMaskID.Items.FindByValue(userForum.Item2.AccessMaskID.ToString()).Selected = true;
            }
        }
예제 #24
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.PageContext.IsGuest)
            {
                BuildLink.AccessDenied();
            }

            if (this.Get <HttpRequestBase>().QueryString.GetFirstOrDefault("m").IsSet())
            {
                if (!int.TryParse(this.Get <HttpRequestBase>().QueryString.GetFirstOrDefault("m"), out this.messageID))
                {
                    this.Get <HttpResponseBase>().Redirect(
                        BuildLink.GetLink(ForumPages.error, "Incorrect message value: {0}", this.messageID));
                }

                this.ReturnBtn.Visible = true;
            }

            if (this.Get <HttpRequestBase>().QueryString.GetFirstOrDefault("f").IsSet())
            {
                // We check here if the user have access to the option
                if (this.PageContext.IsGuest)
                {
                    this.Get <HttpResponseBase>().Redirect(BuildLink.GetLinkNotEscaped(ForumPages.info, "i=4"));
                }

                if (!int.TryParse(this.Get <HttpRequestBase>().QueryString.GetFirstOrDefault("f"), out this.forumID))
                {
                    this.Get <HttpResponseBase>().Redirect(
                        BuildLink.GetLink(ForumPages.error, "Incorrect forum value: {0}", this.forumID));
                }

                this.ReturnModBtn.Visible = true;
            }

            this.originalRow = this.GetRepository <Message>().SecAsDataTable(this.messageID, this.PageContext.PageUserID);

            if (this.originalRow.Rows.Count <= 0)
            {
                this.Get <HttpResponseBase>().Redirect(
                    BuildLink.GetLink(ForumPages.error, "Incorrect message value: {0}", this.messageID));
            }

            if (this.IsPostBack)
            {
                return;
            }

            this.PageLinks.AddLink(this.PageContext.BoardSettings.Name, BuildLink.GetLink(ForumPages.forum));
            this.PageLinks.AddLink(this.GetText("TITLE"), string.Empty);

            this.BindData();
        }
예제 #25
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.GetFirstRow();

            // 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.IconHeader.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 = this.Get <IAspNetUsersHelper>().GetMembershipUserById(this.CurrentUserId);

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

            this.EditUserTabs.DataBind();
        }
예제 #26
0
        /// <summary>
        /// The new topic_ click.
        /// </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 NewTopic_Click([NotNull] object sender, [NotNull] EventArgs e)
        {
            if (this.forum.ForumFlags.IsLocked)
            {
                this.PageContext.AddLoadMessage(this.GetText("WARN_FORUM_LOCKED"), MessageTypes.warning);
                return;
            }

            if (!this.PageContext.ForumPostAccess)
            {
                BuildLink.AccessDenied(/*"You don't have access to post new topics in this forum."*/);
            }
        }
예제 #27
0
        /// <summary>
        /// The setup reCAPTCHA control.
        /// </summary>
        private void SetupRecaptchaControl()
        {
            this.RecaptchaPlaceHolder.Visible = true;

            if (this.Get <BoardSettings>().RecaptchaPrivateKey.IsSet() &&
                this.Get <BoardSettings>().RecaptchaPublicKey.IsSet())
            {
                return;
            }

            this.Logger.Log(this.PageContext.PageUserID, this, "secret or site key is required for reCAPTCHA!");
            BuildLink.AccessDenied();
        }
예제 #28
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.PageContext.User.UserFlags.IsHostAdmin)
            {
                BuildLink.AccessDenied();
            }

            this.PageContext.PageElements.RegisterJsBlock(
                "tablesorterLoadJs",
                JavaScriptBlocks.LoadTableSorter(
                    ".table",
                    null));
        }
예제 #29
0
        /// <summary>
        /// Sets the IsOutbox property as appropriate for this private message.
        /// </summary>
        /// <param name="fromUserId">
        /// The from User Id.
        /// </param>
        /// <param name="toUserId">
        /// The to User Id.
        /// </param>
        /// <param name="messageIsInOutbox">
        /// Indicating whether the message is in the sender's outbox
        /// </param>
        /// <param name="messageIsArchived">
        /// The message Is Archived.
        /// </param>
        private void SetMessageView(
            [NotNull] int fromUserId,
            [NotNull] int toUserId,
            bool messageIsInOutbox,
            bool messageIsArchived)
        {
            var isCurrentUserFrom = fromUserId.Equals(this.PageContext.PageUserID);
            var isCurrentUserTo   = toUserId.Equals(this.PageContext.PageUserID);

            // check if it's the same user...
            if (isCurrentUserFrom && isCurrentUserTo)
            {
                // it is... handle the view based on the query string passed
                this.IsOutbox   = this.Get <HttpRequestBase>().QueryString.GetFirstOrDefault("v") == "out";
                this.IsArchived = this.Get <HttpRequestBase>().QueryString.GetFirstOrDefault("v") == "arch";

                // see if the message got deleted, if so, redirect to their outbox/archive
                if (this.IsOutbox && !messageIsInOutbox)
                {
                    BuildLink.Redirect(ForumPages.MyMessages, "v=out");
                }
                else if (this.IsArchived && !messageIsArchived)
                {
                    BuildLink.Redirect(ForumPages.MyMessages, "v=arch");
                }
            }
            else if (isCurrentUserFrom)
            {
                // see if it's been deleted by the from user...
                if (!messageIsInOutbox)
                {
                    // deleted for this user, redirect...
                    BuildLink.Redirect(ForumPages.MyMessages, "v=out");
                }
                else
                {
                    // nope
                    this.IsOutbox = true;
                }
            }
            else if (isCurrentUserTo)
            {
                // get the status for the receiver
                this.IsArchived = messageIsArchived;
                this.IsOutbox   = false;
            }
            else
            {
                BuildLink.AccessDenied();
            }
        }
예제 #30
0
        /// <summary>
        /// Called when the page loads
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e(EventArgs).
        /// </param>
        protected void Page_Load([NotNull] object sender, [NotNull] EventArgs e)
        {
            if (!this.Get <IPermissions>().Check(this.Get <BoardSettings>().ShowTeamTo))
            {
                BuildLink.AccessDenied();
            }

            if (this.IsPostBack)
            {
                return;
            }

            this.BindData();
        }