...
|
...
|
@@ -11,9 +11,8 @@ |
|
|
use Illuminate\Http\Exceptions\HttpResponseException;
|
|
|
use Illuminate\Http\JsonResponse;
|
|
|
use Illuminate\Http\Request;
|
|
|
use Illuminate\Support\Facades\Log;
|
|
|
use RecursiveDirectoryIterator;
|
|
|
use RecursiveIteratorIterator;
|
|
|
use Illuminate\Support\Facades\Cache;
|
|
|
use Illuminate\Support\Facades\Validator;
|
|
|
use ZipArchive;
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -52,15 +51,37 @@ protected function error($message = 'error', $status = 400, $data = []) |
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 响应response
|
|
|
* @param array $data
|
|
|
* @param int $code
|
|
|
* @param string $msg
|
|
|
* @param int $result_code
|
|
|
* @param string $type
|
|
|
*/
|
|
|
public function responseA($data = [], $code = 200, $msg = 'success', $result_code = 200, $type = 'application/json')
|
|
|
{
|
|
|
$result = [
|
|
|
'msg' => $msg,
|
|
|
'code' => $code,
|
|
|
'data' => $data,
|
|
|
];
|
|
|
$header = [
|
|
|
'Content-Type' => $type,
|
|
|
];
|
|
|
$response = response($result, $result_code, $header);
|
|
|
throw new HttpResponseException($response);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 响应
|
|
|
* @param null $msg
|
|
|
* @param string $code
|
|
|
* @param int $code
|
|
|
* @param array $data
|
|
|
* @param int $result_code
|
|
|
* @param string $type
|
|
|
* @return JsonResponse
|
|
|
* @return void
|
|
|
*/
|
|
|
public function response($msg = null,string $code = self::SUCCESS,$data = [],$result_code = 200,$type = 'application/json'): JsonResponse
|
|
|
public function response($msg = null,$code = self::SUCCESS,$data = [],$result_code = 200,$type = 'application/json')
|
|
|
{
|
|
|
$result = [
|
|
|
'msg' => $msg,
|
...
|
...
|
@@ -98,8 +119,10 @@ public function curlGet($url){ |
|
|
|
|
|
/**
|
|
|
* A端上传验证代码
|
|
|
* @param Request $request
|
|
|
* @return string
|
|
|
*/
|
|
|
public function uploadVerifyFile(Request $request): string
|
|
|
public function uploadVerifyFile(Request $request)
|
|
|
{
|
|
|
$domain = $request->getHost();
|
|
|
$files = $request->allFiles();
|
...
|
...
|
@@ -117,7 +140,7 @@ public function uploadVerifyFile(Request $request): string |
|
|
* @param Request $request
|
|
|
* @return string
|
|
|
*/
|
|
|
public function uploadAmpVerifyFile(Request $request): string
|
|
|
public function uploadAmpVerifyFile(Request $request)
|
|
|
{
|
|
|
$domain = $request->getHost();
|
|
|
|
...
|
...
|
@@ -156,7 +179,6 @@ public function websiteHtml(Request $request){ |
|
|
$requestUrl = $apiUrl."?domain=".$domain."&token=".$token;
|
|
|
@file_put_contents(storage_path('logs/notify_get_url.log'), date('Y-m-d H:i:s') . "接收到通知:". $requestUrl . PHP_EOL, FILE_APPEND);
|
|
|
|
|
|
|
|
|
try {
|
|
|
$res = $this->curlGet($requestUrl);
|
|
|
$url = isset($res["data"]["url"]) && !empty($res["data"]["url"]) ? urldecode($res["data"]["url"]) : "";
|
...
|
...
|
@@ -170,11 +192,12 @@ public function websiteHtml(Request $request){ |
|
|
return $this->websiteHtmlHandle($url,$domain);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 网站html解压
|
|
|
* @param $url
|
|
|
* @return string
|
|
|
*/
|
|
|
/**
|
|
|
* 网站html解压
|
|
|
* @param $url
|
|
|
* @param $domain
|
|
|
* @return string
|
|
|
*/
|
|
|
public function websiteHtmlHandle($url,$domain)
|
|
|
{
|
|
|
$pathInfo = pathinfo($url);
|
...
|
...
|
@@ -237,7 +260,7 @@ public function downLoadFile($url){ |
|
|
* @param $path
|
|
|
* @return bool
|
|
|
*/
|
|
|
public function deleteDirectory($path): bool
|
|
|
public function deleteDirectory($path)
|
|
|
{
|
|
|
if (!is_dir($path)) {
|
|
|
try {
|
...
|
...
|
@@ -265,31 +288,156 @@ public function deleteDirectory($path): bool |
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 客户访问埋点接口
|
|
|
* @param Request $request
|
|
|
* @return JsonResponse
|
|
|
*/
|
|
|
public function customerVisit(Request $request)
|
|
|
{
|
|
|
$data = $request->all();
|
|
|
$data["referrer_url"] = !empty($data["referrer_url"]) ? $data["referrer_url"] : "";
|
|
|
$data["url"] = !empty($data["url"]) ? $data["url"] : "";
|
|
|
$data["domain"] = !empty($data["domain"]) ? $data["domain"] : "";
|
|
|
$data["ip"] = $request->getClientIp();
|
|
|
$data["user_agent"] = $request->userAgent();
|
|
|
if (empty($data["referrer_url"]) || empty($data["url"]) || empty($data["domain"])){
|
|
|
return response()->json([
|
|
|
'code' => self::SUCCESS,
|
|
|
'msg' => 'success',
|
|
|
]);
|
|
|
}
|
|
|
|
|
|
//转发data
|
|
|
|
|
|
//埋点成功
|
|
|
return response()->json([
|
|
|
'code' => self::SUCCESS,
|
|
|
'msg' => 'success',
|
|
|
]);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 接口
|
|
|
* @param Request $request
|
|
|
* @return string
|
|
|
*/
|
|
|
public function trafficVisit(Request $request)
|
|
|
{
|
|
|
//获取参数
|
|
|
$data = $request->all();
|
|
|
$data["id"] = $request->input('ip');
|
|
|
$data["url"] = $request->input('url');
|
|
|
$data["device_port"] = intval($request->input('device_port'));
|
|
|
$data["referrer_url"] = $request->input('referrer_url');
|
|
|
$data["user_agent"] = $request->input('user_agent');
|
|
|
if (empty($data["id"]) || empty($data["url"]) || empty($data["referrer_url"]) || empty($data["user_agent"])){
|
|
|
return response()->json([
|
|
|
'code' => self::SUCCESS,
|
|
|
'msg' => 'success',
|
|
|
]);
|
|
|
}
|
|
|
|
|
|
//转发data
|
|
|
|
|
|
//成功
|
|
|
return response()->json([
|
|
|
'code' => self::SUCCESS,
|
|
|
'msg' => 'success',
|
|
|
]);
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* C端表单提交 询盘信息
|
|
|
* @param Request $request
|
|
|
* @return mixed
|
|
|
*/
|
|
|
public function inquiry(Request $request)
|
|
|
{
|
|
|
$data = $request->all();
|
|
|
|
|
|
$black_ips = ['203.86.233.27', '37.19.221.202'];
|
|
|
if(in_array(request()->getClientIp(), $black_ips)){
|
|
|
$this->success();
|
|
|
}
|
|
|
|
|
|
//同一ip 5秒内超过5次 限制1小时
|
|
|
$ip = $request->ip();
|
|
|
$lock_key = 'lock_ip_' . $ip;
|
|
|
$rate_key = 'rate_limit:' . $ip;
|
|
|
if(Cache::has($lock_key)){
|
|
|
$this->success();
|
|
|
}
|
|
|
if (Cache::has($rate_key)) {
|
|
|
$count = Cache::get($rate_key);
|
|
|
if ($count >= 5) {
|
|
|
Cache::put($lock_key, 1, 3600);
|
|
|
$this->success();
|
|
|
}
|
|
|
Cache::increment($rate_key);
|
|
|
} else {
|
|
|
Cache::put($rate_key, 1, 5);
|
|
|
}
|
|
|
|
|
|
$data["files"] = $request->allFiles();
|
|
|
|
|
|
//转发data
|
|
|
//返回数据
|
|
|
$res = "";
|
|
|
|
|
|
return $this->responseA($res);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 收集邮箱或者手机号等其他信息
|
|
|
* @param Request $request
|
|
|
* @return mixed
|
|
|
*/
|
|
|
public function inquiryOtherInfo(Request $request)
|
|
|
{
|
|
|
return $this->inquiry($request);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 起点表单询盘
|
|
|
* @param Request $request
|
|
|
* @return void
|
|
|
*/
|
|
|
public function inquiryQd(Request $request){
|
|
|
$data = $request->post();
|
|
|
$data['submit_ip'] = $data['submit_ip'] ? $data['submit_ip'] : '';
|
|
|
$data['submit_time'] = $data['submit_time'] ? $data['submit_time'] : '';
|
|
|
$data['refer'] = $data['refer'] ? $data['refer'] : '';
|
|
|
|
|
|
//转发data
|
|
|
//返回数据
|
|
|
$res = "";
|
|
|
|
|
|
return $this->responseA($res);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 搜索
|
|
|
* @param Request $request
|
|
|
*/
|
|
|
public function search(Request $request)
|
|
|
{
|
|
|
$project = $request->get('project');
|
|
|
$data = $request->all();
|
|
|
|
|
|
//获取搜索参数
|
|
|
$searchContent = '';
|
|
|
$data["search_content"] = '';
|
|
|
if (isset($data['s'])) {
|
|
|
$searchContent = $data['s'];
|
|
|
$data["search_content"] = $searchContent = $data['s'];
|
|
|
}
|
|
|
if (isset($data['search'])) {
|
|
|
$searchContent = $data['search'];
|
|
|
$data["search_content"] = $data['search'];
|
|
|
}
|
|
|
|
|
|
$page = 1;
|
|
|
if (isset($data['page']) && (int)$data['page'] > 1) {
|
|
|
$page = (int)$data['page'];
|
|
|
}
|
|
|
$data["page"] = isset($data['page']) && (int)$data['page'] > 1 ? (int)$data['page'] : 1;
|
|
|
|
|
|
// $htmlService = new HtmlService();
|
|
|
//转发data
|
|
|
|
|
|
|
|
|
// return $htmlService->getSearchHtml($project, $data, $searchContent, $page);
|
|
|
}
|
|
|
} |
...
|
...
|
|