MediaWiki
REL1_24
|
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= '') | |
delete () | |
Delete the row from the IP blocks table. | |
deleteIfExpired () | |
Check if a block has expired. | |
doAutoblock ($autoblockIP) | |
Autoblocks the given IP, referring to this Block. | |
equals (Block $block) | |
Check if two blocks are effectively equal. | |
fromMaster ($x=null) | |
Get/set a flag determining whether the master is used for reads. | |
getBlocker () | |
Get the user who implemented this block. | |
getBy () | |
Get the user id of the blocking sysop. | |
getByName () | |
Get the username of the blocking sysop. | |
getExpiry () | |
getId () | |
Get the block ID. | |
getPermissionsError (IContextSource $context) | |
Get the key and parameters for the corresponding error message. | |
getRangeEnd () | |
Get the IP address at the end of the range in Hex form. | |
getRangeStart () | |
Get the IP address at the start of the range in Hex form. | |
getRedactedName () | |
Get the block name, but with autoblocked IPs hidden as per standard privacy policy. | |
getTarget () | |
Get the target for this particular Block. | |
getTargetAndType () | |
Get the target and target type for this particular Block. | |
getType () | |
Get the type of target for this particular block. | |
insert ($dbw=null) | |
Insert a block into the block table. | |
isAutoblocking ($x=null) | |
isExpired () | |
Has the block expired? | |
isHardblock ($x=null) | |
Get/set whether the Block is a hardblock (affects logged-in users on a given IP/range. | |
isValid () | |
Is the block address valid (i.e. | |
prevents ($action, $x=null) | |
Get/set whether the Block prevents a given action. | |
setBlocker ($user) | |
Set the user who implemented (or will implement) this block. | |
setTarget ($target) | |
Set the target for this block, and update $this->type accordingly. | |
update () | |
Update a block in the DB with new parameters. | |
updateTimestamp () | |
Update the timestamp on autoblocks. | |
Static Public Member Functions | |
static | chooseBlock (array $blocks, array $ipChain) |
From a list of multiple blocks, find the most exact and strongest Block. | |
static | getAutoblockExpiry ($timestamp) |
Get a timestamp of the expiry for autoblocks. | |
static | getBlocksForIPList (array $ipChain, $isAnon, $fromMaster=false) |
Get all blocks that match any IP from an array of IP addresses. | |
static | getRangeCond ($start, $end=null) |
Get a set of SQL conditions which will select rangeblocks encompassing a given range. | |
static | isWhitelistedFromAutoblocks ($ip) |
Checks whether a given IP is on the autoblock whitelist. | |
static | newFromID ($id) |
Load a blocked user from their block id. | |
static | newFromRow ($row) |
Create a new Block object from a database row. | |
static | newFromTarget ($specificTarget, $vagueTarget=null, $fromMaster=false) |
Given a target and the target's type, get an existing Block object if possible. | |
static | parseTarget ($target) |
From an existing Block, get the target and the type of target. | |
static | purgeExpired () |
Purge expired blocks from the ipblocks table. | |
static | selectFields () |
Return the list of ipblocks fields that should be selected to create a new block. | |
Public Attributes | |
int | $mAuto |
* | |
bool string | $mExpiry |
* | |
$mHideName | |
int | $mParentBlockId |
* | |
string | $mReason |
* | |
bool string | $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. | |
getAutoblockUpdateArray () | |
getDatabaseArray ($db=null) | |
Get an array suitable for passing to $dbw->insert() or $dbw->update() | |
initFromRow ($row) | |
Given a database row from the ipblocks table, initialize member variables. | |
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. | |
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. | |
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. | |
Protected Attributes | |
User | $blocker |
* | |
int | $forcedTargetID |
Hack for foreign blocking (CentralAuth) *. | |
bool | $isAutoblocking = true |
* | |
bool | $isHardblock = true |
* | |
bool | $mBlockEmail |
* | |
bool | $mCreateAccount |
* | |
bool | $mDisableUsertalk |
* | |
bool | $mFromMaster |
* | |
int | $mId |
* | |
User string | $target |
* | |
int | $type |
Block::TYPE_ constant. |
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 = '' |
||
) |
string | $address | |
int | $user | |
int | $by | |
string | $reason | |
mixed | $timestamp | |
int | $auto | |
string | $expiry | |
int | $anonOnly | |
int | $createAccount | |
int | $enableAutoblock | |
int | $hideName | |
int | $blockEmail | |
int | $allowUsertalk | |
string | $byText |
static Block::chooseBlock | ( | array $ | blocks, |
array $ | ipChain | ||
) | [static] |
From a list of multiple blocks, find the most exact and strongest Block.
The logic for finding the "best" block is:
array | $blocks | Array of blocks |
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, ...) |
static Block::defaultRetroactiveAutoblock | ( | Block $ | block, |
array &$ | blockIds | ||
) | [static, protected] |
Block::delete | ( | ) |
Block::doAutoblock | ( | $ | autoblockIP | ) |
Block::doRetroactiveAutoblock | ( | ) | [protected] |
Block::equals | ( | Block $ | block | ) |
Block::fromMaster | ( | $ | x = null | ) |
static Block::getAutoblockExpiry | ( | $ | timestamp | ) | [static] |
Block::getAutoblockUpdateArray | ( | ) | [protected] |
static Block::getBlocksForIPList | ( | array $ | ipChain, |
$ | isAnon, | ||
$ | fromMaster = false |
||
) | [static] |
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 |
Block::getBy | ( | ) |
Block::getByName | ( | ) |
Block::getDatabaseArray | ( | $ | db = null | ) | [protected] |
Get an array suitable for passing to $dbw->insert() or $dbw->update()
DatabaseBase | $db |
Definition at line 506 of file Block.php.
References array(), and doRetroactiveAutoblock().
Block::getExpiry | ( | ) |
Block::getId | ( | ) |
static Block::getIpFragment | ( | $ | hex | ) | [static, protected] |
Block::getPermissionsError | ( | IContextSource $ | context | ) |
Get the key and parameters for the corresponding error message.
IContextSource | $context |
Definition at line 1340 of file Block.php.
References $user.
Referenced by UserBlockedError\__construct().
static Block::getRangeCond | ( | $ | start, |
$ | end = null |
||
) | [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 303 of file Block.php.
References initFromRow(), and prevents().
Referenced by SpecialBlockList\showList().
Get the IP address at the end of the range in Hex form.
MWException |
Get the IP address at the start of the range in Hex form.
MWException |
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.
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.
Block::getType | ( | ) |
Get the type of target for this particular block.
Definition at line 1273 of file Block.php.
Referenced by prevents().
Block::initFromRow | ( | $ | row | ) | [protected] |
Given a database row from the ipblocks table, initialize member variables.
stdClass | $row | A row from the ipblocks table |
Definition at line 350 of file Block.php.
Referenced by getRangeCond().
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.
DatabaseBase | $dbw | If you have one available |
Block::isAutoblocking | ( | $ | x = null | ) |
Definition at line 893 of file Block.php.
Referenced by prevents().
Block::isExpired | ( | ) |
Block::isHardblock | ( | $ | x = null | ) |
Get/set whether the Block is a hardblock (affects logged-in users on a given IP/range.
bool | $x |
Definition at line 884 of file Block.php.
References wfSetVar().
Block::isValid | ( | ) |
static Block::isWhitelistedFromAutoblocks | ( | $ | ip | ) | [static] |
static Block::newFromID | ( | $ | id | ) | [static] |
static Block::newFromRow | ( | $ | row | ) | [static] |
Create a new Block object from a database row.
stdClass | $row | Row from the ipblocks table |
Definition at line 386 of file Block.php.
Referenced by selectFields().
static Block::newFromTarget | ( | $ | specificTarget, |
$ | vagueTarget = null , |
||
$ | fromMaster = false |
||
) | [static] |
Given a target and the target's type, get an existing Block object if possible.
string | User | int | $specificTarget | A block target, which may be one of several types: * A user to block, in which case $target will be a User * An IP to block, in which case $target will be a User generated by using User::newFromName( $ip, false ) to turn off name validation * An IP range, in which case $target will be a String "123.123.123.123/18" etc * The ID of an existing block, in the format "#12345" (since pure numbers are valid usernames Calling this with a user, IP address or range will not select autoblocks, and will only select a block where the targets match exactly (so looking for blocks on 1.2.3.4 will not select 1.2.0.0/16 or even 1.2.3.4/32) |
string | User | int | $vagueTarget | 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 993 of file Block.php.
Referenced by DeletedContributionsPage\__construct(), BlockTest\addDBData(), SpecialContributions\contributionsSub(), ApiUnblock\execute(), SpecialUnblock\execute(), ApiBlock\execute(), User\isBlockedFromCreateAccount(), SpecialUnblock\processUnblock(), and ApiBlockTest\testMakeNormalBlock().
Block::newLoad | ( | $ | vagueTarget = null | ) | [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.
User | string | $vagueTarget | 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 |
static Block::parseTarget | ( | $ | target | ) | [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().
string | int | User | null | $target |
Definition at line 1217 of file Block.php.
Referenced by BlockListPager\formatValue(), setBlocker(), and SpecialBlockList\showList().
Block::prevents | ( | $ | action, |
$ | x = null |
||
) |
Get/set whether the Block prevents a given action.
string | $action | |
bool | $x |
Definition at line 909 of file Block.php.
References getType(), isAutoblocking(), and wfSetVar().
Referenced by getRangeCond().
static Block::purgeExpired | ( | ) | [static] |
Purge expired blocks from the ipblocks table.
Definition at line 960 of file Block.php.
References $timestamp, global, and wfTimestamp().
Referenced by ApiQueryBlocks\execute(), and SpecialBlockList\showList().
static Block::selectFields | ( | ) | [static] |
Return the list of ipblocks fields that should be selected to create a new block.
Definition at line 148 of file Block.php.
References $res, and newFromRow().
Block::setBlocker | ( | $ | user | ) |
Block::setTarget | ( | $ | target | ) |
Block::update | ( | ) |
Update a block in the DB with new parameters.
The ID field needs to be loaded first.
Definition at line 459 of file Block.php.
References array(), and doRetroactiveAutoblock().
int Block::$forcedTargetID [protected] |
bool Block::$isAutoblocking = true [protected] |
bool Block::$isHardblock = true [protected] |
User string Block::$target [protected] |
int Block::$type [protected] |
const Block::TYPE_AUTO = 4 |
Definition at line 61 of file Block.php.
Referenced by DeletedContributionsPage\__construct(), SpecialContributions\contributionsSub(), ApiUnblock\execute(), SpecialUnblock\execute(), SpecialUnblock\getFields(), SpecialUnblock\processUnblock(), and SpecialBlockList\showList().
const Block::TYPE_ID = 5 |
Definition at line 62 of file Block.php.
Referenced by SpecialUnblock\execute(), and SpecialBlockList\showList().
const Block::TYPE_IP = 2 |
Definition at line 59 of file Block.php.
Referenced by BlockTest\addXffBlocks(), SpecialUnblock\execute(), BlockListPager\formatValue(), SpecialUnblock\getFields(), SpecialUnblock\processUnblock(), and SpecialBlockList\showList().
const Block::TYPE_RANGE = 3 |
Definition at line 60 of file Block.php.
Referenced by DeletedContributionsPage\__construct(), BlockTest\addXffBlocks(), SpecialContributions\contributionsSub(), SpecialUnblock\execute(), BlockListPager\formatValue(), SpecialUnblock\getFields(), SpecialUnblock\processUnblock(), and SpecialBlockList\showList().
const Block::TYPE_USER = 1 |
Definition at line 58 of file Block.php.
Referenced by SpecialUnblock\execute(), BlockListPager\formatValue(), SpecialUnblock\getFields(), and SpecialBlockList\showList().