Exemple #1
0
         require_once GLPI_ROOT . '/plugins/accounts/inc/aes.function.php';
         $hash = 0;
         $restrict = "`entities_id` = '" . $_SESSION['glpiactive_entity'] . "'";
         $hashes = getAllDatasFromTable("glpi_plugin_accounts_hashes", $restrict);
         if (!empty($hashes)) {
             foreach ($hashes as $hashe) {
                 $hash_id = $hashe["id"];
                 $hash = $hashe["hash"];
             }
         }
         if (!empty($_POST["aeskeynew"]) && !empty($_POST["aeskey"]) && !empty($hash)) {
             if ($hash != hash("sha256", hash("sha256", $_POST["aeskey"]))) {
                 Session::addMessageAfterRedirect(__('Wrong encryption key', 'accounts'), true, ERROR);
                 Html::back();
             } else {
                 PluginAccountsHash::updateHash($_POST["aeskey"], $_POST["aeskeynew"], $hash_id);
                 Session::addMessageAfterRedirect(__('Encryption key modified', 'accounts'), true);
                 Html::back();
             }
         } else {
             Session::addMessageAfterRedirect(__('The old or the new encryption key can not be empty', 'accounts'), true, ERROR);
             Html::back();
         }
     }
 } else {
     if ($plugin->isActivated("environment")) {
         Html::header(PluginAccountsAccount::getTypeName(2), '', "assets", "pluginenvironmentdisplay", "hash");
     } else {
         Html::header(PluginAccountsAccount::getTypeName(2), '', "admin", "pluginaccountsmenu", "hash");
     }
     $options = array("id" => $_GET['id'], "update" => false, "upgrade" => 0);