Ejemplo n.º 1
0
 function __construct($device = null)
 {
     $this->version = intval(Kurogo::getSiteVar('MOBI_SERVICE_VERSION'));
     $this->userAgent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '';
     if (KurogoWebBridge::forceNativePlatform($pagetype, $platform, $browser)) {
         $this->setDevice("{$pagetype}-{$platform}-{$browser}");
     } else {
         if ($device && strlen($device)) {
             Kurogo::log(LOG_DEBUG, "Setting device to {$device} (override)", "deviceDetection");
             $this->setDevice($device);
             // user override of device detection
         } else {
             if (isset($_COOKIE[$this->cookieKey()])) {
                 $cookie = $_COOKIE[$this->cookieKey()];
                 if (get_magic_quotes_gpc()) {
                     $cookie = stripslashes($cookie);
                 }
                 $this->setDeviceFromCookieString($cookie);
                 Kurogo::log(LOG_DEBUG, "Setting device to " . $this->getDevice() . " (cookie)", "deviceDetection");
             } else {
                 if (isset($_SERVER['HTTP_USER_AGENT'])) {
                     $this->classification = $this->detectDevice($this->userAgent);
                     $this->setDeviceCookie();
                 }
             }
         }
     }
     // Do this after caching and setting cookies or the value of TABLET_ENABLED would be effectively cached
     if ($this->classification['pagetype'] == 'tablet' && !Kurogo::getOptionalSiteVar('TABLET_ENABLED', 1)) {
         $this->classification['pagetype'] = 'compliant';
         if ($this->classification['platform'] == 'ipad') {
             $this->classification['platform'] = 'iphone';
             // currently not used but just in case
         }
     }
     // Do this after caching and setting cookies or the value of TOUCH_ENABLED would be effectively cached
     if ($this->classification['pagetype'] == 'touch' && !Kurogo::getOptionalSiteVar('TOUCH_ENABLED', 1)) {
         $this->classification['pagetype'] = 'basic';
     }
 }
Ejemplo n.º 2
0
 function __construct($device = null, $deviceCacheTimeout = null, $override = null)
 {
     $this->version = intval(Kurogo::getSiteVar('MOBI_SERVICE_VERSION'));
     if (isset($override)) {
         $this->override = $override;
         $this->setOverrideCookie($override);
     } elseif (isset($_COOKIE['deviceClassificationOverride'])) {
         $this->override = $_COOKIE['deviceClassificationOverride'];
     }
     $this->userAgent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '';
     if (KurogoWebBridge::forceNativePlatform($pagetype, $platform, $browser)) {
         $this->setDevice("{$pagetype}-{$platform}-{$browser}");
     } else {
         if ($device && strlen($device)) {
             Kurogo::log(LOG_DEBUG, "Setting device to {$device} (override)", "deviceDetection");
             $this->setDevice($device);
             // user override of device detection
             $this->setDeviceCookie($deviceCacheTimeout);
         } else {
             if (isset($_COOKIE[self::cookieKey()])) {
                 $cookie = $_COOKIE[self::cookieKey()];
                 if (get_magic_quotes_gpc()) {
                     $cookie = stripslashes($cookie);
                 }
                 $this->setDeviceFromCookieString($cookie, $deviceCacheTimeout);
                 Kurogo::log(LOG_DEBUG, "Setting device to " . $this->getDevice() . " (cookie)", "deviceDetection");
             } else {
                 if (isset($_SERVER['HTTP_USER_AGENT'])) {
                     $this->classification = $this->detectDevice($this->userAgent);
                     $this->setDeviceCookie($deviceCacheTimeout);
                 }
             }
         }
     }
     // Do this after caching and setting cookies or the values
     // of TABLET_ENABLED and COMPUTER_TABLET_ENABLED would be effectively cached
     if (Kurogo::getOptionalSiteVar('TABLET_ENABLED', 1)) {
         if ($this->classification['platform'] == 'computer') {
             if (Kurogo::getOptionalSiteVar('COMPUTER_TABLET_ENABLED', 1)) {
                 $this->classification['pagetype'] = 'tablet';
             } else {
                 $this->classification['pagetype'] = 'compliant';
             }
         }
     } else {
         if ($this->classification['pagetype'] == 'tablet') {
             $this->classification['pagetype'] = 'compliant';
             // platform ipad is currently not used but just in case:
             if ($this->classification['platform'] == 'ipad') {
                 $this->classification['platform'] = 'iphone';
             }
         }
     }
     // Touch pagetype is no longer supported.  Remap to basic:
     if ($this->classification['pagetype'] == 'touch') {
         $this->classification['pagetype'] = 'basic';
     }
 }