Changeset 17127 for branches/version-2/data/module
- Timestamp:
- 2008/03/12 16:43:11 (16 years ago)
- Location:
- branches/version-2/data/module/Net/UserAgent
- Files:
-
- 2 added
- 3 deleted
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/version-2/data/module/Net/UserAgent/Mobile.php
r15532 r17127 14 14 * @package Net_UserAgent_Mobile 15 15 * @author KUBO Atsuhiro <iteman@users.sourceforge.net> 16 * @copyright 2003-200 7KUBO Atsuhiro <iteman@users.sourceforge.net>16 * @copyright 2003-2008 KUBO Atsuhiro <iteman@users.sourceforge.net> 17 17 * @license http://www.php.net/license/3_0.txt PHP License 3.0 18 18 * @version CVS: $Id$ … … 20 20 */ 21 21 22 require_once dirname(__FILE__) . '/../../PEAR.php'; 23 require_once dirname(__FILE__) . '/Mobile/Request.php'; 22 require_once 'PEAR.php'; 24 23 25 24 // {{{ constants … … 89 88 * @package Net_UserAgent_Mobile 90 89 * @author KUBO Atsuhiro <iteman@users.sourceforge.net> 91 * @copyright 2003-200 7KUBO Atsuhiro <iteman@users.sourceforge.net>90 * @copyright 2003-2008 KUBO Atsuhiro <iteman@users.sourceforge.net> 92 91 * @license http://www.php.net/license/3_0.txt PHP License 3.0 93 * @version Release: 0.3 0.092 * @version Release: 0.31.0 94 93 * @since Class available since Release 0.1 95 94 */ … … 126 125 * If no argument is supplied, $_SERVER{'HTTP_*'} is used. 127 126 * 128 * @param mixed $stuff User-Agent string or object that works with 129 * HTTP_Request (not implemented) 127 * @param string $userAgent User-Agent string 130 128 * @return mixed a newly created Net_UserAgent_Mobile object, or a PEAR 131 129 * error object on error 132 * @see Net_UserAgent_Mobile_Request::factory() 133 */ 134 function &factory($stuff = null) 135 { 136 static $mobileRegex; 137 if (!isset($mobileRegex)) { 138 $docomoRegex = '^DoCoMo/\d\.\d[ /]'; 139 $vodafoneRegex = '^(?:(?:SoftBank|Vodafone|J-PHONE|Vemulator|J-EMULATOR)/\d\.\d|(?:MOT|MOTEMULATOR)-)'; 140 $ezwebRegex = '^(?:KDDI-[A-Z]+\d+[A-Z]? )?UP\.Browser\/'; 141 $airhphoneRegex = '^Mozilla/3\.0\((?:DDIPOCKET|WILLCOM);'; 142 $mobileRegex = 143 "(?:($docomoRegex)|($vodafoneRegex)|($ezwebRegex)|($airhphoneRegex))"; 144 } 145 146 $request = &Net_UserAgent_Mobile_Request::factory($stuff); 130 */ 131 function &factory($userAgent = null) 132 { 133 if (is_null($userAgent)) { 134 $userAgent = $_SERVER['HTTP_USER_AGENT']; 135 } 147 136 148 137 // parse User-Agent string 149 $ua = $request->get('User-Agent'); 150 $sub = 'NonMobile'; 151 if (preg_match("!$mobileRegex!", $ua, $matches)) { 152 $sub = @$matches[1] ? 'DoCoMo' : 153 (@$matches[2] ? 'Vodafone' : 154 (@$matches[3] ? 'EZweb' : 'AirHPhone')); 155 } 156 $className = "Net_UserAgent_Mobile_{$sub}"; 157 158 if (!class_exists($className)) { 159 $file = dirname(__FILE__) . "/Mobile/{$sub}.php"; 138 if (Net_UserAgent_Mobile::isDoCoMo($userAgent)) { 139 $driver = 'DoCoMo'; 140 } elseif (Net_UserAgent_Mobile::isEZweb($userAgent)) { 141 $driver = 'EZweb'; 142 } elseif (Net_UserAgent_Mobile::isSoftBank($userAgent)) { 143 $driver = 'SoftBank'; 144 } elseif (Net_UserAgent_Mobile::isWillcom($userAgent)) { 145 $driver = 'Willcom'; 146 } else { 147 $driver = 'NonMobile'; 148 } 149 150 $class = "Net_UserAgent_Mobile_$driver"; 151 152 if (!class_exists($class)) { 153 $file = str_replace('_', '/', $class) . '.php'; 160 154 if (!include_once $file) { 161 155 return PEAR::raiseError(null, … … 168 162 } 169 163 170 $instance = &new $class Name($request);164 $instance = &new $class($userAgent); 171 165 $error = &$instance->isError(); 172 166 if (Net_UserAgent_Mobile::isError($error)) { … … 191 185 * returns a instance from existent ones 192 186 * 193 * @param mixed $stuff User-Agent string or object that works with 194 * HTTP_Request (not implemented) 187 * @param string $userAgent User-Agent string 195 188 * @return mixed a newly created or a existent Net_UserAgent_Mobile 196 189 * object, or a PEAR error object on error 197 190 * @see Net_UserAgent_Mobile::factory() 198 191 */ 199 function &singleton($stuff = null) 200 { 201 static $instance; 202 if (!isset($instance)) { 203 $instance = Net_UserAgent_Mobile::factory($stuff); 204 } 205 206 return $instance; 207 } 192 function &singleton($userAgent = null) 193 { 194 static $instances; 195 196 if (!isset($instances)) { 197 $instances = array(); 198 } 199 200 if (is_null($userAgent)) { 201 $userAgent = $_SERVER['HTTP_USER_AGENT']; 202 } 203 204 if (!array_key_exists($userAgent, $instances)) { 205 $instances[$userAgent] = Net_UserAgent_Mobile::factory($userAgent); 206 } 207 208 return $instances[$userAgent]; 209 } 208 210 209 211 // }}} … … 253 255 } 254 256 257 // }}} 258 // {{{ isMobile() 259 260 /** 261 * Checks whether or not the user agent is mobile by a given user agent 262 * string. 263 * 264 * @param string $userAgent 265 * @return boolean 266 * @since Method available since Release 0.31.0 267 */ 268 function isMobile($userAgent = null) 269 { 270 if (Net_UserAgent_Mobile::isDoCoMo($userAgent)) { 271 return true; 272 } elseif (Net_UserAgent_Mobile::isEZweb($userAgent)) { 273 return true; 274 } elseif (Net_UserAgent_Mobile::isSoftBank($userAgent)) { 275 return true; 276 } elseif (Net_UserAgent_Mobile::isWillcom($userAgent)) { 277 return true; 278 } 279 280 return false; 281 } 282 283 // }}} 284 // {{{ isDoCoMo() 285 286 /** 287 * Checks whether or not the user agent is DoCoMo by a given user agent 288 * string. 289 * 290 * @param string $userAgent 291 * @return boolean 292 * @since Method available since Release 0.31.0 293 */ 294 function isDoCoMo($userAgent = null) 295 { 296 if (is_null($userAgent)) { 297 $userAgent = $_SERVER['HTTP_USER_AGENT']; 298 } 299 300 if (preg_match('!^DoCoMo!', $userAgent)) { 301 return true; 302 } 303 304 return false; 305 } 306 307 // }}} 308 // {{{ isEZweb() 309 310 /** 311 * Checks whether or not the user agent is EZweb by a given user agent 312 * string. 313 * 314 * @param string $userAgent 315 * @return boolean 316 * @since Method available since Release 0.31.0 317 */ 318 function isEZweb($userAgent = null) 319 { 320 if (is_null($userAgent)) { 321 $userAgent = $_SERVER['HTTP_USER_AGENT']; 322 } 323 324 if (preg_match('!^KDDI-!', $userAgent)) { 325 return true; 326 } elseif (preg_match('!^UP\.Browser!', $userAgent)) { 327 return true; 328 } 329 330 return false; 331 } 332 333 // }}} 334 // {{{ isSoftBank() 335 336 /** 337 * Checks whether or not the user agent is SoftBank by a given user agent 338 * string. 339 * 340 * @param string $userAgent 341 * @return boolean 342 * @since Method available since Release 0.31.0 343 */ 344 function isSoftBank($userAgent = null) 345 { 346 if (is_null($userAgent)) { 347 $userAgent = $_SERVER['HTTP_USER_AGENT']; 348 } 349 350 if (preg_match('!^SoftBank!', $userAgent)) { 351 return true; 352 } elseif (preg_match('!^Semulator!', $userAgent)) { 353 return true; 354 } elseif (preg_match('!^Vodafone!', $userAgent)) { 355 return true; 356 } elseif (preg_match('!^Vemulator!', $userAgent)) { 357 return true; 358 } elseif (preg_match('!^MOT-!', $userAgent)) { 359 return true; 360 } elseif (preg_match('!^MOTEMULATOR!', $userAgent)) { 361 return true; 362 } elseif (preg_match('!^J-PHONE!', $userAgent)) { 363 return true; 364 } elseif (preg_match('!^J-EMULATOR!', $userAgent)) { 365 return true; 366 } 367 368 return false; 369 } 370 371 // }}} 372 // {{{ isWillcom() 373 374 /** 375 * Checks whether or not the user agent is Willcom by a given user agent 376 * string. 377 * 378 * @param string $userAgent 379 * @return boolean 380 * @since Method available since Release 0.31.0 381 */ 382 function isWillcom($userAgent = null) 383 { 384 if (is_null($userAgent)) { 385 $userAgent = $_SERVER['HTTP_USER_AGENT']; 386 } 387 388 if (preg_match('!^Mozilla/3\.0\((?:DDIPOCKET|WILLCOM);!', $userAgent)) { 389 return true; 390 } 391 392 return false; 393 } 394 255 395 /**#@-*/ 256 396 … … 276 416 * @copyright 2003-2007 KUBO Atsuhiro <iteman@users.sourceforge.net> 277 417 * @license http://www.php.net/license/3_0.txt PHP License 3.0 278 * @version Release: 0.3 0.0418 * @version Release: 0.31.0 279 419 * @since Class available since Release 0.1 280 420 */ … … 356 496 * End: 357 497 */ 358 ?> -
branches/version-2/data/module/Net/UserAgent/Mobile/Common.php
r15532 r17127 14 14 * @package Net_UserAgent_Mobile 15 15 * @author KUBO Atsuhiro <iteman@users.sourceforge.net> 16 * @copyright 2003-200 7KUBO Atsuhiro <iteman@users.sourceforge.net>16 * @copyright 2003-2008 KUBO Atsuhiro <iteman@users.sourceforge.net> 17 17 * @license http://www.php.net/license/3_0.txt PHP License 3.0 18 18 * @version CVS: $Id$ 19 19 * @since File available since Release 0.1 20 20 */ 21 22 require_once 'Net/UserAgent/Mobile.php'; 21 23 22 24 // {{{ Net_UserAgent_Mobile_Common … … 31 33 * @package Net_UserAgent_Mobile 32 34 * @author KUBO Atsuhiro <iteman@users.sourceforge.net> 33 * @copyright 2003-200 7KUBO Atsuhiro <iteman@users.sourceforge.net>35 * @copyright 2003-2008 KUBO Atsuhiro <iteman@users.sourceforge.net> 34 36 * @license http://www.php.net/license/3_0.txt PHP License 3.0 35 * @version Release: 0.3 0.037 * @version Release: 0.31.0 36 38 * @since Class available since Release 0.1 37 39 */ … … 49 51 * @var string 50 52 */ 51 var $name = '';53 var $name; 52 54 53 55 /** … … 55 57 * @var string 56 58 */ 57 var $version = '';59 var $version; 58 60 59 61 /**#@-*/ … … 68 70 */ 69 71 var $_display; 70 71 /**72 * Net_UserAgent_Mobile_Request_XXX object73 * @var object {@link Net_UserAgent_Mobile_Request_Env}74 */75 var $_request;76 72 77 73 /** … … 80 76 * @var object 81 77 **/ 82 var $_error = null; 78 var $_error; 79 80 /** 81 * The User-Agent string. 82 * @var string 83 * @since Property available since Release 0.31.0 84 **/ 85 var $_userAgent; 86 87 /** 88 * The model name of the user agent. 89 * 90 * @var string 91 * @since Property available since Release 0.31.0 92 */ 93 var $_model; 94 95 /** 96 * The raw model name of the user agent. 97 * 98 * @var string 99 * @since Property available since Release 0.31.0 100 */ 101 var $_rawModel; 83 102 84 103 /**#@-*/ … … 94 113 * constructor 95 114 * 96 * @param object $request a {@link Net_UserAgent_Mobile_Request_Env} 97 * object 98 */ 99 function Net_UserAgent_Mobile_Common($request) 115 * @param string $userAgent User-Agent string 116 */ 117 function Net_UserAgent_Mobile_Common($userAgent) 100 118 { 101 119 parent::PEAR('Net_UserAgent_Mobile_Error'); 102 $this->_request = $request; 103 if (Net_UserAgent_Mobile::isError($result = $this->parse())) { 120 121 $result = $this->parse($userAgent); 122 if (Net_UserAgent_Mobile::isError($result)) { 104 123 $this->isError($result); 105 124 } 125 126 $this->_userAgent = $userAgent; 106 127 } 107 128 … … 175 196 function getUserAgent() 176 197 { 177 return $this-> getHeader('User-Agent');198 return $this->_userAgent; 178 199 } 179 200 … … 189 210 function getHeader($header) 190 211 { 191 return $this->_request->get($header);212 return @$_SERVER[ 'HTTP_' . str_replace('-', '_', $header) ]; 192 213 } 193 214 … … 256 277 257 278 /** 258 * parse HTTP_USER_AGENT string (should be implemented in subclasses) 259 * 279 * Parses HTTP_USER_AGENT string. 280 * 281 * @param string $userAgent User-Agent string 260 282 * @abstract 261 283 */ 262 function parse() 263 { 264 die(); 265 } 284 function parse($userAgent) {} 266 285 267 286 // }}} … … 420 439 { 421 440 die(); 441 } 442 443 // }}} 444 // {{{ isSoftBank() 445 446 /** 447 * Returns whether the agent is SoftBank or not. 448 * 449 * @return boolean 450 * @since Method available since Release 0.31.0 451 */ 452 function isSoftBank() 453 { 454 return false; 455 } 456 457 // }}} 458 // {{{ isWillcom() 459 460 /** 461 * Returns whether the agent is Willcom or not. 462 * 463 * @return boolean 464 * @since Method available since Release 0.31.0 465 */ 466 function isWillcom() 467 { 468 return false; 469 } 470 471 // }}} 472 // {{{ getModel() 473 474 /** 475 * Returns the model name of the user agent. 476 * 477 * @return string 478 * @since Method available since Release 0.31.0 479 */ 480 function getModel() 481 { 482 if (is_null($this->_model)) { 483 return $this->_rawModel; 484 } else { 485 return $this->_model; 486 } 487 } 488 489 // }}} 490 // {{{ getRawModel() 491 492 /** 493 * Returns the raw model name of the user agent. 494 * 495 * @return string 496 * @since Method available since Release 0.31.0 497 */ 498 function getRawModel() 499 { 500 return $this->_rawModel; 422 501 } 423 502 … … 445 524 * End: 446 525 */ 447 ?> -
branches/version-2/data/module/Net/UserAgent/Mobile/Display.php
r15532 r17127 60 60 * @copyright 2003-2007 KUBO Atsuhiro <iteman@users.sourceforge.net> 61 61 * @license http://www.php.net/license/3_0.txt PHP License 3.0 62 * @version Release: 0.3 0.062 * @version Release: 0.31.0 63 63 * @since Class available since Release 0.1 64 64 */ … … 266 266 * End: 267 267 */ 268 ?> -
branches/version-2/data/module/Net/UserAgent/Mobile/DoCoMo.php
r15532 r17127 14 14 * @package Net_UserAgent_Mobile 15 15 * @author KUBO Atsuhiro <iteman@users.sourceforge.net> 16 * @copyright 2003-200 7KUBO Atsuhiro <iteman@users.sourceforge.net>16 * @copyright 2003-2008 KUBO Atsuhiro <iteman@users.sourceforge.net> 17 17 * @license http://www.php.net/license/3_0.txt PHP License 3.0 18 18 * @version CVS: $Id$ … … 22 22 */ 23 23 24 require_once dirname(__FILE__) . '/Common.php';25 require_once dirname(__FILE__) . '/Display.php';26 require_once dirname(__FILE__) . '/DoCoMoDisplayMap.php';24 require_once 'Net/UserAgent/Mobile/Common.php'; 25 require_once 'Net/UserAgent/Mobile/Display.php'; 26 require_once 'Net/UserAgent/Mobile/DoCoMoDisplayMap.php'; 27 27 28 28 // {{{ Net_UserAgent_Mobile_DoCoMo … … 75 75 * @package Net_UserAgent_Mobile 76 76 * @author KUBO Atsuhiro <iteman@users.sourceforge.net> 77 * @copyright 2003-200 7KUBO Atsuhiro <iteman@users.sourceforge.net>77 * @copyright 2003-2008 KUBO Atsuhiro <iteman@users.sourceforge.net> 78 78 * @license http://www.php.net/license/3_0.txt PHP License 3.0 79 * @version Release: 0.3 0.079 * @version Release: 0.31.0 80 80 * @link http://www.nttdocomo.co.jp/service/imode/make/content/spec/useragent/index.html 81 81 * @see Net_UserAgent_Mobile_Common … … 98 98 99 99 /** 100 * name of the model like 'P502i'101 * @var string102 */103 var $_model = '';104 105 /**106 100 * status of the cache (TC, TB, TD, TJ) 107 101 * @var string 108 102 */ 109 var $_status = '';103 var $_status; 110 104 111 105 /** … … 113 107 * @var integer 114 108 */ 115 var $_bandwidth = null;109 var $_bandwidth; 116 110 117 111 /** … … 119 113 * @var string 120 114 */ 121 var $_serialNumber = null;115 var $_serialNumber; 122 116 123 117 /** … … 131 125 * @var string 132 126 */ 133 var $_cardID = null;127 var $_cardID; 134 128 135 129 /** … … 137 131 * @var string 138 132 */ 139 var $_comment = null;133 var $_comment; 140 134 141 135 /** … … 149 143 * @var string 150 144 */ 151 var $_displayBytes = '';145 var $_displayBytes; 152 146 153 147 /**#@-*/ … … 174 168 175 169 /** 176 * parse HTTP_USER_AGENT string 177 * 170 * Parses HTTP_USER_AGENT string. 171 * 172 * @param string $userAgent User-Agent string 178 173 * @return mixed void, or a PEAR error object on error 179 174 */ 180 function parse() 181 { 182 @list($main, $foma_or_comment) = 183 explode(' ', $this->getUserAgent(), 2); 175 function parse($userAgent) 176 { 177 @list($main, $foma_or_comment) = explode(' ', $userAgent, 2); 184 178 185 179 if ($foma_or_comment … … 220 214 function makeDisplay() 221 215 { 222 $display = Net_UserAgent_Mobile_DoCoMoDisplayMap::get($this-> _model);223 if ( $this->_displayBytes !== '') {216 $display = Net_UserAgent_Mobile_DoCoMoDisplayMap::get($this->getModel()); 217 if (!is_null($this->_displayBytes)) { 224 218 list($widthBytes, $heightBytes) = 225 219 explode('*', $this->_displayBytes); … … 248 242 '504i|251i|^F671iS$|212i|2051|2102V|661i|2701|672i|SO213i|850i' => '4.0', 249 243 'eggy|P751v' => '3.2', 250 '505i|252i|900i|506i|880i|253i|P213i|901i|700i|851i|701i|881i|^SA800i$|600i|^L601i$|^M702i(S|G)$' => '5.0', 251 '902i|702i|851i|882i|^N601i$|^D800iDS$|^P703imyu$' => '6.0', 252 '903i|703i' => '7.0' 244 '505i|252i|900i|506i|880i|253i|P213i|901i|700i|^(SH|P)851i|701i|881i|^SA800i$|600i|^L601i$|^M702i(S|G)$|^L602i$' => '5.0', 245 '902i|702i|851i|882i|^N601i$|^D800iDS$|^P703imyu$|^P704imyu$|^L70[45]i$|^F883i$' => '6.0', 246 '903i|703i|904i|704i|883i|801i|^[FD]705i' => '7.0', 247 '905i|705i' => '7.1' 253 248 ); 254 249 } 255 250 256 251 foreach ($htmlVersionMap as $key => $value) { 257 if (preg_match("/$key/", $this->_ model)) {252 if (preg_match("/$key/", $this->_rawModel)) { 258 253 return $value; 259 254 } … … 293 288 function getSeries() 294 289 { 295 if ($this->isFOMA() && preg_match('/(\d{4})/', $this->_ model)) {290 if ($this->isFOMA() && preg_match('/(\d{4})/', $this->_rawModel)) { 296 291 return 'FOMA'; 297 292 } 298 293 299 if (preg_match('/(\d{3}i)/', $this->_ model, $matches)) {294 if (preg_match('/(\d{3}i)/', $this->_rawModel, $matches)) { 300 295 return $matches[1]; 301 296 } 302 297 303 if ($this->_ model == 'P651ps') {298 if ($this->_rawModel == 'P651ps') { 304 299 return '651'; 305 300 } … … 318 313 function getVendor() 319 314 { 320 if (preg_match('/([A-Z]+)\d/', $this->_ model, $matches)) {315 if (preg_match('/([A-Z]+)\d/', $this->_rawModel, $matches)) { 321 316 return $matches[1]; 322 317 } 318 323 319 return null; 324 }325 326 // }}}327 // {{{ getModel()328 329 /**330 * returns name of the model like 'P502i'331 *332 * @return string333 */334 function getModel()335 {336 return $this->_model;337 320 } 338 321 … … 437 420 $gpsModels = array('F661i', 'F505iGPS'); 438 421 } 439 return in_array($this->_ model, $gpsModels);422 return in_array($this->_rawModel, $gpsModels); 440 423 } 441 424 … … 483 466 function _parseMain($main) 484 467 { 485 @list($this->name, $this->version, $this->_ model, $cache, $rest) =468 @list($this->name, $this->version, $this->_rawModel, $cache, $rest) = 486 469 explode('/', $main, 5); 487 if ($this->_ model === 'SH505i2') {470 if ($this->_rawModel == 'SH505i2') { 488 471 $this->_model = 'SH505i'; 489 472 } 490 473 491 474 if ($cache) { 492 if (!preg_match('/^c(\d+) /', $cache, $matches)) {475 if (!preg_match('/^c(\d+)$/', $cache, $matches)) { 493 476 return $this->noMatch(); 494 477 } … … 530 513 function _parseFOMA($foma) 531 514 { 532 if (!preg_match('/^([^( ]+)/', $foma, $matches)) {515 if (!preg_match('/^([^(\s]+)/', $foma, $matches)) { 533 516 return $this->noMatch(); 534 517 } 535 $this->_model = $matches[1]; 536 if ($matches[1] === 'MST_v_SH2101V') { 518 519 $this->_rawModel = $matches[1]; 520 if ($this->_rawModel == 'MST_v_SH2101V') { 537 521 $this->_model = 'SH2101V'; 538 522 } 539 523 540 if (preg_match('/^[^(]+\((.*?)\)$/', $foma, $matches)) { 524 if (preg_match('/^[^(\s]+\s?\((.*?)\)$/', $foma, $matches)) { 525 if (preg_match('/^compatible/', $matches[1])) { // The user-agent is DoCoMo compatible. 526 $this->_comment = $matches[1]; 527 return; 528 } 529 541 530 $rest = explode(';', $matches[1]); 542 531 foreach ($rest as $value) { 543 if (preg_match('/^c(\d+) /', $value, $matches)) {532 if (preg_match('/^c(\d+)$/', $value, $matches)) { 544 533 $this->_cacheSize = (integer)$matches[1]; 545 534 continue; … … 585 574 * End: 586 575 */ 587 ?> -
branches/version-2/data/module/Net/UserAgent/Mobile/DoCoMoDisplayMap.php
r15532 r17127 14 14 * @package Net_UserAgent_Mobile 15 15 * @author KUBO Atsuhiro <iteman@users.sourceforge.net> 16 * @copyright 2003-200 7KUBO Atsuhiro <iteman@users.sourceforge.net>16 * @copyright 2003-2008 KUBO Atsuhiro <iteman@users.sourceforge.net> 17 17 * @license http://www.php.net/license/3_0.txt PHP License 3.0 18 18 * @version CVS: $Id$ … … 30 30 * @package Net_UserAgent_Mobile 31 31 * @author KUBO Atsuhiro <iteman@users.sourceforge.net> 32 * @copyright 2003-200 7KUBO Atsuhiro <iteman@users.sourceforge.net>32 * @copyright 2003-2008 KUBO Atsuhiro <iteman@users.sourceforge.net> 33 33 * @license http://www.php.net/license/3_0.txt PHP License 3.0 34 * @version Release: 0.3 0.034 * @version Release: 0.31.0 35 35 * @link http://www.nttdocomo.co.jp/service/imode/make/content/spec/screen_area/index.html 36 36 * @see Net_UserAgent_Mobile_Display … … 823 823 'color' => 1 824 824 ), 825 'N506IS II' => array(826 827 828 829 830 825 'N506IS2' => array( 826 'width' => 240, 827 'height' => 295, 828 'depth' => 262144, 829 'color' => 1 830 ), 831 831 'P506ICII' => array( 832 832 'width' => 240, … … 1110 1110 ), 1111 1111 'L600I' => array( 1112 'width' => 17 6,1112 'width' => 170, 1113 1113 'height' => 189, 1114 1114 'depth' => 65536, … … 1122 1122 ), 1123 1123 'L601I' => array( 1124 'width' => 17 6,1124 'width' => 170, 1125 1125 'height' => 189, 1126 1126 'depth' => 65536, … … 1137 1137 'height' => 267, 1138 1138 'depth' => 262144, 1139 'color' => 1 1140 ), 1141 'L602I' => array( 1142 'width' => 170, 1143 'height' => 189, 1144 'depth' => 65536, 1139 1145 'color' => 1 1140 1146 ), … … 1150 1156 'D902I' => array( 1151 1157 'width' => 230, 1152 'height' => 240,1158 'height' => 320, 1153 1159 'depth' => 262144, 1154 1160 'color' => 1 … … 1334 1340 'color' => 1 1335 1341 ), 1342 'F883I' => array( 1343 'width' => 240, 1344 'height' => 256, 1345 'depth' => 65536, 1346 'color' => 1 1347 ), 1348 'P704IMYU' => array( 1349 'width' => 240, 1350 'height' => 270, 1351 'depth' => 262144, 1352 'color' => 1 1353 ), 1354 'L704I' => array( 1355 'width' => 240, 1356 'height' => 280, 1357 'depth' => 262144, 1358 'color' => 1 1359 ), 1360 'L705I' => array( 1361 'width' => 240, 1362 'height' => 280, 1363 'depth' => 262144, 1364 'color' => 1 1365 ), 1336 1366 1337 1367 // i-mode compliant HTML 7.0 … … 1374 1404 ), 1375 1405 'D903ITV' => array( 1376 'width' => 230,1377 'height' => 320,1378 'depth' => 262144,1379 'color' => 11380 ),1406 'width' => 230, 1407 'height' => 320, 1408 'depth' => 262144, 1409 'color' => 1 1410 ), 1381 1411 'F903IX' => array( 1382 1412 'width' => 230, … … 1391 1421 'color' => 1 1392 1422 ), 1423 'SH903ITV' => array( 1424 'width' => 240, 1425 'height' => 320, 1426 'depth' => 262144, 1427 'color' => 1 1428 ), 1429 'F903IBSC' => array( 1430 'width' => 230, 1431 'height' => 240, 1432 'depth' => 262144, 1433 'color' => 1 1434 ), 1435 'P903IX' => array( 1436 'width' => 240, 1437 'height' => 270, 1438 'depth' => 262144, 1439 'color' => 1 1440 ), 1441 'SO903ITV' => array( 1442 'width' => 240, 1443 'height' => 368, 1444 'depth' => 262144, 1445 'color' => 1 1446 ), 1393 1447 'N703ID' => array( 1394 1448 'width' => 240, … … 1438 1492 'depth' => 262144, 1439 1493 'color' => 1 1440 ) 1494 ), 1495 'P904I' => array( 1496 'width' => 240, 1497 'height' => 350, 1498 'depth' => 262144, 1499 'color' => 1 1500 ), 1501 'D904I' => array( 1502 'width' => 240, 1503 'height' => 320, 1504 'depth' => 262144, 1505 'color' => 1 1506 ), 1507 'F904I' => array( 1508 'width' => 240, 1509 'height' => 352, 1510 'depth' => 262144, 1511 'color' => 1 1512 ), 1513 'N904I' => array( 1514 'width' => 240, 1515 'height' => 352, 1516 'depth' => 262144, 1517 'color' => 1 1518 ), 1519 'SH904I' => array( 1520 'width' => 240, 1521 'height' => 320, 1522 'depth' => 262144, 1523 'color' => 1 1524 ), 1525 'P704I' => array( 1526 'width' => 240, 1527 'height' => 270, 1528 'depth' => 262144, 1529 'color' => 1 1530 ), 1531 'D704I' => array( 1532 'width' => 230, 1533 'height' => 240, 1534 'depth' => 262144, 1535 'color' => 1 1536 ), 1537 'SH704I' => array( 1538 'width' => 240, 1539 'height' => 320, 1540 'depth' => 262144, 1541 'color' => 1 1542 ), 1543 'N704IMYU' => array( 1544 'width' => 240, 1545 'height' => 270, 1546 'depth' => 262144, 1547 'color' => 1 1548 ), 1549 'F704I' => array( 1550 'width' => 230, 1551 'height' => 240, 1552 'depth' => 262144, 1553 'color' => 1 1554 ), 1555 'SO704I' => array( 1556 'width' => 240, 1557 'height' => 368, 1558 'depth' => 262144, 1559 'color' => 1 1560 ), 1561 'F883IES' => array( 1562 'width' => 240, 1563 'height' => 256, 1564 'depth' => 65536, 1565 'color' => 1 1566 ), 1567 'F801I' => array( 1568 'width' => 240, 1569 'height' => 352, 1570 'depth' => 65536, 1571 'color' => 1 1572 ), 1573 'F705I' => array( 1574 'width' => 240, 1575 'height' => 352, 1576 'depth' => 262144, 1577 'color' => 1 1578 ), 1579 'D705I' => array( 1580 'width' => 240, 1581 'height' => 320, 1582 'depth' => 262144, 1583 'color' => 1 1584 ), 1585 'D705IMYU' => array( 1586 'width' => 240, 1587 'height' => 240, 1588 'depth' => 262144, 1589 'color' => 1 1590 ), 1591 1592 // i-mode compliant HTML 7.1 1593 // (FOMA 905i etc.) 1594 'SH905I' => array( 1595 'width' => 240, 1596 'height' => 320, 1597 'depth' => 16777216, 1598 'color' => 1 1599 ), 1600 'D905I' => array( 1601 'width' => 240, 1602 'height' => 352, 1603 'depth' => 262144, 1604 'color' => 1 1605 ), 1606 'N905I' => array( 1607 'width' => 240, 1608 'height' => 320, 1609 'depth' => 262144, 1610 'color' => 1 1611 ), 1612 'P905I' => array( 1613 'width' => 240, 1614 'height' => 350, 1615 'depth' => 262144, 1616 'color' => 1 1617 ), 1618 'F905I' => array( 1619 'width' => 240, 1620 'height' => 352, 1621 'depth' => 16777216, 1622 'color' => 1 1623 ), 1624 'SO905I' => array( 1625 'width' => 240, 1626 'height' => 368, 1627 'depth' => 16777216, 1628 'color' => 1 1629 ), 1630 'N905IMYU' => array( 1631 'width' => 240, 1632 'height' => 320, 1633 'depth' => 262144, 1634 'color' => 1 1635 ), 1636 'N905IBIZ' => array( 1637 'width' => 240, 1638 'height' => 320, 1639 'depth' => 262144, 1640 'color' => 1 1641 ), 1642 'SH905ITV' => array( 1643 'width' => 240, 1644 'height' => 320, 1645 'depth' => 16777216, 1646 'color' => 1 1647 ), 1648 'P705I' => array( 1649 'width' => 240, 1650 'height' => 350, 1651 'depth' => 262144, 1652 'color' => 1 1653 ), 1654 'N705I' => array( 1655 'width' => 240, 1656 'height' => 320, 1657 'depth' => 262144, 1658 'color' => 1 1659 ) 1441 1660 ); 1442 1661 } … … 1469 1688 * End: 1470 1689 */ 1471 ?> -
branches/version-2/data/module/Net/UserAgent/Mobile/EZweb.php
r15532 r17127 14 14 * @package Net_UserAgent_Mobile 15 15 * @author KUBO Atsuhiro <iteman@users.sourceforge.net> 16 * @copyright 2003-200 7KUBO Atsuhiro <iteman@users.sourceforge.net>16 * @copyright 2003-2008 KUBO Atsuhiro <iteman@users.sourceforge.net> 17 17 * @license http://www.php.net/license/3_0.txt PHP License 3.0 18 18 * @version CVS: $Id$ … … 23 23 */ 24 24 25 require_once (dirname(__FILE__) . '/Common.php');26 require_once (dirname(__FILE__) . '/Display.php');25 require_once 'Net/UserAgent/Mobile/Common.php'; 26 require_once 'Net/UserAgent/Mobile/Display.php'; 27 27 28 28 // {{{ Net_UserAgent_Mobile_EZweb … … 59 59 * @package Net_UserAgent_Mobile 60 60 * @author KUBO Atsuhiro <iteman@users.sourceforge.net> 61 * @copyright 2003-200 7KUBO Atsuhiro <iteman@users.sourceforge.net>61 * @copyright 2003-2008 KUBO Atsuhiro <iteman@users.sourceforge.net> 62 62 * @license http://www.php.net/license/3_0.txt PHP License 3.0 63 * @version Release: 0.3 0.063 * @version Release: 0.31.0 64 64 * @link http://www.au.kddi.com/ezfactory/tec/spec/4_4.html 65 65 * @link http://www.au.kddi.com/ezfactory/tec/spec/new_win/ezkishu.html … … 83 83 84 84 /** 85 * name of the model like 'P502i'86 * @var string87 */88 var $_model = '';89 90 /**91 * device ID like 'TS21'92 * @var string93 */94 var $_deviceID = '';95 96 /**97 85 * server string like 'UP.Link/3.2.1.2' 98 86 * @var string … … 141 129 function isTUKa() 142 130 { 143 $tuka = substr($this->_ deviceID, 2, 1);131 $tuka = substr($this->_rawModel, 2, 1); 144 132 if ($this->isWAP2()) { 145 133 if ($tuka == 'U') { … … 159 147 160 148 /** 161 * parse HTTP_USER_AGENT string162 * /163 function parse()164 {165 $agent = $this->getUserAgent();166 167 if (preg_match('/^KDDI-(.*)/', $ agent, $matches)) {149 * Parses HTTP_USER_AGENT string. 150 * 151 * @param string $userAgent User-Agent string 152 */ 153 function parse($userAgent) 154 { 155 if (preg_match('/^KDDI-(.*)/', $userAgent, $matches)) { 168 156 169 157 // KDDI-TS21 UP.Browser/6.0.2.276 (GUI) MMP/1.1 170 158 $this->_xhtmlCompliant = true; 171 list($this->_ deviceID, $browser, $opt, $this->_serverName) =159 list($this->_rawModel, $browser, $opt, $this->_serverName) = 172 160 explode(' ', $matches[1], 4); 173 161 list($this->name, $version) = explode('/', $browser); … … 177 165 // UP.Browser/3.01-HI01 UP.Link/3.4.5.2 178 166 @list($browser, $this->_serverName, $comment) = 179 explode(' ', $ agent, 3);167 explode(' ', $userAgent, 3); 180 168 list($this->name, $software) = explode('/', $browser); 181 list($this->version, $this->_ deviceID) =169 list($this->version, $this->_rawModel) = 182 170 explode('-', $software); 183 171 if ($comment) { … … 186 174 } 187 175 } 188 189 $this->_model = $this->_deviceID;190 176 } 191 177 … … 203 189 { 204 190 @list($width, $height) = 205 explode(',', $this->getHeader(' x-up-devcap-screenpixels'));191 explode(',', $this->getHeader('X-UP-DEVCAP-SCREENPIXELS')); 206 192 $screenDepth = 207 explode(',', $this->getHeader(' x-up-devcap-screendepth'));193 explode(',', $this->getHeader('X-UP-DEVCAP-SCREENDEPTH')); 208 194 $depth = $screenDepth[0] ? pow(2, (integer)$screenDepth[0]) : 0; 209 195 $color = 210 $this->getHeader(' x-up-devcap-iscolor') === '1' ? true : false;196 $this->getHeader('X-UP-DEVCAP-ISCOLOR') === '1' ? true : false; 211 197 return new Net_UserAgent_Mobile_Display(array( 212 198 'width' => $width, … … 219 205 220 206 // }}} 221 // {{{ get Model()222 223 /** 224 * returns name of the model (device ID) like 'TS21'207 // {{{ getDeviceID() 208 209 /** 210 * Returns the device ID of the user agent. 225 211 * 226 212 * @return string 227 213 */ 228 function get Model()229 { 230 return $this->_ model;231 } 232 233 // }}} 234 // {{{ get DeviceID()235 236 /** 237 * returns device ID like 'TS21'214 function getDeviceID() 215 { 216 return $this->_rawModel; 217 } 218 219 // }}} 220 // {{{ getServer() 221 222 /** 223 * returns server string like 'UP.Link/3.2.1.2' 238 224 * 239 225 * @return string 240 226 */ 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' 227 function getServer() 228 { 229 return $this->_serverName; 230 } 231 232 // }}} 233 // {{{ getComment() 234 235 /** 236 * returns comment like 'Google WAP Proxy/1.0'. returns null if nothinng. 237 * 238 * @return boolean 239 */ 240 function getComment() 241 { 242 return $this->_comment; 243 } 244 245 // }}} 246 // {{{ isXHTMLCompliant() 247 248 /** 249 * returns whether it's XHTML compliant or not 250 * 251 * @return boolean 252 */ 253 function isXHTMLCompliant() 254 { 255 return $this->_xhtmlCompliant; 256 } 257 258 // }}} 259 // {{{ getCarrierShortName() 260 261 /** 262 * returns the short name of the carrier 251 263 * 252 264 * @return string 253 265 */ 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 266 function getCarrierShortName() 267 { 268 return 'E'; 269 } 270 271 // }}} 272 // {{{ getCarrierLongName() 273 274 /** 275 * returns the long name of the carrier 290 276 * 291 277 * @return string 292 278 */ 293 function getCarrierShortName()294 {295 return 'E';296 }297 298 // }}}299 // {{{ getCarrierLongName()300 301 /**302 * returns the long name of the carrier303 *304 * @return string305 */306 279 function getCarrierLongName() 307 280 { … … 319 292 function isWIN() 320 293 { 321 return substr($this->_ deviceID, 2, 1) == 3 ? true : false;294 return substr($this->_rawModel, 2, 1) == 3 ? true : false; 322 295 } 323 296 … … 345 318 * End: 346 319 */ 347 ?> -
branches/version-2/data/module/Net/UserAgent/Mobile/NonMobile.php
r15532 r17127 14 14 * @package Net_UserAgent_Mobile 15 15 * @author KUBO Atsuhiro <iteman@users.sourceforge.net> 16 * @copyright 2003-200 7KUBO Atsuhiro <iteman@users.sourceforge.net>16 * @copyright 2003-2008 KUBO Atsuhiro <iteman@users.sourceforge.net> 17 17 * @license http://www.php.net/license/3_0.txt PHP License 3.0 18 18 * @version CVS: $Id$ … … 21 21 */ 22 22 23 require_once (dirname(__FILE__) . '/Common.php');24 require_once (dirname(__FILE__) . '/Display.php');23 require_once 'Net/UserAgent/Mobile/Common.php'; 24 require_once 'Net/UserAgent/Mobile/Display.php'; 25 25 26 26 // {{{ Net_UserAgent_Mobile_NonMobile … … 44 44 * @package Net_UserAgent_Mobile 45 45 * @author KUBO Atsuhiro <iteman@users.sourceforge.net> 46 * @copyright 2003-200 7KUBO Atsuhiro <iteman@users.sourceforge.net>46 * @copyright 2003-2008 KUBO Atsuhiro <iteman@users.sourceforge.net> 47 47 * @license http://www.php.net/license/3_0.txt PHP License 3.0 48 * @version Release: 0.3 0.048 * @version Release: 0.31.0 49 49 * @see Net_UserAgent_Mobile_Common 50 50 * @since Class available since Release 0.1.0 … … 88 88 89 89 /** 90 * parse HTTP_USER_AGENT string 90 * Parses HTTP_USER_AGENT string. 91 * 92 * @param string $userAgent User-Agent string 91 93 */ 92 function parse( )94 function parse($userAgent) 93 95 { 94 @list($this->name, $this->version) = 95 explode('/', $this->getUserAgent()); 96 @list($this->name, $this->version) = explode('/', $userAgent); 96 97 } 97 98 … … 109 110 { 110 111 return new Net_UserAgent_Mobile_Display(null); 111 }112 113 // }}}114 // {{{ getModel()115 116 /**117 * returns name of the model118 *119 * @return string120 */121 function getModel()122 {123 return '';124 }125 126 // }}}127 // {{{ getDeviceID()128 129 /**130 * returns device ID131 *132 * @return string133 */134 function getDeviceID()135 {136 return '';137 112 } 138 113 … … 186 161 * End: 187 162 */ 188 ?>
Note: See TracChangeset
for help on using the changeset viewer.