From f51c9ed2abe5c68211bb3736be5f70b1fe2c9ec0 Mon Sep 17 00:00:00 2001 From: M.Gergo Date: Fri, 8 Mar 2019 21:20:34 +0100 Subject: további rendrakás --- .../share/facebook/HttpClients/FacebookCurl.php | 129 ---------------- .../HttpClients/FacebookCurlHttpClient.php | 163 --------------------- .../HttpClients/FacebookGuzzleHttpClient.php | 97 ------------ .../HttpClients/FacebookHttpClientInterface.php | 47 ------ .../share/facebook/HttpClients/FacebookStream.php | 80 ---------- .../HttpClients/FacebookStreamHttpClient.php | 94 ------------ .../facebook/HttpClients/HttpClientsFactory.php | 99 ------------- .../certs/DigiCertHighAssuranceEVRootCA.pem | 23 --- 8 files changed, 732 deletions(-) delete mode 100644 mayor-orig/www/include/share/facebook/HttpClients/FacebookCurl.php delete mode 100644 mayor-orig/www/include/share/facebook/HttpClients/FacebookCurlHttpClient.php delete mode 100644 mayor-orig/www/include/share/facebook/HttpClients/FacebookGuzzleHttpClient.php delete mode 100644 mayor-orig/www/include/share/facebook/HttpClients/FacebookHttpClientInterface.php delete mode 100644 mayor-orig/www/include/share/facebook/HttpClients/FacebookStream.php delete mode 100644 mayor-orig/www/include/share/facebook/HttpClients/FacebookStreamHttpClient.php delete mode 100644 mayor-orig/www/include/share/facebook/HttpClients/HttpClientsFactory.php delete mode 100644 mayor-orig/www/include/share/facebook/HttpClients/certs/DigiCertHighAssuranceEVRootCA.pem (limited to 'mayor-orig/www/include/share/facebook/HttpClients') diff --git a/mayor-orig/www/include/share/facebook/HttpClients/FacebookCurl.php b/mayor-orig/www/include/share/facebook/HttpClients/FacebookCurl.php deleted file mode 100644 index 28e4ba59..00000000 --- a/mayor-orig/www/include/share/facebook/HttpClients/FacebookCurl.php +++ /dev/null @@ -1,129 +0,0 @@ -curl = curl_init(); - } - - /** - * Set a curl option - * - * @param $key - * @param $value - */ - public function setopt($key, $value) - { - curl_setopt($this->curl, $key, $value); - } - - /** - * Set an array of options to a curl resource - * - * @param array $options - */ - public function setoptArray(array $options) - { - curl_setopt_array($this->curl, $options); - } - - /** - * Send a curl request - * - * @return mixed - */ - public function exec() - { - return curl_exec($this->curl); - } - - /** - * Return the curl error number - * - * @return int - */ - public function errno() - { - return curl_errno($this->curl); - } - - /** - * Return the curl error message - * - * @return string - */ - public function error() - { - return curl_error($this->curl); - } - - /** - * Get info from a curl reference - * - * @param $type - * - * @return mixed - */ - public function getinfo($type) - { - return curl_getinfo($this->curl, $type); - } - - /** - * Get the currently installed curl version - * - * @return array - */ - public function version() - { - return curl_version(); - } - - /** - * Close the resource connection to curl - */ - public function close() - { - curl_close($this->curl); - } -} diff --git a/mayor-orig/www/include/share/facebook/HttpClients/FacebookCurlHttpClient.php b/mayor-orig/www/include/share/facebook/HttpClients/FacebookCurlHttpClient.php deleted file mode 100644 index 9516cc83..00000000 --- a/mayor-orig/www/include/share/facebook/HttpClients/FacebookCurlHttpClient.php +++ /dev/null @@ -1,163 +0,0 @@ -facebookCurl = $facebookCurl ?: new FacebookCurl(); - } - - /** - * @inheritdoc - */ - public function send($url, $method, $body, array $headers, $timeOut) - { - $this->openConnection($url, $method, $body, $headers, $timeOut); - $this->sendRequest(); - - if ($curlErrorCode = $this->facebookCurl->errno()) { - throw new FacebookSDKException($this->facebookCurl->error(), $curlErrorCode); - } - - // Separate the raw headers from the raw body - list($rawHeaders, $rawBody) = $this->extractResponseHeadersAndBody(); - - $this->closeConnection(); - - return new GraphRawResponse($rawHeaders, $rawBody); - } - - /** - * Opens a new curl connection. - * - * @param string $url The endpoint to send the request to. - * @param string $method The request method. - * @param string $body The body of the request. - * @param array $headers The request headers. - * @param int $timeOut The timeout in seconds for the request. - */ - public function openConnection($url, $method, $body, array $headers, $timeOut) - { - $options = [ - CURLOPT_CUSTOMREQUEST => $method, - CURLOPT_HTTPHEADER => $this->compileRequestHeaders($headers), - CURLOPT_URL => $url, - CURLOPT_CONNECTTIMEOUT => 10, - CURLOPT_TIMEOUT => $timeOut, - CURLOPT_RETURNTRANSFER => true, // Return response as string - CURLOPT_HEADER => true, // Enable header processing - CURLOPT_SSL_VERIFYHOST => 2, - CURLOPT_SSL_VERIFYPEER => true, - CURLOPT_CAINFO => __DIR__ . '/certs/DigiCertHighAssuranceEVRootCA.pem', - ]; - - if ($method !== "GET") { - $options[CURLOPT_POSTFIELDS] = $body; - } - - $this->facebookCurl->init(); - $this->facebookCurl->setoptArray($options); - } - - /** - * Closes an existing curl connection - */ - public function closeConnection() - { - $this->facebookCurl->close(); - } - - /** - * Send the request and get the raw response from curl - */ - public function sendRequest() - { - $this->rawResponse = $this->facebookCurl->exec(); - } - - /** - * Compiles the request headers into a curl-friendly format. - * - * @param array $headers The request headers. - * - * @return array - */ - public function compileRequestHeaders(array $headers) - { - $return = []; - - foreach ($headers as $key => $value) { - $return[] = $key . ': ' . $value; - } - - return $return; - } - - /** - * Extracts the headers and the body into a two-part array - * - * @return array - */ - public function extractResponseHeadersAndBody() - { - $parts = explode("\r\n\r\n", $this->rawResponse); - $rawBody = array_pop($parts); - $rawHeaders = implode("\r\n\r\n", $parts); - - return [trim($rawHeaders), trim($rawBody)]; - } -} diff --git a/mayor-orig/www/include/share/facebook/HttpClients/FacebookGuzzleHttpClient.php b/mayor-orig/www/include/share/facebook/HttpClients/FacebookGuzzleHttpClient.php deleted file mode 100644 index 8feb7cb6..00000000 --- a/mayor-orig/www/include/share/facebook/HttpClients/FacebookGuzzleHttpClient.php +++ /dev/null @@ -1,97 +0,0 @@ -guzzleClient = $guzzleClient ?: new Client(); - } - - /** - * @inheritdoc - */ - public function send($url, $method, $body, array $headers, $timeOut) - { - $options = [ - 'headers' => $headers, - 'body' => $body, - 'timeout' => $timeOut, - 'connect_timeout' => 10, - 'verify' => __DIR__ . '/certs/DigiCertHighAssuranceEVRootCA.pem', - ]; - $request = $this->guzzleClient->createRequest($method, $url, $options); - - try { - $rawResponse = $this->guzzleClient->send($request); - } catch (RequestException $e) { - $rawResponse = $e->getResponse(); - - if ($e->getPrevious() instanceof RingException || !$rawResponse instanceof ResponseInterface) { - throw new FacebookSDKException($e->getMessage(), $e->getCode()); - } - } - - $rawHeaders = $this->getHeadersAsString($rawResponse); - $rawBody = $rawResponse->getBody(); - $httpStatusCode = $rawResponse->getStatusCode(); - - return new GraphRawResponse($rawHeaders, $rawBody, $httpStatusCode); - } - - /** - * Returns the Guzzle array of headers as a string. - * - * @param ResponseInterface $response The Guzzle response. - * - * @return string - */ - public function getHeadersAsString(ResponseInterface $response) - { - $headers = $response->getHeaders(); - $rawHeaders = []; - foreach ($headers as $name => $values) { - $rawHeaders[] = $name . ": " . implode(", ", $values); - } - - return implode("\r\n", $rawHeaders); - } -} diff --git a/mayor-orig/www/include/share/facebook/HttpClients/FacebookHttpClientInterface.php b/mayor-orig/www/include/share/facebook/HttpClients/FacebookHttpClientInterface.php deleted file mode 100644 index 1fbf953d..00000000 --- a/mayor-orig/www/include/share/facebook/HttpClients/FacebookHttpClientInterface.php +++ /dev/null @@ -1,47 +0,0 @@ -stream = stream_context_create($options); - } - - /** - * The response headers from the stream wrapper - * - * @return array - */ - public function getResponseHeaders() - { - return $this->responseHeaders; - } - - /** - * Send a stream wrapped request - * - * @param string $url - * - * @return mixed - */ - public function fileGetContents($url) - { - $rawResponse = file_get_contents($url, false, $this->stream); - $this->responseHeaders = $http_response_header ?: []; - - return $rawResponse; - } -} diff --git a/mayor-orig/www/include/share/facebook/HttpClients/FacebookStreamHttpClient.php b/mayor-orig/www/include/share/facebook/HttpClients/FacebookStreamHttpClient.php deleted file mode 100644 index 1cdfd539..00000000 --- a/mayor-orig/www/include/share/facebook/HttpClients/FacebookStreamHttpClient.php +++ /dev/null @@ -1,94 +0,0 @@ -facebookStream = $facebookStream ?: new FacebookStream(); - } - - /** - * @inheritdoc - */ - public function send($url, $method, $body, array $headers, $timeOut) - { - $options = [ - 'http' => [ - 'method' => $method, - 'header' => $this->compileHeader($headers), - 'content' => $body, - 'timeout' => $timeOut, - 'ignore_errors' => true - ], - 'ssl' => [ - 'verify_peer' => true, - 'verify_peer_name' => true, - 'allow_self_signed' => true, // All root certificates are self-signed - 'cafile' => __DIR__ . '/certs/DigiCertHighAssuranceEVRootCA.pem', - ], - ]; - - $this->facebookStream->streamContextCreate($options); - $rawBody = $this->facebookStream->fileGetContents($url); - $rawHeaders = $this->facebookStream->getResponseHeaders(); - - if ($rawBody === false || empty($rawHeaders)) { - throw new FacebookSDKException('Stream returned an empty response', 660); - } - - $rawHeaders = implode("\r\n", $rawHeaders); - - return new GraphRawResponse($rawHeaders, $rawBody); - } - - /** - * Formats the headers for use in the stream wrapper. - * - * @param array $headers The request headers. - * - * @return string - */ - public function compileHeader(array $headers) - { - $header = []; - foreach ($headers as $k => $v) { - $header[] = $k . ': ' . $v; - } - - return implode("\r\n", $header); - } -} diff --git a/mayor-orig/www/include/share/facebook/HttpClients/HttpClientsFactory.php b/mayor-orig/www/include/share/facebook/HttpClients/HttpClientsFactory.php deleted file mode 100644 index d9f2a8d3..00000000 --- a/mayor-orig/www/include/share/facebook/HttpClients/HttpClientsFactory.php +++ /dev/null @@ -1,99 +0,0 @@ -