Source for file Vodafone.php
Documentation is available at Vodafone.php
/* vim: set expandtab tabstop=4 shiftwidth=4: */
// +----------------------------------------------------------------------+
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2004 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 3.0 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available through the world-wide-web at the following url: |
// | http://www.php.net/license/3_0.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Authors: KUBO Atsuhiro <kubo@isite.co.jp> |
// +----------------------------------------------------------------------+
// $Id: Vodafone.php,v 1.5 2005/08/04 05:36:19 kuboa Exp $
require_once(dirname (__FILE__ ) . '/Common.php');
require_once(dirname (__FILE__ ) . '/Display.php');
* Vodafone implementation
* Net_UserAgent_Mobile_Vodafone is a subclass of
* {@link Net_UserAgent_Mobile_Common}, which implements Vodafone 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@isite.co.jp>
* @version $Revision: 1.5 $
* @see Net_UserAgent_Mobile_Common
* @link http://developers.vodafone.jp/dp/tool_dl/web/useragent.php
* @link http://developers.vodafone.jp/dp/tool_dl/web/position.php
* name of the model like 'J-DN02'
* whether the agent is packet connection complicant or not
var $_packetCompliant = false;
* terminal unique serial number
var $_serialNumber = null;
* vendor version like '0001a'
var $_vendorVersion = null;
var $_javaInfo = array ();
* whether the agent is 3G
* the name of the mobile phone
* parse HTTP_USER_AGENT string
* @return mixed void, or a PEAR error object on error
preg_match('!(?:(^Vodafone)|(^J-PHONE)|(^MOT-))!', $agent[0 ],
$class = @$matches[1 ] ? 'Vodafone' :
(@$matches[2 ] ? 'J-PHONE' : 'Motorola');
$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 object a newly created {@link Net_UserAgent_Mobile_Display}
* @see 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;
* returns name of the model like 'J-DN02'
// {{{ 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 his/her serial number.
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
* parse HTTP_USER_AGENT string for the Vodafone 3G aegnt
* @param array $agent parts of the User-Agent string
* @return mixed void, or a PEAR error object on 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->_model, $modelVersion,
$serialNumber) = explode('/', $agent[0 ]);
if (!preg_match('!^SN(.+)!', $serialNumber, $matches)) {
$this->_serialNumber = $matches[1 ];
if (!preg_match('!^([a-z]+)([a-z]\d{3})$!i', $modelVersion, $matches)
$this->_vendor = $matches[1 ];
$this->_vendorVersion = $matches[2 ];
for ($i = 2; $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
* @return mixed void, or a PEAR error object on 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;
$serialNumber) = explode('/', $agent[0 ]);
if (!preg_match('!^SN(.+)!', $serialNumber, $matches)) {
$this->_serialNumber = $matches[1 ];
list ($this->_vendor, $this->_vendorVersion) =
for ($i = 2; $i < $count; ++ $i) {
list ($key, $value) = explode('/', $agent[$i]);
$this->_javaInfo[$key] = $value;
$this->_model = (string) $model;
if (preg_match('!V\d+([A-Z]+)!', $this->_model, $matches)) {
$this->_vendor = $matches[1 ];
} elseif (preg_match('!J-([A-Z]+)!', $this->_model, $matches)) {
$this->_vendor = $matches[1 ];
* parse HTTP_USER_AGENT string for the Motorola 3G aegnt
* @param array $agent parts of the User-Agent string
* @return mixed void, or a PEAR error object on error
function _parseMotorola (&$agent)
$this->_packetCompliant = true;
// MOT-V980/80.2F.2E. MIB/2.2.1 Profile/MIDP-2.0 Configuration/CLDC-1.1
list ($name, $this->_vendorVersion) = explode('/', $agent[0 ]);
for ($i = 2; $i < $count; ++ $i) {
list ($key, $value) = explode('/', $agent[$i]);
$this->_javaInfo[$key] = $value;
* c-hanging-comment-ender-p: nil
Documentation generated on Mon, 11 Mar 2019 14:16:46 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|