Page MenuHomeWickedGov Phorge

AnonIpBlockTarget.php
No OneTemporary

Size
1 KB
Referenced Files
None
Subscribers
None

AnonIpBlockTarget.php

<?php
namespace MediaWiki\Block;
use MediaWiki\DAO\WikiAwareEntity;
use MediaWiki\Page\PageReference;
use MediaWiki\Page\PageReferenceValue;
use MediaWiki\User\UserIdentity;
use MediaWiki\User\UserIdentityValue;
use StatusValue;
use Wikimedia\IPUtils;
/**
* A block target for a single IP address with an associated user page
*
* @since 1.44
*/
class AnonIpBlockTarget extends BlockTarget implements BlockTargetWithUserPage, BlockTargetWithIp {
private string $addr;
public function __construct( string $addr, string|false $wikiId = WikiAwareEntity::LOCAL ) {
parent::__construct( $wikiId );
$this->addr = $addr;
}
public function toString(): string {
return $this->addr;
}
public function getType(): int {
return Block::TYPE_IP;
}
/** @inheritDoc */
public function getSpecificity() {
return 2;
}
public function getLogPage(): PageReference {
return $this->getUserPage();
}
public function getUserPage(): PageReference {
return new PageReferenceValue( NS_USER, $this->addr, $this->wikiId );
}
public function getUserIdentity(): UserIdentity {
return new UserIdentityValue( 0, $this->addr, $this->wikiId );
}
public function validateForCreation(): StatusValue {
return StatusValue::newGood();
}
/**
* Get the IP address in hexadecimal form
*
* @return string
*/
public function toHex(): string {
return IPUtils::toHex( $this->addr );
}
/**
* Get the IP address as a hex "range" tuple, with the start and end equal
*
* @return string[]
*/
public function toHexRange(): array {
$hex = $this->toHex();
return [ $hex, $hex ];
}
/** @inheritDoc */
protected function getLegacyUnion() {
return $this->getUserIdentity();
}
}

File Metadata

Mime Type
text/x-php
Expires
Sat, Oct 3, 21:34 (1 w, 1 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
ee/71/59218d177c246b68274725e9fd98
Default Alt Text
AnonIpBlockTarget.php (1 KB)

Event Timeline