Merge branch 'master' of http://47.244.231.31:8099/zhl/globalso-v6-c-customer
正在显示
1 个修改的文件
包含
15 行增加
和
17 行删除
@@ -63,14 +63,14 @@ protected function error($message = 'error', $status = 400, $data = []) | @@ -63,14 +63,14 @@ protected function error($message = 'error', $status = 400, $data = []) | ||
63 | 63 | ||
64 | /** | 64 | /** |
65 | * 响应 | 65 | * 响应 |
66 | - * @param null $msg | 66 | + * @param string $msg |
67 | * @param int $code | 67 | * @param int $code |
68 | * @param array $data | 68 | * @param array $data |
69 | * @param int $result_code | 69 | * @param int $result_code |
70 | * @param string $type | 70 | * @param string $type |
71 | * @return void | 71 | * @return void |
72 | */ | 72 | */ |
73 | - public function response($msg = null, $code = self::SUCCESS, $data = [], $result_code = 200, $type = 'application/json') | 73 | + public function response($msg = 'success', $code = self::SUCCESS, $data = [], $result_code = 200, $type = 'application/json') |
74 | { | 74 | { |
75 | $result = [ | 75 | $result = [ |
76 | 'msg' => $msg, | 76 | 'msg' => $msg, |
@@ -256,7 +256,8 @@ public function websiteHtml(Request $request) | @@ -256,7 +256,8 @@ public function websiteHtml(Request $request) | ||
256 | * 文案 | 256 | * 文案 |
257 | * @param Request $request | 257 | * @param Request $request |
258 | */ | 258 | */ |
259 | - public function getRandInquiryText(Request $request){ | 259 | + public function getRandInquiryText(Request $request) |
260 | + { | ||
260 | //IP限流+验证参数 | 261 | //IP限流+验证参数 |
261 | $this->limitIp($request); | 262 | $this->limitIp($request); |
262 | 263 | ||
@@ -266,7 +267,7 @@ public function getRandInquiryText(Request $request){ | @@ -266,7 +267,7 @@ public function getRandInquiryText(Request $request){ | ||
266 | } catch (\Exception $e) { | 267 | } catch (\Exception $e) { |
267 | $resStr = $e->getMessage(); | 268 | $resStr = $e->getMessage(); |
268 | } | 269 | } |
269 | - $this->response("ok",self::SUCCESS,$resStr); | 270 | + $this->response("ok", self::SUCCESS, $resStr); |
270 | return; | 271 | return; |
271 | } | 272 | } |
272 | 273 | ||
@@ -275,7 +276,8 @@ public function getRandInquiryText(Request $request){ | @@ -275,7 +276,8 @@ public function getRandInquiryText(Request $request){ | ||
275 | * @param Request $request | 276 | * @param Request $request |
276 | * @return string | 277 | * @return string |
277 | */ | 278 | */ |
278 | - public function pullCode(Request $request){ | 279 | + public function pullCode(Request $request) |
280 | + { | ||
279 | $command = "cd /www/wwwroot/self_site && ./pull_custom_code.sh"; | 281 | $command = "cd /www/wwwroot/self_site && ./pull_custom_code.sh"; |
280 | shell_exec($command); | 282 | shell_exec($command); |
281 | return $this->success(); | 283 | return $this->success(); |
@@ -285,8 +287,9 @@ public function pullCode(Request $request){ | @@ -285,8 +287,9 @@ public function pullCode(Request $request){ | ||
285 | * @param $url | 287 | * @param $url |
286 | * @return bool|string | 288 | * @return bool|string |
287 | */ | 289 | */ |
288 | - public function httpGet($url){ | ||
289 | - $ch1 = curl_init(); | 290 | + public function httpGet($url) |
291 | + { | ||
292 | + $ch1 = curl_init(); | ||
290 | $timeout = 0; | 293 | $timeout = 0; |
291 | curl_setopt($ch1, CURLOPT_URL, $url); | 294 | curl_setopt($ch1, CURLOPT_URL, $url); |
292 | curl_setopt($ch1, CURLOPT_RETURNTRANSFER, true); | 295 | curl_setopt($ch1, CURLOPT_RETURNTRANSFER, true); |
@@ -461,17 +464,17 @@ public function deleteDirectory($path) | @@ -461,17 +464,17 @@ public function deleteDirectory($path) | ||
461 | public function transmit($request, $type = self::TYPEVISIT, $traffic = self::TRAFFICZERO) | 464 | public function transmit($request, $type = self::TYPEVISIT, $traffic = self::TRAFFICZERO) |
462 | { | 465 | { |
463 | if ($request->getClientIp() == "127.0.0.1") { | 466 | if ($request->getClientIp() == "127.0.0.1") { |
464 | - return $this->success(); | 467 | + $this->response(); |
465 | } | 468 | } |
466 | //判断是否是爬虫 | 469 | //判断是否是爬虫 |
467 | $isReptile = $this->isReptile($request); | 470 | $isReptile = $this->isReptile($request); |
468 | if ($isReptile) { | 471 | if ($isReptile) { |
469 | - return $this->success(); | 472 | + $this->response(); |
470 | } | 473 | } |
471 | 474 | ||
472 | $data = $request->all(); | 475 | $data = $request->all(); |
473 | if (empty($data)) { | 476 | if (empty($data)) { |
474 | - return $this->success(); | 477 | + $this->response(); |
475 | } | 478 | } |
476 | $data["device_port"] = $this->userAgentHandle($request->userAgent(), $data["device_port"] ?? self::DEVICE_PORT_ONE); | 479 | $data["device_port"] = $this->userAgentHandle($request->userAgent(), $data["device_port"] ?? self::DEVICE_PORT_ONE); |
477 | $req["data"] = $data; | 480 | $req["data"] = $data; |
@@ -491,19 +494,14 @@ public function transmit($request, $type = self::TYPEVISIT, $traffic = self::TRA | @@ -491,19 +494,14 @@ public function transmit($request, $type = self::TYPEVISIT, $traffic = self::TRA | ||
491 | //转发接口 | 494 | //转发接口 |
492 | $transmitUrl = env("TRANSMIT_URL"); | 495 | $transmitUrl = env("TRANSMIT_URL"); |
493 | $resp = $this->httpPost($transmitUrl . "api/selfSiteApi/", json_encode($req)); | 496 | $resp = $this->httpPost($transmitUrl . "api/selfSiteApi/", json_encode($req)); |
494 | - if ($resp["status"] != self::SUCCESS) { | 497 | + if (($resp["status"] ?? 0) != self::SUCCESS) { |
495 | $dataJson = json_encode($req); | 498 | $dataJson = json_encode($req); |
496 | if (!file_exists(storage_path('logs/fail_req'))) { | 499 | if (!file_exists(storage_path('logs/fail_req'))) { |
497 | mkdir(storage_path('logs/fail_req', 0777, true)); | 500 | mkdir(storage_path('logs/fail_req', 0777, true)); |
498 | } | 501 | } |
499 | @file_put_contents(storage_path('logs/fail_req/' . date('Y-m-d') . '.log'), var_export($dataJson, true) . PHP_EOL, FILE_APPEND); | 502 | @file_put_contents(storage_path('logs/fail_req/' . date('Y-m-d') . '.log'), var_export($dataJson, true) . PHP_EOL, FILE_APPEND); |
500 | } | 503 | } |
501 | - if (isset($resp["data"])){ | ||
502 | - $this->response("success",self::SUCCESS,$resp["data"]); | ||
503 | - }else{ | ||
504 | - $this->success(); | ||
505 | - } | ||
506 | - return; | 504 | + $this->response("success", self::SUCCESS, $resp["data"] ?? []); |
507 | } | 505 | } |
508 | 506 | ||
509 | /** | 507 | /** |
-
请 注册 或 登录 后发表评论