|
|
@@ -20,13 +20,96 @@ class InfoSettingDataProvider extends BaseDataProvider
|
|
|
|
|
|
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(
|
|
|
'kerioEmail',
|
|
|
__FUNCTION__,
|
|
|
$this->data,
|
|
|
'Debug Data',
|
|
|
- $this
|
|
|
+ $this->actionElementId
|
|
|
);
|
|
|
|
|
|
}
|