Advertisement
Guest User

Untitled

a guest
Jul 13th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQL 1.60 KB | None | 0 0
  1. <?php
  2.  
  3. $xml = simplexml_load_file('furnidata.xml');
  4.  
  5. foreach ($xml->xpath('//roomitemtypes') AS $v) {
  6.     foreach ($v->furnitype AS $v) {
  7.         $name = (string) $v->attributes()->classname;
  8.         $line = (string) $v->furniline;
  9.  
  10.         $item[$line][$name] = [
  11.             (string) $v->name,
  12.             's',
  13.             (INT) $v->xdim,
  14.             (INT) $v->ydim,
  15.             (INT) $v->canstandon,
  16.             (INT) $v->cansiton,
  17.             (INT) $v->canlayon === 1 ? 'bed' : 'default',
  18.         ];
  19.     }
  20. }
  21.  
  22. foreach ($xml->xpath('//wallitemtypes') AS $v) {
  23.     foreach ($v->furnitype AS $v) {
  24.         $name = (string) $v->attributes()->classname;
  25.         $line = (string) $v->furniline;
  26.  
  27.         $item[$line][$name] = [
  28.             (string) $v->name,
  29.             'i',
  30.             (INT) $v->xdim,
  31.             (INT) $v->ydim,
  32.             (INT) $v->canstandon,
  33.             (INT) $v->cansiton,
  34.             (INT) $v->canlayon === 1 ? 'bed' : 'default',
  35.         ];
  36.     }
  37. }
  38.  
  39. ksort($item, SORT_FLAG_CASE | SORT_NATURAL);
  40.  
  41. foreach ($item AS $k => $v) {
  42.     ksort($item[$k], SORT_FLAG_CASE | SORT_NATURAL);
  43. }
  44.  
  45. // print_r($item); exit;
  46.  
  47. $i = 1;
  48.  
  49. foreach ($item AS $k => $v) {
  50.     foreach ($v AS $x => $y) {
  51.         echo "INSERT INTO catalog_items (id, page_id, item_id, catalog_name) VALUES ({$i}, 0, {$i}, \"{$x}\");\n";
  52.         echo "INSERT INTO items_base (id, sprite_id, public_name, item_name, type, width, length, is_walkable, can_sit, interaction_type) VALUES ({$i}, {$i}, \"{$y[0]}\", \"{$x}\", \"{$y[1]}\", {$y[2]}, {$y[3]}, {$y[4]}, {$y[5]}, \"{$y[6]}\");\n";
  53.         $i++;
  54.     }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement