Пример #1
2
 public function detectDevice()
 {
     // @ https://github.com/jenssegers/agent
     $agent = new Agent();
     if ($agent->isMobile() || $agent->isTablet()) {
         if ($agent->is('android')) {
             return 'android';
         }
         if ($agent->is('iOS')) {
             return 'ios';
         }
         return $agent->platform();
     }
     if ($agent->isDesktop()) {
         if ($agent->is('Windows')) {
             return 'windows';
         }
         if ($agent->is('OS X')) {
             return 'OSX';
         }
         return 'desktop';
     }
 }
Пример #2
0
 /**
  * @medium
  * @dataProvider userAgentData
  */
 public function testUserAgents($userAgent, $isMobile, $isTablet, $version, $model, $vendor)
 {
     //make sure we're passed valid data
     if (!is_string($userAgent) || !is_bool($isMobile) || !is_bool($isTablet)) {
         $this->markTestIncomplete("The User-Agent {$userAgent} does not have sufficient information for testing.");
         return;
     }
     //setup
     $md = new Agent();
     $md->setUserAgent($userAgent);
     //is mobile?
     $this->assertEquals($md->isMobile(), $isMobile);
     //is tablet?
     $this->assertEquals($md->isTablet(), $isTablet);
     if (isset($version)) {
         foreach ($version as $condition => $assertion) {
             $this->assertEquals($assertion, $md->version($condition), 'FAILED UA (version("' . $condition . '")): ' . $userAgent);
         }
     }
     //version property tests
     if (isset($version)) {
         foreach ($version as $property => $stringVersion) {
             $v = $md->version($property);
             $this->assertSame($stringVersion, $v);
         }
     }
     //@todo: model test, not sure how exactly yet
     //@todo: vendor test. The below is theoretical, but fails 50% of the tests...
     /*if (isset($vendor)) {
           $method = "is$vendor";
           $this->assertTrue($md->{$method}(), "Expected Mobile_Detect::{$method}() to be true.");
       }*/
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $agent = new Agent();
     $set = Set::with('media', 'squares.purchase.media', 'content', 'rewards')->where('id', 1)->first();
     if ($agent->isMobile() || $agent->isTablet()) {
         return view('public.mobile.index', ['set' => $set]);
     }
     return view('public.index', ['set' => $set]);
 }
 public function testBasicMethods()
 {
     $this->assertNotEmpty($this->detect->getScriptVersion());
     $this->detect->setHttpHeaders(array('SERVER_SOFTWARE' => 'Apache/2.2.15 (Linux) Whatever/4.0 PHP/5.2.13', 'REQUEST_METHOD' => 'POST', 'HTTP_HOST' => 'home.ghita.org', 'HTTP_X_REAL_IP' => '1.2.3.4', 'HTTP_X_FORWARDED_FOR' => '1.2.3.5', 'HTTP_CONNECTION' => 'close', 'HTTP_USER_AGENT' => 'Mozilla/5.0 (iPhone; CPU iPhone OS 6_0_1 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A523 Safari/8536.25', 'HTTP_ACCEPT' => 'text/vnd.wap.wml, application/json, text/javascript, */*; q=0.01', 'HTTP_ACCEPT_LANGUAGE' => 'en-us,en;q=0.5', 'HTTP_ACCEPT_ENCODING' => 'gzip, deflate', 'HTTP_X_REQUESTED_WITH' => 'XMLHttpRequest', 'HTTP_REFERER' => 'http://mobiledetect.net', 'HTTP_PRAGMA' => 'no-cache', 'HTTP_CACHE_CONTROL' => 'no-cache', 'REMOTE_ADDR' => '11.22.33.44', 'REQUEST_TIME' => '01-10-2012 07:57'));
     //12 because only 12 start with HTTP_
     $this->assertCount(12, $this->detect->getHttpHeaders());
     $this->assertTrue($this->detect->checkHttpHeadersForMobile());
     $this->detect->setUserAgent('Mozilla/5.0 (iPhone; CPU iPhone OS 6_0_1 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A523 Safari/8536.25');
     $this->assertNotEmpty($this->detect->getUserAgent());
     $this->assertTrue($this->detect->isMobile());
     $this->assertFalse($this->detect->isTablet());
     $this->assertTrue($this->detect->isIphone());
     $this->assertTrue($this->detect->isiphone());
     $this->assertTrue($this->detect->isiOS());
     $this->assertTrue($this->detect->isios());
     $this->assertTrue($this->detect->is('iphone'));
     $this->assertTrue($this->detect->is('ios'));
 }
Пример #5
0
 public function getUA()
 {
     // Initialize UA
     $agent = new Agent();
     $browser = $agent->browser();
     // Assemble data
     $data = ['browser' => $browser, 'browser_version' => $agent->version($browser), 'languages' => array($agent->languages()), 'device' => $agent->device(), 'platform' => $agent->platform(), 'is_mobile' => $agent->isMobile(), 'is_tablet' => $agent->isTablet(), 'is_desktop' => $agent->isDesktop(), 'is_robot' => $agent->isRobot(), 'robot_name' => $agent->robot()];
     return $data;
 }
Пример #6
0
 public function getPlatform()
 {
     if ($this->agent->isPhone()) {
         return 'phone';
     }
     if ($this->agent->isTablet()) {
         return 'tablet';
     }
     if ($this->agent->isMobile()) {
         return 'mobile';
     }
     if ($this->agent->isDesktop()) {
         return 'desktop';
     }
     if ($this->agent->isRobot()) {
         return 'robot';
     }
     return null;
 }
Пример #7
0
 public function access_channel()
 {
     $agent = new Agent();
     if ($agent->isMobile()) {
         return "Mobile";
     } elseif ($agent->isTablet()) {
         return "Tablet";
     } else {
         return "Web";
     }
 }
 public function edit()
 {
     $agent = new Agent();
     if ($agent->isMobile() or $agent->isTablet()) {
         $messages = 'This feature is disabled for Mobile and Tablet devices. If you want to change profile information, do it later from allowed devices.';
         return redirect('/system/notification')->with('messages', $messages);
     } else {
         $name = \Auth::user()->name;
         $results = \DB::select('select * from users_data where name = ?', [$name]);
         return view('profile.edit')->with('results', $results);
     }
 }
 public function create()
 {
     $agent = new Agent();
     if ($agent->isMobile() or $agent->isTablet()) {
         $messages = 'This feature is disabled for Mobile and Tablet devices. If you want to make a publication do it later from allowed devices.';
         return redirect('/system/notification')->with('messages', $messages);
     } else {
         if (\Auth::user()->suspend == true) {
             $messages = 'You are now suspended. Suspended users cannot publish contents.';
             return redirect('/system/notification')->with('messages', $messages);
         } else {
             return view('publication.create');
         }
     }
 }
Пример #10
0
 public function index()
 {
     $agent = new Agent();
     if (Auth::check()) {
         if (Auth::user()->email === NULL) {
             return view('base.referral');
         }
         if ($agent->isMobile() or $agent->isTablet()) {
             return view('base.nomobile');
         }
         $users = User::orderBy('id', 'desc')->take(50)->get();
         return view('base.home', compact('users'));
     }
     return view('welcome');
 }
Пример #11
0
 public function downloadfileAction($fileid)
 {
     $agent = new Agent();
     if ($agent->isMobile() || $agent->isTablet()) {
         $params = app('\\Aimeos\\Shop\\Base\\Page')->getSections('no-mobile-page');
         return \View::make('shop::page.nomobile', $params);
     }
     $user = Auth::user();
     $context = \App::make('\\Aimeos\\Shop\\Base\\Context')->get();
     $dlManager = \MShop_Factory::createManager($context, 'download');
     $search = $dlManager->createSearch(true);
     $expr = array($search->compare('==', 'download.fileid', $fileid), $search->compare('==', 'download.userid', $user->id), $search->getConditions());
     $search->setConditions($search->combine('&&', $expr));
     $dlList = $dlManager->searchItems($search);
     $download = reset($dlList);
     $relPath = $download->getUrl();
     $disk = Storage::disk(config('shop.distros.drivename'));
     $filename = substr(strrchr($relPath, "/"), 1);
     $filesize = $disk->size($relPath);
     $expDate = Carbon::parse($download->getTimeCreated())->addDays(config('shop.distros.max-time'));
     $expiration = $expDate->toFormattedDateString();
     $today = Carbon::now();
     $downloadtotal = config('shop.distros.max-downloads');
     $downloadcount = $download->getDownloads();
     $params = app('\\Aimeos\\Shop\\Base\\Page')->getSections('download-page');
     $params['fileid'] = $fileid;
     $params['filename'] = $filename;
     $params['filesize'] = $filesize;
     $params['downloadtotal'] = $downloadtotal;
     $params['downloadcount'] = $downloadcount;
     if ($today->gt($expDate) || $downloadcount >= $downloadtotal) {
         $params['expiration'] = 'Expired';
     } else {
         $params['expiration'] = $expiration;
     }
     return \View::make('shop::page.download', $params);
 }
Пример #12
0
function isMobile() {
  $agent = new MobileDetectAgent(); 
  return ($agent->isMobile() || $agent->isTablet());
}
Пример #13
0
 /**
  * Check if the device is a tablet.
  * 
  * Return true if any type of tablet device is detected.
  *
  * @param string $userAgent deprecated
  * @param array $httpHeaders deprecated
  * @return bool 
  * @static 
  */
 public static function isTablet($userAgent = null, $httpHeaders = null)
 {
     //Method inherited from \Mobile_Detect
     return \Jenssegers\Agent\Agent::isTablet($userAgent, $httpHeaders);
 }
Пример #14
0
 private function getBodyClass()
 {
     $agent = new Agent();
     $browser_css_classes = array();
     $unsupported = [];
     if ($mobile = $agent->isMobile()) {
         $browser_css_classes[] = 'device-mobile';
     }
     if ($tablet = $agent->isTablet()) {
         $browser_css_classes[] = 'device-tablet';
     }
     if ($iphone = $agent->is('iPhone')) {
         $browser_css_classes[] = 'device-iphone';
     }
     if ($ipad = $agent->is('iPad')) {
         $browser_css_classes[] = 'device-ipad';
     }
     $other_browser = $agent->browser();
     if ($agent->browser() == "Safari") {
         $other_browser = false;
         $browser_css_classes[] = 'browser-safari';
         if ($agent->version('Safari') < 5) {
             $unsupported['browser'] = 'Safari';
         }
     }
     if ($agent->browser() == "Chrome") {
         $other_browser = false;
         $browser_css_classes[] = 'browser-chrome';
         $browser_css_classes[] = 'browser-chrome-' . (int) $agent->version('Chrome');
         if ($agent->version('Chrome') < 30) {
             $unsupported['browser'] = 'Chrome';
         }
     }
     if ($agent->browser() == "Firefox") {
         $other_browser = false;
         $browser_css_classes[] = 'browser-firefox';
         $browser_css_classes[] = 'browser-firefox-' . (int) $agent->version('Firefox');
         if ($agent->version('Firefox') < 25) {
             $unsupported['browser'] = 'Firefox';
         }
     }
     if ($browser = $agent->browser() == "IE") {
         $version = $agent->version("IE");
         $version = str_replace('.0', '', $version);
         $other_browser = false;
         $browser_css_classes[] = 'browser-ie';
         $browser_css_classes[] = 'browser-ie-' . (int) $version;
         if ((int) $version < 10) {
             $browser_css_classes[] = 'browser-lt-ie10';
         }
         if ((int) $version < 9) {
             $unsupported['browser'] = 'Internet Explorer';
         }
         $browser_css_classes[] = 'browser-ie' . $version;
     }
     if ($other_browser) {
         $browser_css_classes[] = 'browser-' . strtolower($other_browser);
         $version = (int) $agent->version($other_browser);
         $browser_css_classes[] = 'browser-' . strtolower($other_browser) . '-' . $version;
     }
     if ($agent->is('Windows')) {
         $browser_css_classes[] = 'os-windows';
     }
     if ($agent->is('OS X')) {
         $browser_css_classes[] = 'os-mac';
     }
     if ($agent->isDesktop()) {
         $browser_css_classes[] = 'desktop';
     } else {
         //Don't display errors on non-desktop devices
         $unsupported = [];
     }
     $browser_css_classes = implode(' ', $browser_css_classes);
     return $browser_css_classes;
 }
