error.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. if (!isset($_)) { //also provide standalone error page
  3. require_once __DIR__ . '/../../../lib/base.php';
  4. $l = OC_L10N::get('files_encryption');
  5. if (isset($_GET['errorCode'])) {
  6. $errorCode = $_GET['errorCode'];
  7. switch ($errorCode) {
  8. case \OCA\Encryption\Crypt::ENCRYPTION_NOT_INITIALIZED_ERROR:
  9. $errorMsg = $l->t('Encryption app not initialized! Maybe the encryption app was re-enabled during your session. Please try to log out and log back in to initialize the encryption app.');
  10. break;
  11. case \OCA\Encryption\Crypt::ENCRYPTION_PRIVATE_KEY_NOT_VALID_ERROR:
  12. $theme = new OC_Defaults();
  13. $errorMsg = $l->t('Your private key is not valid! Likely your password was changed outside of %s (e.g. your corporate directory). You can update your private key password in your personal settings to recover access to your encrypted files.', array($theme->getName()));
  14. break;
  15. case \OCA\Encryption\Crypt::ENCRYPTION_NO_SHARE_KEY_FOUND:
  16. $errorMsg = $l->t('Can not decrypt this file, probably this is a shared file. Please ask the file owner to reshare the file with you.');
  17. break;
  18. default:
  19. $errorMsg = $l->t("Unknown error please check your system settings or contact your administrator");
  20. break;
  21. }
  22. } else {
  23. $errorCode = \OCA\Encryption\Crypt::ENCRYPTION_UNKNOWN_ERROR;
  24. $errorMsg = $l->t("Unknown error please check your system settings or contact your administrator");
  25. }
  26. if (isset($_GET['p']) && $_GET['p'] === '1') {
  27. header('HTTP/1.0 403 ' . $errorMsg);
  28. }
  29. // check if ajax request
  30. if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
  31. \OCP\JSON::error(array('data' => array('message' => $errorMsg)));
  32. } else {
  33. header('HTTP/1.0 403 ' . $errorMsg);
  34. $tmpl = new OC_Template('files_encryption', 'invalid_private_key', 'guest');
  35. $tmpl->assign('message', $errorMsg);
  36. $tmpl->assign('errorCode', $errorCode);
  37. $tmpl->printPage();
  38. }
  39. exit;
  40. }