/** * Get an HTTP client based on cURL * * @param string $location SOAP URL * @param string $ca_file Certification authority file path * @param array $headers HTTP headers * * @return CHTTPClient */ protected function getHttpClient($location, $ca_file, $headers) { $http_client = new CHTTPClient($location); if ($this->local_cert) { $http_client->setSSLAuthentification($this->local_cert, $this->passphrase); } if ($ca_file) { $http_client->setSSLPeer($ca_file); } $http_client->header = $headers; return $http_client; }
/** * Check the URL disponibility * * @param String $url URL site * @param String[] $option Option array * @param Boolean $return_body Return the content of the page * * @return bool|int */ static function checkUrl($url, $option = null, $return_body = false) { try { $http_client = new CHTTPClient($url); if ($option) { if (CMbArray::get($option, "ca_cert")) { $http_client->setSSLPeer($option["ca_cert"]); } if (CMbArray::get($option, "username") || CMbArray::get($option, "password")) { $http_client->setHTTPAuthentification($option["username"], $option["password"]); } if (CMbArray::get($option, "local_cert")) { $http_client->setSSLAuthentification($option["local_cert"], $option["passphrase"]); } } $http_client->setOption(CURLOPT_HEADER, true); $result = $http_client->get(); } catch (Exception $e) { return false; } if ($return_body) { return $result; } return preg_match("|200|", $result); }