<?
// Fresh proxy list takes from http://proxy-list.org/ru/index.php
set_time_limit(10000);
$list = "
60.247.2.241:8080
123.176.47.203:6588 - fine - fine
";
$goodproxylist = '';
function pping($a)
{
error_reporting(0);
$ret = 0;
$z = explode(":", $a);
// Если это прокси, то в $z должно быть 2 элемента. В идеале можно регуляркой проверить что это IP:PORT
if( 2 == count($z) ){
$z = $z[0];
if( $fo = fsockopen($z, 21, $errno, $errstr, 1) ){
$ret = 1;
fclose($fo);
}
}
return $ret;
}/******************************************************************/
foreach (explode ("\n", $list) as $key=>$value) {
$z ='';
$z=explode("\t", trim($value));
$allproxy[] = $z[0];
}
foreach ($allproxy as $key=>$value)
{
$proxy = $value;
if(strlen($proxy)<5) continue;
//if (!pping($value)) continue;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://iscience.ru/');
curl_setopt($ch, CURLOPT_HEADER, 1);
$headers[] = 'Accept: image/gif, image/x-bitmap, image/jpeg, image/pjpeg';
$headers[] = 'Connection: Keep-Alive';
$headers[] = 'Content-type: application/x-www-form-urlencoded;charset=UTF-8';
$user_agent = 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.0.3705; .NET CLR 1.1.4322; Media Center PC 4.0)';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1);
curl_setopt($ch, CURLOPT_PROXY, "$proxy");
curl_setopt($ch,CURLOPT_FAILONERROR,true);
$data = curl_exec($ch);
if (curl_error($ch)) {
print "Curl error #: " . curl_errno($ch) . " - " . curl_error ($ch) . " - exiting.<br>";
}else {
echo $proxy . ' - fine<br>';
$goodproxylist .= $proxy.'<br>';
}
curl_close($ch);
@ob_flush(); flush();
}
echo '<hr>'.$goodproxylist.'<hr>';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://www.google.com.ua/');
curl_setopt($ch, CURLOPT_TIMEOUT, 300);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_PROXY, "123.176.47.203:6588");
//curl_setopt($ch, CURLOPT_PROXY, 'ip:port');
$xml = curl_exec($ch);
if (curl_error($ch)) {
print "Curl error #: " . curl_errno($ch) . " - " . curl_error ($ch) . " - exiting.<br>";
}else {
echo $xml;
}
curl_close($ch);
echo $xml;
?>