private void OnSendButtonClick(object sender, EventArgs e) { if (Page.IsValid) { var contactMessage = new FeedbackItem(FeedbackType.ContactPage) { Author = tbName.Text, Email = tbEmail.Text, Body = tbMessage.Text, Title = string.Format("CONTACT: {0}", tbSubject.Text), IpAddress = HttpHelper.GetUserIpAddress(SubtextContext.HttpContext) }; if (SendContactMessageToFeedback || String.IsNullOrEmpty(Blog.Email)) { CreateCommentWithContactMessage(contactMessage); } else { try { var emailService = new EmailService(EmailProvider.Instance(), new EmbeddedTemplateEngine(), SubtextContext); emailService.EmailCommentToBlogAuthor(contactMessage); } catch (Exception) { lblMessage.Text = "Your message could not be sent, most likely due to a problem with the mail server."; return; } } if (!Context.User.IsAdministrator()) { lblMessage.Text = "Your message was sent."; } else { lblMessage.Text = "Message submitted successfully, but no email was sent because you’re logged in as administrator."; } SwapWithLabel(tbName); SwapWithLabel(tbEmail); SwapWithLabel(tbMessage); SwapWithLabel(tbSubject); if (captcha != null) { Controls.Remove(captcha); } Controls.Remove(btnSend); } }
public string pingBack(string sourceURI, string targetURI) { if (!Blog.TrackbacksEnabled) { return("Pingbacks are not enabled for this site."); } string pageTitle; // GetPostIDFromUrl returns the postID int?id = SubtextContext.RequestContext.GetIdFromRequest(); if (id == null) { throw new XmlRpcFaultException(33, Resources.XmlRcpFault_DidNotLinkToPermalink); } Uri sourceUrl = sourceURI.ParseUri(); Uri targetUrl = targetURI.ParseUri(); // does the sourceURI actually contain the permalink ? if (sourceUrl == null || targetUrl == null || !Verifier.SourceContainsTarget(sourceUrl, targetUrl, out pageTitle)) { throw new XmlRpcFaultException(17, Resources.XmlRcpFault_InvalidLink); } //PTR = Pingback - TrackBack - Referral var trackback = new Trackback(id.Value, HtmlHelper.SafeFormat(pageTitle, SubtextContext.HttpContext.Server), new Uri(sourceURI), string.Empty, HtmlHelper.SafeFormat(pageTitle, SubtextContext.HttpContext.Server), Blog.TimeZone.Now); ICommentSpamService feedbackService = null; if (Blog.FeedbackSpamServiceEnabled) { feedbackService = new AkismetSpamService(Blog.FeedbackSpamServiceKey, Blog, null, Url); } var commentService = new CommentService(SubtextContext, new CommentFilter(SubtextContext, feedbackService)); commentService.Create(trackback, true /*runFilters*/); //TODO: Create this using IoC container var emailService = new EmailService(EmailProvider.Instance(), new EmbeddedTemplateEngine(), SubtextContext); emailService.EmailCommentToBlogAuthor(trackback); return(String.Format(CultureInfo.InvariantCulture, Resources.XmlRpcMessage_ThanksForThePingback, sourceURI)); }
private void CreateTrackbackAndSendResponse(ISubtextContext subtextContext, IEntryIdentity entry, int entryId) { HttpContextBase context = subtextContext.RequestContext.HttpContext; string title = SafeParam(context, "title"); string excerpt = SafeParam(context, "excerpt"); string urlText = SafeParam(context, "url"); string blogName = SafeParam(context, "blog_name"); Uri url = urlText.ParseUri(); if (url == null) { SendTrackbackResponse(context, 1, Resources.TrackbackResponse_NoUrl); return; } if (entry == null || !IsSourceVerification(url, subtextContext.UrlHelper.EntryUrl(entry).ToFullyQualifiedUrl(subtextContext.Blog))) { SendTrackbackResponse(context, 2, String.Format(CultureInfo.InvariantCulture, Resources.TrackbackResponse_NoRelevantLink, url)); return; } var trackback = new Trackback(entryId, title, url, blogName, excerpt, Blog.TimeZone.Now); ICommentSpamService feedbackService = null; Blog blog = subtextContext.Blog; if (blog.FeedbackSpamServiceEnabled) { feedbackService = new AkismetSpamService(blog.FeedbackSpamServiceKey, blog, null, Url); } var commentService = new CommentService(SubtextContext, new CommentFilter(SubtextContext, feedbackService)); commentService.Create(trackback, true /*runFilters*/); //TODO: Create this using IoC container var emailService = new EmailService(EmailProvider.Instance(), new EmbeddedTemplateEngine(), subtextContext); emailService.EmailCommentToBlogAuthor(trackback); }
private void OnSubmitButtonClick(object sender, EventArgs e) { Thread.Sleep(5000); if (!Page.IsValid) { return; } LastDitchValidation(); try { Entry currentEntry = RealEntry; if (IsCommentAllowed) { FeedbackItem feedbackItem = CreateFeedbackInstanceFromFormInput(currentEntry); ICommentSpamService feedbackService = null; if (Blog.FeedbackSpamServiceEnabled) { feedbackService = new AkismetSpamService(Blog.FeedbackSpamServiceKey, Blog, null, Url); } var commentService = new CommentService(SubtextContext, new CommentFilter(SubtextContext, feedbackService)); commentService.Create(feedbackItem, true /*runFilters*/); var emailService = new EmailService(EmailProvider.Instance(), new EmbeddedTemplateEngine(), SubtextContext); emailService.EmailCommentToBlogAuthor(feedbackItem); if (chkRemember == null || chkRemember.Checked) { SetRememberedUserCookie(); } DisplayResultMessage(feedbackItem); } } catch (BaseCommentException exception) { Message.Text = exception.Message; } }
private void ResetAdminPassword(Blog currentBlog) { if (String.IsNullOrEmpty(currentBlog.Email) || currentBlog.Email != emailTextBox.Text || currentBlog.UserName != usernameTextBox.Text) { Message.Visible = false; FailureText.Visible = true; FailureText.Text = Resources.ForgotPassword_UsernameAndPasswordDoNotMatch; } else { defaultInstructions.Visible = false; Message.Visible = true; FailureText.Visible = false; string newPassword = SecurityHelper.ResetPassword(); EmailProvider.Instance().Send(currentBlog.Email, currentBlog.Email, Resources.ForgotPassword_NewPassword , String.Format(CultureInfo.InvariantCulture, Resources.ForgotPaswword_HereIsNewPassword, newPassword)); Message.Text = Resources.ForgotPassword_NewPasswordSent; } }
private void OnSendButtonClick(object sender, EventArgs e) { if (Page.IsValid) { var contactMessage = new FeedbackItem(FeedbackType.ContactPage) { Author = tbName.Text, Email = tbEmail.Text, Body = tbMessage.Text, Title = string.Format("CONTACT: {0}", tbSubject.Text), IpAddress = HttpHelper.GetUserIpAddress(SubtextContext.HttpContext) }; if (SendContactMessageToFeedback || String.IsNullOrEmpty(Blog.Email)) { CreateCommentWithContactMessage(contactMessage); } else { try { var emailService = new EmailService(EmailProvider.Instance(), new EmbeddedTemplateEngine(), SubtextContext); emailService.EmailCommentToBlogAuthor(contactMessage); } catch (Exception) { lblMessage.Text = "Your message could not be sent, most likely due to a problem with the mail server."; return; } } lblMessage.Text = "Your message was sent."; } }