コード例 #1
0
ファイル: topics.ascx.cs プロジェクト: jre08/YAFNET
        /// <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)
        {
            this.Get <IYafSession>().UnreadTopics = 0;

            this.RssFeed.AdditionalParameters =
                "f={0}".FormatWith(this.Get <HttpRequestBase>().QueryString.GetFirstOrDefault("f"));

            this.ForumJumpHolder.Visible = this.Get <YafBoardSettings>().ShowForumJump &&
                                           this.PageContext.Settings.LockedForum == 0;

            this.LastPostImageTT = this.GetText("DEFAULT", "GO_LAST_POST");

            if (this.ForumSearchHolder.Visible)
            {
                this.forumSearch.Attributes["onkeydown"] =
                    "if(event.which || event.keyCode){{if ((event.which == 13) || (event.keyCode == 13)) {{document.getElementById('{0}').click();return false;}}}} else {{return true}}; "
                    .FormatWith(this.forumSearchOK.ClientID);
            }

            if (!this.IsPostBack)
            {
                // PageLinks.Clear();
                if (this.PageContext.Settings.LockedForum == 0)
                {
                    this.PageLinks.AddRoot();
                    this.PageLinks.AddLink(
                        this.PageContext.PageCategoryName,
                        YafBuildLink.GetLink(ForumPages.forum, "c={0}", this.PageContext.PageCategoryID));
                }

                this.PageLinks.AddForum(this.PageContext.PageForumID, true);

                this.ShowList.DataSource     = StaticDataHelper.TopicTimes();
                this.ShowList.DataTextField  = "TopicText";
                this.ShowList.DataValueField = "TopicValue";
                this._showTopicListSelected  = (this.Get <IYafSession>().ShowList == -1)
                                                  ? this.Get <YafBoardSettings>().ShowTopicsDefault
                                                  : this.Get <IYafSession>().ShowList;

                this.moderate1.NavigateUrl     =
                    this.moderate2.NavigateUrl =
                        YafBuildLink.GetLinkNotEscaped(ForumPages.moderating, "f={0}", this.PageContext.PageForumID);

                this.NewTopic1.NavigateUrl     =
                    this.NewTopic2.NavigateUrl =
                        YafBuildLink.GetLinkNotEscaped(ForumPages.postmessage, "f={0}", this.PageContext.PageForumID);

                this.HandleWatchForum();
            }

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

            if (this.PageContext.IsGuest && !this.PageContext.ForumReadAccess)
            {
                // attempt to get permission by redirecting to login...
                this.Get <IPermissions>().HandleRequest(ViewPermissions.RegisteredUsers);
            }
            else if (!this.PageContext.ForumReadAccess)
            {
                YafBuildLink.AccessDenied();
            }

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

            this._forum = dt.FirstOrDefault();

            if (this._forum.RemoteURL.IsSet())
            {
                this.Response.Clear();
                this.Response.Redirect(this._forum.RemoteURL);
            }

            this._forumFlags = this._forum.ForumFlags;

            this.PageTitle.Text = this._forum.Description.IsSet()
                                      ? "{0} - <em>{1}</em>".FormatWith(
                this.HtmlEncode(this._forum.Name),
                this.HtmlEncode(this._forum.Description))
                                      : this.HtmlEncode(this._forum.Name);

            this.BindData(); // Always because of yaf:TopicLine

            if (!this.PageContext.ForumPostAccess ||
                (this._forumFlags.IsLocked && !this.PageContext.ForumModeratorAccess))
            {
                this.NewTopic1.Visible = false;
                this.NewTopic2.Visible = false;
            }

            if (this.PageContext.ForumModeratorAccess)
            {
                return;
            }

            this.moderate1.Visible = false;
            this.moderate2.Visible = false;
        }
コード例 #2
0
ファイル: index.ascx.cs プロジェクト: happyyb/YAFNET
        /// <summary>
        /// Load the Complete Help Pages From the language File.
        /// </summary>
        private void LoadHelpContent()
        {
            if (!this.helpContents.Count.Equals(0))
            {
                return;
            }

            var helpNavigation = new List <YafHelpNavigation>();

            var serializer = new XmlSerializer(typeof(List <YafHelpNavigation>));

            var xmlFilePath =
                HttpContext.Current.Server.MapPath($"{YafForumInfo.ForumServerFileRoot}Resources/{"HelpMenuList.xml"}");

            if (File.Exists(xmlFilePath))
            {
                var reader = new StreamReader(xmlFilePath);

                helpNavigation = (List <YafHelpNavigation>)serializer.Deserialize(reader);

                reader.Close();
            }

            foreach (var helpPage in helpNavigation.SelectMany(category => category.HelpPages))
            {
                string helpContent;

                switch (helpPage.HelpPage)
                {
                case "RECOVER":
                {
                    helpContent = this.GetTextFormatted(
                        $"{helpPage.HelpPage}CONTENT",
                        YafBuildLink.GetLink(ForumPages.recoverpassword));
                }

                break;

                case "BBCODES":
                {
                    helpContent = this.GetTextFormatted(
                        $"{helpPage.HelpPage}CONTENT",
                        YafForumInfo.ForumBaseUrl);
                }

                break;

                case "POSTING":
                {
                    helpContent = this.GetTextFormatted(
                        $"{helpPage.HelpPage}CONTENT",
                        YafBuildLink.GetLink(ForumPages.help_index, "faq=bbcodes"));
                }

                break;

                default:
                {
                    helpContent = this.GetText($"{helpPage.HelpPage}CONTENT");
                }

                break;
                }

                this.helpContents.Add(
                    new YafHelpContent
                {
                    HelpPage    = helpPage.HelpPage,
                    HelpTitle   = this.GetText($"{helpPage.HelpPage}TITLE"),
                    HelpContent = helpContent
                });
            }
        }
コード例 #3
0
ファイル: Header.cs プロジェクト: TechnicsUser/newForum
        /// <summary>
        /// The render regular.
        /// </summary>
        /// <param name="writer">
        /// The writer.
        /// </param>
        protected void RenderRegular([NotNull] ref HtmlTextWriter writer)
        {
            // BEGIN HEADER
            var buildHeader = new StringBuilder();

            buildHeader.AppendFormat(
                @"<table width=""100%"" cellspacing=""0"" class=""content"" cellpadding=""0"" id=""yafheader""><tr>");

            MembershipUser user = UserMembershipHelper.GetUser();

            if (user != null)
            {
                string displayName = this.PageContext.CurrentUserData.DisplayName;
                buildHeader.AppendFormat(
                    @"<td style=""padding:5px"" class=""post"" align=""left""><strong>{0}&nbsp;<span id=""nick_{1}"" style =""{2}"" >{1}</span></strong></td>",
                    this.GetText("TOOLBAR", "LOGGED_IN_AS").FormatWith(string.Empty),
                    this.Get <HttpServerUtilityBase>().HtmlEncode(
                        this.Get <YafBoardSettings>().EnableDisplayName&& displayName.IsSet() ? displayName : this.PageContext.PageUserName),
                    this.Get <YafBoardSettings>().UseStyledNicks
                        ? this.Get <IStyleTransform>().DecodeStyleByString(this.PageContext.UserStyle, false)
                        : null);

                buildHeader.AppendFormat(@"<td style=""padding:5px"" align=""right"" valign=""middle"" class=""post"">");

                if (!this.PageContext.IsGuest && this.Get <YafBoardSettings>().AllowPrivateMessages)
                {
                    if (this.PageContext.UnreadPrivate > 0)
                    {
                        string unreadText = this.GetText("TOOLBAR", "NEWPM").FormatWith(this.PageContext.UnreadPrivate);
                        buildHeader.AppendFormat("	<a target='_top' href=\"{0}\">{1}</a>&nbsp;<span class=\"unread\">{2}</span> | ".FormatWith(
                                                     YafBuildLink.GetLink(ForumPages.cp_pm), this.GetText("CP_PM", "INBOX"), unreadText));
                    }
                    else
                    {
                        buildHeader.AppendFormat(
                            "	<a target='_top' href=\"{0}\">{1}</a> | ".FormatWith(
                                YafBuildLink.GetLink(ForumPages.cp_pm), this.GetText("CP_PM", "INBOX")));
                    }
                }

                if (!this.PageContext.IsGuest && this.Get <YafBoardSettings>().EnableBuddyList&&
                    this.PageContext.UserHasBuddies)
                {
                    if (this.PageContext.PendingBuddies > 0)
                    {
                        string pendingBuddiesText =
                            this.GetText("TOOLBAR", "BUDDYREQUEST").FormatWith(this.PageContext.PendingBuddies);
                        buildHeader.AppendFormat(
                            "	<a target='_top' href=\"{0}\">{1}</a>&nbsp;<span class=\"unread\">{2}</span> | ".FormatWith(
                                YafBuildLink.GetLink(ForumPages.cp_editbuddies),
                                this.GetText("TOOLBAR", "BUDDIES"),
                                pendingBuddiesText));
                    }
                    else
                    {
                        buildHeader.AppendFormat(
                            "	<a target='_top' href=\"{0}\">{1}</a> | ".FormatWith(
                                YafBuildLink.GetLink(ForumPages.cp_editbuddies), this.GetText("TOOLBAR", "BUDDIES")));
                    }
                }

                if (!this.PageContext.IsGuest && this.Get <YafBoardSettings>().EnableAlbum&&
                    (this.PageContext.UsrAlbums > 0 || this.PageContext.NumAlbums > 0))
                {
                    buildHeader.AppendFormat(
                        "	<a target='_top' href=\"{0}\">{1}</a> | ".FormatWith(
                            YafBuildLink.GetLink(ForumPages.albums, "u={0}", this.PageContext.PageUserID),
                            this.GetText("TOOLBAR", "MYALBUMS")));
                }

                buildHeader.AppendFormat(
                    "	<a target='_top' href=\"{0}\">{1}</a> | ".FormatWith(
                        YafBuildLink.GetLink(ForumPages.help_index), this.GetText("TOOLBAR", "HELP")));

                if (this.PageContext.IsAdmin)
                {
                    buildHeader.AppendFormat(
                        "	<a target='_top' href=\"{0}\">{1}</a> | ".FormatWith(
                            YafBuildLink.GetLink(ForumPages.admin_admin), this.GetText("TOOLBAR", "ADMIN")));
                }

                if (this.PageContext.IsModeratorInAnyForum)
                {
                    buildHeader.AppendFormat(
                        "	<a href=\"{0}\">{1}</a> | ".FormatWith(
                            YafBuildLink.GetLink(ForumPages.moderate_index), this.GetText("TOOLBAR", "MODERATE")));
                }

                if (this.Get <IPermissions>().Check(this.Get <YafBoardSettings>().ExternalSearchPermissions) ||
                    this.Get <IPermissions>().Check(this.Get <YafBoardSettings>().SearchPermissions))
                {
                    buildHeader.AppendFormat(
                        "	<a href=\"{0}\">{1}</a> | ".FormatWith(
                            YafBuildLink.GetLink(ForumPages.search), this.GetText("TOOLBAR", "SEARCH")));
                }

                if (!this.PageContext.IsGuest)
                {
                    buildHeader.AppendFormat(
                        "	<a href=\"{0}\">{1}</a> | ".FormatWith(
                            YafBuildLink.GetLink(ForumPages.mytopics), this.GetText("TOOLBAR", "MYTOPICS")));
                    buildHeader.AppendFormat(
                        "	<a href=\"{0}\">{1}</a> | ".FormatWith(
                            YafBuildLink.GetLink(ForumPages.cp_profile), this.GetText("TOOLBAR", "MYPROFILE")));
                }
                else
                {
                    buildHeader.AppendFormat(
                        "	<a href=\"{0}\">{1}</a> | ".FormatWith(
                            YafBuildLink.GetLink(ForumPages.mytopics), this.GetText("TOOLBAR", "ACTIVETOPICS")));
                }

                if (this.Get <IPermissions>().Check(this.Get <YafBoardSettings>().MembersListViewPermissions))
                {
                    buildHeader.AppendFormat(
                        "	<a href=\"{0}\">{1}</a> | ".FormatWith(
                            YafBuildLink.GetLink(ForumPages.members), this.GetText("TOOLBAR", "MEMBERS")));
                }

                if (!Config.IsAnyPortal && Config.AllowLoginAndLogoff)
                {
                    buildHeader.AppendFormat(
                        " <a href=\"{0}\" onclick=\"return confirm('{2}');\">{1}</a>".FormatWith(
                            YafBuildLink.GetLink(ForumPages.logout),
                            this.GetText("TOOLBAR", "LOGOUT"),
                            this.GetText("TOOLBAR", "LOGOUT_QUESTION")));
                }
            }
            else
            {
                buildHeader.AppendFormat(
                    @"<td style=""padding:5px"" class=""post"" align=""left""><strong>{0}</strong></td>".FormatWith(
                        this.GetText("TOOLBAR", "WELCOME_GUEST")));

                buildHeader.AppendFormat(@"<td style=""padding:5px"" align=""right"" valign=""middle"" class=""post"">");
                if (this.Get <IPermissions>().Check(this.Get <YafBoardSettings>().ExternalSearchPermissions) ||
                    this.Get <IPermissions>().Check(this.Get <YafBoardSettings>().SearchPermissions))
                {
                    buildHeader.AppendFormat(
                        "	<a href=\"{0}\">{1}</a> | ".FormatWith(
                            YafBuildLink.GetLink(ForumPages.search), this.GetText("TOOLBAR", "SEARCH")));
                }

                buildHeader.AppendFormat(
                    "	<a href=\"{0}\">{1}</a> | ".FormatWith(
                        YafBuildLink.GetLink(ForumPages.mytopics), this.GetText("TOOLBAR", "ACTIVETOPICS")));
                if (this.Get <IPermissions>().Check(this.Get <YafBoardSettings>().MembersListViewPermissions))
                {
                    buildHeader.AppendFormat(
                        "	<a href=\"{0}\">{1}</a> | ".FormatWith(
                            YafBuildLink.GetLink(ForumPages.members), this.GetText("TOOLBAR", "MEMBERS")));
                }

                string returnUrl = this.GetReturnUrl();

                if (!Config.IsAnyPortal && Config.AllowLoginAndLogoff)
                {
                    buildHeader.AppendFormat(
                        " <a href=\"{0}\">{1}</a>".FormatWith(
                            (returnUrl == string.Empty)
                                ? (!this.Get <YafBoardSettings>().UseSSLToLogIn
                                       ? YafBuildLink.GetLink(ForumPages.login)
                                       : YafBuildLink.GetLink(ForumPages.login, true).Replace("http:", "https:"))
                                : (!this.Get <YafBoardSettings>().UseSSLToLogIn
                                       ? YafBuildLink.GetLink(ForumPages.login, "ReturnUrl={0}", returnUrl)
                                       : YafBuildLink.GetLink(ForumPages.login, true, "ReturnUrl={0}", returnUrl).Replace("http:", "https:")),
                            this.GetText("TOOLBAR", "LOGIN")));

                    if (!this.Get <YafBoardSettings>().DisableRegistrations)
                    {
                        buildHeader.AppendFormat(
                            " | <a href=\"{0}\">{1}</a>".FormatWith(
                                this.Get <YafBoardSettings>().ShowRulesForRegistration
                                    ? YafBuildLink.GetLink(ForumPages.rules)
                                    : (!this.Get <YafBoardSettings>().UseSSLToRegister
                                           ? YafBuildLink.GetLink(ForumPages.register)
                                           : YafBuildLink.GetLink(ForumPages.register, true).Replace("http:", "https:")),
                                this.GetText("TOOLBAR", "REGISTER")));
                    }
                }
            }

            buildHeader.ToString().TrimEnd(' ', '|');
            buildHeader.Append("</td></tr></table>");
            buildHeader.Append("<br />");

            // END HEADER
            writer.Write(buildHeader);
        }
