Explorar o código

new settings section

andre hai 5 meses
pai
achega
9f57f35919
Modificáronse 2 ficheiros con 30 adicións e 19 borrados
  1. 2 16
      app/UI/Client/Setting/Pages/Settings.php
  2. 28 3
      core/Helper/DnsHelper.php

+ 2 - 16
app/UI/Client/Setting/Pages/Settings.php

@@ -170,23 +170,9 @@ class Settings extends DataTable implements ClientArea
         foreach($domains as $domain){
             in_array($domain,$clientDomains) ? $selfdomain = 'active' : $selfdomain = 'inactive';
             $selfDns = 'inactive';
-            $zoneID = $dns->selfDns($domain);
-            if($zoneID){
-                $selfDns = 'active';
-                $dnsZone = $dns->getZone($zoneID);
-                logModuleCall(
-                    'kerioEmail',
-                    __FUNCTION__,
-                    $dnsZone,
-                    'Debug Settings',
-                    $zoneID
-                );
-
-
-            } 
-            $dnsRecords = $dns->getMX($domain);
+            $dnsRecords = $dns->getRecords($domain);
+
             $dnsRecords['mx'] == 'set' ? $mx = 'active' : $mx = 'inactive';
-            $dnsRecords = $dns->getTxtRecords($domain);
             $dnsRecords['spf'] == 'set' ? $spf = 'active' : $spf = 'inactive';
             $dnsRecords['dmarc'] == 'set' ? $dmarc = 'active' : $dmarc = 'inactive';
             $dnsRecords['dkim'] == 'set' ? $dkim = 'active' : $dkim = 'inactive';

+ 28 - 3
core/Helper/DnsHelper.php

@@ -86,10 +86,18 @@ class DnsHelper
         return $vars;
     }
 
-    public function getTxtRecords($domain)
+    public function getRecords($domain) {
+        $zoneID = $this->selfDns($domain);
+        if($zoneID) {
+            return $this->getLocalRecords($zoneID);
+        }
+        return $this->getResolverRecords($domain);
+    }
+
+    public function getResolverRecords($domain)
     {
         try {
-            $result = $this->resolver->query($domain, 'TXT');
+            $result = $this->resolver->query($domain);
             
         } catch(\Net_DNS2_Exception $e) {
                 
@@ -97,6 +105,14 @@ class DnsHelper
         }
         $domainTXT = $result->answer;
 
+            logModuleCall(
+                'kerioEmail',
+                __FUNCTION__,
+                $domain,
+                'DEbug',
+                $domainTXT
+            );
+
         $domainSPF = array();
         $domainDMARC = array();
         $domainDKIM = array();
@@ -179,11 +195,20 @@ class DnsHelper
         return $zoneIDobj->{'id'};
     }
 
-    public function getZone($zoneID) {
+    public function getLocalRecords($zoneID) {
         $dnsZone = localAPI('dnsmanager', array( 'dnsaction' => 'getZone', 'zone_id' => $zoneID));
         if($dnsZone['result'] != 'success') {
             return 'Error: cloud not fetch zone for ID ' . $zoneID;
         }
+
+            logModuleCall(
+                'kerioEmail',
+                __FUNCTION__,
+                $zoneID,
+                'DEbug',
+                $dnsZone
+            );
+
         $zoneRecords = array();
         foreach($dnsZone['data']->records as $record) {
             if(in_array($record->type, ['MX', 'TXT'])){