예제 #1
0
        public string SendTrackback(string sourceURL, Guid siteID, string sTgtURL)
        {
            this.DestinationUrl = new Uri(sTgtURL);
            this.BlogSite = SiteData.GetSiteFromCache(siteID);

            using (SiteNavHelper snh = new SiteNavHelper()) {
                this.SourcePage = snh.FindByFilename(siteID, sourceURL);
            }

            return SendTrackback();
        }
예제 #2
0
        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();
        }