Cleanup for r41831:
[lhc/web/wiklou.git] / includes / specials / SpecialBlockip.php
1 <?php
2 /**
3 * Constructor for Special:Blockip page
4 *
5 * @file
6 * @ingroup SpecialPage
7 */
8
9 /**
10 * Constructor
11 */
12 function wfSpecialBlockip( $par ) {
13 global $wgUser, $wgOut, $wgRequest;
14
15 # Can't block when the database is locked
16 if( wfReadOnly() ) {
17 $wgOut->readOnlyPage();
18 return;
19 }
20
21 # Permission check
22 if( !$wgUser->isAllowed( 'block' ) ) {
23 $wgOut->permissionRequired( 'block' );
24 return;
25 }
26
27 $ipb = new IPBlockForm( $par );
28
29 $action = $wgRequest->getVal( 'action' );
30 if ( 'success' == $action ) {
31 $ipb->showSuccess();
32 } else if ( $wgRequest->wasPosted() && 'submit' == $action &&
33 $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) ) ) {
34 $ipb->doSubmit();
35 } else {
36 $ipb->showForm( '' );
37 }
38 }
39
40 /**
41 * Form object for the Special:Blockip page.
42 *
43 * @ingroup SpecialPage
44 */
45 class IPBlockForm {
46 var $BlockAddress, $BlockExpiry, $BlockReason;
47 # var $BlockEmail;
48
49 function IPBlockForm( $par ) {
50 global $wgRequest, $wgUser, $wgBlockAllowsUTEdit;
51
52 $this->BlockAddress = $wgRequest->getVal( 'wpBlockAddress', $wgRequest->getVal( 'ip', $par ) );
53 $this->BlockAddress = strtr( $this->BlockAddress, '_', ' ' );
54 $this->BlockReason = $wgRequest->getText( 'wpBlockReason' );
55 $this->BlockReasonList = $wgRequest->getText( 'wpBlockReasonList' );
56 $this->BlockExpiry = $wgRequest->getVal( 'wpBlockExpiry', wfMsg('ipbotheroption') );
57 $this->BlockOther = $wgRequest->getVal( 'wpBlockOther', '' );
58
59 # Unchecked checkboxes are not included in the form data at all, so having one
60 # that is true by default is a bit tricky
61 $byDefault = !$wgRequest->wasPosted();
62 $this->BlockAnonOnly = $wgRequest->getBool( 'wpAnonOnly', $byDefault );
63 $this->BlockCreateAccount = $wgRequest->getBool( 'wpCreateAccount', $byDefault );
64 $this->BlockEnableAutoblock = $wgRequest->getBool( 'wpEnableAutoblock', $byDefault );
65 $this->BlockEmail = $wgRequest->getBool( 'wpEmailBan', false );
66 $this->BlockWatchUser = $wgRequest->getBool( 'wpWatchUser', false );
67 # Re-check user's rights to hide names, very serious, defaults to 0
68 $this->BlockHideName = ( $wgRequest->getBool( 'wpHideName', 0 ) && $wgUser->isAllowed( 'hideuser' ) ) ? 1 : 0;
69 $this->BlockAllowUsertalk = ( $wgRequest->getBool( 'wpAllowUsertalk', $byDefault ) && $wgBlockAllowsUTEdit );
70 }
71
72 function showForm( $err ) {
73 global $wgOut, $wgUser, $wgSysopUserBans;
74
75 $wgOut->setPagetitle( wfMsg( 'blockip' ) );
76 $wgOut->addWikiMsg( 'blockiptext' );
77
78 if($wgSysopUserBans) {
79 $mIpaddress = Xml::label( wfMsg( 'ipadressorusername' ), 'mw-bi-target' );
80 } else {
81 $mIpaddress = Xml::label( wfMsg( 'ipaddress' ), 'mw-bi-target' );
82 }
83 $mIpbexpiry = Xml::label( wfMsg( 'ipbexpiry' ), 'wpBlockExpiry' );
84 $mIpbother = Xml::label( wfMsg( 'ipbother' ), 'mw-bi-other' );
85 $mIpbreasonother = Xml::label( wfMsg( 'ipbreason' ), 'wpBlockReasonList' );
86 $mIpbreason = Xml::label( wfMsg( 'ipbotherreason' ), 'mw-bi-reason' );
87
88 $titleObj = SpecialPage::getTitleFor( 'Blockip' );
89
90 if ( "" != $err ) {
91 $wgOut->setSubtitle( wfMsgHtml( 'formerror' ) );
92 $wgOut->addHTML( Xml::tags( 'p', array( 'class' => 'error' ), $err ) );
93 }
94
95 $scBlockExpiryOptions = wfMsgForContent( 'ipboptions' );
96
97 $showblockoptions = $scBlockExpiryOptions != '-';
98 if (!$showblockoptions)
99 $mIpbother = $mIpbexpiry;
100
101 $blockExpiryFormOptions = Xml::option( wfMsg( 'ipbotheroption' ), 'other' );
102 foreach (explode(',', $scBlockExpiryOptions) as $option) {
103 if ( strpos($option, ":") === false ) $option = "$option:$option";
104 list($show, $value) = explode(":", $option);
105 $show = htmlspecialchars($show);
106 $value = htmlspecialchars($value);
107 $blockExpiryFormOptions .= Xml::option( $show, $value, $this->BlockExpiry === $value ? true : false ) . "\n";
108 }
109
110 $reasonDropDown = Xml::listDropDown( 'wpBlockReasonList',
111 wfMsgForContent( 'ipbreason-dropdown' ),
112 wfMsgForContent( 'ipbreasonotherlist' ), $this->BlockReasonList, 'wpBlockDropDown', 4 );
113
114 global $wgStylePath, $wgStyleVersion;
115 $wgOut->addHTML(
116 Xml::tags( 'script', array( 'type' => 'text/javascript', 'src' => "$wgStylePath/common/block.js?$wgStyleVersion" ), '' ) .
117 Xml::openElement( 'form', array( 'method' => 'post', 'action' => $titleObj->getLocalURL( "action=submit" ), 'id' => 'blockip' ) ) .
118 Xml::openElement( 'fieldset' ) .
119 Xml::element( 'legend', null, wfMsg( 'blockip-legend' ) ) .
120 Xml::openElement( 'table', array ( 'border' => '0', 'id' => 'mw-blockip-table' ) ) .
121 "<tr>
122 <td class='mw-label'>
123 {$mIpaddress}
124 </td>
125 <td class='mw-input'>" .
126 Xml::input( 'wpBlockAddress', 45, $this->BlockAddress,
127 array(
128 'tabindex' => '1',
129 'id' => 'mw-bi-target',
130 'onchange' => 'updateBlockOptions()' ) ). "
131 </td>
132 </tr>
133 <tr>"
134 );
135 if ( $showblockoptions ) {
136 $wgOut->addHTML("
137 <td class='mw-label'>
138 {$mIpbexpiry}
139 </td>
140 <td class='mw-input'>" .
141 Xml::tags( 'select',
142 array(
143 'id' => 'wpBlockExpiry',
144 'name' => 'wpBlockExpiry',
145 'onchange' => 'considerChangingExpiryFocus()',
146 'tabindex' => '2' ),
147 $blockExpiryFormOptions ) .
148 "</td>"
149 );
150 }
151 $wgOut->addHTML("
152 </tr>
153 <tr id='wpBlockOther'>
154 <td class='mw-label'>
155 {$mIpbother}
156 </td>
157 <td class='mw-input'>" .
158 Xml::input( 'wpBlockOther', 45, $this->BlockOther,
159 array( 'tabindex' => '3', 'id' => 'mw-bi-other' ) ) . "
160 </td>
161 </tr>
162 <tr>
163 <td class='mw-label'>
164 {$mIpbreasonother}
165 </td>
166 <td class='mw-input'>
167 {$reasonDropDown}
168 </td>
169 </tr>
170 <tr id=\"wpBlockReason\">
171 <td class='mw-label'>
172 {$mIpbreason}
173 </td>
174 <td class='mw-input'>" .
175 Xml::input( 'wpBlockReason', 45, $this->BlockReason,
176 array( 'tabindex' => '5', 'id' => 'mw-bi-reason', 'maxlength'=> '200' ) ) . "
177 </td>
178 </tr>
179 <tr id='wpAnonOnlyRow'>
180 <td>&nbsp;</td>
181 <td class='mw-input'>" .
182 Xml::checkLabel( wfMsg( 'ipbanononly' ),
183 'wpAnonOnly', 'wpAnonOnly', $this->BlockAnonOnly,
184 array( 'tabindex' => '6' ) ) . "
185 </td>
186 </tr>
187 <tr id='wpCreateAccountRow'>
188 <td>&nbsp;</td>
189 <td class='mw-input'>" .
190 Xml::checkLabel( wfMsg( 'ipbcreateaccount' ),
191 'wpCreateAccount', 'wpCreateAccount', $this->BlockCreateAccount,
192 array( 'tabindex' => '7' ) ) . "
193 </td>
194 </tr>
195 <tr id='wpEnableAutoblockRow'>
196 <td>&nbsp;</td>
197 <td class='mw-input'>" .
198 Xml::checkLabel( wfMsg( 'ipbenableautoblock' ),
199 'wpEnableAutoblock', 'wpEnableAutoblock', $this->BlockEnableAutoblock,
200 array( 'tabindex' => '8' ) ) . "
201 </td>
202 </tr>"
203 );
204
205 global $wgSysopEmailBans, $wgBlockAllowsUTEdit;
206 if ( $wgSysopEmailBans && $wgUser->isAllowed( 'blockemail' ) ) {
207 $wgOut->addHTML("
208 <tr id='wpEnableEmailBan'>
209 <td>&nbsp;</td>
210 <td class='mw-input'>" .
211 Xml::checkLabel( wfMsg( 'ipbemailban' ),
212 'wpEmailBan', 'wpEmailBan', $this->BlockEmail,
213 array( 'tabindex' => '9' )) . "
214 </td>
215 </tr>"
216 );
217 }
218
219 // Allow some users to hide name from block log, blocklist and listusers
220 if ( $wgUser->isAllowed( 'hideuser' ) ) {
221 $wgOut->addHTML("
222 <tr id='wpEnableHideUser'>
223 <td>&nbsp;</td>
224 <td class='mw-input'>" .
225 Xml::checkLabel( wfMsg( 'ipbhidename' ),
226 'wpHideName', 'wpHideName', $this->BlockHideName,
227 array( 'tabindex' => '10' ) ) . "
228 </td>
229 </tr>"
230 );
231 }
232
233 # Watchlist their user page?
234 $wgOut->addHTML("
235 <tr id='wpEnableWatchUser'>
236 <td>&nbsp;</td>
237 <td class='mw-input'>" .
238 Xml::checkLabel( wfMsg( 'ipbwatchuser' ),
239 'wpWatchUser', 'wpWatchUser', $this->BlockWatchUser,
240 array( 'tabindex' => '11' ) ) . "
241 </td>
242 </tr>"
243 );
244 if( $wgBlockAllowsUTEdit ){
245 $wgOut->addHTML("
246 <tr id='wpAllowUsertalkRow'>
247 <td>&nbsp;</td>
248 <td class='mw-input'>" .
249 Xml::checkLabel( wfMsg( 'ipballowusertalk' ),
250 'wpAllowUsertalk', 'wpAllowUsertalk', $this->BlockAllowUsertalk,
251 array( 'tabindex' => '12' ) ) . "
252 </td>
253 </tr>"
254 );
255 }
256
257 $wgOut->addHTML("
258 <tr>
259 <td style='padding-top: 1em'>&nbsp;</td>
260 <td class='mw-submit' style='padding-top: 1em'>" .
261 Xml::submitButton( wfMsg( 'ipbsubmit' ),
262 array( 'name' => 'wpBlock', 'tabindex' => '13', 'accesskey' => 's' ) ) . "
263 </td>
264 </tr>" .
265 Xml::closeElement( 'table' ) .
266 Xml::hidden( 'wpEditToken', $wgUser->editToken() ) .
267 Xml::closeElement( 'fieldset' ) .
268 Xml::closeElement( 'form' ) .
269 Xml::tags( 'script', array( 'type' => 'text/javascript' ), 'updateBlockOptions()' ) . "\n"
270 );
271
272 $wgOut->addHtml( $this->getConvenienceLinks() );
273
274 $user = User::newFromName( $this->BlockAddress );
275 if( is_object( $user ) ) {
276 $this->showLogFragment( $wgOut, $user->getUserPage() );
277 } elseif( preg_match( '/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/', $this->BlockAddress ) ) {
278 $this->showLogFragment( $wgOut, Title::makeTitle( NS_USER, $this->BlockAddress ) );
279 } 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}/', $this->BlockAddress ) ) {
280 $this->showLogFragment( $wgOut, Title::makeTitle( NS_USER, $this->BlockAddress ) );
281 }
282 }
283
284 /**
285 * Backend block code.
286 * $userID and $expiry will be filled accordingly
287 * @return array(message key, arguments) on failure, empty array on success
288 */
289 function doBlock( &$userId = null, &$expiry = null ) {
290 global $wgUser, $wgSysopUserBans, $wgSysopRangeBans, $wgBlockAllowsUTEdit;
291
292 $userId = 0;
293 # Expand valid IPv6 addresses, usernames are left as is
294 $this->BlockAddress = IP::sanitizeIP( $this->BlockAddress );
295 # isIPv4() and IPv6() are used for final validation
296 $rxIP4 = '\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}';
297 $rxIP6 = '\w{1,4}:\w{1,4}:\w{1,4}:\w{1,4}:\w{1,4}:\w{1,4}:\w{1,4}:\w{1,4}';
298 $rxIP = "($rxIP4|$rxIP6)";
299
300 # Check for invalid specifications
301 if ( !preg_match( "/^$rxIP$/", $this->BlockAddress ) ) {
302 $matches = array();
303 if ( preg_match( "/^($rxIP4)\\/(\\d{1,2})$/", $this->BlockAddress, $matches ) ) {
304 # IPv4
305 if ( $wgSysopRangeBans ) {
306 if ( !IP::isIPv4( $this->BlockAddress ) || $matches[2] < 16 || $matches[2] > 32 ) {
307 return array('ip_range_invalid');
308 }
309 $this->BlockAddress = Block::normaliseRange( $this->BlockAddress );
310 } else {
311 # Range block illegal
312 return array('range_block_disabled');
313 }
314 } else if ( preg_match( "/^($rxIP6)\\/(\\d{1,3})$/", $this->BlockAddress, $matches ) ) {
315 # IPv6
316 if ( $wgSysopRangeBans ) {
317 if ( !IP::isIPv6( $this->BlockAddress ) || $matches[2] < 64 || $matches[2] > 128 ) {
318 return array('ip_range_invalid');
319 }
320 $this->BlockAddress = Block::normaliseRange( $this->BlockAddress );
321 } else {
322 # Range block illegal
323 return array('range_block_disabled');
324 }
325 } else {
326 # Username block
327 if ( $wgSysopUserBans ) {
328 $user = User::newFromName( $this->BlockAddress );
329 if( !is_null( $user ) && $user->getId() ) {
330 # Use canonical name
331 $userId = $user->getId();
332 $this->BlockAddress = $user->getName();
333 } else {
334 return array('nosuchusershort', htmlspecialchars( $user ? $user->getName() : $this->BlockAddress ) );
335 }
336 } else {
337 return array('badipaddress');
338 }
339 }
340 }
341
342 if ( $wgUser->isBlocked() && ( $wgUser->getId() !== $userId ) ) {
343 return array( 'cant-block-while-blocked' );
344 }
345
346 $reasonstr = $this->BlockReasonList;
347 if ( $reasonstr != 'other' && $this->BlockReason != '' ) {
348 // Entry from drop down menu + additional comment
349 $reasonstr .= ': ' . $this->BlockReason;
350 } elseif ( $reasonstr == 'other' ) {
351 $reasonstr = $this->BlockReason;
352 }
353
354 $expirestr = $this->BlockExpiry;
355 if( $expirestr == 'other' )
356 $expirestr = $this->BlockOther;
357
358 if ( ( strlen( $expirestr ) == 0) || ( strlen( $expirestr ) > 50) ) {
359 return array('ipb_expiry_invalid');
360 }
361
362 if ( false === ($expiry = Block::parseExpiryInput( $expirestr )) ) {
363 // Bad expiry.
364 return array('ipb_expiry_invalid');
365 }
366
367 if( $this->BlockHideName && $expiry != 'infinity' ) {
368 // Bad expiry.
369 return array('ipb_expiry_temp');
370 }
371
372 # Create block
373 # Note: for a user block, ipb_address is only for display purposes
374 $block = new Block( $this->BlockAddress, $userId, $wgUser->getId(),
375 $reasonstr, wfTimestampNow(), 0, $expiry, $this->BlockAnonOnly,
376 $this->BlockCreateAccount, $this->BlockEnableAutoblock, $this->BlockHideName,
377 $this->BlockEmail, isset( $this->BlockAllowUsertalk ) ? $this->BlockAllowUsertalk : $wgBlockAllowsUTEdit );
378
379 if ( wfRunHooks('BlockIp', array(&$block, &$wgUser)) ) {
380
381 if ( !$block->insert() ) {
382 return array('ipb_already_blocked', htmlspecialchars($this->BlockAddress));
383 }
384
385 wfRunHooks('BlockIpComplete', array($block, $wgUser));
386
387 if ( $this->BlockWatchUser ) {
388 $wgUser->addWatch ( Title::makeTitle( NS_USER, $this->BlockAddress ) );
389 }
390
391 # Prepare log parameters
392 $logParams = array();
393 $logParams[] = $expirestr;
394 $logParams[] = $this->blockLogFlags();
395
396 # Make log entry, if the name is hidden, put it in the oversight log
397 $log_type = ($this->BlockHideName) ? 'suppress' : 'block';
398 $log = new LogPage( $log_type );
399 $log->addEntry( 'block', Title::makeTitle( NS_USER, $this->BlockAddress ),
400 $reasonstr, $logParams );
401
402 # Report to the user
403 return array();
404 }
405 else
406 return array('hookaborted');
407 }
408
409 /**
410 * UI entry point for blocking
411 * Wraps around doBlock()
412 */
413 function doSubmit()
414 {
415 global $wgOut;
416 $retval = $this->doBlock();
417 if(empty($retval)) {
418 $titleObj = SpecialPage::getTitleFor( 'Blockip' );
419 $wgOut->redirect( $titleObj->getFullURL( 'action=success&ip=' .
420 urlencode( $this->BlockAddress ) ) );
421 return;
422 }
423 $key = array_shift($retval);
424 $this->showForm(wfMsgReal($key, $retval));
425 }
426
427 function showSuccess() {
428 global $wgOut;
429
430 $wgOut->setPagetitle( wfMsg( 'blockip' ) );
431 $wgOut->setSubtitle( wfMsg( 'blockipsuccesssub' ) );
432 $text = wfMsgExt( 'blockipsuccesstext', array( 'parse' ), $this->BlockAddress );
433 $wgOut->addHtml( $text );
434 }
435
436 function showLogFragment( $out, $title ) {
437 global $wgUser;
438 $out->addHtml( Xml::element( 'h2', NULL, LogPage::logName( 'block' ) ) );
439 $count = LogEventsList::showLogExtract( $out, 'block', $title->getPrefixedText(), '', 10 );
440 if($count > 10){
441 $out->addHtml( $wgUser->getSkin()->link(
442 SpecialPage::getTitleFor( 'Log' ),
443 wfMsgHtml( 'blocklog-fulllog' ),
444 array(),
445 array(
446 'type' => 'block',
447 'page' => $title->getPrefixedText() ) ) );
448 }
449 }
450
451 /**
452 * Return a comma-delimited list of "flags" to be passed to the log
453 * reader for this block, to provide more information in the logs
454 *
455 * @return array
456 */
457 private function blockLogFlags() {
458 global $wgBlockAllowsUTEdit;
459 $flags = array();
460 if( $this->BlockAnonOnly && IP::isIPAddress( $this->BlockAddress ) )
461 // when blocking a user the option 'anononly' is not available/has no effect -> do not write this into log
462 $flags[] = 'anononly';
463 if( $this->BlockCreateAccount )
464 $flags[] = 'nocreate';
465 if( !$this->BlockEnableAutoblock )
466 $flags[] = 'noautoblock';
467 if ( $this->BlockEmail )
468 $flags[] = 'noemail';
469 if ( !$this->BlockAllowUsertalk && $wgBlockAllowsUTEdit )
470 $flags[] = 'nousertalk';
471 return implode( ',', $flags );
472 }
473
474 /**
475 * Builds unblock and block list links
476 *
477 * @return string
478 */
479 private function getConvenienceLinks() {
480 global $wgUser;
481 $skin = $wgUser->getSkin();
482 $contribsPage = SpecialPage::getTitleFor( 'Contributions', $this->BlockAddress );
483 $links[] = $skin->link( $contribsPage, wfMsgHtml( 'ipb-blocklist-contribs', $this->BlockAddress ) );
484 $links[] = $this->getUnblockLink( $skin );
485 $links[] = $this->getBlockListLink( $skin );
486 $links[] = $skin->makeLink ( 'MediaWiki:Ipbreason-dropdown', wfMsgHtml( 'ipb-edit-dropdown' ) );
487 return '<p class="mw-ipb-conveniencelinks">' . implode( ' | ', $links ) . '</p>';
488 }
489
490 /**
491 * Build a convenient link to unblock the given username or IP
492 * address, if available; otherwise link to a blank unblock
493 * form
494 *
495 * @param $skin Skin to use
496 * @return string
497 */
498 private function getUnblockLink( $skin ) {
499 $list = SpecialPage::getTitleFor( 'Ipblocklist' );
500 if( $this->BlockAddress ) {
501 $addr = htmlspecialchars( strtr( $this->BlockAddress, '_', ' ' ) );
502 return $skin->makeKnownLinkObj( $list, wfMsgHtml( 'ipb-unblock-addr', $addr ),
503 'action=unblock&ip=' . urlencode( $this->BlockAddress ) );
504 } else {
505 return $skin->makeKnownLinkObj( $list, wfMsgHtml( 'ipb-unblock' ), 'action=unblock' );
506 }
507 }
508
509 /**
510 * Build a convenience link to the block list
511 *
512 * @param $skin Skin to use
513 * @return string
514 */
515 private function getBlockListLink( $skin ) {
516 $list = SpecialPage::getTitleFor( 'Ipblocklist' );
517 if( $this->BlockAddress ) {
518 $addr = htmlspecialchars( strtr( $this->BlockAddress, '_', ' ' ) );
519 return $skin->makeKnownLinkObj( $list, wfMsgHtml( 'ipb-blocklist-addr', $addr ),
520 'ip=' . urlencode( $this->BlockAddress ) );
521 } else {
522 return $skin->makeKnownLinkObj( $list, wfMsgHtml( 'ipb-blocklist' ) );
523 }
524 }
525
526 /**
527 * Block a list of selected users
528 * @param array $users
529 * @param string $reason
530 * @param string $tag
531 * @returns array, list of html-safe usernames
532 */
533 public static function doMassUserBlock( $users, $reason = '', $tag = '' ) {
534 global $wgUser;
535 $counter = $blockSize = 0;
536 $safeUsers = array();
537 $log = new LogPage( 'block' );
538 foreach( $users as $name ) {
539 # Enforce limits
540 $counter++;
541 $blockSize++;
542 # Lets not go *too* fast
543 if( $blockSize >= 20 ) {
544 $blockSize = 0;
545 wfWaitForSlaves( 5 );
546 }
547 $u = User::newFromName( $name, false );
548 // If user doesn't exist, it ought to be an IP then
549 if( is_null($u) || (!$u->getId() && !IP::isIPAddress( $u->getName() )) ) {
550 continue;
551 }
552 $usertitle = Title::makeTitle( NS_USER, $u->getName() );
553 $userpage = new Article( $usertitle );
554 $safeUsers[] = '[[' . $usertitle->getPrefixedText() . '|' . $usertitle->getText() . ']]';
555 $expirestr = $u->getId() ? 'indefinite' : '1 week';
556 $expiry = Block::parseExpiryInput( $expirestr );
557 $anonOnly = IP::isIPAddress( $u->getName() ) ? 1 : 0;
558 // Create the block
559 $block = new Block( $u->getName(), // victim
560 $u->getId(), // uid
561 $wgUser->getId(), // blocker
562 $reason, // comment
563 wfTimestampNow(), // block time
564 0, // auto ?
565 $expiry, // duration
566 $anonOnly, // anononly?
567 1, // block account creation?
568 1, // autoblocking?
569 0, // suppress name?
570 0 // block from sending email?
571 );
572 $oldblock = Block::newFromDB( $u->getName() );
573 if( !$oldblock ) {
574 $block->insert();
575 # Prepare log parameters
576 $logParams = array();
577 $logParams[] = $expirestr;
578 if( $anonOnly ) {
579 $logParams[] = 'anononly';
580 }
581 $logParams[] = 'nocreate';
582 # Add log entry
583 $log->addEntry( 'block', $usertitle, $reason, $logParams );
584 }
585 # Tag userpage! (check length to avoid mistakes)
586 if( strlen($tag) > 2 ) {
587 $userpage->doEdit( $tag, $reason, EDIT_MINOR );
588 }
589 }
590 return $safeUsers;
591 }
592 }