2 Commits

Author SHA1 Message Date
ac5d003600 Update controllers/ListManagementController.php 2023-07-05 03:19:10 +00:00
4b4f33777c custom fsi 2023-01-04 17:00:39 +07:00
13 changed files with 65 additions and 206 deletions

View File

@@ -6,7 +6,5 @@ return [
"maxLogs" => 50000, "maxLogs" => 50000,
"maxPicture" => 9999, "maxPicture" => 9999,
"version" => "1.0.7", "version" => "1.0.7",
"autoSyncLog" => false, "autoSyncLog" => false
"timeoutRequestServer" => 4,
"test" => 6
]; ];

View File

@@ -58,7 +58,6 @@ class ApiController extends Controller {
public function actionGetLogs() { public function actionGetLogs() {
if (Yii::$app->request->post()) { if (Yii::$app->request->post()) {
Yii::$app->response->format = "json";
$post = Yii::$app->request->bodyParams; $post = Yii::$app->request->bodyParams;
$time = date_format(date_create_from_format('Y-m-d H:i:s', $post['time']), 'U'); $time = date_format(date_create_from_format('Y-m-d H:i:s', $post['time']), 'U');
$key = common::generateRandomString(); $key = common::generateRandomString();
@@ -74,11 +73,6 @@ class ApiController extends Controller {
@unlink("/var/www/html/BiFace_Server_Lite/web/data/uploads/face/" . $lastLogs->image); @unlink("/var/www/html/BiFace_Server_Lite/web/data/uploads/face/" . $lastLogs->image);
$lastLogs->delete(); $lastLogs->delete();
} }
$lastLogs = CaptureLogs::find()->andWhere(["staff_id" => $post['id']])->orderBy(["time" => SORT_DESC])->limit(1)->one();
if ($lastLogs && ($time - $lastLogs->time) < 1) {
file_put_contents("log_connect_server.txt", "\n[" . date("H:i:s d/m/Y") . "] duplicate face " . $post["id"], FILE_APPEND);
return ["status" => "success"];
}
$model = new CaptureLogs(); $model = new CaptureLogs();
$logs = $model->create([ $logs = $model->create([
@@ -91,10 +85,7 @@ class ApiController extends Controller {
$ip = "https://dev-dc.beetai.com"; $ip = "https://dev-dc.beetai.com";
if ($server_ip) if ($server_ip)
$ip = $server_ip->data; $ip = $server_ip->data;
$parseUrl = parse_url($ip); if ($this->is_connected() && $logs) {
$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']); $device_id = \app\models\SyncUrl::findOne(['key_config' => 'device_id']);
$id_camera = 0; $id_camera = 0;
if ($device_id) if ($device_id)
@@ -113,25 +104,39 @@ 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/oem/face_recognition?token=" . $tk, false, stream_context_create([
'http' => [ 'http' => [
'timeout' => Yii::$app->params['timeoutRequestServer'],
'header' => "Content-Type: application/json", 'header' => "Content-Type: application/json",
'method' => "POST", 'method' => "POST",
'content' => json_encode([ 'content' => json_encode([
'image' => base64_encode(file_get_contents("/var/www/html/BiFace_Server_Lite/web/data/uploads/face/" . $fileName)), 'image' => base64_encode(file_get_contents("/var/www/html/BiFace_Server_Lite/web/data/uploads/face/" . $fileName)),
'data' => common::rsaEncode($text), '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",
'confidence' => isset($post["confidence"]["percent1"]) ? $post["confidence"]["percent1"] : 0 'confidence' => isset($post["confidence"]["percent1"]) ? $post["confidence"]["percent1"] : 0
]) ])
] ]
])), true); ])), true);
if ($res && $res['status'] == 10000) { // $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->sync_status = 1;
$logsInfo->save(); $logsInfo->save();
} else {
file_put_contents("log_connect_server.txt", "\n[" . date("H:i:s d/m/Y") . "] /api/box/face_recognition_auth_v2 timeout " . $ip, FILE_APPEND);
} }
} }
Yii::$app->response->format = "json";
return ["status" => "success"]; return ["status" => "success"];
} }
} }
@@ -348,19 +353,17 @@ class ApiController extends Controller {
public function actionSync() { public function actionSync() {
Yii::$app->response->format = "json"; Yii::$app->response->format = "json";
if ($this->is_connected()) {
$server_ip = \app\models\SyncUrl::findOne(['key_config' => 'server_api']); $server_ip = \app\models\SyncUrl::findOne(['key_config' => 'server_api']);
$ip = "https://dev-dc.beetai.com"; $ip = "https://dev-dc.beetai.com";
if ($server_ip) if ($server_ip)
$ip = $server_ip->data; $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']); $device_id = \app\models\SyncUrl::findOne(['key_config' => 'device_id']);
$id_camera = 0; $id_camera = 0;
if ($device_id) if ($device_id)
$id_camera = intval($device_id->data); $id_camera = intval($device_id->data);
$ls = CaptureLogs::find()->andWhere(['sync_status' => null])->all(); $ls = CaptureLogs::find()->andWhere(['sync_status' => null])->all();
$tk = ""; $tk = "";
$token = \app\models\SyncUrl::findOne(['key_config' => 'token']); $token = \app\models\SyncUrl::findOne(['key_config' => 'token']);
if ($token) if ($token)
@@ -369,31 +372,25 @@ class ApiController extends Controller {
if (file_exists("/var/www/html/BiFace_Server_Lite/web/data/uploads/face/" . $value->image)) { if (file_exists("/var/www/html/BiFace_Server_Lite/web/data/uploads/face/" . $value->image)) {
$staffInfo = ListManagement::findOne($value->staff_id); $staffInfo = ListManagement::findOne($value->staff_id);
$confidence = json_decode($value->confidence, true); $confidence = json_decode($value->confidence, true);
$data = []; $res = json_decode(file_get_contents($ip . "/api/oem/face_recognition?token=" . $tk, false, stream_context_create([
$data[] = strval($id_camera); //camera_id
$data[] = date("Y-m-d H:i:s", $value->time); //frametime
$data[] = $staffInfo ? strval($staffInfo->code) : "0"; //idCard
$data[] = $staffInfo ? $staffInfo->staff_id : ""; //idObject
$data[] = "123"; //person_id
$data[] = "+7"; //timezone
$text = implode("|", $data);
$res = json_decode(@file_get_contents($ip . "/api/box/face_recognition_auth_v2?token=" . $tk, false, stream_context_create([
'http' => [ 'http' => [
'timeout' => Yii::$app->params['timeoutRequestServer'],
'header' => "Content-Type: application/json", 'header' => "Content-Type: application/json",
'method' => "POST", 'method' => "POST",
'content' => json_encode([ 'content' => json_encode([
'image' => base64_encode(file_get_contents("/var/www/html/BiFace_Server_Lite/web/data/uploads/face/" . $value->image)), 'image' => base64_encode(file_get_contents("/var/www/html/BiFace_Server_Lite/web/data/uploads/face/" . $value->image)),
'data' => common::rsaEncode($text), 'camera_id' => strval($id_camera),
'frametime' => date("Y-m-d H:i:s", $value->time),
'idCard' => $staffInfo ? strval($staffInfo->code) : "0",
'idObject' => $staffInfo ? $staffInfo->staff_id : "",
"person_id" => "123",
"timezone" => "+7",
'confidence' => isset($confidence['percent1']) ? floatval($confidence['percent1']) : 0 'confidence' => isset($confidence['percent1']) ? floatval($confidence['percent1']) : 0
]) ])
] ]
])), true); ])), true);
if ($res && $res['status'] == 10000) { if ($res['status'] == 10000) {
$value->sync_status = 1; $value->sync_status = 1;
$value->save(); $value->save();
} else {
file_put_contents("log_connect_server.txt", "\n[" . date("H:i:s d/m/Y") . "][SYNC] face_recognition_auth_v2 timeout " . $ip, FILE_APPEND);
} }
} else { } else {
$value->delete(); $value->delete();
@@ -403,16 +400,14 @@ class ApiController extends Controller {
return ["status" => true]; return ["status" => true];
} }
function is_connected($host, $port) { function is_connected($ip = "google.com") {
$connected = @fsockopen($host, $port); $connected = @fsockopen($ip, 80);
//website, port (try 80 or 443) //website, port (try 80 or 443)
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;
} }
@@ -507,14 +502,12 @@ class ApiController extends Controller {
} }
public function actionTest() { public function actionTest() {
$server_ip = \app\models\SyncUrl::findOne(['key_config' => 'server_api']); // $updating = \app\models\SyncUrl::findOne(['key_config' => 'token']);
$ip = "https://dev-dc.beetai.com"; $updating = \app\models\SyncUrl::find()->all();
if ($server_ip) foreach ($updating as $key => $value) {
$ip = $server_ip->data; echo $value->key_config . " " . $value->data . "<br>";
$parseUrl = parse_url($ip); }
$host = $parseUrl['host']; exit();
$port = isset($parseUrl['port']) ? $parseUrl['port'] : 80;
$this->is_connected($host, $port);
} }
public function actionReGenFeature() { public function actionReGenFeature() {

View File

@@ -563,29 +563,4 @@ class ConfigController extends Controller {
} }
} }
public function actionSystemInfo() {
if (Yii::$app->request->isAjax) {
Yii::$app->response->format = "json";
$options = [
'http' => [
'header' => "Content-Type: application/json",
'method' => "POST"
]
];
@file_get_contents("http://localhost:4004/Reboot", false, stream_context_create($options));
return ["status" => true];
} else {
$this->view->title = Yii::t("app", "THONG_TIN_HE_THONG");
$version = \app\models\SyncUrl::findOne(['key_config' => 'version']);
$info = $version ? $version->data : "Pro 4.27.13 (Jul 19 2021 11:49)";
$temp = explode("(", $info);
$ver = trim($temp[0]);
$build_time = str_replace(")", "", $temp[1]);
return $this->render('system-info', [
"version" => $ver,
"build_time" => $build_time
]);
}
}
} }

BIN
db/app.db Executable file → Normal file

Binary file not shown.

View File

@@ -160,8 +160,5 @@ return [
"XOA_LICH_TRINH" => "Delete schedule", "XOA_LICH_TRINH" => "Delete schedule",
"BAN_CO_CHAC_CHAN_MUON_XOA_LICH_TRINH_NAY_KHONG" => "Are you sure you want to delete this schedule?", "BAN_CO_CHAC_CHAN_MUON_XOA_LICH_TRINH_NAY_KHONG" => "Are you sure you want to delete this schedule?",
"SO_SANH_MAT" => "Face comparison", "SO_SANH_MAT" => "Face comparison",
"BAN_CO_CHAC_CHAN_MUON_DOI_IP_KHONG" => "Are you sure you want to change the device's IP address?", "BAN_CO_CHAC_CHAN_MUON_DOI_IP_KHONG" => "Are you sure you want to change the device's IP address?"
"THONG_TIN_HE_THONG" => "System Information",
"REBOOT" => "Reboot",
"BAN_CO_CHAC_CHAN_MUON_REBOOT_KHONG" => "Are you sure you want to reboot?"
]; ];

View File

@@ -160,8 +160,5 @@ return [
"XOA_LICH_TRINH" => "スケジュールを削除", "XOA_LICH_TRINH" => "スケジュールを削除",
"BAN_CO_CHAC_CHAN_MUON_XOA_LICH_TRINH_NAY_KHONG" => "このスケジュールを削除してもよろしいですか?", "BAN_CO_CHAC_CHAN_MUON_XOA_LICH_TRINH_NAY_KHONG" => "このスケジュールを削除してもよろしいですか?",
"SO_SANH_MAT" => "顔比較", "SO_SANH_MAT" => "顔比較",
"BAN_CO_CHAC_CHAN_MUON_DOI_IP_KHONG" => "デバイスの IP アドレスを変更してもよろしいですか?", "BAN_CO_CHAC_CHAN_MUON_DOI_IP_KHONG" => "デバイスの IP アドレスを変更してもよろしいですか?"
"THONG_TIN_HE_THONG" => "システムインフォメーション",
"REBOOT" => "リブート",
"BAN_CO_CHAC_CHAN_MUON_REBOOT_KHONG" => "再起動してもよろしいですか?"
]; ];

