|
@@ 122-125 (lines=4) @@
|
| 119 |
|
*/ |
| 120 |
|
public function validateIP($ipAddress = null) |
| 121 |
|
{ |
| 122 |
|
if ($ipAddress === null) { |
| 123 |
|
$parsed = parse_url($this->uri); |
| 124 |
|
$ipAddress = isset($parsed['host']) ? $parsed['host'] : $parsed['path']; |
| 125 |
|
} |
| 126 |
|
return ( |
| 127 |
|
filter_var($ipAddress, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) || |
| 128 |
|
filter_var(trim($ipAddress, '[]'), FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) |
|
@@ 142-145 (lines=4) @@
|
| 139 |
|
*/ |
| 140 |
|
public function validateHost($host = null) |
| 141 |
|
{ |
| 142 |
|
if ($host === null) { |
| 143 |
|
$parsed = parse_url($this->uri); |
| 144 |
|
$host = isset($parsed['host']) ? $parsed['host'] : $parsed['path']; |
| 145 |
|
} |
| 146 |
|
return ( |
| 147 |
|
preg_match("/^([a-z\d](-*[a-z\d])*)(\.([a-z\d](-*[a-z\d])*))*$/i", $host) //valid chars check |
| 148 |
|
&& preg_match("/^.{1,253}$/", $host) //overall length check |
|
@@ 162-165 (lines=4) @@
|
| 159 |
|
*/ |
| 160 |
|
public function validateScheme($scheme = null) |
| 161 |
|
{ |
| 162 |
|
if ($scheme === null) { |
| 163 |
|
$parsed = parse_url($this->uri); |
| 164 |
|
$scheme = isset($parsed['host']) ? $parsed['host'] : $parsed['path']; |
| 165 |
|
} |
| 166 |
|
return in_array($scheme, [ |
| 167 |
|
'http', |
| 168 |
|
'https', |