Index: trunk/extensions/CheckUser/CheckUser_body.php |
— | — | @@ -5,20 +5,22 @@ |
6 | 6 | exit( 1 ); |
7 | 7 | } |
8 | 8 | |
| 9 | +class CheckUser extends SpecialPage { |
9 | 10 | |
10 | | -class CheckUser extends SpecialPage |
11 | | -{ |
12 | | - function CheckUser() { |
| 11 | + /** |
| 12 | + * Constructor -- set up the new special page |
| 13 | + */ |
| 14 | + public function __construct() { |
13 | 15 | global $wgUser; |
14 | 16 | if ( $wgUser->isAllowed( 'checkuser' ) || !$wgUser->isAllowed( 'checkuser-log' ) ) { |
15 | | - SpecialPage::SpecialPage('CheckUser', 'checkuser'); |
| 17 | + parent::__construct( 'CheckUser', 'checkuser' ); |
16 | 18 | } else { |
17 | | - SpecialPage::SpecialPage('CheckUser', 'checkuser-log'); |
| 19 | + parent::__construct( 'CheckUser', 'checkuser-log' ); |
18 | 20 | } |
19 | | - wfLoadExtensionMessages('CheckUser'); |
| 21 | + wfLoadExtensionMessages( 'CheckUser' ); |
20 | 22 | } |
21 | 23 | |
22 | | - function execute( $subpage ) { |
| 24 | + public function execute( $subpage ) { |
23 | 25 | global $wgRequest, $wgOut, $wgUser, $wgContLang; |
24 | 26 | |
25 | 27 | $this->setHeaders(); |
— | — | @@ -61,25 +63,25 @@ |
62 | 64 | |
63 | 65 | $user = $wgRequest->getText( 'user' ) ? |
64 | 66 | $wgRequest->getText( 'user' ) : $wgRequest->getText( 'ip' ); |
65 | | - $user = trim($user); |
| 67 | + $user = trim( $user ); |
66 | 68 | $reason = $wgRequest->getText( 'reason' ); |
67 | 69 | $blockreason = $wgRequest->getText( 'blockreason' ); |
68 | 70 | $checktype = $wgRequest->getVal( 'checktype' ); |
69 | 71 | $period = $wgRequest->getInt( 'period' ); |
70 | 72 | $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' ) ) : ''; |
73 | 75 | |
74 | 76 | # 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 ); |
77 | 79 | $name = ''; |
78 | 80 | $xff = ''; |
79 | 81 | # 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] ) ) { |
81 | 83 | $ip = ''; |
82 | 84 | $name = ''; |
83 | | - $xff = IP::sanitizeIP($m[1]); |
| 85 | + $xff = IP::sanitizeIP( $m[1] ); |
84 | 86 | # A user? |
85 | 87 | } else { |
86 | 88 | $ip = ''; |
— | — | @@ -90,21 +92,21 @@ |
91 | 93 | $this->doForm( $user, $reason, $checktype, $ip, $xff, $name, $period ); |
92 | 94 | # Perform one of the various submit operations... |
93 | 95 | if( $wgRequest->wasPosted() ) { |
94 | | - if( $wgRequest->getVal('action') === 'block' ) { |
| 96 | + if( $wgRequest->getVal( 'action' ) === 'block' ) { |
95 | 97 | $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' ) { |
99 | 101 | $this->doUserIPsRequest( $name, $reason, $period ); |
100 | | - } else if( $xff && $checktype=='subipedits' ) { |
| 102 | + } elseif( $xff && $checktype == 'subipedits' ) { |
101 | 103 | $this->doIPEditsRequest( $xff, true, $reason, $period ); |
102 | | - } else if( $checktype=='subipedits' ) { |
| 104 | + } elseif( $checktype == 'subipedits' ) { |
103 | 105 | $this->doIPEditsRequest( $ip, false, $reason, $period ); |
104 | | - } else if( $xff && $checktype=='subipusers' ) { |
| 106 | + } elseif( $xff && $checktype == 'subipusers' ) { |
105 | 107 | $this->doIPUsersRequest( $xff, true, $reason, $period, $tag, $talkTag ); |
106 | | - } else if( $checktype=='subipusers' ) { |
| 108 | + } elseif( $checktype == 'subipusers' ) { |
107 | 109 | $this->doIPUsersRequest( $ip, false, $reason, $period, $tag, $talkTag ); |
108 | | - } else if( $checktype=='subuseredits' ) { |
| 110 | + } elseif( $checktype == 'subuseredits' ) { |
109 | 111 | $this->doUserEditsRequest( $user, $reason, $period ); |
110 | 112 | } |
111 | 113 | } |
— | — | @@ -112,7 +114,7 @@ |
113 | 115 | $this->addJsCIDRForm(); |
114 | 116 | $this->addStyles(); |
115 | 117 | } |
116 | | - |
| 118 | + |
117 | 119 | /** |
118 | 120 | * As we use the same small set of messages in various methods and that |
119 | 121 | * they are called often, we call them once and save them in $this->message |
— | — | @@ -120,8 +122,8 @@ |
121 | 123 | protected function preCacheMessages() { |
122 | 124 | // Precache various messages |
123 | 125 | 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' ) ); |
126 | 128 | } |
127 | 129 | } |
128 | 130 | } |
— | — | @@ -138,19 +140,20 @@ |
139 | 141 | $action = $this->getTitle()->escapeLocalUrl(); |
140 | 142 | # Fill in requested type if it makes sense |
141 | 143 | $encipusers = $encipedits = $encuserips = $encuseredits = 0; |
142 | | - if( $checktype=='subipusers' && ( $ip || $xff ) ) |
| 144 | + if( $checktype == 'subipusers' && ( $ip || $xff ) ) { |
143 | 145 | $encipusers = 1; |
144 | | - else if( $checktype=='subipedits' && ( $ip || $xff ) ) |
| 146 | + } elseif( $checktype == 'subipedits' && ( $ip || $xff ) ) { |
145 | 147 | $encipedits = 1; |
146 | | - else if( $checktype=='subuserips' && $name ) |
| 148 | + } elseif( $checktype == 'subuserips' && $name ) { |
147 | 149 | $encuserips = 1; |
148 | | - else if( $checktype=='subuseredits' && $name ) |
| 150 | + } elseif( $checktype == 'subuseredits' && $name ) { |
149 | 151 | $encuseredits = 1; |
150 | 152 | # Defaults otherwise |
151 | | - else if( $ip || $xff ) |
| 153 | + } elseif( $ip || $xff ) { |
152 | 154 | $encipedits = 1; |
153 | | - else |
| 155 | + } else { |
154 | 156 | $encuserips = 1; |
| 157 | + } |
155 | 158 | # Compile our nice form |
156 | 159 | # User box length should fit things like "2001:0db8:85a3:08d3:1319:8a2e:0370:7344/100/xff" |
157 | 160 | if( $wgUser->isAllowed( 'checkuser-log' ) ) { |
— | — | @@ -160,87 +163,87 @@ |
161 | 164 | ); |
162 | 165 | } |
163 | 166 | $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 .= " ".$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 .= " ".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 .= ' ' . $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 .= ' ' . Xml::submitButton( wfMsgHtml( 'checkuser-check' ), |
| 187 | + array( 'id' => 'checkusersubmit', 'name' => 'checkusersubmit' ) ) . '</td>'; |
| 188 | + $form .= '</tr></table></fieldset></form>'; |
186 | 189 | # Output form |
187 | 190 | $wgOut->addHTML( $form ); |
188 | 191 | } |
189 | | - |
| 192 | + |
190 | 193 | /** |
191 | | - * Add CSS/JS |
192 | | - */ |
| 194 | + * Add CSS/JS |
| 195 | + */ |
193 | 196 | protected function addStyles() { |
194 | 197 | global $wgScriptPath, $wgCheckUserStyleVersion, $wgOut; |
195 | 198 | $encJSFile = htmlspecialchars( "$wgScriptPath/extensions/CheckUser/checkuser.js?$wgCheckUserStyleVersion" ); |
196 | 199 | $wgOut->addScript( "<script type=\"text/javascript\" src=\"$encJSFile\"></script>" ); |
197 | 200 | } |
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> "; |
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> '; |
| 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"; |
211 | 214 | return $s; |
212 | 215 | } |
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 | + */ |
217 | 220 | protected function addJsCIDRForm() { |
218 | 221 | 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>'; |
221 | 224 | $s .= '<textarea id="mw-checkuser-iplist" rows="5" cols="50" onkeyup="updateCIDRresult()" onclick="updateCIDRresult()"></textarea><br />'; |
222 | | - $s .= wfMsgHtml('checkuser-cidr-res') . ' ' . |
223 | | - Xml::input( 'mw-checkuser-cidr-res',35,'',array('id'=>'mw-checkuser-cidr-res') ) . |
| 225 | + $s .= wfMsgHtml( 'checkuser-cidr-res' ) . ' ' . |
| 226 | + Xml::input( 'mw-checkuser-cidr-res', 35, '', array( 'id' => 'mw-checkuser-cidr-res' ) ) . |
224 | 227 | ' <strong id="mw-checkuser-ipnote"></strong>'; |
225 | 228 | $s .= '</fieldset>'; |
226 | 229 | $wgOut->addHTML( $s ); |
227 | 230 | } |
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 | + */ |
235 | 238 | protected function doMassUserBlock( $users, $reason = '', $tag = '', $talkTag = '' ) { |
236 | 239 | 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' ) ) ); |
239 | 242 | 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' ) ) ); |
242 | 245 | 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' ) ) ); |
245 | 248 | return; |
246 | 249 | } |
247 | 250 | $safeUsers = IPBlockForm::doMassUserBlock( $users, $reason, $tag, $talkTag ); |
— | — | @@ -253,11 +256,11 @@ |
254 | 257 | $wgOut->addWikiText( wfMsgExt( 'checkuser-block-failure', 'parsemag' ) ); |
255 | 258 | } |
256 | 259 | } |
257 | | - |
| 260 | + |
258 | 261 | protected function noMatchesMessage( $userName ) { |
259 | 262 | global $wgLang; |
260 | 263 | $dbr = wfGetDB( DB_SLAVE ); |
261 | | - $user_id = User::idFromName($userName); |
| 264 | + $user_id = User::idFromName( $userName ); |
262 | 265 | if( $user_id ) { |
263 | 266 | $revEdit = $dbr->selectField( 'revision', |
264 | 267 | 'rev_timestamp', |
— | — | @@ -284,16 +287,16 @@ |
285 | 288 | } |
286 | 289 | $lastEdit = max( $revEdit, $logEdit ); |
287 | 290 | 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 ); |
290 | 293 | return wfMsgExt( 'checkuser-nomatch-edits', 'parse', $lastEditDate, $lastEditTime ); |
291 | 294 | } |
292 | | - return wfMsgExt('checkuser-nomatch','parse'); |
| 295 | + return wfMsgExt( 'checkuser-nomatch','parse' ); |
293 | 296 | } |
294 | | - |
| 297 | + |
295 | 298 | protected function checkReason( $reason ) { |
296 | 299 | global $wgCheckUserForceSummary; |
297 | | - return ( !$wgCheckUserForceSummary || strlen($reason) ); |
| 300 | + return ( !$wgCheckUserForceSummary || strlen( $reason ) ); |
298 | 301 | } |
299 | 302 | |
300 | 303 | /** |
— | — | @@ -317,18 +320,18 @@ |
318 | 321 | return; |
319 | 322 | } |
320 | 323 | # Get ID, works better than text as user may have been renamed |
321 | | - $user_id = User::idFromName($user); |
| 324 | + $user_id = User::idFromName( $user ); |
322 | 325 | |
323 | 326 | # If user is not IP or nonexistent |
324 | 327 | if( !$user_id ) { |
325 | | - $s = wfMsgExt('nosuchusershort',array('parse'),$user); |
| 328 | + $s = wfMsgExt( 'nosuchusershort', array( 'parse' ), $user ); |
326 | 329 | $wgOut->addHTML( $s ); |
327 | 330 | return; |
328 | 331 | } |
329 | 332 | |
330 | 333 | # Record check... |
331 | 334 | 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>' ); |
333 | 336 | } |
334 | 337 | $dbr = wfGetDB( DB_SLAVE ); |
335 | 338 | $time_conds = $this->getTimeConds( $period ); |
— | — | @@ -339,17 +342,17 @@ |
340 | 343 | MIN(cuc_timestamp) AS first, MAX(cuc_timestamp) AS last |
341 | 344 | FROM $cu_changes $use_index WHERE cuc_user = $user_id AND $time_conds |
342 | 345 | GROUP BY cuc_ip,cuc_ip_hex ORDER BY last DESC LIMIT 5001"; |
343 | | - |
| 346 | + |
344 | 347 | $ret = $dbr->query( $sql, __METHOD__ ); |
345 | 348 | if( !$dbr->numRows( $ret ) ) { |
346 | | - $s = $this->noMatchesMessage($user)."\n"; |
| 349 | + $s = $this->noMatchesMessage( $user ) . "\n"; |
347 | 350 | } else { |
348 | 351 | $blockip = SpecialPage::getTitleFor( 'Blockip' ); |
349 | 352 | $ips_edits = array(); |
350 | 353 | $counter = 0; |
351 | | - while( $row = $dbr->fetchObject($ret) ) { |
| 354 | + while( $row = $dbr->fetchObject( $ret ) ) { |
352 | 355 | if( $counter >= 5000 ) { |
353 | | - $wgOut->addHTML( wfMsgExt('checkuser-limited',array('parse')) ); |
| 356 | + $wgOut->addHTML( wfMsgExt( 'checkuser-limited', array( 'parse' ) ) ); |
354 | 357 | break; |
355 | 358 | } |
356 | 359 | $ips_edits[$row->cuc_ip] = $row->count; |
— | — | @@ -360,26 +363,26 @@ |
361 | 364 | } |
362 | 365 | // Count pinging might take some time...make sure it is there |
363 | 366 | wfSuppressWarnings(); |
364 | | - set_time_limit(60); |
| 367 | + set_time_limit( 60 ); |
365 | 368 | wfRestoreWarnings(); |
366 | | - |
| 369 | + |
367 | 370 | $logs = SpecialPage::getTitleFor( 'Log' ); |
368 | 371 | $s = '<div id="checkuserresults"><ul>'; |
369 | 372 | foreach( $ips_edits as $ip => $edits ) { |
370 | 373 | $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>)'; |
376 | 379 | 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 ) . ') '; |
378 | 381 | } 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 ) . ') '; |
381 | 384 | } |
382 | 385 | $s .= ' <strong>[' . $edits . ']</strong>'; |
383 | | - |
| 386 | + |
384 | 387 | # If we get some results, it helps to know if the IP in general |
385 | 388 | # has a lot more edits, e.g. "tip of the iceberg"... |
386 | 389 | $ipedits = $dbr->estimateRowCount( 'cu_changes', '*', |
— | — | @@ -392,14 +395,14 @@ |
393 | 396 | __METHOD__ ); |
394 | 397 | } |
395 | 398 | if( $ipedits > $ips_edits[$ip] ) { |
396 | | - $s .= ' <i>(' . wfMsgHtml('checkuser-ipeditcount',$ipedits) . ')</i>'; |
| 399 | + $s .= ' <i>(' . wfMsgHtml( 'checkuser-ipeditcount', $ipedits ) . ')</i>'; |
397 | 400 | } |
398 | | - |
| 401 | + |
399 | 402 | # If this IP is blocked, give a link to the block log |
400 | 403 | $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>'; |
404 | 407 | $s .= "</li>\n"; |
405 | 408 | } |
406 | 409 | $s .= '</ul></div>'; |
— | — | @@ -407,25 +410,25 @@ |
408 | 411 | $wgOut->addHTML( $s ); |
409 | 412 | $dbr->freeResult( $ret ); |
410 | 413 | } |
411 | | - |
| 414 | + |
412 | 415 | protected function getIPBlockInfo( $ip ) { |
413 | 416 | static $blocklist; |
414 | 417 | $blocklist = SpecialPage::getTitleFor( 'Ipblocklist' ); |
415 | 418 | $block = new Block(); |
416 | 419 | $block->fromMaster( false ); // use slaves |
417 | 420 | if( $block->load( $ip, 0 ) ) { |
418 | | - if( IP::isIPAddress($block->mAddress) && strpos($block->mAddress,'/') ) { |
| 421 | + if( IP::isIPAddress( $block->mAddress ) && strpos( $block->mAddress, '/' ) ) { |
419 | 422 | $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' ), |
421 | 424 | 'type=block&page=' . urlencode( $userpage->getPrefixedText() ) ); |
422 | 425 | 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' ), |
425 | 428 | 'ip=' . urlencode( "#$block->mId" ) ); |
426 | 429 | return ' <strong>(' . $blocklog . ')</strong>'; |
427 | 430 | } else { |
428 | 431 | $userpage = Title::makeTitle( NS_USER, $ip ); |
429 | | - $blocklog = $this->sk->makeKnownLinkObj( $logs, wfMsgHtml('checkuser-blocked'), |
| 432 | + $blocklog = $this->sk->makeKnownLinkObj( $logs, wfMsgHtml( 'checkuser-blocked' ), |
430 | 433 | 'type=block&page=' . urlencode( $userpage->getPrefixedText() ) ); |
431 | 434 | return ' <strong>(' . $blocklog . ')</strong>'; |
432 | 435 | } |
— | — | @@ -465,7 +468,7 @@ |
466 | 469 | # Check how many rows will need sorting ahead of time to see if this is too big. |
467 | 470 | # Also, if we only show 5000, too many will be ignored as well. |
468 | 471 | $index = $xfor ? 'cuc_xff_hex_time' : 'cuc_ip_hex_time'; |
469 | | - if( strpos($ip,'/') !== false ) { |
| 472 | + if( strpos( $ip, '/' ) !== false ) { |
470 | 473 | # Quick index check only OK if no time constraint |
471 | 474 | if( $period ) { |
472 | 475 | $rangecount = $dbr->selectField( 'cu_changes', 'COUNT(*)', |
— | — | @@ -480,12 +483,12 @@ |
481 | 484 | } |
482 | 485 | // Sorting might take some time...make sure it is there |
483 | 486 | wfSuppressWarnings(); |
484 | | - set_time_limit(60); |
| 487 | + set_time_limit( 60 ); |
485 | 488 | wfRestoreWarnings(); |
486 | 489 | } |
487 | 490 | $counter = 0; |
488 | 491 | # See what is best to do after testing the waters... |
489 | | - if( isset($rangecount) && $rangecount > 5000 ) { |
| 492 | + if( isset( $rangecount ) && $rangecount > 5000 ) { |
490 | 493 | $use_index = $dbr->useIndexClause( $index ); |
491 | 494 | $sql = "SELECT cuc_ip_hex, COUNT(*) AS count, |
492 | 495 | MIN(cuc_timestamp) AS first, MAX(cuc_timestamp) AS last |
— | — | @@ -494,39 +497,39 @@ |
495 | 498 | GROUP BY cuc_ip_hex ORDER BY cuc_ip_hex LIMIT 5001"; |
496 | 499 | $ret = $dbr->query( $sql, __METHOD__ ); |
497 | 500 | # List out each IP that has edits |
498 | | - $s = wfMsgExt('checkuser-too-many',array('parse')); |
| 501 | + $s = wfMsgExt( 'checkuser-too-many', array( 'parse' ) ); |
499 | 502 | $s .= '<ol>'; |
500 | 503 | while( $row = $ret->fetchObject() ) { |
501 | 504 | if( $counter >= 5000 ) { |
502 | | - $wgOut->addHTML( wfMsgExt('checkuser-limited',array('parse')) ); |
| 505 | + $wgOut->addHTML( wfMsgExt( 'checkuser-limited', array( 'parse' ) ) ); |
503 | 506 | break; |
504 | 507 | } |
505 | 508 | # 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 ) { |
507 | 510 | $ip = substr( $row->cuc_ip_hex, 3 ); |
508 | 511 | $ip = IP::HextoOctet( $ip ); |
509 | 512 | } else { |
510 | | - $ip = long2ip( wfBaseConvert($row->cuc_ip_hex, 16, 10, 8) ); |
| 513 | + $ip = long2ip( wfBaseConvert( $row->cuc_ip_hex, 16, 10, 8 ) ); |
511 | 514 | } |
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>'; |
515 | 518 | 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 ) . ') '; |
517 | 520 | } 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 ) . ') '; |
520 | 523 | } |
521 | | - $s .= " [<strong>" . $row->count . "</strong>]</li>\n"; |
| 524 | + $s .= ' [<strong>' . $row->count . "</strong>]</li>\n"; |
522 | 525 | ++$counter; |
523 | 526 | } |
524 | 527 | $s .= '</ol>'; |
525 | 528 | $dbr->freeResult( $ret ); |
526 | | - |
| 529 | + |
527 | 530 | $wgOut->addHTML( $s ); |
528 | 531 | return; |
529 | | - } else if( isset($rangecount) && !$rangecount ) { |
530 | | - $s = $this->noMatchesMessage($ip)."\n"; |
| 532 | + } elseif( isset( $rangecount ) && !$rangecount ) { |
| 533 | + $s = $this->noMatchesMessage( $ip ) . "\n"; |
531 | 534 | $wgOut->addHTML( $s ); |
532 | 535 | return; |
533 | 536 | } |
— | — | @@ -538,7 +541,7 @@ |
539 | 542 | $ret = $dbr->query( $sql, __METHOD__ ); |
540 | 543 | |
541 | 544 | if( !$dbr->numRows( $ret ) ) { |
542 | | - $s = $this->noMatchesMessage($ip)."\n"; |
| 545 | + $s = $this->noMatchesMessage( $ip ) . "\n"; |
543 | 546 | } else { |
544 | 547 | # Cache common messages |
545 | 548 | $this->preCacheMessages(); |
— | — | @@ -556,7 +559,7 @@ |
557 | 560 | $s = '<div id="checkuserresults">'; |
558 | 561 | while( $row = $ret->fetchObject() ) { |
559 | 562 | if( $counter >= 5000 ) { |
560 | | - $wgOut->addHTML( wfMsgExt('checkuser-limited',array('parse')) ); |
| 563 | + $wgOut->addHTML( wfMsgExt( 'checkuser-limited', array( 'parse' ) ) ); |
561 | 564 | break; |
562 | 565 | } |
563 | 566 | $s .= $this->CUChangesLine( $row, $reason ); |
— | — | @@ -568,9 +571,9 @@ |
569 | 572 | |
570 | 573 | $wgOut->addHTML( $s ); |
571 | 574 | } |
572 | | - |
| 575 | + |
573 | 576 | /** |
574 | | - * @param string $nuser |
| 577 | + * @param string $user |
575 | 578 | * @param string $reason |
576 | 579 | * Shows all edits in Recent Changes by this user |
577 | 580 | */ |
— | — | @@ -588,18 +591,18 @@ |
589 | 592 | return; |
590 | 593 | } |
591 | 594 | # Get ID, works better than text as user may have been renamed |
592 | | - $user_id = User::idFromName($user); |
| 595 | + $user_id = User::idFromName( $user ); |
593 | 596 | |
594 | 597 | # If user is not IP or nonexistent |
595 | 598 | if( !$user_id ) { |
596 | | - $s = wfMsgExt('nosuchusershort',array('parse'),$user); |
| 599 | + $s = wfMsgExt( 'nosuchusershort', array( 'parse' ), $user ); |
597 | 600 | $wgOut->addHTML( $s ); |
598 | 601 | return; |
599 | 602 | } |
600 | 603 | |
601 | 604 | # Record check... |
602 | 605 | 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>' ); |
604 | 607 | } |
605 | 608 | |
606 | 609 | $dbr = wfGetDB( DB_SLAVE ); |
— | — | @@ -624,7 +627,7 @@ |
625 | 628 | $this->preCacheMessages(); |
626 | 629 | # See what is best to do after testing the waters... |
627 | 630 | if( $count > 5000 ) { |
628 | | - $wgOut->addHTML( wfMsgExt('checkuser-limited',array('parse')) ); |
| 631 | + $wgOut->addHTML( wfMsgExt( 'checkuser-limited', array( 'parse' ) ) ); |
629 | 632 | $use_index = $dbr->useIndexClause( 'cuc_user_ip_time' ); |
630 | 633 | $sql = "SELECT * FROM $cu_changes $use_index |
631 | 634 | WHERE $user_cond AND $time_conds |
— | — | @@ -639,16 +642,16 @@ |
640 | 643 | $ret->seek( 0 ); |
641 | 644 | $s = ''; |
642 | 645 | while( $row = $ret->fetchObject() ) { |
643 | | - if( !$ip = htmlspecialchars($row->cuc_ip) ) { |
| 646 | + if( !$ip = htmlspecialchars( $row->cuc_ip ) ) { |
644 | 647 | continue; |
645 | 648 | } |
646 | | - if( !isset($lastIP) ) { |
| 649 | + if( !isset( $lastIP ) ) { |
647 | 650 | $lastIP = $row->cuc_ip; |
648 | 651 | $s .= "\n<h2>$ip</h2>\n<div class=\"special\">"; |
649 | | - } else if( $lastIP != $row->cuc_ip ) { |
| 652 | + } elseif( $lastIP != $row->cuc_ip ) { |
650 | 653 | $s .= "</ul></div>\n<h2>$ip</h2>\n<div class=\"special\">"; |
651 | 654 | $lastIP = $row->cuc_ip; |
652 | | - unset($this->lastdate); // start over |
| 655 | + unset( $this->lastdate ); // start over |
653 | 656 | } |
654 | 657 | $s .= $this->CUChangesLine( $row, $reason ); |
655 | 658 | } |
— | — | @@ -660,7 +663,7 @@ |
661 | 664 | } |
662 | 665 | // Sorting might take some time...make sure it is there |
663 | 666 | wfSuppressWarnings(); |
664 | | - set_time_limit(60); |
| 667 | + set_time_limit( 60 ); |
665 | 668 | wfRestoreWarnings(); |
666 | 669 | # OK, do the real query... |
667 | 670 | $use_index = $dbr->useIndexClause( 'cuc_user_ip_time' ); |
— | — | @@ -669,7 +672,7 @@ |
670 | 673 | $ret = $dbr->query( $sql, __METHOD__ ); |
671 | 674 | |
672 | 675 | if( !$dbr->numRows( $ret ) ) { |
673 | | - $s = $this->noMatchesMessage($user)."\n"; |
| 676 | + $s = $this->noMatchesMessage( $user ) . "\n"; |
674 | 677 | } else { |
675 | 678 | # Try to optimize this query |
676 | 679 | $lb = new LinkBatch; |
— | — | @@ -701,7 +704,7 @@ |
702 | 705 | * Outputs usernames, latest and earliest found edit date, and count |
703 | 706 | * List unique IPs used for each user in time order, list corresponding user agent |
704 | 707 | */ |
705 | | - protected function doIPUsersRequest( $ip, $xfor = false, $reason = '', $period = 0, $tag='', $talkTag='' ) { |
| 708 | + protected function doIPUsersRequest( $ip, $xfor = false, $reason = '', $period = 0, $tag = '', $talkTag = '' ) { |
706 | 709 | global $wgUser, $wgOut, $wgLang; |
707 | 710 | $dbr = wfGetDB( DB_SLAVE ); |
708 | 711 | # Invalid IPs are passed in as a blank string |
— | — | @@ -726,7 +729,7 @@ |
727 | 730 | $index = $xfor ? 'cuc_xff_hex_time' : 'cuc_ip_hex_time'; |
728 | 731 | # Ordered in descent by timestamp. Can cause large filesorts on range scans. |
729 | 732 | # 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 ) { |
731 | 734 | # Quick index check only OK if no time constraint |
732 | 735 | if( $period ) { |
733 | 736 | $rangecount = $dbr->selectField( 'cu_changes', 'COUNT(*)', |
— | — | @@ -741,11 +744,11 @@ |
742 | 745 | } |
743 | 746 | // Sorting might take some time...make sure it is there |
744 | 747 | wfSuppressWarnings(); |
745 | | - set_time_limit(120); |
| 748 | + set_time_limit( 120 ); |
746 | 749 | wfRestoreWarnings(); |
747 | 750 | } |
748 | 751 | // Are there too many edits? |
749 | | - if( isset($rangecount) && $rangecount > 10000 ) { |
| 752 | + if( isset( $rangecount ) && $rangecount > 10000 ) { |
750 | 753 | $use_index = $dbr->useIndexClause( $index ); |
751 | 754 | $sql = "SELECT cuc_ip_hex, COUNT(*) AS count, |
752 | 755 | MIN(cuc_timestamp) AS first, MAX(cuc_timestamp) AS last |
— | — | @@ -753,31 +756,31 @@ |
754 | 757 | GROUP BY cuc_ip_hex ORDER BY cuc_ip_hex LIMIT 5001"; |
755 | 758 | $ret = $dbr->query( $sql, __METHOD__ ); |
756 | 759 | # List out each IP that has edits |
757 | | - $s = '<h5>' . wfMsg('checkuser-too-many') . '</h5>'; |
| 760 | + $s = '<h5>' . wfMsg( 'checkuser-too-many' ) . '</h5>'; |
758 | 761 | $s .= '<ol>'; |
759 | 762 | $counter = 0; |
760 | 763 | while( $row = $ret->fetchObject() ) { |
761 | 764 | if( $counter >= 5000 ) { |
762 | | - $wgOut->addHTML( wfMsgExt('checkuser-limited',array('parse')) ); |
| 765 | + $wgOut->addHTML( wfMsgExt( 'checkuser-limited', array( 'parse' ) ) ); |
763 | 766 | break; |
764 | 767 | } |
765 | 768 | # 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 ) { |
767 | 770 | $ip = substr( $row->cuc_ip_hex, 3 ); |
768 | 771 | $ip = IP::HextoOctet( $ip ); |
769 | 772 | } else { |
770 | | - $ip = long2ip( wfBaseConvert($row->cuc_ip_hex, 16, 10, 8) ); |
| 773 | + $ip = long2ip( wfBaseConvert( $row->cuc_ip_hex, 16, 10, 8 ) ); |
771 | 774 | } |
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>'; |
775 | 778 | 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 ) . ') '; |
777 | 780 | } 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 ) . ') '; |
780 | 783 | } |
781 | | - $s .= " [<strong>" . $row->count . "</strong>]</li>\n"; |
| 784 | + $s .= ' [<strong>' . $row->count . "</strong>]</li>\n"; |
782 | 785 | ++$counter; |
783 | 786 | } |
784 | 787 | $s .= '</ol>'; |
— | — | @@ -785,8 +788,8 @@ |
786 | 789 | |
787 | 790 | $wgOut->addHTML( $s ); |
788 | 791 | return; |
789 | | - } else if( isset($rangecount) && !$rangecount ) { |
790 | | - $s = $this->noMatchesMessage($ip)."\n"; |
| 792 | + } elseif( isset( $rangecount ) && !$rangecount ) { |
| 793 | + $s = $this->noMatchesMessage( $ip ) . "\n"; |
791 | 794 | $wgOut->addHTML( $s ); |
792 | 795 | return; |
793 | 796 | } |
— | — | @@ -801,10 +804,10 @@ |
802 | 805 | |
803 | 806 | $users_first = $users_last = $users_edits = $users_ids = array(); |
804 | 807 | if( !$dbr->numRows( $ret ) ) { |
805 | | - $s = $this->noMatchesMessage($ip)."\n"; |
| 808 | + $s = $this->noMatchesMessage( $ip ) . "\n"; |
806 | 809 | } else { |
807 | 810 | global $wgAuth; |
808 | | - while( ($row = $dbr->fetchObject($ret) ) != false ) { |
| 811 | + while( ( $row = $dbr->fetchObject( $ret ) ) != false ) { |
809 | 812 | if( !array_key_exists( $row->cuc_user_text, $users_edits ) ) { |
810 | 813 | $users_last[$row->cuc_user_text] = $row->cuc_timestamp; |
811 | 814 | $users_edits[$row->cuc_user_text] = 0; |
— | — | @@ -815,22 +818,22 @@ |
816 | 819 | $users_edits[$row->cuc_user_text] += 1; |
817 | 820 | $users_first[$row->cuc_user_text] = $row->cuc_timestamp; |
818 | 821 | # 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; |
820 | 823 | $xff_ip_combo = array( $row->cuc_ip, $xff ); |
821 | 824 | # 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] ) ) { |
823 | 826 | $users_infosets[$row->cuc_user_text][] = $xff_ip_combo; |
824 | 827 | } |
825 | 828 | # 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] ) ) { |
828 | 831 | $users_agentsets[$row->cuc_user_text][] = $row->cuc_agent; |
829 | 832 | } |
830 | 833 | } |
831 | 834 | } |
832 | 835 | $dbr->freeResult( $ret ); |
833 | 836 | |
834 | | - $action = $this->getTitle()->escapeLocalUrl( 'action=block' ); |
| 837 | + $action = $this->getTitle()->escapeLocalURL( 'action=block' ); |
835 | 838 | $s = "<form name='checkuserblock' id='checkuserblock' action=\"$action\" method='post'>"; |
836 | 839 | $s .= '<div id="checkuserresults"><ul>'; |
837 | 840 | foreach( $users_edits as $name => $count ) { |
— | — | @@ -841,14 +844,14 @@ |
842 | 845 | # Add user tool links |
843 | 846 | $s .= $this->sk->userLink( -1 , $name ) . $this->sk->userToolLinks( -1 , $name ); |
844 | 847 | # 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>)'; |
847 | 850 | # Show edit time range |
848 | 851 | 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 ) . ') '; |
850 | 853 | } 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 ) . ') '; |
853 | 856 | } |
854 | 857 | # Total edit count |
855 | 858 | $s .= ' [<strong>' . $count . '</strong>]<br />'; |
— | — | @@ -858,12 +861,12 @@ |
859 | 862 | # Show if account is local only |
860 | 863 | $authUser = $wgAuth->getUserInstance( $user ); |
861 | 864 | if( $user->getId() && $authUser->getId() === 0 ) { |
862 | | - $flags[] = '<strong>(' . wfMsgHtml('checkuser-localonly') . ')</strong>'; |
| 865 | + $flags[] = '<strong>(' . wfMsgHtml( 'checkuser-localonly' ) . ')</strong>'; |
863 | 866 | } |
864 | 867 | # Check for extra user rights... |
865 | 868 | if( $users_ids[$name] ) { |
866 | 869 | if( $user->isLocked() ) { |
867 | | - $flags[] = '<b>(' . wfMsgHtml('checkuser-locked') . ')</b>'; |
| 870 | + $flags[] = '<b>(' . wfMsgHtml( 'checkuser-locked' ) . ')</b>'; |
868 | 871 | } |
869 | 872 | $list = array(); |
870 | 873 | foreach( $user->getGroups() as $group ) { |
— | — | @@ -882,53 +885,53 @@ |
883 | 886 | $flags[] = '<strong>[' . wfMsgExt( 'checkuser-accounts', 'parsemag', $wgLang->formatNum( $count ) ) . ']</strong>'; |
884 | 887 | } |
885 | 888 | } |
886 | | - $s .= implode(' ',$flags); |
| 889 | + $s .= implode( ' ', $flags ); |
887 | 890 | $s .= '<ol>'; |
888 | 891 | # 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-- ) { |
890 | 893 | $set = $users_infosets[$name][$i]; |
891 | 894 | # IP link |
892 | 895 | $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>'; |
894 | 897 | # XFF string, link to /xff search |
895 | 898 | if( $set[1] ) { |
896 | 899 | # Flag our trusted proxies |
897 | | - list($client,$trusted) = efGetClientIPfromXFF($set[1],$set[0]); |
| 900 | + list( $client, $trusted ) = efGetClientIPfromXFF( $set[1], $set[0] ); |
898 | 901 | $c = $trusted ? '#F0FFF0' : '#FFFFCC'; |
899 | | - $s .= ' <span style="background-color: '.$c.'"><strong>XFF</strong>: '; |
| 902 | + $s .= ' <span style="background-color: ' . $c . '"><strong>XFF</strong>: '; |
900 | 903 | $s .= $this->sk->makeKnownLinkObj( $this->getTitle(), |
901 | 904 | htmlspecialchars( $set[1] ), |
902 | | - "user=" . urlencode( $client ) . "/xff" )."</span>"; |
| 905 | + 'user=' . urlencode( $client ) . '/xff' ) . '</span>'; |
903 | 906 | } |
904 | 907 | $s .= "</li>\n"; |
905 | 908 | } |
906 | 909 | $s .= '</ol><br /><ol>'; |
907 | 910 | # 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-- ) { |
909 | 912 | $agent = $users_agentsets[$name][$i]; |
910 | | - $s .= "<li><i>" . htmlspecialchars($agent) . "</i></li>\n"; |
| 913 | + $s .= '<li><i>' . htmlspecialchars( $agent ) . "</i></li>\n"; |
911 | 914 | } |
912 | 915 | $s .= '</ol>'; |
913 | 916 | $s .= '</li>'; |
914 | 917 | } |
915 | 918 | $s .= "</ul></div>\n"; |
916 | | - if( $wgUser->isAllowed('block') && !$wgUser->isBlocked() ) { |
| 919 | + if( $wgUser->isAllowed( 'block' ) && !$wgUser->isBlocked() ) { |
917 | 920 | $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"; |
920 | 923 | $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>' . |
924 | 927 | '</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>'. |
928 | 931 | '</tr></table>'; |
929 | | - $s .= "<p>" . wfMsgHtml( "checkuser-reason" ) . ' '; |
| 932 | + $s .= '<p>' . wfMsgHtml( 'checkuser-reason' ) . ' '; |
930 | 933 | $s .= Xml::input( 'blockreason', 46, '', array( 'maxlength' => '150', 'id' => 'blockreason' ) ); |
931 | | - $s .= ' ' . Xml::submitButton( wfMsgHtml('checkuser-massblock-commit'), |
932 | | - array('id' => 'checkuserblocksubmit','name' => 'checkuserblock') ) . "</p>\n"; |
| 934 | + $s .= ' ' . Xml::submitButton( wfMsgHtml( 'checkuser-massblock-commit' ), |
| 935 | + array( 'id' => 'checkuserblocksubmit', 'name' => 'checkuserblock' ) ) . "</p>\n"; |
933 | 936 | $s .= "</fieldset>\n"; |
934 | 937 | } |
935 | 938 | $s .= '</form>'; |
— | — | @@ -936,7 +939,7 @@ |
937 | 940 | |
938 | 941 | $wgOut->addHTML( $s ); |
939 | 942 | } |
940 | | - |
| 943 | + |
941 | 944 | protected function userBlockFlags( $ip, $userId, $user ) { |
942 | 945 | static $logs, $blocklist; |
943 | 946 | $logs = SpecialPage::getTitleFor( 'Log' ); |
— | — | @@ -946,28 +949,28 @@ |
947 | 950 | $flags = array(); |
948 | 951 | if( $block->load( $ip, $userId ) ) { |
949 | 952 | // Range blocked? |
950 | | - if( IP::isIPAddress($block->mAddress) && strpos($block->mAddress,'/') ) { |
| 953 | + if( IP::isIPAddress( $block->mAddress ) && strpos( $block->mAddress, '/' ) ) { |
951 | 954 | $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' ), |
953 | 956 | 'type=block&page=' . urlencode( $userpage->getPrefixedText() ) ); |
954 | 957 | $flags[] = '<strong>(' . $blocklog . ' - ' . $block->mAddress . ')</strong>'; |
955 | 958 | // Auto blocked? |
956 | | - } else if( $block->mAuto ) { |
| 959 | + } elseif( $block->mAuto ) { |
957 | 960 | $blocklog = $this->sk->makeKnownLinkObj( $blocklist, |
958 | | - wfMsgHtml('checkuser-blocked'), 'ip=' . urlencode( "#{$block->mId}" ) ); |
| 961 | + wfMsgHtml( 'checkuser-blocked' ), 'ip=' . urlencode( "#{$block->mId}" ) ); |
959 | 962 | $flags[] = '<strong>(' . $blocklog . ')</strong>'; |
960 | 963 | } else { |
961 | 964 | $userpage = $user->getUserPage(); |
962 | | - $blocklog = $this->sk->makeKnownLinkObj( $logs, wfMsgHtml('checkuser-blocked'), |
| 965 | + $blocklog = $this->sk->makeKnownLinkObj( $logs, wfMsgHtml( 'checkuser-blocked' ), |
963 | 966 | 'type=block&page=' . urlencode( $userpage->getPrefixedText() ) ); |
964 | 967 | $flags[] = '<strong>(' . $blocklog . ')</strong>'; |
965 | 968 | } |
966 | 969 | // 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() ) ) { |
970 | 973 | $userpage = $user->getUserPage(); |
971 | | - $blocklog = $this->sk->makeKnownLinkObj( $logs, wfMsgHtml('checkuser-wasblocked'), |
| 974 | + $blocklog = $this->sk->makeKnownLinkObj( $logs, wfMsgHtml( 'checkuser-wasblocked' ), |
972 | 975 | 'type=block&page=' . urlencode( $userpage->getPrefixedText() ) ); |
973 | 976 | $flags[] = '<strong>(' . $blocklog . ')</strong>'; |
974 | 977 | } |
— | — | @@ -984,26 +987,26 @@ |
985 | 988 | static $cuTitle, $flagCache; |
986 | 989 | $cuTitle = SpecialPage::getTitleFor( 'CheckUser' ); |
987 | 990 | # 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 ) ) { |
990 | 993 | $this->lastdate = $date; |
991 | 994 | $line = "\n<h4>$date</h4>\n<ul class=\"special\">"; |
992 | | - } else if( $date != $this->lastdate ) { |
| 995 | + } elseif( $date != $this->lastdate ) { |
993 | 996 | $line = "</ul>\n<h4>$date</h4>\n<ul class=\"special\">"; |
994 | 997 | $this->lastdate = $date; |
995 | 998 | } else { |
996 | 999 | $line = ''; |
997 | 1000 | } |
998 | | - $line .= "<li>"; |
| 1001 | + $line .= '<li>'; |
999 | 1002 | # Create diff/hist/page links |
1000 | 1003 | $line .= $this->getLinksFromRow( $row ); |
1001 | 1004 | # 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 ) . ' . . '; |
1003 | 1006 | # Userlinks |
1004 | 1007 | $line .= $this->sk->userLink( $row->cuc_user, $row->cuc_user_text ); |
1005 | 1008 | $line .= $this->sk->userToolLinks( $row->cuc_user, $row->cuc_user_text ); |
1006 | 1009 | # Get block info |
1007 | | - if( isset($flagCache[$row->cuc_user_text]) ) { |
| 1010 | + if( isset( $flagCache[$row->cuc_user_text] ) ) { |
1008 | 1011 | $flags = $flagCache[$row->cuc_user_text]; |
1009 | 1012 | } else { |
1010 | 1013 | $user = User::newFromName( $row->cuc_user_text, false ); |
— | — | @@ -1012,31 +1015,34 @@ |
1013 | 1016 | $flagCache[$row->cuc_user_text] = $flags; |
1014 | 1017 | } |
1015 | 1018 | # Add any block information |
1016 | | - if( count($flags) ) $line .= ' ' . implode(' ',$flags); |
| 1019 | + if( count( $flags ) ) { |
| 1020 | + $line .= ' ' . implode( ' ', $flags ); |
| 1021 | + } |
1017 | 1022 | # Action text, hackish ... |
1018 | | - if( $row->cuc_actiontext ) |
| 1023 | + if( $row->cuc_actiontext ) { |
1019 | 1024 | $line .= ' ' . $this->sk->formatComment( $row->cuc_actiontext ) . ' '; |
| 1025 | + } |
1020 | 1026 | # Comment |
1021 | 1027 | $line .= $this->sk->commentBlock( $row->cuc_comment ); |
1022 | 1028 | $line .= '<br /> <small>'; |
1023 | 1029 | # 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 ) ); |
1026 | 1032 | # XFF |
1027 | | - if( $row->cuc_xff !=null ) { |
| 1033 | + if( $row->cuc_xff != null ) { |
1028 | 1034 | # 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 ); |
1030 | 1036 | $c = $trusted ? '#F0FFF0' : '#FFFFCC'; |
1031 | | - $line .= ' <span class="mw-checkuser-xff" style="background-color: '.$c.'">'. |
| 1037 | + $line .= ' <span class="mw-checkuser-xff" style="background-color: ' . $c . '">' . |
1032 | 1038 | '<strong>XFF</strong>: '; |
1033 | 1039 | $line .= $this->sk->makeKnownLinkObj( $cuTitle, |
1034 | 1040 | htmlspecialchars( $row->cuc_xff ), |
1035 | | - "user=".urlencode($client)."/xff&reason=".urlencode($reason) )."</span>"; |
| 1041 | + 'user=' . urlencode( $client ) . '/xff&reason=' . urlencode( $reason ) ) . '</span>'; |
1036 | 1042 | } |
1037 | 1043 | # User agent |
1038 | | - $line .= ' <span class="mw-checkuser-agent" style="color:#888;">' . |
1039 | | - htmlspecialchars( $row->cuc_agent )."</span>"; |
1040 | | - |
| 1044 | + $line .= ' <span class="mw-checkuser-agent" style="color:#888;">' . |
| 1045 | + htmlspecialchars( $row->cuc_agent ) . '</span>'; |
| 1046 | + |
1041 | 1047 | $line .= "</small></li>\n"; |
1042 | 1048 | |
1043 | 1049 | return $line; |
— | — | @@ -1057,7 +1063,7 @@ |
1058 | 1064 | } elseif( $row->cuc_type == RC_LOG ) { |
1059 | 1065 | $title = Title::makeTitle( $row->cuc_namespace, $row->cuc_title ); |
1060 | 1066 | $links = '(' . $this->sk->makeKnownLinkObj( SpecialPage::getTitleFor( 'Log' ), $this->message['log'], |
1061 | | - wfArrayToCGI( array('page' => $title->getPrefixedText() ) ) ) . ')'; |
| 1067 | + wfArrayToCGI( array( 'page' => $title->getPrefixedText() ) ) ) . ')'; |
1062 | 1068 | } else { |
1063 | 1069 | $title = Title::makeTitle( $row->cuc_namespace, $row->cuc_title ); |
1064 | 1070 | # New pages |
— | — | @@ -1077,27 +1083,29 @@ |
1078 | 1084 | 'curid' => $row->cuc_page_id, |
1079 | 1085 | 'action' => 'history' ) ) ) . ') . . '; |
1080 | 1086 | # Some basic flags |
1081 | | - if( $row->cuc_type == RC_NEW ) |
| 1087 | + if( $row->cuc_type == RC_NEW ) { |
1082 | 1088 | $links .= '<span class="newpage">' . $this->message['newpageletter'] . '</span>'; |
1083 | | - if( $row->cuc_minor ) |
| 1089 | + } |
| 1090 | + if( $row->cuc_minor ) { |
1084 | 1091 | $links .= '<span class="minor">' . $this->message['minoreditletter'] . '</span>'; |
| 1092 | + } |
1085 | 1093 | # Page link |
1086 | 1094 | $links .= ' ' . $this->sk->makeLinkObj( $title ); |
1087 | 1095 | } |
1088 | 1096 | return $links; |
1089 | 1097 | } |
1090 | | - |
| 1098 | + |
1091 | 1099 | protected static function userWasBlocked( $name ) { |
1092 | 1100 | $userpage = Title::makeTitle( NS_USER, $name ); |
1093 | 1101 | return wfGetDB( DB_SLAVE )->selectField( 'logging', '1', |
1094 | | - array( 'log_type' => array('block','suppress'), |
| 1102 | + array( 'log_type' => array( 'block', 'suppress' ), |
1095 | 1103 | 'log_action' => 'block', |
1096 | 1104 | 'log_namespace' => $userpage->getNamespace(), |
1097 | 1105 | 'log_title' => $userpage->getDBkey() ), |
1098 | 1106 | __METHOD__, |
1099 | 1107 | array( 'USE INDEX' => 'page_time' ) ); |
1100 | 1108 | } |
1101 | | - |
| 1109 | + |
1102 | 1110 | /** |
1103 | 1111 | * Format a link to a group description page |
1104 | 1112 | * |
— | — | @@ -1106,8 +1114,9 @@ |
1107 | 1115 | */ |
1108 | 1116 | protected static function buildGroupLink( $group ) { |
1109 | 1117 | static $cache = array(); |
1110 | | - if( !isset( $cache[$group] ) ) |
| 1118 | + if( !isset( $cache[$group] ) ) { |
1111 | 1119 | $cache[$group] = User::makeGroupLinkHtml( $group, User::getGroupMember( $group ) ); |
| 1120 | + } |
1112 | 1121 | return $cache[$group]; |
1113 | 1122 | } |
1114 | 1123 | |
— | — | @@ -1121,36 +1130,38 @@ |
1122 | 1131 | $type = ( $xfor ) ? 'xff' : 'ip'; |
1123 | 1132 | // IPv4 CIDR, 16-32 bits |
1124 | 1133 | 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 ) { |
1126 | 1135 | return false; // invalid |
| 1136 | + } |
1127 | 1137 | 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 ) ) { |
1130 | 1140 | // IPv6 CIDR, 96-128 bits |
1131 | | - if( $matches[1] < 96 || $matches[1] > 128 ) |
| 1141 | + if( $matches[1] < 96 || $matches[1] > 128 ) { |
1132 | 1142 | return false; // invalid |
| 1143 | + } |
1133 | 1144 | 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 ) ) { |
1136 | 1147 | // 32 bit IPv4 |
1137 | 1148 | $ip_hex = IP::toHex( $ip ); |
1138 | 1149 | 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 ) ) { |
1140 | 1151 | // 128 bit IPv6 |
1141 | 1152 | $ip_hex = IP::toHex( $ip ); |
1142 | | - return array( 'cuc_'.$type.'_hex' => $ip_hex ); |
| 1153 | + return array( 'cuc_' . $type . '_hex' => $ip_hex ); |
1143 | 1154 | } |
1144 | 1155 | // throw away this query, incomplete IP, these don't get through the entry point anyway |
1145 | 1156 | return false; // invalid |
1146 | 1157 | } |
1147 | | - |
| 1158 | + |
1148 | 1159 | protected function getTimeConds( $period ) { |
1149 | 1160 | if( !$period ) { |
1150 | | - return "1 = 1"; |
| 1161 | + return '1 = 1'; |
1151 | 1162 | } |
1152 | 1163 | $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 ); |
1155 | 1166 | $cutoff = $dbr->addQuotes( $dbr->timestamp( $cutoff_unixtime ) ); |
1156 | 1167 | return "cuc_timestamp > $cutoff"; |
1157 | 1168 | } |
— | — | @@ -1164,7 +1175,7 @@ |
1165 | 1176 | $error = false; |
1166 | 1177 | $dbr = wfGetDB( DB_SLAVE ); |
1167 | 1178 | $searchConds = false; |
1168 | | - |
| 1179 | + |
1169 | 1180 | $wgOut->setPageTitle( wfMsg( 'checkuser-log' ) ); |
1170 | 1181 | |
1171 | 1182 | $wgOut->addHTML( $this->sk->makeKnownLinkObj( $this->getTitle(), wfMsgHtml( 'checkuser-log-return' ) ) ); |
— | — | @@ -1187,7 +1198,7 @@ |
1188 | 1199 | $searchConds = array( 'cul_target_hex = ' . $dbr->addQuotes( $start ) . ' OR ' . |
1189 | 1200 | '(cul_range_end >= ' . $dbr->addQuotes( $start ) . ' AND ' . |
1190 | 1201 | 'cul_range_start <= ' . $dbr->addQuotes( $end ) . ')' |
1191 | | - ); |
| 1202 | + ); |
1192 | 1203 | } else { |
1193 | 1204 | $searchConds = array( |
1194 | 1205 | '(cul_target_hex >= ' . $dbr->addQuotes( $start ) . ' AND ' . |
— | — | @@ -1201,10 +1212,10 @@ |
1202 | 1213 | $user = User::newFromName( $target ); |
1203 | 1214 | if ( $user && $user->getID() ) { |
1204 | 1215 | $searchConds = array( |
1205 | | - 'cul_type' => array('userips','useredits'), |
| 1216 | + 'cul_type' => array( 'userips', 'useredits' ), |
1206 | 1217 | 'cul_target_id' => $user->getID(), |
1207 | 1218 | ); |
1208 | | - } else if ( $target ) { |
| 1219 | + } elseif ( $target ) { |
1209 | 1220 | $error = 'checkuser-user-nonexistent'; |
1210 | 1221 | } |
1211 | 1222 | } |
— | — | @@ -1221,7 +1232,7 @@ |
1222 | 1233 | $caption = wfMsgHtml( 'checkuser-search-' . $searchType ); |
1223 | 1234 | $select .= "<option value=\"$searchType\" $checked>$caption</option>\n"; |
1224 | 1235 | } |
1225 | | - $select .= "</select>"; |
| 1236 | + $select .= '</select>'; |
1226 | 1237 | |
1227 | 1238 | $encTarget = htmlspecialchars( $target ); |
1228 | 1239 | $msgSearch = wfMsgHtml( 'checkuser-search' ); |
— | — | @@ -1229,7 +1240,7 @@ |
1230 | 1241 | $msgSearchForm = wfMsgHtml( 'checkuser-search-form', $select, $input ); |
1231 | 1242 | $formAction = $this->getLogSubpageTitle()->escapeLocalURL(); |
1232 | 1243 | $msgSearchSubmit = ' ' . wfMsgHtml( 'checkuser-search-submit' ) . ' '; |
1233 | | - |
| 1244 | + |
1234 | 1245 | $s = "<form method='get' action=\"$formAction\">\n" . |
1235 | 1246 | "<fieldset><legend>$msgSearch</legend>\n" . |
1236 | 1247 | "<p>$msgSearchForm</p>\n" . |
— | — | @@ -1247,10 +1258,11 @@ |
1248 | 1259 | $wgOut->addHTML( |
1249 | 1260 | $pager->getNavigationBar() . |
1250 | 1261 | $pager->getBody() . |
1251 | | - $pager->getNavigationBar() ); |
| 1262 | + $pager->getNavigationBar() |
| 1263 | + ); |
1252 | 1264 | } |
1253 | | - |
1254 | | - /** |
| 1265 | + |
| 1266 | + /** |
1255 | 1267 | * @return string Formatted HTML |
1256 | 1268 | * @param int $year |
1257 | 1269 | * @param int $month |
— | — | @@ -1264,20 +1276,20 @@ |
1265 | 1277 | } |
1266 | 1278 | if ( $year ) { |
1267 | 1279 | $encYear = intval( $year ); |
1268 | | - } else if( $encMonth ) { |
| 1280 | + } elseif( $encMonth ) { |
1269 | 1281 | $thisMonth = intval( gmdate( 'n' ) ); |
1270 | 1282 | $thisYear = intval( gmdate( 'Y' ) ); |
1271 | | - if( intval($encMonth) > $thisMonth ) { |
| 1283 | + if( intval( $encMonth ) > $thisMonth ) { |
1272 | 1284 | $thisYear--; |
1273 | 1285 | } |
1274 | 1286 | $encYear = $thisYear; |
1275 | 1287 | } else { |
1276 | 1288 | $encYear = ''; |
1277 | 1289 | } |
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' ) . ' ' . |
1282 | 1294 | Xml::monthSelector( $encMonth, -1 ); |
1283 | 1295 | } |
1284 | 1296 | |
— | — | @@ -1293,7 +1305,7 @@ |
1294 | 1306 | } else { |
1295 | 1307 | $targetHex = $rangeStart = $rangeEnd = ''; |
1296 | 1308 | } |
1297 | | - |
| 1309 | + |
1298 | 1310 | $dbw = wfGetDB( DB_MASTER ); |
1299 | 1311 | $cul_id = $dbw->nextSequenceValue( 'cu_log_cul_id_seq' ); |
1300 | 1312 | $dbw->insert( 'cu_log', |
— | — | @@ -1343,20 +1355,20 @@ |
1344 | 1356 | $user = $skin->userLink( $row->cul_user, $row->user_name ); |
1345 | 1357 | |
1346 | 1358 | 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 ) . |
1348 | 1360 | $skin->userToolLinks( $row->cul_target_id, $row->cul_target_text ); |
1349 | 1361 | } else { |
1350 | 1362 | $target = $row->cul_target_text; |
1351 | 1363 | } |
1352 | 1364 | |
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 ) . |
1355 | 1367 | wfMsg( 'comma-separator' ) . |
1356 | | - wfMsg( |
| 1368 | + wfMsg( |
1357 | 1369 | 'checkuser-log-' . $row->cul_type, |
1358 | 1370 | $user, |
1359 | | - $target |
1360 | | - ) . |
| 1371 | + $target |
| 1372 | + ) . |
1361 | 1373 | $comment . |
1362 | 1374 | '</li>'; |
1363 | 1375 | } |
— | — | @@ -1382,10 +1394,9 @@ |
1383 | 1395 | } |
1384 | 1396 | |
1385 | 1397 | function getQueryInfo() { |
1386 | | - global $wgRequest; |
1387 | 1398 | $this->searchConds[] = 'user_id = cul_user'; |
1388 | 1399 | return array( |
1389 | | - 'tables' => array('cu_log','user'), |
| 1400 | + 'tables' => array( 'cu_log', 'user' ), |
1390 | 1401 | 'fields' => $this->selectFields(), |
1391 | 1402 | 'conds' => $this->searchConds |
1392 | 1403 | ); |
— | — | @@ -1398,9 +1409,11 @@ |
1399 | 1410 | function getTitle() { |
1400 | 1411 | return $this->specialPage->getLogSubpageTitle(); |
1401 | 1412 | } |
1402 | | - |
| 1413 | + |
1403 | 1414 | 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 | + ); |
1406 | 1419 | } |
1407 | 1420 | } |
Index: trunk/extensions/CheckUser/CheckUser.i18n.php |
— | — | @@ -2,11 +2,16 @@ |
3 | 3 | /** |
4 | 4 | * Internationalisation file for CheckUser extension. |
5 | 5 | * |
6 | | - * @addtogroup Extensions |
7 | | -*/ |
| 6 | + * @file |
| 7 | + * @ingroup Extensions |
| 8 | + */ |
8 | 9 | |
9 | 10 | $messages = array(); |
10 | 11 | |
| 12 | +/** English |
| 13 | + * @author Tim Starling |
| 14 | + * @author Aaron Schulz |
| 15 | + */ |
11 | 16 | $messages['en'] = array( |
12 | 17 | '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. |
13 | 18 | 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 @@ |
20 | 25 | 'group-checkuser' => 'Check users', |
21 | 26 | 'group-checkuser-member' => 'Check user', |
22 | 27 | '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', |
24 | 29 | 'grouppage-checkuser' => '{{ns:project}}:Check user', |
25 | 30 | 'checkuser-reason' => 'Reason:', |
26 | 31 | 'checkuser-showlog' => 'Show log', |
27 | 32 | 'checkuser-log' => 'CheckUser log', |
28 | 33 | 'checkuser-query' => 'Query recent changes', |
29 | | - 'checkuser-target' => 'User or IP', |
| 34 | + 'checkuser-target' => 'User or IP:', |
30 | 35 | 'checkuser-users' => 'Get users', |
31 | 36 | 'checkuser-edits' => 'Get edits from IP', |
32 | 37 | 'checkuser-ips' => 'Get IP addresses', |
— | — | @@ -72,7 +77,7 @@ |
73 | 78 | 'checkuser-ipeditcount' => '~$1 from all users', |
74 | 79 | 'checkuser-log-subpage' => 'Log', |
75 | 80 | 'checkuser-log-return' => 'Return to CheckUser main form', |
76 | | - |
| 81 | + |
77 | 82 | 'checkuser-limited' => '\'\'\'These results have been truncated for performance reasons.\'\'\'', |
78 | 83 | |
79 | 84 | 'checkuser-log-userips' => '$1 got IP addresses for $2', |
— | — | @@ -81,11 +86,11 @@ |
82 | 87 | 'checkuser-log-ipedits-xff' => '$1 got edits for XFF $2', |
83 | 88 | 'checkuser-log-ipusers-xff' => '$1 got users for XFF $2', |
84 | 89 | 'checkuser-log-useredits' => '$1 got edits for $2', |
85 | | - |
| 90 | + |
86 | 91 | 'checkuser-autocreate-action' => 'was automatically created', |
87 | 92 | 'checkuser-email-action' => 'sent an email to user "$1"', |
88 | 93 | 'checkuser-reset-action' => 'reset password for user "$1"', |
89 | | - |
| 94 | + |
90 | 95 | 'checkuser-toollinks' => '<span class="plainlinks">[[http://openrbl.org/query?$1 RDNS] · |
91 | 96 | [http://www.robtex.com/rbls/$1.html RBLs] · |
92 | 97 | [http://www.dnsstuff.com/tools/tracert.ch?ip=$1 Traceroute] · |
Index: trunk/extensions/CheckUser/CheckUser.php |
— | — | @@ -1,30 +1,51 @@ |
2 | 2 | <?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 | + */ |
3 | 15 | |
4 | 16 | # Not a valid entry point, skip unless MEDIAWIKI is defined |
5 | | -if (!defined('MEDIAWIKI')) { |
| 17 | +if ( !defined( 'MEDIAWIKI' ) ) { |
6 | 18 | echo "CheckUser extension"; |
7 | | - exit(1); |
| 19 | + exit( 1 ); |
8 | 20 | } |
9 | 21 | |
10 | 22 | # Internationalisation file |
11 | | -$dir = dirname(__FILE__) . '/'; |
| 23 | +$dir = dirname( __FILE__ ) . '/'; |
12 | 24 | $wgExtensionMessagesFiles['CheckUser'] = $dir . 'CheckUser.i18n.php'; |
13 | 25 | $wgExtensionAliasesFiles['CheckUser'] = $dir . 'CheckUser.alias.php'; |
14 | 26 | |
| 27 | +// Extension credits that will show up on Special:Version |
15 | 28 | $wgExtensionCredits['specialpage'][] = array( |
16 | 29 | 'path' => __FILE__, |
17 | 30 | 'author' => array( 'Tim Starling', 'Aaron Schulz' ), |
18 | 31 | 'name' => 'CheckUser', |
| 32 | + 'version' => '2.3', |
19 | 33 | 'url' => 'http://www.mediawiki.org/wiki/Extension:CheckUser', |
20 | 34 | 'description' => 'Grants users with the appropriate permission the ability to check user\'s IP addresses and other information', |
21 | 35 | 'descriptionmsg'=> 'checkuser-desc', |
22 | 36 | ); |
23 | 37 | |
| 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 |
24 | 41 | $wgAvailableRights[] = 'checkuser'; |
25 | 42 | $wgAvailableRights[] = 'checkuser-log'; |
26 | 43 | $wgGroupPermissions['checkuser']['checkuser'] = true; |
27 | 44 | $wgGroupPermissions['checkuser']['checkuser-log'] = true; |
28 | 45 | |
| 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. |
29 | 50 | $wgCheckUserLog = '/home/wikipedia/logs/checkuser.log'; |
30 | 51 | |
31 | 52 | # How long to keep CU data? |
— | — | @@ -33,9 +54,12 @@ |
34 | 55 | # Mass block limits |
35 | 56 | $wgCheckUserMaxBlocks = 200; |
36 | 57 | |
| 58 | +// Set this to true if you want to force checkusers into giving a reason for |
| 59 | +// each check they do through Special:CheckUser. |
37 | 60 | $wgCheckUserForceSummary = false; |
38 | 61 | |
39 | | -$wgCheckUserStyleVersion = 4; |
| 62 | +// Increment this number every time you touch the .js file. |
| 63 | +$wgCheckUserStyleVersion = 5; |
40 | 64 | |
41 | 65 | # Recent changes data hook |
42 | 66 | global $wgHooks; |
— | — | @@ -60,7 +84,7 @@ |
61 | 85 | $ip = wfGetIP(); |
62 | 86 | // Get XFF header |
63 | 87 | $xff = wfGetForwardedFor(); |
64 | | - list($xff_ip,$trusted) = efGetClientIPfromXFF( $xff ); |
| 88 | + list( $xff_ip, $trusted ) = efGetClientIPfromXFF( $xff ); |
65 | 89 | // Our squid XFFs can flood this up sometimes |
66 | 90 | $isSquidOnly = efXFFChainIsSquid( $xff ); |
67 | 91 | // Get agent |
— | — | @@ -69,14 +93,15 @@ |
70 | 94 | // $rc_comment should just be the log_comment |
71 | 95 | // BC: check if log_type and log_action exists |
72 | 96 | // 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 ) { |
74 | 98 | $target = Title::makeTitle( $rc_namespace, $rc_title ); |
75 | 99 | $actionText = LogPage::actionText( $rc_log_type, $rc_log_action, $target, |
76 | | - NULL, LogPage::extractParams($rc_params) ); |
| 100 | + null, LogPage::extractParams( $rc_params ) |
| 101 | + ); |
77 | 102 | } else { |
78 | 103 | $actionText = ''; |
79 | 104 | } |
80 | | - |
| 105 | + |
81 | 106 | $dbw = wfGetDB( DB_MASTER ); |
82 | 107 | $cuc_id = $dbw->nextSequenceValue( 'cu_changes_cu_id_seq' ); |
83 | 108 | $rcRow = array( |
— | — | @@ -92,14 +117,14 @@ |
93 | 118 | 'cuc_last_oldid' => $rc_last_oldid, |
94 | 119 | 'cuc_type' => $rc_type, |
95 | 120 | 'cuc_timestamp' => $rc_timestamp, |
96 | | - 'cuc_ip' => IP::sanitizeIP($ip), |
| 121 | + 'cuc_ip' => IP::sanitizeIP( $ip ), |
97 | 122 | 'cuc_ip_hex' => $ip ? IP::toHex( $ip ) : null, |
98 | 123 | '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, |
100 | 125 | 'cuc_agent' => $agent |
101 | 126 | ); |
102 | 127 | # 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 ) ) { |
104 | 129 | $rcRow['cuc_page_id'] = $rc_cur_id; |
105 | 130 | } |
106 | 131 | $dbw->insert( 'cu_changes', $rcRow, __METHOD__ ); |
— | — | @@ -112,9 +137,9 @@ |
113 | 138 | $cutoff = $dbw->timestamp( time() - $wgCUDMaxAge ); |
114 | 139 | $recentchanges = $dbw->tableName( 'cu_changes' ); |
115 | 140 | $sql = "DELETE FROM $recentchanges WHERE cuc_timestamp < '{$cutoff}'"; |
116 | | - $dbw->query( $sql ); |
| 141 | + $dbw->query( $sql, __METHOD__ ); |
117 | 142 | } |
118 | | - |
| 143 | + |
119 | 144 | return true; |
120 | 145 | } |
121 | 146 | |
— | — | @@ -126,7 +151,7 @@ |
127 | 152 | wfLoadExtensionMessages( 'CheckUser' ); |
128 | 153 | // Get XFF header |
129 | 154 | $xff = wfGetForwardedFor(); |
130 | | - list($xff_ip,$trusted) = efGetClientIPfromXFF( $xff ); |
| 155 | + list( $xff_ip, $trusted ) = efGetClientIPfromXFF( $xff ); |
131 | 156 | // Our squid XFFs can flood this up sometimes |
132 | 157 | $isSquidOnly = efXFFChainIsSquid( $xff ); |
133 | 158 | // Get agent |
— | — | @@ -140,20 +165,20 @@ |
141 | 166 | 'cuc_minor' => 0, |
142 | 167 | 'cuc_user' => $user->getId(), |
143 | 168 | 'cuc_user_text' => $user->getName(), |
144 | | - 'cuc_actiontext' => wfMsgForContent('checkuser-reset-action',$account->getName()), |
| 169 | + 'cuc_actiontext' => wfMsgForContent( 'checkuser-reset-action', $account->getName() ), |
145 | 170 | 'cuc_comment' => '', |
146 | 171 | 'cuc_this_oldid' => 0, |
147 | 172 | 'cuc_last_oldid' => 0, |
148 | 173 | 'cuc_type' => RC_LOG, |
149 | 174 | 'cuc_timestamp' => $dbw->timestamp( wfTimestampNow() ), |
150 | | - 'cuc_ip' => IP::sanitizeIP($ip), |
| 175 | + 'cuc_ip' => IP::sanitizeIP( $ip ), |
151 | 176 | 'cuc_ip_hex' => $ip ? IP::toHex( $ip ) : null, |
152 | 177 | '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, |
154 | 179 | 'cuc_agent' => $agent |
155 | 180 | ); |
156 | 181 | $dbw->insert( 'cu_changes', $rcRow, __METHOD__ ); |
157 | | - |
| 182 | + |
158 | 183 | return true; |
159 | 184 | } |
160 | 185 | |
— | — | @@ -174,7 +199,7 @@ |
175 | 200 | $ip = wfGetIP(); |
176 | 201 | // Get XFF header |
177 | 202 | $xff = wfGetForwardedFor(); |
178 | | - list($xff_ip,$trusted) = efGetClientIPfromXFF( $xff ); |
| 203 | + list( $xff_ip, $trusted ) = efGetClientIPfromXFF( $xff ); |
179 | 204 | // Our squid XFFs can flood this up sometimes |
180 | 205 | $isSquidOnly = efXFFChainIsSquid( $xff ); |
181 | 206 | // Get agent |
— | — | @@ -188,20 +213,20 @@ |
189 | 214 | 'cuc_minor' => 0, |
190 | 215 | 'cuc_user' => $userFrom->getId(), |
191 | 216 | 'cuc_user_text' => $userFrom->getName(), |
192 | | - 'cuc_actiontext' => wfMsgForContent('checkuser-email-action',$hash), |
| 217 | + 'cuc_actiontext' => wfMsgForContent( 'checkuser-email-action', $hash ), |
193 | 218 | 'cuc_comment' => '', |
194 | 219 | 'cuc_this_oldid' => 0, |
195 | 220 | 'cuc_last_oldid' => 0, |
196 | 221 | 'cuc_type' => RC_LOG, |
197 | 222 | 'cuc_timestamp' => $dbw->timestamp( wfTimestampNow() ), |
198 | | - 'cuc_ip' => IP::sanitizeIP($ip), |
| 223 | + 'cuc_ip' => IP::sanitizeIP( $ip ), |
199 | 224 | 'cuc_ip_hex' => $ip ? IP::toHex( $ip ) : null, |
200 | 225 | '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, |
202 | 227 | 'cuc_agent' => $agent |
203 | 228 | ); |
204 | 229 | $dbw->insert( 'cu_changes', $rcRow, __METHOD__ ); |
205 | | - |
| 230 | + |
206 | 231 | return true; |
207 | 232 | } |
208 | 233 | |
— | — | @@ -210,41 +235,41 @@ |
211 | 236 | * Saves user data into the cu_changes table |
212 | 237 | */ |
213 | 238 | 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; |
249 | 274 | } |
250 | 275 | |
251 | 276 | /** |
— | — | @@ -253,26 +278,28 @@ |
254 | 279 | * @param string $address, the ip that sent this header (optional) |
255 | 280 | * @return array( string, bool ) |
256 | 281 | */ |
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 | + } |
260 | 286 | // Avoid annoyingly long xff hacks |
261 | 287 | $xff = trim( substr( $xff, 0, 255 ) ); |
262 | 288 | $client = null; |
263 | 289 | $trusted = true; |
264 | 290 | // Check each IP, assuming they are separated by commas |
265 | | - $ips = explode(',',$xff); |
| 291 | + $ips = explode( ',', $xff ); |
266 | 292 | foreach( $ips as $n => $ip ) { |
267 | | - $ip = trim($ip); |
| 293 | + $ip = trim( $ip ); |
268 | 294 | // If it is a valid IP, not a hash or such |
269 | | - if( IP::isIPAddress($ip) ) { |
| 295 | + if( IP::isIPAddress( $ip ) ) { |
270 | 296 | # The first IP should be the client. |
271 | 297 | # 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 ) ) { |
274 | 300 | $client = $ip; |
| 301 | + } |
275 | 302 | # Check that all servers are trusted |
276 | | - } else if( !wfIsTrustedProxy($ip) ) { |
| 303 | + } elseif( !wfIsTrustedProxy( $ip ) ) { |
277 | 304 | $trusted = false; |
278 | 305 | break; |
279 | 306 | } |
— | — | @@ -280,44 +307,46 @@ |
281 | 308 | } |
282 | 309 | // We still have to test if the IP that sent |
283 | 310 | // this header is trusted to confirm results |
284 | | - if ( $client != $address && (!$address || !wfIsTrustedProxy($address)) ) |
| 311 | + if ( $client != $address && ( !$address || !wfIsTrustedProxy( $address ) ) ) { |
285 | 312 | $trusted = false; |
286 | | - |
| 313 | + } |
| 314 | + |
287 | 315 | return array( $client, $trusted ); |
288 | 316 | } |
289 | 317 | |
290 | 318 | function efXFFChainIsSquid( $xff ) { |
291 | 319 | global $wgSquidServers, $wgSquidServersNoPurge; |
292 | 320 | |
293 | | - if ( !$xff ) |
| 321 | + if ( !$xff ) { |
294 | 322 | false; |
| 323 | + } |
295 | 324 | // Avoid annoyingly long xff hacks |
296 | 325 | $xff = trim( substr( $xff, 0, 255 ) ); |
297 | 326 | $squidOnly = true; |
298 | 327 | // Check each IP, assuming they are separated by commas |
299 | | - $ips = explode(',',$xff); |
| 328 | + $ips = explode( ',', $xff ); |
300 | 329 | foreach( $ips as $n => $ip ) { |
301 | | - $ip = trim($ip); |
| 330 | + $ip = trim( $ip ); |
302 | 331 | // 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 ) { |
305 | 334 | // 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 ) ) { |
307 | 336 | $squidOnly = false; |
308 | 337 | break; |
309 | 338 | } |
310 | 339 | } |
311 | 340 | } |
312 | | - |
| 341 | + |
313 | 342 | return $squidOnly; |
314 | 343 | } |
315 | 344 | |
316 | 345 | function efCheckUserSchemaUpdates() { |
317 | 346 | global $wgDBtype, $wgExtNewIndexes; |
318 | | - |
| 347 | + |
319 | 348 | # Run install.inc as necessary |
320 | | - $base = dirname(__FILE__); |
321 | | - |
| 349 | + $base = dirname( __FILE__ ); |
| 350 | + |
322 | 351 | $db = wfGetDB( DB_MASTER ); |
323 | 352 | if( $db->tableExists( 'cu_changes' ) ) { |
324 | 353 | echo "...cu_changes already exists.\n"; |
— | — | @@ -325,19 +354,23 @@ |
326 | 355 | require_once "$base/install.inc"; |
327 | 356 | create_cu_changes( $db ); |
328 | 357 | } |
329 | | - |
| 358 | + |
330 | 359 | if( $db->tableExists( 'cu_log' ) ) { |
331 | 360 | echo "...cu_log already exists.\n"; |
332 | 361 | } else { |
333 | 362 | require_once "$base/install.inc"; |
334 | 363 | create_cu_log( $db ); |
335 | 364 | } |
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 | + ); |
342 | 375 | } |
343 | 376 | return true; |
344 | 377 | } |
— | — | @@ -351,19 +384,28 @@ |
352 | 385 | return true; |
353 | 386 | } |
354 | 387 | |
| 388 | +// Set up the new special page |
355 | 389 | $wgSpecialPages['CheckUser'] = 'CheckUser'; |
356 | 390 | $wgSpecialPageGroups['CheckUser'] = 'users'; |
357 | | -$wgAutoloadClasses['CheckUser'] = dirname(__FILE__) . '/CheckUser_body.php'; |
| 391 | +$wgAutoloadClasses['CheckUser'] = dirname( __FILE__ ) . '/CheckUser_body.php'; |
358 | 392 | |
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 | + */ |
360 | 401 | 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' ); |
364 | 405 | $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 | + ); |
368 | 410 | } |
369 | 411 | return true; |
370 | 412 | } |
Index: trunk/extensions/CheckUser/checkuser.js |
— | — | @@ -8,10 +8,14 @@ |
9 | 9 | */ |
10 | 10 | function updateCIDRresult() { |
11 | 11 | var form = document.getElementById( 'mw-checkuser-cidrform' ); |
12 | | - if( !form ) return; // no JS form |
| 12 | + if( !form ) { |
| 13 | + return; // no JS form |
| 14 | + } |
13 | 15 | form.style.display = 'inline'; // unhide form (JS active) |
14 | 16 | var iplist = document.getElementById( 'mw-checkuser-iplist' ); |
15 | | - if( !iplist ) return; // no JS form |
| 17 | + if( !iplist ) { |
| 18 | + return; // no JS form |
| 19 | + } |
16 | 20 | var text = iplist.value; |
17 | 21 | // Each line should have one IP or range |
18 | 22 | if( text.indexOf("\n") != -1 ) { |
— | — | @@ -30,10 +34,10 @@ |
31 | 35 | } |
32 | 36 | var bin_prefix = 0; |
33 | 37 | var prefix_cidr = 0; |
34 | | - var prefix = new String( "" ); |
| 38 | + var prefix = new String( '' ); |
35 | 39 | // Go through each IP in the list, get its binary form, and |
36 | 40 | // 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++ ) { |
38 | 42 | var invalid = false; |
39 | 43 | // ...in the spirit of block.js, call this "addy" |
40 | 44 | var addy = ips[i]; |
— | — | @@ -41,7 +45,7 @@ |
42 | 46 | var ipV4 = addy.match(/(^|\b)(\d+\.\d+\.\d+\.\d+)(\/\d+)?\b/); |
43 | 47 | 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/); |
44 | 48 | // Binary form |
45 | | - var bin = new String( "" ); |
| 49 | + var bin = new String( '' ); |
46 | 50 | // Convert the IP to binary form: IPv4 |
47 | 51 | if( ipV4 ) { |
48 | 52 | var ip = ipV4[2]; |
— | — | @@ -49,35 +53,39 @@ |
50 | 54 | // Get each quad integer |
51 | 55 | var blocs = ip.split('.'); |
52 | 56 | // 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++ ) { |
55 | 61 | bloc = parseInt( blocs[x], 10 ); |
56 | 62 | if( bloc > 255 ) { |
57 | 63 | invalid = true; // bad IP! |
58 | 64 | break; // bad IP! |
59 | 65 | } |
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 |
61 | 67 | 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 |
63 | 69 | } |
64 | 70 | bin += bin_block; |
65 | 71 | } |
66 | | - if( invalid ) continue; // move to next IP |
| 72 | + if( invalid ) { |
| 73 | + continue; // move to next IP |
| 74 | + } |
67 | 75 | prefix = ''; // Rebuild formatted bin_prefix for each IP |
68 | 76 | // Apply any valid CIDRs |
69 | 77 | if( cidr ) { |
70 | 78 | 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 |
72 | 80 | } |
73 | 81 | // Init bin_prefix |
74 | 82 | if( bin_prefix === 0 ) { |
75 | 83 | bin_prefix = new String( bin ); |
76 | 84 | // Get largest common bin_prefix |
77 | 85 | } else { |
78 | | - for( var x=0; x<bin_prefix.length; x++ ) { |
| 86 | + for( var x = 0; x < bin_prefix.length; x++ ) { |
79 | 87 | // Bin_prefix always smaller than bin unless a CIDR was used on bin |
80 | 88 | 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 |
82 | 90 | break; |
83 | 91 | } |
84 | 92 | } |
— | — | @@ -86,36 +94,42 @@ |
87 | 95 | var prefix_cidr = bin_prefix.length; |
88 | 96 | // CIDR too small? |
89 | 97 | if( prefix_cidr < 16 ) { |
90 | | - document.getElementById( 'mw-checkuser-cidr-res' ).value = "!"; |
91 | | - document.getElementById( 'mw-checkuser-ipnote' ).innerHTML = ">"+Math.pow(2,32-prefix_cidr); |
| 98 | + document.getElementById( 'mw-checkuser-cidr-res' ).value = '!'; |
| 99 | + document.getElementById( 'mw-checkuser-ipnote' ).innerHTML = '>' + Math.pow( 2, 32 - prefix_cidr ); |
92 | 100 | return; // too big |
93 | 101 | } |
94 | 102 | // Build the IP in dotted-quad form |
95 | | - for( var z=0; z<=3; z++ ) { |
| 103 | + for( var z = 0; z <= 3; z++ ) { |
96 | 104 | var bloc = 0; |
97 | | - var start = z*8; |
| 105 | + var start = z * 8; |
98 | 106 | 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 ); |
102 | 112 | } |
103 | 113 | prefix += ( z == 3 ) ? bloc : bloc + '.'; |
104 | 114 | } |
105 | 115 | // Get IPs affected |
106 | | - ip_count = Math.pow(2,32-prefix_cidr); |
| 116 | + ip_count = Math.pow( 2, 32 - prefix_cidr ); |
107 | 117 | // Is the CIDR meaningful? |
108 | | - if( prefix_cidr == 32 ) prefix_cidr = false; |
| 118 | + if( prefix_cidr == 32 ) { |
| 119 | + prefix_cidr = false; |
| 120 | + } |
109 | 121 | // Convert the IP to binary form: IPv6 |
110 | 122 | } else if( ipV6 ) { |
111 | 123 | var ip = ipV6[2]; |
112 | 124 | var cidr = ipV6[0].match( /\/\d+$/ ); |
113 | 125 | cidr = cidr ? cidr[0] : false; |
114 | 126 | 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 | + } |
116 | 130 | // Expand out "::"s |
117 | 131 | if( abbrevs && abbrevs.length > 0 ) { |
118 | 132 | var colons = ip.match( /:/g ); |
119 | | - var needed = 7 - (colons.length - 2); // 2 from "::" |
| 133 | + var needed = 7 - ( colons.length - 2 ); // 2 from "::" |
120 | 134 | var insert = ''; |
121 | 135 | while( needed > 1 ) { |
122 | 136 | insert += ':0'; |
— | — | @@ -123,39 +137,43 @@ |
124 | 138 | } |
125 | 139 | ip = ip.replace( '::', insert + ':' ); |
126 | 140 | // 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 | + } |
128 | 144 | } |
129 | 145 | // Get each hex octant |
130 | 146 | 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' ) { |
134 | 150 | invalid = true; // bad IP! |
135 | 151 | break; // bad IP! |
136 | 152 | } |
137 | 153 | 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 |
139 | 155 | 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 |
141 | 157 | } |
142 | 158 | bin += bin_block; |
143 | 159 | } |
144 | | - if( invalid ) continue; // move to next IP |
| 160 | + if( invalid ) { |
| 161 | + continue; // move to next IP |
| 162 | + } |
145 | 163 | prefix = ''; // Rebuild formatted bin_prefix for each IP |
146 | 164 | // Apply any valid CIDRs |
147 | 165 | if( cidr ) { |
148 | 166 | 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 |
150 | 168 | } |
151 | 169 | // Init bin_prefix |
152 | 170 | if( bin_prefix === 0 ) { |
153 | 171 | bin_prefix = new String( bin ); |
154 | 172 | // Get largest common bin_prefix |
155 | 173 | } else { |
156 | | - for( var x=0; x<bin_prefix.length; x++ ) { |
| 174 | + for( var x = 0; x < bin_prefix.length; x++ ) { |
157 | 175 | // Bin_prefix always smaller than bin unless a CIDR was used on bin |
158 | 176 | 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 |
160 | 178 | break; |
161 | 179 | } |
162 | 180 | } |
— | — | @@ -164,30 +182,34 @@ |
165 | 183 | var prefix_cidr = bin_prefix.length; |
166 | 184 | // CIDR too small? |
167 | 185 | if( prefix_cidr < 96 ) { |
168 | | - document.getElementById( 'mw-checkuser-cidr-res' ).value = "!"; |
169 | | - document.getElementById( 'mw-checkuser-ipnote' ).innerHTML = ">"+Math.pow(2,128-prefix_cidr); |
| 186 | + document.getElementById( 'mw-checkuser-cidr-res' ).value = '!'; |
| 187 | + document.getElementById( 'mw-checkuser-ipnote' ).innerHTML = '>' + Math.pow( 2, 128 - prefix_cidr ); |
170 | 188 | return; // too big |
171 | 189 | } |
172 | 190 | // Build the IP in dotted-quad form |
173 | | - for( var z=0; z<=7; z++ ) { |
| 191 | + for( var z = 0; z <= 7; z++ ) { |
174 | 192 | var bloc = 0; |
175 | 193 | var start = z*16; |
176 | 194 | 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 ); |
180 | 200 | } |
181 | | - bloc = bloc.toString(16); // convert to hex |
| 201 | + bloc = bloc.toString( 16 ); // convert to hex |
182 | 202 | prefix += ( z == 7 ) ? bloc : bloc + ':'; |
183 | 203 | } |
184 | 204 | // Get IPs affected |
185 | | - ip_count = Math.pow(2,128-prefix_cidr); |
| 205 | + ip_count = Math.pow( 2, 128 - prefix_cidr ); |
186 | 206 | // Is the CIDR meaningful? |
187 | | - if( prefix_cidr == 128 ) prefix_cidr = false; |
| 207 | + if( prefix_cidr == 128 ) { |
| 208 | + prefix_cidr = false; |
| 209 | + } |
188 | 210 | } |
189 | 211 | } |
190 | 212 | // Update form |
191 | | - if( prefix != "" ) { |
| 213 | + if( prefix != '' ) { |
192 | 214 | if( prefix_cidr != false ) { |
193 | 215 | document.getElementById( 'mw-checkuser-cidr-res' ).value = prefix + '/' + prefix_cidr; |
194 | 216 | } else { |
— | — | @@ -198,7 +220,7 @@ |
199 | 221 | document.getElementById( 'mw-checkuser-cidr-res' ).value = '?'; |
200 | 222 | document.getElementById( 'mw-checkuser-ipnote' ).innerHTML = ''; |
201 | 223 | } |
202 | | - |
| 224 | + |
203 | 225 | } |
204 | 226 | addOnloadHook( updateCIDRresult ); |
205 | 227 | |
— | — | @@ -207,10 +229,9 @@ |
208 | 230 | hex = new String( hex ); |
209 | 231 | hex = hex.toLowerCase(); |
210 | 232 | var intform = 0; |
211 | | - for( var i=0; i<hex.length; i++ ) { |
| 233 | + for( var i = 0; i < hex.length; i++ ) { |
212 | 234 | var digit = 0; |
213 | | - switch( hex[i] ) |
214 | | - { |
| 235 | + switch( hex[i] ) { |
215 | 236 | case 'a': |
216 | 237 | digit = 10; |
217 | 238 | break; |
— | — | @@ -233,7 +254,7 @@ |
234 | 255 | digit = parseInt( hex[i], 10 ); |
235 | 256 | break; |
236 | 257 | } |
237 | | - intform += digit*Math.pow(16,hex.length-1-i); |
| 258 | + intform += digit * Math.pow( 16, hex.length - 1 - i ); |
238 | 259 | } |
239 | 260 | return intform; |
240 | 261 | } |
Index: trunk/extensions/CheckUser/CheckUser.alias.php |
— | — | @@ -2,7 +2,8 @@ |
3 | 3 | /** |
4 | 4 | * Aliases for Special:CheckUser |
5 | 5 | * |
6 | | - * @addtogroup Extensions |
| 6 | + * @file |
| 7 | + * @ingroup Extensions |
7 | 8 | */ |
8 | 9 | |
9 | 10 | $aliases = array(); |
— | — | @@ -11,7 +12,7 @@ |
12 | 13 | * @author Jon Harald Søby |
13 | 14 | */ |
14 | 15 | $aliases['en'] = array( |
15 | | - 'CheckUser' => array( 'CheckUser' ), |
| 16 | + 'CheckUser' => array( 'CheckUser' ), |
16 | 17 | ); |
17 | 18 | |
18 | 19 | /** Arabic (العربية) |