@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | // We should only use the last Content-Type header. c.f. issue #1 |
259 | 259 | if (isset($this->headers[$this->name]) && $this->name !== 'content-type') |
260 | 260 | { |
261 | - $this->headers[$this->name] .= ', ' . $this->value; |
|
261 | + $this->headers[$this->name] .= ', '.$this->value; |
|
262 | 262 | } |
263 | 263 | else |
264 | 264 | { |
@@ -441,7 +441,7 @@ discard block |
||
441 | 441 | protected function body() |
442 | 442 | { |
443 | 443 | $this->body = substr($this->data, $this->position); |
444 | - if (!empty($this->headers['transfer-encoding'])) |
|
444 | + if ( ! empty($this->headers['transfer-encoding'])) |
|
445 | 445 | { |
446 | 446 | unset($this->headers['transfer-encoding']); |
447 | 447 | $this->state = 'chunked'; |
@@ -457,7 +457,7 @@ discard block |
||
457 | 457 | */ |
458 | 458 | protected function chunked() |
459 | 459 | { |
460 | - if (!preg_match('/^([0-9a-f]+)[^\r\n]*\r\n/i', trim($this->body))) |
|
460 | + if ( ! preg_match('/^([0-9a-f]+)[^\r\n]*\r\n/i', trim($this->body))) |
|
461 | 461 | { |
462 | 462 | $this->state = 'emit'; |
463 | 463 | return; |
@@ -468,8 +468,8 @@ discard block |
||
468 | 468 | |
469 | 469 | while (true) |
470 | 470 | { |
471 | - $is_chunked = (bool) preg_match( '/^([0-9a-f]+)[^\r\n]*\r\n/i', $encoded, $matches ); |
|
472 | - if (!$is_chunked) |
|
471 | + $is_chunked = (bool) preg_match('/^([0-9a-f]+)[^\r\n]*\r\n/i', $encoded, $matches); |
|
472 | + if ( ! $is_chunked) |
|
473 | 473 | { |
474 | 474 | // Looks like it's not chunked after all |
475 | 475 | $this->state = 'emit'; |
@@ -155,8 +155,7 @@ discard block |
||
155 | 155 | if ($this->state === 'emit' || $this->state === 'body') |
156 | 156 | { |
157 | 157 | return true; |
158 | - } |
|
159 | - else |
|
158 | + } else |
|
160 | 159 | { |
161 | 160 | $this->http_version = ''; |
162 | 161 | $this->status_code = ''; |
@@ -206,13 +205,11 @@ discard block |
||
206 | 205 | $this->http_version = (float) $this->http_version; |
207 | 206 | $this->position += strspn($this->data, "\x09\x20", $this->position); |
208 | 207 | $this->state = 'status'; |
209 | - } |
|
210 | - else |
|
208 | + } else |
|
211 | 209 | { |
212 | 210 | $this->state = false; |
213 | 211 | } |
214 | - } |
|
215 | - else |
|
212 | + } else |
|
216 | 213 | { |
217 | 214 | $this->state = false; |
218 | 215 | } |
@@ -228,8 +225,7 @@ discard block |
||
228 | 225 | $this->status_code = (int) substr($this->data, $this->position, $len); |
229 | 226 | $this->position += $len; |
230 | 227 | $this->state = 'reason'; |
231 | - } |
|
232 | - else |
|
228 | + } else |
|
233 | 229 | { |
234 | 230 | $this->state = false; |
235 | 231 | } |
@@ -259,8 +255,7 @@ discard block |
||
259 | 255 | if (isset($this->headers[$this->name]) && $this->name !== 'content-type') |
260 | 256 | { |
261 | 257 | $this->headers[$this->name] .= ', ' . $this->value; |
262 | - } |
|
263 | - else |
|
258 | + } else |
|
264 | 259 | { |
265 | 260 | $this->headers[$this->name] = $this->value; |
266 | 261 | } |
@@ -271,13 +266,11 @@ discard block |
||
271 | 266 | { |
272 | 267 | $this->position += 2; |
273 | 268 | $this->state = 'body'; |
274 | - } |
|
275 | - elseif ($this->data[$this->position] === "\x0A") |
|
269 | + } elseif ($this->data[$this->position] === "\x0A") |
|
276 | 270 | { |
277 | 271 | $this->position++; |
278 | 272 | $this->state = 'body'; |
279 | - } |
|
280 | - else |
|
273 | + } else |
|
281 | 274 | { |
282 | 275 | $this->state = 'name'; |
283 | 276 | } |
@@ -295,15 +288,13 @@ discard block |
||
295 | 288 | { |
296 | 289 | $this->position += $len; |
297 | 290 | $this->state = 'new_line'; |
298 | - } |
|
299 | - else |
|
291 | + } else |
|
300 | 292 | { |
301 | 293 | $this->name = substr($this->data, $this->position, $len); |
302 | 294 | $this->position += $len + 1; |
303 | 295 | $this->state = 'value'; |
304 | 296 | } |
305 | - } |
|
306 | - else |
|
297 | + } else |
|
307 | 298 | { |
308 | 299 | $this->state = false; |
309 | 300 | } |
@@ -319,8 +310,7 @@ discard block |
||
319 | 310 | if (substr($this->data, $this->position, 2) === "\x0D\x0A") |
320 | 311 | { |
321 | 312 | $this->position += 2; |
322 | - } |
|
323 | - elseif ($this->data[$this->position] === "\x0A") |
|
313 | + } elseif ($this->data[$this->position] === "\x0A") |
|
324 | 314 | { |
325 | 315 | $this->position++; |
326 | 316 | } |
@@ -337,8 +327,7 @@ discard block |
||
337 | 327 | if ($this->is_linear_whitespace()) |
338 | 328 | { |
339 | 329 | $this->linear_whitespace(); |
340 | - } |
|
341 | - else |
|
330 | + } else |
|
342 | 331 | { |
343 | 332 | switch ($this->data[$this->position]) |
344 | 333 | { |
@@ -387,8 +376,7 @@ discard block |
||
387 | 376 | if ($this->is_linear_whitespace()) |
388 | 377 | { |
389 | 378 | $this->linear_whitespace(); |
390 | - } |
|
391 | - else |
|
379 | + } else |
|
392 | 380 | { |
393 | 381 | switch ($this->data[$this->position]) |
394 | 382 | { |
@@ -445,8 +433,7 @@ discard block |
||
445 | 433 | { |
446 | 434 | unset($this->headers['transfer-encoding']); |
447 | 435 | $this->state = 'chunked'; |
448 | - } |
|
449 | - else |
|
436 | + } else |
|
450 | 437 | { |
451 | 438 | $this->state = 'emit'; |
452 | 439 | } |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | $categories[] = $this->registry->create('Category', array($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null)); |
198 | 198 | } |
199 | 199 | |
200 | - if (!empty($categories)) |
|
200 | + if ( ! empty($categories)) |
|
201 | 201 | { |
202 | 202 | return array_unique($categories); |
203 | 203 | } |
@@ -280,7 +280,7 @@ discard block |
||
280 | 280 | $authors[] = $this->registry->create('Author', array($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null)); |
281 | 281 | } |
282 | 282 | |
283 | - if (!empty($authors)) |
|
283 | + if ( ! empty($authors)) |
|
284 | 284 | { |
285 | 285 | return array_unique($authors); |
286 | 286 | } |
@@ -351,7 +351,7 @@ discard block |
||
351 | 351 | } |
352 | 352 | } |
353 | 353 | |
354 | - if (!empty($contributors)) |
|
354 | + if ( ! empty($contributors)) |
|
355 | 355 | { |
356 | 356 | return array_unique($contributors); |
357 | 357 | } |
@@ -384,7 +384,7 @@ discard block |
||
384 | 384 | |
385 | 385 | public function get_links($rel = 'alternate') |
386 | 386 | { |
387 | - if (!isset($this->data['links'])) |
|
387 | + if ( ! isset($this->data['links'])) |
|
388 | 388 | { |
389 | 389 | $this->data['links'] = array(); |
390 | 390 | if ($links = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'link')) |
@@ -428,19 +428,19 @@ discard block |
||
428 | 428 | { |
429 | 429 | if ($this->registry->call('Misc', 'is_isegment_nz_nc', array($key))) |
430 | 430 | { |
431 | - if (isset($this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key])) |
|
431 | + if (isset($this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY.$key])) |
|
432 | 432 | { |
433 | - $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key] = array_merge($this->data['links'][$key], $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key]); |
|
434 | - $this->data['links'][$key] =& $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key]; |
|
433 | + $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY.$key] = array_merge($this->data['links'][$key], $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY.$key]); |
|
434 | + $this->data['links'][$key] = & $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY.$key]; |
|
435 | 435 | } |
436 | 436 | else |
437 | 437 | { |
438 | - $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key] =& $this->data['links'][$key]; |
|
438 | + $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY.$key] = & $this->data['links'][$key]; |
|
439 | 439 | } |
440 | 440 | } |
441 | 441 | elseif (substr($key, 0, 41) === SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY) |
442 | 442 | { |
443 | - $this->data['links'][substr($key, 41)] =& $this->data['links'][$key]; |
|
443 | + $this->data['links'][substr($key, 41)] = & $this->data['links'][$key]; |
|
444 | 444 | } |
445 | 445 | $this->data['links'][$key] = array_unique($this->data['links'][$key]); |
446 | 446 | } |
@@ -79,8 +79,7 @@ discard block |
||
79 | 79 | if (isset($this->data['child'][$namespace][$tag])) |
80 | 80 | { |
81 | 81 | return $this->data['child'][$namespace][$tag]; |
82 | - } |
|
83 | - else |
|
82 | + } else |
|
84 | 83 | { |
85 | 84 | return null; |
86 | 85 | } |
@@ -106,32 +105,25 @@ discard block |
||
106 | 105 | if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'title')) |
107 | 106 | { |
108 | 107 | return $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_10_construct_type', array($return[0]['attribs'])), $this->get_base($return[0])); |
109 | - } |
|
110 | - elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'title')) |
|
108 | + } elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'title')) |
|
111 | 109 | { |
112 | 110 | return $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_03_construct_type', array($return[0]['attribs'])), $this->get_base($return[0])); |
113 | - } |
|
114 | - elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'title')) |
|
111 | + } elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'title')) |
|
115 | 112 | { |
116 | 113 | return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); |
117 | - } |
|
118 | - elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'title')) |
|
114 | + } elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'title')) |
|
119 | 115 | { |
120 | 116 | return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); |
121 | - } |
|
122 | - elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'title')) |
|
117 | + } elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'title')) |
|
123 | 118 | { |
124 | 119 | return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); |
125 | - } |
|
126 | - elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_11, 'title')) |
|
120 | + } elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_11, 'title')) |
|
127 | 121 | { |
128 | 122 | return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
129 | - } |
|
130 | - elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_10, 'title')) |
|
123 | + } elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_10, 'title')) |
|
131 | 124 | { |
132 | 125 | return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
133 | - } |
|
134 | - else |
|
126 | + } else |
|
135 | 127 | { |
136 | 128 | return null; |
137 | 129 | } |
@@ -143,8 +135,7 @@ discard block |
||
143 | 135 | if (isset($categories[$key])) |
144 | 136 | { |
145 | 137 | return $categories[$key]; |
146 | - } |
|
147 | - else |
|
138 | + } else |
|
148 | 139 | { |
149 | 140 | return null; |
150 | 141 | } |
@@ -181,8 +172,7 @@ discard block |
||
181 | 172 | if (isset($category['attribs']['']['domain'])) |
182 | 173 | { |
183 | 174 | $scheme = $this->sanitize($category['attribs']['']['domain'], SIMPLEPIE_CONSTRUCT_TEXT); |
184 | - } |
|
185 | - else |
|
175 | + } else |
|
186 | 176 | { |
187 | 177 | $scheme = null; |
188 | 178 | } |
@@ -200,8 +190,7 @@ discard block |
||
200 | 190 | if (!empty($categories)) |
201 | 191 | { |
202 | 192 | return array_unique($categories); |
203 | - } |
|
204 | - else |
|
193 | + } else |
|
205 | 194 | { |
206 | 195 | return null; |
207 | 196 | } |
@@ -213,8 +202,7 @@ discard block |
||
213 | 202 | if (isset($authors[$key])) |
214 | 203 | { |
215 | 204 | return $authors[$key]; |
216 | - } |
|
217 | - else |
|
205 | + } else |
|
218 | 206 | { |
219 | 207 | return null; |
220 | 208 | } |
@@ -283,8 +271,7 @@ discard block |
||
283 | 271 | if (!empty($authors)) |
284 | 272 | { |
285 | 273 | return array_unique($authors); |
286 | - } |
|
287 | - else |
|
274 | + } else |
|
288 | 275 | { |
289 | 276 | return null; |
290 | 277 | } |
@@ -296,8 +283,7 @@ discard block |
||
296 | 283 | if (isset($contributors[$key])) |
297 | 284 | { |
298 | 285 | return $contributors[$key]; |
299 | - } |
|
300 | - else |
|
286 | + } else |
|
301 | 287 | { |
302 | 288 | return null; |
303 | 289 | } |
@@ -354,8 +340,7 @@ discard block |
||
354 | 340 | if (!empty($contributors)) |
355 | 341 | { |
356 | 342 | return array_unique($contributors); |
357 | - } |
|
358 | - else |
|
343 | + } else |
|
359 | 344 | { |
360 | 345 | return null; |
361 | 346 | } |
@@ -367,8 +352,7 @@ discard block |
||
367 | 352 | if (isset($links[$key])) |
368 | 353 | { |
369 | 354 | return $links[$key]; |
370 | - } |
|
371 | - else |
|
355 | + } else |
|
372 | 356 | { |
373 | 357 | return null; |
374 | 358 | } |
@@ -432,13 +416,11 @@ discard block |
||
432 | 416 | { |
433 | 417 | $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key] = array_merge($this->data['links'][$key], $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key]); |
434 | 418 | $this->data['links'][$key] =& $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key]; |
435 | - } |
|
436 | - else |
|
419 | + } else |
|
437 | 420 | { |
438 | 421 | $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key] =& $this->data['links'][$key]; |
439 | 422 | } |
440 | - } |
|
441 | - elseif (substr($key, 0, 41) === SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY) |
|
423 | + } elseif (substr($key, 0, 41) === SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY) |
|
442 | 424 | { |
443 | 425 | $this->data['links'][substr($key, 41)] =& $this->data['links'][$key]; |
444 | 426 | } |
@@ -449,8 +431,7 @@ discard block |
||
449 | 431 | if (isset($this->data['links'][$rel])) |
450 | 432 | { |
451 | 433 | return $this->data['links'][$rel]; |
452 | - } |
|
453 | - else |
|
434 | + } else |
|
454 | 435 | { |
455 | 436 | return null; |
456 | 437 | } |
@@ -461,40 +442,31 @@ discard block |
||
461 | 442 | if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'subtitle')) |
462 | 443 | { |
463 | 444 | return $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_10_construct_type', array($return[0]['attribs'])), $this->get_base($return[0])); |
464 | - } |
|
465 | - elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'tagline')) |
|
445 | + } elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'tagline')) |
|
466 | 446 | { |
467 | 447 | return $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_03_construct_type', array($return[0]['attribs'])), $this->get_base($return[0])); |
468 | - } |
|
469 | - elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'description')) |
|
448 | + } elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'description')) |
|
470 | 449 | { |
471 | 450 | return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); |
472 | - } |
|
473 | - elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'description')) |
|
451 | + } elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'description')) |
|
474 | 452 | { |
475 | 453 | return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); |
476 | - } |
|
477 | - elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'description')) |
|
454 | + } elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'description')) |
|
478 | 455 | { |
479 | 456 | return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); |
480 | - } |
|
481 | - elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_11, 'description')) |
|
457 | + } elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_11, 'description')) |
|
482 | 458 | { |
483 | 459 | return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
484 | - } |
|
485 | - elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_10, 'description')) |
|
460 | + } elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_10, 'description')) |
|
486 | 461 | { |
487 | 462 | return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
488 | - } |
|
489 | - elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'summary')) |
|
463 | + } elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'summary')) |
|
490 | 464 | { |
491 | 465 | return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0])); |
492 | - } |
|
493 | - elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'subtitle')) |
|
466 | + } elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'subtitle')) |
|
494 | 467 | { |
495 | 468 | return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0])); |
496 | - } |
|
497 | - else |
|
469 | + } else |
|
498 | 470 | { |
499 | 471 | return null; |
500 | 472 | } |
@@ -505,24 +477,19 @@ discard block |
||
505 | 477 | if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'rights')) |
506 | 478 | { |
507 | 479 | return $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_10_construct_type', array($return[0]['attribs'])), $this->get_base($return[0])); |
508 | - } |
|
509 | - elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'copyright')) |
|
480 | + } elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'copyright')) |
|
510 | 481 | { |
511 | 482 | return $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_03_construct_type', array($return[0]['attribs'])), $this->get_base($return[0])); |
512 | - } |
|
513 | - elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'copyright')) |
|
483 | + } elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'copyright')) |
|
514 | 484 | { |
515 | 485 | return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
516 | - } |
|
517 | - elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_11, 'rights')) |
|
486 | + } elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_11, 'rights')) |
|
518 | 487 | { |
519 | 488 | return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
520 | - } |
|
521 | - elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_10, 'rights')) |
|
489 | + } elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_10, 'rights')) |
|
522 | 490 | { |
523 | 491 | return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
524 | - } |
|
525 | - else |
|
492 | + } else |
|
526 | 493 | { |
527 | 494 | return null; |
528 | 495 | } |
@@ -533,20 +500,16 @@ discard block |
||
533 | 500 | if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'language')) |
534 | 501 | { |
535 | 502 | return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
536 | - } |
|
537 | - elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_11, 'language')) |
|
503 | + } elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_11, 'language')) |
|
538 | 504 | { |
539 | 505 | return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
540 | - } |
|
541 | - elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_10, 'language')) |
|
506 | + } elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_10, 'language')) |
|
542 | 507 | { |
543 | 508 | return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
544 | - } |
|
545 | - elseif (isset($this->data['xml_lang'])) |
|
509 | + } elseif (isset($this->data['xml_lang'])) |
|
546 | 510 | { |
547 | 511 | return $this->sanitize($this->data['xml_lang'], SIMPLEPIE_CONSTRUCT_TEXT); |
548 | - } |
|
549 | - else |
|
512 | + } else |
|
550 | 513 | { |
551 | 514 | return null; |
552 | 515 | } |
@@ -557,12 +520,10 @@ discard block |
||
557 | 520 | if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lat')) |
558 | 521 | { |
559 | 522 | return (float) $return[0]['data']; |
560 | - } |
|
561 | - elseif (($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', trim($return[0]['data']), $match)) |
|
523 | + } elseif (($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', trim($return[0]['data']), $match)) |
|
562 | 524 | { |
563 | 525 | return (float) $match[1]; |
564 | - } |
|
565 | - else |
|
526 | + } else |
|
566 | 527 | { |
567 | 528 | return null; |
568 | 529 | } |
@@ -573,16 +534,13 @@ discard block |
||
573 | 534 | if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'long')) |
574 | 535 | { |
575 | 536 | return (float) $return[0]['data']; |
576 | - } |
|
577 | - elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lon')) |
|
537 | + } elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lon')) |
|
578 | 538 | { |
579 | 539 | return (float) $return[0]['data']; |
580 | - } |
|
581 | - elseif (($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', trim($return[0]['data']), $match)) |
|
540 | + } elseif (($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', trim($return[0]['data']), $match)) |
|
582 | 541 | { |
583 | 542 | return (float) $match[2]; |
584 | - } |
|
585 | - else |
|
543 | + } else |
|
586 | 544 | { |
587 | 545 | return null; |
588 | 546 | } |
@@ -593,16 +551,13 @@ discard block |
||
593 | 551 | if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'image')) |
594 | 552 | { |
595 | 553 | return $this->sanitize($return[0]['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI); |
596 | - } |
|
597 | - elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'logo')) |
|
554 | + } elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'logo')) |
|
598 | 555 | { |
599 | 556 | return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0])); |
600 | - } |
|
601 | - elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'icon')) |
|
557 | + } elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'icon')) |
|
602 | 558 | { |
603 | 559 | return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0])); |
604 | - } |
|
605 | - else |
|
560 | + } else |
|
606 | 561 | { |
607 | 562 | return null; |
608 | 563 | } |
@@ -83,7 +83,7 @@ |
||
83 | 83 | { |
84 | 84 | $type = explode(':', $location, 2); |
85 | 85 | $type = $type[0]; |
86 | - if (!empty(self::$handlers[$type])) |
|
86 | + if ( ! empty(self::$handlers[$type])) |
|
87 | 87 | { |
88 | 88 | $class = self::$handlers[$type]; |
89 | 89 | return new $class($location, $filename, $extension); |
@@ -103,8 +103,7 @@ discard block |
||
103 | 103 | if ($this->url !== null) |
104 | 104 | { |
105 | 105 | return $this->url; |
106 | - } |
|
107 | - else |
|
106 | + } else |
|
108 | 107 | { |
109 | 108 | return null; |
110 | 109 | } |
@@ -120,8 +119,7 @@ discard block |
||
120 | 119 | if ($this->label !== null) |
121 | 120 | { |
122 | 121 | return $this->label; |
123 | - } |
|
124 | - else |
|
122 | + } else |
|
125 | 123 | { |
126 | 124 | return null; |
127 | 125 | } |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | { |
230 | 230 | if ($type & SIMPLEPIE_CONSTRUCT_MAYBE_HTML) |
231 | 231 | { |
232 | - if (preg_match('/(&(#(x[0-9a-fA-F]+|[0-9]+)|[a-zA-Z0-9]+)|<\/[A-Za-z][^\x09\x0A\x0B\x0C\x0D\x20\x2F\x3E]*' . SIMPLEPIE_PCRE_HTML_ATTRIBUTE . '>)/', $data)) |
|
232 | + if (preg_match('/(&(#(x[0-9a-fA-F]+|[0-9]+)|[a-zA-Z0-9]+)|<\/[A-Za-z][^\x09\x0A\x0B\x0C\x0D\x20\x2F\x3E]*'.SIMPLEPIE_PCRE_HTML_ATTRIBUTE.'>)/', $data)) |
|
233 | 233 | { |
234 | 234 | $type |= SIMPLEPIE_CONSTRUCT_HTML; |
235 | 235 | } |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | if ($type & (SIMPLEPIE_CONSTRUCT_HTML | SIMPLEPIE_CONSTRUCT_XHTML)) |
248 | 248 | { |
249 | 249 | |
250 | - if (!class_exists('DOMDocument')) |
|
250 | + if ( ! class_exists('DOMDocument')) |
|
251 | 251 | { |
252 | 252 | $this->registry->call('Misc', 'error', array('DOMDocument not found, unable to use sanitizer', E_USER_WARNING, __FILE__, __LINE__)); |
253 | 253 | return ''; |
@@ -311,7 +311,7 @@ discard block |
||
311 | 311 | |
312 | 312 | if ($cache->load()) |
313 | 313 | { |
314 | - $img->setAttribute('src', $this->image_handler . $image_url); |
|
314 | + $img->setAttribute('src', $this->image_handler.$image_url); |
|
315 | 315 | } |
316 | 316 | else |
317 | 317 | { |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | { |
323 | 323 | if ($cache->save(array('headers' => $file->headers, 'body' => $file->body))) |
324 | 324 | { |
325 | - $img->setAttribute('src', $this->image_handler . $image_url); |
|
325 | + $img->setAttribute('src', $this->image_handler.$image_url); |
|
326 | 326 | } |
327 | 327 | else |
328 | 328 | { |
@@ -350,12 +350,12 @@ discard block |
||
350 | 350 | |
351 | 351 | if ($this->remove_div) |
352 | 352 | { |
353 | - $data = preg_replace('/^<div' . SIMPLEPIE_PCRE_XML_ATTRIBUTE . '>/', '', $data); |
|
353 | + $data = preg_replace('/^<div'.SIMPLEPIE_PCRE_XML_ATTRIBUTE.'>/', '', $data); |
|
354 | 354 | $data = preg_replace('/<\/div>$/', '', $data); |
355 | 355 | } |
356 | 356 | else |
357 | 357 | { |
358 | - $data = preg_replace('/^<div' . SIMPLEPIE_PCRE_XML_ATTRIBUTE . '>/', '<div>', $data); |
|
358 | + $data = preg_replace('/^<div'.SIMPLEPIE_PCRE_XML_ATTRIBUTE.'>/', '<div>', $data); |
|
359 | 359 | } |
360 | 360 | } |
361 | 361 | |
@@ -388,7 +388,7 @@ discard block |
||
388 | 388 | { |
389 | 389 | // Atom XHTML constructs are wrapped with a div by default |
390 | 390 | // Note: No protection if $html contains a stray </div>! |
391 | - $html = '<div>' . $html . '</div>'; |
|
391 | + $html = '<div>'.$html.'</div>'; |
|
392 | 392 | $ret .= '<!DOCTYPE html>'; |
393 | 393 | $content_type = 'text/html'; |
394 | 394 | } |
@@ -399,19 +399,19 @@ discard block |
||
399 | 399 | } |
400 | 400 | |
401 | 401 | $ret .= '<html><head>'; |
402 | - $ret .= '<meta http-equiv="Content-Type" content="' . $content_type . '; charset=utf-8" />'; |
|
403 | - $ret .= '</head><body>' . $html . '</body></html>'; |
|
402 | + $ret .= '<meta http-equiv="Content-Type" content="'.$content_type.'; charset=utf-8" />'; |
|
403 | + $ret .= '</head><body>'.$html.'</body></html>'; |
|
404 | 404 | return $ret; |
405 | 405 | } |
406 | 406 | |
407 | 407 | public function replace_urls($document, $tag, $attributes) |
408 | 408 | { |
409 | - if (!is_array($attributes)) |
|
409 | + if ( ! is_array($attributes)) |
|
410 | 410 | { |
411 | 411 | $attributes = array($attributes); |
412 | 412 | } |
413 | 413 | |
414 | - if (!is_array($this->strip_htmltags) || !in_array($tag, $this->strip_htmltags)) |
|
414 | + if ( ! is_array($this->strip_htmltags) || ! in_array($tag, $this->strip_htmltags)) |
|
415 | 415 | { |
416 | 416 | $elements = $document->getElementsByTagName($tag); |
417 | 417 | foreach ($elements as $element) |
@@ -435,7 +435,7 @@ discard block |
||
435 | 435 | { |
436 | 436 | if ($this->encode_instead_of_strip) |
437 | 437 | { |
438 | - if (isset($match[4]) && !in_array(strtolower($match[1]), array('script', 'style'))) |
|
438 | + if (isset($match[4]) && ! in_array(strtolower($match[1]), array('script', 'style'))) |
|
439 | 439 | { |
440 | 440 | $match[1] = htmlspecialchars($match[1], ENT_COMPAT, 'UTF-8'); |
441 | 441 | $match[2] = htmlspecialchars($match[2], ENT_COMPAT, 'UTF-8'); |
@@ -446,7 +446,7 @@ discard block |
||
446 | 446 | return htmlspecialchars($match[0], ENT_COMPAT, 'UTF-8'); |
447 | 447 | } |
448 | 448 | } |
449 | - elseif (isset($match[4]) && !in_array(strtolower($match[1]), array('script', 'style'))) |
|
449 | + elseif (isset($match[4]) && ! in_array(strtolower($match[1]), array('script', 'style'))) |
|
450 | 450 | { |
451 | 451 | return $match[4]; |
452 | 452 | } |
@@ -459,7 +459,7 @@ discard block |
||
459 | 459 | protected function strip_tag($tag, $document, $type) |
460 | 460 | { |
461 | 461 | $xpath = new DOMXPath($document); |
462 | - $elements = $xpath->query('body//' . $tag); |
|
462 | + $elements = $xpath->query('body//'.$tag); |
|
463 | 463 | if ($this->encode_instead_of_strip) |
464 | 464 | { |
465 | 465 | foreach ($elements as $element) |
@@ -467,9 +467,9 @@ discard block |
||
467 | 467 | $fragment = $document->createDocumentFragment(); |
468 | 468 | |
469 | 469 | // For elements which aren't script or style, include the tag itself |
470 | - if (!in_array($tag, array('script', 'style'))) |
|
470 | + if ( ! in_array($tag, array('script', 'style'))) |
|
471 | 471 | { |
472 | - $text = '<' . $tag; |
|
472 | + $text = '<'.$tag; |
|
473 | 473 | if ($element->hasAttributes()) |
474 | 474 | { |
475 | 475 | $attrs = array(); |
@@ -490,9 +490,9 @@ discard block |
||
490 | 490 | } |
491 | 491 | |
492 | 492 | // Standard attribute text |
493 | - $attrs[] = $name . '="' . $attr->value . '"'; |
|
493 | + $attrs[] = $name.'="'.$attr->value.'"'; |
|
494 | 494 | } |
495 | - $text .= ' ' . implode(' ', $attrs); |
|
495 | + $text .= ' '.implode(' ', $attrs); |
|
496 | 496 | } |
497 | 497 | $text .= '>'; |
498 | 498 | $fragment->appendChild(new DOMText($text)); |
@@ -505,9 +505,9 @@ discard block |
||
505 | 505 | $fragment->appendChild($child); |
506 | 506 | } |
507 | 507 | |
508 | - if (!in_array($tag, array('script', 'style'))) |
|
508 | + if ( ! in_array($tag, array('script', 'style'))) |
|
509 | 509 | { |
510 | - $fragment->appendChild(new DOMText('</' . $tag . '>')); |
|
510 | + $fragment->appendChild(new DOMText('</'.$tag.'>')); |
|
511 | 511 | } |
512 | 512 | |
513 | 513 | $element->parentNode->replaceChild($fragment, $element); |
@@ -544,7 +544,7 @@ discard block |
||
544 | 544 | protected function strip_attr($attrib, $document) |
545 | 545 | { |
546 | 546 | $xpath = new DOMXPath($document); |
547 | - $elements = $xpath->query('//*[@' . $attrib . ']'); |
|
547 | + $elements = $xpath->query('//*[@'.$attrib.']'); |
|
548 | 548 | |
549 | 549 | foreach ($elements as $element) |
550 | 550 | { |
@@ -88,8 +88,7 @@ discard block |
||
88 | 88 | if ($page) |
89 | 89 | { |
90 | 90 | $this->image_handler = (string) $page; |
91 | - } |
|
92 | - else |
|
91 | + } else |
|
93 | 92 | { |
94 | 93 | $this->image_handler = false; |
95 | 94 | } |
@@ -143,13 +142,11 @@ discard block |
||
143 | 142 | if (is_array($tags)) |
144 | 143 | { |
145 | 144 | $this->strip_htmltags = $tags; |
146 | - } |
|
147 | - else |
|
145 | + } else |
|
148 | 146 | { |
149 | 147 | $this->strip_htmltags = explode(',', $tags); |
150 | 148 | } |
151 | - } |
|
152 | - else |
|
149 | + } else |
|
153 | 150 | { |
154 | 151 | $this->strip_htmltags = false; |
155 | 152 | } |
@@ -167,13 +164,11 @@ discard block |
||
167 | 164 | if (is_array($attribs)) |
168 | 165 | { |
169 | 166 | $this->strip_attributes = $attribs; |
170 | - } |
|
171 | - else |
|
167 | + } else |
|
172 | 168 | { |
173 | 169 | $this->strip_attributes = explode(',', $attribs); |
174 | 170 | } |
175 | - } |
|
176 | - else |
|
171 | + } else |
|
177 | 172 | { |
178 | 173 | $this->strip_attributes = false; |
179 | 174 | } |
@@ -232,8 +227,7 @@ discard block |
||
232 | 227 | if (preg_match('/(&(#(x[0-9a-fA-F]+|[0-9]+)|[a-zA-Z0-9]+)|<\/[A-Za-z][^\x09\x0A\x0B\x0C\x0D\x20\x2F\x3E]*' . SIMPLEPIE_PCRE_HTML_ATTRIBUTE . '>)/', $data)) |
233 | 228 | { |
234 | 229 | $type |= SIMPLEPIE_CONSTRUCT_HTML; |
235 | - } |
|
236 | - else |
|
230 | + } else |
|
237 | 231 | { |
238 | 232 | $type |= SIMPLEPIE_CONSTRUCT_TEXT; |
239 | 233 | } |
@@ -312,8 +306,7 @@ discard block |
||
312 | 306 | if ($cache->load()) |
313 | 307 | { |
314 | 308 | $img->setAttribute('src', $this->image_handler . $image_url); |
315 | - } |
|
316 | - else |
|
309 | + } else |
|
317 | 310 | { |
318 | 311 | $file = $this->registry->create('File', array($img->getAttribute('src'), $this->timeout, 5, array('X-FORWARDED-FOR' => $_SERVER['REMOTE_ADDR']), $this->useragent, $this->force_fsockopen)); |
319 | 312 | $headers = $file->headers; |
@@ -323,8 +316,7 @@ discard block |
||
323 | 316 | if ($cache->save(array('headers' => $file->headers, 'body' => $file->body))) |
324 | 317 | { |
325 | 318 | $img->setAttribute('src', $this->image_handler . $image_url); |
326 | - } |
|
327 | - else |
|
319 | + } else |
|
328 | 320 | { |
329 | 321 | trigger_error("$this->cache_location is not writeable. Make sure you've set the correct relative or absolute path, and that the location is server-writable.", E_USER_WARNING); |
330 | 322 | } |
@@ -352,8 +344,7 @@ discard block |
||
352 | 344 | { |
353 | 345 | $data = preg_replace('/^<div' . SIMPLEPIE_PCRE_XML_ATTRIBUTE . '>/', '', $data); |
354 | 346 | $data = preg_replace('/<\/div>$/', '', $data); |
355 | - } |
|
356 | - else |
|
347 | + } else |
|
357 | 348 | { |
358 | 349 | $data = preg_replace('/^<div' . SIMPLEPIE_PCRE_XML_ATTRIBUTE . '>/', '<div>', $data); |
359 | 350 | } |
@@ -391,8 +382,7 @@ discard block |
||
391 | 382 | $html = '<div>' . $html . '</div>'; |
392 | 383 | $ret .= '<!DOCTYPE html>'; |
393 | 384 | $content_type = 'text/html'; |
394 | - } |
|
395 | - else |
|
385 | + } else |
|
396 | 386 | { |
397 | 387 | $ret .= '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'; |
398 | 388 | $content_type = 'application/xhtml+xml'; |
@@ -440,17 +430,14 @@ discard block |
||
440 | 430 | $match[1] = htmlspecialchars($match[1], ENT_COMPAT, 'UTF-8'); |
441 | 431 | $match[2] = htmlspecialchars($match[2], ENT_COMPAT, 'UTF-8'); |
442 | 432 | return "<$match[1]$match[2]>$match[3]</$match[1]>"; |
443 | - } |
|
444 | - else |
|
433 | + } else |
|
445 | 434 | { |
446 | 435 | return htmlspecialchars($match[0], ENT_COMPAT, 'UTF-8'); |
447 | 436 | } |
448 | - } |
|
449 | - elseif (isset($match[4]) && !in_array(strtolower($match[1]), array('script', 'style'))) |
|
437 | + } elseif (isset($match[4]) && !in_array(strtolower($match[1]), array('script', 'style'))) |
|
450 | 438 | { |
451 | 439 | return $match[4]; |
452 | - } |
|
453 | - else |
|
440 | + } else |
|
454 | 441 | { |
455 | 442 | return ''; |
456 | 443 | } |
@@ -514,8 +501,7 @@ discard block |
||
514 | 501 | } |
515 | 502 | |
516 | 503 | return; |
517 | - } |
|
518 | - elseif (in_array($tag, array('script', 'style'))) |
|
504 | + } elseif (in_array($tag, array('script', 'style'))) |
|
519 | 505 | { |
520 | 506 | foreach ($elements as $element) |
521 | 507 | { |
@@ -523,8 +509,7 @@ discard block |
||
523 | 509 | } |
524 | 510 | |
525 | 511 | return; |
526 | - } |
|
527 | - else |
|
512 | + } else |
|
528 | 513 | { |
529 | 514 | foreach ($elements as $element) |
530 | 515 | { |
@@ -222,6 +222,10 @@ discard block |
||
222 | 222 | $this->replace_url_attributes = (array) $element_attribute; |
223 | 223 | } |
224 | 224 | |
225 | + /** |
|
226 | + * @param string $data |
|
227 | + * @param integer $type |
|
228 | + */ |
|
225 | 229 | public function sanitize($data, $type, $base = '') |
226 | 230 | { |
227 | 231 | $data = trim($data); |
@@ -381,6 +385,9 @@ discard block |
||
381 | 385 | return $data; |
382 | 386 | } |
383 | 387 | |
388 | + /** |
|
389 | + * @param string $html |
|
390 | + */ |
|
384 | 391 | protected function preprocess($html, $type) |
385 | 392 | { |
386 | 393 | $ret = ''; |
@@ -404,6 +411,9 @@ discard block |
||
404 | 411 | return $ret; |
405 | 412 | } |
406 | 413 | |
414 | + /** |
|
415 | + * @param DOMDocument $document |
|
416 | + */ |
|
407 | 417 | public function replace_urls($document, $tag, $attributes) |
408 | 418 | { |
409 | 419 | if (!is_array($attributes)) |
@@ -456,6 +466,9 @@ discard block |
||
456 | 466 | } |
457 | 467 | } |
458 | 468 | |
469 | + /** |
|
470 | + * @param DOMDocument $document |
|
471 | + */ |
|
459 | 472 | protected function strip_tag($tag, $document, $type) |
460 | 473 | { |
461 | 474 | $xpath = new DOMXPath($document); |
@@ -541,6 +554,9 @@ discard block |
||
541 | 554 | } |
542 | 555 | } |
543 | 556 | |
557 | + /** |
|
558 | + * @param DOMDocument $document |
|
559 | + */ |
|
544 | 560 | protected function strip_attr($attrib, $document) |
545 | 561 | { |
546 | 562 | $xpath = new DOMXPath($document); |
@@ -82,11 +82,11 @@ discard block |
||
82 | 82 | $useragent = ini_get('user_agent'); |
83 | 83 | $this->useragent = $useragent; |
84 | 84 | } |
85 | - if (!is_array($headers)) |
|
85 | + if ( ! is_array($headers)) |
|
86 | 86 | { |
87 | 87 | $headers = array(); |
88 | 88 | } |
89 | - if (!$force_fsockopen && function_exists('curl_exec')) |
|
89 | + if ( ! $force_fsockopen && function_exists('curl_exec')) |
|
90 | 90 | { |
91 | 91 | $this->method = SIMPLEPIE_FILE_SOURCE_REMOTE | SIMPLEPIE_FILE_SOURCE_CURL; |
92 | 92 | $fp = curl_init(); |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | curl_setopt($fp, CURLOPT_REFERER, $url); |
108 | 108 | curl_setopt($fp, CURLOPT_USERAGENT, $useragent); |
109 | 109 | curl_setopt($fp, CURLOPT_HTTPHEADER, $headers2); |
110 | - if (!ini_get('open_basedir') && !ini_get('safe_mode') && version_compare(SimplePie_Misc::get_curl_version(), '7.15.2', '>=')) |
|
110 | + if ( ! ini_get('open_basedir') && ! ini_get('safe_mode') && version_compare(SimplePie_Misc::get_curl_version(), '7.15.2', '>=')) |
|
111 | 111 | { |
112 | 112 | curl_setopt($fp, CURLOPT_FOLLOWLOCATION, 1); |
113 | 113 | curl_setopt($fp, CURLOPT_MAXREDIRS, $redirects); |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | } |
122 | 122 | if (curl_errno($fp)) |
123 | 123 | { |
124 | - $this->error = 'cURL error ' . curl_errno($fp) . ': ' . curl_error($fp); |
|
124 | + $this->error = 'cURL error '.curl_errno($fp).': '.curl_error($fp); |
|
125 | 125 | $this->success = false; |
126 | 126 | } |
127 | 127 | else |
@@ -155,14 +155,14 @@ discard block |
||
155 | 155 | $socket_host = "ssl://$url_parts[host]"; |
156 | 156 | $url_parts['port'] = 443; |
157 | 157 | } |
158 | - if (!isset($url_parts['port'])) |
|
158 | + if ( ! isset($url_parts['port'])) |
|
159 | 159 | { |
160 | 160 | $url_parts['port'] = 80; |
161 | 161 | } |
162 | 162 | $fp = @fsockopen($socket_host, $url_parts['port'], $errno, $errstr, $timeout); |
163 | - if (!$fp) |
|
163 | + if ( ! $fp) |
|
164 | 164 | { |
165 | - $this->error = 'fsockopen error: ' . $errstr; |
|
165 | + $this->error = 'fsockopen error: '.$errstr; |
|
166 | 166 | $this->success = false; |
167 | 167 | } |
168 | 168 | else |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | |
194 | 194 | if (isset($url_parts['user']) && isset($url_parts['pass'])) |
195 | 195 | { |
196 | - $out .= "Authorization: Basic " . base64_encode("$url_parts[user]:$url_parts[pass]") . "\r\n"; |
|
196 | + $out .= "Authorization: Basic ".base64_encode("$url_parts[user]:$url_parts[pass]")."\r\n"; |
|
197 | 197 | } |
198 | 198 | foreach ($headers as $key => $value) |
199 | 199 | { |
@@ -205,12 +205,12 @@ discard block |
||
205 | 205 | $info = stream_get_meta_data($fp); |
206 | 206 | |
207 | 207 | $this->headers = ''; |
208 | - while (!$info['eof'] && !$info['timed_out']) |
|
208 | + while ( ! $info['eof'] && ! $info['timed_out']) |
|
209 | 209 | { |
210 | 210 | $this->headers .= fread($fp, 1160); |
211 | 211 | $info = stream_get_meta_data($fp); |
212 | 212 | } |
213 | - if (!$info['timed_out']) |
|
213 | + if ( ! $info['timed_out']) |
|
214 | 214 | { |
215 | 215 | $parser = new SimplePie_HTTP_Parser($this->headers); |
216 | 216 | if ($parser->parse()) |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | case 'gzip': |
233 | 233 | case 'x-gzip': |
234 | 234 | $decoder = new SimplePie_gzdecode($this->body); |
235 | - if (!$decoder->parse()) |
|
235 | + if ( ! $decoder->parse()) |
|
236 | 236 | { |
237 | 237 | $this->error = 'Unable to decode HTTP "gzip" stream'; |
238 | 238 | $this->success = false; |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | else |
283 | 283 | { |
284 | 284 | $this->method = SIMPLEPIE_FILE_SOURCE_LOCAL | SIMPLEPIE_FILE_SOURCE_FILE_GET_CONTENTS; |
285 | - if (!$this->body = file_get_contents($url)) |
|
285 | + if ( ! $this->body = file_get_contents($url)) |
|
286 | 286 | { |
287 | 287 | $this->error = 'file_get_contents could not read the file'; |
288 | 288 | $this->success = false; |
@@ -123,8 +123,7 @@ discard block |
||
123 | 123 | { |
124 | 124 | $this->error = 'cURL error ' . curl_errno($fp) . ': ' . curl_error($fp); |
125 | 125 | $this->success = false; |
126 | - } |
|
127 | - else |
|
126 | + } else |
|
128 | 127 | { |
129 | 128 | $info = curl_getinfo($fp); |
130 | 129 | curl_close($fp); |
@@ -144,8 +143,7 @@ discard block |
||
144 | 143 | } |
145 | 144 | } |
146 | 145 | } |
147 | - } |
|
148 | - else |
|
146 | + } else |
|
149 | 147 | { |
150 | 148 | $this->method = SIMPLEPIE_FILE_SOURCE_REMOTE | SIMPLEPIE_FILE_SOURCE_FSOCKOPEN; |
151 | 149 | $url_parts = parse_url($url); |
@@ -164,8 +162,7 @@ discard block |
||
164 | 162 | { |
165 | 163 | $this->error = 'fsockopen error: ' . $errstr; |
166 | 164 | $this->success = false; |
167 | - } |
|
168 | - else |
|
165 | + } else |
|
169 | 166 | { |
170 | 167 | stream_set_timeout($fp, $timeout); |
171 | 168 | if (isset($url_parts['path'])) |
@@ -173,13 +170,11 @@ discard block |
||
173 | 170 | if (isset($url_parts['query'])) |
174 | 171 | { |
175 | 172 | $get = "$url_parts[path]?$url_parts[query]"; |
176 | - } |
|
177 | - else |
|
173 | + } else |
|
178 | 174 | { |
179 | 175 | $get = $url_parts['path']; |
180 | 176 | } |
181 | - } |
|
182 | - else |
|
177 | + } else |
|
183 | 178 | { |
184 | 179 | $get = '/'; |
185 | 180 | } |
@@ -236,8 +231,7 @@ discard block |
||
236 | 231 | { |
237 | 232 | $this->error = 'Unable to decode HTTP "gzip" stream'; |
238 | 233 | $this->success = false; |
239 | - } |
|
240 | - else |
|
234 | + } else |
|
241 | 235 | { |
242 | 236 | $this->body = $decoder->data; |
243 | 237 | } |
@@ -247,16 +241,13 @@ discard block |
||
247 | 241 | if (($decompressed = gzinflate($this->body)) !== false) |
248 | 242 | { |
249 | 243 | $this->body = $decompressed; |
250 | - } |
|
251 | - else if (($decompressed = gzuncompress($this->body)) !== false) |
|
244 | + } else if (($decompressed = gzuncompress($this->body)) !== false) |
|
252 | 245 | { |
253 | 246 | $this->body = $decompressed; |
254 | - } |
|
255 | - else if (function_exists('gzdecode') && ($decompressed = gzdecode($this->body)) !== false) |
|
247 | + } else if (function_exists('gzdecode') && ($decompressed = gzdecode($this->body)) !== false) |
|
256 | 248 | { |
257 | 249 | $this->body = $decompressed; |
258 | - } |
|
259 | - else |
|
250 | + } else |
|
260 | 251 | { |
261 | 252 | $this->error = 'Unable to decode HTTP "deflate" stream'; |
262 | 253 | $this->success = false; |
@@ -269,8 +260,7 @@ discard block |
||
269 | 260 | } |
270 | 261 | } |
271 | 262 | } |
272 | - } |
|
273 | - else |
|
263 | + } else |
|
274 | 264 | { |
275 | 265 | $this->error = 'fsocket timed out'; |
276 | 266 | $this->success = false; |
@@ -278,8 +268,7 @@ discard block |
||
278 | 268 | fclose($fp); |
279 | 269 | } |
280 | 270 | } |
281 | - } |
|
282 | - else |
|
271 | + } else |
|
283 | 272 | { |
284 | 273 | $this->method = SIMPLEPIE_FILE_SOURCE_LOCAL | SIMPLEPIE_FILE_SOURCE_FILE_GET_CONTENTS; |
285 | 274 | if (!$this->body = file_get_contents($url)) |
@@ -112,8 +112,7 @@ discard block |
||
112 | 112 | if ($this->role !== null) |
113 | 113 | { |
114 | 114 | return $this->role; |
115 | - } |
|
116 | - else |
|
115 | + } else |
|
117 | 116 | { |
118 | 117 | return null; |
119 | 118 | } |
@@ -129,8 +128,7 @@ discard block |
||
129 | 128 | if ($this->scheme !== null) |
130 | 129 | { |
131 | 130 | return $this->scheme; |
132 | - } |
|
133 | - else |
|
131 | + } else |
|
134 | 132 | { |
135 | 133 | return null; |
136 | 134 | } |
@@ -146,8 +144,7 @@ discard block |
||
146 | 144 | if ($this->name !== null) |
147 | 145 | { |
148 | 146 | return $this->name; |
149 | - } |
|
150 | - else |
|
147 | + } else |
|
151 | 148 | { |
152 | 149 | return null; |
153 | 150 | } |
@@ -103,8 +103,7 @@ discard block |
||
103 | 103 | if ($this->scheme !== null) |
104 | 104 | { |
105 | 105 | return $this->scheme; |
106 | - } |
|
107 | - else |
|
106 | + } else |
|
108 | 107 | { |
109 | 108 | return null; |
110 | 109 | } |
@@ -120,8 +119,7 @@ discard block |
||
120 | 119 | if ($this->value !== null) |
121 | 120 | { |
122 | 121 | return $this->value; |
123 | - } |
|
124 | - else |
|
122 | + } else |
|
125 | 123 | { |
126 | 124 | return null; |
127 | 125 | } |
@@ -131,8 +131,7 @@ discard block |
||
131 | 131 | if ($this->endTime !== null) |
132 | 132 | { |
133 | 133 | return $this->endTime; |
134 | - } |
|
135 | - else |
|
134 | + } else |
|
136 | 135 | { |
137 | 136 | return null; |
138 | 137 | } |
@@ -149,8 +148,7 @@ discard block |
||
149 | 148 | if ($this->lang !== null) |
150 | 149 | { |
151 | 150 | return $this->lang; |
152 | - } |
|
153 | - else |
|
151 | + } else |
|
154 | 152 | { |
155 | 153 | return null; |
156 | 154 | } |
@@ -166,8 +164,7 @@ discard block |
||
166 | 164 | if ($this->startTime !== null) |
167 | 165 | { |
168 | 166 | return $this->startTime; |
169 | - } |
|
170 | - else |
|
167 | + } else |
|
171 | 168 | { |
172 | 169 | return null; |
173 | 170 | } |
@@ -183,8 +180,7 @@ discard block |
||
183 | 180 | if ($this->text !== null) |
184 | 181 | { |
185 | 182 | return $this->text; |
186 | - } |
|
187 | - else |
|
183 | + } else |
|
188 | 184 | { |
189 | 185 | return null; |
190 | 186 | } |
@@ -200,8 +196,7 @@ discard block |
||
200 | 196 | if ($this->type !== null) |
201 | 197 | { |
202 | 198 | return $this->type; |
203 | - } |
|
204 | - else |
|
199 | + } else |
|
205 | 200 | { |
206 | 201 | return null; |
207 | 202 | } |