Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8620611
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T06:37:18+00:00 2026-06-12T06:37:18+00:00

I have a list of comments that gets formed. The client asked us to

  • 0

I have a list of comments that gets formed. The client asked us to use a profanity filter to check the comments before they get published. I have a ProfanityFilter.cs class. The only thing is I am not sure how to integrate the the two.

Simply put, how to I have the comments hit the filter before they get published.

Thanks in advance!

Here is the code where the list of comments get formed:

public void ProcessRequest (HttpContext context) 
{

    // ****************************************
    if (context.Request["postform"] == "1")
    {

        videomessage myVideoMessage = new videomessage();

        myVideoMessage.video_id = context.Request["video_id"];
        myVideoMessage.first_name_submitter = context.Request["first_name_submitter"];
        myVideoMessage.last_initial_submitter = context.Request["last_initial_submitter"];
        myVideoMessage.message = context.Request["message"];
        myVideoMessage.status = "0";

        myVideoMessage.Save();
    }
    // ****************************************

    // ****************************************
    StringBuilder myStringBuilder = new StringBuilder();


    // PULL VIDEOMESSAGES FOR VIDEO_ID
    videomessage[] myCommentsList = new videomessage().Listing("video_id", context.Request["video_id"], "entry_date" , "DESC");

    // FORM COMMENTS IF MORE THAN ONE COMMENT EXISTS
    foreach (videomessage tmpMessage in myCommentsList)
    {
        if (tmpMessage.status == "0" || tmpMessage.status == "1")
        {
            myStringBuilder.Append("<div class=\"comment_box\">");
            myStringBuilder.Append("<p class=\"comment_date\">");
            myStringBuilder.Append(Utility.FormatShortDate(tmpMessage.entry_date) + " " + tmpMessage.first_name_submitter + " " + tmpMessage.last_initial_submitter + "." + "</p>");

            if (!String.IsNullOrEmpty(tmpMessage.message))
            {
                myStringBuilder.Append("<p>" + tmpMessage.message + "</p>");
                myStringBuilder.Append("</div>");
            }
        }
    }
    string return_str = myStringBuilder.ToString();

    // IF NO COMMENTS RETURN THIS
    if( String.IsNullOrEmpty(return_str) )  return_str = "<p>No comments currently exist for this video.</p>";
    // ****************************************

    // RETURN STRING        
    context.Response.ContentType = "text/plain";
    context.Response.Write(return_str);
}

Here is the filter:

public class ProfanityFilter
{        
    // METHOD: containsProfanity
    public bool containsProfanity(string checkStr)
    {
        bool badwordpresent = false;

        string[] inStrArray = checkStr.Split(new char[] { ' ' });

        string[] words = this.profanityArray();

        // LOOP THROUGH WORDS IN MESSAGE
        for (int x = 0; x < inStrArray.Length; x++)
        {
            // LOOP THROUGH PROFANITY WORDS
            for (int i = 0; i < words.Length; i++)
            {
                // IF WORD IS PROFANITY, SET FLAG AND BREAK OUT OF LOOP
                //if (inStrArray[x].toString().toLowerCase().equals(words[i]))
                if( inStrArray[x].ToLower() == words[i].ToLower() )
                {
                    badwordpresent = true;
                    break;
                }
            }
            // IF FLAG IS SET, BREAK OUT OF OUTER LOOP
            if (badwordpresent == true) break;
        }

        return badwordpresent;
    }
    // ************************************************************************




    // ************************************************************************
    // METHOD: profanityArray()
    // METHOD OF PROFANITY WORDS
    private string[] profanityArray()
    {

        // THESE WERE UPDATED TO USE THE SAME BADWORDS FROM FACESOFMBCFBAPP
        string[] words = {//words in the array}
}
return words;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T06:37:19+00:00Added an answer on June 12, 2026 at 6:37 am

    After string return_str = myStringBuilder.ToString(); add:

    ProfanityFilter filter = new ProfanityFilter();
    
    if (filter.ContainsProfanity(return_str)
    {
        // Do action when message contains profanity
    }
    else
    {
        // Do action when message does not contains profanity     
    }
    

    Also have in mind that your code is not taking into account line breaks (I don’t know if comments cannot have line breaks, just in case of).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a page which list comments of users. My problem is that I
I have a stored procedure that gets a list of items, sorts and applies
So I have a list that gets generated e.g. missingfromauthoratative and with that list
I have a list of nested comments that essentially form a tree. //Non-Relevant properties
I have a list in my python program that gets new items on certain
I have an app (for a given twitter user) that gets a list of
Greetings, I have a list of user comments on a page, with a next
I have a large threaded comment list. When a person replies the author gets
I have list of textareas. For textareas I use tinyMCE Editor. When I start
i have list of rows that user select and i want to delete them,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.