服务器列表3
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
* @Author: kangkang
|
||||
* @Date: 2020-11-06 14:32:57
|
||||
* @LastEditors: kangkang
|
||||
* @LastEditTime: 2020-11-07 17:00:36
|
||||
* @LastEditTime: 2020-11-08 10:46:22
|
||||
*/
|
||||
header('Access-Control-Allow-Origin: *');
|
||||
header("Access-Control-Allow-Methods: *");
|
||||
@@ -47,14 +47,16 @@ switch($id){
|
||||
format_product(__DIR__.'/data/shihui.csv','shihui');
|
||||
break;
|
||||
case 15:
|
||||
format_product(__DIR__.'/data/gongxiang.csv');
|
||||
format_product(__DIR__.'/data/gongxiang.csv','shihui');
|
||||
break;
|
||||
}
|
||||
|
||||
function format_all_product($file_path){
|
||||
$list = [];
|
||||
$dns = '';
|
||||
$record = [];
|
||||
$file = fopen($file_path,'r');
|
||||
$file1 = fopen(__DIR__.'/data/download/all.csv','w');
|
||||
while ($info = fgetcsv($file)) {
|
||||
$data['name'] = $info[0];
|
||||
switch($data['name']){
|
||||
@@ -89,7 +91,7 @@ function format_all_product($file_path){
|
||||
$dns = 'shihui';
|
||||
break;
|
||||
case '共享':
|
||||
$dns = '';
|
||||
$dns = 'shihui';
|
||||
break;
|
||||
}
|
||||
$data['city'] = $info[1];
|
||||
@@ -102,19 +104,24 @@ function format_all_product($file_path){
|
||||
$data['status'] = $info[8];
|
||||
if($dns!='shihui'){
|
||||
$ip = explode('.',$info[9]);
|
||||
$data['nasname'] = $ip[0]?$ip[0].'.'.$dns:'';
|
||||
$data['nasname'] = $ip[0]?ip_repeat($record,$ip[0]).'.'.$dns:'';
|
||||
} else {
|
||||
$data['nasname'] = $info[9];
|
||||
}
|
||||
fputcsv($file1,$data);
|
||||
$list[] = $data;
|
||||
}
|
||||
fclose($file);
|
||||
fclose($file1);
|
||||
echo json_encode(['data'=>$list]);
|
||||
}
|
||||
|
||||
function format_product($file_path,$dns = ''){
|
||||
$list = [];
|
||||
$file = fopen($file_path,'r');
|
||||
$file_path1 = explode('/',$file_path);
|
||||
$file1 = fopen(__DIR__.'/data/download/'.$file_path1[8],'w');
|
||||
$record = [];
|
||||
while ($info = fgetcsv($file)) {
|
||||
$data['name'] = $info[0];
|
||||
$data['city'] = $info[1];
|
||||
@@ -127,12 +134,15 @@ function format_product($file_path,$dns = ''){
|
||||
$data['status'] = $info[8];
|
||||
if($dns!='shihui'){
|
||||
$ip = explode('.',$info[9]);
|
||||
$data['nasname'] = $ip[0]?$ip[0].'.'.$dns:'';
|
||||
$data['nasname'] = $ip[0]?ip_repeat($record,$ip[0]).'.'.$dns:'';
|
||||
} else {
|
||||
$data['nasname'] = $info[9];
|
||||
}
|
||||
fputcsv($file1,$data);
|
||||
$list[] = $data;
|
||||
}
|
||||
|
||||
fclose($file1);
|
||||
fclose($file);
|
||||
echo json_encode(['data'=>$list]);
|
||||
}
|
||||
@@ -142,6 +152,9 @@ function format_xingxing($file_path1,$file_path2,$dns){
|
||||
$list2 = [];
|
||||
$file1 = fopen($file_path1,'r');
|
||||
$file2 = fopen($file_path2,'r');
|
||||
$record = [];
|
||||
$file_path = explode('/',$file_path1);
|
||||
$file3 = fopen(__DIR__.'/data/download/'.$file_path[8],'w');
|
||||
while ($info = fgetcsv($file1)) {
|
||||
$data['name'] = $info[0];
|
||||
$data['city'] = $info[1];
|
||||
@@ -153,7 +166,8 @@ function format_xingxing($file_path1,$file_path2,$dns){
|
||||
$data['online'] = $info[7];
|
||||
$data['status'] = $info[8];
|
||||
$ip = explode('.',$info[9]);
|
||||
$data['nasname'] = $ip[0]?$ip[0].'.'.$dns:'';
|
||||
$data['nasname'] = $ip[0]?ip_repeat($record,$ip[0]).'.'.$dns:'';
|
||||
fputcsv($file3,$data);
|
||||
$list1[] = $data;
|
||||
}
|
||||
while ($info = fgetcsv($file2)) {
|
||||
@@ -167,12 +181,30 @@ function format_xingxing($file_path1,$file_path2,$dns){
|
||||
$data['online'] = $info[7];
|
||||
$data['status'] = $info[8];
|
||||
$ip = explode('.',$info[9]);
|
||||
$data['nasname'] = $ip[0]?$ip[0].'.'.$dns:'';
|
||||
$data['nasname'] = $ip[0]?ip_repeat($record,$ip[0]).'.'.$dns:'';
|
||||
fputcsv($file3,$data);
|
||||
$list2[] = $data;
|
||||
}
|
||||
|
||||
fclose($file1);
|
||||
fclose($file2);
|
||||
fclose($file3);
|
||||
$list = array_merge($list1,$list2);
|
||||
echo json_encode(['data'=>$list]);
|
||||
}
|
||||
|
||||
function ip_repeat(&$record,$ip){
|
||||
for ($i=2;$i<100;$i++){
|
||||
if(in_array($ip,$record)){
|
||||
if(in_array($ip.'v'.$i,$record)){
|
||||
continue;
|
||||
} else {
|
||||
$record[] = $ip.'v'.$i;
|
||||
return $ip.'v'.$i;
|
||||
}
|
||||
} else {
|
||||
$record[] = $ip;
|
||||
return $ip;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user