Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F1429897
AutoblockExemptionList.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
AutoblockExemptionList.php
View Options
<?php
namespace
MediaWiki\Block
;
use
Psr\Log\LoggerInterface
;
use
Wikimedia\IPUtils
;
use
Wikimedia\Message\ITextFormatter
;
use
Wikimedia\Message\MessageValue
;
/**
* Provides access to the wiki's autoblock exemption list.
* @since 1.42
*/
class
AutoblockExemptionList
{
private
LoggerInterface
$logger
;
/** Should be for the wiki's content language */
private
ITextFormatter
$textFormatter
;
public
function
__construct
(
LoggerInterface
$logger
,
ITextFormatter
$textFormatter
)
{
$this
->
logger
=
$logger
;
$this
->
textFormatter
=
$textFormatter
;
}
/**
* Checks whether a given IP is on the autoblock exemption list.
*
* @param string $ip The IP to check
* @return bool
*/
public
function
isExempt
(
$ip
)
{
$list
=
$this
->
textFormatter
->
format
(
MessageValue
::
new
(
'block-autoblock-exemptionlist'
)
);
$lines
=
explode
(
"
\n
"
,
$list
);
$this
->
logger
->
debug
(
"Checking the autoblock exemption list.."
);
foreach
(
$lines
as
$line
)
{
// List items only
if
(
!
str_starts_with
(
$line
,
'*'
)
)
{
continue
;
}
$wlEntry
=
substr
(
$line
,
1
);
$wlEntry
=
trim
(
$wlEntry
);
$this
->
logger
->
debug
(
"Checking $ip against $wlEntry..."
);
// Is the IP in this range?
if
(
IPUtils
::
isInRange
(
$ip
,
$wlEntry
)
)
{
$this
->
logger
->
debug
(
" IP $ip matches $wlEntry, not autoblocking"
);
return
true
;
}
else
{
$this
->
logger
->
debug
(
" No match"
);
}
}
return
false
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sat, May 16, 18:10 (8 h, 17 m)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
07/ab/e0b2307237e0b1ecd535c5186da6
Default Alt Text
AutoblockExemptionList.php (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment