r60361 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r60360‎ | r60361 | r60362 >
Date:14:06, 24 December 2009
Author:ashley
Status:ok (Comments)
Tags:
Comment:
CheckUser cleanup:
*spacing tweaks
*spaces -> tabs in indentation
*double quotes -> single quotes where appropriate
*doxygen tweaks
*moved a hardcoded colon from the code to i18n file
*added version number to Special:Version display
*else if -> elseif
*documented some variables
*marked special page construction and main function as public
*added some braces for readability
*removed an unused global
*bumped $wgCheckUserStyleVersion per js file changes
Modified paths:
  • /trunk/extensions/CheckUser/CheckUser.alias.php (modified) (history)
  • /trunk/extensions/CheckUser/CheckUser.i18n.php (modified) (history)
  • /trunk/extensions/CheckUser/CheckUser.php (modified) (history)
  • /trunk/extensions/CheckUser/CheckUser_body.php (modified) (history)
  • /trunk/extensions/CheckUser/checkuser.js (modified) (history)

Diff [purge]

Index: trunk/extensions/CheckUser/CheckUser_body.php
@@ -5,20 +5,22 @@
66 exit( 1 );
77 }
88
 9+class CheckUser extends SpecialPage {
910
10 -class CheckUser extends SpecialPage
11 -{
12 - function CheckUser() {
 11+ /**
 12+ * Constructor -- set up the new special page
 13+ */
 14+ public function __construct() {
1315 global $wgUser;
1416 if ( $wgUser->isAllowed( 'checkuser' ) || !$wgUser->isAllowed( 'checkuser-log' ) ) {
15 - SpecialPage::SpecialPage('CheckUser', 'checkuser');
 17+ parent::__construct( 'CheckUser', 'checkuser' );
1618 } else {
17 - SpecialPage::SpecialPage('CheckUser', 'checkuser-log');
 19+ parent::__construct( 'CheckUser', 'checkuser-log' );
1820 }
19 - wfLoadExtensionMessages('CheckUser');
 21+ wfLoadExtensionMessages( 'CheckUser' );
2022 }
2123
22 - function execute( $subpage ) {
 24+ public function execute( $subpage ) {
2325 global $wgRequest, $wgOut, $wgUser, $wgContLang;
2426
2527 $this->setHeaders();
@@ -61,25 +63,25 @@
6264
6365 $user = $wgRequest->getText( 'user' ) ?
6466 $wgRequest->getText( 'user' ) : $wgRequest->getText( 'ip' );
65 - $user = trim($user);
 67+ $user = trim( $user );
6668 $reason = $wgRequest->getText( 'reason' );
6769 $blockreason = $wgRequest->getText( 'blockreason' );
6870 $checktype = $wgRequest->getVal( 'checktype' );
6971 $period = $wgRequest->getInt( 'period' );
7072 $users = $wgRequest->getArray( 'users' );
71 - $tag = $wgRequest->getBool('usetag') ? trim( $wgRequest->getVal( 'tag' ) ) : "";
72 - $talkTag = $wgRequest->getBool('usettag') ? trim( $wgRequest->getVal( 'talktag' ) ) : "";
 73+ $tag = $wgRequest->getBool('usetag') ? trim( $wgRequest->getVal( 'tag' ) ) : '';
 74+ $talkTag = $wgRequest->getBool('usettag') ? trim( $wgRequest->getVal( 'talktag' ) ) : '';
7375
7476 # An IPv4? An IPv6? CIDR included?
75 - if( IP::isIPAddress($user) ) {
76 - $ip = IP::sanitizeIP($user);
 77+ if( IP::isIPAddress( $user ) ) {
 78+ $ip = IP::sanitizeIP( $user );
7779 $name = '';
7880 $xff = '';
7981 # An IPv4/IPv6 XFF string? CIDR included?
80 - } else if( preg_match('/^(.+)\/xff$/',$user,$m) && IP::isIPAddress($m[1]) ) {
 82+ } elseif( preg_match( '/^(.+)\/xff$/', $user, $m ) && IP::isIPAddress( $m[1] ) ) {
8183 $ip = '';
8284 $name = '';
83 - $xff = IP::sanitizeIP($m[1]);
 85+ $xff = IP::sanitizeIP( $m[1] );
8486 # A user?
8587 } else {
8688 $ip = '';
@@ -90,21 +92,21 @@
9193 $this->doForm( $user, $reason, $checktype, $ip, $xff, $name, $period );
9294 # Perform one of the various submit operations...
9395 if( $wgRequest->wasPosted() ) {
94 - if( $wgRequest->getVal('action') === 'block' ) {
 96+ if( $wgRequest->getVal( 'action' ) === 'block' ) {
9597 $this->doMassUserBlock( $users, $blockreason, $tag, $talkTag );
96 - } else if( !$this->checkReason($reason) ) {
97 - $wgOut->addWikiText( wfMsgExt('checkuser-noreason',array('parsemag')) );
98 - } else if( $checktype=='subuserips' ) {
 98+ } elseif( !$this->checkReason( $reason ) ) {
 99+ $wgOut->addWikiText( wfMsgExt( 'checkuser-noreason', array( 'parsemag' ) ) );
 100+ } elseif( $checktype == 'subuserips' ) {
99101 $this->doUserIPsRequest( $name, $reason, $period );
100 - } else if( $xff && $checktype=='subipedits' ) {
 102+ } elseif( $xff && $checktype == 'subipedits' ) {
101103 $this->doIPEditsRequest( $xff, true, $reason, $period );
102 - } else if( $checktype=='subipedits' ) {
 104+ } elseif( $checktype == 'subipedits' ) {
103105 $this->doIPEditsRequest( $ip, false, $reason, $period );
104 - } else if( $xff && $checktype=='subipusers' ) {
 106+ } elseif( $xff && $checktype == 'subipusers' ) {
105107 $this->doIPUsersRequest( $xff, true, $reason, $period, $tag, $talkTag );
106 - } else if( $checktype=='subipusers' ) {
 108+ } elseif( $checktype == 'subipusers' ) {
107109 $this->doIPUsersRequest( $ip, false, $reason, $period, $tag, $talkTag );
108 - } else if( $checktype=='subuseredits' ) {
 110+ } elseif( $checktype == 'subuseredits' ) {
109111 $this->doUserEditsRequest( $user, $reason, $period );
110112 }
111113 }
@@ -112,7 +114,7 @@
113115 $this->addJsCIDRForm();
114116 $this->addStyles();
115117 }
116 -
 118+
117119 /**
118120 * As we use the same small set of messages in various methods and that
119121 * they are called often, we call them once and save them in $this->message
@@ -120,8 +122,8 @@
121123 protected function preCacheMessages() {
122124 // Precache various messages
123125 if( !isset( $this->message ) ) {
124 - foreach( explode(' ', 'diff hist minoreditletter newpageletter blocklink log' ) as $msg ) {
125 - $this->message[$msg] = wfMsgExt( $msg, array( 'escape') );
 126+ foreach( explode( ' ', 'diff hist minoreditletter newpageletter blocklink log' ) as $msg ) {
 127+ $this->message[$msg] = wfMsgExt( $msg, array( 'escape' ) );
126128 }
127129 }
128130 }
@@ -138,19 +140,20 @@
139141 $action = $this->getTitle()->escapeLocalUrl();
140142 # Fill in requested type if it makes sense
141143 $encipusers = $encipedits = $encuserips = $encuseredits = 0;
142 - if( $checktype=='subipusers' && ( $ip || $xff ) )
 144+ if( $checktype == 'subipusers' && ( $ip || $xff ) ) {
143145 $encipusers = 1;
144 - else if( $checktype=='subipedits' && ( $ip || $xff ) )
 146+ } elseif( $checktype == 'subipedits' && ( $ip || $xff ) ) {
145147 $encipedits = 1;
146 - else if( $checktype=='subuserips' && $name )
 148+ } elseif( $checktype == 'subuserips' && $name ) {
147149 $encuserips = 1;
148 - else if( $checktype=='subuseredits' && $name )
 150+ } elseif( $checktype == 'subuseredits' && $name ) {
149151 $encuseredits = 1;
150152 # Defaults otherwise
151 - else if( $ip || $xff )
 153+ } elseif( $ip || $xff ) {
152154 $encipedits = 1;
153 - else
 155+ } else {
154156 $encuserips = 1;
 157+ }
155158 # Compile our nice form
156159 # User box length should fit things like "2001:0db8:85a3:08d3:1319:8a2e:0370:7344/100/xff"
157160 if( $wgUser->isAllowed( 'checkuser-log' ) ) {
@@ -160,87 +163,87 @@
161164 );
162165 }
163166 $form = "<form name='checkuserform' id='checkuserform' action=\"$action\" method='post'>";
164 - $form .= "<fieldset><legend>".wfMsgHtml( "checkuser-query" )."</legend>";
165 - $form .= "<table border='0' cellpadding='2'><tr>";
166 - $form .= "<td>".wfMsgHtml( "checkuser-target" ).":</td>";
167 - $form .= "<td>".Xml::input( 'user', 46, $user, array( 'id' => 'checktarget' ) );
168 - $form .= "&nbsp;".$this->getPeriodMenu( $period ) . "</td>";
169 - $form .= "</tr><tr>";
170 - $form .= "<td></td><td class='checkuserradios'><table border='0' cellpadding='3'><tr>";
171 - $form .= "<td>".Xml::radio( 'checktype', 'subuserips', $encuserips, array('id' => 'subuserips') );
172 - $form .= " ".Xml::label( wfMsgHtml("checkuser-ips"), 'subuserips' )."</td>";
173 - $form .= "<td>".Xml::radio( 'checktype', 'subipedits', $encipedits, array('id' => 'subipedits') );
174 - $form .= " ".Xml::label( wfMsgHtml("checkuser-edits"), 'subipedits' )."</td>";
175 - $form .= "<td>".Xml::radio( 'checktype', 'subipusers', $encipusers, array('id' => 'subipusers') );
176 - $form .= " ".Xml::label( wfMsgHtml("checkuser-users"), 'subipusers' )."</td>";
177 - $form .= "<td>".Xml::radio( 'checktype', 'subuseredits', $encuseredits, array('id' => 'subuseredits') );
178 - $form .= " ".Xml::label( wfMsgHtml("checkuser-account"), 'subuseredits' )."</td>";
179 - $form .= "</tr></table></td>";
180 - $form .= "</tr><tr>";
181 - $form .= "<td>".wfMsgHtml( "checkuser-reason" )."</td>";
182 - $form .= "<td>".Xml::input( 'reason', 46, $reason, array( 'maxlength' => '150', 'id' => 'checkreason' ) );
183 - $form .= "&nbsp; &nbsp;".Xml::submitButton( wfMsgHtml('checkuser-check'),
184 - array('id' => 'checkusersubmit','name' => 'checkusersubmit') )."</td>";
185 - $form .= "</tr></table></fieldset></form>";
 167+ $form .= '<fieldset><legend>' . wfMsgHtml( 'checkuser-query' ) . '</legend>';
 168+ $form .= '<table border="0" cellpadding="2"><tr>';
 169+ $form .= '<td>' . wfMsgHtml( 'checkuser-target' ) . '</td>';
 170+ $form .= '<td>' . Xml::input( 'user', 46, $user, array( 'id' => 'checktarget' ) );
 171+ $form .= '&nbsp;' . $this->getPeriodMenu( $period ) . '</td>';
 172+ $form .= '</tr><tr>';
 173+ $form .= '<td></td><td class="checkuserradios"><table border="0" cellpadding="3"><tr>';
 174+ $form .= '<td>' . Xml::radio( 'checktype', 'subuserips', $encuserips, array( 'id' => 'subuserips' ) );
 175+ $form .= ' ' . Xml::label( wfMsgHtml( 'checkuser-ips' ), 'subuserips' ) . '</td>';
 176+ $form .= '<td>' . Xml::radio( 'checktype', 'subipedits', $encipedits, array( 'id' => 'subipedits' ) );
 177+ $form .= ' ' . Xml::label( wfMsgHtml( 'checkuser-edits' ), 'subipedits' ) . '</td>';
 178+ $form .= '<td>' . Xml::radio( 'checktype', 'subipusers', $encipusers, array( 'id' => 'subipusers' ) );
 179+ $form .= ' ' . Xml::label( wfMsgHtml( 'checkuser-users' ), 'subipusers' ) . '</td>';
 180+ $form .= '<td>' . Xml::radio( 'checktype', 'subuseredits', $encuseredits, array( 'id' => 'subuseredits' ) );
 181+ $form .= ' ' . Xml::label( wfMsgHtml( 'checkuser-account' ), 'subuseredits' ) . '</td>';
 182+ $form .= '</tr></table></td>';
 183+ $form .= '</tr><tr>';
 184+ $form .= '<td>' . wfMsgHtml( 'checkuser-reason' ) . '</td>';
 185+ $form .= '<td>' . Xml::input( 'reason', 46, $reason, array( 'maxlength' => '150', 'id' => 'checkreason' ) );
 186+ $form .= '&nbsp; &nbsp;' . Xml::submitButton( wfMsgHtml( 'checkuser-check' ),
 187+ array( 'id' => 'checkusersubmit', 'name' => 'checkusersubmit' ) ) . '</td>';
 188+ $form .= '</tr></table></fieldset></form>';
186189 # Output form
187190 $wgOut->addHTML( $form );
188191 }
189 -
 192+
190193 /**
191 - * Add CSS/JS
192 - */
 194+ * Add CSS/JS
 195+ */
193196 protected function addStyles() {
194197 global $wgScriptPath, $wgCheckUserStyleVersion, $wgOut;
195198 $encJSFile = htmlspecialchars( "$wgScriptPath/extensions/CheckUser/checkuser.js?$wgCheckUserStyleVersion" );
196199 $wgOut->addScript( "<script type=\"text/javascript\" src=\"$encJSFile\"></script>" );
197200 }
198 -
199 - /**
200 - * Get a selector of time period options
201 - * @param int $selected, selected level
202 - */
203 - protected function getPeriodMenu( $selected=null ) {
204 - $s = "<label for='period'>" . wfMsgHtml('checkuser-period') . "</label>&nbsp;";
205 - $s .= Xml::openElement( 'select', array('name' => 'period','id' => 'period','style' => 'margin-top:.2em;') );
206 - $s .= Xml::option( wfMsg( "checkuser-week-1" ), 7, $selected===7 );
207 - $s .= Xml::option( wfMsg( "checkuser-week-2" ), 14, $selected===14 );
208 - $s .= Xml::option( wfMsg( "checkuser-month" ), 31, $selected===31 );
209 - $s .= Xml::option( wfMsg( "checkuser-all" ), 0, $selected===0 );
210 - $s .= Xml::closeElement('select')."\n";
 201+
 202+ /**
 203+ * Get a selector of time period options
 204+ * @param int $selected, selected level
 205+ */
 206+ protected function getPeriodMenu( $selected = null ) {
 207+ $s = '<label for="period">' . wfMsgHtml( 'checkuser-period' ) . '</label>&nbsp;';
 208+ $s .= Xml::openElement( 'select', array( 'name' => 'period', 'id' => 'period', 'style' => 'margin-top:.2em;' ) );
 209+ $s .= Xml::option( wfMsg( 'checkuser-week-1' ), 7, $selected === 7 );
 210+ $s .= Xml::option( wfMsg( 'checkuser-week-2' ), 14, $selected === 14 );
 211+ $s .= Xml::option( wfMsg( 'checkuser-month' ), 31, $selected === 31 );
 212+ $s .= Xml::option( wfMsg( 'checkuser-all' ), 0, $selected === 0 );
 213+ $s .= Xml::closeElement( 'select' ) . "\n";
211214 return $s;
212215 }
213 -
214 - /**
215 - * Make a quick JS form for admins to calculate block ranges
216 - */
 216+
 217+ /**
 218+ * Make a quick JS form for admins to calculate block ranges
 219+ */
217220 protected function addJsCIDRForm() {
218221 global $wgOut;
219 - $s = '<fieldset id="mw-checkuser-cidrform" style="display:none; clear:both;">'.
220 - '<legend>'.wfMsgHtml('checkuser-cidr-label').'</legend>';
 222+ $s = '<fieldset id="mw-checkuser-cidrform" style="display:none; clear:both;">' .
 223+ '<legend>' . wfMsgHtml( 'checkuser-cidr-label' ) . '</legend>';
221224 $s .= '<textarea id="mw-checkuser-iplist" rows="5" cols="50" onkeyup="updateCIDRresult()" onclick="updateCIDRresult()"></textarea><br />';
222 - $s .= wfMsgHtml('checkuser-cidr-res') . '&nbsp;' .
223 - Xml::input( 'mw-checkuser-cidr-res',35,'',array('id'=>'mw-checkuser-cidr-res') ) .
 225+ $s .= wfMsgHtml( 'checkuser-cidr-res' ) . '&nbsp;' .
 226+ Xml::input( 'mw-checkuser-cidr-res', 35, '', array( 'id' => 'mw-checkuser-cidr-res' ) ) .
224227 '&nbsp;<strong id="mw-checkuser-ipnote"></strong>';
225228 $s .= '</fieldset>';
226229 $wgOut->addHTML( $s );
227230 }
228 -
229 - /**
230 - * Block a list of selected users
231 - * @param array $users
232 - * @param string $reason
233 - * @param string $tag
234 - */
 231+
 232+ /**
 233+ * Block a list of selected users
 234+ * @param array $users
 235+ * @param string $reason
 236+ * @param string $tag
 237+ */
235238 protected function doMassUserBlock( $users, $reason = '', $tag = '', $talkTag = '' ) {
236239 global $wgOut, $wgUser, $wgCheckUserMaxBlocks, $wgLang;
237 - if( empty($users) || $wgUser->isBlocked(false) ) {
238 - $wgOut->addWikiText( wfMsgExt('checkuser-block-failure',array('parsemag')) );
 240+ if( empty( $users ) || $wgUser->isBlocked( false ) ) {
 241+ $wgOut->addWikiText( wfMsgExt( 'checkuser-block-failure', array( 'parsemag' ) ) );
239242 return;
240 - } else if( count($users) > $wgCheckUserMaxBlocks ) {
241 - $wgOut->addWikiText( wfMsgExt('checkuser-block-limit',array('parsemag')) );
 243+ } elseif( count( $users ) > $wgCheckUserMaxBlocks ) {
 244+ $wgOut->addWikiText( wfMsgExt( 'checkuser-block-limit', array( 'parsemag' ) ) );
242245 return;
243 - } else if( !$reason ) {
244 - $wgOut->addWikiText( wfMsgExt('checkuser-block-noreason',array('parsemag')) );
 246+ } elseif( !$reason ) {
 247+ $wgOut->addWikiText( wfMsgExt( 'checkuser-block-noreason', array( 'parsemag' ) ) );
245248 return;
246249 }
247250 $safeUsers = IPBlockForm::doMassUserBlock( $users, $reason, $tag, $talkTag );
@@ -253,11 +256,11 @@
254257 $wgOut->addWikiText( wfMsgExt( 'checkuser-block-failure', 'parsemag' ) );
255258 }
256259 }
257 -
 260+
258261 protected function noMatchesMessage( $userName ) {
259262 global $wgLang;
260263 $dbr = wfGetDB( DB_SLAVE );
261 - $user_id = User::idFromName($userName);
 264+ $user_id = User::idFromName( $userName );
262265 if( $user_id ) {
263266 $revEdit = $dbr->selectField( 'revision',
264267 'rev_timestamp',
@@ -284,16 +287,16 @@
285288 }
286289 $lastEdit = max( $revEdit, $logEdit );
287290 if( $lastEdit ) {
288 - $lastEditDate = $wgLang->date( wfTimestamp(TS_MW,$lastEdit), true );
289 - $lastEditTime = $wgLang->time( wfTimestamp(TS_MW,$lastEdit), true );
 291+ $lastEditDate = $wgLang->date( wfTimestamp( TS_MW, $lastEdit ), true );
 292+ $lastEditTime = $wgLang->time( wfTimestamp( TS_MW, $lastEdit ), true );
290293 return wfMsgExt( 'checkuser-nomatch-edits', 'parse', $lastEditDate, $lastEditTime );
291294 }
292 - return wfMsgExt('checkuser-nomatch','parse');
 295+ return wfMsgExt( 'checkuser-nomatch','parse' );
293296 }
294 -
 297+
295298 protected function checkReason( $reason ) {
296299 global $wgCheckUserForceSummary;
297 - return ( !$wgCheckUserForceSummary || strlen($reason) );
 300+ return ( !$wgCheckUserForceSummary || strlen( $reason ) );
298301 }
299302
300303 /**
@@ -317,18 +320,18 @@
318321 return;
319322 }
320323 # Get ID, works better than text as user may have been renamed
321 - $user_id = User::idFromName($user);
 324+ $user_id = User::idFromName( $user );
322325
323326 # If user is not IP or nonexistent
324327 if( !$user_id ) {
325 - $s = wfMsgExt('nosuchusershort',array('parse'),$user);
 328+ $s = wfMsgExt( 'nosuchusershort', array( 'parse' ), $user );
326329 $wgOut->addHTML( $s );
327330 return;
328331 }
329332
330333 # Record check...
331334 if( !$this->addLogEntry( 'userips', 'user', $user, $reason, $user_id ) ) {
332 - $wgOut->addHTML( '<p>'.wfMsgHtml('checkuser-log-fail').'</p>' );
 335+ $wgOut->addHTML( '<p>' . wfMsgHtml( 'checkuser-log-fail' ) . '</p>' );
333336 }
334337 $dbr = wfGetDB( DB_SLAVE );
335338 $time_conds = $this->getTimeConds( $period );
@@ -339,17 +342,17 @@
340343 MIN(cuc_timestamp) AS first, MAX(cuc_timestamp) AS last
341344 FROM $cu_changes $use_index WHERE cuc_user = $user_id AND $time_conds
342345 GROUP BY cuc_ip,cuc_ip_hex ORDER BY last DESC LIMIT 5001";
343 -
 346+
344347 $ret = $dbr->query( $sql, __METHOD__ );
345348 if( !$dbr->numRows( $ret ) ) {
346 - $s = $this->noMatchesMessage($user)."\n";
 349+ $s = $this->noMatchesMessage( $user ) . "\n";
347350 } else {
348351 $blockip = SpecialPage::getTitleFor( 'Blockip' );
349352 $ips_edits = array();
350353 $counter = 0;
351 - while( $row = $dbr->fetchObject($ret) ) {
 354+ while( $row = $dbr->fetchObject( $ret ) ) {
352355 if( $counter >= 5000 ) {
353 - $wgOut->addHTML( wfMsgExt('checkuser-limited',array('parse')) );
 356+ $wgOut->addHTML( wfMsgExt( 'checkuser-limited', array( 'parse' ) ) );
354357 break;
355358 }
356359 $ips_edits[$row->cuc_ip] = $row->count;
@@ -360,26 +363,26 @@
361364 }
362365 // Count pinging might take some time...make sure it is there
363366 wfSuppressWarnings();
364 - set_time_limit(60);
 367+ set_time_limit( 60 );
365368 wfRestoreWarnings();
366 -
 369+
367370 $logs = SpecialPage::getTitleFor( 'Log' );
368371 $s = '<div id="checkuserresults"><ul>';
369372 foreach( $ips_edits as $ip => $edits ) {
370373 $s .= '<li>';
371 - $s .= '<a href="' .
372 - $this->getTitle()->escapeLocalURL( 'user='.urlencode($ip) . '&reason='.urlencode($reason) ) . '">' .
373 - htmlspecialchars($ip) . '</a>';
374 - $s .= ' (<a href="' . $blockip->escapeLocalURL( 'ip='.urlencode($ip) ).'">' .
375 - wfMsgHtml('blocklink') . '</a>)';
 374+ $s .= '<a href="' .
 375+ $this->getTitle()->escapeLocalURL( 'user=' . urlencode( $ip ) . '&reason=' . urlencode( $reason ) ) . '">' .
 376+ htmlspecialchars( $ip ) . '</a>';
 377+ $s .= ' (<a href="' . $blockip->escapeLocalURL( 'ip=' . urlencode( $ip ) ) . '">' .
 378+ wfMsgHtml( 'blocklink' ) . '</a>)';
376379 if( $ips_first[$ip] == $ips_last[$ip] ) {
377 - $s .= ' (' . $wgLang->timeanddate( wfTimestamp(TS_MW,$ips_first[$ip]), true ) . ') ';
 380+ $s .= ' (' . $wgLang->timeanddate( wfTimestamp( TS_MW, $ips_first[$ip] ), true ) . ') ';
378381 } else {
379 - $s .= ' (' . $wgLang->timeanddate( wfTimestamp(TS_MW,$ips_first[$ip]), true ) .
380 - ' -- ' . $wgLang->timeanddate( wfTimestamp(TS_MW,$ips_last[$ip]), true ) . ') ';
 382+ $s .= ' (' . $wgLang->timeanddate( wfTimestamp( TS_MW, $ips_first[$ip] ), true ) .
 383+ ' -- ' . $wgLang->timeanddate( wfTimestamp( TS_MW, $ips_last[$ip] ), true ) . ') ';
381384 }
382385 $s .= ' <strong>[' . $edits . ']</strong>';
383 -
 386+
384387 # If we get some results, it helps to know if the IP in general
385388 # has a lot more edits, e.g. "tip of the iceberg"...
386389 $ipedits = $dbr->estimateRowCount( 'cu_changes', '*',
@@ -392,14 +395,14 @@
393396 __METHOD__ );
394397 }
395398 if( $ipedits > $ips_edits[$ip] ) {
396 - $s .= ' <i>(' . wfMsgHtml('checkuser-ipeditcount',$ipedits) . ')</i>';
 399+ $s .= ' <i>(' . wfMsgHtml( 'checkuser-ipeditcount', $ipedits ) . ')</i>';
397400 }
398 -
 401+
399402 # If this IP is blocked, give a link to the block log
400403 $s.= $this->getIPBlockInfo( $ip );
401 - $s .= "<div style='margin-left:5%'>";
402 - $s .= "<small>" . wfMsgExt('checkuser-toollinks',array('parseinline'),urlencode($ip)) . "</small>";
403 - $s .= "</div>";
 404+ $s .= '<div style="margin-left:5%">';
 405+ $s .= '<small>' . wfMsgExt( 'checkuser-toollinks', array( 'parseinline' ), urlencode( $ip ) ) . '</small>';
 406+ $s .= '</div>';
404407 $s .= "</li>\n";
405408 }
406409 $s .= '</ul></div>';
@@ -407,25 +410,25 @@
408411 $wgOut->addHTML( $s );
409412 $dbr->freeResult( $ret );
410413 }
411 -
 414+
412415 protected function getIPBlockInfo( $ip ) {
413416 static $blocklist;
414417 $blocklist = SpecialPage::getTitleFor( 'Ipblocklist' );
415418 $block = new Block();
416419 $block->fromMaster( false ); // use slaves
417420 if( $block->load( $ip, 0 ) ) {
418 - if( IP::isIPAddress($block->mAddress) && strpos($block->mAddress,'/') ) {
 421+ if( IP::isIPAddress( $block->mAddress ) && strpos( $block->mAddress, '/' ) ) {
419422 $userpage = Title::makeTitle( NS_USER, $block->mAddress );
420 - $blocklog = $this->sk->makeKnownLinkObj( $logs, wfMsgHtml('checkuser-blocked'),
 423+ $blocklog = $this->sk->makeKnownLinkObj( $logs, wfMsgHtml( 'checkuser-blocked' ),
421424 'type=block&page=' . urlencode( $userpage->getPrefixedText() ) );
422425 return ' <strong>(' . $blocklog . ' - ' . $block->mAddress . ')</strong>';
423 - } else if( $block->mAuto ) {
424 - $blocklog = $this->sk->makeKnownLinkObj( $blocklist, wfMsgHtml('checkuser-blocked'),
 426+ } elseif( $block->mAuto ) {
 427+ $blocklog = $this->sk->makeKnownLinkObj( $blocklist, wfMsgHtml( 'checkuser-blocked' ),
425428 'ip=' . urlencode( "#$block->mId" ) );
426429 return ' <strong>(' . $blocklog . ')</strong>';
427430 } else {
428431 $userpage = Title::makeTitle( NS_USER, $ip );
429 - $blocklog = $this->sk->makeKnownLinkObj( $logs, wfMsgHtml('checkuser-blocked'),
 432+ $blocklog = $this->sk->makeKnownLinkObj( $logs, wfMsgHtml( 'checkuser-blocked' ),
430433 'type=block&page=' . urlencode( $userpage->getPrefixedText() ) );
431434 return ' <strong>(' . $blocklog . ')</strong>';
432435 }
@@ -465,7 +468,7 @@
466469 # Check how many rows will need sorting ahead of time to see if this is too big.
467470 # Also, if we only show 5000, too many will be ignored as well.
468471 $index = $xfor ? 'cuc_xff_hex_time' : 'cuc_ip_hex_time';
469 - if( strpos($ip,'/') !== false ) {
 472+ if( strpos( $ip, '/' ) !== false ) {
470473 # Quick index check only OK if no time constraint
471474 if( $period ) {
472475 $rangecount = $dbr->selectField( 'cu_changes', 'COUNT(*)',
@@ -480,12 +483,12 @@
481484 }
482485 // Sorting might take some time...make sure it is there
483486 wfSuppressWarnings();
484 - set_time_limit(60);
 487+ set_time_limit( 60 );
485488 wfRestoreWarnings();
486489 }
487490 $counter = 0;
488491 # See what is best to do after testing the waters...
489 - if( isset($rangecount) && $rangecount > 5000 ) {
 492+ if( isset( $rangecount ) && $rangecount > 5000 ) {
490493 $use_index = $dbr->useIndexClause( $index );
491494 $sql = "SELECT cuc_ip_hex, COUNT(*) AS count,
492495 MIN(cuc_timestamp) AS first, MAX(cuc_timestamp) AS last
@@ -494,39 +497,39 @@
495498 GROUP BY cuc_ip_hex ORDER BY cuc_ip_hex LIMIT 5001";
496499 $ret = $dbr->query( $sql, __METHOD__ );
497500 # List out each IP that has edits
498 - $s = wfMsgExt('checkuser-too-many',array('parse'));
 501+ $s = wfMsgExt( 'checkuser-too-many', array( 'parse' ) );
499502 $s .= '<ol>';
500503 while( $row = $ret->fetchObject() ) {
501504 if( $counter >= 5000 ) {
502 - $wgOut->addHTML( wfMsgExt('checkuser-limited',array('parse')) );
 505+ $wgOut->addHTML( wfMsgExt( 'checkuser-limited', array( 'parse' ) ) );
503506 break;
504507 }
505508 # Convert the IP hexes into normal form
506 - if( strpos($row->cuc_ip_hex,'v6-') !==false ) {
 509+ if( strpos( $row->cuc_ip_hex, 'v6-' ) !==false ) {
507510 $ip = substr( $row->cuc_ip_hex, 3 );
508511 $ip = IP::HextoOctet( $ip );
509512 } else {
510 - $ip = long2ip( wfBaseConvert($row->cuc_ip_hex, 16, 10, 8) );
 513+ $ip = long2ip( wfBaseConvert( $row->cuc_ip_hex, 16, 10, 8 ) );
511514 }
512 - $s .= '<li><a href="'.
513 - $this->getTitle()->escapeLocalURL( 'user='.urlencode($ip).'&reason='.urlencode($reason).'&checktype=subipusers' ) .
514 - '">'.$ip.'</a>';
 515+ $s .= '<li><a href="' .
 516+ $this->getTitle()->escapeLocalURL( 'user=' . urlencode( $ip ) . '&reason=' . urlencode( $reason ) . '&checktype=subipusers' ) .
 517+ '">' . $ip . '</a>';
515518 if( $row->first == $row->last ) {
516 - $s .= ' (' . $wgLang->timeanddate( wfTimestamp(TS_MW,$row->first), true ) . ') ';
 519+ $s .= ' (' . $wgLang->timeanddate( wfTimestamp( TS_MW, $row->first ), true ) . ') ';
517520 } else {
518 - $s .= ' (' . $wgLang->timeanddate( wfTimestamp(TS_MW,$row->first), true ) .
519 - ' -- ' . $wgLang->timeanddate( wfTimestamp(TS_MW,$row->last), true ) . ') ';
 521+ $s .= ' (' . $wgLang->timeanddate( wfTimestamp( TS_MW, $row->first ), true ) .
 522+ ' -- ' . $wgLang->timeanddate( wfTimestamp( TS_MW, $row->last ), true ) . ') ';
520523 }
521 - $s .= " [<strong>" . $row->count . "</strong>]</li>\n";
 524+ $s .= ' [<strong>' . $row->count . "</strong>]</li>\n";
522525 ++$counter;
523526 }
524527 $s .= '</ol>';
525528 $dbr->freeResult( $ret );
526 -
 529+
527530 $wgOut->addHTML( $s );
528531 return;
529 - } else if( isset($rangecount) && !$rangecount ) {
530 - $s = $this->noMatchesMessage($ip)."\n";
 532+ } elseif( isset( $rangecount ) && !$rangecount ) {
 533+ $s = $this->noMatchesMessage( $ip ) . "\n";
531534 $wgOut->addHTML( $s );
532535 return;
533536 }
@@ -538,7 +541,7 @@
539542 $ret = $dbr->query( $sql, __METHOD__ );
540543
541544 if( !$dbr->numRows( $ret ) ) {
542 - $s = $this->noMatchesMessage($ip)."\n";
 545+ $s = $this->noMatchesMessage( $ip ) . "\n";
543546 } else {
544547 # Cache common messages
545548 $this->preCacheMessages();
@@ -556,7 +559,7 @@
557560 $s = '<div id="checkuserresults">';
558561 while( $row = $ret->fetchObject() ) {
559562 if( $counter >= 5000 ) {
560 - $wgOut->addHTML( wfMsgExt('checkuser-limited',array('parse')) );
 563+ $wgOut->addHTML( wfMsgExt( 'checkuser-limited', array( 'parse' ) ) );
561564 break;
562565 }
563566 $s .= $this->CUChangesLine( $row, $reason );
@@ -568,9 +571,9 @@
569572
570573 $wgOut->addHTML( $s );
571574 }
572 -
 575+
573576 /**
574 - * @param string $nuser
 577+ * @param string $user
575578 * @param string $reason
576579 * Shows all edits in Recent Changes by this user
577580 */
@@ -588,18 +591,18 @@
589592 return;
590593 }
591594 # Get ID, works better than text as user may have been renamed
592 - $user_id = User::idFromName($user);
 595+ $user_id = User::idFromName( $user );
593596
594597 # If user is not IP or nonexistent
595598 if( !$user_id ) {
596 - $s = wfMsgExt('nosuchusershort',array('parse'),$user);
 599+ $s = wfMsgExt( 'nosuchusershort', array( 'parse' ), $user );
597600 $wgOut->addHTML( $s );
598601 return;
599602 }
600603
601604 # Record check...
602605 if( !$this->addLogEntry( 'useredits', 'user', $user, $reason, $user_id ) ) {
603 - $wgOut->addHTML( '<p>'.wfMsgHtml('checkuser-log-fail').'</p>' );
 606+ $wgOut->addHTML( '<p>' . wfMsgHtml( 'checkuser-log-fail' ) . '</p>' );
604607 }
605608
606609 $dbr = wfGetDB( DB_SLAVE );
@@ -624,7 +627,7 @@
625628 $this->preCacheMessages();
626629 # See what is best to do after testing the waters...
627630 if( $count > 5000 ) {
628 - $wgOut->addHTML( wfMsgExt('checkuser-limited',array('parse')) );
 631+ $wgOut->addHTML( wfMsgExt( 'checkuser-limited', array( 'parse' ) ) );
629632 $use_index = $dbr->useIndexClause( 'cuc_user_ip_time' );
630633 $sql = "SELECT * FROM $cu_changes $use_index
631634 WHERE $user_cond AND $time_conds
@@ -639,16 +642,16 @@
640643 $ret->seek( 0 );
641644 $s = '';
642645 while( $row = $ret->fetchObject() ) {
643 - if( !$ip = htmlspecialchars($row->cuc_ip) ) {
 646+ if( !$ip = htmlspecialchars( $row->cuc_ip ) ) {
644647 continue;
645648 }
646 - if( !isset($lastIP) ) {
 649+ if( !isset( $lastIP ) ) {
647650 $lastIP = $row->cuc_ip;
648651 $s .= "\n<h2>$ip</h2>\n<div class=\"special\">";
649 - } else if( $lastIP != $row->cuc_ip ) {
 652+ } elseif( $lastIP != $row->cuc_ip ) {
650653 $s .= "</ul></div>\n<h2>$ip</h2>\n<div class=\"special\">";
651654 $lastIP = $row->cuc_ip;
652 - unset($this->lastdate); // start over
 655+ unset( $this->lastdate ); // start over
653656 }
654657 $s .= $this->CUChangesLine( $row, $reason );
655658 }
@@ -660,7 +663,7 @@
661664 }
662665 // Sorting might take some time...make sure it is there
663666 wfSuppressWarnings();
664 - set_time_limit(60);
 667+ set_time_limit( 60 );
665668 wfRestoreWarnings();
666669 # OK, do the real query...
667670 $use_index = $dbr->useIndexClause( 'cuc_user_ip_time' );
@@ -669,7 +672,7 @@
670673 $ret = $dbr->query( $sql, __METHOD__ );
671674
672675 if( !$dbr->numRows( $ret ) ) {
673 - $s = $this->noMatchesMessage($user)."\n";
 676+ $s = $this->noMatchesMessage( $user ) . "\n";
674677 } else {
675678 # Try to optimize this query
676679 $lb = new LinkBatch;
@@ -701,7 +704,7 @@
702705 * Outputs usernames, latest and earliest found edit date, and count
703706 * List unique IPs used for each user in time order, list corresponding user agent
704707 */
705 - protected function doIPUsersRequest( $ip, $xfor = false, $reason = '', $period = 0, $tag='', $talkTag='' ) {
 708+ protected function doIPUsersRequest( $ip, $xfor = false, $reason = '', $period = 0, $tag = '', $talkTag = '' ) {
706709 global $wgUser, $wgOut, $wgLang;
707710 $dbr = wfGetDB( DB_SLAVE );
708711 # Invalid IPs are passed in as a blank string
@@ -726,7 +729,7 @@
727730 $index = $xfor ? 'cuc_xff_hex_time' : 'cuc_ip_hex_time';
728731 # Ordered in descent by timestamp. Can cause large filesorts on range scans.
729732 # Check how many rows will need sorting ahead of time to see if this is too big.
730 - if( strpos($ip,'/') !==false ) {
 733+ if( strpos( $ip, '/' ) !== false ) {
731734 # Quick index check only OK if no time constraint
732735 if( $period ) {
733736 $rangecount = $dbr->selectField( 'cu_changes', 'COUNT(*)',
@@ -741,11 +744,11 @@
742745 }
743746 // Sorting might take some time...make sure it is there
744747 wfSuppressWarnings();
745 - set_time_limit(120);
 748+ set_time_limit( 120 );
746749 wfRestoreWarnings();
747750 }
748751 // Are there too many edits?
749 - if( isset($rangecount) && $rangecount > 10000 ) {
 752+ if( isset( $rangecount ) && $rangecount > 10000 ) {
750753 $use_index = $dbr->useIndexClause( $index );
751754 $sql = "SELECT cuc_ip_hex, COUNT(*) AS count,
752755 MIN(cuc_timestamp) AS first, MAX(cuc_timestamp) AS last
@@ -753,31 +756,31 @@
754757 GROUP BY cuc_ip_hex ORDER BY cuc_ip_hex LIMIT 5001";
755758 $ret = $dbr->query( $sql, __METHOD__ );
756759 # List out each IP that has edits
757 - $s = '<h5>' . wfMsg('checkuser-too-many') . '</h5>';
 760+ $s = '<h5>' . wfMsg( 'checkuser-too-many' ) . '</h5>';
758761 $s .= '<ol>';
759762 $counter = 0;
760763 while( $row = $ret->fetchObject() ) {
761764 if( $counter >= 5000 ) {
762 - $wgOut->addHTML( wfMsgExt('checkuser-limited',array('parse')) );
 765+ $wgOut->addHTML( wfMsgExt( 'checkuser-limited', array( 'parse' ) ) );
763766 break;
764767 }
765768 # Convert the IP hexes into normal form
766 - if( strpos($row->cuc_ip_hex,'v6-') !==false ) {
 769+ if( strpos( $row->cuc_ip_hex, 'v6-' ) !==false ) {
767770 $ip = substr( $row->cuc_ip_hex, 3 );
768771 $ip = IP::HextoOctet( $ip );
769772 } else {
770 - $ip = long2ip( wfBaseConvert($row->cuc_ip_hex, 16, 10, 8) );
 773+ $ip = long2ip( wfBaseConvert( $row->cuc_ip_hex, 16, 10, 8 ) );
771774 }
772 - $s .= '<li><a href="'.
773 - $this->getTitle()->escapeLocalURL( 'user='.urlencode($ip).'&reason='.urlencode($reason).'&checktype=subipusers' ) .
774 - '">'.$ip.'</a>';
 775+ $s .= '<li><a href="' .
 776+ $this->getTitle()->escapeLocalURL( 'user=' . urlencode( $ip ) . '&reason=' . urlencode( $reason ) . '&checktype=subipusers' ) .
 777+ '">' . $ip . '</a>';
775778 if( $row->first == $row->last ) {
776 - $s .= ' (' . $wgLang->timeanddate( wfTimestamp(TS_MW,$row->first), true ) . ') ';
 779+ $s .= ' (' . $wgLang->timeanddate( wfTimestamp( TS_MW, $row->first ), true ) . ') ';
777780 } else {
778 - $s .= ' (' . $wgLang->timeanddate( wfTimestamp(TS_MW,$row->first), true ) .
779 - ' -- ' . $wgLang->timeanddate( wfTimestamp(TS_MW,$row->last), true ) . ') ';
 781+ $s .= ' (' . $wgLang->timeanddate( wfTimestamp( TS_MW, $row->first ), true ) .
 782+ ' -- ' . $wgLang->timeanddate( wfTimestamp( TS_MW, $row->last ), true ) . ') ';
780783 }
781 - $s .= " [<strong>" . $row->count . "</strong>]</li>\n";
 784+ $s .= ' [<strong>' . $row->count . "</strong>]</li>\n";
782785 ++$counter;
783786 }
784787 $s .= '</ol>';
@@ -785,8 +788,8 @@
786789
787790 $wgOut->addHTML( $s );
788791 return;
789 - } else if( isset($rangecount) && !$rangecount ) {
790 - $s = $this->noMatchesMessage($ip)."\n";
 792+ } elseif( isset( $rangecount ) && !$rangecount ) {
 793+ $s = $this->noMatchesMessage( $ip ) . "\n";
791794 $wgOut->addHTML( $s );
792795 return;
793796 }
@@ -801,10 +804,10 @@
802805
803806 $users_first = $users_last = $users_edits = $users_ids = array();
804807 if( !$dbr->numRows( $ret ) ) {
805 - $s = $this->noMatchesMessage($ip)."\n";
 808+ $s = $this->noMatchesMessage( $ip ) . "\n";
806809 } else {
807810 global $wgAuth;
808 - while( ($row = $dbr->fetchObject($ret) ) != false ) {
 811+ while( ( $row = $dbr->fetchObject( $ret ) ) != false ) {
809812 if( !array_key_exists( $row->cuc_user_text, $users_edits ) ) {
810813 $users_last[$row->cuc_user_text] = $row->cuc_timestamp;
811814 $users_edits[$row->cuc_user_text] = 0;
@@ -815,22 +818,22 @@
816819 $users_edits[$row->cuc_user_text] += 1;
817820 $users_first[$row->cuc_user_text] = $row->cuc_timestamp;
818821 # Treat blank or NULL xffs as empty strings
819 - $xff = empty($row->cuc_xff) ? null : $row->cuc_xff;
 822+ $xff = empty( $row->cuc_xff ) ? null : $row->cuc_xff;
820823 $xff_ip_combo = array( $row->cuc_ip, $xff );
821824 # Add this IP/XFF combo for this username if it's not already there
822 - if( !in_array($xff_ip_combo,$users_infosets[$row->cuc_user_text]) ) {
 825+ if( !in_array( $xff_ip_combo, $users_infosets[$row->cuc_user_text] ) ) {
823826 $users_infosets[$row->cuc_user_text][] = $xff_ip_combo;
824827 }
825828 # Add this agent string if it's not already there; 10 max.
826 - if( count($users_agentsets[$row->cuc_user_text]) < 10 ) {
827 - if( !in_array($row->cuc_agent,$users_agentsets[$row->cuc_user_text]) ) {
 829+ if( count( $users_agentsets[$row->cuc_user_text] ) < 10 ) {
 830+ if( !in_array( $row->cuc_agent, $users_agentsets[$row->cuc_user_text] ) ) {
828831 $users_agentsets[$row->cuc_user_text][] = $row->cuc_agent;
829832 }
830833 }
831834 }
832835 $dbr->freeResult( $ret );
833836
834 - $action = $this->getTitle()->escapeLocalUrl( 'action=block' );
 837+ $action = $this->getTitle()->escapeLocalURL( 'action=block' );
835838 $s = "<form name='checkuserblock' id='checkuserblock' action=\"$action\" method='post'>";
836839 $s .= '<div id="checkuserresults"><ul>';
837840 foreach( $users_edits as $name => $count ) {
@@ -841,14 +844,14 @@
842845 # Add user tool links
843846 $s .= $this->sk->userLink( -1 , $name ) . $this->sk->userToolLinks( -1 , $name );
844847 # Add CheckUser link
845 - $s .= ' (<a href="' . $this->getTitle()->escapeLocalURL( 'user='.urlencode($name) .
846 - '&reason='.urlencode($reason) ) . '">' . wfMsgHtml('checkuser-check') . '</a>)';
 848+ $s .= ' (<a href="' . $this->getTitle()->escapeLocalURL( 'user=' . urlencode( $name ) .
 849+ '&reason=' . urlencode( $reason ) ) . '">' . wfMsgHtml( 'checkuser-check' ) . '</a>)';
847850 # Show edit time range
848851 if( $users_first[$name] == $users_last[$name] ) {
849 - $s .= ' (' . $wgLang->timeanddate( wfTimestamp(TS_MW,$users_first[$name]), true ) . ') ';
 852+ $s .= ' (' . $wgLang->timeanddate( wfTimestamp( TS_MW, $users_first[$name] ), true ) . ') ';
850853 } else {
851 - $s .= ' (' . $wgLang->timeanddate( wfTimestamp(TS_MW,$users_first[$name]), true ) .
852 - ' -- ' . $wgLang->timeanddate( wfTimestamp(TS_MW,$users_last[$name]), true ) . ') ';
 854+ $s .= ' (' . $wgLang->timeanddate( wfTimestamp( TS_MW, $users_first[$name] ), true ) .
 855+ ' -- ' . $wgLang->timeanddate( wfTimestamp( TS_MW, $users_last[$name] ), true ) . ') ';
853856 }
854857 # Total edit count
855858 $s .= ' [<strong>' . $count . '</strong>]<br />';
@@ -858,12 +861,12 @@
859862 # Show if account is local only
860863 $authUser = $wgAuth->getUserInstance( $user );
861864 if( $user->getId() && $authUser->getId() === 0 ) {
862 - $flags[] = '<strong>(' . wfMsgHtml('checkuser-localonly') . ')</strong>';
 865+ $flags[] = '<strong>(' . wfMsgHtml( 'checkuser-localonly' ) . ')</strong>';
863866 }
864867 # Check for extra user rights...
865868 if( $users_ids[$name] ) {
866869 if( $user->isLocked() ) {
867 - $flags[] = '<b>(' . wfMsgHtml('checkuser-locked') . ')</b>';
 870+ $flags[] = '<b>(' . wfMsgHtml( 'checkuser-locked' ) . ')</b>';
868871 }
869872 $list = array();
870873 foreach( $user->getGroups() as $group ) {
@@ -882,53 +885,53 @@
883886 $flags[] = '<strong>[' . wfMsgExt( 'checkuser-accounts', 'parsemag', $wgLang->formatNum( $count ) ) . ']</strong>';
884887 }
885888 }
886 - $s .= implode(' ',$flags);
 889+ $s .= implode( ' ', $flags );
887890 $s .= '<ol>';
888891 # List out each IP/XFF combo for this username
889 - for( $i = (count($users_infosets[$name]) - 1); $i >= 0; $i-- ) {
 892+ for( $i = ( count( $users_infosets[$name] ) - 1 ); $i >= 0; $i-- ) {
890893 $set = $users_infosets[$name][$i];
891894 # IP link
892895 $s .= '<li>';
893 - $s .= '<a href="'.$this->getTitle()->escapeLocalURL( 'user='.urlencode($set[0]) ).'">'.htmlspecialchars($set[0]).'</a>';
 896+ $s .= '<a href="'.$this->getTitle()->escapeLocalURL( 'user=' . urlencode( $set[0] ) ) . '">' . htmlspecialchars( $set[0] ) . '</a>';
894897 # XFF string, link to /xff search
895898 if( $set[1] ) {
896899 # Flag our trusted proxies
897 - list($client,$trusted) = efGetClientIPfromXFF($set[1],$set[0]);
 900+ list( $client, $trusted ) = efGetClientIPfromXFF( $set[1], $set[0] );
898901 $c = $trusted ? '#F0FFF0' : '#FFFFCC';
899 - $s .= '&nbsp;&nbsp;&nbsp;<span style="background-color: '.$c.'"><strong>XFF</strong>: ';
 902+ $s .= '&nbsp;&nbsp;&nbsp;<span style="background-color: ' . $c . '"><strong>XFF</strong>: ';
900903 $s .= $this->sk->makeKnownLinkObj( $this->getTitle(),
901904 htmlspecialchars( $set[1] ),
902 - "user=" . urlencode( $client ) . "/xff" )."</span>";
 905+ 'user=' . urlencode( $client ) . '/xff' ) . '</span>';
903906 }
904907 $s .= "</li>\n";
905908 }
906909 $s .= '</ol><br /><ol>';
907910 # List out each agent for this username
908 - for( $i = (count($users_agentsets[$name]) - 1); $i >= 0; $i-- ) {
 911+ for( $i = ( count( $users_agentsets[$name] ) - 1 ); $i >= 0; $i-- ) {
909912 $agent = $users_agentsets[$name][$i];
910 - $s .= "<li><i>" . htmlspecialchars($agent) . "</i></li>\n";
 913+ $s .= '<li><i>' . htmlspecialchars( $agent ) . "</i></li>\n";
911914 }
912915 $s .= '</ol>';
913916 $s .= '</li>';
914917 }
915918 $s .= "</ul></div>\n";
916 - if( $wgUser->isAllowed('block') && !$wgUser->isBlocked() ) {
 919+ if( $wgUser->isAllowed( 'block' ) && !$wgUser->isBlocked() ) {
917920 $s .= "<fieldset>\n";
918 - $s .= "<legend>" . wfMsgHtml('checkuser-massblock') . "</legend>\n";
919 - $s .= "<p>" . wfMsgExt('checkuser-massblock-text',array('parseinline')) . "</p>\n";
 921+ $s .= '<legend>' . wfMsgHtml( 'checkuser-massblock' ) . "</legend>\n";
 922+ $s .= '<p>' . wfMsgExt( 'checkuser-massblock-text', array( 'parseinline' ) ) . "</p>\n";
920923 $s .= '<table><tr>' .
921 - '<td>' . Xml::check( 'usetag', false, array('id' => 'usetag') ) . '</td>' .
922 - '<td>' . Xml::label( wfMsgHtml( "checkuser-blocktag" ), 'usetag' ) . '</td>' .
923 - '<td>' . Xml::input( 'tag', 46, $tag, array('id' => 'blocktag') ) . '</td>' .
 924+ '<td>' . Xml::check( 'usetag', false, array( 'id' => 'usetag' ) ) . '</td>' .
 925+ '<td>' . Xml::label( wfMsgHtml( 'checkuser-blocktag' ), 'usetag' ) . '</td>' .
 926+ '<td>' . Xml::input( 'tag', 46, $tag, array( 'id' => 'blocktag' ) ) . '</td>' .
924927 '</tr><tr>' .
925 - '<td>' . Xml::check( 'usettag', false, array('id' => 'usettag') ) . '</td>' .
926 - '<td>' . Xml::label( wfMsgHtml( "checkuser-blocktag-talk" ), 'usettag' ) . '</td>' .
927 - '<td>' . Xml::input( 'talktag', 46, $talkTag, array('id' => 'talktag') ).'</td>'.
 928+ '<td>' . Xml::check( 'usettag', false, array('id' => 'usettag' ) ) . '</td>' .
 929+ '<td>' . Xml::label( wfMsgHtml( 'checkuser-blocktag-talk' ), 'usettag' ) . '</td>' .
 930+ '<td>' . Xml::input( 'talktag', 46, $talkTag, array( 'id' => 'talktag' ) ) . '</td>'.
928931 '</tr></table>';
929 - $s .= "<p>" . wfMsgHtml( "checkuser-reason" ) . '&nbsp;';
 932+ $s .= '<p>' . wfMsgHtml( 'checkuser-reason' ) . '&nbsp;';
930933 $s .= Xml::input( 'blockreason', 46, '', array( 'maxlength' => '150', 'id' => 'blockreason' ) );
931 - $s .= '&nbsp;' . Xml::submitButton( wfMsgHtml('checkuser-massblock-commit'),
932 - array('id' => 'checkuserblocksubmit','name' => 'checkuserblock') ) . "</p>\n";
 934+ $s .= '&nbsp;' . Xml::submitButton( wfMsgHtml( 'checkuser-massblock-commit' ),
 935+ array( 'id' => 'checkuserblocksubmit', 'name' => 'checkuserblock' ) ) . "</p>\n";
933936 $s .= "</fieldset>\n";
934937 }
935938 $s .= '</form>';
@@ -936,7 +939,7 @@
937940
938941 $wgOut->addHTML( $s );
939942 }
940 -
 943+
941944 protected function userBlockFlags( $ip, $userId, $user ) {
942945 static $logs, $blocklist;
943946 $logs = SpecialPage::getTitleFor( 'Log' );
@@ -946,28 +949,28 @@
947950 $flags = array();
948951 if( $block->load( $ip, $userId ) ) {
949952 // Range blocked?
950 - if( IP::isIPAddress($block->mAddress) && strpos($block->mAddress,'/') ) {
 953+ if( IP::isIPAddress( $block->mAddress ) && strpos( $block->mAddress, '/' ) ) {
951954 $userpage = Title::makeTitle( NS_USER, $block->mAddress );
952 - $blocklog = $this->sk->makeKnownLinkObj( $logs, wfMsgHtml('checkuser-blocked'),
 955+ $blocklog = $this->sk->makeKnownLinkObj( $logs, wfMsgHtml( 'checkuser-blocked' ),
953956 'type=block&page=' . urlencode( $userpage->getPrefixedText() ) );
954957 $flags[] = '<strong>(' . $blocklog . ' - ' . $block->mAddress . ')</strong>';
955958 // Auto blocked?
956 - } else if( $block->mAuto ) {
 959+ } elseif( $block->mAuto ) {
957960 $blocklog = $this->sk->makeKnownLinkObj( $blocklist,
958 - wfMsgHtml('checkuser-blocked'), 'ip=' . urlencode( "#{$block->mId}" ) );
 961+ wfMsgHtml( 'checkuser-blocked' ), 'ip=' . urlencode( "#{$block->mId}" ) );
959962 $flags[] = '<strong>(' . $blocklog . ')</strong>';
960963 } else {
961964 $userpage = $user->getUserPage();
962 - $blocklog = $this->sk->makeKnownLinkObj( $logs, wfMsgHtml('checkuser-blocked'),
 965+ $blocklog = $this->sk->makeKnownLinkObj( $logs, wfMsgHtml( 'checkuser-blocked' ),
963966 'type=block&page=' . urlencode( $userpage->getPrefixedText() ) );
964967 $flags[] = '<strong>(' . $blocklog . ')</strong>';
965968 }
966969 // IP that is blocked on all wikis?
967 - } else if( $ip == $user->getName() && $user->isBlockedGlobally( $ip ) ) {
968 - $flags[] = '<strong>(' . wfMsgHtml('checkuser-gblocked') . ')</strong>';
969 - } else if( self::userWasBlocked( $user->getName() ) ) {
 970+ } elseif( $ip == $user->getName() && $user->isBlockedGlobally( $ip ) ) {
 971+ $flags[] = '<strong>(' . wfMsgHtml( 'checkuser-gblocked' ) . ')</strong>';
 972+ } elseif( self::userWasBlocked( $user->getName() ) ) {
970973 $userpage = $user->getUserPage();
971 - $blocklog = $this->sk->makeKnownLinkObj( $logs, wfMsgHtml('checkuser-wasblocked'),
 974+ $blocklog = $this->sk->makeKnownLinkObj( $logs, wfMsgHtml( 'checkuser-wasblocked' ),
972975 'type=block&page=' . urlencode( $userpage->getPrefixedText() ) );
973976 $flags[] = '<strong>(' . $blocklog . ')</strong>';
974977 }
@@ -984,26 +987,26 @@
985988 static $cuTitle, $flagCache;
986989 $cuTitle = SpecialPage::getTitleFor( 'CheckUser' );
987990 # Add date headers as needed
988 - $date = $wgLang->date( wfTimestamp(TS_MW,$row->cuc_timestamp), true, true );
989 - if( !isset($this->lastdate) ) {
 991+ $date = $wgLang->date( wfTimestamp( TS_MW, $row->cuc_timestamp ), true, true );
 992+ if( !isset( $this->lastdate ) ) {
990993 $this->lastdate = $date;
991994 $line = "\n<h4>$date</h4>\n<ul class=\"special\">";
992 - } else if( $date != $this->lastdate ) {
 995+ } elseif( $date != $this->lastdate ) {
993996 $line = "</ul>\n<h4>$date</h4>\n<ul class=\"special\">";
994997 $this->lastdate = $date;
995998 } else {
996999 $line = '';
9971000 }
998 - $line .= "<li>";
 1001+ $line .= '<li>';
9991002 # Create diff/hist/page links
10001003 $line .= $this->getLinksFromRow( $row );
10011004 # Show date
1002 - $line .= ' . . ' . $wgLang->time( wfTimestamp(TS_MW,$row->cuc_timestamp), true, true ) . ' . . ';
 1005+ $line .= ' . . ' . $wgLang->time( wfTimestamp( TS_MW, $row->cuc_timestamp ), true, true ) . ' . . ';
10031006 # Userlinks
10041007 $line .= $this->sk->userLink( $row->cuc_user, $row->cuc_user_text );
10051008 $line .= $this->sk->userToolLinks( $row->cuc_user, $row->cuc_user_text );
10061009 # Get block info
1007 - if( isset($flagCache[$row->cuc_user_text]) ) {
 1010+ if( isset( $flagCache[$row->cuc_user_text] ) ) {
10081011 $flags = $flagCache[$row->cuc_user_text];
10091012 } else {
10101013 $user = User::newFromName( $row->cuc_user_text, false );
@@ -1012,31 +1015,34 @@
10131016 $flagCache[$row->cuc_user_text] = $flags;
10141017 }
10151018 # Add any block information
1016 - if( count($flags) ) $line .= ' ' . implode(' ',$flags);
 1019+ if( count( $flags ) ) {
 1020+ $line .= ' ' . implode( ' ', $flags );
 1021+ }
10171022 # Action text, hackish ...
1018 - if( $row->cuc_actiontext )
 1023+ if( $row->cuc_actiontext ) {
10191024 $line .= ' ' . $this->sk->formatComment( $row->cuc_actiontext ) . ' ';
 1025+ }
10201026 # Comment
10211027 $line .= $this->sk->commentBlock( $row->cuc_comment );
10221028 $line .= '<br />&nbsp; &nbsp; &nbsp; &nbsp; <small>';
10231029 # IP
1024 - $line .= ' <strong>IP</strong>: '.$this->sk->makeKnownLinkObj( $cuTitle,
1025 - htmlspecialchars( $row->cuc_ip ), "user=".urlencode( $row->cuc_ip ).'&reason='.urlencode($reason) );
 1030+ $line .= ' <strong>IP</strong>: ' . $this->sk->makeKnownLinkObj( $cuTitle,
 1031+ htmlspecialchars( $row->cuc_ip ), 'user=' . urlencode( $row->cuc_ip ) . '&reason=' . urlencode( $reason ) );
10261032 # XFF
1027 - if( $row->cuc_xff !=null ) {
 1033+ if( $row->cuc_xff != null ) {
10281034 # Flag our trusted proxies
1029 - list($client,$trusted) = efGetClientIPfromXFF($row->cuc_xff,$row->cuc_ip);
 1035+ list( $client, $trusted ) = efGetClientIPfromXFF( $row->cuc_xff, $row->cuc_ip );
10301036 $c = $trusted ? '#F0FFF0' : '#FFFFCC';
1031 - $line .= '&nbsp;&nbsp;&nbsp;<span class="mw-checkuser-xff" style="background-color: '.$c.'">'.
 1037+ $line .= '&nbsp;&nbsp;&nbsp;<span class="mw-checkuser-xff" style="background-color: ' . $c . '">' .
10321038 '<strong>XFF</strong>: ';
10331039 $line .= $this->sk->makeKnownLinkObj( $cuTitle,
10341040 htmlspecialchars( $row->cuc_xff ),
1035 - "user=".urlencode($client)."/xff&reason=".urlencode($reason) )."</span>";
 1041+ 'user=' . urlencode( $client ) . '/xff&reason=' . urlencode( $reason ) ) . '</span>';
10361042 }
10371043 # User agent
1038 - $line .= '&nbsp;&nbsp;&nbsp;<span class="mw-checkuser-agent" style="color:#888;">' .
1039 - htmlspecialchars( $row->cuc_agent )."</span>";
1040 -
 1044+ $line .= '&nbsp;&nbsp;&nbsp;<span class="mw-checkuser-agent" style="color:#888;">' .
 1045+ htmlspecialchars( $row->cuc_agent ) . '</span>';
 1046+
10411047 $line .= "</small></li>\n";
10421048
10431049 return $line;
@@ -1057,7 +1063,7 @@
10581064 } elseif( $row->cuc_type == RC_LOG ) {
10591065 $title = Title::makeTitle( $row->cuc_namespace, $row->cuc_title );
10601066 $links = '(' . $this->sk->makeKnownLinkObj( SpecialPage::getTitleFor( 'Log' ), $this->message['log'],
1061 - wfArrayToCGI( array('page' => $title->getPrefixedText() ) ) ) . ')';
 1067+ wfArrayToCGI( array( 'page' => $title->getPrefixedText() ) ) ) . ')';
10621068 } else {
10631069 $title = Title::makeTitle( $row->cuc_namespace, $row->cuc_title );
10641070 # New pages
@@ -1077,27 +1083,29 @@
10781084 'curid' => $row->cuc_page_id,
10791085 'action' => 'history' ) ) ) . ') . . ';
10801086 # Some basic flags
1081 - if( $row->cuc_type == RC_NEW )
 1087+ if( $row->cuc_type == RC_NEW ) {
10821088 $links .= '<span class="newpage">' . $this->message['newpageletter'] . '</span>';
1083 - if( $row->cuc_minor )
 1089+ }
 1090+ if( $row->cuc_minor ) {
10841091 $links .= '<span class="minor">' . $this->message['minoreditletter'] . '</span>';
 1092+ }
10851093 # Page link
10861094 $links .= ' ' . $this->sk->makeLinkObj( $title );
10871095 }
10881096 return $links;
10891097 }
1090 -
 1098+
10911099 protected static function userWasBlocked( $name ) {
10921100 $userpage = Title::makeTitle( NS_USER, $name );
10931101 return wfGetDB( DB_SLAVE )->selectField( 'logging', '1',
1094 - array( 'log_type' => array('block','suppress'),
 1102+ array( 'log_type' => array( 'block', 'suppress' ),
10951103 'log_action' => 'block',
10961104 'log_namespace' => $userpage->getNamespace(),
10971105 'log_title' => $userpage->getDBkey() ),
10981106 __METHOD__,
10991107 array( 'USE INDEX' => 'page_time' ) );
11001108 }
1101 -
 1109+
11021110 /**
11031111 * Format a link to a group description page
11041112 *
@@ -1106,8 +1114,9 @@
11071115 */
11081116 protected static function buildGroupLink( $group ) {
11091117 static $cache = array();
1110 - if( !isset( $cache[$group] ) )
 1118+ if( !isset( $cache[$group] ) ) {
11111119 $cache[$group] = User::makeGroupLinkHtml( $group, User::getGroupMember( $group ) );
 1120+ }
11121121 return $cache[$group];
11131122 }
11141123
@@ -1121,36 +1130,38 @@
11221131 $type = ( $xfor ) ? 'xff' : 'ip';
11231132 // IPv4 CIDR, 16-32 bits
11241133 if( preg_match( '#^(\d+\.\d+\.\d+\.\d+)/(\d+)$#', $ip, $matches ) ) {
1125 - if( $matches[2] < 16 || $matches[2] > 32 )
 1134+ if( $matches[2] < 16 || $matches[2] > 32 ) {
11261135 return false; // invalid
 1136+ }
11271137 list( $start, $end ) = IP::parseRange( $ip );
1128 - return array( 'cuc_'.$type.'_hex BETWEEN ' . $db->addQuotes( $start ) . ' AND ' . $db->addQuotes( $end ) );
1129 - } else if( preg_match( '#^\w{1,4}:\w{1,4}:\w{1,4}:\w{1,4}:\w{1,4}:\w{1,4}:\w{1,4}:\w{1,4}/(\d+)$#', $ip, $matches ) ) {
 1138+ return array( 'cuc_' . $type . '_hex BETWEEN ' . $db->addQuotes( $start ) . ' AND ' . $db->addQuotes( $end ) );
 1139+ } elseif( preg_match( '#^\w{1,4}:\w{1,4}:\w{1,4}:\w{1,4}:\w{1,4}:\w{1,4}:\w{1,4}:\w{1,4}/(\d+)$#', $ip, $matches ) ) {
11301140 // IPv6 CIDR, 96-128 bits
1131 - if( $matches[1] < 96 || $matches[1] > 128 )
 1141+ if( $matches[1] < 96 || $matches[1] > 128 ) {
11321142 return false; // invalid
 1143+ }
11331144 list( $start, $end ) = IP::parseRange6( $ip );
1134 - return array( 'cuc_'.$type.'_hex BETWEEN ' . $db->addQuotes( $start ) . ' AND ' . $db->addQuotes( $end ) );
1135 - } else if( preg_match( '#^(\d+)\.(\d+)\.(\d+)\.(\d+)$#', $ip ) ) {
 1145+ return array( 'cuc_' . $type . '_hex BETWEEN ' . $db->addQuotes( $start ) . ' AND ' . $db->addQuotes( $end ) );
 1146+ } elseif( preg_match( '#^(\d+)\.(\d+)\.(\d+)\.(\d+)$#', $ip ) ) {
11361147 // 32 bit IPv4
11371148 $ip_hex = IP::toHex( $ip );
11381149 return array( 'cuc_'.$type.'_hex' => $ip_hex );
1139 - } else if( preg_match( '#^\w{1,4}:\w{1,4}:\w{1,4}:\w{1,4}:\w{1,4}:\w{1,4}:\w{1,4}:\w{1,4}$#', $ip ) ) {
 1150+ } elseif( preg_match( '#^\w{1,4}:\w{1,4}:\w{1,4}:\w{1,4}:\w{1,4}:\w{1,4}:\w{1,4}:\w{1,4}$#', $ip ) ) {
11401151 // 128 bit IPv6
11411152 $ip_hex = IP::toHex( $ip );
1142 - return array( 'cuc_'.$type.'_hex' => $ip_hex );
 1153+ return array( 'cuc_' . $type . '_hex' => $ip_hex );
11431154 }
11441155 // throw away this query, incomplete IP, these don't get through the entry point anyway
11451156 return false; // invalid
11461157 }
1147 -
 1158+
11481159 protected function getTimeConds( $period ) {
11491160 if( !$period ) {
1150 - return "1 = 1";
 1161+ return '1 = 1';
11511162 }
11521163 $dbr = wfGetDB( DB_SLAVE );
1153 - $cutoff_unixtime = time() - ($period * 24 * 3600);
1154 - $cutoff_unixtime = $cutoff_unixtime - ($cutoff_unixtime % 86400);
 1164+ $cutoff_unixtime = time() - ( $period * 24 * 3600 );
 1165+ $cutoff_unixtime = $cutoff_unixtime - ( $cutoff_unixtime % 86400 );
11551166 $cutoff = $dbr->addQuotes( $dbr->timestamp( $cutoff_unixtime ) );
11561167 return "cuc_timestamp > $cutoff";
11571168 }
@@ -1164,7 +1175,7 @@
11651176 $error = false;
11661177 $dbr = wfGetDB( DB_SLAVE );
11671178 $searchConds = false;
1168 -
 1179+
11691180 $wgOut->setPageTitle( wfMsg( 'checkuser-log' ) );
11701181
11711182 $wgOut->addHTML( $this->sk->makeKnownLinkObj( $this->getTitle(), wfMsgHtml( 'checkuser-log-return' ) ) );
@@ -1187,7 +1198,7 @@
11881199 $searchConds = array( 'cul_target_hex = ' . $dbr->addQuotes( $start ) . ' OR ' .
11891200 '(cul_range_end >= ' . $dbr->addQuotes( $start ) . ' AND ' .
11901201 'cul_range_start <= ' . $dbr->addQuotes( $end ) . ')'
1191 - );
 1202+ );
11921203 } else {
11931204 $searchConds = array(
11941205 '(cul_target_hex >= ' . $dbr->addQuotes( $start ) . ' AND ' .
@@ -1201,10 +1212,10 @@
12021213 $user = User::newFromName( $target );
12031214 if ( $user && $user->getID() ) {
12041215 $searchConds = array(
1205 - 'cul_type' => array('userips','useredits'),
 1216+ 'cul_type' => array( 'userips', 'useredits' ),
12061217 'cul_target_id' => $user->getID(),
12071218 );
1208 - } else if ( $target ) {
 1219+ } elseif ( $target ) {
12091220 $error = 'checkuser-user-nonexistent';
12101221 }
12111222 }
@@ -1221,7 +1232,7 @@
12221233 $caption = wfMsgHtml( 'checkuser-search-' . $searchType );
12231234 $select .= "<option value=\"$searchType\" $checked>$caption</option>\n";
12241235 }
1225 - $select .= "</select>";
 1236+ $select .= '</select>';
12261237
12271238 $encTarget = htmlspecialchars( $target );
12281239 $msgSearch = wfMsgHtml( 'checkuser-search' );
@@ -1229,7 +1240,7 @@
12301241 $msgSearchForm = wfMsgHtml( 'checkuser-search-form', $select, $input );
12311242 $formAction = $this->getLogSubpageTitle()->escapeLocalURL();
12321243 $msgSearchSubmit = '&nbsp;&nbsp;' . wfMsgHtml( 'checkuser-search-submit' ) . '&nbsp;&nbsp;';
1233 -
 1244+
12341245 $s = "<form method='get' action=\"$formAction\">\n" .
12351246 "<fieldset><legend>$msgSearch</legend>\n" .
12361247 "<p>$msgSearchForm</p>\n" .
@@ -1247,10 +1258,11 @@
12481259 $wgOut->addHTML(
12491260 $pager->getNavigationBar() .
12501261 $pager->getBody() .
1251 - $pager->getNavigationBar() );
 1262+ $pager->getNavigationBar()
 1263+ );
12521264 }
1253 -
1254 - /**
 1265+
 1266+ /**
12551267 * @return string Formatted HTML
12561268 * @param int $year
12571269 * @param int $month
@@ -1264,20 +1276,20 @@
12651277 }
12661278 if ( $year ) {
12671279 $encYear = intval( $year );
1268 - } else if( $encMonth ) {
 1280+ } elseif( $encMonth ) {
12691281 $thisMonth = intval( gmdate( 'n' ) );
12701282 $thisYear = intval( gmdate( 'Y' ) );
1271 - if( intval($encMonth) > $thisMonth ) {
 1283+ if( intval( $encMonth ) > $thisMonth ) {
12721284 $thisYear--;
12731285 }
12741286 $encYear = $thisYear;
12751287 } else {
12761288 $encYear = '';
12771289 }
1278 - return Xml::label( wfMsg( 'year' ), 'year' ) . ' '.
1279 - Xml::input( 'year', 4, $encYear, array('id' => 'year', 'maxlength' => 4) ) .
1280 - ' '.
1281 - Xml::label( wfMsg( 'month' ), 'month' ) . ' '.
 1290+ return Xml::label( wfMsg( 'year' ), 'year' ) . ' ' .
 1291+ Xml::input( 'year', 4, $encYear, array( 'id' => 'year', 'maxlength' => 4 ) ) .
 1292+ ' ' .
 1293+ Xml::label( wfMsg( 'month' ), 'month' ) . ' ' .
12821294 Xml::monthSelector( $encMonth, -1 );
12831295 }
12841296
@@ -1293,7 +1305,7 @@
12941306 } else {
12951307 $targetHex = $rangeStart = $rangeEnd = '';
12961308 }
1297 -
 1309+
12981310 $dbw = wfGetDB( DB_MASTER );
12991311 $cul_id = $dbw->nextSequenceValue( 'cu_log_cul_id_seq' );
13001312 $dbw->insert( 'cu_log',
@@ -1343,20 +1355,20 @@
13441356 $user = $skin->userLink( $row->cul_user, $row->user_name );
13451357
13461358 if ( $row->cul_type == 'userips' || $row->cul_type == 'useredits' ) {
1347 - $target = $skin->userLink( $row->cul_target_id, $row->cul_target_text ) .
 1359+ $target = $skin->userLink( $row->cul_target_id, $row->cul_target_text ) .
13481360 $skin->userToolLinks( $row->cul_target_id, $row->cul_target_text );
13491361 } else {
13501362 $target = $row->cul_target_text;
13511363 }
13521364
1353 - return '<li>' .
1354 - $wgLang->timeanddate( wfTimestamp(TS_MW,$row->cul_timestamp), true ) .
 1365+ return '<li>' .
 1366+ $wgLang->timeanddate( wfTimestamp( TS_MW, $row->cul_timestamp ), true ) .
13551367 wfMsg( 'comma-separator' ) .
1356 - wfMsg(
 1368+ wfMsg(
13571369 'checkuser-log-' . $row->cul_type,
13581370 $user,
1359 - $target
1360 - ) .
 1371+ $target
 1372+ ) .
13611373 $comment .
13621374 '</li>';
13631375 }
@@ -1382,10 +1394,9 @@
13831395 }
13841396
13851397 function getQueryInfo() {
1386 - global $wgRequest;
13871398 $this->searchConds[] = 'user_id = cul_user';
13881399 return array(
1389 - 'tables' => array('cu_log','user'),
 1400+ 'tables' => array( 'cu_log', 'user' ),
13901401 'fields' => $this->selectFields(),
13911402 'conds' => $this->searchConds
13921403 );
@@ -1398,9 +1409,11 @@
13991410 function getTitle() {
14001411 return $this->specialPage->getLogSubpageTitle();
14011412 }
1402 -
 1413+
14031414 function selectFields() {
1404 - return array('cul_id','cul_timestamp','cul_user','cul_reason','cul_type',
1405 - 'cul_target_id','cul_target_text','user_name');
 1415+ return array(
 1416+ 'cul_id', 'cul_timestamp', 'cul_user', 'cul_reason', 'cul_type',
 1417+ 'cul_target_id', 'cul_target_text', 'user_name'
 1418+ );
14061419 }
14071420 }
Index: trunk/extensions/CheckUser/CheckUser.i18n.php
@@ -2,11 +2,16 @@
33 /**
44 * Internationalisation file for CheckUser extension.
55 *
6 - * @addtogroup Extensions
7 -*/
 6+ * @file
 7+ * @ingroup Extensions
 8+ */
89
910 $messages = array();
1011
 12+/** English
 13+ * @author Tim Starling
 14+ * @author Aaron Schulz
 15+ */
1116 $messages['en'] = array(
1217 'checkuser-summary' => 'This tool scans recent changes to retrieve the IP addresses used by a user or show the edit/user data for an IP address.
1318 Users and edits by a client IP can be retrieved via XFF headers by appending the IP with "/xff". IPv4 (CIDR 16-32) and IPv6 (CIDR 96-128) are supported.
@@ -19,13 +24,13 @@
2025 'group-checkuser' => 'Check users',
2126 'group-checkuser-member' => 'Check user',
2227 'right-checkuser' => "Check user's IP addresses and other information",
23 - 'right-checkuser-log' => "View the checkuser log",
 28+ 'right-checkuser-log' => 'View the checkuser log',
2429 'grouppage-checkuser' => '{{ns:project}}:Check user',
2530 'checkuser-reason' => 'Reason:',
2631 'checkuser-showlog' => 'Show log',
2732 'checkuser-log' => 'CheckUser log',
2833 'checkuser-query' => 'Query recent changes',
29 - 'checkuser-target' => 'User or IP',
 34+ 'checkuser-target' => 'User or IP:',
3035 'checkuser-users' => 'Get users',
3136 'checkuser-edits' => 'Get edits from IP',
3237 'checkuser-ips' => 'Get IP addresses',
@@ -72,7 +77,7 @@
7378 'checkuser-ipeditcount' => '~$1 from all users',
7479 'checkuser-log-subpage' => 'Log',
7580 'checkuser-log-return' => 'Return to CheckUser main form',
76 -
 81+
7782 'checkuser-limited' => '\'\'\'These results have been truncated for performance reasons.\'\'\'',
7883
7984 'checkuser-log-userips' => '$1 got IP addresses for $2',
@@ -81,11 +86,11 @@
8287 'checkuser-log-ipedits-xff' => '$1 got edits for XFF $2',
8388 'checkuser-log-ipusers-xff' => '$1 got users for XFF $2',
8489 'checkuser-log-useredits' => '$1 got edits for $2',
85 -
 90+
8691 'checkuser-autocreate-action' => 'was automatically created',
8792 'checkuser-email-action' => 'sent an email to user "$1"',
8893 'checkuser-reset-action' => 'reset password for user "$1"',
89 -
 94+
9095 'checkuser-toollinks' => '<span class="plainlinks">[[http://openrbl.org/query?$1 RDNS] ·
9196 [http://www.robtex.com/rbls/$1.html RBLs] ·
9297 [http://www.dnsstuff.com/tools/tracert.ch?ip=$1 Traceroute] ·
Index: trunk/extensions/CheckUser/CheckUser.php
@@ -1,30 +1,51 @@
22 <?php
 3+/**
 4+ * CheckUser extension - grants users with the appropriate permission the
 5+ * ability to check user's IP addresses and other information.
 6+ *
 7+ * @file
 8+ * @ingroup Extensions
 9+ * @version 2.3
 10+ * @author Tim Starling
 11+ * @author Aaron Schulz
 12+ * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
 13+ * @link http://www.mediawiki.org/wiki/Extension:CheckUser Documentation
 14+ */
315
416 # Not a valid entry point, skip unless MEDIAWIKI is defined
5 -if (!defined('MEDIAWIKI')) {
 17+if ( !defined( 'MEDIAWIKI' ) ) {
618 echo "CheckUser extension";
7 - exit(1);
 19+ exit( 1 );
820 }
921
1022 # Internationalisation file
11 -$dir = dirname(__FILE__) . '/';
 23+$dir = dirname( __FILE__ ) . '/';
1224 $wgExtensionMessagesFiles['CheckUser'] = $dir . 'CheckUser.i18n.php';
1325 $wgExtensionAliasesFiles['CheckUser'] = $dir . 'CheckUser.alias.php';
1426
 27+// Extension credits that will show up on Special:Version
1528 $wgExtensionCredits['specialpage'][] = array(
1629 'path' => __FILE__,
1730 'author' => array( 'Tim Starling', 'Aaron Schulz' ),
1831 'name' => 'CheckUser',
 32+ 'version' => '2.3',
1933 'url' => 'http://www.mediawiki.org/wiki/Extension:CheckUser',
2034 'description' => 'Grants users with the appropriate permission the ability to check user\'s IP addresses and other information',
2135 'descriptionmsg'=> 'checkuser-desc',
2236 );
2337
 38+// New user rights
 39+// 'checkuser' right is required to query IPs/users through Special:CheckUser
 40+// 'checkuser-log' is required to view the private log of checkuser checks
2441 $wgAvailableRights[] = 'checkuser';
2542 $wgAvailableRights[] = 'checkuser-log';
2643 $wgGroupPermissions['checkuser']['checkuser'] = true;
2744 $wgGroupPermissions['checkuser']['checkuser-log'] = true;
2845
 46+// Legacy variable, no longer used. Used to point to a file in the server where
 47+// CheckUser would log all queries done through Special:CheckUser.
 48+// If this file exists, the installer will try to import data from this file to
 49+// the 'cu_log' table in the database.
2950 $wgCheckUserLog = '/home/wikipedia/logs/checkuser.log';
3051
3152 # How long to keep CU data?
@@ -33,9 +54,12 @@
3455 # Mass block limits
3556 $wgCheckUserMaxBlocks = 200;
3657
 58+// Set this to true if you want to force checkusers into giving a reason for
 59+// each check they do through Special:CheckUser.
3760 $wgCheckUserForceSummary = false;
3861
39 -$wgCheckUserStyleVersion = 4;
 62+// Increment this number every time you touch the .js file.
 63+$wgCheckUserStyleVersion = 5;
4064
4165 # Recent changes data hook
4266 global $wgHooks;
@@ -60,7 +84,7 @@
6185 $ip = wfGetIP();
6286 // Get XFF header
6387 $xff = wfGetForwardedFor();
64 - list($xff_ip,$trusted) = efGetClientIPfromXFF( $xff );
 88+ list( $xff_ip, $trusted ) = efGetClientIPfromXFF( $xff );
6589 // Our squid XFFs can flood this up sometimes
6690 $isSquidOnly = efXFFChainIsSquid( $xff );
6791 // Get agent
@@ -69,14 +93,15 @@
7094 // $rc_comment should just be the log_comment
7195 // BC: check if log_type and log_action exists
7296 // If not, then $rc_comment is the actiontext and comment
73 - if( isset($rc_log_type) && $rc_type==RC_LOG ) {
 97+ if( isset( $rc_log_type ) && $rc_type == RC_LOG ) {
7498 $target = Title::makeTitle( $rc_namespace, $rc_title );
7599 $actionText = LogPage::actionText( $rc_log_type, $rc_log_action, $target,
76 - NULL, LogPage::extractParams($rc_params) );
 100+ null, LogPage::extractParams( $rc_params )
 101+ );
77102 } else {
78103 $actionText = '';
79104 }
80 -
 105+
81106 $dbw = wfGetDB( DB_MASTER );
82107 $cuc_id = $dbw->nextSequenceValue( 'cu_changes_cu_id_seq' );
83108 $rcRow = array(
@@ -92,14 +117,14 @@
93118 'cuc_last_oldid' => $rc_last_oldid,
94119 'cuc_type' => $rc_type,
95120 'cuc_timestamp' => $rc_timestamp,
96 - 'cuc_ip' => IP::sanitizeIP($ip),
 121+ 'cuc_ip' => IP::sanitizeIP( $ip ),
97122 'cuc_ip_hex' => $ip ? IP::toHex( $ip ) : null,
98123 'cuc_xff' => !$isSquidOnly ? $xff : '',
99 - 'cuc_xff_hex' => ($xff_ip && !$isSquidOnly) ? IP::toHex( $xff_ip ) : null,
 124+ 'cuc_xff_hex' => ( $xff_ip && !$isSquidOnly ) ? IP::toHex( $xff_ip ) : null,
100125 'cuc_agent' => $agent
101126 );
102127 # On PG, MW unsets cur_id due to schema incompatibilites. So it may not be set!
103 - if( isset($rc_cur_id) ) {
 128+ if( isset( $rc_cur_id ) ) {
104129 $rcRow['cuc_page_id'] = $rc_cur_id;
105130 }
106131 $dbw->insert( 'cu_changes', $rcRow, __METHOD__ );
@@ -112,9 +137,9 @@
113138 $cutoff = $dbw->timestamp( time() - $wgCUDMaxAge );
114139 $recentchanges = $dbw->tableName( 'cu_changes' );
115140 $sql = "DELETE FROM $recentchanges WHERE cuc_timestamp < '{$cutoff}'";
116 - $dbw->query( $sql );
 141+ $dbw->query( $sql, __METHOD__ );
117142 }
118 -
 143+
119144 return true;
120145 }
121146
@@ -126,7 +151,7 @@
127152 wfLoadExtensionMessages( 'CheckUser' );
128153 // Get XFF header
129154 $xff = wfGetForwardedFor();
130 - list($xff_ip,$trusted) = efGetClientIPfromXFF( $xff );
 155+ list( $xff_ip, $trusted ) = efGetClientIPfromXFF( $xff );
131156 // Our squid XFFs can flood this up sometimes
132157 $isSquidOnly = efXFFChainIsSquid( $xff );
133158 // Get agent
@@ -140,20 +165,20 @@
141166 'cuc_minor' => 0,
142167 'cuc_user' => $user->getId(),
143168 'cuc_user_text' => $user->getName(),
144 - 'cuc_actiontext' => wfMsgForContent('checkuser-reset-action',$account->getName()),
 169+ 'cuc_actiontext' => wfMsgForContent( 'checkuser-reset-action', $account->getName() ),
145170 'cuc_comment' => '',
146171 'cuc_this_oldid' => 0,
147172 'cuc_last_oldid' => 0,
148173 'cuc_type' => RC_LOG,
149174 'cuc_timestamp' => $dbw->timestamp( wfTimestampNow() ),
150 - 'cuc_ip' => IP::sanitizeIP($ip),
 175+ 'cuc_ip' => IP::sanitizeIP( $ip ),
151176 'cuc_ip_hex' => $ip ? IP::toHex( $ip ) : null,
152177 'cuc_xff' => !$isSquidOnly ? $xff : '',
153 - 'cuc_xff_hex' => ($xff_ip && !$isSquidOnly) ? IP::toHex( $xff_ip ) : null,
 178+ 'cuc_xff_hex' => ( $xff_ip && !$isSquidOnly ) ? IP::toHex( $xff_ip ) : null,
154179 'cuc_agent' => $agent
155180 );
156181 $dbw->insert( 'cu_changes', $rcRow, __METHOD__ );
157 -
 182+
158183 return true;
159184 }
160185
@@ -174,7 +199,7 @@
175200 $ip = wfGetIP();
176201 // Get XFF header
177202 $xff = wfGetForwardedFor();
178 - list($xff_ip,$trusted) = efGetClientIPfromXFF( $xff );
 203+ list( $xff_ip, $trusted ) = efGetClientIPfromXFF( $xff );
179204 // Our squid XFFs can flood this up sometimes
180205 $isSquidOnly = efXFFChainIsSquid( $xff );
181206 // Get agent
@@ -188,20 +213,20 @@
189214 'cuc_minor' => 0,
190215 'cuc_user' => $userFrom->getId(),
191216 'cuc_user_text' => $userFrom->getName(),
192 - 'cuc_actiontext' => wfMsgForContent('checkuser-email-action',$hash),
 217+ 'cuc_actiontext' => wfMsgForContent( 'checkuser-email-action', $hash ),
193218 'cuc_comment' => '',
194219 'cuc_this_oldid' => 0,
195220 'cuc_last_oldid' => 0,
196221 'cuc_type' => RC_LOG,
197222 'cuc_timestamp' => $dbw->timestamp( wfTimestampNow() ),
198 - 'cuc_ip' => IP::sanitizeIP($ip),
 223+ 'cuc_ip' => IP::sanitizeIP( $ip ),
199224 'cuc_ip_hex' => $ip ? IP::toHex( $ip ) : null,
200225 'cuc_xff' => !$isSquidOnly ? $xff : '',
201 - 'cuc_xff_hex' => ($xff_ip && !$isSquidOnly) ? IP::toHex( $xff_ip ) : null,
 226+ 'cuc_xff_hex' => ( $xff_ip && !$isSquidOnly ) ? IP::toHex( $xff_ip ) : null,
202227 'cuc_agent' => $agent
203228 );
204229 $dbw->insert( 'cu_changes', $rcRow, __METHOD__ );
205 -
 230+
206231 return true;
207232 }
208233
@@ -210,41 +235,41 @@
211236 * Saves user data into the cu_changes table
212237 */
213238 function efUpdateAutoCreateData( $user ) {
214 - wfLoadExtensionMessages( 'CheckUser' );
215 - // Get IP
216 - $ip = wfGetIP();
217 - // Get XFF header
218 - $xff = wfGetForwardedFor();
219 - list($xff_ip,$trusted) = efGetClientIPfromXFF( $xff );
220 - // Our squid XFFs can flood this up sometimes
221 - $isSquidOnly = efXFFChainIsSquid( $xff );
222 - // Get agent
223 - $agent = wfGetAgent();
224 - $dbw = wfGetDB( DB_MASTER );
225 - $cuc_id = $dbw->nextSequenceValue( 'cu_changes_cu_id_seq' );
226 - $rcRow = array(
227 - 'cuc_id' => $cuc_id,
228 - 'cuc_page_id' => 0,
229 - 'cuc_namespace' => NS_USER,
230 - 'cuc_title' => '',
231 - 'cuc_minor' => 0,
232 - 'cuc_user' => $user->getId(),
233 - 'cuc_user_text' => $user->getName(),
234 - 'cuc_actiontext' => wfMsgForContent('checkuser-autocreate-action'),
235 - 'cuc_comment' => '',
236 - 'cuc_this_oldid' => 0,
237 - 'cuc_last_oldid' => 0,
238 - 'cuc_type' => RC_LOG,
239 - 'cuc_timestamp' => $dbw->timestamp( wfTimestampNow() ),
240 - 'cuc_ip' => IP::sanitizeIP($ip),
241 - 'cuc_ip_hex' => $ip ? IP::toHex( $ip ) : null,
242 - 'cuc_xff' => !$isSquidOnly ? $xff : '',
243 - 'cuc_xff_hex' => ($xff_ip && !$isSquidOnly) ? IP::toHex( $xff_ip ) : null,
244 - 'cuc_agent' => $agent
245 - );
246 - $dbw->insert( 'cu_changes', $rcRow, __METHOD__ );
247 -
248 - return true;
 239+ wfLoadExtensionMessages( 'CheckUser' );
 240+ // Get IP
 241+ $ip = wfGetIP();
 242+ // Get XFF header
 243+ $xff = wfGetForwardedFor();
 244+ list( $xff_ip, $trusted ) = efGetClientIPfromXFF( $xff );
 245+ // Our squid XFFs can flood this up sometimes
 246+ $isSquidOnly = efXFFChainIsSquid( $xff );
 247+ // Get agent
 248+ $agent = wfGetAgent();
 249+ $dbw = wfGetDB( DB_MASTER );
 250+ $cuc_id = $dbw->nextSequenceValue( 'cu_changes_cu_id_seq' );
 251+ $rcRow = array(
 252+ 'cuc_id' => $cuc_id,
 253+ 'cuc_page_id' => 0,
 254+ 'cuc_namespace' => NS_USER,
 255+ 'cuc_title' => '',
 256+ 'cuc_minor' => 0,
 257+ 'cuc_user' => $user->getId(),
 258+ 'cuc_user_text' => $user->getName(),
 259+ 'cuc_actiontext' => wfMsgForContent( 'checkuser-autocreate-action' ),
 260+ 'cuc_comment' => '',
 261+ 'cuc_this_oldid' => 0,
 262+ 'cuc_last_oldid' => 0,
 263+ 'cuc_type' => RC_LOG,
 264+ 'cuc_timestamp' => $dbw->timestamp( wfTimestampNow() ),
 265+ 'cuc_ip' => IP::sanitizeIP( $ip ),
 266+ 'cuc_ip_hex' => $ip ? IP::toHex( $ip ) : null,
 267+ 'cuc_xff' => !$isSquidOnly ? $xff : '',
 268+ 'cuc_xff_hex' => ( $xff_ip && !$isSquidOnly ) ? IP::toHex( $xff_ip ) : null,
 269+ 'cuc_agent' => $agent
 270+ );
 271+ $dbw->insert( 'cu_changes', $rcRow, __METHOD__ );
 272+
 273+ return true;
249274 }
250275
251276 /**
@@ -253,26 +278,28 @@
254279 * @param string $address, the ip that sent this header (optional)
255280 * @return array( string, bool )
256281 */
257 -function efGetClientIPfromXFF( $xff, $address=NULL ) {
258 - if( !$xff )
259 - return array(null, false);
 282+function efGetClientIPfromXFF( $xff, $address = null ) {
 283+ if( !$xff ) {
 284+ return array( null, false );
 285+ }
260286 // Avoid annoyingly long xff hacks
261287 $xff = trim( substr( $xff, 0, 255 ) );
262288 $client = null;
263289 $trusted = true;
264290 // Check each IP, assuming they are separated by commas
265 - $ips = explode(',',$xff);
 291+ $ips = explode( ',', $xff );
266292 foreach( $ips as $n => $ip ) {
267 - $ip = trim($ip);
 293+ $ip = trim( $ip );
268294 // If it is a valid IP, not a hash or such
269 - if( IP::isIPAddress($ip) ) {
 295+ if( IP::isIPAddress( $ip ) ) {
270296 # The first IP should be the client.
271297 # Start only from the first public IP.
272 - if( is_null($client) ) {
273 - if( IP::isPublic($ip) )
 298+ if( is_null( $client ) ) {
 299+ if( IP::isPublic( $ip ) ) {
274300 $client = $ip;
 301+ }
275302 # Check that all servers are trusted
276 - } else if( !wfIsTrustedProxy($ip) ) {
 303+ } elseif( !wfIsTrustedProxy( $ip ) ) {
277304 $trusted = false;
278305 break;
279306 }
@@ -280,44 +307,46 @@
281308 }
282309 // We still have to test if the IP that sent
283310 // this header is trusted to confirm results
284 - if ( $client != $address && (!$address || !wfIsTrustedProxy($address)) )
 311+ if ( $client != $address && ( !$address || !wfIsTrustedProxy( $address ) ) ) {
285312 $trusted = false;
286 -
 313+ }
 314+
287315 return array( $client, $trusted );
288316 }
289317
290318 function efXFFChainIsSquid( $xff ) {
291319 global $wgSquidServers, $wgSquidServersNoPurge;
292320
293 - if ( !$xff )
 321+ if ( !$xff ) {
294322 false;
 323+ }
295324 // Avoid annoyingly long xff hacks
296325 $xff = trim( substr( $xff, 0, 255 ) );
297326 $squidOnly = true;
298327 // Check each IP, assuming they are separated by commas
299 - $ips = explode(',',$xff);
 328+ $ips = explode( ',', $xff );
300329 foreach( $ips as $n => $ip ) {
301 - $ip = trim($ip);
 330+ $ip = trim( $ip );
302331 // If it is a valid IP, not a hash or such
303 - if ( IP::isIPAddress($ip) ) {
304 - if ( $n==0 ) {
 332+ if ( IP::isIPAddress( $ip ) ) {
 333+ if ( $n == 0 ) {
305334 // The first IP should be the client...
306 - } else if ( !in_array($ip,$wgSquidServers) && !in_array($ip,$wgSquidServersNoPurge) ) {
 335+ } elseif ( !in_array( $ip, $wgSquidServers ) && !in_array( $ip, $wgSquidServersNoPurge ) ) {
307336 $squidOnly = false;
308337 break;
309338 }
310339 }
311340 }
312 -
 341+
313342 return $squidOnly;
314343 }
315344
316345 function efCheckUserSchemaUpdates() {
317346 global $wgDBtype, $wgExtNewIndexes;
318 -
 347+
319348 # Run install.inc as necessary
320 - $base = dirname(__FILE__);
321 -
 349+ $base = dirname( __FILE__ );
 350+
322351 $db = wfGetDB( DB_MASTER );
323352 if( $db->tableExists( 'cu_changes' ) ) {
324353 echo "...cu_changes already exists.\n";
@@ -325,19 +354,23 @@
326355 require_once "$base/install.inc";
327356 create_cu_changes( $db );
328357 }
329 -
 358+
330359 if( $db->tableExists( 'cu_log' ) ) {
331360 echo "...cu_log already exists.\n";
332361 } else {
333362 require_once "$base/install.inc";
334363 create_cu_log( $db );
335364 }
336 -
337 - if ($wgDBtype == 'mysql') {
338 - $wgExtNewIndexes[] = array('cu_changes', 'cuc_ip_hex_time',
339 - "$base/archives/patch-cu_changes_indexes.sql" );
340 - $wgExtNewIndexes[] = array('cu_changes', 'cuc_user_ip_time',
341 - "$base/archives/patch-cu_changes_indexes2.sql" );
 365+
 366+ if ( $wgDBtype == 'mysql' ) {
 367+ $wgExtNewIndexes[] = array(
 368+ 'cu_changes', 'cuc_ip_hex_time',
 369+ "$base/archives/patch-cu_changes_indexes.sql"
 370+ );
 371+ $wgExtNewIndexes[] = array(
 372+ 'cu_changes', 'cuc_user_ip_time',
 373+ "$base/archives/patch-cu_changes_indexes2.sql"
 374+ );
342375 }
343376 return true;
344377 }
@@ -351,19 +384,28 @@
352385 return true;
353386 }
354387
 388+// Set up the new special page
355389 $wgSpecialPages['CheckUser'] = 'CheckUser';
356390 $wgSpecialPageGroups['CheckUser'] = 'users';
357 -$wgAutoloadClasses['CheckUser'] = dirname(__FILE__) . '/CheckUser_body.php';
 391+$wgAutoloadClasses['CheckUser'] = dirname( __FILE__ ) . '/CheckUser_body.php';
358392
359 -
 393+/**
 394+ * Add a link to Special:CheckUser on Special:Contributions/<username> for
 395+ * privileged users.
 396+ * @param $id Integer: user ID
 397+ * @param $nt Title: user page title
 398+ * @param $links Array: tool links
 399+ * @return true
 400+ */
360401 function efLoadCheckUserLink( $id, $nt, &$links ) {
361 - global $wgUser;
362 - if( $wgUser->isAllowed( 'checkuser' ) ) {
363 - wfLoadExtensionMessages( 'CheckUser' );
 402+ global $wgUser;
 403+ if( $wgUser->isAllowed( 'checkuser' ) ) {
 404+ wfLoadExtensionMessages( 'CheckUser' );
364405 $links[] = $wgUser->getSkin()->makeKnownLinkObj(
365 - SpecialPage::getTitleFor( 'CheckUser' ),
366 - wfMsgHtml( 'checkuser-contribs' ),
367 - 'user=' . urlencode( $nt->getText() ) );
 406+ SpecialPage::getTitleFor( 'CheckUser' ),
 407+ wfMsgHtml( 'checkuser-contribs' ),
 408+ 'user=' . urlencode( $nt->getText() )
 409+ );
368410 }
369411 return true;
370412 }
Index: trunk/extensions/CheckUser/checkuser.js
@@ -8,10 +8,14 @@
99 */
1010 function updateCIDRresult() {
1111 var form = document.getElementById( 'mw-checkuser-cidrform' );
12 - if( !form ) return; // no JS form
 12+ if( !form ) {
 13+ return; // no JS form
 14+ }
1315 form.style.display = 'inline'; // unhide form (JS active)
1416 var iplist = document.getElementById( 'mw-checkuser-iplist' );
15 - if( !iplist ) return; // no JS form
 17+ if( !iplist ) {
 18+ return; // no JS form
 19+ }
1620 var text = iplist.value;
1721 // Each line should have one IP or range
1822 if( text.indexOf("\n") != -1 ) {
@@ -30,10 +34,10 @@
3135 }
3236 var bin_prefix = 0;
3337 var prefix_cidr = 0;
34 - var prefix = new String( "" );
 38+ var prefix = new String( '' );
3539 // Go through each IP in the list, get its binary form, and
3640 // track the largest binary prefix among them...
37 - for( var i=0; i<ips.length; i++ ) {
 41+ for( var i = 0; i < ips.length; i++ ) {
3842 var invalid = false;
3943 // ...in the spirit of block.js, call this "addy"
4044 var addy = ips[i];
@@ -41,7 +45,7 @@
4246 var ipV4 = addy.match(/(^|\b)(\d+\.\d+\.\d+\.\d+)(\/\d+)?\b/);
4347 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/);
4448 // Binary form
45 - var bin = new String( "" );
 49+ var bin = new String( '' );
4650 // Convert the IP to binary form: IPv4
4751 if( ipV4 ) {
4852 var ip = ipV4[2];
@@ -49,35 +53,39 @@
5054 // Get each quad integer
5155 var blocs = ip.split('.');
5256 // IANA 1.0.0.0/8, 2.0.0.0/8
53 - if( blocs[0] < 3 ) continue;
54 - for( var x=0; x<blocs.length; x++ ) {
 57+ if( blocs[0] < 3 ) {
 58+ continue;
 59+ }
 60+ for( var x = 0; x < blocs.length; x++ ) {
5561 bloc = parseInt( blocs[x], 10 );
5662 if( bloc > 255 ) {
5763 invalid = true; // bad IP!
5864 break; // bad IP!
5965 }
60 - bin_block = bloc.toString(2); // concat bin with binary form of bloc
 66+ bin_block = bloc.toString( 2 ); // concat bin with binary form of bloc
6167 while( bin_block.length < 8 ) {
62 - bin_block = "0" + bin_block; // pad out as needed
 68+ bin_block = '0' + bin_block; // pad out as needed
6369 }
6470 bin += bin_block;
6571 }
66 - if( invalid ) continue; // move to next IP
 72+ if( invalid ) {
 73+ continue; // move to next IP
 74+ }
6775 prefix = ''; // Rebuild formatted bin_prefix for each IP
6876 // Apply any valid CIDRs
6977 if( cidr ) {
7078 cidr = cidr.match( /\d+$/ )[0]; // get rid of slash
71 - bin = bin.substring(0,cidr); // truncate bin
 79+ bin = bin.substring( 0, cidr ); // truncate bin
7280 }
7381 // Init bin_prefix
7482 if( bin_prefix === 0 ) {
7583 bin_prefix = new String( bin );
7684 // Get largest common bin_prefix
7785 } else {
78 - for( var x=0; x<bin_prefix.length; x++ ) {
 86+ for( var x = 0; x < bin_prefix.length; x++ ) {
7987 // Bin_prefix always smaller than bin unless a CIDR was used on bin
8088 if( bin[x] == undefined || bin_prefix[x] != bin[x] ) {
81 - bin_prefix = bin_prefix.substring(0,x); // shorten bin_prefix
 89+ bin_prefix = bin_prefix.substring( 0, x ); // shorten bin_prefix
8290 break;
8391 }
8492 }
@@ -86,36 +94,42 @@
8795 var prefix_cidr = bin_prefix.length;
8896 // CIDR too small?
8997 if( prefix_cidr < 16 ) {
90 - document.getElementById( 'mw-checkuser-cidr-res' ).value = "!";
91 - document.getElementById( 'mw-checkuser-ipnote' ).innerHTML = "&gt;"+Math.pow(2,32-prefix_cidr);
 98+ document.getElementById( 'mw-checkuser-cidr-res' ).value = '!';
 99+ document.getElementById( 'mw-checkuser-ipnote' ).innerHTML = '&gt;' + Math.pow( 2, 32 - prefix_cidr );
92100 return; // too big
93101 }
94102 // Build the IP in dotted-quad form
95 - for( var z=0; z<=3; z++ ) {
 103+ for( var z = 0; z <= 3; z++ ) {
96104 var bloc = 0;
97 - var start = z*8;
 105+ var start = z * 8;
98106 var end = start + 7;
99 - for( var x=start; x<=end; x++ ) {
100 - if( bin_prefix[x] == undefined ) break;
101 - bloc += parseInt(bin_prefix[x],10)*Math.pow(2,end-x);
 107+ for( var x = start; x <= end; x++ ) {
 108+ if( bin_prefix[x] == undefined ) {
 109+ break;
 110+ }
 111+ bloc += parseInt( bin_prefix[x], 10 ) * Math.pow( 2, end - x );
102112 }
103113 prefix += ( z == 3 ) ? bloc : bloc + '.';
104114 }
105115 // Get IPs affected
106 - ip_count = Math.pow(2,32-prefix_cidr);
 116+ ip_count = Math.pow( 2, 32 - prefix_cidr );
107117 // Is the CIDR meaningful?
108 - if( prefix_cidr == 32 ) prefix_cidr = false;
 118+ if( prefix_cidr == 32 ) {
 119+ prefix_cidr = false;
 120+ }
109121 // Convert the IP to binary form: IPv6
110122 } else if( ipV6 ) {
111123 var ip = ipV6[2];
112124 var cidr = ipV6[0].match( /\/\d+$/ );
113125 cidr = cidr ? cidr[0] : false;
114126 var abbrevs = ip.match( /::/g );
115 - if( abbrevs && abbrevs.length > 1 ) continue; // bad IP!
 127+ if( abbrevs && abbrevs.length > 1 ) {
 128+ continue; // bad IP!
 129+ }
116130 // Expand out "::"s
117131 if( abbrevs && abbrevs.length > 0 ) {
118132 var colons = ip.match( /:/g );
119 - var needed = 7 - (colons.length - 2); // 2 from "::"
 133+ var needed = 7 - ( colons.length - 2 ); // 2 from "::"
120134 var insert = '';
121135 while( needed > 1 ) {
122136 insert += ':0';
@@ -123,39 +137,43 @@
124138 }
125139 ip = ip.replace( '::', insert + ':' );
126140 // For IPs that start with "::", correct the final IP so that it starts with '0' and not ':'
127 - if( ip[0] == ':' ) ip = '0' + ip;
 141+ if( ip[0] == ':' ) {
 142+ ip = '0' + ip;
 143+ }
128144 }
129145 // Get each hex octant
130146 var blocs = ip.split(':');
131 - for( var x=0; x<=7; x++ ) {
132 - bloc = blocs[x] ? blocs[x] : "0";
133 - if( bloc > "ffff" ) {
 147+ for( var x = 0; x <= 7; x++ ) {
 148+ bloc = blocs[x] ? blocs[x] : '0';
 149+ if( bloc > 'ffff' ) {
134150 invalid = true; // bad IP!
135151 break; // bad IP!
136152 }
137153 int_block = hex2int( bloc ); // convert hex -> int
138 - bin_block = int_block.toString(2); // concat bin with binary form of bloc
 154+ bin_block = int_block.toString( 2 ); // concat bin with binary form of bloc
139155 while( bin_block.length < 16 ) {
140 - bin_block = "0" + bin_block; // pad out as needed
 156+ bin_block = '0' + bin_block; // pad out as needed
141157 }
142158 bin += bin_block;
143159 }
144 - if( invalid ) continue; // move to next IP
 160+ if( invalid ) {
 161+ continue; // move to next IP
 162+ }
145163 prefix = ''; // Rebuild formatted bin_prefix for each IP
146164 // Apply any valid CIDRs
147165 if( cidr ) {
148166 cidr = cidr.match( /\d+$/ )[0]; // get rid of slash
149 - bin = bin.substring(0,cidr); // truncate bin
 167+ bin = bin.substring( 0, cidr ); // truncate bin
150168 }
151169 // Init bin_prefix
152170 if( bin_prefix === 0 ) {
153171 bin_prefix = new String( bin );
154172 // Get largest common bin_prefix
155173 } else {
156 - for( var x=0; x<bin_prefix.length; x++ ) {
 174+ for( var x = 0; x < bin_prefix.length; x++ ) {
157175 // Bin_prefix always smaller than bin unless a CIDR was used on bin
158176 if( bin[x] == undefined || bin_prefix[x] != bin[x] ) {
159 - bin_prefix = bin_prefix.substring(0,x); // shorten bin_prefix
 177+ bin_prefix = bin_prefix.substring( 0, x ); // shorten bin_prefix
160178 break;
161179 }
162180 }
@@ -164,30 +182,34 @@
165183 var prefix_cidr = bin_prefix.length;
166184 // CIDR too small?
167185 if( prefix_cidr < 96 ) {
168 - document.getElementById( 'mw-checkuser-cidr-res' ).value = "!";
169 - document.getElementById( 'mw-checkuser-ipnote' ).innerHTML = "&gt;"+Math.pow(2,128-prefix_cidr);
 186+ document.getElementById( 'mw-checkuser-cidr-res' ).value = '!';
 187+ document.getElementById( 'mw-checkuser-ipnote' ).innerHTML = '&gt;' + Math.pow( 2, 128 - prefix_cidr );
170188 return; // too big
171189 }
172190 // Build the IP in dotted-quad form
173 - for( var z=0; z<=7; z++ ) {
 191+ for( var z = 0; z <= 7; z++ ) {
174192 var bloc = 0;
175193 var start = z*16;
176194 var end = start + 15;
177 - for( var x=start; x<=end; x++ ) {
178 - if( bin_prefix[x] == undefined ) break;
179 - bloc += parseInt(bin_prefix[x],10)*Math.pow(2,end-x);
 195+ for( var x = start; x <= end; x++ ) {
 196+ if( bin_prefix[x] == undefined ) {
 197+ break;
 198+ }
 199+ bloc += parseInt( bin_prefix[x], 10 ) * Math.pow( 2, end - x );
180200 }
181 - bloc = bloc.toString(16); // convert to hex
 201+ bloc = bloc.toString( 16 ); // convert to hex
182202 prefix += ( z == 7 ) ? bloc : bloc + ':';
183203 }
184204 // Get IPs affected
185 - ip_count = Math.pow(2,128-prefix_cidr);
 205+ ip_count = Math.pow( 2, 128 - prefix_cidr );
186206 // Is the CIDR meaningful?
187 - if( prefix_cidr == 128 ) prefix_cidr = false;
 207+ if( prefix_cidr == 128 ) {
 208+ prefix_cidr = false;
 209+ }
188210 }
189211 }
190212 // Update form
191 - if( prefix != "" ) {
 213+ if( prefix != '' ) {
192214 if( prefix_cidr != false ) {
193215 document.getElementById( 'mw-checkuser-cidr-res' ).value = prefix + '/' + prefix_cidr;
194216 } else {
@@ -198,7 +220,7 @@
199221 document.getElementById( 'mw-checkuser-cidr-res' ).value = '?';
200222 document.getElementById( 'mw-checkuser-ipnote' ).innerHTML = '';
201223 }
202 -
 224+
203225 }
204226 addOnloadHook( updateCIDRresult );
205227
@@ -207,10 +229,9 @@
208230 hex = new String( hex );
209231 hex = hex.toLowerCase();
210232 var intform = 0;
211 - for( var i=0; i<hex.length; i++ ) {
 233+ for( var i = 0; i < hex.length; i++ ) {
212234 var digit = 0;
213 - switch( hex[i] )
214 - {
 235+ switch( hex[i] ) {
215236 case 'a':
216237 digit = 10;
217238 break;
@@ -233,7 +254,7 @@
234255 digit = parseInt( hex[i], 10 );
235256 break;
236257 }
237 - intform += digit*Math.pow(16,hex.length-1-i);
 258+ intform += digit * Math.pow( 16, hex.length - 1 - i );
238259 }
239260 return intform;
240261 }
Index: trunk/extensions/CheckUser/CheckUser.alias.php
@@ -2,7 +2,8 @@
33 /**
44 * Aliases for Special:CheckUser
55 *
6 - * @addtogroup Extensions
 6+ * @file
 7+ * @ingroup Extensions
78 */
89
910 $aliases = array();
@@ -11,7 +12,7 @@
1213 * @author Jon Harald Søby
1314 */
1415 $aliases['en'] = array(
15 - 'CheckUser' => array( 'CheckUser' ),
 16+ 'CheckUser' => array( 'CheckUser' ),
1617 );
1718
1819 /** Arabic (العربية)

Comments

#Comment by Tim Starling (talk | contribs)   07:46, 12 January 2010

I love you Ashley.

Status & tagging log