1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
use EventEspresso\core\exceptions\InvalidDataTypeException; |
4
|
|
|
use EventEspresso\core\exceptions\InvalidInterfaceException; |
5
|
|
|
use EventEspresso\core\interfaces\InterminableInterface; |
6
|
|
|
use EventEspresso\core\services\loaders\LoaderFactory; |
7
|
|
|
use EventEspresso\core\services\request\LegacyRequestInterface; |
8
|
|
|
use EventEspresso\core\services\request\RequestInterface; |
9
|
|
|
|
10
|
|
|
defined('EVENT_ESPRESSO_VERSION') || exit('No direct script access allowed'); |
11
|
|
|
|
12
|
|
|
|
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* class EE_Request |
16
|
|
|
* |
17
|
|
|
* @deprecated 4.9.53 |
18
|
|
|
* @package Event Espresso |
19
|
|
|
* @subpackage /core/ |
20
|
|
|
* @author Brent Christensen |
21
|
|
|
*/ |
22
|
|
|
class EE_Request implements LegacyRequestInterface, InterminableInterface |
23
|
|
|
{ |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* @var RequestInterface $request |
27
|
|
|
*/ |
28
|
|
|
private $request; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* whether current request is for the admin but NOT via AJAX |
32
|
|
|
* |
33
|
|
|
* @var boolean $admin |
34
|
|
|
*/ |
35
|
|
|
public $admin = false; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* whether current request is via AJAX |
39
|
|
|
* |
40
|
|
|
* @var boolean $ajax |
41
|
|
|
*/ |
42
|
|
|
public $ajax = false; |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* whether current request is via AJAX from the frontend of the site |
46
|
|
|
* |
47
|
|
|
* @var boolean $front_ajax |
48
|
|
|
*/ |
49
|
|
|
public $front_ajax = false; |
50
|
|
|
|
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* @deprecated 4.9.53 |
54
|
|
|
* @param array $get |
55
|
|
|
* @param array $post |
56
|
|
|
* @param array $cookie |
57
|
|
|
* @param array $server |
58
|
|
|
*/ |
59
|
|
|
public function __construct(array $get, array $post, array $cookie, array $server = array()) |
60
|
|
|
{ |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* @return RequestInterface |
66
|
|
|
* @throws InvalidArgumentException |
67
|
|
|
* @throws InvalidInterfaceException |
68
|
|
|
* @throws InvalidDataTypeException |
69
|
|
|
*/ |
70
|
|
|
private function request() |
71
|
|
|
{ |
72
|
|
|
if($this->request instanceof RequestInterface){ |
73
|
|
|
return $this->request; |
74
|
|
|
} |
75
|
|
|
$loader = LoaderFactory::getLoader(); |
76
|
|
|
$this->request = $loader->getShared('EventEspresso\core\services\request\RequestInterface'); |
77
|
|
|
return $this->request; |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* @param RequestInterface $request |
83
|
|
|
*/ |
84
|
|
|
public function setRequest(RequestInterface $request) |
85
|
|
|
{ |
86
|
|
|
$this->request = $request; |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
|
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* @deprecated 4.9.53 |
93
|
|
|
* @return array |
94
|
|
|
* @throws InvalidArgumentException |
95
|
|
|
* @throws InvalidDataTypeException |
96
|
|
|
* @throws InvalidInterfaceException |
97
|
|
|
*/ |
98
|
|
|
public function get_params() |
99
|
|
|
{ |
100
|
|
|
return $this->request()->getParams(); |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
|
104
|
|
|
|
105
|
|
|
/** |
106
|
|
|
* @deprecated 4.9.53 |
107
|
|
|
* @return array |
108
|
|
|
* @throws InvalidArgumentException |
109
|
|
|
* @throws InvalidDataTypeException |
110
|
|
|
* @throws InvalidInterfaceException |
111
|
|
|
*/ |
112
|
|
|
public function post_params() |
113
|
|
|
{ |
114
|
|
|
return $this->request()->postParams(); |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
|
118
|
|
|
|
119
|
|
|
/** |
120
|
|
|
* @deprecated 4.9.53 |
121
|
|
|
* @return array |
122
|
|
|
* @throws InvalidArgumentException |
123
|
|
|
* @throws InvalidDataTypeException |
124
|
|
|
* @throws InvalidInterfaceException |
125
|
|
|
*/ |
126
|
|
|
public function cookie_params() |
127
|
|
|
{ |
128
|
|
|
return $this->request()->cookieParams(); |
129
|
|
|
} |
130
|
|
|
|
131
|
|
|
|
132
|
|
|
/** |
133
|
|
|
* @deprecated 4.9.53 |
134
|
|
|
* @return array |
135
|
|
|
* @throws InvalidArgumentException |
136
|
|
|
* @throws InvalidDataTypeException |
137
|
|
|
* @throws InvalidInterfaceException |
138
|
|
|
*/ |
139
|
|
|
public function server_params() |
140
|
|
|
{ |
141
|
|
|
return $this->request()->serverParams(); |
142
|
|
|
} |
143
|
|
|
|
144
|
|
|
|
145
|
|
|
|
146
|
|
|
/** |
147
|
|
|
* returns contents of $_REQUEST |
148
|
|
|
* |
149
|
|
|
* @deprecated 4.9.53 |
150
|
|
|
* @return array |
151
|
|
|
* @throws InvalidArgumentException |
152
|
|
|
* @throws InvalidDataTypeException |
153
|
|
|
* @throws InvalidInterfaceException |
154
|
|
|
*/ |
155
|
|
|
public function params() |
156
|
|
|
{ |
157
|
|
|
return $this->request()->requestParams(); |
158
|
|
|
} |
159
|
|
|
|
160
|
|
|
|
161
|
|
|
|
162
|
|
|
/** |
163
|
|
|
* @deprecated 4.9.53 |
164
|
|
|
* @param $key |
165
|
|
|
* @param $value |
166
|
|
|
* @param bool $override_ee |
167
|
|
|
* @return void |
168
|
|
|
* @throws InvalidArgumentException |
169
|
|
|
* @throws InvalidDataTypeException |
170
|
|
|
* @throws InvalidInterfaceException |
171
|
|
|
*/ |
172
|
|
|
public function set($key, $value, $override_ee = false) |
173
|
|
|
{ |
174
|
|
|
$this->request()->setRequestParam($key, $value, $override_ee); |
175
|
|
|
} |
176
|
|
|
|
177
|
|
|
|
178
|
|
|
|
179
|
|
|
/** |
180
|
|
|
* returns the value for a request param if the given key exists |
181
|
|
|
* |
182
|
|
|
* @deprecated 4.9.53 |
183
|
|
|
* @param $key |
184
|
|
|
* @param null $default |
185
|
|
|
* @return mixed |
186
|
|
|
* @throws InvalidArgumentException |
187
|
|
|
* @throws InvalidDataTypeException |
188
|
|
|
* @throws InvalidInterfaceException |
189
|
|
|
*/ |
190
|
|
|
public function get($key, $default = null) |
191
|
|
|
{ |
192
|
|
|
return $this->request()->getRequestParam($key, $default); |
193
|
|
|
} |
194
|
|
|
|
195
|
|
|
|
196
|
|
|
|
197
|
|
|
/** |
198
|
|
|
* check if param exists |
199
|
|
|
* |
200
|
|
|
* @deprecated 4.9.53 |
201
|
|
|
* @param $key |
202
|
|
|
* @return bool |
203
|
|
|
* @throws InvalidArgumentException |
204
|
|
|
* @throws InvalidDataTypeException |
205
|
|
|
* @throws InvalidInterfaceException |
206
|
|
|
*/ |
207
|
|
|
public function is_set($key) |
208
|
|
|
{ |
209
|
|
|
return $this->request()->requestParamIsSet($key); |
210
|
|
|
} |
211
|
|
|
|
212
|
|
|
|
213
|
|
|
|
214
|
|
|
/** |
215
|
|
|
* remove param |
216
|
|
|
* |
217
|
|
|
* @deprecated 4.9.53 |
218
|
|
|
* @param $key |
219
|
|
|
* @param bool $unset_from_global_too |
220
|
|
|
* @throws InvalidArgumentException |
221
|
|
|
* @throws InvalidDataTypeException |
222
|
|
|
* @throws InvalidInterfaceException |
223
|
|
|
*/ |
224
|
|
|
public function un_set($key, $unset_from_global_too = false) |
225
|
|
|
{ |
226
|
|
|
$this->request()->unSetRequestParam($key, $unset_from_global_too); |
227
|
|
|
} |
228
|
|
|
|
229
|
|
|
|
230
|
|
|
|
231
|
|
|
/** |
232
|
|
|
* @deprecated 4.9.53 |
233
|
|
|
* @return string |
234
|
|
|
* @throws InvalidArgumentException |
235
|
|
|
* @throws InvalidDataTypeException |
236
|
|
|
* @throws InvalidInterfaceException |
237
|
|
|
*/ |
238
|
|
|
public function ip_address() |
239
|
|
|
{ |
240
|
|
|
return $this->request()->ipAddress(); |
241
|
|
|
} |
242
|
|
|
|
243
|
|
|
|
244
|
|
|
/** |
245
|
|
|
* @deprecated 4.9.53 |
246
|
|
|
* @return bool |
247
|
|
|
* @throws InvalidArgumentException |
248
|
|
|
* @throws InvalidDataTypeException |
249
|
|
|
* @throws InvalidInterfaceException |
250
|
|
|
*/ |
251
|
|
|
public function isAdmin() |
252
|
|
|
{ |
253
|
|
|
return $this->request()->isAdmin(); |
254
|
|
|
} |
255
|
|
|
|
256
|
|
|
|
257
|
|
|
/** |
258
|
|
|
* @deprecated 4.9.53 |
259
|
|
|
* @return mixed |
260
|
|
|
* @throws InvalidArgumentException |
261
|
|
|
* @throws InvalidDataTypeException |
262
|
|
|
* @throws InvalidInterfaceException |
263
|
|
|
*/ |
264
|
|
|
public function isAjax() |
265
|
|
|
{ |
266
|
|
|
return $this->request()->isAjax(); |
267
|
|
|
} |
268
|
|
|
|
269
|
|
|
|
270
|
|
|
/** |
271
|
|
|
* @deprecated 4.9.53 |
272
|
|
|
* @return mixed |
273
|
|
|
* @throws InvalidArgumentException |
274
|
|
|
* @throws InvalidDataTypeException |
275
|
|
|
* @throws InvalidInterfaceException |
276
|
|
|
*/ |
277
|
|
|
public function isFrontAjax() |
278
|
|
|
{ |
279
|
|
|
return $this->request()->isFrontAjax(); |
280
|
|
|
} |
281
|
|
|
|
282
|
|
|
|
283
|
|
|
/** |
284
|
|
|
* @deprecated 4.9.53 |
285
|
|
|
* @return mixed|string |
286
|
|
|
* @throws InvalidArgumentException |
287
|
|
|
* @throws InvalidDataTypeException |
288
|
|
|
* @throws InvalidInterfaceException |
289
|
|
|
*/ |
290
|
|
|
public function requestUri() |
291
|
|
|
{ |
292
|
|
|
return $this->request()->requestUri(); |
293
|
|
|
} |
294
|
|
|
|
295
|
|
|
|
296
|
|
|
/** |
297
|
|
|
* @deprecated 4.9.53 |
298
|
|
|
* @return string |
299
|
|
|
* @throws InvalidArgumentException |
300
|
|
|
* @throws InvalidDataTypeException |
301
|
|
|
* @throws InvalidInterfaceException |
302
|
|
|
*/ |
303
|
|
|
public function userAgent() |
304
|
|
|
{ |
305
|
|
|
return $this->request()->userAgent(); |
306
|
|
|
} |
307
|
|
|
|
308
|
|
|
|
309
|
|
|
/** |
310
|
|
|
* @deprecated 4.9.53 |
311
|
|
|
* @param string $user_agent |
312
|
|
|
* @throws InvalidArgumentException |
313
|
|
|
* @throws InvalidDataTypeException |
314
|
|
|
* @throws InvalidInterfaceException |
315
|
|
|
*/ |
316
|
|
|
public function setUserAgent($user_agent = '') |
317
|
|
|
{ |
318
|
|
|
$this->request()->setUserAgent($user_agent); |
319
|
|
|
} |
320
|
|
|
|
321
|
|
|
|
322
|
|
|
/** |
323
|
|
|
* @deprecated 4.9.53 |
324
|
|
|
* @return bool |
325
|
|
|
* @throws InvalidArgumentException |
326
|
|
|
* @throws InvalidDataTypeException |
327
|
|
|
* @throws InvalidInterfaceException |
328
|
|
|
*/ |
329
|
|
|
public function isBot() |
330
|
|
|
{ |
331
|
|
|
return $this->request()->isBot(); |
332
|
|
|
} |
333
|
|
|
|
334
|
|
|
|
335
|
|
|
/** |
336
|
|
|
* @deprecated 4.9.53 |
337
|
|
|
* @param bool $is_bot |
338
|
|
|
* @throws InvalidArgumentException |
339
|
|
|
* @throws InvalidDataTypeException |
340
|
|
|
* @throws InvalidInterfaceException |
341
|
|
|
*/ |
342
|
|
|
public function setIsBot($is_bot) |
343
|
|
|
{ |
344
|
|
|
$this->request()->setIsBot($is_bot); |
345
|
|
|
} |
346
|
|
|
|
347
|
|
|
|
348
|
|
|
|
349
|
|
|
} |
350
|
|
|
// End of file EE_Request.core.php |
351
|
|
|
// Location: /core/request/EE_Request.core.php |
352
|
|
|
|