Extension:AbuseFilter/zh

滥用过滤器（AbuseFilter）扩展允许具有权限的用户设置当用户的操作（例如编辑）匹配特定标准时，要进行的特定動作.

例如，可以创建一个过滤器防止匿名用户添加外部链接或封禁移除超过2000个字符的用户.

用户权限
一旦您安装了此扩展，您将需要在"LocalSettings.php"设置用户权限.

举个例子，如果按照以下配置的话，管理员能对滥用过滤器做任何设定，而任何人都能查看过滤日志和已公开的过滤器过滤代码：

参数

 * 緊急限制

防濫用過濾器有個功能是能夠自動節流（停用）過濾器，當過濾器最近編輯過且符合最近操作的數量達到一定門檻時運作.

這麼做是為了防止對過濾器進行有害的編輯，而導致阻止所有用戶對Wiki進行操作.

停用過濾器的條件根據這些變數：
 * - 觀測期間內匹配數在操作總數中的百分比.
 * - 觀察期間內過濾器的匹配數.
 * - 進行評估的過濾器年齡. 如果過濾器的最後一次編輯時間早於該秒數，則不會對其進行限制，除非它已被限制.
 * - 最近操作中可計入閾值的最大數量. 请注意，每个操作都会增加一次计数，一旦计数器的计数达到此配置的顶值，此计数器计数和与所有筛选器匹配的最近操作的数量将重置为0.

被拦截过滤器的, 状态可以在的过滤器列表(Special:AbuseFilter)中查看. 拦截是无声的，我们没有办法看到过滤器何时被拦截.

当过滤器被拦截时，它不会执行任何危险的操作(在 中指定的操作)，并且只允许“安全”操作. 拦截过滤器不会自动启用. 若要禁用拦截，则需要编辑过滤器设置. 请注意，您实际上需要更改过滤器：从过滤器的注释中更改内容就可以了.

请注意，编辑过滤器将会更新它的历史，如果它再次达到上次编辑后的短时间内被拦截的条件，则会导致它被禁用，如果您的wiki比合法的编辑有更多的滥用，则会导致无法使用的过滤器. 如果操作计数达到 ，则过滤器也会被随机拦截，导致所有过滤器匹配计数重置为0，之后会有人重复触发过滤器.

创建和管理过滤器
当安装好本插件，通过滥用管理器管理页Special:AbuseFilter查看过滤日志和创建、修改、测试、删除过滤器.

全域规则 优化过滤器条件限制指南
 * 规则格式——如何写一段过滤器的基础知识
 * 注意
 * To import filters from Wikipedia: When you have installed the extension, go to w:Special:AbuseFilter, choose a filter (say w:Special:AbuseFilter/3), then click "Export this filter to another wiki", copy the text, go to "Special:AbuseFilter/import" on your wiki, paste the text.
 * m:Small wiki toolkits/Starter kit/AbuseFilter - Metawiki上針對小型Wiki的社區指南

API
滥用过滤器有两个API的list模块，一个用于获得过滤器列表（“abusefilters”），另一个用于获得过滤日志. 过滤日志是孤立于其他MediaWiki日志的（日志名为“abuselog”）. 不能通过API创建或修改滥用过滤器.

list = abusefilters
列出关于过滤器的信息


 * 参数:
 * - 从该过滤器ID开始列举
 * - 列举到该过滤器ID为止
 * - 列举的方向（older、newer）
 * - 只显示符合对应属性的过滤器（enabled|!enabled|deleted|!deleted|private|!private）
 * - 每次列举最大数量
 * - 欲获取的属性（id|description|pattern|actions|hits|comments|lasteditor|lastedittime|status|private）

如果过滤器是非公开的且您没有查看它的权限， 中某些参数则不会显示.


 * 例子:

list = abuselog
列出过滤器的触发日志.


 * 参数:
 * - 从该时间戳开始列举
 * - 列举到该时间戳为止
 * - 列举的方向（older、newer）
 * - 只显示该用户或IP地址触发过滤器的日志.
 * - 只显示该页面中触发过滤器的日志.
 * - 只显示该过滤器ID的触发日志
 * - 每次列举最大数量
 * - 欲获取的属性（ids|user|title|action|result|timestamp|details） (ids|filter|user|ip|title|action|details|result|timestamp|hidden|revid|wiki)


 * 例子:

可能的错误

 * Some users might experience that creating new filters or modifying old filters fail and the user just gets redirected to the original page. If the Wiki is using SSL certificates, this error could possibly be because of the value, which might be using "http://" instead of "https://". An indication of this error will be, the browser giving https warning for Special:AbuseFilter pages. (Topic:T23dyyih0ofjada5)

結合其他扩展
您可以通過多種方式將防濫用過濾器與其他擴展整合.

添加用於過濾的變數
It is possible to add new variables, to be used in abuse filters. A list of examples. To do that, you should:


 * Add a handler for the hook. To add a variable, you should use , where   is the name of the variable, and   is the fragment of an i18n key. The full key will be.
 * Add the i18n messages you chose at the previous point.
 * Choose a hook handler where the variable will be computed. Depending on your use case, you could:
 * Implement the hook; this is specifically thought for page-related variables;
 * Implement the hook; this is specifically thought for user-related variables;
 * Implement the hook; this is for variables not bound to a specific page or user;
 * Implement the hook; this is a bit more flexible than the other hooks, but it has a downside: your variable will not be available when examining past RecentChanges entries. If you want to implement that feature (and it's recommended to do so), you should use one of the hooks listed above, and use its third parameter.
 * Inside the hook handler, there are two ways to add a variable:
 * The "direct" way is calling . This is ideal only when the value is easy and quick to compute: the value is computed even if no active filter will use it.
 * The "lazy" way is calling . Here, 'method_name' is a (unique) identifier that will be used to compute the variable (it's recommended to prefix it with the name of your extension). To register the method, you should add a handler for the  hook; therein, you should check if the $method passed matches your 'method_name', and if so, compute the variable. Lastly, $params is an array of parameters that you'll need to compute the variable; these are passed to the computeVariable hook handler. For an example of this, you can check out CentralAuth's.

添加規則組
You can also add extra rule groups, which can be used to group existing abuse filters. Note that, at the moment, each filter can only be in a single group (T116642). Currently, the only known consumer of this feature is Extension:StructuredDiscussions. To do that, you should:


 * Append the name of the group to
 * Add some code to run the filters with your group. Note that AbuseFilter won't do that on its own. To do that, you should construct an  object, passing in the name of your group.

参见

 * 多个启用此擴展的WMF維基（以及使用的配置）