Hi
I am getting an info from a remote host via cURL. I am using proxy, and I have a database with a lot of proxies, so I put them in the arrays:
$str1 = mysql_evaluate_array("SELECT ip FROM proxies"); // ip addresse
$str2 = mysql_evaluate_array("SELECT port FROM proxies"); //ports
mysql_evaluate_array() is previously defined and put all the fields of a column from a table in an array.
and then I want randomly to choose one of them, which is up and the file via it.
For that reason I try the following:
function getPage($proxy, $url, $agent, $header, $timeout, $timeouttransfer) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, $header);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_PROXY, $proxy);
curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
curl_setopt($ch, CURLOPT_TIMEOUT, $timeouttransfer);
$result['EXE'] = curl_exec($ch);
$result['INF'] = curl_getinfo($ch);
$result['ERR'] = curl_error($ch);
curl_close($ch);
return $result;
}
$page = array(
'EXE' => "",
'INF' => "",
'ERR' => "",
);
while($page['ERR'] == "" && $page['EXE'] != "")
{
$rand = rand(0,count($str1)-1);
$proxy = $str1[$rand] . ":" . $str2[$rand];
$page = getPage($proxy, $url, $agent, 1, 1, 2);
}
echo $page['EXE'];
but the script is immediately executed and there is no output. I think the problem is that PHP thinks that the while() statement is completed in the beginning of the cycle. Do you have any ideas where could be the problem and how to fix it? 😕