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' => $this->getWhmcsParamByKey('userid'))); $dns = new DnsHelper(); /** * format model to array */ 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 = $dnsRecords['mx'] : $mx = 'wrong'; } if(empty($dnsRecords['spf'])) { $spf = 'unset'; } else { if (count($dnsRecords['spf']) > 1) { $spf = 'multi'; } else { if($dnsRecords['spf'][0] === $this->spfConfig){ $dnsRecords['spf'][0]; } 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 = $dnsRecords['dmarc'][0]; } else { $dmarc = 'wrong'; } } } in_array($this->domainKey, $dnsRecords['dkim']) ? $dkim = 'set' : $dkim = 'unset'; $this->data = [ 'id' => $domain, 'domain' => $domain, 'mxactive' => $dnsRecords['mx'], 'spf' => $spf, 'dmarc' => $dmarc, 'dkim' => $dkim, 'selfdns' => $selfDns, 'selfdomain' => $selfdomain, 'mxthurdata' => $this->actionElementId. ' MX 10 ' . $this->getWhmcsParamByKey('serverhostname'), 'spfthurdata' => $this->actionElementId. ' TXT ' . $this->spfConfig, 'dmarcthurdata' => $this->actionElementId. ' TXT ' . $this->dmarcConfig, 'dkimthurdata' => $this->dkimName. ' TXT ' . $this->domainKey ]; $this->availableValues['dnsrecords'] = $dnsRecords; logModuleCall( 'kerioEmail', __FUNCTION__, $this->data, 'Debug Data', $this->actionElementId ); } public function create() { } public function updateStatus() { } public function update() { } }