コード例 #4
0
ファイル: editmedal.ascx.cs プロジェクト: wqshabib/YAFNET
        /// <summary>
        /// Creates link to user editing admin interface.
        /// </summary>
        /// <param name="data">
        /// The data.
        /// </param>
        /// <returns>
        /// The format user link.
        /// </returns>
        protected string FormatUserLink([NotNull] object data)
        {
            var dr = (DataRowView)data;

            return("<a href=\"{2}\">{0}({1})</a>".FormatWith(
                       this.HtmlEncode(dr["DisplayName"]), this.HtmlEncode(dr["UserName"]), YafBuildLink.GetLink(ForumPages.admin_edituser, "u={0}", dr["UserID"])));
        }
コード例 #5
0
        /// <summary>
        /// Renders the ActiveDiscussions control.
        /// </summary>
        /// <param name="writer">
        /// The writer.
        /// </param>
        protected override void Render([NotNull] HtmlTextWriter writer)
        {
            // for HTML code string representing the control
            var html = new StringBuilder();

            // try to get data from the cache first
            var topicLatest = this.Get <IDataCache>().GetOrSet(
                Constants.Cache.ActiveDiscussions,
                () =>
            {
                // nothing was cached, retrieve it from the database
                var dt =
                    this.Get <IDbFunction>().GetAsDataTable(
                        cdb =>
                        cdb.topic_latest(
                            this.PageContext.PageBoardID,
                            this._displayNumber,
                            this.PageContext.PageUserID,
                            this.Get <YafBoardSettings>().UseStyledNicks,
                            this.Get <YafBoardSettings>().NoCountForumsInActiveDiscussions,
                            this.Get <YafBoardSettings>().UseReadTrackingByDatabase));

                // Set colorOnly parameter to true, as we get all but color from css in the place
                if (this.Get <YafBoardSettings>().UseStyledNicks)
                {
                    var styleTransform = this.Get <IStyleTransform>();
                    styleTransform.DecodeStyleByTable(dt, false, new[] { "LastUserStyle" });
                }

                return(dt);
            },
                TimeSpan.FromMinutes(this.Get <YafBoardSettings>().ActiveDiscussionsCacheTimeout));

            // render head of control
            html.Append("<table width=\"100%\" class=\"content\" cellspacing=\"1\" border=\"0\" cellpadding=\"0\">");
            html.AppendFormat(
                "<tr><td class=\"header1\">{0}</td></tr>", this.GetText("LATEST_POSTS"));

            // now container for posts themselves
            html.Append("<tr><td class=\"post\">");

            // order of post we are currently rendering
            int currentPost = 1;

            // go through all active topics returned
            foreach (DataRow r in topicLatest.Rows)
            {
                // Output Topic Link
                html.AppendFormat(
                    "{2}.&nbsp;<a href=\"{1}\">{0}</a> ({3})",
                    this.Get <IBadWordReplace>().Replace(this.HtmlEncode(Convert.ToString(r["Topic"]))),
                    YafBuildLink.GetLink(ForumPages.posts, "m={0}#{0}", r["LastMessageID"]),
                    currentPost,
                    r["NumPosts"]);

                // new line after topic link
                html.Append("<br />");

                // moving onto next position
                currentPost++;
            }

            // close posts container
            html.Append("</td></tr></table>");

            // render control to the output
            writer.Write(html.ToString());
        }
コード例 #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>
        private void Page_Load([NotNull] object sender, [NotNull] EventArgs e)
        {
            if (Config.IsDotNetNuke)
            {
                // Not accessbile...
                YafBuildLink.AccessDenied();
            }

            if (!this.Get <YafBoardSettings>().AllowPasswordChange&&
                !(this.PageContext.IsAdmin || this.PageContext.IsForumModerator))
            {
                // Not accessbile...
                YafBuildLink.AccessDenied();
            }

            if (this.IsPostBack)
            {
                return;
            }

            this.PageLinks.AddRoot();
            this.PageLinks.AddLink(
                this.Get <YafBoardSettings>().EnableDisplayName
                    ? this.PageContext.CurrentUserData.DisplayName
                    : this.PageContext.PageUserName,
                YafBuildLink.GetLink(ForumPages.cp_profile));
            this.PageLinks.AddLink(this.GetText("TITLE"));

            var oldPasswordRequired =
                (RequiredFieldValidator)
                this.ChangePassword1.ChangePasswordTemplateContainer.FindControl("CurrentPasswordRequired");
            var newPasswordRequired =
                (RequiredFieldValidator)
                this.ChangePassword1.ChangePasswordTemplateContainer.FindControl("NewPasswordRequired");
            var confirmNewPasswordRequired =
                (RequiredFieldValidator)
                this.ChangePassword1.ChangePasswordTemplateContainer.FindControl("ConfirmNewPasswordRequired");
            var passwordsEqual =
                (CompareValidator)this.ChangePassword1.ChangePasswordTemplateContainer.FindControl("NewPasswordCompare");
            var passwordsNotEqual =
                (CompareValidator)
                this.ChangePassword1.ChangePasswordTemplateContainer.FindControl("NewOldPasswordCompare");

            oldPasswordRequired.ToolTip                 = oldPasswordRequired.ErrorMessage = this.GetText("NEED_OLD_PASSWORD");
            newPasswordRequired.ToolTip                 = newPasswordRequired.ErrorMessage = this.GetText("NEED_NEW_PASSWORD");
            confirmNewPasswordRequired.ToolTip          =
                confirmNewPasswordRequired.ErrorMessage = this.GetText("NEED_NEW_CONFIRM_PASSWORD");
            passwordsEqual.ToolTip    = passwordsEqual.ErrorMessage = this.GetText("NO_PASSWORD_MATCH");
            passwordsNotEqual.ToolTip = passwordsNotEqual.ErrorMessage = this.GetText("PASSWORD_NOT_NEW");

            ((Button)this.ChangePassword1.ChangePasswordTemplateContainer.FindControl("ChangePasswordPushButton")).Text
                = this.GetText("CHANGE_BUTTON");
            ((Button)this.ChangePassword1.ChangePasswordTemplateContainer.FindControl("CancelPushButton")).Text =
                this.GetText("CANCEL");
            ((Button)this.ChangePassword1.SuccessTemplateContainer.FindControl("ContinuePushButton")).Text =
                this.GetText("CONTINUE");

            // make failure text...
            // 1. Password incorrect or New Password invalid.
            // 2. New Password length minimum: {0}.
            // 3. Non-alphanumeric characters required: {1}.
            string failureText = this.GetText("PASSWORD_INCORRECT");

            failureText += "<br />{0}".FormatWith(this.GetText("PASSWORD_BAD_LENGTH"));
            failureText += "<br />{0}".FormatWith(this.GetText("PASSWORD_NOT_COMPLEX"));

            this.ChangePassword1.ChangePasswordFailureText = failureText;

            this.DataBind();
        }
コード例 #7
0
        /// <summary>
        /// The replace.
        /// </summary>
        /// <param name="text">
        /// The text.
        /// </param>
        /// <param name="replacement">
        /// The replacement.
        /// </param>
        public override void Replace(ref string text, IReplaceBlocks replacement)
        {
            var sb = new StringBuilder(text);

            var match = this._regExSearch.Match(text);

            while (match.Success)
            {
                var innerReplace = new StringBuilder(this._regExReplace);
                var i            = 0;

                if (this._truncateLength > 0)
                {
                    // special handling to truncate urls
                    innerReplace.Replace(
                        "${innertrunc}",
                        match.Groups["inner"].Value.TruncateMiddle(this._truncateLength));
                }

                var quote = match.Groups["quote"].Value;

                var localQuoteWrote  = YafContext.Current.Get <ILocalization>().GetText("COMMON", "BBCODE_QUOTEWROTE");
                var localQuotePosted = YafContext.Current.Get <ILocalization>().GetText("COMMON", "BBCODE_QUOTEPOSTED");

                // extract post id if exists
                if (quote.Contains(";"))
                {
                    string postId;

                    string userName;

                    try
                    {
                        postId   = quote.Substring(quote.LastIndexOf(";", StringComparison.Ordinal) + 1);
                        userName = quote = quote.Remove(quote.LastIndexOf(";", StringComparison.Ordinal));
                    }
                    catch (Exception)
                    {
                        // if post id is missing
                        postId   = string.Empty;
                        userName = quote;
                    }

                    quote = postId.IsSet()
                                ? $@"<div class=""card-header text-muted"">{localQuotePosted.Replace("{0}", userName)} <a href=""{YafBuildLink.GetLink(ForumPages.posts, "m={0}#post{0}", postId)}""><i class=""fas fa-external-link-alt""></i></a></div><div class=""card-body""><p class=""card-text"">"
                                : $@"<div class=""card-header text-muted"">{localQuoteWrote.Replace("{0}", quote)}</div><div class=""card-body""><p class=""card-text"">";
                }
                else
                {
                    quote =
                        $@"<div class=""card-header text-muted"">{localQuoteWrote.Replace("{0}", quote)}</div><div class=""card-body""><p class=""card-text"">";
                }

                innerReplace.Replace("${quote}", quote);

                this._variables.ForEach(
                    variable =>
                {
                    var varName       = variable;
                    var handlingValue = string.Empty;

                    if (varName.Contains(":"))
                    {
                        // has handling section
                        var tmpSplit  = varName.Split(':');
                        varName       = tmpSplit[0];
                        handlingValue = tmpSplit[1];
                    }

                    var value = match.Groups[varName].Value;

                    if (this._variableDefaults != null && value.Length == 0)
                    {
                        // use default instead
                        value = this._variableDefaults[i];
                    }

                    innerReplace.Replace(
                        $"${{{varName}}}",
                        this.ManageVariableValue(varName, value, handlingValue));
                    i++;
                });

                innerReplace.Replace("${inner}", match.Groups["inner"].Value);

                // pulls the html's into the replacement collection before it's inserted back into the main text
                replacement.ReplaceHtmlFromText(ref innerReplace);

                // remove old BBCode...
                sb.Remove(match.Groups[0].Index, match.Groups[0].Length);

                // insert replaced value(s)
                sb.Insert(match.Groups[0].Index, innerReplace.ToString());

                // text = text.Substring( 0, m.Groups [0].Index ) + tStr + text.Substring( m.Groups [0].Index + m.Groups [0].Length );
                match = this._regExSearch.Match(sb.ToString());
            }

            text = sb.ToString();
        }
