mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-06-26 04:41:41 +02:00
Add mirror of xmlrpc ssl send call
This commit is contained in:
parent
51a572a9f5
commit
2247e8c99c
@ -39,7 +39,7 @@ class soap_client
|
|||||||
$this->server = $server;
|
$this->server = $server;
|
||||||
$this->errno;
|
$this->errno;
|
||||||
$this->errstring;
|
$this->errstring;
|
||||||
$this->debug_flag = True;
|
$this->debug_flag = False;
|
||||||
$this->debug_str = "";
|
$this->debug_str = "";
|
||||||
$this->username = "";
|
$this->username = "";
|
||||||
$this->password = "";
|
$this->password = "";
|
||||||
@ -78,11 +78,24 @@ class soap_client
|
|||||||
$this->password = $p;
|
$this->password = $p;
|
||||||
}
|
}
|
||||||
|
|
||||||
function send($msg, $action, $timeout=0)
|
function send($msg, $action, $timeout=0, $ssl=False)
|
||||||
{
|
{
|
||||||
// where msg is an soapmsg
|
// where msg is an soapmsg
|
||||||
$msg->debug_flag = $this->debug_flag;
|
$msg->debug_flag = $this->debug_flag;
|
||||||
$this->action = $action;
|
$this->action = $action;
|
||||||
|
if($ssl)
|
||||||
|
{
|
||||||
|
return $this->ssl_sendPayloadHTTP10(
|
||||||
|
$msg,
|
||||||
|
$this->server,
|
||||||
|
$this->port,
|
||||||
|
$timeout,
|
||||||
|
$this->username,
|
||||||
|
$this->password
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
return $this->sendPayloadHTTP10(
|
return $this->sendPayloadHTTP10(
|
||||||
$msg,
|
$msg,
|
||||||
$this->server,
|
$this->server,
|
||||||
@ -92,8 +105,9 @@ class soap_client
|
|||||||
$this->password
|
$this->password
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function sendPayloadHTTP10($msg, $server, $port, $timeout=0, $username="", $password="")
|
function sendPayloadHTTP10($msg, $server, $port, $timeout=0, $username='', $password='')
|
||||||
{
|
{
|
||||||
if($timeout > 0)
|
if($timeout > 0)
|
||||||
{
|
{
|
||||||
@ -111,11 +125,10 @@ class soap_client
|
|||||||
}
|
}
|
||||||
|
|
||||||
// thanks to Grant Rauscher <grant7@firstworld.net> for this
|
// thanks to Grant Rauscher <grant7@firstworld.net> for this
|
||||||
$credentials = "";
|
$credentials = '';
|
||||||
if ($username != "")
|
if ($username != '')
|
||||||
{
|
{
|
||||||
$credentials = "Authorization: Basic "
|
$credentials = "Authorization: Basic " . base64_encode($username . ":" . $password) . "\r\n";
|
||||||
. base64_encode($username . ":" . $password) . "\r\n";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$soap_data = $msg->serialize();
|
$soap_data = $msg->serialize();
|
||||||
@ -148,6 +161,52 @@ class soap_client
|
|||||||
return $this->response;
|
return $this->response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
*/
|
||||||
|
|
||||||
|
// thanks to Grant Rauscher <grant7@firstworld.net>
|
||||||
|
// for this
|
||||||
|
$credentials = '';
|
||||||
|
if ($username!='')
|
||||||
|
{
|
||||||
|
$credentials = "Authorization: Basic " . base64_encode($username . ':' . $password) . "\r\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
$soap_data = $msg->serialize();
|
||||||
|
$this->outgoing_payload = "POST ".
|
||||||
|
$this->path.
|
||||||
|
" HTTP/1.0\r\n".
|
||||||
|
"User-Agent: SOAPx4 v0.13492\r\n".
|
||||||
|
"Host: ".$this->server . "\r\n".
|
||||||
|
$credentials.
|
||||||
|
"Content-Type: text/xml\r\nContent-Length: ".strlen($soap_data)."\r\n".
|
||||||
|
"SOAPAction: \"$this->action\""."\r\n\r\n".
|
||||||
|
$soap_data;
|
||||||
|
|
||||||
|
// send
|
||||||
|
$ch = curl_init();
|
||||||
|
curl_setopt($ch, CURLOPT_URL,$this->server);
|
||||||
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||||
|
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $this->outgoing_payload);
|
||||||
|
curl_setopt($ch, CURLOPT_HEADER, 0);
|
||||||
|
$incoming_payload = curl_exec($ch);
|
||||||
|
curl_close($ch);
|
||||||
|
|
||||||
|
$this->incoming_payload = $incoming_payload;
|
||||||
|
// $response is a soapmsg object
|
||||||
|
$this->response = $msg->parseResponse($incoming_payload);
|
||||||
|
$this->debug($msg->debug_str);
|
||||||
|
return $this->response;
|
||||||
|
}
|
||||||
|
|
||||||
function debug($string)
|
function debug($string)
|
||||||
{
|
{
|
||||||
if($this->debug_flag)
|
if($this->debug_flag)
|
||||||
@ -155,6 +214,5 @@ class soap_client
|
|||||||
$this->debug_str .= "$string\n";
|
$this->debug_str .= "$string\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // end class soap_client
|
} // end class soap_client
|
||||||
?>
|
?>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user