if ( $this->username == 'newbies' ) {
$max = $this->dbr->selectField( 'user', 'max(user_id)', false, 'make_sql' );
$condition = 'rev_user >' . (int)($max - $max / 100);
- } else if ( preg_match("/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\/(24|16)/", $this->username) ) {
+ } else if ( IP::isIPv4( $this->username ) && preg_match("/\/(24|16)$/", $this->username, $matches) ) {
$abcd = explode( ".", $this->username );
- if( substr( $this->username, -2 ) == 24 ) $ipmask = $abcd[0] . '.' . $abcd[1] . '.' . $abcd[2] . '.%';
+ if( $matches[1] == 24 ) $ipmask = $abcd[0] . '.' . $abcd[1] . '.' . $abcd[2] . '.%';
else $ipmask=$abcd[0] . '.' . $abcd[1] . '.%';
$condition = 'rev_user_text LIKE ' . $this->dbr->addQuotes($ipmask);
+ } else if ( IP::isIPv6( $this->username ) && preg_match("/^(64|80|96|112)$/", $this->username) ) {
+ $abcdefgh = explode( ":", IP::sanitizeIP($this->username) );
+ $abcd = implode( ":", array_slice($abcdefgh, 0, 4) );
+ switch( $matches[1] ) {
+ case '112':
+ $ipmask = $abcd . ':' . $abcd[4] . ':' . $abcd[5] . ':' . $abcd[6] . ':%';
+ break;
+ case '96':
+ $ipmask = $abcd . ':' . $abcd[4] . ':' . $abcd[5] . ':%';
+ break;
+ case '80':
+ $ipmask = $abcd . ':' . $abcd[4] . ':%';
+ break;
+ case '64':
+ $ipmask = $abcd . ':%';
+ break;
+ }
+ $condition = 'rev_user_text LIKE ' . $this->dbr->addQuotes($ipmask);
+ }
+
+ else if ( IP::isIPv6( $this->username ) ) {
+ # All stored IPs should be sanitized from now on, check for exact matches for reverse compatibility
+ $condition = '(rev_user_text=' . $this->dbr->addQuotes(IP::sanitizeIP($this->username)) . ' OR rev_user_text=' . $this->dbr->addQuotes($this->username) . ')';
}
if ( $condition == '' ) {
$use_index = $this->dbr->useIndexClause( $index );
$sql = 'SELECT ' .
'page_namespace,page_title,page_is_new,page_latest,'.
- 'rev_id,rev_page,rev_text_id,rev_timestamp,rev_comment,rev_minor_edit,rev_user,rev_user_text,'.
- 'rev_deleted ' .
- "FROM $page,$revision $use_index " .
+ join(',', Revision::selectFields()).
+ " FROM $page,$revision $use_index " .
"WHERE page_id=rev_page AND $userCond $nscond $offsetQuery " .
'ORDER BY rev_timestamp DESC';
$sql = $this->dbr->limitResult( $sql, $this->limit, 0 );
$wgOut->addHTML( "</ul>\n" );
$wgOut->addHTML( "<p>{$prevnextbits}</p>\n" );
+
+ # If there were contributions, and it was a valid user or IP, show
+ # the appropriate "footer" message - WHOIS tools, etc.
+ if( count( $contribs ) > 0 && $target != 'newbies' && $nt instanceof Title ) {
+ $message = IP::isIPAddress( $target )
+ ? 'sp-contributions-footer-anon'
+ : 'sp-contributions-footer';
+ $text = wfMsg( $message, $target );
+ if( !wfEmptyMsg( $message, $text ) && $text != '-' ) {
+ $wgOut->addHtml( '<div class="mw-contributions-footer">' );
+ $wgOut->addWikiText( wfMsg( $message, $target ) );
+ $wgOut->addHtml( '</div>' );
+ }
+ }
+
}
/**
Xml::element( 'legend', array(), wfMsg( 'sp-contributions-search' ) ) .
Xml::radioLabel( wfMsgExt( 'sp-contributions-newbies', array( 'parseinline' ) ), 'newbie' , 'contribs-newbie' , 'contribs-newbie', 'contribs-newbie' ) . '<br />' .
Xml::radioLabel( wfMsgExt( 'sp-contributions-username', array( 'parseinline' ) ), 'newbie' , 'contribs-all', 'contribs-all', 'contribs-all' ) . ' ' .
- Xml::input( 'target', 20, $options['target']) . ' '.
+ Xml::input( 'target', 30, $options['target']) . ' '.
Xml::label( wfMsg( 'namespace' ), 'namespace' ) .
Xml::namespaceSelector( $options['namespace'], '' ) .
Xml::submitButton( wfMsg( 'sp-contributions-submit' ) ) .