[Formatted file added some dynamic properties and added general SOAP error handler Tijmen de Mes **20240314093345 Ignore-this: 3b1ab18172e374822198834488a6afab5a0b1a01aef276acee8d02b00d316f84b05cfb76cc75bdd2 ] hunk ./library/sip_settings.php 173 - public function __construct($account,$loginCredentials=array(),$soapEngines=array()) + public function __construct($account, $loginCredentials=array(), $soapEngines=array()) hunk ./library/sip_settings.php 176 - //define_syslog_variables(); + //define_syslog_variables(); hunk ./library/sip_settings.php 182 - $debug=sprintf("

Initialize %s(%s)",get_class($this),$account); + $debug=sprintf("

Initialize %s(%s)", get_class($this), $account); hunk ./library/sip_settings.php 188 - if ($this->isEmbedded()) { - $this->login_type = 'subscriber'; + if ($this->isEmbedded()) { + $this->login_type = 'subscriber'; hunk ./library/sip_settings.php 237 - hunk ./library/sip_settings.php 238 - hunk ./library/sip_settings.php 244 - hunk ./library/sip_settings.php 255 - $this->hiddenElements=sprintf(" - - - - - ", - $this->account, - $this->sip_engine, - $_REQUEST['user_agent'], - $_REQUEST['realm'] + $this->hiddenElements = sprintf( + " + + + + + ", + $this->account, + $this->sip_engine, + $_REQUEST['user_agent'], + $_REQUEST['realm'] hunk ./library/sip_settings.php 311 - "WEBName" =>sprintf (_("Reject Anonymous")), + "WEBName" =>sprintf(_("Reject Anonymous")), hunk ./library/sip_settings.php 320 - "WEBName" =>sprintf (_("Email Missed Calls")), + "WEBName" =>sprintf(_("Email Missed Calls")), hunk ./library/sip_settings.php 326 - hunk ./library/sip_settings.php 343 - $this->tabs['diversions']=_('Forwarding'); - $this->tabs['accept']=_('Accept'); - $this->tabs['contacts']=_('Contacts'); + $this->tabs['diversions']=_('Forwarding'); + $this->tabs['accept']=_('Accept'); + $this->tabs['contacts']=_('Contacts'); hunk ./library/sip_settings.php 350 - $this->tabs['barring']=_("Barring"); + $this->tabs['barring']=_("Barring"); hunk ./library/sip_settings.php 412 - $_protocol=preg_match("/^(https?:\/\/)/",$_SERVER['SCRIPT_URI'],$m); + $_protocol=preg_match("/^(https?:\/\/)/", $_SERVER['SCRIPT_URI'], $m); hunk ./library/sip_settings.php 452 - hunk ./library/sip_settings.php 453 - hunk ./library/sip_settings.php 668 - if ($this->showSoapConnectionInfo) { - printf ("

%s at %s as %s ",$this->soapClassSipPort,$this->SOAPurl,$this->SOAPurl,$this->soapUsername); + if ($this->showSoapConnectionInfo) { + printf("

