Exemple #1
0
        public void GenerateSuccessResponse(HttpRequest request, XmlWriter writer, TrackBackInfo tb)
        {
            SiteNav navData = null;

            using (ISiteNavHelper navHelper = SiteNavFactory.GetSiteNavHelper()) {
                navData = navHelper.FindByFilename(SiteData.CurrentSiteID, tb.BlogPostID);
            }
            string sReferer = null;
            string sIP      = request.ServerVariables["REMOTE_ADDR"].ToString();

            try { sReferer = request.ServerVariables["HTTP_REFERER"].ToString(); } catch { }

            PostComment pc = new PostComment();

            pc.ContentCommentID = Guid.NewGuid();
            pc.Root_ContentID   = navData.Root_ContentID;
            pc.CreateDate       = SiteData.CurrentSite.Now;
            pc.IsApproved       = false;
            pc.IsSpam           = false;
            pc.CommenterIP      = sIP;
            pc.CommenterEmail   = "trackback";

            pc.CommenterName   = tb.BlogName;
            pc.PostCommentText = tb.BlogExcerpt;

#if DEBUG
            pc.PostCommentText = request.UserAgent + "\r\n" + tb.RequestSourceURL + "\r\n" + tb.BlogExcerpt;
#endif

            pc.CommenterURL = tb.RequestSourceURL;
            if (!string.IsNullOrEmpty(sReferer))
            {
                pc.CommenterURL = sReferer;
            }

            pc.Save();

            writer.WriteStartElement("response");
            writer.WriteElementString("error", "0");
            writer.WriteStartElement("rss");
            writer.WriteAttributeString("version", "0.91");
            writer.WriteStartElement("channel");

            if (navData != null)
            {
                writer.WriteElementString("title", navData.NavMenuText);
                writer.WriteElementString("link", SiteData.CurrentSite.ConstructedCanonicalURL(navData));
                writer.WriteElementString("description", navData.PageTextPlainSummary);
            }

            writer.WriteElementString("language", "");

            writer.WriteEndElement();
            writer.WriteEndElement();
            writer.WriteEndElement();

            writer.Flush();
            writer.Close();
        }
        public void ProcessTrackback(HttpContext context, bool bRequireID)
        {
            HttpRequest request = context.Request;
            HttpResponse response = context.Response;

            response.Buffer = false;
            response.Clear();
            response.ContentType = "application/xml";

            XmlWriter writer = XmlWriter.Create(response.Output);

            if (request.Form.AllKeys.Count() < 6 && (!String.IsNullOrEmpty(request["id"]) || !bRequireID)
                && !String.IsNullOrEmpty(request["excerpt"])
                && !String.IsNullOrEmpty(request["blog_name"])) {
                string blogId = String.Empty;
                if (!String.IsNullOrEmpty(request["id"]))
                    blogId = request["id"];

                if (!bRequireID && String.IsNullOrEmpty(blogId)) {
                    blogId = request.Path;
                }

                string blogTitle = String.Empty;
                if (!String.IsNullOrEmpty(request["blog_name"]))
                    blogTitle = request["blog_name"];

                string url = String.Empty;
                if (!String.IsNullOrEmpty(request["url"]))
                    url = request["url"];

                string title = String.Empty;
                if (!String.IsNullOrEmpty(request["title"]))
                    title = request["title"];

                string excerpt = String.Empty;
                if (!String.IsNullOrEmpty(request["excerpt"]))
                    excerpt = request["excerpt"];

                TrackBackInfo tb = new TrackBackInfo {
                    RequestSourceURL = url,
                    BlogName = blogTitle,
                    BlogPostID = blogId,
                    BlogPostTitle = title,
                    BlogExcerpt = excerpt
                };

                if (request.HttpMethod == "POST") {
                    // Store trackback based on the id parameter
                    GenerateSuccessResponse(request, writer, tb);
                } else {
                    GenerateErrorResponse(2, "Only HTTP POST verb can be used to send trackbacks", writer);
                }
            } else {
                GenerateErrorResponse(1, "Item identifier is missing", writer);
            }
        }
