Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F12661184
PhutilCIDRList.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
903 B
Referenced Files
None
Subscribers
None
PhutilCIDRList.php
View Options
<?php
/**
* List of CIDR notation IP blocks, like "172.30.0.0/16".
*
* This class is primarily useful for managing IP whitelists or blacklists.
* For example, you can check if an address is on a subnet like this:
*
* $whitelist = PhutilCIDRList::newList(array('172.30.0.0/16'));
* $ok = $whitelist->containsAddrsss('172.30.0.1');
*/
final
class
PhutilCIDRList
extends
Phobject
{
private
$blocks
;
private
function
__construct
()
{
// <private>
}
public
static
function
newList
(
array
$blocks
)
{
foreach
(
$blocks
as
$key
=>
$block
)
{
$blocks
[
$key
]
=
PhutilCIDRBlock
::
newBlock
(
$block
);
}
$obj
=
new
PhutilCIDRList
();
$obj
->
blocks
=
$blocks
;
return
$obj
;
}
public
function
containsAddress
(
$address
)
{
foreach
(
$this
->
blocks
as
$block
)
{
if
(
$block
->
containsAddress
(
$address
))
{
return
true
;
}
}
return
false
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Fri, Nov 28, 15:44 (1 d, 20 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1045223
Default Alt Text
PhutilCIDRList.php (903 B)
Attached To
Mode
R118 Arcanist - fork
Attached
Detach File
Event Timeline
Log In to Comment