andre 5 месяцев назад
Родитель
Сommit
df9a11e2c6
2 измененных файлов с 28 добавлено и 28 удалено
  1. 15 5
      app/UI/Client/Setting/Pages/Settings.php
  2. 13 23
      core/Helper/DnsHelper.php

+ 15 - 5
app/UI/Client/Setting/Pages/Settings.php

@@ -171,11 +171,21 @@ class Settings extends DataTable implements ClientArea
             in_array($domain,$clientDomains) ? $selfdomain = 'active' : $selfdomain = 'inactive';
             $selfDns = 'inactive';
             $dnsRecords = $dns->getRecords($domain);
-
-            $dnsRecords['mx'] == 'set' ? $mx = 'active' : $mx = 'inactive';
-            $dnsRecords['spf'] == 'set' ? $spf = 'active' : $spf = 'inactive';
-            $dnsRecords['dmarc'] == 'set' ? $dmarc = 'active' : $dmarc = 'inactive';
-            $dnsRecords['dkim'] == 'set' ? $dkim = 'active' : $dkim = 'inactive';
+            in_array($params['serverhostname'],$dnsRecords['mx']) ? $mx = 'active' : $mx = 'inactive';
+            $spf = 'inactive';
+            if(!empty($dnsRecords['spf']) && !(count($dnsRecords['spf']) > 1)) {
+                if($dnsRecords['spf'][0] === $this->spfConfig){
+                    $spf = 'active';
+                }
+            }
+            $dmarc = 'inactive';
+            if(!empty($dnsRecords['dmarc']) && !(count($dnsRecords['dmarc']) > 1)) {
+                if($dnsRecords['dmarc'][0] === $this->dmarcConfig){
+                    $spf = 'active';
+                }
+            }
+            $dkim = 'inactive';
+            in_array($this->domainKey, $dnsRecords['dkim']) ? $dkim = 'active' : $dkim = 'inactive';
             $tmp = [
                 'domain' => $domain,
                 'mxactive' => $mx,

+ 13 - 23
core/Helper/DnsHelper.php

@@ -2,7 +2,6 @@
 
 namespace ThurData\Servers\KerioEmail\Core\Helper;
 use ThurData\Servers\KerioEmail\Core\Models\Whmcs\Server;
-use ThurData\Servers\KerioEmail\Api\KerioWhmcs;
 use \WHMCS\Database\Capsule;
 
 require_once '/usr/share/php/Net/DNS2.php';
@@ -33,6 +32,18 @@ class DnsHelper
         }
         return $this->getResolverRecords($domain);
     }
+    
+    private function selfDns($domain){
+        $zoneIDcollection = Capsule::table('dns_manager2_zone')
+            ->select('id')
+            ->where('name', '=', $domain)
+            ->get();
+        $zoneIDobj = $zoneIDcollection[0];
+        if(!isset($zoneIDobj->{'id'})) {
+            return false;
+        }
+        return $zoneIDobj->{'id'};
+    }
 
     private function getResolverRecords($domain)
     {
@@ -40,6 +51,7 @@ class DnsHelper
         $vars['spf'] = array();
         $vars['dmarc'] = array();
         $vars['dkim'] = array();
+        $vars['selfDNS'] = false;
         try {
             $responseMX = $this->resolver->query($domain, 'MX');
             $responseTXT = $this->resolver->query($domain, 'TXT');
@@ -68,18 +80,6 @@ class DnsHelper
         }
         return $vars;
     }
-    
-    private function selfDns($domain){
-        $zoneIDcollection = Capsule::table('dns_manager2_zone')
-            ->select('id')
-            ->where('name', '=', $domain)
-            ->get();
-        $zoneIDobj = $zoneIDcollection[0];
-        if(!isset($zoneIDobj->{'id'})) {
-            return false;
-        }
-        return $zoneIDobj->{'id'};
-    }
 
     private function getLocalRecords($zoneID) {
         $vars['mx'] = array();
@@ -90,7 +90,6 @@ class DnsHelper
         if($dnsZone['result'] != 'success') {
             return 'Error: cloud not fetch zone for ID ' . $zoneID;
         }
-        $zoneRecords = array();
         foreach($dnsZone['data']->records as $localRecord) {
             if($localRecord->type == 'MX'){
                 array_push($vars['mx'], $localRecord->rdata->exchange);
@@ -107,15 +106,6 @@ class DnsHelper
                 }
             }
         }
-
-            logModuleCall(
-                'kerioEmail',
-                __FUNCTION__,
-                $vars,
-                'DEbug',
-                $domain
-            );
-
         return $vars;
     }