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.

error.php 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. /**
  3. * @author Björn Schießle <schiessle@owncloud.com>
  4. * @author Joas Schilling <nickvergessen@owncloud.com>
  5. * @author Lukas Reschke <lukas@owncloud.com>
  6. * @author Morris Jobke <hey@morrisjobke.de>
  7. * @author Robin Appelman <icewind@owncloud.com>
  8. * @author Thomas Müller <thomas.mueller@tmit.eu>
  9. * @author Volkan Gezer <volkangezer@gmail.com>
  10. *
  11. * @copyright Copyright (c) 2015, ownCloud, Inc.
  12. * @license AGPL-3.0
  13. *
  14. * This code is free software: you can redistribute it and/or modify
  15. * it under the terms of the GNU Affero General Public License, version 3,
  16. * as published by the Free Software Foundation.
  17. *
  18. * This program is distributed in the hope that it will be useful,
  19. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. * GNU Affero General Public License for more details.
  22. *
  23. * You should have received a copy of the GNU Affero General Public License, version 3,
  24. * along with this program. If not, see <http://www.gnu.org/licenses/>
  25. *
  26. */
  27. if (!isset($_)) { //also provide standalone error page
  28. require_once __DIR__ . '/../../../lib/base.php';
  29. require_once __DIR__ . '/../lib/crypt.php';
  30. OC_JSON::checkAppEnabled('files_encryption');
  31. OC_App::loadApp('files_encryption');
  32. $l = \OC::$server->getL10N('files_encryption');
  33. if (isset($_GET['errorCode'])) {
  34. $errorCode = $_GET['errorCode'];
  35. switch ($errorCode) {
  36. case \OCA\Files_Encryption\Crypt::ENCRYPTION_NOT_INITIALIZED_ERROR:
  37. $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.');
  38. break;
  39. case \OCA\Files_Encryption\Crypt::ENCRYPTION_PRIVATE_KEY_NOT_VALID_ERROR:
  40. $theme = new OC_Defaults();
  41. $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()));
  42. break;
  43. case \OCA\Files_Encryption\Crypt::ENCRYPTION_NO_SHARE_KEY_FOUND:
  44. $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.');
  45. break;
  46. default:
  47. $errorMsg = $l->t("Unknown error. Please check your system settings or contact your administrator");
  48. break;
  49. }
  50. } else {
  51. $errorCode = \OCA\Files_Encryption\Crypt::ENCRYPTION_UNKNOWN_ERROR;
  52. $errorMsg = $l->t("Unknown error. Please check your system settings or contact your administrator");
  53. }
  54. if (isset($_GET['p']) && $_GET['p'] === '1') {
  55. header('HTTP/1.0 403 ' . $errorMsg);
  56. }
  57. // check if ajax request
  58. if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
  59. \OCP\JSON::error(array('data' => array('message' => $errorMsg)));
  60. } else {
  61. header('HTTP/1.0 403 ' . $errorMsg);
  62. $tmpl = new OC_Template('files_encryption', 'invalid_private_key', 'guest');
  63. $tmpl->assign('message', $errorMsg);
  64. $tmpl->assign('errorCode', $errorCode);
  65. $tmpl->printPage();
  66. }
  67. exit;
  68. }