View File

@@ -160,8 +160,5 @@ return [
"XOA_LICH_TRINH" => "Xóa lịch trình", "XOA_LICH_TRINH" => "Xóa lịch trình",
"BAN_CO_CHAC_CHAN_MUON_XOA_LICH_TRINH_NAY_KHONG" => "Bạn có chắc chắn muốn xóa lịch trình này không?", "BAN_CO_CHAC_CHAN_MUON_XOA_LICH_TRINH_NAY_KHONG" => "Bạn có chắc chắn muốn xóa lịch trình này không?",
"SO_SANH_MAT" => "So sánh mặt", "SO_SANH_MAT" => "So sánh mặt",
"BAN_CO_CHAC_CHAN_MUON_DOI_IP_KHONG" => "Bạn có chắc chắn muốn thay đổi địa chỉ IP của thiết bị không?", "BAN_CO_CHAC_CHAN_MUON_DOI_IP_KHONG" => "Bạn có chắc chắn muốn thay đổi địa chỉ IP của thiết bị không?"
"THONG_TIN_HE_THONG" => "Thông tin hệ thống",
"REBOOT" => "Khởi động lại thiết bị",
"BAN_CO_CHAC_CHAN_MUON_REBOOT_KHONG" => "Bạn có chắc chắn muốn khởi động lại thiết bị không?"
]; ];

