diff --git a/library/NGNPro/Records/DnsRecords.php b/library/NGNPro/Records/DnsRecords.php index 71efc00..5d92766 100644 --- a/library/NGNPro/Records/DnsRecords.php +++ b/library/NGNPro/Records/DnsRecords.php @@ -1,1440 +1,1481 @@ '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,'%')) { + 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() { + 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)); + $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 " -
$this->rows records found. Click on record id to edit the values.
-

- - "; + print <<< END +
+
$this->rows records found. Click on record id to edit the values.
+
+

+

+END; if ($this->fancy) { - print " - - - - - - - - - - - - - - - "; + print <<< END + + + + + + + + + + + + + + +END; } else { - print " - - - - - - - - - - - - - - - "; + print <<< END + + + + + + + + + + + + + + + +END; } if (!$this->next) $this->next=0; - if ($this->rows > $this->maxrowsperpage) { + if ($this->rows > $this->maxrowsperpage) { $maxrows = $this->maxrowsperpage + $this->next; if ($maxrows > $this->rows) $maxrows = $this->maxrowsperpage; } else { - $maxrows=$this->rows; + $maxrows = $this->rows; } $i=0; if ($this->rows) { - while ($i < $maxrows) { + while ($i < $maxrows) { if (!$result->records[$i]) { break; } $record = $result->records[$i]; - $index=$this->next+$i+1; + $index = $this->next+$i+1; $_url = $this->url.sprintf( "&service=%s&action=Delete&name_filter=%s&zone_filter=%s&id_filter=%s", urlencode($this->SoapEngine->service), urlencode($record->name), urlencode($record->zone), urlencode($record->id) ); - if ($this->adminonly) $_url.= sprintf ("&reseller_filter=%s",$record->reseller); + if ($this->adminonly) $_url.= sprintf ("&reseller_filter=%s", $record->reseller); if ($_REQUEST['action'] == 'Delete' && $_REQUEST['id_filter'] == $record->id) { $_url .= "&confirm=1"; $actionText = "Confirm"; } else { $actionText = "Delete"; } $_customer_url = $this->url.sprintf( "&service=customers@%s&customer_filter=%s", urlencode($this->SoapEngine->customer_engine), urlencode($record->customer) ); $_zone_url = $this->url.sprintf( "&service=dns_zones@%s&name_filter=%s", urlencode($this->SoapEngine->soapEngine), urlencode($record->zone) ); if ($this->adminonly) { $_zone_url.= sprintf("&reseller_filter=%s", $record->reseller); } $_record_url = $this->url.sprintf( "&service=%s@%s&zone_filter=%s&id_filter=%s", urlencode($this->SoapEngine->service), urlencode($this->SoapEngine->soapEngine), urlencode($record->zone), urlencode($record->id) ); - if ($this->adminonly) $_record_url.= sprintf ("&reseller_filter=%s",$record->reseller); + if ($this->adminonly) $_record_url.= sprintf ("&reseller_filter=%s", $record->reseller); if ($record->owner) { $_owner_url = sprintf( "%s", $this->url, urlencode($this->SoapEngine->soapEngine), urlencode($record->owner), $record->owner ); } else { $_owner_url=''; } if ($this->fancy) { printf( " - ", + + ", $index, $_customer_url, $record->customer, $record->reseller, $_zone_url, $record->zone, $_record_url, $record->id, $record->name, $record->type, $record->value, $record->owner, $record->changeDate, $_url, $actionText ); } else { - printf(" + printf( + " - ", + + ", $index, $_customer_url, $record->customer, $record->reseller, $_zone_url, $record->zone, $_record_url, $record->id, $record->name, $record->type, $record->priority, $record->value, $record->ttl, $record->changeDate, $_url, $actionText ); } $i++; } } print "
Zone ownerZoneIdNameTypeValueOwnerChange dateActions
Zone ownerZoneIdNameTypeValueOwnerChange dateActions
Zone ownerZoneIdNameTypePriorityValueTTLChange dateActions
Zone ownerZoneIdNameTypePriorityValueTTLChange dateActions
%s %s.%s %s %s %s %s %s %s %s %s
%s %s.%s %s %s %s %s %s %s %s %s %s
"; - if ($this->rows == 1 ) { + if ($this->rows == 1) { $this->showRecord($record); } else { $this->showPagination($maxrows); } return true; } } - function showSeachFormCustom() { + function showSeachFormCustom() + { printf( "

Record Id
", $this->filters['id'] ); printf( "
Name
", $this->filters['name'] ); if (count($this->allowedDomains) > 0) { $selected_zone[$this->filters['zone']]='selected'; print ""; } else { printf( "
DNS zone
", $this->filters['zone'] ); } if ($this->typeFilter) { printf( " Type %s", $this->typeFilter, $this->typeFilter ); } else { $selected_type[$this->filters['type']]='selected'; echo " "; } printf( "
Value
", $this->filters['value'] ); } - function deleteRecord($dictionary=array()) { + function deleteRecord($dictionary = array()) + { if (!$dictionary['confirm'] && !$_REQUEST['confirm']) { print "

Please press on Confirm to confirm the delete. "; return true; } if ($dictionary['id']) { - $id=$dictionary['id']; + $id = $dictionary['id']; } else { - $id=$this->filters['id']; + $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)) + 'logs' => array('success' => sprintf('DNS record %s has been deleted', $id)) ) ); - $zone=$this->filters['zone']; - unset($this->filters); - $this->filters['zone']=$zone; + $zone = $this->filters['zone']; + unset($this->filters); + $this->filters['zone'] = $zone; - $result = $this->SoapEngine->execute($function,$this->html); + $result = $this->SoapEngine->execute($function, $this->html); return (bool)$result; } - function showAddForm() { + function showAddForm() + { /* if ($this->adminonly) { - if (!$this->filters['reseller']) { + if (!$this->filters['reseller']) { print "

To add a new record you must search first for a customer"; - return; + return; } } */ printf("

", $_SERVER['PHP_SELF']); print "
"; if ($this->adminonly) { printf( "", $this->filters['reseller'] ); } print "
Name "; printf( "
", trim($_REQUEST['name']) ); if (count($this->allowedDomains) > 0) { if ($_REQUEST['zone']) { $selected_zone[$_REQUEST['zone']]='selected'; - } else if ($this->filters['zone']) { + } elseif ($this->filters['zone']) { $selected_zone[$this->filters['zone']]='selected'; - } else if ($_zone=$this->getCustomerProperty('dns_records_last_zone')) { + } elseif ($_zone = $this->getCustomerProperty('dns_records_last_zone')) { $selected_zone[$_zone]='selected'; } print "."; } else { if ($_REQUEST['zone']) { - $_zone_selected=$_REQUEST['zone']; - } else if ($this->filters['zone']) { - $_zone_selected=$this->filters['zone']; - } else if ($_zone=$this->getCustomerProperty('dns_records_last_zone')) { - $_zone_selected=$_zone; + $_zone_selected = $_REQUEST['zone']; + } elseif ($this->filters['zone']) { + $_zone_selected = $this->filters['zone']; + } elseif ($_zone = $this->getCustomerProperty('dns_records_last_zone')) { + $_zone_selected = $_zone; } printf( " -
DNS zone
+
+ DNS zone + +
", $_zone_selected ); } if ($this->typeFilter) { - printf("Type %s ",$this->typeFilter,$this->typeFilter); + printf("Type %s ", $this->typeFilter, $this->typeFilter); } else { print "
Type
"; } printf( " -
Value
+
+ Value + +
", trim($_REQUEST['value']) ); - if (!$this->fancy) { + if (!$this->fancy) { printf( " -
Priority
+
+ Priority + +
", trim($_REQUEST['priority']) ); } $this->printHiddenFormElements(); print "
"; } - function getAllowedDomains() { + 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; + foreach ($result->zones as $zone) { + if (in_array($zone->name, $this->allowedDomains)) continue; + $this->allowedDomains[] = $zone->name; $seen[$zone->name]++; } } } - function addRecord($dictionary=array()) { - + function addRecord($dictionary = array()) + { if ($this->typeFilter) { $type = $this->typeFilter; - } else if ($dictionary['type']) { + } 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,"."); + $name = rtrim($name, "."); if (preg_match("/^(.+)@(.*)$/", $name, $m)) { $zone = $m[2]; } else { if ($dictionary['zone']) { - $zone=$dictionary['zone']; - $this->skipSaveProperties=true; - } else if ($_REQUEST['zone']) { - $zone=$_REQUEST['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 "
Error: Missing zone name.
"; + echo "
Error: Missing zone name.
"; } return false; } - $this->filters['zone']=$zone; + $this->filters['zone'] = $zone; if (!strlen($type)) { if ($this->html) { echo "
Error: Missing record type.
"; } return false; } if ($dictionary['value']) { $value = $dictionary['value']; } else { $value = trim($_REQUEST['value']); } - $value=rtrim($value,"."); + $value = rtrim($value, "."); if ($this->adminonly) { if ($dictionary['reseller']) { - } else if ($this->filters['reseller']) { + } elseif ($this->filters['reseller']) { } else { if ($this->html) { - echo "
Error: Missing reseller, please first search zones for a given reseller
"; + print <<< END +
+ Error: Missing reseller, please first search zones for a given reseller +
+END; } return false; } } if ($dictionary['ttl']) { $ttl = intval($dictionary['ttl']); } else { $ttl = intval(trim($_REQUEST['ttl'])); } if (!$ttl) $ttl=3600; if ($dictionary['owner']) { $owner = intval($dictionary['owner']); } else { $owner = intval(trim($_REQUEST['owner'])); } if ($dictionary['priority']) { $priority = $dictionary['priority']; } else { $priority = trim($_REQUEST['priority']); } - if (in_array($type,array_keys($this->recordTypes))) { + if (in_array($type, array_keys($this->recordTypes))) { // See RFC 1912 - Section 2.4 if (trim($name).trim($zone) == trim($zone) && $type == 'CNAME') { printf( - "
Error: CNAME (%s) equal to zone name (%s) is not allowed
", + " +
+ Error: CNAME (%s) equal to zone name (%s) is not allowed +
+ ", trim($name).trim($zone), trim($zone) ); return false; } if (!strlen($value)) { if ($this->html) { - echo "
Error: Missing record value.
"; + echo "
Error: Missing record value.
"; } return false; } $record = array( 'name' => trim($name), 'zone' => trim($zone), 'type' => $type, 'value' => trim($value), 'owner' => intval($owner), 'ttl' => intval($ttl), 'priority' => intval($priority) ); - if (!$this->skipSaveProperties=true) { + if (!$this->skipSaveProperties = true) { $_p = array( array( 'name' => 'dns_records_last_zone', 'category' => 'web', 'value' => $_REQUEST['zone'], 'permission' => 'customer' ), array( 'name' => 'dns_records_last_type', 'category' => 'web', 'value' => "$type", 'permission' => 'customer' ) ); $this->setCustomerProperties($_p); } $function = array( 'commit' => array( 'name' => $this->addRecordFunction, 'parameters' => array($record), - 'logs' => array('success' => sprintf('DNS record %s under %s has been added',$name,$zone)) + 'logs' => array('success' => sprintf('DNS record %s under %s has been added', $name, $zone)) ) ); - $result = $this->SoapEngine->execute($function,$this->html); + $result = $this->SoapEngine->execute($function, $this->html); dprint_r($result); return (bool)$result; - } else if (in_array($type,array_keys($this->recordTypesTemplate))) { - $push_notifications_server = $this->getResellerProperty('push_notifications_server_private') or $this->getResellerProperty('push_notifications_server'); + } elseif (in_array($type, array_keys($this->recordTypesTemplate))) { + $push_notifications_server = $this->getResellerProperty('push_notifications_server_private') + or $this->getResellerProperty('push_notifications_server'); if ($type == "sip2sip" && $push_notifications_server) { if (preg_match("/^(.*):(\d+);transport=(.*)$/", $push_notifications_server, $m)) { $push_hostname = $m[1]; $push_port = $m[2]; $push_transport = $m[3]; if ($push_transport == "tls") { $naptr_type = "_sips._tcp"; $naptr_s = "SIPS+D2T"; - } else if ($push_transport == "tcp") { + } elseif ($push_transport == "tcp") { $naptr_type = "_sip._tcp"; $naptr_s = "SIP+D2T"; } else { $naptr_type = "_sip._udp"; $naptr_s = "SIP+D2U"; } $this->recordTypesTemplate[$type]['records']['push_naptr'] = array( 'name' => 'push', 'type' => 'NAPTR', 'priority' => '100', 'ttl' => '600', 'value' => sprintf('10 100 "s" "%s" "" %s.push', $naptr_s, $naptr_type) ); $this->recordTypesTemplate[$type]['records']['push_srv'] = array( 'name' => sprintf('%s.push', $naptr_type), 'type' => 'SRV', 'priority' => '100', 'ttl' => '600', 'value' => sprintf('100 %d %s', $push_port, $push_hostname) ); - } + } } foreach (array_values($this->recordTypesTemplate[$type]['records']) as $_records) { $value_new=''; if (strlen($_records['value'])) { - if (preg_match("/^_sip/",$_records['name'])) { + if (preg_match("/^_sip/", $_records['name'])) { if (!$value) { - $value=$this->getCustomerProperty('dns_records_last_sip_server'); - if (!$value) { - $value = $this->getCustomerProperty('sip_proxy'); + $value = $this->getCustomerProperty('dns_records_last_sip_server'); + if (!$value) { + $value = $this->getCustomerProperty('sip_proxy'); } if (!value) { - $value = $this->SoapEngine->default_sip_proxy; + $value = $this->SoapEngine->default_sip_proxy; } - $save_new_value=false; + $save_new_value = false; } else { - $save_new_value=true; + $save_new_value = true; } } - $els=explode("|",$_records['value']); + $els = explode("|", $_records['value']); foreach ($els as $el) { - if (preg_match("/#VALUE#/",$el)) { - if ($value) { - $value_new=preg_replace("/#VALUE#/",$value,$el); + if (preg_match("/#VALUE#/", $el)) { + if ($value) { + $value_new = preg_replace("/#VALUE#/", $value, $el); } else { continue; } } else { - $value_new=$el; + $value_new = $el; } break; } // save value if type sip server - if ($save_new_value && $_records['name'] && preg_match("/^_sip/",$_records['name'])) { + if ($save_new_value && $_records['name'] && preg_match("/^_sip/", $_records['name'])) { $_p = array( array( 'name' => 'dns_records_last_sip_server', 'category' => 'web', 'value' => $value, 'permission' => 'customer' ) ); $this->setCustomerProperties($_p); } } - if (!in_array($_records['type'],array_keys($this->recordTypes))) { + if (!in_array($_records['type'], array_keys($this->recordTypes))) { continue; } $record = array( 'name' => $_records['name'], 'zone' => trim($zone), 'type' => $_records['type'], 'value' => $value_new, 'owner' => intval($owner), 'ttl' => intval($_records['ttl']), 'priority' => intval($_records['priority']) ); //print_r($record); - $function=array( + $function = array( 'commit' => array( 'name' => $this->addRecordFunction, 'parameters' => array($record), 'logs' => array( 'success' => sprintf('Dns %s record under %s has been added', $_records['type'], $zone) ) ) ); - $result = $this->SoapEngine->execute($function,$this->html); + $result = $this->SoapEngine->execute($function, $this->html); return (bool)$result; } } else { if ($this->html) { - printf ("
Error: Invalid or missing record type.
"); + print "
Error: Invalid or missing record type.
"; } return false; } return true; } - function getRecordKeys() { + function getRecordKeys() + { // Filter $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' => 0, 'count' => 1000 ); // 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('getRecords'); // Call function $result = $this->SoapEngine->soapclient->getRecords($Query); if ($this->checkLogSoapError($result, true)) { return false; } else { foreach ($result->records as $record) { - $this->selectionKeys[]=array('id' => $record->id); + $this->selectionKeys[] = array('id' => $record->id); } return true; } } - function showRecord($record) { + function showRecord($record) + { echo "

Record

"; printf("
", $_SERVER['PHP_SELF']); echo ""; printf( "
%s
", $record->name ); foreach (array_keys($this->Fields) as $item) { - if (is_array($this->havePriority) && $item == 'priority' && !in_array($record->type,$this->havePriority)) { + if (is_array($this->havePriority) && $item == 'priority' && !in_array($record->type, $this->havePriority)) { continue; } if ($this->Fields[$item]['name']) { $item_name = $this->Fields[$item]['name']; } else { $item_name = ucfirst($item); } if ($item == 'type') { - $selected_type[$record->$item]='selected'; + $selected_type[$record->$item]='selected'; - $select_box=sprintf("", $item); + foreach (array_keys($this->recordTypes) as $_type) { $select_box .= sprintf( "
"; - } - function getRecord($id) { + function getRecord($id) + { // Filter if (!$id) { print "Error in getRecord(): Missing record id"; return false; } $filter = array('id' => $id); // Range $range = array( 'start' => 0, 'count' => 1 ); // Order $orderBy = array( 'attribute' => 'changeDate', 'direction' => 'DESC' ); // Compose query $Query = array( 'filter' => $filter, 'orderBy' => $orderBy, 'range' => $range ); $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)); + $result = call_user_func_array(array($this->SoapEngine->soapclient, $this->getRecordsFunction), array($Query)); if ($this->checkLogSoapError($result, true)) { return false; } else { - if ($result->records[0]){ + if ($result->records[0]) { return $result->records[0]; } else { return false; } } } - function updateRecord () { + function updateRecord() + { //print "

Updating record ..."; if (!$_REQUEST['id_filter']) return; if (!$record = $this->getRecord(intval($_REQUEST['id_filter']))) { return false; } - $record_old=$record; + $record_old = $record; foreach (array_keys($this->Fields) as $item) { - $var_name=$item.'_form'; - //printf ("
%s=%s",$var_name,$_REQUEST[$var_name]); + $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, + $function = array('commit' => array('name' => $this->updateRecordFunction, 'parameters' => array($record), - 'logs' => array('success' => sprintf('Record %s has been updated',$_REQUEST['id_filter']))) + 'logs' => array('success' => sprintf('Record %s has been updated', $_REQUEST['id_filter']))) ); - $result = $this->SoapEngine->execute($function,$this->html); + $result = $this->SoapEngine->execute($function, $this->html); dprint_r($result); return (bool)$result; } - function showTextBeforeCustomerSelection() { + function showTextBeforeCustomerSelection() + { print _("Zone owner"); } - } -