$mainPwd = KPHPUI::getPost("main_pwd"); $usePwdInKey = KPHPUI::getPost("use_pwd_in_key") == "true"; $otherPwd = KPHPUI::getPost("open_other_pwd"); if (empty($dbid)) { $answer->set(AjaxAnswer::SOMETHING_EMPTY, "dbid"); } elseif (empty($mainPwd)) { $answer->set(AjaxAnswer::SOMETHING_EMPTY, "main_pwd"); } elseif (!$usePwdInKey && empty($otherPwd)) { $answer->set(AjaxAnswer::SOMETHING_EMPTY, "open_other_pwd"); } else { require_once KEEPASSPHP_LOCATION; KeePassPHP::init(dirname(KEEPASSPHP_LOCATION), KEEPASSPHP_DEBUG); if (KeePassPHP::exists($dbid)) { $db = KeePassPHP::get($dbid, $mainPwd, $usePwdInKey ? $mainPwd : $otherPwd); if ($db != null) { $uuid = KPHPUI::getPost("uuid"); if (!empty($uuid)) { $pwd = $db->getPassword($uuid); if ($pwd != null) { $answer->set(AjaxAnswer::SUCCESS, '<input type="text" class="verysmall selectOnFocus form-control" value="' . KPHPUI::htmlify($pwd) . '" style="font-size:3px !important;"/>'); } else { $answer->set(AjaxAnswer::PASSWORD_NOT_FOUND, '<span class="label label-danger">' . KPHPUI::l(KPHPUI::LANG_SEE_PWD_DOES_NOT_EXIST) . '</span>'); } } else { $s = '<table class="table table-hover form-inline"><thead><tr><th> </th><th>' . KPHPUI::l(KPHPUI::LANG_SEE_ENTRY_TITLE) . '</th><th>' . KPHPUI::l(KPHPUI::LANG_SEE_ENTRY_URL) . '</th><th>' . KPHPUI::l(KPHPUI::LANG_SEE_ENTRY_USERNAME) . '</th><th>' . KPHPUI::l(KPHPUI::LANG_SEE_ENTRY_PASSWORD) . '</th></tr></thead><tbody>'; foreach ($db->getEntries() as $uuid => $entry) { $icon = $entry[Database::KEY_CUSTOMICON]; if (!empty($icon)) { $icon = $db->getIconSrc($icon); } if (empty($icon) && isset($entry[Database::KEY_ICON])) {
$url_lang_param = isset($_GET["l"]) && $_GET["l"] == KPHPUI::$lang ? "l=" . KPHPUI::$lang . "&" : ""; // always force lang of ajax queries $javascriptContent .= "\nvar forceLang = \"" . KPHPUI::$lang . "\";"; // add a database if the add form is being submitted $formErrors = array(); $submitted = KPHPUI::getPost("submitted"); if ($submitted == "add") { // check all POST & FILE parameters $dbid = KPHPUI::getPost("add_dbid"); $mainPwd = KPHPUI::getPost("add_main_pwd"); $otherPwd = KPHPUI::getPost("add_other_pwd"); $kdbxFile = null; $kdbxFileStatus = KPHPUI::getFile("add_kdbx_file", $kdbxFile); $keyFile = null; $keyFileStatus = KPHPUI::getFile("add_other_keyfile", $keyFile); $usePwdInKey = !empty(KPHPUI::getPost("add_use_pwd_in_key")); $ok = true; if (empty($dbid)) { $ok = false; $formErrors["add_dbid"] = "empty"; } if (empty($mainPwd)) { $ok = false; $formErrors["add_main_pwd"] = "empty"; } if (!$usePwdInKey && empty($otherPwd) && $keyFileStatus != KPHPUI::GET_FILE_OK) { $ok = false; $formErrors["add_other_pwd"] = "nootherkey"; $formErrors["add_other_keyfile"] = "nootherkey"; } if ($kdbxFileStatus != KPHPUI::GET_FILE_OK) {