public bool ValidateComment(Comment comment) {
            CommentSettingsRecord commentSettingsRecord = CurrentSite.As<CommentSettings>().Record;
            string akismetKey = commentSettingsRecord.AkismetKey;
            string akismetUrl = commentSettingsRecord.AkismetUrl;
            bool enableSpamProtection = commentSettingsRecord.EnableSpamProtection;
            if (enableSpamProtection == false) {
                return true;
            }
            if (String.IsNullOrEmpty(akismetKey)) {
                _notifer.Information(T("Please configure your Akismet key for spam protection"));
                return true;
            }
            if (String.IsNullOrEmpty(akismetUrl)) {
                akismetUrl = "http://www.orchardproject.net";
            }
            Akismet akismetApi = new Akismet(akismetKey, akismetUrl, null);
            AkismetComment akismetComment = new AkismetComment {
                CommentAuthor = comment.Record.Author,
                CommentAuthorEmail = comment.Record.Email,
                Blog = comment.Record.SiteName,
                CommentAuthorUrl = comment.Record.SiteName,
                CommentContent = comment.Record.CommentText,
                UserAgent = HttpContext.Current.Request.UserAgent,
            };

            if (akismetApi.VerifyKey()) {
                return akismetApi.CommentCheck(akismetComment);
            }

            return false;
        }
        public override Boolean Check(int nodeid,
            string UserAgent, string UserIp, string Author,
            string AuthorEmail, string AuthorUrl, string Content)
        {

           
                Akismet api = Initialize(nodeid);

                if (api != null)
                {
                    AkismetComment comment = new AkismetComment();
                    comment.UserAgent = UserAgent;
                    comment.UserIp = UserIp;
                    comment.CommentType = "comment";
                    comment.CommentAuthor = Author;
                    comment.CommentAuthorEmail = AuthorEmail;
                    comment.CommentAuthorUrl = AuthorUrl;
                    comment.CommentContent = Content;

                    return api.CommentCheck(comment);
                }
                else
                {
                    return false;
                }
        }
示例#3
0
        /// <summary>Checks TypePadComment object against Akismet database.</summary>
        /// <param name="comment">TypePadComment object to check.</param>
        /// <returns>'True' if spam, 'False' if not spam.</returns>
        public bool CommentCheck(AkismetComment comment)
        {
            bool value = false;

            value = Convert.ToBoolean(HttpPost(String.Format(commentCheckUrl, apiKey), CreateData(comment), CharSet));
            return(value);
        }
示例#4
0
        /// <summary>
        /// Checks TypePadComment object against Akismet database.
        /// </summary>
        /// <param name="comment">
        /// TypePadComment object to check.
        /// </param>
        /// <returns>
        /// 'True' if spam, 'False' if not spam.
        /// </returns>
        public bool CommentCheck(AkismetComment comment)
        {
            var value =
                Convert.ToBoolean(
                    this.HttpPost(String.Format(this.commentCheckUrl, this.apiKey), CreateData(comment), this.CharSet));

            return(value);
        }
示例#5
0
文件: Akismet.cs 项目: phaniav/WeBlog
        /// <summary>Submits AkismetComment object into Akismet database.</summary>
        /// <param name="comment">AkismetComment object to submit.</param>
        public void SubmitSpam(AkismetComment comment)
        {
            string value = HttpPost(String.Format(submitSpamUrl, apiKey), CreateData(comment), CharSet);

#if DEBUG
            Console.WriteLine("SubmitSpam() = {0}.", value);
#endif
        }
示例#6
0
        /// <summary>Checks AkismetComment object against Akismet database.</summary>
        /// <param name="comment">AkismetComment object to check.</param>
        /// <returns>'True' if spam, 'False' if not spam.</returns>
        public bool CommentCheck(AkismetComment comment) {
            bool value = false;

            value = Convert.ToBoolean(HttpPost(String.Format(commentCheckUrl, apiKey), CreateData(comment), CharSet));

#if DEBUG
            Console.WriteLine("CommentCheck() = {0}.", value);
#endif

            return value;
        }
        public void Verify(Pingback pingback)
        {
            var akismet = Connect();
            var akismetComment = new AkismetComment();
            akismetComment.Blog = "http://www.funnelweblog.com";
            akismetComment.CommentAuthorUrl = pingback.TargetUri;
            akismetComment.CommentContent = pingback.TargetUri;
            akismetComment.CommentType = "pingback";

            pingback.IsSpam = akismet.CommentCheck(akismetComment);
        }
