Public Member Functions | |
| __construct ($address= '', $user=0, $by=0, $reason= '', $timestamp= '', $auto=0, $expiry= '', $anonOnly=0, $createAccount=0, $enableAutoblock=0, $hideName=0, $blockEmail=0, $allowUsertalk=0) | |
| equals (Block $block) | |
| Check if two blocks are effectively equal. | |
| clear () | |
| Clear all member variables in the current object. | |
| load ($address= '', $user=0, $killExpired=true) | |
| Get a block from the DB, with either the given address or the given username. | |
| loadRange ($address, $killExpired=true, $user=0) | |
| Search the database for any range blocks matching the given address, and load the row if one is found. | |
| initFromRow ($row) | |
| Given a database row from the ipblocks table, initialize member variables. | |
| delete () | |
| Delete the row from the IP blocks table. | |
| insert () | |
| Insert a block into the block table. | |
| update () | |
| Update a block in the DB with new parameters. | |
| doRetroactiveAutoblock () | |
| Retroactively autoblocks the last IP used by the user (if it is a user) blocked by this Block. | |
| doAutoblock ($autoblockIP, $justInserted=false) | |
| Autoblocks the given IP, referring to this Block. | |
| deleteIfExpired () | |
| Check if a block has expired. | |
| isExpired () | |
| Has the block expired? | |
| isValid () | |
| Is the block address valid (i.e. | |
| updateTimestamp () | |
| Update the timestamp on autoblocks. | |
| getBy () | |
| Get the user id of the blocking sysop. | |
| getByName () | |
| Get the username of the blocking sysop. | |
| forUpdate ($x=NULL) | |
| Get/set the SELECT . | |
| fromMaster ($x=NULL) | |
| Get/set a flag determining whether the master is used for reads. | |
| getRedactedName () | |
| Get the block name, but with autoblocked IPs hidden as per standard privacy policy. | |
Static Public Member Functions | |
| static | newFromDB ($address, $user=0, $killExpired=true) |
| 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 | isWhitelistedFromAutoblocks ($ip) |
| Checks whether a given IP is on the autoblock whitelist. | |
| static | encodeExpiry ($expiry, $db) |
| Encode expiry for DB. | |
| static | decodeExpiry ($expiry, $timestampType=TS_MW) |
| Decode expiry which has come from the DB. | |
| static | getAutoblockExpiry ($timestamp) |
| Get a timestamp of the expiry for autoblocks. | |
| 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 | purgeExpired () |
| Purge expired blocks from the ipblocks table. | |
| static | infinity () |
| Get a value to insert into expiry field of the database when infinite expiry is desired. | |
| static | formatExpiry ($encoded_expiry) |
| Convert a DB-encoded expiry into a real string that humans can read. | |
| static | parseExpiryInput ($expiry_input) |
| Convert a typed-in expiry time into something we can put into the database. | |
Public Attributes | |
| $mAddress | |
| $mUser | |
| $mBy | |
| $mReason | |
| $mTimestamp | |
| $mAuto | |
| $mId | |
| $mExpiry | |
| $mRangeStart | |
| $mRangeEnd | |
| $mAnonOnly | |
| $mEnableAutoblock | |
| $mHideName | |
| $mBlockEmail | |
| $mByName | |
| $mAngryAutoblock | |
| $mAllowUsertalk | |
| $mNetworkBits | |
| $mIntegerAddr | |
| $mForUpdate | |
| $mFromMaster | |
| const | EB_KEEP_EXPIRED = 1 |
| const | EB_FOR_UPDATE = 2 |
| const | EB_RANGE_ONLY = 4 |
Protected Member Functions | |
| & | getDBOptions (&$options) |
| Get the DB object and set the reference parameter to the select options. | |
| loadFromResult (ResultWrapper $res, $killExpired=true) | |
| Fill in member variables from a result wrapper. | |
| initialiseRange () | |
| Once $mAddress has been set, get the range they came from. | |
| validateBlockParams () | |
| Make sure all the proper members are set to sane values before adding/updating a block. | |
It is not load-on-demand. There are no accessors.
Globals used: $wgAutoblockExpiry, $wgAntiLockFlags
Definition at line 16 of file Block.php.
| Block::__construct | ( | $ | address = '', |
|
| $ | user = 0, |
|||
| $ | by = 0, |
|||
| $ | reason = '', |
|||
| $ | timestamp = '', |
|||
| $ | auto = 0, |
|||
| $ | expiry = '', |
|||
| $ | anonOnly = 0, |
|||
| $ | createAccount = 0, |
|||
| $ | enableAutoblock = 0, |
|||
| $ | hideName = 0, |
|||
| $ | blockEmail = 0, |
|||
| $ | allowUsertalk = 0 | |||
| ) |
Definition at line 26 of file Block.php.
References $reason, $user, decodeExpiry(), initialiseRange(), IP::sanitizeIP(), and wfTimestamp().
| Block::clear | ( | ) |
| static Block::decodeExpiry | ( | $ | expiry, | |
| $ | timestampType = TS_MW | |||
| ) | [static] |
Decode expiry which has come from the DB.
| $expiry | String: Database expiry format | |
| $timestampType | Requested timestamp format |
Definition at line 748 of file Block.php.
References infinity(), and wfTimestamp().
Referenced by __construct(), ApiQueryBlocks::execute(), formatExpiry(), ProtectedTitlesForm::formatRow(), ProtectedPagesForm::formatRow(), Title::getCascadeProtectionSources(), ApiQueryInfo::getProtectionInfo(), initFromRow(), Title::loadRestrictions(), Title::loadRestrictionsFromRow(), and ApiQueryProtectedTitles::run().
| Block::delete | ( | ) |
| Block::deleteIfExpired | ( | ) |
Check if a block has expired.
Delete it if it is.
Definition at line 626 of file Block.php.
References $fname, isExpired(), wfDebug(), wfProfileIn(), and wfProfileOut().
Referenced by loadFromResult().
| Block::doAutoblock | ( | $ | autoblockIP, | |
| $ | justInserted = false | |||
| ) |
Autoblocks the given IP, referring to this Block.
| $autoblockIP | String: the IP to autoblock. | |
| $justInserted | Boolean: the main block was just inserted |
Definition at line 561 of file Block.php.
References getAutoblockExpiry(), isWhitelistedFromAutoblocks(), newFromDB(), wfDebug(), wfMsgForContent(), wfRunHooks(), and wfTimestampNow().
Referenced by doRetroactiveAutoblock().
| Block::doRetroactiveAutoblock | ( | ) |
Retroactively autoblocks the last IP used by the user (if it is a user) blocked by this Block.
Definition at line 476 of file Block.php.
References $conds, $dbr, $options, $res, $row, doAutoblock(), wfDebug(), and wfGetDB().
Referenced by insert().
| static Block::encodeExpiry | ( | $ | expiry, | |
| $ | db | |||
| ) | [static] |
Encode expiry for DB.
| $expiry | String: timestamp for expiry, or | |
| $db | Database object |
Definition at line 733 of file Block.php.
References $db, and infinity().
Referenced by insert(), update(), Article::updateRestrictions(), and Title::updateTitleProtection().
| Block::equals | ( | Block $ | block | ) |
| static Block::formatExpiry | ( | $ | encoded_expiry | ) | [static] |
Convert a DB-encoded expiry into a real string that humans can read.
| $encoded_expiry | String: Database encoded expiry time |
Definition at line 828 of file Block.php.
References $key, $keys, $msg, $wgLang, decodeExpiry(), wfMsgHtml(), and wfMsgReplaceArgs().
Referenced by IPUnblockForm::formatRow().
| Block::forUpdate | ( | $ | x = NULL |
) |
Get/set the SELECT .
.. FOR UPDATE flag
Definition at line 703 of file Block.php.
References wfSetVar().
| Block::fromMaster | ( | $ | x = NULL |
) |
Get/set a flag determining whether the master is used for reads.
Definition at line 710 of file Block.php.
References wfSetVar().
| static Block::getAutoblockExpiry | ( | $ | timestamp | ) | [static] |
Get a timestamp of the expiry for autoblocks.
Definition at line 761 of file Block.php.
References $wgAutoblockExpiry, and wfTimestamp().
Referenced by doAutoblock(), and updateTimestamp().
| Block::getBy | ( | ) |
| Block::getByName | ( | ) |
| & Block::getDBOptions | ( | &$ | options | ) | [protected] |
Get the DB object and set the reference parameter to the select options.
The options array will contain FOR UPDATE if appropriate.
| $options | Array |
Definition at line 131 of file Block.php.
References $db, $options, $wgAntiLockFlags, and wfGetDB().
Referenced by load(), and loadRange().
| Block::getRedactedName | ( | ) |
| static Block::infinity | ( | ) | [static] |
Get a value to insert into expiry field of the database when infinite expiry is desired.
In principle this could be DBMS-dependant, but currently all supported DBMS's support the string "infinity", so we just use that.
Definition at line 816 of file Block.php.
Referenced by decodeExpiry(), RestrictUserForm::doNamespaceRestriction(), RestrictUserForm::doPageRestriction(), encodeExpiry(), ApiProtect::execute(), ApiBlock::execute(), and ProtectionForm::getExpiry().
| Block::initFromRow | ( | $ | row | ) |
Given a database row from the ipblocks table, initialize member variables.
| $row | ResultWrapper: a row from the ipblocks table |
Definition at line 309 of file Block.php.
References $row, decodeExpiry(), and wfTimestamp().
Referenced by loadFromResult().
| Block::initialiseRange | ( | ) | [protected] |
Once $mAddress has been set, get the range they came from.
Wrapper for IP::parseRange
Definition at line 337 of file Block.php.
References IP::parseRange().
Referenced by __construct(), and insert().
| Block::insert | ( | ) |
Insert a block into the block table.
Will fail if there is a conflicting block (same name and options) already in the database.
Definition at line 370 of file Block.php.
References $affected, $dbw, doRetroactiveAutoblock(), encodeExpiry(), initialiseRange(), purgeExpired(), validateBlockParams(), wfDebug(), and wfGetDB().
| Block::isExpired | ( | ) |
Has the block expired?
Definition at line 645 of file Block.php.
References wfDebug(), and wfTimestampNow().
Referenced by deleteIfExpired().
| Block::isValid | ( | ) |
| static Block::isWhitelistedFromAutoblocks | ( | $ | ip | ) | [static] |
Checks whether a given IP is on the autoblock whitelist.
| $ip | String: The IP to check |
Definition at line 517 of file Block.php.
References $key, $wgMemc, IP::isInRange(), wfDebug(), wfMemcKey(), and wfMsgForContentNoTrans().
Referenced by doAutoblock().
| Block::load | ( | $ | address = '', |
|
| $ | user = 0, |
|||
| $ | killExpired = true | |||
| ) |
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 | |
| $killExpired | bool Whether to delete expired rows while loading |
Definition at line 156 of file Block.php.
References $conds, $db, $options, $res, $user, clear(), getDBOptions(), loadFromResult(), loadRange(), and wfDebug().
| Block::loadFromResult | ( | ResultWrapper $ | res, | |
| $ | killExpired = true | |||
| ) | [protected] |
Fill in member variables from a result wrapper.
| $res | ResultWrapper: row from the ipblocks table | |
| $killExpired | Boolean: whether to delete expired rows while loading |
Definition at line 235 of file Block.php.
References $row, deleteIfExpired(), ResultWrapper::fetchObject(), ResultWrapper::free(), initFromRow(), and ResultWrapper::numRows().
Referenced by load(), and loadRange().
| Block::loadRange | ( | $ | address, | |
| $ | killExpired = true, |
|||
| $ | user = 0 | |||
| ) |
Search the database for any range blocks matching the given address, and load the row if one is found.
| $address | String: IP address range | |
| $killExpired | Boolean: whether to delete expired rows while loading | |
| $userid | Integer: if not 0, then sets ipb_anon_only |
Definition at line 275 of file Block.php.
References $conds, $db, $options, $res, $success, $user, getDBOptions(), loadFromResult(), and IP::toHex().
Referenced by load().
| static Block::newFromDB | ( | $ | address, | |
| $ | user = 0, |
|||
| $ | killExpired = true | |||
| ) | [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 | |
| $killExpired | Boolean: delete expired blocks on load |
Definition at line 63 of file Block.php.
References $user.
Referenced by doAutoblock(), IPBlockForm::doMassUserBlock(), IPUnblockForm::doUnblock(), IPBlockForm::showForm(), and User::spreadBlock().
| static Block::newFromID | ( | $ | id | ) | [static] |
Load a blocked user from their block id.
| $id | Integer: Block id to search for |
Definition at line 79 of file Block.php.
References $dbr, $res, and wfGetDB().
Referenced by IPUnblockForm::doUnblock(), and IPUnblockForm::showForm().
| 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 772 of file Block.php.
References IP::isIPv4(), IP::isIPv6(), IP::toOctet(), IP::toUnsigned(), IP::toUnsigned6(), and wfBaseConvert().
Referenced by IPUnblockForm::showList().
| static Block::parseExpiryInput | ( | $ | expiry_input | ) | [static] |
Convert a typed-in expiry time into something we can put into the database.
| $expiry_input | String: whatever was typed into the form |
Definition at line 855 of file Block.php.
Referenced by IPBlockForm::doMassUserBlock().
| static Block::purgeExpired | ( | ) | [static] |
Purge expired blocks from the ipblocks table.
Definition at line 804 of file Block.php.
References $dbw, and wfGetDB().
Referenced by ApiQueryBlocks::execute(), insert(), and IPUnblockForm::showList().
| Block::update | ( | ) |
Update a block in the DB with new parameters.
The ID field needs to be loaded first.
Definition at line 414 of file Block.php.
References $dbw, encodeExpiry(), validateBlockParams(), wfDebug(), and wfGetDB().
| Block::updateTimestamp | ( | ) |
Update the timestamp on autoblocks.
Definition at line 665 of file Block.php.
References $dbw, getAutoblockExpiry(), wfGetDB(), and wfTimestamp().
| Block::validateBlockParams | ( | ) | [protected] |
| const Block::EB_FOR_UPDATE = 2 |
| const Block::EB_KEEP_EXPIRED = 1 |
| const Block::EB_RANGE_ONLY = 4 |
1.5.9