MediaWiki REL1_28
|
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. | |
static | makeLikeArray ( $filterEntry, $protocol='http://') |
Make an array to be used for calls to Database::buildLike(), which will match the specified string. | |
static | matchEntry (Content $content, $filterEntry) |
Check whether $content contains a link to $filterEntry. | |
Static Private Member Functions | |
static | makeRegex ( $filterEntry) |
Builds a regex pattern for $filterEntry. | |
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 33 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 177 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 94 of file LinkFilter.php.
References as, 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 63 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 42 of file LinkFilter.php.
References $content, and makeRegex().
Referenced by CleanupSpam\cleanupArticle().