Пример #1
0
 public function getCustomList()
 {
     if ($this->error()) {
         return $this->error();
     }
     $userList = $this->userList;
     $userListProfiles = UserList::where('user_list.id', $userList->id)->leftjoin('user_list_profile as ulp_1', 'ulp_1.user_list_id', '=', 'user_list.id')->whereNull('ulp_1.deleted_at')->leftJoin('user_list_profile as ulp_2', function ($join) {
         $join->on('ulp_2.profile_id', '=', 'ulp_1.profile_id')->whereNull('ulp_2.deleted_at');
     })->leftjoin('profile', 'ulp_1.profile_id', '=', 'profile.id')->leftjoin('profile_ban', 'profile.id', '=', 'profile_ban.profile_id')->leftjoin('users', 'profile.small_id', '=', 'users.small_id')->leftJoin('subscription', function ($join) {
         $join->on('subscription.user_list_id', '=', 'user_list.id')->whereNull('subscription.deleted_at');
     })->groupBy('profile.id')->orderBy('ulp_1.id', 'desc')->get(['ulp_1.profile_name', 'ulp_1.profile_description', 'profile.id', 'profile.display_name', 'profile.avatar_thumb', 'profile.small_id', 'profile_ban.vac', 'profile_ban.vac_banned_on', 'profile_ban.community', 'profile_ban.trade', 'users.site_admin', 'users.donation', 'users.beta', \DB::raw('max(ulp_1.created_at) as created_at'), \DB::raw('count(ulp_2.profile_id) as total'), \DB::raw('count(distinct subscription.id) as sub_count')]);
     $canSub = false;
     $subscription = null;
     if (Auth::check()) {
         $user = Auth::user();
         $userMail = $user->UserMail;
         $subscription = $user->Subscription->where('user_list_id', $userList->id)->first();
         if ($userMail && ($userMail->verify == "verified" || $userMail->pushbullet_verify == "verified")) {
             $canSub = true;
         }
     }
     $return = ['id' => $userList->id, 'title' => $userList->title, 'author' => $userList->user->display_name, 'my_list' => $this->myList(), 'can_sub' => $canSub, 'subscription' => $subscription, 'privacy' => $userList->privacy, 'sub_count' => isset($userListProfiles[0]) ? $userListProfiles[0]->sub_count : 0, 'list' => []];
     foreach ($userListProfiles as $userListProfile) {
         if (is_null($userListProfile->id)) {
             continue;
         }
         $vacBanDate = new DateTime($userListProfile->vac_banned_on);
         $return['list'][] = ['id' => $userListProfile->id, 'display_name' => $userListProfile->profile_name ?: $userListProfile->display_name, 'avatar_thumb' => $userListProfile->avatar_thumb, 'small_id' => $userListProfile->small_id, 'steam_64_bit' => Steam::to64Bit($userListProfile->small_id), 'vac' => $userListProfile->vac, 'vac_banned_on' => $vacBanDate->format("M j Y"), 'community' => $userListProfile->community, 'trade' => $userListProfile->trade, 'site_admin' => (int) $userListProfile->site_admin ?: 0, 'donation' => (int) $userListProfile->donation ?: 0, 'beta' => (int) $userListProfile->beta ?: 0, 'profile_description' => $userListProfile->profile_description, 'times_added' => ['number' => $userListProfile->total, 'time' => (new DateTime($userListProfile->created_at))->format("M j Y")]];
     }
     $multiProfile = new MultiProfile($return['list']);
     $return['list'] = $multiProfile->run();
     return $return;
 }
Пример #2
0
 public function index($steam64BitId)
 {
     $smallId = Steam::toSmallId($steam64BitId);
     if (is_array($smallId)) {
         return ['error' => 'invalid_small_id'];
     }
     $singleProfile = new SingleProfile($smallId);
     return $singleProfile->getProfile();
 }
