/classes/anyxml/minixml/minixml.inc.php

https://github.com/shafiqissani/Thunrianz · PHP · 134 lines · 52 code · 31 blank · 51 comment · 10 complexity · 21272b57da7ae107db78140be0189954 MD5 · raw file

  1. <?php if(!defined('_VALID')){header('Status: 404 Not Found');die;}
  2. /***************************************************************************************************
  3. ****************************************************************************************************
  4. *****
  5. ***** MiniXML - PHP class library for generating and parsing XML.
  6. *****
  7. ***** Copyright (C) 2002-2005 Patrick Deegan, Psychogenic.com
  8. ***** All rights reserved.
  9. *****
  10. ***** http://minixml.psychogenic.com
  11. *****
  12. ***** This program is free software; you can redistribute
  13. ***** it and/or modify it under the terms of the GNU
  14. ***** General Public License as published by the Free
  15. ***** Software Foundation; either version 2 of the
  16. ***** License, or (at your option) any later version.
  17. *****
  18. ***** This program is distributed in the hope that it will
  19. ***** be useful, but WITHOUT ANY WARRANTY; without even
  20. ***** the implied warranty of MERCHANTABILITY or FITNESS
  21. ***** FOR A PARTICULAR PURPOSE. See the GNU General
  22. ***** Public License for more details.
  23. *****
  24. ***** You should have received a copy of the GNU General
  25. ***** Public License along with this program; if not,
  26. ***** write to the Free Software Foundation, Inc., 675
  27. ***** Mass Ave, Cambridge, MA 02139, USA.
  28. *****
  29. *****
  30. ***** You may contact the author, Pat Deegan, through the
  31. ***** contact section at http://www.psychogenic.com
  32. *****
  33. ***** Much more information on using this API can be found on the
  34. ***** official MiniXML website - http://minixml.psychogenic.com
  35. ***** or within the Perl version (XML::Mini) available through CPAN
  36. *****
  37. ****************************************************************************************************
  38. ****************************************************************************************************/
  39. define("MINIXML_CASESENSITIVE", 1); /* Set to 1 to use case sensitive element name comparisons */
  40. define("MINIXML_AUTOESCAPE_ENTITIES", 1); /* Set to 1 to autoescape stuff like > and < and & in text, 0 to turn it off */
  41. define("MINIXML_AUTOSETPARENT", 0); /* Set to 1 to automatically register parents elements with children */
  42. define("MINIXML_AVOIDLOOPS", 0); /* Set to 1 to set the default behavior of 'avoidLoops' to ON, 0 otherwise */
  43. define("MINIXML_IGNOREWHITESPACES", 0); /* Set to 1 to eliminate leading and trailing whitespaces from strings */
  44. /* Lower/upper case attribute names. Choose UPPER or LOWER or neither - not both... UPPER takes precedence */
  45. define("MINIXML_UPPERCASEATTRIBUTES", 0); /* Set to 1 to UPPERCASE all attributes, 0 otherwise */
  46. define("MINIXML_LOWERCASEATTRIBUTES", 0); /* Set to 1 to lowercase all attributes, 0 otherwise */
  47. /* fromFile cache.
  48. ** If you are using lots of $xmlDoc->fromFile('path/to/file.xml') calls, it is possible to use
  49. ** a caching mechanism. This cache will read the file, store a serialized version of the resulting
  50. ** object and read in the serialize object on subsequent calls.
  51. **
  52. ** If the original XML file is updated, the cache will automatically be refreshed.
  53. **
  54. ** To use caching, set MINIXML_USEFROMFILECACHING to 1 and set the
  55. ** MINIXML_FROMFILECACHEDIR to a suitable directory in which the cache files will
  56. ** be stored (eg, "/tmp")
  57. **/
  58. define("MINIXML_USEFROMFILECACHING", 0);
  59. define("MINIXML_FROMFILECACHEDIR", "/tmp");
  60. define("MINIXML_DEBUG", 0); /* Set Debug to 1 for more verbose output, 0 otherwise */
  61. /***************************************** end Configuration ***************************************/
  62. define("MINIXML_USE_SIMPLE", 0);
  63. define("MINIXML_VERSION", "1.3.0"); /* Version information */
  64. define("MINIXML_NOWHITESPACES", -999); /* Flag that may be passed to the toString() methods */
  65. $MiniXMLLocation = dirname(__FILE__);
  66. define("MINIXML_CLASSDIR", $MiniXMLLocation.'/classes');
  67. require_once(MINIXML_CLASSDIR . '/doc.inc.php');
  68. function _MiniXMLLog ($message)
  69. {
  70. error_log("MiniXML LOG MESSAGE:\n$message\n");
  71. }
  72. function _MiniXMLError ($message)
  73. {
  74. error_log("MiniXML ERROR:\n$message\n");
  75. return NULL;
  76. }
  77. function _MiniXML_NumKeyArray (&$v)
  78. {
  79. if (! is_array($v))
  80. {
  81. return NULL;
  82. }
  83. $arrayKeys = array_keys($v);
  84. $numKeys = count($arrayKeys);
  85. $totalNumeric = 0;
  86. for($i=0; $i<$numKeys; $i++)
  87. {
  88. if (is_numeric($arrayKeys[$i]) && $arrayKeys[$i] == $i)
  89. {
  90. $totalNumeric++;
  91. } else {
  92. return 0;
  93. }
  94. }
  95. if ($totalNumeric == $numKeys)
  96. {
  97. // All numeric - assume it is a "straight" array
  98. return 1;
  99. } else {
  100. return 0;
  101. }
  102. }
  103. ?>