Index: branches/wmf/1.19wmf1/includes/specials/SpecialBlock.php |
— | — | @@ -546,7 +546,7 @@ |
547 | 547 | * @return Bool|String |
548 | 548 | */ |
549 | 549 | public static function processForm( array $data, IContextSource $context ){ |
550 | | - global $wgBlockAllowsUTEdit; |
| 550 | + global $wgBlockAllowsUTEdit, $wgBlockCIDRLimit; |
551 | 551 | |
552 | 552 | $performer = $context->getUser(); |
553 | 553 | |
— | — | @@ -558,7 +558,14 @@ |
559 | 559 | $data['Confirm'] = !in_array( $data['Confirm'], array( '', '0', null, false ), true ); |
560 | 560 | |
561 | 561 | list( $target, $type ) = self::getTargetAndType( $data['Target'] ); |
| 562 | + ob_end_clean(); |
| 563 | + var_dump( compact( 'target', 'type' ) ); |
| 564 | + exit; |
562 | 565 | if( $type == Block::TYPE_USER ){ |
| 566 | + if( !$target->getId() ){ |
| 567 | + return array( array( 'nosuchusershort', $target->getName() ) ); |
| 568 | + } |
| 569 | + |
563 | 570 | $user = $target; |
564 | 571 | $target = $user->getName(); |
565 | 572 | $userId = $user->getId(); |
— | — | @@ -576,6 +583,30 @@ |
577 | 584 | return array( 'ipb-blockingself' ); |
578 | 585 | } |
579 | 586 | } elseif( $type == Block::TYPE_RANGE ){ |
| 587 | + list( $ip, $range ) = explode( '/', $target, 2 ); |
| 588 | + |
| 589 | + if( ( IP::isIPv4( $ip ) && $wgBlockCIDRLimit['IPv4'] == 32 ) |
| 590 | + || ( IP::isIPv6( $ip ) && $wgBlockCIDRLimit['IPV6'] == 128 ) ) |
| 591 | + { |
| 592 | + # Range block effectively disabled |
| 593 | + return array( 'range_block_disabled' ); |
| 594 | + } |
| 595 | + |
| 596 | + if( ( IP::isIPv4( $ip ) && $range > 32 ) |
| 597 | + || ( IP::isIPv6( $ip ) && $range > 128 ) ) |
| 598 | + { |
| 599 | + # Dodgy range |
| 600 | + return array( 'ip_range_invalid' ); |
| 601 | + } |
| 602 | + |
| 603 | + if( IP::isIPv4( $ip ) && $range < $wgBlockCIDRLimit['IPv4'] ) { |
| 604 | + return array( array( 'ip_range_toolarge', $wgBlockCIDRLimit['IPv4'] ) ); |
| 605 | + } |
| 606 | + |
| 607 | + if( IP::isIPv6( $ip ) && $range < $wgBlockCIDRLimit['IPv6'] ) { |
| 608 | + return array( array( 'ip_range_toolarge', $wgBlockCIDRLimit['IPv6'] ) ); |
| 609 | + } |
| 610 | + |
580 | 611 | $userId = 0; |
581 | 612 | } elseif( $type == Block::TYPE_IP ){ |
582 | 613 | $target = $target->getName(); |