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 <iteman@users.sourceforge.net> | |
---|
17 | // +----------------------------------------------------------------------+ |
---|
18 | // |
---|
19 | // $Id: Request.php,v 1.5 2006/11/07 09:25:14 kuboa Exp $ |
---|
20 | // |
---|
21 | |
---|
22 | /** |
---|
23 | * Utility class that constructs appropriate class instance for miscellaneous |
---|
24 | * HTTP header containers |
---|
25 | * |
---|
26 | * @package Net_UserAgent_Mobile |
---|
27 | * @category Networking |
---|
28 | * @author KUBO Atsuhiro <iteman@users.sourceforge.net> |
---|
29 | * @access public |
---|
30 | * @version $Revision: 1.5 $ |
---|
31 | */ |
---|
32 | class Net_UserAgent_Mobile_Request |
---|
33 | { |
---|
34 | |
---|
35 | /**#@+ |
---|
36 | * @access public |
---|
37 | * @static |
---|
38 | */ |
---|
39 | |
---|
40 | // }}} |
---|
41 | // {{{ factory() |
---|
42 | |
---|
43 | /** |
---|
44 | * create a new Net_UserAgent_Mobile_Request_XXX instance |
---|
45 | * |
---|
46 | * parses HTTP headers and constructs appropriate class instance. |
---|
47 | * If no argument is supplied, $_SERVER is used. |
---|
48 | * |
---|
49 | * @param mixed $stuff User-Agent string or object that works with |
---|
50 | * HTTP_Request (not implemented) |
---|
51 | * @return mixed a newly created Net_UserAgent_Request object |
---|
52 | * @global array $_SERVER |
---|
53 | */ |
---|
54 | function &factory($stuff = null) |
---|
55 | { |
---|
56 | if ($stuff === null) { |
---|
57 | $request = &new Net_UserAgent_Mobile_Request_Env($_SERVER); |
---|
58 | } else { |
---|
59 | $request = |
---|
60 | &new Net_UserAgent_Mobile_Request_Env(array( |
---|
61 | 'HTTP_USER_AGENT' => $stuff) |
---|
62 | ); |
---|
63 | } |
---|
64 | return $request; |
---|
65 | } |
---|
66 | |
---|
67 | /**#@-*/ |
---|
68 | } |
---|
69 | |
---|
70 | /** |
---|
71 | * provides easy way to access environment variables |
---|
72 | * |
---|
73 | * @package Net_UserAgent_Mobile |
---|
74 | * @category Networking |
---|
75 | * @author KUBO Atsuhiro <iteman@users.sourceforge.net> |
---|
76 | * @access public |
---|
77 | * @version $Revision: 1.5 $ |
---|
78 | */ |
---|
79 | class Net_UserAgent_Mobile_Request_Env |
---|
80 | { |
---|
81 | |
---|
82 | // {{{ properties |
---|
83 | |
---|
84 | /**#@+ |
---|
85 | * @access private |
---|
86 | */ |
---|
87 | |
---|
88 | /** |
---|
89 | * array of environment variables defined by Web Server |
---|
90 | * @var array |
---|
91 | */ |
---|
92 | var $_env; |
---|
93 | |
---|
94 | /**#@-*/ |
---|
95 | |
---|
96 | /**#@+ |
---|
97 | * @access public |
---|
98 | */ |
---|
99 | |
---|
100 | // }}} |
---|
101 | // {{{ constructor |
---|
102 | |
---|
103 | /** |
---|
104 | * constructor |
---|
105 | * |
---|
106 | * @param array $env |
---|
107 | */ |
---|
108 | function Net_UserAgent_Mobile_Request_Env($env) |
---|
109 | { |
---|
110 | $this->_env = $env; |
---|
111 | } |
---|
112 | |
---|
113 | /** |
---|
114 | * returns a specified HTTP Header |
---|
115 | * |
---|
116 | * @param string $header |
---|
117 | * @return string |
---|
118 | */ |
---|
119 | function get($header) |
---|
120 | { |
---|
121 | $header = strtr($header, '-', '_'); |
---|
122 | return @$this->_env[ 'HTTP_' . strtoupper($header) ]; |
---|
123 | } |
---|
124 | |
---|
125 | /**#@-*/ |
---|
126 | } |
---|
127 | |
---|
128 | /* |
---|
129 | * Local Variables: |
---|
130 | * mode: php |
---|
131 | * coding: iso-8859-1 |
---|
132 | * tab-width: 4 |
---|
133 | * c-basic-offset: 4 |
---|
134 | * c-hanging-comment-ender-p: nil |
---|
135 | * indent-tabs-mode: nil |
---|
136 | * End: |
---|
137 | */ |
---|
138 | ?> |
---|