%s at %s as %s ", $this->soapClassSipPort, $this->SOAPurl, $this->SOAPurl, $this->soapUsername); hunk ./library/sip_settings.php 694 - printf ("
%s at %s as %s ",$this->soapClassVoicemailPort,$this->SOAPurlVoicemail,$this->SOAPurlVoicemail,$this->soapEngines[$this->voicemail_engine]['username']); + printf("
%s at %s as %s ", $this->soapClassVoicemailPort, $this->SOAPurlVoicemail, $this->SOAPurlVoicemail, $this->soapEngines[$this->voicemail_engine]['username']); hunk ./library/sip_settings.php 719 - printf ("
%s at %s as %s ",$this->soapClassEnumPort,$this->SOAPurlEnum,$this->SOAPurlEnum,$this->soapEngines[$this->enum_engine]['username']); + printf("
%s at %s as %s ", $this->soapClassEnumPort, $this->SOAPurlEnum, $this->SOAPurlEnum, $this->soapEngines[$this->enum_engine]['username']); hunk ./library/sip_settings.php 744 - printf ("
%s at %s as %s ",$this->soapClassRatingPort,$this->SOAPurlRating,$this->SOAPurlRating,$this->soapEngines[$this->rating_engine]['username']); + printf("
%s at %s as %s ", $this->soapClassRatingPort, $this->SOAPurlRating, $this->SOAPurlRating, $this->soapEngines[$this->rating_engine]['username']); hunk ./library/sip_settings.php 768 - printf ("
%s at %s as %s ",$this->soapClassCustomerPort,$this->SOAPurlCustomer,$this->SOAPurlCustomer,$this->soapEngines[$this->customer_engine]['username']); + printf("
%s at %s as %s ", $this->soapClassCustomerPort, $this->SOAPurlCustomer, $this->SOAPurlCustomer, $this->soapEngines[$this->customer_engine]['username']); hunk ./library/sip_settings.php 776 - list($username, $domain)=explode("@",trim($account)); + list($username, $domain)=explode("@", trim($account)); hunk ./library/sip_settings.php 785 - printf ("

Error (SipPort): %s (%s): %s",$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); + printf("

Error (SipPort): %s (%s): %s", $error_msg, $error_fault->detail->exception->errorcode, $error_fault->detail->exception->errorstring); hunk ./library/sip_settings.php 808 - if ( $this->Preferences['blocked_by'] && !in_array("blocked",$result->groups)) { + if ( $this->Preferences['blocked_by'] && !in_array("blocked", $result->groups)) { hunk ./library/sip_settings.php 847 - $this->ip_access_list .= sprintf("%s/%s ",$result->acl[$key]->ip, $result->acl[$key]->mask); + $this->ip_access_list .= sprintf("%s/%s ", $result->acl[$key]->ip, $result->acl[$key]->mask); hunk ./library/sip_settings.php 924 - if (!array_key_exists($this->tab,$this->tabs)) $this->tab="settings"; + if (!array_key_exists($this->tab, $this->tabs)) $this->tab="settings"; hunk ./library/sip_settings.php 937 - function getDomainOwner ($domain='') + public function soapHasError($result) hunk ./library/sip_settings.php 939 + return (new PEAR)->isError($result); + } + + + public function checkPrintSoapError($result, $port = 'SipPort') + { + if (!$this->soapHasError($result)) { + return false; + } + + $error_msg = $result->getMessage(); + $error_fault= $result->getFault(); + $error_code = $result->getCode(); + + printf( + " +

+
+ Error (%s): %s (%s): %s +
+
+ ", + $port, + $error_msg, + $error_fault->detail->exception->errorcode, + $error_fault->detail->exception->errorstring + ); + return true; + } + + function getDomainOwner($domain = '') + { hunk ./library/sip_settings.php 1062 - printf ("

Error (CustomerPort): %s (%s): %s",$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); + printf("

Error (CustomerPort): %s (%s): %s", $error_msg, $error_fault->detail->exception->errorcode, $error_fault->detail->exception->errorstring); hunk ./library/sip_settings.php 1122 - if ((new PEAR)->isError($result)) { - $error_msg = $result->getMessage(); - $error_fault= $result->getFault(); - $error_code = $result->getCode(); - printf ("

Error (SipPort): %s (%s): %s",$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); + if ($this->checkPrintSoapError($result)) { hunk ./library/sip_settings.php 1146 - printf ("

Error (RatingPort): %s (%s): %s",$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); + printf("

Error (RatingPort): %s (%s): %s", $error_msg, $error_fault->detail->exception->errorcode, $error_fault->detail->exception->errorstring); hunk ./library/sip_settings.php 1161 - $addAliases = array_unique(array_diff($aliases_new,$aliases_old)); - $deleteAliases = array_unique(array_diff($aliases_old,$aliases_new)); + $addAliases = array_unique(array_diff($aliases_new, $aliases_old)); + $deleteAliases = array_unique(array_diff($aliases_old, $aliases_new)); hunk ./library/sip_settings.php 1167 - if (!preg_match("/^[a-z0-9-_.@]+$/i",$_alias)) continue; - - $els=explode("@",$_alias); + if (!preg_match("/^[a-z0-9-_.@]+$/i", $_alias)) continue; + + $els=explode("@", $_alias); hunk ./library/sip_settings.php 1192 - if ((new PEAR)->isError($result)) { - $error_msg = $result->getMessage(); - $error_fault= $result->getFault(); - $error_code = $result->getCode(); - printf ("

