r39242 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r39241‎ | r39242 | r39243 >
Date:20:33, 12 August 2008
Author:aaron
Status:old
Tags:
Comment:
List recent account creation count (related to bug 14189)
Modified paths:
  • /trunk/extensions/CheckUser/CheckUser.i18n.php (modified) (history)
  • /trunk/extensions/CheckUser/CheckUser_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CheckUser/CheckUser_body.php
@@ -466,9 +466,10 @@
467467 } else if( isset($rangecount) && !$rangecount ) {
468468 $s = wfMsgHtml("checkuser-nomatch")."\n";
469469 $wgOut->addHTML( $s );
470 -
471470 return;
472 - }
 471+ }
 472+
 473+ global $wgMemc;
473474 # OK, do the real query...
474475 $use_index = $dbr->useIndexClause( $index );
475476 $sql = "SELECT cuc_user_text, cuc_timestamp, cuc_user, cuc_ip, cuc_agent, cuc_xff
@@ -477,7 +478,6 @@
478479 $ret = $dbr->query( $sql, __METHOD__ );
479480
480481 $users_first = $users_last = $users_edits = $users_ids = array();
481 -
482482 if( !$dbr->numRows( $ret ) ) {
483483 $s = wfMsgHtml( "checkuser-nomatch" )."\n";
484484 } else {
@@ -506,7 +506,7 @@
507507 }
508508 }
509509 $dbr->freeResult( $ret );
510 -
 510+
511511 $logs = SpecialPage::getTitleFor( 'Log' );
512512 $blocklist = SpecialPage::getTitleFor( 'Ipblocklist' );
513513 $s = '<ul>';
@@ -522,32 +522,42 @@
523523 ' -- ' . $wgLang->timeanddate( $users_last[$name], true ) . ') ';
524524 }
525525 $s .= ' [<strong>' . $count . '</strong>]<br />';
 526+ $flags = array();
526527 # Check if this user or IP is blocked. If so, give a link to the block log...
527528 $block = new Block();
528529 $block->fromMaster( false ); // use slaves
529 - $ip = IP::isIPAddress( $name ) ? $name : ''; // only check IP blocks if we have an IP
 530+ $ip = IP::isIPAddress( $name ) ? // If an account, get last IP
 531+ $name : $users_infosets[$name][count($users_infosets[$name])-1][0];
530532 if( $block->load( $ip, $users_ids[$name] ) ) {
531533 if( IP::isIPAddress($block->mAddress) && strpos($block->mAddress,'/') ) {
532534 $userpage = Title::makeTitle( NS_USER, $block->mAddress );
533535 $blocklog = $this->sk->makeKnownLinkObj( $logs, wfMsgHtml('checkuser-blocked'),
534536 'type=block&page=' . urlencode( $userpage->getPrefixedText() ) );
535 - $s .= ' <strong>(' . $blocklog . ' - ' . $block->mAddress . ')</strong>';
 537+ $flags[] = '<strong>(' . $blocklog . ' - ' . $block->mAddress . ')</strong>';
536538 } else if( $block->mAuto ) {
537539 $blocklog = $this->sk->makeKnownLinkObj( $blocklist,
538540 wfMsgHtml('checkuser-blocked'), 'ip=' . urlencode( "#$block->mId" ) );
539 - $s .= ' <strong>(' . $blocklog . ')</strong>';
 541+ $flags[] = '<strong>(' . $blocklog . ')</strong>';
540542 } else {
541543 $userpage = Title::makeTitle( NS_USER, $name );
542544 $blocklog = $this->sk->makeKnownLinkObj( $logs, wfMsgHtml('checkuser-blocked'),
543545 'type=block&page=' . urlencode( $userpage->getPrefixedText() ) );
544 - $s .= '<strong>(' . $blocklog . ')</strong>';
 546+ $flags[] = '<strong>(' . $blocklog . ')</strong>';
545547 }
546548 } else if( self::userWasBlocked( $name ) ) {
547549 $userpage = Title::makeTitle( NS_USER, $name );
548550 $blocklog = $this->sk->makeKnownLinkObj( $logs, wfMsgHtml('checkuser-wasblocked'),
549551 'type=block&page=' . urlencode( $userpage->getPrefixedText() ) );
550 - $s .= '<strong>(' . $blocklog . ')</strong>';
 552+ $flags[] = '<strong>(' . $blocklog . ')</strong>';
551553 }
 554+ # Check how many accounts the user made recently?
 555+ if( $ip ) {
 556+ $key = wfMemcKey( 'acctcreate', 'ip', $ip );
 557+ $count = intval( $wgMemc->get( $key ) );
 558+ if( $count ) {
 559+ $flags[] = '<strong>[' . wfMsgHtml('checkuser-accounts',$count) . ']</strong>';
 560+ }
 561+ }
552562 # Check for extra user rights...
553563 if( $users_ids[$name] ) {
554564 $user = User::newFromId( $users_ids[$name] );
@@ -557,9 +567,10 @@
558568 }
559569 $groups = implode( ', ', $list );
560570 if( $groups ) {
561 - $s .= '&nbsp;(' . $groups . ')';
 571+ $flags[] = '<i>(' . $groups . ')</i>';
562572 }
563573 }
 574+ $s .= implode(' ',$flags);
564575 $s .= '<ol>';
565576 # List out each IP/XFF combo for this username
566577 for( $i = (count($users_infosets[$name]) - 1); $i >= 0; $i-- ) {
@@ -583,7 +594,6 @@
584595 # List out each agent for this username
585596 for( $i = (count($users_agentsets[$name]) - 1); $i >= 0; $i-- ) {
586597 $agent = $users_agentsets[$name][$i];
587 - # IP link
588598 $s .= "<li><i>" . htmlspecialchars($agent) . "</i></li>\n";
589599 }
590600 $s .= '</ol>';
Index: trunk/extensions/CheckUser/CheckUser.i18n.php
@@ -35,6 +35,7 @@
3636 'checkuser-nolog' => 'No log file found.',
3737 'checkuser-blocked' => 'Blocked',
3838 'checkuser-wasblocked' => 'Previously blocked',
 39+ 'checkuser-accounts' => '$1 new accounts',
3940 'checkuser-too-many' => 'Too many results, please narrow down the CIDR.
4041 Here are the IPs used (5000 max, sorted by address):',
4142 'checkuser-user-nonexistent' => 'The specified user does not exist.',

Status & tagging log