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.13 2004/09/25 11:02:37 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.13 $
  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.     // {{{ isTUKa()
  121.  
  122.     /**
  123.      * returns true if the agent is TU-Ka
  124.      *
  125.      * @return boolean 
  126.      */
  127.     function isTUKa()
  128.     {
  129.         $tuka substr($this->_deviceID21);
  130.         if ($this->isWAP2()) {
  131.             if ($tuka == 'U'{
  132.                 return true;
  133.             }
  134.         else {
  135.             if ($tuka == 'T'{
  136.                 return true;
  137.             }
  138.         }
  139.         
  140.         return false;
  141.     }
  142.  
  143.     // }}}
  144.     // {{{ parse()
  145.  
  146.     /**
  147.      * parse HTTP_USER_AGENT string
  148.      */
  149.     function parse()
  150.     {
  151.         $agent $this->getUserAgent();
  152.  
  153.         if (preg_match('/^KDDI-(.*)/'$agent$matches)) {
  154.  
  155.             // KDDI-TS21 UP.Browser/6.0.2.276 (GUI) MMP/1.1
  156.             $this->_xhtmlCompliant = true;
  157.             list($this->_deviceID$browser$opt$this->_serverName=
  158.                 explode(' '$matches[1]4);
  159.             list($this->name$versionexplode('/'$browser);
  160.             $this->version = "$version $opt";
  161.         else {
  162.  
  163.             // UP.Browser/3.01-HI01 UP.Link/3.4.5.2
  164.             @list($browser$this->_serverName$comment=
  165.                 explode(' '$agent3);
  166.             list($this->name$softwareexplode('/'$browser);
  167.             list($this->version$this->_deviceID=
  168.                 explode('-'$software);
  169.             if ($comment{
  170.                 $this->_comment =
  171.                     preg_replace('/^\((.*)\)$/''$1'$comment);
  172.             }
  173.         }
  174.  
  175.         $this->_model $this->_deviceID;
  176.     }
  177.  
  178.     // }}}
  179.     // {{{ makeDisplay()
  180.  
  181.     /**
  182.      * create a new {@link Net_UserAgent_Mobile_Display} class instance
  183.      *
  184.      * @return object newly created {@link Net_UserAgent_Mobile_Display}
  185.      *      object
  186.      * @see Net_UserAgent_Mobile_Display
  187.      */
  188.     function makeDisplay()
  189.     {
  190.         @list($width$height=
  191.             explode(','$this->getHeader('x-up-devcap-screenpixels'));
  192.         $screenDepth =
  193.             explode(','$this->getHeader('x-up-devcap-screendepth'));
  194.         $depth $screenDepth[0pow(2(integer)$screenDepth[0]: 0;
  195.         $color =
  196.             $this->getHeader('x-up-devcap-iscolor'=== '1' ? true : false;
  197.         return new Net_UserAgent_Mobile_Display(array(
  198.                                                       'width'  => $width,
  199.                                                       'height' => $height,
  200.                                                       'color'  => $color,
  201.                                                       'depth'  => $depth
  202.                                                       )
  203.                                                 );
  204.     }
  205.  
  206.     // }}}
  207.     // {{{ getModel()
  208.  
  209.     /**
  210.      * returns name of the model (device ID) like 'TS21'
  211.      *
  212.      * @return string 
  213.      */
  214.     function getModel()
  215.     {
  216.         return $this->_model;
  217.     }
  218.  
  219.     // }}}
  220.     // {{{ getDeviceID()
  221.  
  222.     /**
  223.      * returns device ID like 'TS21'
  224.      *
  225.      * @return string 
  226.      */
  227.     function getDeviceID()
  228.     {
  229.         return $this->_deviceID;
  230.     }
  231.  
  232.     // }}}
  233.     // {{{ getServer()
  234.  
  235.     /**
  236.      * returns server string like 'UP.Link/3.2.1.2'
  237.      *
  238.      * @return string 
  239.      */
  240.     function getServer()
  241.     {
  242.         return $this->_serverName;
  243.     }
  244.  
  245.     // }}}
  246.     // {{{ getComment()
  247.  
  248.     /**
  249.      * returns comment like 'Google WAP Proxy/1.0'. returns null if nothinng.
  250.      *
  251.      * @return boolean 
  252.      */
  253.     function getComment()
  254.     {
  255.         return $this->_comment;
  256.     }
  257.  
  258.     // }}}
  259.     // {{{ isXHTMLCompliant()
  260.  
  261.     /**
  262.      * returns whether it's XHTML compliant or not
  263.      *
  264.      * @return boolean 
  265.      */
  266.     function isXHTMLCompliant()
  267.     {
  268.         return $this->_xhtmlCompliant;
  269.     }
  270.  
  271.     // }}}
  272.     // {{{ getCarrierShortName()
  273.  
  274.     /**
  275.      * returns the short name of the carrier
  276.      *
  277.      * @return string 
  278.      */
  279.     function getCarrierShortName()
  280.     {
  281.         return 'E';
  282.     }
  283.  
  284.     // }}}
  285.     // {{{ getCarrierLongName()
  286.  
  287.     /**
  288.      * returns the long name of the carrier
  289.      *
  290.      * @return string 
  291.      */
  292.     function getCarrierLongName()
  293.     {
  294.         return 'EZweb';
  295.     }
  296.  
  297.     /**#@-*/
  298. }
  299.  
  300. /*
  301.  * Local Variables:
  302.  * mode: php
  303.  * coding: iso-8859-1
  304.  * tab-width: 4
  305.  * c-basic-offset: 4
  306.  * c-hanging-comment-ender-p: nil
  307.  * indent-tabs-mode: nil
  308.  * End:
  309.  */
  310. ?>

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