diff --git a/library/NGNPro/Records/DnsRecords.php b/library/NGNPro/Records/DnsRecords.php index b2e9322..d24cd42 100644 --- a/library/NGNPro/Records/DnsRecords.php +++ b/library/NGNPro/Records/DnsRecords.php @@ -1,1477 +1,1477 @@ 'Change date', 'type' => 'Type', 'name' => 'Name' ); var $FieldsReadOnly = array( 'customer', 'reseller' ); var $Fields = array( 'type' => array('type'=>'string'), 'priority' => array('type'=>'integer'), 'value' => array('type'=>'string'), 'ttl' => array('type'=>'integer') ); var $recordTypes = array( 'A' => 'IP address', 'AAAA' => 'IP v6 address', 'CNAME' => 'Hostname alias', 'MX' => 'Mail server address', 'SRV' => 'Server resource', 'NS' => 'Name server address', 'NAPTR' => 'Name authority', 'PTR' => 'Reverse IP address', 'TXT' => 'Text', 'LOC' => 'Geo location' ); var $havePriority = array('MX','SRV','NAPTR'); var $addRecordFunction = 'addRecord'; var $deleteRecordFunction = 'deleteRecord'; var $updateRecordFunction = 'updateRecord'; var $getRecordsFunction = 'getRecords'; var $getRecordFunction = 'getRecord'; var $recordTypesTemplate = array( 'sip2sip' => array( 'name' => 'SIP2SIP infrastructure', 'records' => array( 'naptr1' => array( 'name' => '', 'type' => 'NAPTR', 'priority' => '100', 'ttl' => '600', 'value' => '20 100 "s" "SIP+D2T" "" _sip._tcp' ), 'naptr2' => array( 'name' => '', 'type' => 'NAPTR', 'priority' => '100', 'ttl' => '600', 'value' => '30 100 "s" "SIP+D2U" "" _sip._udp' ), 'naptr3' => array( 'name' => '', 'type' => 'NAPTR', 'priority' => '100', 'ttl' => '600', 'value' => '10 100 "s" "SIPS+D2T" "" _sips._tcp' ), 'srv1' => array( 'name' => '_sip._tcp', 'type' => 'SRV', 'priority' => '100', 'ttl' => '600', 'value' => '100 5060 proxy.sipthor.net' ), 'srv2' => array( 'name' => '_sip._udp', 'type' => 'SRV', 'priority' => '100', 'ttl' => '600', 'value' => '100 5060 proxy.sipthor.net' ), 'srv3' => array( 'name' => '_sips._tcp', 'type' => 'SRV', 'priority' => '100', 'ttl' => '600', 'value' => '100 5061 proxy.sipthor.net' ), 'srv4' => array( 'name' => '_stun._udp', 'type' => 'SRV', 'priority' => '0', 'value' => '10 3478 stun1.sipthor.net' ), 'srv5' => array( 'name' => '_stun._udp', 'type' => 'SRV', 'priority' => '0', 'value' => '10 3478 stun2.sipthor.net' ), 'srv6' => array( 'name' => '_msrps._tcp', 'type' => 'SRV', 'priority' => '10', 'value' => '0 2855 msrprelay.sipthor.net' ), 'txt1' => array( 'name' => 'xcap', 'type' => 'TXT', 'priority' => '10', 'value' => 'https://xcap.sipthor.net/xcap-root' ) ), ), 'siptcp' => array( 'name' => 'SIP - TCP transport', 'records' => array( 'naptr' => array( 'name' => '', 'type' => 'NAPTR', 'priority' => '100', 'ttl' => '3600', 'value' => '10 100 "s" "SIP+D2T" "" _sip._tcp' ), 'srv' => array( 'name' => '_sip._tcp', 'type' => 'SRV', 'priority' => '100', 'ttl' => '3600', 'value' => '100 5060 #VALUE#|10 5060 sip' ) ), ), 'siptls' => array( 'name' => 'SIP - TLS transport', 'records' => array( 'naptr' => array( 'name' => '', 'type' => 'NAPTR', 'priority' => '100', 'ttl' => '3600', 'value' => '20 100 "s" "SIPS+D2T" "" _sips._tcp' ), 'srv' => array( 'name' => '_sips._tcp', 'type' => 'SRV', 'priority' => '100', 'ttl' => '3600', 'value' => '100 5061 #VALUE#|10 5061 sip' ) ) ), 'sipudp' => array( 'name' => 'SIP - UDP transport', 'records' => array( 'naptr' => array( 'name' => '', 'type' => 'NAPTR', 'priority' => '100', 'ttl' => '3600', 'value' => '30 100 "s" "SIP+D2U" "" _sip._udp' ), 'srv' => array( 'name' => '_sip._udp', 'type' => 'SRV', 'priority' => '100', 'ttl' => '3600', 'value' => '100 5060 #VALUE#|10 5060 sip' ) ), ), 'stun' => array( 'name' => 'STUN - NAT mirror', 'records' => array( 'srv' => array( 'name' => '_stun._udp', 'type' => 'SRV', 'priority' => '0', 'value' => '10 3478 #VALUE#|10 3478 stun' ) ), ), 'xmpp-server' => array( 'name' => 'XMPP server-to-server over TCP', 'records' => array( 'srv' => array( 'name' => '_xmpp-server._tcp', 'type' => 'SRV', 'priority' => '0', 'value' => '10 5269 #VALUE#|10 5269 xmpp' ), 'srv1' => array( 'name' => '_jabber._tcp', 'type' => 'SRV', 'priority' => '0', 'value' => '10 5269 #VALUE#|10 5269 xmpp' ) ), ), 'xmpp-client' => array( 'name' => 'XMPP client-to-server over TCP', 'records' => array( 'srv' => array( 'name' => '_xmpp-client._tcp', 'type' => 'SRV', 'priority' => '0', 'value' => '10 5222 #VALUE#|10 5222 xmpp' ) ), ), 'xmpps-server' => array( 'name' => 'XMPP server-to-server over TLS', 'records' => array( 'srv' => array( 'name' => '_xmpps-server._tcp', 'type' => 'SRV', 'priority' => '0', 'value' => '10 5269 #VALUE#|10 5269 xmpp' ), 'srv1' => array( 'name' => '_jabbers._tcp', 'type' => 'SRV', 'priority' => '0', 'value' => '10 5269 #VALUE#|10 5269 xmpp' ) ), ), 'xmpps-client' => array( 'name' => 'XMPP client-to-server over TLS', 'records' => array( 'srv' => array( 'name' => '_xmpps-client._tcp', 'type' => 'SRV', 'priority' => '0', 'value' => '10 5222 #VALUE#|10 5222 xmpp' ) ), ), 'msrp' => array( 'name' => 'MSRP - IM relay', 'records' => array( 'srv' => array( 'name' => '_msrps._tcp', 'type' => 'SRV', 'priority' => '10', 'value' => '0 2855 msrprelay' ) ) ), 'sipthor' => array( 'name' => 'SIP - Thor network', 'records' => array( 'eventserver' => array( 'name' => '_eventserver._tcp', 'type' => 'SRV', 'priority' => '10', 'value' => '0 8000 eventserver' ), 'sipserver' => array( 'name' => '_sip._udp', 'type' => 'SRV', 'priority' => '10', 'value' => '30 5060 proxy' ), 'sipns1' => array( 'name' => 'proxy', 'type' => 'NS', 'value' => 'ns1' ), 'sipns2' => array( 'name' => 'proxy', 'type' => 'NS', 'value' => 'ns2' ), 'sipns3' => array( 'name' => 'proxy', 'type' => 'NS', 'value' => 'ns3' ), 'ngnproserver' => array( 'name' => '_ngnpro._tcp', 'type' => 'SRV', 'priority' => '10', 'value' => '0 9200 ngnpro' ), 'ngnns1' => array( 'name' => 'ngnpro', 'type' => 'NS', 'value' => 'ns1' ), 'ngnns2' => array( 'name' => 'ngnpro', 'type' => 'NS', 'value' => 'ns2' ), 'ngnns3' => array( 'name' => 'ngnpro', 'type' => 'NS', 'value' => 'ns3' ), 'xcapserver' => array( 'name' => '_xcap._tcp', 'type' => 'SRV', 'priority' => '10', 'value' => '0 443 xcap' ), 'xcapns1' => array( 'name' => 'xcap', 'type' => 'NS', 'value' => 'ns1' ), 'xcapns2' => array( 'name' => 'xcap', 'type' => 'NS', 'value' => 'ns2' ), 'xcapns3' => array( 'name' => 'xcap', 'type' => 'NS', 'value' => 'ns3' ), 'msrpserver' => array( 'name' => '_msrps._tcp', 'type' => 'SRV', 'priority' => '10', 'value' => '0 2855 msrprelay' ), 'msrpns1' => array( 'name' => 'msrprelay', 'type' => 'NS', 'value' => 'ns1' ), 'msrpns2' => array( 'name' => 'msrprelay', 'type' => 'NS', 'value' => 'ns2' ), 'msrpns3' => array( 'name' => 'msrprelay', 'type' => 'NS', 'value' => 'ns3' ), 'voicemail' => array( 'name' => '_voicemail._tcp', 'type' => 'SRV', 'priority' => '10', 'value' => '0 9200 voicemail' ), 'vmns1' => array( 'name' => 'voicemail', 'type' => 'NS', 'value' => 'ns1' ), 'vmns2' => array( 'name' => 'voicemail', 'type' => 'NS', 'value' => 'ns2' ), 'vmns3' => array( 'name' => 'voicemail', 'type' => 'NS', 'value' => 'ns3' ) ) ) ); public function __construct($SoapEngine) { dprint("init DnsRecords"); $_name = trim($_REQUEST['name_filter']); if (strlen($_name) && !strstr($_name, '.') && !strstr($_name, '%')) { $_name .= '%'; } if ($this->typeFilter) { $this->filters = array( 'id' => trim($_REQUEST['id_filter']), 'zone' => trim($_REQUEST['zone_filter']), 'name' => $_name, 'type' => $this->typeFilter, 'value' => trim($_REQUEST['value_filter']), 'owner' => trim($_REQUEST['owner_filter']) ); } else { $this->filters = array( 'id' => trim($_REQUEST['id_filter']), 'zone' => trim($_REQUEST['zone_filter']), 'name' => $_name, 'type' => trim($_REQUEST['type_filter']), 'value' => trim($_REQUEST['value_filter']), 'owner' => trim($_REQUEST['owner_filter']) ); } parent::__construct($SoapEngine); $this->getAllowedDomains(); } function listRecords() { $this->showSeachForm(); if ($this->typeFilter) { $filter = array( 'id' => intval($this->filters['id']), 'zone' => $this->filters['zone'], 'name' => $this->filters['name'], 'type' => $this->typeFilter, 'value' => $this->filters['value'], 'owner' => intval($this->filters['owner']), 'customer' => intval($this->filters['customer']), 'reseller' => intval($this->filters['reseller']) ); } else { $filter = array( 'id' => intval($this->filters['id']), 'zone' => $this->filters['zone'], 'name' => $this->filters['name'], 'type' => $this->filters['type'], 'value' => $this->filters['value'], 'owner' => intval($this->filters['owner']), 'customer' => intval($this->filters['customer']), 'reseller' => intval($this->filters['reseller']) ); } // Range $range = array( 'start' => intval($this->next), 'count' => intval($this->maxrowsperpage) ); // Order if (!$this->sorting['sortBy']) $this->sorting['sortBy'] = 'changeDate'; if (!$this->sorting['sortOrder']) $this->sorting['sortOrder'] = 'DESC'; $orderBy = array( 'attribute' => $this->sorting['sortBy'], 'direction' => $this->sorting['sortOrder'] ); // Compose query $Query = array( 'filter' => $filter, 'orderBy' => $orderBy, 'range' => $range ); // Insert credetials $this->SoapEngine->soapclient->addHeader($this->SoapEngine->SoapAuth); $this->log_action($this->getRecordsFunction); // Call function $result = call_user_func_array(array($this->SoapEngine->soapclient, $this->getRecordsFunction), array($Query)); if ($this->checkLogSoapError($result, true)) { return false; } else { $this->rows = $result->total; if ($this->rows > 1 && $_REQUEST['action'] != 'PerformActions' && $_REQUEST['action'] != 'Delete') { $this->showActionsForm(); } print <<< END
Zone owner | Zone | Id | Name | Type | Value | Owner | Change date | Actions | ||
---|---|---|---|---|---|---|---|---|---|---|
Zone owner | Zone | Id | Name | Type | Priority | Value | TTL | Change date | Actions | |
%s | %s.%s | %s | %s | %s | %s | %s | %s | %s | %s | |
%s | %s.%s | %s | %s | %s | %s | %s | %s | %s | %s | %s |
Please press on Confirm to confirm the delete. "; return true; } if ($dictionary['id']) { $id = $dictionary['id']; } else { $id = $this->filters['id']; } if (!$id) { print "
Missing record id. "; return false; } $function = array( 'commit' => array( 'name' => $this->deleteRecordFunction, 'parameters' => array($id), 'logs' => array('success' => sprintf('DNS record %s has been deleted', $id)) ) ); $zone = $this->filters['zone']; unset($this->filters); $this->filters['zone'] = $zone; $result = $this->SoapEngine->execute($function, $this->html); return (bool)$result; } function showAddForm() { /* if ($this->adminonly) { if (!$this->filters['reseller']) { print "
To add a new record you must search first for a customer"; return; } } */ printf("
"; } function getAllowedDomains() { // Filter $filter = array( 'customer' => intval($this->filters['customer']), 'reseller' => intval($this->filters['reseller']) ); // Range $range = array( 'start' => 0, 'count' => $this->max_zones_selection ); // Order $orderBy = array( 'attribute' => 'name', 'direction' => 'ASC' ); // Compose query $Query = array( 'filter' => $filter, 'orderBy' => $orderBy, 'range' => $range ); $this->SoapEngine->soapclient->addHeader($this->SoapEngine->SoapAuth); $this->log_action('getZones'); $result = $this->SoapEngine->soapclient->getZones($Query); if ($this->checkLogSoapError($result, true)) { return false; } else { if ($result->total > $this->max_zones_selection) return false; foreach ($result->zones as $zone) { if (in_array($zone->name, $this->allowedDomains)) continue; $this->allowedDomains[] = $zone->name; $seen[$zone->name]++; } } } function addRecord($dictionary = array()) { if ($this->typeFilter) { $type = $this->typeFilter; } elseif ($dictionary['type']) { $type = $dictionary['type']; } else { $type = trim($_REQUEST['type']); } if ($dictionary['name']) { $name = $dictionary['name']; } else { $name = trim($_REQUEST['name']); } $name = rtrim($name, "."); if (preg_match("/^(.+)@(.*)$/", $name, $m)) { $zone = $m[2]; } else { if ($dictionary['zone']) { $zone = $dictionary['zone']; $this->skipSaveProperties = true; } elseif ($_REQUEST['zone']) { $zone = $_REQUEST['zone']; } if ($type == 'MBOXFW') { $name .= '@'.$zone; } } if (!strlen($zone)) { if ($this->html) { echo "Updating record ...";
if (!$_REQUEST['id_filter']) return;
if (!$record = $this->getRecord(intval($_REQUEST['id_filter']))) {
return false;
}
$record_old = $record;
foreach (array_keys($this->Fields) as $item) {
$var_name = $item.'_form';
//printf ("
%s=%s", $var_name, $_REQUEST[$var_name]);
if ($this->Fields[$item]['type'] == 'integer') {
$record->$item = intval($_REQUEST[$var_name]);
} else {
$record->$item = trim($_REQUEST[$var_name]);
}
}
$function = array('commit' => array('name' => $this->updateRecordFunction,
'parameters' => array($record),
'logs' => array('success' => sprintf('Record %s has been updated', $_REQUEST['id_filter'])))
);
$result = $this->SoapEngine->execute($function, $this->html);
dprint_r($result);
return (bool)$result;
}
function showTextBeforeCustomerSelection()
{
print _("Zone owner");
}
}