Esempio n. 1
0
        /// <summary>
        /// Checks the access rights.
        /// </summary>
        /// <param name="boardId">The board id.</param>
        /// <param name="forumId">The forum identifier.</param>
        /// <returns>
        /// The check access rights.
        /// </returns>
        private bool CheckAccessRights([NotNull] int boardId, [NotNull] int forumId)
        {
            // Find user name
            var user = this.Get <IAspNetUsersHelper>().GetUser();

            var browser =
                $"{HttpContext.Current.Request.Browser.Browser} {HttpContext.Current.Request.Browser.Version}";
            var platform       = HttpContext.Current.Request.Browser.Platform;
            var isMobileDevice = HttpContext.Current.Request.Browser.IsMobileDevice;
            var userAgent      = HttpContext.Current.Request.UserAgent;

            // try and get more verbose platform name by ref and other parameters
            UserAgentHelper.Platform(
                userAgent,
                HttpContext.Current.Request.Browser.Crawler,
                ref platform,
                ref browser,
                out var isSearchEngine,
                out var doNotTrack);

            this.Get <StartupInitializeDb>().Run();

            string userKey;

            if (user != null)
            {
                userKey = user.Id;
            }
            else
            {
                return(false);
            }

            if (forumId == 0)
            {
                // is private message upload
                return(true);
            }

            var pageRow = this.Get <DataBroker>().GetPageLoad(
                HttpContext.Current.Session.SessionID,
                boardId,
                userKey,
                HttpContext.Current.Request.GetUserRealIPAddress(),
                HttpContext.Current.Request.FilePath,
                HttpContext.Current.Request.QueryString.ToString(),
                browser,
                platform,
                0,
                forumId,
                0,
                0,
                isSearchEngine,
                isMobileDevice,
                doNotTrack);

            return(pageRow.UploadAccess || pageRow.ModeratorAccess);
        }
Esempio n. 2
0
        /// <summary>
        /// Checks the access rights.
        /// </summary>
        /// <param name="boardID">The board id.</param>
        /// <param name="forumID">The forum identifier.</param>
        /// <returns>
        /// The check access rights.
        /// </returns>
        private bool CheckAccessRights([NotNull] int boardID, [NotNull] int forumID)
        {
            if (forumID == 0)
            {
                // is private message upload
                return(true);
            }

            // Find user name
            var user = UserMembershipHelper.GetUser();

            var browser = "{0} {1}".FormatWith(
                HttpContext.Current.Request.Browser.Browser, HttpContext.Current.Request.Browser.Version);
            var  platform       = HttpContext.Current.Request.Browser.Platform;
            var  isMobileDevice = HttpContext.Current.Request.Browser.IsMobileDevice;
            bool isSearchEngine;
            bool dontTrack;
            var  userAgent = HttpContext.Current.Request.UserAgent;

            // try and get more verbose platform name by ref and other parameters
            UserAgentHelper.Platform(
                userAgent,
                HttpContext.Current.Request.Browser.Crawler,
                ref platform,
                ref browser,
                out isSearchEngine,
                out dontTrack);

            this.Get <StartupInitializeDb>().Run();

            object userKey = DBNull.Value;

            if (user != null)
            {
                userKey = user.ProviderUserKey;
            }

            DataRow pageRow = LegacyDb.pageload(
                HttpContext.Current.Session.SessionID,
                boardID,
                userKey,
                HttpContext.Current.Request.GetUserRealIPAddress(),
                HttpContext.Current.Request.FilePath,
                HttpContext.Current.Request.QueryString.ToString(),
                browser,
                platform,
                null,
                forumID,
                null,
                null,
                isSearchEngine, // don't track if this is a search engine
                isMobileDevice,
                dontTrack);

            return(pageRow["UploadAccess"].ToType <bool>() || pageRow["ModeratorAccess"].ToType <bool>());
        }
