public CommentExport() { CarrotCakeVersion = SiteData.CarrotCakeCMSVersion; ExportDate = DateTime.UtcNow; TheComment = new PostComment(); }
public void FetchItem() { guidItemID = GetGuidIDFromQuery(); item = PostComment.GetContentCommentByID(guidItemID); pageType = ContentPageType.PageType.Unknown; if (item != null) { guidRootContentID = item.Root_ContentID; } if (guidRootContentID != Guid.Empty) { ContentPage pageContents = pageHelper.FindContentByID(SiteID, guidRootContentID); pageType = pageContents.ContentType; } ReturnPageQueryString = ""; if (IsFullSite) { ReturnPageQueryString = string.Format("type={0}", pageType); } else { ReturnPageQueryString = string.Format("id={0}", guidRootContentID); } ReturnPageURL = string.Format("{0}?{1}", ReturnPage, ReturnPageQueryString); }
public PostCommentModel(PostComment comment, ViewType viewType) : this() { this.Comment = comment; this.ViewMode = viewType; this.Root_ContentID = this.Comment.Root_ContentID; }
protected void btnDelete_Click(object sender, EventArgs e) { item = PostComment.GetContentCommentByID(guidItemID); item.Delete(); Response.Redirect(ReturnPageURL); }
public static PostComment IdentifyLinkAsInactive(PostComment pc) { if (pc != null) { if (!pc.IsApproved) { pc.CommenterName = InactivePagePrefix + pc.CommenterName; } if (pc.IsSpam) { pc.CommenterName = RetiredPagePrefix + pc.CommenterName; } } return(pc); }
private void SetVals(PostComment pc) { CarrotCakeVersion = SiteData.CarrotCakeCMSVersion; ExportDate = DateTime.UtcNow; NewContentCommentID = Guid.NewGuid(); TheComment = pc; if (TheComment == null) { TheComment = new PostComment(); TheComment.Root_ContentID = Guid.NewGuid(); } OriginalRootContentID = TheComment.Root_ContentID; OriginalContentCommentID = TheComment.ContentCommentID; TheComment.ContentCommentID = NewContentCommentID; }
public override bool Equals(Object obj) { //Check for null and compare run-time types. if (obj == null || GetType() != obj.GetType()) { return(false); } if (obj is PostComment) { PostComment p = (PostComment)obj; return((this.ContentCommentID == p.ContentCommentID) && (this.Root_ContentID == p.Root_ContentID)); } else { return(false); } }
protected void btnSave_Click(object sender, EventArgs e) { item = PostComment.GetContentCommentByID(guidItemID); if (item == null) { item = new PostComment(); item.ContentCommentID = Guid.NewGuid(); } guidRootContentID = item.Root_ContentID; item.CommenterEmail = txtEmail.Text; item.CommenterName = txtName.Text; item.PostCommentText = txtComment.Text; item.CommenterURL = txtURL.Text; item.IsApproved = chkApproved.Checked; item.IsSpam = chkSpam.Checked; item.Save(); Response.Redirect(SiteData.CurrentScriptName + "?id=" + item.ContentCommentID.ToString()); }
public CommentExport(PostComment pc) { SetVals(pc); }
public static List <CommentExport> GetPageCommentExport(Guid rootContentID) { List <CommentExport> lst = PostComment.GetCommentsByContentPage(rootContentID, false).Select(x => new CommentExport(x)).ToList(); return(lst); }
private void ImportStuff() { SiteData.CurrentSite = null; SiteData site = SiteData.CurrentSite; litMessage.Text = "<p>No Items Selected For Import</p>"; string sMsg = ""; if (chkSite.Checked || chkPages.Checked || chkPosts.Checked) { List<string> tags = site.GetTagList().Select(x => x.TagSlug.ToLower()).ToList(); List<string> cats = site.GetCategoryList().Select(x => x.CategorySlug.ToLower()).ToList(); wpSite.Tags.RemoveAll(x => tags.Contains(x.InfoKey.ToLower())); wpSite.Categories.RemoveAll(x => cats.Contains(x.InfoKey.ToLower())); sMsg += "<p>Imported Tags and Categories</p>"; List<ContentTag> lstTag = (from l in wpSite.Tags.Distinct() select new ContentTag { ContentTagID = Guid.NewGuid(), IsPublic = true, SiteID = site.SiteID, TagSlug = l.InfoKey, TagText = l.InfoLabel }).Distinct().ToList(); List<ContentCategory> lstCat = (from l in wpSite.Categories.Distinct() select new ContentCategory { ContentCategoryID = Guid.NewGuid(), IsPublic = true, SiteID = site.SiteID, CategorySlug = l.InfoKey, CategoryText = l.InfoLabel }).Distinct().ToList(); foreach (var v in lstTag) { v.Save(); } foreach (var v in lstCat) { v.Save(); } } SetMsg(sMsg); if (chkSite.Checked) { sMsg += "<p>Updated Site Name</p>"; site.SiteName = wpSite.SiteTitle; site.SiteTagline = wpSite.SiteDescription; site.Save(); } SetMsg(sMsg); if (!chkMapAuthor.Checked) { wpSite.Authors = new List<WordPressUser>(); } //itterate author collection and find if in the system foreach (WordPressUser wpu in wpSite.Authors) { wpu.ImportUserID = Guid.Empty; MembershipUser usr = null; //attempt to find the user in the userbase usr = SecurityData.GetUserListByEmail(wpu.Email).FirstOrDefault(); if (usr != null) { wpu.ImportUserID = new Guid(usr.ProviderUserKey.ToString()); } else { usr = SecurityData.GetUserListByName(wpu.Login).FirstOrDefault(); if (usr != null) { wpu.ImportUserID = new Guid(usr.ProviderUserKey.ToString()); } } if (chkAuthors.Checked) { if (wpu.ImportUserID == Guid.Empty) { usr = Membership.CreateUser(wpu.Login, ProfileManager.GenerateSimplePassword(), wpu.Email); Roles.AddUserToRole(wpu.Login, SecurityData.CMSGroup_Users); wpu.ImportUserID = new Guid(usr.ProviderUserKey.ToString()); } if (wpu.ImportUserID != Guid.Empty) { ExtendedUserData ud = new ExtendedUserData(wpu.ImportUserID); if (!string.IsNullOrEmpty(wpu.FirstName) || !string.IsNullOrEmpty(wpu.LastName)) { ud.FirstName = wpu.FirstName; ud.LastName = wpu.LastName; ud.Save(); } } } } wpSite.Comments.ForEach(r => r.ImportRootID = Guid.Empty); using (SiteNavHelper navHelper = new SiteNavHelper()) { if (chkPages.Checked) { sMsg += "<p>Imported Pages</p>"; int iOrder = 0; SiteNav navHome = navHelper.FindHome(site.SiteID, false); if (navHome != null) { iOrder = 2; } foreach (var wpp in (from c in wpSite.Content where c.PostType == WordPressPost.WPPostType.Page orderby c.PostOrder, c.PostTitle select c).ToList()) { GrabAttachments(wpp); RepairBody(wpp); ContentPage cp = ContentImportExportUtils.CreateWPContentPage(wpSite, wpp, site); cp.SiteID = site.SiteID; cp.ContentType = ContentPageType.PageType.ContentEntry; cp.EditDate = SiteData.CurrentSite.Now; cp.NavOrder = iOrder; cp.TemplateFile = ddlTemplatePage.SelectedValue; WordPressPost parent = (from c in wpSite.Content where c.PostType == WordPressPost.WPPostType.Page && c.PostID == wpp.ParentPostID select c).FirstOrDefault(); SiteNav navParent = null; SiteNav navData = navHelper.GetLatestVersion(site.SiteID, false, cp.FileName.ToLower()); if (parent != null) { navParent = navHelper.GetLatestVersion(site.SiteID, false, parent.ImportFileName.ToLower()); } //if URL exists already, make this become a new version in the current series if (navData != null) { cp.Root_ContentID = navData.Root_ContentID; if (navData.NavOrder == 0) { cp.NavOrder = 0; } } if (navParent != null) { cp.Parent_ContentID = navParent.Root_ContentID; } else { if (parent != null) { cp.Parent_ContentID = parent.ImportRootID; } } //preserve homepage if (navHome != null && navHome.FileName.ToLower() == cp.FileName.ToLower()) { cp.NavOrder = 0; } cp.RetireDate = CalcNearestFiveMinTime(cp.CreateDate).AddYears(200); cp.GoLiveDate = CalcNearestFiveMinTime(cp.CreateDate).AddMinutes(-5); //if URL exists already, make this become a new version in the current series if (navData != null) { cp.Root_ContentID = navData.Root_ContentID; cp.RetireDate = navData.RetireDate; cp.GoLiveDate = navData.GoLiveDate; } cp.SavePageEdit(); wpSite.Comments.Where(x => x.PostID == wpp.PostID).ToList().ForEach(r => r.ImportRootID = cp.Root_ContentID); iOrder++; } } if (chkPosts.Checked) { sMsg += "<p>Imported Posts</p>"; foreach (var wpp in (from c in wpSite.Content where c.PostType == WordPressPost.WPPostType.BlogPost orderby c.PostOrder select c).ToList()) { GrabAttachments(wpp); RepairBody(wpp); ContentPage cp = ContentImportExportUtils.CreateWPContentPage(wpSite, wpp, site); cp.SiteID = site.SiteID; cp.Parent_ContentID = null; cp.ContentType = ContentPageType.PageType.BlogEntry; cp.EditDate = SiteData.CurrentSite.Now; cp.NavOrder = SiteData.BlogSortOrderNumber; cp.TemplateFile = ddlTemplatePost.SelectedValue; SiteNav navData = navHelper.GetLatestVersion(site.SiteID, false, cp.FileName.ToLower()); cp.RetireDate = CalcNearestFiveMinTime(cp.CreateDate).AddYears(200); cp.GoLiveDate = CalcNearestFiveMinTime(cp.CreateDate).AddMinutes(-5); //if URL exists already, make this become a new version in the current series if (navData != null) { cp.Root_ContentID = navData.Root_ContentID; cp.RetireDate = navData.RetireDate; cp.GoLiveDate = navData.GoLiveDate; } cp.SavePageEdit(); wpSite.Comments.Where(x => x.PostID == wpp.PostID).ToList().ForEach(r => r.ImportRootID = cp.Root_ContentID); } using (ContentPageHelper cph = new ContentPageHelper()) { //cph.BulkBlogFileNameUpdateFromDate(site.SiteID); cph.ResolveDuplicateBlogURLs(site.SiteID); cph.FixBlogNavOrder(site.SiteID); } } } SetMsg(sMsg); wpSite.Comments.RemoveAll(r => r.ImportRootID == Guid.Empty); if (wpSite.Comments.Any()) { sMsg += "<p>Imported Comments</p>"; } foreach (WordPressComment wpc in wpSite.Comments) { int iCommentCount = -1; iCommentCount = PostComment.GetCommentCountByContent(site.SiteID, wpc.ImportRootID, wpc.CommentDateUTC, wpc.AuthorIP, wpc.CommentContent); if (iCommentCount < 1) { iCommentCount = PostComment.GetCommentCountByContent(site.SiteID, wpc.ImportRootID, wpc.CommentDateUTC, wpc.AuthorIP); } if (iCommentCount < 1) { PostComment pc = new PostComment(); pc.ContentCommentID = Guid.NewGuid(); pc.Root_ContentID = wpc.ImportRootID; pc.CreateDate = site.ConvertUTCToSiteTime(wpc.CommentDateUTC); pc.IsApproved = false; pc.IsSpam = false; pc.CommenterIP = wpc.AuthorIP; pc.CommenterName = wpc.Author; pc.CommenterEmail = wpc.AuthorEmail; pc.PostCommentText = wpc.CommentContent; pc.CommenterURL = wpc.AuthorURL; if (wpc.Approved == "1") { pc.IsApproved = true; } if (wpc.Approved.ToLower() == "trash") { pc.IsSpam = true; } if (wpc.Type.ToLower() == "trackback" || wpc.Type.ToLower() == "pingback") { pc.CommenterEmail = wpc.Type; } pc.Save(); } } SetMsg(sMsg); BindData(); }
public PartialViewResult Contact(ContactInfo model) { model.ReconstructSettings(); this.ViewData[ContactInfo.Key] = model; model.IsSaved = false; LoadPage(model.Settings.Uri); var settings = model.Settings; if (settings.UseValidateHuman) { bool IsValidated = model.ValidateHuman.ValidateValue(model.ValidationValue); if (!IsValidated) { ModelState.AddModelError("ValidationValue", model.ValidateHuman.AltValidationFailText); model.ValidationValue = String.Empty; } } //TODO: log the comment and B64 encode some of the settings (TBD) if (ModelState.IsValid) { string sIP = Request.ServerVariables["REMOTE_ADDR"].ToString(); PostComment pc = new PostComment(); pc.ContentCommentID = Guid.NewGuid(); pc.Root_ContentID = _page.ThePage.Root_ContentID; pc.CreateDate = SiteData.CurrentSite.Now; pc.IsApproved = false; pc.IsSpam = false; pc.CommenterIP = sIP; pc.CommenterName = Server.HtmlEncode(model.CommenterName); pc.CommenterEmail = Server.HtmlEncode(model.CommenterEmail ?? String.Empty); pc.PostCommentText = Server.HtmlEncode(model.PostCommentText); //.Replace("<", "<").Replace(">", ">"); pc.CommenterURL = Server.HtmlEncode(model.CommenterURL ?? String.Empty); pc.Save(); model.IsSaved = true; model.CommenterName = String.Empty; model.CommenterEmail = String.Empty; model.PostCommentText = String.Empty; model.CommenterURL = String.Empty; model.ValidationValue = String.Empty; this.ViewData[ContactInfo.Key] = model; model.SendMail(pc, _page.ThePage); ModelState.Clear(); } return PartialView(settings.PostPartialName); }
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(); }
public void SendMail(PostComment pc, ContentPage page) { HttpRequest request = HttpContext.Current.Request; if (this.Settings.NotifyEditors || !String.IsNullOrEmpty(this.Settings.DirectEmailKeyName)) { List<string> emails = new List<string>(); if (this.Settings.NotifyEditors && page != null) { emails.Add(page.CreateUser.Email); if (page.EditUser.UserId != page.CreateUser.UserId) { emails.Add(page.EditUser.Email); } if (page.CreditUserId.HasValue) { emails.Add(page.CreditUser.Email); } } if (!String.IsNullOrEmpty(this.Settings.DirectEmailKeyName)) { emails.Add(ConfigurationManager.AppSettings[this.Settings.DirectEmailKeyName].ToString()); } string strHTTPHost = String.Empty; try { strHTTPHost = request.ServerVariables["HTTP_HOST"].ToString().Trim(); } catch { strHTTPHost = String.Empty; } string hostName = strHTTPHost.ToLowerInvariant(); string strHTTPPrefix = "http://"; try { strHTTPPrefix = request.ServerVariables["SERVER_PORT_SECURE"] == "1" ? "https://" : "http://"; } catch { strHTTPPrefix = "http://"; } strHTTPHost = String.Format("{0}{1}", strHTTPPrefix, strHTTPHost).ToLowerInvariant(); string mailSubject = String.Format("Comment Form From {0}", hostName); string sBody = "Name: " + pc.CommenterName + "\r\nEmail: " + pc.CommenterEmail + "\r\nURL: " + pc.CommenterURL + "\r\n-----------------" + "\r\nComment:\r\n" + HttpUtility.HtmlEncode(pc.PostCommentText) + "\r\n=================\r\n" + "\r\nIP: " + pc.CommenterIP + "\r\nSite URL: " + String.Format("{0}{1}", strHTTPHost, page.FileName) + "\r\nSite Time: " + SiteData.CurrentSite.Now.ToString() + "\r\nUTC Time: " + DateTime.UtcNow.ToString(); string sEmail = String.Join(";", emails); EmailHelper.SendMail(null, sEmail, mailSubject, sBody, false); } }
public void ImportStuff() { this.HasLoaded = false; this.Site = ContentImportExportUtils.GetSerializedWPExport(this.ImportID); SiteData.CurrentSite = null; SiteData site = SiteData.CurrentSite; this.Message = String.Empty; string sMsg = String.Empty; if (this.ImportSite || this.ImportPages || this.ImportPosts) { List<string> tags = site.GetTagList().Select(x => x.TagSlug.ToLowerInvariant()).ToList(); List<string> cats = site.GetCategoryList().Select(x => x.CategorySlug.ToLowerInvariant()).ToList(); this.Site.Tags.RemoveAll(x => tags.Contains(x.InfoKey.ToLowerInvariant())); this.Site.Categories.RemoveAll(x => cats.Contains(x.InfoKey.ToLowerInvariant())); sMsg += "<li>Imported Tags and Categories</li>"; List<ContentTag> lstTag = (from l in this.Site.Tags.Distinct() select new ContentTag { ContentTagID = Guid.NewGuid(), IsPublic = true, SiteID = site.SiteID, TagSlug = l.InfoKey, TagText = l.InfoLabel }).Distinct().ToList(); List<ContentCategory> lstCat = (from l in this.Site.Categories.Distinct() select new ContentCategory { ContentCategoryID = Guid.NewGuid(), IsPublic = true, SiteID = site.SiteID, CategorySlug = l.InfoKey, CategoryText = l.InfoLabel }).Distinct().ToList(); foreach (var v in lstTag) { v.Save(); } foreach (var v in lstCat) { v.Save(); } } SetMsg(sMsg); if (this.ImportSite) { sMsg += "<li>Updated Site Name</li>"; site.SiteName = this.Site.SiteTitle; site.SiteTagline = this.Site.SiteDescription; site.Save(); } SetMsg(sMsg); if (!this.MapUsers) { this.Site.Authors = new List<WordPressUser>(); } //iterate author collection and find if in the system foreach (WordPressUser wpu in this.Site.Authors) { SecurityData sd = new SecurityData(); ExtendedUserData usr = null; wpu.ImportUserID = Guid.Empty; //attempt to find the user in the userbase usr = ExtendedUserData.FindByEmail(wpu.Email); if (usr != null && usr.UserId != Guid.Empty) { wpu.ImportUserID = usr.UserId; } else { usr = ExtendedUserData.FindByUsername(wpu.Login); if (usr != null && usr.UserId != Guid.Empty) { wpu.ImportUserID = usr.UserId; } } if (this.CreateUsers) { if (wpu.ImportUserID == Guid.Empty) { ApplicationUser user = new ApplicationUser { UserName = wpu.Login, Email = wpu.Email }; var result = sd.CreateApplicationUser(user, out usr); if (result.Succeeded) { usr = ExtendedUserData.FindByUsername(wpu.Login); } else { throw new Exception(String.Format("Could not create user: {0} ({1}) \r\n{2}", wpu.Login, wpu.Email, String.Join("\r\n", result.Errors))); } wpu.ImportUserID = usr.UserId; } if (wpu.ImportUserID != Guid.Empty) { ExtendedUserData ud = new ExtendedUserData(wpu.ImportUserID); if (!String.IsNullOrEmpty(wpu.FirstName) || !String.IsNullOrEmpty(wpu.LastName)) { ud.FirstName = wpu.FirstName; ud.LastName = wpu.LastName; ud.Save(); } } } } this.Site.Comments.ForEach(r => r.ImportRootID = Guid.Empty); using (ISiteNavHelper navHelper = SiteNavFactory.GetSiteNavHelper()) { if (this.ImportPages) { sMsg += "<li>Imported Pages</li>"; int iOrder = 0; SiteNav navHome = navHelper.FindHome(site.SiteID, false); if (navHome != null) { iOrder = 2; } foreach (var wpp in (from c in this.Site.Content where c.PostType == WordPressPost.WPPostType.Page orderby c.PostOrder, c.PostTitle select c).ToList()) { GrabAttachments(wpp); RepairBody(wpp); ContentPage cp = ContentImportExportUtils.CreateWPContentPage(this.Site, wpp, site); cp.SiteID = site.SiteID; cp.ContentType = ContentPageType.PageType.ContentEntry; cp.EditDate = SiteData.CurrentSite.Now; cp.NavOrder = iOrder; cp.TemplateFile = this.PageTemplate; WordPressPost parent = (from c in this.Site.Content where c.PostType == WordPressPost.WPPostType.Page && c.PostID == wpp.ParentPostID select c).FirstOrDefault(); SiteNav navParent = null; SiteNav navData = navHelper.GetLatestVersion(site.SiteID, false, cp.FileName.ToLowerInvariant()); if (parent != null) { navParent = navHelper.GetLatestVersion(site.SiteID, false, parent.ImportFileName.ToLowerInvariant()); } //if URL exists already, make this become a new version in the current series if (navData != null) { cp.Root_ContentID = navData.Root_ContentID; if (navData.NavOrder == 0) { cp.NavOrder = 0; } } if (navParent != null) { cp.Parent_ContentID = navParent.Root_ContentID; } else { if (parent != null) { cp.Parent_ContentID = parent.ImportRootID; } } //preserve homepage if (navHome != null && navHome.FileName.ToLowerInvariant() == cp.FileName.ToLowerInvariant()) { cp.NavOrder = 0; } cp.RetireDate = CMSConfigHelper.CalcNearestFiveMinTime(cp.CreateDate).AddYears(200); cp.GoLiveDate = CMSConfigHelper.CalcNearestFiveMinTime(cp.CreateDate).AddMinutes(-5); //if URL exists already, make this become a new version in the current series if (navData != null) { cp.Root_ContentID = navData.Root_ContentID; cp.RetireDate = navData.RetireDate; cp.GoLiveDate = navData.GoLiveDate; } cp.SavePageEdit(); this.Site.Comments.Where(x => x.PostID == wpp.PostID).ToList().ForEach(r => r.ImportRootID = cp.Root_ContentID); iOrder++; } } if (this.ImportPosts) { sMsg += "<li>Imported Posts</li>"; foreach (var wpp in (from c in this.Site.Content where c.PostType == WordPressPost.WPPostType.BlogPost orderby c.PostOrder select c).ToList()) { GrabAttachments(wpp); RepairBody(wpp); ContentPage cp = ContentImportExportUtils.CreateWPContentPage(this.Site, wpp, site); cp.SiteID = site.SiteID; cp.Parent_ContentID = null; cp.ContentType = ContentPageType.PageType.BlogEntry; cp.EditDate = SiteData.CurrentSite.Now; cp.NavOrder = SiteData.BlogSortOrderNumber; cp.TemplateFile = this.PostTemplate; SiteNav navData = navHelper.GetLatestVersion(site.SiteID, false, cp.FileName.ToLowerInvariant()); cp.RetireDate = CMSConfigHelper.CalcNearestFiveMinTime(cp.CreateDate).AddYears(200); cp.GoLiveDate = CMSConfigHelper.CalcNearestFiveMinTime(cp.CreateDate).AddMinutes(-5); //if URL exists already, make this become a new version in the current series if (navData != null) { cp.Root_ContentID = navData.Root_ContentID; cp.RetireDate = navData.RetireDate; cp.GoLiveDate = navData.GoLiveDate; } cp.SavePageEdit(); this.Site.Comments.Where(x => x.PostID == wpp.PostID).ToList().ForEach(r => r.ImportRootID = cp.Root_ContentID); } using (ContentPageHelper cph = new ContentPageHelper()) { //cph.BulkBlogFileNameUpdateFromDate(site.SiteID); cph.ResolveDuplicateBlogURLs(site.SiteID); cph.FixBlogNavOrder(site.SiteID); } } } SetMsg(sMsg); this.Site.Comments.RemoveAll(r => r.ImportRootID == Guid.Empty); if (this.Site.Comments.Any()) { sMsg += "<li>Imported Comments</li>"; } foreach (WordPressComment wpc in this.Site.Comments) { int iCommentCount = -1; iCommentCount = PostComment.GetCommentCountByContent(site.SiteID, wpc.ImportRootID, wpc.CommentDateUTC, wpc.AuthorIP, wpc.CommentContent); if (iCommentCount < 1) { iCommentCount = PostComment.GetCommentCountByContent(site.SiteID, wpc.ImportRootID, wpc.CommentDateUTC, wpc.AuthorIP); } if (iCommentCount < 1) { PostComment pc = new PostComment(); pc.ContentCommentID = Guid.NewGuid(); pc.Root_ContentID = wpc.ImportRootID; pc.CreateDate = site.ConvertUTCToSiteTime(wpc.CommentDateUTC); pc.IsApproved = false; pc.IsSpam = false; pc.CommenterIP = wpc.AuthorIP; pc.CommenterName = wpc.Author; pc.CommenterEmail = wpc.AuthorEmail; pc.PostCommentText = wpc.CommentContent; pc.CommenterURL = wpc.AuthorURL; if (wpc.Approved == "1") { pc.IsApproved = true; } if (wpc.Approved.ToLowerInvariant() == "trash") { pc.IsSpam = true; } if (wpc.Type.ToLowerInvariant() == "trackback" || wpc.Type.ToLowerInvariant() == "pingback") { pc.CommenterEmail = wpc.Type; } pc.Save(); } } SetMsg(sMsg); }
public static PostComment IdentifyLinkAsInactive(PostComment pc) { if (pc != null) { if (!pc.IsApproved) { pc.CommenterName = InactivePagePrefix + pc.CommenterName; } if (pc.IsSpam) { pc.CommenterName = RetiredPagePrefix + pc.CommenterName; } } return pc; }
protected void Submit_ContentCommentForm(object sender, EventArgs e) { bool bCaptcha = false; Captcha captcha = (Captcha)GetEntryFormControl("ContentCommentCaptcha"); if (captcha != null) { bCaptcha = captcha.Validate(); } else { bCaptcha = true; } if (bCaptcha) { HttpRequest request = HttpContext.Current.Request; bool bIgnorePublishState = SecurityData.AdvancedEditMode || SecurityData.IsAdmin || SecurityData.IsSiteEditor; SiteNav navData = navHelper.GetLatestVersion(SiteData.CurrentSiteID, !bIgnorePublishState, SiteData.CurrentScriptName); Label lblContentCommentFormMsg = (Label)GetEntryFormControl("ContentCommentFormMsg"); TextBox txtCommenterName = (TextBox)GetEntryFormControl("CommenterName"); TextBox txtCommenterEmail = (TextBox)GetEntryFormControl("CommenterEmail"); TextBox txtVisitorComments = (TextBox)GetEntryFormControl("VisitorComments"); TextBox txtCommenterURL = (TextBox)GetEntryFormControl("CommenterURL"); string sIP = request.ServerVariables["REMOTE_ADDR"].ToString(); 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; if (txtCommenterName != null) { pc.CommenterName = txtCommenterName.Text; } if (txtCommenterEmail != null) { pc.CommenterEmail = txtCommenterEmail.Text; } if (txtVisitorComments != null) { pc.PostCommentText = txtVisitorComments.Text; } if (txtCommenterURL != null) { pc.CommenterURL = txtCommenterURL.Text; } if (SiteData.IsWebView && HttpContext.Current.User.Identity.IsAuthenticated) { if ((this.AutoApproveAdmin)) { pc.IsApproved = SecurityData.IsAdmin; } if (!string.IsNullOrEmpty(this.AutoApproveGroupName)) { pc.IsApproved = SecurityData.IsUserInRole(this.AutoApproveGroupName); } } pc.Save(); if (!string.IsNullOrEmpty(this.DirectEmail) || !string.IsNullOrEmpty(this.DirectEmailKeyName)) { string sEmail = ""; EmailSender mailer = new EmailSender(); if (!string.IsNullOrEmpty(this.DirectEmail)) { sEmail = this.DirectEmail.ToString(); } if (!string.IsNullOrEmpty(this.DirectEmailKeyName)) { sEmail = ConfigurationManager.AppSettings[this.DirectEmailKeyName].ToString(); } mailer.MailSubject = "Comment Form " + request.ServerVariables["SERVER_NAME"]; mailer.Recepient = sEmail; mailer.TemplateFile = null; mailer.IsHTML = false; mailer.WebControl = this; string sBody = "Name: " + pc.CommenterName + "\r\nEmail: " + pc.CommenterEmail + "\r\nURL: " + pc.CommenterURL + "\r\n-----------------\r\nComment:\r\n" + pc.PostCommentText + "\r\n=================\r\n\r\nIP: " + pc.CommenterIP + "\r\nSite Page: " + request.ServerVariables["script_name"].ToString() + "\r\nSite Time: " + pc.CreateDate.ToString() + "\r\nUTC Time: " + DateTime.UtcNow.ToString(); mailer.Body = sBody; mailer.SendMail(); } //if (lbl != null && txt1 != null && txt2 != null) { // lbl.Text = "Clicked the button: " + txt1.Text + " - " + txt2.Text; //} phEntry.Visible = false; phThanks.Visible = true; } }
protected void Submit_ContentCommentForm(object sender, EventArgs e) { bool bCaptcha = false; Captcha captcha = (Captcha)GetEntryFormControl("ContentCommentCaptcha"); if (captcha != null) { bCaptcha = captcha.Validate(); } else { bCaptcha = true; } if (bCaptcha) { HttpRequest request = HttpContext.Current.Request; bool bIgnorePublishState = SecurityData.AdvancedEditMode || SecurityData.IsAdmin || SecurityData.IsSiteEditor; SiteNav navData = navHelper.GetLatestVersion(SiteData.CurrentSiteID, !bIgnorePublishState, SiteData.CurrentScriptName); Label lblContentCommentFormMsg = (Label)GetEntryFormControl("ContentCommentFormMsg"); TextBox txtCommenterName = (TextBox)GetEntryFormControl("CommenterName"); TextBox txtCommenterEmail = (TextBox)GetEntryFormControl("CommenterEmail"); TextBox txtVisitorComments = (TextBox)GetEntryFormControl("VisitorComments"); TextBox txtCommenterURL = (TextBox)GetEntryFormControl("CommenterURL"); string sIP = request.ServerVariables["REMOTE_ADDR"].ToString(); 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; if (txtCommenterName != null) { pc.CommenterName = txtCommenterName.Text; } if (txtCommenterEmail != null) { pc.CommenterEmail = txtCommenterEmail.Text; } if (txtVisitorComments != null) { pc.PostCommentText = txtVisitorComments.Text; } if (txtCommenterURL != null) { pc.CommenterURL = txtCommenterURL.Text; } if (SiteData.IsWebView && HttpContext.Current.User.Identity.IsAuthenticated) { if ((this.AutoApproveAdmin)) { pc.IsApproved = SecurityData.IsAdmin; } if (!String.IsNullOrEmpty(this.AutoApproveGroupName)) { pc.IsApproved = SecurityData.IsUserInRole(this.AutoApproveGroupName); } } pc.Save(); if (!String.IsNullOrEmpty(this.DirectEmail) || this.NotifyEditors || !String.IsNullOrEmpty(this.DirectEmailKeyName)) { List<string> emails = new List<string>(); EmailSender mailer = new EmailSender(); if (!String.IsNullOrEmpty(this.DirectEmail)) { emails.Add(this.DirectEmail); } if (!String.IsNullOrEmpty(this.DirectEmailKeyName)) { emails.Add(ConfigurationManager.AppSettings[this.DirectEmailKeyName].ToString()); } if (this.NotifyEditors) { ContentPage page = navData.GetContentPage(); emails.Add(page.CreateUser.EmailAddress); if (page.EditUser.UserId != page.CreateUser.UserId) { emails.Add(page.EditUser.EmailAddress); } if (page.CreditUserId.HasValue) { emails.Add(page.CreditUser.EmailAddress); } } string sEmail = String.Join(",", emails.ToArray()); mailer.MailSubject = "Comment Form " + request.ServerVariables["HTTP_HOST"]; mailer.Recepient = sEmail; mailer.TemplateFile = null; mailer.IsHTML = false; mailer.WebControl = this; string strHTTPHost = String.Empty; try { strHTTPHost = request.ServerVariables["HTTP_HOST"] + String.Empty; } catch { strHTTPHost = String.Empty; } string strHTTPProto = "http://"; try { strHTTPProto = request.ServerVariables["SERVER_PORT_SECURE"] + String.Empty; if (strHTTPProto == "1") { strHTTPProto = "https://"; } else { strHTTPProto = "http://"; } } catch { } strHTTPHost = String.Format("{0}{1}", strHTTPProto, strHTTPHost).ToLower(); string sBody = "Name: " + pc.CommenterName + "\r\nEmail: " + pc.CommenterEmail + "\r\nURL: " + pc.CommenterURL + "\r\n-----------------\r\nComment:\r\n" + HttpUtility.HtmlEncode(pc.PostCommentText) + "\r\n=================\r\n\r\nIP: " + pc.CommenterIP //+ "\r\nSite Page: " + request.ServerVariables["script_name"].ToString() + "\r\nSite URL: " + String.Format("{0}{1}", strHTTPHost, request.ServerVariables["script_name"]) + "\r\nSite Time: " + SiteData.CurrentSite.Now.ToString() + "\r\nUTC Time: " + DateTime.UtcNow.ToString(); mailer.Body = sBody; mailer.SendMail(); } //if (lbl != null && txt1 != null && txt2 != null) { // lbl.Text = "Clicked the button: " + txt1.Text + " - " + txt2.Text; //} phEntry.Visible = false; phThanks.Visible = true; } }