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><font color='red' size='+1'>{$err}</font>\n" );
56 <form id=\"unblockip\" method=\"post\" action=\"{$action}\">
58 <td align=right>{$ipa}:</td>
60 <input tabindex=1 type=text size=20 name=\"wpUnblockAddress\" value=\"" . htmlspecialchars( $this->ip
) . "\">
62 <td align=right>{$ipr}:</td>
64 <input tabindex=1 type=text size=40 name=\"wpUnblockReason\" value=\"" . htmlspecialchars( $this->reason
) . "\">
66 <td> </td><td align=left>
67 <input tabindex=2 type=submit name=\"wpBlock\" value=\"{$ipus}\">
75 global $wgOut, $wgUser, $wgLang;
78 $this->ip
= trim( $this->ip
);
80 if ( $this->ip
{0} == "#" ) {
81 $block->mId
= substr( $this->ip
, 1 );
83 $block->mAddress
= $this->ip
;
86 # Delete block (if it exists)
87 # We should probably check for errors rather than just declaring success
91 $log = new LogPage( wfMsg( "blocklogpage" ), wfMsg( "blocklogtext" ) );
92 $action = wfMsg( "unblocklogentry", $this->ip
);
93 $log->addEntry( $action, $this->reason
);
96 $titleObj = Title
::makeTitle( NS_SPECIAL
, "Ipblocklist" );
97 $success = $titleObj->getFullURL( "action=success&ip=" . urlencode( $this->ip
) );
98 $wgOut->redirect( $success );
101 function showList( $msg )
105 $wgOut->setPagetitle( wfMsg( "ipblocklist" ) );
107 $wgOut->setSubtitle( $msg );
109 $wgOut->addHTML( "<ul>" );
110 Block
::enumBlocks( "wfAddRow", 0 );
111 $wgOut->addHTML( "</ul>\n" );
115 # Callback function to output a block
116 function wfAddRow( $block, $tag ) {
117 global $wgOut, $wgUser, $wgLang;
119 $sk = $wgUser->getSkin();
121 # Hide addresses blocked by User::spreadBlocks, for privacy
122 $addr = $block->mAuto ?
"#{$block->mId}" : $block->mAddress
;
124 $name = User
::whoIs( $block->mBy
);
125 $ulink = $sk->makeKnownLink( $wgLang->getNsText( Namespace::getUser() ). ":{$name}", $name );
126 $formattedTime = $wgLang->timeanddate( $block->mTimestamp
, true );
128 if ( $block->mExpiry
=== "" ) {
129 $formattedExpiry = "indefinite";
131 $formattedExpiry = $wgLang->timeanddate( $block->mExpiry
, true );
134 $line = wfMsg( "blocklistline", $formattedTime, $ulink, $addr, $formattedExpiry );
136 $wgOut->addHTML( "<li>{$line}" );
138 if ( !$block->mAuto
) {
139 $titleObj = Title
::makeTitle( NS_SPECIAL
, "Contributions" );
140 $clink = "<a href=\"" . $titleObj->escapeLocalURL( "target={$block->mAddress}" ) . "\">" .
141 wfMsg( "contribslink" ) . "</a>";
142 $wgOut->addHTML( " ({$clink})" );
145 if ( $wgUser->isSysop() ) {
146 $titleObj = Title
::makeTitle( NS_SPECIAL
, "Ipblocklist" );
147 $ublink = "<a href=\"" .
148 $titleObj->escapeLocalURL( "action=unblock&ip=" . urlencode( $addr ) ) . "\">" .
149 wfMsg( "unblocklink" ) . "</a>";
150 $wgOut->addHTML( " ({$ublink})" );
152 if ( "" != $block->mReason
) {
153 $wgOut->addHTML( " <em>(" . wfEscapeHTML( $block->mReason
) .
156 $wgOut->addHTML( "</li>\n" );