settings.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. /**
  3. * ownCloud - admin_migrate
  4. *
  5. * @author Thomas Schmidt
  6. * @copyright 2011 Thomas Schmidt tom@opensuse.org
  7. * @author Tom Needham
  8. * @copyright 2012 Tom Needham tom@owncloud.com
  9. *
  10. * This library is free software; you can redistribute it and/or
  11. * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
  12. * License as published by the Free Software Foundation; either
  13. * version 3 of the License, or any later version.
  14. *
  15. * This library is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
  19. *
  20. * You should have received a copy of the GNU Affero General Public
  21. * License along with this library. If not, see <http://www.gnu.org/licenses/>.
  22. *
  23. */
  24. OCP\User::checkAdminUser();
  25. OCP\App::checkAppEnabled('admin_migrate');
  26. // Export?
  27. if (isset($_POST['admin_export'])) {
  28. // Create the export zip
  29. $response = json_decode( OC_Migrate::export( null, $_POST['export_type'] ) );
  30. if( !$response->success ){
  31. // Error
  32. die('error');
  33. } else {
  34. $path = $response->data;
  35. // Download it
  36. header("Content-Type: application/zip");
  37. header("Content-Disposition: attachment; filename=" . basename($path));
  38. header("Content-Length: " . filesize($path));
  39. @ob_end_clean();
  40. readfile( $path );
  41. unlink( $path );
  42. }
  43. // Import?
  44. } else if( isset($_POST['admin_import']) ){
  45. $from = $_FILES['owncloud_import']['tmp_name'];
  46. if( !OC_Migrate::import( $from, 'instance' ) ){
  47. die('failed');
  48. }
  49. } else {
  50. // fill template
  51. $tmpl = new OCP\Template('admin_migrate', 'settings');
  52. return $tmpl->fetchPage();
  53. }