コード例 #8
0
ファイル: boardsettings.ascx.cs プロジェクト: wqshabib/YAFNET
        /// <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.IsPostBack)
            {
                return;
            }

            var boardSettings = this.Get <YafBoardSettings>();

            this.PageLinks.AddLink(boardSettings.Name, YafBuildLink.GetLink(ForumPages.forum));
            this.PageLinks.AddLink(
                this.GetText("ADMIN_ADMIN", "Administration"), YafBuildLink.GetLink(ForumPages.admin_admin));
            this.PageLinks.AddLink(this.GetText("ADMIN_BOARDSETTINGS", "TITLE"), string.Empty);

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

            this.Save.Text = "<i class=\"fa fa-floppy-o fa-fw\"></i>&nbsp;{0}".FormatWith(this.GetText("SAVE"));

            // create list boxes by populating datasources from Data class
            var themeData = StaticDataHelper.Themes().AsEnumerable().Where(x => !x.Field <bool>("IsMobile"));

            if (themeData.Any())
            {
                this.Theme.DataSource     = themeData.CopyToDataTable();
                this.Theme.DataTextField  = "Theme";
                this.Theme.DataValueField = "FileName";
            }

            var mobileThemeData = StaticDataHelper.Themes().AsEnumerable().Where(x => x.Field <bool>("IsMobile"));

            if (mobileThemeData.Any())
            {
                var mobileThemes = mobileThemeData.CopyToDataTable();

                // Add Dummy Disabled Mobile Theme Item to allow disabling the Mobile Theme
                DataRow dr = mobileThemes.NewRow();
                dr["Theme"] = "[ {0} ]".FormatWith(this.GetText("ADMIN_COMMON", "DISABLED"));

                dr["FileName"] = string.Empty;
                dr["IsMobile"] = false;

                mobileThemes.Rows.InsertAt(dr, 0);

                this.MobileTheme.DataSource     = mobileThemes;
                this.MobileTheme.DataTextField  = "Theme";
                this.MobileTheme.DataValueField = "FileName";
            }

            this.Culture.DataSource =
                StaticDataHelper.Cultures()
                .AsEnumerable()
                .OrderBy(x => x.Field <string>("CultureNativeName"))
                .CopyToDataTable();

            this.Culture.DataTextField  = "CultureNativeName";
            this.Culture.DataValueField = "CultureTag";

            this.ShowTopic.DataSource     = StaticDataHelper.TopicTimes();
            this.ShowTopic.DataTextField  = "TopicText";
            this.ShowTopic.DataValueField = "TopicValue";

            this.FileExtensionAllow.DataSource     = StaticDataHelper.AllowDisallow();
            this.FileExtensionAllow.DataTextField  = "Text";
            this.FileExtensionAllow.DataValueField = "Value";

            this.BindData();

            // bind poll group list
            var pollGroup =
                LegacyDb.PollGroupList(this.PageContext.PageUserID, null, this.PageContext.PageBoardID)
                .Distinct(new AreEqualFunc <TypedPollGroup>((v1, v2) => v1.PollGroupID == v2.PollGroupID))
                .ToList();

            pollGroup.Insert(0, new TypedPollGroup(string.Empty, -1));

            // TODO: vzrus needs some work, will be in polls only until feature is debugged there.
            this.PollGroupListDropDown.Items.AddRange(pollGroup.Select(x => new ListItem(x.Question, x.PollGroupID.ToString())).ToArray());

            // population default notification setting options...
            var items = EnumHelper.EnumToDictionary <UserNotificationSetting>();

            if (!boardSettings.AllowNotificationAllPostsAllTopics)
            {
                // remove it...
                items.Remove(UserNotificationSetting.AllTopics.ToInt());
            }

            var notificationItems =
                items.Select(x => new ListItem(HtmlHelper.StripHtml(this.GetText("CP_SUBSCRIPTIONS", x.Value)), x.Key.ToString())).ToArray();

            this.DefaultNotificationSetting.Items.AddRange(notificationItems);

            // Get first default full culture from a language file tag.
            string langFileCulture = StaticDataHelper.CultureDefaultFromFile(boardSettings.Language)
                                     ?? "en-US";

            SetSelectedOnList(ref this.Theme, boardSettings.Theme);
            SetSelectedOnList(ref this.MobileTheme, boardSettings.MobileTheme);

            // If 2-letter language code is the same we return Culture, else we return  a default full culture from language file

            /* SetSelectedOnList(
            *   ref this.Culture,
            *   langFileCulture.Substring(0, 2) == this.Get<YafBoardSettings>().Culture
            *     ? this.Get<YafBoardSettings>().Culture
            *     : langFileCulture);*/
            SetSelectedOnList(ref this.Culture, boardSettings.Culture);
            if (this.Culture.SelectedIndex == 0)
            {
                // If 2-letter language code is the same we return Culture, else we return  a default full culture from language file
                SetSelectedOnList(
                    ref this.Culture, langFileCulture.Substring(0, 2) == boardSettings.Culture ? boardSettings.Culture : langFileCulture);
            }

            SetSelectedOnList(ref this.ShowTopic, boardSettings.ShowTopicsDefault.ToString());
            SetSelectedOnList(
                ref this.FileExtensionAllow, boardSettings.FileExtensionAreAllowed ? "0" : "1");

            SetSelectedOnList(
                ref this.DefaultNotificationSetting,
                boardSettings.DefaultNotificationSetting.ToInt().ToString());

            this.NotificationOnUserRegisterEmailList.Text =
                boardSettings.NotificationOnUserRegisterEmailList;
            this.AllowThemedLogo.Checked = boardSettings.AllowThemedLogo;
            this.EmailModeratorsOnModeratedPost.Checked = boardSettings.EmailModeratorsOnModeratedPost;
            this.EmailModeratorsOnReportedPost.Checked  = boardSettings.EmailModeratorsOnReportedPost;
            this.AllowDigestEmail.Checked       = boardSettings.AllowDigestEmail;
            this.DefaultSendDigestEmail.Checked = boardSettings.DefaultSendDigestEmail;
            this.ForumEmail.Text       = boardSettings.ForumEmail;
            this.ForumBaseUrlMask.Text = boardSettings.BaseUrlMask;

            this.CopyrightRemovalKey.Text = boardSettings.CopyrightRemovalDomainKey;

            this.DigestSendEveryXHours.Text = boardSettings.DigestSendEveryXHours.ToString();

            if (boardSettings.BoardPollID > 0)
            {
                this.PollGroupListDropDown.SelectedValue = boardSettings.BoardPollID.ToString();
            }
            else
            {
                this.PollGroupListDropDown.SelectedIndex = 0;
            }

            this.PollGroupList.Visible = true;

            // Copyright Linkback Algorithm
            // Please keep if you haven't purchased a removal or commercial license.
            this.CopyrightHolder.Visible = true;
        }
コード例 #9
0
        /// <summary>
        /// The render.
        /// </summary>
        /// <param name="output">
        /// The output.
        /// </param>
        protected override void Render([NotNull] HtmlTextWriter output)
        {
            var    forumPageName       = this.ForumPage;
            string forumPageAttributes = null;
            var    outText             = new StringBuilder();

            // Find a user page name. If it's missing we are very probably on the start page
            if (string.IsNullOrEmpty(forumPageName))
            {
                forumPageName = "MAINPAGE";
            }
            else
            {
                // We find here a page name start position
                if (forumPageName.Contains("g="))
                {
                    forumPageName = forumPageName.Substring(forumPageName.IndexOf("g=") + 2);

                    // We find here a page name end position
                    if (forumPageName.Contains("&"))
                    {
                        forumPageAttributes = forumPageName.Substring(forumPageName.IndexOf("&") + 1);
                        forumPageName       = forumPageName.Substring(0, forumPageName.IndexOf("&"));
                    }
                }
                else
                {
                    if (Config.IsDotNetNuke)
                    {
                        int idxfrst = forumPageName.IndexOf("&");
                        forumPageName = forumPageName.Substring(idxfrst + 1);
                    }

                    int idx = forumPageName.IndexOf("=");
                    if (idx > 0)
                    {
                        forumPageAttributes = forumPageName.Substring(
                            0, forumPageName.IndexOf("&") > 0 ? forumPageName.IndexOf("&") : forumPageName.Length - 1);
                        forumPageName = forumPageName.Substring(0, idx);
                    }
                }
            }

            output.BeginRender();

            // All pages should be processed in call frequency order
            // We are in messages
            if (this.TopicID > 0 && this.ForumID > 0)
            {
                switch (forumPageName)
                {
                case "topics":
                    outText.Append(this.GetText("ACTIVELOCATION", "TOPICS"));
                    break;

                case "posts":
                    outText.Append(this.GetText("ACTIVELOCATION", "POSTS"));
                    break;

                case "postmessage":
                    outText.Append(this.GetText("ACTIVELOCATION", "POSTMESSAGE_FULL"));
                    break;

                case "reportpost":
                    outText.Append(this.GetText("ACTIVELOCATION", "REPORTPOST"));
                    outText.Append(". ");
                    outText.Append(this.GetText("ACTIVELOCATION", "TOPICS"));
                    break;

                case "messagehistory":
                    outText.Append(this.GetText("ACTIVELOCATION", "MESSAGEHISTORY"));
                    outText.Append(". ");
                    outText.Append(this.GetText("ACTIVELOCATION", "TOPICS"));
                    break;

                default:
                    outText.Append(this.GetText("ACTIVELOCATION", "POSTS"));
                    break;
                }

                if (this.HasForumAccess)
                {
                    outText.Append(
                        @"<a href=""{0}"" id=""topicid_{1}""  title=""{2}"" runat=""server""> {3} </a>".FormatWith(
                            YafBuildLink.GetLink(ForumPages.posts, "t={0}", this.TopicID),
                            this.UserID,
                            this.GetText("COMMON", "VIEW_TOPIC"),
                            HttpUtility.HtmlEncode(this.TopicName)));
                    if (!this.LastLinkOnly)
                    {
                        outText.Append(this.GetText("ACTIVELOCATION", "TOPICINFORUM"));
                        outText.Append(
                            @"<a href=""{0}"" id=""forumidtopic_{1}"" title=""{2}"" runat=""server""> {3} </a>".FormatWith(
                                YafBuildLink.GetLink(ForumPages.topics, "f={0}", this.ForumID),
                                this.UserID,
                                this.GetText("COMMON", "VIEW_FORUM"),
                                HttpUtility.HtmlEncode(this.ForumName)));
                    }
                }
            }
            else if (this.ForumID > 0 && this.TopicID <= 0)
            {
                // User views a forum
                if (forumPageName == "topics")
                {
                    outText.Append(this.GetText("ACTIVELOCATION", "FORUM"));

                    if (this.HasForumAccess)
                    {
                        outText.Append(
                            @"<a href=""{0}"" id=""forumid_{1}"" title=""{2}"" runat=""server""> {3} </a>".FormatWith(
                                YafBuildLink.GetLink(ForumPages.topics, "f={0}", this.ForumID),
                                this.UserID,
                                this.GetText("COMMON", "VIEW_FORUM"),
                                HttpUtility.HtmlEncode(this.ForumName)));
                    }
                }
            }
            else
            {
                // First specially treated pages where we can render
                // an info about user name, etc.
                switch (forumPageName)
                {
                case "profile":
                    outText.Append(this.Profile(forumPageAttributes));
                    break;

                case "albums":
                    outText.Append(this.Albums(forumPageAttributes));
                    break;

                case "album":
                    outText.Append(this.Album(forumPageAttributes));
                    break;

                default:
                    if (forumPageName == "forum" && this.TopicID <= 0 && this.ForumID <= 0)
                    {
                        outText.Append(
                            this.ForumPage.Contains("c=")
                                    ? this.GetText("ACTIVELOCATION", "FORUMFROMCATEGORY")
                                    : this.GetText("ACTIVELOCATION", "MAINPAGE"));
                    }
                    else if (!YafContext.Current.IsAdmin && forumPageName.ToUpper().Contains("MODERATE_"))
                    {
                        // We shouldn't show moderators activity to all users but admins
                        outText.Append(this.GetText("ACTIVELOCATION", "MODERATE"));
                    }
                    else if (!YafContext.Current.IsHostAdmin && forumPageName.ToUpper().Contains("ADMIN_"))
                    {
                        // We shouldn't show admin activity to all users
                        outText.Append(this.GetText("ACTIVELOCATION", "ADMINTASK"));
                    }
                    else
                    {
                        // Generic action name based on page name
                        outText.Append(this.GetText("ACTIVELOCATION", forumPageName.ToUpper()));
                    }

                    break;
                }
            }

            var outputText = outText.ToString();

            if (outputText.Contains("ACTIVELOCATION") || string.IsNullOrEmpty(outputText.Trim()) ||
                (forumPageName.IndexOf("p=") == 0))
            {
                if (forumPageName.Contains("p="))
                {
                    outText.AppendFormat("{0}.", this.GetText("ACTIVELOCATION", "NODATA"));
                }
                else
                {
                    if (this.Get <YafBoardSettings>().EnableActiveLocationErrorsLog)
                    {
                        this.Logger.Log(
                            this.UserID,
                            this,
                            "Incorrect active location string: ForumID = {0}; ForumName= {1}; ForumPage={2}; TopicID={3}; TopicName={4}; UserID={5}; UserName={6}; Attributes={7}; ForumPageName={8}"
                            .FormatWith(
                                this.ForumID,
                                this.ForumName,
                                this.ForumPage,
                                this.TopicID,
                                this.TopicName,
                                this.UserID,
                                this.UserName,
                                forumPageAttributes,
                                forumPageName),
                            EventLogTypes.Error);
                    }

                    outputText = this.GetText("ACTIVELOCATION", "NODATA");
                }
            }

            output.Write(outputText);

            output.EndRender();
        }
