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 $data = file_get_contents($att['filename']);
292 $mimeMessage->addSubpart($data, $params);
294 $mimeMessage->addSubpart($att['data'], $params);
298 $output = $mimeMessage->encode();
299 $mimeHeaders = $output['headers'];
301 foreach ($mimeHeaders as $k => $v) {
302 $this->debug("MIME header $k: $v");
303 if (strtolower($k) == 'content-type') {
304 // PHP header() seems to strip leading whitespace starting
305 // the second line, so force everything to one line
306 $this->mimeContentType = str_replace("\r\n", " ", $v);
310 return $output['body'];
313 return parent::getHTTPBody($soapmsg);
317 * gets the HTTP content type for the current request.
319 * Note: getHTTPBody must be called before this.
321 * @return string the HTTP content type for the current request.
324 function getHTTPContentType() {
325 if (count($this->requestAttachments) > 0) {
326 return $this->mimeContentType;
328 return parent::getHTTPContentType();
332 * gets the HTTP content type charset for the current request.
333 * returns false for non-text content types.
335 * Note: getHTTPBody must be called before this.
337 * @return string the HTTP content type charset for the current request.
340 function getHTTPContentTypeCharset() {
341 if (count($this->requestAttachments) > 0) {
344 return parent::getHTTPContentTypeCharset();
348 * processes SOAP message returned from server
350 * @param array $headers The HTTP headers
351 * @param string $data unprocessed response data from server
352 * @return mixed value of the message, decoded into a PHP type
355 function parseResponse($headers, $data) {
356 $this->debug('Entering parseResponse() for payload of length ' . strlen($data) . ' and type of ' . $headers['content-type']);
357 $this->responseAttachments = array();
358 if (strstr($headers['content-type'], 'multipart/related')) {
359 $this->debug('Decode multipart/related');
361 foreach ($headers as $k => $v) {
362 $input .= "$k: $v\r\n";
364 $params['input'] = $input . "\r\n" . $data;
365 $params['include_bodies'] = true;
366 $params['decode_bodies'] = true;
367 $params['decode_headers'] = true;
369 $structure = Mail_mimeDecode::decode($params);
371 foreach ($structure->parts as $part) {
372 if (!isset($part->disposition)) {
373 $this->debug('Have root part of type ' . $part->headers['content-type']);
374 $return = parent::parseResponse($part->headers, $part->body);
376 $this->debug('Have an attachment of type ' . $part->headers['content-type']);
377 $info['data'] = $part->body;
378 $info['filename'] = isset($part->d_parameters['filename']) ? $part->d_parameters['filename'] : '';
379 $info['contenttype'] = $part->headers['content-type'];
380 $info['cid'] = $part->headers['content-id'];
381 $this->responseAttachments[] = $info;
385 if (isset($return)) {
389 $this->setError('No root part found in multipart/related content');
392 $this->debug('Not multipart/related');
393 return parent::parseResponse($headers, $data);
398 * nusoapservermime server supporting MIME attachments defined at
399 * http://www.w3.org/TR/SOAP-attachments. It depends on the PEAR Mail_MIME library.
401 * @author Scott Nichol <snichol@sourceforge.net>
402 * @author Thanks to Guillaume and Henning Reich for posting great attachment code to the mail list
406 class nusoapservermime extends soap_server {
408 * @var array Each array element in the return is an associative array with keys
409 * data, filename, contenttype, cid
412 var $requestAttachments = array();
414 * @var array Each array element in the return is an associative array with keys
415 * data, filename, contenttype, cid
418 var $responseAttachments;
423 var $mimeContentType;
426 * adds a MIME attachment to the current response.
428 * If the $data parameter contains an empty string, this method will read
429 * the contents of the file named by the $filename parameter.
431 * If the $cid parameter is false, this method will generate the cid.
433 * @param string $data The data of the attachment
434 * @param string $filename The filename of the attachment (default is empty string)
435 * @param string $contenttype The MIME Content-Type of the attachment (default is application/octet-stream)
436 * @param string $cid The content-id (cid) of the attachment (default is false)
437 * @return string The content-id (cid) of the attachment
440 function addAttachment($data, $filename = '', $contenttype = 'application/octet-stream', $cid = false) {
442 $cid = md5(uniqid(time()));
445 $info['data'] = $data;
446 $info['filename'] = $filename;
447 $info['contenttype'] = $contenttype;
450 $this->responseAttachments[] = $info;
456 * clears the MIME attachments for the current response.
460 function clearAttachments() {
461 $this->responseAttachments = array();
465 * gets the MIME attachments from the current request.
467 * Each array element in the return is an associative array with keys
468 * data, filename, contenttype, cid. These keys correspond to the parameters
471 * @return array The attachments.
474 function getAttachments() {
475 return $this->requestAttachments;
479 * gets the HTTP body for the current response.
481 * @param string $soapmsg The SOAP payload
482 * @return string The HTTP body, which includes the SOAP payload
485 function getHTTPBody($soapmsg) {
486 if (count($this->responseAttachments) > 0) {
487 $params['content_type'] = 'multipart/related; type=text/xml';
488 $mimeMessage = new Mail_mimePart('', $params);
491 $params['content_type'] = 'text/xml';
492 $params['encoding'] = '8bit';
493 $params['charset'] = $this->soap_defencoding;
494 $mimeMessage->addSubpart($soapmsg, $params);
496 foreach ($this->responseAttachments as $att) {
499 $params['content_type'] = $att['contenttype'];
500 $params['encoding'] = 'base64';
501 $params['disposition'] = 'attachment';
502 $params['dfilename'] = $att['filename'];
503 $params['cid'] = $att['cid'];
505 if ($att['data'] == '' && $att['filename'] <> '') {
506 $data = file_get_contents($att['filename']);
507 $mimeMessage->addSubpart($data, $params);
509 $mimeMessage->addSubpart($att['data'], $params);
513 $output = $mimeMessage->encode();
514 $mimeHeaders = $output['headers'];
516 foreach ($mimeHeaders as $k => $v) {
517 $this->debug("MIME header $k: $v");
518 if (strtolower($k) == 'content-type') {
519 // PHP header() seems to strip leading whitespace starting
520 // the second line, so force everything to one line
521 $this->mimeContentType = str_replace("\r\n", " ", $v);
525 return $output['body'];
528 return parent::getHTTPBody($soapmsg);
532 * gets the HTTP content type for the current response.
534 * Note: getHTTPBody must be called before this.
536 * @return string the HTTP content type for the current response.
539 function getHTTPContentType() {
540 if (count($this->responseAttachments) > 0) {
541 return $this->mimeContentType;
543 return parent::getHTTPContentType();
547 * gets the HTTP content type charset for the current response.
548 * returns false for non-text content types.
550 * Note: getHTTPBody must be called before this.
552 * @return string the HTTP content type charset for the current response.
555 function getHTTPContentTypeCharset() {
556 if (count($this->responseAttachments) > 0) {
559 return parent::getHTTPContentTypeCharset();
563 * processes SOAP message received from client
565 * @param array $headers The HTTP headers
566 * @param string $data unprocessed request data from client
567 * @return mixed value of the message, decoded into a PHP type
570 function parseRequest($headers, $data) {
571 $this->debug('Entering parseRequest() for payload of length ' . strlen($data) . ' and type of ' . $headers['content-type']);
572 $this->requestAttachments = array();
573 if (strstr($headers['content-type'], 'multipart/related')) {
574 $this->debug('Decode multipart/related');
576 foreach ($headers as $k => $v) {
577 $input .= "$k: $v\r\n";
579 $params['input'] = $input . "\r\n" . $data;
580 $params['include_bodies'] = true;
581 $params['decode_bodies'] = true;
582 $params['decode_headers'] = true;
584 $structure = Mail_mimeDecode::decode($params);
586 foreach ($structure->parts as $part) {
587 if (!isset($part->disposition)) {
588 $this->debug('Have root part of type ' . $part->headers['content-type']);
589 $return = parent::parseRequest($part->headers, $part->body);
591 $this->debug('Have an attachment of type ' . $part->headers['content-type']);
592 $info['data'] = $part->body;
593 $info['filename'] = isset($part->d_parameters['filename']) ? $part->d_parameters['filename'] : '';
594 $info['contenttype'] = $part->headers['content-type'];
595 $info['cid'] = $part->headers['content-id'];
596 $this->requestAttachments[] = $info;
600 if (isset($return)) {
604 $this->setError('No root part found in multipart/related content');
607 $this->debug('Not multipart/related');
608 return parent::parseRequest($headers, $data);