MediaWiki
1.30.0
|
Some functions to help implement an external link filter for spam control. More...
Static Public Member Functions | |
static | keepOneWildcard ( $arr) |
Filters an array returned by makeLikeArray(), removing everything past first pattern placeholder. More... | |
static | makeLikeArray ( $filterEntry, $protocol='http://') |
Make an array to be used for calls to Database::buildLike(), which will match the specified string. More... | |
static | matchEntry (Content $content, $filterEntry) |
Check whether $content contains a link to $filterEntry. More... | |
Static Private Member Functions | |
static | makeRegex ( $filterEntry) |
Builds a regex pattern for $filterEntry. More... | |
Some functions to help implement an external link filter for spam control.
Another cool thing to do would be a web interface for fast spam removal.
Definition at line 34 of file LinkFilter.php.
|
static |
Filters an array returned by makeLikeArray(), removing everything past first pattern placeholder.
array | $arr | Array to filter |
Definition at line 178 of file LinkFilter.php.
Referenced by LinkSearchPage\getQueryInfo(), and ApiQueryBase\prepareUrlQuerySearchString().
|
static |
Make an array to be used for calls to Database::buildLike(), which will match the specified string.
There are several kinds of filter entry: *.domain.com - Produces http://com.domain.%, matches domain.com and www.domain.com domain.com - Produces http://com.domain./%, matches domain.com or domain.com/ but not www.domain.com *.domain.com/x - Produces http://com.domain.%/x%, matches www.domain.com/xy domain.com/x - Produces http://com.domain./x%, matches domain.com/xy but not www.domain.com/xy
Asterisks in any other location are considered invalid.
This function does the same as wfMakeUrlIndexes(), except it also takes care of adding wildcards
string | $filterEntry | Domainparts |
string | $protocol | Protocol (default http://) |
Definition at line 95 of file LinkFilter.php.
References as, captcha-old\count, DB_REPLICA, wfGetDB(), and wfParseUrl().
Referenced by CleanupSpam\execute(), LinkSearchPage\mungeQuery(), ApiQueryBase\prepareUrlQuerySearchString(), LinkFilterTest\testMakeLikeArrayWithInvalidPatterns(), and LinkFilterTest\testMakeLikeArrayWithValidPatterns().
|
staticprivate |
Builds a regex pattern for $filterEntry.
string | $filterEntry | URL, if it begins with "*.", it'll be replaced to match any subdomain |
Definition at line 64 of file LinkFilter.php.
Referenced by matchEntry().
|
static |
Check whether $content contains a link to $filterEntry.
Content | $content | Content to check |
string | $filterEntry | Domainparts, see makeRegex() for more details |
Definition at line 43 of file LinkFilter.php.
References Content\getNativeData(), and makeRegex().
Referenced by CleanupSpam\cleanupArticle().