Ejemplo n.º 1
0
 public function getISOCode($ip = null)
 {
     $location = null;
     if ($ip) {
         $location = GeoIP::getLocation($ip);
     } else {
         $location = GeoIP::getLocation();
     }
     return strtolower($location['isoCode']);
 }
 /**
  * Show the application dashboard to the user.
  *
  * @return Response
  */
 public function index()
 {
     if (Auth::user()) {
         $countryId = Auth::user()->country_id;
     } else {
         $location = GeoIPFacade::getLocation();
         $countryId = Country::where('country_code', '=', $location['isoCode'])->first()->id;
     }
     $questions = Question::whereNotNull('questions.user_id')->whereNotNull('questions.question_category_id')->whereNotNull('questions.country_id')->where('questions.is_displayed', '=', 1)->where('questions.country_id', '=', $countryId)->where('questions_countries.country_id', '=', $countryId)->with('author')->with('category')->with('country')->join('questions_countries', 'questions.id', '=', 'questions_countries.question_id')->orderBy('questions_countries.count', 'DESC')->limit(5)->get();
     $allQuestions = Question::orderBy('updated_at', 'DESC')->paginate(10);
     return view('pages.home', compact('questions', 'allQuestions'));
 }
Ejemplo n.º 3
0
 public static function detectUserLocation()
 {
     $city = [NULL];
     if (auth()->check()) {
         $user = auth()->user();
         // $city = $user->profile->city()->get();
     } else {
         $user_location = GeoIP::getLocation();
         $city = City::where('slug', $user_location['city'])->get();
     }
     if (empty($city[0])) {
         $city[0] = City::first();
     }
     view()->share('user_city', $city[0]);
 }
 public function vote(Request $request)
 {
     $profile = Profile::find($request->input('profile'));
     $location = (object) GeoIP::getLocation();
     if ($this->allowedToVote($location->ip) == true && $profile != null) {
         $profile->votes = $profile->votes + 1;
         $profile->save();
         // Save or update Voting table //
         $votes = Voting::where('ip_address', $location->ip)->first();
         if ($votes != null) {
             $votes->last_vote = Carbon::now();
             $votes->save();
             return redirect('/process?response=1&profile_id=' . $request->input('profile'));
         } else {
             $vote = Voting::create(['ip_address' => $location->ip, 'last_vote' => Carbon::now(), 'last_profile' => $request->input('profile'), 'geoip_tracking' => json_encode($location)]);
             if ($vote) {
                 return redirect('/process?response=2&profile_id=' . $request->input('profile'));
             }
             return redirect('/process?response=3');
         }
     }
     return redirect('/process?response=4');
 }
 /**
  * Scans ip for viruses and Location info.
  *
  * @param $data
  * @return array|bool|float|int|string
  */
 private function ipScan($data)
 {
     $ip_scan = new \VirusTotal\Ip(getenv('VIRUSTOTAL_API_KEY'));
     $ip_resp = $ip_scan->getReport($data);
     $location = GeoIP::getLocation('232.223.11.11');
     if (isset($location)) {
         $ip_resp['location'] = $location;
     }
     return $ip_resp;
 }
 /**
  * Show the application registration form.
  *
  * @return \Illuminate\Http\Response
  */
 public function getRegister()
 {
     $location = GeoIPFacade::getLocation();
     $countries = Country::whereNull('countries.deleted_at')->select(array('countries.id', 'countries.name', 'countries.country_code', 'countries.icon as icon'))->get('countries');
     return view('auth.register', compact('location', 'countries'));
 }
Ejemplo n.º 7
0
 public function hash(Request $request, $key)
 {
     $link = DB::table('keys')->where('key', '=', $key)->get();
     if ($link) {
         $current_ip = $request->getClientIp();
         $test = app('Illuminate\\Routing\\UrlGenerator')->previous();
         // $name = $this->get_title($test);
         $name = 'google.com';
         $location = GeoIPFacade::getLocation('202.142.69.126');
         $os_info = parser::detect();
         //City data
         if (!City::where('city_name', $location['city'])->count()) {
             $city = new City();
             $city_id = $city->insertGetId(['city_name' => $location['city']]);
         } else {
             $city_id = City::where('city_name', $location['city'])->value('id');
         }
         //Country Data
         if (!Country::where('country_name', $location['country'])->count()) {
             $country = new Country();
             $country_id = $country->insertGetId(['country_name' => $location['country']]);
         } else {
             $country_id = Country::where('country_name', $location['country'])->value('id');
         }
         //Os Data
         if (!Operating_system::where('operating_system', $os_info['osFamily'])->count()) {
             $os = new Operating_system();
             $os_id = $os->insertGetId(['operating_system' => $os_info['osFamily']]);
         } else {
             $os_id = Operating_system::where('operating_system', $os_info['osFamily'])->value('id');
         }
         //Browser_data
         if (!Browser::where('browser_name', $os_info['browserFamily'])->count()) {
             $browser = new Browser();
             $browser_id = $browser->insertGetId(['browser_name' => $os_info['browserFamily']]);
         } else {
             $browser_id = Browser::where('browser_name', $os_info['browserFamily'])->value('id');
         }
         //Redirected Website data
         $website_hits = new Redirected_websites();
         $website_hits->user_id = $link[0]->user_id;
         $website_hits->url_id = $link[0]->id;
         $website_hits->city_id = $city_id;
         $website_hits->country_id = $country_id;
         $website_hits->website_url = $test;
         $website_hits->website_name = $name;
         $website_hits->browser_id = $browser_id;
         $website_hits->os_id = $os_id;
         $website_hits->is_mobile = $os_info['isMobile'];
         $website_hits->is_tablet = $os_info['isTablet'];
         $website_hits->is_desktop = $os_info['isDesktop'];
         //Hits data
         $data = new Hit();
         $data->url_ip = $current_ip;
         $data->url_id = $link[0]->id;
         $data->save();
         $website_hits->save();
         //Deep linking
         if (parser::isMobile()) {
             if (parser::osFamily() == 'Apple iOS') {
                 //link for apple store
             } elseif (parser::osFamily() == 'Windows') {
                 return redirect('https://www.microsoft.com/en-us/store/apps/google/9wzdncrfhx3w');
             } elseif (parser::osFamily() == 'Blackberry') {
                 //link for blackberry store
             } elseif (parser::osFamily() == 'AndroidOS') {
                 return redirect('https://play.google.com/store/apps/details?id=com.facebook.katana&hl=en');
             }
         }
         if (parser::isMobile()) {
             if (parser::osFamily() == 'Apple iOS') {
                 //link for apple store
             } elseif (parser::osFamily() == 'Windows') {
                 return redirect('https://www.microsoft.com/en-us/store/apps/google/9wzdncrfhx3w');
             } elseif (parser::osFamily() == 'Blackberry') {
                 //link for blackberry store
             } elseif (parser::osFamily() == 'AndroidOS') {
                 return redirect('https://play.google.com/store/apps/details?id=com.facebook.katana&hl=en');
             }
         } else {
             return redirect($link[0]->url);
         }
     } else {
         return redirect('/');
     }
 }