Source for file SoftBank.php
Documentation is available at SoftBank.php
/* vim: set expandtab tabstop=4 shiftwidth=4: */
* Copyright (c) 2003-2009 KUBO Atsuhiro <kubo@iteman.jp>,
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
* @package Net_UserAgent_Mobile
* @author KUBO Atsuhiro <kubo@iteman.jp>
* @copyright 2003-2009 KUBO Atsuhiro <kubo@iteman.jp>
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License
* @version CVS: $Id: SoftBank.php,v 1.1 2009/05/26 08:48:16 kuboa Exp $
* @link http://creation.mb.softbank.jp/
* @since File available since Release 0.20.0
require_once 'Net/UserAgent/Mobile/Common.php';
require_once 'Net/UserAgent/Mobile/Display.php';
require_once 'Net/UserAgent/Mobile.php';
// {{{ Net_UserAgent_Mobile_SoftBank
* SoftBank implementation
* Net_UserAgent_Mobile_SoftBank is a subclass of {@link Net_UserAgent_Mobile_Common},
* which implements SoftBank user agents.
* require_once 'Net/UserAgent/Mobile.php';
* $_SERVER['HTTP_USER_AGENT'] = 'J-PHONE/2.0/J-DN02';
* $agent = &Net_UserAgent_Mobile::factory();
* printf("Name: %s\n", $agent->getName()); // 'J-PHONE'
* printf("Version: %s\n", $agent->getVersion()); // 2.0
* printf("Model: %s\n", $agent->getModel()); // 'J-DN02'
* if ($agent->isPacketCompliant()) {
* print "Packet is compliant.\n"; // false
* // only availabe in Java compliant
* // 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'
* printf("Serial: %s\n", $agent->getSerialNumber()); // XXXXXXXXX
* printf("Vendor: %s\n", $agent->getVendor()); // 'SH'
* printf("Vendor Version: %s\n", $agent->getVendorVersion()); // '0001a'
* $info = $agent->getJavaInfo(); // array
* foreach ($info as $key => $value) {
* print "$key: $value\n";
* @package Net_UserAgent_Mobile
* @author KUBO Atsuhiro <kubo@iteman.jp>
* @copyright 2003-2009 KUBO Atsuhiro <kubo@iteman.jp>
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License
* @version Release: 1.0.0
* @link http://creation.mb.softbank.jp/
* @since Class available since Release 0.20.0
* whether the agent is packet connection complicant or not
var $_packetCompliant = false;
* terminal unique serial number
* vendor version like '0001a'
var $_javaInfo = array ();
* whether the agent is 3G
* the name of the mobile phone
* Parses HTTP_USER_AGENT string.
* @param string $userAgent User-Agent string
* @throws Net_UserAgent_Mobile_Error
function parse($userAgent)
preg_match('!^(?:(SoftBank|Semulator|Vodafone|Vemulator|J-PHONE|J-EMULATOR)/\d\.\d|MOT-|MOTEMULATOR)!',
if (count($matches) > 1 ) {
$result = $this->_parseVodafone ($agent);
$result = $this->_parseJphone ($agent);
$result = $this->_parseMotorola ($agent);
$this->_msname = $this->getHeader('X-JPHONE-MSNAME');
* create a new {@link Net_UserAgent_Mobile_Display} class instance
* @return Net_UserAgent_Mobile_Display
if ($color_string = $this->getHeader('X-JPHONE-COLOR')) {
preg_match('!^([CG])(\d+)$!', $color_string, $matches);
$color = $matches[1 ] === 'C' ? true : false;
// {{{ isPacketCompliant()
* returns whether the agent is packet connection complicant or not
return $this->_packetCompliant;
* return terminal unique serial number. returns null if user forbids to send
return $this->_serialNumber;
* returns vendor code like 'SH'
// {{{ getVendorVersion()
* returns vendor version like '0001a'. returns null if unknown.
return $this->_vendorVersion;
* returns array of Java profiles
* Array structure is something like:
* - 'Profile' => 'MIDP-1.0',
* - 'Configuration' => 'CLDC-1.0',
* - 'Ext-Profile' => 'JSCL-1.1.0'
// {{{ getCarrierShortName()
* returns the short name of the carrier
// {{{ getCarrierLongName()
* returns the long name of the carrier
* returns true if the type is C
* returns true if the type is P
* returns true if the type is W
* returns true if the type is 3GC
* returns the name of the mobile phone
* @return string the name of the mobile phone
* returns true if the agent is SoftBank.
* Gets the UID of a subscriber.
* @since Method available since Release 1.0.0RC1
return $_SERVER['HTTP_X_JPHONE_UID'];
* parse HTTP_USER_AGENT string for the Vodafone 3G aegnt
* @param array $agent parts of the User-Agent string
* @throws Net_UserAgent_Mobile_Error
function _parseVodafone ($agent)
$this->_packetCompliant = true;
// Vodafone/1.0/V702NK/NKJ001 Series60/2.6 Nokia6630/2.39.148 Profile/MIDP-2.0 Configuration/CLDC-1.1
// Vodafone/1.0/V702NK/NKJ001/SN123456789012345 Series60/2.6 Nokia6630/2.39.148 Profile/MIDP-2.0 Configuration/CLDC-1.1
// Vodafone/1.0/V802SE/SEJ001/SN123456789012345 Browser/SEMC-Browser/4.1 Profile/MIDP-2.0 Configuration/CLDC-1.1
@list ($this->name, $this->version, $this->_rawModel, $modelVersion,
$serialNumber) = explode('/', $agent[0 ]);
if (!preg_match('!^SN(.+)!', $serialNumber, $matches)) {
$this->_serialNumber = $matches[1 ];
if (!preg_match('!^([a-z]+)((?:[a-z]|\d){4})$!i', $modelVersion, $matches)) {
$this->_vendor = $matches[1 ];
$this->_vendorVersion = $matches[2 ];
for ($i = 2 , $count = count($agent); $i < $count; ++ $i) {
@list ($key, $value) = explode('/', $agent[$i]);
$this->_javaInfo[$key] = $value;
* parse HTTP_USER_AGENT string for the ancient agent
* @param array $agent parts of the User-Agent string
* @throws Net_UserAgent_Mobile_Error
function _parseJphone ($agent)
// J-PHONE/4.0/J-SH51/SNJSHA3029293 SH/0001aa Profile/MIDP-1.0 Configuration/CLDC-1.0 Ext-Profile/JSCL-1.1.0
$this->_packetCompliant = true;
@list ($this->name, $this->version, $this->_rawModel, $serialNumber) =
if (!preg_match('!^SN(.+)!', $serialNumber, $matches)) {
$this->_serialNumber = $matches[1 ];
@list ($this->_vendor, $this->_vendorVersion) = explode('/', $agent[1 ]);
for ($i = 2; $i < $count; ++ $i) {
@list ($key, $value) = explode('/', $agent[$i]);
$this->_javaInfo[$key] = $value;
@list ($this->name, $this->version, $this->_rawModel, $serialNumber) =
if (!preg_match('!^SN(.+)!', $serialNumber, $matches)) {
$this->_serialNumber = $matches[1 ];
if (preg_match('!V\d+([A-Z]+)!', $this->_rawModel, $matches)) {
$this->_vendor = $matches[1 ];
} elseif (preg_match('!J-([A-Z]+)!', $this->_rawModel, $matches)) {
$this->_vendor = $matches[1 ];
* parse HTTP_USER_AGENT string for the Motorola 3G aegnt
* @param array $agent parts of the User-Agent string
function _parseMotorola ($agent)
$this->_packetCompliant = true;
// MOT-V980/80.2F.2E. MIB/2.2.1 Profile/MIDP-2.0 Configuration/CLDC-1.1
@list ($this->_rawModel, $this->_vendorVersion) = explode('/', $agent[0 ]);
for ($i = 2 , $count = count($agent); $i < $count; ++ $i) {
@list ($key, $value) = explode('/', $agent[$i]);
$this->_javaInfo[$key] = $value;
* c-hanging-comment-ender-p: nil
Documentation generated on Tue, 23 Jun 2009 10:00:06 +0000 by phpDocumentor 1.4.2. PEAR Logo Copyright © PHP Group 2004.
|