field('Id,Token')->fetchAll(); // // //测试用---------------------------------------------------------------------------------------------------------- // $tiantian = json_decode(file_get_contents("http://api.ipzuiduo.com/api/areas?apiid=135&sendtime=" . time() . "&sign=" . md5('apiid=135&sendtime=' . time() . '7dayCFfY6zcwJa6QHtHbGQBRckjJbrbS')), true)['data']; // dump($tiantian); // die; // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //强子迅联特征码 $sp_xl_code = file_get_contents(__DIR__ . '/data/xl.txt', 'r'); // echo $sp_xl_code; $sp_xl_json = json_decode(substr($sp_xl_code,3),true); $sp_xl_list = []; foreach($sp_xl_json as $k=>$v){ $temp = explode('-',$k); $sp_xl_list[$temp[1]] = $v; } $sp_qz_code = file_get_contents(__DIR__ . '/data/qz.txt', 'r'); // echo $sp_qz_code; $sp_qz_json = json_decode(substr($sp_qz_code,3),true); $sp_qz_list = []; foreach($sp_qz_json as $k=>$v){ $temp = explode('-',$k); $sp_qz_list[$temp[1]] = $v; } //-------------------------------------------- $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); $time = time(); $noce = md5(time()); $apikey = 'a478ad5aa3079bbbef3cd45e2d55d61e'; $sign = md5($time.$noce.$apikey); $url = "http://47.92.116.14:2222/api/getNodeList?agentid=admin1&ti=".$time."&nonce=".$noce."&sign=".$sign; $qiangzi = json_decode(file_get_contents($url), true)['data']; if(!empty($qiangzi)){ $qiangzi_data = get_product(__DIR__ . '/data/qiangzi.csv'); $qiangzi_f = fopen(__DIR__ . '/data/qiangzi.csv', 'w'); //写入强子文件 qiangzi_getList($qiangzi, $qiangzi_f, $all, $qiangzi_data); fclose($qiangzi_f); } $time = time(); $noce = md5(time()); $apikey = 'osoa917321hdjw'; $sign = md5($time.$noce.$apikey); $url = "http://47.92.65.184:2223/api/getNodeList?agentid=admin2&ti=".$time."&nonce=".$noce."&sign=".$sign; $xunlian = json_decode(file_get_contents($url), true)['data']; // $xunlian = false; if ($xunlian){ $xunlian_data = get_product(__DIR__ . '/data/xunlian.csv'); $xunlian_f = fopen(__DIR__ . '/data/xunlian.csv', 'w'); //写入讯连文件 xunlian_getList($xunlian, $xunlian_f, $all, $xunlian_data); fclose($xunlian_f); } $xingxing_data = get_product(__DIR__ . '/data/xingxing.csv'); $xingxing_f = fopen(__DIR__ . '/data/xingxing.csv', 'w'); $time = time(); $noce = md5(time()); $apikey = 'd50f2b2ffd421efa67df8efb96d5ff6c'; $sign = md5($time.$noce.$apikey); $url = "http://106.54.198.154/api/getNodeList?agentid=admin1&ti=".$time."&nonce=".$noce."&sign=".$sign; $xingxing = json_decode(file_get_contents($url), true)['data']; //写入星星文件 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 = json_decode(file_get_contents("http://api.webok.me/beikeiplist/"), true)['data']; //写入极客文件 jike_getList($jike, $jike_f, $all, $jike_data); fclose($jike_f); $xigua_data = get_product(__DIR__ . '/data/xigua.csv'); $xigua_f = fopen(__DIR__ . '/data/xigua.csv', 'w'); $xigua = json_decode(file_get_contents("http://api.webok.me/serverlistyzip/"), true)['data']; //写入西瓜文件 jike_getList($xigua, $xigua_f, $all, $xigua_data, false); fclose($xigua_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() . '7dayCFfY6zcwJa6QHtHbGQBRckjJbrbS')), true)['data']; //写入天天文件 tiantian_getList($tiantian, $tiantian_f, $all, $tiantian_data, '天天'); fclose($tiantian_f); $mogu = json_decode(get_content("http://xjip.hlapi.com/api/area",''), true)['data']; if($mogu){ $mogu_data = get_product(__DIR__ . '/data/mogu.csv'); $mogu_f = fopen(__DIR__ . '/data/mogu.csv', 'w'); // echo 123; // print_r($mogu); //写入蘑菇文件 mogu_getList($mogu, $mogu_f, $all, $mogu_data, '蘑菇'); fclose($mogu_f); } $laoying_data = get_product(__DIR__ . '/data/laoying.csv'); $laoying_f = fopen(__DIR__ . '/data/laoying.csv', 'w'); $laoying = file_get_contents('http://list.wzvps.com/'); //写入老鹰文件 laoying_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_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://221.225.83.92:39999/agent/serversList.html', $product_list[14]['Token']); gongxiang_getList($gongxiang, $gongxiang_f, $all, $gongxiang_data); fclose($gongxiang_f); // $wuxian_data = get_product(__DIR__ . '/data/wuxian.csv'); // $wuxian_f = fopen(__DIR__ . '/data/wuxian.csv', 'w'); // $wuxian = get_content('http://221.225.83.92:6888/agent/serversList.html', $product_list[9]['Token']); // //写入无限文件 // 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(file_get_contents("http://apiserver.pptp.biz/Apiserver/getserver"), true); //写入先锋文件 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(__DIR__ . '/data/2288.csv', 'r'); while ($data = fgetcsv($file2288)) { fputcsv($all, $data); } fclose($file2288); fclose($all); fclose($dnx_exit); sleep(5); auto_format_list(); //强子服务器解析规则 function qiangzi_getList($data, &$file, &$all, $exit) { global $dnx_exit, $dnx_has_exit,$sp_qz_list; $online = ['故障', '正常', '异常']; $status = ['正常', '拥挤', '超载']; $key = ''; $list1 = []; $province_record = []; foreach ($data as $info) { $record = []; $record['name'] = '强子'; //如果存在 不为空 则 $city_name = explode('-',$info['name']); if (strpos($city_name[1], '混播') !== false) { //如果存在 不为空 则 if (!in_array( $city_name[1], $province_record)) { $record['city'] = $city_name[1]; $province_record[] = $city_name[1]; $key = $record['city']; $list1[$key][] = $record; } } else { //如果存在 不为空 则 if (!in_array( $city_name[0], $province_record)) { $record['city'] = $city_name[0]; $province_record[] = $city_name[0]; $key = $record['city']; $list1[$key][] = $record; } } $record['city'] = $city_name[1]; $record['supply'] = isset($city_name[2]) ? $city_name[2] : ''; $daikuan = $info['bandwidth']; $record['ip'] = $info['name2']; $record['daikuan'] = $daikuan; $record['onlineuser'] = ''; $record['maxuser'] = ''; $record['online'] = $info['status'] == 1 ? '正常' : '故障'; $record['status'] = $sp_qz_list[$record['city']]; if(!empty($info['host2'])){ $nas_list = explode(',',$info['host2']); foreach ($nas_list as $nas) { $record['nasname'] = trim($nas); 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; } } $record['nasname'] = trim($info['host']); 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) { fputcsv($file, $net_data); fputcsv($all, $net_data); } } } //星星服务器解析 function xingxing_getList($data, &$file, &$all, $exit) { global $dnx_exit, $dnx_has_exit; $online = ['故障', '正常', '正常']; $province_record = []; $key = ''; $list1 = []; //省会 $province = ['黑龙', '内蒙']; $citys = ['北京', '上海', '天津', '重庆']; foreach ($data as $info) { $record = []; $record['name'] = '星星'; $province_detail = mb_substr($info['name'], 0, 2); if (in_array($province_detail, $province)) { $province_detail = mb_substr($info['name'], 0, 3); $info['name'] = mb_substr($info['name'], 3); } elseif (!in_array($province_detail, $citys)) { $info['name'] = mb_substr($info['name'], 2); } 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['name']); if (strpos($info['name'], '电信') !== false) { $record['city'] = $city_ex[0] . ($city_ex[1] ?? ''); $record['supply'] = '电信'; } elseif (strpos($info['name'], '联通') !== false) { $record['city'] = $city_ex[0] . ($city_ex[1] ?? ''); $record['supply'] = '联通'; } elseif (strpos($info['name'], '移动') !== false) { $record['city'] = $city_ex[0] . ($city_ex[1] ?? ''); $record['supply'] = '移动'; } else { $record['city'] = $info['name']; $record['supply'] = '电信/联通'; } $record['ip'] = strpos($info['name2'], '-') ? explode('-', $info['name2'])[1] : $info['name2']; $record['daikuan'] = $info['bandwidth']; $record['onlineuser'] = ''; $record['maxuser'] = ''; $record['online'] = ($info['status'] == 1) ? '正常' : '故障'; $record['status'] = ''; $record['nasname'] = $info['host']; 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) { fputcsv($file, $net_data); fputcsv($all, $net_data); } } } //极客服务器解析 function jike_getList($data, &$file, &$all, $exit, $is_jike = true) { global $dnx_exit, $dnx_has_exit; $status = ['yes' => '正常', 'no' => '故障']; $key = ''; $list1 = []; $province_record = []; foreach ($data as $info) { $record = []; if($is_jike){ $record['name'] = '极客'; } else { $record['name'] = '西瓜'; } //如果存在 不为空 则 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'] = '全国混播'; } else { $record['city'] = $info['city']; } $record['supply'] = $info['isp']; $record['ip'] = ''; $record['daikuan'] = ''; $record['onlineuser'] = ''; $record['maxuser'] = ''; $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['name'], $record['nasname'], date('Y-m-d H:i:s')]); } $list1[$key][] = $record; } foreach ($list1 as $val) { foreach ($val as $net_data) { fputcsv($file, $net_data); fputcsv($all, $net_data); } } } //天天服务器解析规则 function tiantian_getList($data, &$file, &$all, $exit, $product_name) { global $dnx_exit, $dnx_has_exit; $status = ['故障', '正常']; $key = ''; $list1 = []; foreach ($data as $info) { $record = []; $record['name'] = $product_name; $record['city'] = $info['name']; $key = $record['city']; $list1[$key][] = $record; foreach ($info['areas'] as $v) { if (strpos($v['name'], '电信') !== false) { $record['city'] = explode('电信', $v['name'])[0]; $record['supply'] = '电信'; } elseif (strpos($v['name'], '联通') !== false) { $record['city'] = explode('联通', $v['name'])[0]; $record['supply'] = '联通'; } elseif (strpos($v['name'], '移动') !== false) { $record['city'] = explode('移动', $v['name'])[0]; $record['supply'] = '移动'; } else { $record['city'] = $v['name']; $record['supply'] = '电信/联通'; } $record['ip'] = ''; $record['daikuan'] = ''; $record['onlineuser'] = ''; $record['maxuser'] = ''; $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')]); } $list1[$key][] = $record; } } foreach ($list1 as $val) { foreach ($val as $net_data) { fputcsv($file, $net_data); fputcsv($all, $net_data); } } } //蘑菇服务器解析规则 function mogu_getList($data, &$file, &$all, $exit, $product_name) { global $dnx_exit, $dnx_has_exit; $status = ['故障', '正常']; $key = ''; $list1 = []; // print_r($data); foreach ($data as $info) { $record = []; $record['name'] = $product_name; $record['city'] = $info['title']; $key = $record['city']; $list1[$key][] = $record; foreach ($info['children'] as $v) { if (strpos($v['title'], '电信') !== false) { $record['city'] = explode('电信', $v['title'])[0]; $record['supply'] = '电信'; } elseif (strpos($v['title'], '联通') !== false) { $record['city'] = explode('联通', $v['title'])[0]; $record['supply'] = '联通'; } elseif (strpos($v['title'], '移动') !== false) { $record['city'] = explode('移动', $v['title'])[0]; $record['supply'] = '移动'; } else { $record['city'] = $v['title']; $record['supply'] = '电信/联通'; } $record['ip'] = ''; $record['daikuan'] = $v['bandwidth']; $record['onlineuser'] = ''; $record['maxuser'] = ''; $record['online'] = $v['status'] ? '正常' : '故障'; $record['status'] = ''; $record['nasname'] = $v['address'][0]; 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) { fputcsv($file, $net_data); fputcsv($all, $net_data); } } } function laoying_getList($html, &$file, &$all, $exit) { global $dnx_exit, $dnx_has_exit; $key = ''; $list1 = []; preg_match("/(.*\s*?)<\/tbody>/is", $html, $result); preg_match_all("/(.*?)<\/tr>/is", $result[1], $result_info); $province_record = []; foreach ($result_info[1] as $k => $info) { //生成数据 $record = []; $record['name'] = '老鹰'; $jiexi_data = []; //数据解析 $temp = []; preg_match("/(.*?)<\/td>/is", $info, $address_html); preg_match("/(.*?)<\/span>/is", $info, $status_html); preg_match_all("/(.*?)<\/td>/is", $info, $nas_html); $jiexi_data['address'] = trim($address_html[1]); $jiexi_data['status'] = trim($status_html[1])=='正常运行'?'正常':'故障';; $jiexi_data['nasname'] = trim($nas_html[1][1]); //运营商 if (strpos($jiexi_data['address'], '电信') !== false) { $supply = '电信'; $jiexi_data['address'] = mb_substr($jiexi_data['address'], 0, mb_strlen($jiexi_data['address']) - 2); } elseif (strpos($jiexi_data['address'], '联通') !== false) { $supply = '联通'; $jiexi_data['address'] = mb_substr($jiexi_data['address'], 0, mb_strlen($jiexi_data['address']) - 2); } elseif (strpos($jiexi_data['address'], '移动') !== false) { $supply = '移动'; $jiexi_data['address'] = mb_substr($jiexi_data['address'], 0, mb_strlen($jiexi_data['address']) - 2); } else { $supply = '电信/联通'; } if (strpos($jiexi_data['address'], '混拨') !== false) { if (!in_array('混拨', $province_record)) { $record['city'] = '混拨'; $province_record[] = '混拨'; $key = $record['city']; $list1[$key][] = $record; } $temp['city'] = $jiexi_data['address']; $temp['status'] = $jiexi_data['status']; $temp['nasname'] = $jiexi_data['nasname']; } elseif (strpos($jiexi_data['address'], '省') !== false) { $add_explode = explode('省',$jiexi_data['address']); if (!in_array($add_explode[0], $province_record)) { $record['city'] = $add_explode[0]; $province_record[] = $add_explode[0]; $key = $record['city']; $list1[$key][] = $record; } $temp['city'] = $add_explode[1]; $temp['status'] = $jiexi_data['status']; $temp['nasname'] = $jiexi_data['nasname']; } elseif (strpos($jiexi_data['address'], '自治区') !== false) { $add_explode = explode('自治区',$jiexi_data['address']); if (!in_array($add_explode[0], $province_record)) { $record['city'] = $add_explode[0]; $province_record[] = $add_explode[0]; $key = $record['city']; $list1[$key][] = $record; } $temp['city'] = $add_explode[1]; $temp['status'] = $jiexi_data['status']; $temp['nasname'] = $jiexi_data['nasname']; } elseif (strpos($jiexi_data['address'], '市') !== false) { $add_explode = explode('市',$jiexi_data['address']); if (!in_array($add_explode[0], $province_record)) { $record['city'] = $add_explode[0]; $province_record[] = $add_explode[0]; $key = $record['city']; $list1[$key][] = $record; } $temp['city'] = $add_explode[1]; $temp['status'] = $jiexi_data['status']; $temp['nasname'] = $jiexi_data['nasname']; } $record['city'] =$temp['city']; $record['supply'] = $supply; $record['ip'] = ''; $record['daikuan'] = ''; $record['onlineuser'] = ''; $record['maxuser'] = ''; $record['online'] = $temp['status']; $record['status'] = ''; $record['nasname'] = $temp['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')]); } $list1[$key][] = $record; } foreach ($list1 as $val) { foreach ($val as $net_data) { fputcsv($file, $net_data); fputcsv($all, $net_data); } } } //共享 function gongxiang_getList($html, &$file, &$all, $exit, $pro = '共享') { global $dnx_exit, $dnx_has_exit; //省会 $province = ['黑龙', '内蒙']; $province_record = []; $key = ''; $list1 = []; preg_match_all("//is", $html, $result); foreach ($result[0] as $k => $info) { $record = []; $record['name'] = $pro; $records['name'] = $pro; 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], ''); } $nasname = $info[1]; $data[1] = $info[2]; if (strpos($data[1], '电信') !== false) { $supply = '电信'; $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) { $supply = '移动'; $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)) { $record['city'] = $data[1]; $record['supply'] = $supply; $record['ip'] = ''; $record['daikuan'] = ''; $record['onlineuser'] = ''; $record['maxuser'] = ''; $record['online'] = strpos($info[4], '在线') ? '正常' : '故障'; $record['status'] = ''; $record['nasname'] = $nasname; $records['city'] = $data[1]; $province_record[] = $data[1]; if (in_array($record['city'], ['曾', '龙'])) { continue; } $key = $record['city']; $list1[$key][] = $records; $list1[$key][] = $record; } else { $record['city'] = $data[1]; $record['supply'] = $supply; $record['ip'] = ''; $record['daikuan'] = ''; $record['onlineuser'] = ''; $record['maxuser'] = ''; $record['online'] = strpos($info[4], '在线') ? '正常' : '故障'; $record['status'] = ''; $record['nasname'] = $nasname; 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); $record['supply'] = $supply; $record['ip'] = ''; $record['daikuan'] = ''; $record['onlineuser'] = ''; $record['maxuser'] = ''; $record['online'] = strpos($info[4], '在线') ? '正常' : '故障'; $record['status'] = ''; $record['nasname'] = $nasname; if (in_array($record['city'], ['曾', '龙'])) { continue; } $list1[$key][] = $record; } else { $record['city'] = mb_substr($data['1'], 3); $record['supply'] = $supply; $record['ip'] = ''; $record['daikuan'] = ''; $record['onlineuser'] = ''; $record['maxuser'] = ''; $record['online'] = strpos($info[4], '在线') ? '正常' : '故障'; $record['status'] = ''; $record['nasname'] = $nasname; $records['city'] = $province_detail; $province_record[] = $province_detail; 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); $record['supply'] = $supply; $record['ip'] = ''; $record['daikuan'] = ''; $record['onlineuser'] = ''; $record['maxuser'] = ''; $record['online'] = strpos($info[4], '在线') ? '正常' : '故障'; $record['status'] = ''; $record['nasname'] = $nasname; if (in_array($record['city'], ['曾', '龙'])) { continue; } $list1[$key][] = $record; } else { $record['city'] = mb_substr($data['1'], 2); $record['supply'] = $supply; $record['ip'] = ''; $record['daikuan'] = ''; $record['onlineuser'] = ''; $record['maxuser'] = ''; $record['online'] = strpos($info[4], '在线') ? '正常' : '故障'; $record['status'] = ''; $record['nasname'] = $nasname; $records['city'] = $province_detail; $province_record[] = $province_detail; if (in_array($record['city'], ['曾', '龙'])) { continue; } $list1[$key][] = $records; $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']); fputcsv($file, $net_data); fputcsv($all, $net_data); } } } function xunlian_getList($data, &$file, &$all, $exit) { global $dnx_exit, $dnx_has_exit,$sp_xl_list; $online = ['故障', '正常', '异常']; $status = ['正常', '拥挤', '超载']; $key = ''; $list1 = []; $province_record = []; foreach ($data as $info) { $record = []; $record['name'] = '迅连'; //如果存在 不为空 则 $city_name = explode('-',$info['name']); if (strpos($city_name[1], '混播') !== false) { //如果存在 不为空 则 if (!in_array( $city_name[1], $province_record)) { $record['city'] = $city_name[1]; $province_record[] = $city_name[1]; $key = $record['city']; $list1[$key][] = $record; } } else { //如果存在 不为空 则 if (!in_array( $city_name[0], $province_record)) { $record['city'] = $city_name[0]; $province_record[] = $city_name[0]; $key = $record['city']; $list1[$key][] = $record; } } $record['city'] = $city_name[1]; $record['supply'] = isset($city_name[2]) ? trim($city_name[2]) : ''; $daikuan = $info['bandwidth']; $record['ip'] = $info['name2']; $record['daikuan'] = $daikuan; $record['onlineuser'] = ''; $record['maxuser'] = ''; $record['online'] = $info['status'] == 1 ? '正常' : '故障'; $record['status'] = $sp_xl_list[$record['city']]; if(!empty($info['host2'])){ $nas_list = explode(',',$info['host2']); foreach ($nas_list as $nas) { $record['nasname'] = trim($nas); 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; } } $record['nasname'] = trim($info['host']); 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) { fputcsv($file, $net_data); fputcsv($all, $net_data); } } } function wuxian_getList($html, &$file, &$all, $exit) { // global $dnx_exit, $dnx_has_exit; // //省会 // $province = ['黑龙', '内蒙']; // $province_record = []; // $key = ''; // $list1 = []; // $citys = ['北京', '上海', '天津', '重庆']; // preg_match("/
 <\/div>(.*?)<\/div><\/div>/is", $html, $result); // $result = str_replace('
 
