/// <summary>
        /// Handles the specified @event.
        /// </summary>
        /// <param name="event">The @event.</param>
        public void Handle([NotNull] InitPageLoadEvent @event)
        {
            // vzrus: to log unhandled UserAgent strings
            if (!this.Get <BoardSettings>().UserAgentBadLog)
            {
                return;
            }

            if (this.HttpRequestBase.Url.ToString().Contains("digest"))
            {
                return;
            }

            if (string.IsNullOrWhiteSpace(@event.Data.UserAgent))
            {
                this.Logger.Warn("UserAgent string is empty.");
            }

            if ((@event.Data.Platform.ToLower().Contains("unknown") ||
                 @event.Data.Browser.ToLower().Contains("unknown")) &&
                !UserAgentHelper.IsSearchEngineSpider(@event.Data.UserAgent))
            {
                this.Logger.Log(
                    BoardContext.Current.PageUserID,
                    this,
                    $"Unhandled UserAgent string:'{(string)@event.Data.UserAgent}'<br />Platform:'{this.HttpRequestBase.Browser.Platform}'<br />Browser:'{this.HttpRequestBase.Browser.Browser}'");
            }
        }
        /// <summary>
        /// Handles the specified @event.
        /// </summary>
        /// <param name="event">The @event.</param>
        public void Handle([NotNull] InitPageLoadEvent @event)
        {
            // vzrus: to log unhandled UserAgent strings
            if (!this.Get <YafBoardSettings>().UserAgentBadLog)
            {
                return;
            }

            if (string.IsNullOrWhiteSpace(@event.Data.UserAgent))
            {
                this.Logger.Warn("UserAgent string is empty.");
            }

            if ((@event.Data.Platform.ToLower().Contains("unknown") ||
                 @event.Data.Browser.ToLower().Contains("unknown")) &&
                (!UserAgentHelper.IsSearchEngineSpider(@event.Data.UserAgent)))
            {
                this.Logger.Log(
                    YafContext.Current.User != null ? YafContext.Current.User.UserName : string.Empty,
                    this,
                    "Unhandled UserAgent string:'{0}'<br />Platform:'{1}'<br />Browser:'{2}'".FormatWith(
                        (string)@event.Data.UserAgent,
                        this.HttpRequestBase.Browser.Platform,
                        this.HttpRequestBase.Browser.Browser));
            }
        }
Exemple #3
0
        /// <summary>
        /// The page_ load.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        protected void Page_Load(object sender, EventArgs e)
        {
            this.PollList.Visible     = this.PageContext.BoardSettings.BoardPollID > 0;
            this.PollList.PollGroupId = this.PageContext.BoardSettings.BoardPollID;
            this.PollList.BoardId     = this.PageContext.Settings.BoardID;

            if (!this.IsPostBack)
            {
                // vzrus: needs testing, potentially can cause problems
                if (!(UserAgentHelper.IsSearchEngineSpider(HttpContext.Current.Request.UserAgent)))
                {
                    if (!HttpContext.Current.Request.Browser.Cookies)
                    {
                        YafBuildLink.RedirectInfoPage(InfoMessage.RequiresCookies);
                    }

                    Version ecmaVersion = HttpContext.Current.Request.Browser.EcmaScriptVersion;

                    if (ecmaVersion != null)
                    {
                        if (!(ecmaVersion.Major > 0))
                        {
                            YafBuildLink.RedirectInfoPage(InfoMessage.EcmaScriptVersionUnsupported);
                        }
                    }
                    else
                    {
                        YafBuildLink.RedirectInfoPage(InfoMessage.RequiresEcmaScript);
                    }
                }

                this.ShoutBox1.Visible         = this.PageContext.BoardSettings.ShowShoutbox;
                this.ForumStats.Visible        = this.PageContext.BoardSettings.ShowForumStatistics;
                this.ActiveDiscussions.Visible = this.PageContext.BoardSettings.ShowActiveDiscussions;


                if (this.PageContext.Settings.LockedForum == 0)
                {
                    this.PageLinks.AddLink(this.PageContext.BoardSettings.Name, YafBuildLink.GetLink(ForumPages.forum));
                    if (this.PageContext.PageCategoryID != 0)
                    {
                        this.PageLinks.AddLink(
                            this.PageContext.PageCategoryName,
                            YafBuildLink.GetLink(ForumPages.forum, "c={0}", this.PageContext.PageCategoryID));
                        this.Welcome.Visible = false;
                    }
                }
            }
        }