decryptall.php 810 B

1234567891011121314151617181920212223242526
  1. <?php
  2. //encryption app needs to be loaded
  3. OC_App::loadApp('files_encryption');
  4. // init encryption app
  5. $params = array('uid' => \OCP\User::getUser(),
  6. 'password' => $_POST['password']);
  7. $view = new OC_FilesystemView('/');
  8. $util = new \OCA\Encryption\Util($view, \OCP\User::getUser());
  9. $result = $util->initEncryption($params);
  10. if ($result !== false) {
  11. $successful = $util->decryptAll();
  12. if ($successful === true) {
  13. \OCP\JSON::success(array('data' => array('message' => 'Files decrypted successfully')));
  14. } else {
  15. \OCP\JSON::error(array('data' => array('message' => 'Couldn\'t decrypt your files, please check your owncloud.log or ask your administrator')));
  16. }
  17. } else {
  18. \OCP\JSON::error(array('data' => array('message' => 'Couldn\'t decrypt your files, check your password and try again')));
  19. }