@@ -31,5 +31,5 @@ |
||
| 31 | 31 | * @see Requests_Hooks::register |
| 32 | 32 | * @param Requests_Hooks $hooks Hook system |
| 33 | 33 | */ |
| 34 | - public function register(Requests_Hooks &$hooks); |
|
| 34 | + public function register(Requests_Hooks&$hooks); |
|
| 35 | 35 | } |
| 36 | 36 | \ No newline at end of file |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -class Location{ |
|
| 3 | +class Location { |
|
| 4 | 4 | |
| 5 | 5 | public $cityName; |
| 6 | 6 | |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | { |
| 38 | 38 | $this->lng = $lng; |
| 39 | 39 | } |
| 40 | - public function toArray(){ |
|
| 40 | + public function toArray() { |
|
| 41 | 41 | return array( |
| 42 | 42 | "city" => $this->getCityName(), |
| 43 | 43 | "country" => 'DE', |
@@ -12,7 +12,7 @@ |
||
| 12 | 12 | |
| 13 | 13 | } |
| 14 | 14 | $db = new DatabaseConnect(); |
| 15 | -if ($db->connect_errno) { |
|
| 15 | +if($db->connect_errno) { |
|
| 16 | 16 | echo 'Sorry, die Verbindung zu unserem superfetten endgeilen |
| 17 | 17 | Server ist hops gegangen. Wegen '.$db -> connect_error; |
| 18 | 18 | } |
@@ -36,7 +36,7 @@ |
||
| 36 | 36 | { |
| 37 | 37 | $str = ''; |
| 38 | 38 | $max = mb_strlen($keyspace, '8bit') - 1; |
| 39 | - for ($i = 0; $i < $length; ++$i) { |
|
| 39 | + for($i = 0; $i < $length; ++$i) { |
|
| 40 | 40 | $str .= $keyspace[random_int(0, $max)]; |
| 41 | 41 | } |
| 42 | 42 | return $str; |
@@ -7,22 +7,22 @@ discard block |
||
| 7 | 7 | |
| 8 | 8 | public $url; |
| 9 | 9 | |
| 10 | - function setUrl ($url) |
|
| 10 | + function setUrl($url) |
|
| 11 | 11 | { |
| 12 | 12 | $this->url = $url; |
| 13 | 13 | } |
| 14 | 14 | |
| 15 | - function getUrl () |
|
| 15 | + function getUrl() |
|
| 16 | 16 | { |
| 17 | 17 | return $this->url; |
| 18 | 18 | } |
| 19 | 19 | |
| 20 | - function setLastPostId ($lastPostId) |
|
| 20 | + function setLastPostId($lastPostId) |
|
| 21 | 21 | { |
| 22 | 22 | $this->lastPostId = $lastPostId; |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | - function getlastPostId () |
|
| 25 | + function getlastPostId() |
|
| 26 | 26 | { |
| 27 | 27 | return $this->lastPostId; |
| 28 | 28 | } |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | { |
| 32 | 32 | $apiEndPoint = $this->getUrl(); |
| 33 | 33 | //echo $GLOBALS['lastPostId']; |
| 34 | - if ($this->getLastPostId() != "") { |
|
| 34 | + if($this->getLastPostId() != "") { |
|
| 35 | 35 | $apiEndPoint = $this->getUrl() . '/location/?after=' . $this->getLastPostId(); |
| 36 | 36 | } |
| 37 | 37 | return $apiEndPoint; |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | * @return Requests_Cookie |
| 37 | 37 | */ |
| 38 | 38 | public function normalize_cookie($cookie, $key = null) { |
| 39 | - if ($cookie instanceof Requests_Cookie) { |
|
| 39 | + if($cookie instanceof Requests_Cookie) { |
|
| 40 | 40 | return $cookie; |
| 41 | 41 | } |
| 42 | 42 | |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | * @return string Item value |
| 72 | 72 | */ |
| 73 | 73 | public function offsetGet($key) { |
| 74 | - if (!isset($this->cookies[$key])) { |
|
| 74 | + if(!isset($this->cookies[$key])) { |
|
| 75 | 75 | return null; |
| 76 | 76 | } |
| 77 | 77 | |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | * @param string $value Item value |
| 88 | 88 | */ |
| 89 | 89 | public function offsetSet($key, $value) { |
| 90 | - if ($key === null) { |
|
| 90 | + if($key === null) { |
|
| 91 | 91 | throw new Requests_Exception('Object is a dictionary, not a list', 'invalidset'); |
| 92 | 92 | } |
| 93 | 93 | |
@@ -134,21 +134,21 @@ discard block |
||
| 134 | 134 | * @param array $options |
| 135 | 135 | */ |
| 136 | 136 | public function before_request($url, &$headers, &$data, &$type, &$options) { |
| 137 | - if (!$url instanceof Requests_IRI) { |
|
| 137 | + if(!$url instanceof Requests_IRI) { |
|
| 138 | 138 | $url = new Requests_IRI($url); |
| 139 | 139 | } |
| 140 | 140 | |
| 141 | - if (!empty($this->cookies)) { |
|
| 141 | + if(!empty($this->cookies)) { |
|
| 142 | 142 | $cookies = array(); |
| 143 | - foreach ($this->cookies as $key => $cookie) { |
|
| 143 | + foreach($this->cookies as $key => $cookie) { |
|
| 144 | 144 | $cookie = $this->normalize_cookie($cookie, $key); |
| 145 | 145 | |
| 146 | 146 | // Skip expired cookies |
| 147 | - if ($cookie->is_expired()) { |
|
| 147 | + if($cookie->is_expired()) { |
|
| 148 | 148 | continue; |
| 149 | 149 | } |
| 150 | 150 | |
| 151 | - if ($cookie->domain_matches($url->host)) { |
|
| 151 | + if($cookie->domain_matches($url->host)) { |
|
| 152 | 152 | $cookies[] = $cookie->format_for_header(); |
| 153 | 153 | } |
| 154 | 154 | } |
@@ -162,9 +162,9 @@ discard block |
||
| 162 | 162 | * |
| 163 | 163 | * @var Requests_Response $response |
| 164 | 164 | */ |
| 165 | - public function before_redirect_check(Requests_Response &$return) { |
|
| 165 | + public function before_redirect_check(Requests_Response&$return) { |
|
| 166 | 166 | $url = $return->url; |
| 167 | - if (!$url instanceof Requests_IRI) { |
|
| 167 | + if(!$url instanceof Requests_IRI) { |
|
| 168 | 168 | $url = new Requests_IRI($url); |
| 169 | 169 | } |
| 170 | 170 | |
@@ -31,5 +31,5 @@ |
||
| 31 | 31 | * @see Requests_Hooks::register |
| 32 | 32 | * @param Requests_Hooks $hooks Hook system |
| 33 | 33 | */ |
| 34 | - public function register(Requests_Hooks &$hooks); |
|
| 34 | + public function register(Requests_Hooks&$hooks); |
|
| 35 | 35 | } |
| 36 | 36 | \ No newline at end of file |
@@ -55,14 +55,14 @@ discard block |
||
| 55 | 55 | * @param array|null $args Array of user and password. Must have exactly two elements |
| 56 | 56 | */ |
| 57 | 57 | public function __construct($args = null) { |
| 58 | - if (is_string($args)) { |
|
| 58 | + if(is_string($args)) { |
|
| 59 | 59 | $this->proxy = $args; |
| 60 | 60 | } |
| 61 | - elseif (is_array($args)) { |
|
| 62 | - if (count($args) == 1) { |
|
| 61 | + elseif(is_array($args)) { |
|
| 62 | + if(count($args) == 1) { |
|
| 63 | 63 | list($this->proxy) = $args; |
| 64 | 64 | } |
| 65 | - elseif (count($args) == 3) { |
|
| 65 | + elseif(count($args) == 3) { |
|
| 66 | 66 | list($this->proxy, $this->user, $this->pass) = $args; |
| 67 | 67 | $this->use_authentication = true; |
| 68 | 68 | } |
@@ -82,12 +82,12 @@ discard block |
||
| 82 | 82 | * @see fsockopen_header |
| 83 | 83 | * @param Requests_Hooks $hooks Hook system |
| 84 | 84 | */ |
| 85 | - public function register(Requests_Hooks &$hooks) { |
|
| 85 | + public function register(Requests_Hooks&$hooks) { |
|
| 86 | 86 | $hooks->register('curl.before_send', array(&$this, 'curl_before_send')); |
| 87 | 87 | |
| 88 | 88 | $hooks->register('fsockopen.remote_socket', array(&$this, 'fsockopen_remote_socket')); |
| 89 | 89 | $hooks->register('fsockopen.remote_host_path', array(&$this, 'fsockopen_remote_host_path')); |
| 90 | - if ($this->use_authentication) { |
|
| 90 | + if($this->use_authentication) { |
|
| 91 | 91 | $hooks->register('fsockopen.after_headers', array(&$this, 'fsockopen_header')); |
| 92 | 92 | } |
| 93 | 93 | } |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | curl_setopt($handle, CURLOPT_PROXYTYPE, CURLPROXY_HTTP); |
| 103 | 103 | curl_setopt($handle, CURLOPT_PROXY, $this->proxy); |
| 104 | 104 | |
| 105 | - if ($this->use_authentication) { |
|
| 105 | + if($this->use_authentication) { |
|
| 106 | 106 | curl_setopt($handle, CURLOPT_PROXYAUTH, CURLAUTH_ANY); |
| 107 | 107 | curl_setopt($handle, CURLOPT_PROXYUSERPWD, $this->get_auth_string()); |
| 108 | 108 | } |
@@ -96,14 +96,14 @@ discard block |
||
| 96 | 96 | |
| 97 | 97 | curl_setopt($this->handle, CURLOPT_HEADER, false); |
| 98 | 98 | curl_setopt($this->handle, CURLOPT_RETURNTRANSFER, 1); |
| 99 | - if ($this->version >= self::CURL_7_10_5) { |
|
| 99 | + if($this->version >= self::CURL_7_10_5) { |
|
| 100 | 100 | curl_setopt($this->handle, CURLOPT_ENCODING, ''); |
| 101 | 101 | } |
| 102 | - if (defined('CURLOPT_PROTOCOLS')) { |
|
| 103 | - curl_setopt($this->handle, CURLOPT_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS); |
|
| 102 | + if(defined('CURLOPT_PROTOCOLS')) { |
|
| 103 | + curl_setopt($this->handle, CURLOPT_PROTOCOLS, CURLPROTO_HTTP|CURLPROTO_HTTPS); |
|
| 104 | 104 | } |
| 105 | - if (defined('CURLOPT_REDIR_PROTOCOLS')) { |
|
| 106 | - curl_setopt($this->handle, CURLOPT_REDIR_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS); |
|
| 105 | + if(defined('CURLOPT_REDIR_PROTOCOLS')) { |
|
| 106 | + curl_setopt($this->handle, CURLOPT_REDIR_PROTOCOLS, CURLPROTO_HTTP|CURLPROTO_HTTPS); |
|
| 107 | 107 | } |
| 108 | 108 | } |
| 109 | 109 | |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | * Destructor |
| 112 | 112 | */ |
| 113 | 113 | public function __destruct() { |
| 114 | - if (is_resource($this->handle)) { |
|
| 114 | + if(is_resource($this->handle)) { |
|
| 115 | 115 | curl_close($this->handle); |
| 116 | 116 | } |
| 117 | 117 | } |
@@ -134,28 +134,28 @@ discard block |
||
| 134 | 134 | |
| 135 | 135 | $options['hooks']->dispatch('curl.before_send', array(&$this->handle)); |
| 136 | 136 | |
| 137 | - if ($options['filename'] !== false) { |
|
| 137 | + if($options['filename'] !== false) { |
|
| 138 | 138 | $this->stream_handle = fopen($options['filename'], 'wb'); |
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | $this->response_data = ''; |
| 142 | 142 | $this->response_bytes = 0; |
| 143 | 143 | $this->response_byte_limit = false; |
| 144 | - if ($options['max_bytes'] !== false) { |
|
| 144 | + if($options['max_bytes'] !== false) { |
|
| 145 | 145 | $this->response_byte_limit = $options['max_bytes']; |
| 146 | 146 | } |
| 147 | 147 | |
| 148 | - if (isset($options['verify'])) { |
|
| 149 | - if ($options['verify'] === false) { |
|
| 148 | + if(isset($options['verify'])) { |
|
| 149 | + if($options['verify'] === false) { |
|
| 150 | 150 | curl_setopt($this->handle, CURLOPT_SSL_VERIFYHOST, 0); |
| 151 | 151 | curl_setopt($this->handle, CURLOPT_SSL_VERIFYPEER, 0); |
| 152 | 152 | } |
| 153 | - elseif (is_string($options['verify'])) { |
|
| 153 | + elseif(is_string($options['verify'])) { |
|
| 154 | 154 | curl_setopt($this->handle, CURLOPT_CAINFO, $options['verify']); |
| 155 | 155 | } |
| 156 | 156 | } |
| 157 | 157 | |
| 158 | - if (isset($options['verifyname']) && $options['verifyname'] === false) { |
|
| 158 | + if(isset($options['verifyname']) && $options['verifyname'] === false) { |
|
| 159 | 159 | curl_setopt($this->handle, CURLOPT_SSL_VERIFYHOST, 0); |
| 160 | 160 | } |
| 161 | 161 | |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | |
| 165 | 165 | $options['hooks']->dispatch('curl.after_send', array()); |
| 166 | 166 | |
| 167 | - if (curl_errno($this->handle) === 23 || curl_errno($this->handle) === 61) { |
|
| 167 | + if(curl_errno($this->handle) === 23 || curl_errno($this->handle) === 61) { |
|
| 168 | 168 | // Reset encoding and try again |
| 169 | 169 | curl_setopt($this->handle, CURLOPT_ENCODING, 'none'); |
| 170 | 170 | |
@@ -193,7 +193,7 @@ discard block |
||
| 193 | 193 | */ |
| 194 | 194 | public function request_multiple($requests, $options) { |
| 195 | 195 | // If you're not requesting, we can't get any responses ¯\_(ツ)_/¯ |
| 196 | - if (empty($requests)) { |
|
| 196 | + if(empty($requests)) { |
|
| 197 | 197 | return array(); |
| 198 | 198 | } |
| 199 | 199 | |
@@ -202,7 +202,7 @@ discard block |
||
| 202 | 202 | $subhandles = array(); |
| 203 | 203 | |
| 204 | 204 | $class = get_class($this); |
| 205 | - foreach ($requests as $id => $request) { |
|
| 205 | + foreach($requests as $id => $request) { |
|
| 206 | 206 | $subrequests[$id] = new $class(); |
| 207 | 207 | $subhandles[$id] = $subrequests[$id]->get_subrequest_handle($request['url'], $request['headers'], $request['data'], $request['options']); |
| 208 | 208 | $request['options']['hooks']->dispatch('curl.before_multi_add', array(&$subhandles[$id])); |
@@ -220,22 +220,22 @@ discard block |
||
| 220 | 220 | do { |
| 221 | 221 | $status = curl_multi_exec($multihandle, $active); |
| 222 | 222 | } |
| 223 | - while ($status === CURLM_CALL_MULTI_PERFORM); |
|
| 223 | + while($status === CURLM_CALL_MULTI_PERFORM); |
|
| 224 | 224 | |
| 225 | 225 | $to_process = array(); |
| 226 | 226 | |
| 227 | 227 | // Read the information as needed |
| 228 | - while ($done = curl_multi_info_read($multihandle)) { |
|
| 228 | + while($done = curl_multi_info_read($multihandle)) { |
|
| 229 | 229 | $key = array_search($done['handle'], $subhandles, true); |
| 230 | - if (!isset($to_process[$key])) { |
|
| 230 | + if(!isset($to_process[$key])) { |
|
| 231 | 231 | $to_process[$key] = $done; |
| 232 | 232 | } |
| 233 | 233 | } |
| 234 | 234 | |
| 235 | 235 | // Parse the finished requests before we start getting the new ones |
| 236 | - foreach ($to_process as $key => $done) { |
|
| 236 | + foreach($to_process as $key => $done) { |
|
| 237 | 237 | $options = $requests[$key]['options']; |
| 238 | - if (CURLE_OK !== $done['result']) { |
|
| 238 | + if(CURLE_OK !== $done['result']) { |
|
| 239 | 239 | //get error string for handle. |
| 240 | 240 | $reason = curl_error($done['handle']); |
| 241 | 241 | $exception = new Requests_Exception_Transport_cURL( |
@@ -256,13 +256,13 @@ discard block |
||
| 256 | 256 | curl_multi_remove_handle($multihandle, $done['handle']); |
| 257 | 257 | curl_close($done['handle']); |
| 258 | 258 | |
| 259 | - if (!is_string($responses[$key])) { |
|
| 259 | + if(!is_string($responses[$key])) { |
|
| 260 | 260 | $options['hooks']->dispatch('multiple.request.complete', array(&$responses[$key], $key)); |
| 261 | 261 | } |
| 262 | 262 | $completed++; |
| 263 | 263 | } |
| 264 | 264 | } |
| 265 | - while ($active || $completed < count($subrequests)); |
|
| 265 | + while($active || $completed < count($subrequests)); |
|
| 266 | 266 | |
| 267 | 267 | $request['options']['hooks']->dispatch('curl.after_multi_exec', array(&$multihandle)); |
| 268 | 268 | |
@@ -283,14 +283,14 @@ discard block |
||
| 283 | 283 | public function &get_subrequest_handle($url, $headers, $data, $options) { |
| 284 | 284 | $this->setup_handle($url, $headers, $data, $options); |
| 285 | 285 | |
| 286 | - if ($options['filename'] !== false) { |
|
| 286 | + if($options['filename'] !== false) { |
|
| 287 | 287 | $this->stream_handle = fopen($options['filename'], 'wb'); |
| 288 | 288 | } |
| 289 | 289 | |
| 290 | 290 | $this->response_data = ''; |
| 291 | 291 | $this->response_bytes = 0; |
| 292 | 292 | $this->response_byte_limit = false; |
| 293 | - if ($options['max_bytes'] !== false) { |
|
| 293 | + if($options['max_bytes'] !== false) { |
|
| 294 | 294 | $this->response_byte_limit = $options['max_bytes']; |
| 295 | 295 | } |
| 296 | 296 | $this->hooks = $options['hooks']; |
@@ -310,25 +310,25 @@ discard block |
||
| 310 | 310 | $options['hooks']->dispatch('curl.before_request', array(&$this->handle)); |
| 311 | 311 | |
| 312 | 312 | // Force closing the connection for old versions of cURL (<7.22). |
| 313 | - if ( ! isset( $headers['Connection'] ) ) { |
|
| 313 | + if(!isset($headers['Connection'])) { |
|
| 314 | 314 | $headers['Connection'] = 'close'; |
| 315 | 315 | } |
| 316 | 316 | |
| 317 | 317 | $headers = Requests::flatten($headers); |
| 318 | 318 | |
| 319 | - if (!empty($data)) { |
|
| 319 | + if(!empty($data)) { |
|
| 320 | 320 | $data_format = $options['data_format']; |
| 321 | 321 | |
| 322 | - if ($data_format === 'query') { |
|
| 322 | + if($data_format === 'query') { |
|
| 323 | 323 | $url = self::format_get($url, $data); |
| 324 | 324 | $data = ''; |
| 325 | 325 | } |
| 326 | - elseif (!is_string($data)) { |
|
| 326 | + elseif(!is_string($data)) { |
|
| 327 | 327 | $data = http_build_query($data, null, '&'); |
| 328 | 328 | } |
| 329 | 329 | } |
| 330 | 330 | |
| 331 | - switch ($options['type']) { |
|
| 331 | + switch($options['type']) { |
|
| 332 | 332 | case Requests::POST: |
| 333 | 333 | curl_setopt($this->handle, CURLOPT_POST, true); |
| 334 | 334 | curl_setopt($this->handle, CURLOPT_POSTFIELDS, $data); |
@@ -346,7 +346,7 @@ discard block |
||
| 346 | 346 | case Requests::OPTIONS: |
| 347 | 347 | default: |
| 348 | 348 | curl_setopt($this->handle, CURLOPT_CUSTOMREQUEST, $options['type']); |
| 349 | - if (!empty($data)) { |
|
| 349 | + if(!empty($data)) { |
|
| 350 | 350 | curl_setopt($this->handle, CURLOPT_POSTFIELDS, $data); |
| 351 | 351 | } |
| 352 | 352 | } |
@@ -359,14 +359,14 @@ discard block |
||
| 359 | 359 | // https://github.com/curl/curl/blob/4f45240bc84a9aa648c8f7243be7b79e9f9323a5/lib/hostip.c#L606-L609 |
| 360 | 360 | $timeout = max($options['timeout'], 1); |
| 361 | 361 | |
| 362 | - if (is_int($timeout) || $this->version < self::CURL_7_16_2) { |
|
| 362 | + if(is_int($timeout) || $this->version < self::CURL_7_16_2) { |
|
| 363 | 363 | curl_setopt($this->handle, CURLOPT_TIMEOUT, ceil($timeout)); |
| 364 | 364 | } |
| 365 | 365 | else { |
| 366 | 366 | curl_setopt($this->handle, CURLOPT_TIMEOUT_MS, round($timeout * 1000)); |
| 367 | 367 | } |
| 368 | 368 | |
| 369 | - if (is_int($options['connect_timeout']) || $this->version < self::CURL_7_16_2) { |
|
| 369 | + if(is_int($options['connect_timeout']) || $this->version < self::CURL_7_16_2) { |
|
| 370 | 370 | curl_setopt($this->handle, CURLOPT_CONNECTTIMEOUT, ceil($options['connect_timeout'])); |
| 371 | 371 | } |
| 372 | 372 | else { |
@@ -375,17 +375,17 @@ discard block |
||
| 375 | 375 | curl_setopt($this->handle, CURLOPT_URL, $url); |
| 376 | 376 | curl_setopt($this->handle, CURLOPT_REFERER, $url); |
| 377 | 377 | curl_setopt($this->handle, CURLOPT_USERAGENT, $options['useragent']); |
| 378 | - if (!empty($headers)) { |
|
| 378 | + if(!empty($headers)) { |
|
| 379 | 379 | curl_setopt($this->handle, CURLOPT_HTTPHEADER, $headers); |
| 380 | 380 | } |
| 381 | - if ($options['protocol_version'] === 1.1) { |
|
| 381 | + if($options['protocol_version'] === 1.1) { |
|
| 382 | 382 | curl_setopt($this->handle, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); |
| 383 | 383 | } |
| 384 | 384 | else { |
| 385 | 385 | curl_setopt($this->handle, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); |
| 386 | 386 | } |
| 387 | 387 | |
| 388 | - if (true === $options['blocking']) { |
|
| 388 | + if(true === $options['blocking']) { |
|
| 389 | 389 | curl_setopt($this->handle, CURLOPT_HEADERFUNCTION, array(&$this, 'stream_headers')); |
| 390 | 390 | curl_setopt($this->handle, CURLOPT_WRITEFUNCTION, array(&$this, 'stream_body')); |
| 391 | 391 | curl_setopt($this->handle, CURLOPT_BUFFERSIZE, Requests::BUFFER_SIZE); |
@@ -400,12 +400,12 @@ discard block |
||
| 400 | 400 | * @return string HTTP response data including headers |
| 401 | 401 | */ |
| 402 | 402 | public function process_response($response, $options) { |
| 403 | - if ($options['blocking'] === false) { |
|
| 403 | + if($options['blocking'] === false) { |
|
| 404 | 404 | $fake_headers = ''; |
| 405 | 405 | $options['hooks']->dispatch('curl.after_request', array(&$fake_headers)); |
| 406 | 406 | return false; |
| 407 | 407 | } |
| 408 | - if ($options['filename'] !== false) { |
|
| 408 | + if($options['filename'] !== false) { |
|
| 409 | 409 | fclose($this->stream_handle); |
| 410 | 410 | $this->headers = trim($this->headers); |
| 411 | 411 | } |
@@ -413,7 +413,7 @@ discard block |
||
| 413 | 413 | $this->headers .= $response; |
| 414 | 414 | } |
| 415 | 415 | |
| 416 | - if (curl_errno($this->handle)) { |
|
| 416 | + if(curl_errno($this->handle)) { |
|
| 417 | 417 | $error = sprintf( |
| 418 | 418 | 'cURL error %s: %s', |
| 419 | 419 | curl_errno($this->handle), |
@@ -438,13 +438,13 @@ discard block |
||
| 438 | 438 | // Why do we do this? cURL will send both the final response and any |
| 439 | 439 | // interim responses, such as a 100 Continue. We don't need that. |
| 440 | 440 | // (We may want to keep this somewhere just in case) |
| 441 | - if ($this->done_headers) { |
|
| 441 | + if($this->done_headers) { |
|
| 442 | 442 | $this->headers = ''; |
| 443 | 443 | $this->done_headers = false; |
| 444 | 444 | } |
| 445 | 445 | $this->headers .= $headers; |
| 446 | 446 | |
| 447 | - if ($headers === "\r\n") { |
|
| 447 | + if($headers === "\r\n") { |
|
| 448 | 448 | $this->done_headers = true; |
| 449 | 449 | } |
| 450 | 450 | return strlen($headers); |
@@ -464,20 +464,20 @@ discard block |
||
| 464 | 464 | $data_length = strlen($data); |
| 465 | 465 | |
| 466 | 466 | // Are we limiting the response size? |
| 467 | - if ($this->response_byte_limit) { |
|
| 468 | - if ($this->response_bytes === $this->response_byte_limit) { |
|
| 467 | + if($this->response_byte_limit) { |
|
| 468 | + if($this->response_bytes === $this->response_byte_limit) { |
|
| 469 | 469 | // Already at maximum, move on |
| 470 | 470 | return $data_length; |
| 471 | 471 | } |
| 472 | 472 | |
| 473 | - if (($this->response_bytes + $data_length) > $this->response_byte_limit) { |
|
| 473 | + if(($this->response_bytes + $data_length) > $this->response_byte_limit) { |
|
| 474 | 474 | // Limit the length |
| 475 | 475 | $limited_length = ($this->response_byte_limit - $this->response_bytes); |
| 476 | 476 | $data = substr($data, 0, $limited_length); |
| 477 | 477 | } |
| 478 | 478 | } |
| 479 | 479 | |
| 480 | - if ($this->stream_handle) { |
|
| 480 | + if($this->stream_handle) { |
|
| 481 | 481 | fwrite($this->stream_handle, $data); |
| 482 | 482 | } |
| 483 | 483 | else { |
@@ -496,9 +496,9 @@ discard block |
||
| 496 | 496 | * @return string URL with data |
| 497 | 497 | */ |
| 498 | 498 | protected static function format_get($url, $data) { |
| 499 | - if (!empty($data)) { |
|
| 499 | + if(!empty($data)) { |
|
| 500 | 500 | $url_parts = parse_url($url); |
| 501 | - if (empty($url_parts['query'])) { |
|
| 501 | + if(empty($url_parts['query'])) { |
|
| 502 | 502 | $query = $url_parts['query'] = ''; |
| 503 | 503 | } |
| 504 | 504 | else { |
@@ -508,7 +508,7 @@ discard block |
||
| 508 | 508 | $query .= '&' . http_build_query($data, null, '&'); |
| 509 | 509 | $query = trim($query, '&'); |
| 510 | 510 | |
| 511 | - if (empty($url_parts['query'])) { |
|
| 511 | + if(empty($url_parts['query'])) { |
|
| 512 | 512 | $url .= '?' . $query; |
| 513 | 513 | } |
| 514 | 514 | else { |
@@ -525,14 +525,14 @@ discard block |
||
| 525 | 525 | * @return boolean True if the transport is valid, false otherwise. |
| 526 | 526 | */ |
| 527 | 527 | public static function test($capabilities = array()) { |
| 528 | - if (!function_exists('curl_init') || !function_exists('curl_exec')) { |
|
| 528 | + if(!function_exists('curl_init') || !function_exists('curl_exec')) { |
|
| 529 | 529 | return false; |
| 530 | 530 | } |
| 531 | 531 | |
| 532 | 532 | // If needed, check that our installed curl version supports SSL |
| 533 | - if (isset($capabilities['ssl']) && $capabilities['ssl']) { |
|
| 533 | + if(isset($capabilities['ssl']) && $capabilities['ssl']) { |
|
| 534 | 534 | $curl_version = curl_version(); |
| 535 | - if (!(CURL_VERSION_SSL & $curl_version['features'])) { |
|
| 535 | + if(!(CURL_VERSION_SSL&$curl_version['features'])) { |
|
| 536 | 536 | return false; |
| 537 | 537 | } |
| 538 | 538 | } |