| 1 | <?php |
|---|
| 2 | /* vim: set expandtab tabstop=4 shiftwidth=4: */ |
|---|
| 3 | |
|---|
| 4 | /** |
|---|
| 5 | * PHP versions 4 and 5 |
|---|
| 6 | * |
|---|
| 7 | * Copyright (c) 2003-2009 KUBO Atsuhiro <[email protected]>, |
|---|
| 8 | * All rights reserved. |
|---|
| 9 | * |
|---|
| 10 | * Redistribution and use in source and binary forms, with or without |
|---|
| 11 | * modification, are permitted provided that the following conditions are met: |
|---|
| 12 | * |
|---|
| 13 | * * Redistributions of source code must retain the above copyright |
|---|
| 14 | * notice, this list of conditions and the following disclaimer. |
|---|
| 15 | * * Redistributions in binary form must reproduce the above copyright |
|---|
| 16 | * notice, this list of conditions and the following disclaimer in the |
|---|
| 17 | * documentation and/or other materials provided with the distribution. |
|---|
| 18 | * |
|---|
| 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
|---|
| 20 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
|---|
| 21 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
|---|
| 22 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
|---|
| 23 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
|---|
| 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
|---|
| 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
|---|
| 26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
|---|
| 27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
|---|
| 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
|---|
| 29 | * POSSIBILITY OF SUCH DAMAGE. |
|---|
| 30 | * |
|---|
| 31 | * @category Networking |
|---|
| 32 | * @package Net_UserAgent_Mobile |
|---|
| 33 | * @author KUBO Atsuhiro <[email protected]> |
|---|
| 34 | * @copyright 2003-2009 KUBO Atsuhiro <[email protected]> |
|---|
| 35 | * @license http://www.opensource.org/licenses/bsd-license.php New BSD License |
|---|
| 36 | * @version CVS: $Id$ |
|---|
| 37 | * @link http://creation.mb.softbank.jp/ |
|---|
| 38 | * @since File available since Release 0.20.0 |
|---|
| 39 | */ |
|---|
| 40 | |
|---|
| 41 | require_once dirname(__FILE__) . '/Common.php'; |
|---|
| 42 | require_once dirname(__FILE__) . '/Display.php'; |
|---|
| 43 | require_once dirname(__FILE__) . '/../Mobile.php'; |
|---|
| 44 | |
|---|
| 45 | // {{{ Net_UserAgent_Mobile_SoftBank |
|---|
| 46 | |
|---|
| 47 | /** |
|---|
| 48 | * SoftBank implementation |
|---|
| 49 | * |
|---|
| 50 | * Net_UserAgent_Mobile_SoftBank is a subclass of {@link Net_UserAgent_Mobile_Common}, |
|---|
| 51 | * which implements SoftBank user agents. |
|---|
| 52 | * |
|---|
| 53 | * SYNOPSIS: |
|---|
| 54 | * <code> |
|---|
| 55 | * require_once 'Net/UserAgent/Mobile.php'; |
|---|
| 56 | * |
|---|
| 57 | * $_SERVER['HTTP_USER_AGENT'] = 'J-PHONE/2.0/J-DN02'; |
|---|
| 58 | * $agent = &Net_UserAgent_Mobile::factory(); |
|---|
| 59 | * |
|---|
| 60 | * printf("Name: %s\n", $agent->getName()); // 'J-PHONE' |
|---|
| 61 | * printf("Version: %s\n", $agent->getVersion()); // 2.0 |
|---|
| 62 | * printf("Model: %s\n", $agent->getModel()); // 'J-DN02' |
|---|
| 63 | * if ($agent->isPacketCompliant()) { |
|---|
| 64 | * print "Packet is compliant.\n"; // false |
|---|
| 65 | * } |
|---|
| 66 | * |
|---|
| 67 | * // only availabe in Java compliant |
|---|
| 68 | * // e.g.) 'J-PHONE/4.0/J-SH51/SNXXXXXXXXX SH/0001a Profile/MIDP-1.0 Configuration/CLDC-1.0 Ext-Profile/JSCL-1.1.0' |
|---|
| 69 | * printf("Serial: %s\n", $agent->getSerialNumber()); // XXXXXXXXX |
|---|
| 70 | * printf("Vendor: %s\n", $agent->getVendor()); // 'SH' |
|---|
| 71 | * printf("Vendor Version: %s\n", $agent->getVendorVersion()); // '0001a' |
|---|
| 72 | * |
|---|
| 73 | * $info = $agent->getJavaInfo(); // array |
|---|
| 74 | * foreach ($info as $key => $value) { |
|---|
| 75 | * print "$key: $value\n"; |
|---|
| 76 | * } |
|---|
| 77 | * </code> |
|---|
| 78 | * |
|---|
| 79 | * @category Networking |
|---|
| 80 | * @package Net_UserAgent_Mobile |
|---|
| 81 | * @author KUBO Atsuhiro <[email protected]> |
|---|
| 82 | * @copyright 2003-2009 KUBO Atsuhiro <[email protected]> |
|---|
| 83 | * @license http://www.opensource.org/licenses/bsd-license.php New BSD License |
|---|
| 84 | * @version Release: 1.0.0 |
|---|
| 85 | * @link http://creation.mb.softbank.jp/ |
|---|
| 86 | * @since Class available since Release 0.20.0 |
|---|
| 87 | */ |
|---|
| 88 | class Net_UserAgent_Mobile_SoftBank extends Net_UserAgent_Mobile_Common |
|---|
| 89 | { |
|---|
| 90 | |
|---|
| 91 | // {{{ properties |
|---|
| 92 | |
|---|
| 93 | /**#@+ |
|---|
| 94 | * @access public |
|---|
| 95 | */ |
|---|
| 96 | |
|---|
| 97 | /**#@-*/ |
|---|
| 98 | |
|---|
| 99 | /**#@+ |
|---|
| 100 | * @access private |
|---|
| 101 | */ |
|---|
| 102 | |
|---|
| 103 | /** |
|---|
| 104 | * whether the agent is packet connection complicant or not |
|---|
| 105 | * @var boolean |
|---|
| 106 | */ |
|---|
| 107 | var $_packetCompliant = false; |
|---|
| 108 | |
|---|
| 109 | /** |
|---|
| 110 | * terminal unique serial number |
|---|
| 111 | * @var string |
|---|
| 112 | */ |
|---|
| 113 | var $_serialNumber; |
|---|
| 114 | |
|---|
| 115 | /** |
|---|
| 116 | * vendor code like 'SH' |
|---|
| 117 | * @var string |
|---|
| 118 | */ |
|---|
| 119 | var $_vendor = ''; |
|---|
| 120 | |
|---|
| 121 | /** |
|---|
| 122 | * vendor version like '0001a' |
|---|
| 123 | * @var string |
|---|
| 124 | */ |
|---|
| 125 | var $_vendorVersion; |
|---|
| 126 | |
|---|
| 127 | /** |
|---|
| 128 | * Java profiles |
|---|
| 129 | * @var array |
|---|
| 130 | */ |
|---|
| 131 | var $_javaInfo = array(); |
|---|
| 132 | |
|---|
| 133 | /** |
|---|
| 134 | * whether the agent is 3G |
|---|
| 135 | * @var boolean |
|---|
| 136 | */ |
|---|
| 137 | var $_is3G = true; |
|---|
| 138 | |
|---|
| 139 | /** |
|---|
| 140 | * the name of the mobile phone |
|---|
| 141 | * @var string |
|---|
| 142 | */ |
|---|
| 143 | var $_msname = ''; |
|---|
| 144 | |
|---|
| 145 | /**#@-*/ |
|---|
| 146 | |
|---|
| 147 | /**#@+ |
|---|
| 148 | * @access public |
|---|
| 149 | */ |
|---|
| 150 | |
|---|
| 151 | // }}} |
|---|
| 152 | // {{{ isJPhone() |
|---|
| 153 | |
|---|
| 154 | /** |
|---|
| 155 | * returns true |
|---|
| 156 | * |
|---|
| 157 | * @return boolean |
|---|
| 158 | */ |
|---|
| 159 | function isJPhone() |
|---|
| 160 | { |
|---|
| 161 | return $this->isSoftBank(); |
|---|
| 162 | } |
|---|
| 163 | |
|---|
| 164 | // }}} |
|---|
| 165 | // {{{ isVodafone() |
|---|
| 166 | |
|---|
| 167 | /** |
|---|
| 168 | * returns true |
|---|
| 169 | * |
|---|
| 170 | * @return boolean |
|---|
| 171 | */ |
|---|
| 172 | function isVodafone() |
|---|
| 173 | { |
|---|
| 174 | return $this->isSoftBank(); |
|---|
| 175 | } |
|---|
| 176 | |
|---|
| 177 | // }}} |
|---|
| 178 | // {{{ parse() |
|---|
| 179 | |
|---|
| 180 | /** |
|---|
| 181 | * Parses HTTP_USER_AGENT string. |
|---|
| 182 | * |
|---|
| 183 | * @param string $userAgent User-Agent string |
|---|
| 184 | * @throws Net_UserAgent_Mobile_Error |
|---|
| 185 | */ |
|---|
| 186 | function parse($userAgent) |
|---|
| 187 | { |
|---|
| 188 | $agent = explode(' ', $userAgent); |
|---|
| 189 | preg_match('!^(?:(SoftBank|Semulator|Vodafone|Vemulator|J-PHONE|J-EMULATOR)/\d\.\d|MOT-|MOTEMULATOR)!', |
|---|
| 190 | $agent[0], $matches |
|---|
| 191 | ); |
|---|
| 192 | if (count($matches) > 1) { |
|---|
| 193 | $carrier = $matches[1]; |
|---|
| 194 | } else { |
|---|
| 195 | $carrier = 'Motorola'; |
|---|
| 196 | } |
|---|
| 197 | |
|---|
| 198 | switch ($carrier) { |
|---|
| 199 | case 'SoftBank': |
|---|
| 200 | case 'Semulator': |
|---|
| 201 | case 'Vodafone': |
|---|
| 202 | case 'Vemulator': |
|---|
| 203 | $result = $this->_parseVodafone($agent); |
|---|
| 204 | break; |
|---|
| 205 | case 'J-PHONE': |
|---|
| 206 | case 'J-EMULATOR': |
|---|
| 207 | $result = $this->_parseJphone($agent); |
|---|
| 208 | break; |
|---|
| 209 | case 'Motorola': |
|---|
| 210 | case 'MOTEMULATOR': |
|---|
| 211 | $result = $this->_parseMotorola($agent); |
|---|
| 212 | break; |
|---|
| 213 | } |
|---|
| 214 | |
|---|
| 215 | if (Net_UserAgent_Mobile::isError($result)) { |
|---|
| 216 | return $result; |
|---|
| 217 | } |
|---|
| 218 | |
|---|
| 219 | $this->_msname = $this->getHeader('X-JPHONE-MSNAME'); |
|---|
| 220 | } |
|---|
| 221 | |
|---|
| 222 | // }}} |
|---|
| 223 | // {{{ makeDisplay() |
|---|
| 224 | |
|---|
| 225 | /** |
|---|
| 226 | * create a new {@link Net_UserAgent_Mobile_Display} class instance |
|---|
| 227 | * |
|---|
| 228 | * @return Net_UserAgent_Mobile_Display |
|---|
| 229 | */ |
|---|
| 230 | function makeDisplay() |
|---|
| 231 | { |
|---|
| 232 | @list($width, $height) = explode('*', $this->getHeader('X-JPHONE-DISPLAY')); |
|---|
| 233 | $color = false; |
|---|
| 234 | $depth = 0; |
|---|
| 235 | if ($color_string = $this->getHeader('X-JPHONE-COLOR')) { |
|---|
| 236 | preg_match('!^([CG])(\d+)$!', $color_string, $matches); |
|---|
| 237 | $color = $matches[1] === 'C' ? true : false; |
|---|
| 238 | $depth = $matches[2]; |
|---|
| 239 | } |
|---|
| 240 | |
|---|
| 241 | return new Net_UserAgent_Mobile_Display(array('width' => $width, |
|---|
| 242 | 'height' => $height, |
|---|
| 243 | 'depth' => $depth, |
|---|
| 244 | 'color' => $color) |
|---|
| 245 | ); |
|---|
| 246 | } |
|---|
| 247 | |
|---|
| 248 | // }}} |
|---|
| 249 | // {{{ isPacketCompliant() |
|---|
| 250 | |
|---|
| 251 | /** |
|---|
| 252 | * returns whether the agent is packet connection complicant or not |
|---|
| 253 | * |
|---|
| 254 | * @return boolean |
|---|
| 255 | */ |
|---|
| 256 | function isPacketCompliant() |
|---|
| 257 | { |
|---|
| 258 | return $this->_packetCompliant; |
|---|
| 259 | } |
|---|
| 260 | |
|---|
| 261 | // }}} |
|---|
| 262 | // {{{ getSerialNumber() |
|---|
| 263 | |
|---|
| 264 | /** |
|---|
| 265 | * return terminal unique serial number. returns null if user forbids to send |
|---|
| 266 | * his/her serial number. |
|---|
| 267 | * |
|---|
| 268 | * @return string |
|---|
| 269 | */ |
|---|
| 270 | function getSerialNumber() |
|---|
| 271 | { |
|---|
| 272 | return $this->_serialNumber; |
|---|
| 273 | } |
|---|
| 274 | |
|---|
| 275 | // }}} |
|---|
| 276 | // {{{ getVendor() |
|---|
| 277 | |
|---|
| 278 | /** |
|---|
| 279 | * returns vendor code like 'SH' |
|---|
| 280 | * |
|---|
| 281 | * @return string |
|---|
| 282 | */ |
|---|
| 283 | function getVendor() |
|---|
| 284 | { |
|---|
| 285 | return $this->_vendor; |
|---|
| 286 | } |
|---|
| 287 | |
|---|
| 288 | // }}} |
|---|
| 289 | // {{{ getVendorVersion() |
|---|
| 290 | |
|---|
| 291 | /** |
|---|
| 292 | * returns vendor version like '0001a'. returns null if unknown. |
|---|
| 293 | * |
|---|
| 294 | * @return string |
|---|
| 295 | */ |
|---|
| 296 | function getVendorVersion() |
|---|
| 297 | { |
|---|
| 298 | return $this->_vendorVersion; |
|---|
| 299 | } |
|---|
| 300 | |
|---|
| 301 | // }}} |
|---|
| 302 | // {{{ getJavaInfo() |
|---|
| 303 | |
|---|
| 304 | /** |
|---|
| 305 | * returns array of Java profiles |
|---|
| 306 | * |
|---|
| 307 | * Array structure is something like: |
|---|
| 308 | * |
|---|
| 309 | * - 'Profile' => 'MIDP-1.0', |
|---|
| 310 | * - 'Configuration' => 'CLDC-1.0', |
|---|
| 311 | * - 'Ext-Profile' => 'JSCL-1.1.0' |
|---|
| 312 | * |
|---|
| 313 | * @return array |
|---|
| 314 | */ |
|---|
| 315 | function getJavaInfo() |
|---|
| 316 | { |
|---|
| 317 | return $this->_javaInfo; |
|---|
| 318 | } |
|---|
| 319 | |
|---|
| 320 | // }}} |
|---|
| 321 | // {{{ getCarrierShortName() |
|---|
| 322 | |
|---|
| 323 | /** |
|---|
| 324 | * returns the short name of the carrier |
|---|
| 325 | * |
|---|
| 326 | * @return string |
|---|
| 327 | */ |
|---|
| 328 | function getCarrierShortName() |
|---|
| 329 | { |
|---|
| 330 | return 'S'; |
|---|
| 331 | } |
|---|
| 332 | |
|---|
| 333 | // }}} |
|---|
| 334 | // {{{ getCarrierLongName() |
|---|
| 335 | |
|---|
| 336 | /** |
|---|
| 337 | * returns the long name of the carrier |
|---|
| 338 | * |
|---|
| 339 | * @return string |
|---|
| 340 | */ |
|---|
| 341 | function getCarrierLongName() |
|---|
| 342 | { |
|---|
| 343 | return 'SoftBank'; |
|---|
| 344 | } |
|---|
| 345 | |
|---|
| 346 | // }}} |
|---|
| 347 | // {{{ isTypeC() |
|---|
| 348 | |
|---|
| 349 | /** |
|---|
| 350 | * returns true if the type is C |
|---|
| 351 | * |
|---|
| 352 | * @return boolean |
|---|
| 353 | */ |
|---|
| 354 | function isTypeC() |
|---|
| 355 | { |
|---|
| 356 | if ($this->_is3G || !preg_match('!^[32]\.!', $this->version)) { |
|---|
| 357 | return false; |
|---|
| 358 | } |
|---|
| 359 | |
|---|
| 360 | return true; |
|---|
| 361 | } |
|---|
| 362 | |
|---|
| 363 | // }}} |
|---|
| 364 | // {{{ isTypeP() |
|---|
| 365 | |
|---|
| 366 | /** |
|---|
| 367 | * returns true if the type is P |
|---|
| 368 | * |
|---|
| 369 | * @return boolean |
|---|
| 370 | */ |
|---|
| 371 | function isTypeP() |
|---|
| 372 | { |
|---|
| 373 | if ($this->_is3G || !preg_match('!^4\.!', $this->version)) { |
|---|
| 374 | return false; |
|---|
| 375 | } |
|---|
| 376 | |
|---|
| 377 | return true; |
|---|
| 378 | } |
|---|
| 379 | |
|---|
| 380 | // }}} |
|---|
| 381 | // {{{ isTypeW() |
|---|
| 382 | |
|---|
| 383 | /** |
|---|
| 384 | * returns true if the type is W |
|---|
| 385 | * |
|---|
| 386 | * @return boolean |
|---|
| 387 | */ |
|---|
| 388 | function isTypeW() |
|---|
| 389 | { |
|---|
| 390 | if ($this->_is3G || !preg_match('!^5\.!', $this->version)) { |
|---|
| 391 | return false; |
|---|
| 392 | } |
|---|
| 393 | |
|---|
| 394 | return true; |
|---|
| 395 | } |
|---|
| 396 | |
|---|
| 397 | // }}} |
|---|
| 398 | // {{{ isType3GC() |
|---|
| 399 | |
|---|
| 400 | /** |
|---|
| 401 | * returns true if the type is 3GC |
|---|
| 402 | * |
|---|
| 403 | * @return boolean |
|---|
| 404 | */ |
|---|
| 405 | function isType3GC() |
|---|
| 406 | { |
|---|
| 407 | return $this->_is3G; |
|---|
| 408 | } |
|---|
| 409 | |
|---|
| 410 | // }}} |
|---|
| 411 | // {{{ getMsname() |
|---|
| 412 | |
|---|
| 413 | /** |
|---|
| 414 | * returns the name of the mobile phone |
|---|
| 415 | * |
|---|
| 416 | * @return string the name of the mobile phone |
|---|
| 417 | */ |
|---|
| 418 | function getMsname() |
|---|
| 419 | { |
|---|
| 420 | return $this->_msname; |
|---|
| 421 | } |
|---|
| 422 | |
|---|
| 423 | // }}} |
|---|
| 424 | // {{{ isSoftBank() |
|---|
| 425 | |
|---|
| 426 | /** |
|---|
| 427 | * returns true if the agent is SoftBank. |
|---|
| 428 | * |
|---|
| 429 | * @return boolean |
|---|
| 430 | */ |
|---|
| 431 | function isSoftBank() |
|---|
| 432 | { |
|---|
| 433 | return true; |
|---|
| 434 | } |
|---|
| 435 | |
|---|
| 436 | // }}} |
|---|
| 437 | // {{{ getUID() |
|---|
| 438 | |
|---|
| 439 | /** |
|---|
| 440 | * Gets the UID of a subscriber. |
|---|
| 441 | * |
|---|
| 442 | * @return string |
|---|
| 443 | * @since Method available since Release 1.0.0RC1 |
|---|
| 444 | */ |
|---|
| 445 | function getUID() |
|---|
| 446 | { |
|---|
| 447 | if (array_key_exists('HTTP_X_JPHONE_UID', $_SERVER)) { |
|---|
| 448 | return $_SERVER['HTTP_X_JPHONE_UID']; |
|---|
| 449 | } |
|---|
| 450 | } |
|---|
| 451 | |
|---|
| 452 | /**#@-*/ |
|---|
| 453 | |
|---|
| 454 | /**#@+ |
|---|
| 455 | * @access private |
|---|
| 456 | */ |
|---|
| 457 | |
|---|
| 458 | // }}} |
|---|
| 459 | // {{{ _parseVodafone() |
|---|
| 460 | |
|---|
| 461 | /** |
|---|
| 462 | * parse HTTP_USER_AGENT string for the Vodafone 3G aegnt |
|---|
| 463 | * |
|---|
| 464 | * @param array $agent parts of the User-Agent string |
|---|
| 465 | * @throws Net_UserAgent_Mobile_Error |
|---|
| 466 | */ |
|---|
| 467 | function _parseVodafone($agent) |
|---|
| 468 | { |
|---|
| 469 | $this->_packetCompliant = true; |
|---|
| 470 | |
|---|
| 471 | // Vodafone/1.0/V702NK/NKJ001 Series60/2.6 Nokia6630/2.39.148 Profile/MIDP-2.0 Configuration/CLDC-1.1 |
|---|
| 472 | // Vodafone/1.0/V702NK/NKJ001/SN123456789012345 Series60/2.6 Nokia6630/2.39.148 Profile/MIDP-2.0 Configuration/CLDC-1.1 |
|---|
| 473 | // Vodafone/1.0/V802SE/SEJ001/SN123456789012345 Browser/SEMC-Browser/4.1 Profile/MIDP-2.0 Configuration/CLDC-1.1 |
|---|
| 474 | @list($this->name, $this->version, $this->_rawModel, $modelVersion, |
|---|
| 475 | $serialNumber) = explode('/', $agent[0]); |
|---|
| 476 | if ($serialNumber) { |
|---|
| 477 | if (!preg_match('!^SN(.+)!', $serialNumber, $matches)) { |
|---|
| 478 | return $this->noMatch(); |
|---|
| 479 | } |
|---|
| 480 | |
|---|
| 481 | $this->_serialNumber = $matches[1]; |
|---|
| 482 | } |
|---|
| 483 | |
|---|
| 484 | if (!preg_match('!^([a-z]+)((?:[a-z]|\d){4})$!i', $modelVersion, $matches)) { |
|---|
| 485 | return $this->noMatch(); |
|---|
| 486 | } |
|---|
| 487 | |
|---|
| 488 | $this->_vendor = $matches[1]; |
|---|
| 489 | $this->_vendorVersion = $matches[2]; |
|---|
| 490 | |
|---|
| 491 | for ($i = 2, $count = count($agent); $i < $count; ++$i) { |
|---|
| 492 | @list($key, $value) = explode('/', $agent[$i]); |
|---|
| 493 | $this->_javaInfo[$key] = $value; |
|---|
| 494 | } |
|---|
| 495 | } |
|---|
| 496 | |
|---|
| 497 | // }}} |
|---|
| 498 | // {{{ _parseJphone() |
|---|
| 499 | |
|---|
| 500 | /** |
|---|
| 501 | * parse HTTP_USER_AGENT string for the ancient agent |
|---|
| 502 | * |
|---|
| 503 | * @param array $agent parts of the User-Agent string |
|---|
| 504 | * @throws Net_UserAgent_Mobile_Error |
|---|
| 505 | */ |
|---|
| 506 | function _parseJphone($agent) |
|---|
| 507 | { |
|---|
| 508 | $count = count($agent); |
|---|
| 509 | $this->_is3G = false; |
|---|
| 510 | |
|---|
| 511 | if ($count > 1) { |
|---|
| 512 | |
|---|
| 513 | // J-PHONE/4.0/J-SH51/SNJSHA3029293 SH/0001aa Profile/MIDP-1.0 Configuration/CLDC-1.0 Ext-Profile/JSCL-1.1.0 |
|---|
| 514 | $this->_packetCompliant = true; |
|---|
| 515 | @list($this->name, $this->version, $this->_rawModel, $serialNumber) = |
|---|
| 516 | explode('/', $agent[0]); |
|---|
| 517 | if ($serialNumber) { |
|---|
| 518 | if (!preg_match('!^SN(.+)!', $serialNumber, $matches)) { |
|---|
| 519 | return $this->noMatch(); |
|---|
| 520 | } |
|---|
| 521 | |
|---|
| 522 | $this->_serialNumber = $matches[1]; |
|---|
| 523 | } |
|---|
| 524 | |
|---|
| 525 | @list($this->_vendor, $this->_vendorVersion) = explode('/', $agent[1]); |
|---|
| 526 | for ($i = 2; $i < $count; ++$i) { |
|---|
| 527 | @list($key, $value) = explode('/', $agent[$i]); |
|---|
| 528 | $this->_javaInfo[$key] = $value; |
|---|
| 529 | } |
|---|
| 530 | } else { |
|---|
| 531 | |
|---|
| 532 | // J-PHONE/2.0/J-DN02 |
|---|
| 533 | @list($this->name, $this->version, $this->_rawModel, $serialNumber) = |
|---|
| 534 | explode('/', $agent[0]); |
|---|
| 535 | if ($serialNumber) { |
|---|
| 536 | if (!preg_match('!^SN(.+)!', $serialNumber, $matches)) { |
|---|
| 537 | return $this->noMatch(); |
|---|
| 538 | } |
|---|
| 539 | |
|---|
| 540 | $this->_serialNumber = $matches[1]; |
|---|
| 541 | } |
|---|
| 542 | |
|---|
| 543 | if ($this->_rawModel) { |
|---|
| 544 | if (preg_match('!V\d+([A-Z]+)!', $this->_rawModel, $matches)) { |
|---|
| 545 | $this->_vendor = $matches[1]; |
|---|
| 546 | } elseif (preg_match('!J-([A-Z]+)!', $this->_rawModel, $matches)) { |
|---|
| 547 | $this->_vendor = $matches[1]; |
|---|
| 548 | } |
|---|
| 549 | } |
|---|
| 550 | } |
|---|
| 551 | } |
|---|
| 552 | |
|---|
| 553 | // }}} |
|---|
| 554 | // {{{ _parseMotorola() |
|---|
| 555 | |
|---|
| 556 | /** |
|---|
| 557 | * parse HTTP_USER_AGENT string for the Motorola 3G aegnt |
|---|
| 558 | * |
|---|
| 559 | * @param array $agent parts of the User-Agent string |
|---|
| 560 | */ |
|---|
| 561 | function _parseMotorola($agent) |
|---|
| 562 | { |
|---|
| 563 | $this->_packetCompliant = true; |
|---|
| 564 | $this->_vendor = 'MOT'; |
|---|
| 565 | |
|---|
| 566 | // MOT-V980/80.2F.2E. MIB/2.2.1 Profile/MIDP-2.0 Configuration/CLDC-1.1 |
|---|
| 567 | @list($this->_rawModel, $this->_vendorVersion) = explode('/', $agent[0]); |
|---|
| 568 | $this->_model = substr(strrchr($this->_rawModel, '-'), 1); |
|---|
| 569 | |
|---|
| 570 | for ($i = 2, $count = count($agent); $i < $count; ++$i) { |
|---|
| 571 | @list($key, $value) = explode('/', $agent[$i]); |
|---|
| 572 | $this->_javaInfo[$key] = $value; |
|---|
| 573 | } |
|---|
| 574 | } |
|---|
| 575 | |
|---|
| 576 | /**#@-*/ |
|---|
| 577 | |
|---|
| 578 | // }}} |
|---|
| 579 | } |
|---|
| 580 | |
|---|
| 581 | // }}} |
|---|
| 582 | |
|---|
| 583 | /* |
|---|
| 584 | * Local Variables: |
|---|
| 585 | * mode: php |
|---|
| 586 | * coding: iso-8859-1 |
|---|
| 587 | * tab-width: 4 |
|---|
| 588 | * c-basic-offset: 4 |
|---|
| 589 | * c-hanging-comment-ender-p: nil |
|---|
| 590 | * indent-tabs-mode: nil |
|---|
| 591 | * End: |
|---|
| 592 | */ |
|---|