From bee75c231cc8e21c3e13a0cc1007c3b596aa567a Mon Sep 17 00:00:00 2001 From: alban Date: Tue, 1 Jul 2014 00:22:09 +0200 Subject: [PATCH] =?UTF-8?q?[enh]=C2=A0Adds=20Diagnostic=20DNS?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/Alternc/Diagnostic/Service/Dns.php | 97 +++++++++++++++++++++++++- 1 file changed, 94 insertions(+), 3 deletions(-) diff --git a/lib/Alternc/Diagnostic/Service/Dns.php b/lib/Alternc/Diagnostic/Service/Dns.php index 4e44763c..3b2efd16 100644 --- a/lib/Alternc/Diagnostic/Service/Dns.php +++ b/lib/Alternc/Diagnostic/Service/Dns.php @@ -1,5 +1,4 @@ bind = new system_bind(); + } + function run(){ + + /** @var m_dom */ + global $dom; + + $this->domainList = $dom->get_domain_all_summary(); + + // Writes the domains list + $this->writeSectionData (self::SECTION_LIST,$this->domainList); + // Writes the domains hosts + $this->writeSectionData (self::SECTION_HOST, $this->getHosts()); + // Writes the domains nameservers + $this->writeSectionData (self::SECTION_NAMESERVERS,$this->getNameservers()); + + // Writes the domains zones + $this->writeSectionData (self::SECTION_ZONES,$this->getZones()); + // Writes the domains zones locked + $this->writeSectionData (self::SECTION_ZONES_LOCKED,$this->getZonesLocked()); + // Writes the dns slaves + $this->writeSectionData (self::SECTION_SLAVES,$this->getSlaves()); return $this->data; } - + + function getHosts(){ + $resultArray = array(); + foreach ($this->domainList as $domain => $domainInfo) { + try{ + $resultArray[$domain] = $this->execCmd("host {$domain}"); + }catch( \Exception $e){ + echo $e->getMessage()."\n"; + } + } + return $resultArray; + } + + function getNameservers(){ + $resultArray = array(); + foreach ($this->domainList as $domain => $domainInfo) { + try{ + $resultArray[$domain] = $this->execCmd("dig NS {$domain} +short"); + }catch( \Exception $e){ + echo $e->getMessage()."\n"; + } + } + return $resultArray; + } + + function getZones(){ + $resultArray = array(); + foreach ($this->domainList as $domain => $domainInfo) { + try{ + $file_path = $this->bind->get_zone_file($domain); + $file_content = ""; + if( is_file($file_path)){ + $file_content .= file_get_contents($file_path); + } + $resultArray[$domain] = $file_content; + }catch( \Exception $e){ + echo $e->getMessage()."\n"; + } + } + return $resultArray; + } + + function getZonesLocked(){ + $resultArray = array(); + foreach ($this->domainList as $domain => $domainInfo) { + try{ + $resultArray[$domain] = $this->bind->is_locked($domain); + }catch( \Exception $e){ + echo $e->getMessage()."\n"; + } + } + return $resultArray; + } + + function getSlaves(){ + return $this->dom->enum_slave_account(); + } + } \ No newline at end of file