Пример #3
0
 public function addManyToList()
 {
     $input = Input::all();
     $search = Steam::parseSearch($input['search']);
     $description = isset($input['description']) && !empty($input['description']) ? $input['description'] : null;
     if (!is_array($search)) {
         return ['error' => 'Invalid Search Option'];
     }
     $validProfile = array();
     $invalidProfile = array();
     foreach ($search as $potentialProfile) {
         $steam3Id = Steam::findUser($potentialProfile);
         if (isset($steam3Id['error'])) {
             $invalidProfile[] = $potentialProfile;
         } else {
             $validProfile[] = $steam3Id['success'];
         }
     }
     $smallIds = Steam::toSmallId($validProfile);
     $profiles = Profile::whereIn('small_id', $smallIds)->get(['small_id']);
     $profilesParsed = [];
     foreach ($smallIds as $smallId) {
         $profile = $profiles->where('small_id', $smallId)->first();
         if (is_null($profile)) {
             $profilesParsed[] = ['small_id' => $smallId];
             continue;
         }
     }
     $multiProfile = new MultiProfile($profilesParsed);
     $multiProfile->run();
     $listId = (int) $input['list_id'];
     $userList = UserList::where('id', $listId)->first();
     $userListProfiles = UserListProfile::whereIn('profile.small_id', $smallIds)->leftjoin('profile', 'profile.id', '=', 'user_list_profile.profile_id')->where('user_list_profile.user_list_id', $listId)->where('user_list_profile.deleted_at', null)->get(['profile.small_id', 'profile.id']);
     $userListProfilesSmallId = [];
     foreach ($userListProfiles as $userListProfile) {
         $userListProfilesSmallId[] = $userListProfile->small_id;
     }
     $smallIds = array_diff($smallIds, $userListProfilesSmallId);
     $profiles = Profile::whereIn('small_id', $smallIds)->get();
     $toAddtoList = [];
     foreach ($profiles as $k => $profile) {
         if (Auth::user()->unlockUser() <= $userList->UserListProfile()->count() + $k) {
             break;
         }
         $toAddtoList[] = new UserListProfile(["profile_id" => $profile->id, "profile_name" => $profile->display_name, "profile_description" => $description]);
     }
     $userList->UserListProfile()->saveMany($toAddtoList);
     $customList = new CustomList(UserList::where('id', $listId)->first());
     if ($customList->error()) {
         return $customList->error();
     }
     return $customList->getCustomList();
 }
Пример #4
0
 private function grabFromDB()
 {
     $userListProfiles = UserListProfile::select('profile.id', 'profile.display_name', 'profile.avatar_thumb', 'profile.small_id', 'profile_ban.vac', 'profile_ban.vac_banned_on', 'profile_ban.community', 'profile_ban.trade', 'users.site_admin', 'users.donation', 'users.beta', \DB::raw('max(user_list_profile.created_at) as created_at'), \DB::raw('count(user_list_profile.id) as total'))->groupBy('profile.id')->orderBy('total', 'desc')->whereNull('user_list_profile.deleted_at')->leftjoin('profile', 'user_list_profile.profile_id', '=', 'profile.id')->leftjoin('profile_ban', 'profile.id', '=', 'profile_ban.profile_id')->leftjoin('users', 'profile.small_id', '=', 'users.small_id')->take(20)->get();
     $return = [];
     foreach ($userListProfiles as $userListProfile) {
         $vacBanDate = new DateTime($userListProfile->vac_banned_on);
         $return[] = ['id' => $userListProfile->id, 'display_name' => $userListProfile->display_name, 'avatar_thumb' => $userListProfile->avatar_thumb, 'small_id' => $userListProfile->small_id, 'steam_64_bit' => Steam::to64Bit($userListProfile->small_id), 'vac' => $userListProfile->vac, 'vac_banned_on' => $vacBanDate->format("M j Y"), 'community' => $userListProfile->community, 'trade' => $userListProfile->trade, 'site_admin' => (int) $userListProfile->site_admin ?: 0, 'donation' => (int) $userListProfile->donation ?: 0, 'beta' => (int) $userListProfile->beta ?: 0, 'times_added' => ['number' => $userListProfile->total, 'time' => (new DateTime($userListProfile->created_at))->format("M j Y")]];
     }
     $multiProfile = new MultiProfile($return);
     $return = $multiProfile->run();
     $this->updateCache($return);
     return $return;
 }
