新产品火狐

This commit is contained in:
“wanyongkang”
2021-04-26 18:50:06 +08:00
parent 8efb5f9c5a
commit 33ff11d5ff
5 changed files with 214 additions and 18 deletions

View File

@@ -4,6 +4,8 @@ namespace app\product\controller;
class AccountAddress
{
public function index()
{
$info = $_GET;
@@ -31,4 +33,77 @@ class AccountAddress
echo $content;
}
//火狐ip
public function getList()
{
$login_url = 'http://106.52.152.33:8899/main/raduserLogin';
$params = array(
"username" => $_GET['user'],
"password" => $_GET['password'],
);
$login_content = linkcurl($login_url,'POST',$params);
preg_match_all('/set\-cookie:([^\r\n]*); path/i', $login_content, $m);
$cookie = $m[1][0];
$url = 'http://106.52.152.33:8899/panel/index';
$header = array();
$header[] = "Cookie:".$cookie;
$content = linkcurl($url,'POST',[],$header);
//获取所有大分类
preg_match_all("/<tr(.*?)<\/tr>/is", $content, $result);
//只获取ipmodel的数据
preg_match_all("/<td>(.*?)<\/td>/is", $result[1][1], $ipmodel);
//获取城市数据
preg_match_all("/<td id=\"pools\">(.*?)<a/is", $result[1][2], $city);
$data = [
'ipmodel' => $ipmodel[1],
'city' => $city[1],
];
// print_r($data);
echo json_encode($data);
}
public function setAddress()
{
$data = json_decode(file_get_contents("php://input"),true);
$login_url = 'http://106.52.152.33:8899/main/raduserLogin';
$params = array(
"username" => $data['account'],
"password" => $data['password'],
);
$login_content = linkcurl($login_url,'POST',$params);
preg_match_all('/set\-cookie:([^\r\n]*); path/i', $login_content, $m);
$cookie = $m[1][0];
$url = 'http://106.52.152.33:8899/panel/index';
$params = array(
"act" => 'save',
"username" => $data['account'],
"ipmode" => $data['ipmode'],
"citys[]" => implode(',',$data['list']),
);
$header = array();
$header[] = "Cookie:".$cookie;
$data = linkcurl($url,'POST',$params,$header);
if (strpos($data, '提交成功') !== false) {
echo json_encode(['code'=>1]);
}
}
}

View File