コード例 #10
0
ファイル: UserLink.cs プロジェクト: wqshabib/YAFNET
        /// <summary>
        /// The render.
        /// </summary>
        /// <param name="output">
        /// The output.
        /// </param>
        protected override void Render([NotNull] HtmlTextWriter output)
        {
            var displayName = this.ReplaceName.IsNotSet()
                                  ? this.Get <IUserDisplayName>().GetName(this.UserID)
                                  : this.ReplaceName;

            if (this.UserID == -1 || !displayName.IsSet())
            {
                return;
            }

            // is this the guest user? If so, guest's don't have a profile.
            var isGuest = this.IsGuest ? this.IsGuest : UserMembershipHelper.IsGuestUser(this.UserID);

            output.BeginRender();

            if (!isGuest)
            {
                output.WriteBeginTag("a");

                output.WriteAttribute("href", YafBuildLink.GetLink(ForumPages.profile, "u={0}&name={1}", this.UserID, displayName));

                if (this.CanViewProfile && this.IsHoverCardEnabled)
                {
                    if (this.CssClass.IsSet())
                    {
                        this.CssClass += " userHoverCard";
                    }
                    else
                    {
                        this.CssClass = "userHoverCard";
                    }

                    output.WriteAttribute(
                        "data-hovercard",
                        "{0}resource.ashx?userinfo={1}&boardId={2}&type=json&forumUrl={3}".FormatWith(
                            Config.IsDotNetNuke ? BaseUrlBuilder.GetBaseUrlFromVariables() + BaseUrlBuilder.AppPath : YafForumInfo.ForumClientFileRoot,
                            this.UserID,
                            YafContext.Current.PageBoardID,
                            HttpUtility.UrlEncode(YafBuildLink.GetBasePath())));
                }
                else
                {
                    output.WriteAttribute("title", this.GetText("COMMON", "VIEW_USRPROFILE"));
                }

                if (this.Get <YafBoardSettings>().UseNoFollowLinks)
                {
                    output.WriteAttribute("rel", "nofollow");
                }

                if (this.BlankTarget)
                {
                    output.WriteAttribute("target", "_blank");
                }
            }
            else
            {
                output.WriteBeginTag("span");
            }

            this.RenderMainTagAttributes(output);

            output.Write(HtmlTextWriter.TagRightChar);

            // Replace Name with Crawler Name if Set, otherwise use regular display name or Replace Name if set
            if (this.CrawlerName.IsSet())
            {
                output.WriteEncodedText(this.CrawlerName);
            }
            else if (!this.CrawlerName.IsSet() && this.ReplaceName.IsSet() && isGuest)
            {
                output.WriteEncodedText(this.ReplaceName);
            }
            else
            {
                output.WriteEncodedText(displayName);
            }

            output.WriteEndTag(!isGuest ? "a" : "span");

            if (this.PostfixText.IsSet())
            {
                output.Write(this.PostfixText);
            }

            output.EndRender();
        }
コード例 #11
0
ファイル: register.ascx.cs プロジェクト: RichardBer/ParkCMS
        /// <summary>
        /// The page_ load.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.IsPostBack)
            {
                this.CreateUserWizard1.MembershipProvider = Config.MembershipProvider;

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

                // handle the CreateUser Step localization
                this.SetupCreateUserStep();

                // handle other steps localization
                ((Button)this.CreateUserWizard1.FindWizardControlRecursive("ProfileNextButton")).Text = this.GetText("SAVE");
                ((Button)this.CreateUserWizard1.FindWizardControlRecursive("ContinueButton")).Text    = this.GetText("CONTINUE");

                // get the time zone data source
                var timeZones = (DropDownList)this.CreateUserWizard1.FindWizardControlRecursive("TimeZones");
                timeZones.DataSource = StaticDataHelper.TimeZones();

                if (_userIpLocator == null)
                {
                    // vzrus: we should always get not null class here
                    _userIpLocator = new IPDetails().GetData(HttpContext.Current.Request.UserHostAddress, true);
                }
                // fill dst field
                if (this._userIpLocator.Isdst.IsSet() && _userIpLocator.Status.ToUpper() == "OK")
                {
                    this.CreateUserWizard1.FindControlRecursiveAs <CheckBox>("DSTUser").Checked = _userIpLocator.Isdst == "1" ? true : false;
                }
                // fill location field
                if (this._userIpLocator.Isdst.IsSet() && _userIpLocator.Status.ToUpper() == "OK")
                {
                    // Trying to consume data about user IP whereabouts
                    if (_userIpLocator.Status == "OK")
                    {
                        string txtLoc = String.Empty;
                        if (this._userIpLocator.CountryName.IsSet())
                        {
                            txtLoc += _userIpLocator.CountryName;
                        }
                        if (this._userIpLocator.RegionName.IsSet())
                        {
                            txtLoc += ", " + _userIpLocator.RegionName;
                        }
                        if (this._userIpLocator.City.IsSet())
                        {
                            txtLoc += ", " + _userIpLocator.City;
                        }
                        this.CreateUserWizard1.FindControlRecursiveAs <TextBox>("Location").Text = txtLoc;
                    }
                }


                if (!this.PageContext.BoardSettings.EmailVerification)
                {
                    // automatically log in created users
                    this.CreateUserWizard1.LoginCreatedUser   = true;
                    this.CreateUserWizard1.DisableCreatedUser = false;

                    // success notification localization
                    ((Literal)this.CreateUserWizard1.FindWizardControlRecursive("AccountCreated")).Text =
                        YafBBCode.MakeHtml(this.GetText("ACCOUNT_CREATED"), true, false);
                }
                else
                {
                    this.CreateUserWizard1.LoginCreatedUser   = false;
                    this.CreateUserWizard1.DisableCreatedUser = true;

                    // success notification localization
                    ((Literal)this.CreateUserWizard1.FindWizardControlRecursive("AccountCreated")).Text =
                        YafBBCode.MakeHtml(this.GetText("ACCOUNT_CREATED_VERIFICATION"), true, false);
                }

                this.CreateUserWizard1.FinishDestinationPageUrl = YafForumInfo.ForumURL;

                this.DataBind();
                int tz = 0;
                if (_userIpLocator.Status == "OK")
                {
                    if (this._userIpLocator.Gmtoffset.IsSet() && (this._userIpLocator.Isdst.IsSet()))
                    {
                        tz = (Convert.ToInt32(_userIpLocator.Gmtoffset) - Convert.ToInt32(_userIpLocator.Isdst) * 3600) / 60;
                    }
                }

                timeZones.Items.FindByValue(tz.ToString()).Selected = true;
                this.CreateUserWizard1.FindWizardControlRecursive("UserName").Focus();
            }

            // password requirement parameters...
            var requirementText = (LocalizedLabel)this.CreateUserStepContainer.FindControl("LocalizedLabelRequirementsText");

            requirementText.Param0 = this.PageContext.CurrentMembership.MinRequiredPasswordLength.ToString();
            requirementText.Param1 = this.PageContext.CurrentMembership.MinRequiredNonAlphanumericCharacters.ToString();

            // max user name length
            var usernamelehgthText =
                (LocalizedLabel)this.CreateUserStepContainer.FindControl("LocalizedLabelLohgUserNameWarnText");

            usernamelehgthText.Param0 = this.PageContext.BoardSettings.UserNameMaxLength.ToString();

            if (this.PageContext.BoardSettings.CaptchaTypeRegister == 2)
            {
                this.SetupRecaptchaControl();
            }
        }
コード例 #12
0
ファイル: info.ascx.cs プロジェクト: wangyoutian/YAFNET
        /// <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)
        {
            // Put user code to initialize the page here
            if (this.IsPostBack)
            {
                return;
            }

            // localize button label
            this.Continue.Text = this.GetText("continue");

            // get redirect URL from parameter
            if (this.Request.QueryString.GetFirstOrDefault("url") != null)
            {
                // unescape ampersands
                this.RefreshURL = this.Request.QueryString.GetFirstOrDefault("url").Replace("&amp;", "&");
            }

            // try to get infomessage code from parameter
            try
            {
                // compare it converted to enumeration
                switch ((InfoMessage)this.Request.QueryString.GetFirstOrDefaultAs <int>("i"))
                {
                case InfoMessage.Moderated:     // Moderated
                    this.Title.Text  = this.GetText("title_moderated");
                    this.Info.Text   = this.GetText("moderated");
                    this.RefreshTime = 10;
                    break;

                case InfoMessage.Suspended:     // Suspended
                    this.Title.Text = this.GetText("title_suspended");


                    if (this.PageContext.SuspendedReason.IsSet())
                    {
                        this.Info.Text =
                            "{0}{1}".FormatWith(
                                this.GetTextFormatted(
                                    "SUSPENDED",
                                    this.Get <IDateTime>().GetUserDateTime(this.PageContext.SuspendedUntil)),
                                this.GetTextFormatted("SUSPENDED_REASON", this.PageContext.SuspendedReason));
                    }
                    else
                    {
                        this.Info.Text = this.GetTextFormatted(
                            "SUSPENDED",
                            this.Get <IDateTime>().GetUserDateTime(this.PageContext.SuspendedUntil));
                    }

                    break;

                case InfoMessage.RegistrationEmail:     // Registration email
                    this.Title.Text  = this.GetText("title_registration");
                    this.Info.Text   = this.GetText("registration");
                    this.RefreshTime = 10;
                    this.RefreshURL  = YafBuildLink.GetLink(ForumPages.login);
                    break;

                case InfoMessage.AccessDenied:     // Access Denied
                    this.Title.Text  = this.GetText("title_accessdenied");
                    this.Info.Text   = this.GetText("accessdenied");
                    this.RefreshTime = 10;
                    this.RefreshURL  = YafBuildLink.GetLink(ForumPages.forum);
                    break;

                case InfoMessage.Disabled:     // Disabled feature
                    this.Title.Text  = this.GetText("TITLE_ACCESSDENIED");
                    this.Info.Text   = this.GetText("DISABLED");
                    this.RefreshTime = 10;
                    this.RefreshURL  = YafBuildLink.GetLink(ForumPages.forum);
                    break;

                case InfoMessage.Invalid:     // Invalid argument!
                    this.Title.Text  = this.GetText("TITLE_INVALID");
                    this.Info.Text   = this.GetText("INVALID");
                    this.RefreshTime = 10;
                    this.RefreshURL  = YafBuildLink.GetLink(ForumPages.forum);
                    break;

                case InfoMessage.Failure:     // some sort of failure
                    this.Title.Text  = this.GetText("TITLE_FAILURE");
                    this.Info.Text   = this.GetText("FAILURE");
                    this.RefreshTime = 10;
                    this.RefreshURL  = YafBuildLink.GetLink(ForumPages.forum);
                    break;

                case InfoMessage.HostAdminPermissionsAreRequired:     // some sort of failure
                    this.Title.Text  = this.GetText("TITLE_HOSTADMINPERMISSIONSREQUIRED");
                    this.Info.Text   = this.GetText("HOSTADMINPERMISSIONSREQUIRED");
                    this.RefreshTime = 10;
                    this.RefreshURL  = YafBuildLink.GetLink(ForumPages.forum);
                    break;
                }
            }
            catch (Exception)
            {
                // get title for exception message
                this.Title.Text = this.GetText("title_exception");

                // exception message
                this.Info.Text = "{1} <strong>{0}</strong>.".FormatWith(
                    this.PageContext.PageUserName, this.GetText("exception"));

                // redirect to forum main after 2 seconds
                this.RefreshTime = 2;
                this.RefreshURL  = YafBuildLink.GetLink(ForumPages.forum);
            }

            // set continue button URL and visibility
            this.Continue.NavigateUrl = this.RefreshURL;
            this.Continue.Visible     = this.RefreshURL != null;

            // create page links - must be placed after switch to display correct title (last breadcrumb trail)
            this.CreatePageLinks();
        }
