Store in GIT
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
function stream_verify($ip, $port, $path)
|
||||
{
|
||||
if(filter_var($ip, FILTER_VALIDATE_IP) === false) {
|
||||
$temp = getAddresses_www( $ip);
|
||||
|
||||
if(count($temp) == 0)
|
||||
return false;
|
||||
else
|
||||
$ip = $temp[0];
|
||||
}
|
||||
|
||||
$response = get_headers("http://" . $ip . ":" . $port . "/" . $path);
|
||||
|
||||
if(get_http_response_code($response) != 200 && !if_http_audio($response))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return $ip;
|
||||
}
|
||||
}
|
||||
|
||||
function get_http_response_code($headers) {
|
||||
return substr($headers[0], 9, 3);
|
||||
}
|
||||
|
||||
function if_http_audio($headers) {
|
||||
$type = substr($headers[3], 14);
|
||||
$arr = explode("/", $type);
|
||||
return $arr[0] == "audio";
|
||||
}
|
||||
|
||||
function getAddresses($domain) {
|
||||
$records = dns_get_record($domain);
|
||||
$res = array();
|
||||
foreach ($records as $r) {
|
||||
if ($r['host'] != $domain) continue; // glue entry
|
||||
if (!isset($r['type'])) continue; // DNSSec
|
||||
|
||||
if ($r['type'] == 'A') $res[] = $r['ip'];
|
||||
if ($r['type'] == 'AAAA') $res[] = $r['ipv6'];
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
function getAddresses_www($domain) {
|
||||
$res = getAddresses($domain);
|
||||
if (count($res) == 0) {
|
||||
$res = getAddresses('www.' . $domain);
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user