示例#8
0
文件: Akismet.cs 项目: phaniav/WeBlog
        /// <summary>Checks AkismetComment object against Akismet database.</summary>
        /// <param name="comment">AkismetComment object to check.</param>
        /// <returns>'True' if spam, 'False' if not spam.</returns>
        public bool CommentCheck(AkismetComment comment)
        {
            bool value = false;

            value = Convert.ToBoolean(HttpPost(String.Format(commentCheckUrl, apiKey), CreateData(comment), CharSet));

#if DEBUG
            Console.WriteLine("CommentCheck() = {0}.", value);
#endif

            return(value);
        }
示例#9
0
        private static AkismetComment GetComment(Comment zComment)
        {
            Joel.Net.AkismetComment comment = new Joel.Net.AkismetComment();
            comment.Blog             = new Macros().FullUrl(new Urls().Home);
            comment.CommentAuthor    = zComment.Name;
            comment.CommentAuthorUrl = zComment.WebSite;
            comment.CommentContent   = zComment.Body;
            comment.CommentType      = "comment";
            comment.UserAgent        = HttpContext.Current.Request.UserAgent;
            comment.UserIp           = zComment.IPAddress;

            return(comment);
        }
示例#10
0
 private static AkismetComment GetAkismetComment(Comment comment)
 {
     AkismetComment akismetComment = new AkismetComment();
     akismetComment.Blog = _settings.GetSingleValue("SiteURL");
     akismetComment.UserIp = comment.IP;
     akismetComment.CommentContent = comment.Content;
     akismetComment.CommentAuthor = comment.Author;
     akismetComment.CommentAuthorEmail = comment.Email;
     if (comment.Website != null)
     {
         akismetComment.CommentAuthorUrl = comment.Website.OriginalString;
     }
     return akismetComment;
 }
        public override void MarkAsSpam(int nodeid, string Author, string AuthorEmail, string AuthorUrl, string Content)
        {
            Akismet api = Initialize(nodeid);

            if (api != null)
            {
                AkismetComment comment = new AkismetComment();
                comment.CommentType = "comment";
                comment.CommentAuthor = Author;
                comment.CommentAuthorEmail = AuthorEmail;
                comment.CommentAuthorUrl = AuthorUrl;
                comment.CommentContent = Content;

                api.SubmitSpam(comment);
            }
        }
示例#12
0
        /// <summary>Takes an TypePadComment object and returns an (escaped) string of data to POST.</summary>
        /// <param name="comment">TypePadComment object to translate.</param>
        /// <returns>A System.String containing the data to POST to Akismet API.</returns>
        private string CreateData(AkismetComment comment)
        {
            string value = String.Format("blog={0}&user_ip={1}&user_agent={2}&referrer={3}&permalink={4}&comment_type={5}" +
                                         "&comment_author={6}&comment_author_email={7}&comment_author_url={8}&comment_content={9}",
                                         HttpUtility.UrlEncode(comment.Blog),
                                         HttpUtility.UrlEncode(comment.UserIp),
                                         HttpUtility.UrlEncode(comment.UserAgent),
                                         HttpUtility.UrlEncode(comment.Referrer),
                                         HttpUtility.UrlEncode(comment.Permalink),
                                         HttpUtility.UrlEncode(comment.CommentType),
                                         HttpUtility.UrlEncode(comment.CommentAuthor),
                                         HttpUtility.UrlEncode(comment.CommentAuthorEmail),
                                         HttpUtility.UrlEncode(comment.CommentAuthorUrl),
                                         HttpUtility.UrlEncode(comment.CommentContent)
                                         );

            return(value);
        }
