andre vor 5 Monaten
Ursprung
Commit
cd95dcb07c

+ 1 - 1
app/UI/Client/Setting/Forms/InfoForm.php

@@ -30,7 +30,7 @@ class InfoForm extends BaseForm implements ClientArea
 
 
     private function initFields()
     private function initFields()
     {
     {
-        $this->setConfirmMessage(new Text('domain'));
+        $this->setConfirmMessage("DNS Information");
         $this->addInternalAlert('Test', 'info', 100);
         $this->addInternalAlert('Test', 'info', 100);
         $this->addField(new Hidden("id"));
         $this->addField(new Hidden("id"));
         $this->addField(new Hidden("selfdns"));
         $this->addField(new Hidden("selfdns"));

+ 84 - 1
app/UI/Client/Setting/Providers/InfoSettingDataProvider.php

@@ -20,13 +20,96 @@ class InfoSettingDataProvider extends BaseDataProvider
 
 
     public function read()
     public function read()
     {
     {
+        $maildomain = $this->actionElementId;
+        $api = new KerioWhmcs('whmcsKerioEmail', 'Thurdata', '1.0');
+        try {
+            $api->login($this->getWhmcsParamByKey('serverhostname'), $this->getWhmcsParamByKey('serverusername'), $this->getWhmcsParamByKey('serverpassword'));
+            $dkimSet = $api->getDkimDnsRecord($maildomain);
+        } catch (KerioApiException $error) {
+            logModuleCall(
+                'kerioEmail',
+                __FUNCTION__,
+                $error,
+                'Debug Error',
+                $error->getMessage()
+            );
+            return ['error' => $error->getMessage()];
+        }
+        $api->logout();
+        // format dkim response
+        $dkimArray = explode(PHP_EOL,$dkimSet['detail']);
+        $dkimValue = explode(":",$dkimArray[1]);
+        $this->domainKey = ltrim($dkimValue[1]);
+        $dkimName = explode(":",$dkimArray[0]);
+        $this->dkimName = ltrim($dkimName[1]);
+
+        // get settings from product configuration
+        $productManager = new ProductManager();
+        $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();
+
+        /**
+         * format model to array
+         */
+        $data = [];
+
+        in_array($domain,$clientDomains) ? $selfdomain = 1 : $selfdomain = 0;
+        $dnsRecords = $dns->getRecords($domain);
+        $dnsRecords['selfdns'] ? $selfDns = 1 : $selfDns = 0;
+        if(empty($dnsRecords['mx'])){
+            $mx = 'unset';
+        } else {
+            in_array($params['serverhostname'],$dnsRecords['mx']) ? $mx = 'set' : $mx = 'wrong';
+        }
+        if(empty($dnsRecords['spf'])) {
+            $spf = 'unset';
+        } else {
+            if (count($dnsRecords['spf']) > 1) {
+                $spf = 'multi';
+            } else {
+                if($dnsRecords['spf'][0] === $this->spfConfig){
+                    $spf = 'set';
+                } else {
+                    $spf = 'wrong';
+                }
+            }
+        }
+        if(empty($dnsRecords['dmarc'])) {
+            $dmarc = 'unset';
+        } else {
+            if (count($dnsRecords['dmarc']) > 1) {
+                $dmarc = 'multi';
+            } else {
+                if($dnsRecords['dmarc'][0] === $this->dmarcConfig){
+                    $dmarc = 'set';
+                } else {
+                    $dmarc = 'wrong';
+                }
+            }
+        }
+        in_array($this->domainKey, $dnsRecords['dkim']) ? $dkim = 'set' : $dkim = 'unset';
+        $tmp = [
+            'id' => $domain,
+            'domain' => $domain,
+            'mxactive' => $mx,
+            'spf' => $spf,
+            'dmarc' => $dmarc,
+            'dkim' => $dkim,
+            'selfdns' => $selfDns,
+            'selfdomain' => $selfdomain
+        ];
+        $this->data[] = $tmp;
 
 
         logModuleCall(
         logModuleCall(
             'kerioEmail',
             'kerioEmail',
             __FUNCTION__,
             __FUNCTION__,
             $this->data,
             $this->data,
             'Debug Data',
             'Debug Data',
-            $this
+            $this->actionElementId
         );
         );
 
 
     }
     }