diff --git a/script/linedata/get_line_list.php b/script/linedata/get_line_list.php index 25ae547..cb5e11f 100755 --- a/script/linedata/get_line_list.php +++ b/script/linedata/get_line_list.php @@ -32,6 +32,15 @@ $product_list = $product_model->field('Id,Token')->fetchAll(); // fclose($qiangzi_f); // } + +// $time = time(); +// $noce = md5(time()); +// $apikey = 'a77160a26aa0c4f8bb68c85e5e2c73d8'; +// $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']; +// print_r($xunlian);die; + // die; // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -40,7 +49,12 @@ $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 = json_decode(file_get_contents("http://47.92.116.14:2222/api/areaPool.html?type=json"), true); +$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'); @@ -50,6 +64,22 @@ qiangzi_getList($qiangzi, $qiangzi_f, $all, $qiangzi_data); fclose($qiangzi_f); } + +$time = time(); +$noce = md5(time()); +$apikey = 'a77160a26aa0c4f8bb68c85e5e2c73d8'; +$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(); @@ -113,14 +143,6 @@ gongxiang_getList($gongxiang, $gongxiang_f, $all, $gongxiang_data); fclose($gongxiang_f); -$xunlian = json_decode(file_get_contents("http://xunyou.ippptp.com:2222/api/areaPool.html?type=json"), true); -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); -} // $wuxian_data = get_product(__DIR__ . '/data/wuxian.csv'); // $wuxian_f = fopen(__DIR__ . '/data/wuxian.csv', 'w'); @@ -164,60 +186,69 @@ function qiangzi_getList($data, &$file, &$all, $exit) $key = ''; $list1 = []; + $province_record = []; foreach ($data as $info) { $record = []; $record['name'] = '强子'; //如果存在 不为空 则 - if (!empty($info['titleRow'])) { - $record['city'] = $info['titleRow']; - $key = $record['city']; - $list1[$key][] = $record; - } - if (empty($info['province'])) { - $record['city'] = $info['description']; - } else { - $record['city'] = trim($info['city'], '\"'); - } - if (strpos($info['description'], '省混')) { - $record['city'] = $info['description']; - } - $record['city'] = str_replace(' ', '', $record['city']); - if (strpos($info['description'], '电信') !== false) { - $record['supply'] = '电信'; - } elseif (strpos($info['description'], '联通') !== false) { - $record['supply'] = '联通'; - } elseif (strpos($info['description'], '移动') !== false) { - $record['supply'] = '移动'; - } else { - $record['supply'] = '电信/联通'; - } - $daikuan = explode('带宽', trim($info['description2'])); - $record['ip'] = $daikuan[0]; - $record['daikuan'] = $daikuan[1]; - $record['onlineuser'] = $info['onlineuser']; - $record['maxuser'] = $info['maxuser']; - $record['online'] = $info['online'] == 1 ? '正常' : '故障'; + $city_name = explode('-',$info['name']); + if (strpos($city_name[1], '混播') !== false) { - $record['status'] = $status[$info['status']]; - - 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( $city_name[1], $province_record)) { + $record['city'] = $city_name[1]; + $province_record[] = $city_name[1]; + $key = $record['city']; + $list1[$key][] = $record; } - $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')]); - } - $list1[$key][] = $record; + //如果存在 不为空 则 + 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'] = ''; + 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) { @@ -672,76 +703,74 @@ function gongxiang_getList($html, &$file, &$all, $exit, $pro = '共享') function xunlian_getList($data, &$file, &$all, $exit) { global $dnx_exit, $dnx_has_exit; - $online = ['故障', '正常']; - $province = ['黑龙', '内蒙']; - $citys = ['北京', '上海', '天津', '重庆']; + $online = ['故障', '正常', '异常']; + $status = ['正常', '拥挤', '超载']; + $key = ''; $list1 = []; $province_record = []; + foreach ($data as $info) { $record = []; - $record['name'] = '讯连'; - $province_detail = mb_substr($info['description'], 0, 2); - if ($province_detail == '全国') { - $record['city'] = $info['description']; - if (!in_array('混播', $province_record)) { - $province_record[] = '混播'; - $key = '混播'; + $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; } - - $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_record)) { - $record['city'] = $province_detail; - $province_record[] = $province_detail; - $key = $province_detail; + //如果存在 不为空 则 + if (!in_array( $city_name[0], $province_record)) { + $record['city'] = $city_name[0]; + $province_record[] = $city_name[0]; + $key = $record['city']; $list1[$key][] = $record; } - $key = $province_detail; - 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); - $record['supply'] = '联通'; - } 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'])); - } - for ($i = 1; $i < 6; $i++) { - if (!empty($info['nasname' . $i])) { + + - $record['ip'] = ''; - if ($i == 1) { - $record['daikuan'] = $info['maxbands'] ?: $info['description2']; - } else { - $record['daikuan'] = $info['maxbands' . ($i - 1)] ?: $info['description2']; - } - $record['onlineuser'] = ''; - $record['maxuser'] = ''; - $record['online'] = $online[$info['online']]; - $record['status'] = ''; - $record['nasname'] = $info['nasname' . $i]; + $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'] = ''; + 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')]); + 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) {