@@ -49,353 +49,353 @@ |
||
| 49 | 49 | use OCP\Util; |
| 50 | 50 | |
| 51 | 51 | class Manager implements IManager { |
| 52 | - /** @var ILogger */ |
|
| 53 | - private $log; |
|
| 54 | - /** @var IDBConnection */ |
|
| 55 | - private $dbc; |
|
| 56 | - /** @var IL10N */ |
|
| 57 | - private $l; |
|
| 58 | - /** @var IConfig */ |
|
| 59 | - private $config; |
|
| 60 | - /** @var EncryptionManager */ |
|
| 61 | - private $encryptionManager; |
|
| 62 | - /** @var IUserManager */ |
|
| 63 | - private $userManager; |
|
| 64 | - /** @var ILockingProvider */ |
|
| 65 | - private $lockingProvider; |
|
| 66 | - /** @var IRequest */ |
|
| 67 | - private $request; |
|
| 68 | - /** @var IURLGenerator */ |
|
| 69 | - private $url; |
|
| 70 | - /** @var AccountManager */ |
|
| 71 | - private $accountManager; |
|
| 72 | - /** @var IGroupManager */ |
|
| 73 | - private $groupManager; |
|
| 74 | - /** @var IFactory */ |
|
| 75 | - private $l10nFactory; |
|
| 76 | - /** @var IAppManager */ |
|
| 77 | - private $appManager; |
|
| 78 | - |
|
| 79 | - /** |
|
| 80 | - * @param ILogger $log |
|
| 81 | - * @param IDBConnection $dbc |
|
| 82 | - * @param IL10N $l |
|
| 83 | - * @param IConfig $config |
|
| 84 | - * @param EncryptionManager $encryptionManager |
|
| 85 | - * @param IUserManager $userManager |
|
| 86 | - * @param ILockingProvider $lockingProvider |
|
| 87 | - * @param IRequest $request |
|
| 88 | - * @param IURLGenerator $url |
|
| 89 | - * @param AccountManager $accountManager |
|
| 90 | - * @param IGroupManager $groupManager |
|
| 91 | - * @param IFactory $l10nFactory |
|
| 92 | - * @param IAppManager $appManager |
|
| 93 | - */ |
|
| 94 | - public function __construct( |
|
| 95 | - ILogger $log, |
|
| 96 | - IDBConnection $dbc, |
|
| 97 | - IL10N $l, |
|
| 98 | - IConfig $config, |
|
| 99 | - EncryptionManager $encryptionManager, |
|
| 100 | - IUserManager $userManager, |
|
| 101 | - ILockingProvider $lockingProvider, |
|
| 102 | - IRequest $request, |
|
| 103 | - IURLGenerator $url, |
|
| 104 | - AccountManager $accountManager, |
|
| 105 | - IGroupManager $groupManager, |
|
| 106 | - IFactory $l10nFactory, |
|
| 107 | - IAppManager $appManager |
|
| 108 | - ) { |
|
| 109 | - $this->log = $log; |
|
| 110 | - $this->dbc = $dbc; |
|
| 111 | - $this->l = $l; |
|
| 112 | - $this->config = $config; |
|
| 113 | - $this->encryptionManager = $encryptionManager; |
|
| 114 | - $this->userManager = $userManager; |
|
| 115 | - $this->lockingProvider = $lockingProvider; |
|
| 116 | - $this->request = $request; |
|
| 117 | - $this->url = $url; |
|
| 118 | - $this->accountManager = $accountManager; |
|
| 119 | - $this->groupManager = $groupManager; |
|
| 120 | - $this->l10nFactory = $l10nFactory; |
|
| 121 | - $this->appManager = $appManager; |
|
| 122 | - } |
|
| 123 | - |
|
| 124 | - /** @var array */ |
|
| 125 | - protected $sectionClasses = []; |
|
| 126 | - |
|
| 127 | - /** @var array */ |
|
| 128 | - protected $sections = []; |
|
| 129 | - |
|
| 130 | - /** |
|
| 131 | - * @param string $type 'admin' or 'personal' |
|
| 132 | - * @param string $section Class must implement OCP\Settings\ISection |
|
| 133 | - * @return void |
|
| 134 | - */ |
|
| 135 | - public function registerSection(string $type, string $section) { |
|
| 136 | - $this->sectionClasses[$section] = $type; |
|
| 137 | - } |
|
| 138 | - |
|
| 139 | - /** |
|
| 140 | - * @param string $type 'admin' or 'personal' |
|
| 141 | - * @return ISection[] |
|
| 142 | - */ |
|
| 143 | - protected function getSections(string $type): array { |
|
| 144 | - if (!isset($this->sections[$type])) { |
|
| 145 | - $this->sections[$type] = []; |
|
| 146 | - } |
|
| 147 | - |
|
| 148 | - foreach ($this->sectionClasses as $class => $sectionType) { |
|
| 149 | - try { |
|
| 150 | - /** @var ISection $section */ |
|
| 151 | - $section = \OC::$server->query($class); |
|
| 152 | - } catch (QueryException $e) { |
|
| 153 | - $this->log->logException($e, ['level' => ILogger::INFO]); |
|
| 154 | - continue; |
|
| 155 | - } |
|
| 156 | - |
|
| 157 | - if (!$section instanceof ISection) { |
|
| 158 | - $this->log->logException(new \InvalidArgumentException('Invalid settings section registered'), ['level' => ILogger::INFO]); |
|
| 159 | - continue; |
|
| 160 | - } |
|
| 161 | - |
|
| 162 | - $this->sections[$sectionType][$section->getID()] = $section; |
|
| 163 | - |
|
| 164 | - unset($this->sectionClasses[$class]); |
|
| 165 | - } |
|
| 166 | - |
|
| 167 | - return $this->sections[$type]; |
|
| 168 | - } |
|
| 169 | - |
|
| 170 | - /** @var array */ |
|
| 171 | - protected $settingClasses = []; |
|
| 172 | - |
|
| 173 | - /** @var array */ |
|
| 174 | - protected $settings = []; |
|
| 175 | - |
|
| 176 | - /** |
|
| 177 | - * @param string $type 'admin' or 'personal' |
|
| 178 | - * @param string $setting Class must implement OCP\Settings\ISetting |
|
| 179 | - * @return void |
|
| 180 | - */ |
|
| 181 | - public function registerSetting(string $type, string $setting) { |
|
| 182 | - $this->settingClasses[$setting] = $type; |
|
| 183 | - } |
|
| 184 | - |
|
| 185 | - /** |
|
| 186 | - * @param string $type 'admin' or 'personal' |
|
| 187 | - * @param string $section |
|
| 188 | - * @return ISettings[] |
|
| 189 | - */ |
|
| 190 | - protected function getSettings(string $type, string $section): array { |
|
| 191 | - if (!isset($this->settings[$type])) { |
|
| 192 | - $this->settings[$type] = []; |
|
| 193 | - } |
|
| 194 | - if (!isset($this->settings[$type][$section])) { |
|
| 195 | - $this->settings[$type][$section] = []; |
|
| 196 | - } |
|
| 197 | - |
|
| 198 | - foreach ($this->settingClasses as $class => $settingsType) { |
|
| 199 | - try { |
|
| 200 | - /** @var ISettings $setting */ |
|
| 201 | - $setting = \OC::$server->query($class); |
|
| 202 | - } catch (QueryException $e) { |
|
| 203 | - $this->log->logException($e, ['level' => ILogger::INFO]); |
|
| 204 | - continue; |
|
| 205 | - } |
|
| 206 | - |
|
| 207 | - if (!$setting instanceof ISettings) { |
|
| 208 | - $this->log->logException(new \InvalidArgumentException('Invalid settings setting registered'), ['level' => ILogger::INFO]); |
|
| 209 | - continue; |
|
| 210 | - } |
|
| 211 | - |
|
| 212 | - if (!isset($this->settings[$settingsType][$setting->getSection()])) { |
|
| 213 | - $this->settings[$settingsType][$setting->getSection()] = []; |
|
| 214 | - } |
|
| 215 | - $this->settings[$settingsType][$setting->getSection()][] = $setting; |
|
| 216 | - |
|
| 217 | - unset($this->settingClasses[$class]); |
|
| 218 | - } |
|
| 219 | - |
|
| 220 | - return $this->settings[$type][$section]; |
|
| 221 | - } |
|
| 222 | - |
|
| 223 | - /** |
|
| 224 | - * @inheritdoc |
|
| 225 | - */ |
|
| 226 | - public function getAdminSections(): array { |
|
| 227 | - // built-in sections |
|
| 228 | - $sections = [ |
|
| 229 | - 0 => [new Section('overview', $this->l->t('Overview'), 0, $this->url->imagePath('settings', 'admin.svg'))], |
|
| 230 | - 1 => [new Section('server', $this->l->t('Basic settings'), 0, $this->url->imagePath('core', 'actions/settings-dark.svg'))], |
|
| 231 | - 5 => [new Section('sharing', $this->l->t('Sharing'), 0, $this->url->imagePath('core', 'actions/share.svg'))], |
|
| 232 | - 10 => [new Section('security', $this->l->t('Security'), 0, $this->url->imagePath('core', 'actions/password.svg'))], |
|
| 233 | - 45 => [new Section('encryption', $this->l->t('Encryption'), 0, $this->url->imagePath('core', 'actions/password.svg'))], |
|
| 234 | - 98 => [new Section('additional', $this->l->t('Additional settings'), 0, $this->url->imagePath('core', 'actions/settings-dark.svg'))], |
|
| 235 | - ]; |
|
| 236 | - |
|
| 237 | - $appSections = $this->getSections('admin'); |
|
| 238 | - |
|
| 239 | - foreach ($appSections as $section) { |
|
| 240 | - /** @var ISection $section */ |
|
| 241 | - if (!isset($sections[$section->getPriority()])) { |
|
| 242 | - $sections[$section->getPriority()] = []; |
|
| 243 | - } |
|
| 244 | - |
|
| 245 | - $sections[$section->getPriority()][] = $section; |
|
| 246 | - } |
|
| 247 | - |
|
| 248 | - ksort($sections); |
|
| 249 | - |
|
| 250 | - return $sections; |
|
| 251 | - } |
|
| 252 | - |
|
| 253 | - /** |
|
| 254 | - * @param string $section |
|
| 255 | - * @return ISection[] |
|
| 256 | - */ |
|
| 257 | - private function getBuiltInAdminSettings($section): array { |
|
| 258 | - $forms = []; |
|
| 259 | - |
|
| 260 | - if ($section === 'overview') { |
|
| 261 | - /** @var ISettings $form */ |
|
| 262 | - $form = new Admin\Overview($this->dbc, $this->request, $this->config, $this->lockingProvider, $this->l); |
|
| 263 | - $forms[$form->getPriority()] = [$form]; |
|
| 264 | - $form = new Admin\ServerDevNotice(); |
|
| 265 | - $forms[$form->getPriority()] = [$form]; |
|
| 266 | - } |
|
| 267 | - if ($section === 'server') { |
|
| 268 | - /** @var ISettings $form */ |
|
| 269 | - $form = new Admin\Server($this->dbc, $this->request, $this->config, $this->lockingProvider, $this->l); |
|
| 270 | - $forms[$form->getPriority()] = [$form]; |
|
| 271 | - $form = new Admin\Mail($this->config); |
|
| 272 | - $forms[$form->getPriority()] = [$form]; |
|
| 273 | - } |
|
| 274 | - if ($section === 'encryption') { |
|
| 275 | - /** @var ISettings $form */ |
|
| 276 | - $form = new Admin\Encryption($this->encryptionManager, $this->userManager); |
|
| 277 | - $forms[$form->getPriority()] = [$form]; |
|
| 278 | - } |
|
| 279 | - if ($section === 'sharing') { |
|
| 280 | - /** @var ISettings $form */ |
|
| 281 | - $form = new Admin\Sharing($this->config, $this->l); |
|
| 282 | - $forms[$form->getPriority()] = [$form]; |
|
| 283 | - } |
|
| 284 | - |
|
| 285 | - return $forms; |
|
| 286 | - } |
|
| 287 | - |
|
| 288 | - /** |
|
| 289 | - * @param string $section |
|
| 290 | - * @return ISection[] |
|
| 291 | - */ |
|
| 292 | - private function getBuiltInPersonalSettings($section): array { |
|
| 293 | - $forms = []; |
|
| 294 | - |
|
| 295 | - if ($section === 'personal-info') { |
|
| 296 | - /** @var ISettings $form */ |
|
| 297 | - $form = new Personal\PersonalInfo( |
|
| 298 | - $this->config, |
|
| 299 | - $this->userManager, |
|
| 300 | - $this->groupManager, |
|
| 301 | - $this->accountManager, |
|
| 302 | - $this->appManager, |
|
| 303 | - $this->l10nFactory, |
|
| 304 | - $this->l |
|
| 305 | - ); |
|
| 306 | - $forms[$form->getPriority()] = [$form]; |
|
| 307 | - } |
|
| 308 | - if($section === 'security') { |
|
| 309 | - /** @var ISettings $form */ |
|
| 310 | - $form = new Personal\Security(); |
|
| 311 | - $forms[$form->getPriority()] = [$form]; |
|
| 312 | - } |
|
| 313 | - if ($section === 'additional') { |
|
| 314 | - /** @var ISettings $form */ |
|
| 315 | - $form = new Personal\Additional(); |
|
| 316 | - $forms[$form->getPriority()] = [$form]; |
|
| 317 | - } |
|
| 318 | - |
|
| 319 | - return $forms; |
|
| 320 | - } |
|
| 321 | - |
|
| 322 | - /** |
|
| 323 | - * @inheritdoc |
|
| 324 | - */ |
|
| 325 | - public function getAdminSettings($section): array { |
|
| 326 | - $settings = $this->getBuiltInAdminSettings($section); |
|
| 327 | - $appSettings = $this->getSettings('admin', $section); |
|
| 328 | - |
|
| 329 | - foreach ($appSettings as $setting) { |
|
| 330 | - if (!isset($settings[$setting->getPriority()])) { |
|
| 331 | - $settings[$setting->getPriority()] = []; |
|
| 332 | - } |
|
| 333 | - $settings[$setting->getPriority()][] = $setting; |
|
| 334 | - } |
|
| 335 | - |
|
| 336 | - ksort($settings); |
|
| 337 | - return $settings; |
|
| 338 | - } |
|
| 339 | - |
|
| 340 | - /** |
|
| 341 | - * @inheritdoc |
|
| 342 | - */ |
|
| 343 | - public function getPersonalSections(): array { |
|
| 344 | - $sections = [ |
|
| 345 | - 0 => [new Section('personal-info', $this->l->t('Personal info'), 0, $this->url->imagePath('core', 'actions/info.svg'))], |
|
| 346 | - 5 => [new Section('security', $this->l->t('Security'), 0, $this->url->imagePath('settings', 'password.svg'))], |
|
| 347 | - 15 => [new Section('sync-clients', $this->l->t('Mobile & desktop'), 0, $this->url->imagePath('core', 'clients/phone.svg'))], |
|
| 348 | - ]; |
|
| 349 | - |
|
| 350 | - $legacyForms = \OC_App::getForms('personal'); |
|
| 351 | - if(!empty($legacyForms) && $this->hasLegacyPersonalSettingsToRender($legacyForms)) { |
|
| 352 | - $sections[98] = [new Section('additional', $this->l->t('Additional settings'), 0, $this->url->imagePath('core', 'actions/settings-dark.svg'))]; |
|
| 353 | - } |
|
| 354 | - |
|
| 355 | - $appSections = $this->getSections('personal'); |
|
| 356 | - |
|
| 357 | - foreach ($appSections as $section) { |
|
| 358 | - /** @var ISection $section */ |
|
| 359 | - if (!isset($sections[$section->getPriority()])) { |
|
| 360 | - $sections[$section->getPriority()] = []; |
|
| 361 | - } |
|
| 362 | - |
|
| 363 | - $sections[$section->getPriority()][] = $section; |
|
| 364 | - } |
|
| 365 | - |
|
| 366 | - ksort($sections); |
|
| 367 | - |
|
| 368 | - return $sections; |
|
| 369 | - } |
|
| 370 | - |
|
| 371 | - /** |
|
| 372 | - * @param string[] $forms |
|
| 373 | - * @return bool |
|
| 374 | - */ |
|
| 375 | - private function hasLegacyPersonalSettingsToRender(array $forms): bool { |
|
| 376 | - foreach ($forms as $form) { |
|
| 377 | - if(trim($form) !== '') { |
|
| 378 | - return true; |
|
| 379 | - } |
|
| 380 | - } |
|
| 381 | - return false; |
|
| 382 | - } |
|
| 383 | - |
|
| 384 | - /** |
|
| 385 | - * @inheritdoc |
|
| 386 | - */ |
|
| 387 | - public function getPersonalSettings($section): array { |
|
| 388 | - $settings = $this->getBuiltInPersonalSettings($section); |
|
| 389 | - $appSettings = $this->getSettings('personal', $section); |
|
| 390 | - |
|
| 391 | - foreach ($appSettings as $setting) { |
|
| 392 | - if (!isset($settings[$setting->getPriority()])) { |
|
| 393 | - $settings[$setting->getPriority()] = []; |
|
| 394 | - } |
|
| 395 | - $settings[$setting->getPriority()][] = $setting; |
|
| 396 | - } |
|
| 397 | - |
|
| 398 | - ksort($settings); |
|
| 399 | - return $settings; |
|
| 400 | - } |
|
| 52 | + /** @var ILogger */ |
|
| 53 | + private $log; |
|
| 54 | + /** @var IDBConnection */ |
|
| 55 | + private $dbc; |
|
| 56 | + /** @var IL10N */ |
|
| 57 | + private $l; |
|
| 58 | + /** @var IConfig */ |
|
| 59 | + private $config; |
|
| 60 | + /** @var EncryptionManager */ |
|
| 61 | + private $encryptionManager; |
|
| 62 | + /** @var IUserManager */ |
|
| 63 | + private $userManager; |
|
| 64 | + /** @var ILockingProvider */ |
|
| 65 | + private $lockingProvider; |
|
| 66 | + /** @var IRequest */ |
|
| 67 | + private $request; |
|
| 68 | + /** @var IURLGenerator */ |
|
| 69 | + private $url; |
|
| 70 | + /** @var AccountManager */ |
|
| 71 | + private $accountManager; |
|
| 72 | + /** @var IGroupManager */ |
|
| 73 | + private $groupManager; |
|
| 74 | + /** @var IFactory */ |
|
| 75 | + private $l10nFactory; |
|
| 76 | + /** @var IAppManager */ |
|
| 77 | + private $appManager; |
|
| 78 | + |
|
| 79 | + /** |
|
| 80 | + * @param ILogger $log |
|
| 81 | + * @param IDBConnection $dbc |
|
| 82 | + * @param IL10N $l |
|
| 83 | + * @param IConfig $config |
|
| 84 | + * @param EncryptionManager $encryptionManager |
|
| 85 | + * @param IUserManager $userManager |
|
| 86 | + * @param ILockingProvider $lockingProvider |
|
| 87 | + * @param IRequest $request |
|
| 88 | + * @param IURLGenerator $url |
|
| 89 | + * @param AccountManager $accountManager |
|
| 90 | + * @param IGroupManager $groupManager |
|
| 91 | + * @param IFactory $l10nFactory |
|
| 92 | + * @param IAppManager $appManager |
|
| 93 | + */ |
|
| 94 | + public function __construct( |
|
| 95 | + ILogger $log, |
|
| 96 | + IDBConnection $dbc, |
|
| 97 | + IL10N $l, |
|
| 98 | + IConfig $config, |
|
| 99 | + EncryptionManager $encryptionManager, |
|
| 100 | + IUserManager $userManager, |
|
| 101 | + ILockingProvider $lockingProvider, |
|
| 102 | + IRequest $request, |
|
| 103 | + IURLGenerator $url, |
|
| 104 | + AccountManager $accountManager, |
|
| 105 | + IGroupManager $groupManager, |
|
| 106 | + IFactory $l10nFactory, |
|
| 107 | + IAppManager $appManager |
|
| 108 | + ) { |
|
| 109 | + $this->log = $log; |
|
| 110 | + $this->dbc = $dbc; |
|
| 111 | + $this->l = $l; |
|
| 112 | + $this->config = $config; |
|
| 113 | + $this->encryptionManager = $encryptionManager; |
|
| 114 | + $this->userManager = $userManager; |
|
| 115 | + $this->lockingProvider = $lockingProvider; |
|
| 116 | + $this->request = $request; |
|
| 117 | + $this->url = $url; |
|
| 118 | + $this->accountManager = $accountManager; |
|
| 119 | + $this->groupManager = $groupManager; |
|
| 120 | + $this->l10nFactory = $l10nFactory; |
|
| 121 | + $this->appManager = $appManager; |
|
| 122 | + } |
|
| 123 | + |
|
| 124 | + /** @var array */ |
|
| 125 | + protected $sectionClasses = []; |
|
| 126 | + |
|
| 127 | + /** @var array */ |
|
| 128 | + protected $sections = []; |
|
| 129 | + |
|
| 130 | + /** |
|
| 131 | + * @param string $type 'admin' or 'personal' |
|
| 132 | + * @param string $section Class must implement OCP\Settings\ISection |
|
| 133 | + * @return void |
|
| 134 | + */ |
|
| 135 | + public function registerSection(string $type, string $section) { |
|
| 136 | + $this->sectionClasses[$section] = $type; |
|
| 137 | + } |
|
| 138 | + |
|
| 139 | + /** |
|
| 140 | + * @param string $type 'admin' or 'personal' |
|
| 141 | + * @return ISection[] |
|
| 142 | + */ |
|
| 143 | + protected function getSections(string $type): array { |
|
| 144 | + if (!isset($this->sections[$type])) { |
|
| 145 | + $this->sections[$type] = []; |
|
| 146 | + } |
|
| 147 | + |
|
| 148 | + foreach ($this->sectionClasses as $class => $sectionType) { |
|
| 149 | + try { |
|
| 150 | + /** @var ISection $section */ |
|
| 151 | + $section = \OC::$server->query($class); |
|
| 152 | + } catch (QueryException $e) { |
|
| 153 | + $this->log->logException($e, ['level' => ILogger::INFO]); |
|
| 154 | + continue; |
|
| 155 | + } |
|
| 156 | + |
|
| 157 | + if (!$section instanceof ISection) { |
|
| 158 | + $this->log->logException(new \InvalidArgumentException('Invalid settings section registered'), ['level' => ILogger::INFO]); |
|
| 159 | + continue; |
|
| 160 | + } |
|
| 161 | + |
|
| 162 | + $this->sections[$sectionType][$section->getID()] = $section; |
|
| 163 | + |
|
| 164 | + unset($this->sectionClasses[$class]); |
|
| 165 | + } |
|
| 166 | + |
|
| 167 | + return $this->sections[$type]; |
|
| 168 | + } |
|
| 169 | + |
|
| 170 | + /** @var array */ |
|
| 171 | + protected $settingClasses = []; |
|
| 172 | + |
|
| 173 | + /** @var array */ |
|
| 174 | + protected $settings = []; |
|
| 175 | + |
|
| 176 | + /** |
|
| 177 | + * @param string $type 'admin' or 'personal' |
|
| 178 | + * @param string $setting Class must implement OCP\Settings\ISetting |
|
| 179 | + * @return void |
|
| 180 | + */ |
|
| 181 | + public function registerSetting(string $type, string $setting) { |
|
| 182 | + $this->settingClasses[$setting] = $type; |
|
| 183 | + } |
|
| 184 | + |
|
| 185 | + /** |
|
| 186 | + * @param string $type 'admin' or 'personal' |
|
| 187 | + * @param string $section |
|
| 188 | + * @return ISettings[] |
|
| 189 | + */ |
|
| 190 | + protected function getSettings(string $type, string $section): array { |
|
| 191 | + if (!isset($this->settings[$type])) { |
|
| 192 | + $this->settings[$type] = []; |
|
| 193 | + } |
|
| 194 | + if (!isset($this->settings[$type][$section])) { |
|
| 195 | + $this->settings[$type][$section] = []; |
|
| 196 | + } |
|
| 197 | + |
|
| 198 | + foreach ($this->settingClasses as $class => $settingsType) { |
|
| 199 | + try { |
|
| 200 | + /** @var ISettings $setting */ |
|
| 201 | + $setting = \OC::$server->query($class); |
|
| 202 | + } catch (QueryException $e) { |
|
| 203 | + $this->log->logException($e, ['level' => ILogger::INFO]); |
|
| 204 | + continue; |
|
| 205 | + } |
|
| 206 | + |
|
| 207 | + if (!$setting instanceof ISettings) { |
|
| 208 | + $this->log->logException(new \InvalidArgumentException('Invalid settings setting registered'), ['level' => ILogger::INFO]); |
|
| 209 | + continue; |
|
| 210 | + } |
|
| 211 | + |
|
| 212 | + if (!isset($this->settings[$settingsType][$setting->getSection()])) { |
|
| 213 | + $this->settings[$settingsType][$setting->getSection()] = []; |
|
| 214 | + } |
|
| 215 | + $this->settings[$settingsType][$setting->getSection()][] = $setting; |
|
| 216 | + |
|
| 217 | + unset($this->settingClasses[$class]); |
|
| 218 | + } |
|
| 219 | + |
|
| 220 | + return $this->settings[$type][$section]; |
|
| 221 | + } |
|
| 222 | + |
|
| 223 | + /** |
|
| 224 | + * @inheritdoc |
|
| 225 | + */ |
|
| 226 | + public function getAdminSections(): array { |
|
| 227 | + // built-in sections |
|
| 228 | + $sections = [ |
|
| 229 | + 0 => [new Section('overview', $this->l->t('Overview'), 0, $this->url->imagePath('settings', 'admin.svg'))], |
|
| 230 | + 1 => [new Section('server', $this->l->t('Basic settings'), 0, $this->url->imagePath('core', 'actions/settings-dark.svg'))], |
|
| 231 | + 5 => [new Section('sharing', $this->l->t('Sharing'), 0, $this->url->imagePath('core', 'actions/share.svg'))], |
|
| 232 | + 10 => [new Section('security', $this->l->t('Security'), 0, $this->url->imagePath('core', 'actions/password.svg'))], |
|
| 233 | + 45 => [new Section('encryption', $this->l->t('Encryption'), 0, $this->url->imagePath('core', 'actions/password.svg'))], |
|
| 234 | + 98 => [new Section('additional', $this->l->t('Additional settings'), 0, $this->url->imagePath('core', 'actions/settings-dark.svg'))], |
|
| 235 | + ]; |
|
| 236 | + |
|
| 237 | + $appSections = $this->getSections('admin'); |
|
| 238 | + |
|
| 239 | + foreach ($appSections as $section) { |
|
| 240 | + /** @var ISection $section */ |
|
| 241 | + if (!isset($sections[$section->getPriority()])) { |
|
| 242 | + $sections[$section->getPriority()] = []; |
|
| 243 | + } |
|
| 244 | + |
|
| 245 | + $sections[$section->getPriority()][] = $section; |
|
| 246 | + } |
|
| 247 | + |
|
| 248 | + ksort($sections); |
|
| 249 | + |
|
| 250 | + return $sections; |
|
| 251 | + } |
|
| 252 | + |
|
| 253 | + /** |
|
| 254 | + * @param string $section |
|
| 255 | + * @return ISection[] |
|
| 256 | + */ |
|
| 257 | + private function getBuiltInAdminSettings($section): array { |
|
| 258 | + $forms = []; |
|
| 259 | + |
|
| 260 | + if ($section === 'overview') { |
|
| 261 | + /** @var ISettings $form */ |
|
| 262 | + $form = new Admin\Overview($this->dbc, $this->request, $this->config, $this->lockingProvider, $this->l); |
|
| 263 | + $forms[$form->getPriority()] = [$form]; |
|
| 264 | + $form = new Admin\ServerDevNotice(); |
|
| 265 | + $forms[$form->getPriority()] = [$form]; |
|
| 266 | + } |
|
| 267 | + if ($section === 'server') { |
|
| 268 | + /** @var ISettings $form */ |
|
| 269 | + $form = new Admin\Server($this->dbc, $this->request, $this->config, $this->lockingProvider, $this->l); |
|
| 270 | + $forms[$form->getPriority()] = [$form]; |
|
| 271 | + $form = new Admin\Mail($this->config); |
|
| 272 | + $forms[$form->getPriority()] = [$form]; |
|
| 273 | + } |
|
| 274 | + if ($section === 'encryption') { |
|
| 275 | + /** @var ISettings $form */ |
|
| 276 | + $form = new Admin\Encryption($this->encryptionManager, $this->userManager); |
|
| 277 | + $forms[$form->getPriority()] = [$form]; |
|
| 278 | + } |
|
| 279 | + if ($section === 'sharing') { |
|
| 280 | + /** @var ISettings $form */ |
|
| 281 | + $form = new Admin\Sharing($this->config, $this->l); |
|
| 282 | + $forms[$form->getPriority()] = [$form]; |
|
| 283 | + } |
|
| 284 | + |
|
| 285 | + return $forms; |
|
| 286 | + } |
|
| 287 | + |
|
| 288 | + /** |
|
| 289 | + * @param string $section |
|
| 290 | + * @return ISection[] |
|
| 291 | + */ |
|
| 292 | + private function getBuiltInPersonalSettings($section): array { |
|
| 293 | + $forms = []; |
|
| 294 | + |
|
| 295 | + if ($section === 'personal-info') { |
|
| 296 | + /** @var ISettings $form */ |
|
| 297 | + $form = new Personal\PersonalInfo( |
|
| 298 | + $this->config, |
|
| 299 | + $this->userManager, |
|
| 300 | + $this->groupManager, |
|
| 301 | + $this->accountManager, |
|
| 302 | + $this->appManager, |
|
| 303 | + $this->l10nFactory, |
|
| 304 | + $this->l |
|
| 305 | + ); |
|
| 306 | + $forms[$form->getPriority()] = [$form]; |
|
| 307 | + } |
|
| 308 | + if($section === 'security') { |
|
| 309 | + /** @var ISettings $form */ |
|
| 310 | + $form = new Personal\Security(); |
|
| 311 | + $forms[$form->getPriority()] = [$form]; |
|
| 312 | + } |
|
| 313 | + if ($section === 'additional') { |
|
| 314 | + /** @var ISettings $form */ |
|
| 315 | + $form = new Personal\Additional(); |
|
| 316 | + $forms[$form->getPriority()] = [$form]; |
|
| 317 | + } |
|
| 318 | + |
|
| 319 | + return $forms; |
|
| 320 | + } |
|
| 321 | + |
|
| 322 | + /** |
|
| 323 | + * @inheritdoc |
|
| 324 | + */ |
|
| 325 | + public function getAdminSettings($section): array { |
|
| 326 | + $settings = $this->getBuiltInAdminSettings($section); |
|
| 327 | + $appSettings = $this->getSettings('admin', $section); |
|
| 328 | + |
|
| 329 | + foreach ($appSettings as $setting) { |
|
| 330 | + if (!isset($settings[$setting->getPriority()])) { |
|
| 331 | + $settings[$setting->getPriority()] = []; |
|
| 332 | + } |
|
| 333 | + $settings[$setting->getPriority()][] = $setting; |
|
| 334 | + } |
|
| 335 | + |
|
| 336 | + ksort($settings); |
|
| 337 | + return $settings; |
|
| 338 | + } |
|
| 339 | + |
|
| 340 | + /** |
|
| 341 | + * @inheritdoc |
|
| 342 | + */ |
|
| 343 | + public function getPersonalSections(): array { |
|
| 344 | + $sections = [ |
|
| 345 | + 0 => [new Section('personal-info', $this->l->t('Personal info'), 0, $this->url->imagePath('core', 'actions/info.svg'))], |
|
| 346 | + 5 => [new Section('security', $this->l->t('Security'), 0, $this->url->imagePath('settings', 'password.svg'))], |
|
| 347 | + 15 => [new Section('sync-clients', $this->l->t('Mobile & desktop'), 0, $this->url->imagePath('core', 'clients/phone.svg'))], |
|
| 348 | + ]; |
|
| 349 | + |
|
| 350 | + $legacyForms = \OC_App::getForms('personal'); |
|
| 351 | + if(!empty($legacyForms) && $this->hasLegacyPersonalSettingsToRender($legacyForms)) { |
|
| 352 | + $sections[98] = [new Section('additional', $this->l->t('Additional settings'), 0, $this->url->imagePath('core', 'actions/settings-dark.svg'))]; |
|
| 353 | + } |
|
| 354 | + |
|
| 355 | + $appSections = $this->getSections('personal'); |
|
| 356 | + |
|
| 357 | + foreach ($appSections as $section) { |
|
| 358 | + /** @var ISection $section */ |
|
| 359 | + if (!isset($sections[$section->getPriority()])) { |
|
| 360 | + $sections[$section->getPriority()] = []; |
|
| 361 | + } |
|
| 362 | + |
|
| 363 | + $sections[$section->getPriority()][] = $section; |
|
| 364 | + } |
|
| 365 | + |
|
| 366 | + ksort($sections); |
|
| 367 | + |
|
| 368 | + return $sections; |
|
| 369 | + } |
|
| 370 | + |
|
| 371 | + /** |
|
| 372 | + * @param string[] $forms |
|
| 373 | + * @return bool |
|
| 374 | + */ |
|
| 375 | + private function hasLegacyPersonalSettingsToRender(array $forms): bool { |
|
| 376 | + foreach ($forms as $form) { |
|
| 377 | + if(trim($form) !== '') { |
|
| 378 | + return true; |
|
| 379 | + } |
|
| 380 | + } |
|
| 381 | + return false; |
|
| 382 | + } |
|
| 383 | + |
|
| 384 | + /** |
|
| 385 | + * @inheritdoc |
|
| 386 | + */ |
|
| 387 | + public function getPersonalSettings($section): array { |
|
| 388 | + $settings = $this->getBuiltInPersonalSettings($section); |
|
| 389 | + $appSettings = $this->getSettings('personal', $section); |
|
| 390 | + |
|
| 391 | + foreach ($appSettings as $setting) { |
|
| 392 | + if (!isset($settings[$setting->getPriority()])) { |
|
| 393 | + $settings[$setting->getPriority()] = []; |
|
| 394 | + } |
|
| 395 | + $settings[$setting->getPriority()][] = $setting; |
|
| 396 | + } |
|
| 397 | + |
|
| 398 | + ksort($settings); |
|
| 399 | + return $settings; |
|
| 400 | + } |
|
| 401 | 401 | } |
@@ -53,277 +53,277 @@ discard block |
||
| 53 | 53 | * @package OC\Settings\Controller |
| 54 | 54 | */ |
| 55 | 55 | class CheckSetupController extends Controller { |
| 56 | - /** @var IConfig */ |
|
| 57 | - private $config; |
|
| 58 | - /** @var IClientService */ |
|
| 59 | - private $clientService; |
|
| 60 | - /** @var \OC_Util */ |
|
| 61 | - private $util; |
|
| 62 | - /** @var IURLGenerator */ |
|
| 63 | - private $urlGenerator; |
|
| 64 | - /** @var IL10N */ |
|
| 65 | - private $l10n; |
|
| 66 | - /** @var Checker */ |
|
| 67 | - private $checker; |
|
| 68 | - /** @var ILogger */ |
|
| 69 | - private $logger; |
|
| 70 | - /** @var EventDispatcherInterface */ |
|
| 71 | - private $dispatcher; |
|
| 72 | - |
|
| 73 | - public function __construct($AppName, |
|
| 74 | - IRequest $request, |
|
| 75 | - IConfig $config, |
|
| 76 | - IClientService $clientService, |
|
| 77 | - IURLGenerator $urlGenerator, |
|
| 78 | - \OC_Util $util, |
|
| 79 | - IL10N $l10n, |
|
| 80 | - Checker $checker, |
|
| 81 | - ILogger $logger, |
|
| 82 | - EventDispatcherInterface $dispatcher) { |
|
| 83 | - parent::__construct($AppName, $request); |
|
| 84 | - $this->config = $config; |
|
| 85 | - $this->clientService = $clientService; |
|
| 86 | - $this->util = $util; |
|
| 87 | - $this->urlGenerator = $urlGenerator; |
|
| 88 | - $this->l10n = $l10n; |
|
| 89 | - $this->checker = $checker; |
|
| 90 | - $this->logger = $logger; |
|
| 91 | - $this->dispatcher = $dispatcher; |
|
| 92 | - } |
|
| 93 | - |
|
| 94 | - /** |
|
| 95 | - * Checks if the server can connect to the internet using HTTPS and HTTP |
|
| 96 | - * @return bool |
|
| 97 | - */ |
|
| 98 | - private function isInternetConnectionWorking() { |
|
| 99 | - if ($this->config->getSystemValue('has_internet_connection', true) === false) { |
|
| 100 | - return false; |
|
| 101 | - } |
|
| 102 | - |
|
| 103 | - $siteArray = ['www.nextcloud.com', |
|
| 104 | - 'www.startpage.com', |
|
| 105 | - 'www.eff.org', |
|
| 106 | - 'www.edri.org', |
|
| 107 | - ]; |
|
| 108 | - |
|
| 109 | - foreach($siteArray as $site) { |
|
| 110 | - if ($this->isSiteReachable($site)) { |
|
| 111 | - return true; |
|
| 112 | - } |
|
| 113 | - } |
|
| 114 | - return false; |
|
| 115 | - } |
|
| 116 | - |
|
| 117 | - /** |
|
| 118 | - * Checks if the Nextcloud server can connect to a specific URL using both HTTPS and HTTP |
|
| 119 | - * @return bool |
|
| 120 | - */ |
|
| 121 | - private function isSiteReachable($sitename) { |
|
| 122 | - $httpSiteName = 'http://' . $sitename . '/'; |
|
| 123 | - $httpsSiteName = 'https://' . $sitename . '/'; |
|
| 124 | - |
|
| 125 | - try { |
|
| 126 | - $client = $this->clientService->newClient(); |
|
| 127 | - $client->get($httpSiteName); |
|
| 128 | - $client->get($httpsSiteName); |
|
| 129 | - } catch (\Exception $e) { |
|
| 130 | - $this->logger->logException($e, ['app' => 'internet_connection_check']); |
|
| 131 | - return false; |
|
| 132 | - } |
|
| 133 | - return true; |
|
| 134 | - } |
|
| 135 | - |
|
| 136 | - /** |
|
| 137 | - * Checks whether a local memcache is installed or not |
|
| 138 | - * @return bool |
|
| 139 | - */ |
|
| 140 | - private function isMemcacheConfigured() { |
|
| 141 | - return $this->config->getSystemValue('memcache.local', null) !== null; |
|
| 142 | - } |
|
| 143 | - |
|
| 144 | - /** |
|
| 145 | - * Whether /dev/urandom is available to the PHP controller |
|
| 146 | - * |
|
| 147 | - * @return bool |
|
| 148 | - */ |
|
| 149 | - private function isUrandomAvailable() { |
|
| 150 | - if(@file_exists('/dev/urandom')) { |
|
| 151 | - $file = fopen('/dev/urandom', 'rb'); |
|
| 152 | - if($file) { |
|
| 153 | - fclose($file); |
|
| 154 | - return true; |
|
| 155 | - } |
|
| 156 | - } |
|
| 157 | - |
|
| 158 | - return false; |
|
| 159 | - } |
|
| 160 | - |
|
| 161 | - /** |
|
| 162 | - * Public for the sake of unit-testing |
|
| 163 | - * |
|
| 164 | - * @return array |
|
| 165 | - */ |
|
| 166 | - protected function getCurlVersion() { |
|
| 167 | - return curl_version(); |
|
| 168 | - } |
|
| 169 | - |
|
| 170 | - /** |
|
| 171 | - * Check if the used SSL lib is outdated. Older OpenSSL and NSS versions do |
|
| 172 | - * have multiple bugs which likely lead to problems in combination with |
|
| 173 | - * functionality required by ownCloud such as SNI. |
|
| 174 | - * |
|
| 175 | - * @link https://github.com/owncloud/core/issues/17446#issuecomment-122877546 |
|
| 176 | - * @link https://bugzilla.redhat.com/show_bug.cgi?id=1241172 |
|
| 177 | - * @return string |
|
| 178 | - */ |
|
| 179 | - private function isUsedTlsLibOutdated() { |
|
| 180 | - // Don't run check when: |
|
| 181 | - // 1. Server has `has_internet_connection` set to false |
|
| 182 | - // 2. AppStore AND S2S is disabled |
|
| 183 | - if(!$this->config->getSystemValue('has_internet_connection', true)) { |
|
| 184 | - return ''; |
|
| 185 | - } |
|
| 186 | - if(!$this->config->getSystemValue('appstoreenabled', true) |
|
| 187 | - && $this->config->getAppValue('files_sharing', 'outgoing_server2server_share_enabled', 'yes') === 'no' |
|
| 188 | - && $this->config->getAppValue('files_sharing', 'incoming_server2server_share_enabled', 'yes') === 'no') { |
|
| 189 | - return ''; |
|
| 190 | - } |
|
| 191 | - |
|
| 192 | - $versionString = $this->getCurlVersion(); |
|
| 193 | - if(isset($versionString['ssl_version'])) { |
|
| 194 | - $versionString = $versionString['ssl_version']; |
|
| 195 | - } else { |
|
| 196 | - return ''; |
|
| 197 | - } |
|
| 198 | - |
|
| 199 | - $features = (string)$this->l10n->t('installing and updating apps via the app store or Federated Cloud Sharing'); |
|
| 200 | - if(!$this->config->getSystemValue('appstoreenabled', true)) { |
|
| 201 | - $features = (string)$this->l10n->t('Federated Cloud Sharing'); |
|
| 202 | - } |
|
| 203 | - |
|
| 204 | - // Check if at least OpenSSL after 1.01d or 1.0.2b |
|
| 205 | - if(strpos($versionString, 'OpenSSL/') === 0) { |
|
| 206 | - $majorVersion = substr($versionString, 8, 5); |
|
| 207 | - $patchRelease = substr($versionString, 13, 6); |
|
| 208 | - |
|
| 209 | - if(($majorVersion === '1.0.1' && ord($patchRelease) < ord('d')) || |
|
| 210 | - ($majorVersion === '1.0.2' && ord($patchRelease) < ord('b'))) { |
|
| 211 | - return (string) $this->l10n->t('cURL is using an outdated %s version (%s). Please update your operating system or features such as %s will not work reliably.', ['OpenSSL', $versionString, $features]); |
|
| 212 | - } |
|
| 213 | - } |
|
| 214 | - |
|
| 215 | - // Check if NSS and perform heuristic check |
|
| 216 | - if(strpos($versionString, 'NSS/') === 0) { |
|
| 217 | - try { |
|
| 218 | - $firstClient = $this->clientService->newClient(); |
|
| 219 | - $firstClient->get('https://nextcloud.com/'); |
|
| 220 | - |
|
| 221 | - $secondClient = $this->clientService->newClient(); |
|
| 222 | - $secondClient->get('https://nextcloud.com/'); |
|
| 223 | - } catch (ClientException $e) { |
|
| 224 | - if($e->getResponse()->getStatusCode() === 400) { |
|
| 225 | - return (string) $this->l10n->t('cURL is using an outdated %s version (%s). Please update your operating system or features such as %s will not work reliably.', ['NSS', $versionString, $features]); |
|
| 226 | - } |
|
| 227 | - } |
|
| 228 | - } |
|
| 229 | - |
|
| 230 | - return ''; |
|
| 231 | - } |
|
| 232 | - |
|
| 233 | - /** |
|
| 234 | - * Whether the version is outdated |
|
| 235 | - * |
|
| 236 | - * @return bool |
|
| 237 | - */ |
|
| 238 | - protected function isPhpOutdated() { |
|
| 239 | - if (version_compare(PHP_VERSION, '7.0.0', '<')) { |
|
| 240 | - return true; |
|
| 241 | - } |
|
| 242 | - |
|
| 243 | - return false; |
|
| 244 | - } |
|
| 245 | - |
|
| 246 | - /** |
|
| 247 | - * Whether the php version is still supported (at time of release) |
|
| 248 | - * according to: https://secure.php.net/supported-versions.php |
|
| 249 | - * |
|
| 250 | - * @return array |
|
| 251 | - */ |
|
| 252 | - private function isPhpSupported() { |
|
| 253 | - return ['eol' => $this->isPhpOutdated(), 'version' => PHP_VERSION]; |
|
| 254 | - } |
|
| 255 | - |
|
| 256 | - /** |
|
| 257 | - * Check if the reverse proxy configuration is working as expected |
|
| 258 | - * |
|
| 259 | - * @return bool |
|
| 260 | - */ |
|
| 261 | - private function forwardedForHeadersWorking() { |
|
| 262 | - $trustedProxies = $this->config->getSystemValue('trusted_proxies', []); |
|
| 263 | - $remoteAddress = $this->request->getRemoteAddress(); |
|
| 264 | - |
|
| 265 | - if (is_array($trustedProxies) && in_array($remoteAddress, $trustedProxies)) { |
|
| 266 | - return false; |
|
| 267 | - } |
|
| 268 | - |
|
| 269 | - // either not enabled or working correctly |
|
| 270 | - return true; |
|
| 271 | - } |
|
| 272 | - |
|
| 273 | - /** |
|
| 274 | - * Checks if the correct memcache module for PHP is installed. Only |
|
| 275 | - * fails if memcached is configured and the working module is not installed. |
|
| 276 | - * |
|
| 277 | - * @return bool |
|
| 278 | - */ |
|
| 279 | - private function isCorrectMemcachedPHPModuleInstalled() { |
|
| 280 | - if ($this->config->getSystemValue('memcache.distributed', null) !== '\OC\Memcache\Memcached') { |
|
| 281 | - return true; |
|
| 282 | - } |
|
| 283 | - |
|
| 284 | - // there are two different memcached modules for PHP |
|
| 285 | - // we only support memcached and not memcache |
|
| 286 | - // https://code.google.com/p/memcached/wiki/PHPClientComparison |
|
| 287 | - return !(!extension_loaded('memcached') && extension_loaded('memcache')); |
|
| 288 | - } |
|
| 289 | - |
|
| 290 | - /** |
|
| 291 | - * Checks if set_time_limit is not disabled. |
|
| 292 | - * |
|
| 293 | - * @return bool |
|
| 294 | - */ |
|
| 295 | - private function isSettimelimitAvailable() { |
|
| 296 | - if (function_exists('set_time_limit') |
|
| 297 | - && strpos(@ini_get('disable_functions'), 'set_time_limit') === false) { |
|
| 298 | - return true; |
|
| 299 | - } |
|
| 300 | - |
|
| 301 | - return false; |
|
| 302 | - } |
|
| 303 | - |
|
| 304 | - /** |
|
| 305 | - * @return RedirectResponse |
|
| 306 | - */ |
|
| 307 | - public function rescanFailedIntegrityCheck() { |
|
| 308 | - $this->checker->runInstanceVerification(); |
|
| 309 | - return new RedirectResponse( |
|
| 310 | - $this->urlGenerator->linkToRoute('settings.AdminSettings.index') |
|
| 311 | - ); |
|
| 312 | - } |
|
| 313 | - |
|
| 314 | - /** |
|
| 315 | - * @NoCSRFRequired |
|
| 316 | - * @return DataResponse |
|
| 317 | - */ |
|
| 318 | - public function getFailedIntegrityCheckFiles() { |
|
| 319 | - if(!$this->checker->isCodeCheckEnforced()) { |
|
| 320 | - return new DataDisplayResponse('Integrity checker has been disabled. Integrity cannot be verified.'); |
|
| 321 | - } |
|
| 322 | - |
|
| 323 | - $completeResults = $this->checker->getResults(); |
|
| 324 | - |
|
| 325 | - if(!empty($completeResults)) { |
|
| 326 | - $formattedTextResponse = 'Technical information |
|
| 56 | + /** @var IConfig */ |
|
| 57 | + private $config; |
|
| 58 | + /** @var IClientService */ |
|
| 59 | + private $clientService; |
|
| 60 | + /** @var \OC_Util */ |
|
| 61 | + private $util; |
|
| 62 | + /** @var IURLGenerator */ |
|
| 63 | + private $urlGenerator; |
|
| 64 | + /** @var IL10N */ |
|
| 65 | + private $l10n; |
|
| 66 | + /** @var Checker */ |
|
| 67 | + private $checker; |
|
| 68 | + /** @var ILogger */ |
|
| 69 | + private $logger; |
|
| 70 | + /** @var EventDispatcherInterface */ |
|
| 71 | + private $dispatcher; |
|
| 72 | + |
|
| 73 | + public function __construct($AppName, |
|
| 74 | + IRequest $request, |
|
| 75 | + IConfig $config, |
|
| 76 | + IClientService $clientService, |
|
| 77 | + IURLGenerator $urlGenerator, |
|
| 78 | + \OC_Util $util, |
|
| 79 | + IL10N $l10n, |
|
| 80 | + Checker $checker, |
|
| 81 | + ILogger $logger, |
|
| 82 | + EventDispatcherInterface $dispatcher) { |
|
| 83 | + parent::__construct($AppName, $request); |
|
| 84 | + $this->config = $config; |
|
| 85 | + $this->clientService = $clientService; |
|
| 86 | + $this->util = $util; |
|
| 87 | + $this->urlGenerator = $urlGenerator; |
|
| 88 | + $this->l10n = $l10n; |
|
| 89 | + $this->checker = $checker; |
|
| 90 | + $this->logger = $logger; |
|
| 91 | + $this->dispatcher = $dispatcher; |
|
| 92 | + } |
|
| 93 | + |
|
| 94 | + /** |
|
| 95 | + * Checks if the server can connect to the internet using HTTPS and HTTP |
|
| 96 | + * @return bool |
|
| 97 | + */ |
|
| 98 | + private function isInternetConnectionWorking() { |
|
| 99 | + if ($this->config->getSystemValue('has_internet_connection', true) === false) { |
|
| 100 | + return false; |
|
| 101 | + } |
|
| 102 | + |
|
| 103 | + $siteArray = ['www.nextcloud.com', |
|
| 104 | + 'www.startpage.com', |
|
| 105 | + 'www.eff.org', |
|
| 106 | + 'www.edri.org', |
|
| 107 | + ]; |
|
| 108 | + |
|
| 109 | + foreach($siteArray as $site) { |
|
| 110 | + if ($this->isSiteReachable($site)) { |
|
| 111 | + return true; |
|
| 112 | + } |
|
| 113 | + } |
|
| 114 | + return false; |
|
| 115 | + } |
|
| 116 | + |
|
| 117 | + /** |
|
| 118 | + * Checks if the Nextcloud server can connect to a specific URL using both HTTPS and HTTP |
|
| 119 | + * @return bool |
|
| 120 | + */ |
|
| 121 | + private function isSiteReachable($sitename) { |
|
| 122 | + $httpSiteName = 'http://' . $sitename . '/'; |
|
| 123 | + $httpsSiteName = 'https://' . $sitename . '/'; |
|
| 124 | + |
|
| 125 | + try { |
|
| 126 | + $client = $this->clientService->newClient(); |
|
| 127 | + $client->get($httpSiteName); |
|
| 128 | + $client->get($httpsSiteName); |
|
| 129 | + } catch (\Exception $e) { |
|
| 130 | + $this->logger->logException($e, ['app' => 'internet_connection_check']); |
|
| 131 | + return false; |
|
| 132 | + } |
|
| 133 | + return true; |
|
| 134 | + } |
|
| 135 | + |
|
| 136 | + /** |
|
| 137 | + * Checks whether a local memcache is installed or not |
|
| 138 | + * @return bool |
|
| 139 | + */ |
|
| 140 | + private function isMemcacheConfigured() { |
|
| 141 | + return $this->config->getSystemValue('memcache.local', null) !== null; |
|
| 142 | + } |
|
| 143 | + |
|
| 144 | + /** |
|
| 145 | + * Whether /dev/urandom is available to the PHP controller |
|
| 146 | + * |
|
| 147 | + * @return bool |
|
| 148 | + */ |
|
| 149 | + private function isUrandomAvailable() { |
|
| 150 | + if(@file_exists('/dev/urandom')) { |
|
| 151 | + $file = fopen('/dev/urandom', 'rb'); |
|
| 152 | + if($file) { |
|
| 153 | + fclose($file); |
|
| 154 | + return true; |
|
| 155 | + } |
|
| 156 | + } |
|
| 157 | + |
|
| 158 | + return false; |
|
| 159 | + } |
|
| 160 | + |
|
| 161 | + /** |
|
| 162 | + * Public for the sake of unit-testing |
|
| 163 | + * |
|
| 164 | + * @return array |
|
| 165 | + */ |
|
| 166 | + protected function getCurlVersion() { |
|
| 167 | + return curl_version(); |
|
| 168 | + } |
|
| 169 | + |
|
| 170 | + /** |
|
| 171 | + * Check if the used SSL lib is outdated. Older OpenSSL and NSS versions do |
|
| 172 | + * have multiple bugs which likely lead to problems in combination with |
|
| 173 | + * functionality required by ownCloud such as SNI. |
|
| 174 | + * |
|
| 175 | + * @link https://github.com/owncloud/core/issues/17446#issuecomment-122877546 |
|
| 176 | + * @link https://bugzilla.redhat.com/show_bug.cgi?id=1241172 |
|
| 177 | + * @return string |
|
| 178 | + */ |
|
| 179 | + private function isUsedTlsLibOutdated() { |
|
| 180 | + // Don't run check when: |
|
| 181 | + // 1. Server has `has_internet_connection` set to false |
|
| 182 | + // 2. AppStore AND S2S is disabled |
|
| 183 | + if(!$this->config->getSystemValue('has_internet_connection', true)) { |
|
| 184 | + return ''; |
|
| 185 | + } |
|
| 186 | + if(!$this->config->getSystemValue('appstoreenabled', true) |
|
| 187 | + && $this->config->getAppValue('files_sharing', 'outgoing_server2server_share_enabled', 'yes') === 'no' |
|
| 188 | + && $this->config->getAppValue('files_sharing', 'incoming_server2server_share_enabled', 'yes') === 'no') { |
|
| 189 | + return ''; |
|
| 190 | + } |
|
| 191 | + |
|
| 192 | + $versionString = $this->getCurlVersion(); |
|
| 193 | + if(isset($versionString['ssl_version'])) { |
|
| 194 | + $versionString = $versionString['ssl_version']; |
|
| 195 | + } else { |
|
| 196 | + return ''; |
|
| 197 | + } |
|
| 198 | + |
|
| 199 | + $features = (string)$this->l10n->t('installing and updating apps via the app store or Federated Cloud Sharing'); |
|
| 200 | + if(!$this->config->getSystemValue('appstoreenabled', true)) { |
|
| 201 | + $features = (string)$this->l10n->t('Federated Cloud Sharing'); |
|
| 202 | + } |
|
| 203 | + |
|
| 204 | + // Check if at least OpenSSL after 1.01d or 1.0.2b |
|
| 205 | + if(strpos($versionString, 'OpenSSL/') === 0) { |
|
| 206 | + $majorVersion = substr($versionString, 8, 5); |
|
| 207 | + $patchRelease = substr($versionString, 13, 6); |
|
| 208 | + |
|
| 209 | + if(($majorVersion === '1.0.1' && ord($patchRelease) < ord('d')) || |
|
| 210 | + ($majorVersion === '1.0.2' && ord($patchRelease) < ord('b'))) { |
|
| 211 | + return (string) $this->l10n->t('cURL is using an outdated %s version (%s). Please update your operating system or features such as %s will not work reliably.', ['OpenSSL', $versionString, $features]); |
|
| 212 | + } |
|
| 213 | + } |
|
| 214 | + |
|
| 215 | + // Check if NSS and perform heuristic check |
|
| 216 | + if(strpos($versionString, 'NSS/') === 0) { |
|
| 217 | + try { |
|
| 218 | + $firstClient = $this->clientService->newClient(); |
|
| 219 | + $firstClient->get('https://nextcloud.com/'); |
|
| 220 | + |
|
| 221 | + $secondClient = $this->clientService->newClient(); |
|
| 222 | + $secondClient->get('https://nextcloud.com/'); |
|
| 223 | + } catch (ClientException $e) { |
|
| 224 | + if($e->getResponse()->getStatusCode() === 400) { |
|
| 225 | + return (string) $this->l10n->t('cURL is using an outdated %s version (%s). Please update your operating system or features such as %s will not work reliably.', ['NSS', $versionString, $features]); |
|
| 226 | + } |
|
| 227 | + } |
|
| 228 | + } |
|
| 229 | + |
|
| 230 | + return ''; |
|
| 231 | + } |
|
| 232 | + |
|
| 233 | + /** |
|
| 234 | + * Whether the version is outdated |
|
| 235 | + * |
|
| 236 | + * @return bool |
|
| 237 | + */ |
|
| 238 | + protected function isPhpOutdated() { |
|
| 239 | + if (version_compare(PHP_VERSION, '7.0.0', '<')) { |
|
| 240 | + return true; |
|
| 241 | + } |
|
| 242 | + |
|
| 243 | + return false; |
|
| 244 | + } |
|
| 245 | + |
|
| 246 | + /** |
|
| 247 | + * Whether the php version is still supported (at time of release) |
|
| 248 | + * according to: https://secure.php.net/supported-versions.php |
|
| 249 | + * |
|
| 250 | + * @return array |
|
| 251 | + */ |
|
| 252 | + private function isPhpSupported() { |
|
| 253 | + return ['eol' => $this->isPhpOutdated(), 'version' => PHP_VERSION]; |
|
| 254 | + } |
|
| 255 | + |
|
| 256 | + /** |
|
| 257 | + * Check if the reverse proxy configuration is working as expected |
|
| 258 | + * |
|
| 259 | + * @return bool |
|
| 260 | + */ |
|
| 261 | + private function forwardedForHeadersWorking() { |
|
| 262 | + $trustedProxies = $this->config->getSystemValue('trusted_proxies', []); |
|
| 263 | + $remoteAddress = $this->request->getRemoteAddress(); |
|
| 264 | + |
|
| 265 | + if (is_array($trustedProxies) && in_array($remoteAddress, $trustedProxies)) { |
|
| 266 | + return false; |
|
| 267 | + } |
|
| 268 | + |
|
| 269 | + // either not enabled or working correctly |
|
| 270 | + return true; |
|
| 271 | + } |
|
| 272 | + |
|
| 273 | + /** |
|
| 274 | + * Checks if the correct memcache module for PHP is installed. Only |
|
| 275 | + * fails if memcached is configured and the working module is not installed. |
|
| 276 | + * |
|
| 277 | + * @return bool |
|
| 278 | + */ |
|
| 279 | + private function isCorrectMemcachedPHPModuleInstalled() { |
|
| 280 | + if ($this->config->getSystemValue('memcache.distributed', null) !== '\OC\Memcache\Memcached') { |
|
| 281 | + return true; |
|
| 282 | + } |
|
| 283 | + |
|
| 284 | + // there are two different memcached modules for PHP |
|
| 285 | + // we only support memcached and not memcache |
|
| 286 | + // https://code.google.com/p/memcached/wiki/PHPClientComparison |
|
| 287 | + return !(!extension_loaded('memcached') && extension_loaded('memcache')); |
|
| 288 | + } |
|
| 289 | + |
|
| 290 | + /** |
|
| 291 | + * Checks if set_time_limit is not disabled. |
|
| 292 | + * |
|
| 293 | + * @return bool |
|
| 294 | + */ |
|
| 295 | + private function isSettimelimitAvailable() { |
|
| 296 | + if (function_exists('set_time_limit') |
|
| 297 | + && strpos(@ini_get('disable_functions'), 'set_time_limit') === false) { |
|
| 298 | + return true; |
|
| 299 | + } |
|
| 300 | + |
|
| 301 | + return false; |
|
| 302 | + } |
|
| 303 | + |
|
| 304 | + /** |
|
| 305 | + * @return RedirectResponse |
|
| 306 | + */ |
|
| 307 | + public function rescanFailedIntegrityCheck() { |
|
| 308 | + $this->checker->runInstanceVerification(); |
|
| 309 | + return new RedirectResponse( |
|
| 310 | + $this->urlGenerator->linkToRoute('settings.AdminSettings.index') |
|
| 311 | + ); |
|
| 312 | + } |
|
| 313 | + |
|
| 314 | + /** |
|
| 315 | + * @NoCSRFRequired |
|
| 316 | + * @return DataResponse |
|
| 317 | + */ |
|
| 318 | + public function getFailedIntegrityCheckFiles() { |
|
| 319 | + if(!$this->checker->isCodeCheckEnforced()) { |
|
| 320 | + return new DataDisplayResponse('Integrity checker has been disabled. Integrity cannot be verified.'); |
|
| 321 | + } |
|
| 322 | + |
|
| 323 | + $completeResults = $this->checker->getResults(); |
|
| 324 | + |
|
| 325 | + if(!empty($completeResults)) { |
|
| 326 | + $formattedTextResponse = 'Technical information |
|
| 327 | 327 | ===================== |
| 328 | 328 | The following list covers which files have failed the integrity check. Please read |
| 329 | 329 | the previous linked documentation to learn more about the errors and how to fix |
@@ -332,132 +332,132 @@ discard block |
||
| 332 | 332 | Results |
| 333 | 333 | ======= |
| 334 | 334 | '; |
| 335 | - foreach($completeResults as $context => $contextResult) { |
|
| 336 | - $formattedTextResponse .= "- $context\n"; |
|
| 337 | - |
|
| 338 | - foreach($contextResult as $category => $result) { |
|
| 339 | - $formattedTextResponse .= "\t- $category\n"; |
|
| 340 | - if($category !== 'EXCEPTION') { |
|
| 341 | - foreach ($result as $key => $results) { |
|
| 342 | - $formattedTextResponse .= "\t\t- $key\n"; |
|
| 343 | - } |
|
| 344 | - } else { |
|
| 345 | - foreach ($result as $key => $results) { |
|
| 346 | - $formattedTextResponse .= "\t\t- $results\n"; |
|
| 347 | - } |
|
| 348 | - } |
|
| 349 | - |
|
| 350 | - } |
|
| 351 | - } |
|
| 352 | - |
|
| 353 | - $formattedTextResponse .= ' |
|
| 335 | + foreach($completeResults as $context => $contextResult) { |
|
| 336 | + $formattedTextResponse .= "- $context\n"; |
|
| 337 | + |
|
| 338 | + foreach($contextResult as $category => $result) { |
|
| 339 | + $formattedTextResponse .= "\t- $category\n"; |
|
| 340 | + if($category !== 'EXCEPTION') { |
|
| 341 | + foreach ($result as $key => $results) { |
|
| 342 | + $formattedTextResponse .= "\t\t- $key\n"; |
|
| 343 | + } |
|
| 344 | + } else { |
|
| 345 | + foreach ($result as $key => $results) { |
|
| 346 | + $formattedTextResponse .= "\t\t- $results\n"; |
|
| 347 | + } |
|
| 348 | + } |
|
| 349 | + |
|
| 350 | + } |
|
| 351 | + } |
|
| 352 | + |
|
| 353 | + $formattedTextResponse .= ' |
|
| 354 | 354 | Raw output |
| 355 | 355 | ========== |
| 356 | 356 | '; |
| 357 | - $formattedTextResponse .= print_r($completeResults, true); |
|
| 358 | - } else { |
|
| 359 | - $formattedTextResponse = 'No errors have been found.'; |
|
| 360 | - } |
|
| 361 | - |
|
| 362 | - |
|
| 363 | - $response = new DataDisplayResponse( |
|
| 364 | - $formattedTextResponse, |
|
| 365 | - Http::STATUS_OK, |
|
| 366 | - [ |
|
| 367 | - 'Content-Type' => 'text/plain', |
|
| 368 | - ] |
|
| 369 | - ); |
|
| 370 | - |
|
| 371 | - return $response; |
|
| 372 | - } |
|
| 373 | - |
|
| 374 | - /** |
|
| 375 | - * Checks whether a PHP opcache is properly set up |
|
| 376 | - * @return bool |
|
| 377 | - */ |
|
| 378 | - protected function isOpcacheProperlySetup() { |
|
| 379 | - $iniWrapper = new IniGetWrapper(); |
|
| 380 | - |
|
| 381 | - $isOpcacheProperlySetUp = true; |
|
| 382 | - |
|
| 383 | - if(!$iniWrapper->getBool('opcache.enable')) { |
|
| 384 | - $isOpcacheProperlySetUp = false; |
|
| 385 | - } |
|
| 386 | - |
|
| 387 | - if(!$iniWrapper->getBool('opcache.save_comments')) { |
|
| 388 | - $isOpcacheProperlySetUp = false; |
|
| 389 | - } |
|
| 390 | - |
|
| 391 | - if(!$iniWrapper->getBool('opcache.enable_cli')) { |
|
| 392 | - $isOpcacheProperlySetUp = false; |
|
| 393 | - } |
|
| 394 | - |
|
| 395 | - if($iniWrapper->getNumeric('opcache.max_accelerated_files') < 10000) { |
|
| 396 | - $isOpcacheProperlySetUp = false; |
|
| 397 | - } |
|
| 398 | - |
|
| 399 | - if($iniWrapper->getNumeric('opcache.memory_consumption') < 128) { |
|
| 400 | - $isOpcacheProperlySetUp = false; |
|
| 401 | - } |
|
| 402 | - |
|
| 403 | - if($iniWrapper->getNumeric('opcache.interned_strings_buffer') < 8) { |
|
| 404 | - $isOpcacheProperlySetUp = false; |
|
| 405 | - } |
|
| 406 | - |
|
| 407 | - return $isOpcacheProperlySetUp; |
|
| 408 | - } |
|
| 409 | - |
|
| 410 | - /** |
|
| 411 | - * Check if the required FreeType functions are present |
|
| 412 | - * @return bool |
|
| 413 | - */ |
|
| 414 | - protected function hasFreeTypeSupport() { |
|
| 415 | - return function_exists('imagettfbbox') && function_exists('imagettftext'); |
|
| 416 | - } |
|
| 417 | - |
|
| 418 | - /** |
|
| 419 | - * Check if the required FreeType functions are present |
|
| 420 | - * @return bool |
|
| 421 | - */ |
|
| 422 | - protected function hasMissingIndexes() { |
|
| 423 | - $indexInfo = new MissingIndexInformation(); |
|
| 424 | - // Dispatch event so apps can also hint for pending index updates if needed |
|
| 425 | - $event = new GenericEvent($indexInfo); |
|
| 426 | - $this->dispatcher->dispatch(IDBConnection::CHECK_MISSING_INDEXES_EVENT, $event); |
|
| 427 | - |
|
| 428 | - return $indexInfo->getListOfMissingIndexes(); |
|
| 429 | - } |
|
| 430 | - |
|
| 431 | - protected function isSqliteUsed() { |
|
| 432 | - return strpos($this->config->getSystemValue('dbtype'), 'sqlite') !== false; |
|
| 433 | - } |
|
| 434 | - |
|
| 435 | - /** |
|
| 436 | - * @return DataResponse |
|
| 437 | - */ |
|
| 438 | - public function check() { |
|
| 439 | - return new DataResponse( |
|
| 440 | - [ |
|
| 441 | - 'serverHasInternetConnection' => $this->isInternetConnectionWorking(), |
|
| 442 | - 'isMemcacheConfigured' => $this->isMemcacheConfigured(), |
|
| 443 | - 'memcacheDocs' => $this->urlGenerator->linkToDocs('admin-performance'), |
|
| 444 | - 'isUrandomAvailable' => $this->isUrandomAvailable(), |
|
| 445 | - 'securityDocs' => $this->urlGenerator->linkToDocs('admin-security'), |
|
| 446 | - 'isUsedTlsLibOutdated' => $this->isUsedTlsLibOutdated(), |
|
| 447 | - 'phpSupported' => $this->isPhpSupported(), |
|
| 448 | - 'forwardedForHeadersWorking' => $this->forwardedForHeadersWorking(), |
|
| 449 | - 'reverseProxyDocs' => $this->urlGenerator->linkToDocs('admin-reverse-proxy'), |
|
| 450 | - 'isCorrectMemcachedPHPModuleInstalled' => $this->isCorrectMemcachedPHPModuleInstalled(), |
|
| 451 | - 'hasPassedCodeIntegrityCheck' => $this->checker->hasPassedCheck(), |
|
| 452 | - 'codeIntegrityCheckerDocumentation' => $this->urlGenerator->linkToDocs('admin-code-integrity'), |
|
| 453 | - 'isOpcacheProperlySetup' => $this->isOpcacheProperlySetup(), |
|
| 454 | - 'phpOpcacheDocumentation' => $this->urlGenerator->linkToDocs('admin-php-opcache'), |
|
| 455 | - 'isSettimelimitAvailable' => $this->isSettimelimitAvailable(), |
|
| 456 | - 'hasFreeTypeSupport' => $this->hasFreeTypeSupport(), |
|
| 457 | - 'hasMissingIndexes' => $this->hasMissingIndexes(), |
|
| 458 | - 'isSqliteUsed' => $this->isSqliteUsed(), |
|
| 459 | - 'databaseConversionDocumentation' => $this->urlGenerator->linkToDocs('admin-db-conversion'), |
|
| 460 | - ] |
|
| 461 | - ); |
|
| 462 | - } |
|
| 357 | + $formattedTextResponse .= print_r($completeResults, true); |
|
| 358 | + } else { |
|
| 359 | + $formattedTextResponse = 'No errors have been found.'; |
|
| 360 | + } |
|
| 361 | + |
|
| 362 | + |
|
| 363 | + $response = new DataDisplayResponse( |
|
| 364 | + $formattedTextResponse, |
|
| 365 | + Http::STATUS_OK, |
|
| 366 | + [ |
|
| 367 | + 'Content-Type' => 'text/plain', |
|
| 368 | + ] |
|
| 369 | + ); |
|
| 370 | + |
|
| 371 | + return $response; |
|
| 372 | + } |
|
| 373 | + |
|
| 374 | + /** |
|
| 375 | + * Checks whether a PHP opcache is properly set up |
|
| 376 | + * @return bool |
|
| 377 | + */ |
|
| 378 | + protected function isOpcacheProperlySetup() { |
|
| 379 | + $iniWrapper = new IniGetWrapper(); |
|
| 380 | + |
|
| 381 | + $isOpcacheProperlySetUp = true; |
|
| 382 | + |
|
| 383 | + if(!$iniWrapper->getBool('opcache.enable')) { |
|
| 384 | + $isOpcacheProperlySetUp = false; |
|
| 385 | + } |
|
| 386 | + |
|
| 387 | + if(!$iniWrapper->getBool('opcache.save_comments')) { |
|
| 388 | + $isOpcacheProperlySetUp = false; |
|
| 389 | + } |
|
| 390 | + |
|
| 391 | + if(!$iniWrapper->getBool('opcache.enable_cli')) { |
|
| 392 | + $isOpcacheProperlySetUp = false; |
|
| 393 | + } |
|
| 394 | + |
|
| 395 | + if($iniWrapper->getNumeric('opcache.max_accelerated_files') < 10000) { |
|
| 396 | + $isOpcacheProperlySetUp = false; |
|
| 397 | + } |
|
| 398 | + |
|
| 399 | + if($iniWrapper->getNumeric('opcache.memory_consumption') < 128) { |
|
| 400 | + $isOpcacheProperlySetUp = false; |
|
| 401 | + } |
|
| 402 | + |
|
| 403 | + if($iniWrapper->getNumeric('opcache.interned_strings_buffer') < 8) { |
|
| 404 | + $isOpcacheProperlySetUp = false; |
|
| 405 | + } |
|
| 406 | + |
|
| 407 | + return $isOpcacheProperlySetUp; |
|
| 408 | + } |
|
| 409 | + |
|
| 410 | + /** |
|
| 411 | + * Check if the required FreeType functions are present |
|
| 412 | + * @return bool |
|
| 413 | + */ |
|
| 414 | + protected function hasFreeTypeSupport() { |
|
| 415 | + return function_exists('imagettfbbox') && function_exists('imagettftext'); |
|
| 416 | + } |
|
| 417 | + |
|
| 418 | + /** |
|
| 419 | + * Check if the required FreeType functions are present |
|
| 420 | + * @return bool |
|
| 421 | + */ |
|
| 422 | + protected function hasMissingIndexes() { |
|
| 423 | + $indexInfo = new MissingIndexInformation(); |
|
| 424 | + // Dispatch event so apps can also hint for pending index updates if needed |
|
| 425 | + $event = new GenericEvent($indexInfo); |
|
| 426 | + $this->dispatcher->dispatch(IDBConnection::CHECK_MISSING_INDEXES_EVENT, $event); |
|
| 427 | + |
|
| 428 | + return $indexInfo->getListOfMissingIndexes(); |
|
| 429 | + } |
|
| 430 | + |
|
| 431 | + protected function isSqliteUsed() { |
|
| 432 | + return strpos($this->config->getSystemValue('dbtype'), 'sqlite') !== false; |
|
| 433 | + } |
|
| 434 | + |
|
| 435 | + /** |
|
| 436 | + * @return DataResponse |
|
| 437 | + */ |
|
| 438 | + public function check() { |
|
| 439 | + return new DataResponse( |
|
| 440 | + [ |
|
| 441 | + 'serverHasInternetConnection' => $this->isInternetConnectionWorking(), |
|
| 442 | + 'isMemcacheConfigured' => $this->isMemcacheConfigured(), |
|
| 443 | + 'memcacheDocs' => $this->urlGenerator->linkToDocs('admin-performance'), |
|
| 444 | + 'isUrandomAvailable' => $this->isUrandomAvailable(), |
|
| 445 | + 'securityDocs' => $this->urlGenerator->linkToDocs('admin-security'), |
|
| 446 | + 'isUsedTlsLibOutdated' => $this->isUsedTlsLibOutdated(), |
|
| 447 | + 'phpSupported' => $this->isPhpSupported(), |
|
| 448 | + 'forwardedForHeadersWorking' => $this->forwardedForHeadersWorking(), |
|
| 449 | + 'reverseProxyDocs' => $this->urlGenerator->linkToDocs('admin-reverse-proxy'), |
|
| 450 | + 'isCorrectMemcachedPHPModuleInstalled' => $this->isCorrectMemcachedPHPModuleInstalled(), |
|
| 451 | + 'hasPassedCodeIntegrityCheck' => $this->checker->hasPassedCheck(), |
|
| 452 | + 'codeIntegrityCheckerDocumentation' => $this->urlGenerator->linkToDocs('admin-code-integrity'), |
|
| 453 | + 'isOpcacheProperlySetup' => $this->isOpcacheProperlySetup(), |
|
| 454 | + 'phpOpcacheDocumentation' => $this->urlGenerator->linkToDocs('admin-php-opcache'), |
|
| 455 | + 'isSettimelimitAvailable' => $this->isSettimelimitAvailable(), |
|
| 456 | + 'hasFreeTypeSupport' => $this->hasFreeTypeSupport(), |
|
| 457 | + 'hasMissingIndexes' => $this->hasMissingIndexes(), |
|
| 458 | + 'isSqliteUsed' => $this->isSqliteUsed(), |
|
| 459 | + 'databaseConversionDocumentation' => $this->urlGenerator->linkToDocs('admin-db-conversion'), |
|
| 460 | + ] |
|
| 461 | + ); |
|
| 462 | + } |
|
| 463 | 463 | } |
@@ -31,101 +31,101 @@ discard block |
||
| 31 | 31 | <p class="settings-hint"><?php p($l->t('It\'s important for the security and performance of your instance that everything is configured correctly. To help you with that we are doing some automatic checks. Please see the linked documentation for more information.'));?></p> |
| 32 | 32 | <ul> |
| 33 | 33 | <?php |
| 34 | - // is php setup properly to query system environment variables like getenv('PATH') |
|
| 35 | - if ($_['getenvServerNotWorking']) { |
|
| 36 | - ?> |
|
| 34 | + // is php setup properly to query system environment variables like getenv('PATH') |
|
| 35 | + if ($_['getenvServerNotWorking']) { |
|
| 36 | + ?> |
|
| 37 | 37 | <li> |
| 38 | 38 | <?php p($l->t('PHP does not seem to be setup properly to query system environment variables. The test with getenv("PATH") only returns an empty response.')); ?><br> |
| 39 | 39 | <?php print_unescaped($l->t('Please check the <a target="_blank" rel="noreferrer noopener" href="%s">installation documentation ↗</a> for PHP configuration notes and the PHP configuration of your server, especially when using php-fpm.', link_to_docs('admin-php-fpm'))); ?> |
| 40 | 40 | </li> |
| 41 | 41 | <?php |
| 42 | - } |
|
| 42 | + } |
|
| 43 | 43 | |
| 44 | - // is read only config enabled |
|
| 45 | - if ($_['readOnlyConfigEnabled']) { |
|
| 46 | - ?> |
|
| 44 | + // is read only config enabled |
|
| 45 | + if ($_['readOnlyConfigEnabled']) { |
|
| 46 | + ?> |
|
| 47 | 47 | <li> |
| 48 | 48 | <?php p($l->t('The Read-Only config has been enabled. This prevents setting some configurations via the web-interface. Furthermore, the file needs to be made writable manually for every update.')); ?> |
| 49 | 49 | </li> |
| 50 | 50 | <?php |
| 51 | - } |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | - // Are doc blocks accessible? |
|
| 54 | - if (!$_['isAnnotationsWorking']) { |
|
| 55 | - ?> |
|
| 53 | + // Are doc blocks accessible? |
|
| 54 | + if (!$_['isAnnotationsWorking']) { |
|
| 55 | + ?> |
|
| 56 | 56 | <li> |
| 57 | 57 | <?php p($l->t('PHP is apparently set up to strip inline doc blocks. This will make several core apps inaccessible.')); ?><br> |
| 58 | 58 | <?php p($l->t('This is probably caused by a cache/accelerator such as Zend OPcache or eAccelerator.')); ?> |
| 59 | 59 | </li> |
| 60 | 60 | <?php |
| 61 | - } |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | - // Is the Transaction isolation level READ_COMMITTED? |
|
| 64 | - if ($_['invalidTransactionIsolationLevel']) { |
|
| 65 | - ?> |
|
| 63 | + // Is the Transaction isolation level READ_COMMITTED? |
|
| 64 | + if ($_['invalidTransactionIsolationLevel']) { |
|
| 65 | + ?> |
|
| 66 | 66 | <li> |
| 67 | 67 | <?php p($l->t('Your database does not run with "READ COMMITTED" transaction isolation level. This can cause problems when multiple actions are executed in parallel.')); ?> |
| 68 | 68 | </li> |
| 69 | 69 | <?php |
| 70 | - } |
|
| 70 | + } |
|
| 71 | 71 | |
| 72 | - // Warning if memcache is outdated |
|
| 73 | - foreach ($_['OutdatedCacheWarning'] as $php_module => $data) { |
|
| 74 | - ?> |
|
| 72 | + // Warning if memcache is outdated |
|
| 73 | + foreach ($_['OutdatedCacheWarning'] as $php_module => $data) { |
|
| 74 | + ?> |
|
| 75 | 75 | <li> |
| 76 | 76 | <?php p($l->t('%1$s below version %2$s is installed, for stability and performance reasons it is recommended to update to a newer %1$s version.', $data)); ?> |
| 77 | 77 | </li> |
| 78 | 78 | <?php |
| 79 | - } |
|
| 79 | + } |
|
| 80 | 80 | |
| 81 | - // if module fileinfo available? |
|
| 82 | - if (!$_['has_fileinfo']) { |
|
| 83 | - ?> |
|
| 81 | + // if module fileinfo available? |
|
| 82 | + if (!$_['has_fileinfo']) { |
|
| 83 | + ?> |
|
| 84 | 84 | <li> |
| 85 | 85 | <?php p($l->t('The PHP module \'fileinfo\' is missing. It is strongly recommended to enable this module to get the best results with MIME type detection.')); ?> |
| 86 | 86 | </li> |
| 87 | 87 | <?php |
| 88 | - } |
|
| 88 | + } |
|
| 89 | 89 | |
| 90 | - // locking configured optimally? |
|
| 91 | - if ($_['fileLockingType'] === 'none') { |
|
| 92 | - ?> |
|
| 90 | + // locking configured optimally? |
|
| 91 | + if ($_['fileLockingType'] === 'none') { |
|
| 92 | + ?> |
|
| 93 | 93 | <li> |
| 94 | 94 | <?php print_unescaped($l->t('Transactional file locking is disabled, this might lead to issues with race conditions. Enable \'filelocking.enabled\' in config.php to avoid these problems. See the <a target="_blank" rel="noreferrer noopener" href="%s">documentation ↗</a> for more information.', link_to_docs('admin-transactional-locking'))); ?> |
| 95 | 95 | </li> |
| 96 | 96 | <?php |
| 97 | - } |
|
| 97 | + } |
|
| 98 | 98 | |
| 99 | - // is locale working ? |
|
| 100 | - if (!$_['isLocaleWorking']) { |
|
| 101 | - ?> |
|
| 99 | + // is locale working ? |
|
| 100 | + if (!$_['isLocaleWorking']) { |
|
| 101 | + ?> |
|
| 102 | 102 | <li> |
| 103 | 103 | <?php |
| 104 | - $locales = 'en_US.UTF-8/fr_FR.UTF-8/es_ES.UTF-8/de_DE.UTF-8/ru_RU.UTF-8/pt_BR.UTF-8/it_IT.UTF-8/ja_JP.UTF-8/zh_CN.UTF-8'; |
|
| 105 | - p($l->t('System locale can not be set to a one which supports UTF-8.')); |
|
| 106 | - ?> |
|
| 104 | + $locales = 'en_US.UTF-8/fr_FR.UTF-8/es_ES.UTF-8/de_DE.UTF-8/ru_RU.UTF-8/pt_BR.UTF-8/it_IT.UTF-8/ja_JP.UTF-8/zh_CN.UTF-8'; |
|
| 105 | + p($l->t('System locale can not be set to a one which supports UTF-8.')); |
|
| 106 | + ?> |
|
| 107 | 107 | <br> |
| 108 | 108 | <?php |
| 109 | - p($l->t('This means that there might be problems with certain characters in filenames.')); |
|
| 110 | - ?> |
|
| 109 | + p($l->t('This means that there might be problems with certain characters in filenames.')); |
|
| 110 | + ?> |
|
| 111 | 111 | <br> |
| 112 | 112 | <?php |
| 113 | - p($l->t('It is strongly proposed to install the required packages on your system to support one of the following locales: %s.', [$locales])); |
|
| 114 | - ?> |
|
| 113 | + p($l->t('It is strongly proposed to install the required packages on your system to support one of the following locales: %s.', [$locales])); |
|
| 114 | + ?> |
|
| 115 | 115 | </li> |
| 116 | 116 | <?php |
| 117 | - } |
|
| 117 | + } |
|
| 118 | 118 | |
| 119 | - if ($_['suggestedOverwriteCliUrl']) { |
|
| 120 | - ?> |
|
| 119 | + if ($_['suggestedOverwriteCliUrl']) { |
|
| 120 | + ?> |
|
| 121 | 121 | <li> |
| 122 | 122 | <?php p($l->t('If your installation is not installed at the root of the domain and uses system Cron, there can be issues with the URL generation. To avoid these problems, please set the "overwrite.cli.url" option in your config.php file to the webroot path of your installation (Suggested: "%s")', $_['suggestedOverwriteCliUrl'])); ?> |
| 123 | 123 | </li> |
| 124 | 124 | <?php |
| 125 | - } |
|
| 125 | + } |
|
| 126 | 126 | |
| 127 | - if ($_['cronErrors']) { |
|
| 128 | - ?> |
|
| 127 | + if ($_['cronErrors']) { |
|
| 128 | + ?> |
|
| 129 | 129 | <li> |
| 130 | 130 | <?php p($l->t('It was not possible to execute the cron job via CLI. The following technical errors have appeared:')); ?> |
| 131 | 131 | <br> |
@@ -136,13 +136,13 @@ discard block |
||
| 136 | 136 | </ol> |
| 137 | 137 | </li> |
| 138 | 138 | <?php |
| 139 | - } |
|
| 140 | - ?> |
|
| 139 | + } |
|
| 140 | + ?> |
|
| 141 | 141 | <?php if ($_['lastcron'] !== false): |
| 142 | - $relative_time = relative_modified_date($_['lastcron']); |
|
| 143 | - $formatter = \OC::$server->getDateTimeFormatter(); |
|
| 144 | - $absolute_time = $formatter->formatDateTime($_['lastcron'], 'long', 'long'); |
|
| 145 | - if (time() - $_['lastcron'] > 3600): ?> |
|
| 142 | + $relative_time = relative_modified_date($_['lastcron']); |
|
| 143 | + $formatter = \OC::$server->getDateTimeFormatter(); |
|
| 144 | + $absolute_time = $formatter->formatDateTime($_['lastcron'], 'long', 'long'); |
|
| 145 | + if (time() - $_['lastcron'] > 3600): ?> |
|
| 146 | 146 | <li class="crondate" title="<?php p($absolute_time);?>"> |
| 147 | 147 | <?php p($l->t("Last background job execution ran %s. Something seems wrong.", [$relative_time]));?> |
| 148 | 148 | <a href="<?php p(\OC::$server->getURLGenerator()->linkToRoute('settings.AdminSettings.index', ['section' => 'server'])); ?>#backgroundjobs"><?php p($l->t('Check the background job settings')); ?></a> |
@@ -27,8 +27,8 @@ discard block |
||
| 27 | 27 | ?> |
| 28 | 28 | |
| 29 | 29 | <div id="security-warning" class="section"> |
| 30 | - <h2><?php p($l->t('Security & setup warnings'));?></h2> |
|
| 31 | - <p class="settings-hint"><?php p($l->t('It\'s important for the security and performance of your instance that everything is configured correctly. To help you with that we are doing some automatic checks. Please see the linked documentation for more information.'));?></p> |
|
| 30 | + <h2><?php p($l->t('Security & setup warnings')); ?></h2> |
|
| 31 | + <p class="settings-hint"><?php p($l->t('It\'s important for the security and performance of your instance that everything is configured correctly. To help you with that we are doing some automatic checks. Please see the linked documentation for more information.')); ?></p> |
|
| 32 | 32 | <ul> |
| 33 | 33 | <?php |
| 34 | 34 | // is php setup properly to query system environment variables like getenv('PATH') |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | <?php p($l->t('It was not possible to execute the cron job via CLI. The following technical errors have appeared:')); ?> |
| 131 | 131 | <br> |
| 132 | 132 | <ol> |
| 133 | - <?php foreach(json_decode($_['cronErrors']) as $error) { if(isset($error->error)) {?> |
|
| 133 | + <?php foreach (json_decode($_['cronErrors']) as $error) { if (isset($error->error)) {?> |
|
| 134 | 134 | <li><?php p($error->error) ?> <?php p($error->hint) ?></li> |
| 135 | 135 | <?php }} ?> |
| 136 | 136 | </ol> |
@@ -143,8 +143,8 @@ discard block |
||
| 143 | 143 | $formatter = \OC::$server->getDateTimeFormatter(); |
| 144 | 144 | $absolute_time = $formatter->formatDateTime($_['lastcron'], 'long', 'long'); |
| 145 | 145 | if (time() - $_['lastcron'] > 3600): ?> |
| 146 | - <li class="crondate" title="<?php p($absolute_time);?>"> |
|
| 147 | - <?php p($l->t("Last background job execution ran %s. Something seems wrong.", [$relative_time]));?> |
|
| 146 | + <li class="crondate" title="<?php p($absolute_time); ?>"> |
|
| 147 | + <?php p($l->t("Last background job execution ran %s. Something seems wrong.", [$relative_time])); ?> |
|
| 148 | 148 | <a href="<?php p(\OC::$server->getURLGenerator()->linkToRoute('settings.AdminSettings.index', ['section' => 'server'])); ?>#backgroundjobs"><?php p($l->t('Check the background job settings')); ?></a> |
| 149 | 149 | </li> |
| 150 | 150 | <?php endif; ?> |
@@ -152,35 +152,35 @@ discard block |
||
| 152 | 152 | </ul> |
| 153 | 153 | |
| 154 | 154 | <div id="security-warning-state-ok" class="hidden"> |
| 155 | - <span class="icon icon-checkmark-white"></span><span class="message"><?php p($l->t('All checks passed.'));?></span> |
|
| 155 | + <span class="icon icon-checkmark-white"></span><span class="message"><?php p($l->t('All checks passed.')); ?></span> |
|
| 156 | 156 | </div> |
| 157 | 157 | <div id="security-warning-state-failure" class="hidden"> |
| 158 | - <span class="icon icon-close-white"></span><span class="message"><?php p($l->t('There are some errors regarding your setup.'));?></span> |
|
| 158 | + <span class="icon icon-close-white"></span><span class="message"><?php p($l->t('There are some errors regarding your setup.')); ?></span> |
|
| 159 | 159 | </div> |
| 160 | 160 | <div id="security-warning-state-warning" class="hidden"> |
| 161 | - <span class="icon icon-error-white"></span><span class="message"><?php p($l->t('There are some warnings regarding your setup.'));?></span> |
|
| 161 | + <span class="icon icon-error-white"></span><span class="message"><?php p($l->t('There are some warnings regarding your setup.')); ?></span> |
|
| 162 | 162 | </div> |
| 163 | 163 | <div id="security-warning-state-loading"> |
| 164 | - <span class="icon loading"></span><span class="message"><?php p($l->t('Checking for system and security issues.'));?></span> |
|
| 164 | + <span class="icon loading"></span><span class="message"><?php p($l->t('Checking for system and security issues.')); ?></span> |
|
| 165 | 165 | </div> |
| 166 | 166 | |
| 167 | - <div id="postsetupchecks" data-check-wellknown="<?php if($_['checkForWorkingWellKnownSetup']) { p('true'); } else { p('false'); } ?>"> |
|
| 167 | + <div id="postsetupchecks" data-check-wellknown="<?php if ($_['checkForWorkingWellKnownSetup']) { p('true'); } else { p('false'); } ?>"> |
|
| 168 | 168 | <ul class="errors hidden"></ul> |
| 169 | 169 | <ul class="warnings hidden"></ul> |
| 170 | 170 | <ul class="info hidden"></ul> |
| 171 | 171 | </div> |
| 172 | 172 | <p id="postsetupchecks-hint" class="hidden"> |
| 173 | - <?php print_unescaped($l->t('Please double check the <a target="_blank" rel="noreferrer noopener" href="%s">installation guides ↗</a>, and check for any errors or warnings in the <a href="%s">log</a>.', [link_to_docs('admin-install'), \OC::$server->getURLGenerator()->linkToRoute('settings.AdminSettings.index', ['section' => 'logging'])] )); ?> |
|
| 173 | + <?php print_unescaped($l->t('Please double check the <a target="_blank" rel="noreferrer noopener" href="%s">installation guides ↗</a>, and check for any errors or warnings in the <a href="%s">log</a>.', [link_to_docs('admin-install'), \OC::$server->getURLGenerator()->linkToRoute('settings.AdminSettings.index', ['section' => 'logging'])])); ?> |
|
| 174 | 174 | </p> |
| 175 | 175 | |
| 176 | 176 | <p class="extra-top-margin"> |
| 177 | - <?php print_unescaped($l->t('Check the security of your Nextcloud over <a target="_blank" rel="noreferrer noopener" href="%s">our security scan ↗</a>.', ['https://scan.nextcloud.com']));?> |
|
| 177 | + <?php print_unescaped($l->t('Check the security of your Nextcloud over <a target="_blank" rel="noreferrer noopener" href="%s">our security scan ↗</a>.', ['https://scan.nextcloud.com'])); ?> |
|
| 178 | 178 | </p> |
| 179 | 179 | |
| 180 | 180 | </div> |
| 181 | 181 | |
| 182 | 182 | <div class="section"> |
| 183 | 183 | <!-- should be the last part, so Updater can follow if enabled (it has no heading therefore). --> |
| 184 | - <h2><?php p($l->t('Version'));?></h2> |
|
| 184 | + <h2><?php p($l->t('Version')); ?></h2> |
|
| 185 | 185 | <p><strong><a href="<?php print_unescaped($theme->getBaseUrl()); ?>" rel="noreferrer noopener" target="_blank"><?php p($theme->getTitle()); ?></a> <?php p(OC_Util::getHumanVersion()) ?></strong></p> |
| 186 | 186 | </div> |