diff --git a/includes/functions.php b/includes/functions.php index 73cc107232..2bd660396b 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -968,21 +968,25 @@ function snmp2ipv6($ipv6_snmp) function get_astext($asn) { - global $config,$cache; + global $cache; - if (isset($config['astext'][$asn])) { - return $config['astext'][$asn]; - } else { - if (isset($cache['astext'][$asn])) { - return $cache['astext'][$asn]; - } else { - $result = dns_get_record("AS$asn.asn.cymru.com", DNS_TXT); - $txt = explode('|', $result[0]['txt']); - $result = trim(str_replace('"', '', $txt[4])); - $cache['astext'][$asn] = $result; - return $result; - } + if (Config::has("astext.$asn")) { + return Config::get("astext.$asn"); } + + if (isset($cache['astext'][$asn])) { + return $cache['astext'][$asn]; + } + + $result = dns_get_record("AS$asn.asn.cymru.com", DNS_TXT); + if (!empty($result[0]['txt'])) { + $txt = explode('|', $result[0]['txt']); + $result = trim($txt[4], ' "'); + $cache['astext'][$asn] = $result; + return $result; + } + + return ''; } /**