diff --git a/script/linedata/auto_format.php b/script/linedata/auto_format.php index bd33a10..87b1102 100644 --- a/script/linedata/auto_format.php +++ b/script/linedata/auto_format.php @@ -43,6 +43,9 @@ function auto_format_list(){ case 17: format_product(__DIR__ . '/data/xigua.csv', 'xgip.vip'); break; + case 18: + format_product(__DIR__ . '/data/mogu.csv', 'mgip.net'); + break; } } } diff --git a/script/linedata/display.php b/script/linedata/display.php index 5b741e0..75c290f 100755 --- a/script/linedata/display.php +++ b/script/linedata/display.php @@ -52,6 +52,9 @@ switch ($id) { case 17: get_product(__DIR__ . '/data/download/xigua.csv'); break; + case 18: + get_product(__DIR__ . '/data/download/mogu.csv'); + break; } function get_all_product($file_path) diff --git a/script/linedata/get_line_list.php b/script/linedata/get_line_list.php index 6ac5dc3..f779ab6 100755 --- a/script/linedata/get_line_list.php +++ b/script/linedata/get_line_list.php @@ -15,6 +15,10 @@ use app\api\model\Product; $product_model = new Product; $product_list = $product_model->field('Id,Token')->fetchAll(); + + +// die; + $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); @@ -54,6 +58,15 @@ $tiantian = json_decode(file_get_contents("http://api.ipzuiduo.com/api/areas?api tiantian_getList($tiantian, $tiantian_f, $all, $tiantian_data, '天天'); fclose($tiantian_f); +$mogu_data = get_product(__DIR__ . '/data/mogu.csv'); +$mogu_f = fopen(__DIR__ . '/data/mogu.csv', 'w'); +// echo 123; +$mogu = json_decode(get_content("http://xjip.hlapi.com/api/area",''), true)['data']; +// print_r($mogu); +//写入蘑菇文件 +mogu_getList($mogu, $mogu_f, $all, $mogu_data, 'mogu'); +fclose($mogu_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']; @@ -368,6 +381,61 @@ function tiantian_getList($data, &$file, &$all, $exit, $product_name) } + +//蘑菇服务器解析规则 +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'] = empty($v['status']) ? '故障' : $status[$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 shihui_getList($html, &$file, &$all, $exit) { global $dnx_exit, $dnx_has_exit; @@ -888,12 +956,22 @@ function jinrui_getList($html, &$file, &$all, $exit) 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; } diff --git a/script/linedata/search.php b/script/linedata/search.php index 81cac8d..88ddbcc 100755 --- a/script/linedata/search.php +++ b/script/linedata/search.php @@ -56,6 +56,9 @@ if($_GET['type'] == 1){ case 17: search_product(__DIR__.'/data/download/xigua.csv','xgip.vip'); break; + case 18: + search_product(__DIR__.'/data/download/xigua.csv','mgip.net'); + break; } }