Is there any PHP script to stop the bad words in user generated content?

10 replies
I want a script which can filter or stop the badwords in content posted by the users in my classifieds script. Since there are so many bad words that are there in english and it is tougher to build the list of bad words if some ready made script is available to do that job that will help me well. If any one know such script please help me getting that.
#bad #content #generated #php #script #stop #user #words
  • Profile picture of the author Jeremy_AM
    you could use preg_replace. pass it an array of "bad" words to replace
    {{ DiscussionBoard.errors[4447158].message }}
  • Profile picture of the author SteveJohnson
    Here's a list: Bad words list (458 words)

    Pretty easy to write a simple strip or replace function.
    Signature

    The 2nd Amendment, 1789 - The Original Homeland Security.

    Gun control means never having to say, "I missed you."

    {{ DiscussionBoard.errors[4447267].message }}
    • Profile picture of the author mpchekuri
      I did use this list of badwords. But still I could see a lot of bad words used by the users. I want a comprehensive list of these words. Any one who finds such list please give me a message. Thankyou.
      {{ DiscussionBoard.errors[4701799].message }}
  • Profile picture of the author lwbco
    I like to do jobs like this in PERL. CPAN is so robust and powerful, simple tasks like bad word filtration only take one line of PERL to write.
    {{ DiscussionBoard.errors[4447724].message }}
    • Profile picture of the author Rexibit
      Originally Posted by lwbco View Post

      I like to do jobs like this in PERL. CPAN is so robust and powerful, simple tasks like bad word filtration only take one line of PERL to write.
      In addition to using this language that lwbco discussed, this can easily be done by setting up a Neural Network trained on badwords so that any in the array is replaced by something like , "Smurf". Using a NN means that once it's trained on the current list of common bad words, it'll make assessments (similar to a spam filter in E-mail) about future bad words and permutation there of.

      Might as well save you some work in the future, right?
      {{ DiscussionBoard.errors[4447740].message }}
  • Profile picture of the author lwbco
    neural networks in perl are really the way to go
    {{ DiscussionBoard.errors[4447865].message }}
    • Profile picture of the author Bofu2U
      Originally Posted by lwbco View Post

      neural networks in perl are really the way to go
      I personally like to use neurals in Ruby but that's just me.
      {{ DiscussionBoard.errors[4447926].message }}
      • Profile picture of the author Rexibit
        Originally Posted by Bofu2U View Post

        I personally like to use neurals in Ruby but that's just me.
        He's wanting PHP though, so his server probably isn't equipped for Ruby. Nearly every Linux server runs PEARL, so he can use that to process the comment and then pass to PHP to generate output.
        {{ DiscussionBoard.errors[4447948].message }}
  • Profile picture of the author lwbco
    o yah i assumed this server would have been on windows, so you have to install perl either way.

    i guess for simplicity sake he could just wire it up to a webservice that makes lists of block decisions available by a HTTP interface? then all you have to do is curl the list, decode the data, check it against your posts, and publish away. PERL's CGI capabilities would be ideally suited for this.
    {{ DiscussionBoard.errors[4447968].message }}
  • Profile picture of the author Blacklisted
    use function, array variable. list all the badwords and disable all their value
    {{ DiscussionBoard.errors[4448052].message }}

Trending Topics