فهرست منبع

new settings section

andre 5 ماه پیش
والد
کامیت
3f511c0d0a
2فایلهای تغییر یافته به همراه52 افزوده شده و 8 حذف شده
  1. 40 8
      app/UI/Client/Setting/Pages/Settings.php
  2. 12 0
      core/Helper/DnsHelper.php

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

@@ -58,7 +58,14 @@ class Settings extends DataTable implements ClientArea
                 ->setSearchable(true, Column::TYPE_STRING))
             ->addColumn((new Column('dkim'))
                 ->setOrderable()
-                ->setSearchable(true));
+                ->setSearchable(true))
+            ->addColumn((new Column('selfdns'))
+                ->setOrderable()
+                ->setSearchable(true))
+            ->addColumn((new Column('selfdomain'))
+                ->setOrderable()
+                ->setSearchable(true))
+                ;
     }
 
     /**
@@ -135,7 +142,10 @@ class Settings extends DataTable implements ClientArea
         }
 
         $api->logout();
-
+        $domains = [$maildomain];
+        foreach($aliasList as $aliasDomain){
+            array_push($domains,$aliasDomain);
+        }
         // format dkim response
         $dkimArray = explode(PHP_EOL,$dkimSet['detail']);
         $dkimValue = explode(":",$dkimArray[1]);
@@ -148,22 +158,44 @@ class Settings extends DataTable implements ClientArea
         $productManager->loadById($this->getWhmcsParamByKey('pid'));
         $this->spfConfig = $productManager->get('spf_string');
         $this->dmarcConfig = $productManager->get('dmarc_string');
+        $clientDomains = localAPI('GetClientsDomains', array('clientid' => $params['userid']));
 
         $dns = new DnsHelper();
-        $mx = $dns->getRecords($maildomain);
+
+        /**
+         * format model to array
+         */
+        $data = [];
+
+        foreach($domains as $domain){
+            in_array($domain,$clientDomains) ? $selfdomain = 'active' : $selfdomain = 'inactive';
+            $dns->selfDns($domain) ? $selfDns = 'active' : $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';
+            $tmp = [
+                'domain' => $domain,
+                'active(mx)' => $mx,
+                'spf' => $spf,
+                'dmarc' => $dmarc,
+                'dkim' => $dkim,
+                'selfdns' => $selfDns,
+                'selfdomain' => $selfdomain
+            ];
+            $data[] = $tmp;
+        }
+
 
         logModuleCall(
             'kerioEmail',
             __FUNCTION__,
-            $mx,
+            $data,
             'Debug Settings',
             $maildomain
         );
 
-        /**
-         * format model to array
-         */
-        $data = [];
 
         $dataProv = new ArrayDataProvider();
         $dataProv->setDefaultSorting('setting', 'ASC')->setData($data);

+ 12 - 0
core/Helper/DnsHelper.php

@@ -214,6 +214,18 @@ class DnsHelper
         return $vars;
     }
 
+    public 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 true;
+    }
+
     function KerioEmailsetDNS()
     {
         return 'success';