5 Modification information for LGPL compliance
7 r56990 - 2010-06-16 13:05:36 -0700 (Wed, 16 Jun 2010) - kjing - snapshot "Mango" svn branch to a new one for GitHub sync
9 r56989 - 2010-06-16 13:01:33 -0700 (Wed, 16 Jun 2010) - kjing - defunt "Mango" svn dev branch before github cutover
11 r55980 - 2010-04-19 13:31:28 -0700 (Mon, 19 Apr 2010) - kjing - create Mango (6.1) based on windex
13 r51719 - 2009-10-22 10:18:00 -0700 (Thu, 22 Oct 2009) - mitani - Converted to Build 3 tags and updated the build system
15 r51634 - 2009-10-19 13:32:22 -0700 (Mon, 19 Oct 2009) - mitani - Windex is the branch for Sugar Sales 1.0 development
17 r50375 - 2009-08-24 18:07:43 -0700 (Mon, 24 Aug 2009) - dwong - branch kobe2 from tokyo r50372
19 r42807 - 2008-12-29 11:16:59 -0800 (Mon, 29 Dec 2008) - dwong - Branch from trunk/sugarcrm r42806 to branches/tokyo/sugarcrm
21 r39619 - 2008-09-09 13:41:34 -0700 (Tue, 09 Sep 2008) - jmertic - Bug 24827 - Remove all instances where we return a new object and assign it by reference, since this is deprecated in PHP 5 and emits E_DEPRECATED errors in PHP 5.3.
24 - include/domit/php_http_client_generic.php
25 - include/domit/php_http_connector.php
26 - include/domit/testing_domit.php
27 - include/domit/xml_domit_getelementsbypath.php
28 - include/domit/xml_domit_lite_parser.php
29 - include/domit/xml_domit_nodemaps.php
30 - include/domit/xml_domit_parser.php
31 - include/domit/xml_domit_shared.php
32 - include/generic/SugarWidgets/SugarWidgetField.php
33 - include/generic/SugarWidgets/SugarWidgetReportField.php
34 - include/ListView/ProcessView.php
35 - include/nusoap/class.soapclient.php
36 - include/nusoap/nusoap.php
37 - include/nusoap/nusoapmime.php
38 - include/Pear/HTML_Safe/Safe.php
39 - include/Pear/XML_HTMLSax3/HTMLSax3.php
40 - modules/Administration/RebuildWorkFlow.php
41 - modules/Expressions/RelateSelector.php
42 - modules/Reports/templates/templates_reports.php
43 - modules/WorkFlow/Delete.php
44 - modules/WorkFlow/Save.php
45 - modules/WorkFlow/SaveSequence.php
46 - modules/WorkFlow/WorkFlow.php
47 - modules/WorkFlowActionShells/CreateStep1.php
48 - modules/WorkFlowActionShells/CreateStep2.php
49 - modules/WorkFlowActionShells/Save.php
50 - modules/WorkFlowActionShells/WorkFlowActionShell.php
51 - modules/WorkFlowAlerts/Save.php
52 - modules/WorkFlowAlerts/WorkFlowAlert.php
53 - modules/WorkFlowAlertShells/DetailView.php
54 - modules/WorkFlowAlertShells/WorkFlowAlertShell.php
55 - modules/WorkFlowTriggerShells/CreateStep1.php
56 - modules/WorkFlowTriggerShells/CreateStepFilter.php
57 - modules/WorkFlowTriggerShells/SaveFilter.php
58 - modules/WorkFlowTriggerShells/WorkFlowTriggerShell.php
59 - soap/SoapHelperFunctions.php
60 - test/modules/DynamicFields/DynamicFields_Bug24095_test.php
61 - test/simpletest/browser.php
62 - test/simpletest/default_reporter.php
63 - test/simpletest/detached.php
64 - test/simpletest/eclipse.php
65 - test/simpletest/expectation.php
66 - test/simpletest/extensions/pear_test_case.php
67 - test/simpletest/form.php
68 - test/simpletest/http.php
69 - test/simpletest/mock_objects.php
70 - test/simpletest/page.php
71 - test/simpletest/parser.php
72 - test/simpletest/remote.php
73 - test/simpletest/shell_tester.php
74 - test/simpletest/simple_test.php
75 - test/simpletest/simpletest.php
76 - test/simpletest/test/acceptance_test.php
77 - test/simpletest/test/adapter_test.php
78 - test/simpletest/test/authentication_test.php
79 - test/simpletest/test/browser_test.php
80 - test/simpletest/test/collector_test.php
81 - test/simpletest/test/compatibility_test.php
82 - test/simpletest/test/detached_test.php
83 - test/simpletest/test/eclipse_test.php
84 - test/simpletest/test/encoding_test.php
85 - test/simpletest/test/errors_test.php
86 - test/simpletest/test/expectation_test.php
87 - test/simpletest/test/form_test.php
88 - test/simpletest/test/frames_test.php
89 - test/simpletest/test/http_test.php
90 - test/simpletest/test/live_test.php
91 - test/simpletest/test/mock_objects_test.php
92 - test/simpletest/test/page_test.php
93 - test/simpletest/test/parse_error_test.php
94 - test/simpletest/test/parser_test.php
95 - test/simpletest/test/remote_test.php
96 - test/simpletest/test/shell_test.php
97 - test/simpletest/test/shell_tester_test.php
98 - test/simpletest/test/simpletest_test.php
99 - test/simpletest/test/site/page_request.php
100 - test/simpletest/test/tag_test.php
101 - test/simpletest/test/unit_tester_test.php
102 - test/simpletest/test/user_agent_test.php
103 - test/simpletest/test/visual_test.php
104 - test/simpletest/test/xml_test.php
105 - test/simpletest/test_case.php
106 - test/simpletest/ui/array_reporter/test.php
107 - test/simpletest/ui/recorder/test.php
108 - test/simpletest/unit_tester.php
109 - test/simpletest/url.php
110 - test/simpletest/user_agent.php
111 - test/simpletest/web_tester.php
112 - test/spikephpcoverage/src/PEAR.php
113 - test/spikephpcoverage/src/util/Utility.php
114 - test/spikephpcoverage/src/XML/Parser.php
115 - test/spikephpcoverage/src/XML/Parser/Simple.php
116 - test/test_utilities/SugarTest_SimpleBrowser.php
118 r13782 - 2006-06-06 10:58:55 -0700 (Tue, 06 Jun 2006) - majed - changes entry point code
120 r11115 - 2006-01-17 14:54:45 -0800 (Tue, 17 Jan 2006) - majed - add entry point validation
122 r8991 - 2005-11-03 19:07:25 -0800 (Thu, 03 Nov 2005) - majed - fixes nusoap issue
124 r8846 - 2005-10-31 11:01:12 -0800 (Mon, 31 Oct 2005) - majed - new version of nusoap
126 r7905 - 2005-09-21 19:12:57 -0700 (Wed, 21 Sep 2005) - majed - restores old nusoap pre & with a few fixes
128 r7861 - 2005-09-20 15:40:25 -0700 (Tue, 20 Sep 2005) - majed - & fix for 3.5.1
130 r7452 - 2005-08-17 11:32:34 -0700 (Wed, 17 Aug 2005) - majed - changes soap to nusoap
132 r5462 - 2005-05-25 13:50:11 -0700 (Wed, 25 May 2005) - majed - upgraded nusoap to .6.9
134 r573 - 2004-09-04 13:03:32 -0700 (Sat, 04 Sep 2004) - sugarclint - undoing copyrights added in inadvertantly. --clint
136 r546 - 2004-09-03 11:49:38 -0700 (Fri, 03 Sep 2004) - sugarmsi - removed echo count
138 r354 - 2004-08-02 23:00:37 -0700 (Mon, 02 Aug 2004) - sugarjacob - Adding Soap
144 if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
146 $Id: nusoapmime.php 39619 2008-09-09 20:41:34Z jmertic $
148 NuSOAP - Web Services Toolkit for PHP
150 Copyright (c) 2002 NuSphere Corporation
152 This library is free software; you can redistribute it and/or
153 modify it under the terms of the GNU Lesser General Public
154 License as published by the Free Software Foundation; either
155 version 2.1 of the License, or (at your option) any later version.
157 This library is distributed in the hope that it will be useful,
158 but WITHOUT ANY WARRANTY; without even the implied warranty of
159 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
160 Lesser General Public License for more details.
162 You should have received a copy of the GNU Lesser General Public
163 License along with this library; if not, write to the Free Software
164 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
166 If you have any questions or comments, please email:
170 http://dietrich.ganx4.com/nusoap
173 http://www.nusphere.com
177 /*require_once('nusoap.php');*/
178 /* PEAR Mail_MIME library */
179 require_once('Mail/mimeDecode.php');
180 require_once('Mail/mimePart.php');
183 * nusoapclientmime client supporting MIME attachments defined at
184 * http://www.w3.org/TR/SOAP-attachments. It depends on the PEAR Mail_MIME library.
186 * @author Scott Nichol <snichol@sourceforge.net>
187 * @author Thanks to Guillaume and Henning Reich for posting great attachment code to the mail list
191 class nusoapclientmime extends nusoapclient {
193 * @var array Each array element in the return is an associative array with keys
194 * data, filename, contenttype, cid
197 var $requestAttachments = array();
199 * @var array Each array element in the return is an associative array with keys
200 * data, filename, contenttype, cid
203 var $responseAttachments;
208 var $mimeContentType;
211 * adds a MIME attachment to the current request.
213 * If the $data parameter contains an empty string, this method will read
214 * the contents of the file named by the $filename parameter.
216 * If the $cid parameter is false, this method will generate the cid.
218 * @param string $data The data of the attachment
219 * @param string $filename The filename of the attachment (default is empty string)
220 * @param string $contenttype The MIME Content-Type of the attachment (default is application/octet-stream)
221 * @param string $cid The content-id (cid) of the attachment (default is false)
222 * @return string The content-id (cid) of the attachment
225 function addAttachment($data, $filename = '', $contenttype = 'application/octet-stream', $cid = false) {
227 $cid = md5(uniqid(time()));
230 $info['data'] = $data;
231 $info['filename'] = $filename;
232 $info['contenttype'] = $contenttype;
235 $this->requestAttachments[] = $info;
241 * clears the MIME attachments for the current request.
245 function clearAttachments() {
246 $this->requestAttachments = array();
250 * gets the MIME attachments from the current response.
252 * Each array element in the return is an associative array with keys
253 * data, filename, contenttype, cid. These keys correspond to the parameters
256 * @return array The attachments.
259 function getAttachments() {
260 return $this->responseAttachments;
264 * gets the HTTP body for the current request.
266 * @param string $soapmsg The SOAP payload
267 * @return string The HTTP body, which includes the SOAP payload
270 function getHTTPBody($soapmsg) {
271 if (count($this->requestAttachments) > 0) {
272 $params['content_type'] = 'multipart/related; type=text/xml';
273 $mimeMessage = new Mail_mimePart('', $params);
276 $params['content_type'] = 'text/xml';
277 $params['encoding'] = '8bit';
278 $params['charset'] = $this->soap_defencoding;
279 $mimeMessage->addSubpart($soapmsg, $params);
281 foreach ($this->requestAttachments as $att) {
284 $params['content_type'] = $att['contenttype'];
285 $params['encoding'] = 'base64';
286 $params['disposition'] = 'attachment';
287 $params['dfilename'] = $att['filename'];
288 $params['cid'] = $att['cid'];
290 if ($att['data'] == '' && $att['filename'] <> '') {
291 if ($fd = fopen($att['filename'], 'rb')) {
292 $data = fread($fd, filesize($att['filename']));
297 $mimeMessage->addSubpart($data, $params);
299 $mimeMessage->addSubpart($att['data'], $params);
303 $output = $mimeMessage->encode();
304 $mimeHeaders = $output['headers'];
306 foreach ($mimeHeaders as $k => $v) {
307 $this->debug("MIME header $k: $v");
308 if (strtolower($k) == 'content-type') {
309 // PHP header() seems to strip leading whitespace starting
310 // the second line, so force everything to one line
311 $this->mimeContentType = str_replace("\r\n", " ", $v);
315 return $output['body'];
318 return parent::getHTTPBody($soapmsg);
322 * gets the HTTP content type for the current request.
324 * Note: getHTTPBody must be called before this.
326 * @return string the HTTP content type for the current request.
329 function getHTTPContentType() {
330 if (count($this->requestAttachments) > 0) {
331 return $this->mimeContentType;
333 return parent::getHTTPContentType();
337 * gets the HTTP content type charset for the current request.
338 * returns false for non-text content types.
340 * Note: getHTTPBody must be called before this.
342 * @return string the HTTP content type charset for the current request.
345 function getHTTPContentTypeCharset() {
346 if (count($this->requestAttachments) > 0) {
349 return parent::getHTTPContentTypeCharset();
353 * processes SOAP message returned from server
355 * @param array $headers The HTTP headers
356 * @param string $data unprocessed response data from server
357 * @return mixed value of the message, decoded into a PHP type
360 function parseResponse($headers, $data) {
361 $this->debug('Entering parseResponse() for payload of length ' . strlen($data) . ' and type of ' . $headers['content-type']);
362 $this->responseAttachments = array();
363 if (strstr($headers['content-type'], 'multipart/related')) {
364 $this->debug('Decode multipart/related');
366 foreach ($headers as $k => $v) {
367 $input .= "$k: $v\r\n";
369 $params['input'] = $input . "\r\n" . $data;
370 $params['include_bodies'] = true;
371 $params['decode_bodies'] = true;
372 $params['decode_headers'] = true;
374 $structure = Mail_mimeDecode::decode($params);
376 foreach ($structure->parts as $part) {
377 if (!isset($part->disposition)) {
378 $this->debug('Have root part of type ' . $part->headers['content-type']);
379 $return = parent::parseResponse($part->headers, $part->body);
381 $this->debug('Have an attachment of type ' . $part->headers['content-type']);
382 $info['data'] = $part->body;
383 $info['filename'] = isset($part->d_parameters['filename']) ? $part->d_parameters['filename'] : '';
384 $info['contenttype'] = $part->headers['content-type'];
385 $info['cid'] = $part->headers['content-id'];
386 $this->responseAttachments[] = $info;
390 if (isset($return)) {
394 $this->setError('No root part found in multipart/related content');
397 $this->debug('Not multipart/related');
398 return parent::parseResponse($headers, $data);
403 * nusoapservermime server supporting MIME attachments defined at
404 * http://www.w3.org/TR/SOAP-attachments. It depends on the PEAR Mail_MIME library.
406 * @author Scott Nichol <snichol@sourceforge.net>
407 * @author Thanks to Guillaume and Henning Reich for posting great attachment code to the mail list
411 class nusoapservermime extends soap_server {
413 * @var array Each array element in the return is an associative array with keys
414 * data, filename, contenttype, cid
417 var $requestAttachments = array();
419 * @var array Each array element in the return is an associative array with keys
420 * data, filename, contenttype, cid
423 var $responseAttachments;
428 var $mimeContentType;
431 * adds a MIME attachment to the current response.
433 * If the $data parameter contains an empty string, this method will read
434 * the contents of the file named by the $filename parameter.
436 * If the $cid parameter is false, this method will generate the cid.
438 * @param string $data The data of the attachment
439 * @param string $filename The filename of the attachment (default is empty string)
440 * @param string $contenttype The MIME Content-Type of the attachment (default is application/octet-stream)
441 * @param string $cid The content-id (cid) of the attachment (default is false)
442 * @return string The content-id (cid) of the attachment
445 function addAttachment($data, $filename = '', $contenttype = 'application/octet-stream', $cid = false) {
447 $cid = md5(uniqid(time()));
450 $info['data'] = $data;
451 $info['filename'] = $filename;
452 $info['contenttype'] = $contenttype;
455 $this->responseAttachments[] = $info;
461 * clears the MIME attachments for the current response.
465 function clearAttachments() {
466 $this->responseAttachments = array();
470 * gets the MIME attachments from the current request.
472 * Each array element in the return is an associative array with keys
473 * data, filename, contenttype, cid. These keys correspond to the parameters
476 * @return array The attachments.
479 function getAttachments() {
480 return $this->requestAttachments;
484 * gets the HTTP body for the current response.
486 * @param string $soapmsg The SOAP payload
487 * @return string The HTTP body, which includes the SOAP payload
490 function getHTTPBody($soapmsg) {
491 if (count($this->responseAttachments) > 0) {
492 $params['content_type'] = 'multipart/related; type=text/xml';
493 $mimeMessage = new Mail_mimePart('', $params);
496 $params['content_type'] = 'text/xml';
497 $params['encoding'] = '8bit';
498 $params['charset'] = $this->soap_defencoding;
499 $mimeMessage->addSubpart($soapmsg, $params);
501 foreach ($this->responseAttachments as $att) {
504 $params['content_type'] = $att['contenttype'];
505 $params['encoding'] = 'base64';
506 $params['disposition'] = 'attachment';
507 $params['dfilename'] = $att['filename'];
508 $params['cid'] = $att['cid'];
510 if ($att['data'] == '' && $att['filename'] <> '') {
511 if ($fd = fopen($att['filename'], 'rb')) {
512 $data = fread($fd, filesize($att['filename']));
517 $mimeMessage->addSubpart($data, $params);
519 $mimeMessage->addSubpart($att['data'], $params);
523 $output = $mimeMessage->encode();
524 $mimeHeaders = $output['headers'];
526 foreach ($mimeHeaders as $k => $v) {
527 $this->debug("MIME header $k: $v");
528 if (strtolower($k) == 'content-type') {
529 // PHP header() seems to strip leading whitespace starting
530 // the second line, so force everything to one line
531 $this->mimeContentType = str_replace("\r\n", " ", $v);
535 return $output['body'];
538 return parent::getHTTPBody($soapmsg);
542 * gets the HTTP content type for the current response.
544 * Note: getHTTPBody must be called before this.
546 * @return string the HTTP content type for the current response.
549 function getHTTPContentType() {
550 if (count($this->responseAttachments) > 0) {
551 return $this->mimeContentType;
553 return parent::getHTTPContentType();
557 * gets the HTTP content type charset for the current response.
558 * returns false for non-text content types.
560 * Note: getHTTPBody must be called before this.
562 * @return string the HTTP content type charset for the current response.
565 function getHTTPContentTypeCharset() {
566 if (count($this->responseAttachments) > 0) {
569 return parent::getHTTPContentTypeCharset();
573 * processes SOAP message received from client
575 * @param array $headers The HTTP headers
576 * @param string $data unprocessed request data from client
577 * @return mixed value of the message, decoded into a PHP type
580 function parseRequest($headers, $data) {
581 $this->debug('Entering parseRequest() for payload of length ' . strlen($data) . ' and type of ' . $headers['content-type']);
582 $this->requestAttachments = array();
583 if (strstr($headers['content-type'], 'multipart/related')) {
584 $this->debug('Decode multipart/related');
586 foreach ($headers as $k => $v) {
587 $input .= "$k: $v\r\n";
589 $params['input'] = $input . "\r\n" . $data;
590 $params['include_bodies'] = true;
591 $params['decode_bodies'] = true;
592 $params['decode_headers'] = true;
594 $structure = Mail_mimeDecode::decode($params);
596 foreach ($structure->parts as $part) {
597 if (!isset($part->disposition)) {
598 $this->debug('Have root part of type ' . $part->headers['content-type']);
599 $return = parent::parseRequest($part->headers, $part->body);
601 $this->debug('Have an attachment of type ' . $part->headers['content-type']);
602 $info['data'] = $part->body;
603 $info['filename'] = isset($part->d_parameters['filename']) ? $part->d_parameters['filename'] : '';
604 $info['contenttype'] = $part->headers['content-type'];
605 $info['cid'] = $part->headers['content-id'];
606 $this->requestAttachments[] = $info;
610 if (isset($return)) {
614 $this->setError('No root part found in multipart/related content');
617 $this->debug('Not multipart/related');
618 return parent::parseRequest($headers, $data);