C
chemax
Прохожие
спасибо. тоже самое исчу=)))
Follow along with the video below to see how to install our site as a web app on your home screen.
Примечание: This feature may not be available in some browsers.
class MCurl
{
private $ref="адрес рефера";
private $u_agent="Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14";
private $cookie;
private $timeout;
function __construct($cookie=false,$new_timeout=60)
{
if($cookie)
{
$this->cookie=realpath(dirname(__FILE__)).'/../cookies/'.$cookie;
}
else
{
$this->cookie=realpath(dirname(__FILE__)).'/../cookies/Cookies.txt';
}
$this->timeout=$new_timeout;
}
function setRef($new_ref)
{
$this->ref=$new_ref;
}
function exec($url, $request=false,$cookie_str=false,$header=false,$fl=true)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_TIMEOUT, $this->timeout);
curl_setopt($ch, CURLOPT_REFERER, $this->ref);
curl_setopt($ch, CURLOPT_USERAGENT, $this->u_agent);
curl_setopt($ch, CURLOPT_COOKIEFILE, $this->cookie); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_PROXY, "адрес прокси");
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); // не проверять SSL сертификат
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); // не проверять Host SSL сертификата
if($cookie_str)
{
curl_setopt($ch, CURLOPT_COOKIEJAR, $this->cookie); // Start cookie save to file
}
else
{
curl_setopt($ch, CURLOPT_COOKIE, $this->cookie); // Use cookie from file
}
if($request)
{
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
}
if($header)
{
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
}
else
{
curl_setopt ($ch, CURLOPT_HTTPHEADER, array('Expect:'));// это необходимо, чтобы cURL не высылал заголовок на ожидание
}
if($fl)
{
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
}
else
{
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
}
$result = curl_exec($ch);
if (curl_errno($ch))
{
return "CURL returned error: ".curl_error($ch)."\n";
}
curl_close($ch);
return $result;
}
}