MediaWiki 1.40.4
|
Some functions to help implement an external link filter for spam control. More...
Static Public Member Functions | |
static | getProtocolPrefix ( $protocol) |
static | getQueryConditions ( $filterEntry, array $options=[]) |
Return query conditions which will match the specified string. | |
static | keepOneWildcard ( $arr) |
Filters an array returned by makeLikeArray(), removing everything past first pattern placeholder. | |
static | makeIndexes ( $url) |
Converts a URL into a format for el_index. | |
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, $protocol='http://') |
Check whether $content contains a link to $filterEntry. | |
static | prepareProtocols () |
Public Attributes | |
const | VERSION = 1 |
Increment this when makeIndexes output changes. | |
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 43 of file LinkFilter.php.
|
static |
Definition at line 291 of file LinkFilter.php.
References MediaWiki\MediaWikiServices\getInstance(), and MediaWiki\MainConfigNames\UrlProtocols.
|
static |
Return query conditions which will match the specified string.
There are several kinds of filter entry:
*.domain.com - Matches domain.com and www.domain.com domain.com - Matches domain.com or domain.com/ but not www.domain.com *.domain.com/x - Matches domain.com/xy or www.domain.com/xy. Also probably matches domain.com/foobar/xy due to limitations of LIKE syntax. domain.com/x - Matches domain.com/xy but not www.domain.com/xy 192.0.2.* - Matches any IP in 192.0.2.0/24. Can also have a path appended. [2001:db8::*] - Matches any IP in 2001:db8::/112. Can also have a path appended. [2001:db8:*] - Matches any IP in 2001:db8::/32. Can also have a path appended. foo@domain.com - With protocol 'mailto:', matches the email address foo@domain.com. *@domain.com - With protocol 'mailto:', matches any email address at domain.com, but not subdomains like foo@mail.domain.com
Asterisks in any other location are considered invalid.
string | $filterEntry | Filter entry, as described above |
array | $options | Options are:
|
Definition at line 248 of file LinkFilter.php.
References DB_REPLICA, MediaWiki\ExternalLinks\LinkFilter\keepOneWildcard(), MediaWiki\ExternalLinks\LinkFilter\makeLikeArray(), and wfGetDB().
|
static |
Filters an array returned by makeLikeArray(), removing everything past first pattern placeholder.
array | $arr | Array to filter |
Definition at line 408 of file LinkFilter.php.
Referenced by MediaWiki\ExternalLinks\LinkFilter\getQueryConditions().
|
static |
Converts a URL into a format for el_index.
string | $url |
Definition at line 171 of file LinkFilter.php.
References wfParseUrl().
|
static |
Make an array to be used for calls to Database::buildLike(), which will match the specified string.
This function does the same as LinkFilter::makeIndexes(), except it also takes care of adding wildcards
string | $filterEntry | Filter entry, |
string | $protocol | Protocol (default http://) |
Definition at line 334 of file LinkFilter.php.
References DB_REPLICA, wfGetDB(), and wfParseUrl().
Referenced by MediaWiki\ExternalLinks\LinkFilter\getQueryConditions().
|
static |
Check whether $content contains a link to $filterEntry.
Content | $content | Content to check |
string | $filterEntry | Domainparts, see makeRegex() for more details |
string | $protocol | 'http://' or 'https://' |
Definition at line 58 of file LinkFilter.php.
References $content.
|
static |
Definition at line 309 of file LinkFilter.php.
References MediaWiki\MediaWikiServices\getInstance(), and MediaWiki\MainConfigNames\UrlProtocols.
const MediaWiki\ExternalLinks\LinkFilter::VERSION = 1 |
Increment this when makeIndexes output changes.
It'll cause maintenance/refreshExternallinksIndex.php to run from update.php.
Definition at line 48 of file LinkFilter.php.