Extension:TitleBlacklist/zh

使用标题黑名单扩展，维基管理员可以以若干条正则表达式的形式来设立一个标题黑名单. 如果一个页面的标题与黑名单中的规则相匹配，用户将不能创建此页面、上传文件至此页面，或将其他页面移动至此页面. 此外，该扩展程序还能设立用户名黑名单，阻止用户创建特定名称的新用户.

配置

 * Array of title blacklist sources.
 * Should be in array( name => source description ) format.
 * Should be in array( name => source description ) format.


 * Sets the sources which may work as a username filter.
 * '*' is for all; false disables all.
 * If you want to limit it to particular sources, use array( source name 1, source name 2 ). This may be useful when you have shared account creation system in order to avoid blacklist fragmentation.
 * If you want to limit it to particular sources, use array( source name 1, source name 2 ). This may be useful when you have shared account creation system in order to avoid blacklist fragmentation.


 * When true, logs on Special:Log/Titleblacklist all attempts of local account creation that match the blacklists. 默认为 . Note that even disabled, the log will still be visible for users groups with the  right.
 * When true, logs on Special:Log/Titleblacklist all attempts of local account creation that match the blacklists. 默认为 . Note that even disabled, the log will still be visible for users groups with the  right.




 * Also blocks account created automatically that match the blacklists. Defaults to.
 * Also blocks account created automatically that match the blacklists. Defaults to.

The Title blacklist can be gathered from multiple sources outside the local message. For configuring blacklist sources use code as described below:
 * 多个黑名单来源

参见问题T113864以获取详细信息

Blacklist
The title blacklist is found on the MediaWiki:Titleblacklist page.

This page consists of regular expressions, each on a separate line, for example:

 Foo  [Bb]ar #No one should create article about it

Each entry may also contain optional attributes, enclosed in  and separated with
 * autoconfirmed - also allows other autoconfirmed users (who are not administrators) to perform such actions
 * casesensitive - don't ignore case when checking title for being blacklisted
 * noedit - users are also unable to edit these pages
 * moveonly - forbid moves but allow ordinary creation (rev:35163)
 * newaccountonly - forbid creation of matching usernames, but allow page creation (rev:38977)
 * reupload - allow reuploads of existing blacklisted files (rev:33656)
 * errmsg - the name of the message that should be displayed instead of standard

If the extension is installed, you can also use the   attribute.

What is referred to here as regular expressions are not proper regular expressions, but rather subpatterns that are inserted into a hard-coded regular expression. i.e. the subpattern Foo from above would create a regular expression like /^Foo$/usi.

Underscores (" ") in regular expressions will be converted to spaces by the extension, because titles are matched against its text form ("Page title" instead of "Page_title").

白名单
There is also a whitelist at MediaWiki:Titlewhitelist. The blacklist is applied first, then the whitelist. So user input that matches an entry on the blacklist is blocked, except if it matches an entry on the whitelist. You don't have to configure anything in LocalSettings.php in order to use the whitelist. Some of the optional attributes listed above, for the blacklist, also work for the whitelist, e.g. casesensitive.

自定义

 * 警告消息

When an attempt to create a page is blocked due to a blacklisted title, a warning message is shown to the user. This can be customized via system messages
 * MediaWiki:Titleblacklist-forbidden-edit: for page creation and editing,
 * MediaWiki:Titleblacklist-forbidden-move: for page moves,
 * MediaWiki:Titleblacklist-forbidden-upload: for image uploads.
 * MediaWiki:Titleblacklist-forbidden-new-account: for new accounts

Custom messages can be defined by using the  attribute.

概念概览
The username for new accounts will be regarded by Titleblacklist differently to the way it regards new articles. Titleblacklist will prepend "User:" (or its localized equivalent) to the string that a user enters at  on the create account page. So when Titleblacklist is performing matches with your Regex's, as found on MediaWiki:Titleblacklist or MediaWiki:Titlewhitelist, it will match against "User:" +.

For example, imagine you want to block "jill" as a new user. Imagine you had a blacklist regex "jill.* " and a user enters "jill" as the username on the create account page. This will pass as the comparison Titleblacklist will make will be between "jill.*" (the regex) and "User:jill" (the constructed input string). These don't match and so "jill" is allowed (and you probably didn't intend this). To effect the intended block use a regex like ".*jill.* " or "User:jill.* " on MediaWiki:Titleblacklist.

If you want to block all users except for all those that do match a regex then block all users in MediaWiki:Titleblacklist and write the permissible regex in the MediaWiki:Titlewhitelist.

How to
If you would like to force all usernames, during account creation, to consist of exactly two names, space separated, with each name capitalized then do the following:

1. 安装TitleBlacklist.

2. 将以下内容添加至您的LocalSettings.php

3. 在https://www.example.com/mywiki/MediaWiki:Titleblacklist中添加

4. 在https://www.example.com/mywiki/MediaWiki:Titlewhitelist中添加

5. 在https://www.example.com/mywiki/MediaWiki:Titleblacklist-forbidden-new-account中编辑

 The user name "$2" has been blocked from creation. It matches the following blacklist entry:.

Please use a real name for the user name. User names need to be comprised of two names separated by a space. Each name must be capitalized.

E.g.:
 * "Mary Smith". OK.
 * "MarySmith". Invalid.
 * "Mary smith". Invalid.
 * "marysmith". Invalid.

User name creation (and article creation) blocking rules are controlled by MediaWiki:Titleblacklist and MediaWiki:Titlewhitelist. This message can be customized at MediaWiki:Titleblacklist-forbidden-new-account

Testing for matches
The API module action=titleblacklist can be used to test a title and action (e.g. edit, create, new-account) against the blacklist. Users with the 'tboverride' right should be sure to supply the  parameter.

For example, if the blacklist contained the filter:

.*(.)\1{10}.*  # Disallows eleven or more of the same character repeated in usernames

you could use an API request like {{ApiEx ",       "message": "titleblacklist-forbidden-new-account-invalid",        "line": ".*(.)\1{10}.* &lt;newaccountonly|errmsg=titleblacklist-forbidden-new-account-invalid&gt; # Disallows eleven or more of the same character repeated in usernames"    } } }}
 * p1=action=titleblacklist
 * p2=tbtitle=AAAAAAAAAAA
 * p3=tbaction=new-account
 * p4=tbnooverride=1
 * result=

If Scribunto is installed, TitleBlacklist allows for testing if particular titles and actions will match an entry in the blacklist using the  function. If a match is found, the details for the matched entry are returned.

For example, if the blacklist contained the filter:

.*(.)\1{10}.*  # Disallows eleven or more of the same character repeated in usernames

running the function:

would return the following table containing details about the matched entry:

Resources on regular expressions

 * Brief Introduction to Regular Expressions
 * https://web.archive.org/web/20050213032350/http://etext.lib.virginia.edu/services/helpsheets/unix/regex.html
 * The 30 Minute Regex. Tutorial
 * http://www.codeproject.com/Articles/9099/The-Minute-Regex-Tutorial
 * PHP: PCRE regex syntax, the syntax of regular expressions used by PHP &mdash; and therefore this extension
 * http://php.net/manual/en/reference.pcre.pattern.syntax.php

参见

 * Combating spam and combating vandalism.