diff --git a/controllers/ConfigController.php b/controllers/ConfigController.php index e85c2334..d9fc57a4 100644 --- a/controllers/ConfigController.php +++ b/controllers/ConfigController.php @@ -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/*.*")); diff --git a/views/config/reset.tpl b/views/config/reset.tpl index e029f16d..2d0d6db4 100644 --- a/views/config/reset.tpl +++ b/views/config/reset.tpl @@ -1,10 +1,11 @@ -