@@ -137,12 +137,12 @@ discard block |
||
137 | 137 | */ |
138 | 138 | public static function autoloader($class) { |
139 | 139 | // Check that the class starts with "Requests" |
140 | - if (strpos($class, 'Requests') !== 0) { |
|
140 | + if(strpos($class, 'Requests') !== 0) { |
|
141 | 141 | return; |
142 | 142 | } |
143 | 143 | |
144 | 144 | $file = str_replace('_', '/', $class); |
145 | - if (file_exists(dirname(__FILE__) . '/' . $file . '.php')) { |
|
145 | + if(file_exists(dirname(__FILE__) . '/' . $file . '.php')) { |
|
146 | 146 | require_once(dirname(__FILE__) . '/' . $file . '.php'); |
147 | 147 | } |
148 | 148 | } |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | * @param string $transport Transport class to add, must support the Requests_Transport interface |
163 | 163 | */ |
164 | 164 | public static function add_transport($transport) { |
165 | - if (empty(self::$transports)) { |
|
165 | + if(empty(self::$transports)) { |
|
166 | 166 | self::$transports = array( |
167 | 167 | 'Requests_Transport_cURL', |
168 | 168 | 'Requests_Transport_fsockopen', |
@@ -186,12 +186,12 @@ discard block |
||
186 | 186 | $cap_string = serialize($capabilities); |
187 | 187 | |
188 | 188 | // Don't search for a transport if it's already been done for these $capabilities |
189 | - if (isset(self::$transport[$cap_string]) && self::$transport[$cap_string] !== null) { |
|
189 | + if(isset(self::$transport[$cap_string]) && self::$transport[$cap_string] !== null) { |
|
190 | 190 | return new self::$transport[$cap_string](); |
191 | 191 | } |
192 | 192 | // @codeCoverageIgnoreEnd |
193 | 193 | |
194 | - if (empty(self::$transports)) { |
|
194 | + if(empty(self::$transports)) { |
|
195 | 195 | self::$transports = array( |
196 | 196 | 'Requests_Transport_cURL', |
197 | 197 | 'Requests_Transport_fsockopen', |
@@ -199,18 +199,18 @@ discard block |
||
199 | 199 | } |
200 | 200 | |
201 | 201 | // Find us a working transport |
202 | - foreach (self::$transports as $class) { |
|
203 | - if (!class_exists($class)) { |
|
202 | + foreach(self::$transports as $class) { |
|
203 | + if(!class_exists($class)) { |
|
204 | 204 | continue; |
205 | 205 | } |
206 | 206 | |
207 | 207 | $result = call_user_func(array($class, 'test'), $capabilities); |
208 | - if ($result) { |
|
208 | + if($result) { |
|
209 | 209 | self::$transport[$cap_string] = $class; |
210 | 210 | break; |
211 | 211 | } |
212 | 212 | } |
213 | - if (self::$transport[$cap_string] === null) { |
|
213 | + if(self::$transport[$cap_string] === null) { |
|
214 | 214 | throw new Requests_Exception('No working transports found', 'notransport', self::$transports); |
215 | 215 | } |
216 | 216 | |
@@ -355,7 +355,7 @@ discard block |
||
355 | 355 | * @return Requests_Response |
356 | 356 | */ |
357 | 357 | public static function request($url, $headers = array(), $data = array(), $type = self::GET, $options = array()) { |
358 | - if (empty($options['type'])) { |
|
358 | + if(empty($options['type'])) { |
|
359 | 359 | $options['type'] = $type; |
360 | 360 | } |
361 | 361 | $options = array_merge(self::get_default_options(), $options); |
@@ -364,10 +364,10 @@ discard block |
||
364 | 364 | |
365 | 365 | $options['hooks']->dispatch('requests.before_request', array(&$url, &$headers, &$data, &$type, &$options)); |
366 | 366 | |
367 | - if (!empty($options['transport'])) { |
|
367 | + if(!empty($options['transport'])) { |
|
368 | 368 | $transport = $options['transport']; |
369 | 369 | |
370 | - if (is_string($options['transport'])) { |
|
370 | + if(is_string($options['transport'])) { |
|
371 | 371 | $transport = new $transport(); |
372 | 372 | } |
373 | 373 | } |
@@ -427,29 +427,29 @@ discard block |
||
427 | 427 | public static function request_multiple($requests, $options = array()) { |
428 | 428 | $options = array_merge(self::get_default_options(true), $options); |
429 | 429 | |
430 | - if (!empty($options['hooks'])) { |
|
430 | + if(!empty($options['hooks'])) { |
|
431 | 431 | $options['hooks']->register('transport.internal.parse_response', array('Requests', 'parse_multiple')); |
432 | - if (!empty($options['complete'])) { |
|
432 | + if(!empty($options['complete'])) { |
|
433 | 433 | $options['hooks']->register('multiple.request.complete', $options['complete']); |
434 | 434 | } |
435 | 435 | } |
436 | 436 | |
437 | - foreach ($requests as $id => &$request) { |
|
438 | - if (!isset($request['headers'])) { |
|
437 | + foreach($requests as $id => &$request) { |
|
438 | + if(!isset($request['headers'])) { |
|
439 | 439 | $request['headers'] = array(); |
440 | 440 | } |
441 | - if (!isset($request['data'])) { |
|
441 | + if(!isset($request['data'])) { |
|
442 | 442 | $request['data'] = array(); |
443 | 443 | } |
444 | - if (!isset($request['type'])) { |
|
444 | + if(!isset($request['type'])) { |
|
445 | 445 | $request['type'] = self::GET; |
446 | 446 | } |
447 | - if (!isset($request['options'])) { |
|
447 | + if(!isset($request['options'])) { |
|
448 | 448 | $request['options'] = $options; |
449 | 449 | $request['options']['type'] = $request['type']; |
450 | 450 | } |
451 | 451 | else { |
452 | - if (empty($request['options']['type'])) { |
|
452 | + if(empty($request['options']['type'])) { |
|
453 | 453 | $request['options']['type'] = $request['type']; |
454 | 454 | } |
455 | 455 | $request['options'] = array_merge($options, $request['options']); |
@@ -458,19 +458,19 @@ discard block |
||
458 | 458 | self::set_defaults($request['url'], $request['headers'], $request['data'], $request['type'], $request['options']); |
459 | 459 | |
460 | 460 | // Ensure we only hook in once |
461 | - if ($request['options']['hooks'] !== $options['hooks']) { |
|
461 | + if($request['options']['hooks'] !== $options['hooks']) { |
|
462 | 462 | $request['options']['hooks']->register('transport.internal.parse_response', array('Requests', 'parse_multiple')); |
463 | - if (!empty($request['options']['complete'])) { |
|
463 | + if(!empty($request['options']['complete'])) { |
|
464 | 464 | $request['options']['hooks']->register('multiple.request.complete', $request['options']['complete']); |
465 | 465 | } |
466 | 466 | } |
467 | 467 | } |
468 | 468 | unset($request); |
469 | 469 | |
470 | - if (!empty($options['transport'])) { |
|
470 | + if(!empty($options['transport'])) { |
|
471 | 471 | $transport = $options['transport']; |
472 | 472 | |
473 | - if (is_string($options['transport'])) { |
|
473 | + if(is_string($options['transport'])) { |
|
474 | 474 | $transport = new $transport(); |
475 | 475 | } |
476 | 476 | } |
@@ -479,10 +479,10 @@ discard block |
||
479 | 479 | } |
480 | 480 | $responses = $transport->request_multiple($requests, $options); |
481 | 481 | |
482 | - foreach ($responses as $id => &$response) { |
|
482 | + foreach($responses as $id => &$response) { |
|
483 | 483 | // If our hook got messed with somehow, ensure we end up with the |
484 | 484 | // correct response |
485 | - if (is_string($response)) { |
|
485 | + if(is_string($response)) { |
|
486 | 486 | $request = $requests[$id]; |
487 | 487 | self::parse_multiple($response, $request); |
488 | 488 | $request['options']['hooks']->dispatch('multiple.request.complete', array(&$response, $id)); |
@@ -521,7 +521,7 @@ discard block |
||
521 | 521 | 'verify' => Requests::get_certificate_path(), |
522 | 522 | 'verifyname' => true, |
523 | 523 | ); |
524 | - if ($multirequest !== false) { |
|
524 | + if($multirequest !== false) { |
|
525 | 525 | $defaults['complete'] = null; |
526 | 526 | } |
527 | 527 | return $defaults; |
@@ -533,7 +533,7 @@ discard block |
||
533 | 533 | * @return string Default certificate path. |
534 | 534 | */ |
535 | 535 | public static function get_certificate_path() { |
536 | - if ( ! empty( Requests::$certificate_path ) ) { |
|
536 | + if(!empty(Requests::$certificate_path)) { |
|
537 | 537 | return Requests::$certificate_path; |
538 | 538 | } |
539 | 539 | |
@@ -545,7 +545,7 @@ discard block |
||
545 | 545 | * |
546 | 546 | * @param string $path Certificate path, pointing to a PEM file. |
547 | 547 | */ |
548 | - public static function set_certificate_path( $path ) { |
|
548 | + public static function set_certificate_path($path) { |
|
549 | 549 | Requests::$certificate_path = $path; |
550 | 550 | } |
551 | 551 | |
@@ -560,39 +560,39 @@ discard block |
||
560 | 560 | * @return array $options |
561 | 561 | */ |
562 | 562 | protected static function set_defaults(&$url, &$headers, &$data, &$type, &$options) { |
563 | - if (!preg_match('/^http(s)?:\/\//i', $url, $matches)) { |
|
563 | + if(!preg_match('/^http(s)?:\/\//i', $url, $matches)) { |
|
564 | 564 | throw new Requests_Exception('Only HTTP(S) requests are handled.', 'nonhttp', $url); |
565 | 565 | } |
566 | 566 | |
567 | - if (empty($options['hooks'])) { |
|
567 | + if(empty($options['hooks'])) { |
|
568 | 568 | $options['hooks'] = new Requests_Hooks(); |
569 | 569 | } |
570 | 570 | |
571 | - if (is_array($options['auth'])) { |
|
571 | + if(is_array($options['auth'])) { |
|
572 | 572 | $options['auth'] = new Requests_Auth_Basic($options['auth']); |
573 | 573 | } |
574 | - if ($options['auth'] !== false) { |
|
574 | + if($options['auth'] !== false) { |
|
575 | 575 | $options['auth']->register($options['hooks']); |
576 | 576 | } |
577 | 577 | |
578 | - if (is_string($options['proxy']) || is_array($options['proxy'])) { |
|
578 | + if(is_string($options['proxy']) || is_array($options['proxy'])) { |
|
579 | 579 | $options['proxy'] = new Requests_Proxy_HTTP($options['proxy']); |
580 | 580 | } |
581 | - if ($options['proxy'] !== false) { |
|
581 | + if($options['proxy'] !== false) { |
|
582 | 582 | $options['proxy']->register($options['hooks']); |
583 | 583 | } |
584 | 584 | |
585 | - if (is_array($options['cookies'])) { |
|
585 | + if(is_array($options['cookies'])) { |
|
586 | 586 | $options['cookies'] = new Requests_Cookie_Jar($options['cookies']); |
587 | 587 | } |
588 | - elseif (empty($options['cookies'])) { |
|
588 | + elseif(empty($options['cookies'])) { |
|
589 | 589 | $options['cookies'] = new Requests_Cookie_Jar(); |
590 | 590 | } |
591 | - if ($options['cookies'] !== false) { |
|
591 | + if($options['cookies'] !== false) { |
|
592 | 592 | $options['cookies']->register($options['hooks']); |
593 | 593 | } |
594 | 594 | |
595 | - if ($options['idn'] !== false) { |
|
595 | + if($options['idn'] !== false) { |
|
596 | 596 | $iri = new Requests_IRI($url); |
597 | 597 | $iri->host = Requests_IDNAEncoder::encode($iri->ihost); |
598 | 598 | $url = $iri->uri; |
@@ -601,8 +601,8 @@ discard block |
||
601 | 601 | // Massage the type to ensure we support it. |
602 | 602 | $type = strtoupper($type); |
603 | 603 | |
604 | - if (!isset($options['data_format'])) { |
|
605 | - if (in_array($type, array(self::HEAD, self::GET, self::DELETE))) { |
|
604 | + if(!isset($options['data_format'])) { |
|
605 | + if(in_array($type, array(self::HEAD, self::GET, self::DELETE))) { |
|
606 | 606 | $options['data_format'] = 'query'; |
607 | 607 | } |
608 | 608 | else { |
@@ -627,15 +627,15 @@ discard block |
||
627 | 627 | */ |
628 | 628 | protected static function parse_response($headers, $url, $req_headers, $req_data, $options) { |
629 | 629 | $return = new Requests_Response(); |
630 | - if (!$options['blocking']) { |
|
630 | + if(!$options['blocking']) { |
|
631 | 631 | return $return; |
632 | 632 | } |
633 | 633 | |
634 | 634 | $return->raw = $headers; |
635 | 635 | $return->url = $url; |
636 | 636 | |
637 | - if (!$options['filename']) { |
|
638 | - if (($pos = strpos($headers, "\r\n\r\n")) === false) { |
|
637 | + if(!$options['filename']) { |
|
638 | + if(($pos = strpos($headers, "\r\n\r\n")) === false) { |
|
639 | 639 | // Crap! |
640 | 640 | throw new Requests_Exception('Missing header/body separator', 'requests.no_crlf_separator'); |
641 | 641 | } |
@@ -652,44 +652,44 @@ discard block |
||
652 | 652 | $headers = preg_replace('/\n[ \t]/', ' ', $headers); |
653 | 653 | $headers = explode("\n", $headers); |
654 | 654 | preg_match('#^HTTP/(1\.\d)[ \t]+(\d+)#i', array_shift($headers), $matches); |
655 | - if (empty($matches)) { |
|
655 | + if(empty($matches)) { |
|
656 | 656 | throw new Requests_Exception('Response could not be parsed', 'noversion', $headers); |
657 | 657 | } |
658 | - $return->protocol_version = (float) $matches[1]; |
|
659 | - $return->status_code = (int) $matches[2]; |
|
660 | - if ($return->status_code >= 200 && $return->status_code < 300) { |
|
658 | + $return->protocol_version = (float)$matches[1]; |
|
659 | + $return->status_code = (int)$matches[2]; |
|
660 | + if($return->status_code >= 200 && $return->status_code < 300) { |
|
661 | 661 | $return->success = true; |
662 | 662 | } |
663 | 663 | |
664 | - foreach ($headers as $header) { |
|
664 | + foreach($headers as $header) { |
|
665 | 665 | list($key, $value) = explode(':', $header, 2); |
666 | 666 | $value = trim($value); |
667 | 667 | preg_replace('#(\s+)#i', ' ', $value); |
668 | 668 | $return->headers[$key] = $value; |
669 | 669 | } |
670 | - if (isset($return->headers['transfer-encoding'])) { |
|
670 | + if(isset($return->headers['transfer-encoding'])) { |
|
671 | 671 | $return->body = self::decode_chunked($return->body); |
672 | 672 | unset($return->headers['transfer-encoding']); |
673 | 673 | } |
674 | - if (isset($return->headers['content-encoding'])) { |
|
674 | + if(isset($return->headers['content-encoding'])) { |
|
675 | 675 | $return->body = self::decompress($return->body); |
676 | 676 | } |
677 | 677 | |
678 | 678 | //fsockopen and cURL compatibility |
679 | - if (isset($return->headers['connection'])) { |
|
679 | + if(isset($return->headers['connection'])) { |
|
680 | 680 | unset($return->headers['connection']); |
681 | 681 | } |
682 | 682 | |
683 | 683 | $options['hooks']->dispatch('requests.before_redirect_check', array(&$return, $req_headers, $req_data, $options)); |
684 | 684 | |
685 | - if ($return->is_redirect() && $options['follow_redirects'] === true) { |
|
686 | - if (isset($return->headers['location']) && $options['redirected'] < $options['redirects']) { |
|
687 | - if ($return->status_code === 303) { |
|
685 | + if($return->is_redirect() && $options['follow_redirects'] === true) { |
|
686 | + if(isset($return->headers['location']) && $options['redirected'] < $options['redirects']) { |
|
687 | + if($return->status_code === 303) { |
|
688 | 688 | $options['type'] = self::GET; |
689 | 689 | } |
690 | 690 | $options['redirected']++; |
691 | 691 | $location = $return->headers['location']; |
692 | - if (strpos($location, 'http://') !== 0 && strpos($location, 'https://') !== 0) { |
|
692 | + if(strpos($location, 'http://') !== 0 && strpos($location, 'https://') !== 0) { |
|
693 | 693 | // relative redirect, for compatibility make it absolute |
694 | 694 | $location = Requests_IRI::absolutize($url, $location); |
695 | 695 | $location = $location->uri; |
@@ -707,7 +707,7 @@ discard block |
||
707 | 707 | $redirected->history[] = $return; |
708 | 708 | return $redirected; |
709 | 709 | } |
710 | - elseif ($options['redirected'] >= $options['redirects']) { |
|
710 | + elseif($options['redirected'] >= $options['redirects']) { |
|
711 | 711 | throw new Requests_Exception('Too many redirects', 'toomanyredirects', $return); |
712 | 712 | } |
713 | 713 | } |
@@ -736,7 +736,7 @@ discard block |
||
736 | 736 | $options = $request['options']; |
737 | 737 | $response = self::parse_response($response, $url, $headers, $data, $options); |
738 | 738 | } |
739 | - catch (Requests_Exception $e) { |
|
739 | + catch(Requests_Exception $e) { |
|
740 | 740 | $response = $e; |
741 | 741 | } |
742 | 742 | } |
@@ -749,7 +749,7 @@ discard block |
||
749 | 749 | * @return string Decoded body |
750 | 750 | */ |
751 | 751 | protected static function decode_chunked($data) { |
752 | - if (!preg_match('/^([0-9a-f]+)(?:;(?:[\w-]*)(?:=(?:(?:[\w-]*)*|"(?:[^\r\n])*"))?)*\r\n/i', trim($data))) { |
|
752 | + if(!preg_match('/^([0-9a-f]+)(?:;(?:[\w-]*)(?:=(?:(?:[\w-]*)*|"(?:[^\r\n])*"))?)*\r\n/i', trim($data))) { |
|
753 | 753 | return $data; |
754 | 754 | } |
755 | 755 | |
@@ -758,15 +758,15 @@ discard block |
||
758 | 758 | $decoded = ''; |
759 | 759 | $encoded = $data; |
760 | 760 | |
761 | - while (true) { |
|
762 | - $is_chunked = (bool) preg_match('/^([0-9a-f]+)(?:;(?:[\w-]*)(?:=(?:(?:[\w-]*)*|"(?:[^\r\n])*"))?)*\r\n/i', $encoded, $matches); |
|
763 | - if (!$is_chunked) { |
|
761 | + while(true) { |
|
762 | + $is_chunked = (bool)preg_match('/^([0-9a-f]+)(?:;(?:[\w-]*)(?:=(?:(?:[\w-]*)*|"(?:[^\r\n])*"))?)*\r\n/i', $encoded, $matches); |
|
763 | + if(!$is_chunked) { |
|
764 | 764 | // Looks like it's not chunked after all |
765 | 765 | return $data; |
766 | 766 | } |
767 | 767 | |
768 | 768 | $length = hexdec(trim($matches[1])); |
769 | - if ($length === 0) { |
|
769 | + if($length === 0) { |
|
770 | 770 | // Ignore trailer headers |
771 | 771 | return $decoded; |
772 | 772 | } |
@@ -775,7 +775,7 @@ discard block |
||
775 | 775 | $decoded .= substr($encoded, $chunk_length, $length); |
776 | 776 | $encoded = substr($encoded, $chunk_length + $length + 2); |
777 | 777 | |
778 | - if (trim($encoded) === '0' || empty($encoded)) { |
|
778 | + if(trim($encoded) === '0' || empty($encoded)) { |
|
779 | 779 | return $decoded; |
780 | 780 | } |
781 | 781 | } |
@@ -793,7 +793,7 @@ discard block |
||
793 | 793 | */ |
794 | 794 | public static function flatten($array) { |
795 | 795 | $return = array(); |
796 | - foreach ($array as $key => $value) { |
|
796 | + foreach($array as $key => $value) { |
|
797 | 797 | $return[] = sprintf('%s: %s', $key, $value); |
798 | 798 | } |
799 | 799 | return $return; |
@@ -821,21 +821,21 @@ discard block |
||
821 | 821 | * @return string Decompressed string |
822 | 822 | */ |
823 | 823 | public static function decompress($data) { |
824 | - if (substr($data, 0, 2) !== "\x1f\x8b" && substr($data, 0, 2) !== "\x78\x9c") { |
|
824 | + if(substr($data, 0, 2) !== "\x1f\x8b" && substr($data, 0, 2) !== "\x78\x9c") { |
|
825 | 825 | // Not actually compressed. Probably cURL ruining this for us. |
826 | 826 | return $data; |
827 | 827 | } |
828 | 828 | |
829 | - if (function_exists('gzdecode') && ($decoded = @gzdecode($data)) !== false) { |
|
829 | + if(function_exists('gzdecode') && ($decoded = @gzdecode($data)) !== false) { |
|
830 | 830 | return $decoded; |
831 | 831 | } |
832 | - elseif (function_exists('gzinflate') && ($decoded = @gzinflate($data)) !== false) { |
|
832 | + elseif(function_exists('gzinflate') && ($decoded = @gzinflate($data)) !== false) { |
|
833 | 833 | return $decoded; |
834 | 834 | } |
835 | - elseif (($decoded = self::compatible_gzinflate($data)) !== false) { |
|
835 | + elseif(($decoded = self::compatible_gzinflate($data)) !== false) { |
|
836 | 836 | return $decoded; |
837 | 837 | } |
838 | - elseif (function_exists('gzuncompress') && ($decoded = @gzuncompress($data)) !== false) { |
|
838 | + elseif(function_exists('gzuncompress') && ($decoded = @gzuncompress($data)) !== false) { |
|
839 | 839 | return $decoded; |
840 | 840 | } |
841 | 841 | |
@@ -865,26 +865,26 @@ discard block |
||
865 | 865 | public static function compatible_gzinflate($gzData) { |
866 | 866 | // Compressed data might contain a full zlib header, if so strip it for |
867 | 867 | // gzinflate() |
868 | - if (substr($gzData, 0, 3) == "\x1f\x8b\x08") { |
|
868 | + if(substr($gzData, 0, 3) == "\x1f\x8b\x08") { |
|
869 | 869 | $i = 10; |
870 | 870 | $flg = ord(substr($gzData, 3, 1)); |
871 | - if ($flg > 0) { |
|
872 | - if ($flg & 4) { |
|
871 | + if($flg > 0) { |
|
872 | + if($flg&4) { |
|
873 | 873 | list($xlen) = unpack('v', substr($gzData, $i, 2)); |
874 | 874 | $i = $i + 2 + $xlen; |
875 | 875 | } |
876 | - if ($flg & 8) { |
|
876 | + if($flg&8) { |
|
877 | 877 | $i = strpos($gzData, "\0", $i) + 1; |
878 | 878 | } |
879 | - if ($flg & 16) { |
|
879 | + if($flg&16) { |
|
880 | 880 | $i = strpos($gzData, "\0", $i) + 1; |
881 | 881 | } |
882 | - if ($flg & 2) { |
|
882 | + if($flg&2) { |
|
883 | 883 | $i = $i + 2; |
884 | 884 | } |
885 | 885 | } |
886 | 886 | $decompressed = self::compatible_gzinflate(substr($gzData, $i)); |
887 | - if (false !== $decompressed) { |
|
887 | + if(false !== $decompressed) { |
|
888 | 888 | return $decompressed; |
889 | 889 | } |
890 | 890 | } |
@@ -905,17 +905,17 @@ discard block |
||
905 | 905 | // First 2 bytes should be divisible by 0x1F |
906 | 906 | list(, $first_two_bytes) = unpack('n', $gzData); |
907 | 907 | |
908 | - if (0x08 == $first_nibble && 0 == ($first_two_bytes % 0x1F)) { |
|
908 | + if(0x08 == $first_nibble && 0 == ($first_two_bytes % 0x1F)) { |
|
909 | 909 | $huffman_encoded = true; |
910 | 910 | } |
911 | 911 | |
912 | - if ($huffman_encoded) { |
|
913 | - if (false !== ($decompressed = @gzinflate(substr($gzData, 2)))) { |
|
912 | + if($huffman_encoded) { |
|
913 | + if(false !== ($decompressed = @gzinflate(substr($gzData, 2)))) { |
|
914 | 914 | return $decompressed; |
915 | 915 | } |
916 | 916 | } |
917 | 917 | |
918 | - if ("\x50\x4b\x03\x04" == substr($gzData, 0, 4)) { |
|
918 | + if("\x50\x4b\x03\x04" == substr($gzData, 0, 4)) { |
|
919 | 919 | // ZIP file format header |
920 | 920 | // Offset 6: 2 bytes, General-purpose field |
921 | 921 | // Offset 26: 2 bytes, filename length |
@@ -927,9 +927,9 @@ discard block |
||
927 | 927 | // If the file has been compressed on the fly, 0x08 bit is set of |
928 | 928 | // the general purpose field. We can use this to differentiate |
929 | 929 | // between a compressed document, and a ZIP file |
930 | - $zip_compressed_on_the_fly = (0x08 == (0x08 & $general_purpose_flag)); |
|
930 | + $zip_compressed_on_the_fly = (0x08 == (0x08&$general_purpose_flag)); |
|
931 | 931 | |
932 | - if (!$zip_compressed_on_the_fly) { |
|
932 | + if(!$zip_compressed_on_the_fly) { |
|
933 | 933 | // Don't attempt to decode a compressed zip file |
934 | 934 | return $gzData; |
935 | 935 | } |
@@ -937,20 +937,20 @@ discard block |
||
937 | 937 | // Determine the first byte of data, based on the above ZIP header |
938 | 938 | // offsets: |
939 | 939 | $first_file_start = array_sum(unpack('v2', substr($gzData, 26, 4))); |
940 | - if (false !== ($decompressed = @gzinflate(substr($gzData, 30 + $first_file_start)))) { |
|
940 | + if(false !== ($decompressed = @gzinflate(substr($gzData, 30 + $first_file_start)))) { |
|
941 | 941 | return $decompressed; |
942 | 942 | } |
943 | 943 | return false; |
944 | 944 | } |
945 | 945 | |
946 | 946 | // Finally fall back to straight gzinflate |
947 | - if (false !== ($decompressed = @gzinflate($gzData))) { |
|
947 | + if(false !== ($decompressed = @gzinflate($gzData))) { |
|
948 | 948 | return $decompressed; |
949 | 949 | } |
950 | 950 | |
951 | 951 | // Fallback for all above failing, not expected, but included for |
952 | 952 | // debugging and preventing regressions and to track stats |
953 | - if (false !== ($decompressed = @gzinflate(substr($gzData, 2)))) { |
|
953 | + if(false !== ($decompressed = @gzinflate(substr($gzData, 2)))) { |
|
954 | 954 | return $decompressed; |
955 | 955 | } |
956 | 956 | |
@@ -959,7 +959,7 @@ discard block |
||
959 | 959 | |
960 | 960 | public static function match_domain($host, $reference) { |
961 | 961 | // Check for a direct match |
962 | - if ($host === $reference) { |
|
962 | + if($host === $reference) { |
|
963 | 963 | return true; |
964 | 964 | } |
965 | 965 | |
@@ -967,10 +967,10 @@ discard block |
||
967 | 967 | // Also validates that the host has 3 parts or more, as per Firefox's |
968 | 968 | // ruleset. |
969 | 969 | $parts = explode('.', $host); |
970 | - if (ip2long($host) === false && count($parts) >= 3) { |
|
970 | + if(ip2long($host) === false && count($parts) >= 3) { |
|
971 | 971 | $parts[0] = '*'; |
972 | 972 | $wildcard = implode('.', $parts); |
973 | - if ($wildcard === $reference) { |
|
973 | + if($wildcard === $reference) { |
|
974 | 974 | return true; |
975 | 975 | } |
976 | 976 | } |
@@ -29,5 +29,5 @@ |
||
29 | 29 | * @see Requests_Hooks::register |
30 | 30 | * @param Requests_Hooks $hooks Hook system |
31 | 31 | */ |
32 | - public function register(Requests_Hooks &$hooks); |
|
32 | + public function register(Requests_Hooks&$hooks); |
|
33 | 33 | } |
34 | 34 | \ No newline at end of file |
@@ -37,7 +37,7 @@ |
||
37 | 37 | { |
38 | 38 | $str = ''; |
39 | 39 | $max = mb_strlen($keyspace, '8bit') - 1; |
40 | - for ($i = 0; $i < $length; ++$i) { |
|
40 | + for($i = 0; $i < $length; ++$i) { |
|
41 | 41 | $str .= $keyspace[rand(0, $max)]; |
42 | 42 | } |
43 | 43 | return $str; |
@@ -11,22 +11,22 @@ discard block |
||
11 | 11 | public $url; |
12 | 12 | |
13 | 13 | |
14 | - function setUrl ($url) |
|
14 | + function setUrl($url) |
|
15 | 15 | { |
16 | 16 | $this->url = $url; |
17 | 17 | } |
18 | 18 | |
19 | - function getUrl () |
|
19 | + function getUrl() |
|
20 | 20 | { |
21 | 21 | return $this->url; |
22 | 22 | } |
23 | 23 | |
24 | - function setLastPostId ($lastPostId) |
|
24 | + function setLastPostId($lastPostId) |
|
25 | 25 | { |
26 | 26 | $this->lastPostId = $lastPostId; |
27 | 27 | } |
28 | 28 | |
29 | - function getlastPostId () |
|
29 | + function getlastPostId() |
|
30 | 30 | { |
31 | 31 | return $this->lastPostId; |
32 | 32 | } |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | { |
36 | 36 | $apiEndPoint = $this->getUrl(); |
37 | 37 | |
38 | - if ($this->getLastPostId() != "") { |
|
38 | + if($this->getLastPostId() != "") { |
|
39 | 39 | $apiEndPoint = $this->getUrl() . '?after=' . $this->getLastPostId(); |
40 | 40 | } |
41 | 41 | return $apiEndPoint; |
@@ -47,6 +47,6 @@ |
||
47 | 47 | </content> |
48 | 48 | </article> |
49 | 49 | </div> |
50 | - <?php include 'templates/nav-bottom.php';?> |
|
50 | + <?php include 'templates/nav-bottom.php'; ?> |
|
51 | 51 | </div> |
52 | -<?php include 'templates/footer.php';?> |
|
53 | 52 | \ No newline at end of file |
53 | +<?php include 'templates/footer.php'; ?> |
|
54 | 54 | \ No newline at end of file |
@@ -66,4 +66,4 @@ |
||
66 | 66 | </article> |
67 | 67 | </div> |
68 | 68 | </div> |
69 | -<?php include(realpath(__DIR__ . '/..') . '/templates/footer.php');?> |
|
70 | 69 | \ No newline at end of file |
70 | +<?php include(realpath(__DIR__ . '/..') . '/templates/footer.php'); ?> |
|
71 | 71 | \ No newline at end of file |
@@ -66,4 +66,4 @@ |
||
66 | 66 | </article> |
67 | 67 | </div> |
68 | 68 | </div> |
69 | -<?php include(realpath(__DIR__ . '/..') . '/templates/footer.php');?> |
|
70 | 69 | \ No newline at end of file |
70 | +<?php include(realpath(__DIR__ . '/..') . '/templates/footer.php'); ?> |
|
71 | 71 | \ No newline at end of file |
@@ -1,16 +1,16 @@ |
||
1 | 1 | <div id="sortJodelBy" class="row"> |
2 | 2 | <div class="col-3"> |
3 | - <a <?php if($view->view == 'combo')echo 'class="active"';?> href="<?php echo $view->changeView('combo')->back()->toUrl();?>"><i class="fa fa-clock-o fa-3x"></i></a> |
|
3 | + <a <?php if($view->view == 'combo')echo 'class="active"'; ?> href="<?php echo $view->changeView('combo')->back()->toUrl(); ?>"><i class="fa fa-clock-o fa-3x"></i></a> |
|
4 | 4 | </div> |
5 | 5 | <div class="col-3"> |
6 | - <a <?php if($view->view == 'discussed') echo 'class="active"';?> href="<?php echo $view->changeView('discussed')->back()->toUrl();?>"><i class="fa fa-commenting-o fa-3x"></i></a> |
|
6 | + <a <?php if($view->view == 'discussed') echo 'class="active"'; ?> href="<?php echo $view->changeView('discussed')->back()->toUrl(); ?>"><i class="fa fa-commenting-o fa-3x"></i></a> |
|
7 | 7 | </div> |
8 | 8 | <div class="col-3"> |
9 | - <a <?php if($view->view == 'popular') echo 'class="active"';?> href="<?php echo $view->changeView('popular')->back()->toUrl();?>"><i class="fa fa-angle-up fa-3x"></i></a> |
|
9 | + <a <?php if($view->view == 'popular') echo 'class="active"'; ?> href="<?php echo $view->changeView('popular')->back()->toUrl(); ?>"><i class="fa fa-angle-up fa-3x"></i></a> |
|
10 | 10 | </div> |
11 | 11 | <div class="col-3"> |
12 | 12 | <nav> |
13 | - <a href="<?php echo $baseUrl;?>about-us.php">about</a> |
|
13 | + <a href="<?php echo $baseUrl; ?>about-us.php">about</a> |
|
14 | 14 | </nav> |
15 | 15 | </div> |
16 | 16 | </div> |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | { |
36 | 36 | $this->refreshToken(); |
37 | 37 | } |
38 | - $this->accessToken = $this->getAccessToken(); |
|
38 | + $this->accessToken = $this->getAccessToken(); |
|
39 | 39 | |
40 | 40 | /* if($this->isAccountVerified() != 1) |
41 | 41 | { |
@@ -106,11 +106,11 @@ discard block |
||
106 | 106 | } |
107 | 107 | |
108 | 108 | $db = new DatabaseConnect(); |
109 | - $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid . "'"); |
|
109 | + $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid . "'"); |
|
110 | 110 | |
111 | 111 | $location = new Location(); |
112 | 112 | |
113 | - if ($result->num_rows > 0) |
|
113 | + if($result->num_rows > 0) |
|
114 | 114 | { |
115 | 115 | // output data of each row |
116 | 116 | while($row = $result->fetch_assoc()) |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | } |
183 | 183 | else |
184 | 184 | { |
185 | - user_log('User with JodelDeviceId:' . $this->deviceUid . ' [' . $_SERVER['REMOTE_ADDR'] . '][' . $_SERVER ['HTTP_USER_AGENT'] . '] changed to Location: ' . $name); |
|
185 | + user_log('User with JodelDeviceId:' . $this->deviceUid . ' [' . $_SERVER['REMOTE_ADDR'] . '][' . $_SERVER ['HTTP_USER_AGENT'] . '] changed to Location: ' . $name); |
|
186 | 186 | } |
187 | 187 | } |
188 | 188 | |
@@ -194,11 +194,11 @@ discard block |
||
194 | 194 | function getLocation() |
195 | 195 | { |
196 | 196 | $db = new DatabaseConnect(); |
197 | - $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid . "'"); |
|
197 | + $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid . "'"); |
|
198 | 198 | |
199 | 199 | $location = new Location(); |
200 | 200 | |
201 | - if ($result->num_rows > 0) |
|
201 | + if($result->num_rows > 0) |
|
202 | 202 | { |
203 | 203 | // output data of each row |
204 | 204 | while($row = $result->fetch_assoc()) |
@@ -321,7 +321,7 @@ discard block |
||
321 | 321 | if(isset($_POST['color'])) |
322 | 322 | { |
323 | 323 | $color = $_POST['color']; |
324 | - switch ($color) { |
|
324 | + switch($color) { |
|
325 | 325 | case '8ABDB0': |
326 | 326 | $color = '8ABDB0'; |
327 | 327 | break; |
@@ -389,7 +389,7 @@ discard block |
||
389 | 389 | $db = new DatabaseConnect(); |
390 | 390 | $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid . "'"); |
391 | 391 | |
392 | - if ($result->num_rows > 0) |
|
392 | + if($result->num_rows > 0) |
|
393 | 393 | { |
394 | 394 | // output data of each row |
395 | 395 | while($row = $result->fetch_assoc()) |
@@ -428,7 +428,7 @@ discard block |
||
428 | 428 | expiration_date='" . $expiration_date . "' |
429 | 429 | WHERE device_uid='" . $device_uid . "'"); |
430 | 430 | |
431 | - if($result === false){ |
|
431 | + if($result === false) { |
|
432 | 432 | error_log("Adding account failed: (" . $db->errno . ") " . $db->error); |
433 | 433 | } |
434 | 434 | } |
@@ -438,11 +438,11 @@ discard block |
||
438 | 438 | function getAccessToken() |
439 | 439 | { |
440 | 440 | $db = new DatabaseConnect(); |
441 | - $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid . "'"); |
|
441 | + $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid . "'"); |
|
442 | 442 | |
443 | 443 | $accessToken; |
444 | 444 | |
445 | - if ($result->num_rows > 0) |
|
445 | + if($result->num_rows > 0) |
|
446 | 446 | { |
447 | 447 | // output data of each row |
448 | 448 | while($row = $result->fetch_assoc()) |
@@ -508,7 +508,7 @@ discard block |
||
508 | 508 | $result = $db->query("INSERT INTO votes (device_uid, postId, type) |
509 | 509 | VALUES ('" . $this->deviceUid . "','" . $postId . "','" . $voteType . "')"); |
510 | 510 | |
511 | - if($result === false){ |
|
511 | + if($result === false) { |
|
512 | 512 | $error = db_error(); |
513 | 513 | echo $error; |
514 | 514 | echo "Adding Vote failed: (" . $result->errno . ") " . $result->error; |
@@ -536,11 +536,11 @@ discard block |
||
536 | 536 | $result = $db->query("INSERT INTO accounts (access_token, refresh_token, token_type, |
537 | 537 | expires_in, expiration_date, distinct_id, device_uid, name, lat, lng) |
538 | 538 | VALUES ('" . $access_token . "','" . $refresh_token . "','" . $token_type . |
539 | - "','" . $expires_in . "','" . $expiration_date . "','" . $distinct_id . |
|
539 | + "','" . $expires_in . "','" . $expiration_date . "','" . $distinct_id . |
|
540 | 540 | "','" . $device_uid . "','" . $name . "','" . $lat . "','" . $lng . "') "); |
541 | 541 | |
542 | 542 | $success = TRUE; |
543 | - if($result === false){ |
|
543 | + if($result === false) { |
|
544 | 544 | $error = $db->error(); |
545 | 545 | echo $error; |
546 | 546 | echo "Adding account failed: (" . $result->errno . ") " . $result->error; |