Index: trunk/extensions/CheckUser/CheckUser_body.php |
— | — | @@ -68,32 +68,20 @@ |
69 | 69 | $tag = $wgRequest->getBool('usetag') ? trim( $wgRequest->getVal( 'tag' ) ) : ""; |
70 | 70 | $talkTag = $wgRequest->getBool('usettag') ? trim( $wgRequest->getVal( 'talktag' ) ) : ""; |
71 | 71 | |
72 | | - # An IPv4? |
73 | | - if( preg_match( '#^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}(/\d{1,2}|)$#', $user ) ) { |
74 | | - $ip = $user; |
75 | | - $name = ''; |
| 72 | + # An IPv4? An IPv6? CIDR included? |
| 73 | + if( IP::isIPAddress($user) ) { |
| 74 | + $ip = IP::sanitizeIP($user); |
| 75 | + $name = ''; |
76 | 76 | $xff = ''; |
77 | | - # An IPv6? |
78 | | - } else if( preg_match( '#^[0-9A-Fa-f]{1,4}(:[0-9A-Fa-f]{1,4})+(/\d{1,3}|)$#', $user ) ) { |
79 | | - $ip = IP::sanitizeIP($user); |
80 | | - $name = ''; |
81 | | - $xff = ''; |
82 | | - # An IPv4 XFF string? |
83 | | - } else if( preg_match( '#^(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})(/\d{1,2}|)/xff$#', $user, $matches ) ) { |
84 | | - list( $junk, $xffip, $xffbit) = $matches; |
85 | | - $ip = ''; |
86 | | - $name = ''; |
87 | | - $xff = $xffip . $xffbit; |
88 | | - # An IPv6 XFF string? |
89 | | - } else if( preg_match( '#^([0-9A-Fa-f]{1,4}(:[0-9A-Fa-f]{1,4})+)(/\d{1,3}|)/xff$#', $user, $matches ) ) { |
90 | | - list( $junk, $xffip, $xffbit ) = $matches; |
91 | | - $ip = ''; |
92 | | - $name = ''; |
93 | | - $xff = IP::sanitizeIP( $xffip ) . $xffbit; |
| 77 | + # An IPv4/IPv6 XFF string? CIDR included? |
| 78 | + } else if( preg_match('/(.+)\/xff$/',$user,$m) && IP::isIPAddress($m[1]) ) { |
| 79 | + $ip = ''; |
| 80 | + $name = ''; |
| 81 | + $xff = IP::sanitizeIP($m[1]) . '/xff'; |
94 | 82 | # A user? |
95 | 83 | } else { |
96 | | - $ip = ''; |
97 | | - $name = $user; |
| 84 | + $ip = ''; |
| 85 | + $name = $user; |
98 | 86 | $xff = ''; |
99 | 87 | } |
100 | 88 | |
— | — | @@ -227,7 +215,7 @@ |
228 | 216 | $s .= '<textarea id="mw-checkuser-iplist" rows="5" cols="50" onkeyup="updateCIDRresult()" onclick="updateCIDRresult()"></textarea><br/>'; |
229 | 217 | $s .= wfMsgHtml('checkuser-cidr-res') . ' ' . |
230 | 218 | Xml::input( 'mw-checkuser-cidr-res',35,'',array('id'=>'mw-checkuser-cidr-res') ) . |
231 | | - '<span id="mw-checkuser-ipnote"></span>'; |
| 219 | + ' <strong id="mw-checkuser-ipnote"></strong>'; |
232 | 220 | $s .= '</fieldset>'; |
233 | 221 | $wgOut->addHTML( $s ); |
234 | 222 | } |
— | — | @@ -294,7 +282,7 @@ |
295 | 283 | $lastEditTime = $wgLang->time( wfTimestamp(TS_MW,$lastEdit), true ); |
296 | 284 | return wfMsgHtml( 'checkuser-nomatch-edits', $lastEditDate, $lastEditTime ); |
297 | 285 | } |
298 | | - return wfMsgHtml('checkuser-nomatch'); |
| 286 | + return wfMsgExt('checkuser-nomatch','parse'); |
299 | 287 | } |
300 | 288 | |
301 | 289 | /** |
Index: trunk/extensions/CheckUser/CheckUser.php |
— | — | @@ -34,7 +34,7 @@ |
35 | 35 | # Mass block limits |
36 | 36 | $wgCheckUserMaxBlocks = 200; |
37 | 37 | |
38 | | -$wgCheckUserStyleVersion = 3; |
| 38 | +$wgCheckUserStyleVersion = 4; |
39 | 39 | |
40 | 40 | # Recent changes data hook |
41 | 41 | global $wgHooks; |
Index: trunk/extensions/CheckUser/checkuser.js |
— | — | @@ -30,8 +30,6 @@ |
31 | 31 | // Go through each IP in the list, get it's binary form, and track |
32 | 32 | // the largest binary prefix among them |
33 | 33 | for( var i=0; i<ips.length; i++ ) { |
34 | | - // Rebuilt formatted bin_prefix for each IP |
35 | | - var prefix = ""; |
36 | 34 | // ...in the spirit of block.js, call this "addy" |
37 | 35 | var addy = ips[i]; |
38 | 36 | // Match the first IP in each list (ignore other garbage) |
— | — | @@ -39,6 +37,8 @@ |
40 | 38 | var ipV6 = addy.match(/(^|\b)(:(:[0-9A-Fa-f]{1,4}){1,7}|[0-9A-Fa-f]{1,4}(:{1,2}[0-9A-Fa-f]{1,4}|::$){1,7})(\/\d+)?\b/); |
41 | 39 | // Binary form |
42 | 40 | var bin = new String( "" ); |
| 41 | + // Rebuilt formatted bin_prefix for each IP |
| 42 | + if( ipV4 || ipV6 ) prefix = ''; |
43 | 43 | // Convert the IP to binary form: IPv4 |
44 | 44 | if( ipV4 ) { |
45 | 45 | var ip = ipV4[2]; |
— | — | @@ -77,7 +77,7 @@ |
78 | 78 | // CIDR too small? |
79 | 79 | if( prefix_cidr < 16 ) { |
80 | 80 | document.getElementById( 'mw-checkuser-cidr-res' ).value = "!"; |
81 | | - document.getElementById( 'mw-checkuser-ipnote' ).innerHTML = ''; |
| 81 | + document.getElementById( 'mw-checkuser-ipnote' ).innerHTML = ">"+Math.pow(2,32-prefix_cidr); |
82 | 82 | return; // too big |
83 | 83 | } |
84 | 84 | // Build the IP in dotted-quad form |
— | — | @@ -98,7 +98,22 @@ |
99 | 99 | // Convert the IP to binary form: IPv6 |
100 | 100 | } else if( ipV6 ) { |
101 | 101 | var ip = ipV6[2]; |
102 | | - var cidr = ipV6[3]; |
| 102 | + var cidr = ipV6[0].match( /\/\d+$/ ); |
| 103 | + var abbrevs = ip.match( /::/g ); |
| 104 | + if( abbrevs.length > 1 ) continue; // bad IP! |
| 105 | + // Expand out "::"s |
| 106 | + if( abbrevs.length > 0 ) { |
| 107 | + var colons = ip.match( /:/g ); |
| 108 | + var needed = 7 - (colons.length - 2); // 2 from "::" |
| 109 | + var insert = ''; |
| 110 | + while( needed > 1 ) { |
| 111 | + insert += ':0'; |
| 112 | + needed--; |
| 113 | + } |
| 114 | + ip = ip.replace( '::', insert + ':' ); |
| 115 | + // For IPs that start with "::", correct the final IP so that it starts with '0' and not ':' |
| 116 | + if( ip[0] == ':' ) ip = '0' + ip; |
| 117 | + } |
103 | 118 | // Get each hex octant |
104 | 119 | var blocs = ip.split(':'); |
105 | 120 | for( var x=0; x<=7; x++ ) { |
— | — | @@ -134,7 +149,7 @@ |
135 | 150 | // CIDR too small? |
136 | 151 | if( prefix_cidr < 96 ) { |
137 | 152 | document.getElementById( 'mw-checkuser-cidr-res' ).value = "!"; |
138 | | - document.getElementById( 'mw-checkuser-ipnote' ).innerHTML = ''; |
| 153 | + document.getElementById( 'mw-checkuser-ipnote' ).innerHTML = ">"+Math.pow(2,128-prefix_cidr); |
139 | 154 | return; // too big |
140 | 155 | } |
141 | 156 | // Build the IP in dotted-quad form |
— | — | @@ -148,11 +163,11 @@ |
149 | 164 | } |
150 | 165 | bloc = bloc.toString(16); // convert to hex |
151 | 166 | prefix += ( z == 7 ) ? bloc : bloc + ':'; |
152 | | - // Is the CIDR meaningful? |
153 | | - if( prefix_cidr == 128 ) prefix_cidr = false; |
154 | 167 | } |
155 | 168 | // Get IPs affected |
156 | 169 | ip_count = Math.pow(2,128-prefix_cidr); |
| 170 | + // Is the CIDR meaningful? |
| 171 | + if( prefix_cidr == 128 ) prefix_cidr = false; |
157 | 172 | } |
158 | 173 | } |
159 | 174 | // Update form |
— | — | @@ -162,7 +177,10 @@ |
163 | 178 | } else { |
164 | 179 | document.getElementById( 'mw-checkuser-cidr-res' ).value = prefix; |
165 | 180 | } |
166 | | - document.getElementById( 'mw-checkuser-ipnote' ).innerHTML = ' ~' + ip_count; |
| 181 | + document.getElementById( 'mw-checkuser-ipnote' ).innerHTML = '~' + ip_count; |
| 182 | + } else { |
| 183 | + document.getElementById( 'mw-checkuser-cidr-res' ).value = '?'; |
| 184 | + document.getElementById( 'mw-checkuser-ipnote' ).innerHTML = ''; |
167 | 185 | } |
168 | 186 | |
169 | 187 | } |