|
|
@ -17,32 +17,59 @@ class Dig |
|
|
|
]; |
|
|
|
]; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static function isProvider(mixed $value): bool |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
( |
|
|
|
|
|
|
|
is_string($value) && |
|
|
|
|
|
|
|
false !== filter_var($value, FILTER_VALIDATE_IP) |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static function isHostName(mixed $value, array $find = ['_'], array $replace = []): bool |
|
|
|
public static function isHostName(mixed $value, array $find = ['_'], array $replace = []): bool |
|
|
|
{ |
|
|
|
{ |
|
|
|
return is_string($value) && false !== filter_var(str_replace($find, $replace, $value), FILTER_VALIDATE_DOMAIN, FILTER_FLAG_HOSTNAME); |
|
|
|
return ( |
|
|
|
|
|
|
|
is_string($value) && |
|
|
|
|
|
|
|
false !== filter_var(str_replace($find, $replace, $value), FILTER_VALIDATE_DOMAIN, FILTER_FLAG_HOSTNAME) |
|
|
|
|
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static function isRecord(mixed $value): bool |
|
|
|
public static function isRecord(mixed $value): bool |
|
|
|
{ |
|
|
|
{ |
|
|
|
return is_string($value) && isset(self::_records()[$value]); |
|
|
|
return |
|
|
|
|
|
|
|
( |
|
|
|
|
|
|
|
is_string($value) && |
|
|
|
|
|
|
|
isset(self::_records()[$value]) |
|
|
|
|
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static function isRecordValue(mixed $record, mixed $value): bool |
|
|
|
public static function isRecordValue(mixed $record, mixed $value): bool |
|
|
|
{ |
|
|
|
{ |
|
|
|
return is_string($record) && |
|
|
|
return |
|
|
|
|
|
|
|
( |
|
|
|
|
|
|
|
is_string($record) && |
|
|
|
is_string($value) && |
|
|
|
is_string($value) && |
|
|
|
isset(self::_records()[$record]) && self::_records()[$record]($value); |
|
|
|
isset(self::_records()[$record]) && self::_records()[$record]($value) |
|
|
|
|
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static function records(string $hostname, array $records, array &$result = [], array &$error = []): array |
|
|
|
public static function records(string $hostname, array $records, array &$result = [], array &$error = [], ?string $provider = null): array |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
if (self::isProvider($provider)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
$provider = sprintf( |
|
|
|
|
|
|
|
'@%s', |
|
|
|
|
|
|
|
$provider |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (self::isHostName($hostname)) |
|
|
|
if (self::isHostName($hostname)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
foreach ($records as $record) |
|
|
|
foreach ($records as $record) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (self::isRecord($record)) |
|
|
|
if (self::isRecord($record)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if ($values = exec(sprintf('dig %s %s +short', $record, $hostname))) |
|
|
|
if ($values = exec(sprintf('dig %s %s %s +short', (string) $provider, (string) $record, (string) $hostname))) |
|
|
|
{ |
|
|
|
{ |
|
|
|
foreach (explode(PHP_EOL, $values) as $value) |
|
|
|
foreach (explode(PHP_EOL, $values) as $value) |
|
|
|
{ |
|
|
|
{ |
|
|
|