0
runtime/temp.txt Executable file → Normal file
View File

View File

@@ -36,7 +36,7 @@ use yii\widgets\ActiveForm;
<!-- Collect the nav links, forms, and other content for toggling --> <!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse pull-left" id="navbar-collapse"> <div class="collapse navbar-collapse pull-left" id="navbar-collapse">
<ul class="nav navbar-nav"> <ul class="nav navbar-nav">
<li class="<?php if (Yii::$app->controller->id == "config" && Yii::$app->controller->action->id != "system-info") echo "active"; ?>"> <li class="<?php if (Yii::$app->controller->id == "config") echo "active"; ?>">
<a href="<?php echo yii\helpers\Url::to(['/config/cau-hinh-thiet-bi']); ?>"> <a href="<?php echo yii\helpers\Url::to(['/config/cau-hinh-thiet-bi']); ?>">
<i class="fa fa-cogs"></i> <?php echo Yii::t("app", "CAU_HINH"); ?> <i class="fa fa-cogs"></i> <?php echo Yii::t("app", "CAU_HINH"); ?>
</a> </a>
@@ -62,11 +62,6 @@ use yii\widgets\ActiveForm;
<li><a href="<?php echo \yii\helpers\Url::to(['/capture-logs/face-comparison']); ?>"><i class="fa fa-users"></i> <?php echo Yii::t("app", "SO_SANH_MAT"); ?></a></li> <li><a href="<?php echo \yii\helpers\Url::to(['/capture-logs/face-comparison']); ?>"><i class="fa fa-users"></i> <?php echo Yii::t("app", "SO_SANH_MAT"); ?></a></li>
</ul> </ul>
</li> </li>
<li class="<?php if (Yii::$app->controller->id == "config" && Yii::$app->controller->action->id == "system-info") echo "active"; ?>">
<a href="<?php echo yii\helpers\Url::to(['/config/system-info']); ?>">
<i class="fa fa-info-circle"></i> <?php echo Yii::t("app", "THONG_TIN_HE_THONG"); ?>
</a>
</li>
<?php } ?> <?php } ?>
</ul> </ul>
</div> </div>

