class mycurl {
protected $_url;
protected $_headers = [];
protected $_post;
protected $_postFields;
protected $_proxy;
protected $_proxyAddr;
protected $_proxyPort;
protected $_proxyUserPass;
protected $_useragent = 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.86 Safari/537.36';
protected $_referer = "https://www.google.com";
protected $_timeout = 10;
protected $_maxRedirects = 4;
protected $_followlocation = true;
protected $_includeHeader = true;
protected $_info;
public function __construct($url,
$headers = null,
$post = false,
$postFields = null,
$isproxy = false,
$proxy = null,
$includeHeader = true) {
$this->_url = $url;
($headers == null) ? $this->_headers = [] : $this->_headers = $headers;
$this->_post = $post;
$this->_postFields = $postFields;
$this->_proxy = $isproxy;
$this->_includeHeader = $includeHeader;
if ($isproxy) {
$proxy_arr = explode(":", $proxy);
if (count($proxy_arr) == 4) {
$this->_proxyAddr = $proxy_arr[0];
$this->_proxyPort = $proxy_arr[1];
$this->_proxyUserPass = $proxy_arr[2] . ":" . $proxy_arr[3];
}
else {
$this->_proxyAddr = $proxy_arr[0];
$this->_proxyPort = $proxy_arr[1];
$this->_proxyUserPass = null;
}
}
else {
$this->_proxyAddr = null;
$this->_proxyPort = null;
$this->_proxyUserPass = null;
}
}
public function GetResponse() {
$s = curl_init();
curl_setopt($s, CURLOPT_RETURNTRANSFER, true);
curl_setopt($s, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($s, CURLOPT_URL, $this->_url);
curl_setopt($s, CURLOPT_HTTPHEADER, $this->_headers);
curl_setopt($s, CURLOPT_TIMEOUT, $this->_timeout);
curl_setopt($s, CURLOPT_MAXREDIRS, $this->_maxRedirects);
curl_setopt($s, CURLOPT_FOLLOWLOCATION, $this->_followlocation);
if ($this->_post)
{
curl_setopt($s, CURLOPT_POST, true);
curl_setopt($s, CURLOPT_POSTFIELDS, $this->_postFields);
}
if ($this->_proxy) {
curl_setopt($s, CURLOPT_PROXYTYPE, 'HTTP');
curl_setopt($s, CURLOPT_HTTPPROXYTUNNEL, 0);
curl_setopt($s, CURLOPT_PROXY, $this->_proxyAddr);
curl_setopt($s, CURLOPT_PROXYPORT, $this->_proxyPort);
if ($this->_proxyUserPass != null) {
curl_setopt($s, CURLOPT_PROXYUSERPWD, $this->_proxyUserPass);
curl_setopt($s, CURLOPT_PROXYAUTH, CURLAUTH_BASIC);
}
}
if ($this->_includeHeader) curl_setopt($s, CURLOPT_HEADER,true);
curl_setopt($s, CURLOPT_USERAGENT, $this->_useragent);
curl_setopt($s, CURLOPT_REFERER, $this->_referer);
$response = curl_exec($s);
$this->_info = curl_getinfo($s);
curl_close($s);
return $response;
}
public function GetInfo() {
return $this->_info;
}
}
$MyCURL = new mycurl(
"http://ip-api.com/json/",
false,
false,
null,
true,
GetProxy(),
true
);
$result = $MyCURL->GetResponse();
echo $result;
curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
curl_setopt($ch, CURLOPT_PROXY, $proxy_ip);
curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTPS);
curl_setopt($ch, CURLOPT_PROXY, $proxy_ip);
curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS4);
curl_setopt($ch, CURLOPT_PROXY, $proxy_ip);
curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
curl_setopt($ch, CURLOPT_PROXY, $proxy_ip);
curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
curl_setopt($ch, CURLOPT_PROXY, $proxy_ip);
curl_setopt($ch, CURLOPT_PROXYUSERPWD, $proxy_pass);