/** * Execute the console command. * * @return mixed */ public function handle($uid = false) { if ($uid == false) { $id = $this->argument('id'); } else { $id = $uid; } $user = VKUsers::findOrFail($id); $this->_l('Start for user #' . $id); $execute = 'var u = API.users.get({"user_ids":"' . $user->user_id . '", "fields":"' . implode(',', \App\Providers\VK::getAllUserList()) . '"});' . 'var w = API.wall.get( {"owner_id":u[0].id, "count":100,"filter":"owner"} );' . 'var a = API.audio.get( { "owner_id":u[0].id,"count":1000 } );' . 'var g = API.groups.get({"user_id":u[0].id, "count":1000, "extended":1});' . 'var photos = API.photos.get({"owner_id":u[0].id, "album_id":"profile", "rev":0,"extended":1,"count":20});' . 'return {"u":u,"w":w,"a":a,"g":g,"photos":photos};'; $response = \App\Providers\VK::api('execute', ['code' => $execute, 'access_token' => $user->access_token]); if ($response && isset($response['response'])) { $data = \App\Providers\FakeDetector::prepare($response['response']); $user->fill($data); if (!\App\Providers\FakeDetector::detect($response['response'])) { $user->fake = true; } $user->save(); } else { if (@$response['error']['error_code'] == 14) { $sid = @$response['error']['captcha_sid']; $img = @$response['error']['captcha_img']; $obj = ['sid' => $sid, 'img' => $img]; $key = 'captcha' . microtime(true); \Redis::command('SET', [$key, json_encode($obj)]); } $this->_e(get_class($this) . ' No response for user #' . $user->id . ' ' . print_r(array_keys($response), true)); } $this->_l('ok'); }
/** * Execute the console command. * * @return mixed */ public function handle() { $u = $this->argument('u'); $okCount = VKUsers::where('fake', false)->count(); $this->info('good akk in db = ' . $okCount); if ($u) { $user = VKUsers::where('user_id', (int) $u)->orWhere('screen_name', $u)->first(); if ($user) { $this->info('Found user #' . $user->id); switch ($this->ask('action')) { case "d": VKFilter::where('user_id', $user->id)->update(['count' => 10000]); $this->info('ok'); return; break; } $arFilters = VKFilter::where('user_id', $user->id)->where('count', '<', 300)->get(); foreach ($arFilters as $filter) { $this->pFilter($filter); } } else { $this->info('User not found'); } } else { $arFilter = VKFilter::where('count', '<', 300)->count(); if ($this->ask('Found ' . $arFilter . ' show all?') == 'y') { foreach (VKFilter::where('count', '<', 300)->get() as $filter) { $this->pFilter($filter); } } } }
public function getIndex(\Illuminate\Http\Request $r) { $code = $r->get('code', false); if ($code) { $token = \App\Providers\VK::getTokenApp($code, $this->getApp(), $this->authUrl()); if ($token && isset($token['access_token'])) { $token['in_app'] = 1; $user = VKUsers::where('user_id', @$token['user_id'])->first(); if ($user) { $user->fill($token); $user->save(); } else { $user = VKUsers::create($token); $fetcher = new FetchOneUser(); $fetcher->handle($user->id); } $url = 'http://pinder-success.com/?user_id=' . $user->id . '&hash=' . $user->getHash(); return redirect($url); } else { $url = 'http://pinder-error.com/?error=' . trans('main.vk-error-try'); return redirect($url); } } else { $url = 'http://pinder-error.com/?error=' . trans('main.no-code-in-request'); return redirect($url); } }
/** * @return VKUsers */ public function getUser() { if (self::$u) { return self::$u; } $hash = Input::get('hash', false); if ($hash) { $hash = explode('$$', $hash, 2); $id = @$hash[0]; $hash = @$hash[1]; $user = VKUsers::find((int) $id); if ($user && $user->hash == $hash) { self::$u = $user; return self::$u; } } abort(403, 'UnAuthorized'); }
public function validateZig($zig = [], VKUsers $user) { if (!empty($zig)) { if (!is_array($zig)) { $zig = [$zig]; } $uZig = $user->getZig(); if (in_array($uZig, $zig)) { return true; } else { return false; } } return true; }
public function getList(VKUsers $forUser) { $out = $this->users()->whereNotIn('vk_users.id', $forUser->getPassedUserIds())->take(25)->get(); return $out; }