コード例 #13
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)
                {
                    var displayName =
                        HttpUtility.HtmlEncode(UserMembershipHelper.GetDisplayNameFromID(userID.ToType <long>()));

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

                    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}&name={1}", userID, displayName),
                            userID,
                            HttpUtility.HtmlEncode(displayName));
                }
                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);
        }
コード例 #14
0
        /// <summary>
        /// The replace.
        /// </summary>
        /// <param name="text">
        /// The text.
        /// </param>
        /// <param name="replacement">
        /// The replacement.
        /// </param>
        public override void Replace(ref string text, IReplaceBlocks replacement)
        {
            var sb = new StringBuilder(text);

            var match = this._regExSearch.Match(text);

            while (match.Success)
            {
                var innerReplace = new StringBuilder(this._regExReplace);
                var i            = 0;

                if (this._truncateLength > 0)
                {
                    // special handling to truncate urls
                    innerReplace.Replace(
                        "${innertrunc}", match.Groups["inner"].Value.TruncateMiddle(this._truncateLength));
                }

                var quote = match.Groups["quote"].Value;

                var localQuoteWrote  = YafContext.Current.Get <ILocalization>().GetText("COMMON", "BBCODE_QUOTEWROTE");
                var localQuotePosted = YafContext.Current.Get <ILocalization>()
                                       .GetText("COMMON", "BBCODE_QUOTEPOSTED");

                // extract post id if exists
                if (quote.Contains(";"))
                {
                    string postId;

                    string userName;

                    try
                    {
                        postId   = quote.Substring(quote.LastIndexOf(";") + 1);
                        userName = quote = quote.Remove(quote.LastIndexOf(";"));
                    }
                    catch (Exception)
                    {
                        // if post id is missing
                        postId   = string.Empty;
                        userName = quote;
                    }

                    if (postId.IsSet())
                    {
                        quote =
                            @"{0} <a href=""{1}""><img src=""{2}"" title=""{3}"" alt=""{3}"" /></a>".FormatWith(
                                localQuotePosted.Replace("{0}", userName),
                                YafBuildLink.GetLink(ForumPages.posts, "m={0}#post{0}", postId),
                                YafContext.Current.Get <ITheme>().GetItem("ICONS", "ICON_LATEST"),
                                YafContext.Current.Get <ILocalization>().GetText("COMMON", "BBCODE_QUOTEPOSTED_TT"));
                    }
                    else
                    {
                        quote = localQuoteWrote.Replace("{0}", quote);
                    }
                }
                else
                {
                    quote = localQuoteWrote.Replace("{0}", quote);
                }

                innerReplace.Replace("${quote}", quote);

                foreach (var tVar in this._variables)
                {
                    var varName       = tVar;
                    var handlingValue = string.Empty;

                    if (varName.Contains(":"))
                    {
                        // has handling section
                        var tmpSplit = varName.Split(':');
                        varName       = tmpSplit[0];
                        handlingValue = tmpSplit[1];
                    }

                    var tValue = match.Groups[varName].Value;

                    if (this._variableDefaults != null && tValue.Length == 0)
                    {
                        // use default instead
                        tValue = this._variableDefaults[i];
                    }

                    innerReplace.Replace("${" + varName + "}", this.ManageVariableValue(varName, tValue, handlingValue));
                    i++;
                }

                innerReplace.Replace("${inner}", match.Groups["inner"].Value);

                // pulls the htmls into the replacement collection before it's inserted back into the main text
                replacement.ReplaceHtmlFromText(ref innerReplace);

                // remove old bbcode...
                sb.Remove(match.Groups[0].Index, match.Groups[0].Length);

                // insert replaced value(s)
                sb.Insert(match.Groups[0].Index, innerReplace.ToString());

                // text = text.Substring( 0, m.Groups [0].Index ) + tStr + text.Substring( m.Groups [0].Index + m.Groups [0].Length );
                match = this._regExSearch.Match(sb.ToString());
            }

            text = sb.ToString();
        }
コード例 #15
0
ファイル: login.ascx.cs プロジェクト: RichardBer/ParkCMS
        /// <summary>
        /// The page_ load.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                this.Login1.MembershipProvider = Config.MembershipProvider;

                this.PageLinks.AddLink(PageContext.BoardSettings.Name, YafBuildLink.GetLink(ForumPages.forum));
                this.PageLinks.AddLink(GetText("title"));

                // Login1.CreateUserText = "Sign up for a new account.";
                // Login1.CreateUserUrl = YafBuildLink.GetLink( ForumPages.register );
                this.Login1.PasswordRecoveryText = GetText("lostpassword");
                this.Login1.PasswordRecoveryUrl  = YafBuildLink.GetLink(ForumPages.recoverpassword);
                this.Login1.FailureText          = GetText("password_error");

                if (this.Request.QueryString.GetFirstOrDefault("ReturnUrl").IsSet())
                {
                    this.Login1.DestinationPageUrl = Server.UrlDecode(Request.QueryString.GetFirstOrDefault("ReturnUrl"));
                }
                else
                {
                    this.Login1.DestinationPageUrl = YafBuildLink.GetLink(ForumPages.forum);
                }

                // localize controls
                var rememberMe       = this.Login1.FindControlAs <CheckBox>("RememberMe");
                var userName         = this.Login1.FindControlAs <TextBox>("UserName");
                var password         = this.Login1.FindControlAs <TextBox>("Password");
                var forumLogin       = this.Login1.FindControlAs <Button>("LoginButton");
                var passwordRecovery = this.Login1.FindControlAs <Button>("PasswordRecovery");

                userName.Focus();

                /*
                 * RequiredFieldValidator usernameRequired = ( RequiredFieldValidator ) Login1.FindControl( "UsernameRequired" );
                 * RequiredFieldValidator passwordRequired = ( RequiredFieldValidator ) Login1.FindControl( "PasswordRequired" );
                 *
                 * usernameRequired.ToolTip = usernameRequired.ErrorMessage = GetText( "REGISTER", "NEED_USERNAME" );
                 * passwordRequired.ToolTip = passwordRequired.ErrorMessage = GetText( "REGISTER", "NEED_PASSWORD" );
                 */
                if (rememberMe != null)
                {
                    rememberMe.Text = GetText("auto");
                }

                if (forumLogin != null)
                {
                    forumLogin.Text = GetText("forum_login");
                }

                if (passwordRecovery != null)
                {
                    passwordRecovery.Text = GetText("lostpassword");
                }

                if (password != null && forumLogin != null)
                {
                    password.Attributes.Add(
                        "onkeydown",
                        "if(event.which || event.keyCode){if ((event.which == 13) || (event.keyCode == 13)) {document.getElementById('" + forumLogin.ClientID +
                        "').click();return false;}} else {return true}; ");
                }

                DataBind();
            }
        }
コード例 #16
0
ファイル: cp_message.ascx.cs プロジェクト: stantoxt/YAFNET
        /// <summary>
        /// Binds the data.
        /// </summary>
        private void BindData()
        {
            using (
                DataTable dt =
                    LegacyDb.pmessage_list(
                        Security.StringToLongOrRedirect(this.Get <HttpRequestBase>().QueryString.GetFirstOrDefault("pm"))))
            {
                if (dt.HasRows())
                {
                    DataRow row = dt.Rows[0];

                    // if the pm isn't from or two the current user--then it's access denied
                    if ((int)row["ToUserID"] != this.PageContext.PageUserID &&
                        (int)row["FromUserID"] != this.PageContext.PageUserID)
                    {
                        YafBuildLink.AccessDenied();
                    }

                    this.SetMessageView(
                        row["FromUserID"],
                        row["ToUserID"],
                        Convert.ToBoolean(row["IsInOutbox"]),
                        Convert.ToBoolean(row["IsArchived"]));

                    // get the return link to the pm listing
                    if (this.IsOutbox)
                    {
                        this.PageLinks.AddLink(
                            this.GetText("SENTITEMS"), YafBuildLink.GetLink(ForumPages.cp_pm, "v=out"));
                    }
                    else if (this.IsArchived)
                    {
                        this.PageLinks.AddLink(
                            this.GetText("ARCHIVE"), YafBuildLink.GetLink(ForumPages.cp_pm, "v=arch"));
                    }
                    else
                    {
                        this.PageLinks.AddLink(this.GetText("INBOX"), YafBuildLink.GetLink(ForumPages.cp_pm));
                    }

                    this.PageLinks.AddLink(row["Subject"].ToString());

                    this.Inbox.DataSource = dt;
                }
                else
                {
                    YafBuildLink.Redirect(ForumPages.cp_pm);
                }
            }

            this.DataBind();

            if (this.IsOutbox)
            {
                return;
            }

            var userPmessageId = this.Get <HttpRequestBase>().QueryString.GetFirstOrDefault("pm").ToType <int>();

            LegacyDb.pmessage_markread(userPmessageId);
            this.Get <IDataCache>().Remove(Constants.Cache.ActiveUserLazyData.FormatWith(this.PageContext.PageUserID));
            this.Get <IRaiseEvent>().Raise(
                new UpdateUserPrivateMessageEvent(this.PageContext.PageUserID, userPmessageId));
        }
コード例 #17
0
ファイル: polledit.ascx.cs プロジェクト: ggagnaux/YAFNET
        /// <summary>
        /// The return to page.
        /// </summary>
        private void ReturnToPage()
        {
            if (this._topicUnapproved)
            {
                // Tell user that his message will have to be approved by a moderator
                string url = YafBuildLink.GetLink(ForumPages.topics, "f={0}", this._returnForum);

                if (Config.IsRainbow)
                {
                    YafBuildLink.Redirect(ForumPages.info, "i=1");
                }
                else
                {
                    YafBuildLink.Redirect(ForumPages.info, "i=1&url={0}", this.Server.UrlEncode(url));
                }
            }

            // YafBuildLink.Redirect(ForumPages.posts, "m={0}#{0}", this.Get<HttpRequestBase>().QueryString.GetFirstOrDefault("m"));
            string retliterals;
            int?   retvalue;

            this.ParamsToSend(out retliterals, out retvalue);

            switch (retliterals)
            {
            case "t":
                YafBuildLink.Redirect(ForumPages.posts, "t={0}", retvalue);
                break;

            case "em":

                YafBuildLink.Redirect(ForumPages.postmessage, "m={0}", retvalue);
                break;

            case "f":

                YafBuildLink.Redirect(ForumPages.topics, "f={0}", retvalue);
                break;

            case "ef":
                YafBuildLink.Redirect(ForumPages.admin_editforum, "f={0}", retvalue);
                break;

            case "c":
                YafBuildLink.Redirect(ForumPages.forum, "c={0}", retvalue);
                break;

            case "ec":
                YafBuildLink.Redirect(ForumPages.admin_editcategory, "c={0}", retvalue);
                break;

            case "b":
                YafBuildLink.Redirect(ForumPages.forum);
                break;

            case "eb":
                YafBuildLink.Redirect(ForumPages.admin_editboard, "b={0}", retvalue);
                break;

            default:
                YafBuildLink.RedirectInfoPage(InfoMessage.Invalid);
                break;
            }
        }
