laoying linelist
This commit is contained in:
@@ -15,14 +15,14 @@ $product_model = new Product;
|
||||
$product_list = $product_model->field('Id,Token')->fetchAll();
|
||||
|
||||
// //测试用----------------------------------------------------------------------------------------------------------
|
||||
// $apikey = '80cf4f64e990b78a9fc5eb';
|
||||
// $url = "http://rds-api.juip.com/server/index/getList?apikey=".$apikey;
|
||||
// $mogu = json_decode(file_get_contents($url), true)['data'];
|
||||
// dump($mogu);die;
|
||||
// $mogu_data = get_product(__DIR__ . '/data/mogu.csv');
|
||||
// $mogu_f = fopen(__DIR__ . '/data/mogu.csv', 'w');
|
||||
// mogu_getList($mogu, $mogu_f, $all, $mogu_data);
|
||||
// fclose($mogu_f);
|
||||
// $laoying = json_decode(file_get_contents("http://diqu.pptp.pro:8070/sapi/getroslist"), true)['list'];
|
||||
// if($laoying){
|
||||
// $laoying_data = get_product(__DIR__ . '/data/laoying.csv');
|
||||
// $laoying_f = fopen(__DIR__ . '/data/laoying.csv', 'w');
|
||||
// //写入老鹰文件
|
||||
// laoying_getList($laoying, $laoying_f, $all, $laoying_data);
|
||||
// fclose($laoying_f);
|
||||
// }
|
||||
// die;
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//强子迅联特征码
|
||||
@@ -192,14 +192,14 @@ fclose($xianfeng_f);
|
||||
// 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);
|
||||
$laoying = json_decode(file_get_contents("http://diqu.pptp.pro:8070/sapi/getroslist"), true)['list'];
|
||||
if($laoying){
|
||||
$laoying_data = get_product(__DIR__ . '/data/laoying.csv');
|
||||
$laoying_f = fopen(__DIR__ . '/data/laoying.csv', 'w');
|
||||
//写入老鹰文件
|
||||
laoying_getList($laoying, $laoying_f, $all, $laoying_data);
|
||||
fclose($laoying_f);
|
||||
}
|
||||
|
||||
sleep(5);
|
||||
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;
|
||||
$key = '';
|
||||
$list1 = [];
|
||||
preg_match("/<tbody>(.*\s*?)<\/tbody>/is", $html, $result);
|
||||
preg_match_all("/<tr>(.*?)<\/tr>/is", $result[1], $result_info);
|
||||
|
||||
$online = ['故障', '正常'];
|
||||
$province_record = [];
|
||||
foreach ($result_info[1] as $k => $info) {
|
||||
foreach ($list as $k => $info) {
|
||||
|
||||
//生成数据
|
||||
$record = [];
|
||||
$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 = '电信';
|
||||
$jiexi_data['address'] = mb_substr($jiexi_data['address'], 0, mb_strlen($jiexi_data['address']) - 2);
|
||||
} elseif (strpos($jiexi_data['address'], '联通') !== false) {
|
||||
$info['server_address'] = mb_substr($info['server_address'], 0, mb_strlen($info['server_address']) - 2);
|
||||
} elseif (strpos($info['server_address'], '联通') !== false) {
|
||||
$supply = '联通';
|
||||
$jiexi_data['address'] = mb_substr($jiexi_data['address'], 0, mb_strlen($jiexi_data['address']) - 2);
|
||||
} elseif (strpos($jiexi_data['address'], '移动') !== false) {
|
||||
$info['server_address'] = mb_substr($info['server_address'], 0, mb_strlen($info['server_address']) - 2);
|
||||
} elseif (strpos($info['server_address'], '移动') !== false) {
|
||||
$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 {
|
||||
$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'];
|
||||
}
|
||||
//如果存在 不为空 则
|
||||
if (!in_array( $info['category_name'], $province_record)) {
|
||||
$record['city'] = $info['category_name'];
|
||||
$province_record[] = $info['category_name'];
|
||||
$key = $record['city'];
|
||||
$list1[$key][] = $record;
|
||||
}
|
||||
$key = $info['category_name'];
|
||||
|
||||
$record['city'] =$temp['city'];
|
||||
|
||||
$record['city'] =$info['server_address'];
|
||||
$record['supply'] = $supply;
|
||||
$record['ip'] = '';
|
||||
$record['daikuan'] = '';
|
||||
$record['onlineuser'] = '';
|
||||
$record['maxuser'] = '';
|
||||
$record['online'] = $temp['status'];
|
||||
$record['online'] = $online[$info['isonline']];
|
||||
$record['status'] = '';
|
||||
$record['nasname'] = $temp['nasname'];
|
||||
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')]);
|
||||
if (strpos($info['remote_domain'], ' ') !== false) {
|
||||
$nas_list = explode(' ',$info['remote_domain']);
|
||||
$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) {
|
||||
|
||||
Reference in New Issue
Block a user