Pda.php 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. <?php
  2. namespace WhichBrowser\Analyser\Header\Useragent\Device;
  3. use WhichBrowser\Constants;
  4. use WhichBrowser\Data;
  5. use WhichBrowser\Model\Family;
  6. use WhichBrowser\Model\Version;
  7. trait Pda
  8. {
  9. private function detectPda($ua)
  10. {
  11. if (!preg_match('/(CASIO|Palm|Psion|pdQ|COM|airboard|sharp|pda|POCKET-E|OASYS|NTT\/PI)/ui', $ua)) {
  12. return;
  13. }
  14. $this->detectCasio($ua);
  15. $this->detectPalm($ua);
  16. $this->detectPsion($ua);
  17. $this->detectSonyMylo($ua);
  18. $this->detectSonyAirboard($ua);
  19. $this->detectSharpZaurus($ua);
  20. $this->detectSharpShoin($ua);
  21. $this->detectPanasonicPocketE($ua);
  22. $this->detectFujitsuOasys($ua);
  23. $this->detectNttPetitWeb($ua);
  24. }
  25. /* Casio */
  26. private function detectCasio($ua)
  27. {
  28. if (preg_match('/Product\=CASIO\/([^\);]+)[\);]/ui', $ua, $match)) {
  29. $this->data->device->manufacturer = 'Casio';
  30. $this->data->device->identified |= Constants\Id::MATCH_UA;
  31. $this->data->device->type = Constants\DeviceType::PDA;
  32. if ($match[1] == 'CASSIOPEIA BE') {
  33. $this->data->device->model = 'Cassiopeia';
  34. }
  35. if ($match[1] == 'PPP101') {
  36. $this->data->device->model = 'Pocket PostPet';
  37. $this->data->device->carrier = 'DoCoMo';
  38. }
  39. }
  40. }
  41. /* Palm */
  42. private function detectPalm($ua)
  43. {
  44. if (preg_match('/PalmOS/iu', $ua, $match)) {
  45. $this->data->os->name = 'Palm OS';
  46. $this->data->device->type = Constants\DeviceType::PDA;
  47. if (preg_match('/PalmOS ([0-9.]*)/iu', $ua, $match)) {
  48. $this->data->os->version = new Version([ 'value' => $match[1] ]);
  49. }
  50. if (preg_match('/; ([^;)]+)\)/u', $ua, $match)) {
  51. $device = Data\DeviceModels::identify('palmos', $match[1]);
  52. if ($device->identified) {
  53. $device->identified |= $this->data->device->identified;
  54. $this->data->device = $device;
  55. }
  56. }
  57. if (preg_match('/PalmOS\/([a-z]+)\/model ([^\/]+)\//iu', $ua, $match)) {
  58. $device = Data\DeviceModels::identify('palmos', $match[1] . '-' . $match[2]);
  59. if ($device->identified) {
  60. $device->identified |= $this->data->device->identified;
  61. $this->data->device = $device;
  62. }
  63. }
  64. }
  65. if (preg_match('/Palm OS ([0-9.]*)/iu', $ua, $match)) {
  66. $this->data->os->name = 'Palm OS';
  67. $this->data->os->version = new Version([ 'value' => $match[1] ]);
  68. $this->data->device->type = Constants\DeviceType::PDA;
  69. }
  70. if (preg_match('/PalmSource/u', $ua, $match)) {
  71. $this->data->os->name = 'Palm OS';
  72. $this->data->os->version = null;
  73. $this->data->device->type = Constants\DeviceType::PDA;
  74. if (preg_match('/PalmSource\/([^;]+)/u', $ua, $match)) {
  75. $this->data->device->model = $match[1];
  76. $this->data->device->identified = Constants\Id::PATTERN;
  77. }
  78. if (isset($this->data->device->model) && $this->data->device->model) {
  79. $device = Data\DeviceModels::identify('palmos', $this->data->device->model);
  80. if ($device->identified) {
  81. $device->identified |= $this->data->device->identified;
  82. $this->data->device = $device;
  83. }
  84. }
  85. }
  86. /* Some model markers */
  87. if (preg_match('/PalmPilot Pro/ui', $ua, $match)) {
  88. $this->data->device->manufacturer = 'Palm';
  89. $this->data->device->model = 'Pilot Professional';
  90. $this->data->device->identified |= Constants\Id::MATCH_UA;
  91. }
  92. if (preg_match('/pdQbrowser/ui', $ua, $match)) {
  93. $this->data->device->manufacturer = 'Kyocera';
  94. $this->data->device->model = 'QCP-6035';
  95. $this->data->device->identified |= Constants\Id::MATCH_UA;
  96. }
  97. }
  98. /* PSION */
  99. private function detectPsion($ua)
  100. {
  101. if (preg_match('/Psion Cpw\//iu', $ua, $match)) {
  102. $this->data->browser->name = 'WAP Browser';
  103. $this->data->browser->version = null;
  104. $this->data->browser->type = Constants\BrowserType::BROWSER;
  105. $this->data->os->name = 'EPOC';
  106. $this->data->os->family = new Family([ 'name' => 'Symbian' ]);
  107. $this->data->device->manufacturer = 'Psion';
  108. $this->data->device->identified |= Constants\Id::MATCH_UA;
  109. $this->data->device->type = Constants\DeviceType::PDA;
  110. if (preg_match('/\(([A-Z0-9]+)\)/u', $ua, $match)) {
  111. switch ($match[1]) {
  112. case 'S5':
  113. $this->data->device->model = 'Series 5mx';
  114. break;
  115. case 'S7':
  116. $this->data->device->model = 'Series 7';
  117. break;
  118. case 'RV':
  119. $this->data->device->model = 'Revo';
  120. break;
  121. }
  122. }
  123. }
  124. }
  125. /* Sony Mylo */
  126. private function detectSonyMylo($ua)
  127. {
  128. if (preg_match('/SONY\/COM([0-9])/ui', $ua, $match)) {
  129. $this->data->device->manufacturer = 'Sony';
  130. $this->data->device->model = 'Mylo ' . $match[1];
  131. $this->data->device->identified |= Constants\Id::MATCH_UA;
  132. $this->data->device->type = Constants\DeviceType::PDA;
  133. $this->data->os->reset();
  134. if (preg_match('/Qt embedded/ui', $ua, $match)) {
  135. $this->data->os->name = 'Qtopia';
  136. }
  137. }
  138. }
  139. /* Sony Airboard */
  140. private function detectSonyAirboard($ua)
  141. {
  142. if (preg_match('/SONY\/airboard\/IDT-([A-Z0-9]+)/ui', $ua, $match)) {
  143. $this->data->device->manufacturer = 'Sony';
  144. $this->data->device->model = 'Airboard ' . $match[1];
  145. $this->data->device->identified |= Constants\Id::MATCH_UA;
  146. $this->data->device->type = Constants\DeviceType::PDA;
  147. }
  148. if (preg_match('/LocationFreeTV; Airboard\/(LF-[A-Z0-9]+)/ui', $ua, $match)) {
  149. $this->data->device->manufacturer = 'Sony';
  150. $this->data->device->model = 'Airboard ' . $match[1];
  151. $this->data->device->identified |= Constants\Id::MATCH_UA;
  152. $this->data->device->type = Constants\DeviceType::PDA;
  153. }
  154. }
  155. /* Sharp Zaurus */
  156. private function detectSharpZaurus($ua)
  157. {
  158. if (preg_match('/sharp pda browser\/([0-9\.]+)/ui', $ua, $match)) {
  159. $this->data->device->manufacturer = 'Sharp';
  160. $this->data->device->model = 'Zaurus';
  161. $this->data->device->type = Constants\DeviceType::PDA;
  162. if (preg_match('/\(([A-Z0-9\-]+)\/[0-9\.]+\)/ui', $ua, $match)) {
  163. $this->data->device->model = 'Zaurus ' . $match[1];
  164. $this->data->device->identified |= Constants\Id::MATCH_UA;
  165. $this->data->device->generic = false;
  166. }
  167. }
  168. if (preg_match('/\(PDA; (SL-[A-Z][0-9]+)\/[0-9\.]/ui', $ua, $match)) {
  169. $this->data->device->manufacturer = 'Sharp';
  170. $this->data->device->model = 'Zaurus ' . $match[1];
  171. $this->data->device->type = Constants\DeviceType::PDA;
  172. $this->data->device->identified |= Constants\Id::MATCH_UA;
  173. $this->data->device->generic = false;
  174. }
  175. }
  176. /* Sharp Shoin (Word Processor) */
  177. private function detectSharpShoin($ua)
  178. {
  179. if (preg_match('/sharp wd browser\/([0-9\.]+)/ui', $ua, $match)) {
  180. $this->data->device->manufacturer = 'Sharp';
  181. $this->data->device->model = 'Mobile Shoin';
  182. $this->data->device->type = Constants\DeviceType::PDA;
  183. if (preg_match('/\(([A-Z0-9\-]+)\/[0-9\.]+\)/ui', $ua, $match)) {
  184. $this->data->device->model = 'Mobile Shoin ' . $match[1];
  185. $this->data->device->identified |= Constants\Id::MATCH_UA;
  186. $this->data->device->generic = false;
  187. }
  188. }
  189. }
  190. /* Panasonic POCKET・E */
  191. private function detectPanasonicPocketE($ua)
  192. {
  193. if (preg_match('/Product\=Panasonic\/POCKET-E/ui', $ua, $match)) {
  194. $this->data->device->manufacturer = 'Panasonic';
  195. $this->data->device->model = 'POCKET・E';
  196. $this->data->device->type = Constants\DeviceType::PDA;
  197. $this->data->device->identified |= Constants\Id::MATCH_UA;
  198. $this->data->device->generic = false;
  199. }
  200. }
  201. /* Fujitsu OASYS */
  202. private function detectFujitsuOasys($ua)
  203. {
  204. if (preg_match('/Fujitsu; OASYS/ui', $ua, $match)) {
  205. $this->data->device->manufacturer = 'Fujitsu';
  206. $this->data->device->model = 'OASYS';
  207. $this->data->device->type = Constants\DeviceType::PDA;
  208. $this->data->device->identified |= Constants\Id::MATCH_UA;
  209. $this->data->device->generic = false;
  210. if (preg_match('/eNavigator/ui', $ua, $match)) {
  211. $this->data->browser->name = 'eNavigator';
  212. $this->data->browser->version = null;
  213. $this->data->browser->type = Constants\BrowserType::BROWSER;
  214. }
  215. }
  216. }
  217. /* PetitWeb */
  218. private function detectNttPetitWeb($ua)
  219. {
  220. if (preg_match('/Product\=NTT\/(PI-[0-9]+)/ui', $ua, $match)) {
  221. $this->data->device->manufacturer = 'NTT';
  222. $this->data->device->model = 'PetitWeb ' . $match[1];
  223. $this->data->device->type = Constants\DeviceType::PDA;
  224. $this->data->device->identified |= Constants\Id::MATCH_UA;
  225. $this->data->device->generic = false;
  226. }
  227. }
  228. }