laoying linelist

This commit is contained in:
“wanyongkang”
2021-09-04 13:32:03 +08:00
parent fecba879ac
commit 19f6c7c074

View File

@@ -15,14 +15,14 @@ $product_model = new Product;
$product_list = $product_model->field('Id,Token')->fetchAll(); $product_list = $product_model->field('Id,Token')->fetchAll();
// //测试用---------------------------------------------------------------------------------------------------------- // //测试用----------------------------------------------------------------------------------------------------------
// $apikey = '80cf4f64e990b78a9fc5eb'; // $laoying = json_decode(file_get_contents("http://diqu.pptp.pro:8070/sapi/getroslist"), true)['list'];
// $url = "http://rds-api.juip.com/server/index/getList?apikey=".$apikey; // if($laoying){
// $mogu = json_decode(file_get_contents($url), true)['data']; // $laoying_data = get_product(__DIR__ . '/data/laoying.csv');
// dump($mogu);die; // $laoying_f = fopen(__DIR__ . '/data/laoying.csv', 'w');
// $mogu_data = get_product(__DIR__ . '/data/mogu.csv'); // //写入老鹰文件
// $mogu_f = fopen(__DIR__ . '/data/mogu.csv', 'w'); // laoying_getList($laoying, $laoying_f, $all, $laoying_data);
// mogu_getList($mogu, $mogu_f, $all, $mogu_data); // fclose($laoying_f);
// fclose($mogu_f); // }
// die; // die;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//强子迅联特征码 //强子迅联特征码
@@ -192,14 +192,14 @@ fclose($xianfeng_f);
// jinrui_getList($jinrui, $jinrui_f, $all, $jinrui_data); // jinrui_getList($jinrui, $jinrui_f, $all, $jinrui_data);
// fclose($jinrui_f); // fclose($jinrui_f);
// //星星2288写入all $laoying = json_decode(file_get_contents("http://diqu.pptp.pro:8070/sapi/getroslist"), true)['list'];
// $file2288 = fopen(__DIR__ . '/data/2288.csv', 'r'); if($laoying){
// while ($data = fgetcsv($file2288)) { $laoying_data = get_product(__DIR__ . '/data/laoying.csv');
// fputcsv($all, $data); $laoying_f = fopen(__DIR__ . '/data/laoying.csv', 'w');
// } //写入老鹰文件
// fclose($file2288); laoying_getList($laoying, $laoying_f, $all, $laoying_data);
// fclose($all); fclose($laoying_f);
// fclose($dnx_exit); }
sleep(5); sleep(5);
auto_format_list(); auto_format_list();
@@ -561,103 +561,71 @@ function mogu_getList($data, &$file, &$all )
} }
function laoying_getList($html, &$file, &$all, $exit) function laoying_getList($list, &$file, &$all, $exit)
{ {
global $dnx_exit, $dnx_has_exit; global $dnx_exit, $dnx_has_exit;
$key = ''; $key = '';
$list1 = [];
preg_match("/<tbody>(.*\s*?)<\/tbody>/is", $html, $result);
preg_match_all("/<tr>(.*?)<\/tr>/is", $result[1], $result_info);
$online = ['故障', '正常'];
$province_record = []; $province_record = [];
foreach ($result_info[1] as $k => $info) { foreach ($list as $k => $info) {
//生成数据 //生成数据
$record = []; $record = [];
$record['name'] = '老鹰'; $record['name'] = '老鹰';
$jiexi_data = [];
//数据解析
$temp = [];
preg_match("/<td class=\"text-center\">(.*?)<\/td>/is", $info, $address_html);
preg_match("/<span class=\"badge badge-success\">(.*?)<\/span>/is", $info, $status_html);
preg_match_all("/<td class=\"d-none d-sm-table-cell text-center\">(.*?)<\/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) { if (strpos($info['server_address'], '电信') !== false) {
$supply = '电信'; $supply = '电信';
$jiexi_data['address'] = mb_substr($jiexi_data['address'], 0, mb_strlen($jiexi_data['address']) - 2); $info['server_address'] = mb_substr($info['server_address'], 0, mb_strlen($info['server_address']) - 2);
} elseif (strpos($jiexi_data['address'], '联通') !== false) { } elseif (strpos($info['server_address'], '联通') !== false) {
$supply = '联通'; $supply = '联通';
$jiexi_data['address'] = mb_substr($jiexi_data['address'], 0, mb_strlen($jiexi_data['address']) - 2); $info['server_address'] = mb_substr($info['server_address'], 0, mb_strlen($info['server_address']) - 2);
} elseif (strpos($jiexi_data['address'], '移动') !== false) { } elseif (strpos($info['server_address'], '移动') !== false) {
$supply = '移动'; $supply = '移动';
$jiexi_data['address'] = mb_substr($jiexi_data['address'], 0, mb_strlen($jiexi_data['address']) - 2); $info['server_address'] = mb_substr($info['server_address'], 0, mb_strlen($info['server_address']) - 2);
} else { } else {
$supply = '电信/联通'; $supply = '电信/联通';
} }
if (strpos($jiexi_data['address'], '混拨') !== false) { //如果存在 不为空 则
if (!in_array('混拨', $province_record)) { if (!in_array( $info['category_name'], $province_record)) {
$record['city'] = '混拨'; $record['city'] = $info['category_name'];
$province_record[] = '混拨'; $province_record[] = $info['category_name'];
$key = $record['city']; $key = $record['city'];
$list1[$key][] = $record; $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'];
} }
$key = $info['category_name'];
$record['city'] =$temp['city'];
$record['city'] =$info['server_address'];
$record['supply'] = $supply; $record['supply'] = $supply;
$record['ip'] = ''; $record['ip'] = '';
$record['daikuan'] = ''; $record['daikuan'] = '';
$record['onlineuser'] = ''; $record['onlineuser'] = '';
$record['maxuser'] = ''; $record['maxuser'] = '';
$record['online'] = $temp['status']; $record['online'] = $online[$info['isonline']];
$record['status'] = ''; $record['status'] = '';
$record['nasname'] = $temp['nasname']; if (strpos($info['remote_domain'], ' ') !== false) {
if (!in_array($record['nasname'], $exit) && !in_array($record['nasname'], $dnx_has_exit)) { $nas_list = explode(' ',$info['remote_domain']);
fputcsv($dnx_exit, ['老鹰', explode('.',$record['nasname'])[0], $record['nasname'], date('Y-m-d H:i:s')]); $record['nasname'] = $nas_list[0];
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')]);
}
$list1[$key][] = $record;
$record['nasname'] = empty($nas_list[1])?$nas_list[2]:$nas_list[1];
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')]);
}
$list1[$key][] = $record;
} else {
$record['nasname'] = $info['remote_domain'];
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')]);
}
$list1[$key][] = $record;
} }
$list1[$key][] = $record;
} }
foreach ($list1 as $val) { foreach ($list1 as $val) {