/// <summary> /// Process trackback parameters. /// </summary> private void ProcessParameters() { TreeProvider tree = new TreeProvider(MembershipContext.AuthenticatedUser); TreeNode node = tree.SelectSingleNode(postGuid, culture, SiteContext.CurrentSiteName); // Check that requested blog post exists if (node != null) { node = TreeHelper.SelectSingleDocument(node.DocumentID); // Check if comment from given URL is not already inserted int existingComment = BlogCommentInfoProvider.GetBlogComments() .Column("CommentID") .WhereEquals("CommentPostDocumentID", node.DocumentID) .WhereTrue("CommentIsTrackback") .WhereEquals("CommentUrl", url) .Count; if (existingComment == 0) { // Check if blog for blog post exists TreeNode blogNode = BlogHelper.GetParentBlog(node.DocumentID, false); if (blogNode != null) { // Check if comments are opened int days = ValidationHelper.GetInteger(blogNode.GetValue("BlogOpenCommentsFor"), 0); // Check if comments are always opened bool opened = (days == BlogProperties.OPEN_COMMENTS_ALWAYS); // Check if comments are opened in present time if ((ValidationHelper.GetDateTime(node.GetValue("BlogPostDate"), DateTime.Today).AddDays(days)) >= DateTime.Today) { opened = true; } // Check if comments are disabled if (days == BlogProperties.OPEN_COMMENTS_DISABLE) { opened = false; } // Check if trackback comments are enabled, anonymous comments are enabled, comments are enabled in present time and blog post allow comments if (ValidationHelper.GetBoolean(blogNode.GetValue("BlogEnableTrackbacks"), false) && (ValidationHelper.GetBoolean(blogNode.GetValue("BlogAllowAnonymousComments"), false)) && (opened) && (ValidationHelper.GetBoolean(node.GetValue("BlogPostAllowComments"), false))) { // Create new comment BlogCommentInfo comment = new BlogCommentInfo(); comment.CommentUrl = url.Length > 450 ? url.Substring(0, 450) : url; comment.CommentText = excerpt; comment.CommentDate = DateTime.Now; comment.CommentUserName = GetCommentUserName(blogName, title); comment.CommentUserID = 0; comment.CommentApprovedByUserID = 0; comment.CommentPostDocumentID = node.DocumentID; comment.CommentIsTrackback = true; comment.CommentIsSpam = false; // User IP address comment.CommentInfo.IPAddress = RequestContext.UserHostAddress; // User agent comment.CommentInfo.Agent = Request.UserAgent; // Check if comments are moderated comment.CommentApproved = !ValidationHelper.GetBoolean(blogNode.GetValue("BlogModerateComments"), false); // Save changes to database BlogCommentInfoProvider.SetBlogCommentInfo(comment); // Send OK response, no error message SendResponse(null); } else { SendResponse("Blog doesn't enable trackbacks."); } } else { SendResponse("Blog not found."); } } else { SendResponse("Blog post with given URL is already referenced."); } } else { SendResponse("Blog post not found."); } }