| 1 | <?php |
|---|
| 2 | |
|---|
| 3 | // |
|---|
| 4 | // Open Web Analytics - An Open Source Web Analytics Framework |
|---|
| 5 | // |
|---|
| 6 | // Copyright 2006 Peter Adams. All rights reserved. |
|---|
| 7 | // |
|---|
| 8 | // Licensed under GPL v2.0 http://www.gnu.org/copyleft/gpl.html |
|---|
| 9 | // |
|---|
| 10 | // Unless required by applicable law or agreed to in writing, software |
|---|
| 11 | // distributed under the License is distributed on an "AS IS" BASIS, |
|---|
| 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|---|
| 13 | // See the License for the specific language governing permissions and |
|---|
| 14 | // limitations under the License. |
|---|
| 15 | // |
|---|
| 16 | // $Id$ |
|---|
| 17 | // |
|---|
| 18 | |
|---|
| 19 | /** |
|---|
| 20 | * OWA Request Params |
|---|
| 21 | * |
|---|
| 22 | * @author Peter Adams <peter@openwebanalytics.com> |
|---|
| 23 | * @copyright Copyright © 2006 Peter Adams <peter@openwebanalytics.com> |
|---|
| 24 | * @license http://www.gnu.org/copyleft/gpl.html GPL v2.0 |
|---|
| 25 | * @category owa |
|---|
| 26 | * @package owa |
|---|
| 27 | * @version $Revision$ |
|---|
| 28 | * @since owa 1.0.0 |
|---|
| 29 | */ |
|---|
| 30 | |
|---|
| 31 | class owa_requestContainer { |
|---|
| 32 | |
|---|
| 33 | var $php_self; |
|---|
| 34 | var $cli_args; |
|---|
| 35 | var $gateway_interface; |
|---|
| 36 | var $server_ip_address; |
|---|
| 37 | var $server_name; |
|---|
| 38 | var $server_software; |
|---|
| 39 | var $server_protocol; |
|---|
| 40 | var $server_document_root; |
|---|
| 41 | var $request_method; |
|---|
| 42 | var $request_time; |
|---|
| 43 | var $query_string; |
|---|
| 44 | var $is_https; |
|---|
| 45 | var $remote_ip_address; |
|---|
| 46 | var $remote_host; |
|---|
| 47 | var $remote_port; |
|---|
| 48 | var $path_translated; |
|---|
| 49 | var $script_filename; |
|---|
| 50 | var $request_uri; |
|---|
| 51 | var $server_auth_user; |
|---|
| 52 | var $server_auth_password; |
|---|
| 53 | var $auth_type; |
|---|
| 54 | var $owa_params; |
|---|
| 55 | var $cookies; |
|---|
| 56 | var $request; |
|---|
| 57 | var $guid; |
|---|
| 58 | |
|---|
| 59 | /** |
|---|
| 60 | * Request Params |
|---|
| 61 | * @depricated |
|---|
| 62 | * @var array |
|---|
| 63 | */ |
|---|
| 64 | var $params; |
|---|
| 65 | |
|---|
| 66 | |
|---|
| 67 | |
|---|
| 68 | /** |
|---|
| 69 | * Singleton returns request params |
|---|
| 70 | * |
|---|
| 71 | * @return array |
|---|
| 72 | * @todo DEPRICATED |
|---|
| 73 | */ |
|---|
| 74 | function &getInstance() { |
|---|
| 75 | |
|---|
| 76 | static $params; |
|---|
| 77 | |
|---|
| 78 | if(empty($params)): |
|---|
| 79 | |
|---|
| 80 | $params = owa_lib::getRequestParams(); |
|---|
| 81 | |
|---|
| 82 | $params['guid'] = $this->guid; |
|---|
| 83 | |
|---|
| 84 | return $params; |
|---|
| 85 | |
|---|
| 86 | else: |
|---|
| 87 | |
|---|
| 88 | return $params; |
|---|
| 89 | |
|---|
| 90 | endif; |
|---|
| 91 | |
|---|
| 92 | } |
|---|
| 93 | |
|---|
| 94 | function owa_requestContainer() { |
|---|
| 95 | |
|---|
| 96 | return $this->__construct(); |
|---|
| 97 | } |
|---|
| 98 | |
|---|
| 99 | function __construct() { |
|---|
| 100 | |
|---|
| 101 | $this->guid = crc32(microtime().getmypid()); |
|---|
| 102 | |
|---|
| 103 | $this->cli_args = $_SERVER['argv']; |
|---|
| 104 | |
|---|
| 105 | $this->php_self = $_SERVER['PHP_SELF']; |
|---|
| 106 | $this->gateway_interface = $_SERVER['GATEWAY_INTERFACE']; |
|---|
| 107 | $this->server_ip_address = $_SERVER['SERVER_ADDR']; |
|---|
| 108 | $this->server_name = $_SERVER['SERVER_NAME']; |
|---|
| 109 | $this->server_software = $_SERVER['SERVER_SOFTWARE']; |
|---|
| 110 | $this->server_protocol = $_SERVER['SERVER_PROTOCOL']; |
|---|
| 111 | $this->server_document_root = $_SERVER['DOCUMENT_ROOT']; |
|---|
| 112 | $this->server_auth_user = $_SERVER['PHP_AUTH_USER']; |
|---|
| 113 | $this->server_auth_password = $_SERVER['PHP_AUTH_PW']; |
|---|
| 114 | $this->server_auth_type = $_SERVER['AUTH_TYPE']; |
|---|
| 115 | $this->server_path_translated = $_SERVER['PATH_TRANSLATED']; |
|---|
| 116 | $this->request_method = $_SERVER['REQUEST_METHOD']; |
|---|
| 117 | $this->request_time = $_SERVER['REQUEST_TIME']; |
|---|
| 118 | $this->query_string = $_SERVER['QUERY_STRING']; |
|---|
| 119 | $this->http_accept = $_SERVER['HTTP_ACCEPT']; |
|---|
| 120 | $this->http_accept_charset = $_SERVER['HTTP_ACCEPT_CHARSET']; |
|---|
| 121 | $this->http_accept_encoding = $_SERVER['HTTP_ACCEPT_ENCODING']; |
|---|
| 122 | $this->http_accept_language = $_SERVER['HTTP_ACCEPT_LANGUAGE']; |
|---|
| 123 | $this->http_connection = $_SERVER['HTTP_CONNECTION']; |
|---|
| 124 | $this->http_host = $_SERVER['HTTP_HOST']; |
|---|
| 125 | $this->http_referer = $_SERVER['HTTP_REFERER']; |
|---|
| 126 | $this->http_user_agent = $_SERVER['HTTP_USER_AGENT']; |
|---|
| 127 | $this->remote_ip_address = $_SERVER['REMOTE_ADDR']; |
|---|
| 128 | $this->remote_host = $_SERVER['REMOTE_HOST']; |
|---|
| 129 | $this->remote_port = $_SERVER['REMOTE_PORT']; |
|---|
| 130 | $this->script_filename = $_SERVER['SCRIPT_FILENAME']; |
|---|
| 131 | $this->request_uri = $_SERVER['REQUEST_URI']; |
|---|
| 132 | $this->cookies = $_COOKIE; |
|---|
| 133 | $this->request = owa_lib::inputFilter($_REQUEST); |
|---|
| 134 | $this->owa_params = owa_lib::stripParams($this->request); |
|---|
| 135 | |
|---|
| 136 | |
|---|
| 137 | if(isset($_SERVER['HTTPS'])): |
|---|
| 138 | $this->is_https = true; |
|---|
| 139 | endif; |
|---|
| 140 | |
|---|
| 141 | return; |
|---|
| 142 | |
|---|
| 143 | } |
|---|
| 144 | |
|---|
| 145 | function get($name) { |
|---|
| 146 | |
|---|
| 147 | return $this->$name; |
|---|
| 148 | |
|---|
| 149 | } |
|---|
| 150 | |
|---|
| 151 | function set($name, $value) { |
|---|
| 152 | |
|---|
| 153 | $this->$name = $value; |
|---|
| 154 | return true; |
|---|
| 155 | } |
|---|
| 156 | |
|---|
| 157 | function getParam($name) { |
|---|
| 158 | |
|---|
| 159 | return $this->owa_params[$name]; |
|---|
| 160 | } |
|---|
| 161 | |
|---|
| 162 | function setParam($name, $value) { |
|---|
| 163 | |
|---|
| 164 | $this->owa_params[$name] = $value; |
|---|
| 165 | return true; |
|---|
| 166 | } |
|---|
| 167 | |
|---|
| 168 | function getCookie($name) { |
|---|
| 169 | |
|---|
| 170 | return $this->cookies[$name]; |
|---|
| 171 | } |
|---|
| 172 | |
|---|
| 173 | function getRequestParam($name) { |
|---|
| 174 | |
|---|
| 175 | return $this->request[$name]; |
|---|
| 176 | } |
|---|
| 177 | |
|---|
| 178 | |
|---|
| 179 | } |
|---|
| 180 | |
|---|
| 181 | ?> |
|---|