getstoragestats.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Jörn Friedrich Dreyer <jfd@butonic.de>
  6. * @author Lukas Reschke <lukas@statuscode.ch>
  7. * @author Robin Appelman <robin@icewind.nl>
  8. * @author Thomas Müller <thomas.mueller@tmit.eu>
  9. * @author Vincent Petry <pvince81@owncloud.com>
  10. *
  11. * @license AGPL-3.0
  12. *
  13. * This code is free software: you can redistribute it and/or modify
  14. * it under the terms of the GNU Affero General Public License, version 3,
  15. * as published by the Free Software Foundation.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU Affero General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU Affero General Public License, version 3,
  23. * along with this program. If not, see <http://www.gnu.org/licenses/>
  24. *
  25. */
  26. $dir = '/';
  27. if (isset($_GET['dir'])) {
  28. $dir = (string)$_GET['dir'];
  29. }
  30. OCP\JSON::checkLoggedIn();
  31. \OC::$server->getSession()->close();
  32. // send back json
  33. try {
  34. OCP\JSON::success(array('data' => \OCA\Files\Helper::buildFileStorageStatistics($dir)));
  35. } catch (\OCP\Files\NotFoundException $e) {
  36. OCP\JSON::error(['data' => ['message' => 'Folder not found']]);
  37. }