/** * Get basic info about a given block * @param Block $block * @return array Array containing several keys: * - blockid - ID of the block * - blockedby - username of the blocker * - blockedbyid - user ID of the blocker * - blockreason - reason provided for the block * - blockedtimestamp - timestamp for when the block was placed/modified * - blockexpiry - expiry time of the block */ public static function getBlockInfo(Block $block) { global $wgContLang; $vals = array(); $vals['blockid'] = $block->getId(); $vals['blockedby'] = $block->getByName(); $vals['blockedbyid'] = $block->getBy(); $vals['blockreason'] = $block->mReason; $vals['blockedtimestamp'] = wfTimestamp(TS_ISO_8601, $block->mTimestamp); $vals['blockexpiry'] = $wgContLang->formatExpiry($block->getExpiry(), TS_ISO_8601, 'infinite'); return $vals; }
public function __construct(Block $block) { global $wgLang, $wgRequest; $blocker = $block->getBlocker(); if ($blocker instanceof User) { // local user $blockerUserpage = $block->getBlocker()->getUserPage(); $link = "[[{$blockerUserpage->getPrefixedText()}|{$blockerUserpage->getText()}]]"; } else { // foreign user $link = $blocker; } $reason = $block->mReason; if ($reason == '') { $reason = wfMsg('blockednoreason'); } /* $ip returns who *is* being blocked, $intended contains who was meant to be blocked. * This could be a username, an IP range, or a single IP. */ $intended = $block->getTarget(); parent::__construct('blockedtitle', $block->mAuto ? 'autoblockedtext' : 'blockedtext', array($link, $reason, $wgRequest->getIP(), $block->getByName(), $block->getId(), $wgLang->formatExpiry($block->mExpiry), $intended, $wgLang->timeanddate(wfTimestamp(TS_MW, $block->mTimestamp), true))); }
/** * Get blocking information * @param $bFromSlave Bool Whether to check the slave database first. To * improve performance, non-critical checks are done * against slaves. Check when actually saving should be * done against master. */ private function getBlockedStatus($bFromSlave = true) { global $wgProxyWhitelist, $wgUser; if (-1 != $this->mBlockedby) { return; } wfProfileIn(__METHOD__); wfDebug(__METHOD__ . ": checking...\n"); // Initialize data... // Otherwise something ends up stomping on $this->mBlockedby when // things get lazy-loaded later, causing false positive block hits // due to -1 !== 0. Probably session-related... Nothing should be // overwriting mBlockedby, surely? $this->load(); # We only need to worry about passing the IP address to the Block generator if the # user is not immune to autoblocks/hardblocks, and they are the current user so we # know which IP address they're actually coming from if (!$this->isAllowed('ipblock-exempt') && $this->getID() == $wgUser->getID()) { $ip = $this->getRequest()->getIP(); } else { $ip = null; } # User/IP blocking $block = Block::newFromTarget($this->getName(), $ip, !$bFromSlave); # Proxy blocking if (!$block instanceof Block && $ip !== null && !$this->isAllowed('proxyunbannable') && !in_array($ip, $wgProxyWhitelist)) { # Local list if (self::isLocallyBlockedProxy($ip)) { $block = new Block(); $block->setBlocker(wfMsg('proxyblocker')); $block->mReason = wfMsg('proxyblockreason'); $block->setTarget($ip); } elseif ($this->isAnon() && $this->isDnsBlacklisted($ip)) { $block = new Block(); $block->setBlocker(wfMsg('sorbs')); $block->mReason = wfMsg('sorbsreason'); $block->setTarget($ip); } } if ($block instanceof Block) { wfDebug(__METHOD__ . ": Found block.\n"); $this->mBlock = $block; $this->mBlockedby = $block->getByName(); $this->mBlockreason = $block->mReason; $this->mHideName = $block->mHideName; $this->mAllowUsertalk = !$block->prevents('editownusertalk'); } else { $this->mBlockedby = ''; $this->mHideName = 0; $this->mAllowUsertalk = false; } # Extensions wfRunHooks('GetBlockedStatus', array(&$this)); wfProfileOut(__METHOD__); }
} ?> <div id="headerNav"> <?php $a = new Area('Header Nav'); $a->display($c); ?> </div> <h1 id="logo"><!-- --><a href="<?php echo DIR_REL; ?> /"><?php $block = Block::getByName('My_Site_Name'); if ($block && $block->bID) { $block->display(); } else { echo h(SITE); } ?> </a><!-- --></h1> <?php // we use the "is edit mode" check because, in edit mode, the bottom of the area overlaps the item below it, because // we're using absolute positioning. So in edit mode we add a bit of space so everything looks nice. ?> <div class="spacer"></div>
/** * Output a message that informs the user that they cannot create an account because * there is a block on them or their IP which prevents account creation. Note that * User::isBlockedFromCreateAccount(), which gets this block, ignores the 'hardblock' * setting on blocks (bug 13611). * @param Block $block The block causing this error * @throws ErrorPageError */ function userBlockedMessage(Block $block) { # Let's be nice about this, it's likely that this feature will be used # for blocking large numbers of innocent people, e.g. range blocks on # schools. Don't blame it on the user. There's a small chance that it # really is the user's fault, i.e. the username is blocked and they # haven't bothered to log out before trying to create an account to # evade it, but we'll leave that to their guilty conscience to figure # out. $errorParams = array($block->getTarget(), $block->mReason ? $block->mReason : $this->msg('blockednoreason')->text(), $block->getByName()); if ($block->getType() === Block::TYPE_RANGE) { $errorMessage = 'cantcreateaccount-range-text'; $errorParams[] = $this->getRequest()->getIP(); } else { $errorMessage = 'cantcreateaccount-text'; } throw new ErrorPageError('cantcreateaccounttitle', $errorMessage, $errorParams); }
/** * Output a message that informs the user that they cannot create an account because * there is a block on them or their IP which prevents account creation. Note that * User::isBlockedFromCreateAccount(), which gets this block, ignores the 'hardblock' * setting on blocks (bug 13611). * @param $block Block the block causing this error */ function userBlockedMessage( Block $block ) { global $wgOut; # Let's be nice about this, it's likely that this feature will be used # for blocking large numbers of innocent people, e.g. range blocks on # schools. Don't blame it on the user. There's a small chance that it # really is the user's fault, i.e. the username is blocked and they # haven't bothered to log out before trying to create an account to # evade it, but we'll leave that to their guilty conscience to figure # out. $wgOut->setPageTitle( wfMsg( 'cantcreateaccounttitle' ) ); $block_reason = $block->mReason; if ( strval( $block_reason ) === '' ) { $block_reason = wfMsg( 'blockednoreason' ); } $wgOut->addWikiMsg( 'cantcreateaccount-text', $block->getTarget(), $block_reason, $block->getByName() ); $wgOut->returnToMain( false ); }