X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Fspecials%2FSpecialContributions.php;h=5a5f005bafeeacd36129de2a39b22fb4d0df4f2b;hp=1b14fcbe10a9810b6da05b8488d3be845c6e4705;hb=d09554b6ef498a0182110427af6a5b0545de1293;hpb=f884d157f776afece12e0d986a8cd78574ed5335 diff --git a/includes/specials/SpecialContributions.php b/includes/specials/SpecialContributions.php index 1b14fcbe10..5a5f005baf 100644 --- a/includes/specials/SpecialContributions.php +++ b/includes/specials/SpecialContributions.php @@ -103,7 +103,12 @@ class SpecialContributions extends IncludableSpecialPage { 'pagetitle', $this->msg( 'contributions-title', $target )->plain() )->inContentLanguage() ); - $this->getSkin()->setRelevantUser( $userObj ); + + # For IP ranges, we want the contributionsSub, but not the skin-dependent + # links under 'Tools', which may include irrelevant links like 'Logs'. + if ( !IP::isValidRange( $target ) ) { + $this->getSkin()->setRelevantUser( $userObj ); + } } else { $out->addSubtitle( $this->msg( 'sp-contributions-newbies-sub' ) ); $out->setHTMLTitle( $this->msg( @@ -206,7 +211,12 @@ class SpecialContributions extends IncludableSpecialPage { 'associated' => $this->opts['associated'], ] ); - if ( !$pager->getNumRows() ) { + if ( IP::isValidRange( $target ) && !$pager->isQueryableRange( $target ) ) { + // Valid range, but outside CIDR limit. + $limits = $this->getConfig()->get( 'RangeContributionsCIDRLimit' ); + $limit = $limits[ IP::isIPv4( $target ) ? 'IPv4' : 'IPv6' ]; + $out->addWikiMsg( 'sp-contributions-outofrange', $limit ); + } elseif ( !$pager->getNumRows() ) { $out->addWikiMsg( 'nocontribs', $target ); } else { # Show a message about replica DB lag, if applicable @@ -223,11 +233,14 @@ class SpecialContributions extends IncludableSpecialPage { } $out->addHTML( $output ); } + $out->preventClickjacking( $pager->getPreventClickjacking() ); # Show the appropriate "footer" message - WHOIS tools, etc. if ( $this->opts['contribs'] == 'newbie' ) { $message = 'sp-contributions-footer-newbies'; + } elseif ( IP::isValidRange( $target ) ) { + $message = 'sp-contributions-footer-anon-range'; } elseif ( IP::isIPAddress( $target ) ) { $message = 'sp-contributions-footer-anon'; } elseif ( $userObj->isAnon() ) { @@ -258,8 +271,11 @@ class SpecialContributions extends IncludableSpecialPage { */ protected function contributionsSub( $userObj ) { if ( $userObj->isAnon() ) { - // Show a warning message that the user being searched for doesn't exists - if ( !User::isIP( $userObj->getName() ) ) { + // Show a warning message that the user being searched for doesn't exists. + // User::isIP returns true for IP address and usemod IPs like '123.123.123.xxx', + // but returns false for IP ranges. We don't want to suggest either of these are + // valid usernames which we would with the 'contributions-userdoesnotexist' message. + if ( !User::isIP( $userObj->getName() ) && !$userObj->isIPRange() ) { $this->getOutput()->wrapWikiMsg( "