@@ -18,181 +18,181 @@ |
||
18 | 18 | class RequestTypeContextDetector |
19 | 19 | { |
20 | 20 | |
21 | - /** |
|
22 | - * @var RequestTypeContextFactoryInterface $factory |
|
23 | - */ |
|
24 | - private $factory; |
|
25 | - |
|
26 | - /** |
|
27 | - * @var RequestInterface $request |
|
28 | - */ |
|
29 | - private $request; |
|
30 | - |
|
31 | - /** |
|
32 | - * @var array $globalRouteConditions |
|
33 | - */ |
|
34 | - private $globalRouteConditions; |
|
35 | - |
|
36 | - |
|
37 | - /** |
|
38 | - * RequestTypeContextDetector constructor. |
|
39 | - * |
|
40 | - * @param RequestInterface $request |
|
41 | - * @param RequestTypeContextFactoryInterface $factory |
|
42 | - * @param array $globalRouteConditions an array for injecting values that would |
|
43 | - * otherwise be defined as global constants |
|
44 | - * or other global variables for the current |
|
45 | - * request route such as DOING_AJAX |
|
46 | - */ |
|
47 | - public function __construct( |
|
48 | - RequestInterface $request, |
|
49 | - RequestTypeContextFactoryInterface $factory, |
|
50 | - array $globalRouteConditions = array() |
|
51 | - ) { |
|
52 | - $this->request = $request; |
|
53 | - $this->factory = $factory; |
|
54 | - $this->globalRouteConditions = $globalRouteConditions; |
|
55 | - } |
|
56 | - |
|
57 | - |
|
58 | - /** |
|
59 | - * @return mixed |
|
60 | - */ |
|
61 | - private function getGlobalRouteCondition($globalRouteCondition, $default) |
|
62 | - { |
|
63 | - return isset($this->globalRouteConditions[ $globalRouteCondition ]) |
|
64 | - ? $this->globalRouteConditions[ $globalRouteCondition ] |
|
65 | - : $default; |
|
66 | - } |
|
67 | - |
|
68 | - |
|
69 | - /** |
|
70 | - * @return RequestTypeContext |
|
71 | - * @throws InvalidArgumentException |
|
72 | - */ |
|
73 | - public function detectRequestTypeContext() |
|
74 | - { |
|
75 | - // Detect error scrapes |
|
76 | - if ($this->request->getRequestParam('wp_scrape_key') !== null |
|
77 | - && $this->request->getRequestParam('wp_scrape_nonce') !== null |
|
78 | - ) { |
|
79 | - return $this->factory->create(RequestTypeContext::WP_SCRAPE); |
|
80 | - } |
|
81 | - // Detect EE REST API |
|
82 | - if ($this->isEspressoRestApiRequest()) { |
|
83 | - return $this->factory->create(RequestTypeContext::API); |
|
84 | - } |
|
85 | - // Detect WP REST API |
|
86 | - if ($this->isWordPressRestApiRequest()) { |
|
87 | - return $this->factory->create(RequestTypeContext::WP_API); |
|
88 | - } |
|
89 | - // Detect AJAX |
|
90 | - if ($this->getGlobalRouteCondition('DOING_AJAX', false)) { |
|
91 | - if (filter_var($this->request->getRequestParam('ee_front_ajax'), FILTER_VALIDATE_BOOLEAN)) { |
|
92 | - return $this->factory->create(RequestTypeContext::AJAX_FRONT); |
|
93 | - } |
|
94 | - if (filter_var($this->request->getRequestParam('ee_admin_ajax'), FILTER_VALIDATE_BOOLEAN)) { |
|
95 | - return $this->factory->create(RequestTypeContext::AJAX_ADMIN); |
|
96 | - } |
|
97 | - if ($this->request->getRequestParam('action') === 'heartbeat') { |
|
98 | - return $this->factory->create(RequestTypeContext::AJAX_HEARTBEAT); |
|
99 | - } |
|
100 | - return $this->factory->create(RequestTypeContext::AJAX_OTHER); |
|
101 | - } |
|
102 | - // Detect WP_Cron |
|
103 | - if ($this->isCronRequest()) { |
|
104 | - return $this->factory->create(RequestTypeContext::CRON); |
|
105 | - } |
|
106 | - // Detect command line requests |
|
107 | - if ($this->getGlobalRouteCondition('WP_CLI', false)) { |
|
108 | - return $this->factory->create(RequestTypeContext::CLI); |
|
109 | - } |
|
110 | - // detect WordPress admin (ie: "Dashboard") |
|
111 | - if ($this->getGlobalRouteCondition('is_admin', false)) { |
|
112 | - return $this->factory->create(RequestTypeContext::ADMIN); |
|
113 | - } |
|
114 | - // Detect iFrames |
|
115 | - if ($this->isIframeRoute()) { |
|
116 | - return $this->factory->create(RequestTypeContext::IFRAME); |
|
117 | - } |
|
118 | - // Detect Feeds |
|
119 | - if ($this->isFeedRequest()) { |
|
120 | - return $this->factory->create(RequestTypeContext::FEED); |
|
121 | - } |
|
122 | - // and by process of elimination... |
|
123 | - return $this->factory->create(RequestTypeContext::FRONTEND); |
|
124 | - } |
|
125 | - |
|
126 | - |
|
127 | - /** |
|
128 | - * @return bool |
|
129 | - */ |
|
130 | - private function isEspressoRestApiRequest() |
|
131 | - { |
|
132 | - // Check for URLs like http://mysite.com/?rest_route=/ee... and http://mysite.com/wp-json/ee/... |
|
133 | - return strpos( |
|
134 | - $this->request->getRequestParam('rest_route', false), |
|
135 | - '/' . Domain::API_NAMESPACE |
|
136 | - ) === 0 |
|
137 | - || $this->uriPathMatches(trim(rest_get_url_prefix(), '/') . '/' . Domain::API_NAMESPACE); |
|
138 | - } |
|
139 | - |
|
140 | - |
|
141 | - |
|
142 | - /** |
|
143 | - * @return bool |
|
144 | - */ |
|
145 | - private function isWordPressRestApiRequest() |
|
146 | - { |
|
147 | - // Check for URLs like http://mysite.com/?rest_route=/.. and http://mysite.com/wp-json/... |
|
148 | - return $this->request->getRequestParam('rest_route', false) |
|
149 | - || $this->uriPathMatches(trim(rest_get_url_prefix(), '/')); |
|
150 | - } |
|
151 | - |
|
152 | - |
|
153 | - /** |
|
154 | - * @return bool |
|
155 | - */ |
|
156 | - private function isCronRequest() |
|
157 | - { |
|
158 | - return $this->uriPathMatches('wp-cron.php'); |
|
159 | - } |
|
160 | - |
|
161 | - |
|
162 | - /** |
|
163 | - * @return bool |
|
164 | - */ |
|
165 | - private function isFeedRequest() |
|
166 | - { |
|
167 | - return $this->uriPathMatches('feed'); |
|
168 | - } |
|
169 | - |
|
170 | - |
|
171 | - /** |
|
172 | - * @param string $component |
|
173 | - * @return bool |
|
174 | - */ |
|
175 | - private function uriPathMatches($component) |
|
176 | - { |
|
177 | - $request_uri = $this->request->requestUriAfterSiteHomeUri(); |
|
178 | - $parts = explode('?', $request_uri); |
|
179 | - $path = trim(reset($parts), '/'); |
|
180 | - return strpos($path, $component) === 0; |
|
181 | - } |
|
182 | - |
|
183 | - |
|
184 | - /** |
|
185 | - * @return bool |
|
186 | - */ |
|
187 | - private function isIframeRoute() |
|
188 | - { |
|
189 | - $is_iframe_route = apply_filters( |
|
190 | - 'FHEE__EventEspresso_core_domain_services_contexts_RequestTypeContextDetector__isIframeRoute', |
|
191 | - $this->request->getRequestParam('event_list', '') === 'iframe' |
|
192 | - || $this->request->getRequestParam('ticket_selector', '') === 'iframe' |
|
193 | - || $this->request->getRequestParam('calendar', '') === 'iframe', |
|
194 | - $this |
|
195 | - ); |
|
196 | - return filter_var($is_iframe_route, FILTER_VALIDATE_BOOLEAN); |
|
197 | - } |
|
21 | + /** |
|
22 | + * @var RequestTypeContextFactoryInterface $factory |
|
23 | + */ |
|
24 | + private $factory; |
|
25 | + |
|
26 | + /** |
|
27 | + * @var RequestInterface $request |
|
28 | + */ |
|
29 | + private $request; |
|
30 | + |
|
31 | + /** |
|
32 | + * @var array $globalRouteConditions |
|
33 | + */ |
|
34 | + private $globalRouteConditions; |
|
35 | + |
|
36 | + |
|
37 | + /** |
|
38 | + * RequestTypeContextDetector constructor. |
|
39 | + * |
|
40 | + * @param RequestInterface $request |
|
41 | + * @param RequestTypeContextFactoryInterface $factory |
|
42 | + * @param array $globalRouteConditions an array for injecting values that would |
|
43 | + * otherwise be defined as global constants |
|
44 | + * or other global variables for the current |
|
45 | + * request route such as DOING_AJAX |
|
46 | + */ |
|
47 | + public function __construct( |
|
48 | + RequestInterface $request, |
|
49 | + RequestTypeContextFactoryInterface $factory, |
|
50 | + array $globalRouteConditions = array() |
|
51 | + ) { |
|
52 | + $this->request = $request; |
|
53 | + $this->factory = $factory; |
|
54 | + $this->globalRouteConditions = $globalRouteConditions; |
|
55 | + } |
|
56 | + |
|
57 | + |
|
58 | + /** |
|
59 | + * @return mixed |
|
60 | + */ |
|
61 | + private function getGlobalRouteCondition($globalRouteCondition, $default) |
|
62 | + { |
|
63 | + return isset($this->globalRouteConditions[ $globalRouteCondition ]) |
|
64 | + ? $this->globalRouteConditions[ $globalRouteCondition ] |
|
65 | + : $default; |
|
66 | + } |
|
67 | + |
|
68 | + |
|
69 | + /** |
|
70 | + * @return RequestTypeContext |
|
71 | + * @throws InvalidArgumentException |
|
72 | + */ |
|
73 | + public function detectRequestTypeContext() |
|
74 | + { |
|
75 | + // Detect error scrapes |
|
76 | + if ($this->request->getRequestParam('wp_scrape_key') !== null |
|
77 | + && $this->request->getRequestParam('wp_scrape_nonce') !== null |
|
78 | + ) { |
|
79 | + return $this->factory->create(RequestTypeContext::WP_SCRAPE); |
|
80 | + } |
|
81 | + // Detect EE REST API |
|
82 | + if ($this->isEspressoRestApiRequest()) { |
|
83 | + return $this->factory->create(RequestTypeContext::API); |
|
84 | + } |
|
85 | + // Detect WP REST API |
|
86 | + if ($this->isWordPressRestApiRequest()) { |
|
87 | + return $this->factory->create(RequestTypeContext::WP_API); |
|
88 | + } |
|
89 | + // Detect AJAX |
|
90 | + if ($this->getGlobalRouteCondition('DOING_AJAX', false)) { |
|
91 | + if (filter_var($this->request->getRequestParam('ee_front_ajax'), FILTER_VALIDATE_BOOLEAN)) { |
|
92 | + return $this->factory->create(RequestTypeContext::AJAX_FRONT); |
|
93 | + } |
|
94 | + if (filter_var($this->request->getRequestParam('ee_admin_ajax'), FILTER_VALIDATE_BOOLEAN)) { |
|
95 | + return $this->factory->create(RequestTypeContext::AJAX_ADMIN); |
|
96 | + } |
|
97 | + if ($this->request->getRequestParam('action') === 'heartbeat') { |
|
98 | + return $this->factory->create(RequestTypeContext::AJAX_HEARTBEAT); |
|
99 | + } |
|
100 | + return $this->factory->create(RequestTypeContext::AJAX_OTHER); |
|
101 | + } |
|
102 | + // Detect WP_Cron |
|
103 | + if ($this->isCronRequest()) { |
|
104 | + return $this->factory->create(RequestTypeContext::CRON); |
|
105 | + } |
|
106 | + // Detect command line requests |
|
107 | + if ($this->getGlobalRouteCondition('WP_CLI', false)) { |
|
108 | + return $this->factory->create(RequestTypeContext::CLI); |
|
109 | + } |
|
110 | + // detect WordPress admin (ie: "Dashboard") |
|
111 | + if ($this->getGlobalRouteCondition('is_admin', false)) { |
|
112 | + return $this->factory->create(RequestTypeContext::ADMIN); |
|
113 | + } |
|
114 | + // Detect iFrames |
|
115 | + if ($this->isIframeRoute()) { |
|
116 | + return $this->factory->create(RequestTypeContext::IFRAME); |
|
117 | + } |
|
118 | + // Detect Feeds |
|
119 | + if ($this->isFeedRequest()) { |
|
120 | + return $this->factory->create(RequestTypeContext::FEED); |
|
121 | + } |
|
122 | + // and by process of elimination... |
|
123 | + return $this->factory->create(RequestTypeContext::FRONTEND); |
|
124 | + } |
|
125 | + |
|
126 | + |
|
127 | + /** |
|
128 | + * @return bool |
|
129 | + */ |
|
130 | + private function isEspressoRestApiRequest() |
|
131 | + { |
|
132 | + // Check for URLs like http://mysite.com/?rest_route=/ee... and http://mysite.com/wp-json/ee/... |
|
133 | + return strpos( |
|
134 | + $this->request->getRequestParam('rest_route', false), |
|
135 | + '/' . Domain::API_NAMESPACE |
|
136 | + ) === 0 |
|
137 | + || $this->uriPathMatches(trim(rest_get_url_prefix(), '/') . '/' . Domain::API_NAMESPACE); |
|
138 | + } |
|
139 | + |
|
140 | + |
|
141 | + |
|
142 | + /** |
|
143 | + * @return bool |
|
144 | + */ |
|
145 | + private function isWordPressRestApiRequest() |
|
146 | + { |
|
147 | + // Check for URLs like http://mysite.com/?rest_route=/.. and http://mysite.com/wp-json/... |
|
148 | + return $this->request->getRequestParam('rest_route', false) |
|
149 | + || $this->uriPathMatches(trim(rest_get_url_prefix(), '/')); |
|
150 | + } |
|
151 | + |
|
152 | + |
|
153 | + /** |
|
154 | + * @return bool |
|
155 | + */ |
|
156 | + private function isCronRequest() |
|
157 | + { |
|
158 | + return $this->uriPathMatches('wp-cron.php'); |
|
159 | + } |
|
160 | + |
|
161 | + |
|
162 | + /** |
|
163 | + * @return bool |
|
164 | + */ |
|
165 | + private function isFeedRequest() |
|
166 | + { |
|
167 | + return $this->uriPathMatches('feed'); |
|
168 | + } |
|
169 | + |
|
170 | + |
|
171 | + /** |
|
172 | + * @param string $component |
|
173 | + * @return bool |
|
174 | + */ |
|
175 | + private function uriPathMatches($component) |
|
176 | + { |
|
177 | + $request_uri = $this->request->requestUriAfterSiteHomeUri(); |
|
178 | + $parts = explode('?', $request_uri); |
|
179 | + $path = trim(reset($parts), '/'); |
|
180 | + return strpos($path, $component) === 0; |
|
181 | + } |
|
182 | + |
|
183 | + |
|
184 | + /** |
|
185 | + * @return bool |
|
186 | + */ |
|
187 | + private function isIframeRoute() |
|
188 | + { |
|
189 | + $is_iframe_route = apply_filters( |
|
190 | + 'FHEE__EventEspresso_core_domain_services_contexts_RequestTypeContextDetector__isIframeRoute', |
|
191 | + $this->request->getRequestParam('event_list', '') === 'iframe' |
|
192 | + || $this->request->getRequestParam('ticket_selector', '') === 'iframe' |
|
193 | + || $this->request->getRequestParam('calendar', '') === 'iframe', |
|
194 | + $this |
|
195 | + ); |
|
196 | + return filter_var($is_iframe_route, FILTER_VALIDATE_BOOLEAN); |
|
197 | + } |
|
198 | 198 | } |
@@ -17,660 +17,660 @@ |
||
17 | 17 | class Request implements InterminableInterface, RequestInterface, ReservedInstanceInterface |
18 | 18 | { |
19 | 19 | |
20 | - /** |
|
21 | - * $_GET parameters |
|
22 | - * |
|
23 | - * @var array $get |
|
24 | - */ |
|
25 | - private $get; |
|
26 | - |
|
27 | - /** |
|
28 | - * $_POST parameters |
|
29 | - * |
|
30 | - * @var array $post |
|
31 | - */ |
|
32 | - private $post; |
|
33 | - |
|
34 | - /** |
|
35 | - * $_COOKIE parameters |
|
36 | - * |
|
37 | - * @var array $cookie |
|
38 | - */ |
|
39 | - private $cookie; |
|
40 | - |
|
41 | - /** |
|
42 | - * $_SERVER parameters |
|
43 | - * |
|
44 | - * @var array $server |
|
45 | - */ |
|
46 | - private $server; |
|
47 | - |
|
48 | - /** |
|
49 | - * $_FILES parameters |
|
50 | - * |
|
51 | - * @var array $files |
|
52 | - */ |
|
53 | - private $files; |
|
54 | - |
|
55 | - /** |
|
56 | - * $_REQUEST parameters |
|
57 | - * |
|
58 | - * @var array $request |
|
59 | - */ |
|
60 | - private $request; |
|
61 | - |
|
62 | - /** |
|
63 | - * @var RequestTypeContextCheckerInterface |
|
64 | - */ |
|
65 | - private $request_type; |
|
66 | - |
|
67 | - /** |
|
68 | - * IP address for request |
|
69 | - * |
|
70 | - * @var string $ip_address |
|
71 | - */ |
|
72 | - private $ip_address; |
|
73 | - |
|
74 | - /** |
|
75 | - * @var string $user_agent |
|
76 | - */ |
|
77 | - private $user_agent; |
|
78 | - |
|
79 | - /** |
|
80 | - * true if current user appears to be some kind of bot |
|
81 | - * |
|
82 | - * @var bool $is_bot |
|
83 | - */ |
|
84 | - private $is_bot; |
|
85 | - |
|
86 | - |
|
87 | - /** |
|
88 | - * @param array $get |
|
89 | - * @param array $post |
|
90 | - * @param array $cookie |
|
91 | - * @param array $server |
|
92 | - * @param array $files |
|
93 | - */ |
|
94 | - public function __construct(array $get, array $post, array $cookie, array $server, array $files = array()) |
|
95 | - { |
|
96 | - // grab request vars |
|
97 | - $this->get = $get; |
|
98 | - $this->post = $post; |
|
99 | - $this->cookie = $cookie; |
|
100 | - $this->server = $server; |
|
101 | - $this->files = $files; |
|
102 | - $this->request = array_merge($this->get, $this->post); |
|
103 | - $this->ip_address = $this->visitorIp(); |
|
104 | - } |
|
105 | - |
|
106 | - |
|
107 | - /** |
|
108 | - * @param RequestTypeContextCheckerInterface $type |
|
109 | - */ |
|
110 | - public function setRequestTypeContextChecker(RequestTypeContextCheckerInterface $type) |
|
111 | - { |
|
112 | - $this->request_type = $type; |
|
113 | - } |
|
114 | - |
|
115 | - |
|
116 | - /** |
|
117 | - * @return array |
|
118 | - */ |
|
119 | - public function getParams() |
|
120 | - { |
|
121 | - return $this->get; |
|
122 | - } |
|
123 | - |
|
124 | - |
|
125 | - /** |
|
126 | - * @return array |
|
127 | - */ |
|
128 | - public function postParams() |
|
129 | - { |
|
130 | - return $this->post; |
|
131 | - } |
|
132 | - |
|
133 | - |
|
134 | - /** |
|
135 | - * @return array |
|
136 | - */ |
|
137 | - public function cookieParams() |
|
138 | - { |
|
139 | - return $this->cookie; |
|
140 | - } |
|
141 | - |
|
142 | - |
|
143 | - /** |
|
144 | - * @return array |
|
145 | - */ |
|
146 | - public function serverParams() |
|
147 | - { |
|
148 | - return $this->server; |
|
149 | - } |
|
150 | - |
|
151 | - |
|
152 | - /** |
|
153 | - * @return array |
|
154 | - */ |
|
155 | - public function filesParams() |
|
156 | - { |
|
157 | - return $this->files; |
|
158 | - } |
|
159 | - |
|
160 | - |
|
161 | - /** |
|
162 | - * returns contents of $_REQUEST |
|
163 | - * |
|
164 | - * @return array |
|
165 | - */ |
|
166 | - public function requestParams() |
|
167 | - { |
|
168 | - return $this->request; |
|
169 | - } |
|
170 | - |
|
171 | - |
|
172 | - /** |
|
173 | - * @param $key |
|
174 | - * @param $value |
|
175 | - * @param bool $override_ee |
|
176 | - * @return void |
|
177 | - */ |
|
178 | - public function setRequestParam($key, $value, $override_ee = false) |
|
179 | - { |
|
180 | - // don't allow "ee" to be overwritten unless explicitly instructed to do so |
|
181 | - if ($key !== 'ee' |
|
182 | - || ($key === 'ee' && empty($this->request['ee'])) |
|
183 | - || ($key === 'ee' && ! empty($this->request['ee']) && $override_ee) |
|
184 | - ) { |
|
185 | - $this->request[ $key ] = $value; |
|
186 | - } |
|
187 | - } |
|
188 | - |
|
189 | - |
|
190 | - /** |
|
191 | - * returns the value for a request param if the given key exists |
|
192 | - * |
|
193 | - * @param $key |
|
194 | - * @param null $default |
|
195 | - * @return mixed |
|
196 | - */ |
|
197 | - public function getRequestParam($key, $default = null) |
|
198 | - { |
|
199 | - return $this->requestParameterDrillDown($key, $default, 'get'); |
|
200 | - } |
|
201 | - |
|
202 | - |
|
203 | - /** |
|
204 | - * check if param exists |
|
205 | - * |
|
206 | - * @param $key |
|
207 | - * @return bool |
|
208 | - */ |
|
209 | - public function requestParamIsSet($key) |
|
210 | - { |
|
211 | - return $this->requestParameterDrillDown($key); |
|
212 | - } |
|
213 | - |
|
214 | - |
|
215 | - /** |
|
216 | - * check if a request parameter exists whose key that matches the supplied wildcard pattern |
|
217 | - * and return the value for the first match found |
|
218 | - * wildcards can be either of the following: |
|
219 | - * ? to represent a single character of any type |
|
220 | - * * to represent one or more characters of any type |
|
221 | - * |
|
222 | - * @param string $pattern |
|
223 | - * @param null|mixed $default |
|
224 | - * @return mixed |
|
225 | - */ |
|
226 | - public function getMatch($pattern, $default = null) |
|
227 | - { |
|
228 | - return $this->requestParameterDrillDown($pattern, $default, 'match'); |
|
229 | - } |
|
230 | - |
|
231 | - |
|
232 | - /** |
|
233 | - * check if a request parameter exists whose key matches the supplied wildcard pattern |
|
234 | - * wildcards can be either of the following: |
|
235 | - * ? to represent a single character of any type |
|
236 | - * * to represent one or more characters of any type |
|
237 | - * returns true if a match is found or false if not |
|
238 | - * |
|
239 | - * @param string $pattern |
|
240 | - * @return bool |
|
241 | - */ |
|
242 | - public function matches($pattern) |
|
243 | - { |
|
244 | - return $this->requestParameterDrillDown($pattern, null, 'match') !== null; |
|
245 | - } |
|
246 | - |
|
247 | - |
|
248 | - /** |
|
249 | - * @see https://stackoverflow.com/questions/6163055/php-string-matching-with-wildcard |
|
250 | - * @param string $pattern A string including wildcards to be converted to a regex pattern |
|
251 | - * and used to search through the current request's parameter keys |
|
252 | - * @param array $request_params The array of request parameters to search through |
|
253 | - * @param mixed $default [optional] The value to be returned if no match is found. |
|
254 | - * Default is null |
|
255 | - * @param string $return [optional] Controls what kind of value is returned. |
|
256 | - * Options are: |
|
257 | - * 'bool' will return true or false if match is found or not |
|
258 | - * 'key' will return the first key found that matches the supplied pattern |
|
259 | - * 'value' will return the value for the first request parameter |
|
260 | - * whose key matches the supplied pattern |
|
261 | - * Default is 'value' |
|
262 | - * @return boolean|string |
|
263 | - */ |
|
264 | - private function match($pattern, array $request_params, $default = null, $return = 'value') |
|
265 | - { |
|
266 | - $return = in_array($return, array('bool', 'key', 'value'), true) |
|
267 | - ? $return |
|
268 | - : 'is_set'; |
|
269 | - // replace wildcard chars with regex chars |
|
270 | - $pattern = str_replace( |
|
271 | - array("\*", "\?"), |
|
272 | - array('.*', '.'), |
|
273 | - preg_quote($pattern, '/') |
|
274 | - ); |
|
275 | - foreach ($request_params as $key => $request_param) { |
|
276 | - if (preg_match('/^' . $pattern . '$/is', $key)) { |
|
277 | - // return value for request param |
|
278 | - if ($return === 'value') { |
|
279 | - return $request_params[ $key ]; |
|
280 | - } |
|
281 | - // or actual key or true just to indicate it was found |
|
282 | - return $return === 'key' ? $key : true; |
|
283 | - } |
|
284 | - } |
|
285 | - // match not found so return default value or false |
|
286 | - return $return === 'value' ? $default : false; |
|
287 | - } |
|
288 | - |
|
289 | - |
|
290 | - /** |
|
291 | - * the supplied key can be a simple string to represent a "top-level" request parameter |
|
292 | - * or represent a key for a request parameter that is nested deeper within the request parameter array, |
|
293 | - * by using square brackets to surround keys for deeper array elements. |
|
294 | - * For example : |
|
295 | - * if the supplied $key was: "first[second][third]" |
|
296 | - * then this will attempt to drill down into the request parameter array to find a value. |
|
297 | - * Given the following request parameters: |
|
298 | - * array( |
|
299 | - * 'first' => array( |
|
300 | - * 'second' => array( |
|
301 | - * 'third' => 'has a value' |
|
302 | - * ) |
|
303 | - * ) |
|
304 | - * ) |
|
305 | - * would return true if default parameters were set |
|
306 | - * |
|
307 | - * @param string $callback |
|
308 | - * @param $key |
|
309 | - * @param null $default |
|
310 | - * @param array $request_params |
|
311 | - * @return bool|mixed|null |
|
312 | - */ |
|
313 | - private function requestParameterDrillDown( |
|
314 | - $key, |
|
315 | - $default = null, |
|
316 | - $callback = 'is_set', |
|
317 | - array $request_params = array() |
|
318 | - ) { |
|
319 | - $callback = in_array($callback, array('is_set', 'get', 'match'), true) |
|
320 | - ? $callback |
|
321 | - : 'is_set'; |
|
322 | - $request_params = ! empty($request_params) |
|
323 | - ? $request_params |
|
324 | - : $this->request; |
|
325 | - // does incoming key represent an array like 'first[second][third]' ? |
|
326 | - if (strpos($key, '[') !== false) { |
|
327 | - // turn it into an actual array |
|
328 | - $key = str_replace(']', '', $key); |
|
329 | - $keys = explode('[', $key); |
|
330 | - $key = array_shift($keys); |
|
331 | - if ($callback === 'match') { |
|
332 | - $real_key = $this->match($key, $request_params, $default, 'key'); |
|
333 | - $key = $real_key ? $real_key : $key; |
|
334 | - } |
|
335 | - // check if top level key exists |
|
336 | - if (isset($request_params[ $key ])) { |
|
337 | - // build a new key to pass along like: 'second[third]' |
|
338 | - // or just 'second' depending on depth of keys |
|
339 | - $key_string = array_shift($keys); |
|
340 | - if (! empty($keys)) { |
|
341 | - $key_string .= '[' . implode('][', $keys) . ']'; |
|
342 | - } |
|
343 | - return $this->requestParameterDrillDown( |
|
344 | - $key_string, |
|
345 | - $default, |
|
346 | - $callback, |
|
347 | - $request_params[ $key ] |
|
348 | - ); |
|
349 | - } |
|
350 | - } |
|
351 | - if ($callback === 'is_set') { |
|
352 | - return isset($request_params[ $key ]); |
|
353 | - } |
|
354 | - if ($callback === 'match') { |
|
355 | - return $this->match($key, $request_params, $default); |
|
356 | - } |
|
357 | - return isset($request_params[ $key ]) |
|
358 | - ? $request_params[ $key ] |
|
359 | - : $default; |
|
360 | - } |
|
361 | - |
|
362 | - |
|
363 | - /** |
|
364 | - * remove param |
|
365 | - * |
|
366 | - * @param $key |
|
367 | - * @param bool $unset_from_global_too |
|
368 | - */ |
|
369 | - public function unSetRequestParam($key, $unset_from_global_too = false) |
|
370 | - { |
|
371 | - unset($this->request[ $key ]); |
|
372 | - if ($unset_from_global_too) { |
|
373 | - unset($_REQUEST[ $key ]); |
|
374 | - } |
|
375 | - } |
|
376 | - |
|
377 | - |
|
378 | - /** |
|
379 | - * @return string |
|
380 | - */ |
|
381 | - public function ipAddress() |
|
382 | - { |
|
383 | - return $this->ip_address; |
|
384 | - } |
|
385 | - |
|
386 | - |
|
387 | - /** |
|
388 | - * attempt to get IP address of current visitor from server |
|
389 | - * plz see: http://stackoverflow.com/a/2031935/1475279 |
|
390 | - * |
|
391 | - * @access public |
|
392 | - * @return string |
|
393 | - */ |
|
394 | - private function visitorIp() |
|
395 | - { |
|
396 | - $visitor_ip = '0.0.0.0'; |
|
397 | - $server_keys = array( |
|
398 | - 'HTTP_CLIENT_IP', |
|
399 | - 'HTTP_X_FORWARDED_FOR', |
|
400 | - 'HTTP_X_FORWARDED', |
|
401 | - 'HTTP_X_CLUSTER_CLIENT_IP', |
|
402 | - 'HTTP_FORWARDED_FOR', |
|
403 | - 'HTTP_FORWARDED', |
|
404 | - 'REMOTE_ADDR', |
|
405 | - ); |
|
406 | - foreach ($server_keys as $key) { |
|
407 | - if (isset($this->server[ $key ])) { |
|
408 | - foreach (array_map('trim', explode(',', $this->server[ $key ])) as $ip) { |
|
409 | - if ($ip === '127.0.0.1' || filter_var($ip, FILTER_VALIDATE_IP) !== false) { |
|
410 | - $visitor_ip = $ip; |
|
411 | - } |
|
412 | - } |
|
413 | - } |
|
414 | - } |
|
415 | - return $visitor_ip; |
|
416 | - } |
|
417 | - |
|
418 | - |
|
419 | - /** |
|
420 | - * Gets the request's literal URI. Related to `requestUriAfterSiteHomeUri`, see its description for a comparison. |
|
421 | - * @return string |
|
422 | - */ |
|
423 | - public function requestUri() |
|
424 | - { |
|
425 | - $request_uri = filter_input( |
|
426 | - INPUT_SERVER, |
|
427 | - 'REQUEST_URI', |
|
428 | - FILTER_SANITIZE_URL, |
|
429 | - FILTER_NULL_ON_FAILURE |
|
430 | - ); |
|
431 | - if (empty($request_uri)) { |
|
432 | - // fallback sanitization if the above fails |
|
433 | - $request_uri = wp_sanitize_redirect($this->server['REQUEST_URI']); |
|
434 | - } |
|
435 | - return $request_uri; |
|
436 | - } |
|
437 | - |
|
438 | - |
|
439 | - /** |
|
440 | - * Returns the REQUEST_URI after the current blog's home URI. |
|
441 | - * Eg, if this is a multisite, subdirectory install, the main blog lives at "http://mysite.com", and the current |
|
442 | - * blog lives at "http://mysite.com/other/", and a request comes to "http://mysite.com/other/path-relative-to-site", |
|
443 | - * this will return "/path-relative-to-site" whereas `requestUri` will return "/other/path-relative-to-site". |
|
444 | - * @since $VID:$ |
|
445 | - * @return mixed|string |
|
446 | - */ |
|
447 | - public function requestUriAfterSiteHomeUri() |
|
448 | - { |
|
449 | - $request_uri = filter_input( |
|
450 | - INPUT_SERVER, |
|
451 | - 'REQUEST_URI', |
|
452 | - FILTER_SANITIZE_URL, |
|
453 | - FILTER_NULL_ON_FAILURE |
|
454 | - ); |
|
455 | - // If it's a subdomain multisite install, we're actually only interested in |
|
456 | - if(is_multisite()){ |
|
457 | - $blog_details = get_blog_details(get_current_blog_id()); |
|
458 | - $request_uri = str_replace( |
|
459 | - untrailingslashit($blog_details->path), |
|
460 | - '', |
|
461 | - $request_uri |
|
462 | - ); |
|
463 | - } |
|
464 | - |
|
465 | - if (empty($request_uri)) { |
|
466 | - // fallback sanitization if the above fails |
|
467 | - $request_uri = $this->requestUri(); |
|
468 | - } |
|
469 | - return $request_uri; |
|
470 | - |
|
471 | - } |
|
472 | - |
|
473 | - |
|
474 | - /** |
|
475 | - * @return string |
|
476 | - */ |
|
477 | - public function userAgent() |
|
478 | - { |
|
479 | - return $this->user_agent; |
|
480 | - } |
|
481 | - |
|
482 | - |
|
483 | - /** |
|
484 | - * @param string $user_agent |
|
485 | - */ |
|
486 | - public function setUserAgent($user_agent = '') |
|
487 | - { |
|
488 | - if ($user_agent === '' || ! is_string($user_agent)) { |
|
489 | - $user_agent = isset($_SERVER['HTTP_USER_AGENT']) ? (string) esc_attr($_SERVER['HTTP_USER_AGENT']) : ''; |
|
490 | - } |
|
491 | - $this->user_agent = $user_agent; |
|
492 | - } |
|
493 | - |
|
494 | - |
|
495 | - /** |
|
496 | - * @return bool |
|
497 | - */ |
|
498 | - public function isBot() |
|
499 | - { |
|
500 | - return $this->is_bot; |
|
501 | - } |
|
502 | - |
|
503 | - |
|
504 | - /** |
|
505 | - * @param bool $is_bot |
|
506 | - */ |
|
507 | - public function setIsBot($is_bot) |
|
508 | - { |
|
509 | - $this->is_bot = filter_var($is_bot, FILTER_VALIDATE_BOOLEAN); |
|
510 | - } |
|
511 | - |
|
512 | - |
|
513 | - /** |
|
514 | - * @return bool |
|
515 | - */ |
|
516 | - public function isActivation() |
|
517 | - { |
|
518 | - return $this->request_type->isActivation(); |
|
519 | - } |
|
520 | - |
|
521 | - |
|
522 | - /** |
|
523 | - * @param $is_activation |
|
524 | - * @return bool |
|
525 | - */ |
|
526 | - public function setIsActivation($is_activation) |
|
527 | - { |
|
528 | - return $this->request_type->setIsActivation($is_activation); |
|
529 | - } |
|
530 | - |
|
531 | - |
|
532 | - /** |
|
533 | - * @return bool |
|
534 | - */ |
|
535 | - public function isAdmin() |
|
536 | - { |
|
537 | - return $this->request_type->isAdmin(); |
|
538 | - } |
|
539 | - |
|
540 | - |
|
541 | - /** |
|
542 | - * @return bool |
|
543 | - */ |
|
544 | - public function isAdminAjax() |
|
545 | - { |
|
546 | - return $this->request_type->isAdminAjax(); |
|
547 | - } |
|
548 | - |
|
549 | - |
|
550 | - /** |
|
551 | - * @return bool |
|
552 | - */ |
|
553 | - public function isAjax() |
|
554 | - { |
|
555 | - return $this->request_type->isAjax(); |
|
556 | - } |
|
557 | - |
|
558 | - |
|
559 | - /** |
|
560 | - * @return bool |
|
561 | - */ |
|
562 | - public function isEeAjax() |
|
563 | - { |
|
564 | - return $this->request_type->isEeAjax(); |
|
565 | - } |
|
566 | - |
|
567 | - |
|
568 | - /** |
|
569 | - * @return bool |
|
570 | - */ |
|
571 | - public function isOtherAjax() |
|
572 | - { |
|
573 | - return $this->request_type->isOtherAjax(); |
|
574 | - } |
|
575 | - |
|
576 | - |
|
577 | - /** |
|
578 | - * @return bool |
|
579 | - */ |
|
580 | - public function isApi() |
|
581 | - { |
|
582 | - return $this->request_type->isApi(); |
|
583 | - } |
|
584 | - |
|
585 | - |
|
586 | - /** |
|
587 | - * @return bool |
|
588 | - */ |
|
589 | - public function isCli() |
|
590 | - { |
|
591 | - return $this->request_type->isCli(); |
|
592 | - } |
|
593 | - |
|
594 | - |
|
595 | - /** |
|
596 | - * @return bool |
|
597 | - */ |
|
598 | - public function isCron() |
|
599 | - { |
|
600 | - return $this->request_type->isCron(); |
|
601 | - } |
|
602 | - |
|
603 | - |
|
604 | - /** |
|
605 | - * @return bool |
|
606 | - */ |
|
607 | - public function isFeed() |
|
608 | - { |
|
609 | - return $this->request_type->isFeed(); |
|
610 | - } |
|
611 | - |
|
612 | - |
|
613 | - /** |
|
614 | - * @return bool |
|
615 | - */ |
|
616 | - public function isFrontend() |
|
617 | - { |
|
618 | - return $this->request_type->isFrontend(); |
|
619 | - } |
|
620 | - |
|
621 | - |
|
622 | - /** |
|
623 | - * @return bool |
|
624 | - */ |
|
625 | - public function isFrontAjax() |
|
626 | - { |
|
627 | - return $this->request_type->isFrontAjax(); |
|
628 | - } |
|
629 | - |
|
630 | - |
|
631 | - /** |
|
632 | - * @return bool |
|
633 | - */ |
|
634 | - public function isIframe() |
|
635 | - { |
|
636 | - return $this->request_type->isIframe(); |
|
637 | - } |
|
638 | - |
|
639 | - |
|
640 | - /** |
|
641 | - * @return bool |
|
642 | - */ |
|
643 | - public function isWordPressApi() |
|
644 | - { |
|
645 | - return $this->request_type->isWordPressApi(); |
|
646 | - } |
|
647 | - |
|
648 | - |
|
649 | - |
|
650 | - /** |
|
651 | - * @return bool |
|
652 | - */ |
|
653 | - public function isWordPressHeartbeat() |
|
654 | - { |
|
655 | - return $this->request_type->isWordPressHeartbeat(); |
|
656 | - } |
|
657 | - |
|
658 | - |
|
659 | - |
|
660 | - /** |
|
661 | - * @return bool |
|
662 | - */ |
|
663 | - public function isWordPressScrape() |
|
664 | - { |
|
665 | - return $this->request_type->isWordPressScrape(); |
|
666 | - } |
|
667 | - |
|
668 | - |
|
669 | - /** |
|
670 | - * @return string |
|
671 | - */ |
|
672 | - public function slug() |
|
673 | - { |
|
674 | - return $this->request_type->slug(); |
|
675 | - } |
|
20 | + /** |
|
21 | + * $_GET parameters |
|
22 | + * |
|
23 | + * @var array $get |
|
24 | + */ |
|
25 | + private $get; |
|
26 | + |
|
27 | + /** |
|
28 | + * $_POST parameters |
|
29 | + * |
|
30 | + * @var array $post |
|
31 | + */ |
|
32 | + private $post; |
|
33 | + |
|
34 | + /** |
|
35 | + * $_COOKIE parameters |
|
36 | + * |
|
37 | + * @var array $cookie |
|
38 | + */ |
|
39 | + private $cookie; |
|
40 | + |
|
41 | + /** |
|
42 | + * $_SERVER parameters |
|
43 | + * |
|
44 | + * @var array $server |
|
45 | + */ |
|
46 | + private $server; |
|
47 | + |
|
48 | + /** |
|
49 | + * $_FILES parameters |
|
50 | + * |
|
51 | + * @var array $files |
|
52 | + */ |
|
53 | + private $files; |
|
54 | + |
|
55 | + /** |
|
56 | + * $_REQUEST parameters |
|
57 | + * |
|
58 | + * @var array $request |
|
59 | + */ |
|
60 | + private $request; |
|
61 | + |
|
62 | + /** |
|
63 | + * @var RequestTypeContextCheckerInterface |
|
64 | + */ |
|
65 | + private $request_type; |
|
66 | + |
|
67 | + /** |
|
68 | + * IP address for request |
|
69 | + * |
|
70 | + * @var string $ip_address |
|
71 | + */ |
|
72 | + private $ip_address; |
|
73 | + |
|
74 | + /** |
|
75 | + * @var string $user_agent |
|
76 | + */ |
|
77 | + private $user_agent; |
|
78 | + |
|
79 | + /** |
|
80 | + * true if current user appears to be some kind of bot |
|
81 | + * |
|
82 | + * @var bool $is_bot |
|
83 | + */ |
|
84 | + private $is_bot; |
|
85 | + |
|
86 | + |
|
87 | + /** |
|
88 | + * @param array $get |
|
89 | + * @param array $post |
|
90 | + * @param array $cookie |
|
91 | + * @param array $server |
|
92 | + * @param array $files |
|
93 | + */ |
|
94 | + public function __construct(array $get, array $post, array $cookie, array $server, array $files = array()) |
|
95 | + { |
|
96 | + // grab request vars |
|
97 | + $this->get = $get; |
|
98 | + $this->post = $post; |
|
99 | + $this->cookie = $cookie; |
|
100 | + $this->server = $server; |
|
101 | + $this->files = $files; |
|
102 | + $this->request = array_merge($this->get, $this->post); |
|
103 | + $this->ip_address = $this->visitorIp(); |
|
104 | + } |
|
105 | + |
|
106 | + |
|
107 | + /** |
|
108 | + * @param RequestTypeContextCheckerInterface $type |
|
109 | + */ |
|
110 | + public function setRequestTypeContextChecker(RequestTypeContextCheckerInterface $type) |
|
111 | + { |
|
112 | + $this->request_type = $type; |
|
113 | + } |
|
114 | + |
|
115 | + |
|
116 | + /** |
|
117 | + * @return array |
|
118 | + */ |
|
119 | + public function getParams() |
|
120 | + { |
|
121 | + return $this->get; |
|
122 | + } |
|
123 | + |
|
124 | + |
|
125 | + /** |
|
126 | + * @return array |
|
127 | + */ |
|
128 | + public function postParams() |
|
129 | + { |
|
130 | + return $this->post; |
|
131 | + } |
|
132 | + |
|
133 | + |
|
134 | + /** |
|
135 | + * @return array |
|
136 | + */ |
|
137 | + public function cookieParams() |
|
138 | + { |
|
139 | + return $this->cookie; |
|
140 | + } |
|
141 | + |
|
142 | + |
|
143 | + /** |
|
144 | + * @return array |
|
145 | + */ |
|
146 | + public function serverParams() |
|
147 | + { |
|
148 | + return $this->server; |
|
149 | + } |
|
150 | + |
|
151 | + |
|
152 | + /** |
|
153 | + * @return array |
|
154 | + */ |
|
155 | + public function filesParams() |
|
156 | + { |
|
157 | + return $this->files; |
|
158 | + } |
|
159 | + |
|
160 | + |
|
161 | + /** |
|
162 | + * returns contents of $_REQUEST |
|
163 | + * |
|
164 | + * @return array |
|
165 | + */ |
|
166 | + public function requestParams() |
|
167 | + { |
|
168 | + return $this->request; |
|
169 | + } |
|
170 | + |
|
171 | + |
|
172 | + /** |
|
173 | + * @param $key |
|
174 | + * @param $value |
|
175 | + * @param bool $override_ee |
|
176 | + * @return void |
|
177 | + */ |
|
178 | + public function setRequestParam($key, $value, $override_ee = false) |
|
179 | + { |
|
180 | + // don't allow "ee" to be overwritten unless explicitly instructed to do so |
|
181 | + if ($key !== 'ee' |
|
182 | + || ($key === 'ee' && empty($this->request['ee'])) |
|
183 | + || ($key === 'ee' && ! empty($this->request['ee']) && $override_ee) |
|
184 | + ) { |
|
185 | + $this->request[ $key ] = $value; |
|
186 | + } |
|
187 | + } |
|
188 | + |
|
189 | + |
|
190 | + /** |
|
191 | + * returns the value for a request param if the given key exists |
|
192 | + * |
|
193 | + * @param $key |
|
194 | + * @param null $default |
|
195 | + * @return mixed |
|
196 | + */ |
|
197 | + public function getRequestParam($key, $default = null) |
|
198 | + { |
|
199 | + return $this->requestParameterDrillDown($key, $default, 'get'); |
|
200 | + } |
|
201 | + |
|
202 | + |
|
203 | + /** |
|
204 | + * check if param exists |
|
205 | + * |
|
206 | + * @param $key |
|
207 | + * @return bool |
|
208 | + */ |
|
209 | + public function requestParamIsSet($key) |
|
210 | + { |
|
211 | + return $this->requestParameterDrillDown($key); |
|
212 | + } |
|
213 | + |
|
214 | + |
|
215 | + /** |
|
216 | + * check if a request parameter exists whose key that matches the supplied wildcard pattern |
|
217 | + * and return the value for the first match found |
|
218 | + * wildcards can be either of the following: |
|
219 | + * ? to represent a single character of any type |
|
220 | + * * to represent one or more characters of any type |
|
221 | + * |
|
222 | + * @param string $pattern |
|
223 | + * @param null|mixed $default |
|
224 | + * @return mixed |
|
225 | + */ |
|
226 | + public function getMatch($pattern, $default = null) |
|
227 | + { |
|
228 | + return $this->requestParameterDrillDown($pattern, $default, 'match'); |
|
229 | + } |
|
230 | + |
|
231 | + |
|
232 | + /** |
|
233 | + * check if a request parameter exists whose key matches the supplied wildcard pattern |
|
234 | + * wildcards can be either of the following: |
|
235 | + * ? to represent a single character of any type |
|
236 | + * * to represent one or more characters of any type |
|
237 | + * returns true if a match is found or false if not |
|
238 | + * |
|
239 | + * @param string $pattern |
|
240 | + * @return bool |
|
241 | + */ |
|
242 | + public function matches($pattern) |
|
243 | + { |
|
244 | + return $this->requestParameterDrillDown($pattern, null, 'match') !== null; |
|
245 | + } |
|
246 | + |
|
247 | + |
|
248 | + /** |
|
249 | + * @see https://stackoverflow.com/questions/6163055/php-string-matching-with-wildcard |
|
250 | + * @param string $pattern A string including wildcards to be converted to a regex pattern |
|
251 | + * and used to search through the current request's parameter keys |
|
252 | + * @param array $request_params The array of request parameters to search through |
|
253 | + * @param mixed $default [optional] The value to be returned if no match is found. |
|
254 | + * Default is null |
|
255 | + * @param string $return [optional] Controls what kind of value is returned. |
|
256 | + * Options are: |
|
257 | + * 'bool' will return true or false if match is found or not |
|
258 | + * 'key' will return the first key found that matches the supplied pattern |
|
259 | + * 'value' will return the value for the first request parameter |
|
260 | + * whose key matches the supplied pattern |
|
261 | + * Default is 'value' |
|
262 | + * @return boolean|string |
|
263 | + */ |
|
264 | + private function match($pattern, array $request_params, $default = null, $return = 'value') |
|
265 | + { |
|
266 | + $return = in_array($return, array('bool', 'key', 'value'), true) |
|
267 | + ? $return |
|
268 | + : 'is_set'; |
|
269 | + // replace wildcard chars with regex chars |
|
270 | + $pattern = str_replace( |
|
271 | + array("\*", "\?"), |
|
272 | + array('.*', '.'), |
|
273 | + preg_quote($pattern, '/') |
|
274 | + ); |
|
275 | + foreach ($request_params as $key => $request_param) { |
|
276 | + if (preg_match('/^' . $pattern . '$/is', $key)) { |
|
277 | + // return value for request param |
|
278 | + if ($return === 'value') { |
|
279 | + return $request_params[ $key ]; |
|
280 | + } |
|
281 | + // or actual key or true just to indicate it was found |
|
282 | + return $return === 'key' ? $key : true; |
|
283 | + } |
|
284 | + } |
|
285 | + // match not found so return default value or false |
|
286 | + return $return === 'value' ? $default : false; |
|
287 | + } |
|
288 | + |
|
289 | + |
|
290 | + /** |
|
291 | + * the supplied key can be a simple string to represent a "top-level" request parameter |
|
292 | + * or represent a key for a request parameter that is nested deeper within the request parameter array, |
|
293 | + * by using square brackets to surround keys for deeper array elements. |
|
294 | + * For example : |
|
295 | + * if the supplied $key was: "first[second][third]" |
|
296 | + * then this will attempt to drill down into the request parameter array to find a value. |
|
297 | + * Given the following request parameters: |
|
298 | + * array( |
|
299 | + * 'first' => array( |
|
300 | + * 'second' => array( |
|
301 | + * 'third' => 'has a value' |
|
302 | + * ) |
|
303 | + * ) |
|
304 | + * ) |
|
305 | + * would return true if default parameters were set |
|
306 | + * |
|
307 | + * @param string $callback |
|
308 | + * @param $key |
|
309 | + * @param null $default |
|
310 | + * @param array $request_params |
|
311 | + * @return bool|mixed|null |
|
312 | + */ |
|
313 | + private function requestParameterDrillDown( |
|
314 | + $key, |
|
315 | + $default = null, |
|
316 | + $callback = 'is_set', |
|
317 | + array $request_params = array() |
|
318 | + ) { |
|
319 | + $callback = in_array($callback, array('is_set', 'get', 'match'), true) |
|
320 | + ? $callback |
|
321 | + : 'is_set'; |
|
322 | + $request_params = ! empty($request_params) |
|
323 | + ? $request_params |
|
324 | + : $this->request; |
|
325 | + // does incoming key represent an array like 'first[second][third]' ? |
|
326 | + if (strpos($key, '[') !== false) { |
|
327 | + // turn it into an actual array |
|
328 | + $key = str_replace(']', '', $key); |
|
329 | + $keys = explode('[', $key); |
|
330 | + $key = array_shift($keys); |
|
331 | + if ($callback === 'match') { |
|
332 | + $real_key = $this->match($key, $request_params, $default, 'key'); |
|
333 | + $key = $real_key ? $real_key : $key; |
|
334 | + } |
|
335 | + // check if top level key exists |
|
336 | + if (isset($request_params[ $key ])) { |
|
337 | + // build a new key to pass along like: 'second[third]' |
|
338 | + // or just 'second' depending on depth of keys |
|
339 | + $key_string = array_shift($keys); |
|
340 | + if (! empty($keys)) { |
|
341 | + $key_string .= '[' . implode('][', $keys) . ']'; |
|
342 | + } |
|
343 | + return $this->requestParameterDrillDown( |
|
344 | + $key_string, |
|
345 | + $default, |
|
346 | + $callback, |
|
347 | + $request_params[ $key ] |
|
348 | + ); |
|
349 | + } |
|
350 | + } |
|
351 | + if ($callback === 'is_set') { |
|
352 | + return isset($request_params[ $key ]); |
|
353 | + } |
|
354 | + if ($callback === 'match') { |
|
355 | + return $this->match($key, $request_params, $default); |
|
356 | + } |
|
357 | + return isset($request_params[ $key ]) |
|
358 | + ? $request_params[ $key ] |
|
359 | + : $default; |
|
360 | + } |
|
361 | + |
|
362 | + |
|
363 | + /** |
|
364 | + * remove param |
|
365 | + * |
|
366 | + * @param $key |
|
367 | + * @param bool $unset_from_global_too |
|
368 | + */ |
|
369 | + public function unSetRequestParam($key, $unset_from_global_too = false) |
|
370 | + { |
|
371 | + unset($this->request[ $key ]); |
|
372 | + if ($unset_from_global_too) { |
|
373 | + unset($_REQUEST[ $key ]); |
|
374 | + } |
|
375 | + } |
|
376 | + |
|
377 | + |
|
378 | + /** |
|
379 | + * @return string |
|
380 | + */ |
|
381 | + public function ipAddress() |
|
382 | + { |
|
383 | + return $this->ip_address; |
|
384 | + } |
|
385 | + |
|
386 | + |
|
387 | + /** |
|
388 | + * attempt to get IP address of current visitor from server |
|
389 | + * plz see: http://stackoverflow.com/a/2031935/1475279 |
|
390 | + * |
|
391 | + * @access public |
|
392 | + * @return string |
|
393 | + */ |
|
394 | + private function visitorIp() |
|
395 | + { |
|
396 | + $visitor_ip = '0.0.0.0'; |
|
397 | + $server_keys = array( |
|
398 | + 'HTTP_CLIENT_IP', |
|
399 | + 'HTTP_X_FORWARDED_FOR', |
|
400 | + 'HTTP_X_FORWARDED', |
|
401 | + 'HTTP_X_CLUSTER_CLIENT_IP', |
|
402 | + 'HTTP_FORWARDED_FOR', |
|
403 | + 'HTTP_FORWARDED', |
|
404 | + 'REMOTE_ADDR', |
|
405 | + ); |
|
406 | + foreach ($server_keys as $key) { |
|
407 | + if (isset($this->server[ $key ])) { |
|
408 | + foreach (array_map('trim', explode(',', $this->server[ $key ])) as $ip) { |
|
409 | + if ($ip === '127.0.0.1' || filter_var($ip, FILTER_VALIDATE_IP) !== false) { |
|
410 | + $visitor_ip = $ip; |
|
411 | + } |
|
412 | + } |
|
413 | + } |
|
414 | + } |
|
415 | + return $visitor_ip; |
|
416 | + } |
|
417 | + |
|
418 | + |
|
419 | + /** |
|
420 | + * Gets the request's literal URI. Related to `requestUriAfterSiteHomeUri`, see its description for a comparison. |
|
421 | + * @return string |
|
422 | + */ |
|
423 | + public function requestUri() |
|
424 | + { |
|
425 | + $request_uri = filter_input( |
|
426 | + INPUT_SERVER, |
|
427 | + 'REQUEST_URI', |
|
428 | + FILTER_SANITIZE_URL, |
|
429 | + FILTER_NULL_ON_FAILURE |
|
430 | + ); |
|
431 | + if (empty($request_uri)) { |
|
432 | + // fallback sanitization if the above fails |
|
433 | + $request_uri = wp_sanitize_redirect($this->server['REQUEST_URI']); |
|
434 | + } |
|
435 | + return $request_uri; |
|
436 | + } |
|
437 | + |
|
438 | + |
|
439 | + /** |
|
440 | + * Returns the REQUEST_URI after the current blog's home URI. |
|
441 | + * Eg, if this is a multisite, subdirectory install, the main blog lives at "http://mysite.com", and the current |
|
442 | + * blog lives at "http://mysite.com/other/", and a request comes to "http://mysite.com/other/path-relative-to-site", |
|
443 | + * this will return "/path-relative-to-site" whereas `requestUri` will return "/other/path-relative-to-site". |
|
444 | + * @since $VID:$ |
|
445 | + * @return mixed|string |
|
446 | + */ |
|
447 | + public function requestUriAfterSiteHomeUri() |
|
448 | + { |
|
449 | + $request_uri = filter_input( |
|
450 | + INPUT_SERVER, |
|
451 | + 'REQUEST_URI', |
|
452 | + FILTER_SANITIZE_URL, |
|
453 | + FILTER_NULL_ON_FAILURE |
|
454 | + ); |
|
455 | + // If it's a subdomain multisite install, we're actually only interested in |
|
456 | + if(is_multisite()){ |
|
457 | + $blog_details = get_blog_details(get_current_blog_id()); |
|
458 | + $request_uri = str_replace( |
|
459 | + untrailingslashit($blog_details->path), |
|
460 | + '', |
|
461 | + $request_uri |
|
462 | + ); |
|
463 | + } |
|
464 | + |
|
465 | + if (empty($request_uri)) { |
|
466 | + // fallback sanitization if the above fails |
|
467 | + $request_uri = $this->requestUri(); |
|
468 | + } |
|
469 | + return $request_uri; |
|
470 | + |
|
471 | + } |
|
472 | + |
|
473 | + |
|
474 | + /** |
|
475 | + * @return string |
|
476 | + */ |
|
477 | + public function userAgent() |
|
478 | + { |
|
479 | + return $this->user_agent; |
|
480 | + } |
|
481 | + |
|
482 | + |
|
483 | + /** |
|
484 | + * @param string $user_agent |
|
485 | + */ |
|
486 | + public function setUserAgent($user_agent = '') |
|
487 | + { |
|
488 | + if ($user_agent === '' || ! is_string($user_agent)) { |
|
489 | + $user_agent = isset($_SERVER['HTTP_USER_AGENT']) ? (string) esc_attr($_SERVER['HTTP_USER_AGENT']) : ''; |
|
490 | + } |
|
491 | + $this->user_agent = $user_agent; |
|
492 | + } |
|
493 | + |
|
494 | + |
|
495 | + /** |
|
496 | + * @return bool |
|
497 | + */ |
|
498 | + public function isBot() |
|
499 | + { |
|
500 | + return $this->is_bot; |
|
501 | + } |
|
502 | + |
|
503 | + |
|
504 | + /** |
|
505 | + * @param bool $is_bot |
|
506 | + */ |
|
507 | + public function setIsBot($is_bot) |
|
508 | + { |
|
509 | + $this->is_bot = filter_var($is_bot, FILTER_VALIDATE_BOOLEAN); |
|
510 | + } |
|
511 | + |
|
512 | + |
|
513 | + /** |
|
514 | + * @return bool |
|
515 | + */ |
|
516 | + public function isActivation() |
|
517 | + { |
|
518 | + return $this->request_type->isActivation(); |
|
519 | + } |
|
520 | + |
|
521 | + |
|
522 | + /** |
|
523 | + * @param $is_activation |
|
524 | + * @return bool |
|
525 | + */ |
|
526 | + public function setIsActivation($is_activation) |
|
527 | + { |
|
528 | + return $this->request_type->setIsActivation($is_activation); |
|
529 | + } |
|
530 | + |
|
531 | + |
|
532 | + /** |
|
533 | + * @return bool |
|
534 | + */ |
|
535 | + public function isAdmin() |
|
536 | + { |
|
537 | + return $this->request_type->isAdmin(); |
|
538 | + } |
|
539 | + |
|
540 | + |
|
541 | + /** |
|
542 | + * @return bool |
|
543 | + */ |
|
544 | + public function isAdminAjax() |
|
545 | + { |
|
546 | + return $this->request_type->isAdminAjax(); |
|
547 | + } |
|
548 | + |
|
549 | + |
|
550 | + /** |
|
551 | + * @return bool |
|
552 | + */ |
|
553 | + public function isAjax() |
|
554 | + { |
|
555 | + return $this->request_type->isAjax(); |
|
556 | + } |
|
557 | + |
|
558 | + |
|
559 | + /** |
|
560 | + * @return bool |
|
561 | + */ |
|
562 | + public function isEeAjax() |
|
563 | + { |
|
564 | + return $this->request_type->isEeAjax(); |
|
565 | + } |
|
566 | + |
|
567 | + |
|
568 | + /** |
|
569 | + * @return bool |
|
570 | + */ |
|
571 | + public function isOtherAjax() |
|
572 | + { |
|
573 | + return $this->request_type->isOtherAjax(); |
|
574 | + } |
|
575 | + |
|
576 | + |
|
577 | + /** |
|
578 | + * @return bool |
|
579 | + */ |
|
580 | + public function isApi() |
|
581 | + { |
|
582 | + return $this->request_type->isApi(); |
|
583 | + } |
|
584 | + |
|
585 | + |
|
586 | + /** |
|
587 | + * @return bool |
|
588 | + */ |
|
589 | + public function isCli() |
|
590 | + { |
|
591 | + return $this->request_type->isCli(); |
|
592 | + } |
|
593 | + |
|
594 | + |
|
595 | + /** |
|
596 | + * @return bool |
|
597 | + */ |
|
598 | + public function isCron() |
|
599 | + { |
|
600 | + return $this->request_type->isCron(); |
|
601 | + } |
|
602 | + |
|
603 | + |
|
604 | + /** |
|
605 | + * @return bool |
|
606 | + */ |
|
607 | + public function isFeed() |
|
608 | + { |
|
609 | + return $this->request_type->isFeed(); |
|
610 | + } |
|
611 | + |
|
612 | + |
|
613 | + /** |
|
614 | + * @return bool |
|
615 | + */ |
|
616 | + public function isFrontend() |
|
617 | + { |
|
618 | + return $this->request_type->isFrontend(); |
|
619 | + } |
|
620 | + |
|
621 | + |
|
622 | + /** |
|
623 | + * @return bool |
|
624 | + */ |
|
625 | + public function isFrontAjax() |
|
626 | + { |
|
627 | + return $this->request_type->isFrontAjax(); |
|
628 | + } |
|
629 | + |
|
630 | + |
|
631 | + /** |
|
632 | + * @return bool |
|
633 | + */ |
|
634 | + public function isIframe() |
|
635 | + { |
|
636 | + return $this->request_type->isIframe(); |
|
637 | + } |
|
638 | + |
|
639 | + |
|
640 | + /** |
|
641 | + * @return bool |
|
642 | + */ |
|
643 | + public function isWordPressApi() |
|
644 | + { |
|
645 | + return $this->request_type->isWordPressApi(); |
|
646 | + } |
|
647 | + |
|
648 | + |
|
649 | + |
|
650 | + /** |
|
651 | + * @return bool |
|
652 | + */ |
|
653 | + public function isWordPressHeartbeat() |
|
654 | + { |
|
655 | + return $this->request_type->isWordPressHeartbeat(); |
|
656 | + } |
|
657 | + |
|
658 | + |
|
659 | + |
|
660 | + /** |
|
661 | + * @return bool |
|
662 | + */ |
|
663 | + public function isWordPressScrape() |
|
664 | + { |
|
665 | + return $this->request_type->isWordPressScrape(); |
|
666 | + } |
|
667 | + |
|
668 | + |
|
669 | + /** |
|
670 | + * @return string |
|
671 | + */ |
|
672 | + public function slug() |
|
673 | + { |
|
674 | + return $this->request_type->slug(); |
|
675 | + } |
|
676 | 676 | } |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | || ($key === 'ee' && empty($this->request['ee'])) |
183 | 183 | || ($key === 'ee' && ! empty($this->request['ee']) && $override_ee) |
184 | 184 | ) { |
185 | - $this->request[ $key ] = $value; |
|
185 | + $this->request[$key] = $value; |
|
186 | 186 | } |
187 | 187 | } |
188 | 188 | |
@@ -273,10 +273,10 @@ discard block |
||
273 | 273 | preg_quote($pattern, '/') |
274 | 274 | ); |
275 | 275 | foreach ($request_params as $key => $request_param) { |
276 | - if (preg_match('/^' . $pattern . '$/is', $key)) { |
|
276 | + if (preg_match('/^'.$pattern.'$/is', $key)) { |
|
277 | 277 | // return value for request param |
278 | 278 | if ($return === 'value') { |
279 | - return $request_params[ $key ]; |
|
279 | + return $request_params[$key]; |
|
280 | 280 | } |
281 | 281 | // or actual key or true just to indicate it was found |
282 | 282 | return $return === 'key' ? $key : true; |
@@ -333,29 +333,29 @@ discard block |
||
333 | 333 | $key = $real_key ? $real_key : $key; |
334 | 334 | } |
335 | 335 | // check if top level key exists |
336 | - if (isset($request_params[ $key ])) { |
|
336 | + if (isset($request_params[$key])) { |
|
337 | 337 | // build a new key to pass along like: 'second[third]' |
338 | 338 | // or just 'second' depending on depth of keys |
339 | 339 | $key_string = array_shift($keys); |
340 | - if (! empty($keys)) { |
|
341 | - $key_string .= '[' . implode('][', $keys) . ']'; |
|
340 | + if ( ! empty($keys)) { |
|
341 | + $key_string .= '['.implode('][', $keys).']'; |
|
342 | 342 | } |
343 | 343 | return $this->requestParameterDrillDown( |
344 | 344 | $key_string, |
345 | 345 | $default, |
346 | 346 | $callback, |
347 | - $request_params[ $key ] |
|
347 | + $request_params[$key] |
|
348 | 348 | ); |
349 | 349 | } |
350 | 350 | } |
351 | 351 | if ($callback === 'is_set') { |
352 | - return isset($request_params[ $key ]); |
|
352 | + return isset($request_params[$key]); |
|
353 | 353 | } |
354 | 354 | if ($callback === 'match') { |
355 | 355 | return $this->match($key, $request_params, $default); |
356 | 356 | } |
357 | - return isset($request_params[ $key ]) |
|
358 | - ? $request_params[ $key ] |
|
357 | + return isset($request_params[$key]) |
|
358 | + ? $request_params[$key] |
|
359 | 359 | : $default; |
360 | 360 | } |
361 | 361 | |
@@ -368,9 +368,9 @@ discard block |
||
368 | 368 | */ |
369 | 369 | public function unSetRequestParam($key, $unset_from_global_too = false) |
370 | 370 | { |
371 | - unset($this->request[ $key ]); |
|
371 | + unset($this->request[$key]); |
|
372 | 372 | if ($unset_from_global_too) { |
373 | - unset($_REQUEST[ $key ]); |
|
373 | + unset($_REQUEST[$key]); |
|
374 | 374 | } |
375 | 375 | } |
376 | 376 | |
@@ -404,8 +404,8 @@ discard block |
||
404 | 404 | 'REMOTE_ADDR', |
405 | 405 | ); |
406 | 406 | foreach ($server_keys as $key) { |
407 | - if (isset($this->server[ $key ])) { |
|
408 | - foreach (array_map('trim', explode(',', $this->server[ $key ])) as $ip) { |
|
407 | + if (isset($this->server[$key])) { |
|
408 | + foreach (array_map('trim', explode(',', $this->server[$key])) as $ip) { |
|
409 | 409 | if ($ip === '127.0.0.1' || filter_var($ip, FILTER_VALIDATE_IP) !== false) { |
410 | 410 | $visitor_ip = $ip; |
411 | 411 | } |
@@ -453,7 +453,7 @@ discard block |
||
453 | 453 | FILTER_NULL_ON_FAILURE |
454 | 454 | ); |
455 | 455 | // If it's a subdomain multisite install, we're actually only interested in |
456 | - if(is_multisite()){ |
|
456 | + if (is_multisite()) { |
|
457 | 457 | $blog_details = get_blog_details(get_current_blog_id()); |
458 | 458 | $request_uri = str_replace( |
459 | 459 | untrailingslashit($blog_details->path), |
@@ -16,152 +16,152 @@ |
||
16 | 16 | interface RequestInterface extends RequestTypeContextCheckerInterface |
17 | 17 | { |
18 | 18 | |
19 | - /** |
|
20 | - * @param RequestTypeContextCheckerInterface $type |
|
21 | - */ |
|
22 | - public function setRequestTypeContextChecker(RequestTypeContextCheckerInterface $type); |
|
23 | - |
|
24 | - /** |
|
25 | - * @return array |
|
26 | - */ |
|
27 | - public function getParams(); |
|
28 | - |
|
29 | - |
|
30 | - /** |
|
31 | - * @return array |
|
32 | - */ |
|
33 | - public function postParams(); |
|
34 | - |
|
35 | - |
|
36 | - /** |
|
37 | - * @return array |
|
38 | - */ |
|
39 | - public function cookieParams(); |
|
40 | - |
|
41 | - |
|
42 | - /** |
|
43 | - * @return array |
|
44 | - */ |
|
45 | - public function serverParams(); |
|
46 | - |
|
47 | - |
|
48 | - /** |
|
49 | - * @return array |
|
50 | - */ |
|
51 | - public function filesParams(); |
|
19 | + /** |
|
20 | + * @param RequestTypeContextCheckerInterface $type |
|
21 | + */ |
|
22 | + public function setRequestTypeContextChecker(RequestTypeContextCheckerInterface $type); |
|
23 | + |
|
24 | + /** |
|
25 | + * @return array |
|
26 | + */ |
|
27 | + public function getParams(); |
|
28 | + |
|
29 | + |
|
30 | + /** |
|
31 | + * @return array |
|
32 | + */ |
|
33 | + public function postParams(); |
|
34 | + |
|
35 | + |
|
36 | + /** |
|
37 | + * @return array |
|
38 | + */ |
|
39 | + public function cookieParams(); |
|
40 | + |
|
41 | + |
|
42 | + /** |
|
43 | + * @return array |
|
44 | + */ |
|
45 | + public function serverParams(); |
|
46 | + |
|
47 | + |
|
48 | + /** |
|
49 | + * @return array |
|
50 | + */ |
|
51 | + public function filesParams(); |
|
52 | 52 | |
53 | 53 | |
54 | - /** |
|
55 | - * returns contents of $_REQUEST |
|
56 | - * |
|
57 | - * @return array |
|
58 | - */ |
|
59 | - public function requestParams(); |
|
54 | + /** |
|
55 | + * returns contents of $_REQUEST |
|
56 | + * |
|
57 | + * @return array |
|
58 | + */ |
|
59 | + public function requestParams(); |
|
60 | 60 | |
61 | 61 | |
62 | - /** |
|
63 | - * @param string $key |
|
64 | - * @param string $value |
|
65 | - * @param bool $override_ee |
|
66 | - * @return void |
|
67 | - */ |
|
68 | - public function setRequestParam($key, $value, $override_ee = false); |
|
62 | + /** |
|
63 | + * @param string $key |
|
64 | + * @param string $value |
|
65 | + * @param bool $override_ee |
|
66 | + * @return void |
|
67 | + */ |
|
68 | + public function setRequestParam($key, $value, $override_ee = false); |
|
69 | 69 | |
70 | 70 | |
71 | - /** |
|
72 | - * returns the value for a request param if the given key exists |
|
73 | - * |
|
74 | - * @param string $key |
|
75 | - * @param null $default |
|
76 | - * @return mixed |
|
77 | - */ |
|
78 | - public function getRequestParam($key, $default = null); |
|
71 | + /** |
|
72 | + * returns the value for a request param if the given key exists |
|
73 | + * |
|
74 | + * @param string $key |
|
75 | + * @param null $default |
|
76 | + * @return mixed |
|
77 | + */ |
|
78 | + public function getRequestParam($key, $default = null); |
|
79 | 79 | |
80 | 80 | |
81 | - /** |
|
82 | - * check if param exists |
|
83 | - * |
|
84 | - * @param string $key |
|
85 | - * @return bool |
|
86 | - */ |
|
87 | - public function requestParamIsSet($key); |
|
81 | + /** |
|
82 | + * check if param exists |
|
83 | + * |
|
84 | + * @param string $key |
|
85 | + * @return bool |
|
86 | + */ |
|
87 | + public function requestParamIsSet($key); |
|
88 | 88 | |
89 | 89 | |
90 | - /** |
|
91 | - * check if a request parameter exists whose key that matches the supplied wildcard pattern |
|
92 | - * and return the value for the first match found |
|
93 | - * wildcards can be either of the following: |
|
94 | - * ? to represent a single character of any type |
|
95 | - * * to represent one or more characters of any type |
|
96 | - * |
|
97 | - * @param string $pattern |
|
98 | - * @param null|mixed $default |
|
99 | - * @return false|int |
|
100 | - */ |
|
101 | - public function getMatch($pattern, $default = null); |
|
90 | + /** |
|
91 | + * check if a request parameter exists whose key that matches the supplied wildcard pattern |
|
92 | + * and return the value for the first match found |
|
93 | + * wildcards can be either of the following: |
|
94 | + * ? to represent a single character of any type |
|
95 | + * * to represent one or more characters of any type |
|
96 | + * |
|
97 | + * @param string $pattern |
|
98 | + * @param null|mixed $default |
|
99 | + * @return false|int |
|
100 | + */ |
|
101 | + public function getMatch($pattern, $default = null); |
|
102 | 102 | |
103 | 103 | |
104 | - /** |
|
105 | - * check if a request parameter exists whose key matches the supplied wildcard pattern |
|
106 | - * wildcards can be either of the following: |
|
107 | - * ? to represent a single character of any type |
|
108 | - * * to represent one or more characters of any type |
|
109 | - * returns true if a match is found or false if not |
|
110 | - * |
|
111 | - * @param string $pattern |
|
112 | - * @return false|int |
|
113 | - */ |
|
114 | - public function matches($pattern); |
|
104 | + /** |
|
105 | + * check if a request parameter exists whose key matches the supplied wildcard pattern |
|
106 | + * wildcards can be either of the following: |
|
107 | + * ? to represent a single character of any type |
|
108 | + * * to represent one or more characters of any type |
|
109 | + * returns true if a match is found or false if not |
|
110 | + * |
|
111 | + * @param string $pattern |
|
112 | + * @return false|int |
|
113 | + */ |
|
114 | + public function matches($pattern); |
|
115 | 115 | |
116 | 116 | |
117 | - /** |
|
118 | - * remove param |
|
119 | - * |
|
120 | - * @param string $key |
|
121 | - * @param bool $unset_from_global_too |
|
122 | - */ |
|
123 | - public function unSetRequestParam($key, $unset_from_global_too = false); |
|
117 | + /** |
|
118 | + * remove param |
|
119 | + * |
|
120 | + * @param string $key |
|
121 | + * @param bool $unset_from_global_too |
|
122 | + */ |
|
123 | + public function unSetRequestParam($key, $unset_from_global_too = false); |
|
124 | 124 | |
125 | 125 | |
126 | - /** |
|
127 | - * @return string |
|
128 | - */ |
|
129 | - public function ipAddress(); |
|
126 | + /** |
|
127 | + * @return string |
|
128 | + */ |
|
129 | + public function ipAddress(); |
|
130 | 130 | |
131 | 131 | |
132 | - /** |
|
133 | - * @return string |
|
134 | - */ |
|
135 | - public function requestUri(); |
|
132 | + /** |
|
133 | + * @return string |
|
134 | + */ |
|
135 | + public function requestUri(); |
|
136 | 136 | |
137 | 137 | |
138 | - /** |
|
139 | - * @since $VID:$ |
|
140 | - * @return string |
|
141 | - */ |
|
142 | - public function requestUriAfterSiteHomeUri(); |
|
143 | - |
|
138 | + /** |
|
139 | + * @since $VID:$ |
|
140 | + * @return string |
|
141 | + */ |
|
142 | + public function requestUriAfterSiteHomeUri(); |
|
143 | + |
|
144 | 144 | |
145 | - /** |
|
146 | - * @return string |
|
147 | - */ |
|
148 | - public function userAgent(); |
|
149 | - |
|
150 | - |
|
151 | - /** |
|
152 | - * @param string $user_agent |
|
153 | - */ |
|
154 | - public function setUserAgent($user_agent = ''); |
|
155 | - |
|
156 | - |
|
157 | - /** |
|
158 | - * @return bool |
|
159 | - */ |
|
160 | - public function isBot(); |
|
161 | - |
|
162 | - |
|
163 | - /** |
|
164 | - * @param bool $is_bot |
|
165 | - */ |
|
166 | - public function setIsBot($is_bot); |
|
145 | + /** |
|
146 | + * @return string |
|
147 | + */ |
|
148 | + public function userAgent(); |
|
149 | + |
|
150 | + |
|
151 | + /** |
|
152 | + * @param string $user_agent |
|
153 | + */ |
|
154 | + public function setUserAgent($user_agent = ''); |
|
155 | + |
|
156 | + |
|
157 | + /** |
|
158 | + * @return bool |
|
159 | + */ |
|
160 | + public function isBot(); |
|
161 | + |
|
162 | + |
|
163 | + /** |
|
164 | + * @param bool $is_bot |
|
165 | + */ |
|
166 | + public function setIsBot($is_bot); |
|
167 | 167 | } |