Main Page | Namespace List | Class Hierarchy | Class List | File List | Class Members | File Members | Related Pages

SpecialIpblocklist.php

Go to the documentation of this file.
00001 <?php 00002 00003 function wfSpecialIpblocklist() 00004 { 00005 global $wgUser, $wgOut, $wgRequest; 00006 00007 $ip = $wgRequest->getVal( 'wpUnblockAddress', $wgRequest->getVal( 'ip' ) ); 00008 $reason = $wgRequest->getText( 'wpUnblockReason' ); 00009 $action = $wgRequest->getText( 'action' ); 00010 00011 $ipu = new IPUnblockForm( $ip, $reason ); 00012 00013 if ( "success" == $action ) { 00014 $msg = wfMsg( "ipusuccess", $ip ); 00015 $ipu->showList( $msg ); 00016 } else if ( "submit" == $action && $wgRequest->wasPosted() ) { 00017 if ( ! $wgUser->isSysop() ) { 00018 $wgOut->sysopRequired(); 00019 return; 00020 } 00021 $ipu->doSubmit(); 00022 } else if ( "unblock" == $action ) { 00023 $ipu->showForm( "" ); 00024 } else { 00025 $ipu->showList( "" ); 00026 } 00027 } 00028 00029 class IPUnblockForm { 00030 var $ip, $reason; 00031 00032 function IPUnblockForm( $ip, $reason ) { 00033 $this->ip = $ip; 00034 $this->reason = $reason; 00035 } 00036 00037 function showForm( $err ) 00038 { 00039 global $wgOut, $wgUser, $wgLang; 00040 00041 $wgOut->setPagetitle( wfMsg( "unblockip" ) ); 00042 $wgOut->addWikiText( wfMsg( "unblockiptext" ) ); 00043 00044 $ipa = wfMsg( "ipaddress" ); 00045 $ipr = wfMsg( "ipbreason" ); 00046 $ipus = htmlspecialchars( wfMsg( "ipusubmit" ) ); 00047 $titleObj = Title::makeTitle( NS_SPECIAL, "Ipblocklist" ); 00048 $action = $titleObj->escapeLocalURL( "action=submit" ); 00049 00050 if ( "" != $err ) { 00051 $wgOut->setSubtitle( wfMsg( "formerror" ) ); 00052 $wgOut->addHTML( "<p class='error'>{$err}</p>\n" ); 00053 } 00054 00055 $wgOut->addHTML( " 00056 <form id=\"unblockip\" method=\"post\" action=\"{$action}\"> 00057 <table border='0'> 00058 <tr> 00059 <td align='right'>{$ipa}:</td> 00060 <td align='left'> 00061 <input tabindex='1' type='text' size='20' name=\"wpUnblockAddress\" value=\"" . htmlspecialchars( $this->ip ) . "\" /> 00062 </td> 00063 </tr> 00064 <tr> 00065 <td align='right'>{$ipr}:</td> 00066 <td align='left'> 00067 <input tabindex='1' type='text' size='40' name=\"wpUnblockReason\" value=\"" . htmlspecialchars( $this->reason ) . "\" /> 00068 </td> 00069 </tr> 00070 <tr> 00071 <td>&nbsp;</td> 00072 <td align='left'> 00073 <input tabindex='2' type='submit' name=\"wpBlock\" value=\"{$ipus}\" /> 00074 </td> 00075 </tr> 00076 </table> 00077 </form>\n" ); 00078 00079 } 00080 00081 function doSubmit() 00082 { 00083 global $wgOut, $wgUser, $wgLang; 00084 00085 $block = new Block(); 00086 $this->ip = trim( $this->ip ); 00087 00088 if ( $this->ip{0} == "#" ) { 00089 $block->mId = substr( $this->ip, 1 ); 00090 } else { 00091 $block->mAddress = $this->ip; 00092 } 00093 00094 # Delete block (if it exists) 00095 # We should probably check for errors rather than just declaring success 00096 $block->delete(); 00097 00098 # Make log entry 00099 $log = new LogPage( wfMsg( "blocklogpage" ), wfMsg( "blocklogtext" ) ); 00100 $action = wfMsg( "unblocklogentry", $this->ip ); 00101 $log->addEntry( $action, $this->reason ); 00102 00103 # Report to the user 00104 $titleObj = Title::makeTitle( NS_SPECIAL, "Ipblocklist" ); 00105 $success = $titleObj->getFullURL( "action=success&ip=" . urlencode( $this->ip ) ); 00106 $wgOut->redirect( $success ); 00107 } 00108 00109 function showList( $msg ) 00110 { 00111 global $wgOut; 00112 00113 $wgOut->setPagetitle( wfMsg( "ipblocklist" ) ); 00114 if ( "" != $msg ) { 00115 $wgOut->setSubtitle( $msg ); 00116 } 00117 $wgOut->addHTML( "<ul>" ); 00118 Block::enumBlocks( "wfAddRow", 0 ); 00119 $wgOut->addHTML( "</ul>\n" ); 00120 } 00121 } 00122 00123 # Callback function to output a block 00124 function wfAddRow( $block, $tag ) { 00125 global $wgOut, $wgUser, $wgLang; 00126 00127 $sk = $wgUser->getSkin(); 00128 00129 # Hide addresses blocked by User::spreadBlocks, for privacy 00130 $addr = $block->mAuto ? "#{$block->mId}" : $block->mAddress; 00131 00132 $name = User::whoIs( $block->mBy ); 00133 $ulink = $sk->makeKnownLink( $wgLang->getNsText( Namespace::getUser() ). ":{$name}", $name ); 00134 $formattedTime = $wgLang->timeanddate( $block->mTimestamp, true ); 00135 00136 if ( $block->mExpiry === "" ) { 00137 $formattedExpiry = "indefinite"; 00138 } else { 00139 $formattedExpiry = $wgLang->timeanddate( $block->mExpiry, true ); 00140 } 00141 00142 $line = wfMsg( "blocklistline", $formattedTime, $ulink, $addr, $formattedExpiry ); 00143 00144 $wgOut->addHTML( "<li>{$line}" ); 00145 00146 if ( !$block->mAuto ) { 00147 $titleObj = Title::makeTitle( NS_SPECIAL, "Contributions" ); 00148 $clink = "<a href=\"" . $titleObj->escapeLocalURL( "target={$block->mAddress}" ) . "\">" . 00149 wfMsg( "contribslink" ) . "</a>"; 00150 $wgOut->addHTML( " ({$clink})" ); 00151 } 00152 00153 if ( $wgUser->isSysop() ) { 00154 $titleObj = Title::makeTitle( NS_SPECIAL, "Ipblocklist" ); 00155 $ublink = "<a href=\"" . 00156 $titleObj->escapeLocalURL( "action=unblock&ip=" . urlencode( $addr ) ) . "\">" . 00157 wfMsg( "unblocklink" ) . "</a>"; 00158 $wgOut->addHTML( " ({$ublink})" ); 00159 } 00160 if ( "" != $block->mReason ) { 00161 $wgOut->addHTML( " <em>(" . wfEscapeHTML( $block->mReason ) . 00162 ")</em>" ); 00163 } 00164 $wgOut->addHTML( "</li>\n" ); 00165 } 00166 00167 00168 ?>

Generated on Tue Jun 29 23:40:07 2004 for Mediawiki by doxygen 1.3.7