Find this useful? Enter your email to receive occasional updates for securing PHP code.

Signing you up...

Thank you for signing up!

PHP Decode

<?php namespace WpOrg\Requests\Transport; use RecursiveArrayIterator; use RecursiveIterat..

Decoded Output download

<?php
 namespace WpOrg\Requests\Transport; use RecursiveArrayIterator; use RecursiveIteratorIterator; use WpOrg\Requests\Capability; use WpOrg\Requests\Exception; use WpOrg\Requests\Exception\InvalidArgument; use WpOrg\Requests\Exception\Transport\Curl as CurlException; use WpOrg\Requests\Requests; use WpOrg\Requests\Transport; use WpOrg\Requests\Utility\InputValidator; final class Curl implements Transport { const CURL_7_10_5 = 461317; const CURL_7_16_2 = 462850; public $headers = ''; public $response_data = ''; public $info; public $version; private $handle; private $hooks; private $done_headers = false; private $stream_handle; private $response_bytes; private $response_byte_limit; public function __construct() { $curl = curl_version(); $this->version = $curl["version_number"]; $this->handle = curl_init(); curl_setopt($this->handle, CURLOPT_HEADER, false); curl_setopt($this->handle, CURLOPT_RETURNTRANSFER, 1); if ($this->version >= self::CURL_7_10_5) { curl_setopt($this->handle, CURLOPT_ENCODING, ''); } if (defined("CURLOPT_PROTOCOLS")) { curl_setopt($this->handle, CURLOPT_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS); } if (defined("CURLOPT_REDIR_PROTOCOLS")) { curl_setopt($this->handle, CURLOPT_REDIR_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS); } } public function __destruct() { if (is_resource($this->handle)) { curl_close($this->handle); } } public function request($url, $headers = array(), $data = array(), $options = array()) { if (InputValidator::is_string_or_stringable($url) === false) { throw InvalidArgument::create(1, "$url", "string|Stringable", gettype($url)); } if (is_array($headers) === false) { throw InvalidArgument::create(2, "$headers", "array", gettype($headers)); } if (!is_array($data) && !is_string($data)) { if ($data === null) { $data = ''; } else { throw InvalidArgument::create(3, "$data", "array|string", gettype($data)); } } if (is_array($options) === false) { throw InvalidArgument::create(4, "$options", "array", gettype($options)); } $this->hooks = $options["hooks"]; $this->setup_handle($url, $headers, $data, $options); $options["hooks"]->dispatch("curl.before_send", array(&$this->handle)); if ($options["filename"] !== false) { $this->stream_handle = @fopen($options["filename"], "wb"); if ($this->stream_handle === false) { $error = error_get_last(); throw new Exception($error["message"], "fopen"); } } $this->response_data = ''; $this->response_bytes = 0; $this->response_byte_limit = false; if ($options["max_bytes"] !== false) { $this->response_byte_limit = $options["max_bytes"]; } if (isset($options["verify"])) { if ($options["verify"] === false) { curl_setopt($this->handle, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($this->handle, CURLOPT_SSL_VERIFYPEER, 0); } elseif (is_string($options["verify"])) { curl_setopt($this->handle, CURLOPT_CAINFO, $options["verify"]); } } if (isset($options["verifyname"]) && $options["verifyname"] === false) { curl_setopt($this->handle, CURLOPT_SSL_VERIFYHOST, 0); } curl_exec($this->handle); $response = $this->response_data; $options["hooks"]->dispatch("curl.after_send", array()); if (curl_errno($this->handle) === CURLE_WRITE_ERROR || curl_errno($this->handle) === CURLE_BAD_CONTENT_ENCODING) { curl_setopt($this->handle, CURLOPT_ENCODING, "none"); $this->response_data = ''; $this->response_bytes = 0; curl_exec($this->handle); $response = $this->response_data; } $this->process_response($response, $options); curl_setopt($this->handle, CURLOPT_HEADERFUNCTION, null); curl_setopt($this->handle, CURLOPT_WRITEFUNCTION, null); return $this->headers; } public function request_multiple($requests, $options) { if (empty($requests)) { return array(); } if (InputValidator::has_array_access($requests) === false || InputValidator::is_iterable($requests) === false) { throw InvalidArgument::create(1, "$requests", "array|ArrayAccess&Traversable", gettype($requests)); } if (is_array($options) === false) { throw InvalidArgument::create(2, "$options", "array", gettype($options)); } $multihandle = curl_multi_init(); $subrequests = array(); $subhandles = array(); $class = get_class($this); foreach ($requests as $id => $request) { $subrequests[$id] = new $class(); $subhandles[$id] = $subrequests[$id]->get_subrequest_handle($request["url"], $request["headers"], $request["data"], $request["options"]); $request["options"]["hooks"]->dispatch("curl.before_multi_add", array(&$subhandles[$id])); curl_multi_add_handle($multihandle, $subhandles[$id]); } $completed = 0; $responses = array(); $subrequestcount = count($subrequests); $request["options"]["hooks"]->dispatch("curl.before_multi_exec", array(&$multihandle)); do { $active = 0; do { $status = curl_multi_exec($multihandle, $active); } while ($status === CURLM_CALL_MULTI_PERFORM); $to_process = array(); while ($done = curl_multi_info_read($multihandle)) { $key = array_search($done["handle"], $subhandles, true); if (!isset($to_process[$key])) { $to_process[$key] = $done; } } foreach ($to_process as $key => $done) { $options = $requests[$key]["options"]; if ($done["result"] !== CURLE_OK) { $reason = curl_error($done["handle"]); $exception = new CurlException($reason, CurlException::EASY, $done["handle"], $done["result"]); $responses[$key] = $exception; $options["hooks"]->dispatch("transport.internal.parse_error", array(&$responses[$key], $requests[$key])); } else { $responses[$key] = $subrequests[$key]->process_response($subrequests[$key]->response_data, $options); $options["hooks"]->dispatch("transport.internal.parse_response", array(&$responses[$key], $requests[$key])); } curl_multi_remove_handle($multihandle, $done["handle"]); curl_close($done["handle"]); if (!is_string($responses[$key])) { $options["hooks"]->dispatch("multiple.request.complete", array(&$responses[$key], $key)); } $completed++; } } while ($active || $completed < $subrequestcount); $request["options"]["hooks"]->dispatch("curl.after_multi_exec", array(&$multihandle)); curl_multi_close($multihandle); return $responses; } public function &get_subrequest_handle($url, $headers, $data, $options) { $this->setup_handle($url, $headers, $data, $options); if ($options["filename"] !== false) { $this->stream_handle = fopen($options["filename"], "wb"); } $this->response_data = ''; $this->response_bytes = 0; $this->response_byte_limit = false; if ($options["max_bytes"] !== false) { $this->response_byte_limit = $options["max_bytes"]; } $this->hooks = $options["hooks"]; return $this->handle; } private function setup_handle($url, $headers, $data, $options) { $options["hooks"]->dispatch("curl.before_request", array(&$this->handle)); if (!isset($headers["Connection"])) { $headers["Connection"] = "close"; } if (!isset($headers["Expect"]) && $options["protocol_version"] === 1.1) { $headers["Expect"] = $this->get_expect_header($data); } $headers = Requests::flatten($headers); if (!empty($data)) { $data_format = $options["data_format"]; if ($data_format === "query") { $url = self::format_get($url, $data); $data = ''; } elseif (!is_string($data)) { $data = http_build_query($data, '', "&"); } } switch ($options["type"]) { case Requests::POST: curl_setopt($this->handle, CURLOPT_POST, true); curl_setopt($this->handle, CURLOPT_POSTFIELDS, $data); break; case Requests::HEAD: curl_setopt($this->handle, CURLOPT_CUSTOMREQUEST, $options["type"]); curl_setopt($this->handle, CURLOPT_NOBODY, true); break; case Requests::TRACE: curl_setopt($this->handle, CURLOPT_CUSTOMREQUEST, $options["type"]); break; case Requests::PATCH: case Requests::PUT: case Requests::DELETE: case Requests::OPTIONS: default: curl_setopt($this->handle, CURLOPT_CUSTOMREQUEST, $options["type"]); if (!empty($data)) { curl_setopt($this->handle, CURLOPT_POSTFIELDS, $data); } } $timeout = max($options["timeout"], 1); if (is_int($timeout) || $this->version < self::CURL_7_16_2) { curl_setopt($this->handle, CURLOPT_TIMEOUT, ceil($timeout)); } else { curl_setopt($this->handle, CURLOPT_TIMEOUT_MS, round($timeout * 1000)); } if (is_int($options["connect_timeout"]) || $this->version < self::CURL_7_16_2) { curl_setopt($this->handle, CURLOPT_CONNECTTIMEOUT, ceil($options["connect_timeout"])); } else { curl_setopt($this->handle, CURLOPT_CONNECTTIMEOUT_MS, round($options["connect_timeout"] * 1000)); } curl_setopt($this->handle, CURLOPT_URL, $url); curl_setopt($this->handle, CURLOPT_USERAGENT, $options["useragent"]); if (!empty($headers)) { curl_setopt($this->handle, CURLOPT_HTTPHEADER, $headers); } if ($options["protocol_version"] === 1.1) { curl_setopt($this->handle, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); } else { curl_setopt($this->handle, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); } if ($options["blocking"] === true) { curl_setopt($this->handle, CURLOPT_HEADERFUNCTION, array($this, "stream_headers")); curl_setopt($this->handle, CURLOPT_WRITEFUNCTION, array($this, "stream_body")); curl_setopt($this->handle, CURLOPT_BUFFERSIZE, Requests::BUFFER_SIZE); } } public function process_response($response, $options) { if ($options["blocking"] === false) { $fake_headers = ''; $options["hooks"]->dispatch("curl.after_request", array(&$fake_headers)); return false; } if ($options["filename"] !== false && $this->stream_handle) { fclose($this->stream_handle); $this->headers = trim($this->headers); } else { $this->headers .= $response; } if (curl_errno($this->handle)) { $error = sprintf("cURL error %s: %s", curl_errno($this->handle), curl_error($this->handle)); throw new Exception($error, "curlerror", $this->handle); } $this->info = curl_getinfo($this->handle); $options["hooks"]->dispatch("curl.after_request", array(&$this->headers, &$this->info)); return $this->headers; } public function stream_headers($handle, $headers) { if ($this->done_headers) { $this->headers = ''; $this->done_headers = false; } $this->headers .= $headers; if ($headers === "
") { $this->done_headers = true; } return strlen($headers); } public function stream_body($handle, $data) { $this->hooks->dispatch("request.progress", array($data, $this->response_bytes, $this->response_byte_limit)); $data_length = strlen($data); if ($this->response_byte_limit) { if ($this->response_bytes === $this->response_byte_limit) { return $data_length; } if ($this->response_bytes + $data_length > $this->response_byte_limit) { $limited_length = $this->response_byte_limit - $this->response_bytes; $data = substr($data, 0, $limited_length); } } if ($this->stream_handle) { fwrite($this->stream_handle, $data); } else { $this->response_data .= $data; } $this->response_bytes += strlen($data); return $data_length; } private static function format_get($url, $data) { if (!empty($data)) { $query = ''; $url_parts = parse_url($url); if (empty($url_parts["query"])) { $url_parts["query"] = ''; } else { $query = $url_parts["query"]; } $query .= "&" . http_build_query($data, '', "&"); $query = trim($query, "&"); if (empty($url_parts["query"])) { $url .= "?" . $query; } else { $url = str_replace($url_parts["query"], $query, $url); } } return $url; } public static function test($capabilities = array()) { if (!function_exists("curl_init") || !function_exists("curl_exec")) { return false; } if (isset($capabilities[Capability::SSL]) && $capabilities[Capability::SSL]) { $curl_version = curl_version(); if (!(CURL_VERSION_SSL & $curl_version["features"])) { return false; } } return true; } private function get_expect_header($data) { if (!is_array($data)) { return strlen((string) $data) >= 1048576 ? "100-Continue" : ''; } $bytesize = 0; $iterator = new RecursiveIteratorIterator(new RecursiveArrayIterator($data)); foreach ($iterator as $datum) { $bytesize += strlen((string) $datum); if ($bytesize >= 1048576) { return "100-Continue"; } } return ''; } } ?>

Did this file decode correctly?

Original Code

<?php
 namespace WpOrg\Requests\Transport; use RecursiveArrayIterator; use RecursiveIteratorIterator; use WpOrg\Requests\Capability; use WpOrg\Requests\Exception; use WpOrg\Requests\Exception\InvalidArgument; use WpOrg\Requests\Exception\Transport\Curl as CurlException; use WpOrg\Requests\Requests; use WpOrg\Requests\Transport; use WpOrg\Requests\Utility\InputValidator; final class Curl implements Transport { const CURL_7_10_5 = 461317; const CURL_7_16_2 = 462850; public $headers = ''; public $response_data = ''; public $info; public $version; private $handle; private $hooks; private $done_headers = false; private $stream_handle; private $response_bytes; private $response_byte_limit; public function __construct() { $curl = curl_version(); $this->version = $curl["\x76\145\162\x73\x69\x6f\x6e\x5f\156\x75\x6d\142\145\x72"]; $this->handle = curl_init(); curl_setopt($this->handle, CURLOPT_HEADER, false); curl_setopt($this->handle, CURLOPT_RETURNTRANSFER, 1); if ($this->version >= self::CURL_7_10_5) { curl_setopt($this->handle, CURLOPT_ENCODING, ''); } if (defined("\103\125\x52\114\117\x50\124\x5f\120\x52\117\124\117\x43\x4f\x4c\123")) { curl_setopt($this->handle, CURLOPT_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS); } if (defined("\x43\x55\122\x4c\x4f\120\x54\x5f\x52\x45\x44\x49\122\x5f\x50\x52\x4f\124\x4f\x43\x4f\114\x53")) { curl_setopt($this->handle, CURLOPT_REDIR_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS); } } public function __destruct() { if (is_resource($this->handle)) { curl_close($this->handle); } } public function request($url, $headers = array(), $data = array(), $options = array()) { if (InputValidator::is_string_or_stringable($url) === false) { throw InvalidArgument::create(1, "\44\165\162\154", "\x73\164\162\151\x6e\147\174\123\164\162\151\156\147\x61\142\154\145", gettype($url)); } if (is_array($headers) === false) { throw InvalidArgument::create(2, "\44\150\x65\141\144\145\x72\163", "\x61\162\162\141\x79", gettype($headers)); } if (!is_array($data) && !is_string($data)) { if ($data === null) { $data = ''; } else { throw InvalidArgument::create(3, "\x24\x64\141\164\141", "\141\162\x72\141\x79\174\x73\164\x72\151\x6e\x67", gettype($data)); } } if (is_array($options) === false) { throw InvalidArgument::create(4, "\x24\157\x70\164\x69\x6f\156\163", "\x61\x72\162\x61\x79", gettype($options)); } $this->hooks = $options["\x68\x6f\x6f\153\x73"]; $this->setup_handle($url, $headers, $data, $options); $options["\150\x6f\x6f\x6b\163"]->dispatch("\x63\165\x72\x6c\56\x62\145\x66\157\162\145\137\x73\x65\156\x64", array(&$this->handle)); if ($options["\x66\151\154\145\156\x61\155\145"] !== false) { $this->stream_handle = @fopen($options["\x66\x69\154\145\x6e\x61\155\x65"], "\x77\142"); if ($this->stream_handle === false) { $error = error_get_last(); throw new Exception($error["\x6d\x65\163\x73\x61\147\145"], "\x66\157\x70\145\156"); } } $this->response_data = ''; $this->response_bytes = 0; $this->response_byte_limit = false; if ($options["\x6d\x61\170\137\142\x79\x74\145\163"] !== false) { $this->response_byte_limit = $options["\x6d\x61\170\x5f\142\x79\x74\x65\163"]; } if (isset($options["\166\x65\x72\151\x66\171"])) { if ($options["\166\x65\x72\151\146\x79"] === false) { curl_setopt($this->handle, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($this->handle, CURLOPT_SSL_VERIFYPEER, 0); } elseif (is_string($options["\166\x65\162\x69\146\171"])) { curl_setopt($this->handle, CURLOPT_CAINFO, $options["\166\x65\x72\x69\x66\x79"]); } } if (isset($options["\x76\x65\x72\x69\x66\171\156\x61\155\145"]) && $options["\x76\x65\162\x69\146\171\156\141\x6d\145"] === false) { curl_setopt($this->handle, CURLOPT_SSL_VERIFYHOST, 0); } curl_exec($this->handle); $response = $this->response_data; $options["\x68\x6f\157\x6b\163"]->dispatch("\143\x75\x72\x6c\x2e\x61\146\x74\145\x72\137\163\x65\156\144", array()); if (curl_errno($this->handle) === CURLE_WRITE_ERROR || curl_errno($this->handle) === CURLE_BAD_CONTENT_ENCODING) { curl_setopt($this->handle, CURLOPT_ENCODING, "\x6e\x6f\x6e\x65"); $this->response_data = ''; $this->response_bytes = 0; curl_exec($this->handle); $response = $this->response_data; } $this->process_response($response, $options); curl_setopt($this->handle, CURLOPT_HEADERFUNCTION, null); curl_setopt($this->handle, CURLOPT_WRITEFUNCTION, null); return $this->headers; } public function request_multiple($requests, $options) { if (empty($requests)) { return array(); } if (InputValidator::has_array_access($requests) === false || InputValidator::is_iterable($requests) === false) { throw InvalidArgument::create(1, "\44\162\145\x71\x75\x65\x73\164\x73", "\x61\x72\x72\141\171\174\101\x72\x72\x61\171\x41\143\143\145\163\x73\x26\x54\162\141\x76\x65\x72\x73\x61\142\x6c\145", gettype($requests)); } if (is_array($options) === false) { throw InvalidArgument::create(2, "\x24\x6f\160\164\x69\x6f\x6e\163", "\x61\x72\162\141\171", gettype($options)); } $multihandle = curl_multi_init(); $subrequests = array(); $subhandles = array(); $class = get_class($this); foreach ($requests as $id => $request) { $subrequests[$id] = new $class(); $subhandles[$id] = $subrequests[$id]->get_subrequest_handle($request["\165\x72\154"], $request["\150\x65\x61\x64\x65\x72\x73"], $request["\x64\141\164\141"], $request["\157\x70\164\151\157\x6e\163"]); $request["\157\160\164\151\157\156\163"]["\x68\x6f\x6f\153\x73"]->dispatch("\143\x75\162\154\56\142\145\x66\157\x72\145\x5f\x6d\x75\x6c\164\151\x5f\x61\144\144", array(&$subhandles[$id])); curl_multi_add_handle($multihandle, $subhandles[$id]); } $completed = 0; $responses = array(); $subrequestcount = count($subrequests); $request["\157\x70\164\151\x6f\x6e\x73"]["\x68\x6f\157\153\163"]->dispatch("\x63\165\x72\x6c\x2e\x62\145\146\157\x72\145\x5f\x6d\x75\x6c\164\151\x5f\x65\170\x65\143", array(&$multihandle)); do { $active = 0; do { $status = curl_multi_exec($multihandle, $active); } while ($status === CURLM_CALL_MULTI_PERFORM); $to_process = array(); while ($done = curl_multi_info_read($multihandle)) { $key = array_search($done["\150\x61\x6e\x64\154\x65"], $subhandles, true); if (!isset($to_process[$key])) { $to_process[$key] = $done; } } foreach ($to_process as $key => $done) { $options = $requests[$key]["\x6f\160\x74\151\157\156\x73"]; if ($done["\x72\145\x73\165\x6c\164"] !== CURLE_OK) { $reason = curl_error($done["\x68\x61\156\x64\154\145"]); $exception = new CurlException($reason, CurlException::EASY, $done["\x68\x61\x6e\x64\x6c\145"], $done["\x72\x65\163\165\154\x74"]); $responses[$key] = $exception; $options["\x68\x6f\x6f\153\163"]->dispatch("\164\162\141\x6e\x73\x70\157\162\164\56\151\x6e\164\145\162\x6e\x61\x6c\56\160\141\162\163\145\x5f\x65\162\x72\x6f\162", array(&$responses[$key], $requests[$key])); } else { $responses[$key] = $subrequests[$key]->process_response($subrequests[$key]->response_data, $options); $options["\x68\157\x6f\x6b\163"]->dispatch("\x74\x72\141\x6e\x73\160\157\162\x74\x2e\x69\156\x74\145\162\x6e\x61\154\56\x70\141\x72\163\145\x5f\x72\x65\163\160\x6f\156\163\x65", array(&$responses[$key], $requests[$key])); } curl_multi_remove_handle($multihandle, $done["\150\x61\156\144\154\x65"]); curl_close($done["\150\141\x6e\144\x6c\145"]); if (!is_string($responses[$key])) { $options["\x68\x6f\x6f\x6b\163"]->dispatch("\155\165\154\164\151\x70\154\145\56\162\x65\161\x75\145\163\164\56\x63\157\155\160\x6c\x65\164\x65", array(&$responses[$key], $key)); } $completed++; } } while ($active || $completed < $subrequestcount); $request["\x6f\x70\164\151\157\156\163"]["\x68\x6f\157\x6b\x73"]->dispatch("\x63\x75\162\154\56\141\x66\x74\x65\x72\137\155\x75\x6c\x74\151\x5f\x65\170\145\143", array(&$multihandle)); curl_multi_close($multihandle); return $responses; } public function &get_subrequest_handle($url, $headers, $data, $options) { $this->setup_handle($url, $headers, $data, $options); if ($options["\x66\x69\154\x65\x6e\x61\x6d\145"] !== false) { $this->stream_handle = fopen($options["\x66\151\x6c\145\156\141\155\x65"], "\x77\142"); } $this->response_data = ''; $this->response_bytes = 0; $this->response_byte_limit = false; if ($options["\155\x61\x78\137\142\x79\x74\145\163"] !== false) { $this->response_byte_limit = $options["\155\x61\x78\x5f\x62\171\164\x65\x73"]; } $this->hooks = $options["\x68\x6f\x6f\153\163"]; return $this->handle; } private function setup_handle($url, $headers, $data, $options) { $options["\150\x6f\x6f\153\163"]->dispatch("\143\165\x72\x6c\x2e\142\x65\146\x6f\162\145\x5f\x72\x65\161\165\x65\163\x74", array(&$this->handle)); if (!isset($headers["\103\x6f\156\x6e\x65\143\164\151\157\x6e"])) { $headers["\103\157\x6e\156\x65\143\164\151\x6f\x6e"] = "\143\154\x6f\163\145"; } if (!isset($headers["\x45\170\160\x65\143\164"]) && $options["\160\x72\157\164\x6f\x63\x6f\154\137\166\x65\162\x73\x69\x6f\x6e"] === 1.1) { $headers["\105\x78\160\x65\x63\x74"] = $this->get_expect_header($data); } $headers = Requests::flatten($headers); if (!empty($data)) { $data_format = $options["\x64\x61\164\x61\137\x66\157\x72\155\141\x74"]; if ($data_format === "\161\x75\x65\162\x79") { $url = self::format_get($url, $data); $data = ''; } elseif (!is_string($data)) { $data = http_build_query($data, '', "\x26"); } } switch ($options["\164\171\160\x65"]) { case Requests::POST: curl_setopt($this->handle, CURLOPT_POST, true); curl_setopt($this->handle, CURLOPT_POSTFIELDS, $data); break; case Requests::HEAD: curl_setopt($this->handle, CURLOPT_CUSTOMREQUEST, $options["\x74\x79\160\x65"]); curl_setopt($this->handle, CURLOPT_NOBODY, true); break; case Requests::TRACE: curl_setopt($this->handle, CURLOPT_CUSTOMREQUEST, $options["\164\x79\160\145"]); break; case Requests::PATCH: case Requests::PUT: case Requests::DELETE: case Requests::OPTIONS: default: curl_setopt($this->handle, CURLOPT_CUSTOMREQUEST, $options["\164\x79\x70\x65"]); if (!empty($data)) { curl_setopt($this->handle, CURLOPT_POSTFIELDS, $data); } } $timeout = max($options["\x74\x69\x6d\145\x6f\165\164"], 1); if (is_int($timeout) || $this->version < self::CURL_7_16_2) { curl_setopt($this->handle, CURLOPT_TIMEOUT, ceil($timeout)); } else { curl_setopt($this->handle, CURLOPT_TIMEOUT_MS, round($timeout * 1000)); } if (is_int($options["\x63\157\x6e\x6e\x65\x63\x74\137\164\x69\155\145\157\165\x74"]) || $this->version < self::CURL_7_16_2) { curl_setopt($this->handle, CURLOPT_CONNECTTIMEOUT, ceil($options["\143\157\x6e\x6e\x65\x63\164\x5f\164\151\155\x65\157\x75\x74"])); } else { curl_setopt($this->handle, CURLOPT_CONNECTTIMEOUT_MS, round($options["\143\x6f\156\156\x65\x63\164\137\164\x69\x6d\145\x6f\x75\164"] * 1000)); } curl_setopt($this->handle, CURLOPT_URL, $url); curl_setopt($this->handle, CURLOPT_USERAGENT, $options["\165\x73\145\162\x61\147\145\156\x74"]); if (!empty($headers)) { curl_setopt($this->handle, CURLOPT_HTTPHEADER, $headers); } if ($options["\160\162\x6f\164\x6f\143\157\154\137\x76\x65\x72\x73\x69\x6f\156"] === 1.1) { curl_setopt($this->handle, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); } else { curl_setopt($this->handle, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); } if ($options["\142\154\x6f\143\x6b\x69\x6e\x67"] === true) { curl_setopt($this->handle, CURLOPT_HEADERFUNCTION, array($this, "\x73\164\162\x65\x61\x6d\x5f\150\145\141\144\145\162\163")); curl_setopt($this->handle, CURLOPT_WRITEFUNCTION, array($this, "\163\164\162\145\141\x6d\x5f\x62\x6f\144\171")); curl_setopt($this->handle, CURLOPT_BUFFERSIZE, Requests::BUFFER_SIZE); } } public function process_response($response, $options) { if ($options["\142\x6c\157\143\x6b\x69\156\147"] === false) { $fake_headers = ''; $options["\x68\157\x6f\x6b\163"]->dispatch("\x63\x75\x72\154\56\x61\x66\164\145\162\137\162\x65\x71\x75\x65\163\164", array(&$fake_headers)); return false; } if ($options["\146\151\154\x65\x6e\x61\155\x65"] !== false && $this->stream_handle) { fclose($this->stream_handle); $this->headers = trim($this->headers); } else { $this->headers .= $response; } if (curl_errno($this->handle)) { $error = sprintf("\143\x55\122\114\40\145\162\162\157\162\40\45\163\x3a\x20\x25\x73", curl_errno($this->handle), curl_error($this->handle)); throw new Exception($error, "\x63\x75\162\154\x65\x72\x72\x6f\x72", $this->handle); } $this->info = curl_getinfo($this->handle); $options["\x68\157\157\153\163"]->dispatch("\x63\x75\162\x6c\56\x61\x66\164\x65\x72\x5f\x72\145\161\x75\x65\x73\164", array(&$this->headers, &$this->info)); return $this->headers; } public function stream_headers($handle, $headers) { if ($this->done_headers) { $this->headers = ''; $this->done_headers = false; } $this->headers .= $headers; if ($headers === "\15\12") { $this->done_headers = true; } return strlen($headers); } public function stream_body($handle, $data) { $this->hooks->dispatch("\x72\x65\161\x75\145\x73\164\x2e\x70\x72\157\147\162\145\x73\x73", array($data, $this->response_bytes, $this->response_byte_limit)); $data_length = strlen($data); if ($this->response_byte_limit) { if ($this->response_bytes === $this->response_byte_limit) { return $data_length; } if ($this->response_bytes + $data_length > $this->response_byte_limit) { $limited_length = $this->response_byte_limit - $this->response_bytes; $data = substr($data, 0, $limited_length); } } if ($this->stream_handle) { fwrite($this->stream_handle, $data); } else { $this->response_data .= $data; } $this->response_bytes += strlen($data); return $data_length; } private static function format_get($url, $data) { if (!empty($data)) { $query = ''; $url_parts = parse_url($url); if (empty($url_parts["\161\165\145\x72\x79"])) { $url_parts["\161\165\x65\162\x79"] = ''; } else { $query = $url_parts["\x71\165\x65\x72\171"]; } $query .= "\x26" . http_build_query($data, '', "\46"); $query = trim($query, "\x26"); if (empty($url_parts["\x71\x75\145\162\x79"])) { $url .= "\x3f" . $query; } else { $url = str_replace($url_parts["\x71\x75\x65\x72\171"], $query, $url); } } return $url; } public static function test($capabilities = array()) { if (!function_exists("\143\165\x72\x6c\137\x69\156\x69\164") || !function_exists("\143\x75\162\x6c\x5f\145\170\x65\143")) { return false; } if (isset($capabilities[Capability::SSL]) && $capabilities[Capability::SSL]) { $curl_version = curl_version(); if (!(CURL_VERSION_SSL & $curl_version["\x66\x65\x61\164\x75\162\145\163"])) { return false; } } return true; } private function get_expect_header($data) { if (!is_array($data)) { return strlen((string) $data) >= 1048576 ? "\61\60\60\x2d\103\157\156\164\x69\156\165\x65" : ''; } $bytesize = 0; $iterator = new RecursiveIteratorIterator(new RecursiveArrayIterator($data)); foreach ($iterator as $datum) { $bytesize += strlen((string) $datum); if ($bytesize >= 1048576) { return "\x31\60\60\x2d\x43\157\156\164\x69\x6e\165\145"; } } return ''; } }

Function Calls

None

Variables

None

Stats

MD5 cf46a7342f9c675c4044478dfe842e8e
Eval Count 0
Decode Time 173 ms