1 | <?php |
---|
2 | /** |
---|
3 | * @copyright 2005-2007 OpenPNE Project |
---|
4 | * @license http://www.php.net/license/3_01.txt PHP License 3.01 |
---|
5 | */ |
---|
6 | |
---|
7 | class OpenPNE_KtaiUA |
---|
8 | { |
---|
9 | var $is_ktai = false; |
---|
10 | |
---|
11 | var $is_docomo = false; |
---|
12 | var $is_vodafone = false; |
---|
13 | var $is_au = false; |
---|
14 | var $is_willcom = false; |
---|
15 | |
---|
16 | /** |
---|
17 | * constructor |
---|
18 | */ |
---|
19 | function OpenPNE_KtaiUA($server = null) |
---|
20 | { |
---|
21 | if (is_null($server)) { |
---|
22 | $server = $_SERVER; |
---|
23 | } |
---|
24 | $this->classify($server); |
---|
25 | } |
---|
26 | |
---|
27 | /** |
---|
28 | * User-Agent の値からキャリア情報を判別する |
---|
29 | */ |
---|
30 | function classify($server) |
---|
31 | { |
---|
32 | $ua = $server['HTTP_USER_AGENT']; |
---|
33 | |
---|
34 | // DoCoMo |
---|
35 | if (!strncmp($ua, 'DoCoMo', 6)) { |
---|
36 | $this->is_docomo = true; |
---|
37 | $this->is_ktai = true; |
---|
38 | } |
---|
39 | |
---|
40 | // Vodafone(PDC) |
---|
41 | elseif (!strncmp($ua, 'J-PHONE', 7)) { |
---|
42 | $this->is_vodafone = true; |
---|
43 | $this->is_ktai = true; |
---|
44 | } |
---|
45 | // Vodafone(3G) |
---|
46 | //* Up.Browser を搭載しているものがある(auより先に評価) |
---|
47 | elseif (!strncmp($ua, 'Vodafone', 8) |
---|
48 | || !strncmp($ua, 'MOT', 3)) { |
---|
49 | $this->is_vodafone = true; |
---|
50 | $this->is_ktai = true; |
---|
51 | } |
---|
52 | // SoftBank |
---|
53 | elseif (!strncmp($ua, 'SoftBank', 8)) { |
---|
54 | $this->is_vodafone = true; |
---|
55 | $this->is_ktai = true; |
---|
56 | } |
---|
57 | |
---|
58 | // au |
---|
59 | elseif (!strncmp($ua, 'KDDI', 4) |
---|
60 | || !strncasecmp($ua, 'up.browser', 10)) { |
---|
61 | $this->is_au = true; |
---|
62 | $this->is_ktai = true; |
---|
63 | } |
---|
64 | |
---|
65 | // WILLCOM / DDIPOCKET |
---|
66 | elseif (strpos($ua, 'WILLCOM') !== false |
---|
67 | || strpos($ua, 'SHARP/WS') !== false |
---|
68 | || strpos($ua, 'DDIPOCKET') !== false) { |
---|
69 | $this->is_ktai = true; |
---|
70 | $this->is_willcom = true; |
---|
71 | } |
---|
72 | |
---|
73 | else { |
---|
74 | $this->is_ktai = false; |
---|
75 | } |
---|
76 | } |
---|
77 | |
---|
78 | function is_ktai() { return $this->is_ktai; } |
---|
79 | function is_docomo() { return $this->is_docomo; } |
---|
80 | function is_vodafone() { return $this->is_vodafone; } |
---|
81 | function is_au() { return $this->is_au; } |
---|
82 | function is_willcom() { return $this->is_willcom; } |
---|
83 | } |
---|
84 | |
---|
85 | ?> |
---|