diff --git a/script/linedata/display.php b/script/linedata/display.php index 71c75aa..e5fd19b 100755 --- a/script/linedata/display.php +++ b/script/linedata/display.php @@ -1,267 +1,296 @@ $list,'count'=>$count,'use_count'=>$user_count]); + fclose($file); + fclose($file1); + echo json_encode(['data' => $list, 'count' => $count, 'use_count' => $user_count]); } -function format_product($file_path,$dns = ''){ +function format_product($file_path, $dns = '') +{ $list1 = []; $list = []; $user_count = 0; $count = 0; $key = ''; - $file = fopen($file_path,'r'); - $file_path1 = explode('/',$file_path); - $file1 = fopen(__DIR__.'/data/download/'.$file_path1[8],'w'); + $citys = []; + $file = fopen($file_path, 'r'); + $file_path1 = explode('/', $file_path); + $file1 = fopen(__DIR__ . '/data/download/' . $file_path1[8], 'w'); $record = []; - while ($info = fgetcsv($file)) { - if(in_array($info['1'],['曾','龙'])){ + while ($info = fgetcsv($file)) { + if (in_array($info['1'], ['曾', '龙'])) { continue; } - if(empty($info[9])){ + if (empty($info[9])) { $key = $info[1]; } $data['name'] = $info[0]; - $data['city'] = $info[1]; + $city = city_exist($citys,$info[1]); + $citys[] = $city; + $data['city'] = $city; $data['supply'] = $info[2]; $data['ip'] = $info[3]; $data['daikuan'] = $info[4]; $data['onlineuser'] = $info[5]; $data['maxuser'] = $info[6]; $data['online'] = $info[7]; - if(!empty($info[9])){ - $user_count += $data['online']=='正常'?1:0; + if (!empty($info[9])) { + $user_count += $data['online'] == '正常' ? 1 : 0; $count++; } $data['status'] = $info[8]; - if($dns!='shihui'){ - $ip = explode('.',$info[9]); - $data['nasname'] = $ip[0]?ip_repeat($record,$ip[0]).'.'.$dns:''; + if ($dns != 'shihui') { + $ip = explode('.', $info[9]); + $data['nasname'] = $ip[0] ? ip_repeat($record, $ip[0]) . '.' . $dns : ''; } else { $data['nasname'] = $info[9]; } - fputcsv($file1,$data); + fputcsv($file1, $data); $list1[$key][] = $data; } - fclose($file1); - fclose($file); - foreach($list1 as $k=>$val){ - foreach($val as $net_data){ + fclose($file1); + fclose($file); + foreach ($list1 as $k => $val) { + foreach ($val as $net_data) { - fputcsv($file3,$net_data); + fputcsv($file3, $net_data); $list[] = $net_data; } } - echo json_encode(['data'=>$list,'count'=>$count,'use_count'=>$user_count]); + echo json_encode(['data' => $list, 'count' => $count, 'use_count' => $user_count]); } -function format_xingxing($file_path1,$file_path2,$dns){ +function format_xingxing($file_path1, $file_path2, $dns) +{ $list1 = []; $list = []; $user_count = 0; $count = 0; $key = ''; - $file1 = fopen($file_path1,'r'); - $file2 = fopen($file_path2,'r'); + $citys = []; + $file1 = fopen($file_path1, 'r'); + $file2 = fopen($file_path2, 'r'); $record = []; $keys = []; - $file_path = explode('/',$file_path1); - $file3 = fopen(__DIR__.'/data/download/'.$file_path[8],'w'); - while ($info = fgetcsv($file1)) { - if(empty($info[9])){ + $file_path = explode('/', $file_path1); + $file3 = fopen(__DIR__ . '/data/download/' . $file_path[8], 'w'); + while ($info = fgetcsv($file1)) { + if (empty($info[9])) { $key = $info[1]; $keys[] = $key; } $data['name'] = $info[0]; - $data['city'] = $info[1]; + $city = city_exist($citys,$info[1]); + $citys[] = $city; + $data['city'] = $city; $data['supply'] = $info[2]; $data['ip'] = $info[3]; $data['daikuan'] = $info[4]; $data['onlineuser'] = $info[5]; $data['maxuser'] = $info[6]; $data['online'] = $info[7]; - if(!empty($info[9])){ - $user_count += $data['online']=='正常'?1:0; + if (!empty($info[9])) { + $user_count += $data['online'] == '正常' ? 1 : 0; $count++; } $data['status'] = $info[8]; - $ip = explode('.',$info[9]); - $data['nasname'] = $ip[0]?ip_repeat($record,$ip[0]).'.'.$dns:''; + $ip = explode('.', $info[9]); + $data['nasname'] = $ip[0] ? ip_repeat($record, $ip[0]) . '.' . $dns : ''; $list1[$key][] = $data; } - while ($info = fgetcsv($file2)) { - if(empty($info[9])){ + while ($info = fgetcsv($file2)) { + if (empty($info[9])) { $key = $info[1]; - if(in_array($key,$keys)){ + if (in_array($key, $keys)) { continue; } } $data['name'] = $info[0]; - $data['city'] = $info[1]; + $city = city_exist($citys,$info[1]); + $citys[] = $city; + $data['city'] = $city; $data['supply'] = $info[2]; $data['ip'] = $info[3]; $data['daikuan'] = $info[4]; $data['onlineuser'] = $info[5]; $data['maxuser'] = $info[6]; $data['online'] = $info[7]; - if(!empty($info[9])){ - $user_count += $data['online']=='正常'?1:0; + if (!empty($info[9])) { + $user_count += $data['online'] == '正常' ? 1 : 0; $count++; } $data['status'] = $info[8]; - $ip = explode('.',$info[9]); - $data['nasname'] = $ip[0]?ip_repeat($record,$ip[0]).'.'.$dns:''; + $ip = explode('.', $info[9]); + $data['nasname'] = $ip[0] ? ip_repeat($record, $ip[0]) . '.' . $dns : ''; $list1[$key][] = $data; } - foreach($list1 as $k=>$val){ - foreach($val as $net_data){ + foreach ($list1 as $k => $val) { + foreach ($val as $net_data) { - fputcsv($file3,$net_data); + fputcsv($file3, $net_data); $list[] = $net_data; } } - fclose($file1); - fclose($file2); - fclose($file3); + fclose($file1); + fclose($file2); + fclose($file3); - - echo json_encode(['data'=>$list,'count'=>$count,'use_count'=>$user_count]); + echo json_encode(['data' => $list, 'count' => $count, 'use_count' => $user_count]); } -function ip_repeat(&$record,$ip){ - for ($i=2;$i<100;$i++){ - if(in_array($ip,$record)){ - if(in_array($ip.'v'.$i,$record)){ +function ip_repeat(&$record, $ip) +{ + for ($i = 2; $i < 100; $i++) { + if (in_array($ip, $record)) { + if (in_array($ip . 'v' . $i, $record)) { continue; } else { - $record[] = $ip.'v'.$i; - return $ip.'v'.$i; + $record[] = $ip . 'v' . $i; + return $ip . 'v' . $i; } } else { $record[] = $ip; return $ip; } } -} \ No newline at end of file +} + +function city_exist($citys, $city) +{ + for ($i = 2; $i < 100; $i++) { + if (in_array($city, $citys)) { + if (in_array($city . $i, $citys)) { + continue; + } else { + return $city . $i; + } + } else { + return $city; + } + } +} diff --git a/script/linedata/get_line_list.php b/script/linedata/get_line_list.php index b934371..31d395b 100755 --- a/script/linedata/get_line_list.php +++ b/script/linedata/get_line_list.php @@ -5,139 +5,136 @@ * @Author: kangkang * @Date: 2020-11-03 11:04:15 * @LastEditors: kangkang - * @LastEditTime: 2020-11-12 11:09:15 + * @LastEditTime: 2020-11-13 15:19:10 */ - - $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(__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); -$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(__DIR__.'/data/qiangzi.csv'); -$qiangzi_f = fopen(__DIR__.'/data/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); +qiangzi_getList($qiangzi, $qiangzi_f, $all, $qiangzi_data); fclose($qiangzi_f); -$xingxing_data = get_product(__DIR__.'/data/xingxing.csv'); -$xingxing_f = fopen(__DIR__.'/data/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); +xingxing_getList($xingxing, $xingxing_f, $all, $xingxing_data); +fclose($xingxing_f); -$jike_data = get_product(__DIR__.'/data/jike.csv'); -$jike_f = fopen(__DIR__.'/data/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); +jike_getList($jike, $jike_f, $all, $jike_data); fclose($jike_f); -$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_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); +tiantian_getList($tiantian, $tiantian_f, $all, $tiantian_data, '天天'); +fclose($tiantian_f); -$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']; +$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); +tiantian_getList($laoying, $laoying_f, $all, $laoying_data, '老鹰'); +fclose($laoying_f); -$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_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); +shihui_getList($shihui, $shihui_f, $all, $shihui_data); +fclose($shihui_f); -$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/serversList.html',$product_list[14]['Token']); -gongxiang_getList($gongxiang,$gongxiang_f,$all,$gongxiang_data); -fclose($gongxiang_f); +$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/serversList.html', $product_list[14]['Token']); +gongxiang_getList($gongxiang, $gongxiang_f, $all, $gongxiang_data); +fclose($gongxiang_f); -$xunlian_data = get_product(__DIR__.'/data/xunlian.csv'); -$xunlian_f = fopen(__DIR__.'/data/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); +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/serversList.html',$product_list[9]['Token']); +$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/serversList.html', $product_list[9]['Token']); //写入无限文件 -gongxiang_getList($wuxian,$wuxian_f,$all,$wuxian_data,'无限'); +gongxiang_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=0o1144geu80ocep2obta68o3o1',['page'=>1,'limit'=>1000]),true)['data']; +$xianfeng_data = get_product(__DIR__ . '/data/xianfeng.csv'); +$xianfeng_f = fopen(__DIR__ . '/data/xianfeng.csv', 'w'); +$xianfeng = json_decode(file_get_contents("http://apiserver.pptp.biz/Apiserver/getserver"), true); //写入先锋文件 -xianfeng_getList($xianfeng,$xianfeng_f,$all,$xianfeng_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_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); +jinrui_getList($jinrui, $jinrui_f, $all, $jinrui_data); fclose($jinrui_f); //星星2288写入all -$file2288 = fopen(__DIR__.'/data/2288.csv','r'); -while ($data = fgetcsv($file2288)) { - fputcsv($all,$data); +$file2288 = fopen(__DIR__ . '/data/2288.csv', 'r'); +while ($data = fgetcsv($file2288)) { + fputcsv($all, $data); } -fclose($file2288); +fclose($file2288); fclose($all); fclose($dnx_exit); //强子服务器解析规则 -function qiangzi_getList($data,&$file,&$all,$exit) +function qiangzi_getList($data, &$file, &$all, $exit) { - global $dnx_exit,$dnx_has_exit; - $online = ['故障','正常','异常']; - $status = ['正常','拥挤','超载']; + global $dnx_exit, $dnx_has_exit; + $online = ['故障', '正常', '异常']; + $status = ['正常', '拥挤', '超载']; $key = ''; $list1 = []; - + foreach ($data as $info) { $record = []; $record['name'] = '强子'; //如果存在 不为空 则 - if(!empty($info['titleRow'])){ + if (!empty($info['titleRow'])) { $record['city'] = $info['titleRow']; $key = $record['city']; $list1[$key][] = $record; } - if(empty($info['province'])){ + if (empty($info['province'])) { $record['city'] = $info['description']; - } else { - $record['city'] = trim($info['city'],'\"'); + } else { + $record['city'] = trim($info['city'], '\"'); } - if(strpos($info['description'],'省混')){ + if (strpos($info['description'], '省混')) { $record['city'] = $info['description']; - } - if(strpos($info['description'],'电信') !== false){ + } + if (strpos($info['description'], '电信') !== false) { $record['supply'] = '电信'; - } elseif(strpos($info['description'],'联通') !== false){ + } elseif (strpos($info['description'], '联通') !== false) { $record['supply'] = '联通'; - } elseif(strpos($info['description'],'移动') !== false){ + } elseif (strpos($info['description'], '移动') !== false) { $record['supply'] = '移动'; } else { $record['supply'] = '电信/联通'; @@ -147,126 +144,125 @@ function qiangzi_getList($data,&$file,&$all,$exit) $record['daikuan'] = $daikuan[1]; $record['onlineuser'] = $info['onlineuser']; $record['maxuser'] = $info['maxuser']; - $record['online'] = $info['online']==1?'正常':'故障'; + $record['online'] = $info['online'] == 1 ? '正常' : '故障'; $record['status'] = $status[$info['status']]; - - if(strpos($info['description'],'省混')){ + if (strpos($info['description'], '省混')) { $record['nasname'] = $info['nasname']; - if(!in_array($record['nasname'],$exit) && !in_array($record['nasname'],$dnx_has_exit)){ - fputcsv($dnx_exit,['强子',$record['nasname'],date('Y-m-d H:i:s')]); + if (!in_array($record['nasname'], $exit) && !in_array($record['nasname'], $dnx_has_exit)) { + fputcsv($dnx_exit, ['强子', $record['nasname'], date('Y-m-d H:i:s')]); } $list1[$key][] = $record; - } else{ - for ($i=1;$i<6;$i++){ - if(!empty($info['nasname'.$i])){ - $record['nasname'] = $info['nasname'.$i]; - if(!in_array($record['nasname'],$exit) && !in_array($record['nasname'],$dnx_has_exit)){ - fputcsv($dnx_exit,['强子',$record['nasname'],date('Y-m-d H:i:s')]); + } else { + for ($i = 1; $i < 6; $i++) { + if (!empty($info['nasname' . $i])) { + $record['nasname'] = $info['nasname' . $i]; + if (!in_array($record['nasname'], $exit) && !in_array($record['nasname'], $dnx_has_exit)) { + fputcsv($dnx_exit, ['强子', $record['nasname'], date('Y-m-d H:i:s')]); } $list1[$key][] = $record; } } } } - foreach($list1 as $val){ - foreach($val as $net_data){ + foreach ($list1 as $val) { + foreach ($val as $net_data) { - fputcsv($file,$net_data); - fputcsv($all,$net_data); + fputcsv($file, $net_data); + fputcsv($all, $net_data); } } - + } //星星服务器解析 -function xingxing_getList($data,&$file,&$all,$exit) +function xingxing_getList($data, &$file, &$all, $exit) { - global $dnx_exit,$dnx_has_exit; - $online = ['故障','正常']; + global $dnx_exit, $dnx_has_exit; + $online = ['故障', '正常']; $province_record = []; $key = ''; $list1 = []; //省会 - $province = ['黑龙','内蒙']; - $citys = ['北京','上海','天津','重庆']; + $province = ['黑龙', '内蒙']; + $citys = ['北京', '上海', '天津', '重庆']; 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); - $info['description'] = mb_substr($info['description'],3); - } elseif(!in_array($province_detail,$citys)) { - $info['description'] = mb_substr($info['description'],2); + $province_detail = mb_substr($info['description'], 0, 2); + if (in_array($province_detail, $province)) { + $province_detail = mb_substr($info['description'], 0, 3); + $info['description'] = mb_substr($info['description'], 3); + } elseif (!in_array($province_detail, $citys)) { + $info['description'] = mb_substr($info['description'], 2); } - if(!in_array($province_detail,$province_record)){ + if (!in_array($province_detail, $province_record)) { $record['city'] = $province_detail; $province_record[] = $province_detail; $key = $province_detail; $list1[$key][] = $record; } - $city_ex = explode('电信',$info['description']); - if(strpos($info['description'],'电信') !== false){ - $record['city'] = $city_ex[0].($city_ex[1]??''); + $city_ex = explode('电信', $info['description']); + if (strpos($info['description'], '电信') !== false) { + $record['city'] = $city_ex[0] . ($city_ex[1] ?? ''); $record['supply'] = '电信'; - } elseif(strpos($info['description'],'联通') !== false){ - $record['city'] = $city_ex[0].($city_ex[1]??''); + } elseif (strpos($info['description'], '联通') !== false) { + $record['city'] = $city_ex[0] . ($city_ex[1] ?? ''); $record['supply'] = '联通'; - } elseif(strpos($info['description'],'移动') !== false){ - $record['city'] = $city_ex[0].($city_ex[1]??''); + } elseif (strpos($info['description'], '移动') !== false) { + $record['city'] = $city_ex[0] . ($city_ex[1] ?? ''); $record['supply'] = '移动'; } else { $record['city'] = $info['description']; $record['supply'] = '电信/联通'; } - $record['ip'] = strpos($info['description2'],'-')? explode('-',$info['description2'])[1]:$info['description2']; + $record['ip'] = strpos($info['description2'], '-') ? explode('-', $info['description2'])[1] : $info['description2']; $record['daikuan'] = ''; $record['onlineuser'] = ''; $record['maxuser'] = ''; $record['online'] = $online[$info['online']]; $record['status'] = ''; $record['nasname'] = $info['nasname']; - if(!in_array($record['nasname'],$exit) && !in_array($record['nasname'],$dnx_has_exit)){ - fputcsv($dnx_exit,['星星',$record['nasname'],date('Y-m-d H:i:s')]); + if (!in_array($record['nasname'], $exit) && !in_array($record['nasname'], $dnx_has_exit)) { + fputcsv($dnx_exit, ['星星', $record['nasname'], date('Y-m-d H:i:s')]); } $key = $province_detail; $list1[$key][] = $record; } - foreach($list1 as $val){ - foreach($val as $net_data){ + foreach ($list1 as $val) { + foreach ($val as $net_data) { - fputcsv($file,$net_data); - fputcsv($all,$net_data); + fputcsv($file, $net_data); + fputcsv($all, $net_data); } } - + } //极客服务器解析 -function jike_getList($data,&$file,&$all,$exit) +function jike_getList($data, &$file, &$all, $exit) { - global $dnx_exit,$dnx_has_exit; - $status = ['yes'=>'正常','no'=>'故障']; + global $dnx_exit, $dnx_has_exit; + $status = ['yes' => '正常', 'no' => '故障']; $key = ''; $list1 = []; - + $province_record = []; foreach ($data as $info) { $record = []; $record['name'] = '极客'; //如果存在 不为空 则 - if(!in_array($info['province'],$province_record)){ + if (!in_array($info['province'], $province_record)) { $record['city'] = $info['province']; $province_record[] = $info['province']; $key = $record['city']; $list1[$key][] = $record; } - if(empty($info['city'])){ + if (empty($info['city'])) { $record['city'] = '全国混播'; - } else { + } else { $record['city'] = $info['city']; } $record['supply'] = $info['isp']; @@ -277,29 +273,29 @@ function jike_getList($data,&$file,&$all,$exit) $record['online'] = $status[$info['status']]; $record['status'] = ''; $record['nasname'] = $info['domain']; - if(!in_array($record['nasname'],$exit) && !in_array($record['nasname'],$dnx_has_exit)){ - fputcsv($dnx_exit,['极客',$record['nasname'],date('Y-m-d H:i:s')]); + if (!in_array($record['nasname'], $exit) && !in_array($record['nasname'], $dnx_has_exit)) { + fputcsv($dnx_exit, ['极客', $record['nasname'], date('Y-m-d H:i:s')]); } $list1[$key][] = $record; } - foreach($list1 as $val){ - foreach($val as $net_data){ + foreach ($list1 as $val) { + foreach ($val as $net_data) { - fputcsv($file,$net_data); - fputcsv($all,$net_data); + fputcsv($file, $net_data); + fputcsv($all, $net_data); } } - + } //天天服务器解析规则 -function tiantian_getList($data,&$file,&$all,$exit,$product_name) +function tiantian_getList($data, &$file, &$all, $exit, $product_name) { - global $dnx_exit,$dnx_has_exit; - $status = ['故障','正常']; + global $dnx_exit, $dnx_has_exit; + $status = ['故障', '正常']; $key = ''; $list1 = []; - + foreach ($data as $info) { $record = []; @@ -307,16 +303,16 @@ function tiantian_getList($data,&$file,&$all,$exit,$product_name) $record['city'] = $info['name']; $key = $record['city']; $list1[$key][] = $record; - foreach ($info['areas'] as $v){ + foreach ($info['areas'] as $v) { - if(strpos($v['name'],'电信') !== false){ - $record['city'] = explode('电信',$v['name'])[0]; + if (strpos($v['name'], '电信') !== false) { + $record['city'] = explode('电信', $v['name'])[0]; $record['supply'] = '电信'; - } elseif(strpos($v['name'],'联通') !== false){ - $record['city'] = explode('联通',$v['name'])[0]; + } elseif (strpos($v['name'], '联通') !== false) { + $record['city'] = explode('联通', $v['name'])[0]; $record['supply'] = '联通'; - } elseif(strpos($v['name'],'移动') !== false){ - $record['city'] = explode('移动',$v['name'])[0]; + } elseif (strpos($v['name'], '移动') !== false) { + $record['city'] = explode('移动', $v['name'])[0]; $record['supply'] = '移动'; } else { $record['city'] = $v['name']; @@ -326,52 +322,53 @@ function tiantian_getList($data,&$file,&$all,$exit,$product_name) $record['daikuan'] = ''; $record['onlineuser'] = ''; $record['maxuser'] = ''; - $record['online'] = empty($v['status'])?'故障':$status[$v['status']]; + $record['online'] = empty($v['status']) ? '故障' : $status[$v['status']]; $record['status'] = ''; $record['nasname'] = $v['address']; - if(!in_array($record['nasname'],$exit) && !in_array($record['nasname'],$dnx_has_exit)){ - fputcsv($dnx_exit,[$product_name,$record['nasname'],date('Y-m-d H:i:s')]); + if (!in_array($record['nasname'], $exit) && !in_array($record['nasname'], $dnx_has_exit)) { + fputcsv($dnx_exit, [$product_name, $record['nasname'], date('Y-m-d H:i:s')]); } $list1[$key][] = $record; } } - foreach($list1 as $val){ - foreach($val as $net_data){ + foreach ($list1 as $val) { + foreach ($val as $net_data) { - fputcsv($file,$net_data); - fputcsv($all,$net_data); + fputcsv($file, $net_data); + fputcsv($all, $net_data); } } - + } -function shihui_getList($html,&$file,&$all,$exit){ - global $dnx_exit,$dnx_has_exit; +function shihui_getList($html, &$file, &$all, $exit) +{ + global $dnx_exit, $dnx_has_exit; $key = ''; $list1 = []; preg_match("/
(.*\s*?)
<\/p><\/div>/is", $html, $result); preg_match_all("/
(.*?)<\/p>/is", $result[0], $result);
- foreach($result[0] as $k=>$info){
+ foreach ($result[0] as $k => $info) {
$record = [];
$record['name'] = '实惠';
- if ($k==0||$k==5){
+ if ($k == 0 || $k == 5) {
continue;
} else {
- $list = explode('
',$info);
+ $list = explode('
', $info);
$i = 0;
- foreach($list as $v){
+ foreach ($list as $v) {
$v = trim($v);
- $v = trim(str_replace(' ','',$v),'