Пример #5
0
 public function search($searchKey)
 {
     $searchCache = "search_key_{$searchKey}";
     if (!Cache::has($searchCache)) {
         return ['error' => 'no values'];
     }
     $search = Steam::parseSearch(Cache::pull($searchCache));
     if (Auth::check()) {
         if (count($search) > Auth::User()->unlockSearch()) {
             return ['error' => 'Too many profiles listed in search box.'];
         }
     } else {
         if (count($search) > 30) {
             return ['error' => 'Too many profiles listed in search box for a guest.'];
         }
     }
     if (!is_array($search)) {
         return ['error' => 'Invalid Search Option'];
     }
     $validProfile = array();
     $invalidProfile = array();
     foreach ($search as $potentialProfile) {
         $steam3Id = Steam::findUser($potentialProfile);
         if (isset($steam3Id['error'])) {
             $invalidProfile[] = $potentialProfile;
         } else {
             $validProfile[] = $steam3Id['success'];
         }
     }
     $smallIds = Steam::toSmallId($validProfile);
     $profiles = Profile::select('profile.id', 'profile.display_name', 'profile.avatar_thumb', 'profile.small_id', 'profile.created_at', 'profile_ban.vac', 'profile_ban.vac_banned_on', 'profile_ban.community', 'profile_ban.trade', 'users.site_admin', 'users.donation', 'users.beta', \DB::raw('max(user_list_profile.created_at) as created_at'), \DB::raw('count(user_list_profile.id) as total'))->groupBy('profile.id')->leftJoin('user_list_profile', function ($join) {
         $join->on('user_list_profile.profile_id', '=', 'profile.id')->whereNull('user_list_profile.deleted_at');
     })->whereIn('profile.small_id', $smallIds)->leftjoin('profile_ban', 'profile.id', '=', 'profile_ban.profile_id')->leftjoin('users', 'profile.small_id', '=', 'users.small_id')->get();
     $profilesParsed = [];
     foreach ($smallIds as $smallId) {
         $profile = $profiles->where('small_id', (int) $smallId)->first();
         if (is_null($profile)) {
             $profilesParsed[] = ['small_id' => $smallId];
             continue;
         }
         $vacBanDate = new DateTime($profile->vac_banned_on);
         $profilesParsed[] = ['id' => $profile->id, 'display_name' => $profile->display_name, 'avatar_thumb' => $profile->avatar_thumb, 'small_id' => (int) $smallId, 'steam_64_bit' => Steam::to64Bit($profile->small_id), 'vac' => $profile->vac, 'vac_banned_on' => $vacBanDate->format("M j Y"), 'community' => $profile->community, 'trade' => $profile->trade, 'site_admin' => (int) $profile->site_admin ?: 0, 'donation' => (int) $profile->donation ?: 0, 'beta' => (int) $profile->beta ?: 0, 'times_added' => ['number' => $profile->total ?: 0, 'time' => (new DateTime($profile->created_at))->format("M j Y")]];
     }
     $multiProfile = new MultiProfile($profilesParsed);
     $profilesParsed = $multiProfile->run();
     $return = ['title' => 'Search Result', 'list' => $profilesParsed];
     return $return;
 }
Пример #6
0
 public function index()
 {
     $latestDonation = DonationLog::whereStatus('Completed')->leftjoin('users', 'donation_log.small_id', '=', 'users.small_id')->orderBy('donation_log.id', 'desc')->take(10)->get(['donation_log.original_amount', 'users.display_name', 'users.small_id', 'users.donation', 'users.beta', 'users.site_admin']);
     $latestDonationParsed = [];
     foreach ($latestDonation as $donation) {
         $latestDonationParsed[] = ['original_amount' => $donation->original_amount, 'display_name' => $donation->display_name, 'small_id' => $donation->small_id, 'steam_64_bit' => Steam::to64bit($donation->small_id), 'donation' => (int) $donation->donation, 'beta' => (int) $donation->beta, 'site_admin' => (int) $donation->site_admin];
     }
     $latestDonation = $latestDonationParsed;
     $mostDonation = User::where('donation', '>', '0')->orderBy('donation', 'desc')->take(10)->get(['users.display_name', 'users.small_id', 'users.donation', 'users.beta', 'users.site_admin']);
     $mostDonationParsed = [];
     foreach ($mostDonation as $donation) {
         $mostDonationParsed[] = ['display_name' => $donation->display_name, 'small_id' => $donation->small_id, 'steam_64_bit' => Steam::to64bit($donation->small_id), 'donation' => (int) $donation->donation, 'beta' => (int) $donation->beta, 'site_admin' => (int) $donation->site_admin];
     }
     $mostDonation = $mostDonationParsed;
     $donationPerk = DonationPerk::orderBy('amount', 'asc')->get();
     $user = null;
     if (Auth::check()) {
         $user = Auth::user()->toArray();
         unset($user['remember_token']);
     }
     return compact('user', 'latestDonation', 'mostDonation', 'donationPerk');
 }
