Index: trunk/phase3/includes/Block.php |
— | — | @@ -15,7 +15,7 @@ |
16 | 16 | class Block |
17 | 17 | { |
18 | 18 | /* public*/ var $mAddress, $mUser, $mBy, $mReason, $mTimestamp, $mAuto, $mId, $mExpiry, |
19 | | - $mRangeStart, $mRangeEnd, $mAnonOnly, $mEnableAutoblock; |
| 19 | + $mRangeStart, $mRangeEnd, $mAnonOnly, $mEnableAutoblock, $mHideName; |
20 | 20 | /* private */ var $mNetworkBits, $mIntegerAddr, $mForUpdate, $mFromMaster, $mByName; |
21 | 21 | |
22 | 22 | const EB_KEEP_EXPIRED = 1; |
— | — | @@ -23,7 +23,7 @@ |
24 | 24 | const EB_RANGE_ONLY = 4; |
25 | 25 | |
26 | 26 | function __construct( $address = '', $user = 0, $by = 0, $reason = '', |
27 | | - $timestamp = '' , $auto = 0, $expiry = '', $anonOnly = 0, $createAccount = 0, $enableAutoblock = 0 ) |
| 27 | + $timestamp = '' , $auto = 0, $expiry = '', $anonOnly = 0, $createAccount = 0, $enableAutoblock = 0, $hideName = 0 ) |
28 | 28 | { |
29 | 29 | $this->mId = 0; |
30 | 30 | # Expand valid IPv6 addresses |
— | — | @@ -38,6 +38,7 @@ |
39 | 39 | $this->mCreateAccount = $createAccount; |
40 | 40 | $this->mExpiry = self::decodeExpiry( $expiry ); |
41 | 41 | $this->mEnableAutoblock = $enableAutoblock; |
| 42 | + $this->mHideName = $hideName; |
42 | 43 | |
43 | 44 | $this->mForUpdate = false; |
44 | 45 | $this->mFromMaster = false; |
— | — | @@ -74,7 +75,7 @@ |
75 | 76 | $this->mAddress = $this->mReason = $this->mTimestamp = ''; |
76 | 77 | $this->mId = $this->mAnonOnly = $this->mCreateAccount = |
77 | 78 | $this->mEnableAutoblock = $this->mAuto = $this->mUser = |
78 | | - $this->mBy = 0; |
| 79 | + $this->mBy = $this->mHideName = 0; |
79 | 80 | $this->mByName = false; |
80 | 81 | } |
81 | 82 | |
— | — | @@ -147,7 +148,7 @@ |
148 | 149 | } |
149 | 150 | |
150 | 151 | # Try range block |
151 | | - if ( $this->loadRange( $address, $killExpired, $user ) ) { |
| 152 | + if ( $this->loadRange( $address, $killExpired, $user == 0 ) ) { |
152 | 153 | if ( $user && $this->mAnonOnly ) { |
153 | 154 | $this->clear(); |
154 | 155 | return false; |
— | — | @@ -260,6 +261,7 @@ |
261 | 262 | $this->mAnonOnly = $row->ipb_anon_only; |
262 | 263 | $this->mCreateAccount = $row->ipb_create_account; |
263 | 264 | $this->mEnableAutoblock = $row->ipb_enable_autoblock; |
| 265 | + $this->mHideName = $row->ipb_deleted; |
264 | 266 | $this->mId = $row->ipb_id; |
265 | 267 | $this->mExpiry = self::decodeExpiry( $row->ipb_expiry ); |
266 | 268 | if ( isset( $row->user_name ) ) { |
— | — | @@ -390,6 +392,7 @@ |
391 | 393 | 'ipb_expiry' => self::encodeExpiry( $this->mExpiry, $dbw ), |
392 | 394 | 'ipb_range_start' => $this->mRangeStart, |
393 | 395 | 'ipb_range_end' => $this->mRangeEnd, |
| 396 | + 'ipb_deleted' => $this->mHideName |
394 | 397 | ), 'Block::insert', array( 'IGNORE' ) |
395 | 398 | ); |
396 | 399 | $affected = $dbw->affectedRows(); |
— | — | @@ -500,6 +503,8 @@ |
501 | 504 | $ipblock->mTimestamp = wfTimestampNow(); |
502 | 505 | $ipblock->mAuto = 1; |
503 | 506 | $ipblock->mCreateAccount = $this->mCreateAccount; |
| 507 | + # Continue suppressing the name if needed |
| 508 | + $ipblock->mHideName = $this->mHideName; |
504 | 509 | |
505 | 510 | # If the user is already blocked with an expiry date, we don't |
506 | 511 | # want to pile on top of that! |
— | — | @@ -633,9 +638,12 @@ |
634 | 639 | global $wgAutoblockExpiry; |
635 | 640 | return wfTimestamp( TS_MW, wfTimestamp( TS_UNIX, $timestamp ) + $wgAutoblockExpiry ); |
636 | 641 | } |
637 | | - |
638 | | - static function normaliseRange( $range ) |
639 | | - { |
| 642 | + |
| 643 | + /** |
| 644 | + * Gets rid of uneeded numbers in quad-dotted IP strings |
| 645 | + * For example, 127.111.113.151/24 -> 127.111.113.0/24 |
| 646 | + */ |
| 647 | + static function normaliseRange( $range ) { |
640 | 648 | $parts = explode( '/', $range ); |
641 | 649 | if ( count( $parts ) == 2 ) { |
642 | 650 | $shift = 32 - $parts[1]; |