服务器列表3

This commit is contained in:
wanyongkang
2020-11-07 17:48:11 +08:00
parent f48a253a74
commit e26e80579c
4 changed files with 617 additions and 68 deletions

View File

@@ -5,72 +5,98 @@
* @Author: kangkang
* @Date: 2020-11-03 11:04:15
* @LastEditors: kangkang
* @LastEditTime: 2020-11-06 16:47:03
* @LastEditTime: 2020-11-07 17:34:32
*/
$is_script = 1;
include __DIR__ . '/../../index.php';
use app\api\model\Product;
$product_model = new Product;
$product_list = $product_model->field('Id,Token')->fetchAll();
$all = fopen('./all.csv','w');
$dnx_exit = fopen('./dns_diff.csv','a');
$dnx_has_exit = get_product('./dns_diff.csv',1);
$all = fopen(__DIR__.'/data/all.csv','w');
$dnx_exit = fopen(__DIR__.'/data/dns_diff.csv','a');
$dnx_has_exit = get_product(__DIR__.'/data/dns_diff.csv',1);
$qiangzi_data = get_product('./qiangzi.csv');
$qiangzi_f = fopen('./qiangzi.csv','w');
$qiangzi_data = get_product(__DIR__.'/data/qiangzi.csv');
$qiangzi_f = fopen(__DIR__.'/data/qiangzi.csv','w');
$qiangzi = json_decode(file_get_contents("http://47.92.116.14:2222/api/areaPool.html?type=json"), true);
//写入强子文件
qiangzi_getList($qiangzi,$qiangzi_f,$all,$qiangzi_data);
fclose($qiangzi_f);
$xingxing_data = get_product('./xingxing.csv');
$xingxing_f = fopen('./xingxing.csv','w');
$xingxing_data = get_product(__DIR__.'/data/xingxing.csv');
$xingxing_f = fopen(__DIR__.'/data/xingxing.csv','w');
$xingxing = json_decode(file_get_contents("http://47.110.154.124:6930/api/nasStatus.html?format=json"), true);
//写入星星文件
xingxing_getList($xingxing,$xingxing_f,$all,$xingxing_data);
fclose($xingxing_f);
$jike_data = get_product('./jike.csv');
$jike_f = fopen('./jike.csv','w');
$jike_data = get_product(__DIR__.'/data/jike.csv');
$jike_f = fopen(__DIR__.'/data/jike.csv','w');
$jike = json_decode(file_get_contents("http://api.webok.me/beikeiplist/"), true)['data'];
//写入极客文件
jike_getList($jike,$jike_f,$all,$jike_data);
fclose($jike_f);
$tiantian_data = get_product('./tiantian.csv');
$tiantian_f = fopen('./tiantian.csv','w');
$tiantian_data = get_product(__DIR__.'/data/tiantian.csv');
$tiantian_f = fopen(__DIR__.'/data/tiantian.csv','w');
$tiantian = json_decode(file_get_contents("http://api.ipzuiduo.com/api/areas?apiid=135&sendtime=".time()."&sign=".md5('apiid=135&sendtime='.time().'Fz1JRXVBCuwja2G2SoY2EUdgXtCGSBXS')), true)['data'];
//写入天天文件
tiantian_getList($tiantian,$tiantian_f,$all,$tiantian_data,'天天');
fclose($tiantian_f);
$laoying_data = get_product('./laoying.csv');
$laoying_f = fopen('./laoying.csv','w');
$laoying = json_decode(get_content('https://dl.ipduoduo.com/api/area?_=1604541004026','_dailissid=b3da7e1676537db8a36b7e4778bfed50c4f388237dc4e71d2e09386fe927a8927cd506150a323beda7f3a8330fa7665d31e3a712b14513c61529290a'), true)['data'];
$laoying_data = get_product(__DIR__.'/data/laoying.csv');
$laoying_f = fopen(__DIR__.'/data/laoying.csv','w');
$laoying = json_decode(get_content('https://dl.ipduoduo.com/api/area?_=1604541004026',$product_list[4]['Token']), true)['data'];
//写入老鹰文件
tiantian_getList($laoying,$laoying_f,$all,$laoying_data,'老鹰');
fclose($laoying_f);
$shihui_data = get_product('./shihui.csv');
$shihui_f = fopen('./shihui.csv','w');
$shihui = get_content('http://39.96.182.192:8888/agent.html','PHPSESSID=4215spk7em5u4kutgaro65l9f1; menuid=submenu_profile');
$shihui_data = get_product(__DIR__.'/data/shihui.csv');
$shihui_f = fopen(__DIR__.'/data/shihui.csv','w');
$shihui = get_content('http://39.96.182.192:8888/agent.html',$product_list[15]['Token']);
//写入实惠文件
shihui_getList($shihui,$shihui_f,$all,$shihui_data);
fclose($shihui_f);
$gongxiang_data = get_product('./gongxiang.csv');
$gongxiang_f = fopen('./gongxiang.csv','w');
$gongxiang = get_content('http://118.25.157.170:39999/agent.html','PHPSESSID=hqk8ih6l4hbpp75a7g2sfb3l41');
$gongxiang_data = get_product(__DIR__.'/data/gongxiang.csv');
$gongxiang_f = fopen(__DIR__.'/data/gongxiang.csv','w');
$gongxiang = get_content('http://118.25.157.170:39999/agent.html',$product_list[14]['Token']);
gongxiang_getList($gongxiang,$gongxiang_f,$all,$gongxiang_data);
fclose($gongxiang_f);
$xunlian_data = get_product('./xunlian.csv');
$xunlian_f = fopen('./xunlian.csv','w');
$xunlian_data = get_product(__DIR__.'/data/xunlian.csv');
$xunlian_f = fopen(__DIR__.'/data/xunlian.csv','w');
$xunlian = json_decode(file_get_contents("http://xunyou.ippptp.com:2222/api/areaPool.html?type=json"), true);
//写入讯连文件
xunlian_getList($xunlian,$xunlian_f,$all,$xunlian_data);
fclose($xunlian_f);
$wuxian_data = get_product(__DIR__.'/data/wuxian.csv');
$wuxian_f = fopen(__DIR__.'/data/wuxian.csv','w');
$wuxian = get_content('http://118.25.157.170:6888/agent.html',$product_list[9]['Token']);
//写入无限文件
wuxian_getList($wuxian,$wuxian_f,$all,$wuxian_data);
fclose($wuxian_f);
$xianfeng_data = get_product(__DIR__.'/data/xianfeng.csv');
$xianfeng_f = fopen(__DIR__.'/data/xianfeng.csv','w');
$xianfeng = json_decode(xianfeng_post('http://39.102.54.40/development/fault.html','PHPSESSID=04amq9qmgf1u1sgl29a5a53is6',['page'=>1,'limit'=>1000]),true)['data'];
//写入先锋文件
xianfeng_getList($xianfeng,$xianfeng_f,$all,$xianfeng_data);
fclose($xianfeng_f);
$jinrui_data = get_product(__DIR__.'/data/jinrui.csv');
$jinrui_f = fopen(__DIR__.'/data/jinrui.csv','w');
$jinrui = file_get_contents("http://pptp.zhekou5.com/api/getnas.php");
//写入金瑞文件
jinrui_getList($jinrui,$jinrui_f,$all,$jinrui_data);
fclose($jinrui_f);
//星星2288写入all
$file2288 = fopen('./2288.csv','r');
$file2288 = fopen(__DIR__.'/data/2288.csv','r');
while ($data = fgetcsv($file2288)) {
fputcsv($all,$data);
}
@@ -87,6 +113,7 @@ function qiangzi_getList($data,&$file,&$all,$exit)
foreach ($data as $info) {
$record = [];
$record['name'] = '强子';
//如果存在 不为空 则
if(!empty($info['titleRow'])){
$record['city'] = $info['titleRow'];
@@ -132,7 +159,7 @@ function qiangzi_getList($data,&$file,&$all,$exit)
function xingxing_getList($data,&$file,&$all,$exit)
{
global $dnx_exit,$dnx_has_exit;
$online = ['离线','在线'];
$online = ['离线','正常'];
$province_record = [];
//省会
$province = ['黑龙','内蒙'];
@@ -140,6 +167,7 @@ function xingxing_getList($data,&$file,&$all,$exit)
foreach ($data as $info) {
$record = [];
$record['name'] = '星星';
$province_detail = mb_substr($info['description'],0,2);
if(in_array($province_detail,$province)){
$province_detail = mb_substr($info['description'],0,3);
@@ -192,6 +220,7 @@ function jike_getList($data,&$file,&$all,$exit)
$province_record = [];
foreach ($data as $info) {
$record = [];
$record['name'] = '极客';
//如果存在 不为空 则
if(!in_array($info['province'],$province_record)){
$record['city'] = $info['province'];
@@ -230,6 +259,7 @@ function tiantian_getList($data,&$file,&$all,$exit,$product_name)
foreach ($data as $info) {
$record = [];
$record['name'] = $product_name;
$record['city'] = $info['name'];
fputcsv($file,$record);
fputcsv($all,$record);
@@ -271,6 +301,7 @@ function shihui_getList($html,&$file,&$all,$exit){
preg_match_all("/<p>(.*?)<\/p>/is", $result[0], $result);
foreach($result[0] as $k=>$info){
$record = [];
$record['name'] = '实惠';
if ($k==0||$k==5){
continue;
} else {
@@ -319,6 +350,7 @@ function gongxiang_getList($html,&$file,&$all,$exit){
preg_match_all("/<p>(.*?)<\/p>/is", $html, $result);
foreach($result[0] as $k=>$info){
$record = [];
$record['name'] = '共享';
if ($k==0){
continue;
} else {
@@ -451,6 +483,7 @@ function xunlian_getList($data,&$file,&$all,$exit){
$province_record = [];
foreach($data as $info){
$record = [];
$record['name'] = '讯连';
$province_detail = mb_substr($info['description'],0,2);
if($province_detail == '全国'){
$record['city'] = $info['description'];
@@ -516,6 +549,183 @@ function xunlian_getList($data,&$file,&$all,$exit){
}
}
function wuxian_getList($html,&$file,&$all,$exit){
global $dnx_exit,$dnx_has_exit;
//省会
$province = ['黑龙','内蒙'];
$province_record = [];
$citys = ['北京','上海','天津','重庆'];
preg_match("/<div>&nbsp;<\/div>(.*?)<\/div><\/div>/is", $html, $result);
$result = str_replace('<div>&nbsp;</div>','',$result[0]);
preg_match_all("/<div>(.*?)<\/div>/is", $result, $result);
foreach($result[0] as $k=>$info){
$record = [];
$record['name'] = '无限';
$info = ltrim($info,'<div>');
$info = rtrim($info,'</div>');
if(strpos($info,'span') !== false){
$data = explode('<span class="Apple-tab-span" style="white-space:pre"> </span>',$info);
} else {
$data = explode(' &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;',$info);
}
$data[1] = trim($data[1]);
$province_detail = mb_substr(trim($data[1]),0,2);
if(in_array($province_detail,$province)){
$province_detail = mb_substr($data[1],0,3);
$data[1] = mb_substr($data[1],3);
} elseif(!in_array($province_detail,$citys)) {
$data[1] = mb_substr($data[1],2);
}
if(!in_array($province_detail,$province_record)){
$record['city'] = $province_detail;
$province_record[] = $province_detail;
fputcsv($file,$record);
fputcsv($all,$record);
}
if(strpos($data[1],'电信') !== false){
$record['city'] = explode('电信',$data[1])[0];
$record['city'] = str_replace('&lt;','',$record['city']);
$record['city'] = str_replace('&gt;','',$record['city']);
$record['supply'] = '电信';
} elseif(strpos($data[1],'联通') !== false){
$record['city'] = explode('联通',$data[1])[0];
$record['city'] = str_replace('&lt;','',$record['city']);
$record['city'] = str_replace('&gt;','',$record['city']);
$record['supply'] = '联通';
} elseif(strpos($data[1],'移动') !== false){
$record['city'] = explode('移动',$data[1])[0];
$record['city'] = str_replace('&lt;','',$record['city']);
$record['city'] = str_replace('&gt;','',$record['city']);
$record['supply'] = '移动';
} else {
$record['city'] = $data[1];
$record['city'] = str_replace('&lt;','',$record['city']);
$record['city'] = str_replace('&gt;','',$record['city']);
$record['supply'] = '电信/联通';
}
$record['ip'] = '';
$record['daikuan'] = '';
$record['onlineuser'] = '';
$record['maxuser'] = '';
$record['online'] = '';
$record['status'] = '';
$record['nasname'] = $data[0];
if(!in_array($record['nasname'],$exit) && !in_array($record['nasname'],$dnx_has_exit)){
fputcsv($dnx_exit,['无限',$record['nasname']]);
}
fputcsv($file,$record);
fputcsv($all,$record);
}
}
function xianfeng_getList($data,&$file,&$all,$exit){
global $dnx_exit,$dnx_has_exit;
//省会
$province = ['黑龙','内蒙','直辖'];
$province_record = [];
$status = ['维护中','正常'];
foreach ($data as $info) {
$record = [];
$record['name'] = '先锋';
if(strpos($info['description'],'混播') || strpos($info['description'],'所有单城市')){
$province_detail = '混播';
if(!in_array($province_detail,$province_record)){
$record['city'] = $province_detail;
$province_record[] = $province_detail;
fputcsv($file,$record);
fputcsv($all,$record);
}
$record['city'] = $info['description'];
$record['supply'] = '电信/联通';
} else {
$info['description'] = trim($info['description'],'a');
$province_detail = mb_substr(trim($info['description']),0,2);
if(in_array($province_detail,$province)){
$province_detail = mb_substr($info['description'],0,3);
}
if(!in_array($province_detail,$province_record)){
$record['city'] = $province_detail;
$province_record[] = $province_detail;
fputcsv($file,$record);
fputcsv($all,$record);
}
if(strpos($info['description'],'电信') !== false){
$record['city'] = $info['description'];
$record['supply'] = '电信';
} elseif(strpos($info['description'],'联通') !== false){
$record['city'] = $info['description'];
$record['supply'] = '联通';
} elseif(strpos($info['description'],'移动') !== false){
$record['city'] = $info['description'];
$record['supply'] = '移动';
} else {
$record['city'] = $info['description'];
$record['supply'] = '电信/联通';
}
}
$record['ip'] = '';
$record['daikuan'] = '';
$record['onlineuser'] = '';
$record['maxuser'] = '';
$record['online'] = ($info['serstatus'] == 1)?'正常':'维护中';
$record['status'] = '';
$record['nasname'] = $info['nasname'];
if(!in_array($record['nasname'],$exit) && !in_array($record['nasname'],$dnx_has_exit)){
fputcsv($dnx_exit,['先锋',$record['nasname']]);
}
fputcsv($file,$record);
fputcsv($all,$record);
}
}
function jinrui_getList($html,&$file,&$all,$exit){
global $dnx_exit,$dnx_has_exit;
//省会
$province_record = [];
$status = ['0'=>'维护中','1'=>'正常','-1'=>'离线'];
preg_match_all("/\{(.*?)\}/is", $html, $result);
foreach ($result[0] as $info) {
$info = json_decode($info,true);
if(empty($info)){
continue;
}
$record = [];
$record['name'] = '金瑞';
if(!in_array($info['province'],$province_record)){
$record['city'] = $info['province'];
$province_record[] = $info['province'];
fputcsv($file,$record);
fputcsv($all,$record);
}
if(empty($info['city'])){
$record['city'] = $info['province'] ;
} else {
$record['city'] = $info['city'];
}
$record['supply'] = $info['isp'];
$record['ip'] = '';
$record['daikuan'] = '';
$record['onlineuser'] = '';
$record['maxuser'] = '';
$record['online'] = $status[$info['status']];
$record['status'] = '';
$nasname = explode('|',$info['nasname']);
foreach($nasname as $v){
$record['nasname'] = $v;
if(!in_array($record['nasname'],$exit) && !in_array($record['nasname'],$dnx_has_exit)){
fputcsv($dnx_exit,['金瑞',$record['nasname']]);
}
fputcsv($file,$record);
fputcsv($all,$record);
}
}
}
function get_content($url, $cookie) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
@@ -527,7 +737,7 @@ function get_content($url, $cookie) {
return $rs;
}
function get_product($file_path,$num = 8){
function get_product($file_path,$num = 9){
$list = [];
$file = fopen($file_path,'r');
while ($info = fgetcsv($file)) {
@@ -536,4 +746,19 @@ function get_product($file_path,$num = 8){
}
fclose($file);
return $list;
}
function xianfeng_post($url, $cookie, $post) {
$curl = curl_init();//初始化curl模块
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_HEADER, 0);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_COOKIE, $cookie); //读取cookie
curl_setopt($curl, CURLOPT_POST, 1);//post方式提交
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($post));//要提交的信息
$rs = curl_exec($curl); //执行cURL抓取页面内容
curl_close($curl);
return $rs;
}