Error (SipPort): %s (%s): %s",$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); + if ($this->checkPrintSoapError($result)) { hunk ./library/sip_settings.php 1200 - $els=explode("@",$_alias); + $els=explode("@", $_alias); hunk ./library/sip_settings.php 1221 - if ((new PEAR)->isError($result)) { - $error_msg = $result->getMessage(); - $error_fault= $result->getFault(); - $error_code = $result->getCode(); - printf ("

Error (SipPort): %s (%s): %s",$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); + if ($this->checkPrintSoapError($result)) { hunk ./library/sip_settings.php 1241 - printf ("

Error (VoicemailPort): %s (%s): %s",$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); + printf("

Error (VoicemailPort): %s (%s): %s", $error_msg, $error_fault->detail->exception->errorcode, $error_fault->detail->exception->errorstring); hunk ./library/sip_settings.php 1275 - printf (("%s <sip:%s@%s>"),$this->fullName,$this->username,$this->domain); + printf(("%s <sip:%s@%s>"), $this->fullName, $this->username, $this->domain); hunk ./library/sip_settings.php 1295 - if ($this->homeNode=getSipThorHomeNode($this->account,$this->sip_proxy)) { - printf (" %s",$this->homeNode); + if ($this->homeNode=getSipThorHomeNode($this->account, $this->sip_proxy)) { + printf(" %s", $this->homeNode); hunk ./library/sip_settings.php 1328 - if (in_array("free-pstn",$this->groups)) { + if (in_array("free-pstn", $this->groups)) { hunk ./library/sip_settings.php 1334 - if (!$seen[$tel_enum] && !in_array($tel_enum,$this->enums)) { - $this->divertTargets[]=array("name" => sprintf (_("Tel %s"),$tel), + if (!$seen[$tel_enum] && !in_array($tel_enum, $this->enums)) { + $this->divertTargets[]=array("name" => sprintf(_("Tel %s"), $tel), hunk ./library/sip_settings.php 1346 - if (!$seen[$tel_enum] && !in_array($tel_enum,$this->enums)) { - $this->divertTargets[]=array("name" => sprintf (_("Tel %s"),$tel), + if (!$seen[$tel_enum] && !in_array($tel_enum, $this->enums)) { + $this->divertTargets[]=array("name" => sprintf(_("Tel %s"), $tel), hunk ./library/sip_settings.php 1353 - hunk ./library/sip_settings.php 1354 - hunk ./library/sip_settings.php 1360 - if (!$seen[$tel_enum] && !in_array($tel_enum,$this->enums)) { - $this->divertTargets[] = array("name" => sprintf (_("Mobile %s"),$tel), + if (!$seen[$tel_enum] && !in_array($tel_enum, $this->enums)) { + $this->divertTargets[] = array("name" => sprintf(_("Mobile %s"), $tel), hunk ./library/sip_settings.php 1370 - $this->divertTargets[]=array("name" => sprintf (_("Other")), + $this->divertTargets[]=array("name" => sprintf(_("Other")), hunk ./library/sip_settings.php 1489 - printf ("

Error (CustomerPort): %s (%s): %s",$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); + printf("

Error (CustomerPort): %s (%s): %s", $error_msg, $error_fault->detail->exception->errorcode, $error_fault->detail->exception->errorstring); hunk ./library/sip_settings.php 1499 - hunk ./library/sip_settings.php 1530 - "WEBName" => sprintf (_("PSTN Privacy")), + "WEBName" => sprintf(_("PSTN Privacy")), hunk ./library/sip_settings.php 1554 - hunk ./library/sip_settings.php 1572 - $result = $this->CustomerPort->getAccount(intval($this->reseller)); + $result = $this->CustomerPort->getAccount(intval($this->reseller)); hunk ./library/sip_settings.php 1578 - printf ("