@@ -148,7 +148,7 @@ function realname($data){
* @param int $ipost [是否采用POST形式]
* @return string
*/
function linkcurl($url,$method,$params=false,$header=[]){
function linkcurl($url,$method,$params=[],$header=[]){
$httpInfo = array();
$ch = curl_init();
@@ -157,6 +157,7 @@ function linkcurl($url,$method,$params=false,$header=[]){
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_FAILONERROR, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 1); //是否显示头信息
if (1 == strpos("$".$url, "https://"))
{
@@ -169,7 +170,7 @@ function linkcurl($url,$method,$params=false,$header=[]){
if($method == "POST" ){
curl_setopt( $ch , CURLOPT_POST , true );
curl_setopt( $ch , CURLOPT_POSTFIELDS, json_encode($params) );
curl_setopt( $ch , CURLOPT_POSTFIELDS, $params );
}else if($params){
curl_setopt( $ch , CURLOPT_URL , $url.'?'.http_build_query($params) );
}

View File

@@ -1,7 +1,7 @@
<?php
function auto_format_list(){
$product_list = [0, 1, 2, 4, 5, 6, 8, 10, 13, 14, 15, 16, 17, 18];
$product_list = [0, 1, 2, 4, 5, 6, 8, 10, 13, 14, 15, 16, 17, 18, 19];
foreach ($product_list as $product) {
switch ($product) {
case 0:
@@ -46,6 +46,9 @@ function auto_format_list(){
case 18:
format_product(__DIR__ . '/data/mogu.csv', 'mgip.net');
break;
case 19:
format_product_huohu(__DIR__ . '/data/huohu.csv');
break;
}
}
}
@@ -102,6 +105,9 @@ function format_all_product($file_path)
case '蘑菇':
$dns = 'mgip.net';
break;
case '火狐':
$dns = 'hhip';
break;
default:
$dns = 'xlip.vip';
break;
@@ -116,11 +122,13 @@ function format_all_product($file_path)
$data['maxuser'] = $info[6] ?? '';
$data['online'] = $info[7] ?? '';
$data['status'] = $info[8] ?? '';
if ($dns != 'shihui') {
if ($dns == 'shihui') {
$data['nasname'] = $info[9] ?? '';
} elseif ($dns == 'hhip'){
$data['nasname'] = '1.hhip.vip';
} else {
$ip = explode('.', ($info[9] ?? ''));
$data['nasname'] = $ip[0] ? ip_repeat($record, $ip[0], $dns) . '.' . $dns : '';
} else {
$data['nasname'] = $info[9] ?? '';
}
fputcsv($file1, $data);
}
@@ -128,6 +136,44 @@ function format_all_product($file_path)
fclose($file1);
}
//火狐
function format_product_huohu($file_path)
{
$list1 = [];
$file = fopen($file_path, 'r');
$file_path1 = explode('/', $file_path);
$file1 = fopen(__DIR__ . '/data/download/' . $file_path1[8], 'w');
$record = [];
while ($info = fgetcsv($file)) {
if (empty($info[4])) {
$key = $info[1];
}
$record['name'] = $info[0];
$record['city'] = $info[1]??'';
$record['supply'] = $info[2]??'';
$record['ip'] = '';
$record['daikuan'] = '';
$record['onlineuser'] = '';
$record['maxuser'] = '';
$record['online'] = '正常';
$record['status'] = '';
if(!empty($info[4])){
$record['nasname'] = '1.hhip.vip';
}
$list1[$key][] = $record;
}
foreach ($list1 as $k => $val) {
foreach ($val as $net_data) {
fputcsv($file1, $net_data);
}
}
fclose($file1);
fclose($file);
}
function format_product($file_path, $dns = '')
{
$list1 = [];

View File

@@ -55,6 +55,9 @@ switch ($id) {
case 18:
get_product(__DIR__ . '/data/download/mogu.csv');
break;
case 19:
get_product(__DIR__ . '/data/download/huohu.csv');
break;
}
function get_all_product($file_path)

View File

@@ -15,17 +15,30 @@ $product_model = new Product;
$product_list = $product_model->field('Id,Token')->fetchAll();
// // //测试用----------------------------------------------------------------------------------------------------------
// $url = 'http://106.52.152.33:8899/panel/index';
// $header = array();
// $header[] = "Cookie: PHPSESSID=4c0teagu80klg065dk4ho0nvu6";
// $content = linkcurl($url,'POST',[],$header);
// $xianfeng = json_decode(file_get_contents("http://apiserver.pptp.biz/Apiserver/getserver"), true);
// print_r($xianfeng);die;
// if($xianfeng){
// $xianfeng_data = get_product(__DIR__ . '/data/xianfeng.csv');
// $xianfeng_f = fopen(__DIR__ . '/data/xianfeng.csv', 'w');
// //写入先锋文件
// xianfeng_getList($xianfeng, $xianfeng_f, $all, $xianfeng_data);
// fclose($xianfeng_f);
// //获取所有大分类
// preg_match_all("/<tr(.*?)<\/tr>/is", $content, $result);
// //获取城市数据
// // preg_match_all("/<td id=\"pools\">(.*?)<a/is", $result[1][2], $city);
// //根据省份获取数据
// preg_match_all("/<span class=\"province(.*?)<hr>/is", $result[1][2], $city);
// $huohu = $city[1];
// if(!empty($huohu)){
// $huohu_f = fopen(__DIR__ . '/data/huohu.csv', 'w');
// //写入火狐文件
// huohu_getList($huohu, $huohu_f, $all);
// fclose($huohu_f);
// }
// die;
// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//强子迅联特征码
$sp_xl_code = file_get_contents(__DIR__ . '/data/xl.txt', 'r');
@@ -89,6 +102,27 @@ if ($xunlian){
fclose($xunlian_f);
}
$url = 'http://106.52.152.33:8899/panel/index';
$header = array();
$header[] = "Cookie: PHPSESSID=4c0teagu80klg065dk4ho0nvu6";
$content = linkcurl($url,'POST',[],$header);
//获取所有大分类
preg_match_all("/<tr(.*?)<\/tr>/is", $content, $result);
//获取城市数据
// preg_match_all("/<td id=\"pools\">(.*?)<a/is", $result[1][2], $city);
//根据省份获取数据
preg_match_all("/<span class=\"province(.*?)<hr>/is", $result[1][2], $city);
$huohu = $city[1];
if(!empty($huohu)){
$huohu_f = fopen(__DIR__ . '/data/huohu.csv', 'w');
//写入火狐文件
huohu_getList($huohu, $huohu_f, $all);
fclose($huohu_f);
}
$time = time();
$noce = md5(time());
$apikey = 'd50f2b2ffd421efa67df8efb96d5ff6c';
@@ -284,6 +318,47 @@ function qiangzi_getList($data, &$file, &$all, $exit)
}
//火狐服务器解析规则
function huohu_getList($data, &$file, &$all)
{
$list = [];
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><\/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;
$list[$key][] = $record;
}
}
foreach ($list as $val) {
foreach ($val as $net_data) {
fputcsv($file, $net_data);
fputcsv($all, $net_data);
}
}
}
//星星服务器解析
function xingxing_getList($data, &$file, &$all, $exit)
{
@@ -1005,10 +1080,6 @@ function xianfeng_getList($data, &$file, &$all, $exit)
} else {
$record['status'] = '满载';
}
//南阳
if (strpos($record['city'], '南阳') !== false) {
$record['status'] = '满载';
}
$record['nasname'] = $info['nasname'];
if (!in_array($record['nasname'], $exit) && !in_array($record['nasname'], $dnx_has_exit)) {
fputcsv($dnx_exit, ['先锋', $record['nasname'], date('Y-m-d H:i:s')]);