PageRenderTime 45ms CodeModel.GetById 12ms RepoModel.GetById 1ms app.codeStats 0ms

/admin/export.php

https://gitlab.com/x33n/ampache
PHP | 72 lines | 33 code | 12 blank | 27 comment | 3 complexity | df0af5ba090d0fe6202c78e40e396548 MD5 | raw file
  1. <?php
  2. /* vim:set softtabstop=4 shiftwidth=4 expandtab: */
  3. /**
  4. *
  5. * LICENSE: GNU General Public License, version 2 (GPLv2)
  6. * Copyright 2001 - 2015 Ampache.org
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License v2
  10. * as published by the Free Software Foundation.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  20. *
  21. */
  22. require_once '../lib/init.php';
  23. if (!Access::check('interface','100')) {
  24. UI::access_denied();
  25. exit;
  26. }
  27. UI::show_header();
  28. /* Switch on Action */
  29. switch ($_REQUEST['action']) {
  30. case 'export':
  31. // This may take a while
  32. set_time_limit(0);
  33. // Clear everything we've done so far
  34. ob_end_clean();
  35. // This will disable buffering so contents are sent immediately to browser.
  36. // This is very useful for large catalogs because it will immediately display the download dialog to user,
  37. // instead of waiting until contents are generated, which could take a long time.
  38. ob_implicit_flush(true);
  39. header("Content-Transfer-Encoding: binary");
  40. header("Cache-control: public");
  41. $date = date("d/m/Y",time());
  42. switch ($_REQUEST['export_format']) {
  43. case 'itunes':
  44. header("Content-Type: application/itunes+xml; charset=utf-8");
  45. header("Content-Disposition: attachment; filename=\"ampache-itunes-$date.xml\"");
  46. Catalog::export('itunes', $_REQUEST['export_catalog']);
  47. break;
  48. case 'csv':
  49. header("Content-Type: application/vnd.ms-excel");
  50. header("Content-Disposition: filename=\"ampache-export-$date.csv\"");
  51. Catalog::export('csv', $_REQUEST['export_catalog']);
  52. break;
  53. } // end switch on format
  54. // We don't want the footer so we're done here
  55. exit;
  56. default:
  57. require_once AmpConfig::get('prefix') . '/templates/show_export.inc.php';
  58. break;
  59. } // end switch on action
  60. UI::show_footer();