Advertisement
Guest User

Reserved slot job

a guest
Jul 4th, 2021
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. <?php
  2.  
  3. namespace apathy\HiveSkill\Cron;
  4.  
  5. class ReservedSlots
  6. {
  7. public static function fetchSlotOwners()
  8. {
  9. $app = \XF::app();
  10. $db = \XF::db();
  11. $finder = \XF::finder('XF:User');
  12. $fetch = $app
  13. ->http()
  14. ->client()
  15. ->get('https://api.fortreeforums.xyz/shitbox/Reserved');
  16. $fetch = \GuzzleHttp\json_decode($fetch->getBody(), true);
  17.  
  18. foreach ($fetch['ids'] as $player)
  19. {
  20. $server_id = 1;
  21. $steam_id = $player;
  22. $uid = $finder->where('ap_steam_id', $steam_id)->fetchOne();
  23.  
  24. if(!$uid)
  25. {
  26. $user_id = NULL;
  27. $username = '';
  28. }
  29. else
  30. {
  31. $user_id = $uid->user_id;
  32. $username = $uid->username;
  33. }
  34.  
  35. /* Submit it to the DB */
  36. $stats = $db->query("REPLACE INTO xf_ap_ns2_server_reserved_slots
  37. (server_id,
  38. steam_id,
  39. name,
  40. user_id)
  41. VALUES (?, ?, ?, ?)",
  42. [$server_id, $steam_id, $username, $user_id]);
  43. }
  44. }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement