Ejemplo n.º 1
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) {