Index: trunk/phase3/includes/SpecialContributions.php |
— | — | @@ -71,12 +71,32 @@ |
72 | 72 | if ( $this->username == 'newbies' ) { |
73 | 73 | $max = $this->dbr->selectField( 'user', 'max(user_id)', false, 'make_sql' ); |
74 | 74 | $condition = 'rev_user >' . (int)($max - $max / 100); |
75 | | - } else if ( preg_match("/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\/(24|16)/", $this->username) ) { |
| 75 | + } else if ( IP::isIPv4( $this->username ) && preg_match("/\/(24|16)$/", $this->username, $matches) ) { |
76 | 76 | $abcd = explode( ".", $this->username ); |
77 | | - if( substr( $this->username, -2 ) == 24 ) $ipmask = $abcd[0] . '.' . $abcd[1] . '.' . $abcd[2] . '.%'; |
| 77 | + if( $matches[1] == 24 ) $ipmask = $abcd[0] . '.' . $abcd[1] . '.' . $abcd[2] . '.%'; |
78 | 78 | else $ipmask=$abcd[0] . '.' . $abcd[1] . '.%'; |
79 | 79 | $condition = 'rev_user_text LIKE ' . $this->dbr->addQuotes($ipmask); |
80 | | - } else if ( IP::isIPv6( $this->username ) ) { |
| 80 | + } else if ( IP::isIPv6( $this->username ) && preg_match("/^(64|80|96|112)$/", $this->username) ) { |
| 81 | + $abcdefgh = explode( ":", IP::sanitizeIP($this->username) ); |
| 82 | + $abcd = implode( ":", array_slice($abcdefgh, 0, 4) ); |
| 83 | + switch( $matches[1] ) { |
| 84 | + case '112': |
| 85 | + $ipmask = $abcd . ':' . $abcd[4] . ':' . $abcd[5] . ':' . $abcd[6] . ':%'; |
| 86 | + break; |
| 87 | + case '96': |
| 88 | + $ipmask = $abcd . ':' . $abcd[4] . ':' . $abcd[5] . ':%'; |
| 89 | + break; |
| 90 | + case '80': |
| 91 | + $ipmask = $abcd . ':' . $abcd[4] . ':%'; |
| 92 | + break; |
| 93 | + case '64': |
| 94 | + $ipmask = $abcd . ':%'; |
| 95 | + break; |
| 96 | + } |
| 97 | + $condition = 'rev_user_text LIKE ' . $this->dbr->addQuotes($ipmask); |
| 98 | + } |
| 99 | + |
| 100 | + else if ( IP::isIPv6( $this->username ) ) { |
81 | 101 | # All stored IPs should be sanitized from now on, check for exact matches for reverse compatibility |
82 | 102 | $condition = '(rev_user_text=' . $this->dbr->addQuotes(IP::sanitizeIP($this->username)) . ' OR rev_user_text=' . $this->dbr->addQuotes($this->username) . ')'; |
83 | 103 | } |