Error (CustomerPort): %s (%s): %s",$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); + printf("

Error (CustomerPort): %s (%s): %s", $error_msg, $error_fault->detail->exception->errorcode, $error_fault->detail->exception->errorstring); hunk ./library/sip_settings.php 1731 - "WEBName" => sprintf (_("PSTN Privacy")), + "WEBName" => sprintf(_("PSTN Privacy")), hunk ./library/sip_settings.php 1756 - hunk ./library/sip_settings.php 1758 - hunk ./library/sip_settings.php 1766 - if ((new PEAR)->isError($result)) { - $error_msg = $result->getMessage(); - $error_fault= $result->getFault(); - $error_code = $result->getCode(); - printf ("

Error (SipPort): %s (%s): %s",$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); + if ($this->checkPrintSoapError($result)) { hunk ./library/sip_settings.php 1782 - if (preg_match("/^(sip:|sips:)(.*)$/i",$uri,$m)) { + if (preg_match("/^(sip:|sips:)(.*)$/i", $uri, $m)) { hunk ./library/sip_settings.php 1803 - if ((new PEAR)->isError($result)) { - $error_msg = $result->getMessage(); - $error_fault= $result->getFault(); - $error_code = $result->getCode(); - printf ("

Error (SipPort): %s (%s): %s",$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); + if ($this->checkPrintSoapError($result)) { hunk ./library/sip_settings.php 1805 - } else { + } else { hunk ./library/sip_settings.php 1837 - return array("name" => sprintf (_("Voice Mailbox")), + return array("name" => sprintf(_("Voice Mailbox")), hunk ./library/sip_settings.php 1853 - hunk ./library/sip_settings.php 1906 - if ($this->login_type == 'subscriber' && in_array("blocked",$this->groups)) { + if ($this->login_type == 'subscriber' && in_array("blocked", $this->groups)) { hunk ./library/sip_settings.php 1923 - hunk ./library/sip_settings.php 1950 - printf ("Daily Credit Exceeded"); + printf("Daily Credit Exceeded"); hunk ./library/sip_settings.php 1953 - $log=sprintf("CC transaction is not allowed from %s for %s (%s)",$_SERVER['REMOTE_ADDR'],$account->account,$this->fraud_reason); + $log=sprintf("CC transaction is not allowed from %s for %s (%s)", $_SERVER['REMOTE_ADDR'], $account->account, $this->fraud_reason); hunk ./library/sip_settings.php 1975 - printf (_("Calling to telephone numbers is possible at the costs set forth in the Price List. "),$this->url); - //printf (_("You can purchase credit with a Credit Card or Bitcoin. "),$this->url, $this->url); + printf(_("Calling to telephone numbers is possible at the costs set forth in the Price List. "), $this->url); + //printf(_("You can purchase credit with a Credit Card or Bitcoin. "), $this->url, $this->url); hunk ./library/sip_settings.php 1978 - //printf (_("You can purchase credit using Bitcoin. "), $this->url); + //printf(_("You can purchase credit using Bitcoin. "), $this->url); hunk ./library/sip_settings.php 2003 - if (!in_array("payments",$this->groups)) { + if (!in_array("payments", $this->groups)) { hunk ./library/sip_settings.php 2010 - if (!in_array("payments",$this->groups)) { + if (!in_array("payments", $this->groups)) { hunk ./library/sip_settings.php 2028 - printf ("%s",$this->fraud_reason); + printf("%s", $this->fraud_reason); hunk ./library/sip_settings.php 2031 - $log=sprintf("CC transaction is not allowed from %s for %s (%s)",$_SERVER['REMOTE_ADDR'],$account->account,$this->fraud_reason); + $log=sprintf("CC transaction is not allowed from %s for %s (%s)", $_SERVER['REMOTE_ADDR'], $account->account, $this->fraud_reason); hunk ./library/sip_settings.php 2061 - $this->addBalanceReseller($credit_amount,sprintf("CC transaction %s",$payment_processor->transaction_results['id'])); + $this->addBalanceReseller($credit_amount, sprintf("CC transaction %s", $payment_processor->transaction_results['id'])); hunk ./library/sip_settings.php 2088 - printf (_("Error: Please specify a file")); + printf(_("Error: Please specify a file")); hunk ./library/sip_settings.php 2090 - hunk ./library/sip_settings.php 2092 - printf (_("Error: Please enter the name printed on the Credit Card")); + printf(_("Error: Please enter the name printed on the Credit Card")); hunk ./library/sip_settings.php 2094 - - } elseif (!preg_match("/^\d{4}$/",$_REQUEST['last_digits'])) { + } elseif (!preg_match("/^\d{4}$/", $_REQUEST['last_digits'])) { hunk ./library/sip_settings.php 2096 - printf (_("Error: Last digits must be numeric")); + printf(_("Error: Last digits must be numeric")); hunk ./library/sip_settings.php 2098 - - } elseif (!preg_match("/^\+[1-9][0-9]{7,14}$/",$_REQUEST['mobile_number'])) { + } elseif (!preg_match("/^\+[1-9][0-9]{7,14}$/", $_REQUEST['mobile_number'])) { hunk ./library/sip_settings.php 2101 - printf (_("Error: Mobile Number must be in international format starting with +")); + printf(_("Error: Mobile Number must be in international format starting with +")); hunk ./library/sip_settings.php 2103 - hunk ./library/sip_settings.php 2105 - printf (_("Error: Maximum file size is %s"),$max_file_size); + printf(_("Error: Maximum file size is %s"), $max_file_size); hunk ./library/sip_settings.php 2107 - hunk ./library/sip_settings.php 2108 - hunk ./library/sip_settings.php 2150 - printf ("Error: Failed to save identity document %s (%s)", $this->db->Error,$this->db->Errno); + printf("Error: Failed to save identity document %s (%s)", $this->db->Error, $this->db->Errno); hunk ./library/sip_settings.php 2158 - $subject=sprintf ("%s requested CC Payments",$this->account); + $subject=sprintf("%s requested CC Payments", $this->account); hunk ./library/sip_settings.php 2171 - $mime->addAttachment($content, $_FILES['tmpfile']['type'],$_FILES['tmpfile']['name'],'false'); + $mime->addAttachment($content, $_FILES['tmpfile']['type'], $_FILES['tmpfile']['name'],'false'); hunk ./library/sip_settings.php 2193 - printf ("Error deleting record: %s (%s)", $this->db->Error,$this->db->Errno); + printf("Error deleting record: %s (%s)", $this->db->Error, $this->db->Errno); hunk ./library/sip_settings.php 2208 - printf ("Error for database query: %s (%s)", $this->db->Error,$this->db->Errno); + printf("Error for database query: %s (%s)", $this->db->Error, $this->db->Errno); hunk ./library/sip_settings.php 2217 - if (!in_array("payments",$this->groups)) { + if (!in_array("payments", $this->groups)) { hunk ./library/sip_settings.php 2239 - printf (""); + printf(""); hunk ./library/sip_settings.php 2272 - hunk ./library/sip_settings.php 2281 - printf (_("To become verified, upload a copy of your passport or driving license that matches the Credit Card owner. "),$this->billing_email, $this->account, $this->billing_email); + printf(_("To become verified, upload a copy of your passport or driving license that matches the Credit Card owner. "), $this->billing_email, $this->account, $this->billing_email); hunk ./library/sip_settings.php 2283 - printf (_("This copy will be kept on your profile until the credit card transaction has been approved. ")); + printf(_("This copy will be kept on your profile until the credit card transaction has been approved. ")); hunk ./library/sip_settings.php 2308 - printf ("",$_REQUEST['name']); + printf("", $_REQUEST['name']); hunk ./library/sip_settings.php 2322 - printf (""); + printf(""); hunk ./library/sip_settings.php 2328 - if (in_array("free-pstn",$this->groups)) { + if (in_array("free-pstn", $this->groups)) { hunk ./library/sip_settings.php 2337 - printf(" %s",$_REQUEST['mobile_number'],_("International format starting with +")); + printf(" %s", $_REQUEST['mobile_number'], _("International format starting with +")); hunk ./library/sip_settings.php 2353 - printf("",$_REQUEST['last_digits']); + printf("", $_REQUEST['last_digits']); hunk ./library/sip_settings.php 2390 - printf ("Error for database query: %s (%s)", $this->db->Error,$this->db->Errno); + printf("Error for database query: %s (%s)", $this->db->Error, $this->db->Errno); hunk ./library/sip_settings.php 2397 - $h=sprintf("Content-type: %s",$this->db->f('file_type')); + $h=sprintf("Content-type: %s", $this->db->f('file_type')); hunk ./library/sip_settings.php 2400 - $h=sprintf("Content-Disposition: attachment; filename=%s",$this->db->f('file_name')); + $h=sprintf("Content-Disposition: attachment; filename=%s", $this->db->f('file_name')); hunk ./library/sip_settings.php 2403 - $h=sprintf("Content-Length: %s",$this->db->f('file_size')); + $h=sprintf("Content-Length: %s", $this->db->f('file_size')); hunk ./library/sip_settings.php 2520 - if (!in_array("trunking",$this->groups)) { + if (!in_array("trunking", $this->groups)) { hunk ./library/sip_settings.php 2527 - printf (_("You may create new aliases for incoming calls")); - printf (" + printf(_("You may create new aliases for incoming calls")); + printf(" hunk ./library/sip_settings.php 2603 - printf (" + printf(" hunk ./library/sip_settings.php 2615 - printf (" + printf(" hunk ./library/sip_settings.php 2624 - hunk ./library/sip_settings.php 2636 - printf (_("Email SIP Account information to %s"),$this->email); + printf(_("Email SIP Account information to %s"), $this->email); hunk ./library/sip_settings.php 2647 - printf (_("Login using SIP credentials at %s"),$this->sip_settings_page,$this->sip_settings_page); + printf(_("Login using SIP credentials at %s"), $this->sip_settings_page, $this->sip_settings_page); hunk ./library/sip_settings.php 2677 - //printf (_("Account remove request is active")); + //printf(_("Account remove request is active")); hunk ./library/sip_settings.php 2694 - if (in_array("trunking",$this->groups)) { + if (in_array("trunking", $this->groups)) { hunk ./library/sip_settings.php 2727 - hunk ./library/sip_settings.php 2731 - printf ("NumberCountryExpire DateOrderAction"); + printf("NumberCountryExpire DateOrderAction"); hunk ./library/sip_settings.php 2748 - $form.=sprintf ("

%s
",$_number,$numbers[$_number]['country_name'],$numbers[$_number]['did_expire_date_gmt'],$numbers[$_number]['order_id'],$form); + $form.=sprintf("", $_number); + $form.=sprintf(""); + $form.=sprintf(""); + + printf("+%s%s%s%s
%s
", $_number, $numbers[$_number]['country_name'], $numbers[$_number]['did_expire_date_gmt'], $numbers[$_number]['order_id'], $form); hunk ./library/sip_settings.php 2770 - hunk ./library/sip_settings.php 2784 - $basket = array('ddi_number' => array('price' => sprintf("%.2f",$total), - 'description' => sprintf(_('Telephone Number (+%s %s) for %d months'),$_REQUEST['prefix'],$prefixes[$_REQUEST['prefix']]['country_name'],$_REQUEST['period']), + $basket = array('ddi_number' => array('price' => sprintf("%.2f", $total), + 'description' => sprintf(_('Telephone Number (+%s %s) for %d months'), $_REQUEST['prefix'], $prefixes[$_REQUEST['prefix']]['country_name'], $_REQUEST['period']), hunk ./library/sip_settings.php 2819 - $payment_processor = new $this->payment_processor_class($this,$basket); + $payment_processor = new $this->payment_processor_class($this, $basket); hunk ./library/sip_settings.php 2897 - printf ("