From 2fb820f945c2ca250b52ba95b74affc5650f5151 Mon Sep 17 00:00:00 2001 From: nuxsmin Date: Mon, 26 May 2014 01:39:33 +0200 Subject: [PATCH] * Closes 40. Accounts can be imported from KeePass or KeePassX XML file format. --- ajax/ajax_import.php | 2 +- ajax/ajax_search.php | 7 +- inc/account.class.php | 20 ++- inc/common.class.php | 2 +- inc/import.class.php | 192 ++++++++++++++++------ inc/keepassimport.class.php | 112 +++++++++++++ inc/keepassximport.class.php | 98 +++++++++++ inc/locales/de_DE/LC_MESSAGES/messages.mo | Bin 49481 -> 49545 bytes inc/locales/en_US/LC_MESSAGES/messages.mo | Bin 47666 -> 48744 bytes inc/locales/hu_HU/LC_MESSAGES/messages.mo | Bin 50432 -> 50392 bytes inc/tpl/migrate.php | 2 +- inc/util.class.php | 2 +- js/functions.js | 2 +- 13 files changed, 373 insertions(+), 66 deletions(-) create mode 100644 inc/keepassimport.class.php create mode 100644 inc/keepassximport.class.php diff --git a/ajax/ajax_import.php b/ajax/ajax_import.php index 8548d572..1029a40a 100644 --- a/ajax/ajax_import.php +++ b/ajax/ajax_import.php @@ -1 +1 @@ -. * */ define('APP_ROOT', '..'); require_once APP_ROOT.DIRECTORY_SEPARATOR.'inc'.DIRECTORY_SEPARATOR.'init.php'; SP_Util::checkReferer('POST'); if (!SP_Init::isLoggedIn()) { SP_Common::printJSON(_('La sesión no se ha iniciado o ha caducado'), 10); } if (SP_Util::demoIsEnabled()) { SP_Common::printJSON(_('Ey, esto es una DEMO!!')); } $sk = SP_Common::parseParams('p', 'sk', false); if (!$sk || !SP_Common::checkSessionKey($sk)) { SP_Common::printJSON(_('CONSULTA INVÁLIDA')); } $res = SP_Import::doImport($_FILES["inFile"]); if (is_array($res['error'])) { foreach ($res['error'] as $error) { $errors [] = $error['description']; $errors [] = $error['hint']; error_log($error['hint']); } $out = implode('\n\n', $errors); SP_Common::printJSON($out); } else if (is_array($res['ok'])) { $out = implode('\n\n', $res['ok']); SP_Common::printJSON($out, 0); } \ No newline at end of file +. * */ define('APP_ROOT', '..'); require_once APP_ROOT.DIRECTORY_SEPARATOR.'inc'.DIRECTORY_SEPARATOR.'init.php'; SP_Util::checkReferer('POST'); if (!SP_Init::isLoggedIn()) { SP_Common::printJSON(_('La sesión no se ha iniciado o ha caducado'), 10); } if (SP_Util::demoIsEnabled()) { SP_Common::printJSON(_('Ey, esto es una DEMO!!')); } $sk = SP_Common::parseParams('p', 'sk', false); if (!$sk || !SP_Common::checkSessionKey($sk)) { SP_Common::printJSON(_('CONSULTA INVÁLIDA')); } $res = SP_Import::doImport($_FILES["inFile"]); if (isset($res['error']) && is_array($res['error'])) { foreach ($res['error'] as $error) { $errors [] = $error['description']; $errors [] = $error['hint']; error_log($error['hint']); } $out = implode('\n\n', $errors); SP_Common::printJSON($out); } else if (is_array($res['ok'])) { $out = implode('\n\n', $res['ok']); SP_Common::printJSON($out, 0); } \ No newline at end of file diff --git a/ajax/ajax_search.php b/ajax/ajax_search.php index ddd8e20f..d0f2ae65 100644 --- a/ajax/ajax_search.php +++ b/ajax/ajax_search.php @@ -218,7 +218,10 @@ foreach ($resQuery as $account) { } } - $strAccNotes = (strlen($account->account_notes) > 300) ? substr($account->account_notes, 0, 300) . "..." : $account->account_notes; + if ($account->account_notes){ + $strAccNotes = (strlen($account->account_notes) > 300) ? substr($account->account_notes, 0, 300) . "..." : $account->account_notes; + $strAccNotes = nl2br(wordwrap(htmlspecialchars($strAccNotes), 50, '
', true)); + } } //echo '
'; @@ -254,7 +257,7 @@ foreach ($resQuery as $account) { echo '