Ejemplo n.º 1
0
$usePwdForCK = KphpUI::getString("usePwdForCK", $_POST, "0") != "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
 }
 if (($mainPwd = KphpUI::getString("addMainPwd", $_POST)) == "") {
     $ui->setIfEmpty("addMainPwd", MainUI::HI_EMPTY, "warning");
 }
 $kdbxFile = checkFile("addKdbxFile", getFile("addKdbxFile"), $ui);
 $pwd1 = KphpUI::getString("addPwd1", $_POST);
 $keyfile = getFile("addFile1");
 if (!($usePwdForCK = KphpUI::getString("addUsePwdForCK", $_POST, "") != "") && $pwd1 == "" && $keyfile == null) {
     $ui->setIfEmpty("addUsePwdForCK", null, "error");
     $ui->setIfEmpty("addPwd1", MainUI::HI_NOOTHERKEY, "error");
     $ui->setIfEmpty("addFile1", MainUI::HI_ERROR, "error");
 }
 if (!$ui->isSomethingEmpty) {
     require_once KEEPASSPHP_LOCATION;
     KeePassPHP::init(KEEPASSPHP_DEBUG);
     if (!KeePassPHP::exists($dbid) || KeePassPHP::checkPassword($dbid, $mainPwd)) {
         $keys = $usePwdForCK ? array(array(KeePassPHP::KEY_PWD, $mainPwd)) : array();
         if ($pwd1 != '') {
             $keys[] = array(KeePassPHP::KEY_PWD, $pwd1);
         }
         if ($keyfile != null) {
             if (($keyfile = checkFile("addFile1", $keyfile, $ui)) != null) {
                 $keys[] = array(KeePassPHP::KEY_FILE, $keyfile);
             }
         }
         if (KeePassPHP::checkKeys($kdbxFile, $keys)) {
             if (KeePassPHP::tryAdd($kdbxFile, $dbid, $mainPwd, $keys)) {
                 $ui->addSuccess = true;
             }
         } else {
             if ($usePwdForCK) {