View File

@@ -1,58 +0,0 @@
{extends file=$smarty.current_dir|cat:'/../extends.tpl'}
{use class="yii\helpers\Url"}
{use class="app\assets\ConfigAsset"}
{ConfigAsset::register($this)|void}
{block name='content'}
<style>
.input-group-addon{
width: 120px;
font-weight: bold;
}
.input-group{
width: 100%;
}
.table-striped > tbody > tr:nth-of-type(odd) {
background-color: #d1d1d1;
}
</style>
<div class="container-fluid">
<br>
<div class="row">
<div class="col-md-3 col-md-push-1">
<table class="table table-bordered table-striped" style="background: #fff;">
<thead>
<tr style="background-color: #3c8dbc;color:#fff;">
<th colspan="2">{Yii::t("app", "THONG_TIN_HE_THONG")|upper}</th>
</tr>
</thead>
<tbody>
<tr>
<th>CPU</th>
<td>ARM Mali-450 penta-core</td>
</tr>
<tr>
<th>MemTotal</th>
<td>2.0 GiB</td>
</tr>
<tr>
<th>DiskTotal</th>
<td>16.0 GiB</td>
</tr>
<tr>
<th>Software version number</th>
<td>{$version}</td>
</tr>
<tr>
<th>Build time</th>
<td>{$build_time}</td>
</tr>
</tbody>
</table>
<button class="btn btn-danger" onclick="reboot(this);" data-href="{Url::to(['system-info'])}">
<i class="fa fa-refresh"></i> {Yii::t("app","REBOOT")}
</button>
</div>
</div>
</div>
</div>
{/block}

