$TTL 30
@ IN SOA ns1.webzone.loc. root.webzone.loc. (
20180419 ; Serial
1d ; Refresh
1h ; Retry
1w ; Expire
2h ; Negative Cache TTL
)
@ IN NS webzone.loc.
10 IN PTR ns1.webzone.loc.
site.ru CNAME 192.168.56.10
root@WebServer107:/home/webadmin# dig site.ru @10.114.4.69
; <<>> DiG 9.10.3-P4-Debian <<>> site.ru @10.114.4.69
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 18998
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 13, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;site.ru. IN A
;; ANSWER SECTION:
site.ru. 274 IN A 91.109.201.210
;; AUTHORITY SECTION:
. 38989 IN NS h.root-servers.net.
. 38989 IN NS g.root-servers.net.
. 38989 IN NS b.root-servers.net.
. 38989 IN NS a.root-servers.net.
. 38989 IN NS j.root-servers.net.
. 38989 IN NS c.root-servers.net.
. 38989 IN NS i.root-servers.net.
. 38989 IN NS l.root-servers.net.
. 38989 IN NS m.root-servers.net.
. 38989 IN NS e.root-servers.net.
. 38989 IN NS f.root-servers.net.
. 38989 IN NS k.root-servers.net.
. 38989 IN NS d.root-servers.net.
;; Query time: 0 msec
;; SERVER: 10.114.4.69#53(10.114.4.69)
;; WHEN: Mon May 07 15:56:37 +05 2018
;; MSG SIZE rcvd: 263
root@WebServer107:/home/webadmin#
<?php
/**
*
* Файл-обертка для библиотеки cURL
*
*/
class Curl
{
protected static $curl; //экземпляр объекта
const FOLLOWLOCATION = true;
const RETURNTRANSFER = true;
const AUTOREFERER = true;
const TIMEOUT = 30;
const CONNECT_TIME = 30;
private $ch;
private $url = null;
private $httpheaders = [];
private $postparams = null;
private $proxy_type = null;
private $proxy = null;
public $cookies;
public $user_agent;
private function __construct()
{
$this->ch = curl_init();
}
// Запрос экземпляра класса
public static function setCurl()
{
if (is_null(self::$curl)) {
self::$curl = new self; // Создаем экземпляр класса если он не создан
}
return self::$curl;
}
// Функция POST/GET - запросов
public function post($url, $postparams = [])
{
$this->url = $url;
if (isset($postparams)) {
$this->postparams = $postparams;
}
return $this->exec();
}
// Заголовок запроса
public function addHttpheaders($headers)
{
foreach ($headers as $name => $value) {
$this->httpheaders[$name] = $name . ': ' . $value;
}
}
// Присваемваем USER-AGENT
public function setUserAgent($user_agent = null)
{
$this->user_agent = $user_agent;
}
// Подключение прокси (HTTPS/SOCKS5)
public function setProxy($proxy = null, $proxy_type = null)
{
$this->proxy = $proxy;
$this->proxy_type = $proxy_type;
}
public function clearProxy()
{
$this->proxy = null;
}
// Удаление cookie файла
public function clearCookies()
{
$this->cookies = null;
}
private function exec()
{
curl_setopt($this->ch, CURLOPT_URL, $this->url);
curl_setopt($this->ch, CURLOPT_FOLLOWLOCATION , self::FOLLOWLOCATION);
curl_setopt($this->ch, CURLOPT_AUTOREFERER, self::AUTOREFERER);
curl_setopt($this->ch, CURLOPT_RETURNTRANSFER, self::RETURNTRANSFER);
curl_setopt($this->ch, CURLOPT_HEADER, true);
if ($this->postparams)
curl_setopt($this->ch, CURLOPT_POSTFIELDS, $this->postparams);
if (count($this->httpheaders))
curl_setopt($this->ch, CURLOPT_HTTPHEADER, $this->httpheaders);
if ($this->proxy)
curl_setopt($this->ch, CURLOPT_PROXY, $this->proxy);
if ($this->proxy_type == 'socks5')
curl_setopt($this->ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
curl_setopt($this->ch, CURLOPT_COOKIEFILE, $this->cookies);
curl_setopt($this->ch, CURLOPT_TIMEOUT, self::TIMEOUT);
curl_setopt($this->ch, CURLOPT_CONNECTTIMEOUT, self::CONNECT_TIME);
$response = curl_exec($this->ch);
$response = substr($response, curl_getinfo($this->ch, CURLINFO_HEADER_SIZE));
$this->cookies = implode("\n", curl_getinfo($this->ch, CURLINFO_COOKIELIST));
$this->postparams = null;
return $response;
}
public function __destruct()
{
curl_close($this->ch);
}
}
// Проверка валидности PROXY
function checkProxy($proxy = null)
{
if (!empty($proxy)) {
Curl::setCurl()->addHttpheaders([
"User-Agent" => Curl::setCurl()->user_agent
]);
Curl::setCurl()->setProxy($proxy);
$response = Curl::setCurl()->post('https://vk.com');
if (preg_match('/lg_h/', $response)) {
return true;
}
}
}
Curl::setCurl()->setUserAgent('Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:59.0) Gecko/20100101 Firefox/59.0');
if (!checkProxy('190.190.2.2:8080')) {
echo "Не рабочая прокси!";
}
Curl::setCurl()->clearProxy();
echo Curl::setCurl()->post('https://vk.com');