...
|
...
|
@@ -63,14 +63,14 @@ protected function error($message = 'error', $status = 400, $data = []) |
|
|
|
|
|
/**
|
|
|
* 响应
|
|
|
* @param null $msg
|
|
|
* @param string $msg
|
|
|
* @param int $code
|
|
|
* @param array $data
|
|
|
* @param int $result_code
|
|
|
* @param string $type
|
|
|
* @return void
|
|
|
*/
|
|
|
public function response($msg = null, $code = self::SUCCESS, $data = [], $result_code = 200, $type = 'application/json')
|
|
|
public function response($msg = 'success', $code = self::SUCCESS, $data = [], $result_code = 200, $type = 'application/json')
|
|
|
{
|
|
|
$result = [
|
|
|
'msg' => $msg,
|
...
|
...
|
@@ -256,7 +256,8 @@ public function websiteHtml(Request $request) |
|
|
* 文案
|
|
|
* @param Request $request
|
|
|
*/
|
|
|
public function getRandInquiryText(Request $request){
|
|
|
public function getRandInquiryText(Request $request)
|
|
|
{
|
|
|
//IP限流+验证参数
|
|
|
$this->limitIp($request);
|
|
|
|
...
|
...
|
@@ -266,7 +267,7 @@ public function getRandInquiryText(Request $request){ |
|
|
} catch (\Exception $e) {
|
|
|
$resStr = $e->getMessage();
|
|
|
}
|
|
|
$this->response("ok",self::SUCCESS,$resStr);
|
|
|
$this->response("ok", self::SUCCESS, $resStr);
|
|
|
return;
|
|
|
}
|
|
|
|
...
|
...
|
@@ -275,7 +276,8 @@ public function getRandInquiryText(Request $request){ |
|
|
* @param Request $request
|
|
|
* @return string
|
|
|
*/
|
|
|
public function pullCode(Request $request){
|
|
|
public function pullCode(Request $request)
|
|
|
{
|
|
|
$command = "cd /www/wwwroot/self_site && ./pull_custom_code.sh";
|
|
|
shell_exec($command);
|
|
|
return $this->success();
|
...
|
...
|
@@ -285,7 +287,8 @@ public function pullCode(Request $request){ |
|
|
* @param $url
|
|
|
* @return bool|string
|
|
|
*/
|
|
|
public function httpGet($url){
|
|
|
public function httpGet($url)
|
|
|
{
|
|
|
$ch1 = curl_init();
|
|
|
$timeout = 0;
|
|
|
curl_setopt($ch1, CURLOPT_URL, $url);
|
...
|
...
|
@@ -449,22 +452,22 @@ public function deleteDirectory($path) |
|
|
* @param $request
|
|
|
* @param string $type
|
|
|
* @param int $traffic
|
|
|
* @return string
|
|
|
* @return string|void
|
|
|
*/
|
|
|
public function transmit($request, $type = self::TYPEVISIT, $traffic = self::TRAFFICZERO)
|
|
|
{
|
|
|
if ($request->getClientIp() == "127.0.0.1") {
|
|
|
return $this->success();
|
|
|
$this->response();
|
|
|
}
|
|
|
//判断是否是爬虫
|
|
|
$isReptile = $this->isReptile($request);
|
|
|
if ($isReptile) {
|
|
|
return $this->success();
|
|
|
$this->response();
|
|
|
}
|
|
|
|
|
|
$data = $request->all();
|
|
|
if (empty($data)) {
|
|
|
return $this->success();
|
|
|
$this->response();
|
|
|
}
|
|
|
$data["device_port"] = $this->userAgentHandle($request->userAgent(), $data["device_port"] ?? self::DEVICE_PORT_ONE);
|
|
|
$req["data"] = $data;
|
...
|
...
|
@@ -484,14 +487,14 @@ public function transmit($request, $type = self::TYPEVISIT, $traffic = self::TRA |
|
|
//转发接口
|
|
|
$transmitUrl = env("TRANSMIT_URL");
|
|
|
$resp = $this->httpPost($transmitUrl . "api/selfSiteApi/", json_encode($req));
|
|
|
if (($resp["status"]??0) != self::SUCCESS) {
|
|
|
if (($resp["status"] ?? 0) != self::SUCCESS) {
|
|
|
$dataJson = json_encode($req);
|
|
|
if (!file_exists(storage_path('logs/fail_req'))) {
|
|
|
mkdir(storage_path('logs/fail_req', 0777, true));
|
|
|
}
|
|
|
@file_put_contents(storage_path('logs/fail_req/' . date('Y-m-d') . '.log'), var_export($dataJson, true) . PHP_EOL, FILE_APPEND);
|
|
|
}
|
|
|
return $this->success($resp['data']??[]);
|
|
|
$this->response("success", self::SUCCESS, $resp["data"] ?? []);
|
|
|
}
|
|
|
|
|
|
/**
|
...
|
...
|
|