Network
extends Base
in package
Base
Table of Contents
Properties
- $author : mixed
- $debug_log : mixed
- $debugger : mixed
- $name : mixed
- $url : mixed
- $vars : mixed
- $verbose : mixed
- $version : mixed
Methods
- __construct() : mixed
- cidrToRange() : array<string|int, mixed>
- Convert CIDR notation to IP range.
- getServerIP() : string|array<string|int, mixed>|null
- Get the server's IP address.
- getUserIP() : string|array<string|int, mixed>|null
- Get the user's IP address.
- ipInRange() : bool
- Check if an IP is within a given range.
- usesReverseProxy() : bool
- Check if the user is using a reverse proxy.
Properties
$author
public
mixed
$author
= "Darknetzz"
$debug_log
public
mixed
$debug_log
= []
$debugger
public
mixed
$debugger
$name
public
mixed
$name
= "PHPUtils"
$url
public
mixed
$url
= "https://github.com/Darknetzz"
$vars
public
mixed
$vars
$verbose
public
mixed
$verbose
= \true
$version
public
mixed
$version
= "1.0.0"
Methods
__construct()
public
__construct() : mixed
cidrToRange()
Convert CIDR notation to IP range.
public
cidrToRange(string $cidr) : array<string|int, mixed>
Parameters
- $cidr : string
-
The CIDR notation.
Return values
array<string|int, mixed> —The IP range as an array with two elements: lower IP and upper IP.
getServerIP()
Get the server's IP address.
public
getServerIP([bool $return_array = false ][, bool $die_if_empty = false ]) : string|array<string|int, mixed>|null
Parameters
- $return_array : bool = false
-
Whether to return the result as an array or not.
- $die_if_empty : bool = false
-
Whether to die if the server's IP cannot be determined.
Return values
string|array<string|int, mixed>|null —The server's IP address or an array with 'type' and 'serverip' keys if $return_array is true. Returns null if $die_if_empty is false and the server's IP cannot be determined.
getUserIP()
Get the user's IP address.
public
getUserIP([string|null $reverse_proxy = null ][, bool $return_array = false ][, bool $die_if_empty = false ]) : string|array<string|int, mixed>|null
Parameters
- $reverse_proxy : string|null = null
-
The IP address of the reverse proxy server.
- $return_array : bool = false
-
Whether to return the result as an array or not.
- $die_if_empty : bool = false
-
Whether to die if the user's IP cannot be determined.
Return values
string|array<string|int, mixed>|null —The user's IP address or an array with 'type' and 'userip' keys if $return_array is true. Returns null if $die_if_empty is false and the user's IP cannot be determined.
ipInRange()
Check if an IP is within a given range.
public
ipInRange(string $ip, string $lowerip, string $upperip) : bool
Parameters
- $ip : string
-
The IP address to check.
- $lowerip : string
-
The lower IP address of the range.
- $upperip : string
-
The upper IP address of the range.
Return values
bool —True if the IP is within the range, false otherwise.
usesReverseProxy()
Check if the user is using a reverse proxy.
public
usesReverseProxy([string|null $proxy = null ]) : bool
Parameters
- $proxy : string|null = null
-
The IP address of the reverse proxy server.
Return values
bool —True if the user is using a reverse proxy, false otherwise.