<commit_before><?php

require_once "keepassphpui/main.php";

$hasAddSuccess = false;

// give javascript error messages for the selected language
$javascriptContent = "var errorMessages = {" . 
	"empty: \"" . addslashes(KPHPUI::l(KPHPUI::LANG_FORM_ERROR_EMPTY)) . "\", " .
	"nootherkey: \"" . addslashes(KPHPUI::l(KPHPUI::LANG_FORM_ERROR_NOOTHERKEY)) . "\", " .
	"nosuchid: \"" . addslashes(KPHPUI::l(KPHPUI::LANG_FORM_ERROR_NOSUCHID)) . "\", " .
	"badpwd: \"" . addslashes(KPHPUI::l(KPHPUI::LANG_FORM_ERROR_BADPWD)) . "\", " .
	"filetoobig: \"" . addslashes(KPHPUI::l(KPHPUI::LANG_FORM_ERROR_FILETOOBIG)) . "\", " .
	"fileerror: \"" . addslashes(KPHPUI::l(KPHPUI::LANG_FORM_ERROR_FILEERROR)) . "\", " .
	"idexists: \"" . addslashes(KPHPUI::l(KPHPUI::LANG_FORM_ERROR_IDEXISTS)) . "\"};";

// the page that should be displayed at firt
$p = isset($_GET["p"]) && $_GET["p"] == "add" ? "add" : "open";

$url_nolang_params = isset($_GET["p"]) && $_GET["p"] == $p ? ("&amp;p=" . $p) : "";
$url_lang_param = isset($_GET["l"]) && $_GET["l"] == KPHPUI::$lang ? ("l=" . KPHPUI::$lang . "&amp;") : "";

// 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;<commit_msg>fix empty usage<commit_after><?php

require_once "keepassphpui/main.php";

$hasAddSuccess = false;

// give javascript error messages for the selected language
$javascriptContent = "var errorMessages = {" . 
	"empty: \"" . addslashes(KPHPUI::l(KPHPUI::LANG_FORM_ERROR_EMPTY)) . "\", " .
	"nootherkey: \"" . addslashes(KPHPUI::l(KPHPUI::LANG_FORM_ERROR_NOOTHERKEY)) . "\", " .
	"nosuchid: \"" . addslashes(KPHPUI::l(KPHPUI::LANG_FORM_ERROR_NOSUCHID)) . "\", " .
	"badpwd: \"" . addslashes(KPHPUI::l(KPHPUI::LANG_FORM_ERROR_BADPWD)) . "\", " .
	"filetoobig: \"" . addslashes(KPHPUI::l(KPHPUI::LANG_FORM_ERROR_FILETOOBIG)) . "\", " .
	"fileerror: \"" . addslashes(KPHPUI::l(KPHPUI::LANG_FORM_ERROR_FILEERROR)) . "\", " .
	"idexists: \"" . addslashes(KPHPUI::l(KPHPUI::LANG_FORM_ERROR_IDEXISTS)) . "\"};";

// the page that should be displayed at firt
$p = isset($_GET["p"]) && $_GET["p"] == "add" ? "add" : "open";

$url_nolang_params = isset($_GET["p"]) && $_GET["p"] == $p ? ("&amp;p=" . $p) : "";
$url_lang_param = isset($_GET["l"]) && $_GET["l"] == KPHPUI::$lang ? ("l=" . KPHPUI::$lang . "&amp;") : "";

// 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 = KPHPUI::getPost("add_use_pwd_in_key");
	$usePwdInKey = !empty($usePwdInKey);

	$ok = true;
	if(empty($dbid))
	{
		$ok = false;
		$formErrors["add_dbid"] = "empty";
	}
	if(empty($mainPwd))
	{
		$ok = false;
{'fraction_non_alphanumeric': 0.22181243414120128, 'fraction_numerical': 0.0, 'mean_word_length': 5.173983739837398, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6755845', 'n_tokens_mistral': 1568, 'n_tokens_neox': 1604, 'n_words': 235}