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;
26 $wpBlockAddress = $_REQUEST["wpBlockAddress"];
27 $wpBlockReason = $_REQUEST["wpBlockReason"];
28 $ip = $_REQUEST["ip"];
30 $wgOut->setPagetitle( wfMsg( "blockip" ) );
31 $wgOut->addWikiText( wfMsg( "blockiptext" ) );
33 if ( ! $wpBlockAddress ) { $wpBlockAddress = $ip; }
34 $ipa = wfMsg( "ipaddress" );
35 $reason = wfMsg( "ipbreason" );
36 $ipbs = wfMsg( "ipbsubmit" );
37 $action = wfLocalUrlE( $wgLang->specialPage( "Blockip" ),
41 $wgOut->setSubtitle( wfMsg( "formerror" ) );
42 $wgOut->addHTML( "<p><font color='red' size='+1'>{$err}</font>\n" );
45 <form id=\"blockip\" method=\"post\" action=\"{$action}\">
47 <td align=\"right\">{$ipa}:</td>
49 <input tabindex=1 type=text size=20 name=\"wpBlockAddress\" value=\"{$wpBlockAddress}\">
51 <td align=\"right\">{$reason}:</td>
53 <input tabindex=2 type=text size=40 name=\"wpBlockReason\" value=\"{$wpBlockReason}\">
55 <td> </td><td align=\"left\">
56 <input tabindex=3 type=submit name=\"wpBlock\" value=\"{$ipbs}\">
64 global $wgOut, $wgUser, $wgLang;
65 global $ip, $wpBlockAddress, $wpBlockReason, $wgSysopUserBans;
66 $wpBlockAddress = $_REQUEST["wpBlockAddress"];
67 $wpBlockReason = $_REQUEST["wpBlockReason"];
68 $ip = $_REQUEST["ip"];
71 $wpBlockAddress = trim( $wpBlockAddress );
73 if ( ! preg_match( "/^\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}$/",
76 if ( $wgSysopUserBans ) {
77 $userId = User
::idFromName( $wpBlockAddress );
79 $this->showForm( wfMsg( "badipaddress" ) );
83 $this->showForm( wfMsg( "badipaddress" ) );
87 if ( "" == $wpBlockReason ) {
88 $this->showForm( wfMsg( "noblockreason" ) );
93 # Note: for a user block, ipb_address is only for display purposes
94 $ban = new Block( $wpBlockAddress, $userId, $wgUser->getID(),
95 wfStrencode( $wpBlockReason ), wfTimestampNow(), 0 );
99 $log = new LogPage( wfMsg( "blocklogpage" ), wfMsg( "blocklogtext" ) );
100 $action = wfMsg( "blocklogentry", $wgBlockAddress );
101 $log->addEntry( $action, $wpBlockReason );
104 $success = wfLocalUrl( $wgLang->specialPage( "Blockip" ),
105 "action=success&ip={$wpBlockAddress}" );
106 $wgOut->redirect( $success );
109 function showSuccess()
111 global $wgOut, $wgUser;
113 $wgOut->setPagetitle( wfMsg( "blockip" ) );
114 $wgOut->setSubtitle( wfMsg( "blockipsuccesssub" ) );
115 $text = wfMsg( "blockipsuccesstext", $_REQUEST["ip"] );
116 $wgOut->addWikiText( $text );