3 function wfSpecialBlockip()
5 global $wgUser, $wgOut, $action;
7 if ( ! $wgUser->isSysop() ) {
8 $wgOut->sysopRequired();
11 $fields = array( "wpBlockAddress", "wpBlockReason" );
12 wfCleanFormFields( $fields );
13 $ipb = new IPBlockForm();
15 if ( "success" == $action ) { $ipb->showSuccess(); }
16 else if ( "submit" == $action ) { $ipb->doSubmit(); }
17 else { $ipb->showForm( "" ); }
22 function showForm( $err )
24 global $wgOut, $wgUser, $wgLang;
25 global $ip, $wpBlockAddress, $wpBlockReason;
27 $wgOut->setPagetitle( wfMsg( "blockip" ) );
28 $wgOut->addWikiText( wfMsg( "blockiptext" ) );
30 if ( ! $wpBlockAddress ) { $wpBlockAddress = $ip; }
31 $ipa = wfMsg( "ipaddress" );
32 $reason = wfMsg( "ipbreason" );
33 $ipbs = wfMsg( "ipbsubmit" );
34 $action = wfLocalUrlE( $wgLang->specialPage( "Blockip" ),
38 $wgOut->setSubtitle( wfMsg( "formerror" ) );
39 $wgOut->addHTML( "<p><font color='red' size='+1'>{$err}</font>\n" );
42 <form id=\"blockip\" method=\"post\" action=\"{$action}\">
44 <td align=\"right\">{$ipa}:</td>
46 <input tabindex=1 type=text size=20 name=\"wpBlockAddress\" value=\"{$wpBlockAddress}\">
48 <td align=\"right\">{$reason}:</td>
50 <input tabindex=2 type=text size=40 name=\"wpBlockReason\" value=\"{$wpBlockReason}\">
52 <td> </td><td align=\"left\">
53 <input tabindex=3 type=submit name=\"wpBlock\" value=\"{$ipbs}\">
61 global $wgOut, $wgUser, $wgLang;
62 global $ip, $wpBlockAddress, $wpBlockReason, $wgSysopUserBans;
65 $wpBlockAddress = trim( $wpBlockAddress );
67 if ( ! preg_match( "/^\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}$/",
70 if ( $wgSysopUserBans ) {
71 $userId = User
::idFromName( $wpBlockAddress );
73 $this->showForm( wfMsg( "badipaddress" ) );
77 $this->showForm( wfMsg( "badipaddress" ) );
81 if ( "" == $wpBlockReason ) {
82 $this->showForm( wfMsg( "noblockreason" ) );
87 # Note: for a user block, ipb_address is only for display purposes
88 $ban = new Block( $wpBlockAddress, $userId, $wgUser->getID(),
89 wfStrencode( $wpBlockReason ), wfTimestampNow(), 0 );
93 $log = new LogPage( wfMsg( "blocklogpage" ), wfMsg( "blocklogtext" ) );
94 $action = wfMsg( "blocklogentry", $wgBlockAddress );
95 $log->addEntry( $action, $wpBlockReason );
98 $success = wfLocalUrl( $wgLang->specialPage( "Blockip" ),
99 "action=success&ip={$wpBlockAddress}" );
100 $wgOut->redirect( $success );
103 function showSuccess()
105 global $wgOut, $wgUser;
108 $wgOut->setPagetitle( wfMsg( "blockip" ) );
109 $wgOut->setSubtitle( wfMsg( "blockipsuccesssub" ) );
110 $text = wfMsg( "blockipsuccesstext", $ip );
111 $wgOut->addWikiText( $text );