Browse Source

new settings section

andre 5 tháng trước cách đây
mục cha
commit
354b2ca13a
2 tập tin đã thay đổi với 29 bổ sung24 xóa
  1. 16 8
      app/UI/Client/Setting/Pages/Settings.php
  2. 13 16
      core/Helper/DnsHelper.php

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

@@ -169,13 +169,21 @@ class Settings extends DataTable implements ClientArea
 
         foreach($domains as $domain){
             in_array($domain,$clientDomains) ? $selfdomain = 'active' : $selfdomain = 'inactive';
-            $dns->selfDns($domain) ? $selfDns = 'active' : $selfDns = 'inactive';
-            $dnsRecords = $dns->getMX($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';
+            $zoneID = $dns->selfDns($domain);
+//            if($zoneID){
+                $selfDns = 'active';
+                $dnsZone = $dns->getZone($zoneID);
+
+
+  //          } else {
+    //            $selfDns = 'inactive';
+                $dnsRecords = $dns->getMX($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';
+    //        }
             $tmp = [
                 'domain' => $domain,
                 'mxactive' => $mx,
@@ -191,7 +199,7 @@ class Settings extends DataTable implements ClientArea
         logModuleCall(
             'kerioEmail',
             __FUNCTION__,
-            $data,
+            $dnsZone,
             'Debug Settings',
             $dnsRecords
         );

+ 13 - 16
core/Helper/DnsHelper.php

@@ -27,21 +27,6 @@ class DnsHelper
     }    
 
     public function getMX($domain){
-//        $zoneID = selfDns($domain);
-//        if($zoneID){
-            // use local API
-//            $dnsZone = localAPI('dnsmanager', array( 'dnsaction' => 'getZone', 'zone_id' => $zoneID));
-        
-            logModuleCall(
-                'kerioEmail',
-                __FUNCTION__,
-                $zoneID,
-                'DEbug',
-                $domain
-            );
-
-//        } else {
-            // use resolver
             try {
                     $result = $this->resolver->query($domain, 'MX');
                     
@@ -68,7 +53,6 @@ class DnsHelper
                     $var['mx'] = 'wrong';
                 }
             }
-//        }
         return $vars;
     }
 
@@ -195,6 +179,19 @@ class DnsHelper
         return $zoneIDobj->{'id'};
     }
 
+    public function getZone($zoneID) {
+        $dnsZone = localAPI('dnsmanager', array( 'dnsaction' => 'getZone', 'zone_id' => $zoneID));
+        if($dnsZone['result'] != 'success') {
+            return 'Error: cloud not fetch zone for ID ' . $zoneID;
+        }
+        $zoneRecords = array();
+        foreach($dnsZone['data']->records as $record) {
+            if(in_array($record->type, ['MX', 'TXT'])){
+                array_push($zoneRecords, $record);
+            }
+        }
+        return $zoneRecords;
+    }
     function KerioEmailsetDNS()
     {
         return 'success';