[Reorganize location and file names of ngnpro client Adrian Georgescu **20070918083325 ] hunk ./accounts.phtml 4 - "auth" => "CDRTool_Auth", - "perm" => "CDRTool_Perm") + "auth" => "CDRTool_Auth", + "perm" => "CDRTool_Perm") hunk ./accounts.phtml 30 +$soapFilter = $_REQUEST['soapFilter']; hunk ./accounts.phtml 114 + soapFilter = '%s', hunk ./accounts.phtml 127 + addslashes($soapFilter), hunk ./accounts.phtml 129 - hunk ./accounts.phtml 197 + $soapFilter = $db->f('soapFilter'); hunk ./accounts.phtml 243 + soapFilter, hunk ./accounts.phtml 263 + '%s', hunk ./accounts.phtml 283 + addslashes($soapFilter), hunk ./accounts_lib.phtml 102 +$f->add_element(array( "name"=>"soapFilter", + "type"=>"text", + "maxlength"=>"255", + "size"=>"60" + )); hunk ./accounts_lib.phtml 186 + "soapFilter", hunk ./accounts_lib.phtml 453 - print "Carrier codes"; - $f->show_element("cscodeFilter",""); + print "Soap engines"; + $f->show_element("soapFilter",""); hunk ./cdrlib_ser.phtml 4221 - include('soap_engines.inc'); + include_once('provisioning/ngnpro_engines.inc'); hunk ./cdrlib_ser.phtml 4226 - require_once("provisioning_lib.phtml"); + require_once("provisioning/ngnpro_client_lib.phtml"); hunk ./debian/changelog 52 - -- Adrian Georgescu Sat, 15 Sep 2007 12:15:04 +0200 + -- Adrian Georgescu Tue, 18 Sep 2007 10:33:16 +0200 hunk ./phplib/local.inc 247 + $CDRTool['filter']['soap'] = $this->db->f('soapFilter'); hunk ./phplib/local.inc 286 - "admin" => 1, - "callsearch" => 2, - "statistics" => 4, - "sqlquery" => 8, + "admin" => 1, + "callsearch" => 2, + "statistics" => 4, + "sqlquery" => 8, hunk ./phplib/local.inc 293 - "showPrice" => 128 + "showPrice" => 128, + "provisioning" => 256 hunk ./phplib/local.inc 620 + + if ($perm->have_perm("provisioning")) { + print " | Provisioning"; + } hunk ./provisioning.phtml 17 -//$perm->check("admin"); +$perm->check("provisioning"); hunk ./provisioning.phtml 19 -require_once("provisioning/provisioning_soap_library.phtml"); -require_once("provisioning/provisioning_logic.phtml"); +require_once("provisioning/ngnpro_soap_library.phtml"); +require_once("provisioning/ngnpro_client_lib.phtml"); +include_once("provisioning/ngnpro_engines.inc"); hunk ./provisioning.phtml 33 - 'loginType' => 'reseller' + 'loginType' => 'admin' hunk ./provisioning.phtml 41 +if (strlen($CDRTool['filter']['soap'])) { + $allowedEngines=explode(' ',trim($CDRTool['filter']['soap'])); + foreach(array_keys($soapEngines) as $_engine) { + foreach ($allowedEngines as $_allowed) { + if ($_engine == $_allowed) { + $soapEngines_checked[$_allowed]=$soapEngines[$_allowed]; + continue; + } + } + } + + $soapEngines=$soapEngines_checked; +} + +//print_r($loginCredentials); + addfile ./provisioning/ngnpro_client_lib.phtml hunk ./provisioning/ngnpro_client_lib.phtml 1 +recordGenerators = $recordGenerators; + $this->generatorId=$generatorId; + + $keys = array_keys($this->recordGenerators); + if (!$generatorId) $generatorId=$keys[0]; + + if (!in_array($generatorId,array_keys($this->recordGenerators))) { + return false; + } + + // sip zones + $sipEngine = $this->recordGenerators[$generatorId]['sipEngineId'].'@'.'SIP accounts'; + $this->SipSOAPEngine = new SOAPEngine($sipEngine,$soapEngines,$extraFormElements,$loginCredentials); + $_sip_class = $this->SipSOAPEngine->recordsClass; + $this->sipRecords = new $_sip_class(&$this->SipSOAPEngine); + $this->sipRecords->getAllowedDomains(); + + // enum mappings + $enumEngine = $this->recordGenerators[$generatorId]['enumEngineId'].'@'.'ENUM Numbers'; + $this->EnumSOAPEngine = new SOAPEngine($enumEngine,$soapEngines,$extraFormElements,$loginCredentials); + $_enum_class = $this->EnumSOAPEngine->recordsClass; + $this->enumRecords = new $_enum_class(&$this->EnumSOAPEngine); + $this->enumRecords->getAllowedDomains(); + } + + function generateRecords() { + print "

Generating records +

    "; + + if (!$this->checkGenerateRequest()) return false; + + $i=0; + + while ($i < $this->template['nr_records']) { + + $number = sprintf("%.0f", $this->start_padded + $i); + $username = substr($number,$this->template['strip_digits']); + $mapto = 'sip:'.$username.'@'.$this->template['domain']; + + print "
  1. "; + printf ('Generating number +%s with mapping %s ',$number,$mapto); + flush(); + + $enumMapping = array('tld' => $this->template['tld'], + 'number' => $number, + 'type' => 'sip', + 'mapto' => $mapto, + 'owner' => $this->template['owner'] + ); + + if ($this->template['create_sip']) { + $groups=array(); + if ($this->template['pstn']) $groups[]='free-pstn'; + printf ('and sip account %s@%s ',$username,$this->template['domain']); + + $sipAccount = array('account' => $username.'@'.$this->template['domain'], + 'owner' => $this->template['owner'], + 'quota' => $this->template['quota'], + 'prepaid' => $this->template['prepaid'], + 'password' => $this->template['password'], + 'groups' => $groups + ); + } else { + unset($sipAccount); + } + + if (is_array($enumMapping)) $this->enumRecords->addRecord($enumMapping); + if (is_array($sipAccount)) $this->sipRecords->addRecord($sipAccount); + + $i++; + } + + print "
"; + return true; + } + + function checkGenerateRequest() { + // check number of records + $this->template['create_sip']=trim($_REQUEST['create_sip']); + + $nr_records=trim($_REQUEST['nr_records']); + if (!is_numeric($nr_records) || $nr_records < 1 || $nr_records > 200) { + print "Error: number of records must be a number between 1 and 200."; + return false; + } + $this->template['nr_records'] = $nr_records; + + // length of generated record + $len=trim($_REQUEST['len']); + if (!is_numeric($len) || $len < 4 || $len > 15) { + print "Error: number length must be a number between 4 and 15."; + return false; + } + $this->template['len'] = $len; + + // sip domain + $domain=trim($_REQUEST['domain']); + if (!strlen($domain)) { + print "Error: SIP domain missing"; + return false; + } + $this->template['domain'] = $domain; + + $nr_start=trim($_REQUEST['nr_start']); + if (strlen($nr_start) && !is_numeric($nr_start)) { + print "Error: Use prefix must be numeric"; + return false; + } + $this->template['nr_start'] = $nr_start; + + // check ENUM TLD + list($prefix,$tld)=explode('@',trim($_REQUEST['range'])); + + $this->template['prefix'] = intval($prefix); + $this->template['tld'] = $tld; + $this->template['quota'] = intval($_REQUEST['quota']); + $this->template['owner'] = intval($_REQUEST['owner']); + $this->template['pstn'] = intval($_REQUEST['pstn']); + $this->template['prepaid'] = intval($_REQUEST['prepaid']); + $this->template['password'] = trim($_REQUEST['password']); + + /////////////////////////////////////// + // logical checks + if (strlen($this->template['nr_start'])) { + $start = $this->template['nr_start']; + } else { + $start = 0; + } + + $digits = $this->template['len']-strlen($this->template['prefix']); + $this->start_padded = $this->template['prefix'].str_pad($start,$digits,'0'); + $this->top = sprintf("%.0f", $this->start_padded + pow(10,$digits-strlen($this->template['nr_start']))); + $maxNumbers = pow(10,$digits-strlen($this->template['nr_start'])); + + if ($maxNumbers < $this->template['nr_records']) { + printf ("Error: Insufficient numbers in range, requested = %d, available = %d",$this->template['nr_records'],$maxNumbers); + return false; + } + + return true; + } + + function showGeneratorForm() { + if (!count($this->enumRecords->ranges)) return false; + print " +
+ + + + + + +
+ + + + +
+ + "; + print _("Record generator"); + print " + +
+
+ + + + + + "; + + print " + + + "; + + print " + + + + "; + + print " + + + + ",$_REQUEST['nr_start']); + print " + + + + + + "; + print " + + + + ",$_REQUEST['strip_digits']); + print " + + + "; + + if (count($this->sipRecords->allowedDomains)) { + print " + + + + "; + + print " + + + + "; + + print " + + + + ",$checked_create_sip); + + if ($_REQUEST['pstn']) { + $checked_pstn='checked'; + } else { + $checked_pstn=''; + } + + print " + + + + ",$checked_pstn); + + if ($_REQUEST['prepaid']) { + $checked_prepaid='checked'; + } else { + $checked_prepaid=''; + } + + print " + + + + ",$checked_prepaid); + + print " + + + + ",$_REQUEST['rpid_prefix']); + + print " + + + + ",$_REQUEST['quota']); + + print " + + + + ",$_REQUEST['password']); + + print " + + + + "; + print " + + + "; + + print " + + + + "; + } + + $this->printHiddenFormElements(); + + print " +
+
"; + print _("Range"); + print " + "; + + if (is_array($this->enumRecords->ranges)) { + print ""; + } + + print " +
+ "; + print ""; + print _("ENUM mapping template"); + print ""; + print "
"; + print _("Use prefix:"); + printf (" + + +
"; + print _("Number length:"); + printf (" + + +
+ ",$_REQUEST['len']); + + print _("SIP domain"); + print " + + "; + if (count($this->sipRecords->allowedDomains)) { + print " + "; + } else { + print ""; + } + + print " + "; + print " +
"; + print _("Strip from username"); + printf (" + first + digits +
"; + print _("Owner"); + printf (" + + ",$_REQUEST['owner']); + print " +

+
+ "; + print ""; + print _("SIP account template"); + print ""; + print "
"; + print _("Create SIP records"); + if ($_REQUEST['create_sip']) { + $checked_create_sip='checked'; + } else { + $checked_create_sip=''; + } + printf (" + +
"; + print _("PSTN"); + printf (" + +
"; + print _("Prepaid"); + printf (" + +
"; + print _("Prefix Caller-ID"); + printf (" + +
"; + print _("Quota"); + printf (" + +
"; + print _("Password"); + printf (" + +
+
+
+ "; + + if ($_REQUEST['nr_records']) { + $nr_records=$_REQUEST['nr_records']; + } else { + $nr_records=1; + } + print ""; + print ""; + printf (" + + ",$nr_records); + print _("records"); + print ""; + print " +
+
+ +

"; + print _("Existing records will not be overwritten. "); + print "

+ +
+ "; + } + + function printHiddenFormElements () { + printf("",$this->generatorId); + + if ($this->adminonly) { + printf("",$this->adminonly); + } + + foreach (array_keys($this->extraFormElements) as $element) { + if (!strlen($this->extraFormElements[$element])) continue; + printf ("\n",$element,$this->extraFormElements[$element]); + } + + } + +} + +class SOAPEngine { + var $version = 1; + var $adminonly = 0; + var $reseller = 0; + var $loginType = 'reseller'; + + var $services=array( + 'SIP accounts' => array('recordsClass' => 'SipAccounts', + 'soapClass' => 'WebService_NGNPro_SipPort' + ), + 'SIP Aliases' => array('recordsClass' => 'SipAliases', + 'soapClass' => 'WebService_NGNPro_SipPort' + ), + 'SIP Domains' => array('recordsClass' => 'Domains', + 'soapClass' => 'WebService_NGNPro_SipPort' + ), + 'ENUM Numbers' => array('recordsClass' => 'EnumMappings', + 'soapClass' => 'WebService_NGNPro_EnumPort' + ), + 'ENUM Ranges' => array('recordsClass' => 'EnumRanges', + 'soapClass' => 'WebService_NGNPro_EnumPort' + ), + 'Customers' => array('recordsClass' => 'Customers', + 'soapClass' => 'WebService_NGNPro_CustomerPort' + ), + 'Trusted Peers' => array('recordsClass' => 'TrustedPeers', + 'soapClass' => 'WebService_NGNPro_SipPort' + ), + 'PSTN Gateways' => array('recordsClass' => 'Gateways', + 'soapClass' => 'WebService_NGNPro_NetworkPort' + ), + 'Gateway groups' => array('recordsClass' => 'GatewayGroups', + 'soapClass' => 'WebService_NGNPro_NetworkPort' + ), + 'PSTN Routes' => array('recordsClass' => 'Routes', + 'soapClass' => 'WebService_NGNPro_NetworkPort' + ) + ); + + function SOAPEngine($service,$soapEngines,$extraFormElements,$loginCredentials) { + + /* + $soapEngines=array( + 'mdns' => array('name'=> 'Managed DNS', + 'username'=> 'soapadmin', + 'password'=> 'passwd', + 'url' => 'http://example.com:9200/', + 'impersonate' => 1745 + ), + */ + + + $this->loginCredentials = $loginCredentials; + + if ($this->loginCredentials['loginType'] == 'admin') $this->adminonly = 1; + + $this->soapEngines = $soapEngines; + + if (is_array($this->soapEngines)) { + + if (!$service) { + $_services = array_keys($this->services); + $_soapids = array_keys($this->soapEngines); + $service = $_soapids[0].'@'.$_services[0]; + } + + if (is_array($extraFormElements)) { + $this->extraFormElements = $extraFormElements; + } + + $this->service = $service; + + $_els=explode('@',$this->service); + + $this->soapEngineId = $_els[0]; + $this->soapEngineIdSettingsPage=$this->soapEngineId; + + $this->soapEnginePort = $_els[1]; + $this->recordsClass = $this->services[$this->soapEnginePort]['recordsClass']; + $this->soapClass = $this->services[$this->soapEnginePort]['soapClass']; + + foreach(array_keys($this->soapEngines) as $_key ) { + $this->skipServices[$_key]=$this->soapEngines[$_key]['skipServices']; + $this->skip[$_key]=$this->soapEngines[$_key]['skip']; + } + + if (strlen($this->soapEngines[$this->soapEngineId]['version'])) { + $this->version = $this->soapEngines[$this->soapEngineId]['version']; + } + + $this->defaultEnumTLD = $this->soapEngines[$this->soapEngineId]['defaultEnumTLD']; + + if (strlen($this->soapEngines[$this->soapEngineId]['soapEngineIdSettingsPage'])) { + $this->soapEngineIdSettingsPage=$this->soapEngines[$this->soapEngineId]['soapEngineIdSettingsPage']; + } + + if (strlen($this->soapEngines[$this->soapEngineId]['SipSettingsPage'])) { + $this->SipSettingsPage=$this->soapEngines[$this->soapEngineId]['SipSettingsPage']; + } + + if (strlen($this->soapEngines[$this->soapEngineId]['recordGenerator'])) { + $this->recordGenerator=$this->soapEngines[$this->soapEngineId]['recordGenerator']; + } + + if (strlen($loginCredentials['reseller'])) { + $this->reseller = $loginCredentials['reseller']; + } else if ($this->adminonly && $_REQUEST['reseller_filter']){ + $this->reseller = $_REQUEST['reseller_filter']; + } + + if (strlen($loginCredentials['customer'])) { + $this->customer = $loginCredentials['customer']; + } else if ($this->adminonly && $_REQUEST['customer_filter']){ + $this->customer = $_REQUEST['customer_filter']; + } + + if (strlen($loginCredentials['soapUsername'])) { + $this->soapUsername=$loginCredentials['soapUsername']; + } else if ($this->adminonly) { + $this->soapUsername=$this->soapEngines[$this->soapEngineId]['username']; + } + + //print_r($loginCredentials); + if (strlen($loginCredentials['soapUsername'])) { + $this->SOAPlogin = array( + "username" => $this->soapUsername, + "password" => $loginCredentials['soapPassword'], + "admin" => false + ); + } else { + $this->SOAPlogin = array( + "username" => $this->soapUsername, + "password" => $this->soapEngines[$this->soapEngineId]['password'], + "admin" => true, + "impersonate" => intval($this->reseller) + ); + } + + $this->SOAPurl=$this->soapEngines[$this->soapEngineId]['url']; + printf ("

Connection to %s at %s as %s/%s ",$this->soapClass,$this->SOAPurl,$this->SOAPurl,$this->soapUsername,$this->reseller); + $this->SoapAuth = array('auth', $this->SOAPlogin , 'urn:AGProjects:NGNPro', 0, ''); + + // Instantiate the SOAP client + if (!class_exists($this->soapClass)) return ; + + $this->soapclient = new $this->soapClass($this->SOAPurl); + + $this->soapclient->setOpt('curl', CURLOPT_TIMEOUT, 5); + $this->soapclient->setOpt('curl', CURLOPT_SSL_VERIFYPEER, 0); + $this->soapclient->setOpt('curl', CURLOPT_SSL_VERIFYHOST, 0); + + $this->soapRemoteId=$this->soapEngines[$this->soapEngineId]['depends']; + + if (strlen($this->soapRemoteId) && in_array($this->soapRemoteId,array_keys($this->soapEngines))) { + $this->soapEngineIdRemote = $this->soapEngines[$this->soapRemoteId]; + $impersonateRemote=intval($this->soapEngines[$this->soapRemoteId]['impersonate']); + + $this->SOAPloginRemote = array( + "username" => $this->soapEngines[$this->soapRemoteId]['username'], + "password" => $this->soapEngines[$this->soapRemoteId]['password'], + "admin" => true, + "impersonate" => $impersonateRemote + ); + + //print_r($this->SOAPloginRemote); + $this->SOAPurlRemote=$this->soapEngines[$this->soapRemoteId]['url']; + //printf ("and syncronize writes at %s",$this->SOAPurlRemote,$this->SOAPurlRemote); + + $this->SoapAuthRemote = array('auth', $this->SOAPloginRemote , 'urn:AGProjects:NGNPro', 0, ''); + + // Instantiate the SOAP client depends + $this->soapclientRemote = new $this->soapClass($this->SOAPurlRemote); + + $this->soapclientRemote->setOpt('curl', CURLOPT_TIMEOUT, 5); + $this->soapclientRemote->setOpt('curl', CURLOPT_SSL_VERIFYPEER, 0); + $this->soapclientRemote->setOpt('curl', CURLOPT_SSL_VERIFYHOST, 0); + } + + if ($this->version > 1) { + $this->soapclientCustomers = new WebService_NGNPro_CustomerPort($this->SOAPurl); + $this->soapclientCustomers->setOpt('curl', CURLOPT_TIMEOUT, 5); + $this->soapclientCustomers->setOpt('curl', CURLOPT_SSL_VERIFYPEER, 0); + $this->soapclientCustomers->setOpt('curl', CURLOPT_SSL_VERIFYHOST, 0); + } + + } else { + print "Error: No SOAP credentials defined."; + } + + $this->url = $_SERVER['PHP_SELF']."?1=1"; + + foreach (array_keys($this->extraFormElements) as $element) { + if (!strlen($this->extraFormElements[$element])) continue; + $this->url .= sprintf('&%s=%s',$element,urlencode($this->extraFormElements[$element])); + } + } + + function execute($function) { + + /* + $function=array('commit' => array('name' => 'addAccount', + 'parameters' => array($param1,$param2), + 'logs' => array('success' => 'The function was a success', + 'failure' => 'The function has failed' + ) + ), + 'rollback' => array('name' => 'addAccount', + 'parameters' => array($param1,$param2), + 'logs' => array('success' => 'The function was a success', + 'failure' => 'The function has failed' + ) + ) + + ); + */ + + if (!$function['commit']['name']) { + print "Error: no function name supplied"; + return false; + } + + if (is_object($this->soapclientRemote)) { + + $this->soapclientRemote->addHeader($this->SoapAuthRemote); + + $resultRemote = call_user_func_array(array($this->soapclientRemote,$function['commit']['name']),$function['commit']['parameters']); + + if (PEAR::isError($resultRemote)) { + $error_msg = $resultRemote->getMessage(); + $error_fault = $resultRemote->getFault(); + $error_code = $resultRemote->getCode(); + printf ("

Error from %s: %s (%s): %s",$this->SOAPurlRemote,$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); + return false; + } else { + printf ("

%s %s ",$function['commit']['logs']['success'],$this->SOAPurlRemote); + + $this->soapclient->addHeader($this->SoapAuth); + $result = call_user_func_array(array($this->soapclient,$function['commit']['name']),$function['commit']['parameters']); + + if (PEAR::isError($result)) { + $error_msg = $result->getMessage(); + $error_fault = $result->getFault(); + $error_code = $result->getCode(); + printf ("

Error from %s: %s (%s): %s",$this->SOAPurl,$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); + + if ($function['rollback']['name']) { + + $this->soapclientRemote->addHeader($this->SoapAuthRemote); + $this->counterRemote++; + + $resultRemote = call_user_func_array(array($this->soapclientRemote,$function['rollback']['name']),$function['rollback']['parameters']); + + if (PEAR::isError($result)) { + $error_msg=$result->getMessage(); + $error_fault=$result->getFault(); + $error_code=$result->getCode(); + printf ("

Error roll back at %s: %s (%s): %s",$this->SOAPurl,$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); + } else { + printf ("

Rolled back action at %s ",$this->SOAPurlRemote); + } + } + + return false; + } else { + if ($function['commit']['logs']['success']) { + printf ("

%s %s ",$function['commit']['logs']['success'],$this->SOAPurl); + } + } + } + + } else { + + $this->soapclient->addHeader($this->SoapAuth); + $result = call_user_func_array(array($this->soapclient,$function['commit']['name']),$function['commit']['parameters']); + + if (PEAR::isError($result)) { + $error_msg = $result->getMessage(); + $error_fault = $result->getFault(); + $error_code = $result->getCode(); + printf ("

Error from %s: %s (%s): %s",$this->SOAPurl,$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); + return false; + } else { + if ($function['commit']['logs']['success']) { + printf ("

%s ",$function['commit']['logs']['success']); + } + } + } + + return true; + } +} + +class Records { + var $maxrowsperpage = '15'; + var $SipSettingsPage = 'sip_settings.phtml'; + var $allowedDomains = false; + var $selectionActive = false; + var $selectionKeys = array(); + var $resellers = array(); + var $customers = array(); + var $recordGenerator = false; + + function Records(&$SOAPEngine) { + $this->SOAPEngine = &$SOAPEngine; + $this->version = &$this->SOAPEngine->version; + $this->loginCredentials = &$this->SOAPEngine->loginCredentials; + + $this->sorting['sortBy'] = trim($_REQUEST['sortBy']); + $this->sorting['sortOrder'] = trim($_REQUEST['sortOrder']); + + $this->next = $_REQUEST['next']; + + $this->adminonly = $this->SOAPEngine->adminonly; + $this->reseller = $this->SOAPEngine->reseller; + $this->url = $this->SOAPEngine->url; + + foreach(array_keys($this->filters) as $_filter) { + if (strlen($this->filters[$_filter])) { + $this->selectionActive=true; + break; + } + } + + if ($this->adminonly) { + $this->url .= sprintf('&adminonly=%s',$this->adminonly); + if ($this->loginCredentials['reseller']) { + $this->filters['reseller']=$this->loginCredentials['reseller']; + } else { + $this->filters['reseller']=trim($_REQUEST['reseller_filter']); + } + } + + if ($this->loginCredentials['customer']) { + $this->filters['customer'] = $this->loginCredentials['customer']; + } else { + $this->filters['customer'] = trim($_REQUEST['customer_filter']); + } + + $this->getResellers(); + $this->getCustomers(); + + if (strlen($this->SOAPEngine->SipSettingsPage)) $this->SipSettingsPage=$this->SOAPEngine->SipSettingsPage; + } + + function showEngineSelection() { + $selected_soapEngine[$this->SOAPEngine->service]='selected'; + + printf (""); + + if ($this->version > 1) { + print "Customer"; + + if ($this->adminonly) { + $this->showResellerForm(); + if ($this->filters['reseller']) { + print "."; + $this->showCustomerForm(); + } + } else { + printf ("%s",$this->reseller); + print "."; + $this->showCustomerForm(); + } + } + } + + + function showPagination($maxrows) { + + $url .= $this->url.'&'.$this->addFiltersToURL(). + sprintf("&service=%s&sortBy=%s&sortOrder=%s", + urlencode($this->SOAPEngine->service), + urlencode($this->sorting['sortBy']), + urlencode($this->sorting['sortOrder']) + ); + + print " +

+ + + + + +
+ "; + + if ($this->next != 0 ) { + $show_next=$this->maxrowsperpage-$this->next; + if ($show_next < 0) { + $mod_show_next = $show_next-2*$show_next; + } + if (!$mod_show_next) $mod_show_next=0; + + if ($mod_show_next/$this->maxrowsperpage >= 1) { + printf ("Begin ",$url); + } + + printf ("Previous ",$url,$mod_show_next); + } + + print " + + "; + + if ($this->next + $this->maxrowsperpage < $this->rows) { + $show_next = $this->maxrowsperpage + $this->next; + printf ("Next ",$url,$show_next); + } + + print " +
+ "; + } + + function showSeachFormCustom() { + } + + function showSeachForm() { + print " +

+ + + "; + printf ("",$_SERVER['PHP_SELF']); + print " + + + + +
+ "; + $this->showEngineSelection(); + + $this->showSeachFormCustom(); + + print " + + "; + $this->showSortForm(); + + print " + + "; + $this->printHiddenFormElements(); + + print " +
+ "; + + if ($_REQUEST['action'] != 'Delete') $this->showAddForm(); + } + + function listRecords() { + } + + function getRecordKeys() { + } + + function addRecord() { + } + + function deleteRecord() { + } + + function tel2enum($tel,$tld) { + + if (strlen($tld) == 0) $tld="e164.arpa"; + + // transform telephone number in FQDN Enum style domain name + if (preg_match("/^[+]?(\d+)$/",$tel,$m)) { + $l=strlen($m[1]); + $rev_num=""; + $z=0; + while ($z < $l) { + $ss=substr($m[1],$z,1); + $enum=$ss.".".$enum; + $z++; + } + preg_match("/^(.*)\.$/",$enum,$m); + $enum=$m[1]; + $enum=$enum.".$tld."; + return($enum); + } else { + return($tel); + } + } + + function showAddForm() { + if ($this->selectionActive) return; + } + + function showSortForm() { + + if (!count($this->sortElements)) { + return; + } + + $selected_sortBy[$this->sorting['sortBy']]='selected'; + + //print " Sort "; + + print ""; + + $selected_sortOrder[$this->sorting['sortOrder']]='selected'; + print ""; + } + + function showTimezones() { + if (!$fp = fopen("timezones", "r")) { + print _("Failed to open timezone file."); + return false; + } + print ""; + fclose($fp); + + } + + function printHiddenFormElements () { + printf("",$this->SOAPEngine->service); + + if ($this->adminonly) { + printf("",$this->adminonly); + } + + foreach (array_keys($this->SOAPEngine->extraFormElements) as $element) { + if (!strlen($this->SOAPEngine->extraFormElements[$element])) continue; + printf ("\n",$element,$this->SOAPEngine->extraFormElements[$element]); + } + + } + + function getAllowedDomains() { + } + + + function showActionsForm() { + if (!$this->selectionActive) { + return; + } + + $class_name=get_class($this).'Actions'; + + if (class_exists($class_name)) { + $actions=new $class_name(&$this->SOAPEngine); + $actions->showActionsForm($this->filters,$this->sorting); + } + } + + function performActions() { + $this->showSeachForm(); + + $this->getRecordKeys(); + //print_r($this->selectionKeys); + + $class_name=get_class($this).'Actions'; + + if (class_exists($class_name)) { + $actions=new $class_name(&$this->SOAPEngine); + $actions->performActions(&$this->selectionKeys,$_REQUEST['sub_action'],trim($_REQUEST['sub_action_parameter'])); + } + } + + function getCustomers() { + if (!$this->version <= 1 ) return; + + if (!$this->filters['reseller']) { + return; + } + + // Filter + $filter=array('reseller'=>intval($this->filters['reseller'])); + + $range=array('start' => 0, + 'count' => 100 + ); + + // Order + $orderBy = array('attribute' => 'customer', + 'direction' => 'ASC' + ); + + // Compose query + $Query=array('filter' => $filter, + 'orderBy' => $orderBy, + 'range' => $range + ); + + // Insert credetials + $this->SOAPEngine->soapclientCustomers->addHeader($this->SOAPEngine->SoapAuth); + + // Call function + $result = $this->SOAPEngine->soapclientCustomers->getCustomers($Query); + + if (PEAR::isError($result)) { + $error_msg = $result->getMessage(); + $error_fault= $result->getFault(); + $error_code = $result->getCode(); + printf ("

Error from %s: %s (%s): %s",$this->SOAPEngine->SOAPurl,$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); + return false; + } else { + + if ($result->total > $range['count']) return; + + if ($range['count'] <= $result->total) { + $max=$range['count']; + } else { + $max=$result->total; + } + + $i=0; + while ($i < $max) { + $customer=$result->accounts[$i]; + $this->customers[$customer->id] = $customer->firstName.' '.$customer->lastName; + $i++; + } + return true; + } + } + + function getResellers() { + if (!$this->version <= 1 ) return; + if (!$this->adminonly) { + return; + } + // Filter + $filter=array('reseller'=>intval($this->filters['reseller'])); + + $range=array('start' => 0, + 'count' => 200 + ); + + // Order + $orderBy = array('attribute' => 'customer', + 'direction' => 'ASC' + ); + + // Compose query + $Query=array('filter' => $filter, + 'orderBy' => $orderBy, + 'range' => $range + ); + + // Insert credetials + $this->SOAPEngine->soapclientCustomers->addHeader($this->SOAPEngine->SoapAuth); + + // Call function + $result = $this->SOAPEngine->soapclientCustomers->getResellers($Query); + + if (PEAR::isError($result)) { + $error_msg = $result->getMessage(); + $error_fault= $result->getFault(); + $error_code = $result->getCode(); + printf ("

Error from %s: %s (%s): %s",$this->SOAPEngine->SOAPurl,$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); + return false; + } else { + + //if ($result->total > $range['count']) return; + + if ($range['count'] <= $result->total) { + $max=$range['count']; + } else { + $max=$result->total; + } + + $i=0; + while ($i < $max) { + $reseller = $result->accounts[$i]; + + if (strlen($reseller->organization) && $reseller->organization!= 'N/A') { + $this->resellers[$reseller->id] = $reseller->organization; + } else { + $this->resellers[$reseller->id] = $reseller->firstName.' '.$reseller->lastName; + } + $i++; + } + + //print_r($this->resellers); + return true; + } + } + + function showCustomerForm($name='customer_filter') { + if ($this->loginCredentials['customer']) { + printf (" %s",$this->loginCredentials['customer']); + } else { + if (count($this->customers)) { + $select_customer[$this->filters['customer']]='selected'; + printf (""; + } else { + printf ("",$name,$this->filters['customer']); + } + } + } + + function showResellerForm($name='reseller_filter') { + if (!$this->adminonly) return; + if ($this->loginCredentials['reseller']) { + printf (" %s",$this->loginCredentials['reseller']); + } else { + if (count($this->resellers)) { + $select_reseller[$this->filters['reseller']]='selected'; + printf (""; + } else { + printf ("",$name,$this->filters['reseller']); + } + } + } + + function addFiltersToURL() { + + $j=0; + foreach(array_keys($this->filters) as $filter) { + if (strlen(trim($this->filters[$filter]))) { + if ($j) $url .='&'; + $url .= sprintf('%s_filter=%s',$filter,urlencode(trim($this->filters[$filter]))); + } + $j++; + } + + return $url; + } + + function printFiltersToForm() { + foreach(array_keys($this->filters) as $filter) { + if (strlen(trim($this->filters[$filter]))) { + printf("",$filter,trim($this->filters[$filter])); + } + } + } + + function getRecord () { + } + + function updateRecord () { + } + + function showRecord () { + } + +} + +class Domains extends Records { + + function Domains(&$SOAPEngine) { + + $this->Records(&$SOAPEngine); + + if ($this->version > 1) { + // keep default maxrowsperpage + $this->sortElements=array('changeDate' => 'Change date', + 'domain' => 'Domain' + ); + + $this->filters = array( + 'domain' => trim($_REQUEST['domain_filter']) + ); + + } else { + $this->maxrowsperpage = 10000; + } + } + + function listRecords() { + + $this->showSeachForm(); + + if ($this->version > 1) { + + // Filter + $filter=array( + 'domain' => $this->filters['domain'], + '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); + + // Call function + $result = $this->SOAPEngine->soapclient->getDomains($Query); + } else { + // Insert credetials + $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); + + // Call function + $result = $this->SOAPEngine->soapclient->getDomains(); + } + + if (PEAR::isError($result)) { + $error_msg = $result->getMessage(); + $error_fault= $result->getFault(); + $error_code = $result->getCode(); + printf ("

Error from %s: %s (%s): %s",$this->SOAPEngine->SOAPurl,$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); + return false; + } else { + + if ($this->version > 1) { + $this->rows = $result->total; + } else { + $this->rows = count($result); + } + + if ($this->rows && $_REQUEST['action'] != 'PerformActions' && $_REQUEST['action'] != 'Delete') { + $this->showActionsForm(); + } + + print " + + +
$this->rows records found
+

+ + + "; + print" + + + + + "; + + if (!$this->next) $this->next=0; + + if ($this->rows > $this->maxrowsperpage) { + $maxrows = $this->maxrowsperpage + $this->next; + if ($maxrows > $this->rows) $maxrows = $this->maxrowsperpage; + } else { + $maxrows=$this->rows; + } + + $i=0; + + if ($this->rows) { + while ($i < $maxrows) { + + if ($this->version > 1) { + if (!$result->domains[$i]) break; + $domain = $result->domains[$i]; + } else { + $domain = $result[$i]; + } + + $index = $this->next+$i+1; + + $rr=floor($index/2); + $mod=$index-$rr*2; + + if ($mod ==0) { + $bgcolor="lightgrey"; + } else { + $bgcolor="white"; + } + + if ($this->version > 1) { + $_url = $this->url.sprintf("&service=%s&action=Delete&domain_filter=%s", + urlencode($this->SOAPEngine->service), + urlencode($domain->domain) + ); + + if ($_REQUEST['action'] == 'Delete' && + $_REQUEST['domain_filter'] == $domain->domain) { + $_url .= "&confirm=1"; + $actionText = "Confirm"; + } else { + $actionText = "Delete"; + } + + $_customer_url = $this->url.sprintf("&service=%s@Customers&customer_filter=%s", + urlencode($this->SOAPEngine->soapEngineId), + urlencode($domain->customer) + ); + + printf(" + + + + + + + ", + $bgcolor, + $index, + $_customer_url, + $domain->reseller, + $domain->customer, + $domain->domain, + $domain->changeDate, + $_url, + $actionText + ); + } else { + $_url = $this->url.sprintf("&service=%s&action=Delete&domain_filter=%s", + urlencode($this->SOAPEngine->service), + urlencode($domain) + ); + + if ($_REQUEST['action'] == 'Delete' && + $_REQUEST['domain_filter'] == $domain) { + $_url .= "&confirm=1"; + $actionText = "Confirm"; + } else { + $actionText = "Delete"; + } + printf(" + + + + + + ", + $bgcolor, + $index, + $domain, + $domain->changeDate, + $_url, + $actionText + ); + } + + $i++; + } + } + + print "
Id + "; + if ($this->version > 1) print "CustomerDomainLast changeAction
%s%s.%s%s%s%s
%s%s%s%s
"; + + if ($this->version > 1) { + $this->showPagination($maxrows); + } + + return true; + } + } + + function showSeachFormCustom() { + + if ($this->version > 1) { + printf (" Domain",$this->filters['domain']); + } + } + + function deleteRecord() { + if (!$_REQUEST['confirm']) { + print "

Please press on Confirm to confirm the delete. "; + return 1; + } + + if (!strlen($this->filters['domain']) || !strlen($this->filters['domain'])) { + print "

Error: missing SIP domain. "; + return 0; + } + + $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); + + $result = $this->SOAPEngine->soapclient->deleteDomain($this->filters['domain']); + + if (PEAR::isError($result)) { + $error_msg = $result->getMessage(); + $error_fault= $result->getFault(); + $error_code = $result->getCode(); + printf ("

Error from %s: %s (%s): %s",$this->SOAPEngine->SOAPurl,$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); + return false; + } else { + printf ("

SIP domain %s has been deleted. ",$this->filters['domain']); + unset($this->filters); + return 1; + } + } + + function showAddForm() { + if ($this->selectionActive) return; + print " +

+ + + "; + printf ("",$_SERVER['PHP_SELF']); + print " + + + "; + $this->printHiddenFormElements(); + + print " + + +
+ "; + + print " + + "; + + printf (" Domain"); + + print "Customer"; + + if ($this->adminonly) { + $this->showResellerForm('reseller'); + print "."; + $this->showCustomerForm('customer'); + } else { + $this->showCustomerForm('customer'); + } + + print " + + "; + print " +
+ "; + } + + function addRecord() { + + $domain = trim($_REQUEST['domain']); + + if ($this->adminonly) { + $reseller = trim($_REQUEST['reseller']); + $customer = trim($_REQUEST['customer']); + } else { + $reseller = $this->reseller; + $customer = trim($_REQUEST['customer']); + if (!$customer) $customer=$reseller; + } + + $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); + + if ($this->version >1 ) { + $domainStructure=array('domain' => $domain, + 'customer' => intval($customer), + 'reseller' => intval($reseller) + ); + $result = $this->SOAPEngine->soapclient->addDomain($domainStructure); + } else { + $result = $this->SOAPEngine->soapclient->addDomain($domain); + } + + if (PEAR::isError($result)) { + $error_msg = $result->getMessage(); + $error_fault= $result->getFault(); + $error_code = $result->getCode(); + printf ("

Error from %s: %s (%s): %s",$this->SOAPEngine->SOAPurl,$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); + return false; + } else { + printf ("

SIP domain %s has been added. ",$domain); + return true; + } + } + + function getRecordKeys() { + + if ($this->version > 1) { + // Filter + $filter=array( + 'domain' => $this->filters['domain'], + '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 + ); + + $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); + $result = $this->SOAPEngine->soapclient->getDomains($Query); + + } else { + $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); + $result = $this->SOAPEngine->soapclient->getDomains(); + } + + if (PEAR::isError($result)) { + $error_msg = $result->getMessage(); + $error_fault= $result->getFault(); + $error_code = $result->getCode(); + printf ("

Error in getAllowedDomains from %s: %s (%s): %s",$this->SOAPEngine->SOAPurl,$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); + //return false; + } else { + if ($this->version > 1) { + foreach ($result->domains as $_domain) { + $this->selectionKeys[]=$_domain->domain; + } + } else { + $this->selectionKeys[]=$result; + } + } + } + +} + +class SIPAccounts extends Records { + var $sortElements=array('changeDate' => 'Change date', + 'username' => 'Username', + 'domain' => 'Domain' + ); + + function SIPAccounts(&$SOAPEngine) { + $this->filters = array('username' => trim($_REQUEST['username_filter']), + 'domain' => trim($_REQUEST['domain_filter']), + 'fullname' => trim($_REQUEST['fullname_filter']) + ); + + $this->Records(&$SOAPEngine); + + } + + function getRecordKeys() { + + if (preg_match("/^(.*)@(.*)$/",$this->filters['username'],$m)) { + $this->filters['username'] = $m[1]; + $this->filters['domain'] = $m[2]; + } + + // Filter + $filter=array('username' => $this->filters['username'], + 'domain' => $this->filters['domain'], + 'name' => $this->filters['fullname'], + '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); + + // Call function + $result = $this->SOAPEngine->soapclient->getAccounts($Query); + + if (PEAR::isError($result)) { + $error_msg = $result->getMessage(); + $error_fault= $result->getFault(); + $error_code = $result->getCode(); + printf ("

Error from %s: %s (%s): %s",$this->SOAPEngine->SOAPurl,$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); + return false; + } else { + foreach ($result->accounts as $account) { + $this->selectionKeys[]=array('username' => $account->id->username, + 'domain' => $account->id->domain + ); + } + + return true; + } + + return false; + } + + function listRecords() { + + $this->getAllowedDomains(); + + if (preg_match("/^(.*)@(.*)$/",$this->filters['username'],$m)) { + $this->filters['username'] = $m[1]; + $this->filters['domain'] = $m[2]; + } + + $this->showSeachForm(); + + // Filter + $filter=array('username' => $this->filters['username'], + 'domain' => $this->filters['domain'], + 'name' => $this->filters['fullname'], + '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); + + // Call function + $result = $this->SOAPEngine->soapclient->getAccounts($Query); + + if (PEAR::isError($result)) { + $error_msg = $result->getMessage(); + $error_fault= $result->getFault(); + $error_code = $result->getCode(); + printf ("

Error from %s: %s (%s): %s",$this->SOAPEngine->SOAPurl,$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); + return false; + } else { + + $this->rows = $result->total; + + if ($this->rows && $_REQUEST['action'] != 'PerformActions' && $_REQUEST['action'] != 'Delete') { + $this->showActionsForm(); + } + + print " +

+ + +
$this->rows records found
+

+ + + "; + print" + + + + + + + + + + + "; + + if (!$this->next) $this->next=0; + + if ($this->rows > $this->maxrowsperpage) { + $maxrows = $this->maxrowsperpage + $this->next; + if ($maxrows > $this->rows) $maxrows = $this->maxrowsperpage; + } else { + $maxrows=$this->rows; + } + + $i=0; + + //print "
";
+            //print_r($result->accounts);
+
+			if ($this->rows) {
+                while ($i < $maxrows)  {
+    
+                    if (!$result->accounts[$i]) break;
+    
+                    $account = $result->accounts[$i];
+    
+                    $index=$this->next+$i+1;
+    
+                    $rr=floor($index/2);
+                    $mod=$index-$rr*2;
+            
+                    if ($mod ==0) {
+                    	$bgcolor="lightgrey";
+                    } else {
+                        $bgcolor="white";
+                    }
+
+        			$_url = $this->url.sprintf("&service=%s&action=Delete&username_filter=%s&domain_filter=%s",
+                    urlencode($this->SOAPEngine->service),
+                    urlencode($account->id->username),
+                    urlencode($account->id->domain)
+                    );
+
+                    if ($_REQUEST['action'] == 'Delete' &&
+                    	$_REQUEST['username_filter'] == $account->id->username &&
+                        $_REQUEST['domain_filter'] == $account->id->domain) {
+                		$_url .= "&confirm=1";
+                        $actionText = "Confirm";
+                    } else {
+                        $actionText = "Delete";
+                    }
+
+					if ($account->reseller) {
+                    	$resellerSipSettingsPage=$account->reseller;
+                    } else {
+                    	$resellerSipSettingsPage=$this->reseller;
+                    }
+
+                    if ($this->SipSettingsPage) {
+                        $url=sprintf('%s?account=%s@%s&reseller=%s&soapEngineIdSipPort=%s',
+                        $this->SipSettingsPage,$account->id->username,$account->id->domain,
+                        $resellerSipSettingsPage,$this->SOAPEngine->soapEngineIdSettingsPage);
+
+                        if ($this->adminonly) $url  .= sprintf('&adminonly=%s',$this->adminonly);
+
+                        foreach (array_keys($this->SOAPEngine->extraFormElements) as $element) {
+                            if (!strlen($this->SOAPEngine->extraFormElements[$element])) continue;
+                            $url  .= sprintf('&%s=%s',$element,urlencode($this->SOAPEngine->extraFormElements[$element]));
+                        }
+
+                        $sip_account=sprintf("
+                        
+                        %s@%s",$url,$account->id->username,$account->id->domain);
+                    } else {
+						$sip_account=sprintf("%s@%s",$account->id->username,$account->id->domain);
+                    }
+
+
+                    unset($groups);
+                    foreach ($account->groups as $_grp) $groups.=$_grp.' ';
+
+                    if ($this->version > 1) {
+        			$_customer_url = $this->url.sprintf("&service=%s@Customers&customer_filter=%s",
+                    urlencode($this->SOAPEngine->soapEngineId),
+                    urlencode($account->customer)
+                    );
+
+
+                    printf("
+                    
+ + + + + + + + + + + + + ", + $bgcolor, + $index, + $_customer_url, + $account->reseller, + $account->customer, + $sip_account, + $account->firstName, + $account->lastName, + $account->email, + $account->email, + $account->rpid, + $account->quota, + $groups, + $account->changeDate, + $account->owner, + $_url, + $actionText + ); + } else { + printf(" + + + + + + + + + + + + + ", + $bgcolor, + $index, + $sip_account, + $account->firstName, + $account->lastName, + $account->email, + $account->email, + $account->rpid, + $account->quota, + $groups, + $account->changeDate, + $account->owner, + $_url, + $actionText + ); + } + + $i++; + } + + } + + print "
Id + "; + if ($this->version > 1) print "CustomerSIP accountNameEmailCaller IdQuotaGroupsLast changeOwnerAction
%s %s.%s%s%s %s%s%s%s%s%s%s%s
%s %s%s %s%s%s%s%s%s%s%s
"; + + $this->showPagination($maxrows); + + return true; + } + } + + function showSeachFormCustom() { + printf ("User",$this->filters['username']); + printf ("@"); + + if ($this->allowedDomains) { + if ($this->filters['domain'] && !in_array($this->filters['domain'],$this->allowedDomains)) { + + $selected_domain[$this->filters['domain']]='selected'; + printf (""); + } else { + printf ("",$this->filters['domain']); + } + } else { + printf ("",$this->filters['domain']); + } + + printf (" Name",$this->filters['fullname']); + } + + function deleteRecord() { + if (!$_REQUEST['confirm']) { + print "

Please press on Confirm to confirm the delete. "; + return 1; + } + + if (!strlen($this->filters['username']) || !strlen($this->filters['domain'])) { + print "

Error: missing SIP account username or domain. "; + return 0; + } + + $account=array('username' => $this->filters['username'], + 'domain' => $this->filters['domain'] + ); + + $function=array('commit' => array('name' => 'deleteAccount', + 'parameters' => array($account), + 'logs' => array('success' => sprintf('

SIP account %s@%s has been deleted',$this->filters['username'],$this->filters['domain']) + ) + ) + + ); + + if ($this->SOAPEngine->execute($function)) { + unset($this->filters); + } + + return true; + } + + function showAddForm() { + if ($this->selectionActive) return; + print " +

+ + + "; + printf ("",$_SERVER['PHP_SELF']); + print " + + + "; + $this->printHiddenFormElements(); + + print " + + +
+ "; + + print " + + "; + + printf (" User",$_REQUEST['account']); + if (is_array($this->allowedDomains)) { + print "@"; + + } + + printf (" Pass",$_REQUEST['password']); + printf (" Name",$_REQUEST['fullname']); + printf (" Email",$_REQUEST['email']); + //printf (" CallerId",$_REQUEST['rpid']); + printf ("Owner ",$_REQUEST['owner']); + printf ("PSTN "); + printf ("Quota ",$_REQUEST['quota']); + printf ("Prepaid "); + print ""; + print "Customer"; + if ($this->adminonly) { + $this->showResellerForm('reseller'); + print "."; + $this->showCustomerForm('customer'); + } else { + $this->showCustomerForm('customer'); + } + print ""; + + print " + + "; + print " +
+ "; + } + + function addRecord($dictionary=array()) { + + if ($dictionary['account']) { + $account_els = explode("@", $dictionary['account']); + } else { + $account_els = explode("@", trim($_REQUEST['account'])); + } + + if ($this->adminonly) { + if ($dictionary['reseller']) { + $reseller = $dictionary['reseller']; + } else { + $reseller = trim($_REQUEST['reseller']); + } + if ($dictionary['customer']) { + $customer = $dictionary['customer']; + } else { + $customer = trim($_REQUEST['customer']); + } + if (!$customer) $customer=$reseller; + } else { + $reseller = $this->reseller; + + if ($dictionary['customer']) { + $customer = $dictionary['customer']; + } else { + $customer = trim($_REQUEST['customer']); + } + + if (!$customer) $customer=$reseller; + } + + $username=$account_els[0]; + + if (strlen($account_els[1])) { + $domain=$account_els[1]; + } else if ($dictionary['domain']) { + $domain=$dictionary['domain']; + } else if ($_REQUEST['domain']) { + $domain=trim($_REQUEST['domain']); + + } else { + printf ("

Error: Missing SIP domain"); + return false; + } + + if (is_array($this->allowedDomains) && !in_array($domain,$this->allowedDomains)) { + printf ("

Error: SIP domain %s is not allowed",$domain); + return false; + } + + if ($dictionary['fullname']) { + $name_els = explode(" ", $dictionary['fullname']); + } else { + $name_els = explode(" ", trim($_REQUEST['fullname'])); + } + + if (strlen($name_els[0])) { + $firstName=$name_els[0]; + } else { + $firstName='Account'; + } + + if (strlen($name_els[1])) { + $lastName=$name_els[1]; + } else { + $lastName=$username; + } + + if (strlen($dictionary['timezone'])) { + $timezone=$dictionary['timezone']; + } else if (strlen(trim($_REQUEST['timezone']))) { + $timezone=trim($_REQUEST['timezone']); + } else { + $timezone='Europe/Amsterdam'; + } + + if (strlen($dictionary['password'])) { + $password=$dictionary['password']; + } else if (strlen(trim($_REQUEST['password']))) { + $password=trim($_REQUEST['password']); + } else { + $password=$this->RandomPassword(6); + } + + $groups=array(); + if($dictionary['pstn'] || $_REQUEST['pstn']) $groups[]='free-pstn'; + + if (strlen($dictionary['email'])) { + $email=$dictionary['email']; + } else { + $email=trim($_REQUEST['email']); + } + + if (strlen($dictionary['owner'])) { + $owner=intval($dictionary['owner']); + } else { + $owner=intval($_REQUEST['owner']); + } + if (strlen($dictionary['quota'])) { + $quota=intval($dictionary['quota']); + } else { + $quota=intval($_REQUEST['quota']); + } + if (strlen($dictionary['prepaid'])) { + $prepaid=intval($dictionary['prepaid']); + } else { + $prepaid=intval($_REQUEST['prepaid']); + } + + $regexp = "/^([a-z0-9][a-z0-9_.-]*)@([a-z0-9][a-z0-9-]*\.)+([a-z0-9]{2,})$/i"; + if (!preg_match($regexp, $uri)) $email=$username.'@'.$domain; + + $account=array( + 'id' => array('username' => $username, + 'domain' => $domain), + 'firstName' => $firstName, + 'lastName' => $lastName, + 'password' => $password, + 'timezone' => $timezone, + 'email' => $email, + 'owner' => $owner, + 'customer' => intval($customer), + 'reseller' => intval($reseller), + 'groups' => $groups, + 'prepaid' => $prepaid, + 'quota' => $quota, + 'region' => '' + ); + + //print_r($account); + $deleteAccount=array('username' => $username, + 'domain' => $domain); + + + $function=array('commit' => array('name' => 'addAccount', + 'parameters' => array($account), + 'logs' => array('success' => sprintf('

SIP account %s@%s has been added',$username,$domain))), + 'rollback' => array('name' => 'deleteAlias', + 'parameters' => array($deleteAccount)) + ); + + return $this->SOAPEngine->execute($function); + + } + + function RandomPassword($len=11) { + $alf=array("a","b","c","d","e","f", + "h","i","j","k","l","m", + "n","p","r","s","t","w", + "x","y","1","2","3","4", + "5","6","7","8","9"); + $i=0; + while($i < $len) { + srand((double)microtime()*1000000); + $randval = rand(0,28); + $string="$string"."$alf[$randval]"; + $i++; + } + return $string; + } + + function getAllowedDomains() { + + if ($this->version > 1) { + + // Filter + $filter=array( + 'domain' => '' + ); + + // Range + $range=array('start' => 0, + 'count' => 1000 + ); + + $orderBy = array('attribute' => 'domain', + 'direction' => 'ASC' + ); + + // Compose query + $Query=array('filter' => $filter, + 'orderBy' => $orderBy, + 'range' => $range + ); + + $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); + $result = $this->SOAPEngine->soapclient->getDomains($Query); + } else { + $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); + $result = $this->SOAPEngine->soapclient->getDomains(); + } + + if (PEAR::isError($result)) { + $error_msg = $result->getMessage(); + $error_fault= $result->getFault(); + $error_code = $result->getCode(); + printf ("

Error in getAllowedDomains from %s: %s (%s): %s",$this->SOAPEngine->SOAPurl,$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); + //return false; + } else { + if ($this->version > 1) { + foreach ($result->domains as $_domain) { + $this->allowedDomains[]=$_domain->domain; + } + } else { + $this->allowedDomains=$result; + } + } + } +} + +class SIPAliases extends Records { + var $sortElements=array( + 'aliasUsername' => 'Alias user', + 'aliasDomain' => 'Alias domain', + 'targetUsername' => 'Target user', + 'targetDomain' => 'Target domain' + ); + + function SIPAliases(&$SOAPEngine) { + $this->filters = array('aliasUsername' => trim($_REQUEST['alias_username_filter']), + 'aliasDomain' => trim($_REQUEST['alias_domain_filter']), + 'targetUsername' => trim($_REQUEST['target_username_filter']), + 'targetDomain' => trim($_REQUEST['target_domain_filter']) + ); + + $this->Records(&$SOAPEngine); + + } + + function getRecordKeys() { + + // Filter + $filter=array('aliasUsername' => $this->filters['aliasUsername'], + 'aliasDomain' => $this->filters['aliasDomain'], + 'targetUsername' => $this->filters['targetUsername'], + 'targetDomain' => $this->filters['targetDomain'], + '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'] = 'aliasUsername'; + 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 + ); + + //print_r($Query); + // Insert credetials + $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); + + // Call function + $result = $this->SOAPEngine->soapclient->getAliases($Query); + + if (PEAR::isError($result)) { + $error_msg = $result->getMessage(); + $error_fault= $result->getFault(); + $error_code = $result->getCode(); + printf ("

Error from %s: %s (%s): %s",$this->SOAPEngine->SOAPurl,$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); + return false; + } else { + foreach ($result->aliases as $alias) { + $this->selectionKeys[]=array('username' => $alias->id->username, + 'domain' => $alias->id->domain); + } + + return true; + } + } + + + function listRecords() { + $this->getAllowedDomains(); + + // Make sure we apply the domain filter from the login credetials + + $this->showSeachForm(); + + // Filter + $filter=array('aliasUsername' => $this->filters['aliasUsername'], + 'aliasDomain' => $this->filters['aliasDomain'], + 'targetUsername' => $this->filters['targetUsername'], + 'targetDomain' => $this->filters['targetDomain'], + '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'] = 'aliasUsername'; + 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); + + // Call function + $result = $this->SOAPEngine->soapclient->getAliases($Query); + + if (PEAR::isError($result)) { + $error_msg = $result->getMessage(); + $error_fault= $result->getFault(); + $error_code = $result->getCode(); + printf ("

Error from %s: %s (%s): %s",$this->SOAPEngine->SOAPurl,$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); + return false; + } else { + + $this->rows = $result->total; + + if ($this->rows && $_REQUEST['action'] != 'PerformActions' && $_REQUEST['action'] != 'Delete') { + $this->showActionsForm(); + } + + print " +

+ + +
$this->rows records found
+

+ + + "; + print" + + + + + + + "; + + if (!$this->next) $this->next=0; + + if ($this->rows > $this->maxrowsperpage) { + $maxrows = $this->maxrowsperpage + $this->next; + if ($maxrows > $this->rows) $maxrows = $this->maxrowsperpage; + } else { + $maxrows=$this->rows; + } + + $i=0; + + if ($this->rows) { + while ($i < $maxrows) { + + if (!$result->aliases[$i]) break; + + $alias = $result->aliases[$i]; + + $index=$this->next+$i+1; + + $rr=floor($index/2); + $mod=$index-$rr*2; + + if ($mod ==0) { + $bgcolor="lightgrey"; + } else { + $bgcolor="white"; + } + + $_url = $this->url.sprintf("&service=%s&action=Delete&alias_username_filter=%s&alias_domain_filter=%s", + urlencode($this->SOAPEngine->service), + urlencode($alias->id->username), + urlencode($alias->id->domain) + ); + + if ($_REQUEST['action'] == 'Delete' && + $_REQUEST['alias_username_filter'] == $alias->id->username && + $_REQUEST['alias_domain_filter'] == $alias->id->domain) { + $_url .= "&confirm=1"; + $actionText = "Confirm"; + } else { + $actionText = "Delete"; + } + + if ($this->version > 1) { + + $_customer_url = $this->url.sprintf("&service=%s@Customers&customer_filter=%s", + urlencode($this->SOAPEngine->soapEngineId), + urlencode($alias->customer) + ); + + printf(" + + + + + + + + + + ", + $bgcolor, + $index, + $_customer_url, + $alias->reseller, + $alias->customer, + $alias->id->username, + $alias->id->domain, + $alias->target->username, + $alias->target->domain, + $alias->owner, + $alias->changeDate, + $_url, + $actionText + ); + } else { + printf(" + + + + + + + + + ", + $bgcolor, + $index, + $alias->id->username, + $alias->id->domain, + $alias->target->username, + $alias->target->domain, + $alias->owner, + $alias->changeDate, + $_url, + $actionText + ); + } + $i++; + + } + + } + + print "
Id + "; + if ($this->version > 1) print "CustomerAliasTargetOwnerLast changeAction
%s%s.%s%s@%s%s@%s%s%s%s
%s%s@%s%s@%s%s%s%s
"; + + $this->showPagination($maxrows); + + return true; + } + } + + function deleteRecord() { + if (!$_REQUEST['confirm']) { + print "

Please press on Confirm to confirm the delete. "; + return 1; + } + + if (!strlen($this->filters['aliasUsername']) || !strlen($this->filters['aliasDomain'])) { + print "

Error: missing SIP alias username or domain. "; + return 0; + } + + $alias=array('username' => $this->filters['aliasUsername'], + 'domain' => $this->filters['aliasDomain'] + ); + + $function=array('commit' => array('name' => 'deleteAlias', + 'parameters' => array($alias), + 'logs' => array('success' => sprintf('

SIP alias %s@%s has been deleted',$this->filters['aliasUsername'],$this->filters['aliasDomain']) + ) + ) + + ); + + + if ($this->SOAPEngine->execute($function)) { + unset($this->filters); + return true; + } else { + return flase; + } + + } + + function showSeachFormCustom() { + printf (" Alias",$this->filters['aliasUsername']); + printf ("@"); + + if ($this->allowedDomains) { + if ($this->filters['aliasDomain'] && !in_array($this->filters['aliasDomain'],$this->allowedDomains)) { + printf ("",$this->filters['aliasDomain']); + } else { + $selected_domain[$this->filters['aliasDomain']]='selected'; + printf (""); + } + } else { + printf ("",$this->filters['aliasDomain']); + } + + printf (" Target",$this->filters['targetUsername']); + printf (" @",$this->filters['targetDomain']); + + } + + function showAddForm() { + if ($this->selectionActive) return; + print " +

+ + + "; + printf ("",$_SERVER['PHP_SELF']); + print " + + + "; + $this->printHiddenFormElements(); + + print " + + +
+ "; + + print " + + "; + + printf (" Alias"); + + if (is_array($this->allowedDomains)) { + print "@"; + } + + printf (" Target"); + + print "Customer"; + if ($this->adminonly) { + $this->showResellerForm('reseller'); + print "."; + $this->showCustomerForm('customer'); + } else { + $this->showCustomerForm('customer'); + } + + printf (" Owner"); + + print " + + "; + print " +
+ "; + } + + function addRecord() { + $alias_els = explode("@", trim($_REQUEST['alias'])); + $target_els = explode("@", trim($_REQUEST['target'])); + + $username=$alias_els[0]; + + if (strlen($alias_els[1])) { + $domain=$alias_els[1]; + + } else if (trim($_REQUEST['domain'])) { + $domain=trim($_REQUEST['domain']); + + } else { + printf ("

Error: Missing SIP domain"); + return false; + } + + if (is_array($this->allowedDomains) && !in_array($domain,$this->allowedDomains)) { + printf ("

Error: SIP domain %s is not allowed",$domain); + return false; + } + + if ($this->adminonly) { + $reseller = trim($_REQUEST['reseller']); + $customer = trim($_REQUEST['customer']); + if (!$customer) $customer=$reseller; + } else { + $reseller = $this->reseller; + $customer = trim($_REQUEST['customer']); + if (!$customer || !in_array($customer,array_keys($this->customers))) { + $customer=$reseller; + } + } + + $alias=array( + 'id' => array('username' => $username, + 'domain' => $domain + ), + 'target' => array('username' => $target_els[0], + 'domain' => $target_els[1] + ), + 'owner' => intval($_REQUEST['owner']), + 'customer' => intval($customer), + 'reseller' => intval($reseller) + ); + + //print_r($alias); + + $deleteAlias=array('username' => $username, + 'domain' => $domain); + + $function=array('commit' => array('name' => 'addAlias', + 'parameters' => array($alias), + 'logs' => array('success' => sprintf('

SIP alias %s@%s has been added',$username,$domain))), + 'rollback' => array('name' => 'deleteAlias', + 'parameters' => array($deleteAlias)) + ); + + return $this->SOAPEngine->execute($function); + } + + function getAllowedDomains() { + if ($this->version > 1) { + + // Filter + $filter=array( + 'domain' => '' + ); + + // Range + $range=array('start' => 0, + 'count' => 1000 + ); + + $orderBy = array('attribute' => 'domain', + 'direction' => 'ASC' + ); + + // Compose query + $Query=array('filter' => $filter, + 'orderBy' => $orderBy, + 'range' => $range + ); + + $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); + $result = $this->SOAPEngine->soapclient->getDomains($Query); + } else { + $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); + $result = $this->SOAPEngine->soapclient->getDomains(); + } + + if (PEAR::isError($result)) { + $error_msg = $result->getMessage(); + $error_fault= $result->getFault(); + $error_code = $result->getCode(); + printf ("

Error from %s: %s (%s): %s",$this->SOAPEngine->SOAPurl,$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); + return false; + } else { + if ($this->version > 1) { + foreach ($result->domains as $_domain) { + $this->allowedDomains[]=$_domain->domain; + } + } else { + $this->allowedDomains=$result; + } + } + } +} + +class ENUMranges extends Records { + + function ENUMranges(&$SOAPEngine) { + $this->filters = array('prefix' => trim($_REQUEST['prefix_filter']), + 'tld' => trim($_REQUEST['tld_filter']) + ); + + $this->Records(&$SOAPEngine); + + if ($this->version > 1) { + $this->sortElements=array('changeDate' => 'Change date', + 'prefix' => 'Prefix', + 'tld' => 'TLD' + ); + } + } + + function listRecords() { + $this->getAllowedDomains(); + + $this->showSeachForm(); + + if ($this->version > 1) { + // Filter + $filter=array('prefix' => $this->filters['prefix'], + 'tld' => $this->filters['tld'], + '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 + ); + + $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); + $result = $this->SOAPEngine->soapclient->getRanges($Query); + + } else { + $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); + $result = $this->SOAPEngine->soapclient->getRanges(); + } + + if (PEAR::isError($result)) { + $error_msg = $result->getMessage(); + $error_fault= $result->getFault(); + $error_code = $result->getCode(); + printf ("

Error from %s: %s (%s): %s",$this->SOAPEngine->SOAPurl,$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); + return false; + } else { + + if ($this->version > 1) { + $this->rows = $result->total; + } else { + $this->rows = count($result); + } + + if ($this->rows && $_REQUEST['action'] != 'PerformActions' && $_REQUEST['action'] != 'Delete') { + $this->showActionsForm(); + } + + print " +

+ + +
$this->rows records found
+

+ + + "; + print" + + + + + + + + + + "; + + if (!$this->next) $this->next=0; + + if ($this->rows > $this->maxrowsperpage) { + $maxrows = $this->maxrowsperpage + $this->next; + if ($maxrows > $this->rows) $maxrows = $this->maxrowsperpage; + } else { + $maxrows=$this->rows; + } + + $i=0; + + if ($this->rows) { + while ($i < $maxrows) { + + if ($this->version > 1) { + if (!$result->ranges[$i]) break; + $range = $result->ranges[$i]; + + } else { + $range = $result[$i]; + } + + $index=$this->next+$i+1; + + $rr=floor($index/2); + $mod=$index-$rr*2; + + if ($mod ==0) { + $bgcolor="lightgrey"; + } else { + $bgcolor="white"; + } + + $_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 ($_REQUEST['action'] == 'Delete' && + $_REQUEST['prefix_filter'] == $range->id->prefix && + $_REQUEST['tld_filter'] == $range->id->tld) { + $_url .= "&confirm=1"; + $actionText = "Confirm"; + } else { + $actionText = "Delete"; + } + + if (strlen($this->SOAPEngine->recordGenerator)) { + $range_link=sprintf('%s',$this->url,$this->SOAPEngine->recordGenerator,$range->id->prefix,$range->id->tld,$range->maxDigits,$range->id->prefix); + } else { + $range_link=$range->id->prefix; + } + + if ($this->version > 1) { + $_customer_url = $this->url.sprintf("&service=%s@Customers&customer_filter=%s", + urlencode($this->SOAPEngine->soapEngineId), + urlencode($range->customer) + ); + + printf(" + + + + + + + + + + + + ", + $bgcolor, + $index, + $_customer_url, + $range->reseller, + $range->customer, + $range_link, + $range->id->tld, + $range->ttl, + $range->minDigits, + $range->maxDigits, + $range->used, + $range->changeDate, + $_url, + $actionText + ); + } else { + printf(" + + + + + + + + + + + ", + $bgcolor, + $index, + $range_link, + $range->id->tld, + $range->ttl, + $range->minDigits, + $range->maxDigits, + $range->used, + $range->changeDate, + $_url, + $actionText + ); + + } + printf(" + + "); + + $i++; + + } + + } + + print "
Id + "; + if ($this->version > 1) print "CustomerPrefix TLDTTLMin digitsMax digitsUsedLast changeAction
%s%s.%s+%s%s%s%s%s%s%s%s
%s+%s%s%s%s%s%s%s%s
"; + + $this->showPagination($maxrows); + + return true; + } + } + + function deleteRecord() { + if (!$_REQUEST['confirm']) { + print "

Please press on Confirm to confirm the delete. "; + return 1; + } + + if (!strlen($this->filters['prefix']) || !strlen($this->filters['tld'])) { + print "

Error: missing ENUM range id "; + return 0; + } + + $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']) + ) + ) + ); + + unset($this->filters); + return $this->SOAPEngine->execute($function); + } + + function showAddForm() { + if ($this->selectionActive) return; + + print " +

+ + + "; + printf ("",$_SERVER['PHP_SELF']); + print " + + + "; + + $this->printHiddenFormElements(); + + print " + + +
+ "; + + print " + + "; + printf ("Prefix + "); + printf (" TLD"); + /* + if (is_array($this->allowedDomains)) { + print ""; + } else { + print ""; + } + */ + print ""; + printf ("TTL "); + printf ("Min Digits "); + printf ("Max Digits "); + print "Customer"; + if ($this->adminonly) { + $this->showResellerForm('reseller'); + print "."; + $this->showCustomerForm('customer'); + } else { + $this->showCustomerForm('customer'); + } + //printf ("Info "); + + print " + + "; + print " +
+ "; + } + + function addRecord() { + $tld = trim($_REQUEST['tld']); + $prefix = trim($_REQUEST['prefix']); + $info = trim($_REQUEST['info']); + + if (!strlen($tld)) { + if (strlen($this->SOAPEngine->defaultEnumTLD)) { + $tld=$this->SOAPEngine->defaultEnumTLD; + } else { + $tld='e164.arpa'; + } + } + + if (!strlen($tld) || !strlen($prefix) || !is_numeric($prefix)) { + printf ("

Error: Missing TLD or prefix. "); + return false; + } + + if ($this->adminonly) { + $reseller = trim($_REQUEST['reseller']); + $customer = trim($_REQUEST['customer']); + if (!$customer) $customer=$reseller; + } else { + $reseller = $this->reseller; + $customer = trim($_REQUEST['customer']); + if (!$customer || !in_array($customer,array_keys($this->customers))) { + $customer=$reseller; + } + } + + if (!trim($_REQUEST['ttl'])) { + $ttl=3600; + } else { + $ttl=intval(trim($_REQUEST['ttl'])); + } + + $range=array( + 'id' => array('prefix' => $prefix, + 'tld' => $tld), + 'ttl' => $ttl, + 'minDigits' => intval(trim($_REQUEST['minDigits'])), + 'maxDigits' => intval(trim($_REQUEST['maxDigits'])), + 'customer' => intval($customer), + 'reseller' => intval($reseller) + ); + + $deleteRange=array('prefix'=>$prefix, + 'tld'=>$tld); + + $function=array('commit' => array('name' => 'addRange', + 'parameters' => array($range), + 'logs' => array('success' => sprintf('

ENUM range +%s under %s has been added',$prefix,$tld))), + 'rollback' => array('name' => 'deleteRange', + 'parameters' => array($deleteRange)) + ); + + return $this->SOAPEngine->execute($function); + + } + + function showSeachFormCustom() { + if ($this->version > 1) { + printf (" Prefix",$this->filters['prefix']); + printf (" TLD"); + + if ($this->allowedDomains) { + $selected_tld[$this->filters['tld']]='selected'; + printf (""); + } else { + printf ("",$this->filters['tld']); + } + } + } + + function getAllowedDomains() { + // Insert credetials + if ($this->version > 1) { + // Filter + $filter=array('prefix' => ''); + // Range + $range=array('start' => 0, + 'count' => 200 + ); + + // 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 + ); + + $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); + $result = $this->SOAPEngine->soapclient->getRanges($Query); + + } else { + $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); + $result = $this->SOAPEngine->soapclient->getRanges(); + } + + if (PEAR::isError($result)) { + $error_msg = $result->getMessage(); + $error_fault= $result->getFault(); + $error_code = $result->getCode(); + printf ("

Error from %s: %s (%s): %s",$this->SOAPEngine->SOAPurl,$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); + return false; + } else { + if ($this->version > 1) { + foreach($result->ranges as $range) { + $this->ranges[]=array('prefix' => $range->id->prefix, + 'tld' => $range->id->tld, + 'minDigits' => $range->minDigits, + 'maxDigits' => $range->maxDigits + ); + if (in_array($range->id->tld,$this->allowedDomains)) continue; + $this->allowedDomains[]=$range->id->tld; + $seen[$range->id->tld]++; + } + } else { + foreach($result as $range) { + $this->ranges[]=array('prefix' => $range->id->prefix, + 'tld' => $range->id->tld, + 'minDigits' => $range->minDigits, + 'maxDigits' => $range->maxDigits + ); + if (in_array($range->id->tld,$this->allowedDomains)) continue; + $this->allowedDomains[]=$range->id->tld; + $seen[$range->id->tld]++; + } + } + + if (strlen($this->SOAPEngine->defaultEnumTLD) && !$seen[$this->SOAPEngine->defaultEnumTLD]) { + $this->allowedDomains[]=$this->SOAPEngine->defaultEnumTLD; + } + } + } +} + +class ENUMmappings extends Records { + var $sortElements=array('changeDate' => 'Change date', + 'number' => 'Number', + 'tld' => 'TLD', + 'owner' => 'Owner' + ); + + var $ranges=array(); + + var $NAPTR_services=array( + "sip" => array("service"=>"sip", + "webname"=>"SIP", + "schemas"=>array("sip:","sips:")), + "mailto" => array("service"=>"mailto", + "webname"=>"Email", + "schemas"=>array("mailto:")), + "web:http" => array("service"=>"web:http", + "webname"=>"WEB (http)", + "schemas"=>array("http://")), + "web:https" => array("service"=>"web:https", + "webname"=>"WEB (https)", + "schemas"=>array("https://")), + "x-skype:callto" => array("service"=>"x-skype:callto", + "webname"=>"Skype", + "schemas"=>array("callto:")), + "h323" => array("service"=>"h323", + "webname"=>"H323", + "schemas"=>array("h323:")), + "iax" => array("service"=>"iax", + "webname"=>"IAX", + "schemas"=>array("iax:")), + "iax2" => array("service"=>"iax2", + "webname"=>"IAX2", + "schemas"=>array("iax2:")), + "mms" => array("service"=>"mms", + "webname"=>"MMS", + "schemas"=>array("tel:","mailto:")), + "sms" => array("service"=>"sms", + "webname"=>"SMS", + "schemas"=>array("tel:","mailto:")), + "ems" => array("service"=>"ems", + "webname"=>"EMS", + "schemas"=>array("tel:","mailto:")), + "im" => array("service"=>"im", + "webname"=>"IM", + "schemas"=>array("im:")), + "npd:tel" => array("service"=>"npd+tel", + "webname"=>"Portability", + "schemas"=>array("tel:")), + "void:mailto" => array("service"=>"void:mailto", + "webname"=>"VOID(mail)", + "schemas"=>array("mailto:")), + "void:http" => array("service"=>"void:http", + "webname"=>"VOID(http)", + "schemas"=>array("http://")), + "void:https" => array("service"=>"void:https", + "webname"=>"VOID(https)", + "schemas"=>array("https://")), + "voice" => array("service"=>"voice", + "webname"=>"Voice", + "schemas"=>array("voice:","tel:")), + "tel" => array("service"=>"tel", + "webname"=>"Tel", + "schemas"=>array("tel:")), + "fax:tel" => array("service"=>"fax:tel", + "webname"=>"Fax", + "schemas"=>array("tel:")), + "ifax:mailto" => array("service"=>"ifax:mailto", + "webname"=>"iFax", + "schemas"=>array("mailto:")), + "pres" => array("service"=>"pres", + "webname"=>"Presence", + "schemas"=>array("pres:")), + "ft:ftp" => array("service"=>"ft:ftp", + "webname"=>"FTP", + "schemas"=>array("ftp://")), + "loc:http" => array("service"=>"loc:http", + "webname"=>"GeoLocation", + "schemas"=>array("http://")), + "key:http" => array("service"=>"key:http", + "webname"=>"Public key", + "schemas"=>array("http://")) + ); + + function ENUMmappings(&$SOAPEngine) { + $this->filters = array('number' => trim($_REQUEST['number_filter']), + 'tld' => trim($_REQUEST['tld_filter']), + 'type' => trim($_REQUEST['type_filter']), + 'mapto' => trim($_REQUEST['mapto_filter']), + 'owner' => trim($_REQUEST['owner_filter']) + ); + $this->Records(&$SOAPEngine); + } + + + function listRecords() { + $this->getAllowedDomains(); + + $this->showSeachForm(); + + $filter=array('number' => $this->filters['number'], + 'tld' => $this->filters['tld'], + 'type' => $this->filters['type'], + 'mapto' => $this->filters['mapto'], + '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); + + // Call function + $result = $this->SOAPEngine->soapclient->getNumbers($Query); + + if (PEAR::isError($result)) { + $error_msg = $result->getMessage(); + $error_fault= $result->getFault(); + $error_code = $result->getCode(); + printf ("

Error from %s: %s (%s): %s",$this->SOAPEngine->SOAPurl,$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); + return false; + } else { + + $this->rows = $result->total; + + if ($this->rows && $_REQUEST['action'] != 'PerformActions' && $_REQUEST['action'] != 'Delete') { + $this->showActionsForm(); + } + + print " +

+ + +
$this->rows records found
+

+ + + "; + print" + + + + + + + + + + + + "; + + if (!$this->next) $this->next=0; + + if ($this->rows > $this->maxrowsperpage) { + $maxrows = $this->maxrowsperpage + $this->next; + if ($maxrows > $this->rows) $maxrows = $this->maxrowsperpage; + } else { + $maxrows=$this->rows; + } + + $i=0; + + if ($this->rows) { + while ($i < $maxrows) { + + if (!$result->numbers[$i]) break; + + $number = $result->numbers[$i]; + + $index=$this->next+$i+1; + + $rr=floor($index/2); + $mod=$index-$rr*2; + + if ($mod ==0) { + $bgcolor="lightgrey"; + } else { + $bgcolor="white"; + } + + $j=1; + foreach ($number->mappings as $_mapping) { + $_url = $this->url.sprintf("&service=%s&action=Delete&number_filter=%s&tld_filter=%s&mapto_filter=%s", + urlencode($this->SOAPEngine->service), + urlencode($number->id->number), + urlencode($number->id->tld), + urlencode($_mapping->mapto) + ); + + if ($_REQUEST['action'] == 'Delete' && + $_REQUEST['number_filter'] == $number->id->number && + $_REQUEST['tld_filter'] == $number->id->tld && + $_REQUEST['mapto_filter'] == $_mapping->mapto) { + $_url .= "&confirm=1"; + $actionText = "Confirm"; + } else { + $actionText = "Delete"; + } + + if ($j==1) { + + if ($this->version > 1) { + $_customer_url = $this->url.sprintf("&service=%s@Customers&customer_filter=%s", + urlencode($this->SOAPEngine->soapEngineId), + urlencode($number->customer) + ); + + printf(" + + + + + + + + + + + + + + ", + $bgcolor, + $index, + $_customer_url, + $number->reseller, + $number->customer, + $number->id->number, + $number->id->tld, + $this->tel2enum($number->id->number,$number->id->tld), + ucfirst($_mapping->type), + $_mapping->mapto, + $_mapping->ttl, + $_mapping->priority, + $number->owner, + $_mapping->lastChange, + $_url, + $actionText + ); + } else { + printf(" + + + + + + + + + + + + + ", + $bgcolor, + $index, + $number->id->number, + $number->id->tld, + $this->tel2enum($number->id->number,$number->id->tld), + ucfirst($_mapping->type), + $_mapping->mapto, + $_mapping->ttl, + $_mapping->priority, + $number->owner, + $_mapping->lastChange, + $_url, + $actionText + ); + } + } else { + if ($this->version > 1) { + printf(" + + + + + + + + + + + + + + ", + $bgcolor, + ucfirst($_mapping->type), + $_mapping->mapto, + $_mapping->ttl, + $_mapping->priority, + $_mapping->lastChange, + $_url, + $actionText + ); + } else { + printf(" + + + + + + + + + + + + + ", + $bgcolor, + ucfirst($_mapping->type), + $_mapping->mapto, + $_mapping->ttl, + $_mapping->priority, + $_mapping->lastChange, + $_url, + $actionText + ); + } + } + $j++; + } + + printf(" + + "); + + $i++; + + } + + } + + print "
Id + "; + if ($this->version > 1) print "CustomerNumberTLDDNS nameSrvMap toTTLPrioOwnerLast changeAction
%s%s.%s+%s%s%s%s%s%s%s%s%s%s
%s+%s%s%s%s%s%s%s%s%s%s
%s%s%s%s%s%s
%s%s%s%s%s%s
"; + + $this->showPagination($maxrows); + + return true; + } + } + + function getLastNumber() { + + // Filter + $filter=array('number' => '' + ); + // Range + $range=array('start' => 0, + 'count' => 1 + ); + + // 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); + + // Call function + $result = $this->SOAPEngine->soapclient->getNumbers($Query); + + if (PEAR::isError($result)) { + $error_msg = $result->getMessage(); + $error_fault= $result->getFault(); + $error_code = $result->getCode(); + printf ("

Error from %s: %s (%s): %s",$this->SOAPEngine->SOAPurl,$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); + return false; + } else { + + if ($result->total) { + $number = array('number' => $result->numbers[0]->id->number, + 'tld' => $result->numbers[0]->id->tld, + 'mappings' => $result->numbers[0]->mappings + ); + + return $number; + } + + } + + return false; + } + + function showSeachFormCustom() { + + printf (" Number",$this->filters['number']); + printf (" TLD"); + if ($this->allowedDomains) { + $selected_tld[$this->filters['tld']]='selected'; + printf (""); + } else { + printf ("",$this->filters['tld']); + } + + printf (" Srv"); + print " + "; + printf (" Map to",$this->filters['mapto']); + + } + + function deleteRecord($dictionary=array()) { + + if (!$dictionary['confirm'] && !$_REQUEST['confirm']) { + print "

Please press on Confirm to confirm the delete. "; + return 1; + } + + if ($dictionary['number']) { + $number=$dictionary['number']; + } else { + $number=$this->filters['number']; + } + + if ($dictionary['tld']) { + $tld=$dictionary['tld']; + } else { + $tld=$this->filters['tld']; + } + + if ($dictionary['mapto']) { + $mapto=$dictionary['mapto']; + } else { + $mapto=$this->filters['mapto']; + } + + if (!strlen($number) || !strlen($tld)) { + print "

Error: missing ENUM number or TLD "; + return 0; + } + + $enum_id=array('number'=>$number, + 'tld'=>$tld); + + $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); + $result = $this->SOAPEngine->soapclient->getNumber($enum_id); + + if (!PEAR::isError($result)) { + // the number exists and we make an update + $result_new=$result; + + if (count($result->mappings) > 1) { + foreach ($result->mappings as $_mapping) { + if ($_mapping->mapto != $mapto) { + $mappings_new[]=array('type' => $_mapping->type, + 'mapto' => $_mapping->mapto, + 'ttl' => $_mapping->ttl, + 'priority' => $_mapping->priority + ); + } + } + + $result_new->mappings=$mappings_new; + + $function=array('commit' => array('name' => 'updateNumber', + 'parameters' => array($result_new), + 'logs' => array('success' => sprintf('

ENUM mapping %s has been deleted',$mapto))), + 'rollback' => array('name' => 'updateNumber', + 'parameters' => array($result)) + ); + + } else { + $function=array('commit' => array('name' => 'deleteNumber', + 'parameters' => array($enum_id), + 'logs' => array('success' => sprintf('

ENUM number +%s under %s has been deleted',$number,$tld))), + 'rollback' => array('name' => 'addNumber', + 'parameters' => array($result)) + ); + } + + unset($this->filters); + return $this->SOAPEngine->execute($function); + + } else { + return false; + } + + } + + function showAddForm() { + if ($this->selectionActive) return; + + print " +

+ + + "; + printf ("",$_SERVER['PHP_SELF']); + print " + + + "; + + $this->printHiddenFormElements(); + + print " + + +
+ "; + + print " + + "; + printf (" Number +"); + printf (" TLD"); + if (is_array($this->allowedDomains)) { + print ""; + } else { + print ""; + } + printf (" Map to"); + print " + "; + printf (" "); + printf (" TTL"); + print "Customer"; + if ($this->adminonly) { + $this->showResellerForm('reseller'); + print "."; + $this->showCustomerForm('customer'); + } else { + $this->showCustomerForm('customer'); + } + + printf (" Owner"); + printf (" Prio"); + + print " + + "; + print " +
+ "; + } + + function getAllowedDomains() { + if ($this->version > 1) { + // Filter + $filter=array('prefix' => $this->filters['prefix'], + 'tld' => $this->filters['tld'], + 'customer' => intval($this->filters['customer']), + 'reseller' => intval($this->filters['reseller']) + ); + // Range + $range=array('start' => 0, + 'count' => 200 + ); + + // 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 + ); + + $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); + $result = $this->SOAPEngine->soapclient->getRanges($Query); + + } else { + $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); + $result = $this->SOAPEngine->soapclient->getRanges(); + } + + if (PEAR::isError($result)) { + $error_msg = $result->getMessage(); + $error_fault= $result->getFault(); + $error_code = $result->getCode(); + printf ("

Error from %s: %s (%s): %s",$this->SOAPEngine->SOAPurl,$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); + return false; + } else { + if ($this->version > 1) { + foreach($result->ranges as $range) { + $this->ranges[]=array('prefix' => $range->id->prefix, + 'tld' => $range->id->tld, + 'minDigits' => $range->minDigits, + 'maxDigits' => $range->maxDigits + ); + if (in_array($range->id->tld,$this->allowedDomains)) continue; + $this->allowedDomains[]=$range->id->tld; + $seen[$range->id->tld]++; + } + } else { + foreach($result as $range) { + $this->ranges[]=array('prefix' => $range->id->prefix, + 'tld' => $range->id->tld, + 'minDigits' => $range->minDigits, + 'maxDigits' => $range->maxDigits + ); + if (in_array($range->id->tld,$this->allowedDomains)) continue; + $this->allowedDomains[]=$range->id->tld; + $seen[$range->id->tld]++; + } + } + if (strlen($this->SOAPEngine->defaultEnumTLD) && !$seen[$this->SOAPEngine->defaultEnumTLD]) { + $this->allowedDomains[]=$this->SOAPEngine->defaultEnumTLD; + } + } + } + + function addRecord($dictionary=array()) { + if ($dictionary['tld']) { + $tld=$dictionary['tld']; + } else { + $tld = trim($_REQUEST['tld']); + } + if ($dictionary['number']) { + $number=$dictionary['number']; + } else { + $number = trim($_REQUEST['number']); + } + + if (!strlen($tld)) { + if (strlen($this->SOAPEngine->defaultEnumTLD)) { + $tld=$this->SOAPEngine->defaultEnumTLD; + } else { + $tld='e164.arpa'; + } + } + + if (!strlen($tld) || !strlen($number) || !is_numeric($number)) { + printf ("

Error: Missing TLD or number. "); + return false; + } + + if ($this->adminonly) { + if ($dictionary['reseller']) { + $reseller=$dictionary['reseller']; + } else { + $reseller = trim($_REQUEST['reseller']); + } + if ($dictionary['customer']) { + $customer=$dictionary['customer']; + } else { + $customer = trim($_REQUEST['customer']); + } + if (!$customer) $customer=$reseller; + } else { + $reseller = $this->reseller; + if ($dictionary['customer']) { + $customer=$dictionary['customer']; + } else { + $customer = trim($_REQUEST['customer']); + } + if (!$customer || !in_array($customer,array_keys($this->customers))) { + $customer=$reseller; + } + } + + if ($dictionary['ttl']) { + $ttl = intval($dictionary['ttl']); + } else { + $ttl = intval(trim($_REQUEST['ttl'])); + } + + if (!$ttl) $ttl=3600; + + if ($dictionary['priority']) { + $priority = intval($dictionary['priority']); + } else { + $priority = intval(trim($_REQUEST['priority'])); + } + + if ($dictionary['owner']) { + $owner = intval($dictionary['owner']); + } else { + $owner = intval(trim($_REQUEST['owner'])); + } + + if (!$priority) $priority=5; + + $enum_id=array('number' => $number, + 'tld' => $tld); + + if ($dictionary['mapto']) { + $mapto = $dictionary['mapto']; + } else { + $mapto = trim($_REQUEST['mapto']); + } + + if ($dictionary['type']) { + $type = $dictionary['type']; + } else { + $type = trim($_REQUEST['type']); + } + + if (preg_match("/^([a-z0-9]+:\/\/)(.*)$/i",$mapto,$m)) { + $_scheme = $m[1]; + $_value = $m[2]; + } else if (preg_match("/^([a-z0-9]+:)(.*)$/i",$mapto,$m)) { + $_scheme = $m[1]; + $_value = $m[2]; + } else { + $_scheme = ''; + $_value = $mapto; + } + + if (!$_value) { + $lastNumber=$this->getLastNumber(); + foreach($lastNumber['mappings'] as $_mapping) { + if ($_mapping->type == trim($type)) { + if (preg_match("/^(.*)@(.*)$/",$_mapping->mapto,$m)) { + $_value = $number.'@'.$m[2]; + break; + } + } + } + } + + if (!$_scheme || !in_array($_scheme,$this->NAPTR_services[trim($type)]['schemas'])) { + $_scheme=$this->NAPTR_services[trim($type)]['schemas'][0]; + } + + $mapto=$_scheme.$_value; + + $enum_number=array('id' => $enum_id, + 'owner' => $owner, + 'customer' => intval($customer), + 'reseller' => intval($reseller), + 'mappings' => array(array('type' => $type, + 'mapto' => $mapto, + 'ttl' => $ttl, + 'priority' => $priority + ) + ) + ); + + $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); + $result = $this->SOAPEngine->soapclient->getNumber($enum_id); + + if (PEAR::isError($result)) { + $error_msg=$result->getMessage(); + $error_fault=$result->getFault(); + $error_code=$result->getCode(); + + if ($error_fault->detail->exception->errorcode == "3002") { + + $function=array('commit' => array('name' => 'addNumber', + 'parameters' => array($enum_number), + 'logs' => array('success' => sprintf('

ENUM number +%s under %s has been added',$number,$tld))), + 'rollback' => array('name' => 'deleteNumber', + 'parameters' => array($enumId)) + ); + + return $this->SOAPEngine->execute($function); + } else { + printf ("

Error from %s: %s (%s): %s",$this->SOAPEngine->SOAPurl,$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); + return false; + } + } else { + // the number exists and we make an update + $result_new=$result; + foreach ($result->mappings as $_mapping) { + $mappings_new[]=array('type' => $_mapping->type, + 'mapto' => $_mapping->mapto, + 'ttl' => $_mapping->ttl, + 'priority' => $_mapping->priority + ); + + if ($_mapping->mapto == $mapto) { + printf ("

Info: ENUM mapping %s for number %s already exists",$mapto,$number); + return true; + break; + } + } + + $mappings_new[]=array('type' => trim($type), + 'mapto' => $mapto, + 'ttl' => intval(trim($_REQUEST['ttl'])), + 'priority'=> intval(trim($_REQUEST['priority'])), + ); + // add mapping + $result_new->mappings=$mappings_new; + + $function=array('commit' => array('name' => 'updateNumber', + 'parameters' => array($result_new), + 'logs' => array('success' => sprintf('

ENUM number +%s under %s has been updated',$number,$tld))), + 'rollback' => array('name' => 'updateNumber', + 'parameters' => array($result)) + ); + + return $this->SOAPEngine->execute($function); + } + + return true; + } + + function getRecordKeys() { + + // Filter + $filter=array('number' => $this->filters['number'], + 'tld' => $this->filters['tld'], + 'type' => $this->filters['type'], + 'mapto' => $this->filters['mapto'] + ); + // 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); + + // Call function + $result = $this->SOAPEngine->soapclient->getNumbers($Query); + + if (PEAR::isError($result)) { + $error_msg = $result->getMessage(); + $error_fault= $result->getFault(); + $error_code = $result->getCode(); + printf ("

Error from %s: %s (%s): %s",$this->SOAPEngine->SOAPurl,$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); + return false; + } else { + foreach ($result->numbers as $number) { + $this->selectionKeys[]=array('number' => $number->id->number, + 'tld' => $number->id->tld); + } + return true; + } + } +} + +class TrustedPeers extends Records { + + var $sortElements=array( + 'description' => 'Description', + 'ip' =>'IP address' + ); + + function TrustedPeers(&$SOAPEngine) { + $this->filters = array('ip' => trim($_REQUEST['ip_filter']), + 'description' => trim($_REQUEST['description_filter']) + ); + + $this->Records(&$SOAPEngine); + } + + function listRecords() { + + $this->showSeachForm(); + + // Insert credetials + $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); + + // Filter + $filter=array('ip' => $this->filters['ip'], + 'description' => $this->filters['description'] + ); + + // Range + $range=array('start' => intval($this->next), + 'count' => intval($this->maxrowsperpage) + ); + + // Order + if (!$this->sorting['sortBy']) $this->sorting['sortBy'] = 'description'; + 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 + $result = $this->SOAPEngine->soapclient->getTrustedPeers($Query); + + if (PEAR::isError($result)) { + $error_msg = $result->getMessage(); + $error_fault= $result->getFault(); + $error_code = $result->getCode(); + printf ("

Error from %s: %s (%s): %s",$this->SOAPEngine->SOAPurl,$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); + return false; + } else { + + $this->rows = $result->total; + + if ($this->rows && $_REQUEST['action'] != 'PerformActions' && $_REQUEST['action'] != 'Delete') { + $this->showActionsForm(); + } + + print " + + +
$this->rows records found
+

+ + + "; + print" + + + + + + + + "; + + if (!$this->next) $this->next=0; + + if ($this->rows > $this->maxrowsperpage) { + $maxrows = $this->maxrowsperpage + $this->next; + if ($maxrows > $this->rows) $maxrows = $this->maxrowsperpage; + } else { + $maxrows=$this->rows; + } + + $i=0; + + if ($this->rows) { + while ($i < $maxrows) { + + if (!$result->peers[$i]) break; + + $peer = $result->peers[$i]; + + $index=$this->next+$i+1; + + $rr=floor($index/2); + $mod=$index-$rr*2; + + if ($mod ==0) { + $bgcolor="lightgrey"; + } else { + $bgcolor="white"; + } + + $_url = $this->url.sprintf("&service=%s&action=Delete&ip_filter=%s", + urlencode($this->SOAPEngine->service), + urlencode($peer->ip) + ); + + if ($_REQUEST['action'] == 'Delete' && + $_REQUEST['ip_filter'] == $peer->ip) { + $_url .= "&confirm=1"; + $actionText = "Confirm"; + } else { + $actionText = "Delete"; + } + + if ($this->version > 1) { + + printf(" + + + + + + + + + + ", + $bgcolor, + $index, + $peer->reseller, + $peer->customer, + $peer->ip, + $peer->protocol, + $peer->fromPattern, + $peer->description, + $peer->owner, + $_url, + $actionText + ); + } else { + printf(" + + + + + + + + + ", + $bgcolor, + $index, + $peer->ip, + $peer->protocol, + $peer->fromPattern, + $peer->description, + $peer->owner, + $_url, + $actionText + ); + + } + printf(" + + "); + + $i++; + + } + + } + + print "
Id + "; + if ($this->version > 1) print "CustomerIP addressProtocolFrom patternDescriptionOwnerAction
%s%s.%s%s%s%s%s%s%s
%s%s%s%s%s%s%s
"; + + $this->showPagination($maxrows); + + return true; + } + } + + function showAddForm() { + if ($this->selectionActive) return; + print " +

+ + + "; + printf ("",$_SERVER['PHP_SELF']); + print " + + + "; + + $this->printHiddenFormElements(); + + print " + + +
+ "; + + print " + + "; + printf (" IP address"); + printf (" Description"); + print "Customer"; + if ($this->adminonly) { + $this->showResellerForm('reseller'); + print "."; + $this->showCustomerForm('customer'); + } else { + $this->showCustomerForm('customer'); + } + printf (" Owner"); + + print " + + "; + print " +
+ "; + } + + function addRecord() { + $ipaddress = trim($_REQUEST['ipaddress']); + $description = trim($_REQUEST['description']); + $owner = trim($_REQUEST['owner']); + + if ($this->adminonly) { + $reseller = trim($_REQUEST['reseller']); + $customer = trim($_REQUEST['customer']); + if (!$customer) $customer=$reseller; + } else { + $reseller = $this->reseller; + $customer = trim($_REQUEST['customer']); + if (!$customer || !in_array($customer,array_keys($this->customers))) { + $customer=$reseller; + } + } + + if (!strlen($ipaddress) || !strlen($description)) { + printf ("

Error: Missing IP or description. "); + return false; + } + + $peer=array( + 'ip' => $ipaddress, + 'description' => $description, + 'owner' => intval($_REQUEST['owner']), + 'customer' => intval($customer), + 'reseller' => intval($reseller) + ); + + $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); + + $result = $this->SOAPEngine->soapclient->addTrustedPeer($peer); + + if (PEAR::isError($result)) { + $error_msg = $result->getMessage(); + $error_fault= $result->getFault(); + $error_code = $result->getCode(); + printf ("

Error from %s: %s (%s): %s",$this->SOAPEngine->SOAPurl,$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); + return false; + } else { + printf ("

Trusted peers %s has been added. ",$ipaddress); + return 1; + } + } + + function deleteRecord() { + if (!$_REQUEST['confirm']) { + print "

Please press on Confirm to confirm the delete. "; + return 1; + } + + if (!strlen($this->filters['ip']) || !strlen($this->filters['ip'])) { + print "

Error: missing IP address. "; + return 0; + } + + $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); + + $result = $this->SOAPEngine->soapclient->deleteTrustedPeer($this->filters['ip']); + + if (PEAR::isError($result)) { + $error_msg = $result->getMessage(); + $error_fault= $result->getFault(); + $error_code = $result->getCode(); + printf ("

Error from %s: %s (%s): %s",$this->SOAPEngine->SOAPurl,$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); + return false; + } else { + printf ("

Trusted peer %s has been deleted. ",$this->filters['ip']); + unset($this->filters); + return 1; + } + } + +} + +class GatewayGroups extends Records { + + var $sortElements=array( + 'name' => 'Name' + ); + + function GatewayGroups(&$SOAPEngine) { + $this->filters = array('group' => trim($_REQUEST['group_filter']) + ); + + $this->Records(&$SOAPEngine); + } + + function listRecords() { + + $this->showSeachForm(); + + // Insert credetials + $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); + + // Filter + $filter=array('name' => $this->filters['group'] + ); + + // Range + $range=array('start' => intval($this->next), + 'count' => intval($this->maxrowsperpage) + ); + + // 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 + $result = $this->SOAPEngine->soapclient->getGatewayGroups($Query); + + if (PEAR::isError($result)) { + $error_msg = $result->getMessage(); + $error_fault= $result->getFault(); + $error_code = $result->getCode(); + printf ("

Error from %s: %s (%s): %s",$this->SOAPEngine->SOAPurl,$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); + return false; + } else { + + $this->rows = $result->total; + + print " + + +
$this->rows records found
+

+ + + + + "; + + if (!$this->next) $this->next=0; + + if ($this->rows > $this->maxrowsperpage) { + $maxrows = $this->maxrowsperpage + $this->next; + if ($maxrows > $this->rows) $maxrows = $this->maxrowsperpage; + } else { + $maxrows=$this->rows; + } + + $i=0; + + if ($this->rows) { + while ($i < $maxrows) { + + if (!$result->groups[$i]) break; + + $group = $result->groups[$i]; + + $index=$this->next+$i+1; + + $rr=floor($index/2); + $mod=$index-$rr*2; + + if ($mod ==0) { + $bgcolor="lightgrey"; + } else { + $bgcolor="white"; + } + + $_url = $this->url.sprintf("&service=%s&action=Delete&group_filter=%s", + urlencode($this->SOAPEngine->service), + urlencode($group) + ); + + if ($_REQUEST['action'] == 'Delete' && + $_REQUEST['group_filter'] == $group) { + $_url .= "&confirm=1"; + $actionText = "Confirm"; + } else { + $actionText = "Delete"; + } + + printf(" + + + + + ", + $bgcolor, + $index, + $group, + $_url, + $actionText + ); + + printf(" + + "); + + $i++; + + } + + } + + print "
Id + Name + Action
%s%s%s
"; + + $this->showPagination($maxrows); + + return true; + } + } + + function showAddForm() { + if ($this->selectionActive) return; + print " +

+ + + "; + printf ("",$_SERVER['PHP_SELF']); + print " + + + "; + $this->printHiddenFormElements(); + + print " + + +
+ "; + + print " + + "; + + printf (" Name"); + + $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); + $result = $this->SOAPEngine->soapclient->getGatewayGroups(); + + print " + + "; + print " +
+ "; + } + + function addRecord() { + $name = trim($_REQUEST['name']); + + if (!strlen($name)) { + printf ("

Error: Missing name. "); + return false; + } + + $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); + + $result = $this->SOAPEngine->soapclient->addGatewayGroup($name); + + if (PEAR::isError($result)) { + $error_msg = $result->getMessage(); + $error_fault= $result->getFault(); + $error_code = $result->getCode(); + printf ("

Error from %s: %s (%s): %s",$this->SOAPEngine->SOAPurl,$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); + return false; + } else { + printf ("

Gateway group %s has been added. ",$name); + return 1; + } + } + + function deleteRecord() { + if (!$_REQUEST['confirm']) { + print "

Please press on Confirm to confirm the delete. "; + return 1; + } + + if (!strlen($this->filters['group'])) { + print "

Error: missing gateway group. "; + return 0; + } + + $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); + + $result = $this->SOAPEngine->soapclient->deleteGatewayGroup($this->filters['group']); + + if (PEAR::isError($result)) { + $error_msg = $result->getMessage(); + $error_fault= $result->getFault(); + $error_code = $result->getCode(); + printf ("

Error from %s: %s (%s): %s",$this->SOAPEngine->SOAPurl,$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); + return false; + } else { + printf ("

Gateway %s has been deleted. ",$this->filters['group']); + unset($this->filters); + return 1; + } + } + + function showSeachFormCustom() { + printf (" Group",$this->filters['group']); + } + +} + +class Gateways extends Records { + + var $sortElements=array( + 'name' => 'Name', + 'group' => 'Group', + 'ip' => 'IP address', + 'prefix' => 'Prefix' + ); + + function Gateways(&$SOAPEngine) { + $this->filters = array('name' => trim($_REQUEST['name_filter']), + 'group' => trim($_REQUEST['group_filter']) + ); + + $this->Records(&$SOAPEngine); + } + + function listRecords() { + + $this->showSeachForm(); + + // Insert credetials + $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); + + // Filter + $filter=array('name' => $this->filters['name'], + 'group' => $this->filters['group'] + ); + + // Range + $range=array('start' => intval($this->next), + 'count' => intval($this->maxrowsperpage) + ); + + // 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 + $result = $this->SOAPEngine->soapclient->getGateways($Query); + + if (PEAR::isError($result)) { + $error_msg = $result->getMessage(); + $error_fault= $result->getFault(); + $error_code = $result->getCode(); + printf ("

Error from %s: %s (%s): %s",$this->SOAPEngine->SOAPurl,$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); + return false; + } else { + + $this->rows = $result->total; + + print " + + +
$this->rows records found
+

+ + + + + + + + + "; + + if (!$this->next) $this->next=0; + + if ($this->rows > $this->maxrowsperpage) { + $maxrows = $this->maxrowsperpage + $this->next; + if ($maxrows > $this->rows) $maxrows = $this->maxrowsperpage; + } else { + $maxrows=$this->rows; + } + + $i=0; + + if ($this->rows) { + while ($i < $maxrows) { + + if (!$result->gateways[$i]) break; + + $gateway = $result->gateways[$i]; + + $index=$this->next+$i+1; + + $rr=floor($index/2); + $mod=$index-$rr*2; + + if ($mod ==0) { + $bgcolor="lightgrey"; + } else { + $bgcolor="white"; + } + + $_url = $this->url.sprintf("&service=%s&action=Delete&name_filter=%s", + urlencode($this->SOAPEngine->service), + urlencode($gateway->name) + ); + + if ($_REQUEST['action'] == 'Delete' && + $_REQUEST['name_filter'] == $gateway->name) { + $_url .= "&confirm=1"; + $actionText = "Confirm"; + } else { + $actionText = "Delete"; + } + + printf(" + + + + + + + + + ", + $bgcolor, + $index, + $gateway->name, + $gateway->group, + $gateway->transport, + $gateway->ip, + $gateway->port, + $gateway->strip, + $gateway->prefix, + $_url, + $actionText + ); + + printf(" + + "); + + $i++; + + } + + } + + print "
Id + Name + GroupAddressStripPrefixAction
%s%s%s%s:%s:%s%s%s%s
"; + + $this->showPagination($maxrows); + + return true; + } + } + + function showAddForm() { + if ($this->selectionActive) return; + print " +

+ + + "; + printf ("",$_SERVER['PHP_SELF']); + print " + + + "; + $this->printHiddenFormElements(); + + print " + + +
+ "; + + print " + + "; + + printf (" Name"); + + $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); + $result = $this->SOAPEngine->soapclient->getGatewayGroups(); + + printf (" Group: "); + + // Compose query + $Query=array('filter' => array('name'=>''), + 'orderBy' => array('attribute' => 'name', + 'direction' => 'ASC' + ), + 'range' => array('start' => 0, + 'count' => 1000) + ); + + $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); + $result = $this->SOAPEngine->soapclient->getGatewayGroups($Query); + + if (PEAR::isError($result)) { + $error_msg = $result->getMessage(); + $error_fault= $result->getFault(); + $error_code = $result->getCode(); + printf ("

Error from %s: %s (%s): %s",$this->SOAPEngine->SOAPurl,$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); + return false; + } else { + print ""); + } + printf (" Address"); + printf (" Strip: "; + printf (" Prefix"); + + print " +

+ "; + print " +
+ "; + } + + function addRecord() { + $name = trim($_REQUEST['name']); + $group = trim($_REQUEST['group']); + $address = trim($_REQUEST['address']); + $strip = trim($_REQUEST['strip']); + $prefix = trim($_REQUEST['prefix']); + + if (!strlen($name) || !strlen($group) || !strlen($address)) { + printf ("

Error: Missing name, group or address. "); + return false; + } + + $address_els=explode(':',$address); + + if (count($address_els) == 1) { + $ip=$address_els[0]; + $transport='udp'; + $port='5060'; + } else if (count($address_els) == 2) { + $ip=$address_els[0]; + $port=$address_els[1]; + $transport='udp'; + } else if (count($address_els) == 3) { + $ip=$address_els[1]; + $port=intval($address_els[2]); + if ($address_els[0] == 'tcp' || $address_els[0] == 'tls' || $address_els[0] == 'udp') { + $transport=$address_els[0]; + } else { + $transport='udp'; + } + } + + $gateway=array( + 'name' => $name, + 'group' => $group, + 'ip' => $ip, + 'port' => intval($port), + 'uriScheme' => 'sip', + 'transport' => $transport, + 'strip' => intval($_REQUEST['strip']), + 'prefix' => $_REQUEST['prefix'] + ); + + $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); + + $result = $this->SOAPEngine->soapclient->addGateway($gateway); + + if (PEAR::isError($result)) { + $error_msg = $result->getMessage(); + $error_fault= $result->getFault(); + $error_code = $result->getCode(); + printf ("

Error from %s: %s (%s): %s",$this->SOAPEngine->SOAPurl,$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); + return false; + } else { + printf ("

Gateway %s has been added. ",$address); + return 1; + } + } + + function deleteRecord() { + if (!$_REQUEST['confirm']) { + print "

Please press on Confirm to confirm the delete. "; + return 1; + } + + if (!strlen($this->filters['name'])) { + print "

Error: missing gateway name. "; + return 0; + } + + $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); + + $result = $this->SOAPEngine->soapclient->deleteGateway($this->filters['name']); + + if (PEAR::isError($result)) { + $error_msg = $result->getMessage(); + $error_fault= $result->getFault(); + $error_code = $result->getCode(); + printf ("

Error from %s: %s (%s): %s",$this->SOAPEngine->SOAPurl,$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); + return false; + } else { + printf ("

Gateway %s has been deleted. ",$this->filters['address']); + unset($this->filters); + return 1; + } + } + + function showSeachFormCustom() { + printf (" Name",$this->filters['name']); + printf (" Group",$this->filters['group']); + } + +} + +class Routes extends Records { + var $gatewayGroups=array(); + + var $sortElements=array( + 'prefix' => 'Prefix', + 'fromURI' => 'From URI', + 'priority' => 'Priority' + ); + + function Routes(&$SOAPEngine) { + $this->filters = array('prefix' => trim($_REQUEST['prefix_filter']), + 'gatewayGroup' => trim($_REQUEST['gatewayGroup_filter']), + 'fromURI' => trim($_REQUEST['fromURI_filter']) + ); + + $this->Records(&$SOAPEngine); + } + + function listRecords() { + + // Get gateway groups + $Query=array('filter' => array('name'=>''), + 'orderBy' => array('attribute' => 'name', + 'direction' => 'ASC' + ), + 'range' => array('start' => 0, + 'count' => 1000) + ); + + $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); + $result = $this->SOAPEngine->soapclient->getGatewayGroups($Query); + + if (PEAR::isError($result)) { + $error_msg = $result->getMessage(); + $error_fault= $result->getFault(); + $error_code = $result->getCode(); + printf ("

Error from %s: %s (%s): %s",$this->SOAPEngine->SOAPurl,$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); + return false; + } else { + $this->gatewayGroups=$result->groups; + } + + + $this->showSeachForm(); + + // Insert credetials + $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); + + // Filter + $filter=array('prefix' => $this->filters['prefix'], + 'gatewayGroup' => $this->filters['gatewayGroup'], + 'fromURI' => $this->filters['fromURI'] + ); + + // 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 + $result = $this->SOAPEngine->soapclient->getRoutes($Query); + + if (PEAR::isError($result)) { + $error_msg = $result->getMessage(); + $error_fault= $result->getFault(); + $error_code = $result->getCode(); + printf ("

Error from %s: %s (%s): %s",$this->SOAPEngine->SOAPurl,$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); + return false; + } else { + + $this->rows = $result->total; + + print " + + +
$this->rows records found
+

+ + + + + + + + "; + + if (!$this->next) $this->next=0; + + if ($this->rows > $this->maxrowsperpage) { + $maxrows = $this->maxrowsperpage + $this->next; + if ($maxrows > $this->rows) $maxrows = $this->maxrowsperpage; + } else { + $maxrows=$this->rows; + } + + $i=0; + + if ($this->rows) { + while ($i < $maxrows) { + + if (!$result->routes[$i]) break; + + $route = $result->routes[$i]; + + $index=$this->next+$i+1; + + $rr=floor($index/2); + $mod=$index-$rr*2; + + if ($mod ==0) { + $bgcolor="lightgrey"; + } else { + $bgcolor="white"; + } + + $_url = $this->url.sprintf("&service=%s&action=Delete&prefix_filter=%s&gatewayGroup_filter=%s&fromURI_filter=%s&priority_filter=%s", + urlencode($this->SOAPEngine->service), + urlencode($route->prefix), + urlencode($route->gatewayGroup), + urlencode($route->fromURI), + urlencode($route->priority) + ); + + if ($_REQUEST['action'] == 'Delete' && + $_REQUEST['prefix_filter'] == $route->prefix && + $_REQUEST['gatewayGroup_filter'] == $route->gatewayGroup && + $_REQUEST['fromURI_filter'] == $route->fromURI && + $_REQUEST['priority_filter'] == $route->priority) { + + $_url .= "&confirm=1"; + $actionText = "Confirm"; + } else { + $actionText = "Delete"; + } + + printf(" + + + + + + + + ", + $bgcolor, + $index, + $route->prefix, + $route->gatewayGroup, + $route->fromURI, + $route->priority, + $_url, + $actionText + ); + + printf(" + + "); + + $i++; + + } + + } + + print "
Id + Prefix + Gateway GroupFrom URIPriorityAction
%s%s%s%s%s%s
"; + + $this->showPagination($maxrows); + + return true; + } + } + + function showAddForm() { + if ($this->selectionActive) return; + print " +

+ + + "; + printf ("",$_SERVER['PHP_SELF']); + print " + + + "; + + $this->printHiddenFormElements(); + + print " + + +
+ "; + + print " + + "; + + printf (" Prefix"); + + printf (" Group: "); + + print ""); + printf (" From"); + printf (" Priority"); + + print " + + "; + print " +
+ "; + } + + function addRecord() { + + $prefix = trim($_REQUEST['prefix']); + $gatewayGroup = trim($_REQUEST['gatewayGroup']); + $fromURI = trim($_REQUEST['fromURI']); + $priority = trim($_REQUEST['priority']); + + if (!strlen($prefix) || !strlen($gatewayGroup)) { + printf ("

Error: Missing prefix or gatewayGroup. "); + return false; + } + + $route=array( + 'prefix' => $prefix, + 'gatewayGroup' => $gatewayGroup, + 'fromURI' => $fromURI, + 'priority' => intval($priority) + ); + + $routes=array($route); + + $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); + + $result = $this->SOAPEngine->soapclient->addRoutes($routes); + + if (PEAR::isError($result)) { + $error_msg = $result->getMessage(); + $error_fault= $result->getFault(); + $error_code = $result->getCode(); + printf ("

Error from %s: %s (%s): %s",$this->SOAPEngine->SOAPurl,$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); + return false; + } else { + printf ("

Route %s has been added. ",$prefix); + return 1; + } + } + + function deleteRecord() { + if (!$_REQUEST['confirm']) { + print "

Please press on Confirm to confirm the delete. "; + return 1; + } + + if (!strlen($this->filters['prefix']) || !strlen($this->filters['gatewayGroup'])) { + print "

Error: missing route prefix or gatewayGroup. "; + return 0; + } + + $route=array( + 'prefix' => $this->filters['prefix'], + 'gatewayGroup' => $this->filters['gatewayGroup'], + 'fromURI' => $this->filters['fromURI'], + 'priority' => intval($this->filters['priority']) + ); + + $routes=array($route); + + $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); + + $result = $this->SOAPEngine->soapclient->deleteRoutes($routes); + + if (PEAR::isError($result)) { + $error_msg = $result->getMessage(); + $error_fault= $result->getFault(); + $error_code = $result->getCode(); + printf ("

Error from %s: %s (%s): %s",$this->SOAPEngine->SOAPurl,$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); + return false; + } else { + printf ("

Route %s has been deleted. ",$this->filters['prefix']); + unset($this->filters); + return 1; + } + } + + function showSeachFormCustom() { + printf (" Prefix",$this->filters['prefix']); + print ""); + + printf (" From URI",$this->filters['fromURI']); + } + +} + +class DomainStatistics extends Records { + + var $maxrowsperpage= 200; + + function DomainStatistics(&$SOAPEngine) { + $this->filters = array( + 'domain' => trim($_REQUEST['domain_filter']) + ); + + $this->Records(&$SOAPEngine); + } + + function listRecords() { + + $this->showSeachForm(); + + // Insert credetials + $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); + + $filter=$this->filters['domain']; + + // Call function + $result = $this->SOAPEngine->soapclient->getDomainStatistics($filter); + + if (PEAR::isError($result)) { + $error_msg = $result->getMessage(); + $error_fault= $result->getFault(); + $error_code = $result->getCode(); + printf ("

Error from %s: %s (%s): %s",$this->SOAPEngine->SOAPurl,$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); + return false; + } else { + + $this->rows = count($result); + + //print_r($result); + + print " + + +
$this->rows records found
+

+ + + + + + + + "; + + if (!$this->next) $this->next=0; + + if ($this->rows > $this->maxrowsperpage) { + $maxrows = $this->maxrowsperpage + $this->next; + if ($maxrows > $this->rows) $maxrows = $this->maxrowsperpage; + } else { + $maxrows=$this->rows; + } + + $i=0; + + if ($this->rows) { + while ($i < $maxrows) { + + $domain = $result[$i]; + if (!strlen($domain->users)) break; + + $index = $this->next+$i+1; + + $rr=floor($index/2); + $mod=$index-$rr*2; + + if ($mod ==0) { + $bgcolor="lightgrey"; + } else { + $bgcolor="white"; + } + + $_url = $this->url.sprintf("&service=%s&action=Delete&domain_filter=%s", + urlencode($this->SOAPEngine->service), + urlencode($domain->domain) + ); + + if ($_REQUEST['action'] == 'Delete' && + $_REQUEST['domain_filter'] == $domain->domain) { + $_url .= "&confirm=1"; + $actionText = "Confirm"; + } else { + $actionText = "Delete"; + } + + printf(" + + + + + + + ", + $bgcolor, + $index, + $domain->domain, + $domain->users, + $domain->onlineUsers, + $domain->onlineDevices + ); + + $i++; + } + } + + print "
Id + SIP domainSIP subscribersOnline subscribersOnline SIP devices
%s%s%s%s%s
"; + + $this->showPagination($maxrows); + + return true; + } + } + + function showSeachFormCustom() { + + printf (" Domain",$this->filters['domain']); + + } + + function deleteRecord() { + if (!$_REQUEST['confirm']) { + print "

Please press on Confirm to confirm the delete. "; + return 1; + } + + if (!strlen($this->filters['domain']) || !strlen($this->filters['domain'])) { + print "

Error: missing SIP domain. "; + return 0; + } + + $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); + + $result = $this->SOAPEngine->soapclient->deleteDomain($this->filters['domain']); + + if (PEAR::isError($result)) { + $error_msg = $result->getMessage(); + $error_fault= $result->getFault(); + $error_code = $result->getCode(); + printf ("

Error from %s: %s (%s): %s",$this->SOAPEngine->SOAPurl,$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); + return false; + } else { + printf ("

SIP domain %s has been deleted. ",$this->filters['domain']); + unset($this->filters); + return 1; + } + } + + function addRecord() { + + $domain=trim($_REQUEST['domain']); + + $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); + + $result = $this->SOAPEngine->soapclient->addDomain($domain); + + if (PEAR::isError($result)) { + $error_msg = $result->getMessage(); + $error_fault= $result->getFault(); + $error_code = $result->getCode(); + printf ("

Error from %s: %s (%s): %s",$this->SOAPEngine->SOAPurl,$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); + return false; + } else { + printf ("

SIP domain %s has been added. ",$domain); + return 1; + } + } +} + +class Customers extends Records { + + var $maxrowsperpage= 20; + var $sortElements=array( + 'changeDate' => 'Change date', + 'username' => 'Username', + 'customer' => 'Customer' + ); + + var $propertiesItems = array('sip_credit' => array('name' => 'Credit for SIP account creation', + 'category' => 'admin'), + 'sipa_credit' => array('name' => 'Credit for SIP alias creation', + 'category' => 'admin'), + 'enum_range_credit' => array('name' => 'Credit for ENUM range creation', + 'category' => 'admin'), + 'enum_number_credit' => array('name' => 'Credit for ENUM numbers creation', + 'category' => 'admin'), + 'comp_code' => array('name' => 'Billing code for invoicing', + 'category' => 'admin'), + 'billing_email' => array('name' => 'Email address for invoicing', + 'category' => 'admin'), + 'registrar_id' => array('name' => 'Registrar id for domain registration', + 'category' => 'admin'), + 'pstn_access' => array('name' => 'Access to PSTN', + 'category' => 'admin'), + 'soap_engines' => array('name' => 'SOAP engines', + 'category' => 'admin'), + 'language' => array('name' => 'Language', + 'category' => 'general'), + 'voicemail_server' => array('name' => 'Voicemail server address', + 'category' => 'sip'), + 'sip_proxy_server' => array('name' => 'SIP Proxy server address', + 'category' => 'sip'), + 'support_web' => array('name' => 'Support web site', + 'category' => 'sip'), + 'support_email' => array('name' => 'Support email address', + 'category' => 'sip'), + 'cdrtool_address' => array('name' => 'CDRTool address', + 'category' => 'sip'), + 'sip_settings_page' => array('name' => 'SIP settings page', + 'category' => 'sip'), + 'default_sip_domain' => array('name' => 'Default SIP domain', + 'category' => 'sip'), + 'default_enum_range' => array('name' => 'Default ENUM range', + 'category' => 'sip'), + 'default_enum_tld' => array('name' => 'Default ENUM Top Level Domain', + 'category' => 'sip') + ); + + var $customerFieldsReadOnly=array( + 'id', + 'reseller' + ); + var $customerFields=array( + 'aliasOf' => array('type'=>'integer'), + 'username' => array('type'=>'string'), + 'password' => array('type'=>'string', + 'name'=>'Password'), + 'firstName' => array('type'=>'string', + 'name'=>'First name'), + 'lastName' => array('type'=>'string', + 'name'=>'Last name'), + 'organization'=> array('type'=>'string'), + 'vatNumber' => array('type'=>'string', + 'name'=>'VAT number'), + 'tel' => array('type'=>'string'), + 'fax' => array('type'=>'string'), + 'sip' => array('type'=>'string'), + 'enum' => array('type'=>'string'), + 'mobile' => array('type'=>'string'), + 'email' => array('type'=>'string'), + 'web' => array('type'=>'string'), + 'address' => array('type'=>'text'), + 'postcode' => array('type'=>'string'), + 'city' => array('type'=>'string'), + 'state' => array('type'=>'string'), + 'country' => array('type'=>'string'), + 'timezone' => array('type'=>'string') + ); + + var $states=array( + array("label"=>"", "value"=>"N/A"), + array("label"=>"-- CANADA --", "value"=>"-"), + array("label"=>"Alberta", "value"=>"AB"), + array("label"=>"British Columbia", "value"=>"BC"), + array("label"=>"Manitoba", "value"=>"MB"), + array("label"=>"New Brunswick", "value"=>"NB"), + array("label"=>"Newfoundland/Labrador", "value"=>"NL"), + array("label"=>"Northwest Territory", "value"=>"NT"), + array("label"=>"Nova Scotia", "value"=>"NS"), + array("label"=>"Nunavut", "value"=>"NU"), + array("label"=>"Ontario", "value"=>"ON"), + array("label"=>"Prince Edward Island", "value"=>"PE"), + array("label"=>"Quebec", "value"=>"QC"), + array("label"=>"Saskatchewan", "value"=>"SN"), + array("label"=>"Yukon", "value"=>"YT"), + array("label"=>"---- US -----", "value"=>"-"), + array("label"=>"Alabama", "value"=>"AL"), + array("label"=>"Alaska", "value"=>"AK"), + array("label"=>"American Samoa", "value"=>"AS"), + array("label"=>"Arizona", "value"=>"AZ"), + array("label"=>"Arkansas", "value"=>"AR"), + array("label"=>"California", "value"=>"CA"), + array("label"=>"Canal Zone", "value"=>"CZ"), + array("label"=>"Colorado", "value"=>"CO"), + array("label"=>"Connecticut", "value"=>"CT"), + array("label"=>"Delaware", "value"=>"DE"), + array("label"=>"District of Columbia", "value"=>"DC"), + array("label"=>"Florida", "value"=>"FL"), + array("label"=>"Georgia", "value"=>"GA"), + array("label"=>"Guam", "value"=>"GU"), + array("label"=>"Hawaii", "value"=>"HI"), + array("label"=>"Idaho", "value"=>"ID"), + array("label"=>"Illinois", "value"=>"IL"), + array("label"=>"Indiana", "value"=>"IN"), + array("label"=>"Iowa", "value"=>"IA"), + array("label"=>"Kansas", "value"=>"KS"), + array("label"=>"Kentucky", "value"=>"KY"), + array("label"=>"Louisiana", "value"=>"LA"), + array("label"=>"Maine", "value"=>"ME"), + array("label"=>"Mariana Islands", "value"=>"MP"), + array("label"=>"Maryland", "value"=>"MD"), + array("label"=>"Massachusetts", "value"=>"MA"), + array("label"=>"Michigan", "value"=>"MI"), + array("label"=>"Minnesota", "value"=>"MN"), + array("label"=>"Mississippi", "value"=>"MS"), + array("label"=>"Missouri", "value"=>"MO"), + array("label"=>"Montana", "value"=>"MT"), + array("label"=>"Nebraska", "value"=>"NE"), + array("label"=>"Nevada", "value"=>"NV"), + array("label"=>"New Hampshire", "value"=>"NH"), + array("label"=>"New Jersey", "value"=>"NJ"), + array("label"=>"New Mexico", "value"=>"NM"), + array("label"=>"New York", "value"=>"NY"), + array("label"=>"North Carolina", "value"=>"NC"), + array("label"=>"North Dakota", "value"=>"ND"), + array("label"=>"Ohio", "value"=>"OH"), + array("label"=>"Oklahoma", "value"=>"OK"), + array("label"=>"Oregon", "value"=>"OR"), + array("label"=>"Pennsylvania", "value"=>"PA"), + array("label"=>"Puerto Rico", "value"=>"PR"), + array("label"=>"Rhode Island", "value"=>"RI"), + array("label"=>"South Carolina", "value"=>"SC"), + array("label"=>"South Dakota", "value"=>"SD"), + array("label"=>"Tennessee", "value"=>"TN"), + array("label"=>"Texas", "value"=>"TX"), + array("label"=>"Utah", "value"=>"UT"), + array("label"=>"Vermont", "value"=>"VT"), + array("label"=>"Virgin Islands", "value"=>"VI"), + array("label"=>"Virginia", "value"=>"VA"), + array("label"=>"Washington", "value"=>"WA"), + array("label"=>"West Virginia", "value"=>"WV"), + array("label"=>"Wisconsin", "value"=>"WI"), + array("label"=>"Wyoming", "value"=>"WY"), + array("label"=>"APO", "value"=>"AP"), + array("label"=>"AEO", "value"=>"AE"), + array("label"=>"AAO", "value"=>"AA"), + array("label"=>"FPO", "value"=>"FP") + ); + + var $countries=array( + array("label"=>"Ascension Island", "value"=>"AC"), + array("label"=>"Afghanistan", "value"=>"AF"), + array("label"=>"Albania", "value"=>"AL"), + array("label"=>"Algeria", "value"=>"DZ"), + array("label"=>"American Samoa", "value"=>"AS"), + array("label"=>"Andorra", "value"=>"AD"), + array("label"=>"Angola", "value"=>"AO"), + array("label"=>"Anguilla", "value"=>"AI"), + array("label"=>"Antarctica", "value"=>"AQ"), + array("label"=>"Antigua And Barbuda", "value"=>"AG"), + array("label"=>"Argentina", "value"=>"AR"), + array("label"=>"Armenia", "value"=>"AM"), + array("label"=>"Aruba", "value"=>"AW"), + array("label"=>"Australia", "value"=>"AU"), + array("label"=>"Austria", "value"=>"AT"), + array("label"=>"Azerbaijan", "value"=>"AZ"), + array("label"=>"Bahamas", "value"=>"BS"), + array("label"=>"Bahrain", "value"=>"BH"), + array("label"=>"Bangladesh", "value"=>"BD"), + array("label"=>"Barbados", "value"=>"BB"), + array("label"=>"Belarus", "value"=>"BY"), + array("label"=>"Belgium", "value"=>"BE"), + array("label"=>"Belize", "value"=>"BZ"), + array("label"=>"Benin", "value"=>"BJ"), + array("label"=>"Bermuda", "value"=>"BM"), + array("label"=>"Bhutan", "value"=>"BT"), + array("label"=>"Bolivia", "value"=>"BO"), + array("label"=>"Bosnia And Herzegowina","value"=>"BA"), + array("label"=>"Botswana", "value"=>"BW"), + array("label"=>"Bouvet Island", "value"=>"BV"), + array("label"=>"Brazil", "value"=>"BR"), + array("label"=>"British Indian Ocean Territory", "value"=>"IO"), + array("label"=>"Brunei Darussalam", "value"=>"BN"), + array("label"=>"Bulgaria", "value"=>"BG"), + array("label"=>"Burkina Faso", "value"=>"BF"), + array("label"=>"Burundi", "value"=>"BI"), + array("label"=>"Cambodia", "value"=>"KH"), + array("label"=>"Cameroon", "value"=>"CM"), + array("label"=>"Canada", "value"=>"CA"), + array("label"=>"Cape Verde", "value"=>"CV"), + array("label"=>"Cayman Islands", "value"=>"KY"), + array("label"=>"Central African Republic", "value"=>"CF"), + array("label"=>"Chad", "value"=>"TD"), + array("label"=>"Chile", "value"=>"CL"), + array("label"=>"China", "value"=>"CN"), + array("label"=>"Christmas Island", "value"=>"CX"), + array("label"=>"Cocos (Keeling) Islands", "value"=>"CC"), + array("label"=>"Colombia", "value"=>"CO"), + array("label"=>"Comoros", "value"=>"KM"), + array("label"=>"Congo", "value"=>"CG"), + array("label"=>"Congo, Democratic People's Republic", "value"=>"CD"), + array("label"=>"Cook Islands", "value"=>"CK"), + array("label"=>"Costa Rica", "value"=>"CR"), + array("label"=>"Cote d'Ivoire", "value"=>"CI"), + array("label"=>"Croatia (local name: Hrvatska)", "value"=>"HR"), + array("label"=>"Cuba", "value"=>"CU"), + array("label"=>"Cyprus", "value"=>"CY"), + array("label"=>"Czech Republic","value"=>"CZ"), + array("label"=>"Denmark", "value"=>"DK"), + array("label"=>"Djibouti", "value"=>"DJ"), + array("label"=>"Dominica", "value"=>"DM"), + array("label"=>"Dominican Republic", "value"=>"DO"), + array("label"=>"East Timor", "value"=>"TP"), + array("label"=>"Ecuador", "value"=>"EC"), + array("label"=>"Egypt", "value"=>"EG"), + array("label"=>"El Salvador", "value"=>"SV"), + array("label"=>"Equatorial Guinea", "value"=>"GQ"), + array("label"=>"Eritrea", "value"=>"ER"), + array("label"=>"Estonia", "value"=>"EE"), + array("label"=>"Ethiopia", "value"=>"ET"), + array("label"=>"Falkland Islands (Malvinas)", "value"=>"FK"), + array("label"=>"Faroe Islands", "value"=>"FO"), + array("label"=>"Fiji", "value"=>"FJ"), + array("label"=>"Finland", "value"=>"FI"), + array("label"=>"France", "value"=>"FR"), + array("label"=>"French Guiana", "value"=>"GF"), + array("label"=>"French Polynesia", "value"=>"PF"), + array("label"=>"French Southern Territories", "value"=>"TF"), + array("label"=>"Gabon", "value"=>"GA"), + array("label"=>"Gambia", "value"=>"GM"), + array("label"=>"Georgia", "value"=>"GE"), + array("label"=>"Germany", "value"=>"DE"), + array("label"=>"Ghana", "value"=>"GH"), + array("label"=>"Gibraltar", "value"=>"GI"), + array("label"=>"Greece", "value"=>"GR"), + array("label"=>"Greenland", "value"=>"GL"), + array("label"=>"Grenada", "value"=>"GD"), + array("label"=>"Guadeloupe", "value"=>"GP"), + array("label"=>"Guam", "value"=>"GU"), + array("label"=>"Guatemala", "value"=>"GT"), + array("label"=>"Guernsey", "value"=>"GG"), + array("label"=>"Guinea", "value"=>"GN"), + array("label"=>"Guinea-Bissau", "value"=>"GW"), + array("label"=>"Guyana", "value"=>"GY"), + array("label"=>"Haiti", "value"=>"HT"), + array("label"=>"Heard And Mc Donald Islands", "value"=>"HM"), + array("label"=>"Honduras", "value"=>"HN"), + array("label"=>"Hong Kong", "value"=>"HK"), + array("label"=>"Hungary", "value"=>"HU"), + array("label"=>"Iceland", "value"=>"IS"), + array("label"=>"India", "value"=>"IN"), + array("label"=>"Indonesia", "value"=>"ID"), + array("label"=>"Iran (Islamic Republic Of)", "value"=>"IR"), + array("label"=>"Iraq", "value"=>"IQ"), + array("label"=>"Ireland", "value"=>"IE"), + array("label"=>"Isle of Man", "value"=>"IM"), + array("label"=>"Israel", "value"=>"IL"), + array("label"=>"Italy", "value"=>"IT"), + array("label"=>"Jamaica", "value"=>"JM"), + array("label"=>"Japan", "value"=>"JP"), + array("label"=>"Jersey", "value"=>"JE"), + array("label"=>"Jordan", "value"=>"JO"), + array("label"=>"Kazakhstan", "value"=>"KZ"), + array("label"=>"Kenya", "value"=>"KE"), + array("label"=>"Kiribati", "value"=>"KI"), + array("label"=>"Korea, Democratic People's Republic Of", "value"=>"KP"), + array("label"=>"Korea, Republic Of", "value"=>"KR"), + array("label"=>"Kuwait", "value"=>"KW"), + array("label"=>"Kyrgyzstan", "value"=>"KG"), + array("label"=>"Lao People's Democratic Republic", "value"=>"LA"), + array("label"=>"Latvia", "value"=>"LV"), + array("label"=>"Lebanon", "value"=>"LB"), + array("label"=>"Lesotho", "value"=>"LS"), + array("label"=>"Liberia", "value"=>"LR"), + array("label"=>"Libyan Arab Jamahiriya", "value"=>"LY"), + array("label"=>"Liechtenstein", "value"=>"LI"), + array("label"=>"Lithuania", "value"=>"LT"), + array("label"=>"Luxembourg", "value"=>"LU"), + array("label"=>"Macau", "value"=>"MO"), + array("label"=>"Macedonia, The Former Yugoslav", "value"=>"MK"), + array("label"=>"Of", "value"=>"Republic"), + array("label"=>"Madagascar", "value"=>"MG"), + array("label"=>"Malawi", "value"=>"MW"), + array("label"=>"Malaysia", "value"=>"MY"), + array("label"=>"Maldives", "value"=>"MV"), + array("label"=>"Mali", "value"=>"ML"), + array("label"=>"Malta", "value"=>"MT"), + array("label"=>"Marshall Islands", "value"=>"MH"), + array("label"=>"Martinique", "value"=>"MQ"), + array("label"=>"Mauritania", "value"=>"MR"), + array("label"=>"Mauritius", "value"=>"MU"), + array("label"=>"Mayotte", "value"=>"YT"), + array("label"=>"Mexico", "value"=>"MX"), + array("label"=>"Micronesia, Federated States Of", "value"=>"FM"), + array("label"=>"Moldova, Republic Of", "value"=>"MD"), + array("label"=>"Monaco", "value"=>"MC"), + array("label"=>"Mongolia", "value"=>"MN"), + array("label"=>"Montserrat", "value"=>"MS"), + array("label"=>"Morocco", "value"=>"MA"), + array("label"=>"Mozambique", "value"=>"MZ"), + array("label"=>"Myanmar", "value"=>"MM"), + array("label"=>"Namibia", "value"=>"NA"), + array("label"=>"Nauru", "value"=>"NR"), + array("label"=>"Nepal", "value"=>"NP"), + array("label"=>"Netherlands", "value"=>"NL"), + array("label"=>"Netherlands Antilles", "value"=>"AN"), + array("label"=>"New Caledonia", "value"=>"NC"), + array("label"=>"New Zealand", "value"=>"NZ"), + array("label"=>"Nicaragua", "value"=>"NI"), + array("label"=>"Niger", "value"=>"NE"), + array("label"=>"Nigeria", "value"=>"NG"), + array("label"=>"Niue", "value"=>"NU"), + array("label"=>"Norfolk Island", "value"=>"NF"), + array("label"=>"Northern Mariana Islands", "value"=>"MP"), + array("label"=>"Norway", "value"=>"NO"), + array("label"=>"Oman", "value"=>"OM"), + array("label"=>"Pakistan", "value"=>"PK"), + array("label"=>"Palau", "value"=>"PW"), + array("label"=>"Palestinian Territories", "value"=>"PS"), + array("label"=>"Panama", "value"=>"PA"), + array("label"=>"Papua New Guinea", "value"=>"PG"), + array("label"=>"Paraguay", "value"=>"PY"), + array("label"=>"Peru", "value"=>"PE"), + array("label"=>"Philippines", "value"=>"PH"), + array("label"=>"Pitcairn", "value"=>"PN"), + array("label"=>"Poland", "value"=>"PL"), + array("label"=>"Portugal", "value"=>"PT"), + array("label"=>"Puerto Rico", "value"=>"PR"), + array("label"=>"Qatar", "value"=>"QA"), + array("label"=>"Reunion", "value"=>"RE"), + array("label"=>"Romania", "value"=>"RO"), + array("label"=>"Russian Federation", "value"=>"RU"), + array("label"=>"Rwanda", "value"=>"RW"), + array("label"=>"Saint Kitts And Nevis", "value"=>"KN"), + array("label"=>"Saint Lucia", "value"=>"LC"), + array("label"=>"Saint Vincent And The Grenadines", "value"=>"VC"), + array("label"=>"Samoa", "value"=>"WS"), + array("label"=>"San Marino", "value"=>"SM"), + array("label"=>"Sao Tome And Principe", "value"=>"ST"), + array("label"=>"Saudi Arabia", "value"=>"SA"), + array("label"=>"Senegal", "value"=>"SN"), + array("label"=>"Seychelles", "value"=>"SC"), + array("label"=>"Sierra Leone", "value"=>"SL"), + array("label"=>"Singapore", "value"=>"SG"), + array("label"=>"Slovakia (Slovak Republic)", "value"=>"SK"), + array("label"=>"Slovenia", "value"=>"SI"), + array("label"=>"Solomon Islands", "value"=>"SB"), + array("label"=>"Somalia", "value"=>"SO"), + array("label"=>"South Africa", "value"=>"ZA"), + array("label"=>"South Georgia And South Sandwich", "value"=>"GS"), + array("label"=>"Spain", "value"=>"ES"), + array("label"=>"Sri Lanka", "value"=>"LK"), + array("label"=>"St. Helena", "value"=>"SH"), + array("label"=>"St. Pierre And Miquelon", "value"=>"PM"), + array("label"=>"Sudan", "value"=>"SD"), + array("label"=>"Suriname", "value"=>"SR"), + array("label"=>"Svalbard And Jan Mayen Islands", "value"=>"SJ"), + array("label"=>"Swaziland", "value"=>"SZ"), + array("label"=>"Sweden", "value"=>"SE"), + array("label"=>"Switzerland", "value"=>"CH"), + array("label"=>"Syrian Arab Republic", "value"=>"SY"), + array("label"=>"Taiwan, Province Of China", "value"=>"TW"), + array("label"=>"Tajikistan", "value"=>"TJ"), + array("label"=>"Tanzania, United Republic Of", "value"=>"TZ"), + array("label"=>"Thailand", "value"=>"TH"), + array("label"=>"Togo", "value"=>"TG"), + array("label"=>"Tokelau", "value"=>"TK"), + array("label"=>"Tonga", "value"=>"TO"), + array("label"=>"Trinidad And Tobago", "value"=>"TT"), + array("label"=>"Tunisia", "value"=>"TN"), + array("label"=>"Turkey", "value"=>"TR"), + array("label"=>"Turkmenistan", "value"=>"TM"), + array("label"=>"Turks And Caicos Islands", "value"=>"TC"), + array("label"=>"Tuvalu", "value"=>"TV"), + array("label"=>"Uganda", "value"=>"UG"), + array("label"=>"Ukraine", "value"=>"UA"), + array("label"=>"United Arab Emirates", "value"=>"AE"), + array("label"=>"United Kingdom", "value"=>"UK"), + array("label"=>"United States", "value"=>"US"), + array("label"=>"United States Minor Outlying Islands", "value"=>"UM"), + array("label"=>"Uruguay", "value"=>"UY"), + array("label"=>"Uzbekistan", "value"=>"UZ"), + array("label"=>"Vanuatu", "value"=>"VU"), + array("label"=>"Vatican City State (Holy See)", "value"=>"VA"), + array("label"=>"Venezuela", "value"=>"VE"), + array("label"=>"Viet Nam", "value"=>"VN"), + array("label"=>"Virgin Islands (British)", "value"=>"VG"), + array("label"=>"Virgin Islands (U.S.)", "value"=>"VI"), + array("label"=>"Wallis And Futuna Islands", "value"=>"WF"), + array("label"=>"Western Sahara", "value"=>"EH"), + array("label"=>"Yemen", "value"=>"YE"), + array("label"=>"Yugoslavia", "value"=>"YU"), + array("label"=>"Zaire", "value"=>"ZR"), + array("label"=>"Zambia", "value"=>"ZM"), + array("label"=>"Zimbabwe", "value"=>"ZW"), + array("label"=>"Undefined", "value"=>"N/A") + ); + + function Customers(&$SOAPEngine) { + $this->filters = array( + 'username' => trim($_REQUEST['username_filter']), + 'firstName' => trim($_REQUEST['firstName_filter']), + 'lastName' => trim($_REQUEST['lastName_filter']), + 'email' => trim($_REQUEST['email_filter']), + 'organization' => trim($_REQUEST['organization_filter']), + 'only_resellers' => trim($_REQUEST['only_resellers_filter']) + ); + + $this->Records(&$SOAPEngine); + } + + function listRecords() { + + // Filter + $filter=array('username' => $this->filters['username'], + 'firstName' => $this->filters['firstName'], + 'lastName' => $this->filters['lastName'], + 'email' => $this->filters['email'], + 'organization' => $this->filters['organization'], + 'only_resellers' => $this->filters['only_resellers'], + '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'] = 'customer'; + 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 + ); + + $this->showSeachForm(); + + // Insert credetials + $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); + + // Call function + if ($this->adminonly && $this->filters['only_resellers']) { + $result = $this->SOAPEngine->soapclient->getResellers($Query); + } else { + $result = $this->SOAPEngine->soapclient->getCustomers($Query); + } + + if (PEAR::isError($result)) { + $error_msg = $result->getMessage(); + $error_fault= $result->getFault(); + $error_code = $result->getCode(); + printf ("

Error from %s: %s (%s): %s",$this->SOAPEngine->SOAPurl,$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); + return false; + } else { + + $this->rows = $result->total; + + if ($this->rows && $_REQUEST['action'] != 'PerformActions' && $_REQUEST['action'] != 'Delete') { + $this->showActionsForm(); + } + + print " + + +
$this->rows records found
+

+ + + "; + print" + + + + + + + + "; + + if (!$this->next) $this->next=0; + + if ($this->rows > $this->maxrowsperpage) { + $maxrows = $this->maxrowsperpage + $this->next; + if ($maxrows > $this->rows) $maxrows = $this->maxrowsperpage; + } else { + $maxrows=$this->rows; + } + + $i=0; + + if ($this->rows) { + while ($i < $maxrows) { + + if (!$result->accounts[$i]) break; + + $customer = $result->accounts[$i]; + + $index = $this->next+$i+1; + + $rr=floor($index/2); + $mod=$index-$rr*2; + + if ($mod ==0) { + $bgcolor="lightgrey"; + } else { + $bgcolor="white"; + } + + $_url = $this->url.sprintf("&service=%s&action=Delete&customer_filter=%s", + urlencode($this->SOAPEngine->service), + urlencode($customer->id) + ); + + if ($_REQUEST['action'] == 'Delete' && + $_REQUEST['customer_filter'] == $customer->id) { + $_url .= "&confirm=1"; + $actionText = "Confirm"; + } else { + $actionText = "Delete"; + } + + $_customer_url = $this->url.sprintf("&service=%s&customer_filter=%s", + urlencode($this->SOAPEngine->service), + urlencode($customer->id) + ); + + printf(" + + + + + + + + + + ", + $bgcolor, + $index, + $_customer_url, + $customer->reseller, + $customer->id, + $customer->firstName, + $customer->lastName, + $customer->organization, + $customer->email, + $customer->tel, + $customer->web, + $_url, + $actionText + ); + + $i++; + } + } + + print "
Id + "; + if ($this->version > 1) print "CustomerNameOrganizationE-mailTelephoneWebAction
%s%s.%s%s %s%s%s%s%s%s
"; + + + if ($this->rows == 1 ) { + $this->showRecord($customer->id); + } else { + $this->showPagination($maxrows); + } + + return true; + } + } + + function showSeachFormCustom() { + if (!$this->filters['reseller']) { + printf (".",$this->filters['customer']); + } + printf (" Username",$this->filters['username']); + if ($this->adminonly) { + if ($this->filters['only_resellers']) $check_only_resellers_filter='checked'; + printf (" Resellers",$check_only_resellers_filter); + } + } + + function deleteRecord() { + if (!$_REQUEST['confirm']) { + print "

Please press on Confirm to confirm the delete. "; + return 1; + } + + if (!strlen($this->filters['customer']) || !strlen($this->filters['customer'])) { + print "

Error: missing customer id. "; + return 0; + } + + $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); + $result = $this->SOAPEngine->soapclient->deleteAccount(intval($this->filters['customer'])); + + if (PEAR::isError($result)) { + $error_msg = $result->getMessage(); + $error_fault= $result->getFault(); + $error_code = $result->getCode(); + printf ("

Error from %s: %s (%s): %s",$this->SOAPEngine->SOAPurl,$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); + return false; + } else { + printf ("

Customer id %s has been deleted. ",$this->filters['customer']); + unset($this->filters); + return 1; + } + } + + function getCustomer($id) { + + $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); + $result = $this->SOAPEngine->soapclient->getAccount(intval($id)); + + if (PEAR::isError($result)) { + $error_msg = $result->getMessage(); + $error_fault= $result->getFault(); + $error_code = $result->getCode(); + printf ("

Error from %s: %s (%s): %s",$this->SOAPEngine->SOAPurl,$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); + return false; + } else { + return $result; + } + } + + function showRecord($id) { + + if (!$customer = $this->getCustomer($id)) { + return false; + } + + print ""; + print " + + + + +
+

Customer data

+ "; + printf ("",$_SERVER['PHP_SELF']); + print ""; + print ""; + + print " + "; + + printf (" + + + "); + foreach ($this->customerFieldsReadOnly as $item) { + printf (" + + + ", + ucfirst($item), + $customer->$item + ); + } + foreach (array_keys($this->customerFields) as $item) { + if ($this->customerFields[$item]['name']) { + $item_name=$this->customerFields[$item]['name']; + } else { + $item_name=ucfirst($item); + } + + if ($item=='timezone') { + printf (" + ", + $item_name + ); + print " + + "; + } else if ($item=='country') { + printf (" + ", + $item_name + ); + print " + + "; + + + } else if ($item=='state') { + printf (" + ", + $item_name + ); + + print " + + "; + + } else { + if ($this->customerFields[$item]['type'] == 'text') { + printf (" + + + ", + $item_name, + $item, + $customer->$item + ); + } else { + printf (" + + + ", + $item_name, + $item, + $customer->$item + ); + } + } + } + + $this->printFiltersToForm(); + + $this->printHiddenFormElements(); + + print ""; + print " +
+
FieldValue
%s%s
%s"; + + $this->showTimezones($customer->$item); + + print "
%s + +
%s + +
%s
%s
+ "; + + /* + print "
";
+        print_r($customer);
+        print "
"; + */ + + foreach ($customer->properties as $_property) { + if (in_array($_property->name,array_keys($this->propertiesItems))) { + $this->propertiesItems[$_property->name]['value']=$_property->value; + } + } + + + print "
+

Customer properties

+ "; + printf ("",$_SERVER['PHP_SELF']); + print ""; + print ""; + print " + "; + + printf (" + + + + "); + + foreach (array_keys($this->propertiesItems) as $item) { + $item_print=ucfirst (preg_replace("/_/"," ",$item)); + printf (" + + + + ", + $item_print, + $item, + $this->propertiesItems[$item]['value'], + $this->propertiesItems[$item]['name'] + ); + } + + $this->printFiltersToForm(); + + $this->printHiddenFormElements(); + + print ""; + + print " +
+
PropertyValueDescription
%s%s
+
+ "; + } + + function updateRecord () { + //print "

Updating customer ..."; + + if (!$_REQUEST['customer_filter']) return; + + if (!$customer=$this->getCustomer($_REQUEST['customer_filter'])) { + return false; + } + + $properties=array(); + + if ($_REQUEST['section'] == 'customer_properties') { + foreach (array_keys($this->propertiesItems) as $item) { + $var_name=$item.'_form'; + $properties[]=array('name' => $item, + 'value' => trim($_REQUEST[$var_name]), + 'category' => $this->propertiesItems[$item]['category'] + ); + + } + + $customer->properties=$properties; + + } else { + foreach (array_keys($this->customerFields) as $item) { + $var_name=$item.'_form'; + //printf ("
%s=%s",$var_name,$_REQUEST[$var_name]); + if ($this->customerFields[$item]['type'] == 'integer') { + $customer->$item = intval($_REQUEST[$var_name]); + } else { + $customer->$item = trim($_REQUEST[$var_name]); + } + } + + foreach ($customer->properties as $_property) { + $properties[]=$_property; + } + $customer->properties=$properties; + } + + /* + print "

";
+        print_r($customer);
+        print "
"; + */ + + $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); + $result = $this->SOAPEngine->soapclient->updateAccount($customer); + + if (PEAR::isError($result)) { + $error_msg = $result->getMessage(); + $error_fault= $result->getFault(); + $error_code = $result->getCode(); + printf ("

Error from %s: %s (%s): %s",$this->SOAPEngine->SOAPurl,$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); + return false; + } else { + return true; + } + } + + function showTimezones($timezone) { + if (!$fp = fopen("timezones", "r")) { + print _("Failed to open timezone file."); + return false; + } + + print ""; + } +} + +class recordsGenerator { + function recordsGenerator() { + } + + function showAddForm() { + print " +

+ + + "; + printf ("",$_SERVER['PHP_SELF']); + print " + + + "; + $this->printHiddenFormElements(); + + print " + + +
+ "; + + print " + + "; + + printf (" Name"); + + $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); + $result = $this->SOAPEngine->soapclient->getGatewayGroups(); + + printf (" Group: "); + + // Compose query + $Query=array('filter' => array('name'=>''), + 'orderBy' => array('attribute' => 'name', + 'direction' => 'ASC' + ), + 'range' => array('start' => 0, + 'count' => 1000) + ); + + $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); + $result = $this->SOAPEngine->soapclient->getGatewayGroups($Query); + + if (PEAR::isError($result)) { + $error_msg = $result->getMessage(); + $error_fault= $result->getFault(); + $error_code = $result->getCode(); + printf ("

Error from %s: %s (%s): %s",$this->SOAPEngine->SOAPurl,$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); + return false; + } else { + print ""); + } + printf (" Address"); + printf (" Strip: "; + printf (" Prefix"); + + print " +

+ "; + print " +
+ "; + } + +} + +class Actions { + var $actions=array(); + var $version = 1; + + function Actions(&$SOAPEngine) { + $this->SOAPEngine = $SOAPEngine; + $this->version = $this->SOAPEngine->version; + $this->adminonly = $this->SOAPEngine->adminonly; + } + + function performActions($selectionKeys,$action,$sub_action_parameter) { + } + + function showActionsForm($filters,$sorting,$hideParameter=false) { + if (!count($this->actions)) return; + + print " +

+ + + "; + + printf ("",$_SERVER['PHP_SELF']); + print " + + + "; + + foreach (array_keys($filters) as $_filter) { + printf ("\n", $_filter,$filters[$_filter]); + } + + foreach (array_keys($sorting) as $_sorting) { + printf ("\n", $_sorting,$sorting[$_sorting]); + } + + printf("",$this->SOAPEngine->service); + + foreach (array_keys($this->SOAPEngine->extraFormElements) as $element) { + if (!strlen($this->SOAPEngine->extraFormElements[$element])) continue; + printf ("\n",$element,$this->SOAPEngine->extraFormElements[$element]); + } + print " + + +
+ "; + + print " + + + "; + if ($this->adminonly) { + print " + adminonly> + "; + } + + + print ""; + + + if (!$hideParameter) { + print " + + "; + } + print " + + "; + print " +
+ "; + + } +} + +class SIPAccountsActions extends Actions { + var $actions=array('block' => 'Block SIP accounts', + 'deblock' => 'Deblock SIP accounts', + 'enable_pstn' => 'Enable access to PSTN for the SIP accounts', + 'disable_pstn' => 'Disable access to PSTN for the SIP accounts', + 'deblock_quota' => 'Deblock SIP accounts blocked by quota', + 'prepaid' => 'Make SIP accounts prepaid', + 'postpaid' => 'Make SIP accounts postpaid', + 'delete' => 'Delete SIP accounts', + 'setquota' => 'Set quota of SIP account to:', + 'rpidasusername' => 'Set PSTN caller ID as the username', + 'prefixtorpid' => 'Add to PSTN caller ID this prefix:', + 'rmdsfromrpid' => 'Remove from PSTN caller ID digits:', + 'addtogroup' => 'Add SIP accounts to group:', + 'removefromgroup'=> 'Remove SIP accounts from group:', + 'addbalance' => 'Add to prepaid balance value:', + 'changeowner' => 'Change owner to:' + ); + + function SIPAccountsActions(&$SOAPEngine) { + $this->Actions(&$SOAPEngine); + if ($this->version > 1) { + $this->actions['changecustomer']='Change customer to:'; + } + } + + function performActions($selectionKeys,$action,$sub_action_parameter) { + if (!in_array($action,array_keys($this->actions))) { + print "Error: Invalid action $action"; + return false; + } + + print "

    "; + foreach($selectionKeys as $key) { + print "
  1. "; + + flush(); + //printf ("Performing action=%s on key=%s",$action,$key); + + $account=array('username' => $key['username'], + 'domain' => $key['domain'] + ); + + if ($action=='block') { + + $function=array('commit' => array('name' => 'addToGroup', + 'parameters' => array($account,'block'), + 'logs' => array('success' => sprintf('SIP account %s@%s has been blocked',$key['username'],$key['domain']) + ) + ) + + ); + + $this->SOAPEngine->execute($function); + + } else if ($action=='deblock') { + + $function=array('commit' => array('name' => 'removeFromGroup', + 'parameters' => array($account,'block'), + 'logs' => array('success' => sprintf('SIP account %s@%s has been de-blocked',$key['username'],$key['domain']) + ) + ) + + ); + + $this->SOAPEngine->execute($function); + + } else if ($action=='removefromgroup') { + if (!strlen($sub_action_parameter)) { + printf ("Error: you must enter a group name"); + break; + } + + $function=array('commit' => array('name' => 'removeFromGroup', + 'parameters' => array($account,$sub_action_parameter), + 'logs' => array('success' => sprintf('SIP account %s@%s has been removed from group',$key['username'],$key['domain'],$sub_action_parameter) + ) + ) + + ); + + $this->SOAPEngine->execute($function); + + } else if ($action=='addtogroup') { + if (!strlen($sub_action_parameter)) { + printf ("Error: you must enter a group name"); + break; + } + + $function=array('commit' => array('name' => 'addToGroup', + 'parameters' => array($account,$sub_action_parameter), + 'logs' => array('success' => sprintf('SIP account %s@%s is now in group %s',$key['username'],$key['domain'],$sub_action_parameter) + ) + ) + + ); + + $this->SOAPEngine->execute($function); + + } else if ($action=='deblock_quota') { + + $function=array('commit' => array('name' => 'removeFromGroup', + 'parameters' => array($account,'quota'), + 'logs' => array('success' => sprintf('SIP account %s@%s has been deblocked from quota',$key['username'],$key['domain']) + ) + ) + + ); + + $this->SOAPEngine->execute($function); + + } else if ($action=='disable_pstn') { + + $function=array('commit' => array('name' => 'removeFromGroup', + 'parameters' => array($account,'free-pstn'), + 'logs' => array('success' => sprintf('SIP account %s@%s has no access to the PSTN',$key['username'],$key['domain']) + ) + ) + + ); + + $this->SOAPEngine->execute($function); + + } else if ($action=='enable_pstn') { + + $function=array('commit' => array('name' => 'addToGroup', + 'parameters' => array($account,'free-pstn'), + 'logs' => array('success' => sprintf('SIP account %s@%s has access to the PSTN',$key['username'],$key['domain']) + ) + ) + + ); + + $this->SOAPEngine->execute($function); + + } else if ($action=='delete') { + + $function=array('commit' => array('name' => 'deleteAccount', + 'parameters' => array($account), + 'logs' => array('success' => sprintf('SIP account %s@%s has been deleted',$key['username'],$key['domain']) + ) + ) + + ); + + $this->SOAPEngine->execute($function); + + } else if ($action=='prepaid') { + $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); + $result = $this->SOAPEngine->soapclient->getAccount($account); + + if (PEAR::isError($result)) { + $error_msg = $result->getMessage(); + $error_fault= $result->getFault(); + $error_code = $result->getCode(); + printf ("Error: %s (%s): %s",$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); + break; + } else { + //print_r($result); + // Sanitize data types due to PHP bugs + + if (!is_array($result->properties)) $result->properties=array(); + if (!is_array($result->groups)) $result->groups=array(); + $result->quota = intval($result->quota); + $result->answerTimeout = intval($result->answerTimeout); + + $result->prepaid=1; + + $function=array('commit' => array('name' => 'updateAccount', + 'parameters' => array($result), + 'logs' => array('success' => sprintf('SIP account %s@%s is now prepaid',$key['username'],$key['domain']) + ) + ) + + ); + $this->SOAPEngine->execute($function); + } + } else if ($action=='postpaid') { + $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); + $result = $this->SOAPEngine->soapclient->getAccount($account); + + if (PEAR::isError($result)) { + $error_msg = $result->getMessage(); + $error_fault= $result->getFault(); + $error_code = $result->getCode(); + printf ("Error: %s (%s): %s",$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); + break; + } else { + //print_r($result); + // Sanitize data types due to PHP bugs + + if (!is_array($result->properties)) $result->properties=array(); + if (!is_array($result->groups)) $result->groups=array(); + $result->quota = intval($result->quota); + $result->answerTimeout = intval($result->answerTimeout); + + $result->prepaid=0; + + $function=array('commit' => array('name' => 'updateAccount', + 'parameters' => array($result), + 'logs' => array('success' => sprintf('SIP account %s@%s is now postpaid',$key['username'],$key['domain']) + ) + ) + + ); + $this->SOAPEngine->execute($function); + + } + } else if ($action=='setquota') { + $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); + $result = $this->SOAPEngine->soapclient->getAccount($account); + + if (PEAR::isError($result)) { + $error_msg = $result->getMessage(); + $error_fault= $result->getFault(); + $error_code = $result->getCode(); + printf ("Error: %s (%s): %s",$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); + break; + } else { + //print_r($result); + // Sanitize data types due to PHP bugs + + if (!is_array($result->properties)) $result->properties=array(); + if (!is_array($result->groups)) $result->groups=array(); + $result->quota = intval($sub_action_parameter); + $result->answerTimeout = intval($result->answerTimeout); + + $function=array('commit' => array('name' => 'updateAccount', + 'parameters' => array($result), + 'logs' => array('success' => sprintf('SIP account %s@%s has quota set to %s',$key['username'],$key['domain'],$sub_action_parameter) + ) + ) + + ); + $this->SOAPEngine->execute($function); + + } + + } else if ($action=='rmdsfromrpid') { + $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); + $result = $this->SOAPEngine->soapclient->getAccount($account); + + if (PEAR::isError($result)) { + $error_msg = $result->getMessage(); + $error_fault= $result->getFault(); + $error_code = $result->getCode(); + printf ("Error: %s (%s): %s",$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); + break; + } else { + //print_r($result); + // Sanitize data types due to PHP bugs + + if (!is_array($result->properties)) $result->properties=array(); + if (!is_array($result->groups)) $result->groups=array(); + if (is_numeric($sub_action_parameter) && strlen($result->rpid) > $sub_action_parameter) { + printf("%s %s",$result->rpid,$sub_action_parameter); + $result->rpid=substr($result->rpid,$sub_action_parameter); + printf("%s %s",$result->rpid,$sub_action_parameter); + } else { + printf ("Error: '%s' must be numeric and less than caller if length",$sub_action_parameter); + continue; + } + + $result->quota = intval($result->quota); + $result->answerTimeout = intval($result->answerTimeout); + + $function=array('commit' => array('name' => 'updateAccount', + 'parameters' => array($result), + 'logs' => array('success' => sprintf('SIP account %s@%s has PSTN caller ID set to %s',$key['username'],$key['domain'],$result->rpid) + ) + ) + + ); + $this->SOAPEngine->execute($function); + + } + } else if ($action=='rpidasusername') { + $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); + $result = $this->SOAPEngine->soapclient->getAccount($account); + + if (PEAR::isError($result)) { + $error_msg = $result->getMessage(); + $error_fault= $result->getFault(); + $error_code = $result->getCode(); + printf ("Error: %s (%s): %s",$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); + break; + } else { + //print_r($result); + // Sanitize data types due to PHP bugs + + if (!is_array($result->properties)) $result->properties=array(); + if (!is_array($result->groups)) $result->groups=array(); + if (is_numeric($key['username'])) $result->rpid=$key['username']; + + $result->quota = intval($result->quota); + $result->answerTimeout = intval($result->answerTimeout); + + $function=array('commit' => array('name' => 'updateAccount', + 'parameters' => array($result), + 'logs' => array('success' => sprintf('SIP account %s@%s has PSTN caller ID set to %s',$key['username'],$key['domain'],$key['username']) + ) + ) + + ); + $this->SOAPEngine->execute($function); + + } + } else if ($action=='prefixtorpid') { + $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); + $result = $this->SOAPEngine->soapclient->getAccount($account); + + if (PEAR::isError($result)) { + $error_msg = $result->getMessage(); + $error_fault= $result->getFault(); + $error_code = $result->getCode(); + printf ("Error: %s (%s): %s",$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); + break; + } else { + //print_r($result); + // Sanitize data types due to PHP bugs + + if (!is_array($result->properties)) $result->properties=array(); + if (!is_array($result->groups)) $result->groups=array(); + if (is_numeric($sub_action_parameter)) { + $result->rpid=$sub_action_parameter.$result->rpid; + } else { + printf ("Error: '%s' must be numeric",$sub_action_parameter); + continue; + } + $result->quota = intval($result->quota); + $result->answerTimeout = intval($result->answerTimeout); + + $function=array('commit' => array('name' => 'updateAccount', + 'parameters' => array($result), + 'logs' => array('success' => sprintf('SIP account %s@%s has PSTN caller ID set to %s ',$key['username'],$key['domain'],$result->rpid) + ) + ) + + ); + $this->SOAPEngine->execute($function); + + } + } else if ($action=='changecustomer' && $this->version > 1) { + $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); + $result = $this->SOAPEngine->soapclient->getAccount($account); + + if (PEAR::isError($result)) { + $error_msg = $result->getMessage(); + $error_fault= $result->getFault(); + $error_code = $result->getCode(); + printf ("Error: %s (%s): %s",$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); + break; + } else { + //print_r($result); + // Sanitize data types due to PHP bugs + + if (!is_array($result->properties)) $result->properties=array(); + if (!is_array($result->groups)) $result->groups=array(); + if (is_numeric($sub_action_parameter)) { + $result->customer=intval($sub_action_parameter); + } else { + printf ("Error: '%s' must be numeric",$sub_action_parameter); + continue; + } + $result->quota = intval($result->quota); + $result->answerTimeout = intval($result->answerTimeout); + + $function=array('commit' => array('name' => 'updateAccount', + 'parameters' => array($result), + 'logs' => array('success' => sprintf('SIP account %s@%s has customer set to %s ',$key['username'],$key['domain'],$result->customer) + ) + ) + + ); + $this->SOAPEngine->execute($function); + + } + } else if ($action=='changeowner') { + $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); + $result = $this->SOAPEngine->soapclient->getAccount($account); + + if (PEAR::isError($result)) { + $error_msg = $result->getMessage(); + $error_fault= $result->getFault(); + $error_code = $result->getCode(); + printf ("Error: %s (%s): %s",$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); + break; + } else { + //print_r($result); + // Sanitize data types due to PHP bugs + + if (!is_array($result->properties)) $result->properties=array(); + if (!is_array($result->groups)) $result->groups=array(); + if (is_numeric($sub_action_parameter)) { + $result->owner=intval($sub_action_parameter); + } else { + printf ("Error: '%s' must be numeric",$sub_action_parameter); + continue; + } + $result->quota = intval($result->quota); + $result->answerTimeout = intval($result->answerTimeout); + + $function=array('commit' => array('name' => 'updateAccount', + 'parameters' => array($result), + 'logs' => array('success' => sprintf('SIP account %s@%s has owner set to %s ',$key['username'],$key['domain'],$result->customer) + ) + ) + + ); + $this->SOAPEngine->execute($function); + + } + } else if ($action=='addbalance') { + if (!is_numeric($sub_action_parameter)) { + printf ("Error: you must enter a positive balance"); + break; + } + + $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); + $result = $this->SOAPEngine->soapclient->getAccount($account); + + if (PEAR::isError($result)) { + $error_msg = $result->getMessage(); + $error_fault= $result->getFault(); + $error_code = $result->getCode(); + printf ("Error: %s (%s): %s",$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); + break; + } + + if (!$result->prepaid) { + printf ("Info: SIP account %s@%s is not prepaid, no action performed",$key['username'],$key['domain']); + continue; + } + + $function=array('commit' => array('name' => 'addBalance', + 'parameters' => array($account,$sub_action_parameter), + 'logs' => array('success' => sprintf('SIP account %s@%s balance has been increased with %s',$key['username'],$key['domain'],$sub_action_parameter) + ) + ) + + ); + $this->SOAPEngine->execute($function); + + } + } + print "
"; + + } + +} + +class SIPAliasesActions extends Actions { + var $actions=array( + 'delete' => 'Delete SIP aliases' + ); + + function SIPAliases(&$SOAPEngine) { + $this->Actions(&$SOAPEngine); + } + + function performActions($selectionKeys,$action,$sub_action_parameter) { + if (!in_array($action,array_keys($this->actions))) { + print "Error: Invalid action $action"; + return false; + } + + print "
    "; + foreach($selectionKeys as $key) { + print "
  1. "; + flush(); + + //printf ("Performing action=%s on key=%s",$action,$key); + $alias=array('username' => $key['username'], + 'domain' => $key['domain'] + ); + + if ($action=='delete') { + + $function=array('commit' => array('name' => 'deleteAlias', + 'parameters' => array($alias), + 'logs' => array('success' => sprintf('SIP alias %s@%s has been deleted',$key['username'],$key['domain']) + ) + ) + + ); + + //$this->SOAPEngine->execute($function); + } + } + print "
"; + + } + +} + +class ENUMMappingsActions extends Actions { + var $actions=array( + 'delete' => 'Delete ENUM mappings', + 'changettl' => 'Change TTL to:', + 'changeowner' => 'Change owner to:' + ); + + function ENUMMappingsActions(&$SOAPEngine) { + $this->Actions(&$SOAPEngine); + } + + function performActions($selectionKeys,$action,$sub_action_parameter) { + if (!in_array($action,array_keys($this->actions))) { + print "Error: Invalid action $action"; + return false; + } + + print "
    "; + foreach($selectionKeys as $key) { + flush(); + print "
  1. "; + + $enum_id=array('number' => $key['number'], + 'tld' => $key['tld'] + ); + if ($action=='delete') { + + //printf ("Performing action=%s on key=%s",$action,$key); + $function=array('commit' => array('name' => 'deleteNumber', + 'parameters' => array($enum_id), + 'logs' => array('success' => sprintf('ENUM number +%s under %s has been deleted',$key['number'],$key['tld']) + ) + ) + + ); + + $this->SOAPEngine->execute($function); + } else if ($action == 'changettl') { + $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); + $number = $this->SOAPEngine->soapclient->getNumber($enum_id); + + if (PEAR::isError($number)) { + $error_msg = $number->getMessage(); + $error_fault= $number->getFault(); + $error_code = $number->getCode(); + printf ("Error: %s (%s): %s",$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); + break; + } else { + foreach ($number->mappings as $_property) { + $mappings[]=$_property; + } + $number->mappings=$mappings; + + if (is_numeric($sub_action_parameter)) { + $number->ttl=intval($sub_action_parameter); + } else { + printf ("Error: TTL '%s' must be numeric",$sub_action_parameter); + continue; + } + + $function=array('commit' => array('name' => 'updateNumber', + 'parameters' => array($number), + 'logs' => array('success' => sprintf('ENUM number %s@%s has now TTL %d',$key['number'],$key['tld'],intval($sub_action_parameter)) + ) + ) + + ); + $this->SOAPEngine->execute($function); + } + } else if ($action == 'changeowner') { + $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); + $number = $this->SOAPEngine->soapclient->getNumber($enum_id); + + if (PEAR::isError($number)) { + $error_msg = $number->getMessage(); + $error_fault= $number->getFault(); + $error_code = $number->getCode(); + printf ("Error: %s (%s): %s",$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); + break; + } else { + foreach ($number->mappings as $_property) { + $mappings[]=$_property; + } + $number->mappings=$mappings; + + if (is_numeric($sub_action_parameter)) { + $number->owner=intval($sub_action_parameter); + } else { + printf ("Error: Owner '%s' must be numeric",$sub_action_parameter); + continue; + } + + $function=array('commit' => array('name' => 'updateNumber', + 'parameters' => array($number), + 'logs' => array('success' => sprintf('ENUM number %s@%s has owner set to %d',$key['number'],$key['tld'],intval($sub_action_parameter)) + ) + ) + + ); + $this->SOAPEngine->execute($function); + } + } + } + + print "
"; + + } + +} + +?> addfile ./provisioning/ngnpro_soap_library.phtml hunk ./provisioning/ngnpro_soap_library.phtml 1 +headersOut as $_header) { + if ($_header->name == $soap_value[0]) { + return true; + } + } + } + + if (is_a($soap_value,'soap_header')) { + $this->headersOut[] =& $soap_value; + } else if (gettype($soap_value) == 'array') { + // name, value, namespace, mustunderstand, actor + $this->headersOut[] =& new SOAP_Header($soap_value[0], NULL, $soap_value[1], $soap_value[2], $soap_value[3]);; + } else { + $this->_raiseSoapFault("Don't understand the header info you provided. Must be array or SOAP_Header."); + } + } +} + +class WebService_NGNPro_SipPort extends SOAP_Client_Custom +{ + function WebService_NGNPro_SipPort($url) +{ + $this->SOAP_Client_Custom($url, 0); + } + function &addDomain($domain) { + return $this->call("addDomain", + $v = array("domain"=>$domain), + array('namespace'=>'urn:AGProjects:NGNPro:Sip', + 'soapaction'=>'', + 'style'=>'rpc', + 'use'=>'encoded' )); + } + function &deleteDomain($domain) { + return $this->call("deleteDomain", + $v = array("domain"=>$domain), + array('namespace'=>'urn:AGProjects:NGNPro:Sip', + 'soapaction'=>'', + 'style'=>'rpc', + 'use'=>'encoded' )); + } + function &getDomains($query) { + // query is a ComplexType SipDomainQuery, + //refer to wsdl for more info + $query =& new SOAP_Value('query','{urn:AGProjects:NGNPro}SipDomainQuery',$query); + return $this->call("getDomains", + $v = array("query"=>$query), + array('namespace'=>'urn:AGProjects:NGNPro:Sip', + 'soapaction'=>'', + 'style'=>'rpc', + 'use'=>'encoded' )); + } + function &getDomainStatistics($filter) { + return $this->call("getDomainStatistics", + $v = array("filter"=>$filter), + array('namespace'=>'urn:AGProjects:NGNPro:Sip', + 'soapaction'=>'', + 'style'=>'rpc', + 'use'=>'encoded' )); + } + function &addTrustedPeer($peer) { + // peer is a ComplexType TrustedPeer, + //refer to wsdl for more info + $peer =& new SOAP_Value('peer','{urn:AGProjects:NGNPro}TrustedPeer',$peer); + return $this->call("addTrustedPeer", + $v = array("peer"=>$peer), + array('namespace'=>'urn:AGProjects:NGNPro:Sip', + 'soapaction'=>'', + 'style'=>'rpc', + 'use'=>'encoded' )); + } + function &deleteTrustedPeer($ip) { + return $this->call("deleteTrustedPeer", + $v = array("ip"=>$ip), + array('namespace'=>'urn:AGProjects:NGNPro:Sip', + 'soapaction'=>'', + 'style'=>'rpc', + 'use'=>'encoded' )); + } + function &getTrustedPeers($query) { + // query is a ComplexType TrustedPeerQuery, + //refer to wsdl for more info + $query =& new SOAP_Value('query','{urn:AGProjects:NGNPro}TrustedPeerQuery',$query); + return $this->call("getTrustedPeers", + $v = array("query"=>$query), + array('namespace'=>'urn:AGProjects:NGNPro:Sip', + 'soapaction'=>'', + 'style'=>'rpc', + 'use'=>'encoded' )); + } + function &addAccount($account) { + // account is a ComplexType SipAccount, + //refer to wsdl for more info + $account =& new SOAP_Value('account','{urn:AGProjects:NGNPro}SipAccount',$account); + return $this->call("addAccount", + $v = array("account"=>$account), + array('namespace'=>'urn:AGProjects:NGNPro:Sip', + 'soapaction'=>'', + 'style'=>'rpc', + 'use'=>'encoded' )); + } + function &updateAccount($account) { + // account is a ComplexType SipAccount, + //refer to wsdl for more info + $account =& new SOAP_Value('account','{urn:AGProjects:NGNPro}SipAccount',$account); + return $this->call("updateAccount", + $v = array("account"=>$account), + array('namespace'=>'urn:AGProjects:NGNPro:Sip', + 'soapaction'=>'', + 'style'=>'rpc', + 'use'=>'encoded' )); + } + function &deleteAccount($sipId) { + // sipId is a ComplexType SipId, + //refer to wsdl for more info + $sipId =& new SOAP_Value('sipId','{urn:AGProjects:NGNPro}SipId',$sipId); + return $this->call("deleteAccount", + $v = array("sipId"=>$sipId), + array('namespace'=>'urn:AGProjects:NGNPro:Sip', + 'soapaction'=>'', + 'style'=>'rpc', + 'use'=>'encoded' )); + } + function &getAccount($sipId) { + // sipId is a ComplexType SipId, + //refer to wsdl for more info + $sipId =& new SOAP_Value('sipId','{urn:AGProjects:NGNPro}SipId',$sipId); + return $this->call("getAccount", + $v = array("sipId"=>$sipId), + array('namespace'=>'urn:AGProjects:NGNPro:Sip', + 'soapaction'=>'', + 'style'=>'rpc', + 'use'=>'encoded' )); + } + function &getAccounts($query) { + // query is a ComplexType SipQuery, + //refer to wsdl for more info + $query =& new SOAP_Value('query','{urn:AGProjects:NGNPro}SipQuery',$query); + return $this->call("getAccounts", + $v = array("query"=>$query), + array('namespace'=>'urn:AGProjects:NGNPro:Sip', + 'soapaction'=>'', + 'style'=>'rpc', + 'use'=>'encoded' )); + } + function &addAlias($alias) { + // alias is a ComplexType SipAlias, + //refer to wsdl for more info + $alias =& new SOAP_Value('alias','{urn:AGProjects:NGNPro}SipAlias',$alias); + return $this->call("addAlias", + $v = array("alias"=>$alias), + array('namespace'=>'urn:AGProjects:NGNPro:Sip', + 'soapaction'=>'', + 'style'=>'rpc', + 'use'=>'encoded' )); + } + function &updateAlias($alias) { + // alias is a ComplexType SipAlias, + //refer to wsdl for more info + $alias =& new SOAP_Value('alias','{urn:AGProjects:NGNPro}SipAlias',$alias); + return $this->call("updateAlias", + $v = array("alias"=>$alias), + array('namespace'=>'urn:AGProjects:NGNPro:Sip', + 'soapaction'=>'', + 'style'=>'rpc', + 'use'=>'encoded' )); + } + function &deleteAlias($id) { + // id is a ComplexType SipId, + //refer to wsdl for more info + $id =& new SOAP_Value('id','{urn:AGProjects:NGNPro}SipId',$id); + return $this->call("deleteAlias", + $v = array("id"=>$id), + array('namespace'=>'urn:AGProjects:NGNPro:Sip', + 'soapaction'=>'', + 'style'=>'rpc', + 'use'=>'encoded' )); + } + function &getAlias($id) { + // id is a ComplexType SipId, + //refer to wsdl for more info + $id =& new SOAP_Value('id','{urn:AGProjects:NGNPro}SipId',$id); + return $this->call("getAlias", + $v = array("id"=>$id), + array('namespace'=>'urn:AGProjects:NGNPro:Sip', + 'soapaction'=>'', + 'style'=>'rpc', + 'use'=>'encoded' )); + } + function &getAliasesForAccount($target) { + // target is a ComplexType SipId, + //refer to wsdl for more info + $target =& new SOAP_Value('target','{urn:AGProjects:NGNPro}SipId',$target); + return $this->call("getAliasesForAccount", + $v = array("target"=>$target), + array('namespace'=>'urn:AGProjects:NGNPro:Sip', + 'soapaction'=>'', + 'style'=>'rpc', + 'use'=>'encoded' )); + } + function &getAliases($query) { + // query is a ComplexType AliasQuery, + //refer to wsdl for more info + $query =& new SOAP_Value('query','{urn:AGProjects:NGNPro}AliasQuery',$query); + return $this->call("getAliases", + $v = array("query"=>$query), + array('namespace'=>'urn:AGProjects:NGNPro:Sip', + 'soapaction'=>'', + 'style'=>'rpc', + 'use'=>'encoded' )); + } + function &addToGroup($sipId, $group) { + return $this->call("addToGroup", + $v = array("sipId"=>$sipId, "group"=>$group), + array('namespace'=>'urn:AGProjects:NGNPro:Sip', + 'soapaction'=>'', + 'style'=>'rpc', + 'use'=>'encoded' )); + } + function &removeFromGroup($sipId, $group) { + return $this->call("removeFromGroup", + $v = array("sipId"=>$sipId, "group"=>$group), + array('namespace'=>'urn:AGProjects:NGNPro:Sip', + 'soapaction'=>'', + 'style'=>'rpc', + 'use'=>'encoded' )); + } + function &getGroups($sipId) { + // sipId is a ComplexType SipId, + //refer to wsdl for more info + $sipId =& new SOAP_Value('sipId','{urn:AGProjects:NGNPro}SipId',$sipId); + return $this->call("getGroups", + $v = array("sipId"=>$sipId), + array('namespace'=>'urn:AGProjects:NGNPro:Sip', + 'soapaction'=>'', + 'style'=>'rpc', + 'use'=>'encoded' )); + } + function &addBalance($sipId, $value) { + return $this->call("addBalance", + $v = array("sipId"=>$sipId, "value"=>$value), + array('namespace'=>'urn:AGProjects:NGNPro:Sip', + 'soapaction'=>'', + 'style'=>'rpc', + 'use'=>'encoded' )); + } + function &addBalanceFromVoucher($sipId, $card) { + // card is a ComplexType PrepaidCard, + //refer to wsdl for more info + $card =& new SOAP_Value('card','{urn:AGProjects:NGNPro}PrepaidCard',$card); + return $this->call("addBalanceFromVoucher", + $v = array("sipId"=>$sipId, "card"=>$card), + array('namespace'=>'urn:AGProjects:NGNPro:Sip', + 'soapaction'=>'', + 'style'=>'rpc', + 'use'=>'encoded' )); + } + function &getPrepaidStatus($sipId) { + // sipId is a ComplexType SipId, + //refer to wsdl for more info + $sipId =& new SOAP_Value('sipId','{urn:AGProjects:NGNPro}SipId',$sipId); + return $this->call("getPrepaidStatus", + $v = array("sipId"=>$sipId), + array('namespace'=>'urn:AGProjects:NGNPro:Sip', + 'soapaction'=>'', + 'style'=>'rpc', + 'use'=>'encoded' )); + } + function &getCreditHistory($sipId) { + // sipId is a ComplexType SipId, + //refer to wsdl for more info + $sipId =& new SOAP_Value('sipId','{urn:AGProjects:NGNPro}SipId',$sipId); + return $this->call("getCreditHistory", + $v = array("sipId"=>$sipId), + array('namespace'=>'urn:AGProjects:NGNPro:Sip', + 'soapaction'=>'', + 'style'=>'rpc', + 'use'=>'encoded' )); + } + function &addPhonebookEntry($sipId, $entry) { + // entry is a ComplexType PhonebookEntry, + //refer to wsdl for more info + $entry =& new SOAP_Value('entry','{urn:AGProjects:NGNPro}PhonebookEntry',$entry); + return $this->call("addPhonebookEntry", + $v = array("sipId"=>$sipId, "entry"=>$entry), + array('namespace'=>'urn:AGProjects:NGNPro:Sip', + 'soapaction'=>'', + 'style'=>'rpc', + 'use'=>'encoded' )); + } + function &updatePhonebookEntry($sipId, $entry) { + // entry is a ComplexType PhonebookEntry, + //refer to wsdl for more info + $entry =& new SOAP_Value('entry','{urn:AGProjects:NGNPro}PhonebookEntry',$entry); + return $this->call("updatePhonebookEntry", + $v = array("sipId"=>$sipId, "entry"=>$entry), + array('namespace'=>'urn:AGProjects:NGNPro:Sip', + 'soapaction'=>'', + 'style'=>'rpc', + 'use'=>'encoded' )); + } + function &deletePhonebookEntry($sipId, $uri) { + return $this->call("deletePhonebookEntry", + $v = array("sipId"=>$sipId, "uri"=>$uri), + array('namespace'=>'urn:AGProjects:NGNPro:Sip', + 'soapaction'=>'', + 'style'=>'rpc', + 'use'=>'encoded' )); + } + function &getPhonebookEntries($sipId, $match, $range) { + // range is a ComplexType Range, + //refer to wsdl for more info + $range =& new SOAP_Value('range','{urn:AGProjects:NGNPro}Range',$range); + return $this->call("getPhonebookEntries", + $v = array("sipId"=>$sipId, "match"=>$match, "range"=>$range), + array('namespace'=>'urn:AGProjects:NGNPro:Sip', + 'soapaction'=>'', + 'style'=>'rpc', + 'use'=>'encoded' )); + } + function &setRejectMembers($sipId, $members) { + // members is a ComplexType StringArray, + //refer to wsdl for more info + $members =& new SOAP_Value('members','{urn:AGProjects:NGNPro}StringArray',$members); + return $this->call("setRejectMembers", + $v = array("sipId"=>$sipId, "members"=>$members), + array('namespace'=>'urn:AGProjects:NGNPro:Sip', + 'soapaction'=>'', + 'style'=>'rpc', + 'use'=>'encoded' )); + } + function &getRejectMembers($sipId) { + // sipId is a ComplexType SipId, + //refer to wsdl for more info + $sipId =& new SOAP_Value('sipId','{urn:AGProjects:NGNPro}SipId',$sipId); + return $this->call("getRejectMembers", + $v = array("sipId"=>$sipId), + array('namespace'=>'urn:AGProjects:NGNPro:Sip', + 'soapaction'=>'', + 'style'=>'rpc', + 'use'=>'encoded' )); + } + function &setAcceptRules($sipId, $rules) { + // rules is a ComplexType AcceptRules, + //refer to wsdl for more info + $rules =& new SOAP_Value('rules','{urn:AGProjects:NGNPro}AcceptRules',$rules); + return $this->call("setAcceptRules", + $v = array("sipId"=>$sipId, "rules"=>$rules), + array('namespace'=>'urn:AGProjects:NGNPro:Sip', + 'soapaction'=>'', + 'style'=>'rpc', + 'use'=>'encoded' )); + } + function &getAcceptRules($sipId) { + // sipId is a ComplexType SipId, + //refer to wsdl for more info + $sipId =& new SOAP_Value('sipId','{urn:AGProjects:NGNPro}SipId',$sipId); + return $this->call("getAcceptRules", + $v = array("sipId"=>$sipId), + array('namespace'=>'urn:AGProjects:NGNPro:Sip', + 'soapaction'=>'', + 'style'=>'rpc', + 'use'=>'encoded' )); + } + function &setBarringPrefixes($sipId, $prefixes) { + // prefixes is a ComplexType StringArray, + //refer to wsdl for more info + $prefixes =& new SOAP_Value('prefixes','{urn:AGProjects:NGNPro}StringArray',$prefixes); + return $this->call("setBarringPrefixes", + $v = array("sipId"=>$sipId, "prefixes"=>$prefixes), + array('namespace'=>'urn:AGProjects:NGNPro:Sip', + 'soapaction'=>'', + 'style'=>'rpc', + 'use'=>'encoded' )); + } + function &getBarringPrefixes($sipId) { + // sipId is a ComplexType SipId, + //refer to wsdl for more info + $sipId =& new SOAP_Value('sipId','{urn:AGProjects:NGNPro}SipId',$sipId); + return $this->call("getBarringPrefixes", + $v = array("sipId"=>$sipId), + array('namespace'=>'urn:AGProjects:NGNPro:Sip', + 'soapaction'=>'', + 'style'=>'rpc', + 'use'=>'encoded' )); + } + function &setCallDiversions($sipId, $diversions) { + // diversions is a ComplexType CallDiversions, + //refer to wsdl for more info + $diversions =& new SOAP_Value('diversions','{urn:AGProjects:NGNPro}CallDiversions',$diversions); + return $this->call("setCallDiversions", + $v = array("sipId"=>$sipId, "diversions"=>$diversions), + array('namespace'=>'urn:AGProjects:NGNPro:Sip', + 'soapaction'=>'', + 'style'=>'rpc', + 'use'=>'encoded' )); + } + function &getCallDiversions($sipId) { + // sipId is a ComplexType SipId, + //refer to wsdl for more info + $sipId =& new SOAP_Value('sipId','{urn:AGProjects:NGNPro}SipId',$sipId); + return $this->call("getCallDiversions", + $v = array("sipId"=>$sipId), + array('namespace'=>'urn:AGProjects:NGNPro:Sip', + 'soapaction'=>'', + 'style'=>'rpc', + 'use'=>'encoded' )); + } + function &getCalls($sipId, $query) { + // query is a ComplexType CallsQuery, + //refer to wsdl for more info + $query =& new SOAP_Value('query','{urn:AGProjects:NGNPro}CallsQuery',$query); + return $this->call("getCalls", + $v = array("sipId"=>$sipId, "query"=>$query), + array('namespace'=>'urn:AGProjects:NGNPro:Sip', + 'soapaction'=>'', + 'style'=>'rpc', + 'use'=>'encoded' )); + } + function &getCallStatistics($sipId, $query) { + // query is a ComplexType CallsQuery, + //refer to wsdl for more info + $query =& new SOAP_Value('query','{urn:AGProjects:NGNPro}CallsQuery',$query); + return $this->call("getCallStatistics", + $v = array("sipId"=>$sipId, "query"=>$query), + array('namespace'=>'urn:AGProjects:NGNPro:Sip', + 'soapaction'=>'', + 'style'=>'rpc', + 'use'=>'encoded' )); + } + function &getSipDeviceLocations($sipIds) { + // sipIds is a ComplexType SipIdArray, + //refer to wsdl for more info + $sipIds =& new SOAP_Value('sipIds','{urn:AGProjects:NGNPro}SipIdArray',$sipIds); + return $this->call("getSipDeviceLocations", + $v = array("sipIds"=>$sipIds), + array('namespace'=>'urn:AGProjects:NGNPro:Sip', + 'soapaction'=>'', + 'style'=>'rpc', + 'use'=>'encoded' )); + } + function &getTrace($nodeIP, $callID, $fromTag) { + return $this->call("getTrace", + $v = array("nodeIP"=>$nodeIP, "callID"=>$callID, "fromTag"=>$fromTag), + array('namespace'=>'urn:AGProjects:NGNPro:Sip', + 'soapaction'=>'', + 'style'=>'rpc', + 'use'=>'encoded' )); + } +} +class WebService_NGNPro_VoicemailPort extends SOAP_Client_Custom +{ + function WebService_NGNPro_VoicemailPort($url) +{ + $this->SOAP_Client_Custom($url, 0); + } + function &addAccount($account) { + // account is a ComplexType VoicemailAccount, + //refer to wsdl for more info + $account =& new SOAP_Value('account','{urn:AGProjects:NGNPro}VoicemailAccount',$account); + return $this->call("addAccount", + $v = array("account"=>$account), + array('namespace'=>'urn:AGProjects:NGNPro:Voicemail', + 'soapaction'=>'', + 'style'=>'rpc', + 'use'=>'encoded' )); + } + function &updateAccount($account) { + // account is a ComplexType VoicemailAccount, + //refer to wsdl for more info + $account =& new SOAP_Value('account','{urn:AGProjects:NGNPro}VoicemailAccount',$account); + return $this->call("updateAccount", + $v = array("account"=>$account), + array('namespace'=>'urn:AGProjects:NGNPro:Voicemail', + 'soapaction'=>'', + 'style'=>'rpc', + 'use'=>'encoded' )); + } + function &deleteAccount($sipId) { + // sipId is a ComplexType SipId, + //refer to wsdl for more info + $sipId =& new SOAP_Value('sipId','{urn:AGProjects:NGNPro}SipId',$sipId); + return $this->call("deleteAccount", + $v = array("sipId"=>$sipId), + array('namespace'=>'urn:AGProjects:NGNPro:Voicemail', + 'soapaction'=>'', + 'style'=>'rpc', + 'use'=>'encoded' )); + } + function &getAccount($sipId) { + // sipId is a ComplexType SipId, + //refer to wsdl for more info + $sipId =& new SOAP_Value('sipId','{urn:AGProjects:NGNPro}SipId',$sipId); + return $this->call("getAccount", + $v = array("sipId"=>$sipId), + array('namespace'=>'urn:AGProjects:NGNPro:Voicemail', + 'soapaction'=>'', + 'style'=>'rpc', + 'use'=>'encoded' )); + } + function &setAnnouncement($sipId, $message) { + return $this->call("setAnnouncement", + $v = array("sipId"=>$sipId, "message"=>$message), + array('namespace'=>'urn:AGProjects:NGNPro:Voicemail', + 'soapaction'=>'', + 'style'=>'rpc', + 'use'=>'encoded' )); + } +} +class WebService_NGNPro_EnumPort extends SOAP_Client_Custom +{ + function WebService_NGNPro_EnumPort($url) +{ + $this->SOAP_Client_Custom($url, 0); + } + function &addRange($range) { + // range is a ComplexType EnumRange, + //refer to wsdl for more info + $range =& new SOAP_Value('range','{urn:AGProjects:NGNPro}EnumRange',$range); + return $this->call("addRange", + $v = array("range"=>$range), + array('namespace'=>'urn:AGProjects:NGNPro:Enum', + 'soapaction'=>'', + 'style'=>'rpc', + 'use'=>'encoded' )); + } + function &deleteRange($range) { + // range is a ComplexType EnumRangeId, + //refer to wsdl for more info + $range =& new SOAP_Value('range','{urn:AGProjects:NGNPro}EnumRangeId',$range); + return $this->call("deleteRange", + $v = array("range"=>$range), + array('namespace'=>'urn:AGProjects:NGNPro:Enum', + 'soapaction'=>'', + 'style'=>'rpc', + 'use'=>'encoded' )); + } + function &getRanges($query) { + // query is a ComplexType EnumRangeQuery, + //refer to wsdl for more info + $query =& new SOAP_Value('query','{urn:AGProjects:NGNPro}EnumRangeQuery',$query); + return $this->call("getRanges", + $v = array("query"=>$query), + array('namespace'=>'urn:AGProjects:NGNPro:Enum', + 'soapaction'=>'', + 'style'=>'rpc', + 'use'=>'encoded' )); + } + function &addNumber($number) { + // number is a ComplexType EnumNumber, + //refer to wsdl for more info + $number =& new SOAP_Value('number','{urn:AGProjects:NGNPro}EnumNumber',$number); + return $this->call("addNumber", + $v = array("number"=>$number), + array('namespace'=>'urn:AGProjects:NGNPro:Enum', + 'soapaction'=>'', + 'style'=>'rpc', + 'use'=>'encoded' )); + } + function &updateNumber($number) { + // number is a ComplexType EnumNumber, + //refer to wsdl for more info + $number =& new SOAP_Value('number','{urn:AGProjects:NGNPro}EnumNumber',$number); + return $this->call("updateNumber", + $v = array("number"=>$number), + array('namespace'=>'urn:AGProjects:NGNPro:Enum', + 'soapaction'=>'', + 'style'=>'rpc', + 'use'=>'encoded' )); + } + function &deleteNumber($enumId) { + // enumId is a ComplexType EnumId, + //refer to wsdl for more info + $enumId =& new SOAP_Value('enumId','{urn:AGProjects:NGNPro}EnumId',$enumId); + return $this->call("deleteNumber", + $v = array("enumId"=>$enumId), + array('namespace'=>'urn:AGProjects:NGNPro:Enum', + 'soapaction'=>'', + 'style'=>'rpc', + 'use'=>'encoded' )); + } + function &getNumber($enumId) { + // enumId is a ComplexType EnumId, + //refer to wsdl for more info + $enumId =& new SOAP_Value('enumId','{urn:AGProjects:NGNPro}EnumId',$enumId); + return $this->call("getNumber", + $v = array("enumId"=>$enumId), + array('namespace'=>'urn:AGProjects:NGNPro:Enum', + 'soapaction'=>'', + 'style'=>'rpc', + 'use'=>'encoded' )); + } + function &getNumbers($query) { + // query is a ComplexType EnumQuery, + //refer to wsdl for more info + $query =& new SOAP_Value('query','{urn:AGProjects:NGNPro}EnumQuery',$query); + return $this->call("getNumbers", + $v = array("query"=>$query), + array('namespace'=>'urn:AGProjects:NGNPro:Enum', + 'soapaction'=>'', + 'style'=>'rpc', + 'use'=>'encoded' )); + } +} +class WebService_NGNPro_RatingPort extends SOAP_Client_Custom +{ + function WebService_NGNPro_RatingPort($url) +{ + $this->SOAP_Client_Custom($url, 0); + } + function &setEntityProfiles($profiles) { + // profiles is a ComplexType RatingEntityProfiles, + //refer to wsdl for more info + $profiles =& new SOAP_Value('profiles','{urn:AGProjects:NGNPro}RatingEntityProfiles',$profiles); + return $this->call("setEntityProfiles", + $v = array("profiles"=>$profiles), + array('namespace'=>'urn:AGProjects:NGNPro:Rating', + 'soapaction'=>'', + 'style'=>'rpc', + 'use'=>'encoded' )); + } + function &deleteEntityProfiles($entity) { + return $this->call("deleteEntityProfiles", + $v = array("entity"=>$entity), + array('namespace'=>'urn:AGProjects:NGNPro:Rating', + 'soapaction'=>'', + 'style'=>'rpc', + 'use'=>'encoded' )); + } + function &getEntityProfiles($entity) { + return $this->call("getEntityProfiles", + $v = array("entity"=>$entity), + array('namespace'=>'urn:AGProjects:NGNPro:Rating', + 'soapaction'=>'', + 'style'=>'rpc', + 'use'=>'encoded' )); + } +} +class WebService_NGNPro_CustomerPort extends SOAP_Client_Custom +{ + function WebService_NGNPro_CustomerPort($url) +{ + $this->SOAP_Client_Custom($url, 0); + } + function &addAccount($account) { + // account is a ComplexType CustomerAccount, + //refer to wsdl for more info + $account =& new SOAP_Value('account','{urn:AGProjects:NGNPro}CustomerAccount',$account); + return $this->call("addAccount", + $v = array("account"=>$account), + array('namespace'=>'urn:AGProjects:NGNPro:Customer', + 'soapaction'=>'', + 'style'=>'rpc', + 'use'=>'encoded' )); + } + function &updateAccount($account) { + // account is a ComplexType CustomerAccount, + //refer to wsdl for more info + $account =& new SOAP_Value('account','{urn:AGProjects:NGNPro}CustomerAccount',$account); + return $this->call("updateAccount", + $v = array("account"=>$account), + array('namespace'=>'urn:AGProjects:NGNPro:Customer', + 'soapaction'=>'', + 'style'=>'rpc', + 'use'=>'encoded' )); + } + function &deleteAccount($id) { + return $this->call("deleteAccount", + $v = array("id"=>$id), + array('namespace'=>'urn:AGProjects:NGNPro:Customer', + 'soapaction'=>'', + 'style'=>'rpc', + 'use'=>'encoded' )); + } + function &getAccount($id) { + return $this->call("getAccount", + $v = array("id"=>$id), + array('namespace'=>'urn:AGProjects:NGNPro:Customer', + 'soapaction'=>'', + 'style'=>'rpc', + 'use'=>'encoded' )); + } + function &getCustomers($query) { + // query is a ComplexType CustomerQuery, + //refer to wsdl for more info + $query =& new SOAP_Value('query','{urn:AGProjects:NGNPro}CustomerQuery',$query); + return $this->call("getCustomers", + $v = array("query"=>$query), + array('namespace'=>'urn:AGProjects:NGNPro:Customer', + 'soapaction'=>'', + 'style'=>'rpc', + 'use'=>'encoded' )); + } + function &getResellers($query) { + // query is a ComplexType CustomerQuery, + //refer to wsdl for more info + $query =& new SOAP_Value('query','{urn:AGProjects:NGNPro}CustomerQuery',$query); + return $this->call("getResellers", + $v = array("query"=>$query), + array('namespace'=>'urn:AGProjects:NGNPro:Customer', + 'soapaction'=>'', + 'style'=>'rpc', + 'use'=>'' )); + } + +} +class WebService_NGNPro_NetworkPort extends SOAP_Client_Custom +{ + function WebService_NGNPro_NetworkPort($url) +{ + $this->SOAP_Client_Custom($url, 0); + } + function &addGateway($gateway) { + // gateway is a ComplexType Gateway, + //refer to wsdl for more info + $gateway =& new SOAP_Value('gateway','{urn:AGProjects:NGNPro}Gateway',$gateway); + return $this->call("addGateway", + $v = array("gateway"=>$gateway), + array('namespace'=>'urn:AGProjects:NGNPro:Network', + 'soapaction'=>'', + 'style'=>'rpc', + 'use'=>'encoded' )); + } + function &deleteGateway($name) { + return $this->call("deleteGateway", + $v = array("name"=>$name), + array('namespace'=>'urn:AGProjects:NGNPro:Network', + 'soapaction'=>'', + 'style'=>'rpc', + 'use'=>'encoded' )); + } + function &getGateways($query) { + // query is a ComplexType GatewayQuery, + //refer to wsdl for more info + $query =& new SOAP_Value('query','{urn:AGProjects:NGNPro}GatewayQuery',$query); + return $this->call("getGateways", + $v = array("query"=>$query), + array('namespace'=>'urn:AGProjects:NGNPro:Network', + 'soapaction'=>'', + 'style'=>'rpc', + 'use'=>'encoded' )); + } + function &addGatewayGroup($group) { + return $this->call("addGatewayGroup", + $v = array("group"=>$group), + array('namespace'=>'urn:AGProjects:NGNPro:Network', + 'soapaction'=>'', + 'style'=>'rpc', + 'use'=>'encoded' )); + } + function &deleteGatewayGroup($group) { + return $this->call("deleteGatewayGroup", + $v = array("group"=>$group), + array('namespace'=>'urn:AGProjects:NGNPro:Network', + 'soapaction'=>'', + 'style'=>'rpc', + 'use'=>'encoded' )); + } + function &getGatewayGroups($query) { + // query is a ComplexType GatewayGroupQuery, + //refer to wsdl for more info + $query =& new SOAP_Value('query','{urn:AGProjects:NGNPro}GatewayGroupQuery',$query); + return $this->call("getGatewayGroups", + $v = array("query"=>$query), + array('namespace'=>'urn:AGProjects:NGNPro:Network', + 'soapaction'=>'', + 'style'=>'rpc', + 'use'=>'encoded' )); + } + function &addRoutes($routes) { + // routes is a ComplexType RouteArray, + //refer to wsdl for more info + $routes =& new SOAP_Value('routes','{urn:AGProjects:NGNPro}RouteArray',$routes); + return $this->call("addRoutes", + $v = array("routes"=>$routes), + array('namespace'=>'urn:AGProjects:NGNPro:Network', + 'soapaction'=>'', + 'style'=>'rpc', + 'use'=>'encoded' )); + } + function &deleteRoutes($routes) { + // routes is a ComplexType RouteArray, + //refer to wsdl for more info + $routes =& new SOAP_Value('routes','{urn:AGProjects:NGNPro}RouteArray',$routes); + return $this->call("deleteRoutes", + $v = array("routes"=>$routes), + array('namespace'=>'urn:AGProjects:NGNPro:Network', + 'soapaction'=>'', + 'style'=>'rpc', + 'use'=>'encoded' )); + } + function &getRoutes($query) { + // query is a ComplexType RouteQuery, + //refer to wsdl for more info + $query =& new SOAP_Value('query','{urn:AGProjects:NGNPro}RouteQuery',$query); + return $this->call("getRoutes", + $v = array("query"=>$query), + array('namespace'=>'urn:AGProjects:NGNPro:Network', + 'soapaction'=>'', + 'style'=>'rpc', + 'use'=>'encoded' )); + } +} +class WebService_SoapSIMPLEProxy_PresencePort extends SOAP_Client_Custom +{ + function WebService_SoapSIMPLEProxy_PresencePort($url) +{ + $this->SOAP_Client_Custom($url, 0); + } + function &setPresenceInformation($sipId, $password, $information) { + // information is a ComplexType PresenceInformation, + //refer to wsdl for more info + $information =& new SOAP_Value('information','{urn:AGProjects:SoapSIMPLEProxy}PresenceInformation',$information); + return $this->call("setPresenceInformation", + $v = array("sipId"=>$sipId, "password"=>$password, "information"=>$information), + array('namespace'=>'urn:AGProjects:SoapSIMPLEProxy:Presence', + 'soapaction'=>'', + 'style'=>'rpc', + 'use'=>'encoded' )); + } + function &getPresenceInformation($sipId, $password) { + return $this->call("getPresenceInformation", + $v = array("sipId"=>$sipId, "password"=>$password), + array('namespace'=>'urn:AGProjects:SoapSIMPLEProxy:Presence', + 'soapaction'=>'', + 'style'=>'rpc', + 'use'=>'encoded' )); + } + function &deletePresenceInformation($sipId, $password) { + return $this->call("deletePresenceInformation", + $v = array("sipId"=>$sipId, "password"=>$password), + array('namespace'=>'urn:AGProjects:SoapSIMPLEProxy:Presence', + 'soapaction'=>'', + 'style'=>'rpc', + 'use'=>'encoded' )); + } + function &getWatchers($presentityId) { + // presentityId is a ComplexType SipId, + //refer to wsdl for more info + $presentityId =& new SOAP_Value('presentityId','{urn:AGProjects:SoapSIMPLEProxy}SipId',$presentityId); + return $this->call("getWatchers", + $v = array("presentityId"=>$presentityId), + array('namespace'=>'urn:AGProjects:SoapSIMPLEProxy:Presence', + 'soapaction'=>'', + 'style'=>'rpc', + 'use'=>'encoded' )); + } + function &setPolicy($sipId, $password, $policy) { + // policy is a ComplexType PresencePolicy, + //refer to wsdl for more info + $policy =& new SOAP_Value('policy','{urn:AGProjects:SoapSIMPLEProxy}PresencePolicy',$policy); + return $this->call("setPolicy", + $v = array("sipId"=>$sipId, "password"=>$password, "policy"=>$policy), + array('namespace'=>'urn:AGProjects:SoapSIMPLEProxy:Presence', + 'soapaction'=>'', + 'style'=>'rpc', + 'use'=>'encoded' )); + } + function &getPolicy($sipId, $password) { + return $this->call("getPolicy", + $v = array("sipId"=>$sipId, "password"=>$password), + array('namespace'=>'urn:AGProjects:SoapSIMPLEProxy:Presence', + 'soapaction'=>'', + 'style'=>'rpc', + 'use'=>'encoded' )); + } +} +?> hunk ./provisioning/provisioning_logic.phtml 1 -recordGenerators = $recordGenerators; - $this->generatorId=$generatorId; - - $keys = array_keys($this->recordGenerators); - if (!$generatorId) $generatorId=$keys[0]; - - if (!in_array($generatorId,array_keys($this->recordGenerators))) { - return false; - } - - // sip zones - $sipEngine = $this->recordGenerators[$generatorId]['sipEngineId'].'@'.'SIP accounts'; - $this->SipSOAPEngine = new SOAPEngine($sipEngine,$soapEngines,$extraFormElements,$loginCredentials); - $_sip_class = $this->SipSOAPEngine->recordsClass; - $this->sipRecords = new $_sip_class(&$this->SipSOAPEngine); - $this->sipRecords->getAllowedDomains(); - - // enum mappings - $enumEngine = $this->recordGenerators[$generatorId]['enumEngineId'].'@'.'ENUM Numbers'; - $this->EnumSOAPEngine = new SOAPEngine($enumEngine,$soapEngines,$extraFormElements,$loginCredentials); - $_enum_class = $this->EnumSOAPEngine->recordsClass; - $this->enumRecords = new $_enum_class(&$this->EnumSOAPEngine); - $this->enumRecords->getAllowedDomains(); - } - - function generateRecords() { - print "

Generating records -

    "; - - if (!$this->checkGenerateRequest()) return false; - - $i=0; - - while ($i < $this->template['nr_records']) { - - $number = sprintf("%.0f", $this->start_padded + $i); - $username = substr($number,$this->template['strip_digits']); - $mapto = 'sip:'.$username.'@'.$this->template['domain']; - - print "
  1. "; - printf ('Generating number +%s with mapping %s ',$number,$mapto); - flush(); - - $enumMapping = array('tld' => $this->template['tld'], - 'number' => $number, - 'type' => 'sip', - 'mapto' => $mapto, - 'owner' => $this->template['owner'] - ); - - if ($this->template['create_sip']) { - $groups=array(); - if ($this->template['pstn']) $groups[]='free-pstn'; - printf ('and sip account %s@%s ',$username,$this->template['domain']); - - $sipAccount = array('account' => $username.'@'.$this->template['domain'], - 'owner' => $this->template['owner'], - 'quota' => $this->template['quota'], - 'prepaid' => $this->template['prepaid'], - 'password' => $this->template['password'], - 'groups' => $groups - ); - } else { - unset($sipAccount); - } - - if (is_array($enumMapping)) $this->enumRecords->addRecord($enumMapping); - if (is_array($sipAccount)) $this->sipRecords->addRecord($sipAccount); - - $i++; - } - - print "
"; - return true; - } - - function checkGenerateRequest() { - // check number of records - $this->template['create_sip']=trim($_REQUEST['create_sip']); - - $nr_records=trim($_REQUEST['nr_records']); - if (!is_numeric($nr_records) || $nr_records < 1 || $nr_records > 200) { - print "Error: number of records must be a number between 1 and 200."; - return false; - } - $this->template['nr_records'] = $nr_records; - - // length of generated record - $len=trim($_REQUEST['len']); - if (!is_numeric($len) || $len < 4 || $len > 15) { - print "Error: number length must be a number between 4 and 15."; - return false; - } - $this->template['len'] = $len; - - // sip domain - $domain=trim($_REQUEST['domain']); - if (!strlen($domain)) { - print "Error: SIP domain missing"; - return false; - } - $this->template['domain'] = $domain; - - $nr_start=trim($_REQUEST['nr_start']); - if (strlen($nr_start) && !is_numeric($nr_start)) { - print "Error: Use prefix must be numeric"; - return false; - } - $this->template['nr_start'] = $nr_start; - - // check ENUM TLD - list($prefix,$tld)=explode('@',trim($_REQUEST['range'])); - - $this->template['prefix'] = intval($prefix); - $this->template['tld'] = $tld; - $this->template['quota'] = intval($_REQUEST['quota']); - $this->template['owner'] = intval($_REQUEST['owner']); - $this->template['pstn'] = intval($_REQUEST['pstn']); - $this->template['prepaid'] = intval($_REQUEST['prepaid']); - $this->template['password'] = trim($_REQUEST['password']); - - /////////////////////////////////////// - // logical checks - if (strlen($this->template['nr_start'])) { - $start = $this->template['nr_start']; - } else { - $start = 0; - } - - $digits = $this->template['len']-strlen($this->template['prefix']); - $this->start_padded = $this->template['prefix'].str_pad($start,$digits,'0'); - $this->top = sprintf("%.0f", $this->start_padded + pow(10,$digits-strlen($this->template['nr_start']))); - $maxNumbers = pow(10,$digits-strlen($this->template['nr_start'])); - - if ($maxNumbers < $this->template['nr_records']) { - printf ("Error: Insufficient numbers in range, requested = %d, available = %d",$this->template['nr_records'],$maxNumbers); - return false; - } - - return true; - } - - function showGeneratorForm() { - if (!count($this->enumRecords->ranges)) return false; - print " -
- - - - - - -
- - - - -
- - "; - print _("Record generator"); - print " - -
-
- - - - - - "; - - print " - - - "; - - print " - - - - "; - - print " - - - - ",$_REQUEST['nr_start']); - print " - - - - - - "; - print " - - - - ",$_REQUEST['strip_digits']); - print " - - - "; - - if (count($this->sipRecords->allowedDomains)) { - print " - - - - "; - - print " - - - - "; - - print " - - - - ",$checked_create_sip); - - if ($_REQUEST['pstn']) { - $checked_pstn='checked'; - } else { - $checked_pstn=''; - } - - print " - - - - ",$checked_pstn); - - if ($_REQUEST['prepaid']) { - $checked_prepaid='checked'; - } else { - $checked_prepaid=''; - } - - print " - - - - ",$checked_prepaid); - - print " - - - - ",$_REQUEST['rpid_prefix']); - - print " - - - - ",$_REQUEST['quota']); - - print " - - - - ",$_REQUEST['password']); - - print " - - - - "; - print " - - - "; - - print " - - - - "; - } - - $this->printHiddenFormElements(); - - print " -
-
"; - print _("Range"); - print " - "; - - if (is_array($this->enumRecords->ranges)) { - print ""; - } - - print " -
- "; - print ""; - print _("ENUM mapping template"); - print ""; - print "
"; - print _("Use prefix:"); - printf (" - - -
"; - print _("Number length:"); - printf (" - - -
- ",$_REQUEST['len']); - - print _("SIP domain"); - print " - - "; - if (count($this->sipRecords->allowedDomains)) { - print " - "; - } else { - print ""; - } - - print " - "; - print " -
"; - print _("Strip from username"); - printf (" - first - digits -
"; - print _("Owner"); - printf (" - - ",$_REQUEST['owner']); - print " -

-
- "; - print ""; - print _("SIP account template"); - print ""; - print "
"; - print _("Create SIP records"); - if ($_REQUEST['create_sip']) { - $checked_create_sip='checked'; - } else { - $checked_create_sip=''; - } - printf (" - -
"; - print _("PSTN"); - printf (" - -
"; - print _("Prepaid"); - printf (" - -
"; - print _("Prefix Caller-ID"); - printf (" - -
"; - print _("Quota"); - printf (" - -
"; - print _("Password"); - printf (" - -
-
-
- "; - - if ($_REQUEST['nr_records']) { - $nr_records=$_REQUEST['nr_records']; - } else { - $nr_records=1; - } - print ""; - print ""; - printf (" - - ",$nr_records); - print _("records"); - print ""; - print " -
-
- -

"; - print _("Existing records will not be overwritten. "); - print "

- -
- "; - } - - function printHiddenFormElements () { - printf("",$this->generatorId); - - if ($this->adminonly) { - printf("",$this->adminonly); - } - - foreach (array_keys($this->extraFormElements) as $element) { - if (!strlen($this->extraFormElements[$element])) continue; - printf ("\n",$element,$this->extraFormElements[$element]); - } - - } - -} - -class SOAPEngine { - var $version = 1; - var $adminonly = 0; - var $reseller = 0; - var $loginType = 'reseller'; - - var $services=array( - 'SIP accounts' => array('recordsClass' => 'SipAccounts', - 'soapClass' => 'WebService_NGNPro_SipPort' - ), - 'SIP Aliases' => array('recordsClass' => 'SipAliases', - 'soapClass' => 'WebService_NGNPro_SipPort' - ), - 'SIP Domains' => array('recordsClass' => 'Domains', - 'soapClass' => 'WebService_NGNPro_SipPort' - ), - 'ENUM Numbers' => array('recordsClass' => 'EnumMappings', - 'soapClass' => 'WebService_NGNPro_EnumPort' - ), - 'ENUM Ranges' => array('recordsClass' => 'EnumRanges', - 'soapClass' => 'WebService_NGNPro_EnumPort' - ), - 'Customers' => array('recordsClass' => 'Customers', - 'soapClass' => 'WebService_NGNPro_CustomerPort' - ), - 'Trusted Peers' => array('recordsClass' => 'TrustedPeers', - 'soapClass' => 'WebService_NGNPro_SipPort' - ), - 'PSTN Gateways' => array('recordsClass' => 'Gateways', - 'soapClass' => 'WebService_NGNPro_NetworkPort' - ), - 'Gateway groups' => array('recordsClass' => 'GatewayGroups', - 'soapClass' => 'WebService_NGNPro_NetworkPort' - ), - 'PSTN Routes' => array('recordsClass' => 'Routes', - 'soapClass' => 'WebService_NGNPro_NetworkPort' - ) - ); - - function SOAPEngine($service,$soapEngines,$extraFormElements,$loginCredentials) { - - /* - $soapEngines=array( - 'mdns' => array('name'=> 'Managed DNS', - 'username'=> 'soapadmin', - 'password'=> 'passwd', - 'url' => 'http://example.com:9200/', - 'impersonate' => 1745 - ), - */ - - if ($loginCredentials['loginType'] == 'admin') $this->adminonly = 1; - - $this->loginType = $loginCredentials['loginType']; - - $this->soapEngines = $soapEngines; - - if (is_array($this->soapEngines)) { - - if (!$service) { - $_services = array_keys($this->services); - $_soapids = array_keys($this->soapEngines); - $service = $_soapids[0].'@'.$_services[0]; - } - - if (is_array($extraFormElements)) { - $this->extraFormElements = $extraFormElements; - } - - $this->service = $service; - - $_els=explode('@',$this->service); - - $this->soapEngineId = $_els[0]; - $this->soapEngineIdSettingsPage=$this->soapEngineId; - - $this->soapEnginePort = $_els[1]; - $this->recordsClass = $this->services[$this->soapEnginePort]['recordsClass']; - $this->soapClass = $this->services[$this->soapEnginePort]['soapClass']; - - foreach(array_keys($this->soapEngines) as $_key ) { - $this->skipServices[$_key]=$this->soapEngines[$_key]['skipServices']; - $this->skip[$_key]=$this->soapEngines[$_key]['skip']; - } - - if (strlen($this->soapEngines[$this->soapEngineId]['version'])) { - $this->version = $this->soapEngines[$this->soapEngineId]['version']; - } - - $this->defaultEnumTLD = $this->soapEngines[$this->soapEngineId]['defaultEnumTLD']; - - if (strlen($this->soapEngines[$this->soapEngineId]['soapEngineIdSettingsPage'])) { - $this->soapEngineIdSettingsPage=$this->soapEngines[$this->soapEngineId]['soapEngineIdSettingsPage']; - } - - if (strlen($this->soapEngines[$this->soapEngineId]['SipSettingsPage'])) { - $this->SipSettingsPage=$this->soapEngines[$this->soapEngineId]['SipSettingsPage']; - } - - if (strlen($this->soapEngines[$this->soapEngineId]['recordGenerator'])) { - $this->recordGenerator=$this->soapEngines[$this->soapEngineId]['recordGenerator']; - } - - if (strlen($loginCredentials['reseller'])) { - $this->reseller = $loginCredentials['reseller']; - } else if ($this->adminonly && $_REQUEST['reseller_filter']){ - $this->reseller = $_REQUEST['reseller_filter']; - } - - if (strlen($loginCredentials['customer'])) { - $this->customer = $loginCredentials['customer']; - } else if ($this->adminonly && $_REQUEST['customer_filter']){ - $this->customer = $_REQUEST['customer_filter']; - } - - if (strlen($loginCredentials['soapUsername'])) { - $this->soapUsername=$loginCredentials['soapUsername']; - } else if ($this->adminonly) { - $this->soapUsername=$this->soapEngines[$this->soapEngineId]['username']; - } - - //print_r($loginCredentials); - if (strlen($loginCredentials['soapUsername'])) { - $this->SOAPlogin = array( - "username" => $this->soapUsername, - "password" => $loginCredentials['soapPassword'], - "admin" => false - ); - } else { - $this->SOAPlogin = array( - "username" => $this->soapUsername, - "password" => $this->soapEngines[$this->soapEngineId]['password'], - "admin" => true, - "impersonate" => intval($this->reseller) - ); - } - - $this->SOAPurl=$this->soapEngines[$this->soapEngineId]['url']; - printf ("

Connection to %s at %s as %s/%s ",$this->soapClass,$this->SOAPurl,$this->SOAPurl,$this->soapUsername,$this->reseller); - $this->SoapAuth = array('auth', $this->SOAPlogin , 'urn:AGProjects:NGNPro', 0, ''); - - // Instantiate the SOAP client - if (!class_exists($this->soapClass)) return ; - - $this->soapclient = new $this->soapClass($this->SOAPurl); - - $this->soapclient->setOpt('curl', CURLOPT_TIMEOUT, 5); - $this->soapclient->setOpt('curl', CURLOPT_SSL_VERIFYPEER, 0); - $this->soapclient->setOpt('curl', CURLOPT_SSL_VERIFYHOST, 0); - - $this->soapRemoteId=$this->soapEngines[$this->soapEngineId]['depends']; - - if (strlen($this->soapRemoteId) && in_array($this->soapRemoteId,array_keys($this->soapEngines))) { - $this->soapEngineIdRemote = $this->soapEngines[$this->soapRemoteId]; - $impersonateRemote=intval($this->soapEngines[$this->soapRemoteId]['impersonate']); - - $this->SOAPloginRemote = array( - "username" => $this->soapEngines[$this->soapRemoteId]['username'], - "password" => $this->soapEngines[$this->soapRemoteId]['password'], - "admin" => true, - "impersonate" => $impersonateRemote - ); - - //print_r($this->SOAPloginRemote); - $this->SOAPurlRemote=$this->soapEngines[$this->soapRemoteId]['url']; - printf ("and syncronize writes at %s",$this->SOAPurlRemote,$this->SOAPurlRemote); - - $this->SoapAuthRemote = array('auth', $this->SOAPloginRemote , 'urn:AGProjects:NGNPro', 0, ''); - - // Instantiate the SOAP client depends - $this->soapclientRemote = new $this->soapClass($this->SOAPurlRemote); - - $this->soapclientRemote->setOpt('curl', CURLOPT_TIMEOUT, 5); - $this->soapclientRemote->setOpt('curl', CURLOPT_SSL_VERIFYPEER, 0); - $this->soapclientRemote->setOpt('curl', CURLOPT_SSL_VERIFYHOST, 0); - } - - if ($this->version > 1) { - $this->soapclientCustomers = new WebService_NGNPro_CustomerPort($this->SOAPurl); - $this->soapclientCustomers->setOpt('curl', CURLOPT_TIMEOUT, 5); - $this->soapclientCustomers->setOpt('curl', CURLOPT_SSL_VERIFYPEER, 0); - $this->soapclientCustomers->setOpt('curl', CURLOPT_SSL_VERIFYHOST, 0); - } - - } else { - print "Error: No SOAP credentials defined."; - } - - $this->url = $_SERVER['PHP_SELF']."?1=1"; - - foreach (array_keys($this->extraFormElements) as $element) { - if (!strlen($this->extraFormElements[$element])) continue; - $this->url .= sprintf('&%s=%s',$element,urlencode($this->extraFormElements[$element])); - } - } - - function execute($function) { - - /* - $function=array('commit' => array('name' => 'addAccount', - 'parameters' => array($param1,$param2), - 'logs' => array('success' => 'The function was a success', - 'failure' => 'The function has failed' - ) - ), - 'rollback' => array('name' => 'addAccount', - 'parameters' => array($param1,$param2), - 'logs' => array('success' => 'The function was a success', - 'failure' => 'The function has failed' - ) - ) - - ); - */ - - if (!$function['commit']['name']) { - print "Error: no function name supplied"; - return false; - } - - if (is_object($this->soapclientRemote)) { - - $this->soapclientRemote->addHeader($this->SoapAuthRemote); - - $resultRemote = call_user_func_array(array($this->soapclientRemote,$function['commit']['name']),$function['commit']['parameters']); - - if (PEAR::isError($resultRemote)) { - $error_msg=$resultRemote->getMessage(); - $error_fault=$resultRemote->getFault(); - $error_code=$resultRemote->getCode(); - printf ("

Error from %s: %s (%s): %s",$this->SOAPurlRemote,$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); - return false; - } else { - printf ("

%s %s ",$function['commit']['logs']['success'],$this->SOAPurlRemote); - - $this->soapclient->addHeader($this->SoapAuth); - $result = call_user_func_array(array($this->soapclient,$function['commit']['name']),$function['commit']['parameters']); - - if (PEAR::isError($result)) { - $error_msg=$result->getMessage(); - $error_fault=$result->getFault(); - $error_code=$result->getCode(); - printf ("

Error from %s: %s (%s): %s",$this->SOAPurl,$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); - - if ($function['rollback']['name']) { - - $this->soapclientRemote->addHeader($this->SoapAuthRemote); - $this->counterRemote++; - - $resultRemote = call_user_func_array(array($this->soapclientRemote,$function['rollback']['name']),$function['rollback']['parameters']); - - if (PEAR::isError($result)) { - $error_msg=$result->getMessage(); - $error_fault=$result->getFault(); - $error_code=$result->getCode(); - printf ("

Error roll back at %s: %s (%s): %s",$this->SOAPurl,$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); - } else { - printf ("

Rolled back action at %s ",$this->SOAPurlRemote); - } - - } - - return false; - } else { - if ($function['commit']['logs']['success']) { - printf ("

%s %s ",$function['commit']['logs']['success'],$this->SOAPurl); - } - } - } - - } else { - - $this->soapclient->addHeader($this->SoapAuth); - $result = call_user_func_array(array($this->soapclient,$function['commit']['name']),$function['commit']['parameters']); - - if (PEAR::isError($result)) { - $error_msg=$result->getMessage(); - $error_fault=$result->getFault(); - $error_code=$result->getCode(); - printf ("

Error from %s: %s (%s): %s",$this->SOAPurl,$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); - return false; - } else { - if ($function['commit']['logs']['success']) { - printf ("

%s ",$function['commit']['logs']['success']); - } - } - } - - return true; - } -} - -class Records { - var $maxrowsperpage = '15'; - var $SipSettingsPage = 'sip_settings.phtml'; - var $allowedDomains = false; - var $selectionActive = false; - var $selectionKeys = array(); - var $resellers = array(); - var $customers = array(); - var $recordGenerator = false; - - function Records(&$SOAPEngine) { - $this->SOAPEngine = &$SOAPEngine; - $this->version = $this->SOAPEngine->version; - - $this->sorting['sortBy'] = trim($_REQUEST['sortBy']); - $this->sorting['sortOrder'] = trim($_REQUEST['sortOrder']); - - $this->next = $_REQUEST['next']; - - $this->adminonly = $this->SOAPEngine->adminonly; - $this->reseller = $this->SOAPEngine->reseller; - $this->url = $this->SOAPEngine->url; - $this->loginType = $this->SOAPEngine->loginType; - - foreach(array_keys($this->filters) as $_filter) { - if (strlen($this->filters[$_filter])) { - $this->selectionActive=true; - break; - } - } - - if ($this->adminonly) { - $this->url .= sprintf('&adminonly=%s',$this->adminonly); - } - - $this->filters['customer']=trim($_REQUEST['customer_filter']); - - /* - if (!$this->adminonly && $this->reseller) { - // Force filter if reseller - $this->filters['reseller']=$this->reseller; - } else { - $this->filters['reseller']=trim($_REQUEST['reseller_filter']); - } - */ - - if ($this->adminonly) { - $this->filters['reseller']=trim($_REQUEST['reseller_filter']); - } - - $this->getResellers(); - $this->getCustomers(); - - if (strlen($this->SOAPEngine->SipSettingsPage)) $this->SipSettingsPage=$this->SOAPEngine->SipSettingsPage; - //printf ('

%s',$this->url); - } - - function showEngineSelection() { - $selected_soapEngine[$this->SOAPEngine->service]='selected'; - - printf (""); - - if ($this->version > 1) { - print "Customer"; - - if ($this->adminonly) { - $this->showResellerForm(); - if ($this->filters['reseller']) { - print "."; - $this->showCustomerForm(); - } - } else { - printf ("%s",$this->reseller); - print "."; - $this->showCustomerForm(); - } - } - } - - - function showPagination($maxrows) { - - $url .= $this->url.'&'.$this->addFiltersToURL(). - sprintf("&service=%s&sortBy=%s&sortOrder=%s", - urlencode($this->SOAPEngine->service), - urlencode($this->sorting['sortBy']), - urlencode($this->sorting['sortOrder']) - ); - - print " -

- - - - - -
- "; - - if ($this->next != 0 ) { - $show_next=$this->maxrowsperpage-$this->next; - if ($show_next < 0) { - $mod_show_next = $show_next-2*$show_next; - } - if (!$mod_show_next) $mod_show_next=0; - - if ($mod_show_next/$this->maxrowsperpage >= 1) { - printf ("Begin ",$url); - } - - printf ("Previous ",$url,$mod_show_next); - } - - print " - - "; - - if ($this->next + $this->maxrowsperpage < $this->rows) { - $show_next = $this->maxrowsperpage + $this->next; - - printf ("Next ",$url,$show_next); - } - - print " -
- "; - } - - function showSeachFormCustom() { - } - - function showSeachForm() { - print " -

- - - "; - printf ("",$_SERVER['PHP_SELF']); - print " - - - - -
- "; - $this->showEngineSelection(); - - $this->showSeachFormCustom(); - - print " - - "; - $this->showSortForm(); - - print " - - "; - $this->printHiddenFormElements(); - - print " -
- "; - - if ($_REQUEST['action'] != 'Delete') $this->showAddForm(); - } - - function listRecords() { - } - - function getRecordKeys() { - } - - function addRecord() { - } - - function deleteRecord() { - } - - function tel2enum($tel,$tld) { - - if (strlen($tld) == 0) $tld="e164.arpa"; - - // transform telephone number in FQDN Enum style domain name - if (preg_match("/^[+]?(\d+)$/",$tel,$m)) { - $l=strlen($m[1]); - $rev_num=""; - $z=0; - while ($z < $l) { - $ss=substr($m[1],$z,1); - $enum=$ss.".".$enum; - $z++; - } - preg_match("/^(.*)\.$/",$enum,$m); - $enum=$m[1]; - $enum=$enum.".$tld."; - return($enum); - } else { - return($tel); - } - } - - function showAddForm() { - if ($this->selectionActive) return; - } - - function showSortForm() { - - if (!count($this->sortElements)) { - return; - } - - $selected_sortBy[$this->sorting['sortBy']]='selected'; - - //print " Sort "; - - print ""; - - $selected_sortOrder[$this->sorting['sortOrder']]='selected'; - print ""; - } - - function showTimezones() { - if (!$fp = fopen("timezones", "r")) { - print _("Failed to open timezone file."); - return false; - } - print ""; - fclose($fp); - - } - - function printHiddenFormElements () { - printf("",$this->SOAPEngine->service); - - if ($this->adminonly) { - printf("",$this->adminonly); - } - - foreach (array_keys($this->SOAPEngine->extraFormElements) as $element) { - if (!strlen($this->SOAPEngine->extraFormElements[$element])) continue; - printf ("\n",$element,$this->SOAPEngine->extraFormElements[$element]); - } - - } - - function getAllowedDomains() { - } - - - function showActionsForm() { - if (!$this->selectionActive) { - return; - } - - $class_name=get_class($this).'Actions'; - - if (class_exists($class_name)) { - $actions=new $class_name(&$this->SOAPEngine); - $actions->showActionsForm($this->filters,$this->sorting); - } - } - - function performActions() { - $this->showSeachForm(); - - $this->getRecordKeys(); - //print_r($this->selectionKeys); - - $class_name=get_class($this).'Actions'; - - if (class_exists($class_name)) { - $actions=new $class_name(&$this->SOAPEngine); - $actions->performActions(&$this->selectionKeys,$_REQUEST['sub_action'],trim($_REQUEST['sub_action_parameter'])); - } - } - - function getCustomers() { - if (!$this->version <= 1 ) return; - - if (!$this->filters['reseller']) { - return; - } - - // Filter - $filter=array('reseller'=>intval($this->filters['reseller'])); - - $range=array('start' => 0, - 'count' => 100 - ); - - // Order - $orderBy = array('attribute' => 'customer', - 'direction' => 'ASC' - ); - - // Compose query - $Query=array('filter' => $filter, - 'orderBy' => $orderBy, - 'range' => $range - ); - - // Insert credetials - $this->SOAPEngine->soapclientCustomers->addHeader($this->SOAPEngine->SoapAuth); - - // Call function - $result = $this->SOAPEngine->soapclientCustomers->getCustomers($Query); - - if (PEAR::isError($result)) { - $error_msg = $result->getMessage(); - $error_fault= $result->getFault(); - $error_code = $result->getCode(); - printf ("

Error from %s: %s (%s): %s",$this->SOAPEngine->SOAPurl,$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); - return false; - } else { - - if ($result->total > $range['count']) return; - - if ($range['count'] <= $result->total) { - $max=$range['count']; - } else { - $max=$result->total; - } - - $i=0; - while ($i < $max) { - $customer=$result->accounts[$i]; - $this->customers[$customer->id] = $customer->firstName.' '.$customer->lastName; - $i++; - } - return true; - } - } - - function getResellers() { - if (!$this->version <= 1 ) return; - if (!$this->adminonly) { - return; - } - // Filter - $filter=array('reseller'=>intval($this->filters['reseller'])); - - $range=array('start' => 0, - 'count' => 200 - ); - - // Order - $orderBy = array('attribute' => 'customer', - 'direction' => 'ASC' - ); - - // Compose query - $Query=array('filter' => $filter, - 'orderBy' => $orderBy, - 'range' => $range - ); - - // Insert credetials - $this->SOAPEngine->soapclientCustomers->addHeader($this->SOAPEngine->SoapAuth); - - // Call function - $result = $this->SOAPEngine->soapclientCustomers->getResellers($Query); - - if (PEAR::isError($result)) { - $error_msg = $result->getMessage(); - $error_fault= $result->getFault(); - $error_code = $result->getCode(); - printf ("

Error from %s: %s (%s): %s",$this->SOAPEngine->SOAPurl,$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); - return false; - } else { - - //if ($result->total > $range['count']) return; - - if ($range['count'] <= $result->total) { - $max=$range['count']; - } else { - $max=$result->total; - } - - $i=0; - while ($i < $max) { - $reseller = $result->accounts[$i]; - - if (strlen($reseller->organization) && $reseller->organization!= 'N/A') { - $this->resellers[$reseller->id] = $reseller->organization; - } else { - $this->resellers[$reseller->id] = $reseller->firstName.' '.$reseller->lastName; - } - $i++; - } - - //print_r($this->resellers); - return true; - } - } - - function showCustomerForm($name='customer_filter') { - if (count($this->customers) && count($this->customers) < 200) { - $select_customer[$this->filters['customer']]='selected'; - printf (""; - } else { - printf ("",$name,$this->filters['customer']); - } - } - - function showResellerForm($name='reseller_filter') { - if (!$this->adminonly) return; - if (count($this->resellers) && count($this->resellers) < 200) { - $select_reseller[$this->filters['reseller']]='selected'; - printf (""; - } else { - printf ("",$name,$this->filters['reseller']); - } - } - - function addFiltersToURL() { - - $j=0; - foreach(array_keys($this->filters) as $filter) { - if (strlen(trim($this->filters[$filter]))) { - if ($j) $url .='&'; - $url .= sprintf('%s_filter=%s',$filter,urlencode(trim($this->filters[$filter]))); - } - $j++; - } - - return $url; - } - - function printFiltersToForm() { - foreach(array_keys($this->filters) as $filter) { - if (strlen(trim($this->filters[$filter]))) { - printf("",$filter,trim($this->filters[$filter])); - } - } - } - - function getRecord () { - } - - function updateRecord () { - } - - function showRecord () { - } - -} - -class Domains extends Records { - - function Domains(&$SOAPEngine) { - - $this->Records(&$SOAPEngine); - - if ($this->version > 1) { - // keep default maxrowsperpage - $this->sortElements=array('changeDate' => 'Change date', - 'domain' => 'Domain' - ); - - $this->filters = array( - 'domain' => trim($_REQUEST['domain_filter']) - ); - - } else { - $this->maxrowsperpage = 10000; - } - } - - function listRecords() { - - $this->showSeachForm(); - - if ($this->version > 1) { - - // Filter - $filter=array( - 'domain' => $this->filters['domain'], - '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); - - // Call function - $result = $this->SOAPEngine->soapclient->getDomains($Query); - } else { - // Insert credetials - $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); - - // Call function - $result = $this->SOAPEngine->soapclient->getDomains(); - } - - if (PEAR::isError($result)) { - $error_msg = $result->getMessage(); - $error_fault= $result->getFault(); - $error_code = $result->getCode(); - printf ("

Error from %s: %s (%s): %s",$this->SOAPEngine->SOAPurl,$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); - return false; - } else { - - if ($this->version > 1) { - $this->rows = $result->total; - } else { - $this->rows = count($result); - } - - if ($this->rows && $_REQUEST['action'] != 'PerformActions' && $_REQUEST['action'] != 'Delete') { - $this->showActionsForm(); - } - - print " - - -
$this->rows records found
-

- - - "; - print" - - - - - "; - - if (!$this->next) $this->next=0; - - if ($this->rows > $this->maxrowsperpage) { - $maxrows = $this->maxrowsperpage + $this->next; - if ($maxrows > $this->rows) $maxrows = $this->maxrowsperpage; - } else { - $maxrows=$this->rows; - } - - $i=0; - - if ($this->rows) { - while ($i < $maxrows) { - - if ($this->version > 1) { - if (!$result->domains[$i]) break; - $domain = $result->domains[$i]; - } else { - $domain = $result[$i]; - } - - $index = $this->next+$i+1; - - $rr=floor($index/2); - $mod=$index-$rr*2; - - if ($mod ==0) { - $bgcolor="lightgrey"; - } else { - $bgcolor="white"; - } - - if ($this->version > 1) { - $_url = $this->url.sprintf("&service=%s&action=Delete&domain_filter=%s", - urlencode($this->SOAPEngine->service), - urlencode($domain->domain) - ); - - if ($_REQUEST['action'] == 'Delete' && - $_REQUEST['domain_filter'] == $domain->domain) { - $_url .= "&confirm=1"; - $actionText = "Confirm"; - } else { - $actionText = "Delete"; - } - - $_customer_url = $this->url.sprintf("&service=%s@Customers&customer_filter=%s", - urlencode($this->SOAPEngine->soapEngineId), - urlencode($domain->customer) - ); - - printf(" - - - - - - - ", - $bgcolor, - $index, - $_customer_url, - $domain->reseller, - $domain->customer, - $domain->domain, - $domain->changeDate, - $_url, - $actionText - ); - } else { - $_url = $this->url.sprintf("&service=%s&action=Delete&domain_filter=%s", - urlencode($this->SOAPEngine->service), - urlencode($domain) - ); - - if ($_REQUEST['action'] == 'Delete' && - $_REQUEST['domain_filter'] == $domain) { - $_url .= "&confirm=1"; - $actionText = "Confirm"; - } else { - $actionText = "Delete"; - } - printf(" - - - - - - ", - $bgcolor, - $index, - $domain, - $domain->changeDate, - $_url, - $actionText - ); - } - - $i++; - } - } - - print "
Id - "; - if ($this->version > 1) print "CustomerDomainLast changeAction
%s%s.%s%s%s%s
%s%s%s%s
"; - - if ($this->version > 1) { - $this->showPagination($maxrows); - } - - return true; - } - } - - function showSeachFormCustom() { - - if ($this->version > 1) { - printf (" Domain",$this->filters['domain']); - } - } - - function deleteRecord() { - if (!$_REQUEST['confirm']) { - print "

Please press on Confirm to confirm the delete. "; - return 1; - } - - if (!strlen($this->filters['domain']) || !strlen($this->filters['domain'])) { - print "

Error: missing SIP domain. "; - return 0; - } - - $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); - - $result = $this->SOAPEngine->soapclient->deleteDomain($this->filters['domain']); - - if (PEAR::isError($result)) { - $error_msg = $result->getMessage(); - $error_fault= $result->getFault(); - $error_code = $result->getCode(); - printf ("

Error from %s: %s (%s): %s",$this->SOAPEngine->SOAPurl,$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); - return false; - } else { - printf ("

SIP domain %s has been deleted. ",$this->filters['domain']); - unset($this->filters); - return 1; - } - } - - function showAddForm() { - if ($this->selectionActive) return; - print " -

- - - "; - printf ("",$_SERVER['PHP_SELF']); - print " - - - "; - $this->printHiddenFormElements(); - - print " - - -
- "; - - print " - - "; - - printf (" Domain"); - - print "Customer"; - - if ($this->adminonly) { - $this->showResellerForm('reseller'); - print "."; - $this->showCustomerForm('customer'); - } else { - $this->showCustomerForm('customer'); - } - - print " - - "; - print " -
- "; - } - - function addRecord() { - - $domain = trim($_REQUEST['domain']); - - if ($this->adminonly) { - $reseller = trim($_REQUEST['reseller']); - $customer = trim($_REQUEST['customer']); - } else { - $reseller = $this->reseller; - $customer = trim($_REQUEST['customer']); - if (!$customer) $customer=$reseller; - } - - $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); - - if ($this->version >1 ) { - $domainStructure=array('domain' => $domain, - 'customer' => intval($customer), - 'reseller' => intval($reseller) - ); - $result = $this->SOAPEngine->soapclient->addDomain($domainStructure); - } else { - $result = $this->SOAPEngine->soapclient->addDomain($domain); - } - - if (PEAR::isError($result)) { - $error_msg = $result->getMessage(); - $error_fault= $result->getFault(); - $error_code = $result->getCode(); - printf ("

Error from %s: %s (%s): %s",$this->SOAPEngine->SOAPurl,$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); - return false; - } else { - printf ("

SIP domain %s has been added. ",$domain); - return true; - } - } - - function getRecordKeys() { - - if ($this->version > 1) { - // Filter - $filter=array( - 'domain' => $this->filters['domain'], - '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 - ); - - $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); - $result = $this->SOAPEngine->soapclient->getDomains($Query); - - } else { - $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); - $result = $this->SOAPEngine->soapclient->getDomains(); - } - - if (PEAR::isError($result)) { - $error_msg = $result->getMessage(); - $error_fault= $result->getFault(); - $error_code = $result->getCode(); - printf ("

Error in getAllowedDomains from %s: %s (%s): %s",$this->SOAPEngine->SOAPurl,$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); - //return false; - } else { - if ($this->version > 1) { - foreach ($result->domains as $_domain) { - $this->selectionKeys[]=$_domain->domain; - } - } else { - $this->selectionKeys[]=$result; - } - } - } - -} - -class SIPAccounts extends Records { - var $sortElements=array('changeDate' => 'Change date', - 'username' => 'Username', - 'domain' => 'Domain' - ); - - function SIPAccounts(&$SOAPEngine) { - $this->filters = array('username' => trim($_REQUEST['username_filter']), - 'domain' => trim($_REQUEST['domain_filter']), - 'fullname' => trim($_REQUEST['fullname_filter']) - ); - - $this->Records(&$SOAPEngine); - - } - - function getRecordKeys() { - - if (preg_match("/^(.*)@(.*)$/",$this->filters['username'],$m)) { - $this->filters['username'] = $m[1]; - $this->filters['domain'] = $m[2]; - } - - if ($this->filters['domain'] && $this->allowedDomains && !in_array($this->filters['domain'],$this->allowedDomains)) { - $this->filters['domain'] = $this->allowedDomains[0]; - } - - // Filter - $filter=array('username' => $this->filters['username'], - 'domain' => $this->filters['domain'], - 'name' => $this->filters['fullname'], - '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); - - // Call function - $result = $this->SOAPEngine->soapclient->getAccounts($Query); - - if (PEAR::isError($result)) { - $error_msg = $result->getMessage(); - $error_fault= $result->getFault(); - $error_code = $result->getCode(); - printf ("

Error from %s: %s (%s): %s",$this->SOAPEngine->SOAPurl,$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); - return false; - } else { - foreach ($result->accounts as $account) { - $this->selectionKeys[]=array('username' => $account->id->username, - 'domain' => $account->id->domain - ); - } - - return true; - } - - return false; - } - - function listRecords() { - - $this->getAllowedDomains(); - - if (preg_match("/^(.*)@(.*)$/",$this->filters['username'],$m)) { - $this->filters['username'] = $m[1]; - $this->filters['domain'] = $m[2]; - } - - // Make sure we apply the domain filter from the login credetials - if ($this->allowedDomains && !$this->filters['domain']) { - //$this->filters['domain'] = $this->allowedDomains[0]; - } - - if ($this->filters['domain'] && $this->allowedDomains && !in_array($this->filters['domain'],$this->allowedDomains)) { - $this->filters['domain'] = $this->allowedDomains[0]; - } - - $this->showSeachForm(); - - // Filter - $filter=array('username' => $this->filters['username'], - 'domain' => $this->filters['domain'], - 'name' => $this->filters['fullname'], - '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); - - // Call function - $result = $this->SOAPEngine->soapclient->getAccounts($Query); - - if (PEAR::isError($result)) { - $error_msg = $result->getMessage(); - $error_fault= $result->getFault(); - $error_code = $result->getCode(); - printf ("

Error from %s: %s (%s): %s",$this->SOAPEngine->SOAPurl,$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); - return false; - } else { - - $this->rows = $result->total; - - if ($this->rows && $_REQUEST['action'] != 'PerformActions' && $_REQUEST['action'] != 'Delete') { - $this->showActionsForm(); - } - - print " -

- - -
$this->rows records found
-

- - - "; - print" - - - - - - - - - - - "; - - if (!$this->next) $this->next=0; - - if ($this->rows > $this->maxrowsperpage) { - $maxrows = $this->maxrowsperpage + $this->next; - if ($maxrows > $this->rows) $maxrows = $this->maxrowsperpage; - } else { - $maxrows=$this->rows; - } - - $i=0; - - //print "
";
-            //print_r($result->accounts);
-
-			if ($this->rows) {
-                while ($i < $maxrows)  {
-    
-                    if (!$result->accounts[$i]) break;
-    
-                    $account = $result->accounts[$i];
-    
-                    $index=$this->next+$i+1;
-    
-                    $rr=floor($index/2);
-                    $mod=$index-$rr*2;
-            
-                    if ($mod ==0) {
-                    	$bgcolor="lightgrey";
-                    } else {
-                        $bgcolor="white";
-                    }
-
-        			$_url = $this->url.sprintf("&service=%s&action=Delete&username_filter=%s&domain_filter=%s",
-                    urlencode($this->SOAPEngine->service),
-                    urlencode($account->id->username),
-                    urlencode($account->id->domain)
-                    );
-
-                    if ($_REQUEST['action'] == 'Delete' &&
-                    	$_REQUEST['username_filter'] == $account->id->username &&
-                        $_REQUEST['domain_filter'] == $account->id->domain) {
-                		$_url .= "&confirm=1";
-                        $actionText = "Confirm";
-                    } else {
-                        $actionText = "Delete";
-                    }
-
-					if ($account->reseller) {
-                    	$resellerSipSettingsPage=$account->reseller;
-                    } else {
-                    	$resellerSipSettingsPage=$this->reseller;
-                    }
-
-                    if ($this->SipSettingsPage) {
-                        $url=sprintf('%s?account=%s@%s&reseller=%s&soapEngineIdSipPort=%s',
-                        $this->SipSettingsPage,$account->id->username,$account->id->domain,
-                        $resellerSipSettingsPage,$this->SOAPEngine->soapEngineIdSettingsPage);
-
-                        if ($this->adminonly) $url  .= sprintf('&adminonly=%s',$this->adminonly);
-
-                        foreach (array_keys($this->SOAPEngine->extraFormElements) as $element) {
-                            if (!strlen($this->SOAPEngine->extraFormElements[$element])) continue;
-                            $url  .= sprintf('&%s=%s',$element,urlencode($this->SOAPEngine->extraFormElements[$element]));
-                        }
-
-                        $sip_account=sprintf("
-                        
-                        %s@%s",$url,$account->id->username,$account->id->domain);
-                    } else {
-						$sip_account=sprintf("%s@%s",$account->id->username,$account->id->domain);
-                    }
-
-
-                    unset($groups);
-                    foreach ($account->groups as $_grp) $groups.=$_grp.' ';
-
-                    if ($this->version > 1) {
-        			$_customer_url = $this->url.sprintf("&service=%s@Customers&customer_filter=%s",
-                    urlencode($this->SOAPEngine->soapEngineId),
-                    urlencode($account->customer)
-                    );
-
-
-                    printf("
-                    
- - - - - - - - - - - - - ", - $bgcolor, - $index, - $_customer_url, - $account->reseller, - $account->customer, - $sip_account, - $account->firstName, - $account->lastName, - $account->email, - $account->email, - $account->rpid, - $account->quota, - $groups, - $account->changeDate, - $account->owner, - $_url, - $actionText - ); - } else { - printf(" - - - - - - - - - - - - - ", - $bgcolor, - $index, - $sip_account, - $account->firstName, - $account->lastName, - $account->email, - $account->email, - $account->rpid, - $account->quota, - $groups, - $account->changeDate, - $account->owner, - $_url, - $actionText - ); - } - - $i++; - } - - } - - print "
Id - "; - if ($this->version > 1) print "CustomerSIP accountNameEmailCaller IdQuotaGroupsLast changeOwnerAction
%s %s.%s%s%s %s%s%s%s%s%s%s%s
%s %s%s %s%s%s%s%s%s%s%s
"; - - $this->showPagination($maxrows); - - return true; - } - } - - function showSeachFormCustom() { - printf ("User",$this->filters['username']); - printf ("@"); - - if ($this->allowedDomains) { - $selected_domain[$this->filters['domain']]='selected'; - printf (""); - } else { - printf ("",$this->filters['domain']); - } - - printf (" Name",$this->filters['fullname']); - } - - function deleteRecord() { - if (!$_REQUEST['confirm']) { - print "

Please press on Confirm to confirm the delete. "; - return 1; - } - - if (!strlen($this->filters['username']) || !strlen($this->filters['domain'])) { - print "

Error: missing SIP account username or domain. "; - return 0; - } - - $account=array('username' => $this->filters['username'], - 'domain' => $this->filters['domain'] - ); - - $function=array('commit' => array('name' => 'deleteAccount', - 'parameters' => array($account), - 'logs' => array('success' => sprintf('

SIP account %s@%s has been deleted',$this->filters['username'],$this->filters['domain']) - ) - ) - - ); - - if ($this->SOAPEngine->execute($function)) { - unset($this->filters); - } - - return true; - } - - function showAddForm() { - if ($this->selectionActive) return; - print " -

- - - "; - printf ("",$_SERVER['PHP_SELF']); - print " - - - "; - $this->printHiddenFormElements(); - - print " - - -
- "; - - print " - - "; - - printf (" User",$_REQUEST['account']); - if (is_array($this->allowedDomains)) { - print "@"; - - } - - printf (" Pass",$_REQUEST['password']); - printf (" Name",$_REQUEST['fullname']); - printf (" Email",$_REQUEST['email']); - //printf (" CallerId",$_REQUEST['rpid']); - printf ("Owner ",$_REQUEST['owner']); - printf ("PSTN "); - printf ("Quota ",$_REQUEST['quota']); - printf ("Prepaid "); - print ""; - print "Customer"; - if ($this->adminonly) { - $this->showResellerForm('reseller'); - print "."; - $this->showCustomerForm('customer'); - } else { - $this->showCustomerForm('customer'); - } - print ""; - - print " - - "; - print " -
- "; - } - - function addRecord($dictionary=array()) { - - if ($dictionary['account']) { - $account_els = explode("@", $dictionary['account']); - } else { - $account_els = explode("@", trim($_REQUEST['account'])); - } - - if ($this->adminonly) { - if ($dictionary['reseller']) { - $reseller = $dictionary['reseller']; - } else { - $reseller = trim($_REQUEST['reseller']); - } - if ($dictionary['customer']) { - $customer = $dictionary['customer']; - } else { - $customer = trim($_REQUEST['customer']); - } - if (!$customer) $customer=$reseller; - } else { - $reseller = $this->reseller; - - if ($dictionary['customer']) { - $customer = $dictionary['customer']; - } else { - $customer = trim($_REQUEST['customer']); - } - - if (!$customer) $customer=$reseller; - } - - $username=$account_els[0]; - - if (strlen($account_els[1])) { - $domain=$account_els[1]; - } else if ($dictionary['domain']) { - $domain=$dictionary['domain']; - } else if ($_REQUEST['domain']) { - $domain=trim($_REQUEST['domain']); - - } else { - printf ("

Error: Missing SIP domain"); - return false; - } - - if (is_array($this->allowedDomains) && !in_array($domain,$this->allowedDomains)) { - printf ("

Error: SIP domain %s is not allowed",$domain); - return false; - } - - if ($dictionary['fullname']) { - $name_els = explode(" ", $dictionary['fullname']); - } else { - $name_els = explode(" ", trim($_REQUEST['fullname'])); - } - - if (strlen($name_els[0])) { - $firstName=$name_els[0]; - } else { - $firstName='Account'; - } - - if (strlen($name_els[1])) { - $lastName=$name_els[1]; - } else { - $lastName=$username; - } - - if (strlen($dictionary['timezone'])) { - $timezone=$dictionary['timezone']; - } else if (strlen(trim($_REQUEST['timezone']))) { - $timezone=trim($_REQUEST['timezone']); - } else { - $timezone='Europe/Amsterdam'; - } - - if (strlen($dictionary['password'])) { - $password=$dictionary['password']; - } else if (strlen(trim($_REQUEST['password']))) { - $password=trim($_REQUEST['password']); - } else { - $password=$this->RandomPassword(6); - } - - $groups=array(); - if($dictionary['pstn'] || $_REQUEST['pstn']) $groups[]='free-pstn'; - - if (strlen($dictionary['email'])) { - $email=$dictionary['email']; - } else { - $email=trim($_REQUEST['email']); - } - - if (strlen($dictionary['owner'])) { - $owner=intval($dictionary['owner']); - } else { - $owner=intval($_REQUEST['owner']); - } - if (strlen($dictionary['quota'])) { - $quota=intval($dictionary['quota']); - } else { - $quota=intval($_REQUEST['quota']); - } - if (strlen($dictionary['prepaid'])) { - $prepaid=intval($dictionary['prepaid']); - } else { - $prepaid=intval($_REQUEST['prepaid']); - } - - $regexp = "/^([a-z0-9][a-z0-9_.-]*)@([a-z0-9][a-z0-9-]*\.)+([a-z0-9]{2,})$/i"; - if (!preg_match($regexp, $uri)) $email=$username.'@'.$domain; - - $account=array( - 'id' => array('username' => $username, - 'domain' => $domain), - 'firstName' => $firstName, - 'lastName' => $lastName, - 'password' => $password, - 'timezone' => $timezone, - 'email' => $email, - 'owner' => $owner, - 'customer' => intval($customer), - 'reseller' => intval($reseller), - 'groups' => $groups, - 'prepaid' => $prepaid, - 'quota' => $quota, - 'region' => '' - ); - - //print_r($account); - $deleteAccount=array('username' => $username, - 'domain' => $domain); - - - $function=array('commit' => array('name' => 'addAccount', - 'parameters' => array($account), - 'logs' => array('success' => sprintf('

SIP account %s@%s has been added',$username,$domain))), - 'rollback' => array('name' => 'deleteAlias', - 'parameters' => array($deleteAccount)) - ); - - return $this->SOAPEngine->execute($function); - - } - - function RandomPassword($len=11) { - $alf=array("a","b","c","d","e","f", - "h","i","j","k","l","m", - "n","p","r","s","t","w", - "x","y","1","2","3","4", - "5","6","7","8","9"); - $i=0; - while($i < $len) { - srand((double)microtime()*1000000); - $randval = rand(0,28); - $string="$string"."$alf[$randval]"; - $i++; - } - return $string; - } - - function getAllowedDomains() { - - if ($this->version > 1) { - - // Filter - $filter=array( - 'domain' => '' - ); - - // Range - $range=array('start' => 0, - 'count' => 1000 - ); - - $orderBy = array('attribute' => 'domain', - 'direction' => 'ASC' - ); - - // Compose query - $Query=array('filter' => $filter, - 'orderBy' => $orderBy, - 'range' => $range - ); - - $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); - $result = $this->SOAPEngine->soapclient->getDomains($Query); - } else { - $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); - $result = $this->SOAPEngine->soapclient->getDomains(); - } - - if (PEAR::isError($result)) { - $error_msg = $result->getMessage(); - $error_fault= $result->getFault(); - $error_code = $result->getCode(); - printf ("

Error in getAllowedDomains from %s: %s (%s): %s",$this->SOAPEngine->SOAPurl,$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); - //return false; - } else { - if ($this->version > 1) { - foreach ($result->domains as $_domain) { - $this->allowedDomains[]=$_domain->domain; - } - } else { - $this->allowedDomains=$result; - } - } - } -} - -class SIPAliases extends Records { - var $sortElements=array( - 'aliasUsername' => 'Alias user', - 'aliasDomain' => 'Alias domain', - 'targetUsername' => 'Target user', - 'targetDomain' => 'Target domain' - ); - - function SIPAliases(&$SOAPEngine) { - $this->filters = array('aliasUsername' => trim($_REQUEST['alias_username_filter']), - 'aliasDomain' => trim($_REQUEST['alias_domain_filter']), - 'targetUsername' => trim($_REQUEST['target_username_filter']), - 'targetDomain' => trim($_REQUEST['target_domain_filter']) - ); - - $this->Records(&$SOAPEngine); - - } - - function getRecordKeys() { - // Make sure we apply the domain filter from the login credetials - if ($this->allowedDomains && !$this->filters['aliasDomain']) { - //$this->filters['aliasDomain'] = $this->allowedDomains[0]; - } - - if ($this->filters['aliasDomain'] && $this->allowedDomains && !in_array($this->filters['aliasDomain'],$this->allowedDomains)) { - $this->filters['aliasDomain'] = $this->allowedDomains[0]; - } - - // Filter - $filter=array('aliasUsername' => $this->filters['aliasUsername'], - 'aliasDomain' => $this->filters['aliasDomain'], - 'targetUsername' => $this->filters['targetUsername'], - 'targetDomain' => $this->filters['targetDomain'], - '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'] = 'aliasUsername'; - 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 - ); - - //print_r($Query); - // Insert credetials - $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); - - // Call function - $result = $this->SOAPEngine->soapclient->getAliases($Query); - - if (PEAR::isError($result)) { - $error_msg = $result->getMessage(); - $error_fault= $result->getFault(); - $error_code = $result->getCode(); - printf ("

Error from %s: %s (%s): %s",$this->SOAPEngine->SOAPurl,$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); - return false; - } else { - foreach ($result->aliases as $alias) { - $this->selectionKeys[]=array('username' => $alias->id->username, - 'domain' => $alias->id->domain); - } - - return true; - } - } - - - function listRecords() { - $this->getAllowedDomains(); - - // Make sure we apply the domain filter from the login credetials - if ($this->allowedDomains && !$this->filters['aliasDomain']) { - //$this->filters['aliasDomain'] = $this->allowedDomains[0]; - } - - if ($this->filters['aliasDomain'] && $this->allowedDomains && !in_array($this->filters['aliasDomain'],$this->allowedDomains)) { - $this->filters['aliasDomain'] = $this->allowedDomains[0]; - } - - $this->showSeachForm(); - - // Filter - $filter=array('aliasUsername' => $this->filters['aliasUsername'], - 'aliasDomain' => $this->filters['aliasDomain'], - 'targetUsername' => $this->filters['targetUsername'], - 'targetDomain' => $this->filters['targetDomain'], - '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'] = 'aliasUsername'; - 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); - - // Call function - $result = $this->SOAPEngine->soapclient->getAliases($Query); - - if (PEAR::isError($result)) { - $error_msg = $result->getMessage(); - $error_fault= $result->getFault(); - $error_code = $result->getCode(); - printf ("

Error from %s: %s (%s): %s",$this->SOAPEngine->SOAPurl,$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); - return false; - } else { - - $this->rows = $result->total; - - if ($this->rows && $_REQUEST['action'] != 'PerformActions' && $_REQUEST['action'] != 'Delete') { - $this->showActionsForm(); - } - - print " -

- - -
$this->rows records found
-

- - - "; - print" - - - - - - - "; - - if (!$this->next) $this->next=0; - - if ($this->rows > $this->maxrowsperpage) { - $maxrows = $this->maxrowsperpage + $this->next; - if ($maxrows > $this->rows) $maxrows = $this->maxrowsperpage; - } else { - $maxrows=$this->rows; - } - - $i=0; - - if ($this->rows) { - while ($i < $maxrows) { - - if (!$result->aliases[$i]) break; - - $alias = $result->aliases[$i]; - - $index=$this->next+$i+1; - - $rr=floor($index/2); - $mod=$index-$rr*2; - - if ($mod ==0) { - $bgcolor="lightgrey"; - } else { - $bgcolor="white"; - } - - $_url = $this->url.sprintf("&service=%s&action=Delete&alias_username_filter=%s&alias_domain_filter=%s", - urlencode($this->SOAPEngine->service), - urlencode($alias->id->username), - urlencode($alias->id->domain) - ); - - if ($_REQUEST['action'] == 'Delete' && - $_REQUEST['alias_username_filter'] == $alias->id->username && - $_REQUEST['alias_domain_filter'] == $alias->id->domain) { - $_url .= "&confirm=1"; - $actionText = "Confirm"; - } else { - $actionText = "Delete"; - } - - if ($this->version > 1) { - - $_customer_url = $this->url.sprintf("&service=%s@Customers&customer_filter=%s", - urlencode($this->SOAPEngine->soapEngineId), - urlencode($alias->customer) - ); - - printf(" - - - - - - - - - - ", - $bgcolor, - $index, - $_customer_url, - $alias->reseller, - $alias->customer, - $alias->id->username, - $alias->id->domain, - $alias->target->username, - $alias->target->domain, - $alias->owner, - $alias->changeDate, - $_url, - $actionText - ); - } else { - printf(" - - - - - - - - - ", - $bgcolor, - $index, - $alias->id->username, - $alias->id->domain, - $alias->target->username, - $alias->target->domain, - $alias->owner, - $alias->changeDate, - $_url, - $actionText - ); - } - $i++; - - } - - } - - print "
Id - "; - if ($this->version > 1) print "CustomerAliasTargetOwnerLast changeAction
%s%s.%s%s@%s%s@%s%s%s%s
%s%s@%s%s@%s%s%s%s
"; - - $this->showPagination($maxrows); - - return true; - } - } - - function deleteRecord() { - if (!$_REQUEST['confirm']) { - print "

Please press on Confirm to confirm the delete. "; - return 1; - } - - if (!strlen($this->filters['aliasUsername']) || !strlen($this->filters['aliasDomain'])) { - print "

Error: missing SIP alias username or domain. "; - return 0; - } - - $alias=array('username' => $this->filters['aliasUsername'], - 'domain' => $this->filters['aliasDomain'] - ); - - $function=array('commit' => array('name' => 'deleteAlias', - 'parameters' => array($alias), - 'logs' => array('success' => sprintf('

SIP alias %s@%s has been deleted',$this->filters['aliasUsername'],$this->filters['aliasDomain']) - ) - ) - - ); - - - if ($this->SOAPEngine->execute($function)) { - unset($this->filters); - return true; - } else { - return flase; - } - - } - - function showSeachFormCustom() { - printf (" Alias",$this->filters['aliasUsername']); - printf ("@"); - - if ($this->allowedDomains) { - $selected_domain[$this->filters['aliasDomain']]='selected'; - printf (""); - } else { - printf ("",$this->filters['aliasDomain']); - } - - printf (" Target",$this->filters['targetUsername']); - printf (" @",$this->filters['targetDomain']); - - } - - function showAddForm() { - if ($this->selectionActive) return; - print " -

- - - "; - printf ("",$_SERVER['PHP_SELF']); - print " - - - "; - $this->printHiddenFormElements(); - - print " - - -
- "; - - print " - - "; - - printf (" Alias"); - - if (is_array($this->allowedDomains)) { - print "@"; - } - - printf (" Target"); - - print "Customer"; - if ($this->adminonly) { - $this->showResellerForm('reseller'); - print "."; - $this->showCustomerForm('customer'); - } else { - $this->showCustomerForm('customer'); - } - - printf (" Owner"); - - print " - - "; - print " -
- "; - } - - function addRecord() { - $alias_els = explode("@", trim($_REQUEST['alias'])); - $target_els = explode("@", trim($_REQUEST['target'])); - - $username=$alias_els[0]; - - if (strlen($alias_els[1])) { - $domain=$alias_els[1]; - - } else if (trim($_REQUEST['domain'])) { - $domain=trim($_REQUEST['domain']); - - } else { - printf ("

Error: Missing SIP domain"); - return false; - } - - if (is_array($this->allowedDomains) && !in_array($domain,$this->allowedDomains)) { - printf ("

Error: SIP domain %s is not allowed",$domain); - return false; - } - - if ($this->adminonly) { - $reseller = trim($_REQUEST['reseller']); - $customer = trim($_REQUEST['customer']); - if (!$customer) $customer=$reseller; - } else { - $reseller = $this->reseller; - $customer = trim($_REQUEST['customer']); - if (!$customer || !in_array($customer,array_keys($this->customers))) { - $customer=$reseller; - } - } - - $alias=array( - 'id' => array('username' => $username, - 'domain' => $domain - ), - 'target' => array('username' => $target_els[0], - 'domain' => $target_els[1] - ), - 'owner' => intval($_REQUEST['owner']), - 'customer' => intval($customer), - 'reseller' => intval($reseller) - ); - - //print_r($alias); - - $deleteAlias=array('username' => $username, - 'domain' => $domain); - - $function=array('commit' => array('name' => 'addAlias', - 'parameters' => array($alias), - 'logs' => array('success' => sprintf('

SIP alias %s@%s has been added',$username,$domain))), - 'rollback' => array('name' => 'deleteAlias', - 'parameters' => array($deleteAlias)) - ); - - return $this->SOAPEngine->execute($function); - } - - function getAllowedDomains() { - if ($this->version > 1) { - - // Filter - $filter=array( - 'domain' => '' - ); - - // Range - $range=array('start' => 0, - 'count' => 1000 - ); - - $orderBy = array('attribute' => 'domain', - 'direction' => 'ASC' - ); - - // Compose query - $Query=array('filter' => $filter, - 'orderBy' => $orderBy, - 'range' => $range - ); - - $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); - $result = $this->SOAPEngine->soapclient->getDomains($Query); - } else { - $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); - $result = $this->SOAPEngine->soapclient->getDomains(); - } - - if (PEAR::isError($result)) { - $error_msg = $result->getMessage(); - $error_fault= $result->getFault(); - $error_code = $result->getCode(); - printf ("

Error from %s: %s (%s): %s",$this->SOAPEngine->SOAPurl,$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); - return false; - } else { - if ($this->version > 1) { - foreach ($result->domains as $_domain) { - $this->allowedDomains[]=$_domain->domain; - } - } else { - $this->allowedDomains=$result; - } - } - } -} - -class ENUMranges extends Records { - - function ENUMranges(&$SOAPEngine) { - $this->filters = array('prefix' => trim($_REQUEST['prefix_filter']), - 'tld' => trim($_REQUEST['tld_filter']) - ); - - $this->Records(&$SOAPEngine); - - if ($this->version > 1) { - $this->sortElements=array('changeDate' => 'Change date', - 'prefix' => 'Prefix', - 'tld' => 'TLD' - ); - } - } - - function listRecords() { - $this->getAllowedDomains(); - - $this->showSeachForm(); - - if ($this->version > 1) { - // Filter - $filter=array('prefix' => $this->filters['prefix'], - 'tld' => $this->filters['tld'], - '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 - ); - - $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); - $result = $this->SOAPEngine->soapclient->getRanges($Query); - - } else { - $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); - $result = $this->SOAPEngine->soapclient->getRanges(); - } - - if (PEAR::isError($result)) { - $error_msg = $result->getMessage(); - $error_fault= $result->getFault(); - $error_code = $result->getCode(); - printf ("

Error from %s: %s (%s): %s",$this->SOAPEngine->SOAPurl,$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); - return false; - } else { - - if ($this->version > 1) { - $this->rows = $result->total; - } else { - $this->rows = count($result); - } - - if ($this->rows && $_REQUEST['action'] != 'PerformActions' && $_REQUEST['action'] != 'Delete') { - $this->showActionsForm(); - } - - print " -

- - -
$this->rows records found
-

- - - "; - print" - - - - - - - - - - "; - - if (!$this->next) $this->next=0; - - if ($this->rows > $this->maxrowsperpage) { - $maxrows = $this->maxrowsperpage + $this->next; - if ($maxrows > $this->rows) $maxrows = $this->maxrowsperpage; - } else { - $maxrows=$this->rows; - } - - $i=0; - - if ($this->rows) { - while ($i < $maxrows) { - - if ($this->version > 1) { - if (!$result->ranges[$i]) break; - $range = $result->ranges[$i]; - - } else { - $range = $result[$i]; - } - - $index=$this->next+$i+1; - - $rr=floor($index/2); - $mod=$index-$rr*2; - - if ($mod ==0) { - $bgcolor="lightgrey"; - } else { - $bgcolor="white"; - } - - $_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 ($_REQUEST['action'] == 'Delete' && - $_REQUEST['prefix_filter'] == $range->id->prefix && - $_REQUEST['tld_filter'] == $range->id->tld) { - $_url .= "&confirm=1"; - $actionText = "Confirm"; - } else { - $actionText = "Delete"; - } - - if (strlen($this->SOAPEngine->recordGenerator)) { - $range_link=sprintf('%s',$this->url,$this->SOAPEngine->recordGenerator,$range->id->prefix,$range->id->tld,$range->maxDigits,$range->id->prefix); - } else { - $range_link=$range->id->prefix; - } - - if ($this->version > 1) { - $_customer_url = $this->url.sprintf("&service=%s@Customers&customer_filter=%s", - urlencode($this->SOAPEngine->soapEngineId), - urlencode($range->customer) - ); - - printf(" - - - - - - - - - - - - ", - $bgcolor, - $index, - $_customer_url, - $range->reseller, - $range->customer, - $range_link, - $range->id->tld, - $range->ttl, - $range->minDigits, - $range->maxDigits, - $range->used, - $range->changeDate, - $_url, - $actionText - ); - } else { - printf(" - - - - - - - - - - - ", - $bgcolor, - $index, - $range_link, - $range->id->tld, - $range->ttl, - $range->minDigits, - $range->maxDigits, - $range->used, - $range->changeDate, - $_url, - $actionText - ); - - } - printf(" - - "); - - $i++; - - } - - } - - print "
Id - "; - if ($this->version > 1) print "CustomerPrefix TLDTTLMin digitsMax digitsUsedLast changeAction
%s%s.%s+%s%s%s%s%s%s%s%s
%s+%s%s%s%s%s%s%s%s
"; - - $this->showPagination($maxrows); - - return true; - } - } - - function deleteRecord() { - if (!$_REQUEST['confirm']) { - print "

Please press on Confirm to confirm the delete. "; - return 1; - } - - if (!strlen($this->filters['prefix']) || !strlen($this->filters['tld'])) { - print "

Error: missing ENUM range id "; - return 0; - } - - $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']) - ) - ) - ); - - unset($this->filters); - return $this->SOAPEngine->execute($function); - } - - function showAddForm() { - if ($this->selectionActive) return; - - print " -

- - - "; - printf ("",$_SERVER['PHP_SELF']); - print " - - - "; - - $this->printHiddenFormElements(); - - print " - - -
- "; - - print " - - "; - printf ("Prefix + "); - printf (" TLD"); - /* - if (is_array($this->allowedDomains)) { - print ""; - } else { - print ""; - } - */ - print ""; - printf ("TTL "); - printf ("Min Digits "); - printf ("Max Digits "); - print "Customer"; - if ($this->adminonly) { - $this->showResellerForm('reseller'); - print "."; - $this->showCustomerForm('customer'); - } else { - $this->showCustomerForm('customer'); - } - //printf ("Info "); - - print " - - "; - print " -
- "; - } - - function addRecord() { - $tld = trim($_REQUEST['tld']); - $prefix = trim($_REQUEST['prefix']); - $info = trim($_REQUEST['info']); - - if (!strlen($tld)) { - if (strlen($this->SOAPEngine->defaultEnumTLD)) { - $tld=$this->SOAPEngine->defaultEnumTLD; - } else { - $tld='e164.arpa'; - } - } - - if (!strlen($tld) || !strlen($prefix) || !is_numeric($prefix)) { - printf ("

Error: Missing TLD or prefix. "); - return false; - } - - if ($this->adminonly) { - $reseller = trim($_REQUEST['reseller']); - $customer = trim($_REQUEST['customer']); - if (!$customer) $customer=$reseller; - } else { - $reseller = $this->reseller; - $customer = trim($_REQUEST['customer']); - if (!$customer || !in_array($customer,array_keys($this->customers))) { - $customer=$reseller; - } - } - - if (!trim($_REQUEST['ttl'])) { - $ttl=3600; - } else { - $ttl=intval(trim($_REQUEST['ttl'])); - } - - $range=array( - 'id' => array('prefix' => $prefix, - 'tld' => $tld), - 'ttl' => $ttl, - 'minDigits' => intval(trim($_REQUEST['minDigits'])), - 'maxDigits' => intval(trim($_REQUEST['maxDigits'])), - 'customer' => intval($customer), - 'reseller' => intval($reseller) - ); - - $deleteRange=array('prefix'=>$prefix, - 'tld'=>$tld); - - $function=array('commit' => array('name' => 'addRange', - 'parameters' => array($range), - 'logs' => array('success' => sprintf('

ENUM range +%s under %s has been added',$prefix,$tld))), - 'rollback' => array('name' => 'deleteRange', - 'parameters' => array($deleteRange)) - ); - - return $this->SOAPEngine->execute($function); - - } - - function showSeachFormCustom() { - if ($this->version > 1) { - printf (" Prefix",$this->filters['prefix']); - printf (" TLD"); - - if ($this->allowedDomains) { - $selected_tld[$this->filters['tld']]='selected'; - printf (""); - } else { - printf ("",$this->filters['tld']); - } - } - } - - function getAllowedDomains() { - // Insert credetials - if ($this->version > 1) { - // Filter - $filter=array('prefix' => ''); - // Range - $range=array('start' => 0, - 'count' => 200 - ); - - // 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 - ); - - $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); - $result = $this->SOAPEngine->soapclient->getRanges($Query); - - } else { - $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); - $result = $this->SOAPEngine->soapclient->getRanges(); - } - - if (PEAR::isError($result)) { - $error_msg = $result->getMessage(); - $error_fault= $result->getFault(); - $error_code = $result->getCode(); - printf ("

Error from %s: %s (%s): %s",$this->SOAPEngine->SOAPurl,$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); - return false; - } else { - if ($this->version > 1) { - foreach($result->ranges as $range) { - $this->ranges[]=array('prefix' => $range->id->prefix, - 'tld' => $range->id->tld, - 'minDigits' => $range->minDigits, - 'maxDigits' => $range->maxDigits - ); - if (in_array($range->id->tld,$this->allowedDomains)) continue; - $this->allowedDomains[]=$range->id->tld; - $seen[$range->id->tld]++; - } - } else { - foreach($result as $range) { - $this->ranges[]=array('prefix' => $range->id->prefix, - 'tld' => $range->id->tld, - 'minDigits' => $range->minDigits, - 'maxDigits' => $range->maxDigits - ); - if (in_array($range->id->tld,$this->allowedDomains)) continue; - $this->allowedDomains[]=$range->id->tld; - $seen[$range->id->tld]++; - } - } - - if (strlen($this->SOAPEngine->defaultEnumTLD) && !$seen[$this->SOAPEngine->defaultEnumTLD]) { - $this->allowedDomains[]=$this->SOAPEngine->defaultEnumTLD; - } - } - } -} - -class ENUMmappings extends Records { - var $sortElements=array('changeDate' => 'Change date', - 'number' => 'Number', - 'tld' => 'TLD', - 'owner' => 'Owner' - ); - - var $ranges=array(); - - var $NAPTR_services=array( - "sip" => array("service"=>"sip", - "webname"=>"SIP", - "schemas"=>array("sip:","sips:")), - "mailto" => array("service"=>"mailto", - "webname"=>"Email", - "schemas"=>array("mailto:")), - "web:http" => array("service"=>"web:http", - "webname"=>"WEB (http)", - "schemas"=>array("http://")), - "web:https" => array("service"=>"web:https", - "webname"=>"WEB (https)", - "schemas"=>array("https://")), - "x-skype:callto" => array("service"=>"x-skype:callto", - "webname"=>"Skype", - "schemas"=>array("callto:")), - "h323" => array("service"=>"h323", - "webname"=>"H323", - "schemas"=>array("h323:")), - "iax" => array("service"=>"iax", - "webname"=>"IAX", - "schemas"=>array("iax:")), - "iax2" => array("service"=>"iax2", - "webname"=>"IAX2", - "schemas"=>array("iax2:")), - "mms" => array("service"=>"mms", - "webname"=>"MMS", - "schemas"=>array("tel:","mailto:")), - "sms" => array("service"=>"sms", - "webname"=>"SMS", - "schemas"=>array("tel:","mailto:")), - "ems" => array("service"=>"ems", - "webname"=>"EMS", - "schemas"=>array("tel:","mailto:")), - "im" => array("service"=>"im", - "webname"=>"IM", - "schemas"=>array("im:")), - "npd:tel" => array("service"=>"npd+tel", - "webname"=>"Portability", - "schemas"=>array("tel:")), - "void:mailto" => array("service"=>"void:mailto", - "webname"=>"VOID(mail)", - "schemas"=>array("mailto:")), - "void:http" => array("service"=>"void:http", - "webname"=>"VOID(http)", - "schemas"=>array("http://")), - "void:https" => array("service"=>"void:https", - "webname"=>"VOID(https)", - "schemas"=>array("https://")), - "voice" => array("service"=>"voice", - "webname"=>"Voice", - "schemas"=>array("voice:","tel:")), - "tel" => array("service"=>"tel", - "webname"=>"Tel", - "schemas"=>array("tel:")), - "fax:tel" => array("service"=>"fax:tel", - "webname"=>"Fax", - "schemas"=>array("tel:")), - "ifax:mailto" => array("service"=>"ifax:mailto", - "webname"=>"iFax", - "schemas"=>array("mailto:")), - "pres" => array("service"=>"pres", - "webname"=>"Presence", - "schemas"=>array("pres:")), - "ft:ftp" => array("service"=>"ft:ftp", - "webname"=>"FTP", - "schemas"=>array("ftp://")), - "loc:http" => array("service"=>"loc:http", - "webname"=>"GeoLocation", - "schemas"=>array("http://")), - "key:http" => array("service"=>"key:http", - "webname"=>"Public key", - "schemas"=>array("http://")) - ); - - function ENUMmappings(&$SOAPEngine) { - $this->filters = array('number' => trim($_REQUEST['number_filter']), - 'tld' => trim($_REQUEST['tld_filter']), - 'type' => trim($_REQUEST['type_filter']), - 'mapto' => trim($_REQUEST['mapto_filter']), - 'owner' => trim($_REQUEST['owner_filter']) - ); - $this->Records(&$SOAPEngine); - } - - - function listRecords() { - $this->getAllowedDomains(); - - $this->showSeachForm(); - - $filter=array('number' => $this->filters['number'], - 'tld' => $this->filters['tld'], - 'type' => $this->filters['type'], - 'mapto' => $this->filters['mapto'], - '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); - - // Call function - $result = $this->SOAPEngine->soapclient->getNumbers($Query); - - if (PEAR::isError($result)) { - $error_msg = $result->getMessage(); - $error_fault= $result->getFault(); - $error_code = $result->getCode(); - printf ("

Error from %s: %s (%s): %s",$this->SOAPEngine->SOAPurl,$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); - return false; - } else { - - $this->rows = $result->total; - - if ($this->rows && $_REQUEST['action'] != 'PerformActions' && $_REQUEST['action'] != 'Delete') { - $this->showActionsForm(); - } - - print " -

- - -
$this->rows records found
-

- - - "; - print" - - - - - - - - - - - - "; - - if (!$this->next) $this->next=0; - - if ($this->rows > $this->maxrowsperpage) { - $maxrows = $this->maxrowsperpage + $this->next; - if ($maxrows > $this->rows) $maxrows = $this->maxrowsperpage; - } else { - $maxrows=$this->rows; - } - - $i=0; - - if ($this->rows) { - while ($i < $maxrows) { - - if (!$result->numbers[$i]) break; - - $number = $result->numbers[$i]; - - $index=$this->next+$i+1; - - $rr=floor($index/2); - $mod=$index-$rr*2; - - if ($mod ==0) { - $bgcolor="lightgrey"; - } else { - $bgcolor="white"; - } - - $j=1; - foreach ($number->mappings as $_mapping) { - $_url = $this->url.sprintf("&service=%s&action=Delete&number_filter=%s&tld_filter=%s&mapto_filter=%s", - urlencode($this->SOAPEngine->service), - urlencode($number->id->number), - urlencode($number->id->tld), - urlencode($_mapping->mapto) - ); - - if ($_REQUEST['action'] == 'Delete' && - $_REQUEST['number_filter'] == $number->id->number && - $_REQUEST['tld_filter'] == $number->id->tld && - $_REQUEST['mapto_filter'] == $_mapping->mapto) { - $_url .= "&confirm=1"; - $actionText = "Confirm"; - } else { - $actionText = "Delete"; - } - - if ($j==1) { - - if ($this->version > 1) { - $_customer_url = $this->url.sprintf("&service=%s@Customers&customer_filter=%s", - urlencode($this->SOAPEngine->soapEngineId), - urlencode($number->customer) - ); - - printf(" - - - - - - - - - - - - - - ", - $bgcolor, - $index, - $_customer_url, - $number->reseller, - $number->customer, - $number->id->number, - $number->id->tld, - $this->tel2enum($number->id->number,$number->id->tld), - ucfirst($_mapping->type), - $_mapping->mapto, - $_mapping->ttl, - $_mapping->priority, - $number->owner, - $_mapping->lastChange, - $_url, - $actionText - ); - } else { - printf(" - - - - - - - - - - - - - ", - $bgcolor, - $index, - $number->id->number, - $number->id->tld, - $this->tel2enum($number->id->number,$number->id->tld), - ucfirst($_mapping->type), - $_mapping->mapto, - $_mapping->ttl, - $_mapping->priority, - $number->owner, - $_mapping->lastChange, - $_url, - $actionText - ); - } - } else { - if ($this->version > 1) { - printf(" - - - - - - - - - - - - - - ", - $bgcolor, - ucfirst($_mapping->type), - $_mapping->mapto, - $_mapping->ttl, - $_mapping->priority, - $_mapping->lastChange, - $_url, - $actionText - ); - } else { - printf(" - - - - - - - - - - - - - ", - $bgcolor, - ucfirst($_mapping->type), - $_mapping->mapto, - $_mapping->ttl, - $_mapping->priority, - $_mapping->lastChange, - $_url, - $actionText - ); - } - } - $j++; - } - - printf(" - - "); - - $i++; - - } - - } - - print "
Id - "; - if ($this->version > 1) print "CustomerNumberTLDDNS nameSrvMap toTTLPrioOwnerLast changeAction
%s%s.%s+%s%s%s%s%s%s%s%s%s%s
%s+%s%s%s%s%s%s%s%s%s%s
%s%s%s%s%s%s
%s%s%s%s%s%s
"; - - $this->showPagination($maxrows); - - return true; - } - } - - function getLastNumber() { - - // Filter - $filter=array('number' => '' - ); - // Range - $range=array('start' => 0, - 'count' => 1 - ); - - // 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); - - // Call function - $result = $this->SOAPEngine->soapclient->getNumbers($Query); - - if (PEAR::isError($result)) { - $error_msg = $result->getMessage(); - $error_fault= $result->getFault(); - $error_code = $result->getCode(); - printf ("

Error from %s: %s (%s): %s",$this->SOAPEngine->SOAPurl,$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); - return false; - } else { - - if ($result->total) { - $number = array('number' => $result->numbers[0]->id->number, - 'tld' => $result->numbers[0]->id->tld, - 'mappings' => $result->numbers[0]->mappings - ); - - return $number; - } - - } - - return false; - } - - function showSeachFormCustom() { - - printf (" Number",$this->filters['number']); - printf (" TLD"); - if ($this->allowedDomains) { - $selected_tld[$this->filters['tld']]='selected'; - printf (""); - } else { - printf ("",$this->filters['tld']); - } - - printf (" Srv"); - print " - "; - printf (" Map to",$this->filters['mapto']); - - } - - function deleteRecord($dictionary=array()) { - - if (!$dictionary['confirm'] && !$_REQUEST['confirm']) { - print "

Please press on Confirm to confirm the delete. "; - return 1; - } - - if ($dictionary['number']) { - $number=$dictionary['number']; - } else { - $number=$this->filters['number']; - } - - if ($dictionary['tld']) { - $tld=$dictionary['tld']; - } else { - $tld=$this->filters['tld']; - } - - if ($dictionary['mapto']) { - $mapto=$dictionary['mapto']; - } else { - $mapto=$this->filters['mapto']; - } - - if (!strlen($number) || !strlen($tld)) { - print "

Error: missing ENUM number or TLD "; - return 0; - } - - $enum_id=array('number'=>$number, - 'tld'=>$tld); - - $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); - $result = $this->SOAPEngine->soapclient->getNumber($enum_id); - - if (!PEAR::isError($result)) { - // the number exists and we make an update - $result_new=$result; - - if (count($result->mappings) > 1) { - foreach ($result->mappings as $_mapping) { - if ($_mapping->mapto != $mapto) { - $mappings_new[]=array('type' => $_mapping->type, - 'mapto' => $_mapping->mapto, - 'ttl' => $_mapping->ttl, - 'priority' => $_mapping->priority - ); - } - } - - $result_new->mappings=$mappings_new; - - $function=array('commit' => array('name' => 'updateNumber', - 'parameters' => array($result_new), - 'logs' => array('success' => sprintf('

ENUM mapping %s has been deleted',$mapto))), - 'rollback' => array('name' => 'updateNumber', - 'parameters' => array($result)) - ); - - } else { - $function=array('commit' => array('name' => 'deleteNumber', - 'parameters' => array($enum_id), - 'logs' => array('success' => sprintf('

ENUM number +%s under %s has been deleted',$number,$tld))), - 'rollback' => array('name' => 'addNumber', - 'parameters' => array($result)) - ); - } - - unset($this->filters); - return $this->SOAPEngine->execute($function); - - } else { - return false; - } - - } - - function showAddForm() { - if ($this->selectionActive) return; - - print " -

- - - "; - printf ("",$_SERVER['PHP_SELF']); - print " - - - "; - - $this->printHiddenFormElements(); - - print " - - -
- "; - - print " - - "; - printf (" Number +"); - printf (" TLD"); - if (is_array($this->allowedDomains)) { - print ""; - } else { - print ""; - } - printf (" Map to"); - print " - "; - printf (" "); - printf (" TTL"); - print "Customer"; - if ($this->adminonly) { - $this->showResellerForm('reseller'); - print "."; - $this->showCustomerForm('customer'); - } else { - $this->showCustomerForm('customer'); - } - - printf (" Owner"); - printf (" Prio"); - - print " - - "; - print " -
- "; - } - - function getAllowedDomains() { - if ($this->version > 1) { - // Filter - $filter=array('prefix' => $this->filters['prefix'], - 'tld' => $this->filters['tld'], - 'customer' => intval($this->filters['customer']), - 'reseller' => intval($this->filters['reseller']) - ); - // Range - $range=array('start' => 0, - 'count' => 200 - ); - - // 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 - ); - - $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); - $result = $this->SOAPEngine->soapclient->getRanges($Query); - - } else { - $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); - $result = $this->SOAPEngine->soapclient->getRanges(); - } - - if (PEAR::isError($result)) { - $error_msg = $result->getMessage(); - $error_fault= $result->getFault(); - $error_code = $result->getCode(); - printf ("

Error from %s: %s (%s): %s",$this->SOAPEngine->SOAPurl,$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); - return false; - } else { - if ($this->version > 1) { - foreach($result->ranges as $range) { - $this->ranges[]=array('prefix' => $range->id->prefix, - 'tld' => $range->id->tld, - 'minDigits' => $range->minDigits, - 'maxDigits' => $range->maxDigits - ); - if (in_array($range->id->tld,$this->allowedDomains)) continue; - $this->allowedDomains[]=$range->id->tld; - $seen[$range->id->tld]++; - } - } else { - foreach($result as $range) { - $this->ranges[]=array('prefix' => $range->id->prefix, - 'tld' => $range->id->tld, - 'minDigits' => $range->minDigits, - 'maxDigits' => $range->maxDigits - ); - if (in_array($range->id->tld,$this->allowedDomains)) continue; - $this->allowedDomains[]=$range->id->tld; - $seen[$range->id->tld]++; - } - } - if (strlen($this->SOAPEngine->defaultEnumTLD) && !$seen[$this->SOAPEngine->defaultEnumTLD]) { - $this->allowedDomains[]=$this->SOAPEngine->defaultEnumTLD; - } - } - } - - function addRecord($dictionary=array()) { - if ($dictionary['tld']) { - $tld=$dictionary['tld']; - } else { - $tld = trim($_REQUEST['tld']); - } - if ($dictionary['number']) { - $number=$dictionary['number']; - } else { - $number = trim($_REQUEST['number']); - } - - if (!strlen($tld)) { - if (strlen($this->SOAPEngine->defaultEnumTLD)) { - $tld=$this->SOAPEngine->defaultEnumTLD; - } else { - $tld='e164.arpa'; - } - } - - if (!strlen($tld) || !strlen($number) || !is_numeric($number)) { - printf ("

Error: Missing TLD or number. "); - return false; - } - - if ($this->adminonly) { - if ($dictionary['reseller']) { - $reseller=$dictionary['reseller']; - } else { - $reseller = trim($_REQUEST['reseller']); - } - if ($dictionary['customer']) { - $customer=$dictionary['customer']; - } else { - $customer = trim($_REQUEST['customer']); - } - if (!$customer) $customer=$reseller; - } else { - $reseller = $this->reseller; - if ($dictionary['customer']) { - $customer=$dictionary['customer']; - } else { - $customer = trim($_REQUEST['customer']); - } - if (!$customer || !in_array($customer,array_keys($this->customers))) { - $customer=$reseller; - } - } - - if ($dictionary['ttl']) { - $ttl = intval($dictionary['ttl']); - } else { - $ttl = intval(trim($_REQUEST['ttl'])); - } - - if (!$ttl) $ttl=3600; - - if ($dictionary['priority']) { - $priority = intval($dictionary['priority']); - } else { - $priority = intval(trim($_REQUEST['priority'])); - } - - if ($dictionary['owner']) { - $owner = intval($dictionary['owner']); - } else { - $owner = intval(trim($_REQUEST['owner'])); - } - - if (!$priority) $priority=5; - - $enum_id=array('number' => $number, - 'tld' => $tld); - - if ($dictionary['mapto']) { - $mapto = $dictionary['mapto']; - } else { - $mapto = trim($_REQUEST['mapto']); - } - - if ($dictionary['type']) { - $type = $dictionary['type']; - } else { - $type = trim($_REQUEST['type']); - } - - if (preg_match("/^([a-z0-9]+:\/\/)(.*)$/i",$mapto,$m)) { - $_scheme = $m[1]; - $_value = $m[2]; - } else if (preg_match("/^([a-z0-9]+:)(.*)$/i",$mapto,$m)) { - $_scheme = $m[1]; - $_value = $m[2]; - } else { - $_scheme = ''; - $_value = $mapto; - } - - if (!$_value) { - $lastNumber=$this->getLastNumber(); - foreach($lastNumber['mappings'] as $_mapping) { - if ($_mapping->type == trim($type)) { - if (preg_match("/^(.*)@(.*)$/",$_mapping->mapto,$m)) { - $_value = $number.'@'.$m[2]; - break; - } - } - } - } - - if (!$_scheme || !in_array($_scheme,$this->NAPTR_services[trim($type)]['schemas'])) { - $_scheme=$this->NAPTR_services[trim($type)]['schemas'][0]; - } - - $mapto=$_scheme.$_value; - - $enum_number=array('id' => $enum_id, - 'owner' => $owner, - 'customer' => intval($customer), - 'reseller' => intval($reseller), - 'mappings' => array(array('type' => $type, - 'mapto' => $mapto, - 'ttl' => $ttl, - 'priority' => $priority - ) - ) - ); - - $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); - $result = $this->SOAPEngine->soapclient->getNumber($enum_id); - - if (PEAR::isError($result)) { - $error_msg=$result->getMessage(); - $error_fault=$result->getFault(); - $error_code=$result->getCode(); - - if ($error_fault->detail->exception->errorcode == "3002") { - - $function=array('commit' => array('name' => 'addNumber', - 'parameters' => array($enum_number), - 'logs' => array('success' => sprintf('

ENUM number +%s under %s has been added',$number,$tld))), - 'rollback' => array('name' => 'deleteNumber', - 'parameters' => array($enumId)) - ); - - return $this->SOAPEngine->execute($function); - } else { - printf ("

Error from %s: %s (%s): %s",$this->SOAPEngine->SOAPurl,$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); - return false; - } - } else { - // the number exists and we make an update - $result_new=$result; - foreach ($result->mappings as $_mapping) { - $mappings_new[]=array('type' => $_mapping->type, - 'mapto' => $_mapping->mapto, - 'ttl' => $_mapping->ttl, - 'priority' => $_mapping->priority - ); - - if ($_mapping->mapto == $mapto) { - printf ("

Info: ENUM mapping %s for number %s already exists",$mapto,$number); - return true; - break; - } - } - - $mappings_new[]=array('type' => trim($type), - 'mapto' => $mapto, - 'ttl' => intval(trim($_REQUEST['ttl'])), - 'priority'=> intval(trim($_REQUEST['priority'])), - ); - // add mapping - $result_new->mappings=$mappings_new; - - $function=array('commit' => array('name' => 'updateNumber', - 'parameters' => array($result_new), - 'logs' => array('success' => sprintf('

ENUM number +%s under %s has been updated',$number,$tld))), - 'rollback' => array('name' => 'updateNumber', - 'parameters' => array($result)) - ); - - return $this->SOAPEngine->execute($function); - } - - return true; - } - - function getRecordKeys() { - - // Filter - $filter=array('number' => $this->filters['number'], - 'tld' => $this->filters['tld'], - 'type' => $this->filters['type'], - 'mapto' => $this->filters['mapto'] - ); - // 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); - - // Call function - $result = $this->SOAPEngine->soapclient->getNumbers($Query); - - if (PEAR::isError($result)) { - $error_msg = $result->getMessage(); - $error_fault= $result->getFault(); - $error_code = $result->getCode(); - printf ("

Error from %s: %s (%s): %s",$this->SOAPEngine->SOAPurl,$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); - return false; - } else { - foreach ($result->numbers as $number) { - $this->selectionKeys[]=array('number' => $number->id->number, - 'tld' => $number->id->tld); - } - return true; - } - } -} - -class TrustedPeers extends Records { - - var $sortElements=array( - 'description' => 'Description', - 'ip' =>'IP address' - ); - - function TrustedPeers(&$SOAPEngine) { - $this->filters = array('ip' => trim($_REQUEST['ip_filter']), - 'description' => trim($_REQUEST['description_filter']) - ); - - $this->Records(&$SOAPEngine); - } - - function listRecords() { - - $this->showSeachForm(); - - // Insert credetials - $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); - - // Filter - $filter=array('ip' => $this->filters['ip'], - 'description' => $this->filters['description'] - ); - - // Range - $range=array('start' => intval($this->next), - 'count' => intval($this->maxrowsperpage) - ); - - // Order - if (!$this->sorting['sortBy']) $this->sorting['sortBy'] = 'description'; - 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 - $result = $this->SOAPEngine->soapclient->getTrustedPeers($Query); - - if (PEAR::isError($result)) { - $error_msg = $result->getMessage(); - $error_fault= $result->getFault(); - $error_code = $result->getCode(); - printf ("

Error from %s: %s (%s): %s",$this->SOAPEngine->SOAPurl,$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); - return false; - } else { - - $this->rows = $result->total; - - if ($this->rows && $_REQUEST['action'] != 'PerformActions' && $_REQUEST['action'] != 'Delete') { - $this->showActionsForm(); - } - - print " - - -
$this->rows records found
-

- - - "; - print" - - - - - - - - "; - - if (!$this->next) $this->next=0; - - if ($this->rows > $this->maxrowsperpage) { - $maxrows = $this->maxrowsperpage + $this->next; - if ($maxrows > $this->rows) $maxrows = $this->maxrowsperpage; - } else { - $maxrows=$this->rows; - } - - $i=0; - - if ($this->rows) { - while ($i < $maxrows) { - - if (!$result->peers[$i]) break; - - $peer = $result->peers[$i]; - - $index=$this->next+$i+1; - - $rr=floor($index/2); - $mod=$index-$rr*2; - - if ($mod ==0) { - $bgcolor="lightgrey"; - } else { - $bgcolor="white"; - } - - $_url = $this->url.sprintf("&service=%s&action=Delete&ip_filter=%s", - urlencode($this->SOAPEngine->service), - urlencode($peer->ip) - ); - - if ($_REQUEST['action'] == 'Delete' && - $_REQUEST['ip_filter'] == $peer->ip) { - $_url .= "&confirm=1"; - $actionText = "Confirm"; - } else { - $actionText = "Delete"; - } - - if ($this->version > 1) { - - printf(" - - - - - - - - - - ", - $bgcolor, - $index, - $peer->reseller, - $peer->customer, - $peer->ip, - $peer->protocol, - $peer->fromPattern, - $peer->description, - $peer->owner, - $_url, - $actionText - ); - } else { - printf(" - - - - - - - - - ", - $bgcolor, - $index, - $peer->ip, - $peer->protocol, - $peer->fromPattern, - $peer->description, - $peer->owner, - $_url, - $actionText - ); - - } - printf(" - - "); - - $i++; - - } - - } - - print "
Id - "; - if ($this->version > 1) print "CustomerIP addressProtocolFrom patternDescriptionOwnerAction
%s%s.%s%s%s%s%s%s%s
%s%s%s%s%s%s%s
"; - - $this->showPagination($maxrows); - - return true; - } - } - - function showAddForm() { - if ($this->selectionActive) return; - print " -

- - - "; - printf ("",$_SERVER['PHP_SELF']); - print " - - - "; - - $this->printHiddenFormElements(); - - print " - - -
- "; - - print " - - "; - printf (" IP address"); - printf (" Description"); - print "Customer"; - if ($this->adminonly) { - $this->showResellerForm('reseller'); - print "."; - $this->showCustomerForm('customer'); - } else { - $this->showCustomerForm('customer'); - } - printf (" Owner"); - - print " - - "; - print " -
- "; - } - - function addRecord() { - $ipaddress = trim($_REQUEST['ipaddress']); - $description = trim($_REQUEST['description']); - $owner = trim($_REQUEST['owner']); - - if ($this->adminonly) { - $reseller = trim($_REQUEST['reseller']); - $customer = trim($_REQUEST['customer']); - if (!$customer) $customer=$reseller; - } else { - $reseller = $this->reseller; - $customer = trim($_REQUEST['customer']); - if (!$customer || !in_array($customer,array_keys($this->customers))) { - $customer=$reseller; - } - } - - if (!strlen($ipaddress) || !strlen($description)) { - printf ("

Error: Missing IP or description. "); - return false; - } - - $peer=array( - 'ip' => $ipaddress, - 'description' => $description, - 'owner' => intval($_REQUEST['owner']), - 'customer' => intval($customer), - 'reseller' => intval($reseller) - ); - - $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); - - $result = $this->SOAPEngine->soapclient->addTrustedPeer($peer); - - if (PEAR::isError($result)) { - $error_msg = $result->getMessage(); - $error_fault= $result->getFault(); - $error_code = $result->getCode(); - printf ("

Error from %s: %s (%s): %s",$this->SOAPEngine->SOAPurl,$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); - return false; - } else { - printf ("

Trusted peers %s has been added. ",$ipaddress); - return 1; - } - } - - function deleteRecord() { - if (!$_REQUEST['confirm']) { - print "

Please press on Confirm to confirm the delete. "; - return 1; - } - - if (!strlen($this->filters['ip']) || !strlen($this->filters['ip'])) { - print "

Error: missing IP address. "; - return 0; - } - - $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); - - $result = $this->SOAPEngine->soapclient->deleteTrustedPeer($this->filters['ip']); - - if (PEAR::isError($result)) { - $error_msg = $result->getMessage(); - $error_fault= $result->getFault(); - $error_code = $result->getCode(); - printf ("

Error from %s: %s (%s): %s",$this->SOAPEngine->SOAPurl,$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); - return false; - } else { - printf ("

Trusted peer %s has been deleted. ",$this->filters['ip']); - unset($this->filters); - return 1; - } - } - -} - -class GatewayGroups extends Records { - - var $sortElements=array( - 'name' => 'Name' - ); - - function GatewayGroups(&$SOAPEngine) { - $this->filters = array('group' => trim($_REQUEST['group_filter']) - ); - - $this->Records(&$SOAPEngine); - } - - function listRecords() { - - $this->showSeachForm(); - - // Insert credetials - $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); - - // Filter - $filter=array('name' => $this->filters['group'] - ); - - // Range - $range=array('start' => intval($this->next), - 'count' => intval($this->maxrowsperpage) - ); - - // 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 - $result = $this->SOAPEngine->soapclient->getGatewayGroups($Query); - - if (PEAR::isError($result)) { - $error_msg = $result->getMessage(); - $error_fault= $result->getFault(); - $error_code = $result->getCode(); - printf ("

Error from %s: %s (%s): %s",$this->SOAPEngine->SOAPurl,$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); - return false; - } else { - - $this->rows = $result->total; - - print " - - -
$this->rows records found
-

- - - - - "; - - if (!$this->next) $this->next=0; - - if ($this->rows > $this->maxrowsperpage) { - $maxrows = $this->maxrowsperpage + $this->next; - if ($maxrows > $this->rows) $maxrows = $this->maxrowsperpage; - } else { - $maxrows=$this->rows; - } - - $i=0; - - if ($this->rows) { - while ($i < $maxrows) { - - if (!$result->groups[$i]) break; - - $group = $result->groups[$i]; - - $index=$this->next+$i+1; - - $rr=floor($index/2); - $mod=$index-$rr*2; - - if ($mod ==0) { - $bgcolor="lightgrey"; - } else { - $bgcolor="white"; - } - - $_url = $this->url.sprintf("&service=%s&action=Delete&group_filter=%s", - urlencode($this->SOAPEngine->service), - urlencode($group) - ); - - if ($_REQUEST['action'] == 'Delete' && - $_REQUEST['group_filter'] == $group) { - $_url .= "&confirm=1"; - $actionText = "Confirm"; - } else { - $actionText = "Delete"; - } - - printf(" - - - - - ", - $bgcolor, - $index, - $group, - $_url, - $actionText - ); - - printf(" - - "); - - $i++; - - } - - } - - print "
Id - Name - Action
%s%s%s
"; - - $this->showPagination($maxrows); - - return true; - } - } - - function showAddForm() { - if ($this->selectionActive) return; - print " -

- - - "; - printf ("",$_SERVER['PHP_SELF']); - print " - - - "; - $this->printHiddenFormElements(); - - print " - - -
- "; - - print " - - "; - - printf (" Name"); - - $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); - $result = $this->SOAPEngine->soapclient->getGatewayGroups(); - - print " - - "; - print " -
- "; - } - - function addRecord() { - $name = trim($_REQUEST['name']); - - if (!strlen($name)) { - printf ("

Error: Missing name. "); - return false; - } - - $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); - - $result = $this->SOAPEngine->soapclient->addGatewayGroup($name); - - if (PEAR::isError($result)) { - $error_msg = $result->getMessage(); - $error_fault= $result->getFault(); - $error_code = $result->getCode(); - printf ("

Error from %s: %s (%s): %s",$this->SOAPEngine->SOAPurl,$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); - return false; - } else { - printf ("

Gateway group %s has been added. ",$name); - return 1; - } - } - - function deleteRecord() { - if (!$_REQUEST['confirm']) { - print "

Please press on Confirm to confirm the delete. "; - return 1; - } - - if (!strlen($this->filters['group'])) { - print "

Error: missing gateway group. "; - return 0; - } - - $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); - - $result = $this->SOAPEngine->soapclient->deleteGatewayGroup($this->filters['group']); - - if (PEAR::isError($result)) { - $error_msg = $result->getMessage(); - $error_fault= $result->getFault(); - $error_code = $result->getCode(); - printf ("

Error from %s: %s (%s): %s",$this->SOAPEngine->SOAPurl,$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); - return false; - } else { - printf ("

Gateway %s has been deleted. ",$this->filters['group']); - unset($this->filters); - return 1; - } - } - - function showSeachFormCustom() { - printf (" Group",$this->filters['group']); - } - -} - -class Gateways extends Records { - - var $sortElements=array( - 'name' => 'Name', - 'group' => 'Group', - 'ip' => 'IP address', - 'prefix' => 'Prefix' - ); - - function Gateways(&$SOAPEngine) { - $this->filters = array('name' => trim($_REQUEST['name_filter']), - 'group' => trim($_REQUEST['group_filter']) - ); - - $this->Records(&$SOAPEngine); - } - - function listRecords() { - - $this->showSeachForm(); - - // Insert credetials - $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); - - // Filter - $filter=array('name' => $this->filters['name'], - 'group' => $this->filters['group'] - ); - - // Range - $range=array('start' => intval($this->next), - 'count' => intval($this->maxrowsperpage) - ); - - // 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 - $result = $this->SOAPEngine->soapclient->getGateways($Query); - - if (PEAR::isError($result)) { - $error_msg = $result->getMessage(); - $error_fault= $result->getFault(); - $error_code = $result->getCode(); - printf ("

Error from %s: %s (%s): %s",$this->SOAPEngine->SOAPurl,$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); - return false; - } else { - - $this->rows = $result->total; - - print " - - -
$this->rows records found
-

- - - - - - - - - "; - - if (!$this->next) $this->next=0; - - if ($this->rows > $this->maxrowsperpage) { - $maxrows = $this->maxrowsperpage + $this->next; - if ($maxrows > $this->rows) $maxrows = $this->maxrowsperpage; - } else { - $maxrows=$this->rows; - } - - $i=0; - - if ($this->rows) { - while ($i < $maxrows) { - - if (!$result->gateways[$i]) break; - - $gateway = $result->gateways[$i]; - - $index=$this->next+$i+1; - - $rr=floor($index/2); - $mod=$index-$rr*2; - - if ($mod ==0) { - $bgcolor="lightgrey"; - } else { - $bgcolor="white"; - } - - $_url = $this->url.sprintf("&service=%s&action=Delete&name_filter=%s", - urlencode($this->SOAPEngine->service), - urlencode($gateway->name) - ); - - if ($_REQUEST['action'] == 'Delete' && - $_REQUEST['name_filter'] == $gateway->name) { - $_url .= "&confirm=1"; - $actionText = "Confirm"; - } else { - $actionText = "Delete"; - } - - printf(" - - - - - - - - - ", - $bgcolor, - $index, - $gateway->name, - $gateway->group, - $gateway->transport, - $gateway->ip, - $gateway->port, - $gateway->strip, - $gateway->prefix, - $_url, - $actionText - ); - - printf(" - - "); - - $i++; - - } - - } - - print "
Id - Name - GroupAddressStripPrefixAction
%s%s%s%s:%s:%s%s%s%s
"; - - $this->showPagination($maxrows); - - return true; - } - } - - function showAddForm() { - if ($this->selectionActive) return; - print " -

- - - "; - printf ("",$_SERVER['PHP_SELF']); - print " - - - "; - $this->printHiddenFormElements(); - - print " - - -
- "; - - print " - - "; - - printf (" Name"); - - $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); - $result = $this->SOAPEngine->soapclient->getGatewayGroups(); - - printf (" Group: "); - - // Compose query - $Query=array('filter' => array('name'=>''), - 'orderBy' => array('attribute' => 'name', - 'direction' => 'ASC' - ), - 'range' => array('start' => 0, - 'count' => 1000) - ); - - $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); - $result = $this->SOAPEngine->soapclient->getGatewayGroups($Query); - - if (PEAR::isError($result)) { - $error_msg = $result->getMessage(); - $error_fault= $result->getFault(); - $error_code = $result->getCode(); - printf ("

Error from %s: %s (%s): %s",$this->SOAPEngine->SOAPurl,$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); - return false; - } else { - print ""); - } - printf (" Address"); - printf (" Strip: "; - printf (" Prefix"); - - print " -

- "; - print " -
- "; - } - - function addRecord() { - $name = trim($_REQUEST['name']); - $group = trim($_REQUEST['group']); - $address = trim($_REQUEST['address']); - $strip = trim($_REQUEST['strip']); - $prefix = trim($_REQUEST['prefix']); - - if (!strlen($name) || !strlen($group) || !strlen($address)) { - printf ("

Error: Missing name, group or address. "); - return false; - } - - $address_els=explode(':',$address); - - if (count($address_els) == 1) { - $ip=$address_els[0]; - $transport='udp'; - $port='5060'; - } else if (count($address_els) == 2) { - $ip=$address_els[0]; - $port=$address_els[1]; - $transport='udp'; - } else if (count($address_els) == 3) { - $ip=$address_els[1]; - $port=intval($address_els[2]); - if ($address_els[0] == 'tcp' || $address_els[0] == 'tls' || $address_els[0] == 'udp') { - $transport=$address_els[0]; - } else { - $transport='udp'; - } - } - - $gateway=array( - 'name' => $name, - 'group' => $group, - 'ip' => $ip, - 'port' => intval($port), - 'uriScheme' => 'sip', - 'transport' => $transport, - 'strip' => intval($_REQUEST['strip']), - 'prefix' => $_REQUEST['prefix'] - ); - - $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); - - $result = $this->SOAPEngine->soapclient->addGateway($gateway); - - if (PEAR::isError($result)) { - $error_msg = $result->getMessage(); - $error_fault= $result->getFault(); - $error_code = $result->getCode(); - printf ("

Error from %s: %s (%s): %s",$this->SOAPEngine->SOAPurl,$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); - return false; - } else { - printf ("

Gateway %s has been added. ",$address); - return 1; - } - } - - function deleteRecord() { - if (!$_REQUEST['confirm']) { - print "

Please press on Confirm to confirm the delete. "; - return 1; - } - - if (!strlen($this->filters['name'])) { - print "

Error: missing gateway name. "; - return 0; - } - - $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); - - $result = $this->SOAPEngine->soapclient->deleteGateway($this->filters['name']); - - if (PEAR::isError($result)) { - $error_msg = $result->getMessage(); - $error_fault= $result->getFault(); - $error_code = $result->getCode(); - printf ("

Error from %s: %s (%s): %s",$this->SOAPEngine->SOAPurl,$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); - return false; - } else { - printf ("

Gateway %s has been deleted. ",$this->filters['address']); - unset($this->filters); - return 1; - } - } - - function showSeachFormCustom() { - printf (" Name",$this->filters['name']); - printf (" Group",$this->filters['group']); - } - -} - -class Routes extends Records { - var $gatewayGroups=array(); - - var $sortElements=array( - 'prefix' => 'Prefix', - 'fromURI' => 'From URI', - 'priority' => 'Priority' - ); - - function Routes(&$SOAPEngine) { - $this->filters = array('prefix' => trim($_REQUEST['prefix_filter']), - 'gatewayGroup' => trim($_REQUEST['gatewayGroup_filter']), - 'fromURI' => trim($_REQUEST['fromURI_filter']) - ); - - $this->Records(&$SOAPEngine); - } - - function listRecords() { - - // Get gateway groups - $Query=array('filter' => array('name'=>''), - 'orderBy' => array('attribute' => 'name', - 'direction' => 'ASC' - ), - 'range' => array('start' => 0, - 'count' => 1000) - ); - - $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); - $result = $this->SOAPEngine->soapclient->getGatewayGroups($Query); - - if (PEAR::isError($result)) { - $error_msg = $result->getMessage(); - $error_fault= $result->getFault(); - $error_code = $result->getCode(); - printf ("

Error from %s: %s (%s): %s",$this->SOAPEngine->SOAPurl,$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); - return false; - } else { - $this->gatewayGroups=$result->groups; - } - - - $this->showSeachForm(); - - // Insert credetials - $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); - - // Filter - $filter=array('prefix' => $this->filters['prefix'], - 'gatewayGroup' => $this->filters['gatewayGroup'], - 'fromURI' => $this->filters['fromURI'] - ); - - // 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 - $result = $this->SOAPEngine->soapclient->getRoutes($Query); - - if (PEAR::isError($result)) { - $error_msg = $result->getMessage(); - $error_fault= $result->getFault(); - $error_code = $result->getCode(); - printf ("

Error from %s: %s (%s): %s",$this->SOAPEngine->SOAPurl,$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); - return false; - } else { - - $this->rows = $result->total; - - print " - - -
$this->rows records found
-

- - - - - - - - "; - - if (!$this->next) $this->next=0; - - if ($this->rows > $this->maxrowsperpage) { - $maxrows = $this->maxrowsperpage + $this->next; - if ($maxrows > $this->rows) $maxrows = $this->maxrowsperpage; - } else { - $maxrows=$this->rows; - } - - $i=0; - - if ($this->rows) { - while ($i < $maxrows) { - - if (!$result->routes[$i]) break; - - $route = $result->routes[$i]; - - $index=$this->next+$i+1; - - $rr=floor($index/2); - $mod=$index-$rr*2; - - if ($mod ==0) { - $bgcolor="lightgrey"; - } else { - $bgcolor="white"; - } - - $_url = $this->url.sprintf("&service=%s&action=Delete&prefix_filter=%s&gatewayGroup_filter=%s&fromURI_filter=%s&priority_filter=%s", - urlencode($this->SOAPEngine->service), - urlencode($route->prefix), - urlencode($route->gatewayGroup), - urlencode($route->fromURI), - urlencode($route->priority) - ); - - if ($_REQUEST['action'] == 'Delete' && - $_REQUEST['prefix_filter'] == $route->prefix && - $_REQUEST['gatewayGroup_filter'] == $route->gatewayGroup && - $_REQUEST['fromURI_filter'] == $route->fromURI && - $_REQUEST['priority_filter'] == $route->priority) { - - $_url .= "&confirm=1"; - $actionText = "Confirm"; - } else { - $actionText = "Delete"; - } - - printf(" - - - - - - - - ", - $bgcolor, - $index, - $route->prefix, - $route->gatewayGroup, - $route->fromURI, - $route->priority, - $_url, - $actionText - ); - - printf(" - - "); - - $i++; - - } - - } - - print "
Id - Prefix - Gateway GroupFrom URIPriorityAction
%s%s%s%s%s%s
"; - - $this->showPagination($maxrows); - - return true; - } - } - - function showAddForm() { - if ($this->selectionActive) return; - print " -

- - - "; - printf ("",$_SERVER['PHP_SELF']); - print " - - - "; - - $this->printHiddenFormElements(); - - print " - - -
- "; - - print " - - "; - - printf (" Prefix"); - - printf (" Group: "); - - print ""); - printf (" From"); - printf (" Priority"); - - print " - - "; - print " -
- "; - } - - function addRecord() { - - $prefix = trim($_REQUEST['prefix']); - $gatewayGroup = trim($_REQUEST['gatewayGroup']); - $fromURI = trim($_REQUEST['fromURI']); - $priority = trim($_REQUEST['priority']); - - if (!strlen($prefix) || !strlen($gatewayGroup)) { - printf ("

Error: Missing prefix or gatewayGroup. "); - return false; - } - - $route=array( - 'prefix' => $prefix, - 'gatewayGroup' => $gatewayGroup, - 'fromURI' => $fromURI, - 'priority' => intval($priority) - ); - - $routes=array($route); - - $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); - - $result = $this->SOAPEngine->soapclient->addRoutes($routes); - - if (PEAR::isError($result)) { - $error_msg = $result->getMessage(); - $error_fault= $result->getFault(); - $error_code = $result->getCode(); - printf ("

Error from %s: %s (%s): %s",$this->SOAPEngine->SOAPurl,$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); - return false; - } else { - printf ("

Route %s has been added. ",$prefix); - return 1; - } - } - - function deleteRecord() { - if (!$_REQUEST['confirm']) { - print "

Please press on Confirm to confirm the delete. "; - return 1; - } - - if (!strlen($this->filters['prefix']) || !strlen($this->filters['gatewayGroup'])) { - print "

Error: missing route prefix or gatewayGroup. "; - return 0; - } - - $route=array( - 'prefix' => $this->filters['prefix'], - 'gatewayGroup' => $this->filters['gatewayGroup'], - 'fromURI' => $this->filters['fromURI'], - 'priority' => intval($this->filters['priority']) - ); - - $routes=array($route); - - $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); - - $result = $this->SOAPEngine->soapclient->deleteRoutes($routes); - - if (PEAR::isError($result)) { - $error_msg = $result->getMessage(); - $error_fault= $result->getFault(); - $error_code = $result->getCode(); - printf ("

Error from %s: %s (%s): %s",$this->SOAPEngine->SOAPurl,$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); - return false; - } else { - printf ("

Route %s has been deleted. ",$this->filters['prefix']); - unset($this->filters); - return 1; - } - } - - function showSeachFormCustom() { - printf (" Prefix",$this->filters['prefix']); - print ""); - - printf (" From URI",$this->filters['fromURI']); - } - -} - -class DomainStatistics extends Records { - - var $maxrowsperpage= 200; - - function DomainStatistics(&$SOAPEngine) { - $this->filters = array( - 'domain' => trim($_REQUEST['domain_filter']) - ); - - $this->Records(&$SOAPEngine); - } - - function listRecords() { - - $this->showSeachForm(); - - // Insert credetials - $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); - - $filter=$this->filters['domain']; - - // Call function - $result = $this->SOAPEngine->soapclient->getDomainStatistics($filter); - - if (PEAR::isError($result)) { - $error_msg = $result->getMessage(); - $error_fault= $result->getFault(); - $error_code = $result->getCode(); - printf ("

Error from %s: %s (%s): %s",$this->SOAPEngine->SOAPurl,$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); - return false; - } else { - - $this->rows = count($result); - - //print_r($result); - - print " - - -
$this->rows records found
-

- - - - - - - - "; - - if (!$this->next) $this->next=0; - - if ($this->rows > $this->maxrowsperpage) { - $maxrows = $this->maxrowsperpage + $this->next; - if ($maxrows > $this->rows) $maxrows = $this->maxrowsperpage; - } else { - $maxrows=$this->rows; - } - - $i=0; - - if ($this->rows) { - while ($i < $maxrows) { - - $domain = $result[$i]; - if (!strlen($domain->users)) break; - - $index = $this->next+$i+1; - - $rr=floor($index/2); - $mod=$index-$rr*2; - - if ($mod ==0) { - $bgcolor="lightgrey"; - } else { - $bgcolor="white"; - } - - $_url = $this->url.sprintf("&service=%s&action=Delete&domain_filter=%s", - urlencode($this->SOAPEngine->service), - urlencode($domain->domain) - ); - - if ($_REQUEST['action'] == 'Delete' && - $_REQUEST['domain_filter'] == $domain->domain) { - $_url .= "&confirm=1"; - $actionText = "Confirm"; - } else { - $actionText = "Delete"; - } - - printf(" - - - - - - - ", - $bgcolor, - $index, - $domain->domain, - $domain->users, - $domain->onlineUsers, - $domain->onlineDevices - ); - - $i++; - } - } - - print "
Id - SIP domainSIP subscribersOnline subscribersOnline SIP devices
%s%s%s%s%s
"; - - $this->showPagination($maxrows); - - return true; - } - } - - function showSeachFormCustom() { - - printf (" Domain",$this->filters['domain']); - - } - - function deleteRecord() { - if (!$_REQUEST['confirm']) { - print "

Please press on Confirm to confirm the delete. "; - return 1; - } - - if (!strlen($this->filters['domain']) || !strlen($this->filters['domain'])) { - print "

Error: missing SIP domain. "; - return 0; - } - - $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); - - $result = $this->SOAPEngine->soapclient->deleteDomain($this->filters['domain']); - - if (PEAR::isError($result)) { - $error_msg = $result->getMessage(); - $error_fault= $result->getFault(); - $error_code = $result->getCode(); - printf ("

Error from %s: %s (%s): %s",$this->SOAPEngine->SOAPurl,$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); - return false; - } else { - printf ("

SIP domain %s has been deleted. ",$this->filters['domain']); - unset($this->filters); - return 1; - } - } - - function addRecord() { - - $domain=trim($_REQUEST['domain']); - - $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); - - $result = $this->SOAPEngine->soapclient->addDomain($domain); - - if (PEAR::isError($result)) { - $error_msg = $result->getMessage(); - $error_fault= $result->getFault(); - $error_code = $result->getCode(); - printf ("

Error from %s: %s (%s): %s",$this->SOAPEngine->SOAPurl,$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); - return false; - } else { - printf ("

SIP domain %s has been added. ",$domain); - return 1; - } - } -} - -class Customers extends Records { - - var $maxrowsperpage= 20; - var $sortElements=array( - 'changeDate' => 'Change date', - 'username' => 'Username', - 'customer' => 'Customer' - ); - - var $propertiesItems = array('sip_credit' => array('name' => 'Credit for SIP account creation', - 'category' => 'admin'), - 'sipa_credit' => array('name' => 'Credit for SIP alias creation', - 'category' => 'admin'), - 'enum_range_credit' => array('name' => 'Credit for ENUM range creation', - 'category' => 'admin'), - 'enum_number_credit' => array('name' => 'Credit for ENUM numbers creation', - 'category' => 'admin'), - 'comp_code' => array('name' => 'Billing code for invoicing', - 'category' => 'admin'), - 'billing_email' => array('name' => 'Email address for invoicing', - 'category' => 'admin'), - 'registrar_id' => array('name' => 'Registrar id for domain registration', - 'category' => 'admin'), - 'pstn_access' => array('name' => 'Access to PSTN', - 'category' => 'admin'), - 'soap_engines' => array('name' => 'SOAP engines', - 'category' => 'admin'), - 'language' => array('name' => 'Language', - 'category' => 'general'), - 'voicemail_server' => array('name' => 'Voicemail server address', - 'category' => 'sip'), - 'sip_proxy_server' => array('name' => 'SIP Proxy server address', - 'category' => 'sip'), - 'support_web' => array('name' => 'Support web site', - 'category' => 'sip'), - 'support_email' => array('name' => 'Support email address', - 'category' => 'sip'), - 'cdrtool_address' => array('name' => 'CDRTool address', - 'category' => 'sip'), - 'sip_settings_page' => array('name' => 'SIP settings page', - 'category' => 'sip'), - 'default_sip_domain' => array('name' => 'Default SIP domain', - 'category' => 'sip'), - 'default_enum_range' => array('name' => 'Default ENUM range', - 'category' => 'sip'), - 'default_enum_tld' => array('name' => 'Default ENUM Top Level Domain', - 'category' => 'sip') - ); - - var $customerFieldsReadOnly=array( - 'id', - 'reseller' - ); - var $customerFields=array( - 'aliasOf' => array('type'=>'integer'), - 'username' => array('type'=>'string'), - 'password' => array('type'=>'string', - 'name'=>'Password'), - 'firstName' => array('type'=>'string', - 'name'=>'First name'), - 'lastName' => array('type'=>'string', - 'name'=>'Last name'), - 'organization'=> array('type'=>'string'), - 'vatNumber' => array('type'=>'string', - 'name'=>'VAT number'), - 'tel' => array('type'=>'string'), - 'fax' => array('type'=>'string'), - 'sip' => array('type'=>'string'), - 'enum' => array('type'=>'string'), - 'mobile' => array('type'=>'string'), - 'email' => array('type'=>'string'), - 'web' => array('type'=>'string'), - 'address' => array('type'=>'text'), - 'postcode' => array('type'=>'string'), - 'city' => array('type'=>'string'), - 'state' => array('type'=>'string'), - 'country' => array('type'=>'string'), - 'timezone' => array('type'=>'string') - ); - - var $states=array( - array("label"=>"", "value"=>"N/A"), - array("label"=>"-- CANADA --", "value"=>"-"), - array("label"=>"Alberta", "value"=>"AB"), - array("label"=>"British Columbia", "value"=>"BC"), - array("label"=>"Manitoba", "value"=>"MB"), - array("label"=>"New Brunswick", "value"=>"NB"), - array("label"=>"Newfoundland/Labrador", "value"=>"NL"), - array("label"=>"Northwest Territory", "value"=>"NT"), - array("label"=>"Nova Scotia", "value"=>"NS"), - array("label"=>"Nunavut", "value"=>"NU"), - array("label"=>"Ontario", "value"=>"ON"), - array("label"=>"Prince Edward Island", "value"=>"PE"), - array("label"=>"Quebec", "value"=>"QC"), - array("label"=>"Saskatchewan", "value"=>"SN"), - array("label"=>"Yukon", "value"=>"YT"), - array("label"=>"---- US -----", "value"=>"-"), - array("label"=>"Alabama", "value"=>"AL"), - array("label"=>"Alaska", "value"=>"AK"), - array("label"=>"American Samoa", "value"=>"AS"), - array("label"=>"Arizona", "value"=>"AZ"), - array("label"=>"Arkansas", "value"=>"AR"), - array("label"=>"California", "value"=>"CA"), - array("label"=>"Canal Zone", "value"=>"CZ"), - array("label"=>"Colorado", "value"=>"CO"), - array("label"=>"Connecticut", "value"=>"CT"), - array("label"=>"Delaware", "value"=>"DE"), - array("label"=>"District of Columbia", "value"=>"DC"), - array("label"=>"Florida", "value"=>"FL"), - array("label"=>"Georgia", "value"=>"GA"), - array("label"=>"Guam", "value"=>"GU"), - array("label"=>"Hawaii", "value"=>"HI"), - array("label"=>"Idaho", "value"=>"ID"), - array("label"=>"Illinois", "value"=>"IL"), - array("label"=>"Indiana", "value"=>"IN"), - array("label"=>"Iowa", "value"=>"IA"), - array("label"=>"Kansas", "value"=>"KS"), - array("label"=>"Kentucky", "value"=>"KY"), - array("label"=>"Louisiana", "value"=>"LA"), - array("label"=>"Maine", "value"=>"ME"), - array("label"=>"Mariana Islands", "value"=>"MP"), - array("label"=>"Maryland", "value"=>"MD"), - array("label"=>"Massachusetts", "value"=>"MA"), - array("label"=>"Michigan", "value"=>"MI"), - array("label"=>"Minnesota", "value"=>"MN"), - array("label"=>"Mississippi", "value"=>"MS"), - array("label"=>"Missouri", "value"=>"MO"), - array("label"=>"Montana", "value"=>"MT"), - array("label"=>"Nebraska", "value"=>"NE"), - array("label"=>"Nevada", "value"=>"NV"), - array("label"=>"New Hampshire", "value"=>"NH"), - array("label"=>"New Jersey", "value"=>"NJ"), - array("label"=>"New Mexico", "value"=>"NM"), - array("label"=>"New York", "value"=>"NY"), - array("label"=>"North Carolina", "value"=>"NC"), - array("label"=>"North Dakota", "value"=>"ND"), - array("label"=>"Ohio", "value"=>"OH"), - array("label"=>"Oklahoma", "value"=>"OK"), - array("label"=>"Oregon", "value"=>"OR"), - array("label"=>"Pennsylvania", "value"=>"PA"), - array("label"=>"Puerto Rico", "value"=>"PR"), - array("label"=>"Rhode Island", "value"=>"RI"), - array("label"=>"South Carolina", "value"=>"SC"), - array("label"=>"South Dakota", "value"=>"SD"), - array("label"=>"Tennessee", "value"=>"TN"), - array("label"=>"Texas", "value"=>"TX"), - array("label"=>"Utah", "value"=>"UT"), - array("label"=>"Vermont", "value"=>"VT"), - array("label"=>"Virgin Islands", "value"=>"VI"), - array("label"=>"Virginia", "value"=>"VA"), - array("label"=>"Washington", "value"=>"WA"), - array("label"=>"West Virginia", "value"=>"WV"), - array("label"=>"Wisconsin", "value"=>"WI"), - array("label"=>"Wyoming", "value"=>"WY"), - array("label"=>"APO", "value"=>"AP"), - array("label"=>"AEO", "value"=>"AE"), - array("label"=>"AAO", "value"=>"AA"), - array("label"=>"FPO", "value"=>"FP") - ); - - var $countries=array( - array("label"=>"Ascension Island", "value"=>"AC"), - array("label"=>"Afghanistan", "value"=>"AF"), - array("label"=>"Albania", "value"=>"AL"), - array("label"=>"Algeria", "value"=>"DZ"), - array("label"=>"American Samoa", "value"=>"AS"), - array("label"=>"Andorra", "value"=>"AD"), - array("label"=>"Angola", "value"=>"AO"), - array("label"=>"Anguilla", "value"=>"AI"), - array("label"=>"Antarctica", "value"=>"AQ"), - array("label"=>"Antigua And Barbuda", "value"=>"AG"), - array("label"=>"Argentina", "value"=>"AR"), - array("label"=>"Armenia", "value"=>"AM"), - array("label"=>"Aruba", "value"=>"AW"), - array("label"=>"Australia", "value"=>"AU"), - array("label"=>"Austria", "value"=>"AT"), - array("label"=>"Azerbaijan", "value"=>"AZ"), - array("label"=>"Bahamas", "value"=>"BS"), - array("label"=>"Bahrain", "value"=>"BH"), - array("label"=>"Bangladesh", "value"=>"BD"), - array("label"=>"Barbados", "value"=>"BB"), - array("label"=>"Belarus", "value"=>"BY"), - array("label"=>"Belgium", "value"=>"BE"), - array("label"=>"Belize", "value"=>"BZ"), - array("label"=>"Benin", "value"=>"BJ"), - array("label"=>"Bermuda", "value"=>"BM"), - array("label"=>"Bhutan", "value"=>"BT"), - array("label"=>"Bolivia", "value"=>"BO"), - array("label"=>"Bosnia And Herzegowina","value"=>"BA"), - array("label"=>"Botswana", "value"=>"BW"), - array("label"=>"Bouvet Island", "value"=>"BV"), - array("label"=>"Brazil", "value"=>"BR"), - array("label"=>"British Indian Ocean Territory", "value"=>"IO"), - array("label"=>"Brunei Darussalam", "value"=>"BN"), - array("label"=>"Bulgaria", "value"=>"BG"), - array("label"=>"Burkina Faso", "value"=>"BF"), - array("label"=>"Burundi", "value"=>"BI"), - array("label"=>"Cambodia", "value"=>"KH"), - array("label"=>"Cameroon", "value"=>"CM"), - array("label"=>"Canada", "value"=>"CA"), - array("label"=>"Cape Verde", "value"=>"CV"), - array("label"=>"Cayman Islands", "value"=>"KY"), - array("label"=>"Central African Republic", "value"=>"CF"), - array("label"=>"Chad", "value"=>"TD"), - array("label"=>"Chile", "value"=>"CL"), - array("label"=>"China", "value"=>"CN"), - array("label"=>"Christmas Island", "value"=>"CX"), - array("label"=>"Cocos (Keeling) Islands", "value"=>"CC"), - array("label"=>"Colombia", "value"=>"CO"), - array("label"=>"Comoros", "value"=>"KM"), - array("label"=>"Congo", "value"=>"CG"), - array("label"=>"Congo, Democratic People's Republic", "value"=>"CD"), - array("label"=>"Cook Islands", "value"=>"CK"), - array("label"=>"Costa Rica", "value"=>"CR"), - array("label"=>"Cote d'Ivoire", "value"=>"CI"), - array("label"=>"Croatia (local name: Hrvatska)", "value"=>"HR"), - array("label"=>"Cuba", "value"=>"CU"), - array("label"=>"Cyprus", "value"=>"CY"), - array("label"=>"Czech Republic","value"=>"CZ"), - array("label"=>"Denmark", "value"=>"DK"), - array("label"=>"Djibouti", "value"=>"DJ"), - array("label"=>"Dominica", "value"=>"DM"), - array("label"=>"Dominican Republic", "value"=>"DO"), - array("label"=>"East Timor", "value"=>"TP"), - array("label"=>"Ecuador", "value"=>"EC"), - array("label"=>"Egypt", "value"=>"EG"), - array("label"=>"El Salvador", "value"=>"SV"), - array("label"=>"Equatorial Guinea", "value"=>"GQ"), - array("label"=>"Eritrea", "value"=>"ER"), - array("label"=>"Estonia", "value"=>"EE"), - array("label"=>"Ethiopia", "value"=>"ET"), - array("label"=>"Falkland Islands (Malvinas)", "value"=>"FK"), - array("label"=>"Faroe Islands", "value"=>"FO"), - array("label"=>"Fiji", "value"=>"FJ"), - array("label"=>"Finland", "value"=>"FI"), - array("label"=>"France", "value"=>"FR"), - array("label"=>"French Guiana", "value"=>"GF"), - array("label"=>"French Polynesia", "value"=>"PF"), - array("label"=>"French Southern Territories", "value"=>"TF"), - array("label"=>"Gabon", "value"=>"GA"), - array("label"=>"Gambia", "value"=>"GM"), - array("label"=>"Georgia", "value"=>"GE"), - array("label"=>"Germany", "value"=>"DE"), - array("label"=>"Ghana", "value"=>"GH"), - array("label"=>"Gibraltar", "value"=>"GI"), - array("label"=>"Greece", "value"=>"GR"), - array("label"=>"Greenland", "value"=>"GL"), - array("label"=>"Grenada", "value"=>"GD"), - array("label"=>"Guadeloupe", "value"=>"GP"), - array("label"=>"Guam", "value"=>"GU"), - array("label"=>"Guatemala", "value"=>"GT"), - array("label"=>"Guernsey", "value"=>"GG"), - array("label"=>"Guinea", "value"=>"GN"), - array("label"=>"Guinea-Bissau", "value"=>"GW"), - array("label"=>"Guyana", "value"=>"GY"), - array("label"=>"Haiti", "value"=>"HT"), - array("label"=>"Heard And Mc Donald Islands", "value"=>"HM"), - array("label"=>"Honduras", "value"=>"HN"), - array("label"=>"Hong Kong", "value"=>"HK"), - array("label"=>"Hungary", "value"=>"HU"), - array("label"=>"Iceland", "value"=>"IS"), - array("label"=>"India", "value"=>"IN"), - array("label"=>"Indonesia", "value"=>"ID"), - array("label"=>"Iran (Islamic Republic Of)", "value"=>"IR"), - array("label"=>"Iraq", "value"=>"IQ"), - array("label"=>"Ireland", "value"=>"IE"), - array("label"=>"Isle of Man", "value"=>"IM"), - array("label"=>"Israel", "value"=>"IL"), - array("label"=>"Italy", "value"=>"IT"), - array("label"=>"Jamaica", "value"=>"JM"), - array("label"=>"Japan", "value"=>"JP"), - array("label"=>"Jersey", "value"=>"JE"), - array("label"=>"Jordan", "value"=>"JO"), - array("label"=>"Kazakhstan", "value"=>"KZ"), - array("label"=>"Kenya", "value"=>"KE"), - array("label"=>"Kiribati", "value"=>"KI"), - array("label"=>"Korea, Democratic People's Republic Of", "value"=>"KP"), - array("label"=>"Korea, Republic Of", "value"=>"KR"), - array("label"=>"Kuwait", "value"=>"KW"), - array("label"=>"Kyrgyzstan", "value"=>"KG"), - array("label"=>"Lao People's Democratic Republic", "value"=>"LA"), - array("label"=>"Latvia", "value"=>"LV"), - array("label"=>"Lebanon", "value"=>"LB"), - array("label"=>"Lesotho", "value"=>"LS"), - array("label"=>"Liberia", "value"=>"LR"), - array("label"=>"Libyan Arab Jamahiriya", "value"=>"LY"), - array("label"=>"Liechtenstein", "value"=>"LI"), - array("label"=>"Lithuania", "value"=>"LT"), - array("label"=>"Luxembourg", "value"=>"LU"), - array("label"=>"Macau", "value"=>"MO"), - array("label"=>"Macedonia, The Former Yugoslav", "value"=>"MK"), - array("label"=>"Of", "value"=>"Republic"), - array("label"=>"Madagascar", "value"=>"MG"), - array("label"=>"Malawi", "value"=>"MW"), - array("label"=>"Malaysia", "value"=>"MY"), - array("label"=>"Maldives", "value"=>"MV"), - array("label"=>"Mali", "value"=>"ML"), - array("label"=>"Malta", "value"=>"MT"), - array("label"=>"Marshall Islands", "value"=>"MH"), - array("label"=>"Martinique", "value"=>"MQ"), - array("label"=>"Mauritania", "value"=>"MR"), - array("label"=>"Mauritius", "value"=>"MU"), - array("label"=>"Mayotte", "value"=>"YT"), - array("label"=>"Mexico", "value"=>"MX"), - array("label"=>"Micronesia, Federated States Of", "value"=>"FM"), - array("label"=>"Moldova, Republic Of", "value"=>"MD"), - array("label"=>"Monaco", "value"=>"MC"), - array("label"=>"Mongolia", "value"=>"MN"), - array("label"=>"Montserrat", "value"=>"MS"), - array("label"=>"Morocco", "value"=>"MA"), - array("label"=>"Mozambique", "value"=>"MZ"), - array("label"=>"Myanmar", "value"=>"MM"), - array("label"=>"Namibia", "value"=>"NA"), - array("label"=>"Nauru", "value"=>"NR"), - array("label"=>"Nepal", "value"=>"NP"), - array("label"=>"Netherlands", "value"=>"NL"), - array("label"=>"Netherlands Antilles", "value"=>"AN"), - array("label"=>"New Caledonia", "value"=>"NC"), - array("label"=>"New Zealand", "value"=>"NZ"), - array("label"=>"Nicaragua", "value"=>"NI"), - array("label"=>"Niger", "value"=>"NE"), - array("label"=>"Nigeria", "value"=>"NG"), - array("label"=>"Niue", "value"=>"NU"), - array("label"=>"Norfolk Island", "value"=>"NF"), - array("label"=>"Northern Mariana Islands", "value"=>"MP"), - array("label"=>"Norway", "value"=>"NO"), - array("label"=>"Oman", "value"=>"OM"), - array("label"=>"Pakistan", "value"=>"PK"), - array("label"=>"Palau", "value"=>"PW"), - array("label"=>"Palestinian Territories", "value"=>"PS"), - array("label"=>"Panama", "value"=>"PA"), - array("label"=>"Papua New Guinea", "value"=>"PG"), - array("label"=>"Paraguay", "value"=>"PY"), - array("label"=>"Peru", "value"=>"PE"), - array("label"=>"Philippines", "value"=>"PH"), - array("label"=>"Pitcairn", "value"=>"PN"), - array("label"=>"Poland", "value"=>"PL"), - array("label"=>"Portugal", "value"=>"PT"), - array("label"=>"Puerto Rico", "value"=>"PR"), - array("label"=>"Qatar", "value"=>"QA"), - array("label"=>"Reunion", "value"=>"RE"), - array("label"=>"Romania", "value"=>"RO"), - array("label"=>"Russian Federation", "value"=>"RU"), - array("label"=>"Rwanda", "value"=>"RW"), - array("label"=>"Saint Kitts And Nevis", "value"=>"KN"), - array("label"=>"Saint Lucia", "value"=>"LC"), - array("label"=>"Saint Vincent And The Grenadines", "value"=>"VC"), - array("label"=>"Samoa", "value"=>"WS"), - array("label"=>"San Marino", "value"=>"SM"), - array("label"=>"Sao Tome And Principe", "value"=>"ST"), - array("label"=>"Saudi Arabia", "value"=>"SA"), - array("label"=>"Senegal", "value"=>"SN"), - array("label"=>"Seychelles", "value"=>"SC"), - array("label"=>"Sierra Leone", "value"=>"SL"), - array("label"=>"Singapore", "value"=>"SG"), - array("label"=>"Slovakia (Slovak Republic)", "value"=>"SK"), - array("label"=>"Slovenia", "value"=>"SI"), - array("label"=>"Solomon Islands", "value"=>"SB"), - array("label"=>"Somalia", "value"=>"SO"), - array("label"=>"South Africa", "value"=>"ZA"), - array("label"=>"South Georgia And South Sandwich", "value"=>"GS"), - array("label"=>"Spain", "value"=>"ES"), - array("label"=>"Sri Lanka", "value"=>"LK"), - array("label"=>"St. Helena", "value"=>"SH"), - array("label"=>"St. Pierre And Miquelon", "value"=>"PM"), - array("label"=>"Sudan", "value"=>"SD"), - array("label"=>"Suriname", "value"=>"SR"), - array("label"=>"Svalbard And Jan Mayen Islands", "value"=>"SJ"), - array("label"=>"Swaziland", "value"=>"SZ"), - array("label"=>"Sweden", "value"=>"SE"), - array("label"=>"Switzerland", "value"=>"CH"), - array("label"=>"Syrian Arab Republic", "value"=>"SY"), - array("label"=>"Taiwan, Province Of China", "value"=>"TW"), - array("label"=>"Tajikistan", "value"=>"TJ"), - array("label"=>"Tanzania, United Republic Of", "value"=>"TZ"), - array("label"=>"Thailand", "value"=>"TH"), - array("label"=>"Togo", "value"=>"TG"), - array("label"=>"Tokelau", "value"=>"TK"), - array("label"=>"Tonga", "value"=>"TO"), - array("label"=>"Trinidad And Tobago", "value"=>"TT"), - array("label"=>"Tunisia", "value"=>"TN"), - array("label"=>"Turkey", "value"=>"TR"), - array("label"=>"Turkmenistan", "value"=>"TM"), - array("label"=>"Turks And Caicos Islands", "value"=>"TC"), - array("label"=>"Tuvalu", "value"=>"TV"), - array("label"=>"Uganda", "value"=>"UG"), - array("label"=>"Ukraine", "value"=>"UA"), - array("label"=>"United Arab Emirates", "value"=>"AE"), - array("label"=>"United Kingdom", "value"=>"UK"), - array("label"=>"United States", "value"=>"US"), - array("label"=>"United States Minor Outlying Islands", "value"=>"UM"), - array("label"=>"Uruguay", "value"=>"UY"), - array("label"=>"Uzbekistan", "value"=>"UZ"), - array("label"=>"Vanuatu", "value"=>"VU"), - array("label"=>"Vatican City State (Holy See)", "value"=>"VA"), - array("label"=>"Venezuela", "value"=>"VE"), - array("label"=>"Viet Nam", "value"=>"VN"), - array("label"=>"Virgin Islands (British)", "value"=>"VG"), - array("label"=>"Virgin Islands (U.S.)", "value"=>"VI"), - array("label"=>"Wallis And Futuna Islands", "value"=>"WF"), - array("label"=>"Western Sahara", "value"=>"EH"), - array("label"=>"Yemen", "value"=>"YE"), - array("label"=>"Yugoslavia", "value"=>"YU"), - array("label"=>"Zaire", "value"=>"ZR"), - array("label"=>"Zambia", "value"=>"ZM"), - array("label"=>"Zimbabwe", "value"=>"ZW"), - array("label"=>"Undefined", "value"=>"N/A") - ); - - function Customers(&$SOAPEngine) { - $this->filters = array( - 'username' => trim($_REQUEST['username_filter']), - 'firstName' => trim($_REQUEST['firstName_filter']), - 'lastName' => trim($_REQUEST['lastName_filter']), - 'email' => trim($_REQUEST['email_filter']), - 'organization' => trim($_REQUEST['organization_filter']), - 'only_resellers' => trim($_REQUEST['only_resellers_filter']) - ); - - $this->Records(&$SOAPEngine); - } - - function listRecords() { - - // Filter - $filter=array('username' => $this->filters['username'], - 'firstName' => $this->filters['firstName'], - 'lastName' => $this->filters['lastName'], - 'email' => $this->filters['email'], - 'organization' => $this->filters['organization'], - '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'] = 'customer'; - 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 - ); - - $this->showSeachForm(); - - // Insert credetials - $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); - - // Call function - if ($this->adminonly && $this->filters['only_resellers']) { - $result = $this->SOAPEngine->soapclient->getResellers($Query); - } else { - $result = $this->SOAPEngine->soapclient->getCustomers($Query); - } - - if (PEAR::isError($result)) { - $error_msg = $result->getMessage(); - $error_fault= $result->getFault(); - $error_code = $result->getCode(); - printf ("

Error from %s: %s (%s): %s",$this->SOAPEngine->SOAPurl,$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); - return false; - } else { - - $this->rows = $result->total; - - if ($this->rows && $_REQUEST['action'] != 'PerformActions' && $_REQUEST['action'] != 'Delete') { - $this->showActionsForm(); - } - - print " - - -
$this->rows records found
-

- - - "; - print" - - - - - - - - "; - - if (!$this->next) $this->next=0; - - if ($this->rows > $this->maxrowsperpage) { - $maxrows = $this->maxrowsperpage + $this->next; - if ($maxrows > $this->rows) $maxrows = $this->maxrowsperpage; - } else { - $maxrows=$this->rows; - } - - $i=0; - - if ($this->rows) { - while ($i < $maxrows) { - - if (!$result->accounts[$i]) break; - - $customer = $result->accounts[$i]; - - $index = $this->next+$i+1; - - $rr=floor($index/2); - $mod=$index-$rr*2; - - if ($mod ==0) { - $bgcolor="lightgrey"; - } else { - $bgcolor="white"; - } - - $_url = $this->url.sprintf("&service=%s&action=Delete&customer_filter=%s", - urlencode($this->SOAPEngine->service), - urlencode($customer->id) - ); - - if ($_REQUEST['action'] == 'Delete' && - $_REQUEST['customer_filter'] == $customer->id) { - $_url .= "&confirm=1"; - $actionText = "Confirm"; - } else { - $actionText = "Delete"; - } - - $_customer_url = $this->url.sprintf("&service=%s&customer_filter=%s", - urlencode($this->SOAPEngine->service), - urlencode($customer->id) - ); - - printf(" - - - - - - - - - - ", - $bgcolor, - $index, - $_customer_url, - $customer->reseller, - $customer->id, - $customer->firstName, - $customer->lastName, - $customer->organization, - $customer->email, - $customer->tel, - $customer->web, - $_url, - $actionText - ); - - $i++; - } - } - - print "
Id - "; - if ($this->version > 1) print "CustomerNameOrganizationE-mailTelephoneWebAction
%s%s.%s%s %s%s%s%s%s%s
"; - - - if ($this->rows == 1 ) { - $this->showRecord($customer->id); - } else { - $this->showPagination($maxrows); - } - - return true; - } - } - - function showSeachFormCustom() { - if (!$this->filters['reseller']) { - printf (" Customer",$this->filters['customer']); - } - printf (" Username",$this->filters['username']); - if ($this->adminonly) { - if ($this->filters['only_resellers']) $check_only_resellers_filter='checked'; - printf (" Resellers",$check_only_resellers_filter); - } - } - - function deleteRecord() { - if (!$_REQUEST['confirm']) { - print "

Please press on Confirm to confirm the delete. "; - return 1; - } - - if (!strlen($this->filters['customer']) || !strlen($this->filters['customer'])) { - print "

Error: missing customer id. "; - return 0; - } - - $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); - $result = $this->SOAPEngine->soapclient->deleteAccount(intval($this->filters['customer'])); - - if (PEAR::isError($result)) { - $error_msg = $result->getMessage(); - $error_fault= $result->getFault(); - $error_code = $result->getCode(); - printf ("

Error from %s: %s (%s): %s",$this->SOAPEngine->SOAPurl,$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); - return false; - } else { - printf ("

Customer id %s has been deleted. ",$this->filters['customer']); - unset($this->filters); - return 1; - } - } - - function getCustomer($id) { - - $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); - $result = $this->SOAPEngine->soapclient->getAccount(intval($id)); - - if (PEAR::isError($result)) { - $error_msg = $result->getMessage(); - $error_fault= $result->getFault(); - $error_code = $result->getCode(); - printf ("

Error from %s: %s (%s): %s",$this->SOAPEngine->SOAPurl,$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); - return false; - } else { - return $result; - } - } - - function showRecord($id) { - - if (!$customer = $this->getCustomer($id)) { - return false; - } - - print ""; - print " - - - - -
-

Customer data

- "; - printf ("",$_SERVER['PHP_SELF']); - print ""; - print ""; - - print " - "; - - printf (" - - - "); - foreach ($this->customerFieldsReadOnly as $item) { - printf (" - - - ", - ucfirst($item), - $customer->$item - ); - } - foreach (array_keys($this->customerFields) as $item) { - if ($this->customerFields[$item]['name']) { - $item_name=$this->customerFields[$item]['name']; - } else { - $item_name=ucfirst($item); - } - - if ($item=='timezone') { - printf (" - ", - $item_name - ); - print " - - "; - } else if ($item=='country') { - printf (" - ", - $item_name - ); - print " - - "; - - - } else if ($item=='state') { - printf (" - ", - $item_name - ); - - print " - - "; - - } else { - if ($this->customerFields[$item]['type'] == 'text') { - printf (" - - - ", - $item_name, - $item, - $customer->$item - ); - } else { - printf (" - - - ", - $item_name, - $item, - $customer->$item - ); - } - } - } - - $this->printFiltersToForm(); - - $this->printHiddenFormElements(); - - print ""; - print " -
-
FieldValue
%s%s
%s"; - - $this->showTimezones($customer->$item); - - print "
%s - -
%s - -
%s
%s
- "; - - /* - print "
";
-        print_r($customer);
-        print "
"; - */ - - foreach ($customer->properties as $_property) { - if (in_array($_property->name,array_keys($this->propertiesItems))) { - $this->propertiesItems[$_property->name]['value']=$_property->value; - } - } - - - print "
-

Customer properties

- "; - printf ("",$_SERVER['PHP_SELF']); - print ""; - print ""; - print " - "; - - printf (" - - - - "); - - foreach (array_keys($this->propertiesItems) as $item) { - $item_print=ucfirst (preg_replace("/_/"," ",$item)); - printf (" - - - - ", - $item_print, - $item, - $this->propertiesItems[$item]['value'], - $this->propertiesItems[$item]['name'] - ); - } - - $this->printFiltersToForm(); - - $this->printHiddenFormElements(); - - print ""; - - print " -
-
PropertyValueDescription
%s%s
-
- "; - } - - function updateRecord () { - //print "

Updating customer ..."; - - if (!$_REQUEST['customer_filter']) return; - - if (!$customer=$this->getCustomer($_REQUEST['customer_filter'])) { - return false; - } - - $properties=array(); - - if ($_REQUEST['section'] == 'customer_properties') { - foreach (array_keys($this->propertiesItems) as $item) { - $var_name=$item.'_form'; - $properties[]=array('name' => $item, - 'value' => trim($_REQUEST[$var_name]), - 'category' => $this->propertiesItems[$item]['category'] - ); - - } - - $customer->properties=$properties; - - } else { - foreach (array_keys($this->customerFields) as $item) { - $var_name=$item.'_form'; - //printf ("
%s=%s",$var_name,$_REQUEST[$var_name]); - if ($this->customerFields[$item]['type'] == 'integer') { - $customer->$item = intval($_REQUEST[$var_name]); - } else { - $customer->$item = trim($_REQUEST[$var_name]); - } - } - - foreach ($customer->properties as $_property) { - $properties[]=$_property; - } - $customer->properties=$properties; - } - - /* - print "

";
-        print_r($customer);
-        print "
"; - */ - - $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); - $result = $this->SOAPEngine->soapclient->updateAccount($customer); - - if (PEAR::isError($result)) { - $error_msg = $result->getMessage(); - $error_fault= $result->getFault(); - $error_code = $result->getCode(); - printf ("

Error from %s: %s (%s): %s",$this->SOAPEngine->SOAPurl,$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); - return false; - } else { - return true; - } - } - - function showTimezones($timezone) { - if (!$fp = fopen("timezones", "r")) { - print _("Failed to open timezone file."); - return false; - } - - print ""; - } -} - -class recordsGenerator { - function recordsGenerator() { - } - - function showAddForm() { - print " -

- - - "; - printf ("",$_SERVER['PHP_SELF']); - print " - - - "; - $this->printHiddenFormElements(); - - print " - - -
- "; - - print " - - "; - - printf (" Name"); - - $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); - $result = $this->SOAPEngine->soapclient->getGatewayGroups(); - - printf (" Group: "); - - // Compose query - $Query=array('filter' => array('name'=>''), - 'orderBy' => array('attribute' => 'name', - 'direction' => 'ASC' - ), - 'range' => array('start' => 0, - 'count' => 1000) - ); - - $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); - $result = $this->SOAPEngine->soapclient->getGatewayGroups($Query); - - if (PEAR::isError($result)) { - $error_msg = $result->getMessage(); - $error_fault= $result->getFault(); - $error_code = $result->getCode(); - printf ("

Error from %s: %s (%s): %s",$this->SOAPEngine->SOAPurl,$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); - return false; - } else { - print ""); - } - printf (" Address"); - printf (" Strip: "; - printf (" Prefix"); - - print " -

- "; - print " -
- "; - } - -} - -class Actions { - var $actions=array(); - var $version = 1; - - function Actions(&$SOAPEngine) { - $this->SOAPEngine = $SOAPEngine; - $this->version = $this->SOAPEngine->version; - $this->adminonly = $this->SOAPEngine->adminonly; - } - - function performActions($selectionKeys,$action,$sub_action_parameter) { - } - - function showActionsForm($filters,$sorting,$hideParameter=false) { - if (!count($this->actions)) return; - - print " -

- - - "; - - printf ("",$_SERVER['PHP_SELF']); - print " - - - "; - - foreach (array_keys($filters) as $_filter) { - printf ("\n", $_filter,$filters[$_filter]); - } - - foreach (array_keys($sorting) as $_sorting) { - printf ("\n", $_sorting,$sorting[$_sorting]); - } - - printf("",$this->SOAPEngine->service); - - foreach (array_keys($this->SOAPEngine->extraFormElements) as $element) { - if (!strlen($this->SOAPEngine->extraFormElements[$element])) continue; - printf ("\n",$element,$this->SOAPEngine->extraFormElements[$element]); - } - print " - - -
- "; - - print " - - - "; - if ($this->adminonly) { - print " - adminonly> - "; - } - - - print ""; - - - if (!$hideParameter) { - print " - - "; - } - print " - - "; - print " -
- "; - - } -} - -class SIPAccountsActions extends Actions { - var $actions=array('block' => 'Block SIP accounts', - 'deblock' => 'Deblock SIP accounts', - 'enable_pstn' => 'Enable access to PSTN for the SIP accounts', - 'disable_pstn' => 'Disable access to PSTN for the SIP accounts', - 'deblock_quota' => 'Deblock SIP accounts blocked by quota', - 'prepaid' => 'Make SIP accounts prepaid', - 'postpaid' => 'Make SIP accounts postpaid', - 'delete' => 'Delete SIP accounts', - 'setquota' => 'Set quota of SIP account to:', - 'rpidasusername' => 'Set PSTN caller ID as the username', - 'prefixtorpid' => 'Add to PSTN caller ID this prefix:', - 'rmdsfromrpid' => 'Remove from PSTN caller ID digits:', - 'addtogroup' => 'Add SIP accounts to group:', - 'removefromgroup'=> 'Remove SIP accounts from group:', - 'addbalance' => 'Add to prepaid balance value:', - 'changeowner' => 'Change owner to:' - ); - - function SIPAccountsActions(&$SOAPEngine) { - $this->Actions(&$SOAPEngine); - if ($this->version > 1) { - $this->actions['changecustomer']='Change customer to:'; - } - } - - function performActions($selectionKeys,$action,$sub_action_parameter) { - if (!in_array($action,array_keys($this->actions))) { - print "Error: Invalid action $action"; - return false; - } - - print "

    "; - foreach($selectionKeys as $key) { - print "
  1. "; - - flush(); - //printf ("Performing action=%s on key=%s",$action,$key); - - $account=array('username' => $key['username'], - 'domain' => $key['domain'] - ); - - if ($action=='block') { - - $function=array('commit' => array('name' => 'addToGroup', - 'parameters' => array($account,'block'), - 'logs' => array('success' => sprintf('SIP account %s@%s has been blocked',$key['username'],$key['domain']) - ) - ) - - ); - - $this->SOAPEngine->execute($function); - - } else if ($action=='deblock') { - - $function=array('commit' => array('name' => 'removeFromGroup', - 'parameters' => array($account,'block'), - 'logs' => array('success' => sprintf('SIP account %s@%s has been de-blocked',$key['username'],$key['domain']) - ) - ) - - ); - - $this->SOAPEngine->execute($function); - - } else if ($action=='removefromgroup') { - if (!strlen($sub_action_parameter)) { - printf ("Error: you must enter a group name"); - break; - } - - $function=array('commit' => array('name' => 'removeFromGroup', - 'parameters' => array($account,$sub_action_parameter), - 'logs' => array('success' => sprintf('SIP account %s@%s has been removed from group',$key['username'],$key['domain'],$sub_action_parameter) - ) - ) - - ); - - $this->SOAPEngine->execute($function); - - } else if ($action=='addtogroup') { - if (!strlen($sub_action_parameter)) { - printf ("Error: you must enter a group name"); - break; - } - - $function=array('commit' => array('name' => 'addToGroup', - 'parameters' => array($account,$sub_action_parameter), - 'logs' => array('success' => sprintf('SIP account %s@%s is now in group %s',$key['username'],$key['domain'],$sub_action_parameter) - ) - ) - - ); - - $this->SOAPEngine->execute($function); - - } else if ($action=='deblock_quota') { - - $function=array('commit' => array('name' => 'removeFromGroup', - 'parameters' => array($account,'quota'), - 'logs' => array('success' => sprintf('SIP account %s@%s has been deblocked from quota',$key['username'],$key['domain']) - ) - ) - - ); - - $this->SOAPEngine->execute($function); - - } else if ($action=='disable_pstn') { - - $function=array('commit' => array('name' => 'removeFromGroup', - 'parameters' => array($account,'free-pstn'), - 'logs' => array('success' => sprintf('SIP account %s@%s has no access to the PSTN',$key['username'],$key['domain']) - ) - ) - - ); - - $this->SOAPEngine->execute($function); - - } else if ($action=='enable_pstn') { - - $function=array('commit' => array('name' => 'addToGroup', - 'parameters' => array($account,'free-pstn'), - 'logs' => array('success' => sprintf('SIP account %s@%s has access to the PSTN',$key['username'],$key['domain']) - ) - ) - - ); - - $this->SOAPEngine->execute($function); - - } else if ($action=='delete') { - - $function=array('commit' => array('name' => 'deleteAccount', - 'parameters' => array($account), - 'logs' => array('success' => sprintf('SIP account %s@%s has been deleted',$key['username'],$key['domain']) - ) - ) - - ); - - $this->SOAPEngine->execute($function); - - } else if ($action=='prepaid') { - $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); - $result = $this->SOAPEngine->soapclient->getAccount($account); - - if (PEAR::isError($result)) { - $error_msg = $result->getMessage(); - $error_fault= $result->getFault(); - $error_code = $result->getCode(); - printf ("Error: %s (%s): %s",$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); - break; - } else { - //print_r($result); - // Sanitize data types due to PHP bugs - - if (!is_array($result->properties)) $result->properties=array(); - if (!is_array($result->groups)) $result->groups=array(); - $result->quota = intval($result->quota); - $result->answerTimeout = intval($result->answerTimeout); - - $result->prepaid=1; - - $function=array('commit' => array('name' => 'updateAccount', - 'parameters' => array($result), - 'logs' => array('success' => sprintf('SIP account %s@%s is now prepaid',$key['username'],$key['domain']) - ) - ) - - ); - $this->SOAPEngine->execute($function); - } - } else if ($action=='postpaid') { - $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); - $result = $this->SOAPEngine->soapclient->getAccount($account); - - if (PEAR::isError($result)) { - $error_msg = $result->getMessage(); - $error_fault= $result->getFault(); - $error_code = $result->getCode(); - printf ("Error: %s (%s): %s",$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); - break; - } else { - //print_r($result); - // Sanitize data types due to PHP bugs - - if (!is_array($result->properties)) $result->properties=array(); - if (!is_array($result->groups)) $result->groups=array(); - $result->quota = intval($result->quota); - $result->answerTimeout = intval($result->answerTimeout); - - $result->prepaid=0; - - $function=array('commit' => array('name' => 'updateAccount', - 'parameters' => array($result), - 'logs' => array('success' => sprintf('SIP account %s@%s is now postpaid',$key['username'],$key['domain']) - ) - ) - - ); - $this->SOAPEngine->execute($function); - - } - } else if ($action=='setquota') { - $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); - $result = $this->SOAPEngine->soapclient->getAccount($account); - - if (PEAR::isError($result)) { - $error_msg = $result->getMessage(); - $error_fault= $result->getFault(); - $error_code = $result->getCode(); - printf ("Error: %s (%s): %s",$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); - break; - } else { - //print_r($result); - // Sanitize data types due to PHP bugs - - if (!is_array($result->properties)) $result->properties=array(); - if (!is_array($result->groups)) $result->groups=array(); - $result->quota = intval($sub_action_parameter); - $result->answerTimeout = intval($result->answerTimeout); - - $function=array('commit' => array('name' => 'updateAccount', - 'parameters' => array($result), - 'logs' => array('success' => sprintf('SIP account %s@%s has quota set to %s',$key['username'],$key['domain'],$sub_action_parameter) - ) - ) - - ); - $this->SOAPEngine->execute($function); - - } - - } else if ($action=='rmdsfromrpid') { - $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); - $result = $this->SOAPEngine->soapclient->getAccount($account); - - if (PEAR::isError($result)) { - $error_msg = $result->getMessage(); - $error_fault= $result->getFault(); - $error_code = $result->getCode(); - printf ("Error: %s (%s): %s",$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); - break; - } else { - //print_r($result); - // Sanitize data types due to PHP bugs - - if (!is_array($result->properties)) $result->properties=array(); - if (!is_array($result->groups)) $result->groups=array(); - if (is_numeric($sub_action_parameter) && strlen($result->rpid) > $sub_action_parameter) { - printf("%s %s",$result->rpid,$sub_action_parameter); - $result->rpid=substr($result->rpid,$sub_action_parameter); - printf("%s %s",$result->rpid,$sub_action_parameter); - } else { - printf ("Error: '%s' must be numeric and less than caller if length",$sub_action_parameter); - continue; - } - - $result->quota = intval($result->quota); - $result->answerTimeout = intval($result->answerTimeout); - - $function=array('commit' => array('name' => 'updateAccount', - 'parameters' => array($result), - 'logs' => array('success' => sprintf('SIP account %s@%s has PSTN caller ID set to %s',$key['username'],$key['domain'],$result->rpid) - ) - ) - - ); - $this->SOAPEngine->execute($function); - - } - } else if ($action=='rpidasusername') { - $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); - $result = $this->SOAPEngine->soapclient->getAccount($account); - - if (PEAR::isError($result)) { - $error_msg = $result->getMessage(); - $error_fault= $result->getFault(); - $error_code = $result->getCode(); - printf ("Error: %s (%s): %s",$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); - break; - } else { - //print_r($result); - // Sanitize data types due to PHP bugs - - if (!is_array($result->properties)) $result->properties=array(); - if (!is_array($result->groups)) $result->groups=array(); - if (is_numeric($key['username'])) $result->rpid=$key['username']; - - $result->quota = intval($result->quota); - $result->answerTimeout = intval($result->answerTimeout); - - $function=array('commit' => array('name' => 'updateAccount', - 'parameters' => array($result), - 'logs' => array('success' => sprintf('SIP account %s@%s has PSTN caller ID set to %s',$key['username'],$key['domain'],$key['username']) - ) - ) - - ); - $this->SOAPEngine->execute($function); - - } - } else if ($action=='prefixtorpid') { - $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); - $result = $this->SOAPEngine->soapclient->getAccount($account); - - if (PEAR::isError($result)) { - $error_msg = $result->getMessage(); - $error_fault= $result->getFault(); - $error_code = $result->getCode(); - printf ("Error: %s (%s): %s",$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); - break; - } else { - //print_r($result); - // Sanitize data types due to PHP bugs - - if (!is_array($result->properties)) $result->properties=array(); - if (!is_array($result->groups)) $result->groups=array(); - if (is_numeric($sub_action_parameter)) { - $result->rpid=$sub_action_parameter.$result->rpid; - } else { - printf ("Error: '%s' must be numeric",$sub_action_parameter); - continue; - } - $result->quota = intval($result->quota); - $result->answerTimeout = intval($result->answerTimeout); - - $function=array('commit' => array('name' => 'updateAccount', - 'parameters' => array($result), - 'logs' => array('success' => sprintf('SIP account %s@%s has PSTN caller ID set to %s ',$key['username'],$key['domain'],$result->rpid) - ) - ) - - ); - $this->SOAPEngine->execute($function); - - } - } else if ($action=='changecustomer' && $this->version > 1) { - $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); - $result = $this->SOAPEngine->soapclient->getAccount($account); - - if (PEAR::isError($result)) { - $error_msg = $result->getMessage(); - $error_fault= $result->getFault(); - $error_code = $result->getCode(); - printf ("Error: %s (%s): %s",$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); - break; - } else { - //print_r($result); - // Sanitize data types due to PHP bugs - - if (!is_array($result->properties)) $result->properties=array(); - if (!is_array($result->groups)) $result->groups=array(); - if (is_numeric($sub_action_parameter)) { - $result->customer=intval($sub_action_parameter); - } else { - printf ("Error: '%s' must be numeric",$sub_action_parameter); - continue; - } - $result->quota = intval($result->quota); - $result->answerTimeout = intval($result->answerTimeout); - - $function=array('commit' => array('name' => 'updateAccount', - 'parameters' => array($result), - 'logs' => array('success' => sprintf('SIP account %s@%s has customer set to %s ',$key['username'],$key['domain'],$result->customer) - ) - ) - - ); - $this->SOAPEngine->execute($function); - - } - } else if ($action=='changeowner') { - $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); - $result = $this->SOAPEngine->soapclient->getAccount($account); - - if (PEAR::isError($result)) { - $error_msg = $result->getMessage(); - $error_fault= $result->getFault(); - $error_code = $result->getCode(); - printf ("Error: %s (%s): %s",$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); - break; - } else { - //print_r($result); - // Sanitize data types due to PHP bugs - - if (!is_array($result->properties)) $result->properties=array(); - if (!is_array($result->groups)) $result->groups=array(); - if (is_numeric($sub_action_parameter)) { - $result->owner=intval($sub_action_parameter); - } else { - printf ("Error: '%s' must be numeric",$sub_action_parameter); - continue; - } - $result->quota = intval($result->quota); - $result->answerTimeout = intval($result->answerTimeout); - - $function=array('commit' => array('name' => 'updateAccount', - 'parameters' => array($result), - 'logs' => array('success' => sprintf('SIP account %s@%s has owner set to %s ',$key['username'],$key['domain'],$result->customer) - ) - ) - - ); - $this->SOAPEngine->execute($function); - - } - } else if ($action=='addbalance') { - if (!is_numeric($sub_action_parameter)) { - printf ("Error: you must enter a positive balance"); - break; - } - - $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); - $result = $this->SOAPEngine->soapclient->getAccount($account); - - if (PEAR::isError($result)) { - $error_msg = $result->getMessage(); - $error_fault= $result->getFault(); - $error_code = $result->getCode(); - printf ("Error: %s (%s): %s",$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); - break; - } - - if (!$result->prepaid) { - printf ("Info: SIP account %s@%s is not prepaid, no action performed",$key['username'],$key['domain']); - continue; - } - - $function=array('commit' => array('name' => 'addBalance', - 'parameters' => array($account,$sub_action_parameter), - 'logs' => array('success' => sprintf('SIP account %s@%s balance has been increased with %s',$key['username'],$key['domain'],$sub_action_parameter) - ) - ) - - ); - $this->SOAPEngine->execute($function); - - } - } - print "
"; - - } - -} - -class SIPAliasesActions extends Actions { - var $actions=array( - 'delete' => 'Delete SIP aliases' - ); - - function SIPAliases(&$SOAPEngine) { - $this->Actions(&$SOAPEngine); - } - - function performActions($selectionKeys,$action,$sub_action_parameter) { - if (!in_array($action,array_keys($this->actions))) { - print "Error: Invalid action $action"; - return false; - } - - print "
    "; - foreach($selectionKeys as $key) { - print "
  1. "; - flush(); - - //printf ("Performing action=%s on key=%s",$action,$key); - $alias=array('username' => $key['username'], - 'domain' => $key['domain'] - ); - - if ($action=='delete') { - - $function=array('commit' => array('name' => 'deleteAlias', - 'parameters' => array($alias), - 'logs' => array('success' => sprintf('SIP alias %s@%s has been deleted',$key['username'],$key['domain']) - ) - ) - - ); - - //$this->SOAPEngine->execute($function); - } - } - print "
"; - - } - -} - -class ENUMMappingsActions extends Actions { - var $actions=array( - 'delete' => 'Delete ENUM mappings', - 'changettl' => 'Change TTL to:', - 'changeowner' => 'Change owner to:' - ); - - function ENUMMappingsActions(&$SOAPEngine) { - $this->Actions(&$SOAPEngine); - } - - function performActions($selectionKeys,$action,$sub_action_parameter) { - if (!in_array($action,array_keys($this->actions))) { - print "Error: Invalid action $action"; - return false; - } - - print "
    "; - foreach($selectionKeys as $key) { - flush(); - print "
  1. "; - - $enum_id=array('number' => $key['number'], - 'tld' => $key['tld'] - ); - if ($action=='delete') { - - //printf ("Performing action=%s on key=%s",$action,$key); - $function=array('commit' => array('name' => 'deleteNumber', - 'parameters' => array($enum_id), - 'logs' => array('success' => sprintf('ENUM number +%s under %s has been deleted',$key['number'],$key['tld']) - ) - ) - - ); - - $this->SOAPEngine->execute($function); - } else if ($action == 'changettl') { - $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); - $number = $this->SOAPEngine->soapclient->getNumber($enum_id); - - if (PEAR::isError($number)) { - $error_msg = $number->getMessage(); - $error_fault= $number->getFault(); - $error_code = $number->getCode(); - printf ("Error: %s (%s): %s",$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); - break; - } else { - foreach ($number->mappings as $_property) { - $mappings[]=$_property; - } - $number->mappings=$mappings; - - if (is_numeric($sub_action_parameter)) { - $number->ttl=intval($sub_action_parameter); - } else { - printf ("Error: TTL '%s' must be numeric",$sub_action_parameter); - continue; - } - - $function=array('commit' => array('name' => 'updateNumber', - 'parameters' => array($number), - 'logs' => array('success' => sprintf('ENUM number %s@%s has now TTL %d',$key['number'],$key['tld'],intval($sub_action_parameter)) - ) - ) - - ); - $this->SOAPEngine->execute($function); - } - } else if ($action == 'changeowner') { - $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); - $number = $this->SOAPEngine->soapclient->getNumber($enum_id); - - if (PEAR::isError($number)) { - $error_msg = $number->getMessage(); - $error_fault= $number->getFault(); - $error_code = $number->getCode(); - printf ("Error: %s (%s): %s",$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); - break; - } else { - foreach ($number->mappings as $_property) { - $mappings[]=$_property; - } - $number->mappings=$mappings; - - if (is_numeric($sub_action_parameter)) { - $number->owner=intval($sub_action_parameter); - } else { - printf ("Error: Owner '%s' must be numeric",$sub_action_parameter); - continue; - } - - $function=array('commit' => array('name' => 'updateNumber', - 'parameters' => array($number), - 'logs' => array('success' => sprintf('ENUM number %s@%s has owner set to %d',$key['number'],$key['tld'],intval($sub_action_parameter)) - ) - ) - - ); - $this->SOAPEngine->execute($function); - } - } - } - - print "
"; - - } - -} - -?> rmfile ./provisioning/provisioning_logic.phtml hunk ./provisioning/provisioning_soap_library.phtml 1 -headersOut as $_header) { - if ($_header->name == $soap_value[0]) { - return true; - } - } - } - - if (is_a($soap_value,'soap_header')) { - $this->headersOut[] =& $soap_value; - } else if (gettype($soap_value) == 'array') { - // name, value, namespace, mustunderstand, actor - $this->headersOut[] =& new SOAP_Header($soap_value[0], NULL, $soap_value[1], $soap_value[2], $soap_value[3]);; - } else { - $this->_raiseSoapFault("Don't understand the header info you provided. Must be array or SOAP_Header."); - } - } -} - -class WebService_NGNPro_SipPort extends SOAP_Client_Custom -{ - function WebService_NGNPro_SipPort($url) -{ - $this->SOAP_Client_Custom($url, 0); - } - function &addDomain($domain) { - return $this->call("addDomain", - $v = array("domain"=>$domain), - array('namespace'=>'urn:AGProjects:NGNPro:Sip', - 'soapaction'=>'', - 'style'=>'rpc', - 'use'=>'encoded' )); - } - function &deleteDomain($domain) { - return $this->call("deleteDomain", - $v = array("domain"=>$domain), - array('namespace'=>'urn:AGProjects:NGNPro:Sip', - 'soapaction'=>'', - 'style'=>'rpc', - 'use'=>'encoded' )); - } - function &getDomains($query) { - // query is a ComplexType SipDomainQuery, - //refer to wsdl for more info - $query =& new SOAP_Value('query','{urn:AGProjects:NGNPro}SipDomainQuery',$query); - return $this->call("getDomains", - $v = array("query"=>$query), - array('namespace'=>'urn:AGProjects:NGNPro:Sip', - 'soapaction'=>'', - 'style'=>'rpc', - 'use'=>'encoded' )); - } - function &getDomainStatistics($filter) { - return $this->call("getDomainStatistics", - $v = array("filter"=>$filter), - array('namespace'=>'urn:AGProjects:NGNPro:Sip', - 'soapaction'=>'', - 'style'=>'rpc', - 'use'=>'encoded' )); - } - function &addTrustedPeer($peer) { - // peer is a ComplexType TrustedPeer, - //refer to wsdl for more info - $peer =& new SOAP_Value('peer','{urn:AGProjects:NGNPro}TrustedPeer',$peer); - return $this->call("addTrustedPeer", - $v = array("peer"=>$peer), - array('namespace'=>'urn:AGProjects:NGNPro:Sip', - 'soapaction'=>'', - 'style'=>'rpc', - 'use'=>'encoded' )); - } - function &deleteTrustedPeer($ip) { - return $this->call("deleteTrustedPeer", - $v = array("ip"=>$ip), - array('namespace'=>'urn:AGProjects:NGNPro:Sip', - 'soapaction'=>'', - 'style'=>'rpc', - 'use'=>'encoded' )); - } - function &getTrustedPeers($query) { - // query is a ComplexType TrustedPeerQuery, - //refer to wsdl for more info - $query =& new SOAP_Value('query','{urn:AGProjects:NGNPro}TrustedPeerQuery',$query); - return $this->call("getTrustedPeers", - $v = array("query"=>$query), - array('namespace'=>'urn:AGProjects:NGNPro:Sip', - 'soapaction'=>'', - 'style'=>'rpc', - 'use'=>'encoded' )); - } - function &addAccount($account) { - // account is a ComplexType SipAccount, - //refer to wsdl for more info - $account =& new SOAP_Value('account','{urn:AGProjects:NGNPro}SipAccount',$account); - return $this->call("addAccount", - $v = array("account"=>$account), - array('namespace'=>'urn:AGProjects:NGNPro:Sip', - 'soapaction'=>'', - 'style'=>'rpc', - 'use'=>'encoded' )); - } - function &updateAccount($account) { - // account is a ComplexType SipAccount, - //refer to wsdl for more info - $account =& new SOAP_Value('account','{urn:AGProjects:NGNPro}SipAccount',$account); - return $this->call("updateAccount", - $v = array("account"=>$account), - array('namespace'=>'urn:AGProjects:NGNPro:Sip', - 'soapaction'=>'', - 'style'=>'rpc', - 'use'=>'encoded' )); - } - function &deleteAccount($sipId) { - // sipId is a ComplexType SipId, - //refer to wsdl for more info - $sipId =& new SOAP_Value('sipId','{urn:AGProjects:NGNPro}SipId',$sipId); - return $this->call("deleteAccount", - $v = array("sipId"=>$sipId), - array('namespace'=>'urn:AGProjects:NGNPro:Sip', - 'soapaction'=>'', - 'style'=>'rpc', - 'use'=>'encoded' )); - } - function &getAccount($sipId) { - // sipId is a ComplexType SipId, - //refer to wsdl for more info - $sipId =& new SOAP_Value('sipId','{urn:AGProjects:NGNPro}SipId',$sipId); - return $this->call("getAccount", - $v = array("sipId"=>$sipId), - array('namespace'=>'urn:AGProjects:NGNPro:Sip', - 'soapaction'=>'', - 'style'=>'rpc', - 'use'=>'encoded' )); - } - function &getAccounts($query) { - // query is a ComplexType SipQuery, - //refer to wsdl for more info - $query =& new SOAP_Value('query','{urn:AGProjects:NGNPro}SipQuery',$query); - return $this->call("getAccounts", - $v = array("query"=>$query), - array('namespace'=>'urn:AGProjects:NGNPro:Sip', - 'soapaction'=>'', - 'style'=>'rpc', - 'use'=>'encoded' )); - } - function &addAlias($alias) { - // alias is a ComplexType SipAlias, - //refer to wsdl for more info - $alias =& new SOAP_Value('alias','{urn:AGProjects:NGNPro}SipAlias',$alias); - return $this->call("addAlias", - $v = array("alias"=>$alias), - array('namespace'=>'urn:AGProjects:NGNPro:Sip', - 'soapaction'=>'', - 'style'=>'rpc', - 'use'=>'encoded' )); - } - function &updateAlias($alias) { - // alias is a ComplexType SipAlias, - //refer to wsdl for more info - $alias =& new SOAP_Value('alias','{urn:AGProjects:NGNPro}SipAlias',$alias); - return $this->call("updateAlias", - $v = array("alias"=>$alias), - array('namespace'=>'urn:AGProjects:NGNPro:Sip', - 'soapaction'=>'', - 'style'=>'rpc', - 'use'=>'encoded' )); - } - function &deleteAlias($id) { - // id is a ComplexType SipId, - //refer to wsdl for more info - $id =& new SOAP_Value('id','{urn:AGProjects:NGNPro}SipId',$id); - return $this->call("deleteAlias", - $v = array("id"=>$id), - array('namespace'=>'urn:AGProjects:NGNPro:Sip', - 'soapaction'=>'', - 'style'=>'rpc', - 'use'=>'encoded' )); - } - function &getAlias($id) { - // id is a ComplexType SipId, - //refer to wsdl for more info - $id =& new SOAP_Value('id','{urn:AGProjects:NGNPro}SipId',$id); - return $this->call("getAlias", - $v = array("id"=>$id), - array('namespace'=>'urn:AGProjects:NGNPro:Sip', - 'soapaction'=>'', - 'style'=>'rpc', - 'use'=>'encoded' )); - } - function &getAliasesForAccount($target) { - // target is a ComplexType SipId, - //refer to wsdl for more info - $target =& new SOAP_Value('target','{urn:AGProjects:NGNPro}SipId',$target); - return $this->call("getAliasesForAccount", - $v = array("target"=>$target), - array('namespace'=>'urn:AGProjects:NGNPro:Sip', - 'soapaction'=>'', - 'style'=>'rpc', - 'use'=>'encoded' )); - } - function &getAliases($query) { - // query is a ComplexType AliasQuery, - //refer to wsdl for more info - $query =& new SOAP_Value('query','{urn:AGProjects:NGNPro}AliasQuery',$query); - return $this->call("getAliases", - $v = array("query"=>$query), - array('namespace'=>'urn:AGProjects:NGNPro:Sip', - 'soapaction'=>'', - 'style'=>'rpc', - 'use'=>'encoded' )); - } - function &addToGroup($sipId, $group) { - return $this->call("addToGroup", - $v = array("sipId"=>$sipId, "group"=>$group), - array('namespace'=>'urn:AGProjects:NGNPro:Sip', - 'soapaction'=>'', - 'style'=>'rpc', - 'use'=>'encoded' )); - } - function &removeFromGroup($sipId, $group) { - return $this->call("removeFromGroup", - $v = array("sipId"=>$sipId, "group"=>$group), - array('namespace'=>'urn:AGProjects:NGNPro:Sip', - 'soapaction'=>'', - 'style'=>'rpc', - 'use'=>'encoded' )); - } - function &getGroups($sipId) { - // sipId is a ComplexType SipId, - //refer to wsdl for more info - $sipId =& new SOAP_Value('sipId','{urn:AGProjects:NGNPro}SipId',$sipId); - return $this->call("getGroups", - $v = array("sipId"=>$sipId), - array('namespace'=>'urn:AGProjects:NGNPro:Sip', - 'soapaction'=>'', - 'style'=>'rpc', - 'use'=>'encoded' )); - } - function &addBalance($sipId, $value) { - return $this->call("addBalance", - $v = array("sipId"=>$sipId, "value"=>$value), - array('namespace'=>'urn:AGProjects:NGNPro:Sip', - 'soapaction'=>'', - 'style'=>'rpc', - 'use'=>'encoded' )); - } - function &addBalanceFromVoucher($sipId, $card) { - // card is a ComplexType PrepaidCard, - //refer to wsdl for more info - $card =& new SOAP_Value('card','{urn:AGProjects:NGNPro}PrepaidCard',$card); - return $this->call("addBalanceFromVoucher", - $v = array("sipId"=>$sipId, "card"=>$card), - array('namespace'=>'urn:AGProjects:NGNPro:Sip', - 'soapaction'=>'', - 'style'=>'rpc', - 'use'=>'encoded' )); - } - function &getPrepaidStatus($sipId) { - // sipId is a ComplexType SipId, - //refer to wsdl for more info - $sipId =& new SOAP_Value('sipId','{urn:AGProjects:NGNPro}SipId',$sipId); - return $this->call("getPrepaidStatus", - $v = array("sipId"=>$sipId), - array('namespace'=>'urn:AGProjects:NGNPro:Sip', - 'soapaction'=>'', - 'style'=>'rpc', - 'use'=>'encoded' )); - } - function &getCreditHistory($sipId) { - // sipId is a ComplexType SipId, - //refer to wsdl for more info - $sipId =& new SOAP_Value('sipId','{urn:AGProjects:NGNPro}SipId',$sipId); - return $this->call("getCreditHistory", - $v = array("sipId"=>$sipId), - array('namespace'=>'urn:AGProjects:NGNPro:Sip', - 'soapaction'=>'', - 'style'=>'rpc', - 'use'=>'encoded' )); - } - function &addPhonebookEntry($sipId, $entry) { - // entry is a ComplexType PhonebookEntry, - //refer to wsdl for more info - $entry =& new SOAP_Value('entry','{urn:AGProjects:NGNPro}PhonebookEntry',$entry); - return $this->call("addPhonebookEntry", - $v = array("sipId"=>$sipId, "entry"=>$entry), - array('namespace'=>'urn:AGProjects:NGNPro:Sip', - 'soapaction'=>'', - 'style'=>'rpc', - 'use'=>'encoded' )); - } - function &updatePhonebookEntry($sipId, $entry) { - // entry is a ComplexType PhonebookEntry, - //refer to wsdl for more info - $entry =& new SOAP_Value('entry','{urn:AGProjects:NGNPro}PhonebookEntry',$entry); - return $this->call("updatePhonebookEntry", - $v = array("sipId"=>$sipId, "entry"=>$entry), - array('namespace'=>'urn:AGProjects:NGNPro:Sip', - 'soapaction'=>'', - 'style'=>'rpc', - 'use'=>'encoded' )); - } - function &deletePhonebookEntry($sipId, $uri) { - return $this->call("deletePhonebookEntry", - $v = array("sipId"=>$sipId, "uri"=>$uri), - array('namespace'=>'urn:AGProjects:NGNPro:Sip', - 'soapaction'=>'', - 'style'=>'rpc', - 'use'=>'encoded' )); - } - function &getPhonebookEntries($sipId, $match, $range) { - // range is a ComplexType Range, - //refer to wsdl for more info - $range =& new SOAP_Value('range','{urn:AGProjects:NGNPro}Range',$range); - return $this->call("getPhonebookEntries", - $v = array("sipId"=>$sipId, "match"=>$match, "range"=>$range), - array('namespace'=>'urn:AGProjects:NGNPro:Sip', - 'soapaction'=>'', - 'style'=>'rpc', - 'use'=>'encoded' )); - } - function &setRejectMembers($sipId, $members) { - // members is a ComplexType StringArray, - //refer to wsdl for more info - $members =& new SOAP_Value('members','{urn:AGProjects:NGNPro}StringArray',$members); - return $this->call("setRejectMembers", - $v = array("sipId"=>$sipId, "members"=>$members), - array('namespace'=>'urn:AGProjects:NGNPro:Sip', - 'soapaction'=>'', - 'style'=>'rpc', - 'use'=>'encoded' )); - } - function &getRejectMembers($sipId) { - // sipId is a ComplexType SipId, - //refer to wsdl for more info - $sipId =& new SOAP_Value('sipId','{urn:AGProjects:NGNPro}SipId',$sipId); - return $this->call("getRejectMembers", - $v = array("sipId"=>$sipId), - array('namespace'=>'urn:AGProjects:NGNPro:Sip', - 'soapaction'=>'', - 'style'=>'rpc', - 'use'=>'encoded' )); - } - function &setAcceptRules($sipId, $rules) { - // rules is a ComplexType AcceptRules, - //refer to wsdl for more info - $rules =& new SOAP_Value('rules','{urn:AGProjects:NGNPro}AcceptRules',$rules); - return $this->call("setAcceptRules", - $v = array("sipId"=>$sipId, "rules"=>$rules), - array('namespace'=>'urn:AGProjects:NGNPro:Sip', - 'soapaction'=>'', - 'style'=>'rpc', - 'use'=>'encoded' )); - } - function &getAcceptRules($sipId) { - // sipId is a ComplexType SipId, - //refer to wsdl for more info - $sipId =& new SOAP_Value('sipId','{urn:AGProjects:NGNPro}SipId',$sipId); - return $this->call("getAcceptRules", - $v = array("sipId"=>$sipId), - array('namespace'=>'urn:AGProjects:NGNPro:Sip', - 'soapaction'=>'', - 'style'=>'rpc', - 'use'=>'encoded' )); - } - function &setBarringPrefixes($sipId, $prefixes) { - // prefixes is a ComplexType StringArray, - //refer to wsdl for more info - $prefixes =& new SOAP_Value('prefixes','{urn:AGProjects:NGNPro}StringArray',$prefixes); - return $this->call("setBarringPrefixes", - $v = array("sipId"=>$sipId, "prefixes"=>$prefixes), - array('namespace'=>'urn:AGProjects:NGNPro:Sip', - 'soapaction'=>'', - 'style'=>'rpc', - 'use'=>'encoded' )); - } - function &getBarringPrefixes($sipId) { - // sipId is a ComplexType SipId, - //refer to wsdl for more info - $sipId =& new SOAP_Value('sipId','{urn:AGProjects:NGNPro}SipId',$sipId); - return $this->call("getBarringPrefixes", - $v = array("sipId"=>$sipId), - array('namespace'=>'urn:AGProjects:NGNPro:Sip', - 'soapaction'=>'', - 'style'=>'rpc', - 'use'=>'encoded' )); - } - function &setCallDiversions($sipId, $diversions) { - // diversions is a ComplexType CallDiversions, - //refer to wsdl for more info - $diversions =& new SOAP_Value('diversions','{urn:AGProjects:NGNPro}CallDiversions',$diversions); - return $this->call("setCallDiversions", - $v = array("sipId"=>$sipId, "diversions"=>$diversions), - array('namespace'=>'urn:AGProjects:NGNPro:Sip', - 'soapaction'=>'', - 'style'=>'rpc', - 'use'=>'encoded' )); - } - function &getCallDiversions($sipId) { - // sipId is a ComplexType SipId, - //refer to wsdl for more info - $sipId =& new SOAP_Value('sipId','{urn:AGProjects:NGNPro}SipId',$sipId); - return $this->call("getCallDiversions", - $v = array("sipId"=>$sipId), - array('namespace'=>'urn:AGProjects:NGNPro:Sip', - 'soapaction'=>'', - 'style'=>'rpc', - 'use'=>'encoded' )); - } - function &getCalls($sipId, $query) { - // query is a ComplexType CallsQuery, - //refer to wsdl for more info - $query =& new SOAP_Value('query','{urn:AGProjects:NGNPro}CallsQuery',$query); - return $this->call("getCalls", - $v = array("sipId"=>$sipId, "query"=>$query), - array('namespace'=>'urn:AGProjects:NGNPro:Sip', - 'soapaction'=>'', - 'style'=>'rpc', - 'use'=>'encoded' )); - } - function &getCallStatistics($sipId, $query) { - // query is a ComplexType CallsQuery, - //refer to wsdl for more info - $query =& new SOAP_Value('query','{urn:AGProjects:NGNPro}CallsQuery',$query); - return $this->call("getCallStatistics", - $v = array("sipId"=>$sipId, "query"=>$query), - array('namespace'=>'urn:AGProjects:NGNPro:Sip', - 'soapaction'=>'', - 'style'=>'rpc', - 'use'=>'encoded' )); - } - function &getSipDeviceLocations($sipIds) { - // sipIds is a ComplexType SipIdArray, - //refer to wsdl for more info - $sipIds =& new SOAP_Value('sipIds','{urn:AGProjects:NGNPro}SipIdArray',$sipIds); - return $this->call("getSipDeviceLocations", - $v = array("sipIds"=>$sipIds), - array('namespace'=>'urn:AGProjects:NGNPro:Sip', - 'soapaction'=>'', - 'style'=>'rpc', - 'use'=>'encoded' )); - } - function &getTrace($nodeIP, $callID, $fromTag) { - return $this->call("getTrace", - $v = array("nodeIP"=>$nodeIP, "callID"=>$callID, "fromTag"=>$fromTag), - array('namespace'=>'urn:AGProjects:NGNPro:Sip', - 'soapaction'=>'', - 'style'=>'rpc', - 'use'=>'encoded' )); - } -} -class WebService_NGNPro_VoicemailPort extends SOAP_Client_Custom -{ - function WebService_NGNPro_VoicemailPort($url) -{ - $this->SOAP_Client_Custom($url, 0); - } - function &addAccount($account) { - // account is a ComplexType VoicemailAccount, - //refer to wsdl for more info - $account =& new SOAP_Value('account','{urn:AGProjects:NGNPro}VoicemailAccount',$account); - return $this->call("addAccount", - $v = array("account"=>$account), - array('namespace'=>'urn:AGProjects:NGNPro:Voicemail', - 'soapaction'=>'', - 'style'=>'rpc', - 'use'=>'encoded' )); - } - function &updateAccount($account) { - // account is a ComplexType VoicemailAccount, - //refer to wsdl for more info - $account =& new SOAP_Value('account','{urn:AGProjects:NGNPro}VoicemailAccount',$account); - return $this->call("updateAccount", - $v = array("account"=>$account), - array('namespace'=>'urn:AGProjects:NGNPro:Voicemail', - 'soapaction'=>'', - 'style'=>'rpc', - 'use'=>'encoded' )); - } - function &deleteAccount($sipId) { - // sipId is a ComplexType SipId, - //refer to wsdl for more info - $sipId =& new SOAP_Value('sipId','{urn:AGProjects:NGNPro}SipId',$sipId); - return $this->call("deleteAccount", - $v = array("sipId"=>$sipId), - array('namespace'=>'urn:AGProjects:NGNPro:Voicemail', - 'soapaction'=>'', - 'style'=>'rpc', - 'use'=>'encoded' )); - } - function &getAccount($sipId) { - // sipId is a ComplexType SipId, - //refer to wsdl for more info - $sipId =& new SOAP_Value('sipId','{urn:AGProjects:NGNPro}SipId',$sipId); - return $this->call("getAccount", - $v = array("sipId"=>$sipId), - array('namespace'=>'urn:AGProjects:NGNPro:Voicemail', - 'soapaction'=>'', - 'style'=>'rpc', - 'use'=>'encoded' )); - } - function &setAnnouncement($sipId, $message) { - return $this->call("setAnnouncement", - $v = array("sipId"=>$sipId, "message"=>$message), - array('namespace'=>'urn:AGProjects:NGNPro:Voicemail', - 'soapaction'=>'', - 'style'=>'rpc', - 'use'=>'encoded' )); - } -} -class WebService_NGNPro_EnumPort extends SOAP_Client_Custom -{ - function WebService_NGNPro_EnumPort($url) -{ - $this->SOAP_Client_Custom($url, 0); - } - function &addRange($range) { - // range is a ComplexType EnumRange, - //refer to wsdl for more info - $range =& new SOAP_Value('range','{urn:AGProjects:NGNPro}EnumRange',$range); - return $this->call("addRange", - $v = array("range"=>$range), - array('namespace'=>'urn:AGProjects:NGNPro:Enum', - 'soapaction'=>'', - 'style'=>'rpc', - 'use'=>'encoded' )); - } - function &deleteRange($range) { - // range is a ComplexType EnumRangeId, - //refer to wsdl for more info - $range =& new SOAP_Value('range','{urn:AGProjects:NGNPro}EnumRangeId',$range); - return $this->call("deleteRange", - $v = array("range"=>$range), - array('namespace'=>'urn:AGProjects:NGNPro:Enum', - 'soapaction'=>'', - 'style'=>'rpc', - 'use'=>'encoded' )); - } - function &getRanges($query) { - // query is a ComplexType EnumRangeQuery, - //refer to wsdl for more info - $query =& new SOAP_Value('query','{urn:AGProjects:NGNPro}EnumRangeQuery',$query); - return $this->call("getRanges", - $v = array("query"=>$query), - array('namespace'=>'urn:AGProjects:NGNPro:Enum', - 'soapaction'=>'', - 'style'=>'rpc', - 'use'=>'encoded' )); - } - function &addNumber($number) { - // number is a ComplexType EnumNumber, - //refer to wsdl for more info - $number =& new SOAP_Value('number','{urn:AGProjects:NGNPro}EnumNumber',$number); - return $this->call("addNumber", - $v = array("number"=>$number), - array('namespace'=>'urn:AGProjects:NGNPro:Enum', - 'soapaction'=>'', - 'style'=>'rpc', - 'use'=>'encoded' )); - } - function &updateNumber($number) { - // number is a ComplexType EnumNumber, - //refer to wsdl for more info - $number =& new SOAP_Value('number','{urn:AGProjects:NGNPro}EnumNumber',$number); - return $this->call("updateNumber", - $v = array("number"=>$number), - array('namespace'=>'urn:AGProjects:NGNPro:Enum', - 'soapaction'=>'', - 'style'=>'rpc', - 'use'=>'encoded' )); - } - function &deleteNumber($enumId) { - // enumId is a ComplexType EnumId, - //refer to wsdl for more info - $enumId =& new SOAP_Value('enumId','{urn:AGProjects:NGNPro}EnumId',$enumId); - return $this->call("deleteNumber", - $v = array("enumId"=>$enumId), - array('namespace'=>'urn:AGProjects:NGNPro:Enum', - 'soapaction'=>'', - 'style'=>'rpc', - 'use'=>'encoded' )); - } - function &getNumber($enumId) { - // enumId is a ComplexType EnumId, - //refer to wsdl for more info - $enumId =& new SOAP_Value('enumId','{urn:AGProjects:NGNPro}EnumId',$enumId); - return $this->call("getNumber", - $v = array("enumId"=>$enumId), - array('namespace'=>'urn:AGProjects:NGNPro:Enum', - 'soapaction'=>'', - 'style'=>'rpc', - 'use'=>'encoded' )); - } - function &getNumbers($query) { - // query is a ComplexType EnumQuery, - //refer to wsdl for more info - $query =& new SOAP_Value('query','{urn:AGProjects:NGNPro}EnumQuery',$query); - return $this->call("getNumbers", - $v = array("query"=>$query), - array('namespace'=>'urn:AGProjects:NGNPro:Enum', - 'soapaction'=>'', - 'style'=>'rpc', - 'use'=>'encoded' )); - } -} -class WebService_NGNPro_RatingPort extends SOAP_Client_Custom -{ - function WebService_NGNPro_RatingPort($url) -{ - $this->SOAP_Client_Custom($url, 0); - } - function &setEntityProfiles($profiles) { - // profiles is a ComplexType RatingEntityProfiles, - //refer to wsdl for more info - $profiles =& new SOAP_Value('profiles','{urn:AGProjects:NGNPro}RatingEntityProfiles',$profiles); - return $this->call("setEntityProfiles", - $v = array("profiles"=>$profiles), - array('namespace'=>'urn:AGProjects:NGNPro:Rating', - 'soapaction'=>'', - 'style'=>'rpc', - 'use'=>'encoded' )); - } - function &deleteEntityProfiles($entity) { - return $this->call("deleteEntityProfiles", - $v = array("entity"=>$entity), - array('namespace'=>'urn:AGProjects:NGNPro:Rating', - 'soapaction'=>'', - 'style'=>'rpc', - 'use'=>'encoded' )); - } - function &getEntityProfiles($entity) { - return $this->call("getEntityProfiles", - $v = array("entity"=>$entity), - array('namespace'=>'urn:AGProjects:NGNPro:Rating', - 'soapaction'=>'', - 'style'=>'rpc', - 'use'=>'encoded' )); - } -} -class WebService_NGNPro_CustomerPort extends SOAP_Client_Custom -{ - function WebService_NGNPro_CustomerPort($url) -{ - $this->SOAP_Client_Custom($url, 0); - } - function &addAccount($account) { - // account is a ComplexType CustomerAccount, - //refer to wsdl for more info - $account =& new SOAP_Value('account','{urn:AGProjects:NGNPro}CustomerAccount',$account); - return $this->call("addAccount", - $v = array("account"=>$account), - array('namespace'=>'urn:AGProjects:NGNPro:Customer', - 'soapaction'=>'', - 'style'=>'rpc', - 'use'=>'encoded' )); - } - function &updateAccount($account) { - // account is a ComplexType CustomerAccount, - //refer to wsdl for more info - $account =& new SOAP_Value('account','{urn:AGProjects:NGNPro}CustomerAccount',$account); - return $this->call("updateAccount", - $v = array("account"=>$account), - array('namespace'=>'urn:AGProjects:NGNPro:Customer', - 'soapaction'=>'', - 'style'=>'rpc', - 'use'=>'encoded' )); - } - function &deleteAccount($id) { - return $this->call("deleteAccount", - $v = array("id"=>$id), - array('namespace'=>'urn:AGProjects:NGNPro:Customer', - 'soapaction'=>'', - 'style'=>'rpc', - 'use'=>'encoded' )); - } - function &getAccount($id) { - return $this->call("getAccount", - $v = array("id"=>$id), - array('namespace'=>'urn:AGProjects:NGNPro:Customer', - 'soapaction'=>'', - 'style'=>'rpc', - 'use'=>'encoded' )); - } - function &getCustomers($query) { - // query is a ComplexType CustomerQuery, - //refer to wsdl for more info - $query =& new SOAP_Value('query','{urn:AGProjects:NGNPro}CustomerQuery',$query); - return $this->call("getCustomers", - $v = array("query"=>$query), - array('namespace'=>'urn:AGProjects:NGNPro:Customer', - 'soapaction'=>'', - 'style'=>'rpc', - 'use'=>'encoded' )); - } - function &getResellers($query) { - // query is a ComplexType CustomerQuery, - //refer to wsdl for more info - $query =& new SOAP_Value('query','{urn:AGProjects:NGNPro}CustomerQuery',$query); - return $this->call("getResellers", - $v = array("query"=>$query), - array('namespace'=>'urn:AGProjects:NGNPro:Customer', - 'soapaction'=>'', - 'style'=>'rpc', - 'use'=>'' )); - } - -} -class WebService_NGNPro_NetworkPort extends SOAP_Client_Custom -{ - function WebService_NGNPro_NetworkPort($url) -{ - $this->SOAP_Client_Custom($url, 0); - } - function &addGateway($gateway) { - // gateway is a ComplexType Gateway, - //refer to wsdl for more info - $gateway =& new SOAP_Value('gateway','{urn:AGProjects:NGNPro}Gateway',$gateway); - return $this->call("addGateway", - $v = array("gateway"=>$gateway), - array('namespace'=>'urn:AGProjects:NGNPro:Network', - 'soapaction'=>'', - 'style'=>'rpc', - 'use'=>'encoded' )); - } - function &deleteGateway($name) { - return $this->call("deleteGateway", - $v = array("name"=>$name), - array('namespace'=>'urn:AGProjects:NGNPro:Network', - 'soapaction'=>'', - 'style'=>'rpc', - 'use'=>'encoded' )); - } - function &getGateways($query) { - // query is a ComplexType GatewayQuery, - //refer to wsdl for more info - $query =& new SOAP_Value('query','{urn:AGProjects:NGNPro}GatewayQuery',$query); - return $this->call("getGateways", - $v = array("query"=>$query), - array('namespace'=>'urn:AGProjects:NGNPro:Network', - 'soapaction'=>'', - 'style'=>'rpc', - 'use'=>'encoded' )); - } - function &addGatewayGroup($group) { - return $this->call("addGatewayGroup", - $v = array("group"=>$group), - array('namespace'=>'urn:AGProjects:NGNPro:Network', - 'soapaction'=>'', - 'style'=>'rpc', - 'use'=>'encoded' )); - } - function &deleteGatewayGroup($group) { - return $this->call("deleteGatewayGroup", - $v = array("group"=>$group), - array('namespace'=>'urn:AGProjects:NGNPro:Network', - 'soapaction'=>'', - 'style'=>'rpc', - 'use'=>'encoded' )); - } - function &getGatewayGroups($query) { - // query is a ComplexType GatewayGroupQuery, - //refer to wsdl for more info - $query =& new SOAP_Value('query','{urn:AGProjects:NGNPro}GatewayGroupQuery',$query); - return $this->call("getGatewayGroups", - $v = array("query"=>$query), - array('namespace'=>'urn:AGProjects:NGNPro:Network', - 'soapaction'=>'', - 'style'=>'rpc', - 'use'=>'encoded' )); - } - function &addRoutes($routes) { - // routes is a ComplexType RouteArray, - //refer to wsdl for more info - $routes =& new SOAP_Value('routes','{urn:AGProjects:NGNPro}RouteArray',$routes); - return $this->call("addRoutes", - $v = array("routes"=>$routes), - array('namespace'=>'urn:AGProjects:NGNPro:Network', - 'soapaction'=>'', - 'style'=>'rpc', - 'use'=>'encoded' )); - } - function &deleteRoutes($routes) { - // routes is a ComplexType RouteArray, - //refer to wsdl for more info - $routes =& new SOAP_Value('routes','{urn:AGProjects:NGNPro}RouteArray',$routes); - return $this->call("deleteRoutes", - $v = array("routes"=>$routes), - array('namespace'=>'urn:AGProjects:NGNPro:Network', - 'soapaction'=>'', - 'style'=>'rpc', - 'use'=>'encoded' )); - } - function &getRoutes($query) { - // query is a ComplexType RouteQuery, - //refer to wsdl for more info - $query =& new SOAP_Value('query','{urn:AGProjects:NGNPro}RouteQuery',$query); - return $this->call("getRoutes", - $v = array("query"=>$query), - array('namespace'=>'urn:AGProjects:NGNPro:Network', - 'soapaction'=>'', - 'style'=>'rpc', - 'use'=>'encoded' )); - } -} -class WebService_SoapSIMPLEProxy_PresencePort extends SOAP_Client_Custom -{ - function WebService_SoapSIMPLEProxy_PresencePort($url) -{ - $this->SOAP_Client_Custom($url, 0); - } - function &setPresenceInformation($sipId, $password, $information) { - // information is a ComplexType PresenceInformation, - //refer to wsdl for more info - $information =& new SOAP_Value('information','{urn:AGProjects:SoapSIMPLEProxy}PresenceInformation',$information); - return $this->call("setPresenceInformation", - $v = array("sipId"=>$sipId, "password"=>$password, "information"=>$information), - array('namespace'=>'urn:AGProjects:SoapSIMPLEProxy:Presence', - 'soapaction'=>'', - 'style'=>'rpc', - 'use'=>'encoded' )); - } - function &getPresenceInformation($sipId, $password) { - return $this->call("getPresenceInformation", - $v = array("sipId"=>$sipId, "password"=>$password), - array('namespace'=>'urn:AGProjects:SoapSIMPLEProxy:Presence', - 'soapaction'=>'', - 'style'=>'rpc', - 'use'=>'encoded' )); - } - function &deletePresenceInformation($sipId, $password) { - return $this->call("deletePresenceInformation", - $v = array("sipId"=>$sipId, "password"=>$password), - array('namespace'=>'urn:AGProjects:SoapSIMPLEProxy:Presence', - 'soapaction'=>'', - 'style'=>'rpc', - 'use'=>'encoded' )); - } - function &getWatchers($presentityId) { - // presentityId is a ComplexType SipId, - //refer to wsdl for more info - $presentityId =& new SOAP_Value('presentityId','{urn:AGProjects:SoapSIMPLEProxy}SipId',$presentityId); - return $this->call("getWatchers", - $v = array("presentityId"=>$presentityId), - array('namespace'=>'urn:AGProjects:SoapSIMPLEProxy:Presence', - 'soapaction'=>'', - 'style'=>'rpc', - 'use'=>'encoded' )); - } - function &setPolicy($sipId, $password, $policy) { - // policy is a ComplexType PresencePolicy, - //refer to wsdl for more info - $policy =& new SOAP_Value('policy','{urn:AGProjects:SoapSIMPLEProxy}PresencePolicy',$policy); - return $this->call("setPolicy", - $v = array("sipId"=>$sipId, "password"=>$password, "policy"=>$policy), - array('namespace'=>'urn:AGProjects:SoapSIMPLEProxy:Presence', - 'soapaction'=>'', - 'style'=>'rpc', - 'use'=>'encoded' )); - } - function &getPolicy($sipId, $password) { - return $this->call("getPolicy", - $v = array("sipId"=>$sipId, "password"=>$password), - array('namespace'=>'urn:AGProjects:SoapSIMPLEProxy:Presence', - 'soapaction'=>'', - 'style'=>'rpc', - 'use'=>'encoded' )); - } -} -?> rmfile ./provisioning/provisioning_soap_library.phtml hunk ./provisioning/sip_settings_lib.phtml 251 - require_once("provisioning_soap_library.phtml"); + require_once("ngnpro_soap_library.phtml"); hunk ./provisioning/sip_settings_logic.phtml 1 -headerFile; - $css = $SIPSettings->cssFile; - include($header); - include($css); -} - -if ($action=="Save settings") { - if ($SIPSettings->checkSettings()) { - $SIPSettings->saveSettings(); - unset($SIPSettings); - if (in_array($domain,$freeDomains)) { - $SIPSettings = new $SIPSettings_class($account,$loginCredentials,$soapEngines); - } else { - $SIPSettings = new $SIPSettings_class($account,$loginCredentials,$soapEngines); - } - } else { - print ""; - printf (_("Error: %s"),$SIPSettings->error); - print ""; - } -} else if ($action=="set barring prefixes") { - $SIPSettings->setBarringPrefixes(); -} else if ($action=="set presence") { - $SIPSettings->setPresence(); -} else if ($action=="set reject members") { - $SIPSettings->setRejectMembers(); -} else if ($action=="set accept rules") { - $SIPSettings->setAcceptRules(); -} else if ($action=="set aliases") { - $SIPSettings->setAliases(); -} else if ($action=="Send settings") { - $SIPSettings->sendEmail(); -} else if ($tab=="phonebook" && $export) { - $SIPSettings->exportPhonebook($userAgent); -} - -if (!$export) $SIPSettings->showAccount(); -?> + rmfile ./provisioning/sip_settings_logic.phtml hunk ./rating_lib.phtml 2783 - require_once("provisioning/provisioning_soap_library.phtml"); - require("soap_engines.inc"); + require_once("provisioning/ngnpro_soap_library.phtml"); + require_once("provisioning/ngnpro_engines.inc"); hunk ./setup/mysql/alter_tables.mysql 434 -alter table auth_user add column soapEngines varchar(255) not null; +alter table auth_user add column soapFilter varchar(255) not null after afterDateFilter; hunk ./setup/mysql/create_tables.mysql 107 + `soapFilter` varchar(255) not null default '', hunk ./setup/mysql/create_tables.mysql 114 - `soapEngines` varchar(255) not null, addfile ./setup/ngnpro_engines.inc.sample hunk ./setup/ngnpro_engines.inc.sample 1 + array('name'=> 'SOAP Engine', + 'username'=> 'username', + 'password'=> 'password', + 'url' => 'http://example.com:9200/' + ) + ); + +// Used to generate SIP accounts and ENUM mappings +$recordGenerators =array ( + 'rg'=>array( + 'sipEngineId' => 'sp', + 'enumEngineId'=> 'sp' + ) + ); + +?> hunk ./setup/soap_engines.inc.sample 1 - array('name'=> 'SOAP Engine', - 'username'=> 'username', - 'password'=> 'password', - 'url' => 'http://example.com:9200/' - ) - ); - -// Used to generate SIP accounts and ENUM mappings -$recordGenerators =array ( - 'rg'=>array( - 'sipEngineId' => 'sp', - 'enumEngineId'=> 'sp' - ) - ); - -?> rmfile ./setup/soap_engines.inc.sample hunk ./sip_settings.phtml 25 + hunk ./sip_settings.phtml 44 -require_once("provisioning/sip_settings_logic.phtml"); +$SIPSettings = new $SIPSettings_class($account,$loginCredentials,$soapEngines); + +if (!$export) { + $title = "SIP settings of $account"; + $header = $SIPSettings->headerFile; + $css = $SIPSettings->cssFile; + include($header); + include($css); +} + +if ($action=="Save settings") { + if ($SIPSettings->checkSettings()) { + $SIPSettings->saveSettings(); + unset($SIPSettings); + if (in_array($domain,$freeDomains)) { + $SIPSettings = new $SIPSettings_class($account,$loginCredentials,$soapEngines); + } else { + $SIPSettings = new $SIPSettings_class($account,$loginCredentials,$soapEngines); + } + } else { + print ""; + printf (_("Error: %s"),$SIPSettings->error); + print ""; + } +} else if ($action=="set barring prefixes") { + $SIPSettings->setBarringPrefixes(); +} else if ($action=="set presence") { + $SIPSettings->setPresence(); +} else if ($action=="set reject members") { + $SIPSettings->setRejectMembers(); +} else if ($action=="set accept rules") { + $SIPSettings->setAcceptRules(); +} else if ($action=="set aliases") { + $SIPSettings->setAliases(); +} else if ($action=="Send settings") { + $SIPSettings->sendEmail(); +} else if ($tab=="phonebook" && $export) { + $SIPSettings->exportPhonebook($userAgent); +} hunk ./sip_settings.phtml 85 + $SIPSettings->showAccount(); hunk ./sip_statistics_lib.phtml 622 - require_once("provisioning/provisioning_soap_library.phtml"); - require("soap_engines.inc"); + require_once("provisioning/ngnpro_soap_library.phtml"); + require_once("provisioning/ngnpro_engines.inc");