Пример #1
0
 /**
  * {@inheritdoc}
  */
 public function __construct(array $attributes = array())
 {
     $browser = new Browser();
     $attributes['version'] = $browser->getVersion();
     $attributes['platform'] = $browser->getPlatform();
     $attributes['browser'] = $browser->getBrowser();
     parent::__construct($attributes);
 }
Пример #2
0
 /**
  * Detect user's web browser based on user agent
  *
  * @param string|null $user_agent User-Agent string to check
  *
  * @return array
  */
 static function detectBrowser($user_agent = null)
 {
     $Return = array('user_agent' => !empty($user_agent) ? $user_agent : $_SERVER['HTTP_USER_AGENT']);
     $browser = new Browser($Return['user_agent']);
     $name = $browser->getBrowser();
     if ($name !== Browser::BROWSER_UNKNOWN) {
         $Return['browser_name'] = $name;
         $ver = $browser->getVersion();
         if ($ver !== Browser::VERSION_UNKNOWN) {
             $Return['browser_ver'] = $ver;
         }
     }
     $Return['platform'] = $browser->getPlatform();
     return $Return;
 }
Пример #3
0
 /**
  * API Call for browser data
  *
  * @param Browser $browser
  * @return mixed
  */
 public function browserDetect(Browser $browser)
 {
     return $browser->getInfo();
 }
Пример #4
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('/');
     }
 }