9 function wfSpecialIpblocklist() {
10 global $wgUser, $wgOut, $wgRequest;
12 $ip = $wgRequest->getVal( 'wpUnblockAddress', $wgRequest->getVal( 'ip' ) );
13 $reason = $wgRequest->getText( 'wpUnblockReason' );
14 $action = $wgRequest->getText( 'action' );
16 $ipu = new IPUnblockForm( $ip, $reason );
18 if ( "success" == $action ) {
19 $msg = wfMsg( "ipusuccess", $ip );
20 $ipu->showList( $msg );
21 } else if ( "submit" == $action && $wgRequest->wasPosted() ) {
22 if ( ! $wgUser->isSysop() ) {
23 $wgOut->sysopRequired();
27 } else if ( "unblock" == $action ) {
40 function IPUnblockForm( $ip, $reason ) {
42 $this->reason
= $reason;
45 function showForm( $err )
47 global $wgOut, $wgUser, $wgLang;
49 $wgOut->setPagetitle( wfMsg( "unblockip" ) );
50 $wgOut->addWikiText( wfMsg( "unblockiptext" ) );
52 $ipa = wfMsg( "ipaddress" );
53 $ipr = wfMsg( "ipbreason" );
54 $ipus = htmlspecialchars( wfMsg( "ipusubmit" ) );
55 $titleObj = Title
::makeTitle( NS_SPECIAL
, "Ipblocklist" );
56 $action = $titleObj->escapeLocalURL( "action=submit" );
59 $wgOut->setSubtitle( wfMsg( "formerror" ) );
60 $wgOut->addHTML( "<p class='error'>{$err}</p>\n" );
64 <form id=\"unblockip\" method=\"post\" action=\"{$action}\">
67 <td align='right'>{$ipa}:</td>
69 <input tabindex='1' type='text' size='20' name=\"wpUnblockAddress\" value=\"" . htmlspecialchars( $this->ip
) . "\" />
73 <td align='right'>{$ipr}:</td>
75 <input tabindex='1' type='text' size='40' name=\"wpUnblockReason\" value=\"" . htmlspecialchars( $this->reason
) . "\" />
81 <input tabindex='2' type='submit' name=\"wpBlock\" value=\"{$ipus}\" />
90 global $wgOut, $wgUser, $wgLang;
93 $this->ip
= trim( $this->ip
);
95 if ( $this->ip
{0} == "#" ) {
96 $block->mId
= substr( $this->ip
, 1 );
98 $block->mAddress
= $this->ip
;
101 # Delete block (if it exists)
102 # We should probably check for errors rather than just declaring success
106 $log = new LogPage( 'block' );
107 $log->addEntry( 'unblock', Title
::makeTitle( NS_USER
, $this->ip
), $this->reason
);
110 $titleObj = Title
::makeTitle( NS_SPECIAL
, "Ipblocklist" );
111 $success = $titleObj->getFullURL( "action=success&ip=" . urlencode( $this->ip
) );
112 $wgOut->redirect( $success );
115 function showList( $msg ) {
118 $wgOut->setPagetitle( wfMsg( "ipblocklist" ) );
120 $wgOut->setSubtitle( $msg );
122 $wgOut->addHTML( "<ul>" );
123 Block
::enumBlocks( "wfAddRow", 0 );
124 $wgOut->addHTML( "</ul>\n" );
129 * Callback function to output a block
131 function wfAddRow( $block, $tag ) {
132 global $wgOut, $wgUser, $wgLang;
134 $sk = $wgUser->getSkin();
136 # Hide addresses blocked by User::spreadBlocks, for privacy
137 $addr = $block->mAuto ?
"#{$block->mId}" : $block->mAddress
;
139 $name = User
::whoIs( $block->mBy
);
140 $ulink = $sk->makeKnownLink( $wgLang->getNsText( Namespace::getUser() ). ":{$name}", $name );
141 $formattedTime = $wgLang->timeanddate( $block->mTimestamp
, true );
143 if ( $block->mExpiry
=== "" ) {
144 $formattedExpiry = "indefinite";
146 $formattedExpiry = $wgLang->timeanddate( $block->mExpiry
, true );
149 $line = wfMsg( "blocklistline", $formattedTime, $ulink, $addr, $formattedExpiry );
151 $wgOut->addHTML( "<li>{$line}" );
153 if ( !$block->mAuto
) {
154 $titleObj = Title
::makeTitle( NS_SPECIAL
, "Contributions" );
155 $clink = "<a href=\"" . $titleObj->escapeLocalURL( "target={$block->mAddress}" ) . "\">" .
156 wfMsg( "contribslink" ) . "</a>";
157 $wgOut->addHTML( " ({$clink})" );
160 if ( $wgUser->isSysop() ) {
161 $titleObj = Title
::makeTitle( NS_SPECIAL
, "Ipblocklist" );
162 $ublink = "<a href=\"" .
163 $titleObj->escapeLocalURL( "action=unblock&ip=" . urlencode( $addr ) ) . "\">" .
164 wfMsg( "unblocklink" ) . "</a>";
165 $wgOut->addHTML( " ({$ublink})" );
167 if ( "" != $block->mReason
) {
168 $wgOut->addHTML( " <em>(" . htmlspecialchars( $block->mReason
) .
171 $wgOut->addHTML( "</li>\n" );