-
Notifications
You must be signed in to change notification settings - Fork 25
/
Plateform.php
executable file
·56 lines (52 loc) · 1.68 KB
/
Plateform.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
// +----------------------------------------------------------------------
// | Buddy Framework
// +----------------------------------------------------------------------
// | Copyright (c) 2011 http://buddy.woshimaijia.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: xinqiyang <[email protected]>
// +----------------------------------------------------------------------
class Plateform
{
/**
* return device name
* and display devise name
* if empty $key means get device name else display device chinese name
*/
public static function device($key='')
{
if(empty($key)){
$ua = '';
if (isset($_SERVER['HTTP_USER_AGENT']))
{
$ua = $_SERVER['HTTP_USER_AGENT'];
}
if(!empty($ua))
{
if (substr_count($ua, 'Mozilla/5.0 (iPhone') == 1)
{
$app_name = 'iphone';
}
else if (substr_count($ua, 'Mozilla/5.0 (iPad') == 1)
{
$app_name = 'ipad';
}
else if (substr_count($ua, 'Mozilla/5.0 (iPod') == 1)
{
$app_name = 'ipod';
}
else if (substr_count($ua, 'Android') == 1)
{
$app_name = 'android';
}else{ //need to add wap/symbian and so on
$app_name = 'web';
}
}
return $app_name;
}
$devices = C('device');
return $devices[$key];
}
}