/// <summary>
        /// Checks with blog spam.
        /// </summary>
        /// <param name="userName">Name of the user.</param>
        /// <param name="postMessage">The post message.</param>
        /// <param name="ipAddress">The IP Address.</param>
        /// <param name="result">The result.</param>
        /// <returns>
        /// Returns if the Content or the User was flagged as Spam, or not
        /// </returns>
        private bool CheckWithBlogSpam([NotNull] string userName, [NotNull] string postMessage, [NotNull] string ipAddress, out string result)
        {
            var isLocal = YafContext.Current.Get <HttpRequestBase>().IsLocal;

            var whiteList = isLocal ? "whitelist=127.0.0.1" : string.Empty;

            try
            {
                return
                    (BlogSpamNet.CommentIsSpam(
                         new BlogSpamComment
                {
                    comment = postMessage,
                    ip = ipAddress,
                    agent = YafContext.Current.Get <HttpRequestBase>().UserAgent,
                    name = userName,
                    options = whiteList,
                },
                         true,
                         out result));
            }
            catch (Exception ex)
            {
                YafContext.Current.Get <ILogger>().Error(ex, "Error while Checking for Spam via BlogSpam");

                result = string.Empty;
                return(false);
            }
        }
예제 #2
0
        /// <summary>
        /// Report Message as Spam
        /// </summary>
        /// <param name="comment">
        /// The comment.
        /// </param>
        private void ReportSpam(string comment)
        {
            if (this.Get <YafBoardSettings>().SpamServiceType.Equals(1))
            {
                string message = BlogSpamNet.ClassifyComment(comment, true);

                this.PageContext.AddLoadMessage(message);
            }

            try
            {
                if (this.Get <YafBoardSettings>().SpamServiceType.Equals(2) && !string.IsNullOrEmpty(this.Get <YafBoardSettings>().AkismetApiKey))
                {
                    var service = new AkismetSpamClient(this.Get <YafBoardSettings>().AkismetApiKey, new Uri(BaseUrlBuilder.BaseUrl));

                    service.SubmitSpam(new Comment(null, string.Empty)
                    {
                        Content = comment
                    });

                    this.PageContext.AddLoadMessage(this.GetText("MODERATE_DEFAULT", "SPAM_REPORTED"));
                }
            }
            catch (Exception)
            {
                this.PageContext.AddLoadMessage(this.GetText("MODERATE_DEFAULT", "SPAM_REPORTED_FAILED"));
            }
        }
예제 #3
0
        /// <summary>
        /// Report Message as Spam
        /// </summary>
        /// <param name="comment">
        /// The comment.
        /// </param>
        private void ReportSpam(string comment)
        {
            if (this.Get <YafBoardSettings>().SpamServiceType.Equals(1))
            {
                var message = BlogSpamNet.ClassifyComment(comment, true);

                this.PageContext.AddLoadMessage(message);
            }
        }
예제 #4
0
        /// <summary>
        /// Report Message as Spam
        /// </summary>
        /// <param name="comment">
        /// The comment.
        /// </param>
        private void ReportSpam(string comment)
        {
            if (this.Get <YafBoardSettings>().SpamServiceType.Equals(1))
            {
                string message = BlogSpamNet.ClassifyComment(comment, true);

                this.PageContext.AddLoadMessage(message);
            }

            try
            {
                if (!this.Get <YafBoardSettings>().SpamServiceType.Equals(2) ||
                    string.IsNullOrEmpty(this.Get <YafBoardSettings>().AkismetApiKey))
                {
                    return;
                }

                var service = new AkismetSpamClient(this.Get <YafBoardSettings>().AkismetApiKey, new Uri(BaseUrlBuilder.BaseUrl));

                service.SubmitSpam(new Comment(null, string.Empty)
                {
                    Content = comment
                });

                this.Logger.Log(
                    this.PageContext.PageUserID,
                    "Spam Message Reported",
                    "Message '{0}' was Reported to Akismet.com by {1}".FormatWith(
                        comment,
                        this.Get <YafBoardSettings>().EnableDisplayName
                            ? this.PageContext.CurrentUserData.DisplayName
                            : this.PageContext.CurrentUserData.UserName),
                    EventLogTypes.SpamMessageReported);

                this.PageContext.AddLoadMessage(this.GetText("MODERATE_DEFAULT", "SPAM_REPORTED"));
            }
            catch (Exception)
            {
                this.PageContext.AddLoadMessage(this.GetText("MODERATE_DEFAULT", "SPAM_REPORTED_FAILED"));
            }
        }