| 1 | <?php
|
|---|
| 2 | /* vim: set expandtab tabstop=4 shiftwidth=4: */
|
|---|
| 3 |
|
|---|
| 4 | /**
|
|---|
| 5 | * PHP versions 4 and 5
|
|---|
| 6 | *
|
|---|
| 7 | * LICENSE: This source file is subject to version 3.0 of the PHP license
|
|---|
| 8 | * that is available through the world-wide-web at the following URI:
|
|---|
| 9 | * http://www.php.net/license/3_0.txt. If you did not receive a copy of
|
|---|
| 10 | * the PHP License and are unable to obtain it through the web, please
|
|---|
| 11 | * send a note to [email protected] so we can mail you a copy immediately.
|
|---|
| 12 | *
|
|---|
| 13 | * @category Networking
|
|---|
| 14 | * @package Net_UserAgent_Mobile
|
|---|
| 15 | * @author KUBO Atsuhiro <[email protected]>
|
|---|
| 16 | * @copyright 2003-2007 KUBO Atsuhiro <[email protected]>
|
|---|
| 17 | * @license http://www.php.net/license/3_0.txt PHP License 3.0
|
|---|
| 18 | * @version CVS: $Id$
|
|---|
| 19 | * @since File available since Release 0.1
|
|---|
| 20 | */
|
|---|
| 21 |
|
|---|
| 22 | // {{{ Net_UserAgent_Mobile_Request
|
|---|
| 23 |
|
|---|
| 24 | /**
|
|---|
| 25 | * Utility class that constructs appropriate class instance for miscellaneous
|
|---|
| 26 | * HTTP header containers
|
|---|
| 27 | *
|
|---|
| 28 | * @category Networking
|
|---|
| 29 | * @package Net_UserAgent_Mobile
|
|---|
| 30 | * @author KUBO Atsuhiro <[email protected]>
|
|---|
| 31 | * @copyright 2003-2007 KUBO Atsuhiro <[email protected]>
|
|---|
| 32 | * @license http://www.php.net/license/3_0.txt PHP License 3.0
|
|---|
| 33 | * @version Release: 0.30.0
|
|---|
| 34 | * @since Class available since Release 0.1
|
|---|
| 35 | */
|
|---|
| 36 | class Net_UserAgent_Mobile_Request
|
|---|
| 37 | {
|
|---|
| 38 |
|
|---|
| 39 | // {{{ properties
|
|---|
| 40 |
|
|---|
| 41 | /**#@+
|
|---|
| 42 | * @access public
|
|---|
| 43 | */
|
|---|
| 44 |
|
|---|
| 45 | /**#@-*/
|
|---|
| 46 |
|
|---|
| 47 | /**#@+
|
|---|
| 48 | * @access private
|
|---|
| 49 | */
|
|---|
| 50 |
|
|---|
| 51 | /**#@-*/
|
|---|
| 52 |
|
|---|
| 53 | /**#@+
|
|---|
| 54 | * @access public
|
|---|
| 55 | * @static
|
|---|
| 56 | */
|
|---|
| 57 |
|
|---|
| 58 | // }}}
|
|---|
| 59 | // {{{ factory()
|
|---|
| 60 |
|
|---|
| 61 | /**
|
|---|
| 62 | * create a new Net_UserAgent_Mobile_Request_XXX instance
|
|---|
| 63 | *
|
|---|
| 64 | * parses HTTP headers and constructs appropriate class instance.
|
|---|
| 65 | * If no argument is supplied, $_SERVER is used.
|
|---|
| 66 | *
|
|---|
| 67 | * @param mixed $stuff User-Agent string or object that works with
|
|---|
| 68 | * HTTP_Request (not implemented)
|
|---|
| 69 | * @return mixed a newly created Net_UserAgent_Request object
|
|---|
| 70 | * @global array $_SERVER
|
|---|
| 71 | */
|
|---|
| 72 | function &factory($stuff = null)
|
|---|
| 73 | {
|
|---|
| 74 | if ($stuff === null) {
|
|---|
| 75 | $request = &new Net_UserAgent_Mobile_Request_Env($_SERVER);
|
|---|
| 76 | } else {
|
|---|
| 77 | $request =
|
|---|
| 78 | &new Net_UserAgent_Mobile_Request_Env(array(
|
|---|
| 79 | 'HTTP_USER_AGENT' => $stuff)
|
|---|
| 80 | );
|
|---|
| 81 | }
|
|---|
| 82 | return $request;
|
|---|
| 83 | }
|
|---|
| 84 |
|
|---|
| 85 | /**#@-*/
|
|---|
| 86 |
|
|---|
| 87 | /**#@+
|
|---|
| 88 | * @access private
|
|---|
| 89 | */
|
|---|
| 90 |
|
|---|
| 91 | /**#@-*/
|
|---|
| 92 |
|
|---|
| 93 | // }}}
|
|---|
| 94 | }
|
|---|
| 95 |
|
|---|
| 96 | // }}}
|
|---|
| 97 | // {{{ Net_UserAgent_Mobile_Request_Env
|
|---|
| 98 |
|
|---|
| 99 | /**
|
|---|
| 100 | * provides easy way to access environment variables
|
|---|
| 101 | *
|
|---|
| 102 | * @category Networking
|
|---|
| 103 | * @package Net_UserAgent_Mobile
|
|---|
| 104 | * @author KUBO Atsuhiro <[email protected]>
|
|---|
| 105 | * @copyright 2003-2007 KUBO Atsuhiro <[email protected]>
|
|---|
| 106 | * @license http://www.php.net/license/3_0.txt PHP License 3.0
|
|---|
| 107 | * @version Release: 0.30.0
|
|---|
| 108 | * @since Class available since Release 0.1
|
|---|
| 109 | */
|
|---|
| 110 | class Net_UserAgent_Mobile_Request_Env
|
|---|
| 111 | {
|
|---|
| 112 |
|
|---|
| 113 | // {{{ properties
|
|---|
| 114 |
|
|---|
| 115 | /**#@+
|
|---|
| 116 | * @access public
|
|---|
| 117 | */
|
|---|
| 118 |
|
|---|
| 119 | /**#@-*/
|
|---|
| 120 |
|
|---|
| 121 | /**#@+
|
|---|
| 122 | * @access private
|
|---|
| 123 | */
|
|---|
| 124 |
|
|---|
| 125 | /**
|
|---|
| 126 | * array of environment variables defined by Web Server
|
|---|
| 127 | * @var array
|
|---|
| 128 | */
|
|---|
| 129 | var $_env;
|
|---|
| 130 |
|
|---|
| 131 | /**#@-*/
|
|---|
| 132 |
|
|---|
| 133 | /**#@+
|
|---|
| 134 | * @access public
|
|---|
| 135 | */
|
|---|
| 136 |
|
|---|
| 137 | // }}}
|
|---|
| 138 | // {{{ constructor
|
|---|
| 139 |
|
|---|
| 140 | /**
|
|---|
| 141 | * constructor
|
|---|
| 142 | *
|
|---|
| 143 | * @param array $env
|
|---|
| 144 | */
|
|---|
| 145 | function Net_UserAgent_Mobile_Request_Env($env)
|
|---|
| 146 | {
|
|---|
| 147 | $this->_env = $env;
|
|---|
| 148 | }
|
|---|
| 149 |
|
|---|
| 150 | /**
|
|---|
| 151 | * returns a specified HTTP Header
|
|---|
| 152 | *
|
|---|
| 153 | * @param string $header
|
|---|
| 154 | * @return string
|
|---|
| 155 | */
|
|---|
| 156 | function get($header)
|
|---|
| 157 | {
|
|---|
| 158 | $header = strtr($header, '-', '_');
|
|---|
| 159 | return @$this->_env[ 'HTTP_' . strtoupper($header) ];
|
|---|
| 160 | }
|
|---|
| 161 |
|
|---|
| 162 | /**#@-*/
|
|---|
| 163 |
|
|---|
| 164 | /**#@+
|
|---|
| 165 | * @access private
|
|---|
| 166 | */
|
|---|
| 167 |
|
|---|
| 168 | /**#@-*/
|
|---|
| 169 |
|
|---|
| 170 | // }}}
|
|---|
| 171 | }
|
|---|
| 172 |
|
|---|
| 173 | // }}}
|
|---|
| 174 |
|
|---|
| 175 | /*
|
|---|
| 176 | * Local Variables:
|
|---|
| 177 | * mode: php
|
|---|
| 178 | * coding: iso-8859-1
|
|---|
| 179 | * tab-width: 4
|
|---|
| 180 | * c-basic-offset: 4
|
|---|
| 181 | * c-hanging-comment-ender-p: nil
|
|---|
| 182 | * indent-tabs-mode: nil
|
|---|
| 183 | * End:
|
|---|
| 184 | */
|
|---|
| 185 | ?>
|
|---|