* @package MediaWiki
*/
-/**
- * Some globals
- */
-define ( 'EB_KEEP_EXPIRED', 1 );
-define ( 'EB_FOR_UPDATE', 2 );
-define ( 'EB_RANGE_ONLY', 4 );
-
/**
* The block class
* All the functions in this class assume the object is either explicitly
/* public*/ var $mAddress, $mUser, $mBy, $mReason, $mTimestamp, $mAuto, $mId, $mExpiry,
$mRangeStart, $mRangeEnd;
/* private */ var $mNetworkBits, $mIntegerAddr, $mForUpdate, $mFromMaster, $mByName;
+
+ const EB_KEEP_EXPIRED = 1;
+ const EB_FOR_UPDATE = 2;
+ const EB_RANGE_ONLY = 4;
function Block( $address = '', $user = '', $by = 0, $reason = '',
$timestamp = '' , $auto = 0, $expiry = '' )
{
$fname = 'Block::loadRange';
- $iaddr = ProxyTools::IP2Hex( $address );
+ $iaddr = wfIP2Hex( $address );
if ( $iaddr === false ) {
# Invalid address
return false;
* Determine if a given integer IPv4 address is in a given CIDR network
*/
function isAddressInRange( $addr, $range ) {
- list( $network, $bits ) = ProxyTools::parseCIDR( $range );
+ list( $network, $bits ) = wfParseCIDR( $range );
if ( $network !== false && $addr >> ( 32 - $bits ) == $network >> ( 32 - $bits ) ) {
return true;
} else {
$this->mRangeStart = '';
$this->mRangeEnd = '';
if ( $this->mUser == 0 ) {
- list( $network, $bits ) = ProxyTools::parseCIDR( $this->mAddress );
+ list( $network, $bits ) = wfParseCIDR( $this->mAddress );
if ( $network !== false ) {
$this->mRangeStart = sprintf( '%08X', $network );
$this->mRangeEnd = sprintf( '%08X', $network + (1 << (32 - $bits)) - 1 );
global $wgAntiLockFlags;
$block = new Block();
- if ( $flags & EB_FOR_UPDATE ) {
+ if ( $flags & Block::EB_FOR_UPDATE ) {
$db =& wfGetDB( DB_MASTER );
if ( $wgAntiLockFlags & ALF_NO_BLOCK_LOCK ) {
$options = '';
$db =& wfGetDB( DB_SLAVE );
$options = '';
}
- if ( $flags & EB_RANGE_ONLY ) {
+ if ( $flags & Block::EB_RANGE_ONLY ) {
$cond = " AND ipb_range_start <> ''";
} else {
$cond = '';
while ( $row = $db->fetchObject( $res ) ) {
$block->initFromRow( $row );
- if ( ( $flags & EB_RANGE_ONLY ) && $block->mRangeStart == '' ) {
+ if ( ( $flags & Block::EB_RANGE_ONLY ) && $block->mRangeStart == '' ) {
continue;
}
- if ( !( $flags & EB_KEEP_EXPIRED ) ) {
+ if ( !( $flags & Block::EB_KEEP_EXPIRED ) ) {
if ( $block->mExpiry && $now > $block->mExpiry ) {
$block->delete();
} else {
$parts = explode( '/', $range );
if ( count( $parts ) == 2 ) {
$shift = 32 - $parts[1];
- $ipint = ProxyTools::IP2Unsigned( $parts[0] );
+ $ipint = wfIP2Unsigned( $parts[0] );
$ipint = $ipint >> $shift << $shift;
$newip = long2ip( $ipint );
$range = "$newip/{$parts[1]}";