<?php
/**
* Blocks and bans object
- * @package MediaWiki
*/
/**
* Globals used: $wgAutoblockExpiry, $wgAntiLockFlags
*
* @todo This could be used everywhere, but it isn't.
- * @package MediaWiki
*/
class Block
{
const EB_FOR_UPDATE = 2;
const EB_RANGE_ONLY = 4;
- function Block( $address = '', $user = 0, $by = 0, $reason = '',
+ function __construct( $address = '', $user = 0, $by = 0, $reason = '',
$timestamp = '' , $auto = 0, $expiry = '', $anonOnly = 0, $createAccount = 0, $enableAutoblock = 0 )
{
$this->mId = 0;
$options = array();
$db =& $this->getDBOptions( $options );
- $ret = false;
- $killed = false;
-
if ( 0 == $user && $address == '' ) {
# Invalid user specification, not blocked
$this->clear();
/**
* Determine if a given integer IPv4 address is in a given CIDR network
- * @deprecated Use wfIsAddressInRange
+ * @deprecated Use IP::isInRange
*/
function isAddressInRange( $addr, $range ) {
- return wfIsAddressInRange( $addr, $range );
+ return IP::isInRange( $addr, $range );
}
function initFromRow( $row )
$this->mRangeEnd = '';
if ( $this->mUser == 0 ) {
- $startend = wfRangeStartEnd($this->mAddress);
- $this->mRangeStart = $startend[0];
- $this->mRangeEnd = $startend[1];
+ list( $this->mRangeStart, $this->mRangeEnd ) = IP::parseRange( $this->mAddress );
}
}
$now = wfTimestampNow();
- extract( $db->tableNames( 'ipblocks', 'user' ) );
+ list( $ipblocks, $user ) = $db->tableNamesN( 'ipblocks', 'user' );
$sql = "SELECT $ipblocks.*,user_name FROM $ipblocks,$user " .
"WHERE user_id=ipb_by $cond ORDER BY ipb_timestamp DESC $options";
*@return Whether or not a retroactive autoblock was made.
*/
function doRetroactiveAutoblock() {
- $dbr = wfGetDb( DB_SLAVE );
+ $dbr = wfGetDB( DB_SLAVE );
#If autoblock is enabled, autoblock the LAST IP used
# - stolen shamelessly from CheckUser_body.php
wfDebug("Doing retroactive autoblocks for " . $this->mAddress . "\n");
$row = $dbr->selectRow( 'recentchanges', array( 'rc_ip' ), array( 'rc_user_text' => $this->mAddress ),
- $fname, array( 'ORDER BY' => 'rc_timestamp DESC' ) );
+ __METHOD__ , array( 'ORDER BY' => 'rc_timestamp DESC' ) );
if ( !$row || !$row->rc_ip ) {
#No results, don't autoblock anything
*/
function doAutoblock( $autoblockip ) {
# Check if this IP address is already blocked
- $dbw =& wfGetDb( DB_MASTER );
+ $dbw =& wfGetDB( DB_MASTER );
$dbw->begin();
# If autoblocks are disabled, go away.
$wlEntry = substr($line, 1);
$wlEntry = trim($wlEntry);
- wfDebug("Checking $wlEntry\n");
+ wfDebug("Checking $ip against $wlEntry...");
# Is the IP in this range?
- if (wfIsAddressInRange( $ip, $wlEntry )) {
- wfDebug("IP $ip matches $wlEntry, not autoblocking\n");
+ if (IP::isInRange( $ip, $wlEntry )) {
+ wfDebug(" IP $ip matches $wlEntry, not autoblocking\n");
#$autoblockip = null; # Don't autoblock a whitelisted IP.
return; #This /SHOULD/ introduce a dummy block - but
# I don't know a safe way to do so. -werdna
+ } else {
+ wfDebug( " No match\n" );
}
}