diff --git a/phpgwapi/inc/class.interserver.inc.php b/phpgwapi/inc/class.interserver.inc.php
index f5a02df601..55306d6b5d 100644
--- a/phpgwapi/inc/class.interserver.inc.php
+++ b/phpgwapi/inc/class.interserver.inc.php
@@ -128,17 +128,9 @@
function _send_xmlrpc_ssl($method_name, $args, $url, $debug=True)
{
- if(!function_exists(curl_init))
- {
- $this->debug('No curl functions available - use of ssl is invalid',$debug);
- return False;
- }
- /* curl Method borrowed from:
- http://sourceforge.net/tracker/index.php?func=detail&aid=427359&group_id=23199&atid=377731
- */
list($uri,$hostpart) = $this->_split_url($url . $this->urlparts['xmlrpc']);
- $this->debug("opening curl to $url", $debug);
-
+ $hostpart = ereg_replace('https://','',$hostpart);
+ $hostpart = ereg_replace('http://','',$hostpart);
if(gettype($args) != 'array')
{
$arr[] = CreateObject('phpgwapi.xmlrpcval',$args,'string');
@@ -147,51 +139,29 @@
{
while(list($key,$val) = @each($args))
{
- $arr[] = CreateObject('phpgwapi.xmlrpcval',$val,'string');
+ $arr[] = CreateObject('phpgwapi.xmlrpcval',$val, 'string');
}
}
- $f = CreateObject('phpgwapi.xmlrpcmsg',$method_name,$arr);
- $content_len = strlen($f->serialize());
-
- $cliversion = $GLOBALS['phpgw_info']['server']['versions']['phpgwapi'];
- $http_request = 'POST ' . $uri . ' HTTP/1.0' . "\r\n"
- . 'User-Agent: phpGroupware/' . $cliversion . '(PHP) ' . "\r\n"
- . 'X-PHPGW-Server: ' . $GLOBALS['HTTP_HOST'] . ' ' . "\r\n"
- . 'X-PHPGW-Version: ' . $cliversion . "\r\n"
- . 'Content-Type: text/xml' . "\r\n"
- . 'Content-Length: ' . $content_len . "\r\n\r\n"
- . $f->serialize();
-
- $this->debug("sending http request:
\n" . $http_request . "\n", $debug);
-
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL,$hostpart);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $http_request);
- curl_setopt($ch, CURLOPT_HEADER, 0);
- $response_buf = curl_exec($ch);
- curl_close($ch);
-
- $this->debug("got response:.\n$response_buf\n\n", $debug);
-
- $retval = '';
- if (strlen($response_buf))
+ $f = CreateObject('phpgwapi.xmlrpcmsg', $method_name, $arr,'struct');
+ $this->debug("" . htmlentities($f->serialize()) . "
\n",$debug);
+ $c = CreateObject('phpgwapi.xmlrpc_client',$this->urlparts['xmlrpc'], $hostpart, 80);
+ $c->setDebug(1);
+ $r = $c->send($f,0,True);
+ if (!$r)
{
- $xml_begin = substr($response_buf, strpos($response_buf, "debug('Error: no xml start found from'.$hostpart.'!');
- }
+ $this->debug('send failed');
+ }
+ $v = $r->value();
+ if (!$r->faultCode())
+ {
+ $this->debug('
I got this value back
' . htmlentities($r->serialize()) . '
',$debug);
}
else
{
- $this->debug('Error: no response from '.$hostpart.'!');
+ $this->debug('Fault Code: ' . $r->faultCode() . ' Reason "' . $r->faultString() . '"
',$debug);
}
- $this->result = $retval;
+
+ $this->result = xmlrpc_decode($v);
return $this->result;
}
diff --git a/phpgwapi/inc/class.xmlrpc_client.inc.php b/phpgwapi/inc/class.xmlrpc_client.inc.php
index 2a37de0320..cbf55cf930 100644
--- a/phpgwapi/inc/class.xmlrpc_client.inc.php
+++ b/phpgwapi/inc/class.xmlrpc_client.inc.php
@@ -54,16 +54,29 @@
$this->password = $p;
}
- function send($msg, $timeout=0)
+ function send($msg, $timeout=0, $ssl=False)
{
// where msg is an xmlrpcmsg
- $msg->debug=$this->debug;
- return $this->sendPayloadHTTP10(
- $msg,
- $this->server, $this->port,
- $timeout, $this->username,
- $this->password
- );
+ $msg->debug = $this->debug;
+
+ if($ssl)
+ {
+ return $this->ssl_sendPayloadHTTP10(
+ $msg,
+ $this->server, $this->port,
+ $timeout, $this->username,
+ $this->password
+ );
+ }
+ else
+ {
+ return $this->sendPayloadHTTP10(
+ $msg,
+ $this->server, $this->port,
+ $timeout, $this->username,
+ $this->password
+ );
+ }
}
function sendPayloadHTTP10($msg, $server, $port, $timeout=0,$username="", $password="")
@@ -112,5 +125,52 @@
fclose($fp);
return $resp;
}
+
+ function ssl_sendPayloadHTTP10($msg, $server, $port, $timeout=0,$username='', $password='')
+ {
+ if(!function_exists(curl_init))
+ {
+ $this->errstr = 'No curl functions available - use of ssl is invalid';
+ return False;
+ }
+ /* curl Method borrowed from:
+ http://sourceforge.net/tracker/index.php?func=detail&aid=427359&group_id=23199&atid=377731
+ */
+
+ // Only create the payload if it was not created previously
+ if(empty($msg->payload))
+ {
+ $msg->createPayload();
+ }
+
+ // thanks to Grant Rauscher
+ // for this
+ $credentials = '';
+ if ($username!='')
+ {
+ $credentials = "Authorization: Basic " . base64_encode($username . ':' . $password) . "\r\n";
+ }
+
+ $op = "POST " . $this->path . " HTTP/1.0\r\nUser-Agent: PHP XMLRPC 1.0\r\n"
+ . "Host: ". $this->server . "\r\n"
+ . 'X-PHPGW-Server: ' . $this->server . ' ' . "\r\n"
+ . 'X-PHPGW-Version: ' . $GLOBALS['phpgw_info']['server']['versions']['phpgwapi'] . "\r\n"
+ . $credentials
+ . "Content-Type: text/xml\r\nContent-Length: "
+ . strlen($msg->payload) . "\r\n\r\n"
+ . $msg->payload;
+
+ $ch = curl_init();
+ curl_setopt($ch, CURLOPT_URL,$this->server);
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+ curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $op);
+ curl_setopt($ch, CURLOPT_HEADER, 0);
+ $response_buf = curl_exec($ch);
+ curl_close($ch);
+
+ $resp = $msg->parseResponse($response_buf);
+ return $resp;
+ }
+
}
?>