|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* @copyright Copyright (c) 2016 Arthur Schiwon <[email protected]> |
|
4
|
|
|
* |
|
5
|
|
|
* @author Arthur Schiwon <[email protected]> |
|
6
|
|
|
* |
|
7
|
|
|
* @license GNU AGPL version 3 or any later version |
|
8
|
|
|
* |
|
9
|
|
|
* This program is free software: you can redistribute it and/or modify |
|
10
|
|
|
* it under the terms of the GNU Affero General Public License as |
|
11
|
|
|
* published by the Free Software Foundation, either version 3 of the |
|
12
|
|
|
* License, or (at your option) any later version. |
|
13
|
|
|
* |
|
14
|
|
|
* This program is distributed in the hope that it will be useful, |
|
15
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
16
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
17
|
|
|
* GNU Affero General Public License for more details. |
|
18
|
|
|
* |
|
19
|
|
|
* You should have received a copy of the GNU Affero General Public License |
|
20
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
21
|
|
|
* |
|
22
|
|
|
*/ |
|
23
|
|
|
|
|
24
|
|
|
namespace OCA\Files\Settings; |
|
25
|
|
|
|
|
26
|
|
|
use bantu\IniGetWrapper\IniGetWrapper; |
|
27
|
|
|
use OCP\AppFramework\Http\TemplateResponse; |
|
28
|
|
|
use OCP\IRequest; |
|
29
|
|
|
use OCP\Settings\ISettings; |
|
30
|
|
|
use OCP\Util; |
|
31
|
|
|
|
|
32
|
|
|
class Admin implements ISettings { |
|
33
|
|
|
|
|
34
|
|
|
/** @var IniGetWrapper */ |
|
35
|
|
|
private $iniWrapper; |
|
36
|
|
|
|
|
37
|
|
|
/** @var IRequest */ |
|
38
|
|
|
private $request; |
|
39
|
|
|
|
|
40
|
|
|
public function __construct(IniGetWrapper $iniWrapper, IRequest $request) { |
|
41
|
|
|
$this->iniWrapper = $iniWrapper; |
|
42
|
|
|
$this->request = $request; |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* @return TemplateResponse |
|
47
|
|
|
*/ |
|
48
|
|
|
public function getForm() { |
|
49
|
|
|
$htaccessWorking = (getenv('htaccessWorking') == 'true'); |
|
50
|
|
|
$htaccessWritable = is_writable(\OC::$SERVERROOT.'/.htaccess'); |
|
51
|
|
|
$userIniWritable = is_writable(\OC::$SERVERROOT.'/.user.ini'); |
|
52
|
|
|
|
|
53
|
|
|
$upload_max_filesize = $this->iniWrapper->getBytes('upload_max_filesize'); |
|
54
|
|
|
$post_max_size = $this->iniWrapper->getBytes('post_max_size'); |
|
55
|
|
|
$maxUploadFilesize = Util::humanFileSize(min($upload_max_filesize, $post_max_size)); |
|
56
|
|
|
|
|
57
|
|
|
$parameters = [ |
|
58
|
|
|
'uploadChangable' => (($htaccessWorking and $htaccessWritable) or $userIniWritable ), |
|
59
|
|
|
'uploadMaxFilesize' => $maxUploadFilesize, |
|
60
|
|
|
// max possible makes only sense on a 32 bit system |
|
61
|
|
|
'displayMaxPossibleUploadSize' => PHP_INT_SIZE === 4, |
|
62
|
|
|
'maxPossibleUploadSize' => Util::humanFileSize(PHP_INT_MAX), |
|
63
|
|
|
]; |
|
64
|
|
|
|
|
65
|
|
|
return new TemplateResponse('files', 'admin', $parameters, ''); |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
/** |
|
69
|
|
|
* @return string the section ID, e.g. 'sharing' |
|
70
|
|
|
*/ |
|
71
|
|
|
public function getSection() { |
|
72
|
|
|
return 'additional'; |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
/** |
|
76
|
|
|
* @return int whether the form should be rather on the top or bottom of |
|
77
|
|
|
* the admin section. The forms are arranged in ascending order of the |
|
78
|
|
|
* priority values. It is required to return a value between 0 and 100. |
|
79
|
|
|
* |
|
80
|
|
|
* E.g.: 70 |
|
81
|
|
|
*/ |
|
82
|
|
|
public function getPriority() { |
|
83
|
|
|
return 5; |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
} |
|
87
|
|
|
|