Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
3e7bd8d0dd | |||
b9388a9308 | |||
571b194ddc | |||
1fad90072a |
|
@ -63,6 +63,9 @@ class ApiController extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function actionTest() {
|
public function actionTest() {
|
||||||
|
$sync = \app\models\SyncUrl::find()->one();
|
||||||
|
var_dump(parse_url($sync->data));
|
||||||
|
exit();
|
||||||
Yii::info("Hello");
|
Yii::info("Hello");
|
||||||
// echo base64_encode(file_get_contents("/var/www/html/BiFace_Server_Lite/imgs/test.jpg"));
|
// echo base64_encode(file_get_contents("/var/www/html/BiFace_Server_Lite/imgs/test.jpg"));
|
||||||
// \app\models\WaitingReq::deleteAll();
|
// \app\models\WaitingReq::deleteAll();
|
||||||
|
@ -80,15 +83,22 @@ class ApiController extends Controller {
|
||||||
|
|
||||||
public function actionSync() {
|
public function actionSync() {
|
||||||
Yii::$app->response->format = "json";
|
Yii::$app->response->format = "json";
|
||||||
if ($this->is_connected()) {
|
|
||||||
$sync = \app\models\SyncUrl::find()->one();
|
$sync = \app\models\SyncUrl::find()->one();
|
||||||
if ($sync) {
|
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();
|
$logs = \app\models\WaitingReq::find()->all();
|
||||||
foreach ($logs as $key => $value) {
|
foreach ($logs as $key => $value) {
|
||||||
$contentJSON = json_decode($value->content);
|
$contentJSON = json_decode($value->content);
|
||||||
|
|
||||||
$imgPath = $contentJSON->image;
|
$imgPath = $contentJSON->image;
|
||||||
$imgBase64 = base64_encode(file_get_contents($imgPath));
|
$imgBase64 = file_exists($imgPath) ? base64_encode(file_get_contents($imgPath)) : "";
|
||||||
|
if ($imgBase64 == "") {
|
||||||
|
$value->delete();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
$contentJSON->image = $imgBase64;
|
$contentJSON->image = $imgBase64;
|
||||||
|
|
||||||
$newValue = json_encode($contentJSON);
|
$newValue = json_encode($contentJSON);
|
||||||
|
@ -113,8 +123,8 @@ class ApiController extends Controller {
|
||||||
return ["status" => true];
|
return ["status" => true];
|
||||||
}
|
}
|
||||||
|
|
||||||
function is_connected($ip = "google.com") {
|
function is_connected($host, $port) {
|
||||||
$connected = @fsockopen($ip, 80);
|
$connected = @fsockopen($host, $port);
|
||||||
//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
|
||||||
|
|
|
@ -17,8 +17,8 @@ class ConfigTree extends Widget {
|
||||||
|
|
||||||
public function run() {
|
public function run() {
|
||||||
|
|
||||||
$public_root = ['engine', 'recognition', 'open_door', 'screen', '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'];
|
$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", [
|
return $this->render("config-tree", [
|
||||||
"configLists" => $this->configLists,
|
"configLists" => $this->configLists,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user