コード例 #18
0
ファイル: editforum.ascx.cs プロジェクト: ggagnaux/YAFNET
        /// <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;
            }

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

            this.PageLinks.AddLink(this.GetText("TEAM", "FORUMS"), YafBuildLink.GetLink(ForumPages.admin_forums));
            this.PageLinks.AddLink(this.GetText("ADMIN_EDITFORUM", "TITLE"), string.Empty);

            this.Page.Header.Title = "{0} - {1} - {2}".FormatWith(
                this.GetText("ADMIN_ADMIN", "Administration"),
                this.GetText("TEAM", "FORUMS"),
                this.GetText("ADMIN_EDITFORUM", "TITLE"));

            this.Save.Text   = this.GetText("SAVE");
            this.Cancel.Text = this.GetText("CANCEL");

            this.ModerateAllPosts.Text = this.GetText("MODERATE_ALL_POSTS");

            // Populate Forum Images Table
            this.CreateImagesDataTable();

            this.ForumImages.Attributes["onchange"] =
                "getElementById('{1}').src='{0}{2}/' + this.value".FormatWith(
                    YafForumInfo.ForumClientFileRoot, this.Preview.ClientID, YafBoardFolders.Current.Forums);

            this.BindData();

            var forumId = this.GetQueryStringAsInt("fa") ?? this.GetQueryStringAsInt("copy");

            if (!forumId.HasValue)
            {
                // Currently creating a New Forum, and auto fill the Forum Sort Order + 1
                using (
                    var dt = LegacyDb.forum_list(this.PageContext.PageBoardID, null))
                {
                    var sortOrder = 1;

                    try
                    {
                        var highestRow = dt.Rows[dt.Rows.Count - 1];

                        sortOrder = (short)highestRow["SortOrder"] + sortOrder;
                    }
                    catch
                    {
                        sortOrder = 1;
                    }

                    this.SortOrder.Text = sortOrder.ToString();

                    return;
                }
            }

            using (var dt = LegacyDb.forum_list(this.PageContext.PageBoardID, forumId.Value))
            {
                var row   = dt.Rows[0];
                var flags = new ForumFlags(row["Flags"]);
                this.Name.Text            = row["Name"].ToString();
                this.Description.Text     = row["Description"].ToString();
                this.SortOrder.Text       = row["SortOrder"].ToString();
                this.HideNoAccess.Checked = flags.IsHidden;
                this.Locked.Checked       = flags.IsLocked;
                this.IsTest.Checked       = flags.IsTest;
                this.ForumNameTitle.Text  = this.Name.Text;
                this.Moderated.Checked    = flags.IsModerated;

                this.ModeratedPostCountRow.Visible   = this.Moderated.Checked;
                this.ModerateNewTopicOnlyRow.Visible = this.Moderated.Checked;

                if (row["ModeratedPostCount"].IsNullOrEmptyDBField())
                {
                    this.ModerateAllPosts.Checked = true;
                }
                else
                {
                    this.ModerateAllPosts.Checked   = false;
                    this.ModeratedPostCount.Visible = true;
                    this.ModeratedPostCount.Text    = row["ModeratedPostCount"].ToString();
                }

                this.ModerateNewTopicOnly.Checked = row["IsModeratedNewTopicOnly"].ToType <bool>();

                this.Styles.Text = row["Styles"].ToString();

                this.CategoryList.SelectedValue = row["CategoryID"].ToString();

                this.Preview.Src = YafForumInfo.GetURLToContent("images/spacer.gif"); // use spacer.gif for Description Entry

                var item = this.ForumImages.Items.FindByText(row["ImageURL"].ToString());
                if (item != null)
                {
                    item.Selected    = true;
                    this.Preview.Src = "{0}{2}/{1}".FormatWith(
                        YafForumInfo.ForumClientFileRoot, row["ImageURL"], YafBoardFolders.Current.Forums); // path corrected
                }

                // populate parent forums list with forums according to selected category
                this.BindParentList();

                if (!row.IsNull("ParentID"))
                {
                    this.ParentList.SelectedValue = row["ParentID"].ToString();
                }

                if (!row.IsNull("ThemeURL"))
                {
                    this.ThemeList.SelectedValue = row["ThemeURL"].ToString();
                }

                this.remoteurl.Text = row["RemoteURL"].ToString();
            }

            this.NewGroupRow.Visible = false;
        }
コード例 #19
0
ファイル: LoginBox.ascx.cs プロジェクト: ahsan-sally/demo
        /// <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;
            }

            this.Login1.MembershipProvider = Config.MembershipProvider;

            // Login1.CreateUserText = "Sign up for a new account.";
            // Login1.CreateUserUrl = YafBuildLink.GetLink( ForumPages.register );
            this.Login1.PasswordRecoveryText = this.GetText("lostpassword");
            this.Login1.PasswordRecoveryUrl  = YafBuildLink.GetLink(ForumPages.recoverpassword);
            this.Login1.FailureText          = this.GetText("password_error");

            this.Login1.DestinationPageUrl = this.Page.Request.RawUrl;

            // localize controls
            var rememberMe       = this.Login1.FindControlAs <CheckBox>("RememberMe");
            var userName         = this.Login1.FindControlAs <TextBox>("UserName");
            var password         = this.Login1.FindControlAs <TextBox>("Password");
            var forumLogin       = this.Login1.FindControlAs <Button>("LoginButton");
            var passwordRecovery = this.Login1.FindControlAs <LinkButton>("PasswordRecovery");

            var faceBookHolder   = this.Login1.FindControlAs <PlaceHolder>("FaceBookHolder");
            var facebookRegister = this.Login1.FindControlAs <LinkButton>("FacebookRegister");

            var twitterHolder   = this.Login1.FindControlAs <PlaceHolder>("TwitterHolder");
            var twitterRegister = this.Login1.FindControlAs <LinkButton>("TwitterRegister");

            var googleHolder   = this.Login1.FindControlAs <PlaceHolder>("GoogleHolder");
            var googleRegister = this.Login1.FindControlAs <LinkButton>("GoogleRegister");

            userName.Focus();

            /*
             *  RequiredFieldValidator usernameRequired = ( RequiredFieldValidator ) Login1.FindControl( "UsernameRequired" );
             *  RequiredFieldValidator passwordRequired = ( RequiredFieldValidator ) Login1.FindControl( "PasswordRequired" );
             *
             *  usernameRequired.ToolTip = usernameRequired.ErrorMessage = GetText( "REGISTER", "NEED_USERNAME" );
             *  passwordRequired.ToolTip = passwordRequired.ErrorMessage = GetText( "REGISTER", "NEED_PASSWORD" );
             */
            if (rememberMe != null)
            {
                rememberMe.Text = this.GetText("auto");
            }

            if (forumLogin != null)
            {
                forumLogin.Text = this.GetText("forum_login");
            }

            if (passwordRecovery != null)
            {
                passwordRecovery.Text = this.GetText("lostpassword");
            }

            userName.Attributes.Add(
                "onkeydown",
                "if(event.which || event.keyCode){{if ((event.which == 13) || (event.keyCode == 13)) {{document.getElementById('{0}').click();return false;}}}} else {{return true}}; "
                .FormatWith(forumLogin.ClientID));

            password.Attributes.Add(
                "onkeydown",
                "if(event.which || event.keyCode){{if ((event.which == 13) || (event.keyCode == 13)) {{document.getElementById('{0}').click();return false;}}}} else {{return true}}; "
                .FormatWith(forumLogin.ClientID));

            if (this.Get <YafBoardSettings>().AllowSingleSignOn)
            {
                faceBookHolder.Visible = Config.FacebookAPIKey.IsSet() && Config.FacebookSecretKey.IsSet();
                twitterHolder.Visible  = Config.TwitterConsumerKey.IsSet() && Config.TwitterConsumerSecret.IsSet();
                googleHolder.Visible   = Config.GoogleClientID.IsSet() && Config.GoogleClientSecret.IsSet();

                if (twitterHolder.Visible)
                {
                    twitterRegister.Visible = true;
                    twitterRegister.Text    = this.GetTextFormatted("AUTH_CONNECT", "Twitter");
                    twitterRegister.ToolTip = this.GetTextFormatted("AUTH_CONNECT_HELP", "Twitter");
                }

                if (faceBookHolder.Visible)
                {
                    facebookRegister.Visible = true;
                    facebookRegister.Text    = this.GetTextFormatted("AUTH_CONNECT", "Facebook");
                    facebookRegister.ToolTip = this.GetTextFormatted("AUTH_CONNECT_HELP", "Facebook");
                }

                if (googleHolder.Visible)
                {
                    googleRegister.Visible = true;
                    googleRegister.Text    = this.GetTextFormatted("AUTH_CONNECT", "Google");
                    googleRegister.ToolTip = this.GetTextFormatted("AUTH_CONNECT_HELP", "Google");
                }
            }

            this.DataBind();
        }
コード例 #20
0
ファイル: YafHeader.ascx.cs プロジェクト: happyyb/YAFNET
        /// <summary>
        /// Render the Main Header Menu Links
        /// </summary>
        private void RenderMainHeaderMenu()
        {
            /*
             * // Forum
             * RenderMenuItem(
             *  this.menuListItems,
             *  "nav-link",
             *  this.GetText("DEFAULT", "FORUM"),
             *  this.GetText("TOOLBAR", "FORUM_TITLE"),
             *  YafBuildLink.GetLink(ForumPages.forum),
             *  false,
             *  false,
             *  null,
             *  null,
             *  string.Empty);*/

            // Active Topics
            if (this.PageContext.IsGuest)
            {
                RenderMenuItem(
                    this.menuListItems,
                    "nav-link",
                    this.GetText("TOOLBAR", "ACTIVETOPICS"),
                    this.GetText("TOOLBAR", "ACTIVETOPICS_TITLE"),
                    YafBuildLink.GetLink(ForumPages.mytopics),
                    false,
                    false,
                    null,
                    null,
                    string.Empty);
            }

            // Search
            if (this.Get <IPermissions>().Check(this.Get <YafBoardSettings>().SearchPermissions))
            {
                RenderMenuItem(
                    this.menuListItems,
                    "nav-link",
                    this.GetText("TOOLBAR", "SEARCH"),
                    this.GetText("TOOLBAR", "SEARCH_TITLE"),
                    YafBuildLink.GetLink(ForumPages.search),
                    false,
                    false,
                    null,
                    null,
                    string.Empty);
            }

            // Members
            if (this.Get <IPermissions>().Check(this.Get <YafBoardSettings>().MembersListViewPermissions))
            {
                RenderMenuItem(
                    this.menuListItems,
                    "nav-link",
                    this.GetText("TOOLBAR", "MEMBERS"),
                    this.GetText("TOOLBAR", "MEMBERS_TITLE"),
                    YafBuildLink.GetLink(ForumPages.members),
                    false,
                    false,
                    null,
                    null,
                    string.Empty);
            }

            // Team
            if (this.Get <IPermissions>().Check(this.Get <YafBoardSettings>().ShowTeamTo))
            {
                RenderMenuItem(
                    this.menuListItems,
                    "nav-link",
                    this.GetText("TOOLBAR", "TEAM"),
                    this.GetText("TOOLBAR", "TEAM_TITLE"),
                    YafBuildLink.GetLink(ForumPages.team),
                    false,
                    false,
                    null,
                    null,
                    string.Empty);
            }

            // Help
            if (this.Get <IPermissions>().Check(this.Get <YafBoardSettings>().ShowHelpTo))
            {
                RenderMenuItem(
                    this.menuListItems,
                    "nav-link",
                    this.GetText("TOOLBAR", "HELP"),
                    this.GetText("TOOLBAR", "HELP_TITLE"),
                    YafBuildLink.GetLink(ForumPages.help_index),
                    false,
                    false,
                    null,
                    null,
                    string.Empty);
            }

            if (!this.PageContext.IsGuest || Config.IsAnyPortal)
            {
                return;
            }

            // Login
            if (Config.AllowLoginAndLogoff)
            {
                RenderMenuItem(
                    this.menuListItems,
                    "nav-link  LoginLink",
                    this.GetText("TOOLBAR", "LOGIN"),
                    this.GetText("TOOLBAR", "LOGIN_TITLE"),
                    "javascript:void(0);",
                    true,
                    false,
                    null,
                    null,
                    string.Empty);
            }

            // Register
            if (!this.Get <YafBoardSettings>().DisableRegistrations)
            {
                RenderMenuItem(
                    this.menuListItems,
                    "nav-link",
                    this.GetText("TOOLBAR", "REGISTER"),
                    this.GetText("TOOLBAR", "REGISTER_TITLE"),
                    this.Get <YafBoardSettings>().ShowRulesForRegistration
                        ? YafBuildLink.GetLink(ForumPages.rules)
                        : !this.Get <YafBoardSettings>().UseSSLToRegister
                            ? YafBuildLink.GetLink(ForumPages.register)
                            : YafBuildLink.GetLink(ForumPages.register, true).Replace("http:", "https:"),
                    true,
                    false,
                    null,
                    null,
                    string.Empty);
            }
        }
