|
|
|
|
@@ -85,7 +85,10 @@ class ApiController extends Controller {
|
|
|
|
|
$ip = "https://dev-dc.beetai.com";
|
|
|
|
|
if ($server_ip)
|
|
|
|
|
$ip = $server_ip->data;
|
|
|
|
|
if ($this->is_connected() && $logs) {
|
|
|
|
|
$parseUrl = parse_url($ip);
|
|
|
|
|
$host = $parseUrl['host'];
|
|
|
|
|
$port = isset($parseUrl['port']) ? $parseUrl['port'] : 80;
|
|
|
|
|
if ($this->is_connected($host, $port) && $logs) {
|
|
|
|
|
$device_id = \app\models\SyncUrl::findOne(['key_config' => 'device_id']);
|
|
|
|
|
$id_camera = 0;
|
|
|
|
|
if ($device_id)
|
|
|
|
|
@@ -104,33 +107,17 @@ class ApiController extends Controller {
|
|
|
|
|
$data[] = "123"; //person_id
|
|
|
|
|
$data[] = "+7"; //timezone
|
|
|
|
|
$text = implode("|", $data);
|
|
|
|
|
$res = json_decode(file_get_contents($ip . "/api/oem/face_recognition?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' => [
|
|
|
|
|
'header' => "Content-Type: application/json",
|
|
|
|
|
'method' => "POST",
|
|
|
|
|
'content' => json_encode([
|
|
|
|
|
'image' => base64_encode(file_get_contents("/var/www/html/BiFace_Server_Lite/web/data/uploads/face/" . $fileName)),
|
|
|
|
|
'camera_id' => strval($id_camera),
|
|
|
|
|
'frametime' => date("Y-m-d H:i:s", $time),
|
|
|
|
|
'idCard' => $staffInfo ? strval($staffInfo->code) : "0",
|
|
|
|
|
'idObject' => $staffInfo ? $staffInfo->staff_id : "",
|
|
|
|
|
"person_id" => "123",
|
|
|
|
|
"timezone" => "+7",
|
|
|
|
|
'data' => common::rsaEncode($text),
|
|
|
|
|
'confidence' => isset($post["confidence"]["percent1"]) ? $post["confidence"]["percent1"] : 0
|
|
|
|
|
])
|
|
|
|
|
]
|
|
|
|
|
])), true);
|
|
|
|
|
// $res = json_decode(file_get_contents($ip . "/api/box/face_recognition_auth_v2?token=" . $tk, false, stream_context_create([
|
|
|
|
|
// 'http' => [
|
|
|
|
|
// 'header' => "Content-Type: application/json",
|
|
|
|
|
// 'method' => "POST",
|
|
|
|
|
// 'content' => json_encode([
|
|
|
|
|
// 'image' => base64_encode(file_get_contents("/var/www/html/BiFace_Server_Lite/web/data/uploads/face/" . $fileName)),
|
|
|
|
|
// 'data' => common::rsaEncode($text),
|
|
|
|
|
// 'confidence' => isset($post["confidence"]["percent1"]) ? $post["confidence"]["percent1"] : 0
|
|
|
|
|
// ])
|
|
|
|
|
// ]
|
|
|
|
|
// ])), true);
|
|
|
|
|
if ($res['status'] == 10000) {
|
|
|
|
|
$logsInfo->sync_status = 1;
|
|
|
|
|
$logsInfo->save();
|
|
|
|
|
@@ -353,17 +340,19 @@ class ApiController extends Controller {
|
|
|
|
|
|
|
|
|
|
public function actionSync() {
|
|
|
|
|
Yii::$app->response->format = "json";
|
|
|
|
|
if ($this->is_connected()) {
|
|
|
|
|
$server_ip = \app\models\SyncUrl::findOne(['key_config' => 'server_api']);
|
|
|
|
|
$ip = "https://dev-dc.beetai.com";
|
|
|
|
|
if ($server_ip)
|
|
|
|
|
$ip = $server_ip->data;
|
|
|
|
|
$parseUrl = parse_url($ip);
|
|
|
|
|
$host = $parseUrl['host'];
|
|
|
|
|
$port = isset($parseUrl['port']) ? $parseUrl['port'] : 80;
|
|
|
|
|
if ($this->is_connected($host, $port)) {
|
|
|
|
|
$device_id = \app\models\SyncUrl::findOne(['key_config' => 'device_id']);
|
|
|
|
|
$id_camera = 0;
|
|
|
|
|
if ($device_id)
|
|
|
|
|
$id_camera = intval($device_id->data);
|
|
|
|
|
$ls = CaptureLogs::find()->andWhere(['sync_status' => null])->all();
|
|
|
|
|
|
|
|
|
|
$tk = "";
|
|
|
|
|
$token = \app\models\SyncUrl::findOne(['key_config' => 'token']);
|
|
|
|
|
if ($token)
|
|
|
|
|
@@ -400,9 +389,9 @@ class ApiController extends Controller {
|
|
|
|
|
return ["status" => true];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function is_connected($ip = "google.com") {
|
|
|
|
|
$connected = @fsockopen($ip, 80);
|
|
|
|
|
//website, port (try 80 or 443)
|
|
|
|
|
function is_connected($host, $port) {
|
|
|
|
|
$connected = @fsockopen($host, $port);
|
|
|
|
|
//website, port (try 80 or 443)
|
|
|
|
|
if ($connected) {
|
|
|
|
|
$is_conn = true; //action when connected
|
|
|
|
|
fclose($connected);
|
|
|
|
|
|