94 if ( IPUtils::isValid( $target->getName() ) ) {
99 } elseif ( $target ===
null ) {
100 return [
null, null ];
103 $target = trim( $target );
105 if ( IPUtils::isValid( $target ) ) {
107 UserIdentityValue::newAnonymous( IPUtils::sanitizeIP( $target ) ),
111 } elseif ( IPUtils::isValidRange( $target ) ) {
118 if ( strpos( $target,
'/' ) !==
false ) {
120 $target = explode(
'/', $target )[0];
123 if ( preg_match(
'/^#\d+$/', $target ) ) {
128 $userFromDB = $this->userIdentityLookup->getUserIdentityByName( $target );
129 if ( $userFromDB instanceof UserIdentity ) {
137 $canonicalName = $this->userNameUtils->getCanonical( $target );
138 if ( $canonicalName ) {
140 new UserIdentityValue( 0, $canonicalName ),
145 return [
null, null ];
156 list( $target,
$type ) = $this->parseBlockTarget( $value );
158 $status = Status::newGood( $target );
162 if ( !$target->isRegistered() ) {
171 list( $ip, $range ) = explode(
'/', $target,
'2' );
173 if ( IPUtils::isIPv4( $ip ) ) {
174 $status->merge( $this->validateIPv4Range( $range ) );
175 } elseif ( IPUtils::isIPv6( $ip ) ) {
176 $status->merge( $this->validateIPv6Range( $range ) );
179 $status->fatal(
'badipaddress' );
188 $status->fatal(
'badipaddress' );
203 $status =
Status::newGood();
204 $blockCIDRLimit = $this->options->get(
'BlockCIDRLimit' );
206 if ( $blockCIDRLimit[
'IPv4'] == 32 ) {
208 $status->
fatal(
'range_block_disabled' );
209 } elseif ( $range > 32 ) {
211 $status->fatal(
'ip_range_invalid' );
212 } elseif ( $range < $blockCIDRLimit[
'IPv4'] ) {
213 $status->fatal(
'ip_range_toolarge', $blockCIDRLimit[
'IPv4'] );
227 $status =
Status::newGood();
228 $blockCIDRLimit = $this->options->get(
'BlockCIDRLimit' );
230 if ( $blockCIDRLimit[
'IPv6'] == 128 ) {
232 $status->
fatal(
'range_block_disabled' );
233 } elseif ( $range > 128 ) {
235 $status->fatal(
'ip_range_invalid' );
236 } elseif ( $range < $blockCIDRLimit[
'IPv6'] ) {
237 $status->fatal(
'ip_range_toolarge', $blockCIDRLimit[
'IPv6'] );
wfEscapeWikiText( $text)
Escapes the given text so that it may be output using addWikiText() without any linking,...
if(ini_get('mbstring.func_overload')) if(!defined('MW_ENTRY_POINT'))
Pre-config setup: Before loading LocalSettings.php.
fatal( $message,... $parameters)
Add an error and set OK to false, indicating that the operation as a whole was fatal.
Generic operation result class Has warning/error list, boolean status and arbitrary value.