示例#13
0
        public static bool CheckForSpam(PostComments.Comment comment)
        {
            var api = new Akismet(AkismetKey, BlogUrl, comment.UserAgent);
            if (!api.VerifyKey()) throw new Exception("Akismet API key invalid.");

            var akismetComment = new AkismetComment
            {
                Blog = BlogUrl,
                UserIp = comment.UserHostAddress,
                UserAgent = comment.UserAgent,
                CommentContent = comment.Body,
                CommentType = "comment",
                CommentAuthor = comment.Author,
                CommentAuthorEmail = comment.Email,
                CommentAuthorUrl = comment.Url,
            };

            //Check if Akismet thinks this comment is spam. Returns TRUE if spam.
            return api.CommentCheck(akismetComment);
        }
        public void Verify(Comment comment)
        {
            var settings = settingsProvider.GetSettings<FunnelWebSettings>();
            var akismet = Connect();
            var akismetComment = new AkismetComment();
            akismetComment.Blog = "http://www.funnelweblog.com";
            akismetComment.CommentAuthor = comment.AuthorName;
            akismetComment.CommentAuthorEmail = comment.AuthorEmail;
            akismetComment.CommentAuthorUrl = comment.AuthorUrl;
            akismetComment.CommentContent = comment.Body;
            akismetComment.CommentType = "comment";

            comment.IsSpam = akismet.CommentCheck(akismetComment);

            if (comment.IsSpam)
                return;

            var naughtyWords = settings.SpamWords.Split('\n').Select(x => x.Trim()).Where(x => x.Length > 0).ToArray();
            comment.IsSpam = naughtyWords.Length > 0 && naughtyWords.Any(x => comment.Body.IndexOf(x, StringComparison.InvariantCultureIgnoreCase) >= 0);
        }
示例#15
0
		public static void MarkHam(PostComments.Comment comment)
		{
			var api = new Akismet(AkismetKey, BlogUrl, comment.UserAgent);
			if (!api.VerifyKey()) throw new Exception("Akismet API key invalid.");

			var akismetComment = new AkismetComment
			{
				Blog = BlogUrl,
				UserIp = comment.UserHostAddress,
				UserAgent = comment.UserAgent,
				CommentContent = comment.Body,
				CommentType = "comment",
				CommentAuthor = comment.Author,
				CommentAuthorEmail = comment.Email,
				CommentAuthorUrl = comment.Url,
			};
#if !DEBUG
			api.SubmitHam(akismetComment);
#endif
		}
示例#16
0
        public bool CheckForSpam(PostComments.Comment comment)
        {
            //Create a new instance of the Akismet API and verify your key is valid.
            string blog = ConfigurationManager.AppSettings["MainUrl"];
            var api = new Akismet(akismetKey, blog, comment.UserAgent);
            if (!api.VerifyKey()) throw new Exception("Akismet API key invalid.");

            var akismetComment = new AkismetComment
            {
                Blog = blog,
                UserIp = comment.UserHostAddress,
                UserAgent = comment.UserAgent,
                CommentContent = comment.Body,
                CommentType = "comment",
                CommentAuthor = comment.Author,
                CommentAuthorEmail = comment.Email,
                CommentAuthorUrl = comment.Url,
            };

            //Check if Akismet thinks this comment is spam. Returns TRUE if spam.
            return api.CommentCheck(akismetComment);
        }
示例#17
0
        public void MarkHam(PostComments.Comment comment)
        {
            //Create a new instance of the Akismet API and verify your key is valid.
            string blog = ConfigurationManager.AppSettings["MainUrl"];
            var api = new Akismet(akismetKey, blog, comment.UserAgent);
            if (!api.VerifyKey()) throw new Exception("Akismet API key invalid.");

            var akismetComment = new AkismetComment
            {
                Blog = blog,
                UserIp = comment.UserHostAddress,
                UserAgent = comment.UserAgent,
                CommentContent = comment.Body,
                CommentType = "comment",
                CommentAuthor = comment.Author,
                CommentAuthorEmail = comment.Email,
                CommentAuthorUrl = comment.Url,
            };
            #if !DEBUG
            api.SubmitHam(akismetComment);
            #endif
        }
