@@ -3,18 +3,18 @@ |
||
3 | 3 | |
4 | 4 | class GetPostDetails extends AbstractRequest { |
5 | 5 | |
6 | - function getApiEndPoint() |
|
7 | - { |
|
8 | - return '/v2/posts/' . $_GET['postID']; |
|
9 | - } |
|
10 | - function getPayload() |
|
11 | - { |
|
12 | - return array( |
|
13 | - ); |
|
14 | - } |
|
15 | - function getMethod() |
|
16 | - { |
|
17 | - return 'GET'; |
|
18 | - } |
|
6 | + function getApiEndPoint() |
|
7 | + { |
|
8 | + return '/v2/posts/' . $_GET['postID']; |
|
9 | + } |
|
10 | + function getPayload() |
|
11 | + { |
|
12 | + return array( |
|
13 | + ); |
|
14 | + } |
|
15 | + function getMethod() |
|
16 | + { |
|
17 | + return 'GET'; |
|
18 | + } |
|
19 | 19 | } |
20 | 20 |
@@ -1,7 +1,8 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | |
4 | -class GetPostDetails extends AbstractRequest { |
|
4 | +class GetPostDetails extends AbstractRequest |
|
5 | +{ |
|
5 | 6 | |
6 | 7 | function getApiEndPoint() |
7 | 8 | { |
@@ -3,18 +3,18 @@ |
||
3 | 3 | |
4 | 4 | class Downvote extends AbstractRequest { |
5 | 5 | |
6 | - function getApiEndPoint() |
|
7 | - { |
|
8 | - return '/v2/posts/' . $_GET['postID'] . '/downvote'; |
|
9 | - } |
|
10 | - function getPayload() |
|
11 | - { |
|
12 | - return array( |
|
13 | - ); |
|
14 | - } |
|
15 | - function getMethod() |
|
16 | - { |
|
17 | - return 'PUT'; |
|
18 | - } |
|
6 | + function getApiEndPoint() |
|
7 | + { |
|
8 | + return '/v2/posts/' . $_GET['postID'] . '/downvote'; |
|
9 | + } |
|
10 | + function getPayload() |
|
11 | + { |
|
12 | + return array( |
|
13 | + ); |
|
14 | + } |
|
15 | + function getMethod() |
|
16 | + { |
|
17 | + return 'PUT'; |
|
18 | + } |
|
19 | 19 | } |
20 | 20 |
@@ -1,7 +1,8 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | |
4 | -class Downvote extends AbstractRequest { |
|
4 | +class Downvote extends AbstractRequest |
|
5 | +{ |
|
5 | 6 | |
6 | 7 | function getApiEndPoint() |
7 | 8 | { |
@@ -3,37 +3,37 @@ |
||
3 | 3 | |
4 | 4 | class UpdateLocation extends AbstractRequest { |
5 | 5 | /** |
6 | - * @var Location |
|
7 | - */ |
|
8 | - public $location; |
|
9 | - /** |
|
10 | - * @return Location |
|
11 | - */ |
|
12 | - public function getLocation(): Location |
|
13 | - { |
|
14 | - return $this->location; |
|
15 | - } |
|
16 | - /** |
|
17 | - * @param Location $location |
|
18 | - */ |
|
19 | - public function setLocation(Location $location) |
|
20 | - { |
|
21 | - $this->location = $location; |
|
22 | - } |
|
6 | + * @var Location |
|
7 | + */ |
|
8 | + public $location; |
|
9 | + /** |
|
10 | + * @return Location |
|
11 | + */ |
|
12 | + public function getLocation(): Location |
|
13 | + { |
|
14 | + return $this->location; |
|
15 | + } |
|
16 | + /** |
|
17 | + * @param Location $location |
|
18 | + */ |
|
19 | + public function setLocation(Location $location) |
|
20 | + { |
|
21 | + $this->location = $location; |
|
22 | + } |
|
23 | 23 | |
24 | - function getApiEndPoint() |
|
25 | - { |
|
26 | - return '/v2/users/location'; |
|
27 | - } |
|
28 | - function getPayload() |
|
29 | - { |
|
30 | - return array( |
|
24 | + function getApiEndPoint() |
|
25 | + { |
|
26 | + return '/v2/users/location'; |
|
27 | + } |
|
28 | + function getPayload() |
|
29 | + { |
|
30 | + return array( |
|
31 | 31 | "location" => $this->getLocation()->toArray(), |
32 | - ); |
|
33 | - } |
|
34 | - function getMethod() |
|
35 | - { |
|
36 | - return 'PUT'; |
|
37 | - } |
|
32 | + ); |
|
33 | + } |
|
34 | + function getMethod() |
|
35 | + { |
|
36 | + return 'PUT'; |
|
37 | + } |
|
38 | 38 | } |
39 | 39 |
@@ -1,7 +1,8 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | |
4 | -class UpdateLocation extends AbstractRequest { |
|
4 | +class UpdateLocation extends AbstractRequest |
|
5 | +{ |
|
5 | 6 | /** |
6 | 7 | * @var Location |
7 | 8 | */ |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -class Location{ |
|
3 | +class Location { |
|
4 | 4 | |
5 | 5 | public $cityName; |
6 | 6 | |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | { |
38 | 38 | $this->lng = $lng; |
39 | 39 | } |
40 | - public function toArray(){ |
|
40 | + public function toArray() { |
|
41 | 41 | return array( |
42 | 42 | "city" => $this->getCityName(), |
43 | 43 | "country" => 'DE', |
@@ -1,6 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -class Location{ |
|
3 | +class Location |
|
4 | +{ |
|
4 | 5 | |
5 | 6 | public $cityName; |
6 | 7 | |
@@ -37,7 +38,8 @@ discard block |
||
37 | 38 | { |
38 | 39 | $this->lng = $lng; |
39 | 40 | } |
40 | - public function toArray(){ |
|
41 | + public function toArray() |
|
42 | + { |
|
41 | 43 | return array( |
42 | 44 | "city" => $this->getCityName(), |
43 | 45 | "country" => 'DE', |
@@ -2,51 +2,51 @@ |
||
2 | 2 | |
3 | 3 | class Location{ |
4 | 4 | |
5 | - public $cityName; |
|
6 | - |
|
7 | - public $lat; |
|
8 | - |
|
9 | - public $lng; |
|
10 | - |
|
11 | - public function getCityName() |
|
12 | - { |
|
13 | - return $this->cityName; |
|
14 | - } |
|
15 | - |
|
16 | - public function setCityName(string $cityName) |
|
17 | - { |
|
18 | - $this->cityName = $cityName; |
|
19 | - } |
|
20 | - |
|
21 | - public function getLat() |
|
22 | - { |
|
23 | - return $this->lat; |
|
24 | - } |
|
25 | - |
|
26 | - public function setLat(string $lat) |
|
27 | - { |
|
28 | - $this->lat = $lat; |
|
29 | - } |
|
30 | - |
|
31 | - public function getLng() |
|
32 | - { |
|
33 | - return $this->lng; |
|
34 | - } |
|
35 | - |
|
36 | - public function setLng(string $lng) |
|
37 | - { |
|
38 | - $this->lng = $lng; |
|
39 | - } |
|
40 | - public function toArray(){ |
|
41 | - return array( |
|
42 | - "city" => $this->getCityName(), |
|
43 | - "country" => 'DE', |
|
44 | - "loc_accuracy" => '0.0', |
|
45 | - "loc_coordinates" => array( |
|
46 | - "lat" => $this->getLat(), |
|
47 | - "lng" => $this->getLng(), |
|
48 | - ), |
|
49 | - "name" => $this->getCityName() |
|
50 | - ); |
|
51 | - } |
|
5 | + public $cityName; |
|
6 | + |
|
7 | + public $lat; |
|
8 | + |
|
9 | + public $lng; |
|
10 | + |
|
11 | + public function getCityName() |
|
12 | + { |
|
13 | + return $this->cityName; |
|
14 | + } |
|
15 | + |
|
16 | + public function setCityName(string $cityName) |
|
17 | + { |
|
18 | + $this->cityName = $cityName; |
|
19 | + } |
|
20 | + |
|
21 | + public function getLat() |
|
22 | + { |
|
23 | + return $this->lat; |
|
24 | + } |
|
25 | + |
|
26 | + public function setLat(string $lat) |
|
27 | + { |
|
28 | + $this->lat = $lat; |
|
29 | + } |
|
30 | + |
|
31 | + public function getLng() |
|
32 | + { |
|
33 | + return $this->lng; |
|
34 | + } |
|
35 | + |
|
36 | + public function setLng(string $lng) |
|
37 | + { |
|
38 | + $this->lng = $lng; |
|
39 | + } |
|
40 | + public function toArray(){ |
|
41 | + return array( |
|
42 | + "city" => $this->getCityName(), |
|
43 | + "country" => 'DE', |
|
44 | + "loc_accuracy" => '0.0', |
|
45 | + "loc_coordinates" => array( |
|
46 | + "lat" => $this->getLat(), |
|
47 | + "lng" => $this->getLng(), |
|
48 | + ), |
|
49 | + "name" => $this->getCityName() |
|
50 | + ); |
|
51 | + } |
|
52 | 52 | } |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | * |
63 | 63 | * @param string $name |
64 | 64 | * @param string $value |
65 | - * @param array|Requests_Utility_CaseInsensitiveDictionary $attributes Associative array of attribute data |
|
65 | + * @param Requests_Utility_CaseInsensitiveDictionary $attributes Associative array of attribute data |
|
66 | 66 | */ |
67 | 67 | public function __construct($name, $value, $attributes = array(), $flags = array(), $reference_time = null) { |
68 | 68 | $this->name = $name; |
@@ -377,6 +377,7 @@ discard block |
||
377 | 377 | * specifies some of this handling, but not in a thorough manner. |
378 | 378 | * |
379 | 379 | * @param string Cookie header value (from a Set-Cookie header) |
380 | + * @param integer $reference_time |
|
380 | 381 | * @return Requests_Cookie Parsed cookie object |
381 | 382 | */ |
382 | 383 | public static function parse($string, $name = '', $reference_time = null) { |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | $this->flags = array_merge($default_flags, $flags); |
78 | 78 | |
79 | 79 | $this->reference_time = time(); |
80 | - if ($reference_time !== null) { |
|
80 | + if($reference_time !== null) { |
|
81 | 81 | $this->reference_time = $reference_time; |
82 | 82 | } |
83 | 83 | |
@@ -97,12 +97,12 @@ discard block |
||
97 | 97 | // If a cookie has both the Max-Age and the Expires attribute, the Max- |
98 | 98 | // Age attribute has precedence and controls the expiration date of the |
99 | 99 | // cookie. |
100 | - if (isset($this->attributes['max-age'])) { |
|
100 | + if(isset($this->attributes['max-age'])) { |
|
101 | 101 | $max_age = $this->attributes['max-age']; |
102 | 102 | return $max_age < $this->reference_time; |
103 | 103 | } |
104 | 104 | |
105 | - if (isset($this->attributes['expires'])) { |
|
105 | + if(isset($this->attributes['expires'])) { |
|
106 | 106 | $expires = $this->attributes['expires']; |
107 | 107 | return $expires < $this->reference_time; |
108 | 108 | } |
@@ -117,11 +117,11 @@ discard block |
||
117 | 117 | * @return boolean Whether the cookie is valid for the given URI |
118 | 118 | */ |
119 | 119 | public function uri_matches(Requests_IRI $uri) { |
120 | - if (!$this->domain_matches($uri->host)) { |
|
120 | + if(!$this->domain_matches($uri->host)) { |
|
121 | 121 | return false; |
122 | 122 | } |
123 | 123 | |
124 | - if (!$this->path_matches($uri->path)) { |
|
124 | + if(!$this->path_matches($uri->path)) { |
|
125 | 125 | return false; |
126 | 126 | } |
127 | 127 | |
@@ -135,37 +135,37 @@ discard block |
||
135 | 135 | * @return boolean Whether the cookie is valid for the given domain |
136 | 136 | */ |
137 | 137 | public function domain_matches($string) { |
138 | - if (!isset($this->attributes['domain'])) { |
|
138 | + if(!isset($this->attributes['domain'])) { |
|
139 | 139 | // Cookies created manually; cookies created by Requests will set |
140 | 140 | // the domain to the requested domain |
141 | 141 | return true; |
142 | 142 | } |
143 | 143 | |
144 | 144 | $domain_string = $this->attributes['domain']; |
145 | - if ($domain_string === $string) { |
|
145 | + if($domain_string === $string) { |
|
146 | 146 | // The domain string and the string are identical. |
147 | 147 | return true; |
148 | 148 | } |
149 | 149 | |
150 | 150 | // If the cookie is marked as host-only and we don't have an exact |
151 | 151 | // match, reject the cookie |
152 | - if ($this->flags['host-only'] === true) { |
|
152 | + if($this->flags['host-only'] === true) { |
|
153 | 153 | return false; |
154 | 154 | } |
155 | 155 | |
156 | - if (strlen($string) <= strlen($domain_string)) { |
|
156 | + if(strlen($string) <= strlen($domain_string)) { |
|
157 | 157 | // For obvious reasons, the string cannot be a suffix if the domain |
158 | 158 | // is shorter than the domain string |
159 | 159 | return false; |
160 | 160 | } |
161 | 161 | |
162 | - if (substr($string, -1 * strlen($domain_string)) !== $domain_string) { |
|
162 | + if(substr($string, -1 * strlen($domain_string)) !== $domain_string) { |
|
163 | 163 | // The domain string should be a suffix of the string. |
164 | 164 | return false; |
165 | 165 | } |
166 | 166 | |
167 | 167 | $prefix = substr($string, 0, strlen($string) - strlen($domain_string)); |
168 | - if (substr($prefix, -1) !== '.') { |
|
168 | + if(substr($prefix, -1) !== '.') { |
|
169 | 169 | // The last character of the string that is not included in the |
170 | 170 | // domain string should be a %x2E (".") character. |
171 | 171 | return false; |
@@ -184,12 +184,12 @@ discard block |
||
184 | 184 | * @return boolean Whether the cookie is valid for the given path |
185 | 185 | */ |
186 | 186 | public function path_matches($request_path) { |
187 | - if (empty($request_path)) { |
|
187 | + if(empty($request_path)) { |
|
188 | 188 | // Normalize empty path to root |
189 | 189 | $request_path = '/'; |
190 | 190 | } |
191 | 191 | |
192 | - if (!isset($this->attributes['path'])) { |
|
192 | + if(!isset($this->attributes['path'])) { |
|
193 | 193 | // Cookies created manually; cookies created by Requests will set |
194 | 194 | // the path to the requested path |
195 | 195 | return true; |
@@ -197,19 +197,19 @@ discard block |
||
197 | 197 | |
198 | 198 | $cookie_path = $this->attributes['path']; |
199 | 199 | |
200 | - if ($cookie_path === $request_path) { |
|
200 | + if($cookie_path === $request_path) { |
|
201 | 201 | // The cookie-path and the request-path are identical. |
202 | 202 | return true; |
203 | 203 | } |
204 | 204 | |
205 | - if (strlen($request_path) > strlen($cookie_path) && substr($request_path, 0, strlen($cookie_path)) === $cookie_path) { |
|
206 | - if (substr($cookie_path, -1) === '/') { |
|
205 | + if(strlen($request_path) > strlen($cookie_path) && substr($request_path, 0, strlen($cookie_path)) === $cookie_path) { |
|
206 | + if(substr($cookie_path, -1) === '/') { |
|
207 | 207 | // The cookie-path is a prefix of the request-path, and the last |
208 | 208 | // character of the cookie-path is %x2F ("/"). |
209 | 209 | return true; |
210 | 210 | } |
211 | 211 | |
212 | - if (substr($request_path, strlen($cookie_path), 1) === '/') { |
|
212 | + if(substr($request_path, strlen($cookie_path), 1) === '/') { |
|
213 | 213 | // The cookie-path is a prefix of the request-path, and the |
214 | 214 | // first character of the request-path that is not included in |
215 | 215 | // the cookie-path is a %x2F ("/") character. |
@@ -226,15 +226,15 @@ discard block |
||
226 | 226 | * @return boolean Whether the cookie was successfully normalized |
227 | 227 | */ |
228 | 228 | public function normalize() { |
229 | - foreach ($this->attributes as $key => $value) { |
|
229 | + foreach($this->attributes as $key => $value) { |
|
230 | 230 | $orig_value = $value; |
231 | 231 | $value = $this->normalize_attribute($key, $value); |
232 | - if ($value === null) { |
|
232 | + if($value === null) { |
|
233 | 233 | unset($this->attributes[$key]); |
234 | 234 | continue; |
235 | 235 | } |
236 | 236 | |
237 | - if ($value !== $orig_value) { |
|
237 | + if($value !== $orig_value) { |
|
238 | 238 | $this->attributes[$key] = $value; |
239 | 239 | } |
240 | 240 | } |
@@ -252,15 +252,15 @@ discard block |
||
252 | 252 | * @return mixed Value if available, or null if the attribute value is invalid (and should be skipped) |
253 | 253 | */ |
254 | 254 | protected function normalize_attribute($name, $value) { |
255 | - switch (strtolower($name)) { |
|
255 | + switch(strtolower($name)) { |
|
256 | 256 | case 'expires': |
257 | 257 | // Expiration parsing, as per RFC 6265 section 5.2.1 |
258 | - if (is_int($value)) { |
|
258 | + if(is_int($value)) { |
|
259 | 259 | return $value; |
260 | 260 | } |
261 | 261 | |
262 | 262 | $expiry_time = strtotime($value); |
263 | - if ($expiry_time === false) { |
|
263 | + if($expiry_time === false) { |
|
264 | 264 | return null; |
265 | 265 | } |
266 | 266 | |
@@ -268,17 +268,17 @@ discard block |
||
268 | 268 | |
269 | 269 | case 'max-age': |
270 | 270 | // Expiration parsing, as per RFC 6265 section 5.2.2 |
271 | - if (is_int($value)) { |
|
271 | + if(is_int($value)) { |
|
272 | 272 | return $value; |
273 | 273 | } |
274 | 274 | |
275 | 275 | // Check that we have a valid age |
276 | - if (!preg_match('/^-?\d+$/', $value)) { |
|
276 | + if(!preg_match('/^-?\d+$/', $value)) { |
|
277 | 277 | return null; |
278 | 278 | } |
279 | 279 | |
280 | - $delta_seconds = (int) $value; |
|
281 | - if ($delta_seconds <= 0) { |
|
280 | + $delta_seconds = (int)$value; |
|
281 | + if($delta_seconds <= 0) { |
|
282 | 282 | $expiry_time = 0; |
283 | 283 | } |
284 | 284 | else { |
@@ -289,7 +289,7 @@ discard block |
||
289 | 289 | |
290 | 290 | case 'domain': |
291 | 291 | // Domain normalization, as per RFC 6265 section 5.2.3 |
292 | - if ($value[0] === '.') { |
|
292 | + if($value[0] === '.') { |
|
293 | 293 | $value = substr($value, 1); |
294 | 294 | } |
295 | 295 | |
@@ -332,11 +332,11 @@ discard block |
||
332 | 332 | */ |
333 | 333 | public function format_for_set_cookie() { |
334 | 334 | $header_value = $this->format_for_header(); |
335 | - if (!empty($this->attributes)) { |
|
335 | + if(!empty($this->attributes)) { |
|
336 | 336 | $parts = array(); |
337 | - foreach ($this->attributes as $key => $value) { |
|
337 | + foreach($this->attributes as $key => $value) { |
|
338 | 338 | // Ignore non-associative attributes |
339 | - if (is_numeric($key)) { |
|
339 | + if(is_numeric($key)) { |
|
340 | 340 | $parts[] = $value; |
341 | 341 | } |
342 | 342 | else { |
@@ -383,10 +383,10 @@ discard block |
||
383 | 383 | $parts = explode(';', $string); |
384 | 384 | $kvparts = array_shift($parts); |
385 | 385 | |
386 | - if (!empty($name)) { |
|
386 | + if(!empty($name)) { |
|
387 | 387 | $value = $string; |
388 | 388 | } |
389 | - elseif (strpos($kvparts, '=') === false) { |
|
389 | + elseif(strpos($kvparts, '=') === false) { |
|
390 | 390 | // Some sites might only have a value without the equals separator. |
391 | 391 | // Deviate from RFC 6265 and pretend it was actually a blank name |
392 | 392 | // (`=foo`) |
@@ -404,9 +404,9 @@ discard block |
||
404 | 404 | // Attribute key are handled case-insensitively |
405 | 405 | $attributes = new Requests_Utility_CaseInsensitiveDictionary(); |
406 | 406 | |
407 | - if (!empty($parts)) { |
|
408 | - foreach ($parts as $part) { |
|
409 | - if (strpos($part, '=') === false) { |
|
407 | + if(!empty($parts)) { |
|
408 | + foreach($parts as $part) { |
|
409 | + if(strpos($part, '=') === false) { |
|
410 | 410 | $part_key = $part; |
411 | 411 | $part_value = true; |
412 | 412 | } |
@@ -433,16 +433,16 @@ discard block |
||
433 | 433 | */ |
434 | 434 | public static function parse_from_headers(Requests_Response_Headers $headers, Requests_IRI $origin = null, $time = null) { |
435 | 435 | $cookie_headers = $headers->getValues('Set-Cookie'); |
436 | - if (empty($cookie_headers)) { |
|
436 | + if(empty($cookie_headers)) { |
|
437 | 437 | return array(); |
438 | 438 | } |
439 | 439 | |
440 | 440 | $cookies = array(); |
441 | - foreach ($cookie_headers as $header) { |
|
441 | + foreach($cookie_headers as $header) { |
|
442 | 442 | $parsed = self::parse($header, '', $time); |
443 | 443 | |
444 | 444 | // Default domain/path attributes |
445 | - if (empty($parsed->attributes['domain']) && !empty($origin)) { |
|
445 | + if(empty($parsed->attributes['domain']) && !empty($origin)) { |
|
446 | 446 | $parsed->attributes['domain'] = $origin->host; |
447 | 447 | $parsed->flags['host-only'] = true; |
448 | 448 | } |
@@ -451,17 +451,17 @@ discard block |
||
451 | 451 | } |
452 | 452 | |
453 | 453 | $path_is_valid = (!empty($parsed->attributes['path']) && $parsed->attributes['path'][0] === '/'); |
454 | - if (!$path_is_valid && !empty($origin)) { |
|
454 | + if(!$path_is_valid && !empty($origin)) { |
|
455 | 455 | $path = $origin->path; |
456 | 456 | |
457 | 457 | // Default path normalization as per RFC 6265 section 5.1.4 |
458 | - if (substr($path, 0, 1) !== '/') { |
|
458 | + if(substr($path, 0, 1) !== '/') { |
|
459 | 459 | // If the uri-path is empty or if the first character of |
460 | 460 | // the uri-path is not a %x2F ("/") character, output |
461 | 461 | // %x2F ("/") and skip the remaining steps. |
462 | 462 | $path = '/'; |
463 | 463 | } |
464 | - elseif (substr_count($path, '/') === 1) { |
|
464 | + elseif(substr_count($path, '/') === 1) { |
|
465 | 465 | // If the uri-path contains no more than one %x2F ("/") |
466 | 466 | // character, output %x2F ("/") and skip the remaining |
467 | 467 | // step. |
@@ -477,7 +477,7 @@ discard block |
||
477 | 477 | } |
478 | 478 | |
479 | 479 | // Reject invalid cookie domains |
480 | - if (!empty($origin) && !$parsed->domain_matches($origin->host)) { |
|
480 | + if(!empty($origin) && !$parsed->domain_matches($origin->host)) { |
|
481 | 481 | continue; |
482 | 482 | } |
483 | 483 |
@@ -12,7 +12,8 @@ discard block |
||
12 | 12 | * @package Requests |
13 | 13 | * @subpackage Cookies |
14 | 14 | */ |
15 | -class Requests_Cookie { |
|
15 | +class Requests_Cookie |
|
16 | +{ |
|
16 | 17 | /** |
17 | 18 | * Cookie name. |
18 | 19 | * |
@@ -64,7 +65,8 @@ discard block |
||
64 | 65 | * @param string $value |
65 | 66 | * @param array|Requests_Utility_CaseInsensitiveDictionary $attributes Associative array of attribute data |
66 | 67 | */ |
67 | - public function __construct($name, $value, $attributes = array(), $flags = array(), $reference_time = null) { |
|
68 | + public function __construct($name, $value, $attributes = array(), $flags = array(), $reference_time = null) |
|
69 | + { |
|
68 | 70 | $this->name = $name; |
69 | 71 | $this->value = $value; |
70 | 72 | $this->attributes = $attributes; |
@@ -77,7 +79,8 @@ discard block |
||
77 | 79 | $this->flags = array_merge($default_flags, $flags); |
78 | 80 | |
79 | 81 | $this->reference_time = time(); |
80 | - if ($reference_time !== null) { |
|
82 | + if ($reference_time !== null) |
|
83 | + { |
|
81 | 84 | $this->reference_time = $reference_time; |
82 | 85 | } |
83 | 86 | |
@@ -92,17 +95,20 @@ discard block |
||
92 | 95 | * |
93 | 96 | * @return boolean True if expired, false if time is valid. |
94 | 97 | */ |
95 | - public function is_expired() { |
|
98 | + public function is_expired() |
|
99 | + { |
|
96 | 100 | // RFC6265, s. 4.1.2.2: |
97 | 101 | // If a cookie has both the Max-Age and the Expires attribute, the Max- |
98 | 102 | // Age attribute has precedence and controls the expiration date of the |
99 | 103 | // cookie. |
100 | - if (isset($this->attributes['max-age'])) { |
|
104 | + if (isset($this->attributes['max-age'])) |
|
105 | + { |
|
101 | 106 | $max_age = $this->attributes['max-age']; |
102 | 107 | return $max_age < $this->reference_time; |
103 | 108 | } |
104 | 109 | |
105 | - if (isset($this->attributes['expires'])) { |
|
110 | + if (isset($this->attributes['expires'])) |
|
111 | + { |
|
106 | 112 | $expires = $this->attributes['expires']; |
107 | 113 | return $expires < $this->reference_time; |
108 | 114 | } |
@@ -116,12 +122,15 @@ discard block |
||
116 | 122 | * @param Requests_IRI $uri URI to check |
117 | 123 | * @return boolean Whether the cookie is valid for the given URI |
118 | 124 | */ |
119 | - public function uri_matches(Requests_IRI $uri) { |
|
120 | - if (!$this->domain_matches($uri->host)) { |
|
125 | + public function uri_matches(Requests_IRI $uri) |
|
126 | + { |
|
127 | + if (!$this->domain_matches($uri->host)) |
|
128 | + { |
|
121 | 129 | return false; |
122 | 130 | } |
123 | 131 | |
124 | - if (!$this->path_matches($uri->path)) { |
|
132 | + if (!$this->path_matches($uri->path)) |
|
133 | + { |
|
125 | 134 | return false; |
126 | 135 | } |
127 | 136 | |
@@ -134,38 +143,45 @@ discard block |
||
134 | 143 | * @param string $string Domain to check |
135 | 144 | * @return boolean Whether the cookie is valid for the given domain |
136 | 145 | */ |
137 | - public function domain_matches($string) { |
|
138 | - if (!isset($this->attributes['domain'])) { |
|
146 | + public function domain_matches($string) |
|
147 | + { |
|
148 | + if (!isset($this->attributes['domain'])) |
|
149 | + { |
|
139 | 150 | // Cookies created manually; cookies created by Requests will set |
140 | 151 | // the domain to the requested domain |
141 | 152 | return true; |
142 | 153 | } |
143 | 154 | |
144 | 155 | $domain_string = $this->attributes['domain']; |
145 | - if ($domain_string === $string) { |
|
156 | + if ($domain_string === $string) |
|
157 | + { |
|
146 | 158 | // The domain string and the string are identical. |
147 | 159 | return true; |
148 | 160 | } |
149 | 161 | |
150 | 162 | // If the cookie is marked as host-only and we don't have an exact |
151 | 163 | // match, reject the cookie |
152 | - if ($this->flags['host-only'] === true) { |
|
164 | + if ($this->flags['host-only'] === true) |
|
165 | + { |
|
153 | 166 | return false; |
154 | 167 | } |
155 | 168 | |
156 | - if (strlen($string) <= strlen($domain_string)) { |
|
169 | + if (strlen($string) <= strlen($domain_string)) |
|
170 | + { |
|
157 | 171 | // For obvious reasons, the string cannot be a suffix if the domain |
158 | 172 | // is shorter than the domain string |
159 | 173 | return false; |
160 | 174 | } |
161 | 175 | |
162 | - if (substr($string, -1 * strlen($domain_string)) !== $domain_string) { |
|
176 | + if (substr($string, -1 * strlen($domain_string)) !== $domain_string) |
|
177 | + { |
|
163 | 178 | // The domain string should be a suffix of the string. |
164 | 179 | return false; |
165 | 180 | } |
166 | 181 | |
167 | 182 | $prefix = substr($string, 0, strlen($string) - strlen($domain_string)); |
168 | - if (substr($prefix, -1) !== '.') { |
|
183 | + if (substr($prefix, -1) !== '.') |
|
184 | + { |
|
169 | 185 | // The last character of the string that is not included in the |
170 | 186 | // domain string should be a %x2E (".") character. |
171 | 187 | return false; |
@@ -183,13 +199,16 @@ discard block |
||
183 | 199 | * @param string $request_path Path to check |
184 | 200 | * @return boolean Whether the cookie is valid for the given path |
185 | 201 | */ |
186 | - public function path_matches($request_path) { |
|
187 | - if (empty($request_path)) { |
|
202 | + public function path_matches($request_path) |
|
203 | + { |
|
204 | + if (empty($request_path)) |
|
205 | + { |
|
188 | 206 | // Normalize empty path to root |
189 | 207 | $request_path = '/'; |
190 | 208 | } |
191 | 209 | |
192 | - if (!isset($this->attributes['path'])) { |
|
210 | + if (!isset($this->attributes['path'])) |
|
211 | + { |
|
193 | 212 | // Cookies created manually; cookies created by Requests will set |
194 | 213 | // the path to the requested path |
195 | 214 | return true; |
@@ -197,19 +216,23 @@ discard block |
||
197 | 216 | |
198 | 217 | $cookie_path = $this->attributes['path']; |
199 | 218 | |
200 | - if ($cookie_path === $request_path) { |
|
219 | + if ($cookie_path === $request_path) |
|
220 | + { |
|
201 | 221 | // The cookie-path and the request-path are identical. |
202 | 222 | return true; |
203 | 223 | } |
204 | 224 | |
205 | - if (strlen($request_path) > strlen($cookie_path) && substr($request_path, 0, strlen($cookie_path)) === $cookie_path) { |
|
206 | - if (substr($cookie_path, -1) === '/') { |
|
225 | + if (strlen($request_path) > strlen($cookie_path) && substr($request_path, 0, strlen($cookie_path)) === $cookie_path) |
|
226 | + { |
|
227 | + if (substr($cookie_path, -1) === '/') |
|
228 | + { |
|
207 | 229 | // The cookie-path is a prefix of the request-path, and the last |
208 | 230 | // character of the cookie-path is %x2F ("/"). |
209 | 231 | return true; |
210 | 232 | } |
211 | 233 | |
212 | - if (substr($request_path, strlen($cookie_path), 1) === '/') { |
|
234 | + if (substr($request_path, strlen($cookie_path), 1) === '/') |
|
235 | + { |
|
213 | 236 | // The cookie-path is a prefix of the request-path, and the |
214 | 237 | // first character of the request-path that is not included in |
215 | 238 | // the cookie-path is a %x2F ("/") character. |
@@ -225,16 +248,20 @@ discard block |
||
225 | 248 | * |
226 | 249 | * @return boolean Whether the cookie was successfully normalized |
227 | 250 | */ |
228 | - public function normalize() { |
|
229 | - foreach ($this->attributes as $key => $value) { |
|
251 | + public function normalize() |
|
252 | + { |
|
253 | + foreach ($this->attributes as $key => $value) |
|
254 | + { |
|
230 | 255 | $orig_value = $value; |
231 | 256 | $value = $this->normalize_attribute($key, $value); |
232 | - if ($value === null) { |
|
257 | + if ($value === null) |
|
258 | + { |
|
233 | 259 | unset($this->attributes[$key]); |
234 | 260 | continue; |
235 | 261 | } |
236 | 262 | |
237 | - if ($value !== $orig_value) { |
|
263 | + if ($value !== $orig_value) |
|
264 | + { |
|
238 | 265 | $this->attributes[$key] = $value; |
239 | 266 | } |
240 | 267 | } |
@@ -251,16 +278,20 @@ discard block |
||
251 | 278 | * @param string|boolean $value Attribute value (string value, or true if empty/flag) |
252 | 279 | * @return mixed Value if available, or null if the attribute value is invalid (and should be skipped) |
253 | 280 | */ |
254 | - protected function normalize_attribute($name, $value) { |
|
255 | - switch (strtolower($name)) { |
|
281 | + protected function normalize_attribute($name, $value) |
|
282 | + { |
|
283 | + switch (strtolower($name)) |
|
284 | + { |
|
256 | 285 | case 'expires': |
257 | 286 | // Expiration parsing, as per RFC 6265 section 5.2.1 |
258 | - if (is_int($value)) { |
|
287 | + if (is_int($value)) |
|
288 | + { |
|
259 | 289 | return $value; |
260 | 290 | } |
261 | 291 | |
262 | 292 | $expiry_time = strtotime($value); |
263 | - if ($expiry_time === false) { |
|
293 | + if ($expiry_time === false) |
|
294 | + { |
|
264 | 295 | return null; |
265 | 296 | } |
266 | 297 | |
@@ -268,20 +299,24 @@ discard block |
||
268 | 299 | |
269 | 300 | case 'max-age': |
270 | 301 | // Expiration parsing, as per RFC 6265 section 5.2.2 |
271 | - if (is_int($value)) { |
|
302 | + if (is_int($value)) |
|
303 | + { |
|
272 | 304 | return $value; |
273 | 305 | } |
274 | 306 | |
275 | 307 | // Check that we have a valid age |
276 | - if (!preg_match('/^-?\d+$/', $value)) { |
|
308 | + if (!preg_match('/^-?\d+$/', $value)) |
|
309 | + { |
|
277 | 310 | return null; |
278 | 311 | } |
279 | 312 | |
280 | 313 | $delta_seconds = (int) $value; |
281 | - if ($delta_seconds <= 0) { |
|
314 | + if ($delta_seconds <= 0) |
|
315 | + { |
|
282 | 316 | $expiry_time = 0; |
283 | 317 | } |
284 | - else { |
|
318 | + else |
|
319 | + { |
|
285 | 320 | $expiry_time = $this->reference_time + $delta_seconds; |
286 | 321 | } |
287 | 322 | |
@@ -289,7 +324,8 @@ discard block |
||
289 | 324 | |
290 | 325 | case 'domain': |
291 | 326 | // Domain normalization, as per RFC 6265 section 5.2.3 |
292 | - if ($value[0] === '.') { |
|
327 | + if ($value[0] === '.') |
|
328 | + { |
|
293 | 329 | $value = substr($value, 1); |
294 | 330 | } |
295 | 331 | |
@@ -307,7 +343,8 @@ discard block |
||
307 | 343 | * |
308 | 344 | * @return string Cookie formatted for Cookie header |
309 | 345 | */ |
310 | - public function format_for_header() { |
|
346 | + public function format_for_header() |
|
347 | + { |
|
311 | 348 | return sprintf('%s=%s', $this->name, $this->value); |
312 | 349 | } |
313 | 350 | |
@@ -318,7 +355,8 @@ discard block |
||
318 | 355 | * @deprecated Use {@see Requests_Cookie::format_for_header} |
319 | 356 | * @return string |
320 | 357 | */ |
321 | - public function formatForHeader() { |
|
358 | + public function formatForHeader() |
|
359 | + { |
|
322 | 360 | return $this->format_for_header(); |
323 | 361 | } |
324 | 362 | |
@@ -330,16 +368,21 @@ discard block |
||
330 | 368 | * |
331 | 369 | * @return string Cookie formatted for Set-Cookie header |
332 | 370 | */ |
333 | - public function format_for_set_cookie() { |
|
371 | + public function format_for_set_cookie() |
|
372 | + { |
|
334 | 373 | $header_value = $this->format_for_header(); |
335 | - if (!empty($this->attributes)) { |
|
374 | + if (!empty($this->attributes)) |
|
375 | + { |
|
336 | 376 | $parts = array(); |
337 | - foreach ($this->attributes as $key => $value) { |
|
377 | + foreach ($this->attributes as $key => $value) |
|
378 | + { |
|
338 | 379 | // Ignore non-associative attributes |
339 | - if (is_numeric($key)) { |
|
380 | + if (is_numeric($key)) |
|
381 | + { |
|
340 | 382 | $parts[] = $value; |
341 | 383 | } |
342 | - else { |
|
384 | + else |
|
385 | + { |
|
343 | 386 | $parts[] = sprintf('%s=%s', $key, $value); |
344 | 387 | } |
345 | 388 | } |
@@ -356,7 +399,8 @@ discard block |
||
356 | 399 | * @deprecated Use {@see Requests_Cookie::format_for_set_cookie} |
357 | 400 | * @return string |
358 | 401 | */ |
359 | - public function formatForSetCookie() { |
|
402 | + public function formatForSetCookie() |
|
403 | + { |
|
360 | 404 | return $this->format_for_set_cookie(); |
361 | 405 | } |
362 | 406 | |
@@ -365,7 +409,8 @@ discard block |
||
365 | 409 | * |
366 | 410 | * Attributes and other data can be accessed via methods. |
367 | 411 | */ |
368 | - public function __toString() { |
|
412 | + public function __toString() |
|
413 | + { |
|
369 | 414 | return $this->value; |
370 | 415 | } |
371 | 416 | |
@@ -379,14 +424,17 @@ discard block |
||
379 | 424 | * @param string Cookie header value (from a Set-Cookie header) |
380 | 425 | * @return Requests_Cookie Parsed cookie object |
381 | 426 | */ |
382 | - public static function parse($string, $name = '', $reference_time = null) { |
|
427 | + public static function parse($string, $name = '', $reference_time = null) |
|
428 | + { |
|
383 | 429 | $parts = explode(';', $string); |
384 | 430 | $kvparts = array_shift($parts); |
385 | 431 | |
386 | - if (!empty($name)) { |
|
432 | + if (!empty($name)) |
|
433 | + { |
|
387 | 434 | $value = $string; |
388 | 435 | } |
389 | - elseif (strpos($kvparts, '=') === false) { |
|
436 | + elseif (strpos($kvparts, '=') === false) |
|
437 | + { |
|
390 | 438 | // Some sites might only have a value without the equals separator. |
391 | 439 | // Deviate from RFC 6265 and pretend it was actually a blank name |
392 | 440 | // (`=foo`) |
@@ -395,7 +443,8 @@ discard block |
||
395 | 443 | $name = ''; |
396 | 444 | $value = $kvparts; |
397 | 445 | } |
398 | - else { |
|
446 | + else |
|
447 | + { |
|
399 | 448 | list($name, $value) = explode('=', $kvparts, 2); |
400 | 449 | } |
401 | 450 | $name = trim($name); |
@@ -404,13 +453,17 @@ discard block |
||
404 | 453 | // Attribute key are handled case-insensitively |
405 | 454 | $attributes = new Requests_Utility_CaseInsensitiveDictionary(); |
406 | 455 | |
407 | - if (!empty($parts)) { |
|
408 | - foreach ($parts as $part) { |
|
409 | - if (strpos($part, '=') === false) { |
|
456 | + if (!empty($parts)) |
|
457 | + { |
|
458 | + foreach ($parts as $part) |
|
459 | + { |
|
460 | + if (strpos($part, '=') === false) |
|
461 | + { |
|
410 | 462 | $part_key = $part; |
411 | 463 | $part_value = true; |
412 | 464 | } |
413 | - else { |
|
465 | + else |
|
466 | + { |
|
414 | 467 | list($part_key, $part_value) = explode('=', $part, 2); |
415 | 468 | $part_value = trim($part_value); |
416 | 469 | } |
@@ -431,43 +484,52 @@ discard block |
||
431 | 484 | * @param int|null $time Reference time for expiration calculation |
432 | 485 | * @return array |
433 | 486 | */ |
434 | - public static function parse_from_headers(Requests_Response_Headers $headers, Requests_IRI $origin = null, $time = null) { |
|
487 | + public static function parse_from_headers(Requests_Response_Headers $headers, Requests_IRI $origin = null, $time = null) |
|
488 | + { |
|
435 | 489 | $cookie_headers = $headers->getValues('Set-Cookie'); |
436 | - if (empty($cookie_headers)) { |
|
490 | + if (empty($cookie_headers)) |
|
491 | + { |
|
437 | 492 | return array(); |
438 | 493 | } |
439 | 494 | |
440 | 495 | $cookies = array(); |
441 | - foreach ($cookie_headers as $header) { |
|
496 | + foreach ($cookie_headers as $header) |
|
497 | + { |
|
442 | 498 | $parsed = self::parse($header, '', $time); |
443 | 499 | |
444 | 500 | // Default domain/path attributes |
445 | - if (empty($parsed->attributes['domain']) && !empty($origin)) { |
|
501 | + if (empty($parsed->attributes['domain']) && !empty($origin)) |
|
502 | + { |
|
446 | 503 | $parsed->attributes['domain'] = $origin->host; |
447 | 504 | $parsed->flags['host-only'] = true; |
448 | 505 | } |
449 | - else { |
|
506 | + else |
|
507 | + { |
|
450 | 508 | $parsed->flags['host-only'] = false; |
451 | 509 | } |
452 | 510 | |
453 | 511 | $path_is_valid = (!empty($parsed->attributes['path']) && $parsed->attributes['path'][0] === '/'); |
454 | - if (!$path_is_valid && !empty($origin)) { |
|
512 | + if (!$path_is_valid && !empty($origin)) |
|
513 | + { |
|
455 | 514 | $path = $origin->path; |
456 | 515 | |
457 | 516 | // Default path normalization as per RFC 6265 section 5.1.4 |
458 | - if (substr($path, 0, 1) !== '/') { |
|
517 | + if (substr($path, 0, 1) !== '/') |
|
518 | + { |
|
459 | 519 | // If the uri-path is empty or if the first character of |
460 | 520 | // the uri-path is not a %x2F ("/") character, output |
461 | 521 | // %x2F ("/") and skip the remaining steps. |
462 | 522 | $path = '/'; |
463 | 523 | } |
464 | - elseif (substr_count($path, '/') === 1) { |
|
524 | + elseif (substr_count($path, '/') === 1) |
|
525 | + { |
|
465 | 526 | // If the uri-path contains no more than one %x2F ("/") |
466 | 527 | // character, output %x2F ("/") and skip the remaining |
467 | 528 | // step. |
468 | 529 | $path = '/'; |
469 | 530 | } |
470 | - else { |
|
531 | + else |
|
532 | + { |
|
471 | 533 | // Output the characters of the uri-path from the first |
472 | 534 | // character up to, but not including, the right-most |
473 | 535 | // %x2F ("/"). |
@@ -477,7 +539,8 @@ discard block |
||
477 | 539 | } |
478 | 540 | |
479 | 541 | // Reject invalid cookie domains |
480 | - if (!empty($origin) && !$parsed->domain_matches($origin->host)) { |
|
542 | + if (!empty($origin) && !$parsed->domain_matches($origin->host)) |
|
543 | + { |
|
481 | 544 | continue; |
482 | 545 | } |
483 | 546 | |
@@ -494,7 +557,8 @@ discard block |
||
494 | 557 | * @deprecated Use {@see Requests_Cookie::parse_from_headers} |
495 | 558 | * @return string |
496 | 559 | */ |
497 | - public static function parseFromHeaders(Requests_Response_Headers $headers) { |
|
560 | + public static function parseFromHeaders(Requests_Response_Headers $headers) |
|
561 | + { |
|
498 | 562 | return self::parse_from_headers($headers); |
499 | 563 | } |
500 | 564 | } |
@@ -64,20 +64,20 @@ discard block |
||
64 | 64 | * @param string $value |
65 | 65 | * @param array|Requests_Utility_CaseInsensitiveDictionary $attributes Associative array of attribute data |
66 | 66 | */ |
67 | - public function __construct($name, $value, $attributes = array(), $flags = array(), $reference_time = null) { |
|
67 | + public function __construct($name, $value, $attributes = array(), $flags = array(), $reference_time = NULL) { |
|
68 | 68 | $this->name = $name; |
69 | 69 | $this->value = $value; |
70 | 70 | $this->attributes = $attributes; |
71 | 71 | $default_flags = array( |
72 | 72 | 'creation' => time(), |
73 | 73 | 'last-access' => time(), |
74 | - 'persistent' => false, |
|
75 | - 'host-only' => true, |
|
74 | + 'persistent' => FALSE, |
|
75 | + 'host-only' => TRUE, |
|
76 | 76 | ); |
77 | 77 | $this->flags = array_merge($default_flags, $flags); |
78 | 78 | |
79 | 79 | $this->reference_time = time(); |
80 | - if ($reference_time !== null) { |
|
80 | + if ($reference_time !== NULL) { |
|
81 | 81 | $this->reference_time = $reference_time; |
82 | 82 | } |
83 | 83 | |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | return $expires < $this->reference_time; |
108 | 108 | } |
109 | 109 | |
110 | - return false; |
|
110 | + return FALSE; |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | /** |
@@ -118,11 +118,11 @@ discard block |
||
118 | 118 | */ |
119 | 119 | public function uri_matches(Requests_IRI $uri) { |
120 | 120 | if (!$this->domain_matches($uri->host)) { |
121 | - return false; |
|
121 | + return FALSE; |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | if (!$this->path_matches($uri->path)) { |
125 | - return false; |
|
125 | + return FALSE; |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | return empty($this->attributes['secure']) || $uri->scheme === 'https'; |
@@ -138,37 +138,37 @@ discard block |
||
138 | 138 | if (!isset($this->attributes['domain'])) { |
139 | 139 | // Cookies created manually; cookies created by Requests will set |
140 | 140 | // the domain to the requested domain |
141 | - return true; |
|
141 | + return TRUE; |
|
142 | 142 | } |
143 | 143 | |
144 | 144 | $domain_string = $this->attributes['domain']; |
145 | 145 | if ($domain_string === $string) { |
146 | 146 | // The domain string and the string are identical. |
147 | - return true; |
|
147 | + return TRUE; |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | // If the cookie is marked as host-only and we don't have an exact |
151 | 151 | // match, reject the cookie |
152 | - if ($this->flags['host-only'] === true) { |
|
153 | - return false; |
|
152 | + if ($this->flags['host-only'] === TRUE) { |
|
153 | + return FALSE; |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | if (strlen($string) <= strlen($domain_string)) { |
157 | 157 | // For obvious reasons, the string cannot be a suffix if the domain |
158 | 158 | // is shorter than the domain string |
159 | - return false; |
|
159 | + return FALSE; |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | if (substr($string, -1 * strlen($domain_string)) !== $domain_string) { |
163 | 163 | // The domain string should be a suffix of the string. |
164 | - return false; |
|
164 | + return FALSE; |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | $prefix = substr($string, 0, strlen($string) - strlen($domain_string)); |
168 | 168 | if (substr($prefix, -1) !== '.') { |
169 | 169 | // The last character of the string that is not included in the |
170 | 170 | // domain string should be a %x2E (".") character. |
171 | - return false; |
|
171 | + return FALSE; |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | // The string should be a host name (i.e., not an IP address). |
@@ -192,32 +192,32 @@ discard block |
||
192 | 192 | if (!isset($this->attributes['path'])) { |
193 | 193 | // Cookies created manually; cookies created by Requests will set |
194 | 194 | // the path to the requested path |
195 | - return true; |
|
195 | + return TRUE; |
|
196 | 196 | } |
197 | 197 | |
198 | 198 | $cookie_path = $this->attributes['path']; |
199 | 199 | |
200 | 200 | if ($cookie_path === $request_path) { |
201 | 201 | // The cookie-path and the request-path are identical. |
202 | - return true; |
|
202 | + return TRUE; |
|
203 | 203 | } |
204 | 204 | |
205 | 205 | if (strlen($request_path) > strlen($cookie_path) && substr($request_path, 0, strlen($cookie_path)) === $cookie_path) { |
206 | 206 | if (substr($cookie_path, -1) === '/') { |
207 | 207 | // The cookie-path is a prefix of the request-path, and the last |
208 | 208 | // character of the cookie-path is %x2F ("/"). |
209 | - return true; |
|
209 | + return TRUE; |
|
210 | 210 | } |
211 | 211 | |
212 | 212 | if (substr($request_path, strlen($cookie_path), 1) === '/') { |
213 | 213 | // The cookie-path is a prefix of the request-path, and the |
214 | 214 | // first character of the request-path that is not included in |
215 | 215 | // the cookie-path is a %x2F ("/") character. |
216 | - return true; |
|
216 | + return TRUE; |
|
217 | 217 | } |
218 | 218 | } |
219 | 219 | |
220 | - return false; |
|
220 | + return FALSE; |
|
221 | 221 | } |
222 | 222 | |
223 | 223 | /** |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | foreach ($this->attributes as $key => $value) { |
230 | 230 | $orig_value = $value; |
231 | 231 | $value = $this->normalize_attribute($key, $value); |
232 | - if ($value === null) { |
|
232 | + if ($value === NULL) { |
|
233 | 233 | unset($this->attributes[$key]); |
234 | 234 | continue; |
235 | 235 | } |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | } |
240 | 240 | } |
241 | 241 | |
242 | - return true; |
|
242 | + return TRUE; |
|
243 | 243 | } |
244 | 244 | |
245 | 245 | /** |
@@ -260,8 +260,8 @@ discard block |
||
260 | 260 | } |
261 | 261 | |
262 | 262 | $expiry_time = strtotime($value); |
263 | - if ($expiry_time === false) { |
|
264 | - return null; |
|
263 | + if ($expiry_time === FALSE) { |
|
264 | + return NULL; |
|
265 | 265 | } |
266 | 266 | |
267 | 267 | return $expiry_time; |
@@ -274,7 +274,7 @@ discard block |
||
274 | 274 | |
275 | 275 | // Check that we have a valid age |
276 | 276 | if (!preg_match('/^-?\d+$/', $value)) { |
277 | - return null; |
|
277 | + return NULL; |
|
278 | 278 | } |
279 | 279 | |
280 | 280 | $delta_seconds = (int) $value; |
@@ -379,14 +379,14 @@ discard block |
||
379 | 379 | * @param string Cookie header value (from a Set-Cookie header) |
380 | 380 | * @return Requests_Cookie Parsed cookie object |
381 | 381 | */ |
382 | - public static function parse($string, $name = '', $reference_time = null) { |
|
382 | + public static function parse($string, $name = '', $reference_time = NULL) { |
|
383 | 383 | $parts = explode(';', $string); |
384 | 384 | $kvparts = array_shift($parts); |
385 | 385 | |
386 | 386 | if (!empty($name)) { |
387 | 387 | $value = $string; |
388 | 388 | } |
389 | - elseif (strpos($kvparts, '=') === false) { |
|
389 | + elseif (strpos($kvparts, '=') === FALSE) { |
|
390 | 390 | // Some sites might only have a value without the equals separator. |
391 | 391 | // Deviate from RFC 6265 and pretend it was actually a blank name |
392 | 392 | // (`=foo`) |
@@ -406,9 +406,9 @@ discard block |
||
406 | 406 | |
407 | 407 | if (!empty($parts)) { |
408 | 408 | foreach ($parts as $part) { |
409 | - if (strpos($part, '=') === false) { |
|
409 | + if (strpos($part, '=') === FALSE) { |
|
410 | 410 | $part_key = $part; |
411 | - $part_value = true; |
|
411 | + $part_value = TRUE; |
|
412 | 412 | } |
413 | 413 | else { |
414 | 414 | list($part_key, $part_value) = explode('=', $part, 2); |
@@ -431,7 +431,7 @@ discard block |
||
431 | 431 | * @param int|null $time Reference time for expiration calculation |
432 | 432 | * @return array |
433 | 433 | */ |
434 | - public static function parse_from_headers(Requests_Response_Headers $headers, Requests_IRI $origin = null, $time = null) { |
|
434 | + public static function parse_from_headers(Requests_Response_Headers $headers, Requests_IRI $origin = NULL, $time = NULL) { |
|
435 | 435 | $cookie_headers = $headers->getValues('Set-Cookie'); |
436 | 436 | if (empty($cookie_headers)) { |
437 | 437 | return array(); |
@@ -444,10 +444,10 @@ discard block |
||
444 | 444 | // Default domain/path attributes |
445 | 445 | if (empty($parsed->attributes['domain']) && !empty($origin)) { |
446 | 446 | $parsed->attributes['domain'] = $origin->host; |
447 | - $parsed->flags['host-only'] = true; |
|
447 | + $parsed->flags['host-only'] = TRUE; |
|
448 | 448 | } |
449 | 449 | else { |
450 | - $parsed->flags['host-only'] = false; |
|
450 | + $parsed->flags['host-only'] = FALSE; |
|
451 | 451 | } |
452 | 452 | |
453 | 453 | $path_is_valid = (!empty($parsed->attributes['path']) && $parsed->attributes['path'][0] === '/'); |
@@ -29,6 +29,9 @@ |
||
29 | 29 | */ |
30 | 30 | protected $reason = 'Unknown'; |
31 | 31 | |
32 | + /** |
|
33 | + * @param string $message |
|
34 | + */ |
|
32 | 35 | public function __construct($message, $type, $data = null, $code = 0) { |
33 | 36 | if ($type !== null) { |
34 | 37 | $this->type = $type; |
@@ -30,15 +30,15 @@ |
||
30 | 30 | protected $reason = 'Unknown'; |
31 | 31 | |
32 | 32 | public function __construct($message, $type, $data = null, $code = 0) { |
33 | - if ($type !== null) { |
|
33 | + if($type !== null) { |
|
34 | 34 | $this->type = $type; |
35 | 35 | } |
36 | 36 | |
37 | - if ($code !== null) { |
|
37 | + if($code !== null) { |
|
38 | 38 | $this->code = $code; |
39 | 39 | } |
40 | 40 | |
41 | - if ($message !== null) { |
|
41 | + if($message !== null) { |
|
42 | 42 | $this->reason = $message; |
43 | 43 | } |
44 | 44 |
@@ -1,6 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -class Requests_Exception_Transport_cURL extends Requests_Exception_Transport { |
|
3 | +class Requests_Exception_Transport_cURL extends Requests_Exception_Transport |
|
4 | +{ |
|
4 | 5 | |
5 | 6 | const EASY = 'cURLEasy'; |
6 | 7 | const MULTI = 'cURLMulti'; |
@@ -29,16 +30,20 @@ discard block |
||
29 | 30 | */ |
30 | 31 | protected $reason = 'Unknown'; |
31 | 32 | |
32 | - public function __construct($message, $type, $data = null, $code = 0) { |
|
33 | - if ($type !== null) { |
|
33 | + public function __construct($message, $type, $data = null, $code = 0) |
|
34 | + { |
|
35 | + if ($type !== null) |
|
36 | + { |
|
34 | 37 | $this->type = $type; |
35 | 38 | } |
36 | 39 | |
37 | - if ($code !== null) { |
|
40 | + if ($code !== null) |
|
41 | + { |
|
38 | 42 | $this->code = $code; |
39 | 43 | } |
40 | 44 | |
41 | - if ($message !== null) { |
|
45 | + if ($message !== null) |
|
46 | + { |
|
42 | 47 | $this->reason = $message; |
43 | 48 | } |
44 | 49 | |
@@ -49,7 +54,8 @@ discard block |
||
49 | 54 | /** |
50 | 55 | * Get the error message |
51 | 56 | */ |
52 | - public function getReason() { |
|
57 | + public function getReason() |
|
58 | + { |
|
53 | 59 | return $this->reason; |
54 | 60 | } |
55 | 61 |
@@ -29,16 +29,16 @@ |
||
29 | 29 | */ |
30 | 30 | protected $reason = 'Unknown'; |
31 | 31 | |
32 | - public function __construct($message, $type, $data = null, $code = 0) { |
|
33 | - if ($type !== null) { |
|
32 | + public function __construct($message, $type, $data = NULL, $code = 0) { |
|
33 | + if ($type !== NULL) { |
|
34 | 34 | $this->type = $type; |
35 | 35 | } |
36 | 36 | |
37 | - if ($code !== null) { |
|
37 | + if ($code !== NULL) { |
|
38 | 38 | $this->code = $code; |
39 | 39 | } |
40 | 40 | |
41 | - if ($message !== null) { |
|
41 | + if ($message !== NULL) { |
|
42 | 42 | $this->reason = $message; |
43 | 43 | } |
44 | 44 |
@@ -19,6 +19,7 @@ |
||
19 | 19 | * @param string $hook Hook name |
20 | 20 | * @param callback $callback Function/method to call on event |
21 | 21 | * @param int $priority Priority number. <0 is executed earlier, >0 is executed later |
22 | + * @return void |
|
22 | 23 | */ |
23 | 24 | public function register($hook, $callback, $priority = 0); |
24 | 25 |
@@ -12,7 +12,8 @@ |
||
12 | 12 | * @package Requests |
13 | 13 | * @subpackage Utilities |
14 | 14 | */ |
15 | -interface Requests_Hooker { |
|
15 | +interface Requests_Hooker |
|
16 | +{ |
|
16 | 17 | /** |
17 | 18 | * Register a callback for a hook |
18 | 19 | * |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | $accessToken; |
15 | 15 | $newPostionStatus; |
16 | 16 | |
17 | - if ($result->num_rows > 0) |
|
17 | + if($result->num_rows > 0) |
|
18 | 18 | { |
19 | 19 | // output data of each row |
20 | 20 | while($row = $result->fetch_assoc()) |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | <a href="index.php"> |
114 | 114 | <h1> |
115 | 115 | Jodel WebClient |
116 | - <?php if(!isset($_GET['postID']) && !isset($_GET['getPostDetails'])) echo '<i class="fa fa-refresh fa-1x"></i>';?> |
|
116 | + <?php if(!isset($_GET['postID']) && !isset($_GET['getPostDetails'])) echo '<i class="fa fa-refresh fa-1x"></i>'; ?> |
|
117 | 117 | </h1> |
118 | 118 | </a> |
119 | 119 | <div class="clear"></div> |
@@ -131,11 +131,11 @@ discard block |
||
131 | 131 | if(isset($_GET['postID']) && isset($_GET['getPostDetails'])) { |
132 | 132 | //Header Nav in Comment View |
133 | 133 | ?> |
134 | - <a id="comment-back" href="index.php#postId-<?php echo $_GET['postID'];?>"> |
|
134 | + <a id="comment-back" href="index.php#postId-<?php echo $_GET['postID']; ?>"> |
|
135 | 135 | <i class="fa fa-angle-left fa-3x"></i> |
136 | 136 | </a> |
137 | 137 | |
138 | - <a id="comment-refresh" href="index.php?getPostDetails=<?php echo $_GET['getPostDetails'];?>&postID=<?php echo $_GET['postID'];?>"> |
|
138 | + <a id="comment-refresh" href="index.php?getPostDetails=<?php echo $_GET['getPostDetails']; ?>&postID=<?php echo $_GET['postID']; ?>"> |
|
139 | 139 | <i class="fa fa-refresh fa-2x"></i> |
140 | 140 | </a> |
141 | 141 | <?php |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | } |
183 | 183 | |
184 | 184 | |
185 | - for($i = 0; $i<$loops; $i++) { |
|
185 | + for($i = 0; $i < $loops; $i++) { |
|
186 | 186 | |
187 | 187 | if(isset($posts[$i])) { |
188 | 188 | $lastPostId = $posts[$i]['post_id']; |
@@ -200,24 +200,24 @@ discard block |
||
200 | 200 | $timediff_inHours = (string)$timediff->format('%h'); |
201 | 201 | $timediff_inDays = (string)$timediff->format('%d'); |
202 | 202 | $timediff_inMonth = (string)$timediff->format('%m'); |
203 | - if($timediff_inMonth!=0) { |
|
203 | + if($timediff_inMonth != 0) { |
|
204 | 204 | $timediff = $timediff_inMonth . "m"; |
205 | 205 | } |
206 | 206 | else |
207 | 207 | { |
208 | - if($timediff_inDays!=0) |
|
208 | + if($timediff_inDays != 0) |
|
209 | 209 | { |
210 | 210 | $timediff = $timediff_inDays . "d"; |
211 | 211 | } |
212 | 212 | else |
213 | 213 | { |
214 | - if($timediff_inHours!=0) |
|
214 | + if($timediff_inHours != 0) |
|
215 | 215 | { |
216 | 216 | $timediff = $timediff_inHours . "h"; |
217 | 217 | } |
218 | 218 | else |
219 | 219 | { |
220 | - if($timediff_inMinutes!=0) |
|
220 | + if($timediff_inMinutes != 0) |
|
221 | 221 | { |
222 | 222 | $timediff = $timediff_inMinutes . "m"; |
223 | 223 | } |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | } |
231 | 231 | ?> |
232 | 232 | |
233 | - <article id ="postId-<?php echo $posts[$i]["post_id"]; ?>" class="jodel" style="background-color: #<?php echo $posts[$i]["color"];?>;"> |
|
233 | + <article id ="postId-<?php echo $posts[$i]["post_id"]; ?>" class="jodel" style="background-color: #<?php echo $posts[$i]["color"]; ?>;"> |
|
234 | 234 | <content> |
235 | 235 | <?php |
236 | 236 | if(isset($posts[$i]["image_url"])) { |
@@ -242,12 +242,12 @@ discard block |
||
242 | 242 | ?> |
243 | 243 | </content> |
244 | 244 | <aside> |
245 | - <a href="index.php?vote=up&postID=<?php echo $posts[$i]["post_id"];?>"> |
|
245 | + <a href="index.php?vote=up&postID=<?php echo $posts[$i]["post_id"]; ?>"> |
|
246 | 246 | <i class="fa fa-angle-up fa-3x"></i> |
247 | 247 | </a> |
248 | 248 | <br /> |
249 | - <?php echo $posts[$i]["vote_count"];?><br /> |
|
250 | - <a href="index.php?vote=down&postID=<?php echo $posts[$i]["post_id"];?>"> |
|
249 | + <?php echo $posts[$i]["vote_count"]; ?><br /> |
|
250 | + <a href="index.php?vote=down&postID=<?php echo $posts[$i]["post_id"]; ?>"> |
|
251 | 251 | <i class="fa fa-angle-down fa-3x"></i> |
252 | 252 | </a> |
253 | 253 | </aside> |
@@ -258,13 +258,13 @@ discard block |
||
258 | 258 | <td class="time"> |
259 | 259 | <span data-tooltip="Time"> |
260 | 260 | <i class="fa fa-clock-o"></i> |
261 | - <?php echo $timediff;?> |
|
261 | + <?php echo $timediff; ?> |
|
262 | 262 | </span> |
263 | 263 | </td> |
264 | 264 | <td class="comments"> |
265 | 265 | <?php if($showCommentIcon) {?> |
266 | 266 | <span data-tooltip="Comments"> |
267 | - <a href="index.php?getPostDetails=true&postID=<?php echo $posts[$i]["post_id"];?>"> |
|
267 | + <a href="index.php?getPostDetails=true&postID=<?php echo $posts[$i]["post_id"]; ?>"> |
|
268 | 268 | <i class="fa fa-commenting-o"></i> |
269 | 269 | <?php if(array_key_exists("child_count", $posts[$i])) { |
270 | 270 | echo $posts[$i]["child_count"]; |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | <td class="distance"> |
278 | 278 | <span data-tooltip="Distance"> |
279 | 279 | <i class="fa fa-map-marker"></i> |
280 | - <?php echo $posts[$i]["distance"];?> km |
|
280 | + <?php echo $posts[$i]["distance"]; ?> km |
|
281 | 281 | </span> |
282 | 282 | </td> |
283 | 283 | </tr> |
@@ -298,9 +298,9 @@ discard block |
||
298 | 298 | </p> |
299 | 299 | <?php } ?> |
300 | 300 | <nav id="sortJodelBy"> |
301 | - <a href="index.php" <?php if(isset($timeView)) echo 'class="active"';?>><i class="fa fa-clock-o fa-3x"></i></a> |
|
302 | - <a href="index.php?commentView=true" <?php if(isset($commentView)) echo 'class="active"';?>><i class="fa fa-commenting-o fa-3x"></i></a> |
|
303 | - <a href="index.php?upVoteView=true" <?php if(isset($upVoteView)) echo 'class="active"';?>><i class="fa fa-angle-up fa-3x"></i></a> |
|
301 | + <a href="index.php" <?php if(isset($timeView)) echo 'class="active"'; ?>><i class="fa fa-clock-o fa-3x"></i></a> |
|
302 | + <a href="index.php?commentView=true" <?php if(isset($commentView)) echo 'class="active"'; ?>><i class="fa fa-commenting-o fa-3x"></i></a> |
|
303 | + <a href="index.php?upVoteView=true" <?php if(isset($upVoteView)) echo 'class="active"'; ?>><i class="fa fa-angle-up fa-3x"></i></a> |
|
304 | 304 | </nav> |
305 | 305 | </div> |
306 | 306 | |
@@ -324,7 +324,7 @@ discard block |
||
324 | 324 | <?php if(isset($_GET['postID']) && isset($_GET['getPostDetails'])) { ?> |
325 | 325 | <h2>Comment on Jodel</h2> |
326 | 326 | <form method="POST"> |
327 | - <input type="hidden" name="ancestor" value="<?php echo $_GET['postID'];?>" /> |
|
327 | + <input type="hidden" name="ancestor" value="<?php echo $_GET['postID']; ?>" /> |
|
328 | 328 | <textarea id="message" name="message" placeholder="Send a comment on a Jodel to all students within 10km" required></textarea> |
329 | 329 | <br /> |
330 | 330 | <input type="submit" value="SEND" /> |
@@ -31,7 +31,8 @@ discard block |
||
31 | 31 | //createAccount(); |
32 | 32 | |
33 | 33 | //Set Location |
34 | - if(isset($_GET['city'])) { |
|
34 | + if(isset($_GET['city'])) |
|
35 | + { |
|
35 | 36 | |
36 | 37 | $url = 'https://maps.googleapis.com/maps/api/geocode/json?address=' . $_GET['city'] . '&key=AIzaSyCwhnja-or07012HqrhPW7prHEDuSvFT4w'; |
37 | 38 | $result = Requests::post($url); |
@@ -53,11 +54,14 @@ discard block |
||
53 | 54 | } |
54 | 55 | |
55 | 56 | //Vote |
56 | - if(isset($_GET['vote']) && isset($_GET['postID'])) { |
|
57 | - if($_GET['vote'] == "up") { |
|
57 | + if(isset($_GET['vote']) && isset($_GET['postID'])) |
|
58 | + { |
|
59 | + if($_GET['vote'] == "up") |
|
60 | + { |
|
58 | 61 | $accountCreator = new Upvote(); |
59 | 62 | } |
60 | - else if($_GET['vote'] == "down") { |
|
63 | + else if($_GET['vote'] == "down") |
|
64 | + { |
|
61 | 65 | $accountCreator = new Downvote(); |
62 | 66 | } |
63 | 67 | $accountCreator->setAccessToken($accessToken); |
@@ -69,7 +73,8 @@ discard block |
||
69 | 73 | |
70 | 74 | |
71 | 75 | //SendJodel |
72 | - if(isset($_POST['message'])) { |
|
76 | + if(isset($_POST['message'])) |
|
77 | + { |
|
73 | 78 | $ancestor; |
74 | 79 | if(isset($_POST['ancestor'])) |
75 | 80 | { |
@@ -113,7 +118,11 @@ discard block |
||
113 | 118 | <a href="index.php"> |
114 | 119 | <h1> |
115 | 120 | Jodel WebClient |
116 | - <?php if(!isset($_GET['postID']) && !isset($_GET['getPostDetails'])) echo '<i class="fa fa-refresh fa-1x"></i>';?> |
|
121 | + <?php if(!isset($_GET['postID']) && !isset($_GET['getPostDetails'])) |
|
122 | +{ |
|
123 | + echo '<i class="fa fa-refresh fa-1x"></i>'; |
|
124 | +} |
|
125 | +?> |
|
117 | 126 | </h1> |
118 | 127 | </a> |
119 | 128 | <div class="clear"></div> |
@@ -128,7 +137,8 @@ discard block |
||
128 | 137 | $posts; |
129 | 138 | |
130 | 139 | //Get Post Details |
131 | - if(isset($_GET['postID']) && isset($_GET['getPostDetails'])) { |
|
140 | + if(isset($_GET['postID']) && isset($_GET['getPostDetails'])) |
|
141 | + { |
|
132 | 142 | //Header Nav in Comment View |
133 | 143 | ?> |
134 | 144 | <a id="comment-back" href="index.php#postId-<?php echo $_GET['postID'];?>"> |
@@ -146,17 +156,22 @@ discard block |
||
146 | 156 | $data = $accountCreator->execute(); |
147 | 157 | |
148 | 158 | $posts[0] = $data; |
149 | - if(isset($data['children'])) { |
|
150 | - foreach($data['children'] as $child) { |
|
159 | + if(isset($data['children'])) |
|
160 | + { |
|
161 | + foreach($data['children'] as $child) |
|
162 | + { |
|
151 | 163 | array_push($posts, $child); |
152 | 164 | } |
153 | 165 | $loops = $data['child_count'] + 1; |
154 | 166 | } |
155 | - else $loops = 1; |
|
167 | + else { |
|
168 | + $loops = 1; |
|
169 | + } |
|
156 | 170 | $showCommentIcon = FALSE; |
157 | 171 | } |
158 | 172 | //Get Posts |
159 | - else { |
|
173 | + else |
|
174 | + { |
|
160 | 175 | if(isset($_GET['commentView'])) |
161 | 176 | { |
162 | 177 | $commentView = true; |
@@ -182,9 +197,11 @@ discard block |
||
182 | 197 | } |
183 | 198 | |
184 | 199 | |
185 | - for($i = 0; $i<$loops; $i++) { |
|
200 | + for($i = 0; $i<$loops; $i++) |
|
201 | + { |
|
186 | 202 | |
187 | - if(isset($posts[$i])) { |
|
203 | + if(isset($posts[$i])) |
|
204 | + { |
|
188 | 205 | $lastPostId = $posts[$i]['post_id']; |
189 | 206 | |
190 | 207 | |
@@ -200,7 +217,8 @@ discard block |
||
200 | 217 | $timediff_inHours = (string)$timediff->format('%h'); |
201 | 218 | $timediff_inDays = (string)$timediff->format('%d'); |
202 | 219 | $timediff_inMonth = (string)$timediff->format('%m'); |
203 | - if($timediff_inMonth!=0) { |
|
220 | + if($timediff_inMonth!=0) |
|
221 | + { |
|
204 | 222 | $timediff = $timediff_inMonth . "m"; |
205 | 223 | } |
206 | 224 | else |
@@ -233,10 +251,12 @@ discard block |
||
233 | 251 | <article id ="postId-<?php echo $posts[$i]["post_id"]; ?>" class="jodel" style="background-color: #<?php echo $posts[$i]["color"];?>;"> |
234 | 252 | <content> |
235 | 253 | <?php |
236 | - if(isset($posts[$i]["image_url"])) { |
|
254 | + if(isset($posts[$i]["image_url"])) |
|
255 | + { |
|
237 | 256 | echo '<img src="' . $posts[$i]["image_url"] . '">'; |
238 | 257 | } |
239 | - else { |
|
258 | + else |
|
259 | + { |
|
240 | 260 | echo nl2br($posts[$i]["message"]); |
241 | 261 | } |
242 | 262 | ?> |
@@ -262,13 +282,19 @@ discard block |
||
262 | 282 | </span> |
263 | 283 | </td> |
264 | 284 | <td class="comments"> |
265 | - <?php if($showCommentIcon) {?> |
|
285 | + <?php if($showCommentIcon) |
|
286 | +{ |
|
287 | +?> |
|
266 | 288 | <span data-tooltip="Comments"> |
267 | 289 | <a href="index.php?getPostDetails=true&postID=<?php echo $posts[$i]["post_id"];?>"> |
268 | 290 | <i class="fa fa-commenting-o"></i> |
269 | - <?php if(array_key_exists("child_count", $posts[$i])) { |
|
291 | + <?php if(array_key_exists("child_count", $posts[$i])) |
|
292 | +{ |
|
270 | 293 | echo $posts[$i]["child_count"]; |
271 | - } else echo "0"; |
|
294 | + } |
|
295 | + else { |
|
296 | + echo "0"; |
|
297 | + } |
|
272 | 298 | ?> |
273 | 299 | </a> |
274 | 300 | </span> |
@@ -292,15 +318,29 @@ discard block |
||
292 | 318 | </content> |
293 | 319 | |
294 | 320 | </article> |
295 | - <?php if(!isset($_GET['postID']) && !isset($_GET['getPostDetails'])) { ?> |
|
321 | + <?php if(!isset($_GET['postID']) && !isset($_GET['getPostDetails'])) |
|
322 | +{ |
|
323 | +?> |
|
296 | 324 | <p id="loading"> |
297 | 325 | <img src="images/loading.gif" alt="Loading…" /> |
298 | 326 | </p> |
299 | 327 | <?php } ?> |
300 | 328 | <nav id="sortJodelBy"> |
301 | - <a href="index.php" <?php if(isset($timeView)) echo 'class="active"';?>><i class="fa fa-clock-o fa-3x"></i></a> |
|
302 | - <a href="index.php?commentView=true" <?php if(isset($commentView)) echo 'class="active"';?>><i class="fa fa-commenting-o fa-3x"></i></a> |
|
303 | - <a href="index.php?upVoteView=true" <?php if(isset($upVoteView)) echo 'class="active"';?>><i class="fa fa-angle-up fa-3x"></i></a> |
|
329 | + <a href="index.php" <?php if(isset($timeView)) |
|
330 | +{ |
|
331 | + echo 'class="active"'; |
|
332 | +} |
|
333 | +?>><i class="fa fa-clock-o fa-3x"></i></a> |
|
334 | + <a href="index.php?commentView=true" <?php if(isset($commentView)) |
|
335 | +{ |
|
336 | + echo 'class="active"'; |
|
337 | +} |
|
338 | +?>><i class="fa fa-commenting-o fa-3x"></i></a> |
|
339 | + <a href="index.php?upVoteView=true" <?php if(isset($upVoteView)) |
|
340 | +{ |
|
341 | + echo 'class="active"'; |
|
342 | +} |
|
343 | +?>><i class="fa fa-angle-up fa-3x"></i></a> |
|
304 | 344 | </nav> |
305 | 345 | </div> |
306 | 346 | |
@@ -308,7 +348,14 @@ discard block |
||
308 | 348 | <article> |
309 | 349 | <h3>Position</h3> |
310 | 350 | <form method="get"> |
311 | - <input type="text" id="city" name="city" placeholder="<?php if(isset($newPositionStatus)) echo $newPositionStatus; else echo $posts[0]["location"]["name"]; ?>" required> |
|
351 | + <input type="text" id="city" name="city" placeholder="<?php if(isset($newPositionStatus)) |
|
352 | +{ |
|
353 | + echo $newPositionStatus; |
|
354 | +} |
|
355 | +else { |
|
356 | + echo $posts[0]["location"]["name"]; |
|
357 | +} |
|
358 | +?>" required> |
|
312 | 359 | |
313 | 360 | <input type="submit" value="Set Location" /> |
314 | 361 | </form> |
@@ -321,7 +368,9 @@ discard block |
||
321 | 368 | </article> |
322 | 369 | |
323 | 370 | <article> |
324 | - <?php if(isset($_GET['postID']) && isset($_GET['getPostDetails'])) { ?> |
|
371 | + <?php if(isset($_GET['postID']) && isset($_GET['getPostDetails'])) |
|
372 | +{ |
|
373 | +?> |
|
325 | 374 | <h2>Comment on Jodel</h2> |
326 | 375 | <form method="POST"> |
327 | 376 | <input type="hidden" name="ancestor" value="<?php echo $_GET['postID'];?>" /> |
@@ -329,7 +378,10 @@ discard block |
||
329 | 378 | <br /> |
330 | 379 | <input type="submit" value="SEND" /> |
331 | 380 | </form> |
332 | - <?php } else { ?> |
|
381 | + <?php } |
|
382 | +else |
|
383 | +{ |
|
384 | +?> |
|
333 | 385 | <h2>New Jodel</h2> |
334 | 386 | <form method="POST"> |
335 | 387 | <textarea id="message" name="message" placeholder="Send a Jodel to all students within 10km" required></textarea> |
@@ -358,7 +410,9 @@ discard block |
||
358 | 410 | $(this).addClass('selected'); |
359 | 411 | }); |
360 | 412 | |
361 | - <?php if(!isset($_GET['postID']) && !isset($_GET['getPostDetails'])) { ?> |
|
413 | + <?php if(!isset($_GET['postID']) && !isset($_GET['getPostDetails'])) |
|
414 | +{ |
|
415 | +?> |
|
362 | 416 | $(document).ready(function() { |
363 | 417 | var win = $(window); |
364 | 418 | var lastPostId = "<?php echo $lastPostId; ?>"; |
@@ -35,15 +35,15 @@ discard block |
||
35 | 35 | |
36 | 36 | $url = 'https://maps.googleapis.com/maps/api/geocode/json?address=' . $_GET['city'] . '&key=AIzaSyCwhnja-or07012HqrhPW7prHEDuSvFT4w'; |
37 | 37 | $result = Requests::post($url); |
38 | - if(json_decode($result->body, true)['status'] == 'ZERO_RESULTS') |
|
38 | + if(json_decode($result->body, TRUE)['status'] == 'ZERO_RESULTS') |
|
39 | 39 | { |
40 | 40 | $newPostionStatus = "0 results"; |
41 | 41 | } |
42 | 42 | else |
43 | 43 | { |
44 | 44 | $location = new Location(); |
45 | - $location->setLat(json_decode($result->body, true)['results']['0']['geometry']['location']['lat']); |
|
46 | - $location->setLng(json_decode($result->body, true)['results']['0']['geometry']['location']['lng']); |
|
45 | + $location->setLat(json_decode($result->body, TRUE)['results']['0']['geometry']['location']['lat']); |
|
46 | + $location->setLng(json_decode($result->body, TRUE)['results']['0']['geometry']['location']['lng']); |
|
47 | 47 | $location->setCityName($_GET['city']); |
48 | 48 | $accountCreator = new UpdateLocation(); |
49 | 49 | $accountCreator->setLocation($location); |
@@ -159,19 +159,19 @@ discard block |
||
159 | 159 | else { |
160 | 160 | if(isset($_GET['commentView'])) |
161 | 161 | { |
162 | - $commentView = true; |
|
162 | + $commentView = TRUE; |
|
163 | 163 | $url = "/v2/posts/location/discussed/"; |
164 | 164 | } |
165 | 165 | else |
166 | 166 | { |
167 | 167 | if(isset($_GET['upVoteView'])) |
168 | 168 | { |
169 | - $upVoteView = true; |
|
169 | + $upVoteView = TRUE; |
|
170 | 170 | $url = "/v2/posts/location/popular/"; |
171 | 171 | } |
172 | 172 | else |
173 | 173 | { |
174 | - $timeView = true; |
|
174 | + $timeView = TRUE; |
|
175 | 175 | $url = "/v2/posts"; |
176 | 176 | } |
177 | 177 | } |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | |
20 | 20 | function getPosts($lastPostId, $url) { |
21 | 21 | $db = new DatabaseConnect(); |
22 | - if ($db->connect_errno) { |
|
22 | + if($db->connect_errno) { |
|
23 | 23 | echo 'Sorry, die Verbindung zu unserem superfetten endgeilen |
24 | 24 | Server ist hops gegangen. Wegen '. $db -> connect_error; |
25 | 25 | } |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | |
29 | 29 | $access_token; |
30 | 30 | |
31 | - if ($result->num_rows > 0) { |
|
31 | + if($result->num_rows > 0) { |
|
32 | 32 | // output data of each row |
33 | 33 | while($row = $result->fetch_assoc()) { |
34 | 34 | $access_token = $row["access_token"]; |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | ?> |
77 | 77 | <div class="nextPosts"> |
78 | 78 | <?php |
79 | - for($i = 0; $i<$loops; $i++) { |
|
79 | + for($i = 0; $i < $loops; $i++) { |
|
80 | 80 | |
81 | 81 | if(isset($posts[$i])) { |
82 | 82 | $lastPostId = $posts[$i]['post_id']; |
@@ -94,24 +94,24 @@ discard block |
||
94 | 94 | $timediff_inHours = (string)$timediff->format('%h'); |
95 | 95 | $timediff_inDays = (string)$timediff->format('%d'); |
96 | 96 | $timediff_inMonth = (string)$timediff->format('%m'); |
97 | - if($timediff_inMonth!=0) { |
|
97 | + if($timediff_inMonth != 0) { |
|
98 | 98 | $timediff = $timediff_inMonth . "m"; |
99 | 99 | } |
100 | 100 | else |
101 | 101 | { |
102 | - if($timediff_inDays!=0) |
|
102 | + if($timediff_inDays != 0) |
|
103 | 103 | { |
104 | 104 | $timediff = $timediff_inDays . "d"; |
105 | 105 | } |
106 | 106 | else |
107 | 107 | { |
108 | - if($timediff_inHours!=0) |
|
108 | + if($timediff_inHours != 0) |
|
109 | 109 | { |
110 | 110 | $timediff = $timediff_inHours . "h"; |
111 | 111 | } |
112 | 112 | else |
113 | 113 | { |
114 | - if($timediff_inMinutes!=0) |
|
114 | + if($timediff_inMinutes != 0) |
|
115 | 115 | { |
116 | 116 | $timediff = $timediff_inMinutes . "m"; |
117 | 117 | } |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | } |
125 | 125 | ?> |
126 | 126 | |
127 | - <article class="jodel" style="background-color: #<?php echo $posts[$i]["color"];?>;"> |
|
127 | + <article class="jodel" style="background-color: #<?php echo $posts[$i]["color"]; ?>;"> |
|
128 | 128 | <content> |
129 | 129 | <?php |
130 | 130 | if(isset($posts[$i]["image_url"])) { |
@@ -136,12 +136,12 @@ discard block |
||
136 | 136 | ?> |
137 | 137 | </content> |
138 | 138 | <aside> |
139 | - <a href="index.php?vote=up&postID=<?php echo $posts[$i]["post_id"];?>"> |
|
139 | + <a href="index.php?vote=up&postID=<?php echo $posts[$i]["post_id"]; ?>"> |
|
140 | 140 | <i class="fa fa-angle-up fa-3x"></i> |
141 | 141 | </a> |
142 | 142 | <br /> |
143 | - <?php echo $posts[$i]["vote_count"];?><br /> |
|
144 | - <a href="index.php?vote=down&postID=<?php echo $posts[$i]["post_id"];?>"> |
|
143 | + <?php echo $posts[$i]["vote_count"]; ?><br /> |
|
144 | + <a href="index.php?vote=down&postID=<?php echo $posts[$i]["post_id"]; ?>"> |
|
145 | 145 | <i class="fa fa-angle-down fa-3x"></i> |
146 | 146 | </a> |
147 | 147 | </aside> |
@@ -152,13 +152,13 @@ discard block |
||
152 | 152 | <td class="time"> |
153 | 153 | <span data-tooltip="Time"> |
154 | 154 | <i class="fa fa-clock-o"></i> |
155 | - <?php echo $timediff;?> |
|
155 | + <?php echo $timediff; ?> |
|
156 | 156 | </span> |
157 | 157 | </td> |
158 | 158 | <td class="comments"> |
159 | 159 | <?php if($showCommentIcon) {?> |
160 | 160 | <span data-tooltip="Comments"> |
161 | - <a href="index.php?getPostDetails=true&postID=<?php echo $posts[$i]["post_id"];?>"> |
|
161 | + <a href="index.php?getPostDetails=true&postID=<?php echo $posts[$i]["post_id"]; ?>"> |
|
162 | 162 | <i class="fa fa-commenting-o"></i> |
163 | 163 | <?php if(array_key_exists("child_count", $posts[$i])) { |
164 | 164 | echo $posts[$i]["child_count"]; |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | <td class="distance"> |
172 | 172 | <span data-tooltip="Distance"> |
173 | 173 | <i class="fa fa-map-marker"></i> |
174 | - <?php echo $posts[$i]["distance"];?> km |
|
174 | + <?php echo $posts[$i]["distance"]; ?> km |
|
175 | 175 | </span> |
176 | 176 | </td> |
177 | 177 | </tr> |
@@ -49,19 +49,19 @@ |
||
49 | 49 | |
50 | 50 | if(isset($_GET['commentView'])) |
51 | 51 | { |
52 | - $commentView = true; |
|
52 | + $commentView = TRUE; |
|
53 | 53 | $url = "/posts/location/discussed/"; |
54 | 54 | } |
55 | 55 | else |
56 | 56 | { |
57 | 57 | if(isset($_GET['upVoteView'])) |
58 | 58 | { |
59 | - $upVoteView = true; |
|
59 | + $upVoteView = TRUE; |
|
60 | 60 | $url = "/posts/location/popular/"; |
61 | 61 | } |
62 | 62 | else |
63 | 63 | { |
64 | - $timeView = true; |
|
64 | + $timeView = TRUE; |
|
65 | 65 | $url = "/v2/posts"; |
66 | 66 | } |
67 | 67 | } |
@@ -17,18 +17,22 @@ discard block |
||
17 | 17 | require_once 'php/Requests/libary/Requests.php'; |
18 | 18 | Requests::register_autoloader(); |
19 | 19 | |
20 | -function getPosts($lastPostId, $url) { |
|
20 | +function getPosts($lastPostId, $url) |
|
21 | +{ |
|
21 | 22 | $db = new DatabaseConnect(); |
22 | - if ($db->connect_errno) { |
|
23 | + if ($db->connect_errno) |
|
24 | + { |
|
23 | 25 | echo 'Sorry, die Verbindung zu unserem superfetten endgeilen |
24 | 26 | Server ist hops gegangen. Wegen '. $db -> connect_error; |
25 | 27 | } |
26 | 28 | |
27 | 29 | $result = $db->query("SELECT * FROM accounts WHERE id='1'"); |
28 | 30 | |
29 | - if ($result->num_rows > 0) { |
|
31 | + if ($result->num_rows > 0) |
|
32 | + { |
|
30 | 33 | // output data of each row |
31 | - while($row = $result->fetch_assoc()) { |
|
34 | + while($row = $result->fetch_assoc()) |
|
35 | + { |
|
32 | 36 | $access_token = $row["access_token"]; |
33 | 37 | } |
34 | 38 | } |
@@ -66,7 +70,8 @@ discard block |
||
66 | 70 | } |
67 | 71 | } |
68 | 72 | |
69 | - if(isset($_GET['lastPostId'])) { |
|
73 | + if(isset($_GET['lastPostId'])) |
|
74 | + { |
|
70 | 75 | |
71 | 76 | $lastPostId = $_GET['lastPostId']; |
72 | 77 | |
@@ -76,9 +81,11 @@ discard block |
||
76 | 81 | ?> |
77 | 82 | <div class="nextPosts"> |
78 | 83 | <?php |
79 | - for($i = 0; $i<$loops; $i++) { |
|
84 | + for($i = 0; $i<$loops; $i++) |
|
85 | + { |
|
80 | 86 | |
81 | - if(isset($posts[$i])) { |
|
87 | + if(isset($posts[$i])) |
|
88 | + { |
|
82 | 89 | $lastPostId = $posts[$i]['post_id']; |
83 | 90 | |
84 | 91 | |
@@ -94,7 +101,8 @@ discard block |
||
94 | 101 | $timediff_inHours = (string)$timediff->format('%h'); |
95 | 102 | $timediff_inDays = (string)$timediff->format('%d'); |
96 | 103 | $timediff_inMonth = (string)$timediff->format('%m'); |
97 | - if($timediff_inMonth!=0) { |
|
104 | + if($timediff_inMonth!=0) |
|
105 | + { |
|
98 | 106 | $timediff = $timediff_inMonth . "m"; |
99 | 107 | } |
100 | 108 | else |
@@ -127,10 +135,12 @@ discard block |
||
127 | 135 | <article class="jodel" style="background-color: #<?php echo $posts[$i]["color"];?>;"> |
128 | 136 | <content> |
129 | 137 | <?php |
130 | - if(isset($posts[$i]["image_url"])) { |
|
138 | + if(isset($posts[$i]["image_url"])) |
|
139 | + { |
|
131 | 140 | echo '<img src="' . $posts[$i]["image_url"] . '">'; |
132 | 141 | } |
133 | - else { |
|
142 | + else |
|
143 | + { |
|
134 | 144 | echo nl2br($posts[$i]["message"]); |
135 | 145 | } |
136 | 146 | ?> |
@@ -156,13 +166,19 @@ discard block |
||
156 | 166 | </span> |
157 | 167 | </td> |
158 | 168 | <td class="comments"> |
159 | - <?php if($showCommentIcon) {?> |
|
169 | + <?php if($showCommentIcon) |
|
170 | +{ |
|
171 | +?> |
|
160 | 172 | <span data-tooltip="Comments"> |
161 | 173 | <a href="index.php?getPostDetails=true&postID=<?php echo $posts[$i]["post_id"];?>"> |
162 | 174 | <i class="fa fa-commenting-o"></i> |
163 | - <?php if(array_key_exists("child_count", $posts[$i])) { |
|
175 | + <?php if(array_key_exists("child_count", $posts[$i])) |
|
176 | +{ |
|
164 | 177 | echo $posts[$i]["child_count"]; |
165 | - } else echo "0"; |
|
178 | + } |
|
179 | + else { |
|
180 | + echo "0"; |
|
181 | + } |
|
166 | 182 | ?> |
167 | 183 | </a> |
168 | 184 | </span> |