Answer the question
In order to leave comments, you need to log in
Why is the if condition not processed correctly?
There are following functions:
// Проверка доступности сайта через прокси
function checkProxy($proxy = null)
{
if (!empty($proxy)) {
// Заголовок запроса
Curl::sampleCurl()->addHttpheaders([
"User-Agent" => 'Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:55.0) Gecko/20100101 Firefox/55.0',
"Accept" => "application/json, text/javascript, */*; q=0.01",
"Accept" => "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
"Accept-Language" => "ru-RU,ru;q=0.8,en-US;q=0.5,en;q=0.3"
]);
// Подстановка прокси в запрос
Curl::sampleCurl()->setProxy($proxy);
$response = Curl::sampleCurl()->post('https://site.com');
if (preg_match('/ih" value="(\w+)/', $response)) {
return true;
}
}
}
function newProxy($i = 0)
{
$proxy_list = getProxy(); // getProxy() получает список прокси в виде ip:port
while ($i < sizeof($proxy_list)) {
// Проверка работоспособности прокси и отсутствие дубликата
if (checkProxy($proxy_list[$i]) && !DataBase::Db()->checkRow('SELECT count(proxy) FROM ' . Config::DB_TABLE . ' WHERE proxy="' . $proxy_list[$i] . '"')) {
$proxy = $proxy_list[$i];
break;
}
++$i;
}
if (!empty($proxy)) return $proxy;
}
if (!checkProxy('179.24.4.164:8080')) {
echo 'Новая прокся: ' . newProxy() . '<br />';
}
echo 'Новая прокся: ' . newProxy() . '<br />';
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question