Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

first commit

  • Loading branch information...
commit 2236083a36c7efc084f03d089c4aeaad36f68596 1 parent b8a8bb9
aktuba authored
Showing with 39 additions and 2 deletions.
  1. +35 −0 MobileDetector.php
  2. +4 −2 README.md
View
35 MobileDetector.php
@@ -0,0 +1,35 @@
+<?php
+
+class MobileDetector {
+
+ protected static $_devices = array(
+ "android" => '(android)',
+ "blackberry" => '(blackberry)',
+ "iphone" => '(iphone|ipod)',
+ "ipad" => '(ipad)',
+ "opera" => '(opera mini)',
+ "palm" => '(avantgo|blazer|elaine|hiptop|palm|plucker|xiino)',
+ "windows" => '(iemobile|ppc|smartphone|windows phone)',
+ "other" => '(kindle|mobile|mmp|midp|o2|pda|pocket|psp|symbian|smartphone|treo|up.browser|up.link|vodafone|wap)',
+ );
+
+ public static function check()
+ {
+ $result = NULL;
+
+ if (!empty($_SERVER['HTTP_USER_AGENT']))
+ {
+ foreach (static::$_devices as $device => $expr)
+ {
+ if (preg_match('~' . $expr . '~i', mb_strtolower($_SERVER['HTTP_USER_AGENT']), $matches))
+ {
+ $result = 'other' != $device ? $device : $matches[1];
+ break;
+ }
+ }
+ }
+
+ return $result;
+ }
+
+}
View
6 README.md
@@ -1,2 +1,4 @@
-MobileDetector
-==============
+MobileDetector
+==============
+
+Простейший класс для определения мобильных устройств.
Please sign in to comment.
Something went wrong with that request. Please try again.