Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2021
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.07 KB | None | 0 0
  1. <?php
  2. /**
  3. *
  4. * @ This file is created by http://DeZender.Net
  5. * @ deZender (PHP7 Decoder for ionCube Encoder)
  6. *
  7. * @ Version : 4.1.0.1
  8. * @ Author : DeZender
  9. * @ Release on : 29.08.2020
  10. * @ Official site : http://DeZender.Net
  11. *
  12. */
  13.  
  14. class Achievements
  15. {
  16. public function loadXML($xml)
  17. {
  18. $achievements = [];
  19.  
  20. if ($xml !== false) {
  21. $i = 1;
  22.  
  23. foreach ($xml->achievements->children() as $tag => $ach) {
  24. if ($tag == 'achievement') {
  25. $achievements[$i]['uid'] = trim($ach->uid);
  26. $achievements[$i]['type'] = trim($ach->type);
  27. $achievements[$i]['name'] = trim($ach->name);
  28. $achievements[$i]['img'] = trim($ach->img);
  29. $achievements[$i]['class'] = trim($ach->class);
  30. $achievements[$i]['req_lvl'] = trim($ach->req_lvl);
  31. $achievements[$i]['req_mlvl'] = trim($ach->req_mlvl);
  32. $achievements[$i]['req_reset'] = trim($ach->req_reset);
  33. $achievements[$i]['req_greset'] = trim($ach->req_greset);
  34.  
  35. if ($achievements[$i]['req_lvl'] == NULL) {
  36. $achievements[$i]['req_lvl'] = 0;
  37. }
  38.  
  39. if ($achievements[$i]['req_mlvl'] == NULL) {
  40. $achievements[$i]['req_mlvl'] = 0;
  41. }
  42.  
  43. if ($achievements[$i]['req_reset'] == NULL) {
  44. $achievements[$i]['req_reset'] = 0;
  45. }
  46.  
  47. if ($achievements[$i]['req_greset'] == NULL) {
  48. $achievements[$i]['req_greset'] = 0;
  49. }
  50.  
  51. $achievements[$i]['total_stages'] = trim($ach->total_stages);
  52. $achievements[$i]['stage'] = [];
  53.  
  54. for ($x = 1; $x <= $achievements[$i]['total_stages']; $x++) {
  55. $stage = NULL;
  56. $monsters = NULL;
  57. $monsters_count = NULL;
  58. $items = NULL;
  59. $items_count = NULL;
  60. $rew_items = NULL;
  61. $rew_items_count = NULL;
  62. $stage = [];
  63. $curr_stage = 'stage' . $x;
  64. $stage['desc'] = trim($ach->{$curr_stage}->desc);
  65.  
  66. if ($achievements[$i]['type'] == '0') {
  67. $monsters = [];
  68. $monsters_count = [];
  69. $k = 1;
  70.  
  71. foreach ($ach->{$curr_stage}->monsters->children() as $tag => $monster) {
  72. if ($tag == 'monster') {
  73. $monsters[$k] = trim($monster);
  74. $monsters_count[$k] = intval($monster['count']);
  75. }
  76.  
  77. $k++;
  78. }
  79. }
  80. else if ($achievements[$i]['type'] == '1') {
  81. $stage['zen'] = trim($ach->{$curr_stage}->zen);
  82. }
  83. else if (($achievements[$i]['type'] == '2') || ($achievements[$i]['type'] == '3') || ($achievements[$i]['type'] == '4') || ($achievements[$i]['type'] == '6') || ($achievements[$i]['type'] == '7') || ($achievements[$i]['type'] == '8') || ($achievements[$i]['type'] == '9') || ($achievements[$i]['type'] == '10') || ($achievements[$i]['type'] == '11') || ($achievements[$i]['type'] == '12') || ($achievements[$i]['type'] == '13')) {
  84. $stage['exp'] = trim($ach->{$curr_stage}->exp);
  85. }
  86. else if ($achievements[$i]['type'] == '5') {
  87. $items = [];
  88. $items_count = [];
  89. $k = 1;
  90.  
  91. foreach ($ach->{$curr_stage}->items->children() as $tag => $item) {
  92. if ($tag == 'item') {
  93. $items[$k] = trim($item);
  94. $items_count[$k] = intval($item['count']);
  95. }
  96.  
  97. $k++;
  98. }
  99. }
  100.  
  101. $stage['reward_type'] = trim($ach->{$curr_stage}->reward_type);
  102.  
  103. if ($stage['reward_type'] == '7') {
  104. $rew_items = [];
  105. $rew_items_count = [];
  106. $m = 1;
  107.  
  108. foreach ($ach->{$curr_stage}->reward->children() as $tag => $item) {
  109. if ($tag == 'item') {
  110. $rew_items[$m] = trim($item);
  111. $rew_items_count[$m] = intval($item['count']);
  112. }
  113.  
  114. $m++;
  115. }
  116. }
  117. else {
  118. $stage['reward'] = trim($ach->{$curr_stage}->reward);
  119. }
  120.  
  121. $stage['points'] = trim($ach->{$curr_stage}->points);
  122. $achievements[$i]['stage'][$x] = $stage;
  123. $achievements[$i]['stage'][$x]['monsters'] = $monsters;
  124. $achievements[$i]['stage'][$x]['monsters_count'] = $monsters_count;
  125. $achievements[$i]['stage'][$x]['items'] = $items;
  126. $achievements[$i]['stage'][$x]['items_count'] = $items_count;
  127. $achievements[$i]['stage'][$x]['rew_items'] = $rew_items;
  128. $achievements[$i]['stage'][$x]['rew_items_count'] = $rew_items_count;
  129. }
  130.  
  131. $i++;
  132. }
  133. }
  134.  
  135. return $achievements;
  136. }
  137. else {
  138. message('error', lang('achievement_error_1', true));
  139. }
  140. }
  141.  
  142. public function loadXMLforArray($xml)
  143. {
  144. $achievements = [];
  145.  
  146. if ($xml !== false) {
  147. $i = 1;
  148.  
  149. foreach ($xml->achievements->children() as $tag => $ach) {
  150. if ($tag == 'achievement') {
  151. $achievements[$i]['uid'] = trim($ach->uid);
  152. $achievements[$i]['type'] = trim($ach->type);
  153. $achievements[$i]['name'] = trim($ach->name);
  154. $achievements[$i]['img'] = trim($ach->img);
  155. $achievements[$i]['class'] = trim($ach->class);
  156. $achievements[$i]['req_lvl'] = trim($ach->req_lvl);
  157. $achievements[$i]['req_mlvl'] = trim($ach->req_mlvl);
  158. $achievements[$i]['req_reset'] = trim($ach->req_reset);
  159. $achievements[$i]['req_greset'] = trim($ach->req_greset);
  160.  
  161. if ($achievements[$i]['req_lvl'] == NULL) {
  162. $achievements[$i]['req_lvl'] = 0;
  163. }
  164.  
  165. if ($achievements[$i]['req_mlvl'] == NULL) {
  166. $achievements[$i]['req_mlvl'] = 0;
  167. }
  168.  
  169. if ($achievements[$i]['req_reset'] == NULL) {
  170. $achievements[$i]['req_reset'] = 0;
  171. }
  172.  
  173. if ($achievements[$i]['req_greset'] == NULL) {
  174. $achievements[$i]['req_greset'] = 0;
  175. }
  176.  
  177. $achievements[$i]['total_stages'] = trim($ach->total_stages);
  178.  
  179. for ($x = 1; $x <= $achievements[$i]['total_stages']; $x++) {
  180. $stage = NULL;
  181. $monsters = NULL;
  182. $monsters_count = NULL;
  183. $items = NULL;
  184. $items_count = NULL;
  185. $rew_items = NULL;
  186. $rew_items_count = NULL;
  187. $stage = [];
  188. $curr_stage = 'stage' . $x;
  189. $stage['desc'] = trim($ach->{$curr_stage}->desc);
  190.  
  191. if ($achievements[$i]['type'] == '0') {
  192. $monsters = [];
  193. $monsters_count = [];
  194. $k = 1;
  195.  
  196. foreach ($ach->{$curr_stage}->monsters->children() as $tag => $monster) {
  197. if ($tag == 'monster') {
  198. $monsters[$k] = trim($monster);
  199. $monsters_count[$k] = intval($monster['count']);
  200. }
  201.  
  202. $k++;
  203. }
  204. }
  205. else if ($achievements[$i]['type'] == '1') {
  206. $stage['zen'] = trim($ach->{$curr_stage}->zen);
  207. }
  208. else if (($achievements[$i]['type'] == '2') || ($achievements[$i]['type'] == '3') || ($achievements[$i]['type'] == '4') || ($achievements[$i]['type'] == '6') || ($achievements[$i]['type'] == '7') || ($achievements[$i]['type'] == '8') || ($achievements[$i]['type'] == '9') || ($achievements[$i]['type'] == '10') || ($achievements[$i]['type'] == '11') || ($achievements[$i]['type'] == '12') || ($achievements[$i]['type'] == '13')) {
  209. $stage['exp'] = trim($ach->{$curr_stage}->exp);
  210. }
  211. else if ($achievements[$i]['type'] == '5') {
  212. $items = [];
  213. $items_count = [];
  214. $k = 1;
  215.  
  216. foreach ($ach->{$curr_stage}->items->children() as $tag => $item) {
  217. if ($tag == 'item') {
  218. $items[$k] = trim($item);
  219. $items_count[$k] = intval($item['count']);
  220. }
  221.  
  222. $k++;
  223. }
  224. }
  225.  
  226. $stage['reward_type'] = trim($ach->{$curr_stage}->reward_type);
  227.  
  228. if ($stage['reward_type'] == '7') {
  229. $rew_items = [];
  230. $rew_items_count = [];
  231. $m = 1;
  232.  
  233. foreach ($ach->{$curr_stage}->reward->children() as $tag => $item) {
  234. if ($tag == 'item') {
  235. $rew_items[$m] = trim($item);
  236. $rew_items_count[$m] = intval($item['count']);
  237. }
  238.  
  239. $m++;
  240. }
  241. }
  242. else {
  243. $stage['reward'] = trim($ach->{$curr_stage}->reward);
  244. }
  245.  
  246. $stage['points'] = trim($ach->{$curr_stage}->points);
  247. $achievements[$i]['stage'][$x] = $stage;
  248. $achievements[$i]['stage'][$x]['monsters'] = $monsters;
  249. $achievements[$i]['stage'][$x]['monsters_count'] = $monsters_count;
  250. $achievements[$i]['stage'][$x]['items'] = $items;
  251. $achievements[$i]['stage'][$x]['items_count'] = $items_count;
  252. $achievements[$i]['stage'][$x]['rew_items'] = $rew_items;
  253. $achievements[$i]['stage'][$x]['rew_items_count'] = $rew_items_count;
  254. }
  255.  
  256. $i++;
  257. }
  258. }
  259.  
  260. return $achievements;
  261. }
  262. else {
  263. message('error', lang('achievement_error_1', true));
  264. }
  265. }
  266.  
  267. public function arrayToXML($array)
  268. {
  269. $sxe = new SimpleXMLElement('<achievement_system/>');
  270. $achievements = $sxe->addChild('achievements');
  271. $i = 1;
  272.  
  273. foreach ($array as $thisAch) {
  274. $j = 1;
  275. $achievement = $achievements->addChild('achievement');
  276. $achievement->addChild('uid', $thisAch['uid']);
  277. $achievement->addChild('type', $thisAch['type']);
  278. $achievement->addChild('name', $thisAch['name']);
  279. $achievement->addChild('img', $thisAch['img']);
  280. $achievement->addChild('class', $thisAch['class']);
  281. $achievement->addChild('total_stages', $thisAch['total_stages']);
  282. $achievement->addChild('req_lvl', $thisAch['req_lvl']);
  283. $achievement->addChild('req_mlvl', $thisAch['req_mlvl']);
  284. $achievement->addChild('req_reset', $thisAch['req_reset']);
  285. $achievement->addChild('req_greset', $thisAch['req_greset']);
  286.  
  287. foreach ($thisAch['stage'] as $thisStage) {
  288. $k = 1;
  289. $l = 1;
  290. $m = 1;
  291. $stage = $achievement->addChild('stage' . $j);
  292. $stage->addChild('desc', $thisStage['desc']);
  293.  
  294. if ($thisAch['type'] == '0') {
  295. $monsters = $stage->addChild('monsters');
  296.  
  297. foreach ($thisStage['monsters'] as $thisMonster) {
  298. $monster = $monsters->addChild('monster', $thisMonster);
  299. $monster->addAttribute('count', $thisStage['monsters_count'][$k]);
  300. $k++;
  301. }
  302. }
  303. else if ($thisAch['type'] == '1') {
  304. $stage->addChild('zen', $thisStage['zen']);
  305. }
  306. else if ($thisAch['type'] == '5') {
  307. $items = $stage->addChild('items');
  308.  
  309. foreach ($thisStage['items'] as $thisItem) {
  310. $item = $items->addChild('item', $thisItem);
  311. .............................................................................
  312. ...................................
  313. ................
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement