Extension:AbuseFilter/zh

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

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

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

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

参数

 * 緊急限制

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

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

停用過濾器的條件根據這些變數：
 * - 觀測期間內匹配數在操作總數中的百分比.
 * - 觀察期間內過濾器的匹配數.
 * - 進行評估的過濾器年齡. 如果過濾器的最後一次編輯時間早於該秒數，則不會對其進行限制，除非它已被限制.
 * - 最近操作中可計入閾值的最大數量. Note that each action increments a counter, and once this counter reaches this configured value, this counter and the number of recent actions that matches all filters are reset to 0.

Throttled filters can be identified in the list of filters (Special:AbuseFilter) with the state,. Throttling happens silently, and there's no way to see when a filter got throttled.

When a filter gets throttled, it doesn't perform any dangerous action (the ones specified in ), and only "safe" actions are allowed. Throttled filters don't get enabled automatically. To disable the throttling, you need to edit the filter. Note that you need to actually change something from the filter: changing somethin from the filter's notes is sufficient.

Note that editing the filter updates its age, and can cause it to be disabled if it reaches again the conditions to be throttled in a short period since the last edit, leading to a unusable filter if your wiki has more abuse edits than legitimate ones. Filters can also get randomly throttled if the action count reaches, causing all filter matches count to reset to 0, and then someone repeatedly makes a filter to hit.

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


 * 规则格式——如何写一段过滤器的基础
 * 動作
 * 全域规则
 * 关于比较操作上限的指导手册
 * 要从维基百科导入过滤器：当您安装此扩展后，前往w:zh:Special:AbuseFilter选择一个过滤器（例如w:zh:Special:AbuseFilter/3），然后点击“导出此过滤器至其他wiki”，复制文本，前往您wiki的“Special:AbuseFilter/import”，粘贴文本.

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）


 * 例子:

可能的错误

 * 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 AbuseFilter-builder 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 AbuseFilter-generateTitleVars hook; this is specifically thought for page-related variables;
 * Implement the AbuseFilter-generateUserVars hook; this is specifically thought for user-related variables;
 * Implement the AbuseFilter-generateStaticVars hook; this is specifically thought for "static" variables, i.e. variables whose value shouldn't depend on the context. This is rarely useful;
 * Implement the AbuseFilterAlterVariables 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 AbuseFilter-computeVariable 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.

Adding rule groups
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 Flow. 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維基（以及使用的配置）