Net_UserAgent_Mobile
[ class tree: Net_UserAgent_Mobile ] [ index: Net_UserAgent_Mobile ] [ all elements ]

Source for file EZweb.php

Documentation is available at EZweb.php

  1. <?php
  2. /* vim: set expandtab tabstop=4 shiftwidth=4: */
  3. // +----------------------------------------------------------------------+
  4. // | PHP version 4                                                        |
  5. // +----------------------------------------------------------------------+
  6. // | Copyright (c) 1997-2004 The PHP Group                                |
  7. // +----------------------------------------------------------------------+
  8. // | This source file is subject to version 3.0 of the PHP license,       |
  9. // | that is bundled with this package in the file LICENSE, and is        |
  10. // | available through the world-wide-web at the following url:           |
  11. // | http://www.php.net/license/3_0.txt.                                  |
  12. // | If you did not receive a copy of the PHP license and are unable to   |
  13. // | obtain it through the world-wide-web, please send a note to          |
  14. // | license@php.net so we can mail you a copy immediately.               |
  15. // +----------------------------------------------------------------------+
  16. // | Authors: KUBO Atsuhiro <kubo@isite.co.jp>                            |
  17. // +----------------------------------------------------------------------+
  18. //
  19. // $Id: EZweb.php,v 1.12 2004/05/27 07:24:56 kuboa Exp $
  20. //
  21.  
  22. require_once(dirname(__FILE__'/Common.php');
  23. require_once(dirname(__FILE__'/Display.php');
  24.  
  25. /**
  26.  * EZweb implementation
  27.  *
  28.  * Net_UserAgent_Mobile_EZweb is a subclass of
  29.  * {@link Net_UserAgent_Mobile_Common}, which implements EZweb (WAP1.0/2.0)
  30.  * user agents.
  31.  *
  32.  * SYNOPSIS:
  33.  * <code>
  34.  * require_once('Net/UserAgent/Mobile.php');
  35.  *
  36.  * $_SERVER['HTTP_USER_AGENT'] = 'UP.Browser/3.01-HI02 UP.Link/3.2.1.2';
  37.  * $agent = &Net_UserAgent_Mobile::factory();
  38.  *
  39.  * printf("Name: %s\n", $agent->getName()); // 'UP.Browser'
  40.  * printf("Version: %s\n", $agent->getVersion()); // 3.01
  41.  * printf("DeviceID: %s\n", $agent->getDeviceID()); // 'HI02'
  42.  * printf("Server: %s\n", $agent->getServer()); // 'UP.Link/3.2.1.2'
  43.  *
  44.  * e.g.) 'UP.Browser/3.01-HI02 UP.Link/3.2.1.2 (Google WAP Proxy/1.0)'
  45.  * printf("Comment: %s\n", $agent->getComment()); // 'Google WAP Proxy/1.0'
  46.  *
  47.  * e.g.) 'KDDI-TS21 UP.Browser/6.0.2.276 (GUI) MMP/1.1'
  48.  * if ($agent->isXHTMLCompliant()) {
  49.  *     print "XHTML compliant!\n"; // true
  50.  * }
  51.  * </code>
  52.  *
  53.  * @package  Net_UserAgent_Mobile
  54.  * @category Networking
  55.  * @author   KUBO Atsuhiro <kubo@isite.co.jp>
  56.  * @access   public
  57.  * @version  $Revision: 1.12 $
  58.  * @see      Net_UserAgent_Mobile_Common
  59.  * @link     http://www.au.kddi.com/ezfactory/tec/spec/4_4.html
  60.  * @link     http://www.au.kddi.com/ezfactory/tec/spec/new_win/ezkishu.html
  61.  */
  62. {
  63.  
  64.     // {{{ properties
  65.  
  66.     /**#@+
  67.      * @access private
  68.      */
  69.  
  70.     /**
  71.      * name of the model like 'P502i'
  72.      * @var string 
  73.      */
  74.     var $_model '';
  75.  
  76.     /**
  77.      * device ID like 'TS21'
  78.      * @var string 
  79.      */
  80.     var $_deviceID '';
  81.  
  82.     /**
  83.      * server string like 'UP.Link/3.2.1.2'
  84.      * @var string 
  85.      */
  86.     var $_serverName '';
  87.  
  88.     /**
  89.      * comment like 'Google WAP Proxy/1.0'
  90.      * @var string 
  91.      */
  92.     var $_comment = null;
  93.  
  94.     /**
  95.      * whether it's XHTML compliant or not
  96.      * @var boolean 
  97.      */
  98.     var $_xhtmlCompliant = false;
  99.  
  100.     /**#@-*/
  101.  
  102.     /**#@+
  103.      * @access public
  104.      */
  105.  
  106.     // }}}
  107.     // {{{ isEZweb()
  108.  
  109.     /**
  110.      * returns true
  111.      *
  112.      * @return boolean 
  113.      */
  114.     function isEZweb()
  115.     {
  116.         return true;
  117.     }
  118.  
  119.     // }}}
  120.     // {{{ parse()
  121.  
  122.     /**
  123.      * parse HTTP_USER_AGENT string
  124.      */
  125.     function parse()
  126.     {
  127.         $agent $this->getUserAgent();
  128.  
  129.         if (preg_match('/^KDDI-(.*)/'$agent$matches)) {
  130.  
  131.             // KDDI-TS21 UP.Browser/6.0.2.276 (GUI) MMP/1.1
  132.             $this->_xhtmlCompliant = true;
  133.             list($this->_deviceID$browser$opt$this->_serverName=
  134.                 explode(' '$matches[1]4);
  135.             list($this->name$versionexplode('/'$browser);
  136.             $this->version = "$version $opt";
  137.         else {
  138.  
  139.             // UP.Browser/3.01-HI01 UP.Link/3.4.5.2
  140.             @list($browser$this->_serverName$comment=
  141.                 explode(' '$agent3);
  142.             list($this->name$softwareexplode('/'$browser);
  143.             list($this->version$this->_deviceID=
  144.                 explode('-'$software);
  145.             if ($comment{
  146.                 $this->_comment =
  147.                     preg_replace('/^\((.*)\)$/''$1'$comment);
  148.             }
  149.         }
  150.     }
  151.  
  152.     // }}}
  153.     // {{{ makeDisplay()
  154.  
  155.     /**
  156.      * create a new {@link Net_UserAgent_Mobile_Display} class instance
  157.      *
  158.      * @return object newly created {@link Net_UserAgent_Mobile_Display}
  159.      *      object
  160.      * @see Net_UserAgent_Mobile_Display
  161.      */
  162.     function makeDisplay()
  163.     {
  164.         @list($width$height=
  165.             explode(','$this->getHeader('x-up-devcap-screenpixels'));
  166.         $screenDepth =
  167.             explode(','$this->getHeader('x-up-devcap-screendepth'));
  168.         $depth $screenDepth[0pow(2(integer)$screenDepth[0]: 0;
  169.         $color =
  170.             $this->getHeader('x-up-devcap-iscolor'=== '1' ? true : false;
  171.         return new Net_UserAgent_Mobile_Display(array(
  172.                                                       'width'  => $width,
  173.                                                       'height' => $height,
  174.                                                       'color'  => $color,
  175.                                                       'depth'  => $depth
  176.                                                       )
  177.                                                 );
  178.     }
  179.  
  180.     // }}}
  181.     // {{{ getModel()
  182.  
  183.     /**
  184.      * returns name of the model like 'A5501T'
  185.      *
  186.      * @return string 
  187.      */
  188.     function getModel()
  189.     {
  190.         static $deviceIdToModel;
  191.         if (!isset($deviceIdToModel)) {
  192.             $deviceIdToModel = array(
  193.                                         // W (excluding W01K)
  194.                                         'HI32' => 'W21H',
  195.                                         'KC31' => 'W11K',
  196.                                         'HI31' => 'W11H',
  197.  
  198.                                         // INFOBAR, A5000/C5000
  199.                                         'ST22' => 'INFOBAR',
  200.                                         'TS27' => 'A5504T',
  201.                                         'SA26' => 'A5503SA',
  202.                                         'KC25' => 'A5502K',
  203.                                         'KC24' => 'A5502K',
  204.                                         'TS26' => 'A5501T',
  205.                                         'ST23' => 'A5405SA',
  206.                                         'SN25' => 'A5404S',
  207.                                         'CA24' => 'A5403CA',
  208.                                         'SN24' => 'A5402S',
  209.                                         'CA23' => 'A5401CA'// including A5401CA II
  210.                                         'ST21' => 'A5306ST',
  211.                                         'KC22' => 'A5305K',
  212.                                         'TS24' => 'A5304T',
  213.                                         'HI24' => 'A5303H II',
  214.                                         'HI23' => 'A5303H',
  215.                                         'CA22' => 'A5302CA',
  216.                                         'TS23' => 'A5301T',
  217.                                         'TS21' => 'C5001T',
  218.  
  219.                                         // A1400/A1300/A1100
  220.                                         'SN26' => 'A1402S',
  221.                                         'KC23' => 'A1401K',
  222.                                         'TS25' => 'A1304T'// including A1304T II
  223.                                         'SA25' => 'A1303SA',
  224.                                         'SA24' => 'A1302SA',
  225.                                         'SN23' => 'A1301S',
  226.                                         'SN22' => 'A1101S',
  227.  
  228.                                         // A3000/C3000
  229.                                         'SA22' => 'A3015SA',
  230.                                         'SN21' => 'A3014S',
  231.                                         'TS22' => 'A3013T',
  232.                                         'CA21' => 'A3012CA',
  233.                                         'SA21' => 'A3011SA',
  234.                                         'MA21' => 'C3003P',
  235.                                         'KC21' => 'C3002K',
  236.                                         'HI21' => 'C3001H',
  237.  
  238.                                         // A1000/C1000/C400/C300/C200
  239.                                         'ST14' => 'A1014ST',
  240.                                         'KC15' => 'A1013K',
  241.                                         'KC14' => 'A1012K',
  242.                                         'ST13' => 'A1011ST',
  243.                                         'SN17' => 'C1002S',
  244.                                         'SY15' => 'C1001SA',
  245.                                         'CA14' => 'C452CA',
  246.                                         'HI14' => 'C451H',
  247.                                         'TS14' => 'C415T',
  248.                                         'KC13' => 'C414K',
  249.                                         'SN15' => 'C413S',
  250.                                         'SN16' => 'C413S',
  251.                                         'SY14' => 'C412SA',
  252.                                         'ST12' => 'C411ST',
  253.                                         'TS13' => 'C410T',
  254.                                         'CA13' => 'C409CA',
  255.                                         'MA13' => 'C408P',
  256.                                         'HI13' => 'C407H',
  257.                                         'SN13' => 'C406S',
  258.                                         'SY13' => 'C405SA',
  259.                                         'SN12' => 'C404S',
  260.                                         'SN14' => 'C404S',
  261.                                         'ST11' => 'C403ST',
  262.                                         'DN11' => 'C402DE',
  263.                                         'SY12' => 'C401SA',
  264.                                         'KC12' => 'C313K',
  265.                                         'CA12' => 'C311CA',
  266.                                         'TS12' => 'C310T',
  267.                                         'HI12' => 'C309H',
  268.                                         'MA11' => 'C308P',
  269.                                         'MA12' => 'C308P',
  270.                                         'KC11' => 'C307K',
  271.                                         'SN11' => 'C305S',
  272.                                         'SY11' => 'C304SA',
  273.                                         'CA11' => 'C303CA',
  274.                                         'HI11' => 'C302H',
  275.                                         'TS11' => 'C301T',
  276.                                         'DN01' => 'C202DE',
  277.                                         'HI01' => 'C201H',
  278.                                         'HI02' => 'C201H',
  279.  
  280.                                         // Tu-Ka
  281.                                         'KCU1' => 'TK41',
  282.                                         'SYT5' => 'TS41',
  283.                                         'KCTD' => 'TK40',
  284.                                         'TST8' => 'TT32',
  285.                                         'TST7' => 'TT31',
  286.                                         'KCTC' => 'TK31',
  287.                                         'SYT4' => 'TS31',
  288.                                         'KCTB' => 'TK23',
  289.                                         'KCTA' => 'TK22',
  290.                                         'TST6' => 'TT22',
  291.                                         'KCT9' => 'TK21',
  292.                                         'TST5' => 'TT21',
  293.                                         'TST4' => 'TT11',
  294.                                         'KCT8' => 'TK12',
  295.                                         'SYT3' => 'TS11',
  296.                                         'KCT7' => 'TK11',
  297.                                         'MIT1' => 'TD11',
  298.                                         'MAT3' => 'TP11',
  299.                                         'KCT6' => 'TK05',
  300.                                         'TST3' => 'TT03',
  301.                                         'KCT5' => 'TK04',
  302.                                         'KCT4' => 'TK03',
  303.                                         'SYT2' => 'TS02',
  304.                                         'MAT1' => 'TP01',
  305.                                         'MAT2' => 'TP01',
  306.                                         'TST2' => 'TT02',
  307.                                         'KCT2' => 'TK02',
  308.                                         'KCT3' => 'TK02',
  309.                                         'KCT1' => 'TK01',
  310.                                         'TST1' => 'TT01',
  311.                                         'SYT1' => 'TS01'
  312.                                         );
  313.         }
  314.  
  315.         return @$deviceIdToModel[$this->_deviceID];
  316.     }
  317.  
  318.     // }}}
  319.     // {{{ getDeviceID()
  320.  
  321.     /**
  322.      * returns device ID like 'TS21'
  323.      *
  324.      * @return string 
  325.      */
  326.     function getDeviceID()
  327.     {
  328.         return $this->_deviceID;
  329.     }
  330.  
  331.     // }}}
  332.     // {{{ getServer()
  333.  
  334.     /**
  335.      * returns server string like 'UP.Link/3.2.1.2'
  336.      *
  337.      * @return string 
  338.      */
  339.     function getServer()
  340.     {
  341.         return $this->_serverName;
  342.     }
  343.  
  344.     // }}}
  345.     // {{{ getComment()
  346.  
  347.     /**
  348.      * returns comment like 'Google WAP Proxy/1.0'. returns null if nothinng.
  349.      *
  350.      * @return boolean 
  351.      */
  352.     function getComment()
  353.     {
  354.         return $this->_comment;
  355.     }
  356.  
  357.     // }}}
  358.     // {{{ isXHTMLCompliant()
  359.  
  360.     /**
  361.      * returns whether it's XHTML compliant or not
  362.      *
  363.      * @return boolean 
  364.      */
  365.     function isXHTMLCompliant()
  366.     {
  367.         return $this->_xhtmlCompliant;
  368.     }
  369.  
  370.     /**#@-*/
  371. }
  372.  
  373. /*
  374.  * Local Variables:
  375.  * mode: php
  376.  * coding: iso-8859-1
  377.  * tab-width: 4
  378.  * c-basic-offset: 4
  379.  * c-hanging-comment-ender-p: nil
  380.  * indent-tabs-mode: nil
  381.  * End:
  382.  */
  383. ?>

Documentation generated on Mon, 11 Mar 2019 10:16:55 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.