Merge branch 'dev_DTD' into BiFacePro2.0.1
# Conflicts: # controllers/ApiController.php
This commit is contained in:
@@ -95,18 +95,21 @@ class ApiController extends Controller {
|
||||
$token = \app\models\SyncUrl::findOne(['key_config' => 'token']);
|
||||
if ($token)
|
||||
$tk = $token->data;
|
||||
$res = json_decode(file_get_contents($ip . "/api/oem/face_recognition?token=" . $tk, false, stream_context_create([
|
||||
$data = [];
|
||||
$data[] = strval($id_camera); //camera_id
|
||||
$data[] = date("Y-m-d H:i:s", $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' => [
|
||||
'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)
|
||||
])
|
||||
]
|
||||
])), true);
|
||||
|
||||
@@ -296,6 +296,7 @@ class ConfigController extends Controller {
|
||||
}
|
||||
|
||||
public function actionReset() {
|
||||
Yii::$app->response->format = "json";
|
||||
if (Yii::$app->request->post()) {
|
||||
if (Yii::$app->request->post("deleteDB") === "true") {
|
||||
\Yii::$app->db->createCommand()->truncateTable('capture_logs')->execute();
|
||||
@@ -315,7 +316,7 @@ class ConfigController extends Controller {
|
||||
if ($device_id)
|
||||
$id_camera = intval($device_id->data);
|
||||
try {
|
||||
file_get_contents($ip . "/api/model/reset_log_model", false, stream_context_create([
|
||||
$res = json_decode(file_get_contents($ip . "/api/model/reset_log_model", false, stream_context_create([
|
||||
'http' => [
|
||||
'header' => "Content-Type: application/json",
|
||||
'method' => "POST",
|
||||
@@ -324,9 +325,17 @@ class ConfigController extends Controller {
|
||||
"isCloud" => 0
|
||||
])
|
||||
]
|
||||
]));
|
||||
])), true);
|
||||
if ($res['status'] != 10000)
|
||||
return [
|
||||
"status" => false,
|
||||
"btnText" => Yii::t("app", "THU_LAI")
|
||||
];
|
||||
} catch (Exception $ex) {
|
||||
|
||||
return [
|
||||
"status" => false,
|
||||
"btnText" => Yii::t("app", "THU_LAI")
|
||||
];
|
||||
}
|
||||
}
|
||||
if (Yii::$app->request->post("resetDevice") === "true") {
|
||||
@@ -361,9 +370,11 @@ class ConfigController extends Controller {
|
||||
]));
|
||||
}
|
||||
\app\models\SyncUrl::deleteAll(['IN', 'key_config', ['server_api', 'device_id']]);
|
||||
return Url::to(['/config/cau-hinh-thiet-bi']);
|
||||
return [
|
||||
"status" => true,
|
||||
"url" => Url::to(['/config/cau-hinh-thiet-bi'])
|
||||
];
|
||||
} else {
|
||||
Yii::$app->response->format = "json";
|
||||
return [
|
||||
"title" => Yii::t("app", "RESET_THIET_BI"),
|
||||
"form" => $this->renderPartial("reset")
|
||||
|
||||
@@ -14,13 +14,6 @@ use yii\helpers\Url;
|
||||
*/
|
||||
class DashboardController extends Controller {
|
||||
|
||||
public function init() {
|
||||
parent::init();
|
||||
if (Yii::$app->user->isGuest) {
|
||||
return $this->redirect(['/site/login']);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
@@ -157,4 +150,12 @@ class DashboardController extends Controller {
|
||||
}
|
||||
}
|
||||
|
||||
public function actionChangeLanguageLogin($lang) {
|
||||
$language = \app\models\common::allLanguage();
|
||||
foreach ($language as $key => $value) {
|
||||
if ($value['name'] === $lang)
|
||||
return $this->redirect(['/site/login', 'lang' => $lang]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -66,13 +66,20 @@ class SiteController extends Controller {
|
||||
*
|
||||
* @return Response|string
|
||||
*/
|
||||
public function actionLogin() {
|
||||
public function actionLogin($lang = "vi-VI") {
|
||||
if (!Yii::$app->user->isGuest) {
|
||||
return $this->goHome();
|
||||
}
|
||||
Yii::$app->language = $lang;
|
||||
|
||||
$model = new LoginForm();
|
||||
if ($model->load(Yii::$app->request->post()) && $model->login()) {
|
||||
$lang = Yii::$app->request->post('lang');
|
||||
$language = \app\models\common::allLanguage();
|
||||
foreach ($language as $key => $value) {
|
||||
if ($value['name'] === $lang)
|
||||
Yii::$app->session->set("language", $value);
|
||||
}
|
||||
return $this->redirect(["/config"]);
|
||||
}
|
||||
|
||||
@@ -88,9 +95,10 @@ class SiteController extends Controller {
|
||||
* @return Response
|
||||
*/
|
||||
public function actionLogout() {
|
||||
$lang = Yii::$app->session->get("language") ? Yii::$app->session->get("language")["name"] : Yii::$app->language;
|
||||
Yii::$app->user->logout();
|
||||
|
||||
return $this->goHome();
|
||||
return $this->redirect(['/site/login', 'lang' => $lang]); //$this->goHome();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user