コード例 #21
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)
            {
                YafBuildLink.AccessDenied();
            }

            this.ShowToolBar = false;

            if (this.IsPostBack)
            {
                return;
            }

            if (this.PageContext.Settings.LockedForum == 0)
            {
                this.PageLinks.AddRoot();
                this.PageLinks.AddLink(
                    this.PageContext.PageCategoryName,
                    YafBuildLink.GetLink(ForumPages.forum, "c={0}", this.PageContext.PageCategoryID));
            }

            this.PageLinks.AddForum(this.PageContext.PageForumID);
            this.PageLinks.AddLink(
                this.PageContext.PageTopicName, YafBuildLink.GetLink(ForumPages.posts, "t={0}", this.PageContext.PageTopicID));
            var showDeleted = false;
            var userId      = 0;

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

            if (!showDeleted && (this.Get <YafBoardSettings>().ShowDeletedMessages&&
                                 !this.Get <YafBoardSettings>().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();
        }
コード例 #22
0
ファイル: YafHeader.ascx.cs プロジェクト: happyyb/YAFNET
        /// <summary>
        /// Render The User related Links
        /// </summary>
        private void RenderUserContainer()
        {
            if (this.PageContext.IsGuest)
            {
                return;
            }

            // My Profile
            this.MyProfile.ToolTip     = this.GetText("TOOLBAR", "MYPROFILE_TITLE");
            this.MyProfile.NavigateUrl = YafBuildLink.GetLink(ForumPages.cp_profile);
            this.MyProfile.Text        = $"<i class=\"fa fa-user fa-fw\"></i>  {this.GetText("TOOLBAR", "MYPROFILE")}";

            // My Inbox
            if (this.Get <YafBoardSettings>().AllowPrivateMessages)
            {
                RenderMenuItem(
                    this.MyInboxItem,
                    "dropdown-item",
                    this.GetText("TOOLBAR", "INBOX"),
                    this.GetText("TOOLBAR", "INBOX_TITLE"),
                    YafBuildLink.GetLink(ForumPages.cp_pm),
                    false,
                    this.PageContext.UnreadPrivate > 0,
                    this.PageContext.UnreadPrivate.ToString(),
                    this.GetTextFormatted("TOOLBAR", "NEWPM", this.PageContext.UnreadPrivate),
                    "envelope");
            }

            // My Buddies
            if (this.Get <YafBoardSettings>().EnableBuddyList&& this.PageContext.UserHasBuddies)
            {
                RenderMenuItem(
                    this.MyBuddiesItem,
                    "dropdown-item",
                    this.GetText("TOOLBAR", "BUDDIES"),
                    this.GetText("TOOLBAR", "BUDDIES_TITLE"),
                    YafBuildLink.GetLink(ForumPages.cp_editbuddies),
                    false,
                    this.PageContext.PendingBuddies > 0,
                    this.PageContext.PendingBuddies.ToString(),
                    this.GetTextFormatted("TOOLBAR", "BUDDYREQUEST", this.PageContext.PendingBuddies),
                    "users");
            }

            // My Albums
            if (this.Get <YafBoardSettings>().EnableAlbum &&
                (this.PageContext.UsrAlbums > 0 || this.PageContext.NumAlbums > 0))
            {
                RenderMenuItem(
                    this.MyAlbumsItem,
                    "dropdown-item",
                    this.GetText("TOOLBAR", "MYALBUMS"),
                    this.GetText("TOOLBAR", "MYALBUMS_TITLE"),
                    YafBuildLink.GetLinkNotEscaped(ForumPages.albums, "u={0}", this.PageContext.PageUserID),
                    false,
                    false,
                    null,
                    null,
                    "images");
            }

            // My Topics
            RenderMenuItem(
                this.MyTopicItem,
                "dropdown-item",
                this.GetText("TOOLBAR", "MYTOPICS"),
                this.GetText("TOOLBAR", "MYTOPICS"),
                YafBuildLink.GetLink(ForumPages.mytopics),
                false,
                false,
                string.Empty,
                string.Empty,
                "comment");

            // Logout
            if (!Config.IsAnyPortal && Config.AllowLoginAndLogoff)
            {
                this.LogutItem.Visible = true;
                this.LogOutButton.Text =
                    $"<i class=\"fa fa-sign-out-alt fa-fw\"></i>&nbsp;{this.GetText("TOOLBAR", "LOGOUT")}";
                this.LogOutButton.ToolTip = this.GetText("TOOLBAR", "LOGOUT");
            }

            // Logged in as : username
            this.LoggedInUserPanel.Visible = true;

            this.UnreadPlaceHolder.Visible = this.PageContext.UnreadPrivate + this.PageContext.PendingBuddies > 0;
        }
コード例 #23
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.IsPostBack)
            {
                return;
            }

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

            this.PageLinks.AddLink(this.GetText("ADMIN_TEST_DATA", "TITLE"), string.Empty);

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

            this.Populate_Controls();

            const string _BoardOptionsCurrentBoardIn        = "In Current Board";
            const string _BoardOptionsAllBoardsIn           = "In All Boards";
            const string _BoardOptionsAllBoardsButCurrentIn = "In All But Current";
            const string _BoardOptionsAllBoardsSpecificIn   = "In A Specific Board";

            this.TimeZones.DataSource = StaticDataHelper.TimeZones();

            var categories = this.GetRepository <Category>().List();

            this.ForumsCategory.DataSource = categories;
            this.TopicsCategory.DataSource = categories;
            this.PostsCategory.DataSource  = categories;

            // Access Mask Lists
            this.ForumsStartMask.DataSource = this.GetRepository <AccessMask>().GetByBoardId();
            this.ForumsAdminMask.DataSource = this.ForumsStartMask.DataSource;

            this.ForumsGroups.DataSource = this.GetRepository <Group>().List(boardId: this.PageContext.PageBoardID);

            // Board lists
            this.UsersBoardsList.DataSource      = this.GetRepository <Board>().List();
            this.CategoriesBoardsList.DataSource = this.UsersBoardsList.DataSource;
            this.PMessagesBoardsList.DataSource  = this.UsersBoardsList.DataSource;

            this.DataBind();

            if (this.ForumsAdminMask.Items.Count > 0)
            {
                this.ForumsAdminMask.SelectedIndex = this.ForumsAdminMask.Items.Count - 1;
            }

            if (this.ForumsStartMask.Items.Count > 1)
            {
                this.ForumsStartMask.SelectedIndex = 1;
            }

            this.TopicsCategory.ClearSelection();
            this.PostsCategory.ClearSelection();

            this.ForumsCategory.SelectedIndex = -1;

            this.TimeZones.Items.FindByValue("0").Selected = true;

            this.From.Text = this.PageContext.User.UserName;
            this.To.Text   = this.PageContext.User.UserName;

            this.TopicsPriorityList.Items.Add(new ListItem("Normal", "0"));
            this.TopicsPriorityList.Items.Add(new ListItem("Sticky", "1"));
            this.TopicsPriorityList.Items.Add(new ListItem("Announcement", "2"));

            this.TopicsPriorityList.SelectedIndex = 0;

            this.UsersBoardsOptions.Items.Add(new ListItem(_BoardOptionsCurrentBoardIn, "0"));
            this.UsersBoardsOptions.Items.Add(new ListItem(_BoardOptionsAllBoardsIn, "1"));
            this.UsersBoardsOptions.Items.Add(new ListItem(_BoardOptionsAllBoardsButCurrentIn, "2"));
            this.UsersBoardsOptions.Items.Add(new ListItem(_BoardOptionsAllBoardsSpecificIn, "3"));

            this.UsersBoardsOptions.SelectedIndex = 0;

            this.CategoriesBoardsOptions.Items.Add(new ListItem(_BoardOptionsCurrentBoardIn, "0"));
            this.CategoriesBoardsOptions.Items.Add(new ListItem(_BoardOptionsAllBoardsIn, "1"));
            this.CategoriesBoardsOptions.Items.Add(new ListItem(_BoardOptionsAllBoardsButCurrentIn, "2"));
            this.CategoriesBoardsOptions.Items.Add(new ListItem(_BoardOptionsAllBoardsSpecificIn, "3"));

            this.CategoriesBoardsOptions.SelectedIndex = 0;

            this.PMessagesBoardsOptions.Items.Add(new ListItem(_BoardOptionsCurrentBoardIn, "0"));
            this.PMessagesBoardsOptions.Items.Add(new ListItem(_BoardOptionsAllBoardsIn, "1"));
            this.PMessagesBoardsOptions.Items.Add(new ListItem(_BoardOptionsAllBoardsButCurrentIn, "2"));
            this.PMessagesBoardsOptions.Items.Add(new ListItem(_BoardOptionsAllBoardsSpecificIn, "3"));

            this.PMessagesBoardsOptions.SelectedIndex = 0;
        }
コード例 #24
0
ファイル: YafHeader.ascx.cs プロジェクト: happyyb/YAFNET
        /// <summary>
        /// Render The GuestBar
        /// </summary>
        private void RenderGuestControls()
        {
            if (!this.PageContext.IsGuest)
            {
                return;
            }

            this.GuestUserMessage.Visible = true;

            this.GuestMessage.Text = this.GetText("TOOLBAR", "WELCOME_GUEST_FULL");

            var endPoint = new Label {
                Text = "."
            };

            var isLoginAllowed    = false;
            var isRegisterAllowed = false;

            if (Config.IsAnyPortal)
            {
                this.GuestMessage.Text = this.GetText("TOOLBAR", "WELCOME_GUEST");
            }
            else
            {
                if (Config.AllowLoginAndLogoff)
                {
                    // show login
                    var loginLink = new HyperLink
                    {
                        Text        = this.GetText("TOOLBAR", "LOGIN"),
                        ToolTip     = this.GetText("TOOLBAR", "LOGIN"),
                        NavigateUrl = "javascript:void(0);",
                        CssClass    = "alert-link LoginLink"
                    };

                    this.GuestUserMessage.Controls.Add(loginLink);

                    isLoginAllowed = true;
                }

                if (!this.Get <YafBoardSettings>().DisableRegistrations)
                {
                    if (isLoginAllowed)
                    {
                        this.GuestUserMessage.Controls.Add(
                            new Label {
                            Text = $"&nbsp;{this.GetText("COMMON", "OR")}&nbsp;"
                        });
                    }

                    // show register link
                    var registerLink = new HyperLink
                    {
                        Text        = this.GetText("TOOLBAR", "REGISTER"),
                        NavigateUrl =
                            this.Get <YafBoardSettings>().ShowRulesForRegistration
                                                       ? YafBuildLink.GetLink(ForumPages.rules)
                                                       : !this.Get <YafBoardSettings>().UseSSLToRegister
                                                           ? YafBuildLink.GetLink(ForumPages.register)
                                                           : YafBuildLink.GetLink(
                                ForumPages.register,
                                true).Replace("http:", "https:"),
                        CssClass = "alert-link"
                    };

                    this.GuestUserMessage.Controls.Add(registerLink);

                    this.GuestUserMessage.Controls.Add(endPoint);

                    isRegisterAllowed = true;
                }
                else
                {
                    this.GuestUserMessage.Controls.Add(endPoint);

                    this.GuestUserMessage.Controls.Add(
                        new Label {
                        Text = this.GetText("TOOLBAR", "DISABLED_REGISTER")
                    });
                }

                // If both disallowed
                if (isLoginAllowed || isRegisterAllowed)
                {
                    return;
                }

                this.GuestUserMessage.Controls.Clear();
                this.GuestUserMessage.Controls.Add(new Label {
                    Text = this.GetText("TOOLBAR", "WELCOME_GUEST_NO")
                });
            }
        }
コード例 #25
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;
            }

            DataTable sigData = LegacyDb.user_getalbumsdata(this.PageContext.PageUserID, YafContext.Current.PageBoardID);

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

            int[] albumSize = LegacyDb.album_getstats(this.PageContext.PageUserID, null);
            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[0] >= 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 =
                    LegacyDb.album_list(
                        null, Security.StringToLongOrRedirect(this.Get <HttpRequestBase>().QueryString.GetFirstOrDefault("a")))
                    .Rows[0]["UserID"].ToType <int>();

                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.Back.Text   = this.GetText("BACK");
            this.Upload.Text = this.GetText("UPLOAD");

            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;
            }
        }
