PageRenderTime 46ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 1ms

/server/samples/tree/php/simple/nitobi.xml.php

https://github.com/stevengill/completeui
PHP | 696 lines | 518 code | 45 blank | 133 comment | 22 complexity | 82afbd13e56c8b9cd1726d2545084779 MD5 | raw file
Possible License(s): Apache-2.0, AGPL-3.0, BSD-3-Clause
  1. <?php
  2. // *****************************************************************************
  3. // *****************************************************************************
  4. // * EBAXML PHP Library v2.15
  5. // *****************************************************************************
  6. // * Copyright (C) eBusiness Applications
  7. // * The SOFTWARE PRODUCT is protected by copyright laws and international
  8. // * copyright treaties, as well as other intellectual property laws and treaties.
  9. // * The SOFTWARE PRODUCT is licensed, not sold. The eBusiness Applications
  10. // * distribution file may not have files added to it or removed from it.
  11. // * None of its compiled or encoded contents may be decompiled, or reverse engineered.
  12. // * You may not reverse engineer, decompile, or disassemble the SOFTWARE PRODUCT,
  13. // * except and only to the extent that such activity is expressly permitted by
  14. // * applicable law notwithstanding this limitation.
  15. // *****************************************************************************
  16. ///<class name='ILocaleConverter'>
  17. /// <summary>
  18. /// ILocaleConverter provides a means of extending EBAXML.php to handle different
  19. /// character encodings. If you are using a new encoding you should create a
  20. /// subclass and override the createUnicodeString method
  21. /// </summary>
  22. /// <remarks> The ILocaleConverter is used for internationalization. ILocaleConverter:createUnicodeString should be treated as an pure virtual abstract method. Please create an instance of DefaultLocaleConverter.</remarks>
  23. ///
  24. class ILocaleConverter
  25. {
  26. function ILocaleConverter()
  27. {
  28. }
  29. ///<function name="createUnicodeString" access="public">
  30. ///<summary>Creates a Unicode string</summary>
  31. ///<param name="nativeString" type="string" >A natively encode string</param>
  32. ///<returns type="string" >A Unicode string</returns>
  33. ///<remarks>ILocaleConverter->createUnicodeString should be treated as an pure virtual abstract method. Please create an instance of DefaultLocaleConverter.</remarks>
  34. function createUnicodeString($nativeString)
  35. {
  36. trigger_error("ILocaleConverter->createUnicodeString should be treated as an pure virtual abstract method. Please create an instance of DefaultLocaleConverter.",E_USER_ERROR);
  37. }
  38. ///</function>
  39. }
  40. ///</class>
  41. ///<class name='DefaultLocaleConverter' inherits='ILocaleConverter'>
  42. /// <summary>
  43. /// Converter to create Unicode strings from the default php native encoding
  44. /// </summary>
  45. /// <remarks>
  46. /// It is best to have the mbstring extension loaded. To load this extension
  47. /// remove the ';' from the beginning of the ';extension=php_mbstring.dll' line in
  48. /// your php.ini and restart you webserver. If mbstring is not loaded the
  49. /// nativeString is returned unchanged.
  50. /// </remarks>
  51. class DefaultLocaleConverter extends ILocaleConverter
  52. {
  53. function DefaultLocaleConverter()
  54. {
  55. }
  56. ///<function name="createUnicodeString" access="public">
  57. ///<summary>Creates a Unicode string</summary>
  58. ///<param name="nativeString" type="string" >A string</param>
  59. ///<returns type="string" >A Unicode string</returns>
  60. function createUnicodeString($nativeString)
  61. {
  62. # by default just return the input
  63. $result = $nativeString;
  64. # check if mbstring is loaded.
  65. if(extension_loaded("mbstring"))
  66. {
  67. $result = mb_convert_encoding($nativeString, "UTF-8");
  68. }
  69. return $result;
  70. }
  71. ///</function>
  72. }
  73. ///</class>
  74. ///<class name='Shift_JISLocaleConverter' inherits='ILocaleConverter' >
  75. /// <summary>
  76. /// A Converter use to create Unicode strings from Shift_JIS encoding
  77. /// </summary>
  78. /// <remarks>
  79. /// It is best to have the mbstring extension loaded. To load this extension
  80. /// remove the ';' from the beginning of the ';extension=php_mbstring.dll' line in
  81. /// your php.ini and restart you webserver. If mbstring is not loaded the
  82. /// nativeString is returned unchanged.
  83. /// </remarks>
  84. /// <remarks> Shift_JISLocaleConverter will only work if the mbstring extension is loaded. To load the mbstrings extention, please remove the ';' from the beginning of the ';extension=php_mbstring.dll' line in your php.ini and restart you webserver. For more details see http://ca.php.net/mbstring </remarks>
  85. class Shift_JISLocaleConverter extends ILocaleConverter
  86. {
  87. function Shift_JISLocaleConverter()
  88. {
  89. }
  90. ///<function name="createUnicodeString" access="public">
  91. ///<summary>creates a Unicode encoded string from a Shift_JIS string</summary>
  92. ///<param name="nativeString" type="string" >A string of Shift_JIS encoded characters</param>
  93. ///<returns type="string" >A Unicode string</returns>
  94. function createUnicodeString($nativeString)
  95. {
  96. $result = $nativeString;
  97. if(extension_loaded("mbstring"))
  98. {
  99. $result = mb_convert_encoding($nativeString, "UTF-8", "SJIS");
  100. }
  101. else
  102. {
  103. trigger_error("Shift_JISLocaleConverter will only work if the mbstring extension is loaded. To load the mbstrings extention, please remove the ';' from the beginning of the ';extension=php_mbstring.dll' line in your php.ini and restart you webserver. For more details see http://ca.php.net/mbstring",E_USER_ERROR);
  104. }
  105. return $result;
  106. }
  107. ///</function>
  108. }
  109. ///</class>
  110. ///<class name='EBARecord'>
  111. ///<summary> EBARecord encapsulates a single row of data
  112. /// The row has an id and a set of name value pairs
  113. ///</summary>
  114. class EBARecord
  115. {
  116. var $m_ID = 0;
  117. # Files is a pair of name value fields.
  118. var $m_Fields = array();
  119. function EBARecord($id)
  120. {
  121. $this->m_ID=$id;
  122. }
  123. ///<function name="add" access="public">
  124. /// <summary>Adds a new name value pair to the record</summary>
  125. ///<param name="columnName" type="string" >Name of field</param>
  126. ///<param name="columnValue" type="string" >Field value</param>
  127. ///</function>
  128. function add($columnName, $columnValue)
  129. {
  130. $this->m_Fields[$columnName] = $columnValue;
  131. }
  132. ///<function name="getRows" access="public">
  133. ///<summary>Adds a new name value pair to the record</summary>
  134. ///<returns>An associative array of the name value pairs </returns>
  135. ///</function>
  136. function getRows()
  137. {
  138. return $this->m_Fields;
  139. }
  140. ///<function name="getID" access="public">
  141. ///<summary>Return the ID of the record</summary>
  142. ///<returns type="string" >Record ID</returns>
  143. ///</function>
  144. function getID()
  145. {
  146. return $this->m_ID;
  147. }
  148. }
  149. ///</class>
  150. // EBAXML PHP Library v2.01 Copyright (C) eBusiness Applications The SOFTWARE
  151. // PRODUCT is protected by copyright laws and international copyright treaties, as
  152. // well as other intellectual property laws and treaties. The SOFTWARE PRODUCT is
  153. // licensed, not sold. The eBusiness Applications distribution file may not have
  154. // files added to it or removed from it. None of its compiled or encoded contents
  155. // may be decompiled, or reverse engineered. You may not reverse engineer,
  156. // decompile, or disassemble the SOFTWARE PRODUCT, except and only to the extent
  157. // that such activity is expressly permitted by applicable law notwithstanding
  158. // this limitation. EBAGetHandler is an encapsulation of the data structure used
  159. // to create EBA compressed XML The data includes a set of column names and a set
  160. // of records
  161. // @created 23-Sep-2005 3:19:21 PM
  162. ///<class name='EBAGetHandler'>
  163. /// <summary>Write EBA compressed XML based on a set of records </summary>
  164. //
  165. // The following are a set of depreciated functions Please make your
  166. // life easy and stop using the following functions:
  167. // ProcessRecords - This is now a no-op
  168. // DefineField - This is now a no-op
  169. // CreateNewRecord - No longer supported
  170. // SaveRecord - No longer supported
  171. // DefineRecordFieldValue - No longer supported
  172. // <br></br>
  173. //
  174. // <example>
  175. //<code>
  176. // $getHandler = new EBAGetHandler();
  177. // $record = new EBARecord("ID1");
  178. // $record->add("Field1", "Value One");
  179. // $getHandler.add($record);
  180. // $getHandle.CompleteGet();
  181. //</code>
  182. //</example>
  183. class EBAGetHandler
  184. {
  185. # a list of columns that will be included in the component
  186. var $m_ColunmNames = array();
  187. var $m_Rows = array();
  188. # XML's reserved chars and their entity references
  189. var $m_TranscodeList = array(
  190. "&" => "&amp;", # Make sure to replace this first.
  191. "\"" => "&quot;",
  192. "<" => "&lt;",
  193. ">" => "&gt;",
  194. "\n" => "&#10;",);
  195. # carriageReturn => "&#13;" # need to add c/r
  196. var $m_currentRecord;
  197. # allows for the transcoding of strings
  198. var $m_localeConverter;
  199. # adds the xml:lang attribute to the xml
  200. var $m_dataLanguage;
  201. # for keeping track of any errors. if this is set to a non-empty string then it
  202. # will be sent back to the client as an attribute called "error" in the root element.
  203. var $m_ErrorMessage;
  204. function EBAGetHandler()
  205. {
  206. $this->m_ErrorMessage = "";
  207. $this->m_dataLanguage = "en";
  208. $this->m_localeConverter = new DefaultLocaleConverter();
  209. }
  210. ///<function name="ProcessRecords" access="public">
  211. /// <summary>DEPRECIATED DO NOT USE</summary>
  212. ///<param name="XMLEncoding" type="string" >Do not use</param>
  213. /// <remarks>To set encoding use the 'encoding' parameter of the methods toXML or completeGet</remarks>
  214. ///</function>
  215. function ProcessRecords($XMLEncoding="UTF-8")
  216. {
  217. // this is a no op
  218. }
  219. ///<function name="DefineField" access="public">
  220. /// <summary>Allows the description of data without record being added.
  221. /// This allows the combo to render when there are zero records.</summary>
  222. /// <remarks>The fields do not have to be pre-defined. Fields are now
  223. /// created base on the records. Whenever a record is added all of
  224. /// the records fields are added to the global list of fields.
  225. /// Note DefineFields must be called if no records are added to the EBAGetHandler object.
  226. /// </remarks>
  227. ///<param name="XMLEncoding" type="string" ></param>
  228. ///</function>
  229. function DefineField($FieldName)
  230. {
  231. $this->m_ColunmNames[$FieldName] = 1;
  232. }
  233. ///<function name="CreateNewRecord" access="public">
  234. /// <summary>DEPRECIATED DO NOT USE</summary>
  235. /// <remarks>The supported method to create record is to call $currentRecord = new EBARecord($KeyVal);
  236. /// </remarks>
  237. ///</function>
  238. function CreateNewRecord($KeyVal)
  239. {
  240. $this->m_currentRecord = new EBARecord($KeyVal);
  241. }
  242. ///<function name="SaveRecord" access="public">
  243. /// <summary>DEPRECIATED DO NOT USE</summary>
  244. /// <remarks>The supported method of adding records is to call $currentGetHanlder->add($currentRecord);
  245. /// </remarks>
  246. ///</function>
  247. function SaveRecord()
  248. {
  249. $this->add($this->m_currentRecord);
  250. $this->m_currentRecord = "";
  251. }
  252. ///<function name="DefineRecordFieldValue" access="public">
  253. /// <summary>DEPRECIATED DO NOT USE</summary>
  254. /// <remarks>The supported method of adding field-value pairs is: $currentRecord->add($ColName, $DataValue)
  255. /// </remarks>
  256. ///</function>
  257. function DefineRecordFieldValue($ColName, $DataValue)
  258. {
  259. $this->m_currentRecord->add($ColName, $DataValue);
  260. }
  261. ///<function name="add" access="public">
  262. /// <summary> The 'record' added will become a row element in the eba xml</summary>
  263. ///<param name="record" type="EBARecord" >The record to add</param>
  264. ///</function>
  265. function add($record)
  266. {
  267. # add all the ColumnNames
  268. foreach ($record->getRows() as $columnName => $dummy)
  269. {
  270. $this->m_ColunmNames[$columnName] = 1;
  271. }
  272. # add the Rows
  273. $this->m_Rows[$record->getID()] = $record->getRows();
  274. }
  275. ///<function name="setLocaleConverter" access="public">
  276. /// <summary> Set the localeConverter. This is only needed if different character set are used.</summary>
  277. ///<param name="LocaleConverter" type="ILocaleConverter" >The localeConverter used to generate the EBA compessed xml response</param>
  278. ///</function>
  279. function setLocaleConverter($localeConverter)
  280. {
  281. $this->m_localeConverter = $localeConverter;
  282. }
  283. ///<function name="setDataLanguage" access="public">
  284. /// <summary> Set the datalanguage used for xml:lang</summary>
  285. ///<param name="language" type="string" >The value used for xml:lang</param>
  286. ///</function>
  287. function setDataLanguage($language)
  288. {
  289. $this->m_dataLanguage = $language;
  290. }
  291. ///<function name="setErrorMessage" access="public">
  292. ///<summary> Sets an error message to be sent back to the client in the response. Set this to any empty string to clear the error message.</summary>
  293. ///<param name="message" type="string" >The value for the error message</param>
  294. ///</function>
  295. function setErrorMessage($message)
  296. {
  297. $this->m_ErrorMessage = $message;
  298. }
  299. ///<function name="completeGet" access="public">
  300. /// <summary> Prints UTF-8 EBA XML to the respone</summary>
  301. ///</function>
  302. function completeGet($encoding="UTF-8")
  303. {
  304. header("Content-type:text/xml;charset=$encoding");
  305. print $this->toXML($encoding);
  306. }
  307. ///<function name="toXML" access="public">
  308. /// <summary> Creates an compressed EBA XML document based on the records added to the getHandler object</summary>
  309. /// <returns type="string"> compressed UTF-8 EBA XML document</returns>
  310. ///</function>
  311. function toXML($encoding="UTF-8")
  312. {
  313. $results = "<?xml version=\"1.0\" encoding=\"$encoding\" ?>";
  314. # print the columns as the fields attribute of the opening root tag
  315. $results .= "<root xml:lang=\"{$this->m_dataLanguage}\" fields=\"".
  316. strtr(implode("|",array_keys($this->m_ColunmNames)),$this->m_TranscodeList)."\"";
  317. if ($this->m_ErrorMessage != "")
  318. {
  319. $results .= " error=\"" . strtr($this->m_ErrorMessage,$this->m_TranscodeList) . "\"";
  320. }
  321. $results .= ">";
  322. # print the rows
  323. # following is an example row
  324. # <e xk="de" a="de" b="images/flags/de_flag.gif" c="Deutschland"/>
  325. # create compression indexes a,..,z,aa,ab,..,zy,zz
  326. $EBAColumnOrder = range('a','z');
  327. foreach ($this->m_Rows as $rowID => $rowArray)
  328. {
  329. $results .= "<e xk=\"".strtr($rowID,$this->m_TranscodeList)."\"";
  330. $EBAIndex = -1;
  331. $EBASubIndex = 0;
  332. foreach ($this->m_ColunmNames as $columnName => $dummy)
  333. {
  334. if(count($EBAColumnOrder) <= $EBASubIndex)
  335. {
  336. $EBASubIndex = 0;
  337. $EBAIndex++;
  338. }
  339. $ColumnKey = $EBAColumnOrder[$EBASubIndex];
  340. if($EBAIndex > -1)
  341. {
  342. $ColumnKey = $EBAColumnOrder[$EBAIndex].$ColumnKey;
  343. }
  344. # index "$EBAColumnOrder[$index]$EBAColumnOrder[$subIndex]";
  345. $results .= " $ColumnKey=\"".strtr($rowArray[$columnName],$this->m_TranscodeList)."\"";
  346. $EBASubIndex++;
  347. }
  348. $results .= " />\n";
  349. }
  350. // finish document
  351. $results .= ( "</root>");
  352. return $this->m_localeConverter->createUnicodeString($results);
  353. }
  354. }
  355. ///</class>
  356. class EBASaveHandler
  357. {
  358. var $InsertRecords = array();
  359. var $UpdateRecords = array();
  360. var $DeleteRecords = array();
  361. var $InsertCount = 0;
  362. var $UpdateCount = 0;
  363. var $DeleteCount = 0;
  364. var $Fields = array();
  365. var $FieldsCount = 0;
  366. var $FieldsSet = array();
  367. var $m_ErrorMessage;
  368. # XML's reserved chars and their entity references
  369. var $m_TranscodeList = array(
  370. "&" => "&amp;", # Make sure to replace this first.
  371. "\"" => "&quot;",
  372. "<" => "&lt;",
  373. ">" => "&gt;",
  374. "\n" => "&#10;",);
  375. function EBASaveHandler()
  376. {
  377. }
  378. function CompleteSave()
  379. {
  380. if( $this->m_ErrorMessage != "" )
  381. {
  382. print str_replace("<root ", "<root error=\"".strtr($this->m_ErrorMessage,$this->m_TranscodeList)."\" ", $GLOBALS["HTTP_RAW_POST_DATA"]);
  383. }
  384. else
  385. {
  386. print $GLOBALS["HTTP_RAW_POST_DATA"];
  387. }
  388. }
  389. function ReturnInsertCount()
  390. {
  391. return $this->InsertCount;
  392. }
  393. function ReturnUpdateCount()
  394. {
  395. return $this->UpdateCount;
  396. }
  397. function ReturnDeleteCount()
  398. {
  399. return $this->DeleteCount;
  400. }
  401. ///<function name="setErrorMessage" access="public">
  402. ///<summary> Sets an error message to be sent back to the client in the response. Set this to any empty string to clear the error message.</summary>
  403. ///<param name="message" type="string" >The value for the error message</param>
  404. ///</function>
  405. function setErrorMessage($message)
  406. {
  407. $this->m_ErrorMessage = $message;
  408. }
  409. //<function name="ReturnInsertField" access="public">
  410. // <summary> Returns the number of insert instructions in the updategram.
  411. // Updategrams (saving instructions) contain 3 types of instructions: INSERT, UPDATE, and DELETE.
  412. // Always process INSERT's first, UPDATE's next, and DELETE's last.</summary>
  413. // <returns type="string"> The value for a field. </returns>
  414. //</function>
  415. function ReturnInsertField($RecordNumber, $FieldName = "")
  416. {
  417. $postData = $GLOBALS["HTTP_RAW_POST_DATA"];
  418. $EBAResultValue = "";
  419. $EBASearchField = "";
  420. $index = array_search($FieldName, $this->Fields);
  421. if (($index !== FALSE) || ($FieldName == ""))
  422. {
  423. $EBASearchField = "xk=\"";
  424. if (strlen($FieldName) > 0)
  425. {
  426. $EBASearchField = $this->FieldsSet[$index]."=\"";
  427. if (($this->FieldsSet[$index] == "k") || ($this->FieldsSet[$index] == "i"))
  428. $EBASearchField = " ".$this->FieldsSet[$index] ."=\"";
  429. }
  430. $EBAUpdateGramTemp = EBAright($postData, strlen($postData) - $this->InsertRecords[$RecordNumber]);
  431. $EBANextPos = strpos($EBAUpdateGramTemp, $EBASearchField);
  432. if ($EBANextPos > 0)
  433. {
  434. $EBAUpdateGramTemp = EBAright($EBAUpdateGramTemp, strlen($EBAUpdateGramTemp) - $EBANextPos - strlen($EBASearchField));
  435. $EBANextPos = strpos($EBAUpdateGramTemp, "\"");
  436. $EBAUpdateGramTemp = EBAleft($EBAUpdateGramTemp,$EBANextPos);
  437. $EBAResultValue = $EBAUpdateGramTemp;
  438. }
  439. }
  440. return $EBAResultValue;
  441. }
  442. function ReturnUpdateField($RecordNumber, $FieldName = "")
  443. {
  444. $postData = $GLOBALS["HTTP_RAW_POST_DATA"];
  445. $EBAResultValue = "";
  446. $EBASearchField = "";
  447. $index = array_search($FieldName, $this->Fields);
  448. if (($index !== FALSE) || ($FieldName == ""))
  449. {
  450. $EBASearchField = "xk=\"";
  451. if (strlen($FieldName) > 0)
  452. {
  453. $EBASearchField = $this->FieldsSet[$index] ."=\"";
  454. if ($this->FieldsSet[$index] == "k" || $this->FieldsSet[$index] == "i")
  455. $EBASearchField = " ".$this->FieldsSet[$index] ."=\"";
  456. }
  457. $EBAUpdateGramTemp = EBAright($postData, strlen($postData) - $this->UpdateRecords[$RecordNumber]);
  458. $EBANextPos = strpos($EBAUpdateGramTemp, $EBASearchField);
  459. if ($EBANextPos > 0)
  460. {
  461. $EBAUpdateGramTemp = EBAright($EBAUpdateGramTemp, strlen($EBAUpdateGramTemp) - $EBANextPos - strlen($EBASearchField));
  462. $EBANextPos = strpos($EBAUpdateGramTemp, "\"");
  463. $EBAUpdateGramTemp = EBAleft($EBAUpdateGramTemp, $EBANextPos);
  464. $EBAResultValue = $EBAUpdateGramTemp;
  465. }
  466. }
  467. return $EBAResultValue;
  468. }
  469. function ReturnDeleteField($RecordNumber)
  470. {
  471. $postData = $GLOBALS["HTTP_RAW_POST_DATA"];
  472. $EBAResultValue = "";
  473. $EBASearchField = "xk=\"";
  474. $EBADeleteGramTemp = EBAright($postData, strlen($postData) - $this->DeleteRecords[$RecordNumber]);
  475. $EBANextPos = strpos($EBADeleteGramTemp, $EBASearchField);
  476. if ($EBANextPos > 0)
  477. {
  478. $EBADeleteGramTemp = EBAright($EBADeleteGramTemp, strlen($EBADeleteGramTemp) - $EBANextPos - strlen($EBASearchField));
  479. $EBANextPos = strpos($EBADeleteGramTemp, "\"");
  480. $EBADeleteGramTemp = EBAleft($EBADeleteGramTemp, $EBANextPos);
  481. $EBAResultValue = $EBADeleteGramTemp;
  482. }
  483. return $EBAResultValue;
  484. }
  485. //<function name="ProcessRecords" access="public">
  486. // <summary>This function initializes the SaveHandler based on the data in the GLOBALS[HTTP_RAW_POST_DATA] </summary>
  487. // <returns type="string"> The value for a field</returns>
  488. //</function>
  489. function ProcessRecords()
  490. {
  491. $postData = $GLOBALS["HTTP_RAW_POST_DATA"];
  492. # Populate EBAGetHandler_Fields with the fields names
  493. $EBAUpdategram = $postData;
  494. $ParsePos = 0;
  495. if (strlen($EBAUpdategram) > 5)
  496. {
  497. $ParsePos = strpos(strtolower($EBAUpdategram), "fields");
  498. $ParsePos = strpos(EBAright($EBAUpdategram, strlen($EBAUpdategram) - $ParsePos), "\"") + 7;
  499. $EBAUpdategram = EBAright($EBAUpdategram, strlen($EBAUpdategram) - $ParsePos);
  500. #Begin grabbing fields
  501. $EBANextPos = 0;
  502. $EBAFieldName = "";
  503. do
  504. {
  505. $EBANextPos = strpos($EBAUpdategram, "|");
  506. $EBANextPos = min($EBANextPos, strpos($EBAUpdategram, "\""));
  507. if ($EBANextPos > 0)
  508. {
  509. $EBAFieldName = EBAleft($EBAUpdategram, $EBANextPos);
  510. $EBAUpdategram = EBAright($EBAUpdategram, strlen($EBAUpdategram) - $EBANextPos - 1);
  511. $this->Fields[$this->FieldsCount] = $EBAFieldName;
  512. $this->FieldsCount += 1;
  513. }
  514. }
  515. while ($EBANextPos > 0);
  516. $EBANextPos = strpos($EBAUpdategram, "\"");
  517. if ($EBANextPos > 0)
  518. {
  519. $EBAFieldName = EBAleft($EBAUpdategram, $EBANextPos);
  520. $EBAUpdategram = EBAright($EBAUpdategram, strlen($EBAUpdategram) - $EBANextPos - 1);
  521. $this->Fields[$this->FieldsCount] = $EBAFieldName;
  522. $this->FieldsCount += 1;
  523. }
  524. # Now we count the insert instructions
  525. $EBAUpdategram = $postData;
  526. $EBAUpdateGramTemp = $EBAUpdategram;
  527. $EBATotalCount = 0;
  528. do
  529. {
  530. $EBANextPos = strpos($EBAUpdateGramTemp, "<insert");
  531. if ($EBANextPos > 0)
  532. {
  533. $EBATotalCount += $EBANextPos+1;
  534. $this->InsertRecords[$this->InsertCount] = $EBATotalCount;
  535. $this->InsertCount += 1;
  536. $EBAUpdateGramTemp = EBAright($EBAUpdateGramTemp, strlen($EBAUpdateGramTemp) - $EBANextPos - 1);
  537. }
  538. }
  539. while ($EBANextPos > 0);
  540. $EBAUpdateGramTemp = $EBAUpdategram;
  541. $EBATotalCount = 0;
  542. do
  543. {
  544. $EBANextPos = strpos($EBAUpdateGramTemp, "<update");
  545. if ($EBANextPos > 0)
  546. {
  547. $EBATotalCount += $EBANextPos;
  548. $this->UpdateRecords[$this->UpdateCount] = $EBATotalCount;
  549. $this->UpdateCount += 1;
  550. $EBAUpdateGramTemp = EBAright($EBAUpdateGramTemp, strlen($EBAUpdateGramTemp) - $EBANextPos - 1);
  551. }
  552. }
  553. while ($EBANextPos > 0);
  554. $EBAUpdateGramTemp = $EBAUpdategram;
  555. $EBATotalCount = 0;
  556. do
  557. {
  558. $EBANextPos = strpos($EBAUpdateGramTemp, "<delete");
  559. if ($EBANextPos > 0)
  560. {
  561. $EBATotalCount += $EBANextPos;
  562. $this->DeleteRecords[$this->DeleteCount] = $EBATotalCount;
  563. $this->DeleteCount += 1;
  564. $EBAUpdateGramTemp = EBAright($EBAUpdateGramTemp, strlen($EBAUpdateGramTemp) - $EBANextPos - 1);
  565. }
  566. }
  567. while ($EBANextPos > 0);
  568. $EBAFieldOrder = array('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z');
  569. $MainSetCounter = 0;
  570. for ( $index = 0; $index < 26; $index += 1)
  571. {
  572. $this->FieldsSet[$index] = $EBAFieldOrder[$index];
  573. $MainSetCounter += 1;
  574. }
  575. for ( $index = 0; $index < 26; $index += 1)
  576. {
  577. for ( $subIndex = 0; $subIndex < 26; $subIndex += 1)
  578. {
  579. $this->FieldsSet[$MainSetCounter] = $EBAFieldOrder[$index] . $EBAFieldOrder[$subIndex];
  580. $MainSetCounter += 1;
  581. }
  582. }
  583. }
  584. else
  585. {
  586. print "No valid EBA updategram was discovered!";
  587. }
  588. }
  589. }
  590. function EBAleft ($str, $howManyCharsFromLeft)
  591. {
  592. return substr ($str, 0, $howManyCharsFromLeft);
  593. }
  594. function EBAright ($str, $howManyCharsFromRight)
  595. {
  596. $strLen = strlen ($str);
  597. return substr ($str, $strLen - $howManyCharsFromRight, $strLen);
  598. }
  599. function EBAmid ($str, $start, $howManyCharsToRetrieve = 0)
  600. {
  601. $start--;
  602. if ($howManyCharsToRetrieve == 0)
  603. $howManyCharsToRetrieve = strlen ($str) - $start;
  604. return substr ($str, $start, $howManyCharsToRetrieve);
  605. }
  606. function getDateForMysqlDateField($val)
  607. {
  608. preg_match("#^([0-9]{2})/([0-9]{2})/([0-9]{4})#",$val,$Match);
  609. return(mktime(0,0,0,$Match[2],$Match[1],$Match[3]));
  610. }
  611. ?>