Advertisement
Guest User

Untitled

a guest
Feb 19th, 2013
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.15 KB | None | 0 0
  1. <?php
  2. /**
  3. *
  4. * @ This file is created by deZender.Net
  5. * @ deZender (PHP5 Decoder for ionCube Encoder)
  6. *
  7. * @ Version : 1.1.5.0
  8. * @ Author : DeZender
  9. * @ Release on : 09.06.2012
  10. * @ Official site : http://DeZender.Net
  11. *
  12. */
  13.  
  14. class grepp {
  15. function xml2array($url, $get_attributes = 1, $priority = 'tag') {
  16. $contents = '';
  17.  
  18. if (!function_exists( 'xml_parser_create' )) {
  19. return array( );
  20. }
  21.  
  22. $parser = xml_parser_create( '' );
  23. $contents = $url;
  24. xml_parser_set_option( $parser, XML_OPTION_TARGET_ENCODING, 'UTF-8' );
  25. xml_parser_set_option( $parser, XML_OPTION_CASE_FOLDING, 0 );
  26. xml_parser_set_option( $parser, XML_OPTION_SKIP_WHITE, 1 );
  27. xml_parse_into_struct( $parser, trim( $contents ), $xml_values );
  28. xml_parser_free( $parser );
  29.  
  30. if (!$xml_values) {
  31. return null;
  32. }
  33.  
  34. $xml_array = array( );
  35. $parents = array( );
  36. $opened_tags = array( );
  37. $arr = array( );
  38. $current = &$xml_array;
  39.  
  40. $repeated_tag_index = array( );
  41. foreach ($xml_values as $data) {
  42. unset( $attributes );
  43. unset( $value );
  44. extract( $data );
  45. $result = array( );
  46. $attributes_data = array( );
  47. $value;
  48.  
  49. if (isset( $value )) {
  50. if ($priority == 'tag') {
  51. $result = $value;
  52. } else {
  53. $result['value'] = $value;
  54. }
  55. }
  56.  
  57. $attributes;
  58.  
  59. if (( isset( $attributes ) && $get_attributes )) {
  60. foreach ($attributes as $attr => $val) {
  61. if ($priority == 'tag') {
  62. $attributes_data[$attr] = $val;
  63. continue;
  64. }
  65.  
  66. $result['attr'][$attr] = $val;
  67. }
  68. }
  69.  
  70.  
  71. if ($type == 'open') {
  72. $parent[$level - 1] = &$current;
  73.  
  74. if (( !is_array( $current ) || !in_array( $tag, array_keys( $current ) ) )) {
  75. $current[$tag] = $result;
  76.  
  77. if ($attributes_data) {
  78. $current[$tag . '_attr'] = $attributes_data;
  79. }
  80.  
  81. $repeated_tag_index[$tag . '_' . $level] = 1;
  82. $current = &$current[$tag];
  83.  
  84. continue;
  85. }
  86.  
  87. $current[$tag][0];
  88.  
  89. if (isset( )) {
  90. $current[$tag][$repeated_tag_index[$tag . '_' . $level]] = $result;
  91. ++$repeated_tag_index[$tag . '_' . $level];
  92. } else {
  93. $current[$tag] = array( $current[$tag], $result );
  94. $repeated_tag_index[$tag . '_' . $level] = 2;
  95. $current[$tag . '_attr'];
  96.  
  97. if (isset( )) {
  98. $current[$tag]['0_attr'] = $current[$tag . '_attr'];
  99. unset( $current[$tag . '_attr'] );
  100. }
  101. }
  102.  
  103. $last_item_index = $repeated_tag_index[$tag . '_' . $level] - 1;
  104. $current = &$current[$tag][$last_item_index];
  105.  
  106. continue;
  107. }
  108.  
  109.  
  110. if ($type == 'complete') {
  111. $current[$tag];
  112.  
  113. if (!isset( )) {
  114. $current[$tag] = $result;
  115. $repeated_tag_index[$tag . '_' . $level] = 1;
  116.  
  117. if (( $priority == 'tag' && $attributes_data )) {
  118. $current[$tag . '_attr'] = $attributes_data;
  119. continue;
  120. }
  121.  
  122. continue;
  123. }
  124.  
  125. $current[$tag][0];
  126.  
  127. if (( isset( ) && is_array( $current[$tag] ) )) {
  128. $current[$tag][$repeated_tag_index[$tag . '_' . $level]] = $result;
  129.  
  130. if (( ( $priority == 'tag' && $get_attributes ) && $attributes_data )) {
  131. $current[$tag][$repeated_tag_index[$tag . '_' . $level] . '_attr'] = $attributes_data;
  132. }
  133.  
  134. ++$repeated_tag_index[$tag . '_' . $level];
  135. continue;
  136. }
  137.  
  138. $current[$tag] = array( $current[$tag], $result );
  139. $repeated_tag_index[$tag . '_' . $level] = 1;
  140.  
  141. if (( $priority == 'tag' && $get_attributes )) {
  142. $current[$tag . '_attr'];
  143.  
  144. if (isset( )) {
  145. $current[$tag]['0_attr'] = $current[$tag . '_attr'];
  146. unset( $current[$tag . '_attr'] );
  147. }
  148.  
  149.  
  150. if ($attributes_data) {
  151. $current[$tag][$repeated_tag_index[$tag . '_' . $level] . '_attr'] = $attributes_data;
  152. }
  153. }
  154.  
  155. ++$repeated_tag_index[$tag . '_' . $level];
  156. continue;
  157. }
  158.  
  159.  
  160. if ($type == 'close') {
  161. $current = &$parent[$level - 1];
  162.  
  163. continue;
  164. }
  165. }
  166.  
  167. return $xml_array;
  168. }
  169. ......................................................................
  170. ...................................
  171. .............
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement