0.9.0 - the ZapV version updated to current php standards. Brave search used, while Bing and Google search api are deprecated
This commit is contained in:
parent
3d4298fe8b
commit
4ddaddda3d
31 changed files with 1778 additions and 1 deletions
64
utils/ZAPCurl.class.php
Executable file
64
utils/ZAPCurl.class.php
Executable file
|
|
@ -0,0 +1,64 @@
|
|||
<?php
|
||||
class ZAPCurl {
|
||||
private $url;
|
||||
|
||||
private $binary;
|
||||
|
||||
private $referer;
|
||||
|
||||
private $headers = array();
|
||||
|
||||
public $error = null;
|
||||
|
||||
public $httpCode = null;
|
||||
|
||||
//private $proxyIp = '127.0.0.1:81';
|
||||
|
||||
public function __construct($url, $binary = false) {
|
||||
$this->url = $url;
|
||||
$this->binary = $binary;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a custom header for the request
|
||||
* @param string $key Header name
|
||||
* @param string $value Header value
|
||||
*/
|
||||
public function setHeader($key, $value) {
|
||||
$this->headers[] = $key . ': ' . $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Curl wrapper
|
||||
* @param string $url
|
||||
* @param boolean $binary
|
||||
* @return mixed $curlData
|
||||
*/
|
||||
public function fetchCurlData() {
|
||||
$cUrl = curl_init();
|
||||
curl_setopt($cUrl, CURLOPT_URL, $this->url);
|
||||
curl_setopt($cUrl, CURLOPT_RETURNTRANSFER, 1);
|
||||
curl_setopt($cUrl, CURLOPT_TIMEOUT, ZAP_CURL_TIMEOUT);
|
||||
if (isset($this->referer)) {
|
||||
curl_setopt($cUrl, CURLOPT_REFERER, $this->referer);
|
||||
}
|
||||
if (!empty($this->headers)) {
|
||||
curl_setopt($cUrl, CURLOPT_HTTPHEADER, $this->headers);
|
||||
}
|
||||
//curl_setopt($cUrl, CURLOPT_PROXY, $this->proxyIp);
|
||||
|
||||
$curlData = curl_exec($cUrl);
|
||||
$this->error = curl_error($cUrl);
|
||||
$this->httpCode = curl_getinfo($cUrl, CURLINFO_HTTP_CODE);
|
||||
// curl_close() is deprecated as of PHP 8.5 (no effect since PHP 8.0)
|
||||
|
||||
if ($this->error) {
|
||||
error_log('ZAPCurl error: ' . $this->error . ' URL: ' . $this->url);
|
||||
} elseif ($this->httpCode >= 400) {
|
||||
error_log('ZAPCurl HTTP ' . $this->httpCode . ' URL: ' . $this->url);
|
||||
}
|
||||
|
||||
return $curlData;
|
||||
}
|
||||
}
|
||||
?>
|
||||
Loading…
Add table
Add a link
Reference in a new issue