Index: trunk/extensions/CheckUser/CheckUser_body.php |
— | — | @@ -353,11 +353,14 @@ |
354 | 354 | $users_agentsets[$row->cuc_user_text][] = $row->cuc_agent; |
355 | 355 | } |
356 | 356 | } |
| 357 | + |
357 | 358 | # Reverse the order so it's first -> last |
358 | | - foreach( $users_infosets as $set ) |
359 | | - $set = array_reverse( $set ); |
360 | | - foreach( $users_agentsets as $set ) |
361 | | - $set = array_reverse( $set ); |
| 359 | + foreach( $users_infosets as $name => $set ) { |
| 360 | + $users_infosets[$name] = array_reverse( $set ); |
| 361 | + } |
| 362 | + foreach( $users_agentsets as $name => $set ) { |
| 363 | + $users_agentsets[$name] = array_reverse( $set ); |
| 364 | + } |
362 | 365 | |
363 | 366 | $logs = SpecialPage::getTitleFor( 'Log' ); |
364 | 367 | $s = '<ul>'; |
— | — | @@ -477,6 +480,8 @@ |
478 | 481 | $wgOut->addHTML( $s ); |
479 | 482 | return; |
480 | 483 | } |
| 484 | + |
| 485 | + $sk = $wgUser->getSkin(); |
481 | 486 | |
482 | 487 | if( !$this->addLogEntry( time() , $wgUser->getName() , |
483 | 488 | "got IPs for" , htmlspecialchars( $user ) , $wgDBname , $reason) ) |
— | — | @@ -499,6 +504,8 @@ |
500 | 505 | $ips_edits[$row->cuc_ip]+=1; |
501 | 506 | $ips_first[$row->cuc_ip]=$row->cuc_timestamp; |
502 | 507 | } |
| 508 | + |
| 509 | + $logs = SpecialPage::getTitleFor( 'Log' ); |
503 | 510 | $s = '<ul>'; |
504 | 511 | foreach( $ips_edits as $ip => $edits ) { |
505 | 512 | $s .= '<li>'; |
— | — | @@ -506,6 +513,22 @@ |
507 | 514 | $s .= ' (<a href="' . $blockip->escapeLocalURL( 'ip=' . urlencode( $ip ) ) . '">' . wfMsgHtml('blocklink') . '</a>)'; |
508 | 515 | $s .= ' (' . $wgLang->timeanddate( $ips_first[$ip], true ) . ' -- ' . $wgLang->timeanddate( $ips_last[$ip], true ) . ') '; |
509 | 516 | $s .= ' <strong>[' . $edits . ']</strong>'; |
| 517 | + |
| 518 | + # If this IP is blocked, give a link to the block log |
| 519 | + $block = new Block(); |
| 520 | + $block->fromMaster( false ); // use slaves |
| 521 | + if( $block->load( $ip, 0 ) ) { |
| 522 | + if( IP::isIPAddress($block->mAddress) && strpos($block->mAddress,'/') ) { |
| 523 | + $userpage = Title::makeTitle( NS_USER, $block->mAddress ); |
| 524 | + $blocklog = $sk->makeKnownLinkObj( $logs, wfMsgHtml('blockedtitle'), 'type=block&page=' . urlencode( $userpage->getPrefixedText() ) ); |
| 525 | + $s .= ' <strong>(' . $blocklog . ' - ' . $block->mAddress . ')</strong><br/>'; |
| 526 | + } else { |
| 527 | + $userpage = Title::makeTitle( NS_USER, $ip ); |
| 528 | + $blocklog = $sk->makeKnownLinkObj( $logs, wfMsgHtml('blockedtitle'), 'type=block&page=' . urlencode( $userpage->getPrefixedText() ) ); |
| 529 | + $s .= ' <strong>(' . $blocklog . ')</strong><br/>'; |
| 530 | + } |
| 531 | + } |
| 532 | + |
510 | 533 | $s .= '</li>'; |
511 | 534 | } |
512 | 535 | $s .= '</ul>'; |
Index: trunk/extensions/CheckUser/CheckUser.php |
— | — | @@ -42,6 +42,8 @@ |
43 | 43 | |
44 | 44 | $xff = wfGetForwardedFor(); |
45 | 45 | list($xff_ip,$trusted) = wfGetClientIPfromXFF( $xff ); |
| 46 | + // Our squid XFFs can flood this up sometimes |
| 47 | + $isSquidOnly = wfXFFChainIsSquid( $xff ); |
46 | 48 | |
47 | 49 | $agent = wfGetAgent(); |
48 | 50 | |
— | — | @@ -60,9 +62,9 @@ |
61 | 63 | 'cuc_type' => $rc_type, |
62 | 64 | 'cuc_timestamp' => $rc_timestamp, |
63 | 65 | 'cuc_ip' => $ip, |
64 | | - 'cuc_ip_hex' => ($ip) ? IP::toHex( $ip ) : null, |
65 | | - 'cuc_xff' => $xff, |
66 | | - 'cuc_xff_hex' => ($xff_ip) ? IP::toHex( $xff_ip ) : null, |
| 66 | + 'cuc_ip_hex' => $ip ? IP::toHex( $ip ) : null, |
| 67 | + 'cuc_xff' => !$isSquidOnly ? $xff : '', |
| 68 | + 'cuc_xff_hex' => ($xff_ip && !$isSquidOnly) ? IP::toHex( $xff_ip ) : null, |
67 | 69 | 'cuc_agent' => $agent, |
68 | 70 | ), __METHOD__ |
69 | 71 | ); |
— | — | @@ -117,6 +119,31 @@ |
118 | 120 | return array( $client, $trusted ); |
119 | 121 | } |
120 | 122 | |
| 123 | +function wfXFFChainIsSquid( $xff ) { |
| 124 | + global $wgSquidServers, $wgSquidServersNoPurge; |
| 125 | + |
| 126 | + if ( !$xff ) false; |
| 127 | + // Avoid annoyingly long xff hacks |
| 128 | + $xff = trim( substr( $xff, 0, 255 ) ); |
| 129 | + $squidOnly = true; |
| 130 | + // Check each IP, assuming they are separated by commas |
| 131 | + $ips = explode(',',$xff); |
| 132 | + foreach( $ips as $n => $ip ) { |
| 133 | + $ip = trim($ip); |
| 134 | + // If it is a valid IP, not a hash or such |
| 135 | + if ( IP::isIPAddress($ip) ) { |
| 136 | + if ( $n==0 ) { |
| 137 | + // The first IP should be the client... |
| 138 | + } else if ( !in_array($ip,$wgSquidServers) && !in_array($ip,$wgSquidServersNoPurge) ) { |
| 139 | + $squidOnly = false; |
| 140 | + break; |
| 141 | + } |
| 142 | + } |
| 143 | + } |
| 144 | + |
| 145 | + return $squidOnly; |
| 146 | +} |
| 147 | + |
121 | 148 | /** |
122 | 149 | * Tell the parser test engine to create a stub cu_changes table, |
123 | 150 | * or temporary pages won't save correctly during the test run. |