示例#18
0
        internal static bool CheckCommentForSpamUsingAkismet(HttpRequest request, string name, 
                        string email, string webSite, string feedbackText)
        {
            //Test spam username: viagra-test-123
            Akismet akismetAPI = new Akismet(CacheHandler.GetBlogConfig().AkismetApiKey,
                "http://www." + CacheHandler.GetBlogConfig().Host, "Test/1.0");
            if (!akismetAPI.VerifyKey())
            {
                throw new Exception("Akismet key could not be verified.");
            }
            AkismetComment comment = new AkismetComment();
            comment.Blog = "http://www." + CacheHandler.GetBlogConfig().Host;
            comment.UserIp = request.UserHostAddress;
            comment.UserAgent = request.UserAgent;
            comment.CommentContent = feedbackText;
            comment.CommentType = "comment";
            comment.CommentAuthor = name;
            comment.CommentAuthorEmail = email;
            comment.CommentAuthorUrl = webSite;

            bool spamCheck = akismetAPI.CommentCheck(comment);
            return spamCheck;
        }
示例#19
0
 /// <summary>Retracts false positive from Akismet database.</summary>
 /// <param name="comment">TypePadComment object to retract.</param>
 public void SubmitHam(AkismetComment comment)
 {
     string value = HttpPost(String.Format(submitHamUrl, apiKey), CreateData(comment), CharSet);
 }
示例#20
0
        private static AkismetComment GetComment(Comment zComment)
        {
            Joel.Net.AkismetComment comment = new Joel.Net.AkismetComment();
            comment.Blog = new Macros().FullUrl(new Urls().Home);
            comment.CommentAuthor = zComment.Name;
            comment.CommentAuthorUrl = zComment.WebSite;
            comment.CommentContent = zComment.Body;
            comment.CommentType = "comment";
            comment.UserAgent = HttpContext.Current.Request.UserAgent;
            comment.UserIp = zComment.IPAddress;

            return comment;
        }
示例#21
0
        /// <summary>Checks TypePadComment object against Akismet database.</summary>
        /// <param name="comment">TypePadComment object to check.</param>
        /// <returns>'True' if spam, 'False' if not spam.</returns>
        public bool CommentCheck(AkismetComment comment)
        {
            bool value = false;

            value = Convert.ToBoolean(HttpPost(String.Format(commentCheckUrl, apiKey), CreateData(comment), CharSet));
            return value;
        }
示例#22
0
        /// <summary>Retracts false positive from Akismet database.</summary>
        /// <param name="comment">AkismetComment object to retract.</param>
        public void SubmitHam(AkismetComment comment) {
            string value = HttpPost(String.Format(submitHamUrl, apiKey), CreateData(comment), CharSet);
#if DEBUG
            Console.WriteLine("SubmitHam() = {0}.", value);
#endif
        }
示例#23
0
 /// <summary>Submits TypePadComment object into Akismet database.</summary>
 /// <param name="comment">TypePadComment object to submit.</param>
 public void SubmitSpam(AkismetComment comment)
 {
     string value = HttpPost(String.Format(submitSpamUrl, apiKey), CreateData(comment), CharSet);
 }
