父节点
9f7f68c854
当前提交
350eb81a41
|
@ -32,9 +32,7 @@
|
|||
}
|
||||
},
|
||||
"MessagesDirs": {
|
||||
"RNRSHook": [
|
||||
"i18n"
|
||||
]
|
||||
"RNRSHook": ["i18n"]
|
||||
},
|
||||
"manifest_version": 2
|
||||
}
|
|
@ -1,8 +1,6 @@
|
|||
{
|
||||
"@metadata": {
|
||||
"authors": [
|
||||
"Qiuwen Baike Contributors"
|
||||
]
|
||||
"authors": ["Qiuwen Baike Contributors"]
|
||||
},
|
||||
"rnrshook-desc": "Real-name registration interface.",
|
||||
"rnrshook-prefs-label": "Real-name registration: ",
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
{
|
||||
"@metadata": {
|
||||
"authors": [
|
||||
"Qiuwen Baike Contributors"
|
||||
]
|
||||
"authors": ["Qiuwen Baike Contributors"]
|
||||
},
|
||||
"rnrshook-desc": "{{desc|name=RNRS Hook|url=https://git.qiuwen.wiki/qiuwen/RNRSHook}}",
|
||||
"rnrshook-prefs-label": "Real-name registration: ",
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
{
|
||||
"@metadata": {
|
||||
"authors": [
|
||||
"Qiuwen Baike Contributors"
|
||||
]
|
||||
"authors": ["Qiuwen Baike Contributors"]
|
||||
},
|
||||
"rnrshook-desc": "实名制验证界面",
|
||||
"rnrshook-prefs-label": "实名制验证:",
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
{
|
||||
"@metadata": {
|
||||
"authors": [
|
||||
"Qiuwen Baike Contributors"
|
||||
]
|
||||
"authors": ["Qiuwen Baike Contributors"]
|
||||
},
|
||||
"rnrshook-desc": "實名制認證介面",
|
||||
"rnrshook-prefs-label": "實名制認證:",
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
namespace MediaWiki\Extension\RNRSHook;
|
||||
|
||||
use MediaWiki\Extension\AbuseFilter\Hooks\AbuseFilterAlterVariablesHook;
|
||||
|
@ -9,14 +10,16 @@ use User;
|
|||
use RequestContext;
|
||||
use Wikimedia\IPUtils;
|
||||
|
||||
class AbuseFilterHooks implements AbuseFilterAlterVariablesHook, AbuseFilterBuilderHook {
|
||||
class AbuseFilterHooks implements AbuseFilterAlterVariablesHook, AbuseFilterBuilderHook
|
||||
{
|
||||
/**
|
||||
* Determine if a given IP is an internal server node
|
||||
*
|
||||
* @param string|null $ip The IP address to check, or null to use the request IP
|
||||
* @return bool True if an internal server node, false otherwise
|
||||
*/
|
||||
public static function isInternalNode( $ip = null ) {
|
||||
public static function isInternalNode($ip = null)
|
||||
{
|
||||
if ($ip == null) {
|
||||
$ip = RequestContext::getMain()->getRequest()->getIP();
|
||||
}
|
||||
|
@ -29,8 +32,7 @@ class AbuseFilterHooks implements AbuseFilterAlterVariablesHook, AbuseFilterBuil
|
|||
$low_ip_3 = '127.0.0.0';
|
||||
$high_ip_3 = '127.255.255.255';
|
||||
|
||||
$result = (
|
||||
version_compare ( $low_ip_1, IPUtils::sanitizeIP( $ip ) ) + version_compare( IPUtils::sanitizeIP( $ip ), $high_ip_1 ) === -2 ||
|
||||
$result = (version_compare($low_ip_1, IPUtils::sanitizeIP($ip)) + version_compare(IPUtils::sanitizeIP($ip), $high_ip_1) === -2 ||
|
||||
version_compare($low_ip_2, IPUtils::sanitizeIP($ip)) + version_compare(IPUtils::sanitizeIP($ip), $high_ip_2) === -2 ||
|
||||
version_compare($low_ip_3, IPUtils::sanitizeIP($ip)) + version_compare(IPUtils::sanitizeIP($ip), $high_ip_3) === -2
|
||||
);
|
||||
|
@ -41,7 +43,8 @@ class AbuseFilterHooks implements AbuseFilterAlterVariablesHook, AbuseFilterBuil
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function onAbuseFilterAlterVariables( VariableHolder &$vars, Title $title, User $user ) {
|
||||
public function onAbuseFilterAlterVariables(VariableHolder &$vars, Title $title, User $user)
|
||||
{
|
||||
$vars->setVar('internal_node', self::isInternalNode());
|
||||
return true;
|
||||
}
|
||||
|
@ -49,7 +52,8 @@ class AbuseFilterHooks implements AbuseFilterAlterVariablesHook, AbuseFilterBuil
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function onAbuseFilter_builder( array &$realValues ) {
|
||||
public function onAbuseFilter_builder(array &$realValues)
|
||||
{
|
||||
$realValues['vars']['internal_node'] = 'internal-node';
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -7,14 +7,16 @@ use OOUI\ButtonWidget;
|
|||
use OOUI\HorizontalLayout;
|
||||
use User;
|
||||
|
||||
class PreferencesHook implements GetPreferencesHook {
|
||||
class PreferencesHook implements GetPreferencesHook
|
||||
{
|
||||
/**
|
||||
* @param User $user
|
||||
* @param array &$preferences
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function onGetPreferences( $user, &$preferences ) {
|
||||
public function onGetPreferences($user, &$preferences)
|
||||
{
|
||||
$manageButton = new ButtonWidget([
|
||||
'href' => wfMessage('rnrshook-url')->text(),
|
||||
'label' => wfMessage('rnrshook-ui-manage')->text()
|
||||
|
|
正在加载...
在新工单中引用