diff --git a/library/NGNPro/Records/GatewayRules.php b/library/NGNPro/Records/GatewayRules.php index a2850be..36f4791 100644 --- a/library/NGNPro/Records/GatewayRules.php +++ b/library/NGNPro/Records/GatewayRules.php @@ -1,589 +1,589 @@ array('type'=>'integer','readonly' => true), 'gateway_id' => array('type'=>'integer','name' => 'Gateway'), 'prefix' => array('type'=>'string'), 'strip' => array('type'=>'integer'), 'prepend' => array('type'=>'string'), 'minLength' => array('type'=>'integer'), 'maxLength' => array('type'=>'integer') ); public function __construct($SoapEngine) { $this->filters = array( 'id' => trim($_REQUEST['id_filter']), 'gateway_id' => trim($_REQUEST['gateway_id_filter']), 'carrier_id' => trim($_REQUEST['carrier_id_filter']), 'prefix' => trim($_REQUEST['prefix_filter']), ); $this->sortElements = array( 'changeDate' => 'Change date', 'gateway' => 'Gateway', 'carrier' => 'Carrier', 'prefix' => 'Prefix' ); parent::__construct($SoapEngine); } function listRecords() { $this->getCarriers(); $this->showSeachForm(); // Insert credetials $this->SoapEngine->soapclient->addHeader($this->SoapEngine->SoapAuth); // Filter $filter = array( 'id' => intval($this->filters['id']), 'gateway_id' => intval($this->filters['gateway_id']), 'carrier_id' => intval($this->filters['carrier_id']), 'prefix' => $this->filters['prefix'], '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'] = 'ASC'; $orderBy = array( 'attribute' => $this->sorting['sortBy'], 'direction' => $this->sorting['sortOrder'] ); // Compose query $Query = array( 'filter' => $filter, 'orderBy' => $orderBy, 'range' => $range ); $this->log_action('getGatewayRules'); $result = $this->SoapEngine->soapclient->getGatewayRules($Query); if ($this->checkLogSoapError($result, true)) { return false; } else { $this->rows = $result->total; print "
Owner | Rule | Carrier | Gateway | Prefix | Strip | Prepend | MinLength | MaxLength | Change date | Actions | |
---|---|---|---|---|---|---|---|---|---|---|---|
%s | %s | %s | %s (%d) | %s (%d) | %s | %s | %s | %s | %s | %s | %s |
Create a gateway first
"; return false; } printf(" END; } function addRecord($dictionary = array()) { if ($dictionary['gateway_id']) { $gateway_id = $dictionary['gateway_id']; } else { $gateway_id = trim($_REQUEST['gateway_id']); } if ($dictionary['prefix']) { $prefix = $dictionary['prefix']; } else { $prefix = trim($_REQUEST['prefix']); } if ($dictionary['strip']) { $strip = $dictionary['strip']; } else { $strip = trim($_REQUEST['strip']); } if ($dictionary['prepend']) { $prepend = $dictionary['prepend']; } else { $prepend = trim($_REQUEST['prepend']); } if ($dictionary['minLength']) { $minLength = $dictionary['minLength']; } else { $minLength = trim($_REQUEST['minLength']); } if ($dictionary['maxLength']) { $maxLength = $dictionary['maxLength']; } else { $maxLength = trim($_REQUEST['maxLength']); } if (!strlen($gateway_id)) { printf("Error: Missing gateway id"); return false; } $rule = array( 'gateway_id' => intval($gateway_id), 'prefix' => $prefix, 'prepend' => $prepend, 'strip' => intval($strip), 'minLength' => intval($minLength), 'maxLength' => intval($maxLength) ); $function = array( 'commit' => array( 'name' => 'addGatewayRule', 'parameters' => array($rule), 'logs' => array('success' => sprintf('Gateway rule has been added')) ) ); unset($this->filters); return $this->SoapEngine->execute($function, $this->html); } 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']; } else { $id = trim($this->filters['id']); } if (!strlen($id)) { print "Error: missing rule id "; return false; } $function = array( 'commit' => array( 'name' => 'deleteGatewayRule', 'parameters' => array(intval($id)), 'logs' => array('success' => sprintf('Gateway rule %d has been deleted', $id)) ) ); unset($this->filters); return $this->SoapEngine->execute($function, $this->html); } function showSeachFormCustom() { printf( "
Updating rule ..."; if (!$_REQUEST['id_form'] || !strlen($_REQUEST['reseller_filter'])) { return; } if (!$rule = $this->getRecord($_REQUEST['id_form'])) { return false; } foreach (array_keys($this->Fields) as $item) { $var_name = $item.'_form'; if ($this->Fields[$item]['type'] == 'integer') { $rule->$item = intval($_REQUEST[$var_name]); } else { $rule->$item = trim($_REQUEST[$var_name]); } } $function = array('commit' => array('name' => 'updateGatewayRule', 'parameters' => array($rule), 'logs' => array('success' => sprintf('Rule %d has been updated', $_REQUEST['id_form']))) ); $result = $this->SoapEngine->execute($function, $this->html); dprint_r($result); return (bool)$result; } function getRecord($id) { // Insert credetials $this->SoapEngine->soapclient->addHeader($this->SoapEngine->SoapAuth); // Filter $filter = array('id' => intval($id)); // Range $range = array('start' => 0, 'count' => 1 ); // Order $this->sorting['sortBy'] = 'gateway'; $this->sorting['sortOrder'] = 'ASC'; $orderBy = array('attribute' => $this->sorting['sortBy'], 'direction' => $this->sorting['sortOrder'] ); // Compose query $Query = array('filter' => $filter, 'orderBy' => $orderBy, 'range' => $range ); // Call function $this->log_action('getGatewayRules'); $result = $this->SoapEngine->soapclient->getGatewayRules($Query); if ($this->checkLogSoapError($result, true)) { return false; } else { if ($result->gateway_rules[0]) { return $result->gateway_rules[0]; } else { return false; } } } } diff --git a/library/NGNPro/Records/Gateways.php b/library/NGNPro/Records/Gateways.php index 4092c8e..4e7d77a 100644 --- a/library/NGNPro/Records/Gateways.php +++ b/library/NGNPro/Records/Gateways.php @@ -1,580 +1,580 @@ array('type'=>'integer', 'readonly' => true), 'name' => array('type'=>'string'), 'carrier_id' => array('type'=>'integer'), 'transport' => array('type'=>'string'), 'ip' => array('name'=>'IP or hostname', 'type'=>'string'), 'port' => array('type'=>'integer') ); //var $transports = array('udp','tcp','tls'); var $transports = array('udp'); public function __construct($SoapEngine) { $this->filters = array( 'id' => trim($_REQUEST['id_filter']), 'name' => trim($_REQUEST['name_filter']), 'carrier_id' => trim($_REQUEST['carrier_id_filter']) ); $this->sortElements = array( 'changeDate' => 'Change date', 'name' => 'Gateway', 'carrier_id' => 'Carrier', 'ip' => 'Address' ); parent::__construct($SoapEngine); } function listRecords() { $this->getCarriers(); $this->showSeachForm(); // Insert credetials $this->SoapEngine->soapclient->addHeader($this->SoapEngine->SoapAuth); // Filter $filter = array( 'id' => intval($this->filters['id']), 'name' => $this->filters['name'], 'carrier_id'=> intval($this->filters['carrier_id']), '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 ); // Call function $this->log_action('getGateways'); $result = $this->SoapEngine->soapclient->getGateways($Query); if ($this->checkLogSoapError($result, true)) { return false; } else { $this->rows = $result->total; print <<< END
Id | Owner | Gateway | Carrier | Name | Address | Rules | Change date | Actions |
---|---|---|---|---|---|---|---|---|
%s | %s | %s | %s | %s | %s:%s:%s | Rules | %s | %s |
Create a carrier first"; return false; } printf("
"; } function addRecord($dictionary = array()) { if ($dictionary['name']) { $name = $dictionary['name']; } else { $name = trim($_REQUEST['name']); } if ($dictionary['carrier_id']) { $carrier_id = $dictionary['carrier_id']; } else { $carrier_id = trim($_REQUEST['carrier_id']); } if ($dictionary['address']) { $address = $dictionary['address']; } else { $address = trim($_REQUEST['address']); } if ($dictionary['transport']) { $transport = $dictionary['transport']; } else { $transport = trim($_REQUEST['transport']); } if (!strlen($name) || !strlen($carrier_id) || !strlen($address)) { printf("Error: Missing gateway name, carrier_id or address"); return false; } $address_els = explode(':', $address); if (count($address_els) == 1) { $ip = $address_els[0]; $port ='5060'; } elseif (count($address_els) == 2) { $ip = $address_els[0]; $port = $address_els[1]; } if (!$port) $port = 5060; if (!in_array($transport, $this->transports)) { $transport=$this->transports[0]; } $gateway = array( 'name' => $name, 'carrier_id' => intval($carrier_id), 'ip' => $ip, 'port' => intval($port), 'transport' => $transport ); $function = array( 'commit' => array( 'name' => 'addGateway', 'parameters' => array($gateway), 'logs' => array('success' => sprintf('Gateway %s has been added', $name)) ) ); unset($this->filters); return $this->SoapEngine->execute($function, $this->html); } 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']; } else { $id = trim($this->filters['id']); } if (!strlen($id)) { print "
Error: missing gateway id."; return false; } $function = array( 'commit' => array( 'name' => 'deleteGateway', 'parameters' => array(intval($id)), 'logs' => array('success' => sprintf('Gateway %d has been deleted', $id)) ) ); unset($this->filters); return $this->SoapEngine->execute($function, $this->html); } function showSeachFormCustom() { printf( "
Updating gateway ..."; if (!$_REQUEST['id_filter']) return; if (!$gateway = $this->getRecord($_REQUEST['id_filter'])) { return false; } foreach (array_keys($this->Fields) as $item) { $var_name=$item.'_form'; if ($this->Fields[$item]['type'] == 'integer') { $gateway->$item = intval($_REQUEST[$var_name]); } else { $gateway->$item = trim($_REQUEST[$var_name]); } } if (!in_array($gateway->transport, $this->transports)) { printf("Invalid transport '%s'", $gateway->transport); return false; } $function = array( 'commit' => array( 'name' => 'updateGateway', 'parameters' => array($gateway), 'logs' => array( 'success' => sprintf('Gateway %s has been updated', $_REQUEST['name_filter']))) ); $result = $this->SoapEngine->execute($function, $this->html); dprint_r($result); return (bool)$result; } function getRecord($id) { // Insert credetials $this->SoapEngine->soapclient->addHeader($this->SoapEngine->SoapAuth); // Filter $filter = array('id' => intval($id)); // Range $range = array( 'start' => 0, 'count' => 1 ); // Order if (!$this->sorting['sortBy']) $this->sorting['sortBy'] = 'name'; if (!$this->sorting['sortOrder']) $this->sorting['sortOrder'] = 'ASC'; $orderBy = array( 'attribute' => $this->sorting['sortBy'], 'direction' => $this->sorting['sortOrder'] ); // Compose query $Query = array( 'filter' => $filter, 'orderBy' => $orderBy, 'range' => $range ); // Call function $this->log_action('getGateways'); $result = $this->SoapEngine->soapclient->getGateways($Query); if ($this->checkLogSoapError($result, true)) { return false; } else { if ($result->gateways[0]) { return $result->gateways[0]; } else { return false; } } } } diff --git a/library/NGNPro/Records/Routes.php b/library/NGNPro/Records/Routes.php index 8691089..5939778 100644 --- a/library/NGNPro/Records/Routes.php +++ b/library/NGNPro/Records/Routes.php @@ -1,544 +1,544 @@ array( 'type'=>'integer', 'readonly' => true ), 'carrier_id' => array('type'=>'integer','name'=>'Carrier'), 'prefix' => array('type'=>'string'), 'originator' => array('type'=>'string'), 'priority' => array('type'=>'integer') ); var $sortElements = array( 'prefix' => 'Prefix', 'priority' => 'Priority' ); public function __construct($SoapEngine) { $this->filters = array( 'prefix' => trim($_REQUEST['prefix_filter']), 'priority' => trim($_REQUEST['priority_filter']), 'carrier_id'=> trim($_REQUEST['carrier_id_filter']), 'reseller' => trim($_REQUEST['reseller_filter']), 'id' => trim($_REQUEST['id_filter']) ); parent::__construct($SoapEngine); } function listRecords() { $this->getCarriers(); $this->showSeachForm(); // Insert credetials $this->SoapEngine->soapclient->addHeader($this->SoapEngine->SoapAuth); // Filter $filter = array( 'prefix' => $this->filters['prefix'], 'carrier_id' => intval($this->filters['carrier_id']), 'reseller' => intval($this->filters['reseller']), 'id' => intval($this->filters['id']) ); // Range $range = array( 'start' => intval($this->next), 'count' => intval($this->maxrowsperpage) ); // Order if (!$this->sorting['sortBy']) $this->sorting['sortBy'] = 'prefix'; if (!$this->sorting['sortOrder']) $this->sorting['sortOrder'] = 'ASC'; $orderBy = array( 'attribute' => $this->sorting['sortBy'], 'direction' => $this->sorting['sortOrder'] ); // Compose query $Query = array( 'filter' => $filter, 'orderBy' => $orderBy, 'range' => $range ); // Call function $this->log_action('getRoutes'); $result = $this->SoapEngine->soapclient->getRoutes($Query); if ($this->checkLogSoapError($result, true)) { return false; } else { $this->rows = $result->total; print <<< END
Id | Owner | Route | Carrier | Gateways | Prefix | Originator | Priority | Change date | Actions |
---|---|---|---|---|---|---|---|---|---|
%s | %s | %s | %s | Gateways | %s | %s | %s | %s | %s |
Create a carrier first"; return false; } printf( "
"; } function addRecord($dictionary = array()) { if ($dictionary['prefix']) { $prefix = $dictionary['prefix']; } else { $prefix = trim($_REQUEST['prefix']); } if ($dictionary['carrier_id']) { $carrier_id = $dictionary['carrier_id']; } else { $carrier_id = trim($_REQUEST['carrier_id']); } if ($dictionary['originator']) { $originator = $dictionary['originator']; } else { $originator = trim($_REQUEST['originator']); } if ($dictionary['priority']) { $priority = $dictionary['priority']; } else { $priority = trim($_REQUEST['priority']); } if (!strlen($carrier_id)) { printf("Error: Missing carrier id. "); return false; } $route = array( 'prefix' => $prefix, 'originator' => $originator, 'carrier_id' => intval($carrier_id), 'priority' => intval($priority) ); $routes = array($route); $function = array( 'commit' => array( 'name' => 'addRoutes', 'parameters' => array($routes), 'logs' => array('success' => sprintf('Route %s has been added', $prefix)) ) ); unset($this->filters); return $this->SoapEngine->execute($function, $this->html); } 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']; } else { $id = trim($this->filters['id']); } if (!strlen($id)) { print "
Error: missing route id. "; return false; } $route = array('id'=> intval($id)); $routes = array($route); $function = array( 'commit' => array( 'name' => 'deleteRoutes', 'parameters' => array($routes), 'logs' => array('success' => sprintf('Route %s has been deleted', $id)) ) ); unset($this->filters); return $this->SoapEngine->execute($function, $this->html); } function showSeachFormCustom() { printf( "
Updating route ..."; if (!$_REQUEST['id_filter']) return; if (!$route = $this->getRecord($_REQUEST['id_filter'])) { return false; } foreach (array_keys($this->Fields) as $item) { $var_name = $item.'_form'; if ($this->Fields[$item]['type'] == 'integer') { $route->$item = intval($_REQUEST[$var_name]); } else { $route->$item = trim($_REQUEST[$var_name]); } } $routes = array($route); $function = array( 'commit' => array( 'name' => 'updateRoutes', 'parameters' => array($routes), 'logs' => array('success' => sprintf('Route %d has been updated', $_REQUEST['id_filter'])) ) ); return (bool)$this->SoapEngine->execute($function, $this->html); } }