MediaWiki
1.23.2
|
Public Member Functions | |
__construct ( $address='', $user=0, $by=0, $reason='', $timestamp=0, $auto=0, $expiry='', $anonOnly=0, $createAccount=0, $enableAutoblock=0, $hideName=0, $blockEmail=0, $allowUsertalk=0, $byText='') | |
Constructor. More... | |
delete () | |
Delete the row from the IP blocks table. More... | |
deleteIfExpired () | |
Check if a block has expired. More... | |
doAutoblock ( $autoblockIP) | |
Autoblocks the given IP, referring to this Block. More... | |
equals (Block $block) | |
Check if two blocks are effectively equal. More... | |
fromMaster ( $x=null) | |
Get/set a flag determining whether the master is used for reads. More... | |
getBlocker () | |
Get the user who implemented this block. More... | |
getBy () | |
Get the user id of the blocking sysop. More... | |
getByName () | |
Get the username of the blocking sysop. More... | |
getExpiry () | |
getId () | |
Get the block ID. More... | |
getPermissionsError (IContextSource $context) | |
Get the key and parameters for the corresponding error message. More... | |
getRangeEnd () | |
Get the IP address at the end of the range in Hex form. More... | |
getRangeStart () | |
Get the IP address at the start of the range in Hex form. More... | |
getRedactedName () | |
Get the block name, but with autoblocked IPs hidden as per standard privacy policy. More... | |
getTarget () | |
Get the target for this particular Block. More... | |
getTargetAndType () | |
Get the target and target type for this particular Block. More... | |
getType () | |
Get the type of target for this particular block. More... | |
insert ( $dbw=null) | |
Insert a block into the block table. More... | |
isAutoblocking ( $x=null) | |
isExpired () | |
Has the block expired? More... | |
isHardblock ( $x=null) | |
Get/set whether the Block is a hardblock (affects logged-in users on a given IP/range. More... | |
isValid () | |
Is the block address valid (i.e. More... | |
prevents ( $action, $x=null) | |
Get/set whether the Block prevents a given action. More... | |
setBlocker ( $user) | |
Set the user who implemented (or will implement) this block. More... | |
setTarget ( $target) | |
Set the target for this block, and update $this->type accordingly. More... | |
update () | |
Update a block in the DB with new parameters. More... | |
updateTimestamp () | |
Update the timestamp on autoblocks. More... | |
Static Public Member Functions | |
static | chooseBlock (array $blocks, array $ipChain) |
From a list of multiple blocks, find the most exact and strongest Block. More... | |
static | getAutoblockExpiry ( $timestamp) |
Get a timestamp of the expiry for autoblocks. More... | |
static | getBlocksForIPList (array $ipChain, $isAnon, $fromMaster=false) |
Get all blocks that match any IP from an array of IP addresses. More... | |
static | getRangeCond ( $start, $end=null) |
Get a set of SQL conditions which will select rangeblocks encompassing a given range. More... | |
static | isWhitelistedFromAutoblocks ( $ip) |
Checks whether a given IP is on the autoblock whitelist. More... | |
static | newFromID ( $id) |
Load a blocked user from their block id. More... | |
static | newFromRow ( $row) |
Create a new Block object from a database row. More... | |
static | newFromTarget ( $specificTarget, $vagueTarget=null, $fromMaster=false) |
Given a target and the target's type, get an existing Block object if possible. More... | |
static | parseTarget ( $target) |
From an existing Block, get the target and the type of target. More... | |
static | purgeExpired () |
Purge expired blocks from the ipblocks table. More... | |
static | selectFields () |
Return the list of ipblocks fields that should be selected to create a new block. More... | |
Public Attributes | |
$mAuto | |
$mBlockEmail | |
$mCreateAccount | |
$mDisableUsertalk | |
$mExpiry | |
$mFromMaster | |
$mHideName | |
$mParentBlockId | |
$mReason | |
$mTimestamp | |
const | TYPE_AUTO = 4 |
const | TYPE_ID = 5 |
const | TYPE_IP = 2 |
const | TYPE_RANGE = 3 |
const | TYPE_USER = 1 |
Protected Member Functions | |
doRetroactiveAutoblock () | |
Retroactively autoblocks the last IP used by the user (if it is a user) blocked by this Block. More... | |
getAutoblockUpdateArray () | |
getDatabaseArray ( $db=null) | |
Get an array suitable for passing to $dbw->insert() or $dbw->update() More... | |
initFromRow ( $row) | |
Given a database row from the ipblocks table, initialize member variables. More... | |
newLoad ( $vagueTarget=null) | |
Load a block from the database which affects the already-set $this->target: 1) A block directly on the given user or IP 2) A rangeblock encompassing the given IP (smallest first) 3) An autoblock on the given IP. More... | |
Static Protected Member Functions | |
static | defaultRetroactiveAutoblock (Block $block, array &$blockIds) |
Retroactively autoblocks the last IP used by the user (if it is a user) blocked by this Block. More... | |
static | getIpFragment ( $hex) |
Get the component of an IP address which is certain to be the same between an IP address and a rangeblock containing that IP address. More... | |
Protected Attributes | |
User | $blocker |
Integer | $forcedTargetID |
Hack for foreign blocking (CentralAuth) *. More... | |
Bool | $isAutoblocking = true |
Bool | $isHardblock = true |
$mId | |
User String | $target |
Integer | $type |
Block::TYPE_ constant. More... | |
Block::__construct | ( | $address = '' , |
|
$user = 0 , |
|||
$by = 0 , |
|||
$reason = '' , |
|||
$timestamp = 0 , |
|||
$auto = 0 , |
|||
$expiry = '' , |
|||
$anonOnly = 0 , |
|||
$createAccount = 0 , |
|||
$enableAutoblock = 0 , |
|||
$hideName = 0 , |
|||
$blockEmail = 0 , |
|||
$allowUsertalk = 0 , |
|||
$byText = '' |
|||
) |
Constructor.
Definition at line 58 of file Block.php.
References $allowUsertalk, $timestamp, $user, DB_SLAVE, isAutoblocking(), isHardblock(), prevents(), setBlocker(), setTarget(), TS_MW, wfGetDB(), wfTimestamp(), and wfTimestampNow().
From a list of multiple blocks, find the most exact and strongest Block.
The logic for finding the "best" block is:
Array | $ipChain | list of IPs (strings). This is used to determine how "close" a block is to the server, and if a block matches exactly, or is in a range. The order is furthest from the server to nearest e.g., (Browser, proxy1, proxy2, local-squid, ...) |
Array | $block | Array of blocks |
Definition at line 1089 of file Block.php.
References array(), as, isHardblock(), prevents(), IP\toHex(), wfProfileIn(), and wfProfileOut().
Referenced by User\getBlockedStatus(), and BlockTest\testBlocksOnXff().
Retroactively autoblocks the last IP used by the user (if it is a user) blocked by this Block.
This will use the recentchanges table.
Block | $block | |
array | &$blockIds |
Definition at line 561 of file Block.php.
References $dbr, $options, $res, array(), as, DB_SLAVE, doAutoblock(), getTarget(), global, wfDebug(), and wfGetDB().
Referenced by doRetroactiveAutoblock().
Block::delete | ( | ) |
Delete the row from the IP blocks table.
MWException |
Definition at line 374 of file Block.php.
References array(), DB_MASTER, getId(), wfGetDB(), and wfReadOnly().
Block::deleteIfExpired | ( | ) |
Check if a block has expired.
Delete it if it is.
Definition at line 715 of file Block.php.
References isExpired(), wfDebug(), wfProfileIn(), and wfProfileOut().
Block::doAutoblock | ( | $autoblockIP | ) |
Autoblocks the given IP, referring to this Block.
string | $autoblockIP | the IP to autoblock. |
Definition at line 645 of file Block.php.
References $mHideName, $mId, $timestamp, array(), getAutoblockExpiry(), getBlocker(), getTarget(), isAutoblocking(), newFromTarget(), prevents(), wfDebug(), wfMessage(), wfRunHooks(), and wfTimestampNow().
Referenced by defaultRetroactiveAutoblock().
|
protected |
Retroactively autoblocks the last IP used by the user (if it is a user) blocked by this Block.
Definition at line 537 of file Block.php.
References array(), defaultRetroactiveAutoblock(), getTarget(), getType(), isAutoblocking(), wfDebug(), and wfRunHooks().
Block::equals | ( | Block | $block | ) |
Check if two blocks are effectively equal.
Doesn't check irrelevant things like the blocking user or the block timestamp, only things which affect the blocked user
$block | Block |
Definition at line 152 of file Block.php.
References isAutoblocking(), isHardblock(), and prevents().
Block::fromMaster | ( | $x = null | ) |
Get/set a flag determining whether the master is used for reads.
$x | Bool |
Definition at line 852 of file Block.php.
References wfSetVar().
|
static |
Get a timestamp of the expiry for autoblocks.
$timestamp | String|Int |
Definition at line 928 of file Block.php.
References $timestamp, global, TS_MW, TS_UNIX, and wfTimestamp().
Referenced by doAutoblock(), and updateTimestamp().
|
protected |
Definition at line 520 of file Block.php.
References array(), getBy(), getByName(), and prevents().
Referenced by update().
Block::getBlocker | ( | ) |
Get the user who implemented this block.
Definition at line 1298 of file Block.php.
References $blocker.
Referenced by doAutoblock(), getBy(), getByName(), getPermissionsError(), and BlockTest\testCrappyCrossWikiBlocks().
Get all blocks that match any IP from an array of IP addresses.
Array | $ipChain | list of IPs (strings), usually retrieved from the X-Forwarded-For header of the request |
Bool | $isAnon | Exclude anonymous-only blocks if false |
Bool | $fromMaster | Whether to query the master or slave database |
Definition at line 1010 of file Block.php.
References array(), as, DB_MASTER, DB_SLAVE, getRangeCond(), IP\isValid(), LIST_OR, newFromRow(), selectFields(), IP\toHex(), wfGetDB(), wfIsTrustedProxy(), wfProfileIn(), and wfProfileOut().
Referenced by User\getBlockedStatus(), and BlockTest\testBlocksOnXff().
Block::getBy | ( | ) |
Get the user id of the blocking sysop.
Definition at line 819 of file Block.php.
References $blocker, getBlocker(), and User\getId().
Referenced by getAutoblockUpdateArray(), getDatabaseArray(), and BlockTest\testCrappyCrossWikiBlocks().
Block::getByName | ( | ) |
Get the username of the blocking sysop.
Definition at line 831 of file Block.php.
References $blocker, getBlocker(), and User\getName().
Referenced by getAutoblockUpdateArray(), getDatabaseArray(), getPermissionsError(), BlockTest\testCrappyCrossWikiBlocks(), and LoginForm\userBlockedMessage().
|
protected |
Get an array suitable for passing to $dbw->insert() or $dbw->update()
$db | DatabaseBase |
Definition at line 482 of file Block.php.
References $forcedTargetID, $mAuto, $mParentBlockId, array(), DB_SLAVE, getBy(), getByName(), getRangeEnd(), getRangeStart(), isAutoblocking(), isHardblock(), prevents(), and wfGetDB().
Block::getExpiry | ( | ) |
Block::getId | ( | ) |
|
staticprotected |
Block::getPermissionsError | ( | IContextSource | $context | ) |
Get the key and parameters for the corresponding error message.
IContextSource | $context |
Definition at line 1317 of file Block.php.
References $blocker, $link, $mReason, array(), getBlocker(), getByName(), getId(), IContextSource\getLanguage(), IContextSource\getRequest(), getTarget(), User\getUserPage(), IContextSource\msg(), TS_MW, and wfTimestamp().
Referenced by UserBlockedError\__construct().
|
static |
Get a set of SQL conditions which will select rangeblocks encompassing a given range.
string | $start | Hexadecimal IP representation |
string | $end | Hexadecimal IP representation, or null to use $start = $end |
Definition at line 279 of file Block.php.
References $dbr, array(), DB_SLAVE, getIpFragment(), LIST_AND, and wfGetDB().
Referenced by getBlocksForIPList(), newLoad(), and SpecialBlockList\showList().
Block::getRangeEnd | ( | ) |
Get the IP address at the end of the range in Hex form.
MWException |
Definition at line 800 of file Block.php.
References list, IP\parseRange(), IP\toHex(), type, TYPE_IP, TYPE_RANGE, and TYPE_USER.
Referenced by getDatabaseArray().
Block::getRangeStart | ( | ) |
Get the IP address at the start of the range in Hex form.
MWException |
Definition at line 781 of file Block.php.
References list, IP\parseRange(), IP\toHex(), type, TYPE_IP, TYPE_RANGE, and TYPE_USER.
Referenced by getDatabaseArray().
Block::getRedactedName | ( | ) |
Get the block name, but with autoblocked IPs hidden as per standard privacy policy.
Definition at line 910 of file Block.php.
References array(), getTarget(), Html\rawElement(), and wfMessage().
Block::getTarget | ( | ) |
Get the target for this particular Block.
Note that for autoblocks, this returns the unredacted name; frontend functions need to call $block->getRedactedName() in this situation.
Definition at line 1273 of file Block.php.
References $target.
Referenced by defaultRetroactiveAutoblock(), doAutoblock(), doRetroactiveAutoblock(), getPermissionsError(), getRedactedName(), getTargetAndType(), isValid(), BlockTest\testCrappyCrossWikiBlocks(), updateTimestamp(), and LoginForm\userBlockedMessage().
Block::getTargetAndType | ( | ) |
Get the target and target type for this particular Block.
Note that for autoblocks, this returns the unredacted name; frontend functions need to call $block->getRedactedName() in this situation.
Definition at line 1263 of file Block.php.
References array(), getTarget(), and getType().
Block::getType | ( | ) |
Get the type of target for this particular block.
Definition at line 1250 of file Block.php.
References $type, and TYPE_AUTO.
Referenced by doRetroactiveAutoblock(), getTargetAndType(), isAutoblocking(), isHardblock(), and LoginForm\userBlockedMessage().
|
protected |
Given a database row from the ipblocks table, initialize member variables.
$row | ResultWrapper: a row from the ipblocks table |
Definition at line 326 of file Block.php.
References DB_SLAVE, isAutoblocking(), isHardblock(), prevents(), setBlocker(), setTarget(), TS_MW, wfGetDB(), and wfTimestamp().
Referenced by newFromRow(), and newLoad().
Block::insert | ( | $dbw = null | ) |
Insert a block into the block table.
Will fail if there is a conflicting block (same name and options) already in the database.
$dbw | DatabaseBase if you have one available |
Definition at line 398 of file Block.php.
References array(), DB_MASTER, doRetroactiveAutoblock(), getDatabaseArray(), purgeExpired(), wfDebug(), and wfGetDB().
Referenced by BlockTest\addXffBlocks(), BlockTest\testBlockedUserCanNotCreateAccount(), and BlockTest\testCrappyCrossWikiBlocks().
Block::isAutoblocking | ( | $x = null | ) |
Definition at line 870 of file Block.php.
References getType(), and wfSetVar().
Referenced by __construct(), BlockTest\addXffBlocks(), doAutoblock(), doRetroactiveAutoblock(), equals(), getDatabaseArray(), initFromRow(), and update().
Block::isExpired | ( | ) |
Has the block expired?
Definition at line 735 of file Block.php.
References $mExpiry, $timestamp, wfDebug(), and wfTimestampNow().
Referenced by deleteIfExpired().
Block::isHardblock | ( | $x = null | ) |
Get/set whether the Block is a hardblock (affects logged-in users on a given IP/range.
$x | Bool |
Definition at line 861 of file Block.php.
References $isHardblock, getType(), true, and wfSetVar().
Referenced by __construct(), BlockTest\addXffBlocks(), chooseBlock(), equals(), getDatabaseArray(), and initFromRow().
Block::isValid | ( | ) |
Is the block address valid (i.e.
not a null string?)
Definition at line 750 of file Block.php.
References getTarget().
|
static |
Checks whether a given IP is on the autoblock whitelist.
TODO: this probably belongs somewhere else, but not sure where...
string | $ip | The IP to check |
Definition at line 602 of file Block.php.
References $line, $lines, $wgMemc, as, global, IP\isInRange(), wfDebug(), wfMemcKey(), and wfMessage().
|
static |
Load a blocked user from their block id.
$id | Integer: Block id to search for |
Definition at line 104 of file Block.php.
References $dbr, $res, array(), DB_SLAVE, newFromRow(), and wfGetDB().
Referenced by newFromTarget(), BlockTest\testCrappyCrossWikiBlocks(), and BlockTest\testINewFromIDReturnsCorrectBlock().
|
static |
Create a new Block object from a database row.
$row | ResultWrapper row from the ipblocks table |
Definition at line 362 of file Block.php.
References initFromRow().
Referenced by getBlocksForIPList(), newFromID(), and newLoad().
|
static |
Given a target and the target's type, get an existing Block object if possible.
$specificTarget | String|User|Int a block target, which may be one of several types:
| |
$vagueTarget | String|User|Int as above, but we will search for any block which affects that target (so for an IP address, get ranges containing that IP; and also get any relevant autoblocks). Leave empty or blank to skip IP-based lookups. | |
bool | $fromMaster | whether to use the DB_MASTER database |
Definition at line 970 of file Block.php.
References $target, $type, array(), list, newFromID(), parseTarget(), TYPE_AUTO, TYPE_ID, TYPE_IP, TYPE_RANGE, and TYPE_USER.
Referenced by BlockTest\addDBData(), doAutoblock(), ApiUnblock\execute(), SpecialUnblock\execute(), ApiBlock\execute(), User\getBlockedStatus(), Article\getRobotPolicy(), User\isBlockedFromCreateAccount(), SpecialBlock\maybeAlterFormDefaults(), SpecialBlock\processForm(), SpecialUnblock\processUnblock(), User\spreadBlock(), BlockTest\testBlockedUserCanNotCreateAccount(), BlockTest\testBug29116NewFromTargetWithEmptyIp(), BlockTest\testCrappyCrossWikiBlocks(), BlockTest\testINewFromTargetReturnsCorrectBlock(), and ApiBlockTest\testMakeNormalBlock().
|
protected |
Load a block from the database which affects the already-set $this->target: 1) A block directly on the given user or IP 2) A rangeblock encompassing the given IP (smallest first) 3) An autoblock on the given IP.
$vagueTarget | User|String also search for blocks affecting this target. Doesn't make any sense to use TYPE_AUTO / TYPE_ID here. Leave blank to skip IP lookups. |
MWException |
Definition at line 178 of file Block.php.
References $res, $size, $target, $type, array(), as, DB_MASTER, DB_SLAVE, getRangeCond(), initFromRow(), list, LIST_OR, newFromRow(), IP\parseRange(), parseTarget(), prevents(), IP\toHex(), type, TYPE_IP, TYPE_RANGE, TYPE_USER, and wfGetDB().
|
static |
From an existing Block, get the target and the type of target.
Note that, except for null, it is always safe to treat the target as a string; for User objects this will return User::__toString() which in turn gives User::getName().
$target | String|Int|User|null |
Definition at line 1194 of file Block.php.
References $target, array(), User\getName(), IP\isValid(), IP\isValidBlock(), User\newFromName(), IP\sanitizeIP(), IP\sanitizeRange(), TYPE_AUTO, TYPE_IP, TYPE_RANGE, and TYPE_USER.
Referenced by BlockListPager\formatValue(), SpecialBlock\getTargetAndType(), newFromTarget(), newLoad(), SpecialBlock\setParameter(), setTarget(), and SpecialBlockList\showList().
Block::prevents | ( | $action, | |
$x = null |
|||
) |
Get/set whether the Block prevents a given action.
$action | String |
$x | Bool |
Definition at line 886 of file Block.php.
References wfSetVar().
Referenced by __construct(), BlockTest\addXffBlocks(), chooseBlock(), doAutoblock(), equals(), getAutoblockUpdateArray(), getDatabaseArray(), initFromRow(), User\isBlockedFromCreateAccount(), newLoad(), and BlockTest\testBlockedUserCanNotCreateAccount().
|
static |
Purge expired blocks from the ipblocks table.
Definition at line 937 of file Block.php.
References array(), DB_MASTER, wfGetDB(), and wfReadOnly().
Referenced by ApiQueryBlocks\execute(), insert(), and SpecialBlockList\showList().
|
static |
Return the list of ipblocks fields that should be selected to create a new block.
Definition at line 124 of file Block.php.
References array().
Referenced by getBlocksForIPList().
Block::setBlocker | ( | $user | ) |
Set the user who implemented (or will implement) this block.
$user | User|string Local User object or username string for foreign users |
Definition at line 1306 of file Block.php.
References $user.
Referenced by __construct(), BlockTest\addXffBlocks(), User\getBlockedStatus(), and initFromRow().
Block::setTarget | ( | $target | ) |
Set the target for this block, and update $this->type accordingly.
$target | Mixed |
Definition at line 1290 of file Block.php.
References list, parseTarget(), and type.
Referenced by __construct(), BlockTest\addXffBlocks(), and initFromRow().
Block::update | ( | ) |
Update a block in the DB with new parameters.
The ID field needs to be loaded first.
Definition at line 435 of file Block.php.
References array(), DB_MASTER, doRetroactiveAutoblock(), getAutoblockUpdateArray(), getDatabaseArray(), getId(), isAutoblocking(), wfDebug(), and wfGetDB().
Block::updateTimestamp | ( | ) |
Update the timestamp on autoblocks.
Definition at line 757 of file Block.php.
References array(), DB_MASTER, getAutoblockExpiry(), getTarget(), wfGetDB(), and wfTimestamp().
|
protected |
Definition at line 40 of file Block.php.
Referenced by getBlocker(), getBy(), getByName(), and getPermissionsError().
|
protected |
Hack for foreign blocking (CentralAuth) *.
Definition at line 36 of file Block.php.
Referenced by getDatabaseArray().
|
protected |
Block::$mAuto |
Definition at line 23 of file Block.php.
Referenced by getDatabaseArray().
Block::$mExpiry |
Definition at line 23 of file Block.php.
Referenced by getExpiry(), and isExpired().
Block::$mHideName |
Definition at line 23 of file Block.php.
Referenced by doAutoblock().
|
protected |
Definition at line 26 of file Block.php.
Referenced by doAutoblock(), and getId().
Block::$mParentBlockId |
Definition at line 26 of file Block.php.
Referenced by getDatabaseArray().
Block::$mReason |
Definition at line 23 of file Block.php.
Referenced by getPermissionsError().
|
protected |
Definition at line 34 of file Block.php.
Referenced by getTarget(), newFromTarget(), newLoad(), and parseTarget().
|
protected |
const Block::TYPE_AUTO = 4 |
Definition at line 50 of file Block.php.
Referenced by SpecialContributions\contributionsSub(), ApiUnblock\execute(), SpecialUnblock\execute(), SpecialUnblock\getFields(), getType(), newFromTarget(), parseTarget(), SpecialUnblock\processUnblock(), and SpecialBlockList\showList().
const Block::TYPE_ID = 5 |
Definition at line 51 of file Block.php.
Referenced by SpecialUnblock\execute(), newFromTarget(), and SpecialBlockList\showList().
const Block::TYPE_IP = 2 |
Definition at line 48 of file Block.php.
Referenced by BlockTest\addXffBlocks(), SpecialUnblock\execute(), BlockListPager\formatValue(), SpecialUnblock\getFields(), getRangeEnd(), getRangeStart(), newFromTarget(), newLoad(), parseTarget(), SpecialBlock\processForm(), SpecialUnblock\processUnblock(), SpecialBlockList\showList(), and SpecialBlock\validateTarget().
const Block::TYPE_RANGE = 3 |
Definition at line 49 of file Block.php.
Referenced by BlockTest\addXffBlocks(), SpecialUnblock\execute(), BlockListPager\formatValue(), SpecialUnblock\getFields(), getRangeEnd(), getRangeStart(), newFromTarget(), newLoad(), parseTarget(), SpecialBlock\processForm(), SpecialUnblock\processUnblock(), SpecialBlockList\showList(), LoginForm\userBlockedMessage(), and SpecialBlock\validateTarget().
const Block::TYPE_USER = 1 |
Definition at line 47 of file Block.php.
Referenced by SpecialBlock\blockLogFlags(), SpecialUnblock\execute(), BlockListPager\formatValue(), SpecialUnblock\getFields(), getRangeEnd(), getRangeStart(), newFromTarget(), newLoad(), parseTarget(), SpecialBlock\processForm(), SpecialBlockList\showList(), and SpecialBlock\validateTarget().