Пример #7
0
 public function login()
 {
     if (Auth::check() || Auth::viaRemember()) {
         return redirect()->intended('/list')->with('success', 'You have Successfully logged in!');
     }
     $steamuser = SteamAuth::Auth();
     $steam64BitId = str_replace("http://steamcommunity.com/openid/id/", "", $steamuser['steamid']);
     $steamAPI = new SteamAPI('info');
     $steamAPI->setSteamId($steam64BitId);
     $userSteamInfo = $steamAPI->run();
     if (isset($userSteamInfo->type) && $userSteamInfo->type == 'error' || !isset($userSteamInfo->response->players[0])) {
         return redirect()->intended('/')->with('error', 'There was an error trying to communicate with Steam Server.');
     }
     $userSteamInfo = $userSteamInfo->response->players[0];
     $steamAPI = new SteamAPI('friends');
     $steamAPI->setSteamId($steam64BitId);
     $userSteamFriends = $steamAPI->run();
     $simpleFriends = [];
     if (isset($userSteamFriends->friendslist)) {
         $userSteamFriends = $userSteamFriends->friendslist->friends;
         foreach ($userSteamFriends as $userSteamFriend) {
             $simpleFriends[] = Steam::toSmallId($userSteamFriend->steamid);
         }
     }
     $smallId = Steam::toSmallId($steam64BitId);
     // Try to grab user or create new one
     $user = User::firstOrCreate(['small_id' => $smallId]);
     $user->display_name = $userSteamInfo->personaname;
     $user->friendslist = json_encode($simpleFriends);
     $singleProfile = new SingleProfile($smallId);
     $singleProfile->getProfile();
     if (!$user->save()) {
         return redirect()->intended('/')->with('error', 'There was an error adding user to database');
     }
     Auth::login($user, true);
     return redirect()->intended('/list')->with('success', 'You have Successfully logged in.');
 }
Пример #8
0
 public function listList()
 {
     $return = ['my_list' => [], 'friends_list' => []];
     $user = Auth::user();
     $myLists = UserList::where('user_list.user_id', $user->id)->leftjoin('user_list_profile as ulp_1', 'ulp_1.user_list_id', '=', 'user_list.id')->groupBy('user_list.id')->orderBy('user_list.id', 'desc')->leftJoin('subscription', function ($join) {
         $join->on('subscription.user_list_id', '=', 'user_list.id')->whereNull('subscription.deleted_at');
     })->whereNull('ulp_1.deleted_at')->get(['user_list.id', 'user_list.title', 'user_list.privacy', 'user_list.created_at', \DB::raw('count(ulp_1.id) as users_in_list'), \DB::raw('count(distinct subscription.id) as sub_count')]);
     foreach ($myLists as $myList) {
         $return['my_list'][] = ['id' => $myList->id, 'title' => $myList->title, 'privacy' => $myList->privacy, 'created_at' => $myList->created_at->format("M j Y"), 'users_in_list' => $myList->users_in_list, 'sub_count' => $myList->sub_count];
     }
     if (isset($user->friendslist)) {
         $friendsList = json_decode($user->friendslist);
         $myfriendsLists = User::whereIn('users.small_id', $friendsList)->whereNotIn('user_list.privacy', [3])->whereNull('user_list_profile.deleted_at')->groupBy('user_list.id')->orderBy('user_list.id', 'desc')->leftjoin('user_list', 'user_list.user_id', '=', 'users.id')->leftjoin('user_list_profile', 'user_list.id', '=', 'user_list_profile.user_list_id')->leftjoin('profile', 'profile.small_id', '=', 'users.small_id')->leftJoin('subscription', function ($join) {
             $join->on('subscription.user_list_id', '=', 'user_list.id')->whereNull('subscription.deleted_at');
         })->having('users_in_list', '>', 0)->get(['profile.id as profile_id', 'profile.display_name', 'profile.avatar_thumb', 'profile.small_id', 'user_list.id as user_list_id', 'user_list.title', 'user_list.privacy', 'user_list.created_at', 'users.site_admin', 'users.donation', 'users.beta', \DB::raw('count(user_list_profile.created_at) as users_in_list'), \DB::raw('count(Distinct subscription.id) as sub_count')]);
         foreach ($myfriendsLists as $myfriendsList) {
             if (!isset($myfriendsList->profile_id) || empty($myfriendsList->profile_id)) {
                 continue;
             }
             $return['friends_list'][] = ['profile_id' => $myfriendsList->profile_id, 'display_name' => $myfriendsList->display_name, 'avatar_thumb' => $myfriendsList->avatar_thumb, 'steam_64_bit' => Steam::to64bit($myfriendsList->small_id), 'user_list_id' => $myfriendsList->user_list_id, 'title' => $myfriendsList->title, 'privacy' => $myfriendsList->privacy, 'created_at' => $myfriendsList->created_at->format("M j Y"), 'site_admin' => (int) $myfriendsList->site_admin ?: 0, 'donation' => (int) $myfriendsList->donation ?: 0, 'beta' => (int) $myfriendsList->beta ?: 0, 'users_in_list' => $myfriendsList->users_in_list, 'sub_count' => $myfriendsList->sub_count];
         }
     }
     return $return;
 }
