Добрый вечер,
Я создаю скрипт для проверки прокси.Но я немного разбираюсь в цикле в PHP, я делаю все возможное ..
Вот код:
<?php
//$_POST INFORMATIONS
$address = $_POST['address'];
if (!empty($_POST['address']))
{
//COMPTE LE NOMBRE D'ENTREES
$delimiter = $address;
$delimiterArray = ($delimiter != '')?explode(",",$delimiter):NULL;
$arrayCount = count($delimiterArray);
for ($i = 1; $i <= $arrayCount; $i++) {
$url = 'http://api.proxyipchecker.com/pchk.php';
//DELIMITE L'IP ET PORT
$format = explode(":", $address);
$ip = $format[0];
$port = $format[1];
//CURL
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,'ip='.$ip.'&port='.$port);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
list($res_time, $speed, $country, $type) = explode(';', curl_exec($ch));
//REMPLACE LE RESULT
if (isset($type))
{
if ($type >= 4 or $type <= 0)
{
$type = "Undefined";
}
elseif ($type = 1)
{
$type = "Transparent";
}
elseif ($type = 2)
{
$type = "Anonymous";
}
elseif ($type = 3)
{
$type = "High anonymous";
}
}
//ECHO RESULT
echo $ip.":".$port." / Response time: ".$res_time." seconds / Country ".$country." / Type ".$type."\n";
}
}
Ошибка здесь
//DELIMITE L'IP ET PORT
$format = explode(":", $address);
$ip = $format[0];
$port = $format[1];
Поскольку это цикл, поставьте [0], [1], он будет хорош для первого, а затем будет смещением. Если у кого-то есть идея, большое спасибо!
Информация:Формат -> IP: ПОРТ, IP: ПОРТ ..
И мне нужны IP и ПОРТ для каждого адреса для cURL.
Спасибо!