Exemple #3
0
        public void ProcessTrackback(HttpContext context, bool bRequireID)
        {
            HttpRequest  request  = context.Request;
            HttpResponse response = context.Response;

            response.Buffer = false;
            response.Clear();
            response.ContentType = "application/xml";

            XmlWriter writer = XmlWriter.Create(response.Output);

            if (request.Form.AllKeys.Count() < 6 && (!string.IsNullOrEmpty(request["id"]) || !bRequireID) &&
                !string.IsNullOrEmpty(request["excerpt"]) &&
                !string.IsNullOrEmpty(request["blog_name"]))
            {
                string blogId = string.Empty;
                if (!string.IsNullOrEmpty(request["id"]))
                {
                    blogId = request["id"];
                }

                if (!bRequireID && string.IsNullOrEmpty(blogId))
                {
                    blogId = request.Path;
                }

                string blogTitle = string.Empty;
                if (!string.IsNullOrEmpty(request["blog_name"]))
                {
                    blogTitle = request["blog_name"];
                }

                string url = string.Empty;
                if (!string.IsNullOrEmpty(request["url"]))
                {
                    url = request["url"];
                }

                string title = string.Empty;
                if (!string.IsNullOrEmpty(request["title"]))
                {
                    title = request["title"];
                }

                string excerpt = string.Empty;
                if (!string.IsNullOrEmpty(request["excerpt"]))
                {
                    excerpt = request["excerpt"];
                }

                TrackBackInfo tb = new TrackBackInfo {
                    RequestSourceURL = url,
                    BlogName         = blogTitle,
                    BlogPostID       = blogId,
                    BlogPostTitle    = title,
                    BlogExcerpt      = excerpt
                };

                if (request.HttpMethod == "POST")
                {
                    // Store trackback based on the id parameter
                    GenerateSuccessResponse(request, writer, tb);
                }
                else
                {
                    GenerateErrorResponse(2, "Only HTTP POST verb can be used to send trackbacks", writer);
                }
            }
            else
            {
                GenerateErrorResponse(1, "Item identifier is missing", writer);
            }
        }
        public void GenerateSuccessResponse(HttpRequest request, XmlWriter writer, TrackBackInfo tb)
        {
            SiteNav navData = null;
            using (SiteNavHelper snh = new SiteNavHelper()) {
                navData = snh.FindByFilename(SiteData.CurrentSiteID, tb.BlogPostID);
            }
            string sReferer = null;
            string sIP = request.ServerVariables["REMOTE_ADDR"].ToString();
            try { sReferer = request.ServerVariables["HTTP_REFERER"].ToString(); } catch { }

            PostComment pc = new PostComment();
            pc.ContentCommentID = Guid.NewGuid();
            pc.Root_ContentID = navData.Root_ContentID;
            pc.CreateDate = SiteData.CurrentSite.Now;
            pc.IsApproved = false;
            pc.IsSpam = false;
            pc.CommenterIP = sIP;
            pc.CommenterEmail = "trackback";

            pc.CommenterName = tb.BlogName;
            pc.PostCommentText = tb.BlogExcerpt;

            #if DEBUG
            pc.PostCommentText = request.UserAgent + "\r\n" + tb.RequestSourceURL + "\r\n" + tb.BlogExcerpt;
            #endif

            pc.CommenterURL = tb.RequestSourceURL;
            if (!String.IsNullOrEmpty(sReferer)) {
                pc.CommenterURL = sReferer;
            }

            pc.Save();

            writer.WriteStartElement("response");
            writer.WriteElementString("error", "0");
            writer.WriteStartElement("rss");
            writer.WriteAttributeString("version", "0.91");
            writer.WriteStartElement("channel");

            if (navData != null) {
                writer.WriteElementString("title", navData.NavMenuText);
                writer.WriteElementString("link", SiteData.CurrentSite.ConstructedCanonicalURL(navData));
                writer.WriteElementString("description", navData.PageTextPlainSummary.ToString());
            }

            writer.WriteElementString("language", "");

            writer.WriteEndElement();
            writer.WriteEndElement();
            writer.WriteEndElement();

            writer.Flush();
            writer.Close();
        }