MediaWiki
REL1_20
|
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. | |
clear () | |
Clear all member variables in the current object. | |
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. | |
forUpdate ($x=null) | |
Get/set the SELECT ... | |
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. | |
getRangeEnd () | |
Get the IP address at the start 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. | |
load ($address= '', $user=0) | |
Get a block from the DB, with either the given address or the given username. | |
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 | decodeExpiry ($expiry, $timestampType=TS_MW) |
Decode expiry which has come from the DB. | |
static | encodeExpiry ($expiry, $db) |
Encode expiry for DB. | |
static | getAutoblockExpiry ($timestamp) |
Get a timestamp of the expiry for autoblocks. | |
static | getRangeCond ($start, $end=null) |
Get a set of SQL conditions which will select rangeblocks encompasing a given range. | |
static | infinity () |
Get a value to insert into expiry field of the database when infinite expiry is desired. | |
static | isWhitelistedFromAutoblocks ($ip) |
Checks whether a given IP is on the autoblock whitelist. | |
static | newFromDB ($address, $user=0) |
Load a block from the database, using either the IP address or user ID. | |
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 | normaliseRange ($range) |
Gets rid of uneeded numbers in quad-dotted/octet IP strings For example, 127.111.113.151/24 -> 127.111.113.0/24. | |
static | parseExpiryInput ($expiry) |
Convert a submitted expiry time, which may be relative ("2 weeks", etc) or absolute ("24 May 2034"), into an absolute timestamp we can put into the database. | |
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 | |
$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. | |
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 encompasing 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 | |
$blocker | |
$forcedTargetID | |
$isAutoblocking = true | |
$isHardblock = true | |
$mId | |
$target | |
$type |
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 64 of file Block.php.
References $user, isAutoblocking(), isHardblock(), prevents(), setBlocker(), setTarget(), wfGetDB(), wfTimestamp(), and wfTimestampNow().
Block::clear | ( | ) |
Clear all member variables in the current object.
Does not clear the block from the DB.
Definition at line 194 of file Block.php.
References wfDeprecated().
static Block::decodeExpiry | ( | $ | expiry, |
$ | timestampType = TS_MW |
||
) | [static] |
Decode expiry which has come from the DB.
$expiry | String: Database expiry format |
$timestampType | Int Requested timestamp format |
Definition at line 955 of file Block.php.
References $wgContLang, and wfDeprecated().
static Block::defaultRetroactiveAutoblock | ( | Block $ | block, |
array &$ | blockIds | ||
) | [static, protected] |
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 576 of file Block.php.
References $dbr, $options, $res, doAutoblock(), getTarget(), wfDebug(), and wfGetDB().
Referenced by doRetroactiveAutoblock().
Block::delete | ( | ) |
Check if a block has expired.
Delete it if it is.
Definition at line 720 of file Block.php.
References isExpired(), wfDebug(), wfProfileIn(), and wfProfileOut().
Block::doAutoblock | ( | $ | autoblockIP | ) |
Autoblocks the given IP, referring to this Block.
$autoblockIP | String: the IP to autoblock. |
Definition at line 651 of file Block.php.
References getAutoblockExpiry(), getBlocker(), getTarget(), isAutoblocking(), newFromTarget(), prevents(), wfDebug(), wfMessage(), wfRunHooks(), and wfTimestampNow().
Referenced by defaultRetroactiveAutoblock().
Block::doRetroactiveAutoblock | ( | ) | [protected] |
Retroactively autoblocks the last IP used by the user (if it is a user) blocked by this Block.
Definition at line 552 of file Block.php.
References defaultRetroactiveAutoblock(), getTarget(), getType(), isAutoblocking(), wfDebug(), and wfRunHooks().
Referenced by insert().
static Block::encodeExpiry | ( | $ | expiry, |
$ | db | ||
) | [static] |
Encode expiry for DB.
$expiry | String: timestamp for expiry, or |
$db | DatabaseBase object |
Definition at line 942 of file Block.php.
References wfDeprecated().
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 173 of file Block.php.
References isAutoblocking(), isHardblock(), and prevents().
Block::forUpdate | ( | $ | x = null | ) |
Get/set the SELECT ...
FOR UPDATE flag
$x | Bool |
Definition at line 853 of file Block.php.
References wfDeprecated().
Block::fromMaster | ( | $ | x = null | ) |
Get/set a flag determining whether the master is used for reads.
$x | Bool |
Definition at line 864 of file Block.php.
References wfSetVar().
static Block::getAutoblockExpiry | ( | $ | timestamp | ) | [static] |
Get a timestamp of the expiry for autoblocks.
$timestamp | String|Int |
Definition at line 967 of file Block.php.
References wfTimestamp().
Referenced by doAutoblock(), and updateTimestamp().
Get the user who implemented this block.
Definition at line 1176 of file Block.php.
Referenced by UserBlockedError\__construct(), doAutoblock(), getBy(), and getByName().
Block::getBy | ( | ) |
Get the user id of the blocking sysop.
Definition at line 820 of file Block.php.
References $blocker, and getBlocker().
Referenced by getDatabaseArray().
Block::getByName | ( | ) |
Get the username of the blocking sysop.
Definition at line 832 of file Block.php.
References $blocker, and getBlocker().
Referenced by UserBlockedError\__construct(), and getDatabaseArray().
Block::getDatabaseArray | ( | $ | db = null | ) | [protected] |
Get an array suitable for passing to $dbw->insert() or $dbw->update()
$db | DatabaseBase |
Definition at line 511 of file Block.php.
References getBy(), getByName(), getRangeEnd(), getRangeStart(), isAutoblocking(), isHardblock(), prevents(), and wfGetDB().
Block::getExpiry | ( | ) |
Block::getId | ( | ) |
Get the block ID.
Definition at line 843 of file Block.php.
Referenced by UserBlockedError\__construct(), delete(), and update().
static Block::getIpFragment | ( | $ | hex | ) | [static, protected] |
static Block::getRangeCond | ( | $ | start, |
$ | end = null |
||
) | [static] |
Get a set of SQL conditions which will select rangeblocks encompasing a given range.
$start | String Hexadecimal IP representation |
$end | String Hexadecimal IP represenation, or null to use $start = $end |
Definition at line 337 of file Block.php.
References $dbr, getIpFragment(), and wfGetDB().
Referenced by newLoad(), and SpecialBlockList\showList().
Get the IP address at the start of the range in Hex form.
Definition at line 802 of file Block.php.
References IP\parseRange(), and IP\toHex().
Referenced by getDatabaseArray().
Get the IP address at the start of the range in Hex form.
Definition at line 785 of file Block.php.
References IP\parseRange(), and IP\toHex().
Referenced by getDatabaseArray().
Get the block name, but with autoblocked IPs hidden as per standard privacy policy.
Definition at line 922 of file Block.php.
References 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 1151 of file Block.php.
Referenced by UserBlockedError\__construct(), defaultRetroactiveAutoblock(), doAutoblock(), doRetroactiveAutoblock(), getRedactedName(), getTargetAndType(), isValid(), and updateTimestamp().
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 1141 of file Block.php.
References getTarget(), and getType().
Block::getType | ( | ) |
Get the type of target for this particular block.
Definition at line 1128 of file Block.php.
Referenced by doRetroactiveAutoblock(), getTargetAndType(), isAutoblocking(), and isHardblock().
static Block::infinity | ( | ) | [static] |
Get a value to insert into expiry field of the database when infinite expiry is desired.
Definition at line 1000 of file Block.php.
References wfDeprecated(), and wfGetDB().
Block::initFromRow | ( | $ | row | ) | [protected] |
Given a database row from the ipblocks table, initialize member variables.
$row | ResultWrapper: a row from the ipblocks table |
Definition at line 384 of file Block.php.
References isAutoblocking(), isHardblock(), prevents(), setBlocker(), setTarget(), 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 455 of file Block.php.
References doRetroactiveAutoblock(), getDatabaseArray(), purgeExpired(), wfDebug(), and wfGetDB().
Referenced by BlockTest\testBlockedUserCanNotCreateAccount().
Block::isAutoblocking | ( | $ | x = null | ) |
Definition at line 882 of file Block.php.
References getType(), and wfSetVar().
Referenced by __construct(), doAutoblock(), doRetroactiveAutoblock(), equals(), getDatabaseArray(), and initFromRow().
Block::isExpired | ( | ) |
Has the block expired?
Definition at line 740 of file Block.php.
References 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 873 of file Block.php.
References getType(), and wfSetVar().
Referenced by __construct(), equals(), getDatabaseArray(), and initFromRow().
Block::isValid | ( | ) |
Is the block address valid (i.e.
not a null string?)
Definition at line 755 of file Block.php.
References getTarget().
static Block::isWhitelistedFromAutoblocks | ( | $ | ip | ) | [static] |
Checks whether a given IP is on the autoblock whitelist.
TODO: this probably belongs somewhere else, but not sure where...
$ip | String: The IP to check |
Definition at line 608 of file Block.php.
References $lines, $wgMemc, IP\isInRange(), wfDebug(), wfMemcKey(), and wfMessage().
Block::load | ( | $ | address = '' , |
$ | user = 0 |
||
) |
Get a block from the DB, with either the given address or the given username.
$address | string The IP address of the user, or blank to skip IP blocks |
$user | int The user ID, or zero for anonymous users |
Definition at line 207 of file Block.php.
References $user, $value, newFromTarget(), wfDeprecated(), and User\whoIs().
static Block::newFromDB | ( | $ | address, |
$ | user = 0 |
||
) | [static] |
Load a block from the database, using either the IP address or user ID.
Tries the user ID first, and if that doesn't work, tries the address.
$address | String: IP address of user/anon |
$user | Integer: user id of user |
Definition at line 114 of file Block.php.
References $user, newFromTarget(), wfDeprecated(), and User\whoIs().
static Block::newFromID | ( | $ | id | ) | [static] |
Load a blocked user from their block id.
$id | Integer: Block id to search for |
Definition at line 125 of file Block.php.
References $dbr, $res, newFromRow(), and wfGetDB().
Referenced by newFromTarget(), BlockTest\testCrappyCrossWikiBlocks(), and BlockTest\testInitializerFunctionsReturnCorrectBlock().
static Block::newFromRow | ( | $ | row | ) | [static] |
Create a new Block object from a database row.
$row | ResultWrapper row from the ipblocks table |
Definition at line 420 of file Block.php.
References initFromRow().
Referenced by newFromID(), and newLoad().
static Block::newFromTarget | ( | $ | specificTarget, |
$ | vagueTarget = null , |
||
$ | fromMaster = false |
||
) | [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: * 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) |
$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. |
$fromMaster | Bool whether to use the DB_MASTER database |
Definition at line 1037 of file Block.php.
References $target, $type, newFromID(), parseTarget(), TYPE_AUTO, TYPE_ID, TYPE_IP, TYPE_RANGE, and TYPE_USER.
Referenced by BlockTest\addDBData(), doAutoblock(), SpecialUnblock\execute(), ApiUnblock\execute(), ApiBlock\execute(), User\isBlockedFromCreateAccount(), load(), SpecialBlock\maybeAlterFormDefaults(), newFromDB(), SpecialBlock\processForm(), SpecialUnblock\processUnblock(), BlockTest\testBlockedUserCanNotCreateAccount(), BlockTest\testBug29116NewFromTargetWithEmptyIp(), BlockTest\testCrappyCrossWikiBlocks(), BlockTest\testInitializerFunctionsReturnCorrectBlock(), 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 encompasing 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. |
Definition at line 236 of file Block.php.
References $res, $size, $target, $type, getRangeCond(), initFromRow(), newFromRow(), IP\parseRange(), parseTarget(), prevents(), IP\toHex(), TYPE_RANGE, and wfGetDB().
static Block::normaliseRange | ( | $ | range | ) | [static] |
Gets rid of uneeded numbers in quad-dotted/octet IP strings For example, 127.111.113.151/24 -> 127.111.113.0/24.
$range | String: IP address to normalize |
Definition at line 980 of file Block.php.
References IP\sanitizeRange(), and wfDeprecated().
static Block::parseExpiryInput | ( | $ | expiry | ) | [static] |
Convert a submitted expiry time, which may be relative ("2 weeks", etc) or absolute ("24 May 2034"), into an absolute timestamp we can put into the database.
$expiry | String: whatever was typed into the form |
Definition at line 1012 of file Block.php.
References wfDeprecated().
static Block::parseTarget | ( | $ | target | ) | [static] |
From an existing Block, get the target and the type of target.
Note that 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 |
Definition at line 1072 of file Block.php.
References $target, 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 898 of file Block.php.
References wfSetVar().
Referenced by __construct(), doAutoblock(), equals(), getDatabaseArray(), initFromRow(), and newLoad().
static Block::purgeExpired | ( | ) | [static] |
Purge expired blocks from the ipblocks table.
Definition at line 988 of file Block.php.
References wfGetDB().
Referenced by ApiQueryBlocks\execute(), insert(), and SpecialBlockList\showList().
static Block::selectFields | ( | ) | [static] |
Block::setBlocker | ( | $ | user | ) |
Set the user who implemented (or will implement) this block.
$user | User|string Local User object or username string for foriegn users |
Definition at line 1184 of file Block.php.
References $user.
Referenced by __construct(), and initFromRow().
Block::setTarget | ( | $ | target | ) |
Set the target for this block, and update $this->type accordingly.
$target | Mixed |
Definition at line 1168 of file Block.php.
References $target, and parseTarget().
Referenced by __construct(), and initFromRow().
Block::update | ( | ) |
Update the timestamp on autoblocks.
Definition at line 762 of file Block.php.
References getAutoblockExpiry(), getTarget(), wfGetDB(), and wfTimestamp().
Block::$blocker [protected] |
Definition at line 44 of file Block.php.
Referenced by getBy(), and getByName().
Block::$isAutoblocking = true [protected] |
Block::$isHardblock = true [protected] |
Block::$target [protected] |
Definition at line 35 of file Block.php.
Referenced by newFromTarget(), newLoad(), parseTarget(), and setTarget().
Block::$type [protected] |
Definition at line 41 of file Block.php.
Referenced by newFromTarget(), and newLoad().
const Block::TYPE_AUTO = 4 |
Definition at line 56 of file Block.php.
Referenced by SpecialContributions\contributionsSub(), SpecialUnblock\execute(), ApiUnblock\execute(), SpecialUnblock\getFields(), newFromTarget(), parseTarget(), SpecialUnblock\processUnblock(), and SpecialBlockList\showList().
const Block::TYPE_ID = 5 |
Definition at line 57 of file Block.php.
Referenced by SpecialUnblock\execute(), newFromTarget(), and SpecialBlockList\showList().
const Block::TYPE_IP = 2 |
Definition at line 54 of file Block.php.
Referenced by SpecialUnblock\execute(), BlockListPager\formatValue(), SpecialUnblock\getFields(), newFromTarget(), parseTarget(), SpecialBlock\processForm(), SpecialUnblock\processUnblock(), SpecialBlockList\showList(), and SpecialBlock\validateTargetField().
const Block::TYPE_RANGE = 3 |
Definition at line 55 of file Block.php.
Referenced by SpecialUnblock\execute(), BlockListPager\formatValue(), SpecialUnblock\getFields(), newFromTarget(), newLoad(), parseTarget(), SpecialBlock\processForm(), SpecialUnblock\processUnblock(), SpecialBlockList\showList(), and SpecialBlock\validateTargetField().
const Block::TYPE_USER = 1 |
Definition at line 53 of file Block.php.
Referenced by SpecialBlock\blockLogFlags(), SpecialUnblock\execute(), BlockListPager\formatValue(), SpecialUnblock\getFields(), newFromTarget(), parseTarget(), SpecialBlock\processForm(), SpecialBlockList\showList(), and SpecialBlock\validateTargetField().