/// <summary> /// Handles the CreatingUser event of the CreateUserWizard1 control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="LoginCancelEventArgs" /> instance containing the event data.</param> /// <exception cref="System.ArgumentNullException">CreateUserWizard.UserName;UserName from CreateUserWizard is Null!</exception> /// <exception cref="ArgumentNullException">Argument is null.</exception> protected void CreateUserWizard1_CreatingUser([NotNull] object sender, [NotNull] LoginCancelEventArgs e) { string userName = this.CreateUserWizard1.UserName; if (userName.IsNotSet()) { throw new ArgumentNullException("CreateUserWizard.UserName", "UserName from CreateUserWizard is Null!"); } userName = userName.Trim(); // trim username on postback this.CreateUserWizard1.UserName = userName; // username cannot contain semi-colon or to be a bad word bool badWord = this.Get<IBadWordReplace>() .ReplaceItems.Any(i => userName.Equals(i.BadWord, StringComparison.CurrentCultureIgnoreCase)); string guestUserName = UserMembershipHelper.GuestUserName; guestUserName = guestUserName.IsSet() ? guestUserName.ToLower() : string.Empty; if (userName.Contains(";") || badWord || userName.ToLower().Equals(guestUserName)) { this.PageContext.AddLoadMessage(this.GetText("BAD_USERNAME"), MessageTypes.Warning); e.Cancel = true; return; } if (userName.Length < this.Get<YafBoardSettings>().DisplayNameMinLength) { this.PageContext.AddLoadMessage( this.GetTextFormatted("USERNAME_TOOLONG", this.Get<YafBoardSettings>().DisplayNameMinLength), MessageTypes.Error); e.Cancel = true; return; } if (userName.Length > this.Get<YafBoardSettings>().UserNameMaxLength) { this.PageContext.AddLoadMessage( this.GetTextFormatted("USERNAME_TOOLONG", this.Get<YafBoardSettings>().UserNameMaxLength), MessageTypes.Error); e.Cancel = true; return; } if (this.Get<YafBoardSettings>().EnableDisplayName) { var displayName = this.CreateUserStepContainer.FindControlAs<TextBox>("DisplayName"); if (displayName != null) { // Check if name matches the required minimum length if (displayName.Text.Trim().Length < this.Get<YafBoardSettings>().DisplayNameMinLength) { this.PageContext.AddLoadMessage( this.GetTextFormatted("USERNAME_TOOLONG", this.Get<YafBoardSettings>().DisplayNameMinLength), MessageTypes.Warning); e.Cancel = true; return; } // Check if name matches the required minimum length if (displayName.Text.Length > this.Get<YafBoardSettings>().UserNameMaxLength) { this.PageContext.AddLoadMessage( this.GetTextFormatted("USERNAME_TOOLONG", this.Get<YafBoardSettings>().UserNameMaxLength), MessageTypes.Warning); e.Cancel = true; return; } if (this.Get<IUserDisplayName>().GetId(displayName.Text.Trim()).HasValue) { this.PageContext.AddLoadMessage( this.GetText("ALREADY_REGISTERED_DISPLAYNAME"), MessageTypes.Warning); e.Cancel = true; } } } this.IsPossibleSpamBot = false; // Check user for bot if (this.Get<YafBoardSettings>().BotSpamServiceType > 0) { var spamChecker = new YafSpamCheck(); string result; var userIpAddress = this.Get<HttpRequestBase>().GetUserRealIPAddress(); // Check content for spam if (spamChecker.CheckUserForSpamBot( userName, this.CreateUserWizard1.Email, userIpAddress, out result)) { this.Logger.Log( null, "Bot Detected", "Bot Check detected a possible SPAM BOT: (user name : '{0}', email : '{1}', ip: '{2}', reason : {3}), user was rejected." .FormatWith(userName, this.CreateUserWizard1.Email, userIpAddress, result), EventLogTypes.SpamBotDetected); if (this.Get<YafBoardSettings>().BotHandlingOnRegister.Equals(1)) { // Flag user as spam bot this.IsPossibleSpamBot = true; } else if (this.Get<YafBoardSettings>().BotHandlingOnRegister.Equals(2)) { this.PageContext.AddLoadMessage(this.GetText("BOT_MESSAGE"), MessageTypes.Error); int? num = null; if (this.Get<YafBoardSettings>().BanBotIpOnDetection) { this.GetRepository<BannedIP>() .Save( null, userIpAddress, "A spam Bot who was trying to register was banned by IP {0}".FormatWith( userIpAddress), num.Value); if (YafContext.Current.Get<YafBoardSettings>().LogBannedIP) { this.Get<ILogger>() .Log( this.PageContext.PageUserID, "IP BAN of Bot During Registration", "A spam Bot who was trying to register was banned by IP {0}".FormatWith( userIpAddress), EventLogTypes.IpBanSet); } } e.Cancel = true; } } } var yafCaptchaText = this.CreateUserStepContainer.FindControlAs<TextBox>("tbCaptcha"); // vzrus: Here recaptcha should be always valid. This piece of code for testing only. if (this.Get<YafBoardSettings>().CaptchaTypeRegister == 2) { var recaptcha = this.CreateUserWizard1.FindWizardControlRecursive("Recaptcha1").ToClass<RecaptchaControl>(); if (recaptcha != null && !recaptcha.IsValid) { this.PageContext.AddLoadMessage(this.GetText("BAD_CAPTCHA"), MessageTypes.Error); e.Cancel = true; } } // verify captcha if enabled if (this.Get<YafBoardSettings>().CaptchaTypeRegister != 1 || CaptchaHelper.IsValid(yafCaptchaText.Text.Trim())) { return; } this.PageContext.AddLoadMessage(this.GetText("BAD_CAPTCHA"), MessageTypes.Error); e.Cancel = true; }
/// <summary> /// The quick reply_ click. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> private void QuickReply_Click([NotNull] object sender, [NotNull] EventArgs e) { if (!this.PageContext.ForumReplyAccess || (this._topicFlags.IsLocked && !this.PageContext.ForumModeratorAccess)) { YafBuildLink.AccessDenied(); } if (this._quickReplyEditor.Text.Length <= 0) { this.PageContext.AddLoadMessage(this.GetText("EMPTY_MESSAGE"), MessageTypes.Warning); return; } // No need to check whitespace if they are actually posting something if (this.Get<YafBoardSettings>().MaxPostSize > 0 && this._quickReplyEditor.Text.Length >= this.Get<YafBoardSettings>().MaxPostSize) { this.PageContext.AddLoadMessage(this.GetText("ISEXCEEDED"), MessageTypes.Warning); return; } if (((this.PageContext.IsGuest && this.Get<YafBoardSettings>().EnableCaptchaForGuests) || (this.Get<YafBoardSettings>().EnableCaptchaForPost && !this.PageContext.IsCaptchaExcluded)) && !CaptchaHelper.IsValid(this.tbCaptcha.Text.Trim())) { this.PageContext.AddLoadMessage(this.GetText("BAD_CAPTCHA"), MessageTypes.Warning); return; } if (!(this.PageContext.IsAdmin || this.PageContext.ForumModeratorAccess) && this.Get<YafBoardSettings>().PostFloodDelay > 0) { if (YafContext.Current.Get<IYafSession>().LastPost > DateTime.UtcNow.AddSeconds(-this.Get<YafBoardSettings>().PostFloodDelay)) { this.PageContext.AddLoadMessage( this.GetTextFormatted( "wait", (YafContext.Current.Get<IYafSession>().LastPost - DateTime.UtcNow.AddSeconds(-this.Get<YafBoardSettings>().PostFloodDelay)).Seconds), MessageTypes.Warning); return; } } YafContext.Current.Get<IYafSession>().LastPost = DateTime.UtcNow; // post message... long messageId = 0; object replyTo = -1; string msg = this._quickReplyEditor.Text; long topicID = this.PageContext.PageTopicID; // SPAM Check // Check if Forum is Moderated DataRow forumInfo; bool isForumModerated = false; using (DataTable dt = LegacyDb.forum_list(this.PageContext.PageBoardID, this.PageContext.PageForumID)) { forumInfo = dt.Rows[0]; } if (forumInfo != null) { isForumModerated = this.CheckForumModerateStatus(forumInfo); } var spamApproved = true; var isPossibleSpamMessage = false; // Check for SPAM if (!this.PageContext.IsAdmin && !this.PageContext.ForumModeratorAccess && !this.Get<YafBoardSettings>().SpamServiceType.Equals(0)) { var spamChecker = new YafSpamCheck(); string spamResult; // Check content for spam if (spamChecker.CheckPostForSpam( this.PageContext.IsGuest ? "Guest" : this.PageContext.PageUserName, YafContext.Current.Get<HttpRequestBase>().GetUserRealIPAddress(), this._quickReplyEditor.Text, this.PageContext.IsGuest ? null : this.PageContext.User.Email, out spamResult)) { switch (this.Get<YafBoardSettings>().SpamMessageHandling) { case 0: this.Logger.Log( this.PageContext.PageUserID, "Spam Message Detected", "Spam Check detected possible SPAM ({1}) posted by User: {0}" .FormatWith( this.PageContext.IsGuest ? "Guest" : this.PageContext.PageUserName, spamResult), EventLogTypes.SpamMessageDetected); break; case 1: spamApproved = false; isPossibleSpamMessage = true; this.Logger.Log( this.PageContext.PageUserID, "Spam Message Detected", "Spam Check detected possible SPAM ({1}) posted by User: {0}, it was flagged as unapproved post" .FormatWith( this.PageContext.IsGuest ? "Guest" : this.PageContext.PageUserName, spamResult), EventLogTypes.SpamMessageDetected); break; case 2: this.Logger.Log( this.PageContext.PageUserID, "Spam Message Detected", "Spam Check detected possible SPAM ({1}) posted by User: {0}, post was rejected" .FormatWith( this.PageContext.IsGuest ? "Guest" : this.PageContext.PageUserName, spamResult), EventLogTypes.SpamMessageDetected); this.PageContext.AddLoadMessage(this.GetText("SPAM_MESSAGE"), MessageTypes.Error); return; case 3: this.Logger.Log( this.PageContext.PageUserID, "Spam Message Detected", "Spam Check detected possible SPAM ({1}) posted by User: {0}, user was deleted and bannded" .FormatWith( this.PageContext.IsGuest ? "Guest" : this.PageContext.PageUserName, spamResult), EventLogTypes.SpamMessageDetected); var userIp = new CombinedUserDataHelper( this.PageContext.CurrentUserData.Membership, this.PageContext.PageUserID).LastIP; UserMembershipHelper.DeleteAndBanUser( this.PageContext.PageUserID, this.PageContext.CurrentUserData.Membership, userIp); return; } } } // If Forum is Moderated if (isForumModerated) { spamApproved = false; } // Bypass Approval if Admin or Moderator if (this.PageContext.IsAdmin || this.PageContext.ForumModeratorAccess) { spamApproved = true; } var tFlags = new MessageFlags { IsHtml = this._quickReplyEditor.UsesHTML, IsBBCode = this._quickReplyEditor.UsesBBCode, IsApproved = spamApproved }; // Bypass Approval if Admin or Moderator. if ( !LegacyDb.message_save( topicID, this.PageContext.PageUserID, msg, null, this.Get<HttpRequestBase>().GetUserRealIPAddress(), null, replyTo, tFlags.BitValue, ref messageId)) { topicID = 0; } // Check to see if the user has enabled "auto watch topic" option in his/her profile. if (this.PageContext.CurrentUserData.AutoWatchTopics) { var watchTopicId = this.GetRepository<WatchTopic>().Check(this.PageContext.PageUserID, this.PageContext.PageTopicID); if (!watchTopicId.HasValue) { // subscribe to this topic this.GetRepository<WatchTopic>().Add(this.PageContext.PageUserID, this.PageContext.PageTopicID); } } bool bApproved = false; using (DataTable dt = LegacyDb.message_list(messageId)) { foreach (DataRow row in dt.Rows) { bApproved = ((int)row["Flags"] & 16) == 16; } } if (bApproved) { // send new post notification to users watching this topic/forum this.Get<ISendNotification>().ToWatchingUsers(messageId.ToType<int>()); if (Config.IsDotNetNuke && !this.PageContext.IsGuest) { this.Get<IActivityStream>() .AddReplyToStream( this.PageContext.PageForumID, this.PageContext.PageTopicID, messageId.ToType<int>(), this.PageContext.PageTopicName, msg); } // redirect to newly posted message YafBuildLink.Redirect(ForumPages.posts, "m={0}&#post{0}", messageId); } else { if (this.Get<YafBoardSettings>().EmailModeratorsOnModeratedPost) { // not approved, notifiy moderators this.Get<ISendNotification>() .ToModeratorsThatMessageNeedsApproval( this.PageContext.PageForumID, messageId.ToType<int>(), isPossibleSpamMessage); } string url = YafBuildLink.GetLink(ForumPages.topics, "f={0}", this.PageContext.PageForumID); if (Config.IsRainbow) { YafBuildLink.Redirect(ForumPages.info, "i=1"); } else { YafBuildLink.Redirect(ForumPages.info, "i=1&url={0}", this.Server.UrlEncode(url)); } } }
/// <summary> /// Validates the post. /// </summary> public bool ValidPost() { if (!this.IsPostReplyVerified()) { return false; } if (this.IsPostReplyDelay()) { return false; } // Check for SPAM if (!this.PageContext.IsAdmin && !this.PageContext.ForumModeratorAccess && !this.Get<YafBoardSettings>().SpamServiceType.Equals(0)) { var spamChecker = new YafSpamCheck(); string spamResult; // Check content for spam if ( spamChecker.CheckPostForSpam(this.PageContext.PageUserName, YafContext.Current.Get<HttpRequestBase>().GetUserRealIPAddress(), BBCodeHelper.StripBBCode( HtmlHelper.StripHtml(HtmlHelper.CleanHtmlString(this.CkEditor.Text))) .RemoveMultipleWhitespace(), this.PageContext.User.Email, out spamResult)) { if (this.Get<YafBoardSettings>().SpamMessageHandling.Equals(1)) { this.Get<ILogger>() .Info( "Spam Check detected possible SPAM ({2}) posted by User: {0}, it was flagged as unapproved post. Content was: {1}", this.PageContext.PageUserName, this.CkEditor.Text, spamResult); } else if (this.Get<YafBoardSettings>().SpamMessageHandling.Equals(2)) { this.Get<ILogger>() .Info( "Spam Check detected possible SPAM ({2}) posted by User: {0}, post was rejected. Content was: {1}", this.PageContext.PageUserName, this.CkEditor.Text, spamResult); this.PageContext.AddLoadMessage(this.GetText("SPAM_MESSAGE"), MessageTypes.Error); return false; } } } this.Get<IYafSession>().LastPost = DateTime.UtcNow.AddSeconds(30); return true; }
/// <summary> /// Handles the PostReply click including: Replying, Editing and New post. /// </summary> /// <param name="sender"> /// The Sender Object. /// </param> /// <param name="e"> /// The Event Arguments. /// </param> protected void PostReply_Click([NotNull] object sender, [NotNull] EventArgs e) { if (!this.IsPostReplyVerified()) { return; } if (this.IsPostReplyDelay()) { return; } // Check for SPAM if (!this.PageContext.IsAdmin && !this.PageContext.ForumModeratorAccess && !this.Get<YafBoardSettings>().SpamServiceType.Equals(0)) { var spamChecker = new YafSpamCheck(); string spamResult; // Check content for spam if ( spamChecker.CheckPostForSpam( this.PageContext.IsGuest ? this.From.Text : this.PageContext.PageUserName, YafContext.Current.Get<HttpRequestBase>().GetUserRealIPAddress(), BBCodeHelper.StripBBCode( HtmlHelper.StripHtml(HtmlHelper.CleanHtmlString(this._forumEditor.Text))) .RemoveMultipleWhitespace(), this.PageContext.IsGuest ? null : this.PageContext.User.Email, out spamResult)) { if (this.Get<YafBoardSettings>().SpamMessageHandling.Equals(1)) { this.spamApproved = false; this.Get<ILogger>() .Info( "Spam Check detected possible SPAM ({2}) posted by User: {0}, it was flagged as unapproved post. Content was: {1}", this.PageContext.IsGuest ? this.From.Text : this.PageContext.PageUserName, this._forumEditor.Text, spamResult); } else if (this.Get<YafBoardSettings>().SpamMessageHandling.Equals(2)) { this.Get<ILogger>() .Info( "Spam Check detected possible SPAM ({2}) posted by User: {0}, post was rejected. Content was: {1}", this.PageContext.IsGuest ? this.From.Text : this.PageContext.PageUserName, this._forumEditor.Text, spamResult); this.PageContext.AddLoadMessage(this.GetText("SPAM_MESSAGE"), MessageTypes.Error); return; } } // check user for spam bot /*if (spamChecker.CheckUserForSpamBot( this.PageContext.IsGuest ? this.From.Text : this.PageContext.PageUserName, this.PageContext.IsGuest ? null : this.PageContext.User.Email, this.Get<HttpRequestBase>().GetUserRealIPAddress() )) { if (this.Get<YafBoardSettings>().SpamMessageHandling.Equals(1)) { this.spamApproved = false; this.Get<ILogger>() .Info( "Spam Check detected possible SPAM posted by User: {0}, it was flagged as unapproved post. Content was: {1}", this.PageContext.IsGuest ? this.From.Text : this.PageContext.PageUserName, this._forumEditor.Text); } else if (this.Get<YafBoardSettings>().SpamMessageHandling.Equals(2)) { this.Get<ILogger>() .Info( "Spam Check detected possible SPAM posted by User: {0}, post was rejected. Content was: {1}", this.PageContext.IsGuest ? this.From.Text : this.PageContext.PageUserName, this._forumEditor.Text); this.PageContext.AddLoadMessage(this.GetText("SPAM_MESSAGE"), MessageTypes.Error); return; } }*/ } // TODO /*if (this.Get<YafBoardSettings>().UserPostsRequiredForUrls < this.PageContext.CurrentUserData.NumPosts) { this._forumEditor.Text = BBCodeHelper.StripBBCodeUrls(this._forumEditor.Text); }*/ // update the last post time... this.Get<IYafSession>().LastPost = DateTime.UtcNow.AddSeconds(30); long messageId; long newTopic = 0; if (this.TopicID != null) { // Reply to topic messageId = this.PostReplyHandleReplyToTopic(this.spamApproved); newTopic = this.TopicID.ToType<long>(); } else if (this.EditMessageID != null) { // Edit existing post messageId = this.PostReplyHandleEditPost(); } else { // New post messageId = this.PostReplyHandleNewPost(out newTopic); } // Check if message is approved bool isApproved = false; using (DataTable dt = LegacyDb.message_list(messageId)) { foreach (DataRow row in dt.Rows) { isApproved = row["Flags"].BinaryAnd(MessageFlags.Flags.IsApproved); } } // vzrus^ the poll access controls are enabled and this is a new topic - we add the variables string attachp = string.Empty; string retforum = string.Empty; if (this.PageContext.ForumPollAccess && this.PostOptions1.PollOptionVisible && newTopic > 0) { // new topic poll token attachp = "&t={0}".FormatWith(newTopic); // new return forum poll token retforum = "&f={0}".FormatWith(this.PageContext.PageForumID); } // Create notification emails if (isApproved) { this.Get<ISendNotification>().ToWatchingUsers(messageId.ToType<int>()); if (Config.IsDotNetNuke && this.EditMessageID == null) { if (this.TopicID != null) { this.Get<IActivityStream>() .AddReplyToStream( this.PageContext.PageForumID, newTopic, messageId.ToType<int>(), this.PageContext.PageTopicName, this._forumEditor.Text); } else { this.Get<IActivityStream>() .AddTopicToStream( this.PageContext.PageForumID, newTopic, messageId.ToType<int>(), this.TopicSubjectTextBox.Text, this._forumEditor.Text); } } if (this.PageContext.ForumUploadAccess && this.PostOptions1.AttachChecked) { // 't' variable is required only for poll and this is a attach poll token for attachments page if (!this.PostOptions1.PollChecked) { attachp = string.Empty; } // redirect to the attachment page... YafBuildLink.Redirect(ForumPages.attachments, "m={0}{1}", messageId, attachp); } else { if (attachp.IsNotSet() || (!this.PostOptions1.PollChecked)) { // regular redirect... YafBuildLink.Redirect(ForumPages.posts, "m={0}#post{0}", messageId); } else { // poll edit redirect... YafBuildLink.Redirect(ForumPages.polledit, "{0}", attachp); } } } else { // Not Approved if (this.Get<YafBoardSettings>().EmailModeratorsOnModeratedPost) { // not approved, notifiy moderators this.Get<ISendNotification>() .ToModeratorsThatMessageNeedsApproval(this.PageContext.PageForumID, (int)messageId); } // 't' variable is required only for poll and this is a attach poll token for attachments page if (!this.PostOptions1.PollChecked) { attachp = string.Empty; } if (this.PostOptions1.AttachChecked && this.PageContext.ForumUploadAccess) { // redirect to the attachment page... YafBuildLink.Redirect(ForumPages.attachments, "m={0}&ra=1{1}{2}", messageId, attachp, retforum); } else { // Tell user that his message will have to be approved by a moderator string url = YafBuildLink.GetLink(ForumPages.topics, "f={0}", this.PageContext.PageForumID); if (this.PageContext.PageTopicID > 0) { url = YafBuildLink.GetLink(ForumPages.posts, "t={0}", this.PageContext.PageTopicID); } if (attachp.Length <= 0) { YafBuildLink.Redirect(ForumPages.info, "i=1&url={0}", this.Server.UrlEncode(url)); } else { YafBuildLink.Redirect(ForumPages.polledit, "&ra=1{0}{1}", attachp, retforum); } if (Config.IsRainbow) { YafBuildLink.Redirect(ForumPages.info, "i=1"); } } } }
/// <summary> /// Handles the PostReply click including: Replying, Editing and New post. /// </summary> /// <param name="sender"> /// The Sender Object. /// </param> /// <param name="e"> /// The Event Arguments. /// </param> protected void PostReply_Click([NotNull] object sender, [NotNull] EventArgs e) { if (!this.IsPostReplyVerified()) { return; } if (this.IsPostReplyDelay()) { return; } var isPossibleSpamMessage = false; // Check for SPAM if (!this.PageContext.IsAdmin && !this.PageContext.ForumModeratorAccess && !this.PageContext.BoardSettings.SpamServiceType.Equals(0)) { var spamChecker = new YafSpamCheck(); string spamResult; // Check content for spam if ( spamChecker.CheckPostForSpam( this.PageContext.IsGuest ? this.From.Text : this.PageContext.PageUserName, this.Get<HttpRequestBase>().GetUserRealIPAddress(), BBCodeHelper.StripBBCode( HtmlHelper.StripHtml(HtmlHelper.CleanHtmlString(this._forumEditor.Text))) .RemoveMultipleWhitespace(), this.PageContext.IsGuest ? null : this.PageContext.User.Email, out spamResult)) { switch (this.PageContext.BoardSettings.SpamMessageHandling) { case 0: this.Logger.Log( this.PageContext.PageUserID, "Spam Message Detected", "Spam Check detected possible SPAM ({1}) posted by User: {0}".FormatWith( this.PageContext.IsGuest ? this.From.Text : this.PageContext.PageUserName), EventLogTypes.SpamMessageDetected); break; case 1: this.spamApproved = false; isPossibleSpamMessage = true; this.Logger.Log( this.PageContext.PageUserID, "Spam Message Detected", "Spam Check detected possible SPAM ({1}) posted by User: {0}, it was flagged as unapproved post." .FormatWith( this.PageContext.IsGuest ? this.From.Text : this.PageContext.PageUserName, spamResult), EventLogTypes.SpamMessageDetected); break; case 2: this.Logger.Log( this.PageContext.PageUserID, "Spam Message Detected", "Spam Check detected possible SPAM ({1}) posted by User: {0}, post was rejected" .FormatWith( this.PageContext.IsGuest ? this.From.Text : this.PageContext.PageUserName, spamResult), EventLogTypes.SpamMessageDetected); this.PageContext.AddLoadMessage(this.GetText("SPAM_MESSAGE"), MessageTypes.danger); return; case 3: this.Logger.Log( this.PageContext.PageUserID, "Spam Message Detected", "Spam Check detected possible SPAM ({1}) posted by User: {0}, user was deleted and banned" .FormatWith( this.PageContext.IsGuest ? this.From.Text : this.PageContext.PageUserName, spamResult), EventLogTypes.SpamMessageDetected); var userIp = new CombinedUserDataHelper( this.PageContext.CurrentUserData.Membership, this.PageContext.PageUserID).LastIP; UserMembershipHelper.DeleteAndBanUser( this.PageContext.PageUserID, this.PageContext.CurrentUserData.Membership, userIp); return; } } } // Check posts for urls if the user has only x posts if (YafContext.Current.CurrentUserData.NumPosts <= YafContext.Current.Get<YafBoardSettings>().IgnoreSpamWordCheckPostCount && !this.PageContext.IsAdmin && !this.PageContext.ForumModeratorAccess) { var urlCount = UrlHelper.CountUrls(this._forumEditor.Text); if (urlCount > this.PageContext.BoardSettings.AllowedNumberOfUrls) { var spamResult = "The user posted {0} urls but allowed only {1}".FormatWith( urlCount, this.PageContext.BoardSettings.AllowedNumberOfUrls); switch (this.PageContext.BoardSettings.SpamMessageHandling) { case 0: this.Logger.Log( this.PageContext.PageUserID, "Spam Message Detected", "Spam Check detected possible SPAM ({1}) posted by User: {0}".FormatWith( this.PageContext.IsGuest ? this.From.Text : this.PageContext.PageUserName), EventLogTypes.SpamMessageDetected); break; case 1: this.spamApproved = false; isPossibleSpamMessage = true; this.Logger.Log( this.PageContext.PageUserID, "Spam Message Detected", "Spam Check detected possible SPAM ({1}) posted by User: {0}, it was flagged as unapproved post." .FormatWith( this.PageContext.IsGuest ? this.From.Text : this.PageContext.PageUserName, spamResult), EventLogTypes.SpamMessageDetected); break; case 2: this.Logger.Log( this.PageContext.PageUserID, "Spam Message Detected", "Spam Check detected possible SPAM ({1}) posted by User: {0}, post was rejected" .FormatWith( this.PageContext.IsGuest ? this.From.Text : this.PageContext.PageUserName, spamResult), EventLogTypes.SpamMessageDetected); this.PageContext.AddLoadMessage(this.GetText("SPAM_MESSAGE"), MessageTypes.danger); return; case 3: this.Logger.Log( this.PageContext.PageUserID, "Spam Message Detected", "Spam Check detected possible SPAM ({1}) posted by User: {0}, user was deleted and banned" .FormatWith( this.PageContext.IsGuest ? this.From.Text : this.PageContext.PageUserName, spamResult), EventLogTypes.SpamMessageDetected); var userIp = new CombinedUserDataHelper( this.PageContext.CurrentUserData.Membership, this.PageContext.PageUserID).LastIP; UserMembershipHelper.DeleteAndBanUser( this.PageContext.PageUserID, this.PageContext.CurrentUserData.Membership, userIp); return; } } } // update the last post time... this.Get<IYafSession>().LastPost = DateTime.UtcNow.AddSeconds(30); long messageId; long newTopic = 0; if (this.TopicID != null) { // Reply to topic messageId = this.PostReplyHandleReplyToTopic(this.spamApproved); newTopic = this.TopicID.ToType<long>(); } else if (this.EditMessageID != null) { // Edit existing post messageId = this.PostReplyHandleEditPost(); } else { // New post messageId = this.PostReplyHandleNewPost(out newTopic); } // Check if message is approved var isApproved = false; using (DataTable dt = LegacyDb.message_list(messageId)) { foreach (DataRow row in dt.Rows) { isApproved = row["Flags"].BinaryAnd(MessageFlags.Flags.IsApproved); } } // vzrus^ the poll access controls are enabled and this is a new topic - we add the variables var attachPollParameter = string.Empty; var retforum = string.Empty; if (this.PageContext.ForumPollAccess && this.PostOptions1.PollOptionVisible && newTopic > 0) { // new topic poll token attachPollParameter = "&t={0}".FormatWith(newTopic); // new return forum poll token retforum = "&f={0}".FormatWith(this.PageContext.PageForumID); } // Create notification emails if (isApproved) { this.Get<ISendNotification>().ToWatchingUsers(messageId.ToType<int>()); if (Config.IsDotNetNuke && this.EditMessageID == null && !this.PageContext.IsGuest) { if (this.TopicID != null) { this.Get<IActivityStream>() .AddReplyToStream( this.PageContext.PageForumID, newTopic, messageId.ToType<int>(), this.PageContext.PageTopicName, this._forumEditor.Text); } else { this.Get<IActivityStream>() .AddTopicToStream( this.PageContext.PageForumID, newTopic, messageId.ToType<int>(), this.TopicSubjectTextBox.Text, this._forumEditor.Text); } } if (attachPollParameter.IsNotSet() || (!this.PostOptions1.PollChecked)) { // regular redirect... YafBuildLink.Redirect(ForumPages.posts, "m={0}#post{0}", messageId); } else { // poll edit redirect... YafBuildLink.Redirect(ForumPages.polledit, "{0}", attachPollParameter); } } else { // Not Approved if (this.PageContext.BoardSettings.EmailModeratorsOnModeratedPost) { // not approved, notifiy moderators this.Get<ISendNotification>() .ToModeratorsThatMessageNeedsApproval( this.PageContext.PageForumID, messageId.ToType<int>(), isPossibleSpamMessage); } // 't' variable is required only for poll and this is a attach poll token for attachments page if (!this.PostOptions1.PollChecked) { attachPollParameter = string.Empty; } // Tell user that his message will have to be approved by a moderator var url = YafBuildLink.GetLink(ForumPages.topics, "f={0}", this.PageContext.PageForumID); if (this.PageContext.PageTopicID > 0) { url = YafBuildLink.GetLink(ForumPages.posts, "t={0}", this.PageContext.PageTopicID); } if (attachPollParameter.Length <= 0) { YafBuildLink.Redirect(ForumPages.info, "i=1&url={0}", this.Server.UrlEncode(url)); } else { YafBuildLink.Redirect(ForumPages.polledit, "&ra=1{0}{1}", attachPollParameter, retforum); } if (Config.IsRainbow) { YafBuildLink.Redirect(ForumPages.info, "i=1"); } } }