Admin.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016 Arthur Schiwon <blizzz@arthur-schiwon.de>
  4. *
  5. * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
  6. * @author Joas Schilling <coding@schilljs.com>
  7. *
  8. * @license GNU AGPL version 3 or any later version
  9. *
  10. * This program is free software: you can redistribute it and/or modify
  11. * it under the terms of the GNU Affero General Public License as
  12. * published by the Free Software Foundation, either version 3 of the
  13. * License, or (at your option) any later version.
  14. *
  15. * This program 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 License
  21. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  22. *
  23. */
  24. namespace OCA\Files\Settings;
  25. use bantu\IniGetWrapper\IniGetWrapper;
  26. use OCP\AppFramework\Http\TemplateResponse;
  27. use OCP\IRequest;
  28. use OCP\Settings\ISettings;
  29. use OCP\Util;
  30. class Admin implements ISettings {
  31. /** @var IniGetWrapper */
  32. private $iniWrapper;
  33. /** @var IRequest */
  34. private $request;
  35. public function __construct(IniGetWrapper $iniWrapper, IRequest $request) {
  36. $this->iniWrapper = $iniWrapper;
  37. $this->request = $request;
  38. }
  39. /**
  40. * @return TemplateResponse
  41. */
  42. public function getForm() {
  43. $htaccessWorking = (getenv('htaccessWorking') === 'true');
  44. $htaccessWritable = is_writable(\OC::$SERVERROOT.'/.htaccess');
  45. $userIniWritable = is_writable(\OC::$SERVERROOT.'/.user.ini');
  46. $upload_max_filesize = $this->iniWrapper->getBytes('upload_max_filesize');
  47. $post_max_size = $this->iniWrapper->getBytes('post_max_size');
  48. $maxUploadFilesize = Util::humanFileSize(min($upload_max_filesize, $post_max_size));
  49. $parameters = [
  50. 'uploadChangable' => ($htaccessWorking and $htaccessWritable) or $userIniWritable,
  51. 'uploadMaxFilesize' => $maxUploadFilesize,
  52. // max possible makes only sense on a 32 bit system
  53. 'displayMaxPossibleUploadSize' => PHP_INT_SIZE === 4,
  54. 'maxPossibleUploadSize' => Util::humanFileSize(PHP_INT_MAX),
  55. ];
  56. return new TemplateResponse('files', 'admin', $parameters, '');
  57. }
  58. /**
  59. * @return string the section ID, e.g. 'sharing'
  60. */
  61. public function getSection() {
  62. return 'server';
  63. }
  64. /**
  65. * @return int whether the form should be rather on the top or bottom of
  66. * the admin section. The forms are arranged in ascending order of the
  67. * priority values. It is required to return a value between 0 and 100.
  68. *
  69. * E.g.: 70
  70. */
  71. public function getPriority() {
  72. return 5;
  73. }
  74. }