From 9fa202f23b1d06ac6594f2486030656c7cc3f512 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cwanyongkang=E2=80=9D?= <“937888580@qq.com”> Date: Thu, 14 Apr 2022 17:46:56 +0800 Subject: [PATCH] =?UTF-8?q?=E7=81=AB=E7=8B=90=E7=BA=BF=E8=B7=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- script/linedata/auto_format.php | 13 +++-- script/linedata/get_line_list.php | 87 ++++++++++++++++--------------- 2 files changed, 54 insertions(+), 46 deletions(-) diff --git a/script/linedata/auto_format.php b/script/linedata/auto_format.php index 1655194..f8fbe10 100644 --- a/script/linedata/auto_format.php +++ b/script/linedata/auto_format.php @@ -1,7 +1,7 @@ /is", $content, $result); -//获取城市数据 -// preg_match_all("/(.*?)/is", $result[1][2], $city); +$url = 'http://int.linghangadmin.com:8000/sysadmin/useradmin/lineapi_admin1.php?secretId=108006113&secretKey=87085a351a64c116df09ebc07d5781sf'; +$huohu = json_decode(file_get_contents($url), true); -$huohu = $city[1]; if(!empty($huohu)){ $huohu_f = fopen(__DIR__ . '/data/huohu.csv', 'w'); //写入火狐文件 - huohu_getList($huohu, $huohu_f, $all); + $huohu_data = get_product(__DIR__ . '/data/huohu.csv'); + huohu_getList($huohu, $huohu_f, $all,$huohu_data); fclose($huohu_f); } @@ -272,36 +268,41 @@ function qiangzi_getList($data, &$file, &$all, $exit) } //火狐服务器解析规则 -function huohu_getList($data, &$file, &$all) +function huohu_getList($data, &$file, &$all, $exit) { + + global $dnx_exit, $dnx_has_exit; + $online = ['故障', '正常','故障']; $list = []; + + $province_record = []; foreach ($data as $info){ $record = []; $record['name'] = '火狐'; - //匹配所有的省份 - preg_match("/\'\);\">(.*?)<\/span>/is", $info, $province); - $city = $province[1]; - $record['city'] = $city; - $key = $record['city']; - $list[$key][] = $record; - //匹配所有的城市 - preg_match_all("/<\/span>(.*?)<\/span><\/span>/is", $info, $citys); - //每一个城市再解析获取城市和剩余数量 - foreach ($citys[1] as $city_line){ - preg_match("/(.*?),剩:/is", $city_line, $address_s); - - $address = $address_s[1]; - $num = explode('>',$city_line)[1]; - - $record['city'] = $address; - - $record['supply'] = $num; - - $record['online'] = '正常'; - $record['nasname'] = $address; - + //如果存在 不为空 则 + if (!in_array( $info['province'], $province_record)) { + $record['city'] = $info['province']; + $province_record[] = $info['province']; + $key = $record['city']; $list[$key][] = $record; } + //匹配所有的城市 + //每一个城市再解析获取城市和剩余数量 + + $record['city'] = $info['city']; + $record['supply'] = $info['displayname']; + $record['ip'] = ''; + $record['daikuan'] = ''; + $record['onlineuser'] = ''; + $record['maxuser'] = ''; + $record['online'] = $online[$info['status']]; + $record['nasname'] = $info['ip']; + + $list[$key][] = $record; + + if (!in_array($record['nasname'], $exit) && !in_array($record['nasname'], $dnx_has_exit)) { + fputcsv($dnx_exit, ['强子', explode('.',$record['nasname'])[0], $record['nasname'], date('Y-m-d H:i:s')]); + } } foreach ($list as $val) { foreach ($val as $net_data) {