Пример #9
0
 private function check()
 {
     $userMail = $this->userMail;
     $userLists = $this->userLists;
     $profiles = $this->profiles;
     $profilesToSendForNotification = [];
     $getSmallIds = [];
     foreach ($userLists as $userList) {
         $userListProfiles = $profiles->where('user_list_id', $userList->id);
         foreach ($userListProfiles as $profile) {
             if ($userList->updated_at->timestamp < $profile->updated_at->timestamp && $profile->updated_at->timestamp <= time() && $profile->updated_at->timestamp != $profile->created_at->timestamp && $userList->updated_at->timestamp != $userList->created_at->timestamp) {
                 $profilesToSendForNotification[$profile->id] = $profile;
             }
             if (!in_array($profile->small_id, $getSmallIds)) {
                 $getSmallIds[] = $profile->small_id;
             }
         }
     }
     $steamAPI = new SteamAPI('ban');
     $steamAPI->setSmallId($getSmallIds);
     $steamBans = $steamAPI->run();
     if ($steamAPI->error()) {
         $this->error = $steamAPI->errorMessage();
         return false;
     }
     if (!isset($steamBans->players[0])) {
         $this->error = 'profile_null';
         return false;
     }
     $steamBans = $steamBans->players;
     $indexSave = [];
     foreach ($steamBans as $k => $ban) {
         $indexSave[Steam::toSmallId($ban->SteamId)] = $k;
     }
     foreach ($getSmallIds as $k => $smallId) {
         if (!isset($indexSave[$smallId])) {
             continue;
         }
         $steamBan = $steamBans[$indexSave[$smallId]];
         $profile = $profiles->where('small_id', $smallId)->first();
         $newVacBanDate = new DateTime();
         $newVacBanDate->sub(new DateInterval("P{$steamBan->DaysSinceLastBan}D"));
         $profileBan = ['vac' => (int) $steamBan->NumberOfVACBans + (int) $steamBan->NumberOfGameBans, 'community' => $steamBan->CommunityBanned, 'trade' => $steamBan->EconomyBan != 'none', 'vac_banned_on' => $newVacBanDate->format('Y-m-d')];
         if ($profile->vac != $profileBan['vac'] || $profile->community != $profileBan['community'] || $profile->trade != $profileBan['trade']) {
             $oldProfileBan = ProfileBan::where('profile_id', $profile->id)->first();
             if ($profile->vac > $profileBan['vac']) {
                 $oldProfileBan->timestamps = false;
                 // Dont notify when user is unbanned (Maybe this can be an option in the future)
                 $oldProfileBan->unban = true;
             }
             $oldProfileBan->vac = $profileBan['vac'];
             $oldProfileBan->community = $profileBan['community'];
             $oldProfileBan->trade = $profileBan['trade'];
             $oldProfileBan->vac_banned_on = $profileBan['vac_banned_on'];
             $oldProfileBan->save();
             $profile->vac = $profileBan['vac'];
             $profile->community = $profileBan['community'];
             $profile->trade = $profileBan['trade'];
             $profile->vac_banned_on = $profileBan['vac_banned_on'];
             $profilesToSendForNotification[$profile->id] = $profile;
         }
     }
     if (count($profilesToSendForNotification) == 0) {
         $this->error = 'no_notify_method';
         return false;
     }
     $this->sendEmail = $userMail->verify == "verified" ? $userMail->email : false;
     $this->sendPushbullet = $userMail->pushbullet_verify == "verified" ? $userMail->pushbullet : false;
     $this->sendProfiles = $profilesToSendForNotification;
     return true;
 }
