Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace apathy\HiveSkill\Cron;
- class Bans
- {
- public static function fetchBans()
- {
- $app = \XF::app();
- $db = \XF::db();
- $finder = \XF::finder('XF:User');
- $fetch = $app
- ->http()
- ->client()
- ->get('https://api.fortreeforums.xyz/shitbox/Bans');
- $fetch = \GuzzleHttp\json_decode($fetch->getBody(), true);
- foreach ($fetch['Banned'] as $ban)
- {
- $server_id = 1;
- $steam_id = $ban['ID'];
- $banner_id = $ban['BannerID'];
- $banner_user_id = '';
- $duration = $ban['Duration'];
- $name = $ban['Name'];
- $reason = $ban['Reason'];
- $unban_time = $ban['UnbanTime'];
- $uid = $finder->where('ap_steam_id', $steam_id)->fetchOne();
- if(!$uid)
- {
- $user_id = NULL;
- }
- else
- {
- $user_id = $uid->user_id;
- }
- /* Submit it to the DB */
- $stats = $db->query("REPLACE INTO xf_ap_ns2_server_bans
- (server_id,
- steam_id,
- user_id,
- banner_id,
- duration,
- name,
- reason,
- unban_time)
- VALUES (?, ?, ?, ?, ?, ?, ?, ?)",
- [$server_id, $steam_id, $user_id, $banner_id,
- $duration, $name, $reason, $unban_time]);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement