fix bug exception get logs

This commit is contained in:
dongpd 2023-06-09 11:48:30 +07:00
parent 476f01098f
commit 58a5522642

View File

@ -107,7 +107,7 @@ class ApiController extends Controller {
$data[] = "123"; //person_id $data[] = "123"; //person_id
$data[] = "+7"; //timezone $data[] = "+7"; //timezone
$text = implode("|", $data); $text = implode("|", $data);
$res = json_decode(file_get_contents($ip . "/api/box/face_recognition_auth_v2?token=" . $tk, false, stream_context_create([ $res = json_decode(@file_get_contents($ip . "/api/box/face_recognition_auth_v2?token=" . $tk, false, stream_context_create([
'http' => [ 'http' => [
'header' => "Content-Type: application/json", 'header' => "Content-Type: application/json",
'method' => "POST", 'method' => "POST",
@ -118,7 +118,7 @@ class ApiController extends Controller {
]) ])
] ]
])), true); ])), true);
if ($res['status'] == 10000) { if ($res && $res['status'] == 10000) {
$logsInfo->sync_status = 1; $logsInfo->sync_status = 1;
$logsInfo->save(); $logsInfo->save();
} }
@ -395,8 +395,10 @@ class ApiController extends Controller {
if ($connected) { if ($connected) {
$is_conn = true; //action when connected $is_conn = true; //action when connected
fclose($connected); fclose($connected);
// file_put_contents("log_connect_server.txt", "\n" . date("H:i:s d/m/Y") . " connected " . $host . ":" . $port, FILE_APPEND);
} else { } else {
$is_conn = false; //action in connection failure $is_conn = false; //action in connection failure
// file_put_contents("log_connect_server.txt", "\n" . date("H:i:s d/m/Y") . " disconnected " . $host . ":" . $port, FILE_APPEND);
} }
return $is_conn; return $is_conn;
} }
@ -491,12 +493,14 @@ class ApiController extends Controller {
} }
public function actionTest() { public function actionTest() {
// $updating = \app\models\SyncUrl::findOne(['key_config' => 'token']); $server_ip = \app\models\SyncUrl::findOne(['key_config' => 'server_api']);
$updating = \app\models\SyncUrl::find()->all(); $ip = "https://dev-dc.beetai.com";
foreach ($updating as $key => $value) { if ($server_ip)
echo $value->key_config . " " . $value->data . "<br>"; $ip = $server_ip->data;
} $parseUrl = parse_url($ip);
exit(); $host = $parseUrl['host'];
$port = isset($parseUrl['port']) ? $parseUrl['port'] : 80;
$this->is_connected($host, $port);
} }
public function actionReGenFeature() { public function actionReGenFeature() {