summaryrefslogtreecommitdiffstats
path: root/src/etc/inc/xmlrpc_client.inc
diff options
context:
space:
mode:
authorPiBa-NL <pba_2k3@yahoo.com>2016-09-08 01:09:44 +0200
committerPiBa-NL <pba_2k3@yahoo.com>2016-09-08 01:09:44 +0200
commit4d7522bfc56cfd18f6d0df9fcea73715516b56d0 (patch)
tree2c69055c2d0c6e6602ad8a3334131054bcf8ac60 /src/etc/inc/xmlrpc_client.inc
parenta8620841be1ad5ecced36091cb8bc716df32789c (diff)
downloadpfsense-4d7522bfc56cfd18f6d0df9fcea73715516b56d0.zip
pfsense-4d7522bfc56cfd18f6d0df9fcea73715516b56d0.tar.gz
XMLRPC, xmlrpc_client simplify construction parameters where possible + cleanup
Diffstat (limited to 'src/etc/inc/xmlrpc_client.inc')
-rw-r--r--src/etc/inc/xmlrpc_client.inc31
1 files changed, 28 insertions, 3 deletions
diff --git a/src/etc/inc/xmlrpc_client.inc b/src/etc/inc/xmlrpc_client.inc
index 1ef3107..92b48da 100644
--- a/src/etc/inc/xmlrpc_client.inc
+++ b/src/etc/inc/xmlrpc_client.inc
@@ -21,7 +21,7 @@
require_once("XML/RPC2/Client.php");
-class pfsense_xmlrpc_client {
+class pfsense_xmlrpc_client_extended {
private $username, $password, $url, $filenotice, $error;
@@ -77,13 +77,13 @@ class pfsense_xmlrpc_client {
$resp = $cli->$method($this->username, $this->password, $parameter);
} catch (XML_RPC2_FaultException $e) {
// The XMLRPC server returns a XMLRPC error
- $this->error = "Exception calling XMLRPC method1 {$method} #" . $e->getFaultCode() . ' : ' . $e->getFaultString();
+ $this->error = "Exception calling XMLRPC method {$method} #" . $e->getFaultCode() . ' : ' . $e->getFaultString();
log_error($this->error);
file_notice($this->filenotice, $this->error, "Communications error occurred", "");
continue;
} catch (Exception $e) {
// Other errors (HTTP or networking problems...)
- $this->error = "Exception calling XMLRPC method2 {$method} # " . $e->getMessage() . htmlspecialchars(print_r(debug_backtrace(),true))."DUS";
+ $this->error = "Exception calling XMLRPC method {$method} # " . $e->getMessage();
log_error($this->error);
file_notice($this->filenotice, $this->error, gettext("Error code received"), "");
continue;
@@ -114,3 +114,28 @@ class pfsense_xmlrpc_client {
return $this->error;
}
}
+
+class pfsense_xmlrpc_client extends pfsense_xmlrpc_client_extended {
+ /* Default sync class */
+ public function __construct() {
+ global $config;
+ $hasync = $config['hasync'];
+
+ if (empty($hasync['username'])) {
+ $username = "admin";
+ } else {
+ $username = $hasync['username'];
+ }
+ /* if port is empty lets rely on the protocol selection */
+ $port = $config['system']['webgui']['port'];
+ if (empty($port)) {
+ if ($config['system']['webgui']['protocol'] == "http") {
+ $port = "80";
+ } else {
+ $port = "443";
+ }
+ }
+ parent::__construct($hasync['synchronizetoip'], $port, $username, $hasync['password']);
+ }
+
+} \ No newline at end of file
OpenPOWER on IntegriCloud