42 require_once(
'Mail/mimeDecode.php');
43 require_once(
'Mail/mimePart.php');
90 $cid = md5(uniqid(time()));
93 $info[
'data'] =
$data;
95 $info[
'contenttype'] = $contenttype;
98 $this->requestAttachments[] = $info;
109 $this->requestAttachments = array();
134 if (count($this->requestAttachments) > 0) {
135 $params[
'content_type'] =
'multipart/related; type="text/xml"';
136 $mimeMessage =&
new Mail_mimePart(
'',
$params);
139 $params[
'content_type'] =
'text/xml';
142 $mimeMessage->addSubpart($soapmsg,
$params);
144 foreach ($this->requestAttachments as $att) {
147 $params[
'content_type'] = $att[
'contenttype'];
148 $params[
'encoding'] =
'base64';
149 $params[
'disposition'] =
'attachment';
150 $params[
'dfilename'] = $att[
'filename'];
153 if ($att[
'data'] ==
'' && $att[
'filename'] <>
'') {
154 if ($fd = fopen($att[
'filename'],
'rb')) {
155 $data = fread($fd, filesize($att[
'filename']));
162 $mimeMessage->addSubpart($att[
'data'],
$params);
166 $output = $mimeMessage->encode();
167 $mimeHeaders = $output[
'headers'];
169 foreach ($mimeHeaders as $k => $v) {
170 $this->
debug(
"MIME header $k: $v");
171 if (strtolower($k) ==
'content-type') {
174 $this->mimeContentType = str_replace(
"\r\n",
" ", $v);
178 return $output[
'body'];
193 if (count($this->requestAttachments) > 0) {
209 if (count($this->requestAttachments) > 0) {
224 $this->
debug(
'Entering parseResponse() for payload of length ' . strlen(
$data) .
' and type of ' . $headers[
'content-type']);
225 $this->responseAttachments = array();
226 if (strstr($headers[
'content-type'],
'multipart/related')) {
227 $this->
debug(
'Decode multipart/related');
229 foreach ($headers as $k => $v) {
230 $input .=
"$k: $v\r\n";
233 $params[
'include_bodies'] =
true;
234 $params[
'decode_bodies'] =
true;
235 $params[
'decode_headers'] =
true;
237 $structure = Mail_mimeDecode::decode(
$params);
239 foreach ($structure->parts as $part) {
240 if (!isset($part->disposition) && (strstr($part->headers[
'content-type'],
'text/xml'))) {
241 $this->
debug(
'Have root part of type ' . $part->headers[
'content-type']);
245 $this->
debug(
'Have an attachment of type ' . $part->headers[
'content-type']);
246 $info[
'data'] = $part->body;
247 $info[
'filename'] = isset($part->d_parameters[
'filename']) ? $part->d_parameters[
'filename'] :
'';
248 $info[
'contenttype'] = $part->headers[
'content-type'];
249 $info[
'cid'] = $part->headers[
'content-id'];
250 $this->responseAttachments[] = $info;
254 if (isset($return)) {
255 $this->responseData = $root;
259 $this->
setError(
'No root part found in multipart/related content');
262 $this->
debug(
'Not multipart/related');
270 if (!extension_loaded(
'soap')) {
320 $cid = md5(uniqid(time()));
323 $info[
'data'] =
$data;
325 $info[
'contenttype'] = $contenttype;
328 $this->responseAttachments[] = $info;
339 $this->responseAttachments = array();
364 if (count($this->responseAttachments) > 0) {
365 $params[
'content_type'] =
'multipart/related; type="text/xml"';
366 $mimeMessage =&
new Mail_mimePart(
'',
$params);
369 $params[
'content_type'] =
'text/xml';
372 $mimeMessage->addSubpart($soapmsg,
$params);
374 foreach ($this->responseAttachments as $att) {
377 $params[
'content_type'] = $att[
'contenttype'];
378 $params[
'encoding'] =
'base64';
379 $params[
'disposition'] =
'attachment';
380 $params[
'dfilename'] = $att[
'filename'];
383 if ($att[
'data'] ==
'' && $att[
'filename'] <>
'') {
384 if ($fd = fopen($att[
'filename'],
'rb')) {
385 $data = fread($fd, filesize($att[
'filename']));
392 $mimeMessage->addSubpart($att[
'data'],
$params);
396 $output = $mimeMessage->encode();
397 $mimeHeaders = $output[
'headers'];
399 foreach ($mimeHeaders as $k => $v) {
400 $this->
debug(
"MIME header $k: $v");
401 if (strtolower($k) ==
'content-type') {
404 $this->mimeContentType = str_replace(
"\r\n",
" ", $v);
408 return $output[
'body'];
423 if (count($this->responseAttachments) > 0) {
439 if (count($this->responseAttachments) > 0) {
454 $this->
debug(
'Entering parseRequest() for payload of length ' . strlen(
$data) .
' and type of ' .
$headers[
'content-type']);
455 $this->requestAttachments = array();
456 if (strstr($headers[
'content-type'],
'multipart/related')) {
457 $this->
debug(
'Decode multipart/related');
459 foreach ($headers as $k => $v) {
460 $input .=
"$k: $v\r\n";
463 $params[
'include_bodies'] =
true;
464 $params[
'decode_bodies'] =
true;
465 $params[
'decode_headers'] =
true;
467 $structure = Mail_mimeDecode::decode(
$params);
469 foreach ($structure->parts as $part) {
470 if (!isset($part->disposition) && (strstr($part->headers[
'content-type'],
'text/xml'))) {
471 $this->
debug(
'Have root part of type ' . $part->headers[
'content-type']);
474 $this->
debug(
'Have an attachment of type ' . $part->headers[
'content-type']);
475 $info[
'data'] = $part->body;
476 $info[
'filename'] = isset($part->d_parameters[
'filename']) ? $part->d_parameters[
'filename'] :
'';
477 $info[
'contenttype'] = $part->headers[
'content-type'];
478 $info[
'cid'] = $part->headers[
'content-id'];
479 $this->requestAttachments[] = $info;
483 if (isset($return)) {
487 $this->
setError(
'No root part found in multipart/related content');
490 $this->
debug(
'Not multipart/related');