Exemplo n.º 1
0
Arquivo: UA.php Projeto: fromearth/php
 /**
  * デバイスおよびデバイスタイプ解析
  * @return void
  */
 private static function scanDevice()
 {
     $UA = self::getUserAgent();
     if (strpos($UA, 'iPhone') !== false) {
         // iPhone
         self::$device = 'iphone';
         self::$type = 'sp';
     } elseif (strpos($UA, 'iPad') !== false) {
         // iPad
         self::$device = 'ipad';
         self::$type = 'tb';
     } elseif (strpos($UA, 'Android') !== false) {
         // Android
         self::$device = 'android';
         if (strpos($UA, 'Mobile') !== false) {
             // Android(SmartPhone)
             self::$type = 'sp';
         } else {
             // Android(Tablet)
             self::$type = 'tb';
         }
     } elseif (strpos($UA, 'Windows Phone') !== false) {
         // WindowsPhone
         self::$device = 'windows_phone';
         self::$type = 'sp';
     } elseif (strpos($UA, 'BlackBerry') !== false) {
         // BlackBerry
         self::$device = 'black_berry';
         self::$type = 'sp';
     } elseif (!empty($UA)) {
         // PC
         self::$device = 'pc';
         self::$type = 'pc';
     } else {
         // 不明
         self::$device = 'unknown';
         self::$type = 'pc';
     }
 }