示例#24
0
        /// <summary>Takes an AkismetComment object and returns an (escaped) string of data to POST.</summary>
        /// <param name="comment">AkismetComment object to translate.</param>
        /// <returns>A System.String containing the data to POST to Akismet API.</returns>
        private string CreateData(AkismetComment comment) {
            string value = String.Format("blog={0}&user_ip={1}&user_agent={2}&referrer={3}&permalink={4}&comment_type={5}" +
                "&comment_author={6}&comment_author_email={7}&comment_author_url={8}&comment_content={9}",
                HttpUtility.UrlEncode(comment.Blog),
                HttpUtility.UrlEncode(comment.UserIp),
                HttpUtility.UrlEncode(comment.UserAgent),
                HttpUtility.UrlEncode(comment.Referrer),
                HttpUtility.UrlEncode(comment.Permalink),
                HttpUtility.UrlEncode(comment.CommentType),
                HttpUtility.UrlEncode(comment.CommentAuthor),
                HttpUtility.UrlEncode(comment.CommentAuthorEmail),
                HttpUtility.UrlEncode(comment.CommentAuthorUrl),
                HttpUtility.UrlEncode(comment.CommentContent)
            );

            return value;
        }
 /// <summary>
 /// Submits TypePadComment object into Akismet database.
 /// </summary>
 /// <param name="comment">
 /// TypePadComment object to submit.
 /// </param>
 public void SubmitSpam(AkismetComment comment)
 {
     this.HttpPost(String.Format(this.submitSpamUrl, this.apiKey), CreateData(comment), this.CharSet);
 }
 /// <summary>
 /// Checks TypePadComment object against Akismet database.
 /// </summary>
 /// <param name="comment">
 /// TypePadComment object to check.
 /// </param>
 /// <returns>
 /// 'True' if spam, 'False' if not spam.
 /// </returns>
 public bool CommentCheck(AkismetComment comment)
 {
     var value =
         Convert.ToBoolean(
             this.HttpPost(String.Format(this.commentCheckUrl, this.apiKey), CreateData(comment), this.CharSet));
     return value;
 }
示例#27
0
 /// <summary>
 /// Submits TypePadComment object into Akismet database.
 /// </summary>
 /// <param name="comment">
 /// TypePadComment object to submit.
 /// </param>
 public void SubmitSpam(AkismetComment comment)
 {
     this.HttpPost(String.Format(this.submitSpamUrl, this.apiKey), CreateData(comment), this.CharSet);
 }
示例#28
0
        /// <summary>
        ///   Gets Comments out of XML files, which follow the BlogEngine.NET format.
        /// </summary>
        /// <param name = "folderSystemPath">Folder where XML files are located</param>
        public void ExportToWxr(string folderSystemPath)
        {
            Action<string> die = dieLog =>
                                     {
                                         Debug.WriteLine(dieLog);
                                         throw new Exception(dieLog);
                                     };

            if (String.IsNullOrEmpty(folderSystemPath))
                die("Null Path");

            var files = Directory.GetFiles(folderSystemPath);
            var xmlFiles = (from file in files
                           where file.EndsWith(".xml")
                           select file).ToList();

            if (!xmlFiles.Any())
                die("No XML Files found");

            wxr = new XmlDocument();
            wxr.AppendChild(wxr.CreateNode(XmlNodeType.XmlDeclaration, null, null));

            var rss = XElement("rss");
            foreach (var ns in namespaces)
                rss.SetAttribute("xmlns:" + ns.Key, ns.Value);

            wxr.AppendChild(rss);

            var root = XElement("channel");
            rss.AppendChild(root);


            foreach (var postFile in xmlFiles)
            {
                Log("Working on file : " + postFile);
                var postDoc = new XmlDocument();
                postDoc.Load(postFile);
                var title = Get(postDoc, "post/title");
                var slug = Get(postDoc, "post/slug");
                Log("Title : " + title);
                var item = XElement("item");
                root.AppendChild(item);

                item.AppendChild(XElement("title", title));
                item.AppendChild(XElement("link", Get(postDoc, "WHAT TO DO HERE?")));
                item.AppendChild(XElement("dsq:thread_identifier", slug));
                item.AppendChild(XElement("wp:post_date_gmt", Get(postDoc, "pubDate")));
                item.AppendChild(XElement("content:encoded", wxr.CreateCDataSection(Get(postDoc, "content"))));

                item.AppendChild(XElement("wp:post_id", slug));
                item.AppendChild(XElement("wp:comment_status", "open"));
                item.AppendChild(XElement("wp:ping_status", "open"));
                item.AppendChild(XElement("wp:post_type", "post"));

                foreach (XmlNode node in postDoc.SelectNodes("post/comments/comment"))
                {
                    var comment = new AkismetComment();
                    comment.Blog = "http://zasz.me/Blog";
                    comment.UserIp = Get(node, "ip");
                    comment.CommentContent = Get(node, "content");
                    comment.CommentAuthor = Get(node, "author");
                    comment.CommentAuthorEmail = Get(node, "email");
                    comment.CommentAuthorUrl = Get(node, "website");
                    comment.CommentType = "comment";
                    if (api.CommentCheck(comment))
                        continue;
                    var cmt = XElement("wp:comment");
                    cmt.AppendChild(XElement("wp:comment_id", (++commentCount).ToString()));
                    cmt.AppendChild(XElement("wp:comment_author", wxr.CreateCDataSection(comment.CommentAuthor)));
                    cmt.AppendChild(XElement("wp:comment_author_email", comment.CommentAuthorEmail));
                    cmt.AppendChild(XElement("wp:comment_author_url", comment.CommentAuthorUrl));
                    cmt.AppendChild(XElement("wp:comment_author_IP", comment.UserIp));
                    var date = DateTime.Parse(Get(node, "date")).ToString(dateFormat);
                    cmt.AppendChild(XElement("wp:comment_date", date));
                    cmt.AppendChild(XElement("wp:comment_date_gmt", date));
                    cmt.AppendChild(XElement("wp:comment_content", wxr.CreateCDataSection(comment.CommentContent)));
                    cmt.AppendChild(XElement("wp:comment_approved", "1"));
                    item.AppendChild(cmt);
                }
            }

            wxr.Save(folderSystemPath + @"\Comments\CommentsWXRAksimetFiltered.xml");
        }
