From d6c8b92523050d42926c66f721a85d8d1cf97906 Mon Sep 17 00:00:00 2001 From: Michael Kaufmann Date: Sat, 15 Feb 2020 07:30:56 +0100 Subject: [PATCH] add Froxlor.integrityCheck() API call to externally run integrity/consistency check, fixes #801 Signed-off-by: Michael Kaufmann --- lib/Froxlor/Api/Commands/Froxlor.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/lib/Froxlor/Api/Commands/Froxlor.php b/lib/Froxlor/Api/Commands/Froxlor.php index 709cffe2..080676d6 100644 --- a/lib/Froxlor/Api/Commands/Froxlor.php +++ b/lib/Froxlor/Api/Commands/Froxlor.php @@ -243,6 +243,26 @@ class Froxlor extends \Froxlor\Api\ApiCommand return $this->response(200, "successfull", \Froxlor\System\Crypt::generatePassword()); } + /** + * can be used to remotely run the integritiy checks froxlor implements + * + * @access admin + * @throws \Exception + * @return string + */ + public function integrityCheck() + { + if ($this->isAdmin() && $this->getUserDetail('change_serversettings')) { + $integrity = new \Froxlor\Database\IntegrityCheck(); + $result = $integrity->checkAll(); + if ($result) { + return $this->response(200, "successfull", "OK"); + } + throw new \Exception("Some checks failed.", 406); + } + throw new \Exception("Not allowed to execute given command.", 403); + } + /** * returns a list of all available api functions *