+ /*
+ * Use PhpXmlRpc\Value before encoding the request
+ */
+ function xmlrpcValue($value) {
+ switch(gettype($value)) {
+ case 'array':
+ $members = array();
+ foreach($value as $vk => $vv) {
+ $members[$vk] = $this->xmlrpcValue($vv);
+ }
+
+ if ((array_key_exists(0, $value)) || (empty($value))) {
+ return new PhpXmlRpc\Value(
+ $members,
+ 'array'
+ );
+ } else {
+ return new PhpXmlRpc\Value(
+ $members,
+ 'struct'
+ );
+ }
+
+ break;
+ case 'double':
+ return new PhpXmlRpc\Value($value, 'double');
+ break;
+ case 'boolean':
+ return new PhpXmlRpc\Value($value, 'boolean');
+ break;
+ case 'NULL':
+ case 'null':
+ return new PhpXmlRpc\Value(null, 'null');
+ break;
+ case 'integer':
+ return new PhpXmlRpc\Value($value, 'int');
+ break;
+ default:
+ return new PhpXmlRpc\Value($value);
+ break;
+ }
+ }
+
+ function internal_call($method, $args = NULL, $backtrace_level = 2)
+ {
+ if (class_exists('PhpXmlRpc\\PhpXmlRpc')) {
+ return $this->internal_call_phpxmlrpc($method, $args, $backtrace_level);
+ } else {
+ return $this->internal_call_xmlrpc($method, $args, $backtrace_level);
+ }
+ }
+
+ /*
+ * the new internal call, will use PhpXmlRpc
+ */
+ function internal_call_phpxmlrpc($method, $args = NULL, $backtrace_level = 2)
+ {
+//
+// echo '<pre>';
+// var_dump($method);
+// var_dump($args);
+// echo '</pre>';
+
+ PhpXmlRpc\PhpXmlRpc::$xmlrpc_null_extension = true;
+
+ if ($this->port == 443) {
+ $url = 'https://';
+ } else {
+ $url = 'http://';
+ }
+
+ // Set the URL for the request
+ $url .= $this->server . ':' . $this->port . '/' . $this->path;
+
+ $client = new PhpXmlRpc\Client($url);
+ $client->setSSLVerifyPeer(false);
+ /*
+ * 1 -> not verify CN
+ * 2 -> verify CN (default)
+ */
+ $client->setSSLVerifyHost(1);
+
+ $values = $this->xmlrpcValue($args);
+
+ $response = $client->send(new PhpXmlRpc\Request($method, $values));
+
+
+ if (!$response->faultCode()) {
+ $encoder = new PhpXmlRpc\Encoder();
+ $v = $encoder->decode($response->value());
+
+ return $v;
+ } else {
+ $this->error_log("An error occurred [" . $response->faultCode() . "] ".
+ $response->faultString());
+ return NULL;
+ }
+ }
+
+ /*
+ * The original internal call that uses php XML-RPC
+ */
+ function internal_call_xmlrpc($method, $args = NULL, $backtrace_level = 2)