<?php require_once "kphpui/conf.php"; require_once "kphpui/ajaxui.php"; $isPwd = KphpUI::getString("r", $_GET) == "p" && ($uuid = KphpUI::getString("uuid", $_POST)) != null; $dbid = KphpUI::getString("dbid", $_POST); $pwd = KphpUI::getString("mainPwd", $_POST); $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));
} return $f['tmp_name']; } $ui = new MainUI(); $submitted = KphpUI::getString("submitted", $_POST); if ($submitted == "add") { if (($dbid = KphpUI::getString("addDbid", $_POST)) == "") { $ui->setIfEmpty("addDbid", MainUI::HI_EMPTY, "warning"); } 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);