diff --git a/library/NGNPro/Records/EnumRanges.php b/library/NGNPro/Records/EnumRanges.php index d203a06..5077304 100644 --- a/library/NGNPro/Records/EnumRanges.php +++ b/library/NGNPro/Records/EnumRanges.php @@ -1,713 +1,815 @@ array('type'=>'integer', - 'help' => 'Range owner') - ); - - var $Fields=array( - 'customer' => array('type'=>'integer', - 'help' => 'Range owner' - ), - 'serial' => array('type'=>'integer', - 'help'=>'DNS serial number', - 'readonly' => 1 - ), - 'ttl' => array('type'=>'integer', - 'help'=>'Cache period in DNS clients' - ), - 'info' => array('type'=>'string', - 'help' =>'Range description' - ), - 'size' => array('type'=>'integer', - 'help'=>'Maximum number of telephone numbers' - ), - 'minDigits' => array('type'=>'integer', - 'help'=>'Minimum number of digits for telephone numbers' - ), - 'maxDigits' => array('type'=>'integer', - 'help'=>'Maximum number of digits for telephone numbers' - ) - ); + var $deniedPrefixes = array( + '1','20','210','211','212','213','214','215','216','217','218','219','220','221','222','223','224','225','226', + '227','228','229','230','231','232','233','234','235','236','237','238','239','240','241','242','243','244', + '245','246','247','248','249','250','251','252','253','254','255','256','257','258','259','260','261','262', + '263','264','265','266','267','268','269','27','280','281','282','283','284','285','286','287','288','289', + '290','291','292','293','294','295','296','297','298','299','30','31','32','33','34','350','351','352','353', + '354','355','356','357','358','359','36','370','371','372','373','374','375','376','377','378','379','380', + '381','382','383','384','385','386','387','388','389','39','40','41','420','421','422','423','424','425','426', + '427','428','429','43','44','45','46','47','48','49','500','501','502','503','504','505','506','507','508', + '509','51','52','53','54','55','56','57','58','590','591','592','593','594','595','596','597','598','599','60', + '61','62','63','64','65','66','670','671','672','673','674','675','676','677','678','679','680','681','682', + '683','684','685','686','687','688','689','690','691','692','693','694','695','696','697','698','699','7', + '800','801','802','803','804','805','806','807','808','809','81','82','830','831','832','833','834','835', + '836','837','838','839','84','850','851','852','853','854','855','856','857','858','859','86','870','871', + '872','873','874','875','876','877','878','879','880','881','882','883','884','885','886','887','888','889', + '890','891','892','893','894','895','896','897','898','899','90','91','92','93','94','95','960','961','962', + '963','964','965','966','967','968','969','970','971','972','973','974','975','976','977','978','979','98', + '990','991','992','993','994','995','996','997','998','999' + ); + + var $FieldsAdminOnly = array( + 'reseller' => array( + 'type'=>'integer', + 'help' => 'Range owner' + ) + ); + + var $Fields = array( + 'customer' => array('type'=>'integer', + 'help' => 'Range owner' + ), + 'serial' => array('type'=>'integer', + 'help'=>'DNS serial number', + 'readonly' => 1 + ), + 'ttl' => array('type'=>'integer', + 'help'=>'Cache period in DNS clients' + ), + 'info' => array('type'=>'string', + 'help' =>'Range description' + ), + 'size' => array('type'=>'integer', + 'help'=>'Maximum number of telephone numbers' + ), + 'minDigits' => array('type'=>'integer', + 'help'=>'Minimum number of digits for telephone numbers' + ), + 'maxDigits' => array('type'=>'integer', + 'help'=>'Maximum number of digits for telephone numbers' + ) + ); public function __construct($SoapEngine) { dprint("init EnumRanges"); - $this->filters = array('prefix' => trim(ltrim($_REQUEST['prefix_filter']),'+'), - 'tld' => trim($_REQUEST['tld_filter']), - 'info' => trim($_REQUEST['info_filter']) - ); + $this->filters = array( + 'prefix' => trim(ltrim($_REQUEST['prefix_filter']), '+'), + 'tld' => trim($_REQUEST['tld_filter']), + 'info' => trim($_REQUEST['info_filter']) + ); parent::__construct($SoapEngine); - $this->sortElements=array('changeDate' => 'Change date', - 'prefix' => 'Prefix', - 'tld' => 'TLD' - ); + $this->sortElements = array( + 'changeDate' => 'Change date', + 'prefix' => 'Prefix', + 'tld' => 'TLD' + ); /* $this->Fields['nameservers'] = array('type'=>'text', 'name'=>'Name servers', 'help'=>'Name servers authoritative for this DNS zone' ); */ if ($this->login_credentials['reseller_filters'][$this->reseller]['record_generator']) { - //printf ("Engine: %s",$this->SoapEngine->soapEngine); + //printf("Engine: %s",$this->SoapEngine->soapEngine); if (is_array($this->login_credentials['reseller_filters'][$this->reseller]['record_generator'])) { - $_rg=$this->login_credentials['reseller_filters'][$this->reseller]['record_generator']; + $_rg = $this->login_credentials['reseller_filters'][$this->reseller]['record_generator']; if ($_rg[$this->SoapEngine->soapEngine]) { - $this->record_generator=$_rg[$this->SoapEngine->soapEngine]; + $this->record_generator = $_rg[$this->SoapEngine->soapEngine]; } } else { - $this->record_generator=$this->login_credentials['reseller_filters'][$this->reseller]['record_generator']; + $this->record_generator = $this->login_credentials['reseller_filters'][$this->reseller]['record_generator']; } - } else if (strlen($this->SoapEngine->record_generator)) { - $this->record_generator=$this->SoapEngine->record_generator; + } elseif (strlen($this->SoapEngine->record_generator)) { + $this->record_generator = $this->SoapEngine->record_generator; } } function listRecords() { $this->getAllowedDomains(); $this->showSeachForm(); // Filter - $filter=array('prefix' => $this->filters['prefix'], - 'tld' => $this->filters['tld'], - 'info' => $this->filters['info'], - 'customer' => intval($this->filters['customer']), - 'reseller' => intval($this->filters['reseller']) - ); + $filter = array( + 'prefix' => $this->filters['prefix'], + 'tld' => $this->filters['tld'], + 'info' => $this->filters['info'], + 'customer' => intval($this->filters['customer']), + 'reseller' => intval($this->filters['reseller']) + ); // Range - $range=array('start' => intval($this->next), - 'count' => intval($this->maxrowsperpage) - ); + $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'] - ); + $orderBy = array( + 'attribute' => $this->sorting['sortBy'], + 'direction' => $this->sorting['sortOrder'] + ); // Compose query - $Query=array('filter' => $filter, - 'orderBy' => $orderBy, - 'range' => $range - ); + $Query = array( + 'filter' => $filter, + 'orderBy' => $orderBy, + 'range' => $range + ); $this->SoapEngine->soapclient->addHeader($this->SoapEngine->SoapAuth); $this->log_action('getRanges'); $result = $this->SoapEngine->soapclient->getRanges($Query); if ($this->checkLogSoapError($result, true)) { return false; } else { - $this->rows = $result->total; if ($this->rows && $_REQUEST['action'] != 'PerformActions' && $_REQUEST['action'] != 'Delete') { $this->showActionsForm(); } - print " -
-
Id | -Owner | -Prefix | -TLD | -Serial | -TTL | -Info | -Min | -Max | -Size | -Used | -Change date | -Actions | -Id | +Owner | +Prefix | +TLD | +Serial | +TTL | +Info | +Min | +Max | +Size | +Used | +Change date | +Actions | + + +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) { if (!$result->ranges[$i]) break; $range = $result->ranges[$i]; $index=$this->next+$i+1; $_url = $this->url.sprintf("&service=%s&action=Delete&prefix_filter=%s&tld_filter=%s", urlencode($this->SoapEngine->service), urlencode($range->id->prefix), urlencode($range->id->tld) ); if ($this->adminonly) $_url.= sprintf ("&reseller_filter=%s",$range->reseller); if ($_REQUEST['action'] == 'Delete' && $_REQUEST['prefix_filter'] == $range->id->prefix && $_REQUEST['tld_filter'] == $range->id->tld) { $_url .= "&confirm=1"; $actionText = "Confirm"; } else { $actionText = "Delete"; } if ($this->adminonly) { $range_url=sprintf('%s',$this->url, $this->SoapEngine->service, $range->reseller, $range->id->prefix, $range->id->tld, $range->id->prefix); } else { $range_url=sprintf('%s',$this->url, $this->SoapEngine->service, $range->id->prefix, $range->id->tld, $range->id->prefix); } if ($this->record_generator) { $generator_url=sprintf('+Numbers',$this->url, $this->record_generator, $range->id->prefix, $range->id->tld, $range->maxDigits, $range->reseller); } else { $generator_url=''; } if ($range->size) { - $usage=intval(100*$range->used/$range->size); - $bar=$this->makebar($usage); + $usage = intval(100 * $range->used / $range->size); + $bar = $this->makebar($usage); } else { $bar=""; } $_customer_url = $this->url.sprintf("&service=customers@%s&customer_filter=%s", urlencode($this->SoapEngine->customer_engine), urlencode($range->customer) ); $_nameservers=''; foreach ($range->nameservers as $_ns) { $_nameservers.= $_ns.' '; } - printf(" + printf( + "
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
%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 (!strlen($this->filters['prefix']) || !strlen($this->filters['tld'])) { print "
Error: missing ENUM range id "; return false; } - $rangeId=array('prefix'=>$this->filters['prefix'], + $rangeId = array('prefix'=>$this->filters['prefix'], 'tld'=>$this->filters['tld']); - $function=array('commit' => array('name' => 'deleteRange', - 'parameters' => array($rangeId), - 'logs' => array('success' => sprintf('ENUM range +%s under %s has been deleted',$this->filters['prefix'], $this->filters['tld']) - ) - ) - ); + $function = array( + 'commit' => array( + 'name' => 'deleteRange', + 'parameters' => array($rangeId), + 'logs' => array( + 'success' => sprintf( + 'ENUM range +%s under %s has been deleted', + $this->filters['prefix'], + $this->filters['tld'] + ) + ) + ) + ); - unset($this->filters); + unset($this->filters); $result = $this->SoapEngine->execute($function, $this->html); if ($this->checkLogSoapError($result, true)) { return false; } else { return true; } } function showAddForm() { if ($this->selectionActive) return; - printf ("
"; } - function addRecord($dictionary=array()) + function addRecord($dictionary = array()) { $tld = trim($_REQUEST['tld']); $prefix = trim($_REQUEST['prefix']); $size = trim($_REQUEST['size']); $info = trim($_REQUEST['info']); if (!strlen($tld)) { - $tld=$this->SoapEngine->default_enum_tld; + $tld = $this->SoapEngine->default_enum_tld; } if (!strlen($tld) || !strlen($prefix) || !is_numeric($prefix)) { printf("Error: Missing TLD or prefix. "); return false; } if (!$this->adminonly) { if (in_array($prefix, $this->deniedPrefixes)) { print "
Error: Only an administrator account can create the prefix coresponding to a country code."; return false; } } list($customer, $reseller)=$this->customerFromLogin($dictionary); if (!trim($_REQUEST['ttl'])) { $ttl = 3600; } else { $ttl = intval(trim($_REQUEST['ttl'])); } $range = array( 'id' => array( 'prefix' => $prefix, 'tld' => $tld ), 'ttl' => $ttl, 'info' => $info, 'minDigits' => intval(trim($_REQUEST['minDigits'])), 'maxDigits' => intval(trim($_REQUEST['maxDigits'])), 'size' => intval($size), 'customer' => intval($customer), 'reseller' => intval($reseller) ); $deleteRange = array( 'prefix'=>$prefix, 'tld'=>$tld ); $_p = array( array( 'name' => 'enum_ranges_last_tld', 'category' => 'web', 'value' => "$tld", 'permission' => 'customer' ) ); $this->setCustomerProperties($_p); $function = array( 'commit' => array( 'name' => 'addRange', 'parameters' => array($range), - 'logs' => array('success' => sprintf('ENUM range +%s under %s has been added',$prefix, $tld)) + 'logs' => array('success' => sprintf('ENUM range +%s under %s has been added', $prefix, $tld)) ) ); $result = $this->SoapEngine->execute($function, $this->html); dprint_r($result); if ($this->checkLogSoapError($result, true)) { return false; } else { return true; } } function showSeachFormCustom() { - printf ("
- Updating range ...";
if (!$_REQUEST['prefix_filter'] || !$_REQUEST['tld_filter']) return;
- $rangeid=array('prefix' => $_REQUEST['prefix_filter'],
- 'tld' => $_REQUEST['tld_filter']
- );
+ $rangeid = array(
+ 'prefix' => $_REQUEST['prefix_filter'],
+ 'tld' => $_REQUEST['tld_filter']
+ );
if (!$range = $this->getRecord($rangeid)) {
return false;
}
- $range_old=$range;
+ $range_old = $range;
foreach (array_keys($this->Fields) as $item) {
- $var_name=$item.'_form';
- //printf ("
Please press on Confirm to confirm the delete. "; return true; } if ($dictionary['alias_username']) { $alias_username = $dictionary['alias_username']; } else { $alias_username = $this->filters['alias_username']; } if ($dictionary['alias_domain']) { $alias_domain = $dictionary['alias_domain']; } else { $alias_domain = $this->filters['alias_domain']; } if (!strlen($alias_username) || !strlen($alias_domain)) { print " Error: missing SIP alias username or domain. "; return false; } $alias = array('username' => $alias_username, 'domain' => $alias_domain ); - $function = array('commit' => array('name' => 'deleteAlias', - 'parameters' => array($alias), - 'logs' => array('success' => sprintf('SIP alias %s@%s has been deleted',$this->filters['alias_username'], $this->filters['alias_domain']) - ) - ) - - ); + $function = array( + 'commit' => array( + 'name' => 'deleteAlias', + 'parameters' => array($alias), + 'logs' => array( + 'success' => sprintf( + 'SIP alias %s@%s has been deleted', + $this->filters['alias_username'], + $this->filters['alias_domain'] + ) + ) + ) + ); unset($this->filters); return $this->SoapEngine->execute($function, $this->html); } function showSeachFormCustom() { printf( "
SIP alias
",
$this->filters['alias_username']
);
print "@";
if (count($this->allowedDomains) > 0) {
if ($this->filters['alias_domain'] && !in_array($this->filters['alias_domain'], $this->allowedDomains)) {
printf("", $this->filters['alias_domain']);
} else {
$selected_domain[$this->filters['alias_domain']]='selected';
printf("");
}
} else {
printf("", $this->filters['alias_domain']);
}
printf(
"
Redirect target
",
trim($_REQUEST['target_username_filter'])
);
printf(
"
Owner
",
$this->filters['owner']
);
}
function showAddForm()
{
if ($this->selectionActive) return;
if (!count($this->allowedDomains)) {
print "You must create at least one SIP domain before adding SIP aliases"; return false; } printf("
END;
print <<< END
SIP alias
END;
if ($_REQUEST['domain']) {
$_domain = $_REQUEST['domain'];
$selected_domain[$_REQUEST['domain']]='selected';
} elseif ($_domain = $this->getCustomerProperty('sip_aliases_last_domain')) {
$selected_domain[$_domain]='selected';
}
if (count($this->allowedDomains) > 0) {
print "@";
} else {
printf("", $_domain);
}
print <<< END
Redirect target
END;
print <<< END
Owner
END;
$this->printHiddenFormElements();
print <<< END
Error: Missing SIP domain"); } return false; } if (!$this->validDomain($domain)) { if ($this->html) { print "Error: invalid domain name"; } return false; } list($customer, $reseller)=$this->customerFromLogin($dictionary); if (!$this->skipSaveProperties = true) { $_p = array( array('name' => 'sip_aliases_last_domain', 'category' => 'web', 'value' => strtolower($domain), 'permission' => 'customer' ) ); $this->setCustomerProperties($_p); } $alias = array( 'id' => array('username' => strtolower($username), 'domain' => strtolower($domain) ), 'target' => array('username' => strtolower($target_username), 'domain' => strtolower($target_els[1]) ), 'owner' => intval($owner) ); $deleteAlias = array('username' => strtolower($username), 'domain' => strtolower($domain) ); $function = array( 'commit' => array( 'name' => 'addAlias', 'parameters' => array($alias), 'logs' => array( 'success' => sprintf('SIP alias %s@%s has been added', $username, $domain))) ); return $this->SoapEngine->execute($function, $this->html); } function getAllowedDomains() { // Filter $filter = array( 'domain' => '' ); // Range $range = array( 'start' => 0, 'count' => 500 ); $orderBy = array( 'attribute' => 'domain', 'direction' => 'ASC' ); // Compose query $Query = array( 'filter' => $filter, 'orderBy' => $orderBy, 'range' => $range ); $this->SoapEngine->soapclient->addHeader($this->SoapEngine->SoapAuth); $this->log_action('getDomains'); $result = $this->SoapEngine->soapclient->getDomains($Query); if ($this->checkLogSoapError($result, true)) { return false; } else { foreach ($result->domains as $_domain) { if ($this->validDomain($_domain->domain)) { $this->allowedDomains[] = $_domain->domain; } } } } function showTextBeforeCustomerSelection() { print _("Domain owner"); } } |