- // Set the URL for the request
- $url .= $this->server . ':' . $this->port . '/' . $this->path;
- curl_setopt($curl, CURLOPT_URL, $url);
-
- // Marshal the XML-RPC request as a POST variable. <nil/> is an
- // extension to the XML-RPC spec that is supported in our custom
- // version of xmlrpc.so via the 'allow_null' output_encoding key.
- $request = xmlrpc_encode_request($method, $args, array('null_extension'));
- curl_setopt($curl, CURLOPT_POSTFIELDS, $request);
-
- // Construct the HTTP header
- $header[] = 'Content-type: text/xml';
- $header[] = 'Content-length: ' . strlen($request);
- curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
-
- // Set some miscellaneous options
- curl_setopt($curl, CURLOPT_TIMEOUT, 180);
-
- // Get the output of the request
- curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
- $t0 = $this->microtime_float();
- $output = curl_exec($curl);
- $t1 = $this->microtime_float();
-
- if (curl_errno($curl)) {
- $this->error_log('curl: ' . curl_error($curl), true);
- $ret = NULL;
- } else {
- $ret = xmlrpc_decode($output);
- if (is_array($ret) && xmlrpc_is_fault($ret)) {
- $this->error_log('Fault Code ' . $ret['faultCode'] . ': ' .
- $ret['faultString'], $backtrace_level, true);
- $ret = NULL;
- }
- }
+ /*
+ * The original internal call that uses php XML-RPC
+ */
+ function internal_call_xmlrpc($method, $args = NULL, $backtrace_level = 2) {
+ $curl = curl_init();
+
+ // Verify peer certificate if talking over SSL
+ if ($this->port == 443) {
+ curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 2);
+ if (!empty($this->cainfo)) {
+ curl_setopt($curl, CURLOPT_CAINFO, $this->cainfo);
+ } elseif (defined('PLC_API_CA_SSL_CRT')) {
+ curl_setopt($curl, CURLOPT_CAINFO, PLC_API_CA_SSL_CRT);
+ }
+ $url = 'https://';
+ } else {
+ $url = 'http://';
+ }