Esempio n. 3
0
        /// <summary>
        /// Checks the access rights.
        /// </summary>
        /// <param name="boardId">The board id.</param>
        /// <param name="messageId">The message id.</param>
        /// <returns>
        /// The check access rights.
        /// </returns>
        public bool CheckAccessRights([NotNull] int boardId, [NotNull] int messageId)
        {
            if (messageId.Equals(0))
            {
                return(true);
            }

            // Find user name
            var user = UserMembershipHelper.GetUser();

            var browser =
                $"{HttpContext.Current.Request.Browser.Browser} {HttpContext.Current.Request.Browser.Version}";
            var  platform       = HttpContext.Current.Request.Browser.Platform;
            var  isMobileDevice = HttpContext.Current.Request.Browser.IsMobileDevice;
            bool isSearchEngine;
            bool dontTrack;
            var  userAgent = HttpContext.Current.Request.UserAgent;

            // try and get more verbose platform name by ref and other parameters
            UserAgentHelper.Platform(
                userAgent,
                HttpContext.Current.Request.Browser.Crawler,
                ref platform,
                ref browser,
                out isSearchEngine,
                out dontTrack);

            YafContext.Current.Get <StartupInitializeDb>().Run();

            object userKey = DBNull.Value;

            if (user != null)
            {
                userKey = user.ProviderUserKey;
            }

            var pageRow = YafContext.Current.GetRepository <ActiveAccess>().PageLoad(
                HttpContext.Current.Session.SessionID,
                boardId,
                userKey,
                HttpContext.Current.Request.GetUserRealIPAddress(),
                HttpContext.Current.Request.FilePath,
                HttpContext.Current.Request.QueryString.ToString(),
                browser,
                platform,
                null,
                null,
                null,
                messageId,
                isSearchEngine, // don't track if this is a search engine
                isMobileDevice,
                dontTrack);

            return(pageRow["DownloadAccess"].ToType <bool>() || pageRow["ModeratorAccess"].ToType <bool>());
        }
Esempio n. 4
0
        /// <summary>
        /// Checks the access rights.
        /// </summary>
        /// <param name="boardId">The board id.</param>
        /// <param name="forumId">The forum identifier.</param>
        /// <returns>
        /// The check access rights.
        /// </returns>
        private bool CheckAccessRights([NotNull] int boardId, [NotNull] int forumId)
        {
            if (forumId == 0)
            {
                // is private message upload
                return(true);
            }

            // Find user name
            var user = UserMembershipHelper.GetUser();

            var browser =
                $"{HttpContext.Current.Request.Browser.Browser} {HttpContext.Current.Request.Browser.Version}";
            var platform       = HttpContext.Current.Request.Browser.Platform;
            var isMobileDevice = HttpContext.Current.Request.Browser.IsMobileDevice;
            var userAgent      = HttpContext.Current.Request.UserAgent;

            // try and get more verbose platform name by ref and other parameters
            UserAgentHelper.Platform(
                userAgent,
                HttpContext.Current.Request.Browser.Crawler,
                ref platform,
                ref browser,
                out var isSearchEngine,
                out var doNotTrack);

            this.Get <StartupInitializeDb>().Run();

            object userKey = DBNull.Value;

            if (user != null)
            {
                userKey = user.ProviderUserKey;
            }

            var pageRow = this.GetRepository <ActiveAccess>().PageLoad(
                HttpContext.Current.Session.SessionID,
                boardId,
                userKey,
                HttpContext.Current.Request.GetUserRealIPAddress(),
                HttpContext.Current.Request.FilePath,
                HttpContext.Current.Request.QueryString.ToString(),
                browser,
                platform,
                null,
                forumId,
                null,
                null,
                isSearchEngine,
                isMobileDevice,
                doNotTrack);

            return(pageRow["UploadAccess"].ToType <bool>() || pageRow["ModeratorAccess"].ToType <bool>());
        }
Esempio n. 5
0
        /// <summary>
        /// Handles the specified @event.
        /// </summary>
        /// <param name="event">The @event.</param>
        public void Handle([NotNull] InitPageLoadEvent @event)
        {
            string browser = "{0} {1}".FormatWith(
                this.HttpRequestBase.Browser.Browser, this.HttpRequestBase.Browser.Version);
            string platform = this.HttpRequestBase.Browser.Platform;

            bool isSearchEngine;
            bool dontTrack;

            string userAgent = this.HttpRequestBase.UserAgent;

            bool isMobileDevice = UserAgentHelper.IsMobileDevice(userAgent) ||
                                  this.HttpRequestBase.Browser.IsMobileDevice;

            // try and get more verbose platform name by ref and other parameters
            UserAgentHelper.Platform(
                userAgent,
                this.HttpRequestBase.Browser.Crawler,
                ref platform,
                ref browser,
                out isSearchEngine,
                out dontTrack);

            dontTrack = !this.Get <YafBoardSettings>().ShowCrawlersInActiveList&& isSearchEngine;

            // don't track if this is a feed reader. May be to make it switchable in host settings.
            // we don't have page 'g' token for the feed page.
            if (browser.Contains("Unknown") && !dontTrack)
            {
                dontTrack = UserAgentHelper.IsFeedReader(userAgent);
            }

            @event.Data.DontTrack      = dontTrack;
            @event.Data.UserAgent      = userAgent;
            @event.Data.IsSearchEngine = isSearchEngine;
            @event.Data.IsMobileDevice = isMobileDevice;
            @event.Data.Browser        = browser;
            @event.Data.Platform       = platform;

            YafContext.Current.Vars["DontTrack"] = dontTrack;
        }