MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with accounts. If not, see <http://www.gnu.org/licenses/>. -------------------------------------------------------------------------- */ include '../../../inc/includes.php'; if (!isset($_GET["id"])) { $_GET["id"] = ""; } $plugin = new Plugin(); if ($plugin->isActivated("accounts")) { Session::checkRight("config", UPDATE); $PluginAccountsHash = new PluginAccountsHash(); $PluginAccountsHash->getFromDB(1); $hash = $PluginAccountsHash->fields["hash"]; $update = 0; if (countElementsInTable("glpi_plugin_accounts_accounts") > 0) { $update = 1; } if (empty($hash)) { if ($plugin->isActivated("environment")) { Html::header(PluginAccountsAccount::getTypeName(2), '', "assets", "pluginenvironmentdisplay", "accounts"); } else { Html::header(PluginAccountsAccount::getTypeName(2), '', "assets", "pluginaccountsmenu", "account"); } if ($_SESSION['glpiactive_entity'] == 0) { if ($update == 1) { echo "<div class='center b'>" . __('Upgrade') . "</div><br><br>"; echo "<div class='center b'>" . __('1. Define the encryption key and create hash', 'accounts') . "</div><br><br>";
public static function showAccountsList($values, $list) { global $CFG_GLPI; $ID = $values["id"]; $aeskey = $values["aeskey"]; $PluginAccountsHash = new PluginAccountsHash(); $PluginAccountsHash->getFromDB($ID); $hash = $PluginAccountsHash->fields["hash"]; $default_values["start"] = $start = 0; $default_values["id"] = $id = 0; $default_values["export"] = $export = false; foreach ($default_values as $key => $val) { if (isset($values[$key])) { ${$key} = $values[$key]; } } // Set display type for export if define $output_type = Search::HTML_OUTPUT; if (isset($values["display_type"])) { $output_type = $values["display_type"]; } $header_num = 1; $nbcols = 4; $row_num = 1; $numrows = 1; $parameters = "id=" . $ID . "&aeskey=" . $aeskey; if ($output_type == Search::HTML_OUTPUT && !empty($list)) { self::printPager($start, $numrows, $_SERVER['PHP_SELF'], $parameters, "PluginAccountsReport"); } echo Search::showHeader($output_type, 1, $nbcols, 1); echo Search::showNewLine($output_type); echo Search::showHeaderItem($output_type, __('Name'), $header_num); if (Session::isMultiEntitiesMode()) { echo Search::showHeaderItem($output_type, __('Entity'), $header_num); } echo Search::showHeaderItem($output_type, __('Type'), $header_num); echo Search::showHeaderItem($output_type, __('Login'), $header_num); echo Search::showHeaderItem($output_type, __('Uncrypted password', 'accounts'), $header_num); echo Search::showEndLine($output_type); if (!empty($list)) { foreach ($list as $user => $field) { $row_num++; $item_num = 1; echo Search::showNewLine($output_type); $IDc = $field["id"]; if ($output_type == Search::HTML_OUTPUT) { echo "<input type='hidden' name='hash_id' value='" . $ID . "'>"; echo "<input type='hidden' name='id[{$IDc}]' value='" . $IDc . "'>"; } $name = "<a href='" . $CFG_GLPI["root_doc"] . "/plugins/accounts/front/account.form.php?id=" . $IDc . "'>" . $field["name"]; if ($_SESSION["glpiis_ids_visible"]) { $name .= " (" . $IDc . ")"; } $name .= "</a>"; echo Search::showItem($output_type, $name, $item_num, $row_num); if ($output_type == Search::HTML_OUTPUT) { echo "<input type='hidden' name='name[{$IDc}]' value='" . $field["name"] . "'>"; } if (Session::isMultiEntitiesMode()) { echo Search::showItem($output_type, $field['entities_id'], $item_num, $row_num); if ($output_type == Search::HTML_OUTPUT) { echo "<input type='hidden' name='entities_id[{$IDc}]' value='" . $field["entities_id"] . "'>"; } } echo Search::showItem($output_type, $field["type"], $item_num, $row_num); if ($output_type == Search::HTML_OUTPUT) { echo "<input type='hidden' name='type[{$IDc}]' value='" . $field["type"] . "'>"; } echo Search::showItem($output_type, $field["login"], $item_num, $row_num); if ($output_type == Search::HTML_OUTPUT) { echo "<input type='hidden' name='login[{$IDc}]' value='" . $field["login"] . "'>"; } if ($output_type == Search::HTML_OUTPUT) { $encrypted = $field["password"]; echo "<input type='hidden' name='password[{$IDc}]'>"; $pass = "******"; $pass .= "<script language='javascript'>\n var good_hash=\"{$hash}\";\n var hash=SHA256(SHA256(\"{$aeskey}\"));\n if (hash != good_hash) {\n pass = \"" . __('Wrong encryption key', 'accounts') . "\";\n } else {\n pass = AESDecryptCtr(\"{$encrypted}\",SHA256(\"{$aeskey}\"), 256);\n };\n\n document.getElementsByName(\"password[{$IDc}]\").item(0).value = pass;\n\n document.getElementById(\"show_password\${$IDc}\").innerHTML = pass;\n </script>"; echo Search::showItem($output_type, $pass, $item_num, $row_num); } else { echo Search::showItem($output_type, $field["password"], $item_num, $row_num); } echo Search::showEndLine($output_type); } } if ($output_type == Search::HTML_OUTPUT) { Html::closeForm(); } // Display footer echo Search::showFooter($output_type, __('Linked accounts list', 'accounts')); }