Advertisement
Guest User

Ban job

a guest
Jul 4th, 2021
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. <?php
  2.  
  3. namespace apathy\HiveSkill\Cron;
  4.  
  5. class Bans
  6. {
  7. public static function fetchBans()
  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/Bans');
  16. $fetch = \GuzzleHttp\json_decode($fetch->getBody(), true);
  17.  
  18. foreach ($fetch['Banned'] as $ban)
  19. {
  20. $server_id = 1;
  21. $steam_id = $ban['ID'];
  22. $banner_id = $ban['BannerID'];
  23. $banner_user_id = '';
  24. $duration = $ban['Duration'];
  25. $name = $ban['Name'];
  26. $reason = $ban['Reason'];
  27. $unban_time = $ban['UnbanTime'];
  28. $uid = $finder->where('ap_steam_id', $steam_id)->fetchOne();
  29.  
  30. if(!$uid)
  31. {
  32. $user_id = NULL;
  33. }
  34. else
  35. {
  36. $user_id = $uid->user_id;
  37. }
  38.  
  39. /* Submit it to the DB */
  40. $stats = $db->query("REPLACE INTO xf_ap_ns2_server_bans
  41. (server_id,
  42. steam_id,
  43. user_id,
  44. banner_id,
  45. duration,
  46. name,
  47. reason,
  48. unban_time)
  49. VALUES (?, ?, ?, ?, ?, ?, ?, ?)",
  50. [$server_id, $steam_id, $user_id, $banner_id,
  51. $duration, $name, $reason, $unban_time]);
  52. }
  53. }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement