5 * @subpackage SpecialPage
11 function wfSpecialIpblocklist() {
12 global $wgUser, $wgOut, $wgRequest;
14 $ip = $wgRequest->getVal( 'wpUnblockAddress', $wgRequest->getVal( 'ip' ) );
15 $reason = $wgRequest->getText( 'wpUnblockReason' );
16 $action = $wgRequest->getText( 'action' );
18 $ipu = new IPUnblockForm( $ip, $reason );
20 if ( "success" == $action ) {
21 $msg = wfMsg( "ipusuccess", htmlspecialchars( $ip ) );
22 $ipu->showList( $msg );
23 } else if ( "submit" == $action && $wgRequest->wasPosted() &&
24 $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) ) ) {
25 if ( ! $wgUser->isAllowed('block') ) {
26 $wgOut->sysopRequired();
30 } else if ( "unblock" == $action ) {
40 * @subpackage SpecialPage
45 function IPUnblockForm( $ip, $reason ) {
47 $this->reason
= $reason;
50 function showForm( $err )
52 global $wgOut, $wgUser, $wgLang, $wgSysopUserBans;
54 $wgOut->setPagetitle( wfMsg( 'unblockip' ) );
55 $wgOut->addWikiText( wfMsg( 'unblockiptext' ) );
57 $ipa = wfMsgHtml( $wgSysopUserBans ?
'ipadressorusername' : 'ipaddress' );
58 $ipr = wfMsgHtml( 'ipbreason' );
59 $ipus = wfMsgHtml( 'ipusubmit' );
60 $titleObj = Title
::makeTitle( NS_SPECIAL
, "Ipblocklist" );
61 $action = $titleObj->escapeLocalURL( "action=submit" );
64 $wgOut->setSubtitle( wfMsg( "formerror" ) );
65 $wgOut->addWikitext( "<span class='error'>{$err}</span>\n" );
67 $token = htmlspecialchars( $wgUser->editToken() );
70 <form id=\"unblockip\" method=\"post\" action=\"{$action}\">
73 <td align='right'>{$ipa}:</td>
75 <input tabindex='1' type='text' size='20' name=\"wpUnblockAddress\" value=\"" . htmlspecialchars( $this->ip
) . "\" />
79 <td align='right'>{$ipr}:</td>
81 <input tabindex='1' type='text' size='40' name=\"wpUnblockReason\" value=\"" . htmlspecialchars( $this->reason
) . "\" />
87 <input tabindex='2' type='submit' name=\"wpBlock\" value=\"{$ipus}\" />
91 <input type='hidden' name='wpEditToken' value=\"{$token}\" />
97 global $wgOut, $wgUser, $wgLang;
100 $this->ip
= trim( $this->ip
);
102 if ( $this->ip
{0} == "#" ) {
103 $block->mId
= substr( $this->ip
, 1 );
105 $block->mAddress
= $this->ip
;
108 # Delete block (if it exists)
109 # We should probably check for errors rather than just declaring success
113 $log = new LogPage( 'block' );
114 $log->addEntry( 'unblock', Title
::makeTitle( NS_USER
, $this->ip
), $this->reason
);
117 $titleObj = Title
::makeTitle( NS_SPECIAL
, "Ipblocklist" );
118 $success = $titleObj->getFullURL( "action=success&ip=" . urlencode( $this->ip
) );
119 $wgOut->redirect( $success );
122 function showList( $msg ) {
125 $wgOut->setPagetitle( wfMsg( "ipblocklist" ) );
127 $wgOut->setSubtitle( $msg );
129 $wgOut->addHTML( "<ul>" );
130 // FIXME hack to solve #bug 1487
131 if(!Block
::enumBlocks( "wfAddRow", 0 ))
132 $wgOut->addHTML( '<li>'.wfMsg( 'ipblocklistempty' ).'</li>' );
133 $wgOut->addHTML( "</ul>\n" );
138 * Callback function to output a block
140 function wfAddRow( $block, $tag ) {
141 global $wgOut, $wgUser, $wgLang, $wgContLang;
143 $sk = $wgUser->getSkin();
145 # Hide addresses blocked by User::spreadBlocks, for privacy
146 $addr = $block->mAuto ?
"#{$block->mId}" : $block->mAddress
;
148 $name = User
::whoIs( $block->mBy
);
149 $ulink = $sk->makeKnownLinkObj( Title
::makeTitle( NS_USER
, $name ), $name );
150 $formattedTime = $wgLang->timeanddate( $block->mTimestamp
, true );
152 if ( $block->mExpiry
=== "" ) {
153 $formattedExpiry = wfMsgHtml('infiniteblock');
155 $formattedExpiry = wfMsgHtml('expiringblock', $wgLang->timeanddate( $block->mExpiry
, true ) );
158 $line = wfMsg( "blocklistline", $formattedTime, $ulink, $addr, $formattedExpiry );
160 $wgOut->addHTML( "<li>{$line}" );
162 if ( !$block->mAuto
) {
163 $titleObj = Title
::makeTitle( NS_SPECIAL
, "Contributions" );
164 $wgOut->addHTML( ' (' . $sk->makeKnownLinkObj($titleObj, wfMsgHtml( 'contribslink' ), "target={$block->mAddress}") . ')' );
167 if ( $wgUser->isAllowed('block') ) {
168 $titleObj = Title
::makeTitle( NS_SPECIAL
, "Ipblocklist" );
169 $wgOut->addHTML( ' (' . $sk->makeKnownLinkObj($titleObj, wfMsgHtml( 'unblocklink' ), 'action=unblock&ip=' . urlencode( $addr ) ) . ')' );
171 $wgOut->addHTML( $sk->commentBlock( $block->mReason
) );
172 $wgOut->addHTML( "</li>\n" );