1 | <?php
|
---|
2 | /* vim: set expandtab tabstop=4 shiftwidth=4: */
|
---|
3 |
|
---|
4 | /**
|
---|
5 | * PHP versions 4 and 5
|
---|
6 | *
|
---|
7 | * LICENSE: This source file is subject to version 3.0 of the PHP license
|
---|
8 | * that is available through the world-wide-web at the following URI:
|
---|
9 | * http://www.php.net/license/3_0.txt. If you did not receive a copy of
|
---|
10 | * the PHP License and are unable to obtain it through the web, please
|
---|
11 | * send a note to license@php.net so we can mail you a copy immediately.
|
---|
12 | *
|
---|
13 | * @category Networking
|
---|
14 | * @package Net_UserAgent_Mobile
|
---|
15 | * @author KUBO Atsuhiro <iteman@users.sourceforge.net>
|
---|
16 | * @copyright 2003-2007 KUBO Atsuhiro <iteman@users.sourceforge.net>
|
---|
17 | * @license http://www.php.net/license/3_0.txt PHP License 3.0
|
---|
18 | * @version CVS: $Id: EZweb.php,v 1.17 2007/02/20 15:19:07 kuboa Exp $
|
---|
19 | * @link http://www.au.kddi.com/ezfactory/tec/spec/4_4.html
|
---|
20 | * @link http://www.au.kddi.com/ezfactory/tec/spec/new_win/ezkishu.html
|
---|
21 | * @see Net_UserAgent_Mobile_Common
|
---|
22 | * @since File available since Release 0.1.0
|
---|
23 | */
|
---|
24 |
|
---|
25 | require_once(dirname(__FILE__) . '/Common.php');
|
---|
26 | require_once(dirname(__FILE__) . '/Display.php');
|
---|
27 |
|
---|
28 | // {{{ Net_UserAgent_Mobile_EZweb
|
---|
29 |
|
---|
30 | /**
|
---|
31 | * EZweb implementation
|
---|
32 | *
|
---|
33 | * Net_UserAgent_Mobile_EZweb is a subclass of
|
---|
34 | * {@link Net_UserAgent_Mobile_Common}, which implements EZweb (WAP1.0/2.0)
|
---|
35 | * user agents.
|
---|
36 | *
|
---|
37 | * SYNOPSIS:
|
---|
38 | * <code>
|
---|
39 | * require_once 'Net/UserAgent/Mobile.php';
|
---|
40 | *
|
---|
41 | * $_SERVER['HTTP_USER_AGENT'] = 'UP.Browser/3.01-HI02 UP.Link/3.2.1.2';
|
---|
42 | * $agent = &Net_UserAgent_Mobile::factory();
|
---|
43 | *
|
---|
44 | * printf("Name: %s\n", $agent->getName()); // 'UP.Browser'
|
---|
45 | * printf("Version: %s\n", $agent->getVersion()); // 3.01
|
---|
46 | * printf("DeviceID: %s\n", $agent->getDeviceID()); // 'HI02'
|
---|
47 | * printf("Server: %s\n", $agent->getServer()); // 'UP.Link/3.2.1.2'
|
---|
48 | *
|
---|
49 | * e.g.) 'UP.Browser/3.01-HI02 UP.Link/3.2.1.2 (Google WAP Proxy/1.0)'
|
---|
50 | * printf("Comment: %s\n", $agent->getComment()); // 'Google WAP Proxy/1.0'
|
---|
51 | *
|
---|
52 | * e.g.) 'KDDI-TS21 UP.Browser/6.0.2.276 (GUI) MMP/1.1'
|
---|
53 | * if ($agent->isXHTMLCompliant()) {
|
---|
54 | * print "XHTML compliant!\n"; // true
|
---|
55 | * }
|
---|
56 | * </code>
|
---|
57 | *
|
---|
58 | * @category Networking
|
---|
59 | * @package Net_UserAgent_Mobile
|
---|
60 | * @author KUBO Atsuhiro <iteman@users.sourceforge.net>
|
---|
61 | * @copyright 2003-2007 KUBO Atsuhiro <iteman@users.sourceforge.net>
|
---|
62 | * @license http://www.php.net/license/3_0.txt PHP License 3.0
|
---|
63 | * @version Release: 0.30.0
|
---|
64 | * @link http://www.au.kddi.com/ezfactory/tec/spec/4_4.html
|
---|
65 | * @link http://www.au.kddi.com/ezfactory/tec/spec/new_win/ezkishu.html
|
---|
66 | * @see Net_UserAgent_Mobile_Common
|
---|
67 | * @since Class available since Release 0.1.0
|
---|
68 | */
|
---|
69 | class Net_UserAgent_Mobile_EZweb extends Net_UserAgent_Mobile_Common
|
---|
70 | {
|
---|
71 |
|
---|
72 | // {{{ properties
|
---|
73 |
|
---|
74 | /**#@+
|
---|
75 | * @access public
|
---|
76 | */
|
---|
77 |
|
---|
78 | /**#@-*/
|
---|
79 |
|
---|
80 | /**#@+
|
---|
81 | * @access private
|
---|
82 | */
|
---|
83 |
|
---|
84 | /**
|
---|
85 | * name of the model like 'P502i'
|
---|
86 | * @var string
|
---|
87 | */
|
---|
88 | var $_model = '';
|
---|
89 |
|
---|
90 | /**
|
---|
91 | * device ID like 'TS21'
|
---|
92 | * @var string
|
---|
93 | */
|
---|
94 | var $_deviceID = '';
|
---|
95 |
|
---|
96 | /**
|
---|
97 | * server string like 'UP.Link/3.2.1.2'
|
---|
98 | * @var string
|
---|
99 | */
|
---|
100 | var $_serverName = '';
|
---|
101 |
|
---|
102 | /**
|
---|
103 | * comment like 'Google WAP Proxy/1.0'
|
---|
104 | * @var string
|
---|
105 | */
|
---|
106 | var $_comment = null;
|
---|
107 |
|
---|
108 | /**
|
---|
109 | * whether it's XHTML compliant or not
|
---|
110 | * @var boolean
|
---|
111 | */
|
---|
112 | var $_xhtmlCompliant = false;
|
---|
113 |
|
---|
114 | /**#@-*/
|
---|
115 |
|
---|
116 | /**#@+
|
---|
117 | * @access public
|
---|
118 | */
|
---|
119 |
|
---|
120 | // }}}
|
---|
121 | // {{{ isEZweb()
|
---|
122 |
|
---|
123 | /**
|
---|
124 | * returns true
|
---|
125 | *
|
---|
126 | * @return boolean
|
---|
127 | */
|
---|
128 | function isEZweb()
|
---|
129 | {
|
---|
130 | return true;
|
---|
131 | }
|
---|
132 |
|
---|
133 | // }}}
|
---|
134 | // {{{ isTUKa()
|
---|
135 |
|
---|
136 | /**
|
---|
137 | * returns true if the agent is TU-Ka
|
---|
138 | *
|
---|
139 | * @return boolean
|
---|
140 | */
|
---|
141 | function isTUKa()
|
---|
142 | {
|
---|
143 | $tuka = substr($this->_deviceID, 2, 1);
|
---|
144 | if ($this->isWAP2()) {
|
---|
145 | if ($tuka == 'U') {
|
---|
146 | return true;
|
---|
147 | }
|
---|
148 | } else {
|
---|
149 | if ($tuka == 'T') {
|
---|
150 | return true;
|
---|
151 | }
|
---|
152 | }
|
---|
153 |
|
---|
154 | return false;
|
---|
155 | }
|
---|
156 |
|
---|
157 | // }}}
|
---|
158 | // {{{ parse()
|
---|
159 |
|
---|
160 | /**
|
---|
161 | * parse HTTP_USER_AGENT string
|
---|
162 | */
|
---|
163 | function parse()
|
---|
164 | {
|
---|
165 | $agent = $this->getUserAgent();
|
---|
166 |
|
---|
167 | if (preg_match('/^KDDI-(.*)/', $agent, $matches)) {
|
---|
168 |
|
---|
169 | // KDDI-TS21 UP.Browser/6.0.2.276 (GUI) MMP/1.1
|
---|
170 | $this->_xhtmlCompliant = true;
|
---|
171 | list($this->_deviceID, $browser, $opt, $this->_serverName) =
|
---|
172 | explode(' ', $matches[1], 4);
|
---|
173 | list($this->name, $version) = explode('/', $browser);
|
---|
174 | $this->version = "$version $opt";
|
---|
175 | } else {
|
---|
176 |
|
---|
177 | // UP.Browser/3.01-HI01 UP.Link/3.4.5.2
|
---|
178 | @list($browser, $this->_serverName, $comment) =
|
---|
179 | explode(' ', $agent, 3);
|
---|
180 | list($this->name, $software) = explode('/', $browser);
|
---|
181 | list($this->version, $this->_deviceID) =
|
---|
182 | explode('-', $software);
|
---|
183 | if ($comment) {
|
---|
184 | $this->_comment =
|
---|
185 | preg_replace('/^\((.*)\)$/', '$1', $comment);
|
---|
186 | }
|
---|
187 | }
|
---|
188 |
|
---|
189 | $this->_model = $this->_deviceID;
|
---|
190 | }
|
---|
191 |
|
---|
192 | // }}}
|
---|
193 | // {{{ makeDisplay()
|
---|
194 |
|
---|
195 | /**
|
---|
196 | * create a new {@link Net_UserAgent_Mobile_Display} class instance
|
---|
197 | *
|
---|
198 | * @return object a newly created {@link Net_UserAgent_Mobile_Display}
|
---|
199 | * object
|
---|
200 | * @see Net_UserAgent_Mobile_Display
|
---|
201 | */
|
---|
202 | function makeDisplay()
|
---|
203 | {
|
---|
204 | @list($width, $height) =
|
---|
205 | explode(',', $this->getHeader('x-up-devcap-screenpixels'));
|
---|
206 | $screenDepth =
|
---|
207 | explode(',', $this->getHeader('x-up-devcap-screendepth'));
|
---|
208 | $depth = $screenDepth[0] ? pow(2, (integer)$screenDepth[0]) : 0;
|
---|
209 | $color =
|
---|
210 | $this->getHeader('x-up-devcap-iscolor') === '1' ? true : false;
|
---|
211 | return new Net_UserAgent_Mobile_Display(array(
|
---|
212 | 'width' => $width,
|
---|
213 | 'height' => $height,
|
---|
214 | 'color' => $color,
|
---|
215 | 'depth' => $depth
|
---|
216 | )
|
---|
217 | );
|
---|
218 | }
|
---|
219 |
|
---|
220 | // }}}
|
---|
221 | // {{{ getModel()
|
---|
222 |
|
---|
223 | /**
|
---|
224 | * returns name of the model (device ID) like 'TS21'
|
---|
225 | *
|
---|
226 | * @return string
|
---|
227 | */
|
---|
228 | function getModel()
|
---|
229 | {
|
---|
230 | return $this->_model;
|
---|
231 | }
|
---|
232 |
|
---|
233 | // }}}
|
---|
234 | // {{{ getDeviceID()
|
---|
235 |
|
---|
236 | /**
|
---|
237 | * returns device ID like 'TS21'
|
---|
238 | *
|
---|
239 | * @return string
|
---|
240 | */
|
---|
241 | function getDeviceID()
|
---|
242 | {
|
---|
243 | return $this->_deviceID;
|
---|
244 | }
|
---|
245 |
|
---|
246 | // }}}
|
---|
247 | // {{{ getServer()
|
---|
248 |
|
---|
249 | /**
|
---|
250 | * returns server string like 'UP.Link/3.2.1.2'
|
---|
251 | *
|
---|
252 | * @return string
|
---|
253 | */
|
---|
254 | function getServer()
|
---|
255 | {
|
---|
256 | return $this->_serverName;
|
---|
257 | }
|
---|
258 |
|
---|
259 | // }}}
|
---|
260 | // {{{ getComment()
|
---|
261 |
|
---|
262 | /**
|
---|
263 | * returns comment like 'Google WAP Proxy/1.0'. returns null if nothinng.
|
---|
264 | *
|
---|
265 | * @return boolean
|
---|
266 | */
|
---|
267 | function getComment()
|
---|
268 | {
|
---|
269 | return $this->_comment;
|
---|
270 | }
|
---|
271 |
|
---|
272 | // }}}
|
---|
273 | // {{{ isXHTMLCompliant()
|
---|
274 |
|
---|
275 | /**
|
---|
276 | * returns whether it's XHTML compliant or not
|
---|
277 | *
|
---|
278 | * @return boolean
|
---|
279 | */
|
---|
280 | function isXHTMLCompliant()
|
---|
281 | {
|
---|
282 | return $this->_xhtmlCompliant;
|
---|
283 | }
|
---|
284 |
|
---|
285 | // }}}
|
---|
286 | // {{{ getCarrierShortName()
|
---|
287 |
|
---|
288 | /**
|
---|
289 | * returns the short name of the carrier
|
---|
290 | *
|
---|
291 | * @return string
|
---|
292 | */
|
---|
293 | function getCarrierShortName()
|
---|
294 | {
|
---|
295 | return 'E';
|
---|
296 | }
|
---|
297 |
|
---|
298 | // }}}
|
---|
299 | // {{{ getCarrierLongName()
|
---|
300 |
|
---|
301 | /**
|
---|
302 | * returns the long name of the carrier
|
---|
303 | *
|
---|
304 | * @return string
|
---|
305 | */
|
---|
306 | function getCarrierLongName()
|
---|
307 | {
|
---|
308 | return 'EZweb';
|
---|
309 | }
|
---|
310 |
|
---|
311 | // }}}
|
---|
312 | // {{{ isWIN()
|
---|
313 |
|
---|
314 | /**
|
---|
315 | * Returns whether the agent is CDMA 1X WIN or not.
|
---|
316 | *
|
---|
317 | * @return boolean
|
---|
318 | */
|
---|
319 | function isWIN()
|
---|
320 | {
|
---|
321 | return substr($this->_deviceID, 2, 1) == 3 ? true : false;
|
---|
322 | }
|
---|
323 |
|
---|
324 | /**#@-*/
|
---|
325 |
|
---|
326 | /**#@+
|
---|
327 | * @access private
|
---|
328 | */
|
---|
329 |
|
---|
330 | /**#@-*/
|
---|
331 |
|
---|
332 | // }}}
|
---|
333 | }
|
---|
334 |
|
---|
335 | // }}}
|
---|
336 |
|
---|
337 | /*
|
---|
338 | * Local Variables:
|
---|
339 | * mode: php
|
---|
340 | * coding: iso-8859-1
|
---|
341 | * tab-width: 4
|
---|
342 | * c-basic-offset: 4
|
---|
343 | * c-hanging-comment-ender-p: nil
|
---|
344 | * indent-tabs-mode: nil
|
---|
345 | * End:
|
---|
346 | */
|
---|
347 | ?>
|
---|