Ejemplo n.º 1
0
$otherPwd = KphpUI::getString("openPwd1", $_POST);
$ui = new AjaxUI(AjaxUI::FAIL);
if (strlen($dbid) == 0) {
    $ui->setResult(AjaxUI::SOMETHING_EMPTY);
    $ui->setHTML("dbid");
} elseif (strlen($pwd) == 0) {
    $ui->setResult(AjaxUI::SOMETHING_EMPTY);
    $ui->setHTML("mainPwd");
} elseif (!$usePwdForCK && strlen($otherPwd) == 0) {
    $ui->setResult(AjaxUI::SOMETHING_EMPTY);
    $ui->setHTML("openPwd1");
} else {
    require_once KEEPASSPHP_LOCATION;
    KeePassPHP::init(KEEPASSPHP_DEBUG);
    if (KeePassPHP::exists($dbid)) {
        $db = KeePassPHP::get($dbid, $pwd, $usePwdForCK ? $pwd : $otherPwd);
        if ($db != null && $db->tryLoad()) {
            require_once "kphpui/htmlformat.php";
            if ($isPwd) {
                $pwd = $db->getPassword($uuid);
                if ($pwd != null) {
                    $ui->setResult(AjaxUI::SUCCESS);
                    $ui->addHTML(HTMLFormat::formatPassword($pwd));
                } else {
                    $ui->setResult(AjaxUI::PASSWORD_NOT_FOUND);
                    $ui->addHTML(HTMLFormat::PASSWORD_NOT_FOUND);
                }
            } else {
                $ui->setResult(AjaxUI::SUCCESS);
                $ui->addHTML(HTMLFormat::formatEntries($db));
            }
Ejemplo n.º 2
0
$answer = new AjaxAnswer();
$dbid = KPHPUI::getPost("dbid");
$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);