Compare commits
14 Commits
Author | SHA1 | Date | |
---|---|---|---|
3e7bd8d0dd | |||
b9388a9308 | |||
571b194ddc | |||
1fad90072a | |||
6c29581ded | |||
5bed09b67f | |||
631948f314 | |||
151b86ee6b | |||
4fbf2e21aa | |||
976e89c129 | |||
1196ad712b | |||
db801e7d96 | |||
aade992cf9 | |||
c175187f4f |
|
@ -10,6 +10,8 @@ namespace app\commands;
|
|||
|
||||
use yii\console\Controller;
|
||||
use yii\console\ExitCode;
|
||||
use yii\log\Logger;
|
||||
use Yii;
|
||||
|
||||
/**
|
||||
* This command echoes the first argument that you have entered.
|
||||
|
@ -30,30 +32,39 @@ class SyncController extends Controller {
|
|||
if ($this->is_connected()) {
|
||||
$sync = \app\models\SyncUrl::find()->one();
|
||||
if ($sync) {
|
||||
$logs = \app\models\FaceLogs::find()->all();
|
||||
$logs = \app\models\WaitingReq::find()->all();
|
||||
foreach ($logs as $key => $value) {
|
||||
// $start = round(microtime(true) * 1000);
|
||||
|
||||
$contentJSON = json_decode($value->content);
|
||||
|
||||
$imgPath = $contentJSON->image;
|
||||
$imgBase64 = base64_encode(file_get_contents($imgPath));
|
||||
$contentJSON->image = $imgBase64;
|
||||
|
||||
$newValue = json_encode($contentJSON);
|
||||
|
||||
$options = [
|
||||
'http' => [
|
||||
'header' => "Content-Type: application/json",
|
||||
'method' => "POST",
|
||||
'content' => json_encode([
|
||||
"camera_id" => $value->camera_id,
|
||||
"confidence" => $value->confidence,
|
||||
"enable_door" => $value->enable_door,
|
||||
"encoded_person_image" => $value->encoded_person_image,
|
||||
"frametime" => $value->frametime,
|
||||
"id" => $value->face_id,
|
||||
"image" => $value->image,
|
||||
"name" => $value->name,
|
||||
"person_id" => $value->person_id,
|
||||
"status" => $value->status,
|
||||
"stt" => $value->stt,
|
||||
"timezone" => $value->timezone
|
||||
]),
|
||||
'content' => $newValue
|
||||
]
|
||||
];
|
||||
file_get_contents($sync->data, false, stream_context_create($options));
|
||||
$value->delete();
|
||||
$res = json_decode(file_get_contents($sync->data, false, stream_context_create($options)), true);
|
||||
if ($res['status'] == 1000) {
|
||||
$modelRes = new \app\models\ResponseReq();
|
||||
$modelRes->create(json_encode($res));
|
||||
$value->delete();
|
||||
// Delete image
|
||||
unlink($imgPath);
|
||||
}
|
||||
|
||||
// $end = round(microtime(true) * 1000);
|
||||
// $timeDuration = $end - $start;
|
||||
// Yii::info("Time:" . $timeDuration . " - " . $res, "cloud-response");
|
||||
// var_dump($res);
|
||||
// var_dump($timeDuration);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,4 +2,5 @@
|
|||
|
||||
return [
|
||||
'adminEmail' => 'admin@example.com',
|
||||
"version" => "1.0.7"
|
||||
];
|
||||
|
|
|
@ -35,6 +35,17 @@ class ApiController extends Controller {
|
|||
}
|
||||
}
|
||||
|
||||
public function actionWaitingRecognize() {
|
||||
if (Yii::$app->request->post()) {
|
||||
$post = Yii::$app->request->bodyParams;
|
||||
$model = new \app\models\WaitingReq();
|
||||
$model->create($post);
|
||||
\app\models\SyncUrl::find()->one();
|
||||
Yii::$app->response->format = "json";
|
||||
return ["stt" => true];
|
||||
}
|
||||
}
|
||||
|
||||
public function actionSyncUrl() {
|
||||
if (Yii::$app->request->post()) {
|
||||
$post = Yii::$app->request->bodyParams;
|
||||
|
@ -51,4 +62,77 @@ class ApiController extends Controller {
|
|||
}
|
||||
}
|
||||
|
||||
public function actionTest() {
|
||||
$sync = \app\models\SyncUrl::find()->one();
|
||||
var_dump(parse_url($sync->data));
|
||||
exit();
|
||||
Yii::info("Hello");
|
||||
// echo base64_encode(file_get_contents("/var/www/html/BiFace_Server_Lite/imgs/test.jpg"));
|
||||
// \app\models\WaitingReq::deleteAll();
|
||||
// $test1 = \app\models\WaitingReq::find()->all();
|
||||
$test = \app\models\ResponseReq::find()->orderBy(['time' => SORT_DESC])->all();
|
||||
// echo "<pre>";
|
||||
// var_dump($test1, count($test));
|
||||
// echo "</pre>";
|
||||
foreach ($test as $key => $value) {
|
||||
var_dump($value->content);
|
||||
echo "<br>";
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
public function actionSync() {
|
||||
Yii::$app->response->format = "json";
|
||||
$sync = \app\models\SyncUrl::find()->one();
|
||||
if ($sync) {
|
||||
$parseUrl = parse_url($sync->data);
|
||||
$host = $parseUrl['host'];
|
||||
$port = isset($parseUrl['port']) ? $parseUrl['port'] : 80;
|
||||
if ($this->is_connected($host, $port)) {
|
||||
$logs = \app\models\WaitingReq::find()->all();
|
||||
foreach ($logs as $key => $value) {
|
||||
$contentJSON = json_decode($value->content);
|
||||
|
||||
$imgPath = $contentJSON->image;
|
||||
$imgBase64 = file_exists($imgPath) ? base64_encode(file_get_contents($imgPath)) : "";
|
||||
if ($imgBase64 == "") {
|
||||
$value->delete();
|
||||
continue;
|
||||
}
|
||||
$contentJSON->image = $imgBase64;
|
||||
|
||||
$newValue = json_encode($contentJSON);
|
||||
|
||||
$options = [
|
||||
'http' => [
|
||||
'header' => "Content-Type: application/json",
|
||||
'method' => "POST",
|
||||
'content' => $newValue
|
||||
]
|
||||
];
|
||||
$res = json_decode(file_get_contents($sync->data, false, stream_context_create($options)), true);
|
||||
if (in_array($res['status'], [1000, 10000])) {
|
||||
$modelRes = new \app\models\ResponseReq();
|
||||
$modelRes->create(json_encode($res));
|
||||
$value->delete();
|
||||
unlink($imgPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return ["status" => true];
|
||||
}
|
||||
|
||||
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);
|
||||
} else {
|
||||
$is_conn = false; //action in connection failure
|
||||
}
|
||||
return $is_conn;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -207,9 +207,12 @@ class ConfigController extends Controller {
|
|||
$cfgData = $post['config'];
|
||||
$config_json = [];
|
||||
foreach ($cfgData as $key => $value) {
|
||||
if (is_numeric($value['data'])) {
|
||||
$value['data'] = floatval($value['data']);
|
||||
}
|
||||
$value['data'] = trim(strip_tags($value['data']));
|
||||
$value['data'] = str_replace(' ', '', $value['data']);
|
||||
$value['data'] = preg_replace('/\s+/', ' ', $value['data']);
|
||||
// if (is_numeric($value['data'])) {
|
||||
// $value['data'] = floatval($value['data']);
|
||||
// }
|
||||
|
||||
$pr = explode("|", $value['parent']);
|
||||
if (count($pr) == 1) {
|
||||
|
|
BIN
imgs/test.jpg
Normal file
BIN
imgs/test.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 73 KiB |
60
models/ResponseReq.php
Normal file
60
models/ResponseReq.php
Normal file
|
@ -0,0 +1,60 @@
|
|||
<?php
|
||||
|
||||
namespace app\models;
|
||||
|
||||
use Yii;
|
||||
|
||||
/**
|
||||
* This is the model class for table "response_req".
|
||||
*
|
||||
* @property int $id
|
||||
* @property string $content
|
||||
* @property int $time
|
||||
*/
|
||||
class ResponseReq extends \yii\db\ActiveRecord {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function tableName() {
|
||||
return 'response_req';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function rules() {
|
||||
return [
|
||||
[['content', 'time'], 'required'],
|
||||
[['content'], 'string'],
|
||||
[['time'], 'integer'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function attributeLabels() {
|
||||
return [
|
||||
'id' => 'ID',
|
||||
'content' => 'Content',
|
||||
'time' => 'Time',
|
||||
];
|
||||
}
|
||||
|
||||
public function create($data) {
|
||||
$r = $this->load([
|
||||
'content' => json_encode($data),
|
||||
'time' => time()
|
||||
], '');
|
||||
if ($r) {
|
||||
try {
|
||||
$this->save();
|
||||
return $this->id;
|
||||
} catch (\Exception $ex) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
60
models/WaitingReq.php
Normal file
60
models/WaitingReq.php
Normal file
|
@ -0,0 +1,60 @@
|
|||
<?php
|
||||
|
||||
namespace app\models;
|
||||
|
||||
use Yii;
|
||||
|
||||
/**
|
||||
* This is the model class for table "waiting_req".
|
||||
*
|
||||
* @property int $id
|
||||
* @property string $content
|
||||
* @property int $time
|
||||
*/
|
||||
class WaitingReq extends \yii\db\ActiveRecord {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function tableName() {
|
||||
return 'waiting_req';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function rules() {
|
||||
return [
|
||||
[['content', 'time'], 'required'],
|
||||
[['content'], 'string'],
|
||||
[['time'], 'integer'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function attributeLabels() {
|
||||
return [
|
||||
'id' => 'ID',
|
||||
'content' => 'Content',
|
||||
'time' => 'Time',
|
||||
];
|
||||
}
|
||||
|
||||
public function create($data) {
|
||||
$r = $this->load([
|
||||
'content' => json_encode($data),
|
||||
'time' => time()
|
||||
], '');
|
||||
if ($r) {
|
||||
try {
|
||||
$this->save();
|
||||
return $this->id;
|
||||
} catch (\Exception $ex) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
copy.src.files=false
|
||||
copy.src.on.open=false
|
||||
copy.src.target=
|
||||
remote.connection=bf_local-799e1d
|
||||
remote.connection=BiFace-99bab6
|
||||
remote.directory=/BiFace_Server_Lite
|
||||
remote.upload=ON_SAVE
|
||||
run.as=REMOTE
|
||||
|
|
|
@ -1,28 +1,29 @@
|
|||
<?php
|
||||
|
||||
use yii\widgets\Breadcrumbs;
|
||||
use dmstr\widgets\Alert;
|
||||
|
||||
?>
|
||||
<div class="content-wrapper">
|
||||
<!-- <section class="content-header">
|
||||
<?=
|
||||
Breadcrumbs::widget(
|
||||
<?=
|
||||
Breadcrumbs::widget(
|
||||
[
|
||||
'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [],
|
||||
]
|
||||
) ?>
|
||||
)
|
||||
?>
|
||||
</section>-->
|
||||
|
||||
<section class="content" style="padding: 0 0 15px 0;">
|
||||
<input type="hidden" value="<?php echo Yii::$app->user->id; ?>" name="current_user_id">
|
||||
<?= Alert::widget() ?>
|
||||
<?= $content ?>
|
||||
<?= $content ?>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<footer class="main-footer">
|
||||
<div class="pull-right hidden-xs" style="margin-top: 10px;">
|
||||
<!--<b>Hotline</b> <a href="tel:0912461556">091.246.1556</a>-->
|
||||
<div class="pull-right hidden-xs">
|
||||
<b>Version</b> <?php echo Yii::$app->params["version"]; ?>
|
||||
</div>
|
||||
<!--<strong>Copyright © 2020 <a href="https://beetinnovators.com/"><img src="/images/BI_Logo.png" width="80px"></a> & <a href="https://tctech.vn/"><img src="/images/TCTech.jpg" width="80px"></a>.</strong> All rights reserved.-->
|
||||
<strong>Copyright © 2020 <a href="https://beetinnovators.com/">BEETINNOVATORS</a>.</strong> All rights reserved.
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
<?php
|
||||
|
||||
// comment out the following two lines when deployed to production
|
||||
//defined('YII_DEBUG') or define('YII_DEBUG', true);
|
||||
//defined('YII_ENV') or define('YII_ENV', 'dev');
|
||||
defined('YII_DEBUG') or define('YII_DEBUG', true);
|
||||
defined('YII_ENV') or define('YII_ENV', 'dev');
|
||||
|
||||
require __DIR__ . '/../vendor/autoload.php';
|
||||
require __DIR__ . '/../vendor/yiisoft/yii2/Yii.php';
|
||||
|
|
|
@ -17,8 +17,8 @@ class ConfigTree extends Widget {
|
|||
|
||||
public function run() {
|
||||
|
||||
$public_root = ['engine', 'recognition', 'open_door', 'screen', 'lang'];
|
||||
$public_cfg = ['engine|cam_id', 'engine|server_authen', 'recognition|server_recog', 'open_door|enable', 'open_door|port_name', 'screen|banner', 'lang'];
|
||||
$public_root = ['engine', 'recognition', 'open_door', 'screen', 'lang', 'camera'];
|
||||
$public_cfg = ['engine|cam_id', 'engine|server_authen', 'recognition|server_recog', 'open_door|enable', 'open_door|port_name', 'screen|banner', 'lang', 'camera|rgb', 'camera|ir', 'camera|rgb|url', 'camera|ir|url'];
|
||||
|
||||
return $this->render("config-tree", [
|
||||
"configLists" => $this->configLists,
|
||||
|
|
Loading…
Reference in New Issue
Block a user