thay doi co che reset thiet bi

This commit is contained in:
2020-12-22 17:08:56 +07:00
parent ef59255c52
commit 45be07f772
3 changed files with 48 additions and 34 deletions

View File

@@ -301,36 +301,38 @@ class ConfigController extends Controller {
public function actionReset() {
if (Yii::$app->request->post()) {
$tempConfig = json_decode(file_get_contents("http://localhost:4004/ReadEngineConfig", false, stream_context_create([
'http' => [
'header' => "Content-Type: application/json",
'method' => "POST"
]
])), true);
if ($tempConfig['status']) {
if ($tempConfig['data'] !== "") {
$engineConfig = json_decode($tempConfig['data'], true);
if (count($engineConfig['data']['engines']) == 0) {
$path = "";
if (Yii::$app->request->post("resetDevice") === "true") {
$tempConfig = json_decode(file_get_contents("http://localhost:4004/ReadEngineConfig", false, stream_context_create([
'http' => [
'header' => "Content-Type: application/json",
'method' => "POST"
]
])), true);
if ($tempConfig['status']) {
if ($tempConfig['data'] !== "") {
$engineConfig = json_decode($tempConfig['data'], true);
if (count($engineConfig['data']['engines']) == 0) {
$path = "";
} else {
$path = $engineConfig['data']['engines'][0]['path'];
}
} else {
$path = $engineConfig['data']['engines'][0]['path'];
$path = "";
}
} else {
$path = "";
}
} else {
$path = "";
file_get_contents("http://localhost:4004/Reset", false, stream_context_create([
'http' => [
'header' => "Content-Type: application/json",
'method' => "POST",
'content' => json_encode([
'path' => $path
])
]
]));
}
file_get_contents("http://localhost:4004/Reset", false, stream_context_create([
'http' => [
'header' => "Content-Type: application/json",
'method' => "POST",
'content' => json_encode([
'path' => $path
])
]
]));
if (Yii::$app->request->post("deleteDB") === "yes") {
if (Yii::$app->request->post("deleteDB") === "true") {
\Yii::$app->db->createCommand()->truncateTable('capture_logs')->execute();
\Yii::$app->db->createCommand()->truncateTable('list_management')->execute();
array_map('unlink', glob("/var/www/html/BiFace_Server_Lite/web/data/uploads/face/*.*"));