PageRenderTime 65ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 2ms

/include/nusoap/nusoap.php

https://bitbucket.org/cviolette/sugarcrm
PHP | 10058 lines | 7499 code | 227 blank | 2332 comment | 804 complexity | 08f16a90957ec98acd49a1a5a43458dc MD5 | raw file
Possible License(s): LGPL-2.1, MPL-2.0-no-copyleft-exception, BSD-3-Clause

Large files files are truncated, but you can click here to view the full file

  1. <?php
  2. /*
  3. Modification information for LGPL compliance
  4. commit af784931b8ab2263776badac5ac3fc4776c9cd61
  5. Author: Stanislav Malyshev <smalyshev@gmail.com>
  6. Date: Thu Feb 17 18:09:12 2011 -0800
  7. bug 34897 - remove characters that aren't valid in XML
  8. commit 1767411d701b8216cc5e043888fd1337e2eca315
  9. Author: Stanislav Malyshev <smalyshev@gmail.com>
  10. Date: Fri Jan 7 12:19:10 2011 -0800
  11. conserve memory when no debug is enabled
  12. commit 843510ebf455368865302a05b9d5041815a32c23
  13. Author: John Mertic <jmertic@sugarcrm.com>
  14. Date: Wed Nov 17 13:18:09 2010 -0500
  15. Bug 40716 - Fix WSDL validation problem by removing hardcoded schemaLocation attribute for the <xsd:import> tag.
  16. commit 2bd12c02078f3e291bd9c1e76179a144c788ce97
  17. Author: Collin Lee <clee@Collin-Lee-MacBook-Pro.local>
  18. Date: Fri Oct 22 16:37:42 2010 -0400
  19. Bug: 39937
  20. We traced the error to a combination of the new Hoovers' WSDL + the nusoapclient code that winds up improperly encoding the parameter elem
  21. ents (this is because the namespace specified for the soap call did not match that declared in the WSDL). Made changes to nusoap.php so that w
  22. e may manually set a payload XML portion that will not apply the namespace encoding to the parameters. Fixed unit tests to reflect the changes
  23. and also re-enabled those for Hoovers that were marked skipped.
  24. r58622 - 2010-10-22 18:18:59 -0700 (Fri, 22 Oct 2010) - engsvnbuild - Author: lam <lam@198.18.142.201>
  25. bug 40066
  26. r58361 - 2010-09-29 16:59:02 -0700 (Wed, 29 Sep 2010) - kjing - Author: Jenny Gonsalves <jenny@sugarcrm.com>
  27. Merging with maint_6_0_1 (svn merge -r 58250:58342)
  28. r57813 - 2010-08-19 10:34:44 -0700 (Thu, 19 Aug 2010) - kjing - Author: John Mertic <jmertic@sugarcrm.com>
  29. Bug 39085 - When loading the opposite search panel via ajax on the ListViews, call the index action instead of the ListView action to avoid touching pre-MVC code by accident.
  30. r57707 - 2010-08-10 12:26:13 -0700 (Tue, 10 Aug 2010) - kjing - Author: Stanislav Malyshev <smalyshev@gmail.com>
  31. fix SOAP calls with no parameters
  32. r56990 - 2010-06-16 13:05:36 -0700 (Wed, 16 Jun 2010) - kjing - snapshot "Mango" svn branch to a new one for GitHub sync
  33. r56989 - 2010-06-16 13:01:33 -0700 (Wed, 16 Jun 2010) - kjing - defunt "Mango" svn dev branch before github cutover
  34. r55980 - 2010-04-19 13:31:28 -0700 (Mon, 19 Apr 2010) - kjing - create Mango (6.1) based on windex
  35. r51719 - 2009-10-22 10:18:00 -0700 (Thu, 22 Oct 2009) - mitani - Converted to Build 3 tags and updated the build system
  36. r51634 - 2009-10-19 13:32:22 -0700 (Mon, 19 Oct 2009) - mitani - Windex is the branch for Sugar Sales 1.0 development
  37. r51508 - 2009-10-14 07:40:23 -0700 (Wed, 14 Oct 2009) - jmertic - More fallout fixes from the PHP 5.3 ereg to preg changes.
  38. r51455 - 2009-10-13 07:56:48 -0700 (Tue, 13 Oct 2009) - jmertic - Bug 33202 - Enable install of SugarCRM on PHP 5.3.0, asserting that the minimum supported version is PHP 5.2.x.
  39. r51443 - 2009-10-12 13:34:36 -0700 (Mon, 12 Oct 2009) - jmertic - Bug 33332 - Made application PHP 5.3 compliant with E_DEPRECATED warnings on by:
  40. - Changing all ereg function to either preg or simple string based ones
  41. - No more references to magic quotes.
  42. - Change all the session_unregister() functions to just unset() the correct session variable instead.
  43. r50375 - 2009-08-24 18:07:43 -0700 (Mon, 24 Aug 2009) - dwong - branch kobe2 from tokyo r50372
  44. r45763 - 2009-04-01 12:16:18 -0700 (Wed, 01 Apr 2009) - majed - Removed half of the require_once and include_onces in the product that were redundant or could be handled easily by the auto loader
  45. r45680 - 2009-03-30 14:34:35 -0700 (Mon, 30 Mar 2009) - Samir Gandhi - modifeid serializeSchema to generate WS-I compliant WSDL
  46. r42807 - 2008-12-29 11:16:59 -0800 (Mon, 29 Dec 2008) - dwong - Branch from trunk/sugarcrm r42806 to branches/tokyo/sugarcrm
  47. r42645 - 2008-12-18 13:41:08 -0800 (Thu, 18 Dec 2008) - awu - merging maint_5_2_0 rev41336:HEAD to trunk
  48. r41647 - 2008-11-11 17:44:30 -0800 (Tue, 11 Nov 2008) - majed - Fixes a few bugs
  49. r41596 - 2008-11-10 19:20:04 -0800 (Mon, 10 Nov 2008) - Samir Gandhi - modified to set $method in the code
  50. r41558 - 2008-11-10 14:35:34 -0800 (Mon, 10 Nov 2008) - majed - changes nusoap to allow for registering classes
  51. 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.
  52. Touched:
  53. - data/SugarBean.php
  54. - include/domit/php_http_client_generic.php
  55. - include/domit/php_http_connector.php
  56. - include/domit/testing_domit.php
  57. - include/domit/xml_domit_getelementsbypath.php
  58. - include/domit/xml_domit_lite_parser.php
  59. - include/domit/xml_domit_nodemaps.php
  60. - include/domit/xml_domit_parser.php
  61. - include/domit/xml_domit_shared.php
  62. - include/generic/SugarWidgets/SugarWidgetField.php
  63. - include/generic/SugarWidgets/SugarWidgetReportField.php
  64. - include/ListView/ProcessView.php
  65. - include/nusoap/class.soapclient.php
  66. - include/nusoap/nusoap.php
  67. - include/nusoap/nusoapmime.php
  68. - include/Pear/HTML_Safe/Safe.php
  69. - include/Pear/XML_HTMLSax3/HTMLSax3.php
  70. - modules/Administration/RebuildWorkFlow.php
  71. - modules/Expressions/RelateSelector.php
  72. - modules/Reports/templates/templates_reports.php
  73. - modules/WorkFlow/Delete.php
  74. - modules/WorkFlow/Save.php
  75. - modules/WorkFlow/SaveSequence.php
  76. - modules/WorkFlow/WorkFlow.php
  77. - modules/WorkFlowActionShells/CreateStep1.php
  78. - modules/WorkFlowActionShells/CreateStep2.php
  79. - modules/WorkFlowActionShells/Save.php
  80. - modules/WorkFlowActionShells/WorkFlowActionShell.php
  81. - modules/WorkFlowAlerts/Save.php
  82. - modules/WorkFlowAlerts/WorkFlowAlert.php
  83. - modules/WorkFlowAlertShells/DetailView.php
  84. - modules/WorkFlowAlertShells/WorkFlowAlertShell.php
  85. - modules/WorkFlowTriggerShells/CreateStep1.php
  86. - modules/WorkFlowTriggerShells/CreateStepFilter.php
  87. - modules/WorkFlowTriggerShells/SaveFilter.php
  88. - modules/WorkFlowTriggerShells/WorkFlowTriggerShell.php
  89. - soap/SoapHelperFunctions.php
  90. - test/modules/DynamicFields/DynamicFields_Bug24095_test.php
  91. - test/simpletest/browser.php
  92. - test/simpletest/default_reporter.php
  93. - test/simpletest/detached.php
  94. - test/simpletest/eclipse.php
  95. - test/simpletest/expectation.php
  96. - test/simpletest/extensions/pear_test_case.php
  97. - test/simpletest/form.php
  98. - test/simpletest/http.php
  99. - test/simpletest/mock_objects.php
  100. - test/simpletest/page.php
  101. - test/simpletest/parser.php
  102. - test/simpletest/remote.php
  103. - test/simpletest/shell_tester.php
  104. - test/simpletest/simple_test.php
  105. - test/simpletest/simpletest.php
  106. - test/simpletest/test/acceptance_test.php
  107. - test/simpletest/test/adapter_test.php
  108. - test/simpletest/test/authentication_test.php
  109. - test/simpletest/test/browser_test.php
  110. - test/simpletest/test/collector_test.php
  111. - test/simpletest/test/compatibility_test.php
  112. - test/simpletest/test/detached_test.php
  113. - test/simpletest/test/eclipse_test.php
  114. - test/simpletest/test/encoding_test.php
  115. - test/simpletest/test/errors_test.php
  116. - test/simpletest/test/expectation_test.php
  117. - test/simpletest/test/form_test.php
  118. - test/simpletest/test/frames_test.php
  119. - test/simpletest/test/http_test.php
  120. - test/simpletest/test/live_test.php
  121. - test/simpletest/test/mock_objects_test.php
  122. - test/simpletest/test/page_test.php
  123. - test/simpletest/test/parse_error_test.php
  124. - test/simpletest/test/parser_test.php
  125. - test/simpletest/test/remote_test.php
  126. - test/simpletest/test/shell_test.php
  127. - test/simpletest/test/shell_tester_test.php
  128. - test/simpletest/test/simpletest_test.php
  129. - test/simpletest/test/site/page_request.php
  130. - test/simpletest/test/tag_test.php
  131. - test/simpletest/test/unit_tester_test.php
  132. - test/simpletest/test/user_agent_test.php
  133. - test/simpletest/test/visual_test.php
  134. - test/simpletest/test/xml_test.php
  135. - test/simpletest/test_case.php
  136. - test/simpletest/ui/array_reporter/test.php
  137. - test/simpletest/ui/recorder/test.php
  138. - test/simpletest/unit_tester.php
  139. - test/simpletest/url.php
  140. - test/simpletest/user_agent.php
  141. - test/simpletest/web_tester.php
  142. - test/spikephpcoverage/src/PEAR.php
  143. - test/spikephpcoverage/src/util/Utility.php
  144. - test/spikephpcoverage/src/XML/Parser.php
  145. - test/spikephpcoverage/src/XML/Parser/Simple.php
  146. - test/test_utilities/SugarTest_SimpleBrowser.php
  147. r38362 - 2008-07-28 14:06:59 -0700 (Mon, 28 Jul 2008) - roger - bug: 23897. Using print_r when using the debug statement in nusoap will print out the statements to the screen if the call is coming from the UI.
  148. r38300 - 2008-07-25 13:33:43 -0700 (Fri, 25 Jul 2008) - Samir Gandhi - put the debug in parseresponse function
  149. r38293 - 2008-07-25 12:32:34 -0700 (Fri, 25 Jul 2008) - Samir Gandhi - to put all the debug statements return value in the call function
  150. r36824 - 2008-06-18 09:26:11 -0700 (Wed, 18 Jun 2008) - roger - bug: 21832
  151. r26422 - 2007-09-05 17:29:12 -0700 (Wed, 05 Sep 2007) - majed - migrate from beta 1 to trunk
  152. r15787 - 2006-08-10 10:14:41 -0700 (Thu, 10 Aug 2006) - roger - RRS: bug 7961
  153. r14701 - 2006-07-17 13:37:26 -0700 (Mon, 17 Jul 2006) - roger - RRS: bug 5801
  154. r13782 - 2006-06-06 10:58:55 -0700 (Tue, 06 Jun 2006) - majed - changes entry point code
  155. r11466 - 2006-02-01 15:49:47 -0800 (Wed, 01 Feb 2006) - jacob - Adding extra !empty check to get around a PHP warning.
  156. r11115 - 2006-01-17 14:54:45 -0800 (Tue, 17 Jan 2006) - majed - add entry point validation
  157. r10585 - 2005-12-13 14:42:26 -0800 (Tue, 13 Dec 2005) - majed - adds new license mechanisim
  158. r10170 - 2005-12-05 18:37:46 -0800 (Mon, 05 Dec 2005) - majed - fixes various issues
  159. r8999 - 2005-11-04 05:26:49 -0800 (Fri, 04 Nov 2005) - roger - When nusoap was upgraded we had an issue with the user's default language not being populated during a soap request. I determined the reason this was happening and have checked in the corresponding change to nusoap.
  160. r8991 - 2005-11-03 19:07:25 -0800 (Thu, 03 Nov 2005) - majed - fixes nusoap issue
  161. r8846 - 2005-10-31 11:01:12 -0800 (Mon, 31 Oct 2005) - majed - new version of nusoap
  162. r7905 - 2005-09-21 19:12:57 -0700 (Wed, 21 Sep 2005) - majed - restores old nusoap pre & with a few fixes
  163. r7861 - 2005-09-20 15:40:25 -0700 (Tue, 20 Sep 2005) - majed - & fix for 3.5.1
  164. r7452 - 2005-08-17 11:32:34 -0700 (Wed, 17 Aug 2005) - majed - changes soap to nusoap
  165. r5820 - 2005-06-21 14:22:24 -0700 (Tue, 21 Jun 2005) - majed - fixes issues with nusoap and with custom fields
  166. r5462 - 2005-05-25 13:50:11 -0700 (Wed, 25 May 2005) - majed - upgraded nusoap to .6.9
  167. r5104 - 2005-05-04 15:33:41 -0700 (Wed, 04 May 2005) - majed - gets rid of HTTP_GET_VARS and what not which has been deprecated
  168. r573 - 2004-09-04 13:03:32 -0700 (Sat, 04 Sep 2004) - sugarclint - undoing copyrights added in inadvertantly. --clint
  169. r546 - 2004-09-03 11:49:38 -0700 (Fri, 03 Sep 2004) - sugarmsi - removed echo count
  170. r354 - 2004-08-02 23:00:37 -0700 (Mon, 02 Aug 2004) - sugarjacob - Adding Soap
  171. */
  172. if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
  173. /*
  174. $Id: nusoap.php 58622 2010-10-23 01:18:59Z engsvnbuild $
  175. NuSOAP - Web Services Toolkit for PHP
  176. Copyright (c) 2002 NuSphere Corporation
  177. This library is free software; you can redistribute it and/or
  178. modify it under the terms of the GNU Lesser General Public
  179. License as published by the Free Software Foundation; either
  180. version 2.1 of the License, or (at your option) any later version.
  181. n
  182. This library is distributed in the hope that it will be useful,
  183. but WITHOUT ANY WARRANTY; without even the implied warranty of
  184. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  185. Lesser General Public License for more details.
  186. You should have received a copy of the GNU Lesser General Public
  187. License along with this library; if not, write to the Free Software
  188. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  189. The NuSOAP project home is:
  190. http://sourceforge.net/projects/nusoap/
  191. The primary support for NuSOAP is the Help forum on the project home page.
  192. If you have any questions or comments, please email:
  193. Dietrich Ayala
  194. dietrich@ganx4.com
  195. http://dietrich.ganx4.com/nusoap
  196. NuSphere Corporation
  197. http://www.nusphere.com
  198. */
  199. /*
  200. * Some of the standards implmented in whole or part by NuSOAP:
  201. *
  202. * SOAP 1.1 (http://www.w3.org/TR/2000/NOTE-SOAP-20000508/)
  203. * WSDL 1.1 (http://www.w3.org/TR/2001/NOTE-wsdl-20010315)
  204. * SOAP Messages With Attachments (http://www.w3.org/TR/SOAP-attachments)
  205. * XML 1.0 (http://www.w3.org/TR/2006/REC-xml-20060816/)
  206. * Namespaces in XML 1.0 (http://www.w3.org/TR/2006/REC-xml-names-20060816/)
  207. * XML Schema 1.0 (http://www.w3.org/TR/xmlschema-0/)
  208. * RFC 2045 Multipurpose Internet Mail Extensions (MIME) Part One: Format of Internet Message Bodies
  209. * RFC 2068 Hypertext Transfer Protocol -- HTTP/1.1
  210. * RFC 2617 HTTP Authentication: Basic and Digest Access Authentication
  211. */
  212. /* load classes
  213. // necessary classes
  214. require_once('class.soapclient.php');
  215. require_once('class.soap_val.php');
  216. require_once('class.soap_parser.php');
  217. require_once('class.soap_fault.php');
  218. // transport classes
  219. require_once('class.soap_transport_http.php');
  220. // optional add-on classes
  221. require_once('class.xmlschema.php');
  222. require_once('class.wsdl.php');
  223. // server class
  224. require_once('class.soap_server.php');*/
  225. // class variable emulation
  226. // cf. http://www.webkreator.com/php/techniques/php-static-class-variables.html
  227. $GLOBALS['_transient']['static']['nusoap_base']['globalDebugLevel'] = 0;
  228. /**
  229. *
  230. * nusoap_base
  231. *
  232. * @author Dietrich Ayala <dietrich@ganx4.com>
  233. * @author Scott Nichol <snichol@users.sourceforge.net>
  234. * @access public
  235. */
  236. class nusoap_base {
  237. /**
  238. * Identification for HTTP headers.
  239. *
  240. * @var string
  241. * @access private
  242. */
  243. var $title = 'NuSOAP';
  244. /**
  245. * Version for HTTP headers.
  246. *
  247. * @var string
  248. * @access private
  249. */
  250. var $version = '0.9.5';
  251. /**
  252. * CVS revision for HTTP headers.
  253. *
  254. * @var string
  255. * @access private
  256. */
  257. var $revision = '$Revision: 58622 $';
  258. /**
  259. * Current error string (manipulated by getError/setError)
  260. *
  261. * @var string
  262. * @access private
  263. */
  264. var $error_str = '';
  265. /**
  266. * Current debug string (manipulated by debug/appendDebug/clearDebug/getDebug/getDebugAsXMLComment)
  267. *
  268. * @var string
  269. * @access private
  270. */
  271. var $debug_str = '';
  272. /**
  273. * toggles automatic encoding of special characters as entities
  274. * (should always be true, I think)
  275. *
  276. * @var boolean
  277. * @access private
  278. */
  279. var $charencoding = true;
  280. /**
  281. * the debug level for this instance
  282. *
  283. * @var integer
  284. * @access private
  285. */
  286. var $debugLevel;
  287. /**
  288. * set schema version
  289. *
  290. * @var string
  291. * @access public
  292. */
  293. var $XMLSchemaVersion = 'http://www.w3.org/2001/XMLSchema';
  294. /**
  295. * charset encoding for outgoing messages
  296. *
  297. * @var string
  298. * @access public
  299. */
  300. //var $soap_defencoding = 'ISO-8859-1';
  301. var $soap_defencoding = 'UTF-8';
  302. /**
  303. * namespaces in an array of prefix => uri
  304. *
  305. * this is "seeded" by a set of constants, but it may be altered by code
  306. *
  307. * @var array
  308. * @access public
  309. */
  310. var $namespaces = array(
  311. 'SOAP-ENV' => 'http://schemas.xmlsoap.org/soap/envelope/',
  312. 'xsd' => 'http://www.w3.org/2001/XMLSchema',
  313. 'xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
  314. 'SOAP-ENC' => 'http://schemas.xmlsoap.org/soap/encoding/'
  315. );
  316. /**
  317. * namespaces used in the current context, e.g. during serialization
  318. *
  319. * @var array
  320. * @access private
  321. */
  322. var $usedNamespaces = array();
  323. /**
  324. * XML Schema types in an array of uri => (array of xml type => php type)
  325. * is this legacy yet?
  326. * no, this is used by the nusoap_xmlschema class to verify type => namespace mappings.
  327. * @var array
  328. * @access public
  329. */
  330. var $typemap = array(
  331. 'http://www.w3.org/2001/XMLSchema' => array(
  332. 'string'=>'string','boolean'=>'boolean','float'=>'double','double'=>'double','decimal'=>'double',
  333. 'duration'=>'','dateTime'=>'string','time'=>'string','date'=>'string','gYearMonth'=>'',
  334. 'gYear'=>'','gMonthDay'=>'','gDay'=>'','gMonth'=>'','hexBinary'=>'string','base64Binary'=>'string',
  335. // abstract "any" types
  336. 'anyType'=>'string','anySimpleType'=>'string',
  337. // derived datatypes
  338. 'normalizedString'=>'string','token'=>'string','language'=>'','NMTOKEN'=>'','NMTOKENS'=>'','Name'=>'','NCName'=>'','ID'=>'',
  339. 'IDREF'=>'','IDREFS'=>'','ENTITY'=>'','ENTITIES'=>'','integer'=>'integer','nonPositiveInteger'=>'integer',
  340. 'negativeInteger'=>'integer','long'=>'integer','int'=>'integer','short'=>'integer','byte'=>'integer','nonNegativeInteger'=>'integer',
  341. 'unsignedLong'=>'','unsignedInt'=>'','unsignedShort'=>'','unsignedByte'=>'','positiveInteger'=>''),
  342. 'http://www.w3.org/2000/10/XMLSchema' => array(
  343. 'i4'=>'','int'=>'integer','boolean'=>'boolean','string'=>'string','double'=>'double',
  344. 'float'=>'double','dateTime'=>'string',
  345. 'timeInstant'=>'string','base64Binary'=>'string','base64'=>'string','ur-type'=>'array'),
  346. 'http://www.w3.org/1999/XMLSchema' => array(
  347. 'i4'=>'','int'=>'integer','boolean'=>'boolean','string'=>'string','double'=>'double',
  348. 'float'=>'double','dateTime'=>'string',
  349. 'timeInstant'=>'string','base64Binary'=>'string','base64'=>'string','ur-type'=>'array'),
  350. 'http://soapinterop.org/xsd' => array('SOAPStruct'=>'struct'),
  351. 'http://schemas.xmlsoap.org/soap/encoding/' => array('base64'=>'string','array'=>'array','Array'=>'array'),
  352. 'http://xml.apache.org/xml-soap' => array('Map')
  353. );
  354. /**
  355. * XML entities to convert
  356. *
  357. * @var array
  358. * @access public
  359. * @deprecated
  360. * @see expandEntities
  361. */
  362. var $xmlEntities = array('quot' => '"','amp' => '&',
  363. 'lt' => '<','gt' => '>','apos' => "'");
  364. /**
  365. * Payload override
  366. * This is to allows us to override the payload to resolve issues where we need to take
  367. * control of the xml content
  368. * @var string
  369. * @access public
  370. *
  371. */
  372. var $payloadOverride;
  373. /**
  374. * constructor
  375. *
  376. * @access public
  377. */
  378. function nusoap_base() {
  379. $this->debugLevel = $GLOBALS['_transient']['static']['nusoap_base']['globalDebugLevel'];
  380. }
  381. /**
  382. * gets the global debug level, which applies to future instances
  383. *
  384. * @return integer Debug level 0-9, where 0 turns off
  385. * @access public
  386. */
  387. function getGlobalDebugLevel() {
  388. return $GLOBALS['_transient']['static']['nusoap_base']['globalDebugLevel'];
  389. }
  390. /**
  391. * sets the global debug level, which applies to future instances
  392. *
  393. * @param int $level Debug level 0-9, where 0 turns off
  394. * @access public
  395. */
  396. function setGlobalDebugLevel($level) {
  397. $GLOBALS['_transient']['static']['nusoap_base']['globalDebugLevel'] = $level;
  398. }
  399. /**
  400. * gets the debug level for this instance
  401. *
  402. * @return int Debug level 0-9, where 0 turns off
  403. * @access public
  404. */
  405. function getDebugLevel() {
  406. return $this->debugLevel;
  407. }
  408. /**
  409. * sets the debug level for this instance
  410. *
  411. * @param int $level Debug level 0-9, where 0 turns off
  412. * @access public
  413. */
  414. function setDebugLevel($level) {
  415. $this->debugLevel = $level;
  416. }
  417. /**
  418. * adds debug data to the instance debug string with formatting
  419. *
  420. * @param string $string debug data
  421. * @access private
  422. */
  423. function debug($string){
  424. if ($this->debugLevel > 0) {
  425. $this->appendDebug($this->getmicrotime().' '.get_class($this).": $string\n");
  426. }
  427. }
  428. /**
  429. * adds debug data to the instance debug string without formatting
  430. *
  431. * @param string $string debug data
  432. * @access public
  433. */
  434. function appendDebug($string){
  435. if ($this->debugLevel > 0) {
  436. // it would be nice to use a memory stream here to use
  437. // memory more efficiently
  438. $this->debug_str .= $string;
  439. }
  440. }
  441. /**
  442. * clears the current debug data for this instance
  443. *
  444. * @access public
  445. */
  446. function clearDebug() {
  447. // it would be nice to use a memory stream here to use
  448. // memory more efficiently
  449. $this->debug_str = '';
  450. }
  451. /**
  452. * gets the current debug data for this instance
  453. *
  454. * @return debug data
  455. * @access public
  456. */
  457. function &getDebug() {
  458. // it would be nice to use a memory stream here to use
  459. // memory more efficiently
  460. return $this->debug_str;
  461. }
  462. /**
  463. * gets the current debug data for this instance as an XML comment
  464. * this may change the contents of the debug data
  465. *
  466. * @return debug data as an XML comment
  467. * @access public
  468. */
  469. function &getDebugAsXMLComment() {
  470. // it would be nice to use a memory stream here to use
  471. // memory more efficiently
  472. while (strpos($this->debug_str, '--')) {
  473. $this->debug_str = str_replace('--', '- -', $this->debug_str);
  474. }
  475. $ret = "<!--\n" . $this->debug_str . "\n-->";
  476. return $ret;
  477. }
  478. /**
  479. * expands entities, e.g. changes '<' to '&lt;'.
  480. *
  481. * @param string $val The string in which to expand entities.
  482. * @access private
  483. */
  484. function expandEntities($val) {
  485. if ($this->charencoding) {
  486. $val = htmlspecialchars($val, ENT_QUOTES, $this->soap_defencoding);
  487. // XML 1.0 doesn't allow those...
  488. $val = preg_replace("/([\\x00-\\x08\\x0B\\x0C\\x0E-\\x1F])/", '', $val);
  489. }
  490. return $val;
  491. }
  492. /**
  493. * returns error string if present
  494. *
  495. * @return mixed error string or false
  496. * @access public
  497. */
  498. function getError(){
  499. if($this->error_str != ''){
  500. return $this->error_str;
  501. }
  502. return false;
  503. }
  504. /**
  505. * sets error string
  506. *
  507. * @return boolean $string error string
  508. * @access private
  509. */
  510. function setError($str){
  511. $this->error_str = $str;
  512. }
  513. /**
  514. * detect if array is a simple array or a struct (associative array)
  515. *
  516. * @param mixed $val The PHP array
  517. * @return string (arraySimple|arrayStruct)
  518. * @access private
  519. */
  520. function isArraySimpleOrStruct($val) {
  521. $keyList = array_keys($val);
  522. foreach ($keyList as $keyListValue) {
  523. if (!is_int($keyListValue)) {
  524. return 'arrayStruct';
  525. }
  526. }
  527. return 'arraySimple';
  528. }
  529. /**
  530. * serializes PHP values in accordance w/ section 5. Type information is
  531. * not serialized if $use == 'literal'.
  532. *
  533. * @param mixed $val The value to serialize
  534. * @param string $name The name (local part) of the XML element
  535. * @param string $type The XML schema type (local part) for the element
  536. * @param string $name_ns The namespace for the name of the XML element
  537. * @param string $type_ns The namespace for the type of the element
  538. * @param array $attributes The attributes to serialize as name=>value pairs
  539. * @param string $use The WSDL "use" (encoded|literal)
  540. * @param boolean $soapval Whether this is called from soapval.
  541. * @return string The serialized element, possibly with child elements
  542. * @access public
  543. */
  544. function serialize_val($val,$name=false,$type=false,$name_ns=false,$type_ns=false,$attributes=false,$use='encoded',$soapval=false) {
  545. $this->debug("in serialize_val: name=$name, type=$type, name_ns=$name_ns, type_ns=$type_ns, use=$use, soapval=$soapval");
  546. $this->appendDebug('value=' . $this->varDump($val));
  547. $this->appendDebug('attributes=' . $this->varDump($attributes));
  548. if (is_object($val) && get_class($val) == 'soapval' && (! $soapval)) {
  549. $this->debug("serialize_val: serialize soapval");
  550. $xml = $val->serialize($use);
  551. $this->appendDebug($val->getDebug());
  552. $val->clearDebug();
  553. $this->debug("serialize_val of soapval returning $xml");
  554. return $xml;
  555. }
  556. // force valid name if necessary
  557. if (is_numeric($name)) {
  558. $name = '__numeric_' . $name;
  559. } elseif (! $name) {
  560. $name = 'noname';
  561. }
  562. // if name has ns, add ns prefix to name
  563. $xmlns = '';
  564. if($name_ns){
  565. $prefix = 'nu'.rand(1000,9999);
  566. $name = $prefix.':'.$name;
  567. $xmlns .= " xmlns:$prefix=\"$name_ns\"";
  568. }
  569. // if type is prefixed, create type prefix
  570. if($type_ns != '' && $type_ns == $this->namespaces['xsd']){
  571. // need to fix this. shouldn't default to xsd if no ns specified
  572. // w/o checking against typemap
  573. $type_prefix = 'xsd';
  574. } elseif($type_ns){
  575. $type_prefix = 'ns'.rand(1000,9999);
  576. $xmlns .= " xmlns:$type_prefix=\"$type_ns\"";
  577. }
  578. // serialize attributes if present
  579. $atts = '';
  580. if($attributes){
  581. foreach($attributes as $k => $v){
  582. $atts .= " $k=\"".$this->expandEntities($v).'"';
  583. }
  584. }
  585. // serialize null value
  586. if (is_null($val)) {
  587. $this->debug("serialize_val: serialize null");
  588. if ($use == 'literal') {
  589. // TODO: depends on minOccurs
  590. $xml = "<$name$xmlns$atts/>";
  591. $this->debug("serialize_val returning $xml");
  592. return $xml;
  593. } else {
  594. if (isset($type) && isset($type_prefix)) {
  595. $type_str = " xsi:type=\"$type_prefix:$type\"";
  596. } else {
  597. $type_str = '';
  598. }
  599. $xml = "<$name$xmlns$type_str$atts xsi:nil=\"true\"/>";
  600. $this->debug("serialize_val returning $xml");
  601. return $xml;
  602. }
  603. }
  604. // serialize if an xsd built-in primitive type
  605. if($type != '' && isset($this->typemap[$this->XMLSchemaVersion][$type])){
  606. $this->debug("serialize_val: serialize xsd built-in primitive type");
  607. if (is_bool($val)) {
  608. if ($type == 'boolean') {
  609. $val = $val ? 'true' : 'false';
  610. } elseif (! $val) {
  611. $val = 0;
  612. }
  613. } else if (is_string($val)) {
  614. $val = $this->expandEntities($val);
  615. }
  616. if ($use == 'literal') {
  617. $xml = "<$name$xmlns$atts>$val</$name>";
  618. $this->debug("serialize_val returning $xml");
  619. return $xml;
  620. } else {
  621. $xml = "<$name$xmlns xsi:type=\"xsd:$type\"$atts>$val</$name>";
  622. $this->debug("serialize_val returning $xml");
  623. return $xml;
  624. }
  625. }
  626. // detect type and serialize
  627. $xml = '';
  628. switch(true) {
  629. case (is_bool($val) || $type == 'boolean'):
  630. $this->debug("serialize_val: serialize boolean");
  631. if ($type == 'boolean') {
  632. $val = $val ? 'true' : 'false';
  633. } elseif (! $val) {
  634. $val = 0;
  635. }
  636. if ($use == 'literal') {
  637. $xml .= "<$name$xmlns$atts>$val</$name>";
  638. } else {
  639. $xml .= "<$name$xmlns xsi:type=\"xsd:boolean\"$atts>$val</$name>";
  640. }
  641. break;
  642. case (is_int($val) || is_long($val) || $type == 'int'):
  643. $this->debug("serialize_val: serialize int");
  644. if ($use == 'literal') {
  645. $xml .= "<$name$xmlns$atts>$val</$name>";
  646. } else {
  647. $xml .= "<$name$xmlns xsi:type=\"xsd:int\"$atts>$val</$name>";
  648. }
  649. break;
  650. case (is_float($val)|| is_double($val) || $type == 'float'):
  651. $this->debug("serialize_val: serialize float");
  652. if ($use == 'literal') {
  653. $xml .= "<$name$xmlns$atts>$val</$name>";
  654. } else {
  655. $xml .= "<$name$xmlns xsi:type=\"xsd:float\"$atts>$val</$name>";
  656. }
  657. break;
  658. case (is_string($val) || $type == 'string'):
  659. $this->debug("serialize_val: serialize string");
  660. $val = $this->expandEntities($val);
  661. if ($use == 'literal') {
  662. $xml .= "<$name$xmlns$atts>$val</$name>";
  663. } else {
  664. $xml .= "<$name$xmlns xsi:type=\"xsd:string\"$atts>$val</$name>";
  665. }
  666. break;
  667. case is_object($val):
  668. $this->debug("serialize_val: serialize object");
  669. if (get_class($val) == 'soapval') {
  670. $this->debug("serialize_val: serialize soapval object");
  671. $pXml = $val->serialize($use);
  672. $this->appendDebug($val->getDebug());
  673. $val->clearDebug();
  674. } else {
  675. if (! $name) {
  676. $name = get_class($val);
  677. $this->debug("In serialize_val, used class name $name as element name");
  678. } else {
  679. $this->debug("In serialize_val, do not override name $name for element name for class " . get_class($val));
  680. }
  681. foreach(get_object_vars($val) as $k => $v){
  682. $pXml = isset($pXml) ? $pXml.$this->serialize_val($v,$k,false,false,false,false,$use) : $this->serialize_val($v,$k,false,false,false,false,$use);
  683. }
  684. }
  685. if(isset($type) && isset($type_prefix)){
  686. $type_str = " xsi:type=\"$type_prefix:$type\"";
  687. } else {
  688. $type_str = '';
  689. }
  690. if ($use == 'literal') {
  691. $xml .= "<$name$xmlns$atts>$pXml</$name>";
  692. } else {
  693. $xml .= "<$name$xmlns$type_str$atts>$pXml</$name>";
  694. }
  695. break;
  696. break;
  697. case (is_array($val) || $type):
  698. // detect if struct or array
  699. $valueType = $this->isArraySimpleOrStruct($val);
  700. if($valueType=='arraySimple' || preg_match('/^ArrayOf/',$type)){
  701. $this->debug("serialize_val: serialize array");
  702. $i = 0;
  703. if(is_array($val) && count($val)> 0){
  704. foreach($val as $v){
  705. if(is_object($v) && get_class($v) == 'soapval'){
  706. $tt_ns = $v->type_ns;
  707. $tt = $v->type;
  708. } elseif (is_array($v)) {
  709. $tt = $this->isArraySimpleOrStruct($v);
  710. } else {
  711. $tt = gettype($v);
  712. }
  713. $array_types[$tt] = 1;
  714. // TODO: for literal, the name should be $name
  715. $xml .= $this->serialize_val($v,'item',false,false,false,false,$use);
  716. ++$i;
  717. }
  718. if(count($array_types) > 1){
  719. $array_typename = 'xsd:anyType';
  720. } elseif(isset($tt) && isset($this->typemap[$this->XMLSchemaVersion][$tt])) {
  721. if ($tt == 'integer') {
  722. $tt = 'int';
  723. }
  724. $array_typename = 'xsd:'.$tt;
  725. } elseif(isset($tt) && $tt == 'arraySimple'){
  726. $array_typename = 'SOAP-ENC:Array';
  727. } elseif(isset($tt) && $tt == 'arrayStruct'){
  728. $array_typename = 'unnamed_struct_use_soapval';
  729. } else {
  730. // if type is prefixed, create type prefix
  731. if ($tt_ns != '' && $tt_ns == $this->namespaces['xsd']){
  732. $array_typename = 'xsd:' . $tt;
  733. } elseif ($tt_ns) {
  734. $tt_prefix = 'ns' . rand(1000, 9999);
  735. $array_typename = "$tt_prefix:$tt";
  736. $xmlns .= " xmlns:$tt_prefix=\"$tt_ns\"";
  737. } else {
  738. $array_typename = $tt;
  739. }
  740. }
  741. $array_type = $i;
  742. if ($use == 'literal') {
  743. $type_str = '';
  744. } else if (isset($type) && isset($type_prefix)) {
  745. $type_str = " xsi:type=\"$type_prefix:$type\"";
  746. } else {
  747. $type_str = " xsi:type=\"SOAP-ENC:Array\" SOAP-ENC:arrayType=\"".$array_typename."[$array_type]\"";
  748. }
  749. // empty array
  750. } else {
  751. if ($use == 'literal') {
  752. $type_str = '';
  753. } else if (isset($type) && isset($type_prefix)) {
  754. $type_str = " xsi:type=\"$type_prefix:$type\"";
  755. } else {
  756. $type_str = " xsi:type=\"SOAP-ENC:Array\" SOAP-ENC:arrayType=\"xsd:anyType[0]\"";
  757. }
  758. }
  759. // TODO: for array in literal, there is no wrapper here
  760. $xml = "<$name$xmlns$type_str$atts>".$xml."</$name>";
  761. } else {
  762. // got a struct
  763. $this->debug("serialize_val: serialize struct");
  764. if(isset($type) && isset($type_prefix)){
  765. $type_str = " xsi:type=\"$type_prefix:$type\"";
  766. } else {
  767. $type_str = '';
  768. }
  769. if ($use == 'literal') {
  770. $xml .= "<$name$xmlns$atts>";
  771. } else {
  772. $xml .= "<$name$xmlns$type_str$atts>";
  773. }
  774. foreach($val as $k => $v){
  775. // Apache Map
  776. if ($type == 'Map' && $type_ns == 'http://xml.apache.org/xml-soap') {
  777. $xml .= '<item>';
  778. $xml .= $this->serialize_val($k,'key',false,false,false,false,$use);
  779. $xml .= $this->serialize_val($v,'value',false,false,false,false,$use);
  780. $xml .= '</item>';
  781. } else {
  782. $xml .= $this->serialize_val($v,$k,false,false,false,false,$use);
  783. }
  784. }
  785. $xml .= "</$name>";
  786. }
  787. break;
  788. default:
  789. $this->debug("serialize_val: serialize unknown");
  790. $xml .= 'not detected, got '.gettype($val).' for '.$val;
  791. break;
  792. }
  793. $this->debug("serialize_val returning $xml");
  794. return $xml;
  795. }
  796. /**
  797. * serializes a message
  798. *
  799. * @param string $body the XML of the SOAP body
  800. * @param mixed $headers optional string of XML with SOAP header content, or array of soapval objects for SOAP headers, or associative array
  801. * @param array $namespaces optional the namespaces used in generating the body and headers
  802. * @param string $style optional (rpc|document)
  803. * @param string $use optional (encoded|literal)
  804. * @param string $encodingStyle optional (usually 'http://schemas.xmlsoap.org/soap/encoding/' for encoded)
  805. * @return string the message
  806. * @access public
  807. */
  808. function serializeEnvelope($body,$headers=false,$namespaces=array(),$style='rpc',$use='encoded',$encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'){
  809. // TODO: add an option to automatically run utf8_encode on $body and $headers
  810. // if $this->soap_defencoding is UTF-8. Not doing this automatically allows
  811. // one to send arbitrary UTF-8 characters, not just characters that map to ISO-8859-1
  812. $this->debug("In serializeEnvelope length=" . strlen($body) . " body (max 1000 characters)=" . substr($body, 0, 1000) . " style=$style use=$use encodingStyle=$encodingStyle");
  813. $this->debug("headers:");
  814. $this->appendDebug($this->varDump($headers));
  815. $this->debug("namespaces:");
  816. $this->appendDebug($this->varDump($namespaces));
  817. // serialize namespaces
  818. $ns_string = '';
  819. foreach(array_merge($this->namespaces,$namespaces) as $k => $v){
  820. $ns_string .= " xmlns:$k=\"$v\"";
  821. }
  822. if($encodingStyle) {
  823. $ns_string = " SOAP-ENV:encodingStyle=\"$encodingStyle\"$ns_string";
  824. }
  825. // serialize headers
  826. if($headers){
  827. if (is_array($headers)) {
  828. $xml = '';
  829. foreach ($headers as $k => $v) {
  830. if (is_object($v) && get_class($v) == 'soapval') {
  831. $xml .= $this->serialize_val($v, false, false, false, false, false, $use);
  832. } else {
  833. $xml .= $this->serialize_val($v, $k, false, false, false, false, $use);
  834. }
  835. }
  836. $headers = $xml;
  837. $this->debug("In serializeEnvelope, serialized array of headers to $headers");
  838. }
  839. $headers = "<SOAP-ENV:Header>".$headers."</SOAP-ENV:Header>";
  840. }
  841. // serialize envelope
  842. return
  843. '<?xml version="1.0" encoding="'.$this->soap_defencoding .'"?'.">".
  844. '<SOAP-ENV:Envelope'.$ns_string.">".
  845. $headers.
  846. "<SOAP-ENV:Body>".
  847. $body.
  848. "</SOAP-ENV:Body>".
  849. "</SOAP-ENV:Envelope>";
  850. }
  851. /**
  852. * formats a string to be inserted into an HTML stream
  853. *
  854. * @param string $str The string to format
  855. * @return string The formatted string
  856. * @access public
  857. * @deprecated
  858. */
  859. function formatDump($str){
  860. $str = htmlspecialchars($str);
  861. return nl2br($str);
  862. }
  863. /**
  864. * contracts (changes namespace to prefix) a qualified name
  865. *
  866. * @param string $qname qname
  867. * @return string contracted qname
  868. * @access private
  869. */
  870. function contractQname($qname){
  871. // get element namespace
  872. //$this->xdebug("Contract $qname");
  873. if (strrpos($qname, ':')) {
  874. // get unqualified name
  875. $name = substr($qname, strrpos($qname, ':') + 1);
  876. // get ns
  877. $ns = substr($qname, 0, strrpos($qname, ':'));
  878. $p = $this->getPrefixFromNamespace($ns);
  879. if ($p) {
  880. return $p . ':' . $name;
  881. }
  882. return $qname;
  883. } else {
  884. return $qname;
  885. }
  886. }
  887. /**
  888. * expands (changes prefix to namespace) a qualified name
  889. *
  890. * @param string $qname qname
  891. * @return string expanded qname
  892. * @access private
  893. */
  894. function expandQname($qname){
  895. // get element prefix
  896. if(strpos($qname,':') && !preg_match('/^http:\/\//',$qname)){
  897. // get unqualified name
  898. $name = substr(strstr($qname,':'),1);
  899. // get ns prefix
  900. $prefix = substr($qname,0,strpos($qname,':'));
  901. if(isset($this->namespaces[$prefix])){
  902. return $this->namespaces[$prefix].':'.$name;
  903. } else {
  904. return $qname;
  905. }
  906. } else {
  907. return $qname;
  908. }
  909. }
  910. /**
  911. * returns the local part of a prefixed string
  912. * returns the original string, if not prefixed
  913. *
  914. * @param string $str The prefixed string
  915. * @return string The local part
  916. * @access public
  917. */
  918. function getLocalPart($str){
  919. if($sstr = strrchr($str,':')){
  920. // get unqualified name
  921. return substr( $sstr, 1 );
  922. } else {
  923. return $str;
  924. }
  925. }
  926. /**
  927. * returns the prefix part of a prefixed string
  928. * returns false, if not prefixed
  929. *
  930. * @param string $str The prefixed string
  931. * @return mixed The prefix or false if there is no prefix
  932. * @access public
  933. */
  934. function getPrefix($str){
  935. if($pos = strrpos($str,':')){
  936. // get prefix
  937. return substr($str,0,$pos);
  938. }
  939. return false;
  940. }
  941. /**
  942. * pass it a prefix, it returns a namespace
  943. *
  944. * @param string $prefix The prefix
  945. * @return mixed The namespace, false if no namespace has the specified prefix
  946. * @access public
  947. */
  948. function getNamespaceFromPrefix($prefix){
  949. if (isset($this->namespaces[$prefix])) {
  950. return $this->namespaces[$prefix];
  951. }
  952. //$this->setError("No namespace registered for prefix '$prefix'");
  953. return false;
  954. }
  955. /**
  956. * returns the prefix for a given namespace (or prefix)
  957. * or false if no prefixes registered for the given namespace
  958. *
  959. * @param string $ns The namespace
  960. * @return mixed The prefix, false if the namespace has no prefixes
  961. * @access public
  962. */
  963. function getPrefixFromNamespace($ns) {
  964. foreach ($this->namespaces as $p => $n) {
  965. if ($ns == $n || $ns == $p) {
  966. $this->usedNamespaces[$p] = $n;
  967. return $p;
  968. }
  969. }
  970. return false;
  971. }
  972. /**
  973. * returns the time in ODBC canonical form with microseconds
  974. *
  975. * @return string The time in ODBC canonical form with microseconds
  976. * @access public
  977. */
  978. function getmicrotime() {
  979. if (function_exists('gettimeofday')) {
  980. $tod = gettimeofday();
  981. $sec = $tod['sec'];
  982. $usec = $tod['usec'];
  983. } else {
  984. $sec = time();
  985. $usec = 0;
  986. }
  987. return strftime('%Y-%m-%d %H:%M:%S', $sec) . '.' . sprintf('%06d', $usec);
  988. }
  989. /**
  990. * Returns a string with the output of var_dump
  991. *
  992. * @param mixed $data The variable to var_dump
  993. * @return string The output of var_dump
  994. * @access public
  995. */
  996. function varDump($data) {
  997. if ($this->debugLevel <= 0) {
  998. return '';
  999. }
  1000. ob_start();
  1001. var_dump($data);
  1002. $ret_val = ob_get_contents();
  1003. ob_end_clean();
  1004. return $ret_val;
  1005. }
  1006. /**
  1007. * represents the object as a string
  1008. *
  1009. * @return string
  1010. * @access public
  1011. */
  1012. function __toString() {
  1013. return $this->varDump($this);
  1014. }
  1015. }
  1016. // XML Schema Datatype Helper Functions
  1017. //xsd:dateTime helpers
  1018. /**
  1019. * convert unix timestamp to ISO 8601 compliant date string
  1020. *
  1021. * @param int $timestamp Unix time stamp
  1022. * @param boolean $utc Whether the time stamp is UTC or local
  1023. * @return mixed ISO 8601 date string or false
  1024. * @access public
  1025. */
  1026. function timestamp_to_iso8601($timestamp,$utc=true){
  1027. $datestr = date('Y-m-d\TH:i:sO',$timestamp);
  1028. $pos = strrpos($datestr, "+");
  1029. if ($pos === FALSE) {
  1030. $pos = strrpos($datestr, "-");
  1031. }
  1032. if ($pos !== FALSE) {
  1033. if (strlen($datestr) == $pos + 5) {
  1034. $datestr = substr($datestr, 0, $pos + 3) . ':' . substr($datestr, -2);
  1035. }
  1036. }
  1037. if($utc){
  1038. $pattern = '/'.
  1039. '([0-9]{4})-'. // centuries & years CCYY-
  1040. '([0-9]{2})-'. // months MM-
  1041. '([0-9]{2})'. // days DD
  1042. 'T'. // separator T
  1043. '([0-9]{2}):'. // hours hh:
  1044. '([0-9]{2}):'. // minutes mm:
  1045. '([0-9]{2})(\.[0-9]*)?'. // seconds ss.ss...
  1046. '(Z|[+\-][0-9]{2}:?[0-9]{2})?'. // Z to indicate UTC, -/+HH:MM:SS.SS... for local tz's
  1047. '/';
  1048. if(preg_match($pattern,$datestr,$regs)){
  1049. return sprintf('%04d-%02d-%02dT%02d:%02d:%02dZ',$regs[1],$regs[2],$regs[3],$regs[4],$regs[5],$regs[6]);
  1050. }
  1051. return false;
  1052. } else {
  1053. return $datestr;
  1054. }
  1055. }
  1056. /**
  1057. * convert ISO 8601 compliant date string to unix timestamp
  1058. *
  1059. * @param string $datestr ISO 8601 compliant date string
  1060. * @return mixed Unix timestamp (int) or false
  1061. * @access public
  1062. */
  1063. function iso8601_to_timestamp($datestr){
  1064. $pattern = '/'.
  1065. '([0-9]{4})-'. // centuries & years CCYY-
  1066. '([0-9]{2})-'. // months MM-
  1067. '([0-9]{2})'. // days DD
  1068. 'T'. // separator T
  1069. '([0-9]{2}):'. // hours hh:
  1070. '([0-9]{2}):'. // minutes mm:
  1071. '([0-9]{2})(\.[0-9]+)?'. // seconds ss.ss...
  1072. '(Z|[+\-][0-9]{2}:?[0-9]{2})?'. // Z to indicate UTC, -/+HH:MM:SS.SS... for local tz's
  1073. '/';
  1074. if(preg_match($pattern,$datestr,$regs)){
  1075. // not utc
  1076. if($regs[8] != 'Z'){
  1077. $op = substr($regs[8],0,1);
  1078. $h = substr($regs[8],1,2);
  1079. $m = substr($regs[8],strlen($regs[8])-2,2);
  1080. if($op == '-'){
  1081. $regs[4] = $regs[4] + $h;
  1082. $regs[5] = $regs[5] + $m;
  1083. } elseif($op == '+'){
  1084. $regs[4] = $regs[4] - $h;
  1085. $regs[5] = $regs[5] - $m;
  1086. }
  1087. }
  1088. return gmmktime($regs[4], $regs[5], $regs[6], $regs[2], $regs[3], $regs[1]);
  1089. // return strtotime("$regs[1]-$regs[2]-$regs[3] $regs[4]:$regs[5]:$regs[6]Z");
  1090. } else {
  1091. return false;
  1092. }
  1093. }
  1094. /**
  1095. * sleeps some number of microseconds
  1096. *
  1097. * @param string $usec the number of microseconds to sleep
  1098. * @access public
  1099. * @deprecated
  1100. */
  1101. function usleepWindows($usec)
  1102. {
  1103. $start = gettimeofday();
  1104. do
  1105. {
  1106. $stop = gettimeofday();
  1107. $timePassed = 1000000 * ($stop['sec'] - $start['sec'])
  1108. + $stop['usec'] - $start['usec'];
  1109. }
  1110. while ($timePassed < $usec);
  1111. }
  1112. ?><?php
  1113. /*
  1114. Modification information for LGPL compliance
  1115. r58622 - 2010-10-22 18:18:59 -0700 (Fri, 22 Oct 2010) - engsvnbuild - Author: lam <lam@198.18.142.201>
  1116. bug 40066
  1117. r58361 - 2010-09-29 16:59:02 -0700 (Wed, 29 Sep 2010) - kjing - Author: Jenny Gonsalves <jenny@sugarcrm.com>
  1118. Merging with maint_6_0_1 (svn merge -r 58250:58342)
  1119. r57813 - 2010-08-19 10:34:44 -0700 (Thu, 19 Aug 2010) - kjing - Author: John Mertic <jmertic@sugarcrm.com>
  1120. Bug 39085 - When loading the opposite search panel via ajax on the ListViews, call the index action instead of the ListView action to avoid touching pre-MVC code by accident.
  1121. r57707 - 2010-08-10 12:26:13 -0700 (Tue, 10 Aug 2010) - kjing - Author: Stanislav Malyshev <smalyshev@gmail.com>
  1122. fix SOAP calls with no parameters
  1123. r56990 - 2010-06-16 13:05:36 -0700 (Wed, 16 Jun 2010) - kjing - snapshot "Mango" svn branch to a new one for GitHub sync
  1124. r56989 - 2010-06-16 13:01:33 -0700 (Wed, 16 Jun 2010) - kjing - defunt "Mango" svn dev branch before github cutover
  1125. r55980 - 2010-04-19 13:31:28 -0700 (Mon, 19 Apr 2010) - kjing - create Mango (6.1) based on windex
  1126. r51719 - 2009-10-22 10:18:00 -0700 (Thu, 22 Oct 2009) - mitani - Converted to Build 3 tags and updated the build system
  1127. r51634 - 2009-10-19 13:32:22 -0700 (Mon, 19 Oct 2009) - mitani - Windex is the branch for Sugar Sales 1.0 development
  1128. r51508 - 2009-10-14 07:40:23 -0700 (Wed, 14 Oct 2009) - jmertic - More fallout fixes from the PHP 5.3 ereg to preg changes.
  1129. r51455 - 2009-10-13 07:56:48 -0700 (Tue, 13 Oct 2009) - jmertic - Bug 33202 - Enable install of SugarCRM on PHP 5.3.0, asserting that the minimum supported version is PHP 5.2.x.
  1130. r51443 - 2009-10-12 13:34:36 -0700 (Mon, 12 Oct 2009) - jmertic - Bug 33332 - Made application PHP 5.3 compliant with E_DEPRECATED warnings on by:
  1131. - Changing all ereg function to either preg or simple string based ones
  1132. - No more references to magic quotes.
  1133. - Change all the session_unregister() functions to just unset() the correct session variable instead.
  1134. r50375 - 2009-08-24 18:07:43 -0700 (Mon, 24 Aug 2009) - dwong - branch kobe2 from tokyo r50372
  1135. r45763 - 2009-04-01 12:16:18 -0700 (Wed, 01 Apr 2009) - majed - Removed half of the require_once and include_onces in the product that were redundant or could be handled easily by the auto loader
  1136. r45680 - 2009-03-30 14:34:35 -0700 (Mon, 30 Mar 2009) - Samir Gandhi - modifeid serializeSchema to generate WS-I compliant WSDL
  1137. r42807 - 2008-12-29 11:16:59 -0800 (Mon, 29 Dec 2008) - dwong - Branch from trunk/sugarcrm r42806 to branches/tokyo/sugarcrm
  1138. r42645 - 2008-12-18 13:41:08 -0800 (Thu, 18 Dec 2008) - awu - merging maint_5_2_0 rev41336:HEAD to trunk
  1139. r41647 - 2008-11-11 17:44:30 -0800 (Tue, 11 Nov 2008) - majed - Fixes a few bugs
  1140. r41596 - 2008-11-10 19:20:04 -0800 (Mon, 10 Nov 2008) - Samir Gandhi - modified to set $method in the code
  1141. r41558 - 2008-11-10 14:35:34 -0800 (Mon, 10 Nov 2008) - majed - changes nusoap to allow for registering classes
  1142. 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.
  1143. Touched:
  1144. - data/SugarBean.php
  1145. - include/domit/php_http_client_generic.php
  1146. - include/domit/php_http_connector.php
  1147. - include/domit/testing_domit.php
  1148. - include/domit/xml_domit_getelementsbypath.php
  1149. - include/domit/xml_domit_lite_parser.php
  1150. - include/domit/xml_domit_nodemaps.php
  1151. - include/domit/xml_domit_parser.php
  1152. - include/domit/xml_domit_shared.php
  1153. - include/generic/SugarWidgets/SugarWidgetField.php
  1154. - include/generic/SugarWidgets/SugarWidgetReportField.php
  1155. - include/ListView/ProcessView.php
  1156. - include/nusoap/class.soapclient.php
  1157. - include/nusoap/nusoap.php
  1158. - include/nusoap/nusoapmime.php
  1159. - include/Pear/HTML_Safe/Safe.php
  1160. - include/Pear/XML_HTMLSax3/HTMLSax3.php
  1161. - modules/Administration/RebuildWorkFlow.php
  1162. - modules/Expressions/RelateSelector.php
  1163. - modules/Reports/templates/templates_reports.php
  1164. - modules/WorkFlow/Delete.php
  1165. - modules/WorkFlow/Save.php
  1166. - modules/WorkFlow/SaveSequence.php
  1167. - modules/WorkFlow/WorkFlow.php
  1168. - modules/WorkFlowActionShells/CreateStep1.php
  1169. - modules/WorkFlowActionShells/CreateStep2.php
  1170. - modules/WorkFlowActionShells/Save.php
  1171. - modules/WorkFlowActionShells/WorkFlowActionShell.php
  1172. - modules/WorkFlowAlerts/Save.php
  1173. - modules/WorkFlowAlerts/WorkFlowAlert.php
  1174. - modules/WorkFlowAlertShells/DetailView.php
  1175. - modules/WorkFlowAlertShells/WorkFlowAlertShell.php
  1176. - modules/WorkFlowTriggerShells/CreateStep1.php
  1177. - modules/WorkFlowTriggerShells/CreateStepFilter.php
  1178. - modules/WorkFlowTriggerShells/SaveFilter.php
  1179. - modules/WorkFlowTriggerShells/WorkFlowTriggerShell.php
  1180. - soap/SoapHelperFunctions.php
  1181. - test/modules/DynamicFields/DynamicFields_Bug24095_test.php
  1182. - test/simpletest/browser.php
  1183. - test/simpletest/default_reporter.php
  1184. - test/simpletest/detached.php
  1185. - test/simpletest/eclipse.php
  1186. - test/simpletest/expectation.php
  1187. - test/simpletest/extensions/pear_test_case.php
  1188. - test/simpletest/form.php
  1189. - test/simpletest/http.php
  1190. - test/simpletest/mock_objects.php
  1191. - test/simpletest/page.php
  1192. - test/simpletest/parser.php
  1193. - test/simpletest/remote.php
  1194. - test/simpletest/shell_tester.php
  1195. - test/simpletest/simple_test.php
  1196. - test/simpletest/simpletest.php
  1197. - test/simpletest/test/acceptance_test.php
  1198. - test/simpletest/test/adapter_test.php
  1199. - test/simpletest/test/authentication_test.php
  1200. - test/simpletest/test/browser_test.php
  1201. - test/simpletest/test/collector_test.php
  1202. - test/simpletest/test/compatibility_test.php
  1203. - test/simpletest/test/detached_test.php
  1204. - test/simpletest/test/eclipse_test.php
  1205. - test/simpletest/test/encoding_test.php
  1206. - test/simpletest/test/errors_test.php
  1207. - test/simpletest/test/expectation_test.php
  1208. - test/simpletest/test/form_test.php
  1209. - test/simpletest/test/frames_test.php
  1210. - test/simpletest/test/http_test.php
  1211. - test/simpletest/test/live_test.php
  1212. - test/simpletest/test/mock_objects_test.php
  1213. - test/simpletest/test/page_test.php
  1214. - test/simpletest/test/parse_error_test.php
  1215. - test/simpletest/test/parser_test.php
  1216. - test/simpletest/test/remote_test.php
  1217. - test/simpletest/test/shell_test.php
  1218. - test/simpletest/test/shell_tester_test.php
  1219. - test/simpletest/test/simpletest_test.php
  1220. - test/simpletest/test/site/page_request.php
  1221. - test/simpletest/test/tag_test.php
  1222. - test/simpletest/test/unit_tester_test.php
  1223. - test/simpletest/test/user_agent_test.php
  1224. - test/simpletest/test/visual_test.php
  1225. - test/simpletest/test/xml_test.php
  1226. - test/simpletest/test_case.php
  1227. - test/simpletest/ui/array_reporter/test.php
  1228. - test/simpletest/ui/recorder/test.php
  1229. - test/simpletest/unit_tester.php
  1230. - test/simpletest/url.php
  1231. - test/simpletest/user_agent.php
  1232. - test/simpletest/web_tester.php
  1233. - test/spikephpcoverage/src/PEAR.php
  1234. - test/spikephpcoverage/src/util/Utility.php
  1235. - test/spikephpcoverage/src/XML/Parser.php
  1236. - test/spikephpcoverage/src/XML/Parser/Simple.php
  1237. - test/test_utilities/SugarTest_SimpleBrowser.php
  1238. r38362 - 2008-07-28 14:06:59 -0700 (Mon, 28 Jul 2008) - roger - bug: 23897. Using print_r when using the debug statement in nusoap will print out the statements to the screen if the call is coming from the UI.
  1239. r38300 - 2008-07-25 13:33:43 -0700 (Fri, 25 Jul 2008) - Samir Gandhi - put the debug in parseresponse function
  1240. r38293 - 2008-07-25 12:32:34 -0700 (Fri, 25 Jul 2008) - Samir Gandhi - to put all the debug statements return value in the call function
  1241. r36824 - 2008-06-18 09:26:11 -0700 (Wed, 18 Jun 2008) - roger - bug: 21832
  1242. r26422 - 2007-09-05 17:29:12 -0700 (Wed, 05 Sep 2007) - majed - migrate from beta 1 to trunk
  1243. r15787 - 2006-08-10 10:14:41 -0700 (Thu, 10 Aug 2006) - roger - RRS: bug 7961
  1244. r14701 - 2006-07-17 13:37:26 -0700 (Mon, 17 Jul 2006) - roger - RRS: bug 5801
  1245. r13782 - 2006-06-06 10:58:55 -0700 (Tue, 06 Jun 2006) - majed - changes entry point code
  1246. r11466 - 2006-02-01 15:49:47 -0800 (Wed, 01 Feb 2006) - jacob - Adding extra !empty check to get around a PHP warning.
  1247. r11115 - 2006-01-17 14:54:45 -0800 (Tue, 17 Jan 2006) - majed - add entry point validation
  1248. r10585 - 2005-12-13 14:42:26 -0800 (Tue, 13 Dec 2005) - majed - adds new license mechanisim
  1249. r10170 - 2005-12-05 18:37:46 -0800 (Mon, 05 Dec 2005) - majed - fixes various issues
  1250. r8999 - 2005-11-04 05:26:49 -0800 (Fri, 04 Nov 2005) - roger - When nusoap was upgraded we had an issue with the user's default language not being populated during a soap request. I determined the reason this was happening and have checked in the corresponding change to nusoap.
  1251. r8991 - 2005-11-03 19:07:25 -0800 (Thu, 03 Nov 2005) - majed - fixes nusoap issue
  1252. r8846 - 2005-10-31 11:01:12 -0800 (Mon, 31 Oct 2005) - majed - new version of nusoap
  1253. r7905 - 2005-09-21 19:12:57 -0700 (Wed, 21 Sep 2005) - majed - restores old nusoap pre & with a few fixes
  1254. r7861 - 2005-09-20 15:40:25 -0700 (Tue, 20 Sep 2005) - majed - & fix for 3.5.1
  1255. r7452 - 2005-08-17 11:32:34 -0700 (Wed, 17 Aug 2005) - majed - changes soap to nusoap
  1256. r5820 - 2005-06-21 14:22:24 -0700 (Tue, 21 Jun 2005) - majed - fixes issues with nusoap and with custom fields
  1257. r5462 - 2005-05-25 13:50:11 -0700 (Wed, 25 May 2005) - majed - upgraded nusoap to .6.9
  1258. r5104 - 2005-05-04 15:33:41 -0700 (Wed, 04 May 2005) - majed - gets rid of HTTP_GET_VARS and what not which has been deprecated
  1259. r573 - 2004-09-04 13:03:32 -0700 (Sat, 04 Sep 2004) - sugarclint - undoing copyrights added in inadvertantly. --clint
  1260. r546 - 2004-09-03 11:49:38 -0700 (Fri, 03 Sep 2004) - sugarmsi - removed echo count
  1261. r354 - 2004-08-02 23:00:37 -0700 (Mon, 02 Aug 2004) - sugarjacob - Adding Soap
  1262. */
  1263. /**
  1264. * Contains information for a SOAP fault.
  1265. * Mainly used for returning faults from deployed functions
  1266. * in a server instance.
  1267. * @author …

Large files files are truncated, but you can click here to view the full file