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),'

'); - if($i==0 && !empty($v)){ + $v = trim(str_replace(' ', '', $v), '

'); + if ($i == 0 && !empty($v)) { $record['city'] = $v; $key = $record['city']; $list1[$key][] = $record; } else { - - if(!empty($v)){ - $data = explode(' ',$v); - $add_data = explode('市',$data[0]); - $record['city'] = mb_substr($add_data[0],2); + + if (!empty($v)) { + $data = explode(' ', $v); + $add_data = explode('市', $data[0]); + $record['city'] = mb_substr($add_data[0], 2); $record['supply'] = $add_data[1]; $record['ip'] = ''; $record['daikuan'] = ''; @@ -379,9 +376,9 @@ function shihui_getList($html,&$file,&$all,$exit){ $record['maxuser'] = ''; $record['online'] = ''; $record['status'] = ''; - $record['nasname'] = $data[count($data)-1]; - 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')]); + $record['nasname'] = $data[count($data) - 1]; + 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; } @@ -390,66 +387,67 @@ function shihui_getList($html,&$file,&$all,$exit){ } } } - 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 gongxiang_getList($html,&$file,&$all,$exit,$pro = '共享'){ - global $dnx_exit,$dnx_has_exit; +function gongxiang_getList($html, &$file, &$all, $exit, $pro = '共享') +{ + global $dnx_exit, $dnx_has_exit; //省会 - $province = ['黑龙','内蒙']; + $province = ['黑龙', '内蒙']; $province_record = []; $key = ''; $list1 = []; preg_match_all("//is", $html, $result); - foreach($result[0] as $k=>$info){ + foreach ($result[0] as $k => $info) { $record = []; $record['name'] = $pro; $records['name'] = $pro; - if ($k==0){ + if ($k == 0) { continue; } else { preg_match_all("/(.*?)<\/td>/is", $info, $result); $info = $result[0]; - foreach($info as $i=>$v){ - $info[$i] = ltrim($info[$i],''); - $info[$i] = rtrim($info[$i],''); + foreach ($info as $i => $v) { + $info[$i] = ltrim($info[$i], ''); + $info[$i] = rtrim($info[$i], ''); } $nasname = $info[1]; $data[1] = $info[2]; - if(strpos($data[1],'电信') !== false){ + if (strpos($data[1], '电信') !== false) { $supply = '电信'; - $data[1] = mb_substr($data[1],0,mb_strlen($data[1])-2); - } elseif(strpos($data[1],'联通') !== false){ + $data[1] = mb_substr($data[1], 0, mb_strlen($data[1]) - 2); + } elseif (strpos($data[1], '联通') !== false) { $supply = '联通'; - $data[1] = mb_substr($data[1],0,mb_strlen($data[1])-2); - } elseif(strpos($data[1],'移动') !== false){ + $data[1] = mb_substr($data[1], 0, mb_strlen($data[1]) - 2); + } elseif (strpos($data[1], '移动') !== false) { $supply = '移动'; - $data[1] = mb_substr($data[1],0,mb_strlen($data[1])-2); + $data[1] = mb_substr($data[1], 0, mb_strlen($data[1]) - 2); } else { $supply = '电信/联通'; } - if(mb_strlen($data[1])<=3){ - if(!in_array($data[1],$province_record)){ + if (mb_strlen($data[1]) <= 3) { + if (!in_array($data[1], $province_record)) { $record['city'] = $data[1]; $record['supply'] = $supply; $record['ip'] = ''; $record['daikuan'] = ''; $record['onlineuser'] = ''; $record['maxuser'] = ''; - $record['online'] = strpos($info[4],'在线')?'正常':'故障'; + $record['online'] = strpos($info[4], '在线') ? '正常' : '故障'; $record['status'] = ''; $record['nasname'] = $nasname; $records['city'] = $data[1]; $province_record[] = $data[1]; - if(in_array($record['city'],['曾','龙'])){ + if (in_array($record['city'], ['曾', '龙'])) { continue; } $key = $record['city']; @@ -462,81 +460,81 @@ function gongxiang_getList($html,&$file,&$all,$exit,$pro = '共享'){ $record['daikuan'] = ''; $record['onlineuser'] = ''; $record['maxuser'] = ''; - $record['online'] = strpos($info[4],'在线')?'正常':'故障'; + $record['online'] = strpos($info[4], '在线') ? '正常' : '故障'; $record['status'] = ''; $record['nasname'] = $nasname; - if(in_array($record['city'],['曾','龙'])){ + if (in_array($record['city'], ['曾', '龙'])) { continue; } $list1[$key][] = $record; } } else { - $province_detail = mb_substr($data['1'],0,2); - if(in_array($province_detail,$province)){ - $province_detail = mb_substr($data['1'],0,3); - $key = $province_detail; - if(in_array($province_detail,$province_record)){ - $record['city'] = mb_substr($data['1'],3); + $province_detail = mb_substr($data['1'], 0, 2); + if (in_array($province_detail, $province)) { + $province_detail = mb_substr($data['1'], 0, 3); + $key = $province_detail; + if (in_array($province_detail, $province_record)) { + $record['city'] = mb_substr($data['1'], 3); $record['supply'] = $supply; $record['ip'] = ''; $record['daikuan'] = ''; $record['onlineuser'] = ''; $record['maxuser'] = ''; - $record['online'] = strpos($info[4],'在线')?'正常':'故障'; + $record['online'] = strpos($info[4], '在线') ? '正常' : '故障'; $record['status'] = ''; $record['nasname'] = $nasname; - if(in_array($record['city'],['曾','龙'])){ + if (in_array($record['city'], ['曾', '龙'])) { continue; } $list1[$key][] = $record; } else { - $record['city'] = mb_substr($data['1'],3); + $record['city'] = mb_substr($data['1'], 3); $record['supply'] = $supply; $record['ip'] = ''; $record['daikuan'] = ''; $record['onlineuser'] = ''; $record['maxuser'] = ''; - $record['online'] = strpos($info[4],'在线')?'正常':'故障'; + $record['online'] = strpos($info[4], '在线') ? '正常' : '故障'; $record['status'] = ''; $record['nasname'] = $nasname; $records['city'] = $province_detail; $province_record[] = $province_detail; - if(in_array($record['city'],['曾','龙'])){ + if (in_array($record['city'], ['曾', '龙'])) { continue; } $list1[$key][] = $records; $list1[$key][] = $record; } } else { - $province_detail = mb_substr($data['1'],0,2); - $key = $province_detail; - if(in_array($province_detail,$province_record)){ - $record['city'] = mb_substr($data['1'],2); + $province_detail = mb_substr($data['1'], 0, 2); + $key = $province_detail; + if (in_array($province_detail, $province_record)) { + $record['city'] = mb_substr($data['1'], 2); $record['supply'] = $supply; $record['ip'] = ''; $record['daikuan'] = ''; $record['onlineuser'] = ''; $record['maxuser'] = ''; - $record['online'] = strpos($info[4],'在线')?'正常':'故障'; + $record['online'] = strpos($info[4], '在线') ? '正常' : '故障'; $record['status'] = ''; $record['nasname'] = $nasname; - if(in_array($record['city'],['曾','龙'])){ + if (in_array($record['city'], ['曾', '龙'])) { continue; } $list1[$key][] = $record; } else { - $record['city'] = mb_substr($data['1'],2); + $record['city'] = mb_substr($data['1'], 2); $record['supply'] = $supply; $record['ip'] = ''; $record['daikuan'] = ''; $record['onlineuser'] = ''; $record['maxuser'] = ''; - $record['online'] = strpos($info[4],'在线')?'正常':'故障'; + $record['online'] = strpos($info[4], '在线') ? '正常' : '故障'; $record['status'] = ''; $record['nasname'] = $nasname; $records['city'] = $province_detail; $province_record[] = $province_detail; - if(in_array($record['city'],['曾','龙'])){ + if (in_array($record['city'], ['曾', '龙'])) { continue; } $list1[$key][] = $records; @@ -546,34 +544,34 @@ function gongxiang_getList($html,&$file,&$all,$exit,$pro = '共享'){ } } } - foreach($list1 as $val){ - foreach($val as $net_data){ + foreach ($list1 as $val) { + foreach ($val as $net_data) { + $net_data['city'] = str_replace('电信', '', $net_data['city']); + $net_data['city'] = str_replace('联通', '', $net_data['city']); - $net_data['city'] = str_replace('电信','',$net_data['city']); - $net_data['city'] = str_replace('联通','',$net_data['city']); - - fputcsv($file,$net_data); - fputcsv($all,$net_data); + fputcsv($file, $net_data); + fputcsv($all, $net_data); } } } -function xunlian_getList($data,&$file,&$all,$exit){ - global $dnx_exit,$dnx_has_exit; - $online = ['故障','正常']; - $province = ['黑龙','内蒙']; - $citys = ['北京','上海','天津','重庆']; +function xunlian_getList($data, &$file, &$all, $exit) +{ + global $dnx_exit, $dnx_has_exit; + $online = ['故障', '正常']; + $province = ['黑龙', '内蒙']; + $citys = ['北京', '上海', '天津', '重庆']; $key = ''; $list1 = []; $province_record = []; - foreach($data as $info){ + foreach ($data as $info) { $record = []; $record['name'] = '讯连'; - $province_detail = mb_substr($info['description'],0,2); - if($province_detail == '全国'){ + $province_detail = mb_substr($info['description'], 0, 2); + if ($province_detail == '全国') { $record['city'] = $info['description']; - if(!in_array('混播',$province_record)){ + if (!in_array('混播', $province_record)) { $province_record[] = '混播'; $key = '混播'; $list1[$key][] = $record; @@ -581,124 +579,124 @@ function xunlian_getList($data,&$file,&$all,$exit){ $record['supply'] = '电信/联通'; } else { - 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)) { + $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; - } + } $key = $province_detail; - if(strpos($info['description'],'电信') !== false){ - $record['city'] = mb_substr($info['description'],0,mb_strlen($info['description'])-2); + if (strpos($info['description'], '电信') !== false) { + $record['city'] = mb_substr($info['description'], 0, mb_strlen($info['description']) - 2); $record['supply'] = '电信'; - } elseif(strpos($info['description'],'联通') !== false){ - $record['city'] = mb_substr($info['description'],0,mb_strlen($info['description'])-2); + } elseif (strpos($info['description'], '联通') !== false) { + $record['city'] = mb_substr($info['description'], 0, mb_strlen($info['description']) - 2); $record['supply'] = '联通'; - } elseif(strpos($info['description'],'移动') !== false){ - $record['city'] = mb_substr($info['description'],0,mb_strlen($info['description'])-2); + } elseif (strpos($info['description'], '移动') !== false) { + $record['city'] = mb_substr($info['description'], 0, mb_strlen($info['description']) - 2); $record['supply'] = '移动'; } else { $record['city'] = $info['description']; $record['supply'] = '电信/联通'; } } - if(strpos($record['city'],'省') !== false){ - $record['city'] = mb_substr($record['city'],1,mb_strlen($info['description'])); + if (strpos($record['city'], '省') !== false) { + $record['city'] = mb_substr($record['city'], 1, mb_strlen($info['description'])); } - for ($i=1;$i<6;$i++){ - if(!empty($info['nasname'.$i])){ - + for ($i = 1; $i < 6; $i++) { + if (!empty($info['nasname' . $i])) { $record['ip'] = ''; - if($i==1){ - $record['daikuan'] = $info['maxbands']?:$info['description2']; + if ($i == 1) { + $record['daikuan'] = $info['maxbands'] ?: $info['description2']; } else { - $record['daikuan'] = $info['maxbands'.($i-1)]?:$info['description2']; + $record['daikuan'] = $info['maxbands' . ($i - 1)] ?: $info['description2']; } $record['onlineuser'] = ''; $record['maxuser'] = ''; $record['online'] = $online[$info['online']]; $record['status'] = ''; - $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')]); + $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 wuxian_getList($html,&$file,&$all,$exit){ - global $dnx_exit,$dnx_has_exit; +function wuxian_getList($html, &$file, &$all, $exit) +{ + global $dnx_exit, $dnx_has_exit; //省会 - $province = ['黑龙','内蒙']; + $province = ['黑龙', '内蒙']; $province_record = []; $key = ''; $list1 = []; - $citys = ['北京','上海','天津','重庆']; + $citys = ['北京', '上海', '天津', '重庆']; preg_match("/
 <\/div>(.*?)<\/div><\/div>/is", $html, $result); - $result = str_replace('
 
','',$result[0]); + $result = str_replace('
 
', '', $result[0]); preg_match_all("/
(.*?)<\/div>/is", $result, $result); - foreach($result[0] as $k=>$info){ + foreach ($result[0] as $k => $info) { $record = []; $record['name'] = '无限'; - $info = ltrim($info,'
'); - $info = rtrim($info,'
'); - if(strpos($info,'span') !== false){ - $data = explode(' ',$info); + $info = ltrim($info, '
'); + $info = rtrim($info, '
'); + if (strpos($info, 'span') !== false) { + $data = explode(' ', $info); } else { - $data = explode('            ',$info); + $data = explode('            ', $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); + $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)){ + if (!in_array($province_detail, $province_record)) { $record['city'] = $province_detail; $province_record[] = $province_detail; $key = $record['city']; $list1[$key][] = $record; } - if(strpos($data[1],'电信') !== false){ - $record['city'] = explode('电信',$data[1])[0]; - $record['city'] = str_replace('<','',$record['city']); - $record['city'] = str_replace('>','',$record['city']); + if (strpos($data[1], '电信') !== false) { + $record['city'] = explode('电信', $data[1])[0]; + $record['city'] = str_replace('<', '', $record['city']); + $record['city'] = str_replace('>', '', $record['city']); $record['supply'] = '电信'; - } elseif(strpos($data[1],'联通') !== false){ - $record['city'] = explode('联通',$data[1])[0]; - $record['city'] = str_replace('<','',$record['city']); - $record['city'] = str_replace('>','',$record['city']); + } elseif (strpos($data[1], '联通') !== false) { + $record['city'] = explode('联通', $data[1])[0]; + $record['city'] = str_replace('<', '', $record['city']); + $record['city'] = str_replace('>', '', $record['city']); $record['supply'] = '联通'; - } elseif(strpos($data[1],'移动') !== false){ - $record['city'] = explode('移动',$data[1])[0]; - $record['city'] = str_replace('<','',$record['city']); - $record['city'] = str_replace('>','',$record['city']); + } elseif (strpos($data[1], '移动') !== false) { + $record['city'] = explode('移动', $data[1])[0]; + $record['city'] = str_replace('<', '', $record['city']); + $record['city'] = str_replace('>', '', $record['city']); $record['supply'] = '移动'; } else { $record['city'] = $data[1]; - $record['city'] = str_replace('<','',$record['city']); - $record['city'] = str_replace('>','',$record['city']); + $record['city'] = str_replace('<', '', $record['city']); + $record['city'] = str_replace('>', '', $record['city']); $record['supply'] = '电信/联通'; } - + $record['ip'] = ''; $record['daikuan'] = ''; $record['onlineuser'] = ''; @@ -707,41 +705,40 @@ function wuxian_getList($html,&$file,&$all,$exit){ $record['status'] = ''; $record['nasname'] = $data[0]; - 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){ - $net_data['city'] = str_replace('电信','',$net_data['city']); - $net_data['city'] = str_replace('联通','',$net_data['city']); + foreach ($list1 as $val) { + foreach ($val as $net_data) { + $net_data['city'] = str_replace('电信', '', $net_data['city']); + $net_data['city'] = str_replace('联通', '', $net_data['city']); - - fputcsv($file,$net_data); - fputcsv($all,$net_data); + fputcsv($file, $net_data); + fputcsv($all, $net_data); } } } -function xianfeng_getList($data,&$file,&$all,$exit){ - global $dnx_exit,$dnx_has_exit; +function xianfeng_getList($data, &$file, &$all, $exit) +{ + global $dnx_exit, $dnx_has_exit; //省会 - $province = ['黑龙','内蒙','直辖']; + $province = ['黑龙', '内蒙', '直辖']; $province_record = []; $key = ''; $list1 = []; - $status = ['维护中','正常']; + $status = ['维护中', '正常']; foreach ($data as $info) { $record = []; $record['name'] = '先锋'; - $info['description'] = trim($info['description'],'a'); - if(strpos($info['description'],'混播') || strpos($info['description'],'所有单城市')){ + $info['description'] = trim($info['description'], 'a'); + if (strpos($info['description'], '混播') || strpos($info['description'], '所有单城市')) { $province_detail = '混播'; - if(!in_array($province_detail,$province_record)){ + if (!in_array($province_detail, $province_record)) { $record['city'] = $province_detail; $province_record[] = $province_detail; $key = $record['city']; @@ -750,23 +747,23 @@ function xianfeng_getList($data,&$file,&$all,$exit){ $record['city'] = $info['description']; $record['supply'] = '电信/联通'; } else { - $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)){ + $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; $key = $record['city']; $list1[$key][] = $record; } - if(strpos($info['description'],'电信') !== false){ + if (strpos($info['description'], '电信') !== false) { $record['city'] = $info['description']; $record['supply'] = '电信'; - } elseif(strpos($info['description'],'联通') !== false){ + } elseif (strpos($info['description'], '联通') !== false) { $record['city'] = $info['description']; $record['supply'] = '联通'; - } elseif(strpos($info['description'],'移动') !== false){ + } elseif (strpos($info['description'], '移动') !== false) { $record['city'] = $info['description']; $record['supply'] = '移动'; } else { @@ -775,55 +772,65 @@ function xianfeng_getList($data,&$file,&$all,$exit){ } } $record['ip'] = ''; - $record['daikuan'] = ''; - $record['onlineuser'] = ''; - $record['maxuser'] = ''; - $record['online'] = ($info['serstatus'] == 1)?'正常':'故障'; + $record['daikuan'] = $info['description2']; + $record['onlineuser'] = $info['onlineuser']; + $record['maxuser'] = $info['maxuser']; + $record['online'] = ($info['status'] == 1) ? '正常' : '故障'; + $status_flag = $info['onlineuser'] / $info['maxuser']; $record['status'] = ''; + if ($status_flag < 0.9) { + $record['status'] = '正常'; + } elseif ($status_flag < 0.95) { + $record['status'] = '拥挤'; + } else { + $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')]); } $list1[$key][] = $record; } - foreach($list1 as $val){ - foreach($val as $net_data){ + foreach ($list1 as $val) { + foreach ($val as $net_data) { - $net_data['city'] = str_replace('电信','',$net_data['city']); - $net_data['city'] = str_replace('联通','',$net_data['city']); - - if(mb_strlen($net_data['city'])>3 && !strpos($net_data['city'],'省内')) $net_data['city'] = mb_substr($net_data['city'],3); + $net_data['city'] = str_replace('电信', '', $net_data['city']); + $net_data['city'] = str_replace('联通', '', $net_data['city']); - fputcsv($file,$net_data); - fputcsv($all,$net_data); + if (mb_strlen($net_data['city']) > 3 && !strpos($net_data['city'], '省内')) { + $net_data['city'] = mb_substr($net_data['city'], 3); + } + + fputcsv($file, $net_data); + fputcsv($all, $net_data); } } } - -function jinrui_getList($html,&$file,&$all,$exit){ - global $dnx_exit,$dnx_has_exit; +function jinrui_getList($html, &$file, &$all, $exit) +{ + global $dnx_exit, $dnx_has_exit; //省会 $province_record = []; $key = ''; $list1 = []; preg_match_all("/\{(.*?)\}/is", $html, $result); foreach ($result[0] as $info) { - $info = json_decode($info,true); - if(empty($info)){ + $info = json_decode($info, true); + if (empty($info)) { continue; } $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'])){ - $record['city'] = $info['province'] ; - } else { + if (empty($info['city'])) { + $record['city'] = $info['province']; + } else { $record['city'] = $info['city']; } $record['supply'] = $info['isp']; @@ -831,60 +838,62 @@ function jinrui_getList($html,&$file,&$all,$exit){ $record['daikuan'] = ''; $record['onlineuser'] = ''; $record['maxuser'] = ''; - $record['online'] = $info['status']==1?'正常':'故障'; + $record['online'] = $info['status'] == 1 ? '正常' : '故障'; $record['status'] = ''; - $nasname = explode('|',$info['nasname']); - foreach($nasname as $v){ + $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'],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[$info['province']][] = $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 get_content($url, $cookie) { +function get_content($url, $cookie) +{ $ch = curl_init(); - curl_setopt($ch, CURLOPT_URL, $url); - curl_setopt($ch, CURLOPT_HEADER, 0); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); - curl_setopt($ch, CURLOPT_COOKIE, $cookie); //读取cookie - $rs = curl_exec($ch); //执行cURL抓取页面内容 - curl_close($ch); - return $rs; + curl_setopt($ch, CURLOPT_URL, $url); + curl_setopt($ch, CURLOPT_HEADER, 0); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($ch, CURLOPT_COOKIE, $cookie); //读取cookie + $rs = curl_exec($ch); //执行cURL抓取页面内容 + curl_close($ch); + return $rs; } -function get_product($file_path,$num = 9){ +function get_product($file_path, $num = 9) +{ $list = []; - $file = fopen($file_path,'r'); - while ($info = fgetcsv($file)) { - if(isset($info[$num])) + $file = fopen($file_path, 'r'); + while ($info = fgetcsv($file)) { + if (isset($info[$num])) { $list[] = $info[$num]; + } + } - fclose($file); + 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));//要提交的信息 +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; -} \ No newline at end of file + curl_close($curl); + return $rs; +}