Skip to content

Commit b52a3f1

Browse files
committed
update
1 parent 8d679c4 commit b52a3f1

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

04-api.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,8 @@ This is a reference of all global variables and functions.
146146
| Function | Location | Purpose |
147147
| ------------------------------------------- | ------------- | ---------------------- |
148148
| `Network::isLocalIP($ipAddress):bool ` | *.php | Check local IP |
149-
| `Network::ip4Match($ip4,$range):bool ` | *.php | Match IPv4 CIDR range |
150-
| `Network::ip6Match($ip6,$range):bool ` | *.php | Match IPv6 CIDR range |
149+
| `Network::ipv4Match($ip4,$range):bool ` | *.php | Match IPv4 CIDR range |
150+
| `Network::ipv6Match($ip6,$range):bool ` | *.php | Match IPv6 CIDR range |
151151

152152
## Analyzer
153153

docs/network.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ if (Network::isLocalIP('::1')) {
3737

3838
This is useful for determining if a request is coming from the local machine or for security checks.
3939

40-
## ip4Match
40+
## ipv4Match
4141

4242
```
43-
Network::ip4Match(string $ip4, string $range): bool
43+
Network::ipv4Match(string $ip4, string $range): bool
4444
```
4545

4646
Check if an IPv4 address is within a given CIDR range.
@@ -59,17 +59,17 @@ Example:
5959

6060
```
6161
// Check if IP is in a specific subnet
62-
if (Network::ip4Match('192.168.1.50', '192.168.1.0/24')) {
62+
if (Network::ipv4Match('192.168.1.50', '192.168.1.0/24')) {
6363
echo "IP is in the 192.168.1.0/24 subnet";
6464
}
6565
6666
// Check against a single IP (implicitly /32)
67-
if (Network::ip4Match('10.0.0.1', '10.0.0.1')) {
67+
if (Network::ipv4Match('10.0.0.1', '10.0.0.1')) {
6868
echo "IP matches exactly";
6969
}
7070
7171
// Check if IP is in a larger range
72-
if (Network::ip4Match('172.16.50.10', '172.16.0.0/12')) {
72+
if (Network::ipv4Match('172.16.50.10', '172.16.0.0/12')) {
7373
echo "IP is in the 172.16.0.0/12 range";
7474
}
7575
```
@@ -80,10 +80,10 @@ Common use cases:
8080
- Network security filtering
8181
- Geographic or organizational IP range checks
8282

83-
## ip6Match
83+
## ipv6Match
8484

8585
```
86-
Network::ip6Match(string $ip6, string $range): bool
86+
Network::ipv6Match(string $ip6, string $range): bool
8787
```
8888

8989
Check if an IPv6 address is within a given CIDR range.
@@ -102,17 +102,17 @@ Example:
102102

103103
```
104104
// Check if IPv6 is in a specific subnet
105-
if (Network::ip6Match('2001:db8::1', '2001:db8::/32')) {
105+
if (Network::ipv6Match('2001:db8::1', '2001:db8::/32')) {
106106
echo "IP is in the 2001:db8::/32 subnet";
107107
}
108108
109109
// Check against IPv6 loopback
110-
if (Network::ip6Match('::1', '::1')) {
110+
if (Network::ipv6Match('::1', '::1')) {
111111
echo "This is the IPv6 loopback address";
112112
}
113113
114114
// Check if IP is in a larger range
115-
if (Network::ip6Match('2001:0db8:85a3::8a2e:0370:7334', '2001:db8::/32')) {
115+
if (Network::ipv6Match('2001:0db8:85a3::8a2e:0370:7334', '2001:db8::/32')) {
116116
echo "IP is in the documentation range";
117117
}
118118
```
@@ -135,12 +135,12 @@ $clientIP = $_SERVER['REMOTE_ADDR'];
135135
$isAllowed = false;
136136
foreach ($allowedRanges as $range) {
137137
if (filter_var($clientIP, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) {
138-
if (Network::ip4Match($clientIP, $range)) {
138+
if (Network::ipv4Match($clientIP, $range)) {
139139
$isAllowed = true;
140140
break;
141141
}
142142
} elseif (filter_var($clientIP, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
143-
if (Network::ip6Match($clientIP, $range)) {
143+
if (Network::ipv6Match($clientIP, $range)) {
144144
$isAllowed = true;
145145
break;
146146
}
@@ -179,7 +179,7 @@ function isInternalNetwork(string $ip): bool {
179179
];
180180
181181
foreach ($internalRanges as $range) {
182-
if (Network::ip4Match($ip, $range)) {
182+
if (Network::ipv4Match($ip, $range)) {
183183
return true;
184184
}
185185
}

0 commit comments

Comments
 (0)