admin.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. /**
  3. * @author Arthur Schiwon <blizzz@owncloud.com>
  4. * @author Clark Tomlinson <fallen013@gmail.com>
  5. * @author Frank Karlitschek <frank@owncloud.org>
  6. * @author Jakob Sack <mail@jakobsack.de>
  7. * @author Michael Göhler <somebody.here@gmx.de>
  8. * @author Morris Jobke <hey@morrisjobke.de>
  9. * @author Robin Appelman <icewind@owncloud.com>
  10. * @author Robin McCorkell <robin@mccorkell.me.uk>
  11. * @author Thomas Müller <thomas.mueller@tmit.eu>
  12. *
  13. * @copyright Copyright (c) 2016, ownCloud, Inc.
  14. * @license AGPL-3.0
  15. *
  16. * This code is free software: you can redistribute it and/or modify
  17. * it under the terms of the GNU Affero General Public License, version 3,
  18. * as published by the Free Software Foundation.
  19. *
  20. * This program is distributed in the hope that it will be useful,
  21. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  22. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  23. * GNU Affero General Public License for more details.
  24. *
  25. * You should have received a copy of the GNU Affero General Public License, version 3,
  26. * along with this program. If not, see <http://www.gnu.org/licenses/>
  27. *
  28. */
  29. OCP\User::checkAdminUser();
  30. $htaccessWorking=(getenv('htaccessWorking')=='true');
  31. $upload_max_filesize = OC::$server->getIniWrapper()->getBytes('upload_max_filesize');
  32. $post_max_size = OC::$server->getIniWrapper()->getBytes('post_max_size');
  33. $maxUploadFilesize = OCP\Util::humanFileSize(min($upload_max_filesize, $post_max_size));
  34. if($_POST && \OC::$server->getRequest()->passesCSRFCheck()) {
  35. if(isset($_POST['maxUploadSize'])) {
  36. if(($setMaxSize = OC_Files::setUploadLimit(OCP\Util::computerFileSize($_POST['maxUploadSize']))) !== false) {
  37. $maxUploadFilesize = OCP\Util::humanFileSize($setMaxSize);
  38. }
  39. }
  40. }
  41. $htaccessWritable=is_writable(OC::$SERVERROOT.'/.htaccess');
  42. $userIniWritable=is_writable(OC::$SERVERROOT.'/.user.ini');
  43. $tmpl = new OCP\Template( 'files', 'admin' );
  44. $tmpl->assign( 'uploadChangable', ($htaccessWorking and $htaccessWritable) or $userIniWritable );
  45. $tmpl->assign( 'uploadMaxFilesize', $maxUploadFilesize);
  46. // max possible makes only sense on a 32 bit system
  47. $tmpl->assign( 'displayMaxPossibleUploadSize', PHP_INT_SIZE===4);
  48. $tmpl->assign( 'maxPossibleUploadSize', OCP\Util::humanFileSize(PHP_INT_MAX));
  49. return $tmpl->fetchPage();