Skip to content

Commit

Permalink
3.0.0.19
Browse files Browse the repository at this point in the history
Fix for #3325
Fix in progress regarding backup restore
  • Loading branch information
nilsteampassnet committed Sep 16, 2022
1 parent d66e0ad commit b50064a
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 13 deletions.
15 changes: 9 additions & 6 deletions pages/backups.js.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@ function(data) {
);
});

$(document).on('click', '.btn-choose-file', function() {
$('#onthefly-restore-progress, #onthefly-backup-progress')
.addClass('hidden')
.html('');
});

$(document).on('click', '.start', function() {
var action = $(this).data('action');

Expand Down Expand Up @@ -247,8 +253,8 @@ function(data) {
runtimes: "gears,html5,flash,silverlight,browserplus",
browse_button: "onthefly-restore-file-select",
container: "onthefly-restore-file",
max_file_size: "100mb",
chunk_size: "10mb",
max_file_size: "50mb",
chunk_size: "0",
unique_names: true,
dragdrop: true,
multiple_queues: false,
Expand All @@ -260,6 +266,7 @@ function(data) {
filters: [{
title: "SQL files",
extensions: "sql"
//mime_types : "application/zip"
}],
init: {
FilesAdded: function(up, files) {
Expand Down Expand Up @@ -327,15 +334,11 @@ function(teampassUser) {

// Uploader options
uploader_restoreDB.bind('FileUploaded', function(upldr, file, object) {
console.log(object)
var myData = prepareExchangedData(object.response, "decode", "<?php echo $_SESSION['key']; ?>");
console.log(myData);
$('#onthefly-restore-file').data('operation-id', myData.operation_id);
});

uploader_restoreDB.bind("Error", function(up, err) {
console.log("ERREUR");
console.log(err)
//var myData = prepareExchangedData(err, "decode", "<?php echo $_SESSION['key']; ?>");
$("#onthefly-restore-progress")
.removeClass('hidden')
Expand Down
4 changes: 2 additions & 2 deletions pages/backups.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@

</div>
<div class="row mt-3">
<button class="btn btn-info ml-1 start" data-action="onthefly-backup"><?php echo langHdl('perform_backup'); ?></button>
<button class="btn btn-info ml-1 start btn-choose-file" data-action="onthefly-backup"><?php echo langHdl('perform_backup'); ?></button>
</div>
</div>
</div>
Expand All @@ -145,7 +145,7 @@
<span class="text-bold"><?php echo langHdl('backup_select'); ?></span>
</div>
<div class="col-9 input-group" id="onthefly-restore-file">
<button class="btn btn-default" id="onthefly-restore-file-select"><?php echo langHdl('choose_file'); ?></button>
<button class="btn btn-default btn-choose-file" id="onthefly-restore-file-select"><?php echo langHdl('choose_file'); ?></button>
<span class="ml-2" id="onthefly-restore-file-text"></span>
</div>
</div>
Expand Down
21 changes: 19 additions & 2 deletions pages/import.js.php
Original file line number Diff line number Diff line change
Expand Up @@ -448,11 +448,11 @@ function(data) {

// Plupload for KEEPASS
var uploader_keepass = new plupload.Uploader({
runtimes: "html5,flash,silverlight,html4",
runtimes: "gears,html5,flash,silverlight,browserplus",
browse_button: "import-keepass-attach-pickfile-keepass",
container: "import-keepass-upload-zone",
max_file_size: "10mb",
chunk_size: "1mb",
chunk_size: "0",
unique_names: true,
dragdrop: true,
multiple_queues: false,
Expand Down Expand Up @@ -542,6 +542,16 @@ function(teampassApplication) {
$('.keepass-setup').removeClass('hidden');
}
upldr.splice(); // clear the file queue
},
Error: function(up, data) {
toastr.warning(
data.message + ' (' + up.settings.max_file_size + ')',
'<?php echo langHdl('caution'); ?>',
{
timeOut: 4000,
progressBar: true
}
);
}
}
});
Expand All @@ -567,6 +577,9 @@ function launchKeepassItemsImport() {
$('#import-feedback-progress-text')
.html('<?php echo langHdl('reading_file'); ?>');
$('#import-feedback').removeClass('hidden');

// block time counter
ProcessInProgress = true;

data = {
'file': store.get('teampassApplication').uploadedFileId,
Expand Down Expand Up @@ -727,6 +740,7 @@ function(data) {
$('#import-feedback-result').append(data.info)
$('#import-feedback-progress').addClass('hidden');
$('#import-feedback div').removeClass('hidden');
$('#import-feedback-progress-text').html('');

// Show
toastr.remove();
Expand All @@ -751,6 +765,9 @@ function(teampassApplication) {
teampassApplication.uploadedFileId = '';
}
);

// restart time expiration counter
ProcessInProgress = false;
}

return dfd.promise();
Expand Down
11 changes: 9 additions & 2 deletions sources/backups.queries.php
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@

$post_backupFile = $data['valeur'];

// Undecrypt the file
// Uncrypt the file
if (empty($post_key) === false) {
// Decrypt the file
$ret = prepareFileWithDefuse(
Expand All @@ -299,7 +299,14 @@
);

if (empty($ret) === false) {
echo '[{"result":"db_restore" , "message":"' . $ret . '"}]';
echo prepareExchangedData(
$SETTINGS['cpassman_dir'],
array(
'error' => true,
'message' => 'Error: '.$ret,
),
'encode'
);
break;
}

Expand Down
12 changes: 11 additions & 1 deletion sources/main.functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -2244,7 +2244,7 @@ function prepareFileWithDefuse(
}

// return error
return empty($err) === false ? $err : '';
return $err === true ? '' : $err;
}

/**
Expand All @@ -2265,6 +2265,11 @@ function defuseFileEncrypt(
) {
// load PhpEncryption library
$path_to_encryption = '/includes/libraries/Encryption/Encryption/';
include_once $SETTINGS['cpassman_dir'] . $path_to_encryption . 'Exception/CryptoException.php';
include_once $SETTINGS['cpassman_dir'] . $path_to_encryption . 'Exception/BadFormatException.php';
include_once $SETTINGS['cpassman_dir'] . $path_to_encryption . 'Exception/IOException.php';
include_once $SETTINGS['cpassman_dir'] . $path_to_encryption . 'Exception/EnvironmentIsBrokenException.php';
include_once $SETTINGS['cpassman_dir'] . $path_to_encryption . 'Exception/WrongKeyOrModifiedCiphertextException.php';
include_once $SETTINGS['cpassman_dir'] . $path_to_encryption . 'Crypto.php';
include_once $SETTINGS['cpassman_dir'] . $path_to_encryption . 'Encoding.php';
include_once $SETTINGS['cpassman_dir'] . $path_to_encryption . 'DerivedKeys.php';
Expand Down Expand Up @@ -2310,6 +2315,11 @@ function defuseFileDecrypt(
) {
// load PhpEncryption library
$path_to_encryption = '/includes/libraries/Encryption/Encryption/';
include_once $SETTINGS['cpassman_dir'] . $path_to_encryption . 'Exception/CryptoException.php';
include_once $SETTINGS['cpassman_dir'] . $path_to_encryption . 'Exception/BadFormatException.php';
include_once $SETTINGS['cpassman_dir'] . $path_to_encryption . 'Exception/IOException.php';
include_once $SETTINGS['cpassman_dir'] . $path_to_encryption . 'Exception/EnvironmentIsBrokenException.php';
include_once $SETTINGS['cpassman_dir'] . $path_to_encryption . 'Exception/WrongKeyOrModifiedCiphertextException.php';
include_once $SETTINGS['cpassman_dir'] . $path_to_encryption . 'Crypto.php';
include_once $SETTINGS['cpassman_dir'] . $path_to_encryption . 'Encoding.php';
include_once $SETTINGS['cpassman_dir'] . $path_to_encryption . 'DerivedKeys.php';
Expand Down

0 comments on commit b50064a

Please sign in to comment.