View File

@@ -33,8 +33,6 @@
<input type="hidden" name="HAY_CHON_DOI_TUONG_DE_GAN_LICH_TRINH" value="{Yii::t("app", "HAY_CHON_DOI_TUONG_DE_GAN_LICH_TRINH")}"> <input type="hidden" name="HAY_CHON_DOI_TUONG_DE_GAN_LICH_TRINH" value="{Yii::t("app", "HAY_CHON_DOI_TUONG_DE_GAN_LICH_TRINH")}">
<input type="hidden" name="BAN_CO_CHAC_CHAN_MUON_XOA_LICH_TRINH_NAY_KHONG" value="{Yii::t("app", "BAN_CO_CHAC_CHAN_MUON_XOA_LICH_TRINH_NAY_KHONG")}"> <input type="hidden" name="BAN_CO_CHAC_CHAN_MUON_XOA_LICH_TRINH_NAY_KHONG" value="{Yii::t("app", "BAN_CO_CHAC_CHAN_MUON_XOA_LICH_TRINH_NAY_KHONG")}">
<input type="hidden" name="BAN_CO_CHAC_CHAN_MUON_DOI_IP_KHONG" value="{Yii::t("app", "BAN_CO_CHAC_CHAN_MUON_DOI_IP_KHONG")}"> <input type="hidden" name="BAN_CO_CHAC_CHAN_MUON_DOI_IP_KHONG" value="{Yii::t("app", "BAN_CO_CHAC_CHAN_MUON_DOI_IP_KHONG")}">
<input type="hidden" name="BAN_CO_CHAC_CHAN_MUON_REBOOT_KHONG" value="{Yii::t("app", "BAN_CO_CHAC_CHAN_MUON_REBOOT_KHONG")}">
<div id="blocking" class="fade modal" role="dialog" tabindex="-1"> <div id="blocking" class="fade modal" role="dialog" tabindex="-1">
<div class="modal-dialog" style="top: 50%;margin-top: -45px;"> <div class="modal-dialog" style="top: 50%;margin-top: -45px;">
@@ -49,19 +47,6 @@
</div> </div>
</div> </div>
</div> </div>
<div id="reboot-blocking" class="fade modal" role="dialog" tabindex="-1">
<div class="modal-dialog" style="top: 50%;margin-top: -45px;">
<div class="modal-content" style="background-color: transparent;box-shadow: none;">
<div class="modal-body">
<div id='modelContent' class="text-center">
<i class="fa fa-spinner fa-pulse fa-5x fa-fw" style="color: #fff;"></i>
<br>
<b style="color: #fff;font-size: 25px;">Đang khởi động lại thiết bị, vui lòng chờ trong vài phút và tải lại trang!</b>
</div>
</div>
</div>
</div>
</div>
<div id="uploadBlock" class="fade modal" role="dialog" tabindex="-1"> <div id="uploadBlock" class="fade modal" role="dialog" tabindex="-1">
<div class="modal-dialog" style="top: 50%;margin-top: -45px;"> <div class="modal-dialog" style="top: 50%;margin-top: -45px;">
<div class="modal-content" style="background-color: transparent;box-shadow: none;"> <div class="modal-content" style="background-color: transparent;box-shadow: none;">

0
web/assets/temp.txt Executable file → Normal file
View File

View File

@@ -178,23 +178,3 @@ function changeIP(e) {
}); });
} }
} }
function reboot(e) {
if (confirm($("input[name='BAN_CO_CHAC_CHAN_MUON_REBOOT_KHONG']").val())) {
$("#reboot-blocking").modal({
keyboard: false,
backdrop: false
});
$.ajax({
url: $(e).attr("data-href"),
type: 'POST',
success: function (data) {
},
error: function (jqXHR, textStatus, errorThrown) {
// $("#reboot-blocking").modal("hide");
// common.ajaxError();
}
});
}
}