Пример #10
0
 private function updateUsingAPI()
 {
     $getSmallId = [];
     foreach ($this->refreshProfiles as $profile) {
         $smallId = $profile['profile']['small_id'];
         $key = $profile['profile_key'];
         $getSmallId[] = (int) $smallId;
         $toSaveKey[$smallId] = $key;
     }
     /* grab 'info' from web api and handle errors */
     $steamAPI = new SteamAPI('info');
     $steamAPI->setSmallId($getSmallId);
     $steamInfos = $steamAPI->run();
     if ($steamAPI->error()) {
         return ['error' => $steamAPI->errorMessage()];
     }
     if (!isset($steamInfos->response->players[0])) {
         return ['error' => 'profile_null'];
     }
     // simplify the variable
     $steamInfos = $steamInfos->response->players;
     /* grab 'ban' from web api and handle errors */
     $steamAPI = new SteamAPI('ban');
     $steamAPI->setSmallId($getSmallId);
     $steamBans = $steamAPI->run();
     if ($steamAPI->error()) {
         return ['error' => $steamAPI->errorMessage()];
     }
     if (!isset($steamBans->players[0])) {
         return ['error' => 'profile_null'];
     }
     $steamBans = $steamBans->players;
     // whereIn('profile.small_id', $getSmallId)->
     $profiles = Profile::whereIn('profile.small_id', $getSmallId)->groupBy('profile.id')->leftjoin('profile_ban', 'profile_ban.profile_id', '=', 'profile.id')->leftjoin('users', 'profile.small_id', '=', 'users.small_id')->leftjoin('user_list_profile', 'user_list_profile.profile_id', '=', 'profile.id')->whereNull('user_list_profile.deleted_at')->get(['profile.id', 'profile.small_id', 'profile.display_name', 'profile.privacy', 'profile.avatar_thumb', 'profile.avatar', 'profile.profile_created', 'profile.alias', 'profile.created_at', 'profile_ban.community', 'profile_ban.vac', 'profile_ban.trade', 'profile_ban.unban', 'users.site_admin', 'users.donation', 'users.beta', \DB::raw('max(user_list_profile.created_at) as last_added_created_at'), \DB::raw('count(user_list_profile.id) as total')]);
     $indexSave = [];
     foreach ($steamInfos as $k => $info) {
         $indexSave[Steam::toSmallId($info->steamid)] = ['steamInfos' => $k];
     }
     foreach ($steamBans as $k => $ban) {
         // Lets just not update if api didn't return for this user
         if (!isset($indexSave[Steam::toSmallId($ban->SteamId)])) {
             continue;
         }
         $indexSave[Steam::toSmallId($ban->SteamId)]['steamBans'] = $k;
     }
     $newProfiles = [];
     foreach ($getSmallId as $k => $smallId) {
         // api didn't give values for this user
         if (!isset($indexSave[$smallId])) {
             continue;
         }
         $keys = $indexSave[$smallId];
         $steamInfo = $steamInfos[$keys['steamInfos']];
         if (!isset($keys['steamBans'])) {
             continue;
         }
         // right now dont let this user get through. Figure out a better method
         $steamBan = $steamBans[$keys['steamBans']];
         $profile = $profiles->where('small_id', $smallId)->first();
         if (is_null($profile)) {
             $profile = Profile::whereSmallId($smallId)->first();
             if (!isset($profile->id)) {
                 $profile = new Profile();
                 $profile->small_id = $smallId;
             }
             if (isset($steamInfo->timecreated)) {
                 $profile->profile_created = $steamInfo->timecreated;
             }
         }
         $profile->display_name = $steamInfo->personaname;
         $profile->avatar = Steam::imgToHTTPS($steamInfo->avatarfull);
         $profile->avatar_thumb = Steam::imgToHTTPS($steamInfo->avatar);
         $profile->privacy = $steamInfo->communityvisibilitystate;
         $profile->save();
         $profileBan = $profile->ProfileBan;
         // Dont update the profile_ban if there is nothing to update
         // This has to do with in the future when I check for new bans to notify/email
         $skipProfileBan = false;
         $newVacBanDate = new DateTime();
         $newVacBanDate->sub(new DateInterval("P{$steamBan->DaysSinceLastBan}D"));
         $combinedBan = (int) $steamBan->NumberOfVACBans + (int) $steamBan->NumberOfGameBans;
         if (!isset($profileBan->id)) {
             $profileBan = new ProfileBan();
             $profileBan->profile_id = $profile->id;
             $profileBan->unban = false;
         } else {
             $skipProfileBan = $profileBan->skipProfileBanUpdate($steamBan);
             if ($profileBan->vac != (int) $steamBan->NumberOfVACBans + (int) $steamBan->NumberOfGameBans && $profileBan->vac_banned_on->format('Y-m-d') !== $newVacBanDate->format('Y-m-d')) {
                 $skipProfileBan = false;
                 $profileBan->timestamps = false;
             }
             if ($profileBan->vac > $combinedBan) {
                 $skipProfileBan = false;
                 $profileBan->timestamps = false;
                 $profileBan->unban = true;
             }
         }
         $profileBan->vac = $combinedBan;
         $profileBan->community = $steamBan->CommunityBanned;
         $profileBan->trade = $steamBan->EconomyBan != 'none';
         $profileBan->vac_banned_on = $newVacBanDate->format('Y-m-d');
         if (!$skipProfileBan) {
             $profile->ProfileBan()->save($profileBan);
         }
         /* Time to do profile_old_alias */
         /* Checks to make sure if there is already a same name before inserting new name */
         $profileOldAlias = $profile->ProfileOldAlias()->whereProfileId($profile->id)->orderBy('id', 'desc')->get();
         if ($profileOldAlias->count() == 0) {
             $profileOldAlias = new ProfileOldAlias();
             $profileOldAlias->profile_id = $profile->id;
             $profileOldAlias->seen = time();
             $profileOldAlias->seen_alias = $profile->display_name;
             $profileOldAlias->save();
         } else {
             $match = false;
             $recent = 0;
             foreach ($profileOldAlias as $oldAlias) {
                 if (!is_object($oldAlias)) {
                     continue;
                 }
                 if ($oldAlias->seen_alias == $profile->display_name) {
                     $match = true;
                     break;
                 }
                 $recent = $oldAlias->compareTime($recent);
             }
             if (!$match && $recent + Steam::$UPDATE_TIME < time()) {
                 $newAlias = new ProfileOldAlias();
                 $newAlias->profile_id = $profile->id;
                 $newAlias->seen = time();
                 $newAlias->seen_alias = $profile->display_name;
                 $profile->ProfileOldAlias()->save($newAlias);
             }
         }
         $steam64BitId = Steam::to64Bit($profile->small_id);
         $vacBanDate = new DateTime();
         $vacBanDate->sub(new DateInterval("P{$steamBan->DaysSinceLastBan}D"));
         $oldAliasArray = [];
         foreach ($profileOldAlias as $k => $oldAlias) {
             if (!is_object($oldAlias)) {
                 $oldAliasArray[] = ["newname" => $profileOldAlias->seen_alias, "timechanged" => $profileOldAlias->seen->format("M j Y")];
                 break;
             }
             $oldAliasArray[] = ["newname" => $oldAlias->seen_alias, "timechanged" => $oldAlias->seen->format("M j Y")];
         }
         $profileCheckCache = "profile_checked_";
         $currentProfileCheck = ['number' => 0, 'time' => date("M j Y", time())];
         if (Cache::has($profileCheckCache . $profile->smallId)) {
             $currentProfileCheck = Cache::get($profileCheckCache . $profile->smallId);
         }
         $newProfileCheck = ['number' => $currentProfileCheck['number'] + 1, 'time' => date("M j Y", time())];
         Cache::forever($profileCheckCache . $profile->smallId, $newProfileCheck);
         $return = ['id' => $profile->id, 'display_name' => $steamInfo->personaname, 'avatar' => Steam::imgToHTTPS($steamInfo->avatarfull), 'avatar_thumb' => Steam::imgToHTTPS($steamInfo->avatar), 'small_id' => $profile->small_id, 'steam_64_bit' => $steam64BitId, 'steam_32_bit' => Steam::to32Bit($steam64BitId), 'profile_created' => isset($steamInfo->timecreated) ? date("M j Y", $steamInfo->timecreated) : "Unknown", 'privacy' => $steamInfo->communityvisibilitystate, 'alias' => Steam::friendlyAlias(json_decode($profile->alias)), 'created_at' => $profile->created_at ? $profile->created_at->format("M j Y") : null, 'vac' => $combinedBan, 'vac_banned_on' => $vacBanDate->format("M j Y"), 'community' => $steamBan->CommunityBanned, 'trade' => $steamBan->EconomyBan != 'none', 'site_admin' => (int) $profile->site_admin ?: 0, 'donation' => (int) $profile->donation ?: 0, 'beta' => (int) $profile->beta ?: 0, 'profile_old_alias' => $oldAliasArray, 'times_checked' => $currentProfileCheck, 'times_added' => ['number' => (int) $profile->total ?: 0, 'time' => (new DateTime($profile->last_added_created_at))->format("M j Y")]];
         $newProfiles[$toSaveKey[$profile->small_id]] = $return;
         $this->updateCache($profile->small_id, $return);
     }
     // Send somewhere else to update alias
     // This takes too long for many profiles
     $randomString = str_random(12);
     $updateAliasCacheName = "update_alias_";
     if (Cache::has($updateAliasCacheName . $randomString)) {
         while (Cache::has($updateAliasCacheName . $randomString)) {
             $randomString = str_random(12);
         }
     }
     Cache::forever($updateAliasCacheName . $randomString, $getSmallId);
     shell_exec('php artisan update:alias ' . $randomString . ' > /dev/null 2>/dev/null &');
     return $newProfiles;
 }
