Example #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 = 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;
 }