3 function wfSpecialIpblocklist()
5 global $wgUser, $wgOut, $wgRequest;
7 $ip = $wgRequest->getVal( 'wpUnblockAddress', $wgRequest->getVal( 'ip' ) );
8 $reason = $wgRequest->getText( 'wpUnblockReason' );
9 $action = $wgRequest->getText( 'action' );
11 $ipu = new IPUnblockForm( $ip, $reason );
13 if ( "success" == $action ) {
14 $msg = wfMsg( "ipusuccess", $ip );
15 $ipu->showList( $msg );
16 } else if ( "submit" == $action && $wgRequest->wasPosted() ) {
17 if ( ! $wgUser->isSysop() ) {
18 $wgOut->sysopRequired();
22 } else if ( "unblock" == $action ) {
32 function IPUnblockForm( $ip, $reason ) {
34 $this->reason
= $reason;
37 function showForm( $err )
39 global $wgOut, $wgUser, $wgLang;
41 $wgOut->setPagetitle( wfMsg( "unblockip" ) );
42 $wgOut->addWikiText( wfMsg( "unblockiptext" ) );
44 $ipa = wfMsg( "ipaddress" );
45 $ipr = wfMsg( "ipbreason" );
46 $ipus = htmlspecialchars( wfMsg( "ipusubmit" ) );
47 $titleObj = Title
::makeTitle( NS_SPECIAL
, "Ipblocklist" );
48 $action = $titleObj->escapeLocalURL( "action=submit" );
51 $wgOut->setSubtitle( wfMsg( "formerror" ) );
52 $wgOut->addHTML( "<p class='error'>{$err}</p>\n" );
56 <form id=\"unblockip\" method=\"post\" action=\"{$action}\">
59 <td align='right'>{$ipa}:</td>
61 <input tabindex='1' type='text' size='20' name=\"wpUnblockAddress\" value=\"" . htmlspecialchars( $this->ip
) . "\" />
65 <td align='right'>{$ipr}:</td>
67 <input tabindex='1' type='text' size='40' name=\"wpUnblockReason\" value=\"" . htmlspecialchars( $this->reason
) . "\" />
73 <input tabindex='2' type='submit' name=\"wpBlock\" value=\"{$ipus}\" />
83 global $wgOut, $wgUser, $wgLang;
86 $this->ip
= trim( $this->ip
);
88 if ( $this->ip
{0} == "#" ) {
89 $block->mId
= substr( $this->ip
, 1 );
91 $block->mAddress
= $this->ip
;
94 # Delete block (if it exists)
95 # We should probably check for errors rather than just declaring success
99 $log = new LogPage( wfMsg( "blocklogpage" ), wfMsg( "blocklogtext" ) );
100 $action = wfMsg( "unblocklogentry", $this->ip
);
101 $log->addEntry( $action, $this->reason
);
104 $titleObj = Title
::makeTitle( NS_SPECIAL
, "Ipblocklist" );
105 $success = $titleObj->getFullURL( "action=success&ip=" . urlencode( $this->ip
) );
106 $wgOut->redirect( $success );
109 function showList( $msg )
113 $wgOut->setPagetitle( wfMsg( "ipblocklist" ) );
115 $wgOut->setSubtitle( $msg );
117 $wgOut->addHTML( "<ul>" );
118 Block
::enumBlocks( "wfAddRow", 0 );
119 $wgOut->addHTML( "</ul>\n" );
123 # Callback function to output a block
124 function wfAddRow( $block, $tag ) {
125 global $wgOut, $wgUser, $wgLang;
127 $sk = $wgUser->getSkin();
129 # Hide addresses blocked by User::spreadBlocks, for privacy
130 $addr = $block->mAuto ?
"#{$block->mId}" : $block->mAddress
;
132 $name = User
::whoIs( $block->mBy
);
133 $ulink = $sk->makeKnownLink( $wgLang->getNsText( Namespace::getUser() ). ":{$name}", $name );
134 $formattedTime = $wgLang->timeanddate( $block->mTimestamp
, true );
136 if ( $block->mExpiry
=== "" ) {
137 $formattedExpiry = "indefinite";
139 $formattedExpiry = $wgLang->timeanddate( $block->mExpiry
, true );
142 $line = wfMsg( "blocklistline", $formattedTime, $ulink, $addr, $formattedExpiry );
144 $wgOut->addHTML( "<li>{$line}" );
146 if ( !$block->mAuto
) {
147 $titleObj = Title
::makeTitle( NS_SPECIAL
, "Contributions" );
148 $clink = "<a href=\"" . $titleObj->escapeLocalURL( "target={$block->mAddress}" ) . "\">" .
149 wfMsg( "contribslink" ) . "</a>";
150 $wgOut->addHTML( " ({$clink})" );
153 if ( $wgUser->isSysop() ) {
154 $titleObj = Title
::makeTitle( NS_SPECIAL
, "Ipblocklist" );
155 $ublink = "<a href=\"" .
156 $titleObj->escapeLocalURL( "action=unblock&ip=" . urlencode( $addr ) ) . "\">" .
157 wfMsg( "unblocklink" ) . "</a>";
158 $wgOut->addHTML( " ({$ublink})" );
160 if ( "" != $block->mReason
) {
161 $wgOut->addHTML( " <em>(" . wfEscapeHTML( $block->mReason
) .
164 $wgOut->addHTML( "</li>\n" );