1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

[fgX] Advanced Censoring [Paid] 1.1.1

Powerful post censoring using regular expressions.

  1. farang

    farang Well-Known Member

    farang submitted a new resource:

    [fgX] Advanced Censoring - Censoring posts using regular expressions. Helps prevent spam.

    Read more about this resource...
     
  2. Mouth

    Mouth Well-Known Member

    Would be great to see some example configurations.
     
    farang likes this.
  3. farang

    farang Well-Known Member

    hi @Mouth

    There are some samples provided in the plugin to help You get started. All of them are inactive (commented out) except one.

    Code:
    # Below are some sample pattern matching expressions.
    # Lines  preceded with a # sign are comments.
    
    # Remove mantra-like post text that ends with 2 line breaks followed by some
    # text that ends with 'alk'
    # Matching something like 'Sent from my D96-Phone using a cornstalk'
    "/\n{2}s.+alk$/i", ""
    
    # Replace all e-mail addresses with  the text  '[E-mail removed]'
    # (At this stage they are already BB-encoded)
    # "/\[EMAIL(.+?)\[\/EMAIL\]/i", "[E-mail removed]"
    
    # Replace all URLs to "somesite.com" with  the text  '[URL removed]'
    # "/\[URL(.+?)somesite\.com(.+?)\[\/URL\]/i", "[URL removed]"
    Another example:

    Code:
    # Match viagra, viaaggggra, via gra, via.gra, \/|AGRA, \/I/\GR/\, v1aqra, vi@gr@ and variants
    "/[v\\]+\/?.?[i:1!\|]+.?[a@\/]+\\?.?[gq]+.?r+.?[a@\/]+\\?/i", "[Medicin]"
    The example above is quite powerful since it can catch a lot of common alternative spellings of a word. Using the standard built in censoring would require hundreds of entries (probably thousands) to do the same thing. :D
     
  4. Mouth

    Mouth Well-Known Member

    Is there a regex generator or checker somewhere (site?) that you could suggest I can build and test regex expressions that I would likely use?
     
  5. farang

    farang Well-Known Member

    What we use is PCRE regular expressions. There are a few checker sites out there. I prefer https://regex101.com/
    But don't use the "g" modifier in your defined search patterns. It's implicit with preg_replace()

    ;)
     
  6. farang

    farang Well-Known Member

  7. semprot

    semprot Active Member

    @farang : does this work on 1.5.11?

    Thank you.
     
  8. farang

    farang Well-Known Member

    Hi! It's been tested at version 1.5 and up and there shall be no problem.
     
    Last edited: Nov 18, 2016
    semprot likes this.
  9. R3cK17

    R3cK17 New Member

    Will this prevent the censored word being visible in the bb code editor?
    For example: the XF Censor will cover the word only in rech text, you can quote/reply and the text is plainly visible.

    I am looking for something to fix that as it is the only problem I have with the XF integrated version, but also want it site-wide, so chat add-ons and private messages are still covered. Can this cover all of that?
    Regards
     
  10. farang

    farang Well-Known Member

    This add-on works only for new messages that gets posted. The replacement is permanently committed into posted messages. (It actually changes the posted text) The replacement is occurring at the moment when someone makes a post. I hope that helps. ;)
     
    R3cK17 likes this.
  11. suineg

    suineg Member

    So I have a regex that I want to do but I am not sure why it isn't working. I don't know a ton about regex so bear with me please.

    Code:
    /\W{3}(.*)\W{3}/
    That is the regex that I want to use. What it does is changes (((test words))) or any other kind of bracket and changes it to just the words only.

    The problem is when I use it as your format I don't know how to make it work.

    Code:
    "/\W{3}(.*)\W{3}/",""
    This of course just deletes it entirely. I think the two sides are conflicting but don't know how to resolve it.
     
  12. semprot

    semprot Active Member

    * Try to test in test installation first * :)

    Code:
    "/\W{3}(.*)\W{3}/","\\2"
     
  13. suineg

    suineg Member

    Thanks for the help, that just replaces (((text))) with \2.

    Not sure it allows regex in both sides?
     
  14. semprot

    semprot Active Member

    I am not sure too. Let's wait for the author :)
     
  15. farang

    farang Well-Known Member

    Hi @suineg

    I'm not really a "regex expert" and there are other guys much more talented than me.
    The two strings that you define are the pattern followed by the replacement.
    I've done some testing at https://regex101.com/ this morning
    I found out that something like
    Code:
    \(([^)]+)\) 
    might work as the pattern string. You can use capturing groups in the pattern string and can use a backreference to the captured data in the replacement string.

    The add-on is using the PHP function preg_replace which is used is documented at http://php.net/manual/en/function.preg-replace.php

    I think the guys at http://stackoverflow.com/ can assist You with a more accurate regex than I provided.
     
  16. suineg

    suineg Member

    The pattern string I had was fine on the site, it's the replacement string that is the issue.

    I will try research what a capturing group is.
     
  17. suineg

    suineg Member

    So this is working now.

    Code:
    "/\W{3}(.*)\W{3}/","$1"
    It strips anything preceded and followed by three special characters and leaves the text within alone.
     
    farang likes this.

Share This Page