decryptall.php 861 B

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