Пример #15
0
Route::get('/logout', array('as' => 'logout', 'uses' => 'UsersController@logout'));
Route::get('changePasswordView', array('as' => 'changePasswordView', 'uses' => 'UsersController@changePasswordView'));
Route::post('changePassword', array('as' => 'changePassword', 'uses' => 'UsersController@changePassword'));
Route::get('customerData', array('as' => 'customerData', 'uses' => 'CustomerController@viewCustomerData'));
Route::get('exportData', array('as' => 'exportData', 'uses' => 'CustomerController@exportCustomerData'));
Route::post('deleteData', array('as' => 'deleteCustomerData', 'uses' => 'CustomerController@deleteCustomerData'));
Route::get('contact', array('as' => 'contact', 'uses' => 'CustomerController@requestData'));
Route::post('contact', array('as' => 'contact', 'uses' => 'CustomerController@handleRequestData'));
Route::get('/', function () {
    $Agent = new Agent();
    // return View::make('index');
    if ($Agent->isMobile() && !$Agent->isTablet()) {
        return View::make('indexMobile');
    } else {
        return View::make('index');
    }
});
Route::get('/th', function () {
    Session::put('lang', 'th');
    return Redirect::to('/');
});
Route::get('/en', function () {
    Session::put('lang', 'en');
    $Agent = new Agent();
    // return View::make('index');
    if ($Agent->isMobile() && !$Agent->isTablet()) {
        return Redirect::to('/#Contact');
    } else {
        return Redirect::to('/#ContactNav');
    }
});
Пример #16
0
 /**
  * Determines if the browser is a tablet browser.
  *
  * @return bool
  */
 public function isTablet()
 {
     return $this->agent->isTablet();
 }
Пример #17
-1
 /**
  * Set the user agent field
  *
  * @param string $value
  * @return string
  */
 public function setUserAgentAttribute($value)
 {
     $agent = new Agent();
     $agent->setUserAgent($value);
     $this->browser = $agent->browser();
     $this->browser_version = $agent->version($this->browser);
     $this->platform = $agent->platform();
     $this->platform_version = $agent->version($this->platform);
     $this->device = $agent->device() && !$agent->isDesktop() ? $agent->device() : '';
     $this->device_type = $agent->isMobile() ? 'mobile' : ($agent->isTablet() ? 'tablet' : ($agent->isDesktop() ? 'desktop' : ''));
     $this->attributes['user_agent'] = $value;
 }
Пример #18
-1
 public function setUserAgentAttribute($value)
 {
     $agent = new Agent();
     $agent->setUserAgent($value);
     if ($agent->isDesktop()) {
         $platform = 'Desktop';
     } elseif ($agent->isMobile()) {
         if ($agent->isTablet()) {
             $platform = 'Tablet';
         } else {
             $platform = 'Mobile';
         }
     }
     $this->attributes['remote_platform'] = $platform;
     $this->attributes['user_agent'] = $value;
 }