', '', $result[0]); // preg_match_all("/
(.*?)<\/div>/is", $result, $result); // foreach ($result[0] as $k => $info) { // $record = []; // $record['name'] = '无限'; // $info = ltrim($info, '
'); // $info = rtrim($info, '
'); // if (strpos($info, 'span') !== false) { // $data = explode(' ', $info); // } else { // $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); // } // 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']); // $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']); // $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']); // $record['supply'] = '移动'; // } else { // $record['city'] = $data[1]; // $record['city'] = str_replace('<', '', $record['city']); // $record['city'] = str_replace('>', '', $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'], 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']); // fputcsv($file, $net_data); // fputcsv($all, $net_data); // } // } } function xianfeng_getList($data, &$file, &$all, $exit) { global $dnx_exit, $dnx_has_exit; //省会 $province = ['黑龙', '内蒙', '直辖']; $province_record = []; $key = ''; $list1 = []; $status = ['维护中', '正常']; foreach ($data as $info) { $record = []; $record['name'] = '先锋'; $info['description'] = trim($info['description'], 'a'); if (strpos($info['description'], '混播') || strpos($info['description'], '所有单城市')) { $province_detail = '混播'; if (!in_array($province_detail, $province_record)) { $record['city'] = $province_detail; $province_record[] = $province_detail; $key = $record['city']; $list1[$key][] = $record; } $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)) { $record['city'] = $province_detail; $province_record[] = $province_detail; $key = $record['city']; $list1[$key][] = $record; } $key = $province_detail; 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'] = $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.1) { $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')]); } $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']); 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; //省会 $province_record = []; $key = ''; $list1 = []; 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']; $key = $record['city']; $list1[$key][] = $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'] = $info['status'] == 1 ? '正常' : '故障'; $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'], date('Y-m-d H:i:s')]); } $list1[$info['province']][] = $record; } } foreach ($list1 as $val) { foreach ($val as $net_data) { fputcsv($file, $net_data); fputcsv($all, $net_data); } } } function get_content($url, $cookie) { $product_model = new Product; $product_token = $product_model->where(['Id'=>18])->field('Id,Token')->fetch()['Token']; $header = [ 'Authorization: Bearer '.$product_token, ]; // print_r($header); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_HTTPHEADER, $header); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_COOKIE, $cookie); //读取cookie $rs = curl_exec($ch); //执行cURL抓取页面内容 // print_r($rs); curl_close($ch); return $rs; } function get_product($file_path, $num = 9) { $list = []; $file = fopen($file_path, 'r'); while ($info = fgetcsv($file)) { if (isset($info[$num])) { $list[] = $info[$num]; } } 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; }