作者 李小龙

失败数据存入日志,后期取

... ... @@ -340,7 +340,6 @@ public function deleteDirectory($path)
* @return string
*/
public function transmit($request, $type = self::TYPEVISIT, $traffic = self::TRAFFICZERO){
if($request->getClientIp() == "127.0.0.1"){
return $this->success();
}
... ... @@ -363,10 +362,21 @@ public function transmit($request, $type = self::TYPEVISIT, $traffic = self::TRA
$req["files"] = isset($data["files"]) ? $data["files"] : null;
$req["type"] = $type;
$req["traffic"] = $traffic;
$req["timestamp"] = time();
//转发接口
$transmitUrl = env("TRANSMIT_URL");
return $this->httpPost($transmitUrl."api/selfSiteApi/",json_encode($req));
$resp = $this->httpPost($transmitUrl."api/selfSiteApi/",json_encode($req));
if ($resp["code"] == self::SUCCESS){
return $resp;
}else{
$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();
}
/**
... ...