@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | // Redirection 3xx |
57 | 57 | 300 => 'Multiple Choices', |
58 | 58 | 301 => 'Moved Permanently', |
59 | - 302 => 'Found', // 1.1 |
|
59 | + 302 => 'Found', // 1.1 |
|
60 | 60 | 303 => 'See Other', |
61 | 61 | 304 => 'Not Modified', |
62 | 62 | 305 => 'Use Proxy', |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | $this->body = $body; |
178 | 178 | |
179 | 179 | // Set the HTTP version |
180 | - if (! preg_match('|^\d\.\d$|', $version)) { |
|
180 | + if (!preg_match('|^\d\.\d$|', $version)) { |
|
181 | 181 | require_once 'Zend/Http/Exception.php'; |
182 | 182 | throw new Zend_Http_Exception("Invalid HTTP response version: $version"); |
183 | 183 | } |
@@ -352,7 +352,7 @@ discard block |
||
352 | 352 | public function getHeader($header) |
353 | 353 | { |
354 | 354 | $header = ucwords(strtolower($header)); |
355 | - if (! is_string($header) || ! isset($this->headers[$header])) return null; |
|
355 | + if (!is_string($header) || !isset($this->headers[$header])) return null; |
|
356 | 356 | |
357 | 357 | return $this->headers[$header]; |
358 | 358 | } |
@@ -424,7 +424,7 @@ discard block |
||
424 | 424 | public static function responseCodeAsText($code = null, $http11 = true) |
425 | 425 | { |
426 | 426 | $messages = self::$messages; |
427 | - if (! $http11) $messages[302] = 'Moved Temporarily'; |
|
427 | + if (!$http11) $messages[302] = 'Moved Temporarily'; |
|
428 | 428 | |
429 | 429 | if ($code === null) { |
430 | 430 | return $messages; |
@@ -446,7 +446,7 @@ discard block |
||
446 | 446 | preg_match("|^HTTP/[\d\.x]+ (\d+)|", $response_str, $m); |
447 | 447 | |
448 | 448 | if (isset($m[1])) { |
449 | - return (int) $m[1]; |
|
449 | + return (int)$m[1]; |
|
450 | 450 | } else { |
451 | 451 | return false; |
452 | 452 | } |
@@ -498,14 +498,14 @@ discard block |
||
498 | 498 | |
499 | 499 | // First, split body and headers |
500 | 500 | $parts = preg_split('|(?:\r?\n){2}|m', $response_str, 2); |
501 | - if (! $parts[0]) return $headers; |
|
501 | + if (!$parts[0]) return $headers; |
|
502 | 502 | |
503 | 503 | // Split headers part to lines |
504 | 504 | $lines = explode("\n", $parts[0]); |
505 | 505 | unset($parts); |
506 | 506 | $last_header = null; |
507 | 507 | |
508 | - foreach($lines as $line) { |
|
508 | + foreach ($lines as $line) { |
|
509 | 509 | $line = trim($line, "\r\n"); |
510 | 510 | if ($line == "") break; |
511 | 511 | |
@@ -516,7 +516,7 @@ discard block |
||
516 | 516 | $h_value = $m[2]; |
517 | 517 | |
518 | 518 | if (isset($headers[$h_name])) { |
519 | - if (! is_array($headers[$h_name])) { |
|
519 | + if (!is_array($headers[$h_name])) { |
|
520 | 520 | $headers[$h_name] = array($headers[$h_name]); |
521 | 521 | } |
522 | 522 | |
@@ -567,14 +567,14 @@ discard block |
||
567 | 567 | // If mbstring overloads substr and strlen functions, we have to |
568 | 568 | // override it's internal encoding |
569 | 569 | if (function_exists('mb_internal_encoding') && |
570 | - ((int) ini_get('mbstring.func_overload')) & 2) { |
|
570 | + ((int)ini_get('mbstring.func_overload')) & 2) { |
|
571 | 571 | |
572 | 572 | $mbIntEnc = mb_internal_encoding(); |
573 | 573 | mb_internal_encoding('ASCII'); |
574 | 574 | } |
575 | 575 | |
576 | 576 | while (trim($body)) { |
577 | - if (! preg_match("/^([\da-fA-F]+)[^\r\n]*\r\n/sm", $body, $m)) { |
|
577 | + if (!preg_match("/^([\da-fA-F]+)[^\r\n]*\r\n/sm", $body, $m)) { |
|
578 | 578 | require_once 'Zend/Http/Exception.php'; |
579 | 579 | throw new Zend_Http_Exception("Error parsing body - doesn't seem to be a chunked message"); |
580 | 580 | } |
@@ -602,7 +602,7 @@ discard block |
||
602 | 602 | */ |
603 | 603 | public static function decodeGzip($body) |
604 | 604 | { |
605 | - if (! function_exists('gzinflate')) { |
|
605 | + if (!function_exists('gzinflate')) { |
|
606 | 606 | require_once 'Zend/Http/Exception.php'; |
607 | 607 | throw new Zend_Http_Exception( |
608 | 608 | 'zlib extension is required in order to decode "gzip" encoding' |
@@ -622,7 +622,7 @@ discard block |
||
622 | 622 | */ |
623 | 623 | public static function decodeDeflate($body) |
624 | 624 | { |
625 | - if (! function_exists('gzuncompress')) { |
|
625 | + if (!function_exists('gzuncompress')) { |
|
626 | 626 | require_once 'Zend/Http/Exception.php'; |
627 | 627 | throw new Zend_Http_Exception( |
628 | 628 | 'zlib extension is required in order to decode "deflate" encoding' |
@@ -352,7 +352,9 @@ discard block |
||
352 | 352 | public function getHeader($header) |
353 | 353 | { |
354 | 354 | $header = ucwords(strtolower($header)); |
355 | - if (! is_string($header) || ! isset($this->headers[$header])) return null; |
|
355 | + if (! is_string($header) || ! isset($this->headers[$header])) { |
|
356 | + return null; |
|
357 | + } |
|
356 | 358 | |
357 | 359 | return $this->headers[$header]; |
358 | 360 | } |
@@ -375,10 +377,9 @@ discard block |
||
375 | 377 | // Iterate over the headers and stringify them |
376 | 378 | foreach ($this->headers as $name => $value) |
377 | 379 | { |
378 | - if (is_string($value)) |
|
379 | - $str .= "{$name}: {$value}{$br}"; |
|
380 | - |
|
381 | - elseif (is_array($value)) { |
|
380 | + if (is_string($value)) { |
|
381 | + $str .= "{$name}: {$value}{$br}"; |
|
382 | + } elseif (is_array($value)) { |
|
382 | 383 | foreach ($value as $subval) { |
383 | 384 | $str .= "{$name}: {$subval}{$br}"; |
384 | 385 | } |
@@ -424,7 +425,9 @@ discard block |
||
424 | 425 | public static function responseCodeAsText($code = null, $http11 = true) |
425 | 426 | { |
426 | 427 | $messages = self::$messages; |
427 | - if (! $http11) $messages[302] = 'Moved Temporarily'; |
|
428 | + if (! $http11) { |
|
429 | + $messages[302] = 'Moved Temporarily'; |
|
430 | + } |
|
428 | 431 | |
429 | 432 | if ($code === null) { |
430 | 433 | return $messages; |
@@ -498,7 +501,9 @@ discard block |
||
498 | 501 | |
499 | 502 | // First, split body and headers |
500 | 503 | $parts = preg_split('|(?:\r?\n){2}|m', $response_str, 2); |
501 | - if (! $parts[0]) return $headers; |
|
504 | + if (! $parts[0]) { |
|
505 | + return $headers; |
|
506 | + } |
|
502 | 507 | |
503 | 508 | // Split headers part to lines |
504 | 509 | $lines = explode("\n", $parts[0]); |
@@ -507,7 +512,9 @@ discard block |
||
507 | 512 | |
508 | 513 | foreach($lines as $line) { |
509 | 514 | $line = trim($line, "\r\n"); |
510 | - if ($line == "") break; |
|
515 | + if ($line == "") { |
|
516 | + break; |
|
517 | + } |
|
511 | 518 | |
512 | 519 | // Locate headers like 'Location: ...' and 'Location:...' (note the missing space) |
513 | 520 | if (preg_match("|^([\w-]+):\s*(.+)|", $line, $m)) { |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | public function __construct($code, $headers, $body = null, $version = '1.1', $message = null) |
140 | 140 | { |
141 | 141 | |
142 | - if(is_resource($body)) { |
|
142 | + if (is_resource($body)) { |
|
143 | 143 | $this->setStream($body); |
144 | 144 | $body = ''; |
145 | 145 | } |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | */ |
178 | 178 | public function getBody() |
179 | 179 | { |
180 | - if($this->stream != null) { |
|
180 | + if ($this->stream != null) { |
|
181 | 181 | $this->readStream(); |
182 | 182 | } |
183 | 183 | return parent::getBody(); |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | */ |
194 | 194 | public function getRawBody() |
195 | 195 | { |
196 | - if($this->stream) { |
|
196 | + if ($this->stream) { |
|
197 | 197 | $this->readStream(); |
198 | 198 | } |
199 | 199 | return $this->body; |
@@ -208,11 +208,11 @@ discard block |
||
208 | 208 | */ |
209 | 209 | protected function readStream() |
210 | 210 | { |
211 | - if(!is_resource($this->stream)) { |
|
211 | + if (!is_resource($this->stream)) { |
|
212 | 212 | return ''; |
213 | 213 | } |
214 | 214 | |
215 | - if(isset($headers['content-length'])) { |
|
215 | + if (isset($headers['content-length'])) { |
|
216 | 216 | $this->body = stream_get_contents($this->stream, $headers['content-length']); |
217 | 217 | } else { |
218 | 218 | $this->body = stream_get_contents($this->stream); |
@@ -223,11 +223,11 @@ discard block |
||
223 | 223 | |
224 | 224 | public function __destruct() |
225 | 225 | { |
226 | - if(is_resource($this->stream)) { |
|
226 | + if (is_resource($this->stream)) { |
|
227 | 227 | fclose($this->stream); |
228 | 228 | $this->stream = null; |
229 | 229 | } |
230 | - if($this->_cleanup) { |
|
230 | + if ($this->_cleanup) { |
|
231 | 231 | @unlink($this->stream_name); |
232 | 232 | } |
233 | 233 | } |
@@ -694,8 +694,8 @@ discard block |
||
694 | 694 | $this->cookiejar->addCookie($cookie); |
695 | 695 | } elseif (is_string($cookie) && $value !== null) { |
696 | 696 | $cookie = Zend_Http_Cookie::fromString("{$cookie}={$value}", |
697 | - $this->uri, |
|
698 | - $this->config['encodecookies']); |
|
697 | + $this->uri, |
|
698 | + $this->config['encodecookies']); |
|
699 | 699 | $this->cookiejar->addCookie($cookie); |
700 | 700 | } |
701 | 701 | } else { |
@@ -984,7 +984,7 @@ discard block |
||
984 | 984 | if(!is_string($this->_stream_name)) { |
985 | 985 | // If name is not given, create temp name |
986 | 986 | $this->_stream_name = tempnam(isset($this->config['stream_tmp_dir'])?$this->config['stream_tmp_dir']:sys_get_temp_dir(), |
987 | - 'Zend_Http_Client'); |
|
987 | + 'Zend_Http_Client'); |
|
988 | 988 | } |
989 | 989 | |
990 | 990 | if (false === ($fp = @fopen($this->_stream_name, "w+b"))) { |
@@ -1030,9 +1030,9 @@ discard block |
||
1030 | 1030 | $uri = clone $this->uri; |
1031 | 1031 | if (! empty($this->paramsGet)) { |
1032 | 1032 | $query = $uri->getQuery(); |
1033 | - if (! empty($query)) { |
|
1034 | - $query .= '&'; |
|
1035 | - } |
|
1033 | + if (! empty($query)) { |
|
1034 | + $query .= '&'; |
|
1035 | + } |
|
1036 | 1036 | $query .= http_build_query($this->paramsGet, null, '&'); |
1037 | 1037 | if ($this->config['rfc3986_strict']) { |
1038 | 1038 | $query = str_replace('+', '%20', $query); |
@@ -318,7 +318,7 @@ discard block |
||
318 | 318 | } |
319 | 319 | |
320 | 320 | // We have no ports, set the defaults |
321 | - if (! $uri->getPort()) { |
|
321 | + if (!$uri->getPort()) { |
|
322 | 322 | $uri->setPort(($uri->getScheme() == 'https' ? 443 : 80)); |
323 | 323 | } |
324 | 324 | |
@@ -354,7 +354,7 @@ discard block |
||
354 | 354 | if ($config instanceof Zend_Config) { |
355 | 355 | $config = $config->toArray(); |
356 | 356 | |
357 | - } elseif (! is_array($config)) { |
|
357 | + } elseif (!is_array($config)) { |
|
358 | 358 | /** @see Zend_Http_Client_Exception */ |
359 | 359 | require_once 'Zend/Http/Client/Exception.php'; |
360 | 360 | throw new Zend_Http_Client_Exception('Array or Zend_Config object expected, got ' . gettype($config)); |
@@ -385,7 +385,7 @@ discard block |
||
385 | 385 | */ |
386 | 386 | public function setMethod($method = self::GET) |
387 | 387 | { |
388 | - if (! preg_match('/^[^\x00-\x1f\x7f-\xff\(\)<>@,;:\\\\"\/\[\]\?={}\s]+$/', $method)) { |
|
388 | + if (!preg_match('/^[^\x00-\x1f\x7f-\xff\(\)<>@,;:\\\\"\/\[\]\?={}\s]+$/', $method)) { |
|
389 | 389 | require_once 'Zend/Http/Client/Exception.php'; |
390 | 390 | throw new Zend_Http_Client_Exception("'{$method}' is not a valid HTTP request method."); |
391 | 391 | } |
@@ -442,7 +442,7 @@ discard block |
||
442 | 442 | } |
443 | 443 | |
444 | 444 | // Make sure the name is valid if we are in strict mode |
445 | - if ($this->config['strict'] && (! preg_match('/^[a-zA-Z0-9-]+$/', $name))) { |
|
445 | + if ($this->config['strict'] && (!preg_match('/^[a-zA-Z0-9-]+$/', $name))) { |
|
446 | 446 | /** @see Zend_Http_Client_Exception */ |
447 | 447 | require_once 'Zend/Http/Client/Exception.php'; |
448 | 448 | throw new Zend_Http_Client_Exception("{$name} is not a valid HTTP header name"); |
@@ -542,7 +542,7 @@ discard block |
||
542 | 542 | break; |
543 | 543 | case 'post': |
544 | 544 | $parray = &$this->paramsPost; |
545 | - if ( $value === null ) { |
|
545 | + if ($value === null) { |
|
546 | 546 | if (isset($this->body_field_order[$name])) |
547 | 547 | unset($this->body_field_order[$name]); |
548 | 548 | } else { |
@@ -605,15 +605,15 @@ discard block |
||
605 | 605 | // Else, set up authentication |
606 | 606 | } else { |
607 | 607 | // Check we got a proper authentication type |
608 | - if (! defined('self::AUTH_' . strtoupper($type))) { |
|
608 | + if (!defined('self::AUTH_' . strtoupper($type))) { |
|
609 | 609 | /** @see Zend_Http_Client_Exception */ |
610 | 610 | require_once 'Zend/Http/Client/Exception.php'; |
611 | 611 | throw new Zend_Http_Client_Exception("Invalid or not supported authentication type: '$type'"); |
612 | 612 | } |
613 | 613 | |
614 | 614 | $this->auth = array( |
615 | - 'user' => (string) $user, |
|
616 | - 'password' => (string) $password, |
|
615 | + 'user' => (string)$user, |
|
616 | + 'password' => (string)$password, |
|
617 | 617 | 'type' => $type |
618 | 618 | ); |
619 | 619 | } |
@@ -639,7 +639,7 @@ discard block |
||
639 | 639 | $this->cookiejar = $cookiejar; |
640 | 640 | } elseif ($cookiejar === true) { |
641 | 641 | $this->cookiejar = new Zend_Http_CookieJar(); |
642 | - } elseif (! $cookiejar) { |
|
642 | + } elseif (!$cookiejar) { |
|
643 | 643 | $this->cookiejar = null; |
644 | 644 | } else { |
645 | 645 | /** @see Zend_Http_Client_Exception */ |
@@ -713,7 +713,7 @@ discard block |
||
713 | 713 | |
714 | 714 | $value = addslashes($value); |
715 | 715 | |
716 | - if (! isset($this->headers['cookie'])) { |
|
716 | + if (!isset($this->headers['cookie'])) { |
|
717 | 717 | $this->headers['cookie'] = array('Cookie', ''); |
718 | 718 | } |
719 | 719 | $this->headers['cookie'][1] .= $cookie . '=' . $value . '; '; |
@@ -751,7 +751,7 @@ discard block |
||
751 | 751 | throw new Zend_Http_Client_Exception("Unable to read file '{$filename}' for upload"); |
752 | 752 | } |
753 | 753 | |
754 | - if (! $ctype) { |
|
754 | + if (!$ctype) { |
|
755 | 755 | $ctype = $this->_detectFileMimeType($filename); |
756 | 756 | } |
757 | 757 | } |
@@ -805,7 +805,7 @@ discard block |
||
805 | 805 | if (is_resource($data)) { |
806 | 806 | // We've got stream data |
807 | 807 | $stat = @fstat($data); |
808 | - if($stat) { |
|
808 | + if ($stat) { |
|
809 | 809 | $this->setHeaders(self::CONTENT_LENGTH, $stat['size']); |
810 | 810 | } |
811 | 811 | } |
@@ -862,7 +862,7 @@ discard block |
||
862 | 862 | $this->raw_post_data = null; |
863 | 863 | $this->enctype = null; |
864 | 864 | |
865 | - if($clearAll) { |
|
865 | + if ($clearAll) { |
|
866 | 866 | $this->headers = array(); |
867 | 867 | $this->last_request = null; |
868 | 868 | $this->last_response = null; |
@@ -926,7 +926,7 @@ discard block |
||
926 | 926 | $adapter = new $adapter; |
927 | 927 | } |
928 | 928 | |
929 | - if (! $adapter instanceof Zend_Http_Client_Adapter_Interface) { |
|
929 | + if (!$adapter instanceof Zend_Http_Client_Adapter_Interface) { |
|
930 | 930 | /** @see Zend_Http_Client_Exception */ |
931 | 931 | require_once 'Zend/Http/Client/Exception.php'; |
932 | 932 | throw new Zend_Http_Client_Exception('Passed adapter is not a HTTP connection adapter'); |
@@ -981,9 +981,9 @@ discard block |
||
981 | 981 | protected function _openTempStream() |
982 | 982 | { |
983 | 983 | $this->_stream_name = $this->config['output_stream']; |
984 | - if(!is_string($this->_stream_name)) { |
|
984 | + if (!is_string($this->_stream_name)) { |
|
985 | 985 | // If name is not given, create temp name |
986 | - $this->_stream_name = tempnam(isset($this->config['stream_tmp_dir'])?$this->config['stream_tmp_dir']:sys_get_temp_dir(), |
|
986 | + $this->_stream_name = tempnam(isset($this->config['stream_tmp_dir']) ? $this->config['stream_tmp_dir'] : sys_get_temp_dir(), |
|
987 | 987 | 'Zend_Http_Client'); |
988 | 988 | } |
989 | 989 | |
@@ -1007,7 +1007,7 @@ discard block |
||
1007 | 1007 | */ |
1008 | 1008 | public function request($method = null) |
1009 | 1009 | { |
1010 | - if (! $this->uri instanceof Zend_Uri_Http) { |
|
1010 | + if (!$this->uri instanceof Zend_Uri_Http) { |
|
1011 | 1011 | /** @see Zend_Http_Client_Exception */ |
1012 | 1012 | require_once 'Zend/Http/Client/Exception.php'; |
1013 | 1013 | throw new Zend_Http_Client_Exception('No valid URI has been passed to the client'); |
@@ -1028,9 +1028,9 @@ discard block |
||
1028 | 1028 | do { |
1029 | 1029 | // Clone the URI and add the additional GET parameters to it |
1030 | 1030 | $uri = clone $this->uri; |
1031 | - if (! empty($this->paramsGet)) { |
|
1031 | + if (!empty($this->paramsGet)) { |
|
1032 | 1032 | $query = $uri->getQuery(); |
1033 | - if (! empty($query)) { |
|
1033 | + if (!empty($query)) { |
|
1034 | 1034 | $query .= '&'; |
1035 | 1035 | } |
1036 | 1036 | $query .= http_build_query($this->paramsGet, null, '&'); |
@@ -1054,7 +1054,7 @@ discard block |
||
1054 | 1054 | $headers = $this->_prepareHeaders(); |
1055 | 1055 | |
1056 | 1056 | // check that adapter supports streaming before using it |
1057 | - if(is_resource($body) && !($this->adapter instanceof Zend_Http_Client_Adapter_Stream)) { |
|
1057 | + if (is_resource($body) && !($this->adapter instanceof Zend_Http_Client_Adapter_Stream)) { |
|
1058 | 1058 | /** @see Zend_Http_Client_Exception */ |
1059 | 1059 | require_once 'Zend/Http/Client/Exception.php'; |
1060 | 1060 | throw new Zend_Http_Client_Exception('Adapter does not support streaming'); |
@@ -1064,8 +1064,8 @@ discard block |
||
1064 | 1064 | $this->adapter->connect($uri->getHost(), $uri->getPort(), |
1065 | 1065 | ($uri->getScheme() == 'https' ? true : false)); |
1066 | 1066 | |
1067 | - if($this->config['output_stream']) { |
|
1068 | - if($this->adapter instanceof Zend_Http_Client_Adapter_Stream) { |
|
1067 | + if ($this->config['output_stream']) { |
|
1068 | + if ($this->adapter instanceof Zend_Http_Client_Adapter_Stream) { |
|
1069 | 1069 | $stream = $this->_openTempStream(); |
1070 | 1070 | $this->adapter->setOutputStream($stream); |
1071 | 1071 | } else { |
@@ -1079,13 +1079,13 @@ discard block |
||
1079 | 1079 | $uri, $this->config['httpversion'], $headers, $body); |
1080 | 1080 | |
1081 | 1081 | $response = $this->adapter->read(); |
1082 | - if (! $response) { |
|
1082 | + if (!$response) { |
|
1083 | 1083 | /** @see Zend_Http_Client_Exception */ |
1084 | 1084 | require_once 'Zend/Http/Client/Exception.php'; |
1085 | 1085 | throw new Zend_Http_Client_Exception('Unable to read response, or response is empty'); |
1086 | 1086 | } |
1087 | 1087 | |
1088 | - if($this->config['output_stream']) { |
|
1088 | + if ($this->config['output_stream']) { |
|
1089 | 1089 | $streamMetaData = stream_get_meta_data($stream); |
1090 | 1090 | if ($streamMetaData['seekable']) { |
1091 | 1091 | rewind($stream); |
@@ -1094,7 +1094,7 @@ discard block |
||
1094 | 1094 | $this->adapter->setOutputStream(null); |
1095 | 1095 | $response = Zend_Http_Response_Stream::fromStream($response, $stream); |
1096 | 1096 | $response->setStreamName($this->_stream_name); |
1097 | - if(!is_string($this->config['output_stream'])) { |
|
1097 | + if (!is_string($this->config['output_stream'])) { |
|
1098 | 1098 | // we used temp name, will need to clean up |
1099 | 1099 | $response->setCleanup(true); |
1100 | 1100 | } |
@@ -1121,7 +1121,7 @@ discard block |
||
1121 | 1121 | // Check whether we send the exact same request again, or drop the parameters |
1122 | 1122 | // and send a GET request |
1123 | 1123 | if ($response->getStatus() == 303 || |
1124 | - ((! $this->config['strictredirects']) && ($response->getStatus() == 302 || |
|
1124 | + ((!$this->config['strictredirects']) && ($response->getStatus() == 302 || |
|
1125 | 1125 | $response->getStatus() == 301))) { |
1126 | 1126 | |
1127 | 1127 | $this->resetParameters(); |
@@ -1144,7 +1144,7 @@ discard block |
||
1144 | 1144 | $this->uri->setQuery($query); |
1145 | 1145 | |
1146 | 1146 | // Else, if we got just an absolute path, set it |
1147 | - if(strpos($location, '/') === 0) { |
|
1147 | + if (strpos($location, '/') === 0) { |
|
1148 | 1148 | $this->uri->setPath($location); |
1149 | 1149 | |
1150 | 1150 | // Else, assume we have a relative path |
@@ -1177,11 +1177,11 @@ discard block |
||
1177 | 1177 | $headers = array(); |
1178 | 1178 | |
1179 | 1179 | // Set the host header |
1180 | - if (! isset($this->headers['host'])) { |
|
1180 | + if (!isset($this->headers['host'])) { |
|
1181 | 1181 | $host = $this->uri->getHost(); |
1182 | 1182 | |
1183 | 1183 | // If the port is not default, add it |
1184 | - if (! (($this->uri->getScheme() == 'http' && $this->uri->getPort() == 80) || |
|
1184 | + if (!(($this->uri->getScheme() == 'http' && $this->uri->getPort() == 80) || |
|
1185 | 1185 | ($this->uri->getScheme() == 'https' && $this->uri->getPort() == 443))) { |
1186 | 1186 | $host .= ':' . $this->uri->getPort(); |
1187 | 1187 | } |
@@ -1190,15 +1190,15 @@ discard block |
||
1190 | 1190 | } |
1191 | 1191 | |
1192 | 1192 | // Set the connection header |
1193 | - if (! isset($this->headers['connection'])) { |
|
1194 | - if (! $this->config['keepalive']) { |
|
1193 | + if (!isset($this->headers['connection'])) { |
|
1194 | + if (!$this->config['keepalive']) { |
|
1195 | 1195 | $headers[] = "Connection: close"; |
1196 | 1196 | } |
1197 | 1197 | } |
1198 | 1198 | |
1199 | 1199 | // Set the Accept-encoding header if not set - depending on whether |
1200 | 1200 | // zlib is available or not. |
1201 | - if (! isset($this->headers['accept-encoding'])) { |
|
1201 | + if (!isset($this->headers['accept-encoding'])) { |
|
1202 | 1202 | if (function_exists('gzinflate')) { |
1203 | 1203 | $headers[] = 'Accept-encoding: gzip, deflate'; |
1204 | 1204 | } else { |
@@ -1208,13 +1208,13 @@ discard block |
||
1208 | 1208 | |
1209 | 1209 | // Set the Content-Type header |
1210 | 1210 | if (($this->method == self::POST || $this->method == self::PUT) && |
1211 | - (! isset($this->headers[strtolower(self::CONTENT_TYPE)]) && isset($this->enctype))) { |
|
1211 | + (!isset($this->headers[strtolower(self::CONTENT_TYPE)]) && isset($this->enctype))) { |
|
1212 | 1212 | |
1213 | 1213 | $headers[] = self::CONTENT_TYPE . ': ' . $this->enctype; |
1214 | 1214 | } |
1215 | 1215 | |
1216 | 1216 | // Set the user agent header |
1217 | - if (! isset($this->headers['user-agent']) && isset($this->config['useragent'])) { |
|
1217 | + if (!isset($this->headers['user-agent']) && isset($this->config['useragent'])) { |
|
1218 | 1218 | $headers[] = "User-Agent: {$this->config['useragent']}"; |
1219 | 1219 | } |
1220 | 1220 | |
@@ -1266,7 +1266,7 @@ discard block |
||
1266 | 1266 | // If mbstring overloads substr and strlen functions, we have to |
1267 | 1267 | // override it's internal encoding |
1268 | 1268 | if (function_exists('mb_internal_encoding') && |
1269 | - ((int) ini_get('mbstring.func_overload')) & 2) { |
|
1269 | + ((int)ini_get('mbstring.func_overload')) & 2) { |
|
1270 | 1270 | |
1271 | 1271 | $mbIntEnc = mb_internal_encoding(); |
1272 | 1272 | mb_internal_encoding('ASCII'); |
@@ -1285,13 +1285,13 @@ discard block |
||
1285 | 1285 | $body = ''; |
1286 | 1286 | |
1287 | 1287 | // If we have files to upload, force enctype to multipart/form-data |
1288 | - if (count ($this->files) > 0) { |
|
1288 | + if (count($this->files) > 0) { |
|
1289 | 1289 | $this->setEncType(self::ENC_FORMDATA); |
1290 | 1290 | } |
1291 | 1291 | |
1292 | 1292 | // If we have POST parameters or files, encode and add them to the body |
1293 | 1293 | if (count($this->paramsPost) > 0 || count($this->files) > 0) { |
1294 | - switch($this->enctype) { |
|
1294 | + switch ($this->enctype) { |
|
1295 | 1295 | case self::ENC_FORMDATA: |
1296 | 1296 | // Encode body as multipart/form-data |
1297 | 1297 | $boundary = '---ZENDHTTPCLIENT-' . md5(microtime()); |
@@ -1302,7 +1302,7 @@ discard block |
||
1302 | 1302 | switch ($fieldType) { |
1303 | 1303 | case self::VTYPE_FILE: |
1304 | 1304 | foreach ($this->files as $file) { |
1305 | - if ($file['formname']===$fieldName) { |
|
1305 | + if ($file['formname'] === $fieldName) { |
|
1306 | 1306 | $fhead = array(self::CONTENT_TYPE => $file['ctype']); |
1307 | 1307 | $body .= self::encodeFormData($boundary, $file['formname'], $file['data'], $file['filename'], $fhead); |
1308 | 1308 | } |
@@ -1377,10 +1377,10 @@ discard block |
||
1377 | 1377 | protected function _getParametersRecursive($parray, $urlencode = false) |
1378 | 1378 | { |
1379 | 1379 | // Issue a deprecated notice |
1380 | - trigger_error("The " . __METHOD__ . " method is deprecated and will be dropped in 2.0.", |
|
1380 | + trigger_error("The " . __METHOD__ . " method is deprecated and will be dropped in 2.0.", |
|
1381 | 1381 | E_USER_NOTICE); |
1382 | 1382 | |
1383 | - if (! is_array($parray)) { |
|
1383 | + if (!is_array($parray)) { |
|
1384 | 1384 | return $parray; |
1385 | 1385 | } |
1386 | 1386 | $parameters = array(); |
@@ -1443,7 +1443,7 @@ discard block |
||
1443 | 1443 | } |
1444 | 1444 | |
1445 | 1445 | // Fallback to the default application/octet-stream |
1446 | - if (! $type) { |
|
1446 | + if (!$type) { |
|
1447 | 1447 | $type = 'application/octet-stream'; |
1448 | 1448 | } |
1449 | 1449 | |
@@ -1463,7 +1463,7 @@ discard block |
||
1463 | 1463 | public static function encodeFormData($boundary, $name, $value, $filename = null, $headers = array()) |
1464 | 1464 | { |
1465 | 1465 | $ret = "--{$boundary}\r\n" . |
1466 | - 'Content-Disposition: form-data; name="' . $name .'"'; |
|
1466 | + 'Content-Disposition: form-data; name="' . $name . '"'; |
|
1467 | 1467 | |
1468 | 1468 | if ($filename) { |
1469 | 1469 | $ret .= '; filename="' . $filename . '"'; |
@@ -1538,13 +1538,13 @@ discard block |
||
1538 | 1538 | */ |
1539 | 1539 | protected static function _flattenParametersArray($parray, $prefix = null) |
1540 | 1540 | { |
1541 | - if (! is_array($parray)) { |
|
1541 | + if (!is_array($parray)) { |
|
1542 | 1542 | return $parray; |
1543 | 1543 | } |
1544 | 1544 | |
1545 | 1545 | $parameters = array(); |
1546 | 1546 | |
1547 | - foreach($parray as $name => $value) { |
|
1547 | + foreach ($parray as $name => $value) { |
|
1548 | 1548 | |
1549 | 1549 | // Calculate array key |
1550 | 1550 | if ($prefix) { |
@@ -496,8 +496,9 @@ discard block |
||
496 | 496 | public function setParameterGet($name, $value = null) |
497 | 497 | { |
498 | 498 | if (is_array($name)) { |
499 | - foreach ($name as $k => $v) |
|
500 | - $this->_setParameter('GET', $k, $v); |
|
499 | + foreach ($name as $k => $v) { |
|
500 | + $this->_setParameter('GET', $k, $v); |
|
501 | + } |
|
501 | 502 | } else { |
502 | 503 | $this->_setParameter('GET', $name, $value); |
503 | 504 | } |
@@ -515,8 +516,9 @@ discard block |
||
515 | 516 | public function setParameterPost($name, $value = null) |
516 | 517 | { |
517 | 518 | if (is_array($name)) { |
518 | - foreach ($name as $k => $v) |
|
519 | - $this->_setParameter('POST', $k, $v); |
|
519 | + foreach ($name as $k => $v) { |
|
520 | + $this->_setParameter('POST', $k, $v); |
|
521 | + } |
|
520 | 522 | } else { |
521 | 523 | $this->_setParameter('POST', $name, $value); |
522 | 524 | } |
@@ -543,8 +545,9 @@ discard block |
||
543 | 545 | case 'post': |
544 | 546 | $parray = &$this->paramsPost; |
545 | 547 | if ( $value === null ) { |
546 | - if (isset($this->body_field_order[$name])) |
|
547 | - unset($this->body_field_order[$name]); |
|
548 | + if (isset($this->body_field_order[$name])) { |
|
549 | + unset($this->body_field_order[$name]); |
|
550 | + } |
|
548 | 551 | } else { |
549 | 552 | $this->body_field_order[$name] = self::VTYPE_SCALAR; |
550 | 553 | } |
@@ -552,7 +555,9 @@ discard block |
||
552 | 555 | } |
553 | 556 | |
554 | 557 | if ($value === null) { |
555 | - if (isset($parray[$name])) unset($parray[$name]); |
|
558 | + if (isset($parray[$name])) { |
|
559 | + unset($parray[$name]); |
|
560 | + } |
|
556 | 561 | } else { |
557 | 562 | $parray[$name] = $value; |
558 | 563 | } |
@@ -966,7 +966,7 @@ |
||
966 | 966 | if ($options instanceof Zend_Config) { |
967 | 967 | $options = $options->toArray(); |
968 | 968 | } else if (!is_array($options)) { |
969 | - $temp = array(); |
|
969 | + $temp = array(); |
|
970 | 970 | |
971 | 971 | $options = func_get_args(); |
972 | 972 | $temp['allow'] = array_shift($options); |
@@ -85,12 +85,12 @@ discard block |
||
85 | 85 | /** |
86 | 86 | * Allows Internet domain names (e.g., example.com) |
87 | 87 | */ |
88 | - const ALLOW_DNS = 1; |
|
88 | + const ALLOW_DNS = 1; |
|
89 | 89 | |
90 | 90 | /** |
91 | 91 | * Allows IP addresses |
92 | 92 | */ |
93 | - const ALLOW_IP = 2; |
|
93 | + const ALLOW_IP = 2; |
|
94 | 94 | |
95 | 95 | /** |
96 | 96 | * Allows local network names (e.g., localhost, www.localdomain) |
@@ -1089,9 +1089,9 @@ discard block |
||
1089 | 1089 | * |
1090 | 1090 | * @param boolean $allowed Set allowed to true to validate IDNs, and false to not validate them |
1091 | 1091 | */ |
1092 | - public function setValidateIdn ($allowed) |
|
1092 | + public function setValidateIdn($allowed) |
|
1093 | 1093 | { |
1094 | - $this->_options['idn'] = (bool) $allowed; |
|
1094 | + $this->_options['idn'] = (bool)$allowed; |
|
1095 | 1095 | return $this; |
1096 | 1096 | } |
1097 | 1097 | |
@@ -1112,9 +1112,9 @@ discard block |
||
1112 | 1112 | * |
1113 | 1113 | * @param boolean $allowed Set allowed to true to validate TLDs, and false to not validate them |
1114 | 1114 | */ |
1115 | - public function setValidateTld ($allowed) |
|
1115 | + public function setValidateTld($allowed) |
|
1116 | 1116 | { |
1117 | - $this->_options['tld'] = (bool) $allowed; |
|
1117 | + $this->_options['tld'] = (bool)$allowed; |
|
1118 | 1118 | return $this; |
1119 | 1119 | } |
1120 | 1120 | |
@@ -1217,7 +1217,7 @@ discard block |
||
1217 | 1217 | * @see Zend_Validate_Hostname_Interface |
1218 | 1218 | */ |
1219 | 1219 | $regexChars = array(0 => '/^[a-z0-9\x2d]{1,63}$/i'); |
1220 | - if ($this->_options['idn'] && isset($this->_validIdns[strtoupper($this->_tld)])) { |
|
1220 | + if ($this->_options['idn'] && isset($this->_validIdns[strtoupper($this->_tld)])) { |
|
1221 | 1221 | if (is_string($this->_validIdns[strtoupper($this->_tld)])) { |
1222 | 1222 | $regexChars += include($this->_validIdns[strtoupper($this->_tld)]); |
1223 | 1223 | } else { |
@@ -1253,7 +1253,7 @@ discard block |
||
1253 | 1253 | |
1254 | 1254 | // Check each domain part |
1255 | 1255 | $checked = false; |
1256 | - foreach($regexChars as $regexKey => $regexChar) { |
|
1256 | + foreach ($regexChars as $regexKey => $regexChar) { |
|
1257 | 1257 | $status = @preg_match($regexChar, $domainPart); |
1258 | 1258 | if ($status > 0) { |
1259 | 1259 | $length = 63; |
@@ -1369,7 +1369,7 @@ discard block |
||
1369 | 1369 | $char = 0x80; |
1370 | 1370 | |
1371 | 1371 | for ($indexe = ($separator) ? ($separator + 1) : 0; $indexe < $lengthe; ++$lengthd) { |
1372 | - for ($old_index = $index, $pos = 1, $key = 36; 1 ; $key += 36) { |
|
1372 | + for ($old_index = $index, $pos = 1, $key = 36; 1; $key += 36) { |
|
1373 | 1373 | $hex = ord($encoded[$indexe++]); |
1374 | 1374 | $digit = ($hex - 48 < 10) ? $hex - 22 |
1375 | 1375 | : (($hex - 65 < 26) ? $hex - 65 |
@@ -1382,7 +1382,7 @@ discard block |
||
1382 | 1382 | break; |
1383 | 1383 | } |
1384 | 1384 | |
1385 | - $pos = (int) ($pos * (36 - $tag)); |
|
1385 | + $pos = (int)($pos * (36 - $tag)); |
|
1386 | 1386 | } |
1387 | 1387 | |
1388 | 1388 | $delta = intval($init ? (($index - $old_index) / 700) : (($index - $old_index) / 2)); |
@@ -1393,7 +1393,7 @@ discard block |
||
1393 | 1393 | |
1394 | 1394 | $base = intval($key + 36 * $delta / ($delta + 38)); |
1395 | 1395 | $init = false; |
1396 | - $char += (int) ($index / ($lengthd + 1)); |
|
1396 | + $char += (int)($index / ($lengthd + 1)); |
|
1397 | 1397 | $index %= ($lengthd + 1); |
1398 | 1398 | if ($lengthd > 0) { |
1399 | 1399 | for ($i = $lengthd; $i > $index; $i--) { |
@@ -64,7 +64,7 @@ |
||
64 | 64 | if ($options instanceof Zend_Config) { |
65 | 65 | $options = $options->toArray(); |
66 | 66 | } else if (!is_array($options)) { |
67 | - $temp = array(); |
|
67 | + $temp = array(); |
|
68 | 68 | $options = func_get_args(); |
69 | 69 | $temp['allowipv6'] = array_shift($options); |
70 | 70 | if (!empty($options)) { |
@@ -97,11 +97,11 @@ discard block |
||
97 | 97 | public function setOptions($options) |
98 | 98 | { |
99 | 99 | if (array_key_exists('allowipv6', $options)) { |
100 | - $this->_options['allowipv6'] = (boolean) $options['allowipv6']; |
|
100 | + $this->_options['allowipv6'] = (boolean)$options['allowipv6']; |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | if (array_key_exists('allowipv4', $options)) { |
104 | - $this->_options['allowipv4'] = (boolean) $options['allowipv4']; |
|
104 | + $this->_options['allowipv4'] = (boolean)$options['allowipv4']; |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | if (!$this->_options['allowipv4'] && !$this->_options['allowipv6']) { |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | */ |
146 | 146 | protected function _validateIPv4($value) { |
147 | 147 | $ip2long = ip2long($value); |
148 | - if($ip2long === false) { |
|
148 | + if ($ip2long === false) { |
|
149 | 149 | return false; |
150 | 150 | } |
151 | 151 |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | { |
143 | 143 | if ($messageKey === null) { |
144 | 144 | $keys = array_keys($this->_messageTemplates); |
145 | - foreach($keys as $key) { |
|
145 | + foreach ($keys as $key) { |
|
146 | 146 | $this->setMessage($messageString, $key); |
147 | 147 | } |
148 | 148 | return $this; |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | } elseif (is_array($value)) { |
233 | 233 | $value = $this->_implodeRecursive($value); |
234 | 234 | } else { |
235 | - $value = implode((array) $value); |
|
235 | + $value = implode((array)$value); |
|
236 | 236 | } |
237 | 237 | |
238 | 238 | if ($this->getObscureValue()) { |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | foreach ($this->_messageVariables as $ident => $property) { |
244 | 244 | $message = str_replace( |
245 | 245 | "%$ident%", |
246 | - implode(' ', (array) $this->$property), |
|
246 | + implode(' ', (array)$this->$property), |
|
247 | 247 | $message |
248 | 248 | ); |
249 | 249 | } |
@@ -326,7 +326,7 @@ discard block |
||
326 | 326 | */ |
327 | 327 | public function setObscureValue($flag) |
328 | 328 | { |
329 | - $this->_obscureValue = (bool) $flag; |
|
329 | + $this->_obscureValue = (bool)$flag; |
|
330 | 330 | return $this; |
331 | 331 | } |
332 | 332 | |
@@ -446,7 +446,7 @@ discard block |
||
446 | 446 | */ |
447 | 447 | public function setDisableTranslator($flag) |
448 | 448 | { |
449 | - $this->_translatorDisabled = (bool) $flag; |
|
449 | + $this->_translatorDisabled = (bool)$flag; |
|
450 | 450 | return $this; |
451 | 451 | } |
452 | 452 |
@@ -5,10 +5,10 @@ discard block |
||
5 | 5 | //============ Google Move Code ======================// |
6 | 6 | |
7 | 7 | if ( isset( $_GET['album_download_directory'] ) ) { |
8 | - $album_download_directory = $_GET['album_download_directory']; |
|
9 | - $album_download_directory = '../'.$album_download_directory; |
|
8 | + $album_download_directory = $_GET['album_download_directory']; |
|
9 | + $album_download_directory = '../'.$album_download_directory; |
|
10 | 10 | } else { |
11 | - header('location:../index.php'); |
|
11 | + header('location:../index.php'); |
|
12 | 12 | } |
13 | 13 | |
14 | 14 | require_once 'Zend/Loader.php'; |
@@ -18,10 +18,10 @@ discard block |
||
18 | 18 | |
19 | 19 | |
20 | 20 | function getAuthSubHttpClient() { |
21 | - if ( isset( $_SESSION['google_session_token'] ) ) { |
|
22 | - $client = Zend_Gdata_AuthSub::getHttpClient( $_SESSION['google_session_token'] ); |
|
23 | - return $client; |
|
24 | - } |
|
21 | + if ( isset( $_SESSION['google_session_token'] ) ) { |
|
22 | + $client = Zend_Gdata_AuthSub::getHttpClient( $_SESSION['google_session_token'] ); |
|
23 | + return $client; |
|
24 | + } |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | $gp = new Zend_Gdata_Photos(getAuthSubHttpClient(), "Google-DevelopersGuide-1.0"); |
@@ -29,87 +29,87 @@ discard block |
||
29 | 29 | |
30 | 30 | |
31 | 31 | function add_new_album( $entry, $gp, $album_download_directory, $album_name ) { |
32 | - $new_album_name = str_replace( " ", "_", $album_name ); |
|
33 | - $new_album_name = $new_album_name.'_'.uniqid(); |
|
34 | - |
|
35 | - $entry->setTitle( $gp->newTitle( $new_album_name ) ); |
|
36 | - $entry->setSummary( $gp->newSummary("Album added by Facebook Album Challenge") ); |
|
37 | - $gp->insertAlbumEntry( $entry ); |
|
38 | - |
|
39 | - $path = $album_download_directory.$album_name; |
|
40 | - if ( file_exists( $path ) ) { |
|
41 | - $photos = scandir( $path ); |
|
42 | - |
|
43 | - foreach ( $photos as $photo ) { |
|
44 | - if ( $photo != "." && $photo != ".." ) { |
|
45 | - $photo_path = $path.'/'.$photo; |
|
46 | - add_new_photo_to_album( $gp, $photo_path, $new_album_name ); |
|
47 | - } |
|
48 | - } |
|
49 | - } |
|
32 | + $new_album_name = str_replace( " ", "_", $album_name ); |
|
33 | + $new_album_name = $new_album_name.'_'.uniqid(); |
|
34 | + |
|
35 | + $entry->setTitle( $gp->newTitle( $new_album_name ) ); |
|
36 | + $entry->setSummary( $gp->newSummary("Album added by Facebook Album Challenge") ); |
|
37 | + $gp->insertAlbumEntry( $entry ); |
|
38 | + |
|
39 | + $path = $album_download_directory.$album_name; |
|
40 | + if ( file_exists( $path ) ) { |
|
41 | + $photos = scandir( $path ); |
|
42 | + |
|
43 | + foreach ( $photos as $photo ) { |
|
44 | + if ( $photo != "." && $photo != ".." ) { |
|
45 | + $photo_path = $path.'/'.$photo; |
|
46 | + add_new_photo_to_album( $gp, $photo_path, $new_album_name ); |
|
47 | + } |
|
48 | + } |
|
49 | + } |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | function add_new_photo_to_album( $gp, $path, $new_album_name ) { |
53 | - $user_name = "default"; |
|
54 | - $file_name = $path; |
|
55 | - $photo_name = "Photo added by Facebook Album Challenge"; |
|
56 | - $photo_caption = "Photo added by Facebook Album Challenge"; |
|
57 | - $photo_tags = "Photo, Facebook-Album-Challenge"; |
|
58 | - |
|
59 | - $fd = $gp->newMediaFileSource( $file_name ); |
|
60 | - $fd->setContentType("image/jpeg"); |
|
61 | - |
|
62 | - // Create a PhotoEntry |
|
63 | - $photo_entry = $gp->newPhotoEntry(); |
|
64 | - |
|
65 | - $photo_entry->setMediaSource( $fd ); |
|
66 | - $photo_entry->setTitle( $gp->newTitle( $photo_name ) ); |
|
67 | - $photo_entry->setSummary( $gp->newSummary( $photo_caption ) ); |
|
68 | - |
|
69 | - // add some tags |
|
70 | - $photo_media = new Zend_Gdata_Media_Extension_MediaKeywords(); |
|
71 | - $photo_media->setText( $photo_tags ); |
|
72 | - $photo_entry->mediaGroup = new Zend_Gdata_Media_Extension_MediaGroup(); |
|
73 | - $photo_entry->mediaGroup->keywords = $photo_media; |
|
74 | - |
|
75 | - // We use the AlbumQuery class to generate the URL for the album |
|
76 | - $album_query = $gp->newAlbumQuery(); |
|
77 | - |
|
78 | - $album_query->setUser( $user_name ); |
|
79 | - //$albumQuery->setAlbumId($albumId); |
|
80 | - $album_query->setAlbumName( $new_album_name ); |
|
81 | - |
|
82 | - // We insert the photo, and the server returns the entry representing |
|
83 | - // that photo after it is uploaded |
|
84 | - //$insertedEntry = $gp->insertPhotoEntry( $photoEntry, $albumQuery->getQueryUrl() ); |
|
85 | - $gp->insertPhotoEntry( $photo_entry, $album_query->getQueryUrl() ); |
|
53 | + $user_name = "default"; |
|
54 | + $file_name = $path; |
|
55 | + $photo_name = "Photo added by Facebook Album Challenge"; |
|
56 | + $photo_caption = "Photo added by Facebook Album Challenge"; |
|
57 | + $photo_tags = "Photo, Facebook-Album-Challenge"; |
|
58 | + |
|
59 | + $fd = $gp->newMediaFileSource( $file_name ); |
|
60 | + $fd->setContentType("image/jpeg"); |
|
61 | + |
|
62 | + // Create a PhotoEntry |
|
63 | + $photo_entry = $gp->newPhotoEntry(); |
|
64 | + |
|
65 | + $photo_entry->setMediaSource( $fd ); |
|
66 | + $photo_entry->setTitle( $gp->newTitle( $photo_name ) ); |
|
67 | + $photo_entry->setSummary( $gp->newSummary( $photo_caption ) ); |
|
68 | + |
|
69 | + // add some tags |
|
70 | + $photo_media = new Zend_Gdata_Media_Extension_MediaKeywords(); |
|
71 | + $photo_media->setText( $photo_tags ); |
|
72 | + $photo_entry->mediaGroup = new Zend_Gdata_Media_Extension_MediaGroup(); |
|
73 | + $photo_entry->mediaGroup->keywords = $photo_media; |
|
74 | + |
|
75 | + // We use the AlbumQuery class to generate the URL for the album |
|
76 | + $album_query = $gp->newAlbumQuery(); |
|
77 | + |
|
78 | + $album_query->setUser( $user_name ); |
|
79 | + //$albumQuery->setAlbumId($albumId); |
|
80 | + $album_query->setAlbumName( $new_album_name ); |
|
81 | + |
|
82 | + // We insert the photo, and the server returns the entry representing |
|
83 | + // that photo after it is uploaded |
|
84 | + //$insertedEntry = $gp->insertPhotoEntry( $photoEntry, $albumQuery->getQueryUrl() ); |
|
85 | + $gp->insertPhotoEntry( $photo_entry, $album_query->getQueryUrl() ); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | if ( isset( $album_download_directory ) ) { |
89 | - if ( file_exists( $album_download_directory ) ) { |
|
90 | - $album_names = scandir( $album_download_directory ); |
|
91 | - |
|
92 | - foreach ( $album_names as $album_name ) { |
|
93 | - if ( $album_name != "." && $album_name != "..") { |
|
94 | - add_new_album( $entry, $gp, $album_download_directory, $album_name ); |
|
95 | - } |
|
96 | - } |
|
97 | - |
|
98 | - $unlink_folder = rtrim( $album_download_directory, "/" ); |
|
99 | - require_once('../unlink_directory.php'); |
|
100 | - $unlink_directory = new unlink_directory(); |
|
101 | - $unlink_directory->remove_directory( $unlink_folder ); |
|
102 | - } |
|
103 | - $response = 1; |
|
89 | + if ( file_exists( $album_download_directory ) ) { |
|
90 | + $album_names = scandir( $album_download_directory ); |
|
91 | + |
|
92 | + foreach ( $album_names as $album_name ) { |
|
93 | + if ( $album_name != "." && $album_name != "..") { |
|
94 | + add_new_album( $entry, $gp, $album_download_directory, $album_name ); |
|
95 | + } |
|
96 | + } |
|
97 | + |
|
98 | + $unlink_folder = rtrim( $album_download_directory, "/" ); |
|
99 | + require_once('../unlink_directory.php'); |
|
100 | + $unlink_directory = new unlink_directory(); |
|
101 | + $unlink_directory->remove_directory( $unlink_folder ); |
|
102 | + } |
|
103 | + $response = 1; |
|
104 | 104 | } else { |
105 | - $response = 0; |
|
105 | + $response = 0; |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | |
109 | 109 | if ( isset( $_GET['ajax'] ) ) |
110 | - echo $response; |
|
110 | + echo $response; |
|
111 | 111 | else |
112 | - header('location:../index.php?response='.$response); |
|
112 | + header('location:../index.php?response='.$response); |
|
113 | 113 | |
114 | 114 | |
115 | 115 | ?> |
@@ -4,9 +4,9 @@ discard block |
||
4 | 4 | |
5 | 5 | //============ Google Move Code ======================// |
6 | 6 | |
7 | -if ( isset( $_GET['album_download_directory'] ) ) { |
|
7 | +if (isset($_GET['album_download_directory'])) { |
|
8 | 8 | $album_download_directory = $_GET['album_download_directory']; |
9 | - $album_download_directory = '../'.$album_download_directory; |
|
9 | + $album_download_directory = '../' . $album_download_directory; |
|
10 | 10 | } else { |
11 | 11 | header('location:../index.php'); |
12 | 12 | } |
@@ -18,8 +18,8 @@ discard block |
||
18 | 18 | |
19 | 19 | |
20 | 20 | function getAuthSubHttpClient() { |
21 | - if ( isset( $_SESSION['google_session_token'] ) ) { |
|
22 | - $client = Zend_Gdata_AuthSub::getHttpClient( $_SESSION['google_session_token'] ); |
|
21 | + if (isset($_SESSION['google_session_token'])) { |
|
22 | + $client = Zend_Gdata_AuthSub::getHttpClient($_SESSION['google_session_token']); |
|
23 | 23 | return $client; |
24 | 24 | } |
25 | 25 | } |
@@ -28,77 +28,77 @@ discard block |
||
28 | 28 | $entry = new Zend_Gdata_Photos_AlbumEntry(); |
29 | 29 | |
30 | 30 | |
31 | -function add_new_album( $entry, $gp, $album_download_directory, $album_name ) { |
|
32 | - $new_album_name = str_replace( " ", "_", $album_name ); |
|
33 | - $new_album_name = $new_album_name.'_'.uniqid(); |
|
31 | +function add_new_album($entry, $gp, $album_download_directory, $album_name) { |
|
32 | + $new_album_name = str_replace(" ", "_", $album_name); |
|
33 | + $new_album_name = $new_album_name . '_' . uniqid(); |
|
34 | 34 | |
35 | - $entry->setTitle( $gp->newTitle( $new_album_name ) ); |
|
36 | - $entry->setSummary( $gp->newSummary("Album added by Facebook Album Challenge") ); |
|
37 | - $gp->insertAlbumEntry( $entry ); |
|
35 | + $entry->setTitle($gp->newTitle($new_album_name)); |
|
36 | + $entry->setSummary($gp->newSummary("Album added by Facebook Album Challenge")); |
|
37 | + $gp->insertAlbumEntry($entry); |
|
38 | 38 | |
39 | - $path = $album_download_directory.$album_name; |
|
40 | - if ( file_exists( $path ) ) { |
|
41 | - $photos = scandir( $path ); |
|
39 | + $path = $album_download_directory . $album_name; |
|
40 | + if (file_exists($path)) { |
|
41 | + $photos = scandir($path); |
|
42 | 42 | |
43 | - foreach ( $photos as $photo ) { |
|
44 | - if ( $photo != "." && $photo != ".." ) { |
|
45 | - $photo_path = $path.'/'.$photo; |
|
46 | - add_new_photo_to_album( $gp, $photo_path, $new_album_name ); |
|
43 | + foreach ($photos as $photo) { |
|
44 | + if ($photo != "." && $photo != "..") { |
|
45 | + $photo_path = $path . '/' . $photo; |
|
46 | + add_new_photo_to_album($gp, $photo_path, $new_album_name); |
|
47 | 47 | } |
48 | 48 | } |
49 | 49 | } |
50 | 50 | } |
51 | 51 | |
52 | -function add_new_photo_to_album( $gp, $path, $new_album_name ) { |
|
52 | +function add_new_photo_to_album($gp, $path, $new_album_name) { |
|
53 | 53 | $user_name = "default"; |
54 | 54 | $file_name = $path; |
55 | 55 | $photo_name = "Photo added by Facebook Album Challenge"; |
56 | 56 | $photo_caption = "Photo added by Facebook Album Challenge"; |
57 | 57 | $photo_tags = "Photo, Facebook-Album-Challenge"; |
58 | 58 | |
59 | - $fd = $gp->newMediaFileSource( $file_name ); |
|
59 | + $fd = $gp->newMediaFileSource($file_name); |
|
60 | 60 | $fd->setContentType("image/jpeg"); |
61 | 61 | |
62 | 62 | // Create a PhotoEntry |
63 | 63 | $photo_entry = $gp->newPhotoEntry(); |
64 | 64 | |
65 | - $photo_entry->setMediaSource( $fd ); |
|
66 | - $photo_entry->setTitle( $gp->newTitle( $photo_name ) ); |
|
67 | - $photo_entry->setSummary( $gp->newSummary( $photo_caption ) ); |
|
65 | + $photo_entry->setMediaSource($fd); |
|
66 | + $photo_entry->setTitle($gp->newTitle($photo_name)); |
|
67 | + $photo_entry->setSummary($gp->newSummary($photo_caption)); |
|
68 | 68 | |
69 | 69 | // add some tags |
70 | 70 | $photo_media = new Zend_Gdata_Media_Extension_MediaKeywords(); |
71 | - $photo_media->setText( $photo_tags ); |
|
71 | + $photo_media->setText($photo_tags); |
|
72 | 72 | $photo_entry->mediaGroup = new Zend_Gdata_Media_Extension_MediaGroup(); |
73 | 73 | $photo_entry->mediaGroup->keywords = $photo_media; |
74 | 74 | |
75 | 75 | // We use the AlbumQuery class to generate the URL for the album |
76 | 76 | $album_query = $gp->newAlbumQuery(); |
77 | 77 | |
78 | - $album_query->setUser( $user_name ); |
|
78 | + $album_query->setUser($user_name); |
|
79 | 79 | //$albumQuery->setAlbumId($albumId); |
80 | - $album_query->setAlbumName( $new_album_name ); |
|
80 | + $album_query->setAlbumName($new_album_name); |
|
81 | 81 | |
82 | 82 | // We insert the photo, and the server returns the entry representing |
83 | 83 | // that photo after it is uploaded |
84 | 84 | //$insertedEntry = $gp->insertPhotoEntry( $photoEntry, $albumQuery->getQueryUrl() ); |
85 | - $gp->insertPhotoEntry( $photo_entry, $album_query->getQueryUrl() ); |
|
85 | + $gp->insertPhotoEntry($photo_entry, $album_query->getQueryUrl()); |
|
86 | 86 | } |
87 | 87 | |
88 | -if ( isset( $album_download_directory ) ) { |
|
89 | - if ( file_exists( $album_download_directory ) ) { |
|
90 | - $album_names = scandir( $album_download_directory ); |
|
88 | +if (isset($album_download_directory)) { |
|
89 | + if (file_exists($album_download_directory)) { |
|
90 | + $album_names = scandir($album_download_directory); |
|
91 | 91 | |
92 | - foreach ( $album_names as $album_name ) { |
|
93 | - if ( $album_name != "." && $album_name != "..") { |
|
94 | - add_new_album( $entry, $gp, $album_download_directory, $album_name ); |
|
92 | + foreach ($album_names as $album_name) { |
|
93 | + if ($album_name != "." && $album_name != "..") { |
|
94 | + add_new_album($entry, $gp, $album_download_directory, $album_name); |
|
95 | 95 | } |
96 | 96 | } |
97 | 97 | |
98 | - $unlink_folder = rtrim( $album_download_directory, "/" ); |
|
98 | + $unlink_folder = rtrim($album_download_directory, "/"); |
|
99 | 99 | require_once('../unlink_directory.php'); |
100 | 100 | $unlink_directory = new unlink_directory(); |
101 | - $unlink_directory->remove_directory( $unlink_folder ); |
|
101 | + $unlink_directory->remove_directory($unlink_folder); |
|
102 | 102 | } |
103 | 103 | $response = 1; |
104 | 104 | } else { |
@@ -106,10 +106,10 @@ discard block |
||
106 | 106 | } |
107 | 107 | |
108 | 108 | |
109 | -if ( isset( $_GET['ajax'] ) ) |
|
109 | +if (isset($_GET['ajax'])) |
|
110 | 110 | echo $response; |
111 | 111 | else |
112 | - header('location:../index.php?response='.$response); |
|
112 | + header('location:../index.php?response=' . $response); |
|
113 | 113 | |
114 | 114 | |
115 | 115 | ?> |
@@ -106,10 +106,11 @@ |
||
106 | 106 | } |
107 | 107 | |
108 | 108 | |
109 | -if ( isset( $_GET['ajax'] ) ) |
|
109 | +if ( isset( $_GET['ajax'] ) ) { |
|
110 | 110 | echo $response; |
111 | -else |
|
111 | +} else { |
|
112 | 112 | header('location:../index.php?response='.$response); |
113 | +} |
|
113 | 114 | |
114 | 115 | |
115 | 116 | ?> |
@@ -8,15 +8,15 @@ discard block |
||
8 | 8 | Zend_Loader::loadClass('Zend_Gdata_AuthSub'); |
9 | 9 | |
10 | 10 | if ( isset( $_GET['token'] ) ) { |
11 | - $_SESSION['google_session_token'] = Zend_Gdata_AuthSub::getAuthSubSessionToken( $_GET['token'] ); |
|
11 | + $_SESSION['google_session_token'] = Zend_Gdata_AuthSub::getAuthSubSessionToken( $_GET['token'] ); |
|
12 | 12 | |
13 | - $params = ""; |
|
14 | - foreach($_GET as $key => $value){ |
|
15 | - $params = $params . $key . '=' . $value . '&'; |
|
16 | - } |
|
17 | - //$params = $params . 'ajax='; |
|
18 | - $params = rtrim( $params, '&' ); |
|
19 | - header("location:../download_album.php?".$params); |
|
13 | + $params = ""; |
|
14 | + foreach($_GET as $key => $value){ |
|
15 | + $params = $params . $key . '=' . $value . '&'; |
|
16 | + } |
|
17 | + //$params = $params . 'ajax='; |
|
18 | + $params = rtrim( $params, '&' ); |
|
19 | + header("location:../download_album.php?".$params); |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | ?> |
@@ -59,38 +59,38 @@ discard block |
||
59 | 59 | |
60 | 60 | <div class="container"> |
61 | 61 | <?php |
62 | - //============ Google Move Code ======================// |
|
62 | + //============ Google Move Code ======================// |
|
63 | 63 | |
64 | - function getCurrentUrl() { |
|
65 | - global $_SERVER; |
|
64 | + function getCurrentUrl() { |
|
65 | + global $_SERVER; |
|
66 | 66 | |
67 | - $php_request_uri = htmlentities(substr($_SERVER['REQUEST_URI'], 0, |
|
68 | - strcspn($_SERVER['REQUEST_URI'], "\n\r")), ENT_QUOTES); |
|
67 | + $php_request_uri = htmlentities(substr($_SERVER['REQUEST_URI'], 0, |
|
68 | + strcspn($_SERVER['REQUEST_URI'], "\n\r")), ENT_QUOTES); |
|
69 | 69 | |
70 | - if (isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on') { |
|
71 | - $protocol = 'https://'; |
|
72 | - } else { |
|
73 | - $protocol = 'http://'; |
|
74 | - } |
|
75 | - $host = $_SERVER['HTTP_HOST']; |
|
76 | - if ($_SERVER['SERVER_PORT'] != '' && |
|
77 | - (($protocol == 'http://' && $_SERVER['SERVER_PORT'] != '80') || |
|
78 | - ($protocol == 'https://' && $_SERVER['SERVER_PORT'] != '443'))) { |
|
79 | - $port = ':' . $_SERVER['SERVER_PORT']; |
|
80 | - } else { |
|
81 | - $port = ''; |
|
82 | - } |
|
83 | - return $protocol . $host . $port . $php_request_uri; |
|
84 | - } |
|
70 | + if (isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on') { |
|
71 | + $protocol = 'https://'; |
|
72 | + } else { |
|
73 | + $protocol = 'http://'; |
|
74 | + } |
|
75 | + $host = $_SERVER['HTTP_HOST']; |
|
76 | + if ($_SERVER['SERVER_PORT'] != '' && |
|
77 | + (($protocol == 'http://' && $_SERVER['SERVER_PORT'] != '80') || |
|
78 | + ($protocol == 'https://' && $_SERVER['SERVER_PORT'] != '443'))) { |
|
79 | + $port = ':' . $_SERVER['SERVER_PORT']; |
|
80 | + } else { |
|
81 | + $port = ''; |
|
82 | + } |
|
83 | + return $protocol . $host . $port . $php_request_uri; |
|
84 | + } |
|
85 | 85 | |
86 | - function getAuthSubUrl() { |
|
87 | - $next = getCurrentUrl(); |
|
88 | - $scope = 'http://picasaweb.google.com/data'; |
|
89 | - $secure = 0; |
|
90 | - $session = 1; |
|
91 | - return Zend_Gdata_AuthSub::getAuthSubTokenUri($next, $scope, $secure, $session); |
|
92 | - } |
|
93 | - ?> |
|
86 | + function getAuthSubUrl() { |
|
87 | + $next = getCurrentUrl(); |
|
88 | + $scope = 'http://picasaweb.google.com/data'; |
|
89 | + $secure = 0; |
|
90 | + $session = 1; |
|
91 | + return Zend_Gdata_AuthSub::getAuthSubTokenUri($next, $scope, $secure, $session); |
|
92 | + } |
|
93 | + ?> |
|
94 | 94 | |
95 | 95 | <div id="login-div" class="row"> |
96 | 96 | <a id="login-link" class="btn btn-danger btn-lg" href="<?php echo getAuthSubUrl();?>"> |
@@ -7,16 +7,16 @@ discard block |
||
7 | 7 | //Zend_Loader::loadClass('Zend_Gdata_ClientLogin'); |
8 | 8 | Zend_Loader::loadClass('Zend_Gdata_AuthSub'); |
9 | 9 | |
10 | -if ( isset( $_GET['token'] ) ) { |
|
11 | - $_SESSION['google_session_token'] = Zend_Gdata_AuthSub::getAuthSubSessionToken( $_GET['token'] ); |
|
10 | +if (isset($_GET['token'])) { |
|
11 | + $_SESSION['google_session_token'] = Zend_Gdata_AuthSub::getAuthSubSessionToken($_GET['token']); |
|
12 | 12 | |
13 | 13 | $params = ""; |
14 | - foreach($_GET as $key => $value){ |
|
14 | + foreach ($_GET as $key => $value) { |
|
15 | 15 | $params = $params . $key . '=' . $value . '&'; |
16 | 16 | } |
17 | 17 | //$params = $params . 'ajax='; |
18 | - $params = rtrim( $params, '&' ); |
|
19 | - header("location:../download_album.php?".$params); |
|
18 | + $params = rtrim($params, '&'); |
|
19 | + header("location:../download_album.php?" . $params); |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | ?> |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | ?> |
94 | 94 | |
95 | 95 | <div id="login-div" class="row"> |
96 | - <a id="login-link" class="btn btn-danger btn-lg" href="<?php echo getAuthSubUrl();?>"> |
|
96 | + <a id="login-link" class="btn btn-danger btn-lg" href="<?php echo getAuthSubUrl(); ?>"> |
|
97 | 97 | |
98 | 98 | </a> |
99 | 99 | </div> |
@@ -1,16 +1,16 @@ |
||
1 | 1 | <?php |
2 | 2 | class unlink_directory { |
3 | 3 | |
4 | - function remove_directory( $directory ) { |
|
5 | - if ( isset( $directory ) ) { |
|
6 | - foreach ( glob( "{$directory}/*" ) as $file ) { |
|
7 | - if ( is_dir( $file ) ) { |
|
8 | - $this->remove_directory( $file ); |
|
4 | + function remove_directory($directory) { |
|
5 | + if (isset($directory)) { |
|
6 | + foreach (glob("{$directory}/*") as $file) { |
|
7 | + if (is_dir($file)) { |
|
8 | + $this->remove_directory($file); |
|
9 | 9 | } else { |
10 | - unlink( $file ); |
|
10 | + unlink($file); |
|
11 | 11 | } |
12 | 12 | } |
13 | - rmdir( $directory ); |
|
13 | + rmdir($directory); |
|
14 | 14 | } |
15 | 15 | } |
16 | 16 | } |
17 | 17 | \ No newline at end of file |