Advertisement
xpppppppaicyber

Untitled

Aug 1st, 2024
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.92 KB | None | 0 0
  1. <?php
  2. // Set timezone Asia/Jakarta
  3. date_default_timezone_set('Asia/Jakarta');
  4.  
  5. // Current date
  6. $date = time();
  7.  
  8. // Fetch data from the API
  9. $data = json_decode(file_get_contents("https://pixels-server.pixels.xyz/cache/marketplace/listings/count"), true);
  10.  
  11. $supply = $data['counts'];
  12. $prices = $data['prices'];
  13.  
  14. // Resource itemName
  15. $WoodworkingItem = [
  16.     'itm_woodplank_04',
  17.     'itm_axe_03',
  18.     'itm_sawdust',
  19.     'itm_axe_02',
  20.     'itm_woodplank_03',
  21.     'itm_pickaxe_03',
  22.     'itm_pickaxe_02',
  23.     'itm_woodplank_02',
  24.     'itm_woodplank_01',
  25.     'itm_Glue',
  26.     'itm_woodchest_04',
  27.     'itm_tree_04',
  28.     'itm_tree_01',
  29.     'itm_woodenbeam',
  30.     'itm_woodplank_05',
  31.     'itm_tree_02',
  32.     'itm_pickaxe_04',
  33.     'itm_stick',
  34.     'itm_Wooden_Throne',
  35.     'itm_woodchest_05',
  36.     'itm_woodchest_03',
  37.     'itm_woodenbeam',
  38.     'itm_woodchest_02',
  39.     'itm_woodwork_kit_02',
  40.     'itm_tree_03',
  41.     'itm_woodchest_01',
  42.     'itm_woodwork_kit_03',
  43.     'itm_woodwork_kit_04',
  44.     'itm_pickaxe_05',
  45.     'itm_axe_05',
  46.     'itm_Wooden_Stool',
  47.     'itm_barn',
  48.     'itm_tree_05',
  49.     'itm_frontbench',
  50.     'itm_fireplace',
  51.     'itm_barrel01',
  52.     'itm_barrel03',
  53.     'itm_archery',
  54.     'itm_log_decoration2',
  55.     'itm_scarecrow',
  56.     'itm_barrel04'
  57. ];
  58.  
  59. // Loop through each farming item and update its corresponding JSON file
  60. foreach ($WoodworkingItem as $item) {
  61.     $jsonFile = 'data/'.$item . '.json';
  62.  
  63.     // Read existing data from JSON file
  64.     if (file_exists($jsonFile)) {
  65.         $farmingData = json_decode(file_get_contents($jsonFile), true);
  66.     } else {
  67.         $farmingData = [];
  68.     }
  69.  
  70.     // Update the data
  71.     $farmingData[] = [
  72.         'supply' => $supply[$item],
  73.         'price' => $prices[$item],
  74.         'date' => $date
  75.     ];
  76.  
  77.     // Write the updated data back to the JSON file
  78.     file_put_contents($jsonFile, json_encode($farmingData, JSON_PRETTY_PRINT));
  79. }
  80.  
  81.  
  82.  
  83.  
  84.  
  85. ?>
  86.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement