user interface to allow user to decrypt all his files once the encryption app was disabled
Conflicts: settings/templates/personal.php
This commit is contained in:
parent
48621115c1
commit
2c8e5ec84f
6 changed files with 68 additions and 9 deletions
|
@ -199,12 +199,39 @@ class Helper {
|
|||
public static function stripUserFilesPath($path) {
|
||||
$trimmed = ltrim($path, '/');
|
||||
$split = explode('/', $trimmed);
|
||||
|
||||
// it is not a file relative to data/user/files
|
||||
if ($split[1] !== 'files') {
|
||||
return false;
|
||||
}
|
||||
|
||||
$sliced = array_slice($split, 2);
|
||||
$relPath = implode('/', $sliced);
|
||||
|
||||
return $relPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief get path to the correspondig file in data/user/files
|
||||
* @param string $path path to a version or a file in the trash
|
||||
* @return string path to correspondig file relative to data/user/files
|
||||
*/
|
||||
public static function getPathToRealFile($path) {
|
||||
$trimmed = ltrim($path, '/');
|
||||
$split = explode('/', $trimmed);
|
||||
|
||||
if ($split[1] !== "files_versions") {
|
||||
return false;
|
||||
}
|
||||
|
||||
$sliced = array_slice($split, 2);
|
||||
$realPath = implode('/', $sliced);
|
||||
//remove the last .v
|
||||
$realPath = substr($realPath, 0, strrpos($realPath, '.v'));
|
||||
|
||||
return $realPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief redirect to a error page
|
||||
*/
|
||||
|
|
|
@ -116,7 +116,7 @@ class Proxy extends \OC_FileProxy {
|
|||
return true;
|
||||
}
|
||||
|
||||
$handle = fopen('crypt://' . $relativePath . '.etmp', 'w');
|
||||
$handle = fopen('crypt://' . $path . '.etmp', 'w');
|
||||
if (is_resource($handle)) {
|
||||
|
||||
// write data to stream
|
||||
|
@ -296,14 +296,14 @@ class Proxy extends \OC_FileProxy {
|
|||
|
||||
// Open the file using the crypto stream wrapper
|
||||
// protocol and let it do the decryption work instead
|
||||
$result = fopen('crypt://' . $relativePath, $meta['mode']);
|
||||
$result = fopen('crypt://' . $path, $meta['mode']);
|
||||
|
||||
} elseif (
|
||||
self::shouldEncrypt($path)
|
||||
and $meta ['mode'] !== 'r'
|
||||
and $meta['mode'] !== 'rb'
|
||||
) {
|
||||
$result = fopen('crypt://' . $relativePath, $meta['mode']);
|
||||
$result = fopen('crypt://' . $path, $meta['mode']);
|
||||
}
|
||||
|
||||
// Re-enable the proxy
|
||||
|
|
|
@ -73,7 +73,7 @@ class Stream {
|
|||
private $privateKey;
|
||||
|
||||
/**
|
||||
* @param $path
|
||||
* @param $path raw path relative to data/
|
||||
* @param $mode
|
||||
* @param $options
|
||||
* @param $opened_path
|
||||
|
@ -93,12 +93,16 @@ class Stream {
|
|||
|
||||
$this->userId = $util->getUserId();
|
||||
|
||||
// Strip identifier text from path, this gives us the path relative to data/<user>/files
|
||||
$this->relPath = \OC\Files\Filesystem::normalizePath(str_replace('crypt://', '', $path));
|
||||
|
||||
// rawPath is relative to the data directory
|
||||
$this->rawPath = $util->getUserFilesDir() . $this->relPath;
|
||||
$this->rawPath = \OC\Files\Filesystem::normalizePath(str_replace('crypt://', '', $path));
|
||||
|
||||
// Strip identifier text from path, this gives us the path relative to data/<user>/files
|
||||
$this->relPath = Helper::stripUserFilesPath($this->rawPath);
|
||||
// if raw path doesn't point to a real file, check if it is a version or a file in the trash bin
|
||||
if ($this->relPath === false) {
|
||||
$this->relPath = Helper::getPathToRealFile($this->rawPath);
|
||||
}
|
||||
|
||||
// Disable fileproxies so we can get the file size and open the source file without recursive encryption
|
||||
$proxyStatus = \OC_FileProxy::$enabled;
|
||||
\OC_FileProxy::$enabled = false;
|
||||
|
|
|
@ -693,7 +693,7 @@ class Trashbin {
|
|||
\OC_Log::write('files_trashbin', 'remove "' . $filename . '" fom trash bin because it is older than ' . $retention_obligation, \OC_log::INFO);
|
||||
}
|
||||
}
|
||||
$availableSpace = $availableSpace + $size;
|
||||
$availableSpace += $size;
|
||||
// if size limit for trash bin reached, delete oldest files in trash bin
|
||||
if ($availableSpace < 0) {
|
||||
$query = \OC_DB::prepare('SELECT `location`,`type`,`id`,`timestamp` FROM `*PREFIX*files_trash`'
|
||||
|
|
|
@ -24,6 +24,15 @@ $email=OC_Preferences::getValue(OC_User::getUser(), 'settings', 'email', '');
|
|||
$userLang=OC_Preferences::getValue( OC_User::getUser(), 'core', 'lang', OC_L10N::findLanguage() );
|
||||
$languageCodes=OC_L10N::findAvailableLanguages();
|
||||
|
||||
//check if encryption was enabled in the past
|
||||
$enableDecryptAll = false;
|
||||
if (OC_App::isEnabled('files_encryption') === false) {
|
||||
$view = new OC\Files\View('/'.OC_User::getUser());
|
||||
if ($view->file_exists('files_encryption/keyfiles')) {
|
||||
$enableDecryptAll = true;
|
||||
}
|
||||
}
|
||||
|
||||
// array of common languages
|
||||
$commonlangcodes = array(
|
||||
'en', 'es', 'fr', 'de', 'de_DE', 'ja_JP', 'ar', 'ru', 'nl', 'it', 'pt_BR', 'pt_PT', 'da', 'fi_FI', 'nb_NO', 'sv', 'zh_CN', 'ko'
|
||||
|
@ -80,6 +89,7 @@ $tmpl->assign('activelanguage', $userLang);
|
|||
$tmpl->assign('passwordChangeSupported', OC_User::canUserChangePassword(OC_User::getUser()));
|
||||
$tmpl->assign('displayNameChangeSupported', OC_User::canUserChangeDisplayName(OC_User::getUser()));
|
||||
$tmpl->assign('displayName', OC_User::getDisplayName());
|
||||
$tmpl->assign('enableDecryptAll' , true);
|
||||
|
||||
$forms=OC_App::getForms('personal');
|
||||
$tmpl->assign('forms', array());
|
||||
|
|
|
@ -110,6 +110,24 @@ if($_['passwordChangeSupported']) {
|
|||
print_unescaped($form);
|
||||
};?>
|
||||
|
||||
<?php if($_['enableDecryptAll']): ?>
|
||||
<form id="encryption">
|
||||
<fieldset class="personalblock">
|
||||
<legend>
|
||||
<?php p( $l->t( 'Encryption' ) ); ?>
|
||||
</legend>
|
||||
<?php p($l->t( "The encryption app is no longer enabled, decrypt all your file" )); ?>
|
||||
<p>
|
||||
<button
|
||||
type="button"
|
||||
name="submitDecryptAll"><?php p($l->t( "Decrypt all Files" )); ?>
|
||||
</button>
|
||||
</p>
|
||||
<br />
|
||||
</fieldset>
|
||||
</form>
|
||||
<?php endif; ?>
|
||||
|
||||
<fieldset class="personalblock">
|
||||
<legend><strong><?php p($l->t('Version'));?></strong></legend>
|
||||
<strong><?php p($theme->getName()); ?></strong> <?php p(OC_Util::getVersionString()); ?><br/>
|
||||
|
|
Loading…
Reference in a new issue