|
@@ -16,9 +16,11 @@ use \Net\DNS2\Net_DNS2_Resolver as Net_DNS2_Resolver;
|
|
|
class DnsHelper
|
|
class DnsHelper
|
|
|
{
|
|
{
|
|
|
use \ThurData\Servers\KerioEmail\Core\UI\Traits\WhmcsParams;
|
|
use \ThurData\Servers\KerioEmail\Core\UI\Traits\WhmcsParams;
|
|
|
|
|
+ use ThurData\Servers\KerioEmail\Api\KerioWhmcs;
|
|
|
|
|
+
|
|
|
public function __construct()
|
|
public function __construct()
|
|
|
{
|
|
{
|
|
|
- $this->params = $this->getWhmcsParamsByKeys(['domain', 'userid', 'serverhostname', 'domainid', 'serverid', 'pid']);
|
|
|
|
|
|
|
+ $this->params = $this->getWhmcsParamsByKeys(['domain', 'userid', 'serverhostname', 'username', 'password', 'domainid', 'serverid', 'pid']);
|
|
|
$this->server = Server::select('id', 'nameserver1ip', 'nameserver2ip')->findOrFail($this->params['serverid']);
|
|
$this->server = Server::select('id', 'nameserver1ip', 'nameserver2ip')->findOrFail($this->params['serverid']);
|
|
|
// $this->nameserver = array(trim($this->server->nameserver1ip), trim($this->server->nameserver2ip));
|
|
// $this->nameserver = array(trim($this->server->nameserver1ip), trim($this->server->nameserver2ip));
|
|
|
$this->nameserver = array('127.0.0.1', '127.0.0.2'); //test
|
|
$this->nameserver = array('127.0.0.1', '127.0.0.2'); //test
|
|
@@ -27,6 +29,19 @@ class DnsHelper
|
|
|
$productManager->loadById($this->params['pid']);
|
|
$productManager->loadById($this->params['pid']);
|
|
|
$this->spfConfig = $productManager->get('spf_string');
|
|
$this->spfConfig = $productManager->get('spf_string');
|
|
|
$this->dmarcConfig = $productManager->get('dmarc_string');
|
|
$this->dmarcConfig = $productManager->get('dmarc_string');
|
|
|
|
|
+ $api = new KerioWhmcs('whmcsKerioEmail', 'Thurdata', '1.0');
|
|
|
|
|
+ try {
|
|
|
|
|
+ $api->login($this->params['serverhostname'], $this->params['username'], $this->params['password']);
|
|
|
|
|
+ } catch (KerioApiException $error) {
|
|
|
|
|
+ logModuleCall(
|
|
|
|
|
+ 'kerioEmail',
|
|
|
|
|
+ __FUNCTION__,
|
|
|
|
|
+ $accessData,
|
|
|
|
|
+ 'Error: cannot login to ' . $accessData['kerioServer'],
|
|
|
|
|
+ $error->getMessage()
|
|
|
|
|
+ );
|
|
|
|
|
+ exit();
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public function KerioEmailCheckDNS()
|
|
public function KerioEmailCheckDNS()
|
|
@@ -185,33 +200,35 @@ class DnsHelper
|
|
|
'class' => 'IN',
|
|
'class' => 'IN',
|
|
|
'data' => array(
|
|
'data' => array(
|
|
|
'preference' => '10',
|
|
'preference' => '10',
|
|
|
- 'exchange' => MX,
|
|
|
|
|
|
|
+ 'exchange' => $this->params['serverhostname'],
|
|
|
),
|
|
),
|
|
|
);
|
|
);
|
|
|
array_push($zoneRecords, $mxRecord);
|
|
array_push($zoneRecords, $mxRecord);
|
|
|
- foreach($dnsZone['data']->records as $record) {
|
|
|
|
|
- if($record->type != 'MX') {
|
|
|
|
|
- array_push($zoneRecords, $record);
|
|
|
|
|
- };
|
|
|
|
|
- }
|
|
|
|
|
- $spfRecord = array(
|
|
|
|
|
- 'line' => $params['domain'].'.|TXT|0',
|
|
|
|
|
- 'name' => '@',
|
|
|
|
|
- 'type' => 'TXT',
|
|
|
|
|
- 'class' => 'IN',
|
|
|
|
|
- 'data' => $this->spfConfig
|
|
|
|
|
- );
|
|
|
|
|
|
|
+ $spfRecord = array(
|
|
|
|
|
+ 'line' => $params['domain'].'.|TXT|0',
|
|
|
|
|
+ 'name' => '@',
|
|
|
|
|
+ 'type' => 'TXT',
|
|
|
|
|
+ 'class' => 'IN',
|
|
|
|
|
+ 'data' => $this->spfConfig
|
|
|
|
|
+ );
|
|
|
array_push($zoneRecords, $spfRecord);
|
|
array_push($zoneRecords, $spfRecord);
|
|
|
-
|
|
|
|
|
|
|
+ $dmarcRecord = array(
|
|
|
|
|
+ 'line' => $params['domain'].'.|TXT|0',
|
|
|
|
|
+ 'name' => '@',
|
|
|
|
|
+ 'type' => 'TXT',
|
|
|
|
|
+ 'class' => 'IN',
|
|
|
|
|
+ 'data' => $this->dmarcConfig
|
|
|
|
|
+ );
|
|
|
|
|
+ array_push($zoneRecords, $dmarcRecord);
|
|
|
foreach($dnsZone['data']->records as $record) {
|
|
foreach($dnsZone['data']->records as $record) {
|
|
|
-
|
|
|
|
|
- if(!$record->type === 'TXT'){
|
|
|
|
|
- array_push($zoneRecords, $record);
|
|
|
|
|
- } elseif (!preg_match('/^v=spf(.*)$/i', trim($record->rdata->txtdata,'"'))) {
|
|
|
|
|
- array_push($zoneRecords, $record);
|
|
|
|
|
|
|
+ if($record->type != 'MX') {
|
|
|
|
|
+ if(!$record->type === 'TXT'){
|
|
|
|
|
+ array_push($zoneRecords, $record);
|
|
|
|
|
+ } elseif (!preg_match('/^v=spf(.*)$/i', trim($record->rdata->txtdata,'"'))) {
|
|
|
|
|
+ array_push($zoneRecords, $record);
|
|
|
|
|
+ };
|
|
|
};
|
|
};
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
$result = localAPI('dnsmanager' ,
|
|
$result = localAPI('dnsmanager' ,
|
|
|
array(
|
|
array(
|
|
|
'dnsaction' => 'updateZone',
|
|
'dnsaction' => 'updateZone',
|