Compare commits
2 Commits
LitePro_2.
...
custom/fsi
| Author | SHA1 | Date | |
|---|---|---|---|
| ac5d003600 | |||
| 4b4f33777c |
@@ -6,7 +6,5 @@ return [
|
||||
"maxLogs" => 50000,
|
||||
"maxPicture" => 9999,
|
||||
"version" => "1.0.7",
|
||||
"autoSyncLog" => false,
|
||||
"timeoutRequestServer" => 4,
|
||||
"test" => 6
|
||||
"autoSyncLog" => false
|
||||
];
|
||||
|
||||
@@ -58,7 +58,6 @@ class ApiController extends Controller {
|
||||
|
||||
public function actionGetLogs() {
|
||||
if (Yii::$app->request->post()) {
|
||||
Yii::$app->response->format = "json";
|
||||
$post = Yii::$app->request->bodyParams;
|
||||
$time = date_format(date_create_from_format('Y-m-d H:i:s', $post['time']), 'U');
|
||||
$key = common::generateRandomString();
|
||||
@@ -74,11 +73,6 @@ class ApiController extends Controller {
|
||||
@unlink("/var/www/html/BiFace_Server_Lite/web/data/uploads/face/" . $lastLogs->image);
|
||||
$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();
|
||||
$logs = $model->create([
|
||||
@@ -91,10 +85,7 @@ class ApiController extends Controller {
|
||||
$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) && $logs) {
|
||||
if ($this->is_connected() && $logs) {
|
||||
$device_id = \app\models\SyncUrl::findOne(['key_config' => 'device_id']);
|
||||
$id_camera = 0;
|
||||
if ($device_id)
|
||||
@@ -113,25 +104,39 @@ class ApiController extends Controller {
|
||||
$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' => [
|
||||
'timeout' => Yii::$app->params['timeoutRequestServer'],
|
||||
'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
|
||||
])
|
||||
]
|
||||
$res = json_decode(file_get_contents($ip . "/api/oem/face_recognition?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",
|
||||
'confidence' => isset($post["confidence"]["percent1"]) ? $post["confidence"]["percent1"] : 0
|
||||
])
|
||||
]
|
||||
])), 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->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"];
|
||||
}
|
||||
}
|
||||
@@ -348,19 +353,17 @@ class ApiController extends Controller {
|
||||
|
||||
public function actionSync() {
|
||||
Yii::$app->response->format = "json";
|
||||
$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)) {
|
||||
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;
|
||||
$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)
|
||||
@@ -369,31 +372,25 @@ class ApiController extends Controller {
|
||||
if (file_exists("/var/www/html/BiFace_Server_Lite/web/data/uploads/face/" . $value->image)) {
|
||||
$staffInfo = ListManagement::findOne($value->staff_id);
|
||||
$confidence = json_decode($value->confidence, true);
|
||||
$data = [];
|
||||
$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' => [
|
||||
'timeout' => Yii::$app->params['timeoutRequestServer'],
|
||||
'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/" . $value->image)),
|
||||
'data' => common::rsaEncode($text),
|
||||
'confidence' => isset($confidence['percent1']) ? floatval($confidence['percent1']) : 0
|
||||
])
|
||||
]
|
||||
$res = json_decode(file_get_contents($ip . "/api/oem/face_recognition?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/" . $value->image)),
|
||||
'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
|
||||
])
|
||||
]
|
||||
])), true);
|
||||
if ($res && $res['status'] == 10000) {
|
||||
if ($res['status'] == 10000) {
|
||||
$value->sync_status = 1;
|
||||
$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 {
|
||||
$value->delete();
|
||||
@@ -403,16 +400,14 @@ class ApiController extends Controller {
|
||||
return ["status" => true];
|
||||
}
|
||||
|
||||
function is_connected($host, $port) {
|
||||
$connected = @fsockopen($host, $port);
|
||||
//website, port (try 80 or 443)
|
||||
function is_connected($ip = "google.com") {
|
||||
$connected = @fsockopen($ip, 80);
|
||||
//website, port (try 80 or 443)
|
||||
if ($connected) {
|
||||
$is_conn = true; //action when connected
|
||||
fclose($connected);
|
||||
// file_put_contents("log_connect_server.txt", "\n" . date("H:i:s d/m/Y") . " connected " . $host . ":" . $port, FILE_APPEND);
|
||||
} else {
|
||||
$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;
|
||||
}
|
||||
@@ -507,14 +502,12 @@ class ApiController extends Controller {
|
||||
}
|
||||
|
||||
public function actionTest() {
|
||||
$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;
|
||||
$this->is_connected($host, $port);
|
||||
// $updating = \app\models\SyncUrl::findOne(['key_config' => 'token']);
|
||||
$updating = \app\models\SyncUrl::find()->all();
|
||||
foreach ($updating as $key => $value) {
|
||||
echo $value->key_config . " " . $value->data . "<br>";
|
||||
}
|
||||
exit();
|
||||
}
|
||||
|
||||
public function actionReGenFeature() {
|
||||
|
||||
@@ -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
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -160,8 +160,5 @@ return [
|
||||
"XOA_LICH_TRINH" => "Delete 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",
|
||||
"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?"
|
||||
"BAN_CO_CHAC_CHAN_MUON_DOI_IP_KHONG" => "Are you sure you want to change the device's IP address?"
|
||||
];
|
||||
|
||||
@@ -160,8 +160,5 @@ return [
|
||||
"XOA_LICH_TRINH" => "スケジュールを削除",
|
||||
"BAN_CO_CHAC_CHAN_MUON_XOA_LICH_TRINH_NAY_KHONG" => "このスケジュールを削除してもよろしいですか?",
|
||||
"SO_SANH_MAT" => "顔比較",
|
||||
"BAN_CO_CHAC_CHAN_MUON_DOI_IP_KHONG" => "デバイスの IP アドレスを変更してもよろしいですか?",
|
||||
"THONG_TIN_HE_THONG" => "システムインフォメーション",
|
||||
"REBOOT" => "リブート",
|
||||
"BAN_CO_CHAC_CHAN_MUON_REBOOT_KHONG" => "再起動してもよろしいですか?"
|
||||
"BAN_CO_CHAC_CHAN_MUON_DOI_IP_KHONG" => "デバイスの IP アドレスを変更してもよろしいですか?"
|
||||
];
|
||||
|
||||
@@ -160,8 +160,5 @@ return [
|
||||
"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?",
|
||||
"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?",
|
||||
"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?"
|
||||
"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?"
|
||||
];
|
||||
|
||||
0
runtime/temp.txt
Executable file → Normal file
0
runtime/temp.txt
Executable file → Normal file
@@ -36,7 +36,7 @@ use yii\widgets\ActiveForm;
|
||||
<!-- Collect the nav links, forms, and other content for toggling -->
|
||||
<div class="collapse navbar-collapse pull-left" id="navbar-collapse">
|
||||
<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']); ?>">
|
||||
<i class="fa fa-cogs"></i> <?php echo Yii::t("app", "CAU_HINH"); ?>
|
||||
</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>
|
||||
</ul>
|
||||
</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 } ?>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
@@ -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}
|
||||
@@ -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="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_REBOOT_KHONG" value="{Yii::t("app", "BAN_CO_CHAC_CHAN_MUON_REBOOT_KHONG")}">
|
||||
|
||||
|
||||
<div id="blocking" class="fade modal" role="dialog" tabindex="-1">
|
||||
<div class="modal-dialog" style="top: 50%;margin-top: -45px;">
|
||||
@@ -49,19 +47,6 @@
|
||||
</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 class="modal-dialog" style="top: 50%;margin-top: -45px;">
|
||||
<div class="modal-content" style="background-color: transparent;box-shadow: none;">
|
||||
|
||||
0
web/assets/temp.txt
Executable file → Normal file
0
web/assets/temp.txt
Executable file → Normal file
@@ -177,24 +177,4 @@ 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();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user