/// <summary> /// Check a User (Bot) against the StopForumSpam, BotScout Service or both /// </summary> /// <param name="userName">Name of the user.</param> /// <param name="emailAddress">The email address.</param> /// <param name="ipAddress">The IP address.</param> /// <param name="result">The result.</param> /// <returns> /// Returns if Post is SPAM or not /// </returns> public bool CheckUserForSpamBot([NotNull]string userName, [CanBeNull]string emailAddress, [NotNull]string ipAddress, out string result) { result = string.Empty; if (YafContext.Current.Get<YafBoardSettings>().BotSpamServiceType.Equals(0)) { return false; } switch (YafContext.Current.Get<YafBoardSettings>().BotSpamServiceType) { case 1: { var stopForumSpam = new StopForumSpam(); return stopForumSpam.IsBot(ipAddress, emailAddress, userName, out result); } case 2: { if (YafContext.Current.Get<YafBoardSettings>().BotScoutApiKey.IsSet()) { var botScout = new BotScout(); return botScout.IsBot(ipAddress, emailAddress, userName, out result); } // use StopForumSpam instead var stopForumSpam = new StopForumSpam(); return stopForumSpam.IsBot(ipAddress, emailAddress, userName, out result); } case 3: { // use StopForumSpam instead var stopForumSpam = new StopForumSpam(); if (!YafContext.Current.Get<YafBoardSettings>().BotScoutApiKey.IsSet()) { return stopForumSpam.IsBot(ipAddress, emailAddress, userName, out result); } var botScout = new BotScout(); return botScout.IsBot(ipAddress, emailAddress, userName) && stopForumSpam.IsBot(ipAddress, emailAddress, userName, out result); } case 4: { // use StopForumSpam instead var stopForumSpam = new StopForumSpam(); if (!YafContext.Current.Get<YafBoardSettings>().BotScoutApiKey.IsSet()) { return stopForumSpam.IsBot(ipAddress, emailAddress, userName, out result); } var botScout = new BotScout(); return botScout.IsBot(ipAddress, emailAddress, userName) | stopForumSpam.IsBot(ipAddress, emailAddress, userName, out result); } } return false; }
/// <summary> /// Reports the User /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> protected void Report_OnClick([NotNull] object sender, [NotNull] EventArgs e) { if (this.Get<YafBoardSettings>().StopForumSpamApiKey.IsNotSet()) { return; } var user = UserMembershipHelper.GetMembershipUserById(this.CurrentUserID); try { var stopForumSpam = new StopForumSpam(); if (!stopForumSpam.ReportUserAsBot(this.IPAddresses.FirstOrDefault(), user.Email, user.UserName)) { return; } this.PageContext.AddLoadMessage(this.GetText("ADMIN_EDITUSER", "BOT_REPORTED"), MessageTypes.Success); this.Logger.Log( this.PageContext.PageUserID, "User Reported to StopForumSpam.com", "User (Name:{0}/ID:{1}/IP:{2}/Email:{3}) Reported to StopForumSpam.com by {4}".FormatWith( user.UserName, this.CurrentUserID, this.IPAddresses.FirstOrDefault(), user.Email, this.Get<YafBoardSettings>().EnableDisplayName ? this.PageContext.CurrentUserData.DisplayName : this.PageContext.CurrentUserData.UserName), EventLogTypes.SpamBotReported); } catch (Exception exception) { this.PageContext.AddLoadMessage( this.GetText("ADMIN_EDITUSER", "BOT_REPORTED_FAILED"), MessageTypes.Error); this.Logger.Log( this.PageContext.PageUserID, "User (Name{0}/ID:{1}) Report to StopForumSpam.com Failed".FormatWith( user.UserName, this.CurrentUserID), exception); } }
/// <summary> /// Kills the User /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> protected void Kill_OnClick([NotNull] object sender, [NotNull] EventArgs e) { var user = UserMembershipHelper.GetMembershipUserById(this.CurrentUserID); // Ban User Email? if (this.BanEmail.Checked) { this.GetRepository<BannedEmail>() .Save( null, user.Email, "Email was reported by: {0}".FormatWith( this.Get<YafBoardSettings>().EnableDisplayName ? this.PageContext.CurrentUserData.DisplayName : this.PageContext.CurrentUserData.UserName)); } // Ban User IP? if (this.BanIps.Checked && this.IPAddresses.Any()) { this.BanUserIps(); } // Ban User IP? if (this.BanName.Checked) { this.GetRepository<BannedName>() .Save( null, user.UserName, "Name was reported by: {0}".FormatWith( this.Get<YafBoardSettings>().EnableDisplayName ? this.PageContext.CurrentUserData.DisplayName : this.PageContext.CurrentUserData.UserName)); } this.DeleteAllUserMessages(); if (this.ReportUser.Checked && this.Get<YafBoardSettings>().StopForumSpamApiKey.IsSet() && this.IPAddresses.Any()) { try { var stopForumSpam = new StopForumSpam(); if (!stopForumSpam.ReportUserAsBot(this.IPAddresses.FirstOrDefault(), user.Email, user.UserName)) { this.Logger.Log( this.PageContext.PageUserID, "User Reported to StopForumSpam.com", "User (Name:{0}/ID:{1}/IP:{2}/Email:{3}) Reported to StopForumSpam.com by {4}".FormatWith( user.UserName, this.CurrentUserID, this.IPAddresses.FirstOrDefault(), user.Email, this.Get<YafBoardSettings>().EnableDisplayName ? this.PageContext.CurrentUserData.DisplayName : this.PageContext.CurrentUserData.UserName), EventLogTypes.SpamBotReported); } } catch (Exception exception) { this.PageContext.AddLoadMessage( this.GetText("ADMIN_EDITUSER", "BOT_REPORTED_FAILED"), MessageTypes.Error); this.Logger.Log( this.PageContext.PageUserID, "User (Name{0}/ID:{1}) Report to StopForumSpam.com Failed".FormatWith( user.UserName, this.CurrentUserID), exception); } } switch (this.SuspendOrDelete.SelectedValue) { case "delete": if (this.CurrentUserID > 0) { // we are deleting user if (this.PageContext.PageUserID == this.CurrentUserID) { // deleting yourself isn't an option this.PageContext.AddLoadMessage( this.GetText("ADMIN_USERS", "MSG_SELF_DELETE"), MessageTypes.Error); return; } // get user(s) we are about to delete using ( DataTable dt = LegacyDb.user_list( this.PageContext.PageBoardID, this.CurrentUserID, DBNull.Value)) { // examine each if he's possible to delete foreach (DataRow row in dt.Rows) { if (row["IsGuest"].ToType<int>() > 0) { // we cannot detele guest this.PageContext.AddLoadMessage( this.GetText("ADMIN_USERS", "MSG_DELETE_GUEST"), MessageTypes.Error); return; } if ((row["IsAdmin"] == DBNull.Value || row["IsAdmin"].ToType<int>() <= 0) && (row["IsHostAdmin"] == DBNull.Value || row["IsHostAdmin"].ToType<int>() <= 0)) { continue; } // admin are not deletable either this.PageContext.AddLoadMessage( this.GetText("ADMIN_USERS", "MSG_DELETE_ADMIN"), MessageTypes.Error); return; } } // all is good, user can be deleted UserMembershipHelper.DeleteUser(this.CurrentUserID.ToType<int>()); YafBuildLink.Redirect(ForumPages.admin_users); } break; case "suspend": if (this.CurrentUserID > 0) { LegacyDb.user_suspend(this.CurrentUserID, DateTime.UtcNow.AddYears(5)); } break; } this.PageContext.AddLoadMessage( this.Get<ILocalization>().GetText("ADMIN_EDITUSER", "MSG_USER_KILLED").FormatWith(user.UserName)); // update the displayed data... this.BindData(); }
/// <summary> /// Reports the User /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> protected void Report_OnClick([NotNull] object sender, [NotNull] EventArgs e) { if (this.Get<YafBoardSettings>().StopForumSpamApiKey.IsNotSet()) { return; } try { var stopForumSpam = new StopForumSpam(); MembershipUser user = UserMembershipHelper.GetMembershipUserById(this.CurrentUserID); if (stopForumSpam.ReportUserAsBot(this.IPAddresses.FirstOrDefault(), user.Email, user.UserName)) { this.PageContext.AddLoadMessage(this.GetText("ADMIN_EDITUSER", "BOT_REPORTED"), MessageTypes.Success); } } catch (Exception) { this.PageContext.AddLoadMessage(this.GetText("ADMIN_EDITUSER", "BOT_REPORTED_FAILED"), MessageTypes.Error); } }