示例#29
0
        public static AkismetComment ConstructAkismetComment(Member member, string commentType, string body)
        {
            var comment = new AkismetComment
            {
                Blog = "http://our.umbraco.org",
                UserIp = HttpContext.Current.Request.UserHostAddress,
                CommentAuthor = member.Text,
                CommentAuthorEmail = member.Email,
                CommentType = commentType,
                CommentContent = body,
                UserAgent = HttpContext.Current.Request.UserAgent
            };

            return comment;
        }
示例#30
0
        public static void MarkAsHam(int memberId, string body, string commentType)
        {
            var akismetApi = new Akismet(AkismetApiKey, "http://our.umbraco.org", "Test/1.0");
            if (akismetApi.VerifyKey() == false)
                throw new Exception("Akismet API key could not be verified");

            var member = new Member(memberId);

            var comment = new AkismetComment
                          {
                              Blog = "http://our.umbraco.org",
                              UserIp = member.getProperty("ip").Value.ToString(),
                              CommentAuthor = member.Text,
                              CommentAuthorEmail = member.Email,
                              CommentType = commentType,
                              CommentContent = body
                          };

            akismetApi.SubmitHam(comment);
        }
示例#31
0
        /// <summary>
        /// Gets the akismet comment.
        /// </summary>
        /// <param name="comment">The comment.</param>
        /// <returns>An Akismet Comment.</returns>
        private static AkismetComment GetAkismetComment(Comment comment)
        {
            var akismetComment = new AkismetComment
                {
                    Blog = Settings.GetSingleValue("SiteURL"),
                    UserIp = comment.IP,
                    CommentContent = comment.Content,
                    CommentAuthor = comment.Author,
                    CommentAuthorEmail = comment.Email
                };
            if (comment.Website != null)
            {
                akismetComment.CommentAuthorUrl = comment.Website.OriginalString;
            }

            return akismetComment;
        }
        /// <summary>
        /// Converts the comment to akismet comment.
        /// </summary>
        /// <param name="comment">The comment.</param>
        /// <returns></returns>
        private AkismetComment ConvertCommentToAkismetComment(CheckCommentForSpam comment)
        {
            AkismetComment akismet = new AkismetComment
                                         {
                                             Blog = "http://momntz.com",
                                             CommentAuthor = comment.Author,
                                             CommentAuthorEmail = comment.AuthorEmail,
                                             CommentAuthorUrl = comment.AuthorUrl,
                                             CommentContent = comment.Body,
                                             CommentType = "comment",
                                             UserAgent = comment.UserAgent,
                                             UserIp = comment.UserIP
                                         };

            return akismet;
        }