Olá amigos, aqui um exemplo de mass ping utilizando curl_multi
Code:
Apenas usuários registrados e ativados podem ver os links., Clique aqui para se cadastrar...
[]'s
Code:
php mass_ping.php sites.txt
Código PHP:
<?php
/*
* Mass ping using Curl_multi (Get)
* by n4sss
* */
set_time_limit(0);
error_reporting(0);
function save_buffer($content, $file, $mode){
$fp = fopen($file, $mode);
fwrite($fp, $content."\r\n");
fclose($fp);
}
function parse_content($file){
$content = array_unique(array_filter(explode("\n", file_get_contents($file))));
unlink($file);
foreach($content as $parsed)
{
$fp = fopen($file, "a");
fwrite($fp, $parsed."\r\n");
fclose($fp);
flush();
}
}
function ping($sites, $log, $thread){
$multi = curl_multi_init();
$cnt = 1;
$bolean = array_chunk($sites, $thread);
$regex = '#<b>(.*?)</b>#s';
$reverse = "http://baremetal.com/cgi-bin/dnsip?target=";
foreach($bolean as $url)
{
for($i=0;$i<=count($url)-1;$i++)
{
$site = preg_replace("/http:\/\//", "", $url[$i]);
$ch[$i] = curl_init();
curl_setopt($ch[$i], CURLOPT_URL, $reverse.$site);
curl_setopt($ch[$i], CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch[$i], CURLOPT_TIMEOUT, 8);
curl_multi_add_handle($multi, $ch[$i]);
}do{curl_multi_exec($multi,$handl);usleep(1);}while($handl>0);
foreach($ch as $ch_id => $operator)
{
$grep[$ch_id] = curl_multi_getcontent($operator);
curl_multi_remove_handle($multi, $operator);
preg_match_all($regex, $grep[$ch_id], $result);
foreach($result[1] as $parse);
print "[$cnt] => $parse\n";
save_buffer($parse,$log,"a");
flush();
$cnt++;
}
}
parse_content($log);
$count = count(file($log));
print "All results parsed in => $log [$count] ips filtreds\n";
}
if(!@$argv[1]){
exit("php mass_ping.php sites.txt\n");
}else{
if(!is_file("$argv[1]")) die("- $argv[1] FILE NOT FOUND\n");
$sites = array_unique(array_filter(explode("\n", file_get_contents("$argv[1]"))));
$log = "ping_result.txt";
$thread = "30";
ping($sites, $log, $thread);
}
?>
[]'s