Ejemplo n.º 1
0
 static function identifyList($list, $model, $cleanup = true)
 {
     $original = $model;
     if ($cleanup) {
         $model = DeviceModels::cleanup($model);
     }
     $device = (object) array('type' => TYPE_MOBILE, 'identified' => ID_NONE, 'manufacturer' => null, 'model' => $model, 'identifier' => $original, 'generic' => false);
     foreach ($list as $m => $v) {
         $match = false;
         if (substr($m, -1) == "!") {
             $match = preg_match('/^' . substr($m, 0, -1) . '/iu', $model);
         } else {
             $match = strtolower($m) == strtolower($model);
         }
         if ($match) {
             $device->manufacturer = $v[0];
             $device->model = $v[1];
             if (isset($v[2])) {
                 $device->type = $v[2];
             }
             if (isset($v[3])) {
                 $device->flag = $v[3];
             }
             $device->identified = ID_MATCH_UA;
             if ($device->manufacturer == null && $device->model == null) {
                 $device->identified = ID_PATTERN;
             }
             return $device;
         }
     }
     return $device;
 }
Ejemplo n.º 2
0
 static function identifyList($list, $model, $cleanup = true)
 {
     $original = $model;
     if ($cleanup) {
         $model = DeviceModels::cleanup($model);
     }
     $device = (object) array('type' => TYPE_MOBILE, 'identified' => ID_NONE, 'manufacturer' => null, 'model' => $model, 'identifier' => $original, 'generic' => false);
     foreach ($list as $m => $v) {
         $match = null;
         if (DeviceModels::hasMatch($m, $model)) {
             if (substr($m, -2) == "!!") {
                 foreach ($v as $m2 => $v2) {
                     if (DeviceModels::hasMatch($m2, $model)) {
                         $match = $v2;
                         continue;
                     }
                 }
             } else {
                 $match = $v;
             }
         }
         if ($match) {
             $device->manufacturer = $match[0];
             $device->model = $match[1];
             if (isset($match[2])) {
                 $device->type = $match[2];
             }
             if (isset($match[3])) {
                 $device->flag = $match[3];
             }
             $device->identified = ID_MATCH_UA;
             if ($device->manufacturer == null && $device->model == null) {
                 $device->identified = ID_PATTERN;
             }
             return $device;
         }
     }
     return $device;
 }