VolodiaFR

Furnidata JSON Generator

Apr 6th, 2021 (edited)
691
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 6.50 KB | None | 0 0
  1. <?php
  2.  
  3.     /**
  4.     *  ______  __      ______ ______       ________                  
  5.     *  ___  / / /_____ ___  /____  /__________  __ )___  ____________
  6.     *  __  /_/ /_  __ `/_  __ \_  __ \  __ \_  __  |  / / /__  /__  /
  7.     *  _  __  / / /_/ /_  /_/ /  /_/ / /_/ /  /_/ // /_/ /__  /__  /_
  8.     *  /_/ /_/  \__,_/ /_.___//_.___/\____//_____/ \__,_/ _____/____/
  9.     *
  10.     *  @link https://www.habbobuzz.com                                                        
  11.     *  @copyright The HabboBuzz Group
  12.     *  @author Mercury (volodia)
  13.     */
  14.  
  15. header('Content-Type: application/json');
  16.  
  17. $mysqli = new mysqli("localhost","root","mysql","arcturus");
  18.  
  19. if ($mysqli->connect_errno) {
  20.   echo "Failed to connect to MySQL: " . $mysqli->connect_error;
  21.   exit();
  22. }
  23.  
  24. $resultRoomItem = $mysqli->query("SELECT * FROM items_base WHERE type = 's'");
  25. $resultWallItem = $mysqli->query("SELECT * FROM items_base WHERE type = 'i'");
  26.  
  27. /**
  28. * Put url of the furnidata json Habbo. E.g: https://www.habbo.com/gamedata/furnidata_json/1
  29. * Met l'url du furnidata en json d'Habbo. Ex: https://www.habbo.fr/gamedata/furnidata_json/1
  30. \**/
  31.  
  32. $furnidataJson = file_get_contents('https://www.habbo.com/gamedata/furnidata_json/1');
  33. //https://images.habbobuzz.com/nitro/json/Furnidata_fr.json
  34.  
  35. $json = json_decode($furnidataJson, true);
  36. $roomItem = json_encode($json['roomitemtypes']);
  37. $mobisSol = json_decode($roomItem, true);
  38.  
  39. $wallItem = json_encode($json['wallitemtypes']);
  40. $mobisMur = json_decode($wallItem, true);
  41.  
  42. foreach($mobisSol as $person => $value)
  43. {
  44.     foreach($value as $key => $personal)
  45.     {
  46.         $row = mysqli_fetch_array($resultRoomItem);
  47.         str_replace('"', '', $row['id']);
  48.  
  49.         if(isset($personal['partcolors'])):
  50.         $roomitemtypes[] = array('id' => (int)$row['id'],
  51.                                  'classname' => $row['item_name'],
  52.                                  'revision' => 0,
  53.                                  'category' => $personal['category'],
  54.                                  'defaultdir' => 0,
  55.                                  'xdim' => (int)$row['width'],
  56.                                  'ydim' => (int)$row['length'],
  57.                                  'partcolors' => $personal['partcolors'],
  58.                                  'name' => $personal['name'],
  59.                                  'description' => $personal['description'],
  60.                                  'adurl' => $personal['adurl'],
  61.                                  'offerid' => (int)$personal['id'],
  62.                                  'buyout' => $personal['buyout'],
  63.                                  'rentofferid' => $personal['rentofferid'],
  64.                                  'bc' => $personal['bc'],
  65.                                  'excludeddynamic' => $personal['excludeddynamic'],
  66.                                  'customparams' => $personal['customparams'],
  67.                                  'specialtype' => $personal['specialtype'],
  68.                                  'canstandon' => $personal['canstandon'],
  69.                                  'cansiton' => $personal['cansiton'],
  70.                                  'canlayon' => $personal['canlayon'],
  71.                                  'furniline' => $personal['furniline'],
  72.                                  'environment' => $personal['environment'],
  73.                                  'rare' => $personal['rare']
  74.                              );
  75.         else:
  76.         $roomitemtypes[] = array('id' => (int)$row['id'],
  77.                                  'classname' => $row['item_name'],
  78.                                  'revision' => 0,
  79.                                  'category' => $personal['category'],
  80.                                  'defaultdir' => 0,
  81.                                  'xdim' => (int)$row['width'],
  82.                                  'ydim' => (int)$row['length'],
  83.                                  'name' => $personal['name'],
  84.                                  'description' => $personal['description'],
  85.                                  'adurl' => $personal['adurl'],
  86.                                  'offerid' => (int)$personal['id'],
  87.                                  'buyout' => $personal['buyout'],
  88.                                  'rentofferid' => $personal['rentofferid'],
  89.                                  'bc' => $personal['bc'],
  90.                                  'excludeddynamic' => $personal['excludeddynamic'],
  91.                                  'customparams' => $personal['customparams'],
  92.                                  'specialtype' => $personal['specialtype'],
  93.                                  'canstandon' => $personal['canstandon'],
  94.                                  'cansiton' => $personal['cansiton'],
  95.                                  'canlayon' => $personal['canlayon'],
  96.                                  'furniline' => $personal['furniline'],
  97.                                  'environment' => $personal['environment'],
  98.                                  'rare' => $personal['rare']
  99.                              );
  100.             endif;
  101.     }
  102. }
  103.  
  104. foreach($mobisMur as $person => $value)
  105. {
  106.     foreach($value as $key => $personal)
  107.     {
  108.         $row = mysqli_fetch_array($resultWallItem);
  109.  
  110.         $wallitemtypes[] = array('id' => (int)$row['id'],
  111.                                  'classname' => $row['item_name'],
  112.                                  'revision' => 0,
  113.                                  'category' => $personal['category'],
  114.                                  'name' => $personal['name'],
  115.                                  'description' => $personal['description'],
  116.                                  'adurl' => $personal['adurl'],
  117.                                  'specialtype' => $personal['specialtype'],
  118.                                  'furniline' => $personal['furniline'],
  119.                                  'environment' => $personal['environment'],
  120.                                  'rare' => $personal['rare'],
  121.                                  'offerid' => (int)$personal['id'],
  122.                                  'buyout' => $personal['buyout'],
  123.                                  'rentofferid' => $personal['rentofferid'],
  124.                                  'rentbuyout' => $personal['rentbuyout'],
  125.                                  'bc' => $personal['bc'],
  126.                                  'excludeddynamic' => $personal['excludeddynamic']
  127.                              );
  128.     }
  129. }
  130.  
  131. $furnidata = array("roomitemtypes" => ['furnitype' => $roomitemtypes],
  132.                    "wallitemtypes" => ['furnitype' => $wallitemtypes]);
  133.  
  134. echo json_encode($furnidata);
Add Comment
Please, Sign In to add comment