• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.
[fgX] Advanced Censoring

[fgX] Advanced Censoring [Paid] 1.1.1

No permission to buy ($6.00)

farang

Well-known member
#1
farang submitted a new resource:

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

XenForo has a nice built in function to censor words when displaying messages. Unlike the XenForo word censoring function, the replacements made by this versatile add-on is permanently committed into posted messages. The replacement is occurring at the moment when someone makes a post.

The benefits of using a regular expression instead of a fixed word is that the possibilities are vast. A regular expression is a compact way of describing sets of strings which conform to a pattern.

For...
Read more about this resource...
 

farang

Well-known member
#3
Would be great to see some example configurations.
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
 

Mouth

Well-known member
#4
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?
 

farang

Well-known member
#5
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?
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()

;)
 
#9
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
 

farang

Well-known member
#10
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
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. ;)
 
#11
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.
 

semprot

Active member
#12
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.
* Try to test in test installation first * :)

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

farang

Well-known member
#15
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.
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
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
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.
 
#18
This looks like it can do what I need, but to make sure, here is what I need.

I would like to replace the following (example name used):

OK Corral with OK CORRAL
OKCorral with OK CORRAL
OKcorral with OK CORRAL
okcorral with OK CORRAL

Basically any version of okcorral or ok corral to OK CORRAL using all caps - except I do NOT want to change URL versions of okcorral.com to OK CORRAL.com, which is the issue I have now with the stock version of XF censoring replacement.

Any version of the URL needs to be okcorral.com - all lowercase and all NON-url versions need to be OK CORRAL - all uppercase.

Can this be accomplished with this add-on? I might have to pay someone to help me with the coding.

Thanks!