From 183851b06bd6c52f3cae5375f433da720d410447 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Wed, 11 Oct 2006 18:12:39 +0000 Subject: MediaWiki 1.7.1 wiederhergestellt --- includes/SpecialIpblocklist.php | 255 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 255 insertions(+) create mode 100644 includes/SpecialIpblocklist.php (limited to 'includes/SpecialIpblocklist.php') diff --git a/includes/SpecialIpblocklist.php b/includes/SpecialIpblocklist.php new file mode 100644 index 00000000..cc5c805c --- /dev/null +++ b/includes/SpecialIpblocklist.php @@ -0,0 +1,255 @@ +getVal( 'wpUnblockAddress', $wgRequest->getVal( 'ip' ) ); + $reason = $wgRequest->getText( 'wpUnblockReason' ); + $action = $wgRequest->getText( 'action' ); + + $ipu = new IPUnblockForm( $ip, $reason ); + + if ( "success" == $action ) { + $ipu->showList( wfMsgWikiHtml( 'unblocked', htmlspecialchars( $ip ) ) ); + } else if ( "submit" == $action && $wgRequest->wasPosted() && + $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) ) ) { + if ( ! $wgUser->isAllowed('block') ) { + $wgOut->sysopRequired(); + return; + } + $ipu->doSubmit(); + } else if ( "unblock" == $action ) { + $ipu->showForm( "" ); + } else { + $ipu->showList( "" ); + } +} + +/** + * + * @package MediaWiki + * @subpackage SpecialPage + */ +class IPUnblockForm { + var $ip, $reason; + + function IPUnblockForm( $ip, $reason ) { + $this->ip = $ip; + $this->reason = $reason; + } + + function showForm( $err ) { + global $wgOut, $wgUser, $wgSysopUserBans; + + $wgOut->setPagetitle( wfMsg( 'unblockip' ) ); + $wgOut->addWikiText( wfMsg( 'unblockiptext' ) ); + + $ipa = wfMsgHtml( $wgSysopUserBans ? 'ipadressorusername' : 'ipaddress' ); + $ipr = wfMsgHtml( 'ipbreason' ); + $ipus = wfMsgHtml( 'ipusubmit' ); + $titleObj = Title::makeTitle( NS_SPECIAL, "Ipblocklist" ); + $action = $titleObj->escapeLocalURL( "action=submit" ); + + if ( "" != $err ) { + $wgOut->setSubtitle( wfMsg( "formerror" ) ); + $wgOut->addWikitext( "{$err}\n" ); + } + $token = htmlspecialchars( $wgUser->editToken() ); + + $wgOut->addHTML( " +
+ + + + + + + + + + + + + +
{$ipa}: + ip ) . "\" /> +
{$ipr}: + reason ) . "\" /> +
  + +
+ +
\n" ); + + } + + function doSubmit() { + global $wgOut; + + $block = new Block(); + $this->ip = trim( $this->ip ); + + if ( $this->ip{0} == "#" ) { + $block->mId = substr( $this->ip, 1 ); + } else { + $block->mAddress = $this->ip; + } + + # Delete block (if it exists) + # We should probably check for errors rather than just declaring success + $block->delete(); + + # Make log entry + $log = new LogPage( 'block' ); + $log->addEntry( 'unblock', Title::makeTitle( NS_USER, $this->ip ), $this->reason ); + + # Report to the user + $titleObj = Title::makeTitle( NS_SPECIAL, "Ipblocklist" ); + $success = $titleObj->getFullURL( "action=success&ip=" . urlencode( $this->ip ) ); + $wgOut->redirect( $success ); + } + + function showList( $msg ) { + global $wgOut; + + $wgOut->setPagetitle( wfMsg( "ipblocklist" ) ); + if ( "" != $msg ) { + $wgOut->setSubtitle( $msg ); + } + global $wgRequest; + list( $this->limit, $this->offset ) = $wgRequest->getLimitOffset(); + $this->counter = 0; + + $paging = '

' . wfViewPrevNext( $this->offset, $this->limit, + Title::makeTitle( NS_SPECIAL, 'Ipblocklist' ), + 'ip=' . urlencode( $this->ip ) ) . "

\n"; + $wgOut->addHTML( $paging ); + + $search = $this->searchForm(); + $wgOut->addHTML( $search ); + + $wgOut->addHTML( "\n" ); + $wgOut->addHTML( $paging ); + } + + function searchForm() { + global $wgTitle; + return + wfElement( 'form', array( + 'action' => $wgTitle->getLocalUrl() ), + null ) . + wfElement( 'input', array( + 'type' => 'hidden', + 'name' => 'action', + 'value' => 'search' ) ). + wfElement( 'input', array( + 'type' => 'hidden', + 'name' => 'limit', + 'value' => $this->limit ) ). + wfElement( 'input', array( + 'name' => 'ip', + 'value' => $this->ip ) ) . + wfElement( 'input', array( + 'type' => 'submit', + 'value' => wfMsg( 'search' ) ) ) . + ''; + } + + /** + * Callback function to output a block + */ + function addRow( $block, $tag ) { + global $wgOut, $wgUser, $wgLang; + + if( $this->ip != '' ) { + if( $block->mAuto ) { + if( stristr( $block->mId, $this->ip ) == false ) { + return; + } + } else { + if( stristr( $block->mAddress, $this->ip ) == false ) { + return; + } + } + } + + // Loading blocks is fast; displaying them is slow. + // Quick hack for paging. + $this->counter++; + if( $this->counter <= $this->offset ) { + return; + } + if( $this->counter - $this->offset > $this->limit ) { + return; + } + + $fname = 'IPUnblockForm-addRow'; + wfProfileIn( $fname ); + + static $sk=null, $msg=null; + + if( is_null( $sk ) ) + $sk = $wgUser->getSkin(); + if( is_null( $msg ) ) { + $msg = array(); + foreach( array( 'infiniteblock', 'expiringblock', 'contribslink', 'unblocklink' ) as $key ) { + $msg[$key] = wfMsgHtml( $key ); + } + $msg['blocklistline'] = wfMsg( 'blocklistline' ); + $msg['contribslink'] = wfMsg( 'contribslink' ); + } + + + # Prepare links to the blocker's user and talk pages + $blocker_name = $block->getByName(); + $blocker = $sk->MakeLinkObj( Title::makeTitle( NS_USER, $blocker_name ), $blocker_name ); + $blocker .= ' (' . $sk->makeLinkObj( Title::makeTitle( NS_USER_TALK, $blocker_name ), $wgLang->getNsText( NS_TALK ) ) . ')'; + + # Prepare links to the block target's user and contribs. pages (as applicable, don't do it for autoblocks) + if( $block->mAuto ) { + $target = '#' . $block->mId; # Hide the IP addresses of auto-blocks; privacy + } else { + $target = $sk->makeLinkObj( Title::makeTitle( NS_USER, $block->mAddress ), $block->mAddress ); + $target .= ' (' . $sk->makeKnownLinkObj( Title::makeTitle( NS_SPECIAL, 'Contributions' ), $msg['contribslink'], 'target=' . urlencode( $block->mAddress ) ) . ')'; + } + + # Prep the address for the unblock link, masking autoblocks as before + $addr = $block->mAuto ? '#' . $block->mId : $block->mAddress; + + $formattedTime = $wgLang->timeanddate( $block->mTimestamp, true ); + + if ( $block->mExpiry === "" ) { + $formattedExpiry = $msg['infiniteblock']; + } else { + $formattedExpiry = wfMsgReplaceArgs( $msg['expiringblock'], + array( $wgLang->timeanddate( $block->mExpiry, true ) ) ); + } + + $line = wfMsgReplaceArgs( $msg['blocklistline'], array( $formattedTime, $blocker, $target, $formattedExpiry ) ); + + $wgOut->addHTML( "
  • {$line}" ); + + if ( $wgUser->isAllowed('block') ) { + $titleObj = Title::makeTitle( NS_SPECIAL, "Ipblocklist" ); + $wgOut->addHTML( ' (' . $sk->makeKnownLinkObj($titleObj, $msg['unblocklink'], 'action=unblock&ip=' . urlencode( $addr ) ) . ')' ); + } + $wgOut->addHTML( $sk->commentBlock( $block->mReason ) ); + $wgOut->addHTML( "
  • \n" ); + wfProfileOut( $fname ); + } +} + +?> -- cgit v1.2.3-54-g00ecf