コード例 #26
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)
        {
            var endPoint = new Literal {
                Text = "."
            };

            var isLoginAllowed    = false;
            var isRegisterAllowed = false;

            if (Config.IsAnyPortal)
            {
                this.Visible = false;
            }
            else
            {
                if (Config.AllowLoginAndLogoff)
                {
                    this.ConnectHolder.Controls.Add(
                        new Literal {
                        Text = this.GetText("TOOLBAR", "WELCOME_GUEST_CONNECT")
                    });

                    // show login
                    var loginLink = new ThemeButton
                    {
                        TextLocalizedTag   = "LOGIN_CONNECT",
                        TextLocalizedPage  = "TOOLBAR",
                        ParamTitle0        = this.Get <YafBoardSettings>().Name,
                        TitleLocalizedTag  = "LOGIN",
                        TitleLocalizedPage = "TOOLBAR",
                        CssClass           = "yafcssbigbutton"
                    };

                    if (this.Get <YafBoardSettings>().UseLoginBox&& !(this.Get <IYafSession>().UseMobileTheme ?? false))
                    {
                        loginLink.NavigateUrl = "javascript:void(0);";

                        loginLink.CssClass = "LoginLink";
                    }
                    else
                    {
                        var returnUrl = this.Get <HttpRequestBase>().QueryString.GetFirstOrDefault("ReturnUrl").IsSet()
                                            ? "ReturnUrl={0}".FormatWith(
                            this.Get <HttpRequestBase>().QueryString.GetFirstOrDefault("ReturnUrl"))
                                            : string.Empty;

                        loginLink.NavigateUrl = !this.Get <YafBoardSettings>().UseSSLToLogIn
                                                    ? YafBuildLink.GetLinkNotEscaped(ForumPages.login, returnUrl)
                                                    : YafBuildLink.GetLinkNotEscaped(ForumPages.login, true, returnUrl)
                                                .Replace("http:", "https:");
                    }

                    this.ConnectHolder.Controls.Add(loginLink);

                    isLoginAllowed = true;
                }

                if (!this.Get <YafBoardSettings>().DisableRegistrations)
                {
                    // show register link
                    var registerLink = new ThemeButton
                    {
                        TextLocalizedTag   = "REGISTER_CONNECT",
                        TextLocalizedPage  = "TOOLBAR",
                        TitleLocalizedTag  = "REGISTER",
                        TitleLocalizedPage = "TOOLBAR",
                        CssClass           = "yafcssbigbutton",
                        NavigateUrl        =
                            this.Get <YafBoardSettings>().ShowRulesForRegistration
                                                       ? YafBuildLink.GetLink(ForumPages.rules)
                                                       : (!this.Get <YafBoardSettings>().UseSSLToRegister
                                                              ? YafBuildLink.GetLink(ForumPages.register)
                                                              : YafBuildLink.GetLink(
                                                              ForumPages.register,
                                                              true).Replace("http:", "https:"))
                    };

                    this.ConnectHolder.Controls.Add(registerLink);

                    this.ConnectHolder.Controls.Add(endPoint);

                    isRegisterAllowed = true;
                }
                else
                {
                    this.ConnectHolder.Controls.Add(endPoint);

                    this.ConnectHolder.Controls.Add(new Literal {
                        Text = this.GetText("TOOLBAR", "DISABLED_REGISTER")
                    });
                }

                // If both disallowed
                if (!isLoginAllowed && !isRegisterAllowed)
                {
                    this.ConnectHolder.Controls.Clear();

                    this.ConnectHolder.Visible = false;

                    return;
                }

                if (this.Get <YafBoardSettings>().AllowSingleSignOn &&
                    (Config.FacebookAPIKey.IsSet() || Config.TwitterConsumerKey.IsSet() ||
                     Config.GoogleClientID.IsSet()))
                {
                    this.ConnectHolder.Controls.Add(
                        new Literal {
                        Text = "&nbsp;{0}&nbsp;".FormatWith(this.GetText("LOGIN", "CONNECT_VIA"))
                    });

                    if (Config.FacebookAPIKey.IsSet() && Config.FacebookSecretKey.IsSet())
                    {
                        var linkButton = new LinkButton
                        {
                            Text    = "Facebook",
                            ToolTip =
                                this.GetTextFormatted("AUTH_CONNECT_HELP", "Facebook"),
                            ID       = "FacebookRegister",
                            CssClass = "authLogin facebookLogin"
                        };

                        linkButton.Click += this.FacebookFormClick;

                        this.ConnectHolder.Controls.Add(linkButton);
                    }

                    this.ConnectHolder.Controls.Add(new Literal {
                        Text = "&nbsp;"
                    });

                    if (Config.TwitterConsumerKey.IsSet() && Config.TwitterConsumerSecret.IsSet())
                    {
                        var linkButton = new LinkButton
                        {
                            Text    = "Twitter",
                            ToolTip =
                                this.GetTextFormatted("AUTH_CONNECT_HELP", "Twitter"),
                            ID       = "TwitterRegister",
                            CssClass = "authLogin twitterLogin"
                        };

                        linkButton.Click += this.TwitterFormClick;

                        this.ConnectHolder.Controls.Add(linkButton);
                    }

                    this.ConnectHolder.Controls.Add(new Literal {
                        Text = "&nbsp;"
                    });

                    if (Config.GoogleClientID.IsSet() && Config.GoogleClientSecret.IsSet())
                    {
                        var linkButton = new LinkButton
                        {
                            Text     = "Google",
                            ToolTip  = this.GetTextFormatted("AUTH_CONNECT_HELP", "Google"),
                            ID       = "GoogleRegister",
                            CssClass = "authLogin googleLogin"
                        };

                        linkButton.Click += this.GoogleFormClick;

                        this.ConnectHolder.Controls.Add(linkButton);
                    }
                }
            }
        }
コード例 #27
0
ファイル: editboard.ascx.cs プロジェクト: KnowMoreIT/YAFNET
        /// <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.IsPostBack)
            {
                return;
            }

            this.PageLinks.AddRoot();
            this.PageLinks.AddLink(
                this.GetText("ADMIN_ADMIN", "Administration"),
                YafBuildLink.GetLink(ForumPages.admin_admin));
            this.PageLinks.AddLink(
                this.GetText("ADMIN_BOARDS", "TITLE"),
                YafBuildLink.GetLink(ForumPages.admin_editboard));
            this.PageLinks.AddLink(this.GetText("ADMIN_EDITBOARD", "TITLE"), string.Empty);

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

            this.Save.Text   = this.GetText("SAVE");
            this.Cancel.Text = this.GetText("CANCEL");

            this.Culture.DataSource =
                StaticDataHelper.Cultures()
                .AsEnumerable()
                .OrderBy(x => x.Field <string>("CultureNativeName"))
                .CopyToDataTable();
            this.Culture.DataValueField = "CultureTag";
            this.Culture.DataTextField  = "CultureNativeName";

            this.BindData();

            if (this.Culture.Items.Count > 0)
            {
                this.Culture.Items.FindByValue(this.Get <YafBoardSettings>().Culture).Selected = true;
            }

            if (this.BoardID != null)
            {
                this.CreateNewAdminHolder.Visible = false;

                using (DataTable dt = this.GetRepository <Board>().List(this.BoardID))
                {
                    DataRow row = dt.Rows[0];
                    this.Name.Text             = (string)row["Name"];
                    this.AllowThreaded.Checked = Convert.ToBoolean(row["AllowThreaded"]);

                    var membershipAppName = row["MembershipAppName"].ToString();

                    if (membershipAppName.IsSet())
                    {
                        this.BoardMembershipAppName.Text    = row["MembershipAppName"].ToString();
                        this.BoardMembershipAppName.Enabled = false;
                    }
                    else
                    {
                        this.BoardMembershipAppNameHolder.Visible = false;
                    }
                }
            }
            else
            {
                this.UserName.Text  = this.User.UserName;
                this.UserEmail.Text = this.User.Email;
            }

            if (Config.IsDotNetNuke)
            {
                this.CreateNewAdminHolder.Visible = false;
            }
        }
コード例 #28
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (User == null)
            {
                YafBuildLink.AccessDenied();
            }

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

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

                string displayName = UserMembershipHelper.GetDisplayNameFromID(UserID);

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

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

                Msg.NavigateUrl = "msnim:chat?contact={0}".FormatWith(userData.Profile.MSN);
                //Msg.Attributes.Add( "onclick", "return skypeCheck();" );
                Img.Src = "http://messenger.services.live.com/users/{0}/presenceimage".FormatWith(userData.Profile.MSN);
            }
        }
コード例 #29
0
ファイル: avatar.ascx.cs プロジェクト: ahsan-sally/demo
        /// <summary>
        /// Handles the Bind event of the Files control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="DataListItemEventArgs"/> instance containing the event data.</param>
        public void Files_Bind([NotNull] object sender, [NotNull] DataListItemEventArgs e)
        {
            var directoryPath = Path.Combine(YafForumInfo.ForumClientFileRoot, YafBoardFolders.Current.Avatars);

            var fname = (Literal)e.Item.FindControl("fname");

            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                var finfo = new FileInfo(
                    this.Server.MapPath(Convert.ToString(DataBinder.Eval(e.Item.DataItem, "name"))));

                if (this.CurrentDirectory.IsSet())
                {
                    directoryPath = this.CurrentDirectory;
                }

                var tmpExt = finfo.Extension.ToLower();

                if (tmpExt == ".gif" || tmpExt == ".jpg" || tmpExt == ".jpeg" || tmpExt == ".png" || tmpExt == ".bmp")
                {
                    string link;
                    var    encodedFileName = finfo.Name.Replace(".", "%2E");

                    if (this.returnUserID > 0)
                    {
                        link = YafBuildLink.GetLink(
                            ForumPages.admin_edituser,
                            "u={0}&av={1}",
                            this.returnUserID,
                            this.Server.UrlEncode("{0}/{1}".FormatWith(directoryPath, encodedFileName)));
                    }
                    else
                    {
                        link = YafBuildLink.GetLink(
                            ForumPages.cp_editavatar,
                            "av={0}",
                            this.Server.UrlEncode("{0}/{1}".FormatWith(directoryPath, encodedFileName)));
                    }

                    fname.Text =
                        @"<div style=""text-align:center""><a href=""{0}""><img src=""{1}"" alt=""{2}"" title=""{2}"" class=""borderless"" /></a><br /><small>{2}</small></div>{3}"
                        .FormatWith(
                            link,
                            "{0}/{1}".FormatWith(directoryPath, finfo.Name),
                            finfo.Name,
                            Environment.NewLine);
                }
            }

            if (e.Item.ItemType != ListItemType.Header)
            {
                return;
            }

            // get the previous directory...
            var previousDirectory = Path.Combine(YafForumInfo.ForumClientFileRoot, YafBoardFolders.Current.Avatars);

            var up = e.Item.FindControl("up") as LinkButton;

            up.CommandArgument = previousDirectory;
            up.Text            =
                @"<p style=""text-align:center"">
                     <i class=""far fa-folder-open""style=""font-size:50px""></i><br />
                     <button type=""button"" class=""btn btn-primary btn-sm""><i class=""fas fa-arrow-left""></i>&nbsp;{0}</button></p>".FormatWith(this.GetText("UP"));
            up.ToolTip = this.GetText("UP_TITLE");

            // Hide if Top Folder
            if (this.CurrentDirectory.Equals(previousDirectory))
            {
                up.Visible = false;
            }
        }
コード例 #30
0
        /// <summary>
        /// The render.
        /// </summary>
        /// <param name="output">
        /// The output.
        /// </param>
        protected override void Render([NotNull] HtmlTextWriter output)
        {
            if (this.Visible)
            {
                // get the title...
                string title = this.GetLocalizedTitle();

                output.BeginRender();

                if (this.ShowSpacerBefore)
                {
                    output.Write(" |&nbsp;".FormatWith());
                }

                output.WriteBeginTag("a");
                output.WriteAttribute("id", this.ClientID);

                if (this.CssClass.IsSet())
                {
                    output.WriteAttribute("class", this.CssClass);
                }

                if (title.IsSet())
                {
                    output.WriteAttribute("title", title);
                }

                output.WriteAttribute(
                    "href",
                    YafBuildLink.GetLink(
                        ForumPages.rsstopic,
                        "pg={0}&ft={1}{2}",
                        this.FeedType.ToInt(),
                        this.IsAtomFeed ? 1 : 0,
                        this.AdditionalParameters.IsNotSet() ? string.Empty : "&{0}".FormatWith(this.AdditionalParameters)));

                // handle additional attributes (if any)
                if (this._attributeCollection.Count > 0)
                {
                    // add attributes...
                    foreach (string key in this._attributeCollection.Keys)
                    {
                        if (key.ToLower().StartsWith("on") || key.ToLower() == "rel" || key.ToLower() == "target")
                        {
                            // only write javascript attributes -- and a few other attributes...
                            output.WriteAttribute(key, this._attributeCollection[key]);
                        }
                    }
                }

                output.Write(HtmlTextWriter.TagRightChar);

                output.WriteBeginTag("span");
                output.Write(HtmlTextWriter.TagRightChar);

                // render the optional controls (if any)
                base.Render(output);
                output.WriteEndTag("span");

                output.WriteEndTag("a");

                if (this.ShowSpacerAfter)
                {
                    output.Write("&nbsp;| ".FormatWith());
                }

                output.EndRender();
            }
        }