You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

decryptall.php 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738
  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\Files\View('/');
  10. $util = new \OCA\Files_Encryption\Util($view, \OCP\User::getUser());
  11. $l = \OC::$server->getL10N('settings');
  12. $result = $util->initEncryption($params);
  13. if ($result !== false) {
  14. try {
  15. $successful = $util->decryptAll();
  16. } catch (\Exception $ex) {
  17. \OCP\Util::writeLog('encryption library', "Decryption finished unexpected: " . $ex->getMessage(), \OCP\Util::ERROR);
  18. $successful = false;
  19. }
  20. $util->closeEncryptionSession();
  21. if ($successful === true) {
  22. \OCP\JSON::success(array('data' => array('message' => $l->t('Files decrypted successfully'))));
  23. } else {
  24. \OCP\JSON::error(array('data' => array('message' => $l->t('Couldn\'t decrypt your files, please check your owncloud.log or ask your administrator'))));
  25. }
  26. } else {
  27. \OCP\JSON::error(array('data' => array('message' => $l->t('Couldn\'t decrypt your files, check your password and try again'))));
  28. }