Пример #11
0
 private function grabFromDB()
 {
     $profile = Profile::where('profile.small_id', $this->smallId)->leftjoin('profile_ban', 'profile.id', '=', 'profile_ban.profile_id')->leftjoin('users', 'profile.small_id', '=', 'users.small_id')->first(['profile.id', 'profile.display_name', 'profile.avatar', 'profile.avatar_thumb', 'profile.small_id', 'profile.profile_created', 'profile.privacy', 'profile.alias', 'profile.created_at', 'profile_ban.vac', 'profile_ban.vac_banned_on', 'profile_ban.community', 'profile_ban.trade', 'users.site_admin', 'users.donation', 'users.beta']);
     /* Copied and pasted from function above */
     $profileOldAlias = $profile->ProfileOldAlias()->whereProfileId($profile->id)->orderBy('id', 'desc')->get();
     $gettingCount = UserListProfile::whereProfileId($profile->id)->orderBy('id', 'desc')->whereNull('deleted_at')->get();
     $profileTimesAdded = ['number' => $gettingCount->count(), 'time' => isset($gettingCount[0]) ? (new DateTime($gettingCount[0]->created_at))->format("M j Y") : null];
     $profileCheckCache = "profile_checked_";
     $currentProfileCheck = ['number' => 0, 'time' => date("M j Y", time())];
     if (Cache::has($profileCheckCache . $this->smallId)) {
         $currentProfileCheck = Cache::get($profileCheckCache . $this->smallId);
     }
     $newProfileCheck = ['number' => $currentProfileCheck['number'] + 1, 'time' => date("M j Y", time())];
     Cache::forever($profileCheckCache . $this->smallId, $newProfileCheck);
     /* WOW THAT WAS SHORT!!!!! */
     $steam64BitId = Steam::to64Bit($profile->small_id);
     $oldAliasArray = [];
     foreach ($profileOldAlias as $k => $oldAlias) {
         $oldAliasArray[] = ["newname" => $oldAlias->seen_alias, "timechanged" => $oldAlias->seen->format("M j Y")];
     }
     $return = ['id' => $profile->id, 'display_name' => $profile->display_name, 'avatar' => $profile->avatar, 'small_id' => $profile->small_id, 'steam_64_bit' => $steam64BitId, 'steam_32_bit' => Steam::to32Bit($steam64BitId), 'profile_created' => isset($profile->profile_created) ? date("M j Y", $profile->profile_created) : "Unknown", 'privacy' => $profile->privacy, 'alias' => Steam::friendlyAlias(json_decode($profile->alias)), 'created_at' => $profile->created_at->format("M j Y"), 'vac' => $profile->vac, 'vac_banned_on' => $profile->vac_banned_on->format("M j Y"), 'community' => $profile->community, 'trade' => $profile->trade, 'site_admin' => (int) $profile->site_admin ?: 0, 'donation' => (int) $profile->donation ?: 0, 'beta' => (int) $profile->beta ?: 0, 'profile_old_alias' => $oldAliasArray, 'times_checked' => $currentProfileCheck, 'times_added' => $profileTimesAdded];
     return $return;
 }
Пример #12
0
 public function setSmallId($smallId)
 {
     $this->setSteamId(Steam::to64Bit($smallId));
     return $this;
 }
Пример #13
0
 public function getSteam3Id()
 {
     return Steam::toBigId($this->small_id);
 }