Completed
Push — master ( 5724e7...4c19e7 )
by Morris
39:26 queued 23:18
created
settings/Controller/CheckSetupController.php 1 patch
Indentation   +372 added lines, -372 removed lines patch added patch discarded remove patch
@@ -50,282 +50,282 @@  discard block
 block discarded – undo
50 50
  * @package OC\Settings\Controller
51 51
  */
52 52
 class CheckSetupController extends Controller {
53
-	/** @var IConfig */
54
-	private $config;
55
-	/** @var IClientService */
56
-	private $clientService;
57
-	/** @var \OC_Util */
58
-	private $util;
59
-	/** @var IURLGenerator */
60
-	private $urlGenerator;
61
-	/** @var IL10N */
62
-	private $l10n;
63
-	/** @var Checker */
64
-	private $checker;
65
-	/** @var ILogger */
66
-	private $logger;
67
-
68
-	/**
69
-	 * @param string $AppName
70
-	 * @param IRequest $request
71
-	 * @param IConfig $config
72
-	 * @param IClientService $clientService
73
-	 * @param IURLGenerator $urlGenerator
74
-	 * @param \OC_Util $util
75
-	 * @param IL10N $l10n
76
-	 * @param Checker $checker
77
-	 * @param ILogger $logger
78
-	 */
79
-	public function __construct($AppName,
80
-								IRequest $request,
81
-								IConfig $config,
82
-								IClientService $clientService,
83
-								IURLGenerator $urlGenerator,
84
-								\OC_Util $util,
85
-								IL10N $l10n,
86
-								Checker $checker,
87
-								ILogger $logger) {
88
-		parent::__construct($AppName, $request);
89
-		$this->config = $config;
90
-		$this->clientService = $clientService;
91
-		$this->util = $util;
92
-		$this->urlGenerator = $urlGenerator;
93
-		$this->l10n = $l10n;
94
-		$this->checker = $checker;
95
-		$this->logger = $logger;
96
-	}
97
-
98
-	/**
99
-	 * Checks if the ownCloud server can connect to the internet using HTTPS and HTTP
100
-	 * @return bool
101
-	 */
102
-	private function isInternetConnectionWorking() {
103
-		if ($this->config->getSystemValue('has_internet_connection', true) === false) {
104
-			return false;
105
-		}
106
-
107
-		$siteArray = ['www.nextcloud.com',
108
-						'www.google.com',
109
-						'www.github.com'];
110
-
111
-		foreach($siteArray as $site) {
112
-			if ($this->isSiteReachable($site)) {
113
-				return true;
114
-			}
115
-		}
116
-		return false;
117
-	}
118
-
119
-	/**
120
-	* Chceks if the ownCloud server can connect to a specific URL using both HTTPS and HTTP
121
-	* @return bool
122
-	*/
123
-	private function isSiteReachable($sitename) {
124
-		$httpSiteName = 'http://' . $sitename . '/';
125
-		$httpsSiteName = 'https://' . $sitename . '/';
126
-
127
-		try {
128
-			$client = $this->clientService->newClient();
129
-			$client->get($httpSiteName);
130
-			$client->get($httpsSiteName);
131
-		} catch (\Exception $e) {
132
-			$this->logger->logException($e, ['app' => 'internet_connection_check']);
133
-			return false;
134
-		}
135
-		return true;
136
-	}
137
-
138
-	/**
139
-	 * Checks whether a local memcache is installed or not
140
-	 * @return bool
141
-	 */
142
-	private function isMemcacheConfigured() {
143
-		return $this->config->getSystemValue('memcache.local', null) !== null;
144
-	}
145
-
146
-	/**
147
-	 * Whether /dev/urandom is available to the PHP controller
148
-	 *
149
-	 * @return bool
150
-	 */
151
-	private function isUrandomAvailable() {
152
-		if(@file_exists('/dev/urandom')) {
153
-			$file = fopen('/dev/urandom', 'rb');
154
-			if($file) {
155
-				fclose($file);
156
-				return true;
157
-			}
158
-		}
159
-
160
-		return false;
161
-	}
162
-
163
-	/**
164
-	 * Public for the sake of unit-testing
165
-	 *
166
-	 * @return array
167
-	 */
168
-	protected function getCurlVersion() {
169
-		return curl_version();
170
-	}
171
-
172
-	/**
173
-	 * Check if the used  SSL lib is outdated. Older OpenSSL and NSS versions do
174
-	 * have multiple bugs which likely lead to problems in combination with
175
-	 * functionality required by ownCloud such as SNI.
176
-	 *
177
-	 * @link https://github.com/owncloud/core/issues/17446#issuecomment-122877546
178
-	 * @link https://bugzilla.redhat.com/show_bug.cgi?id=1241172
179
-	 * @return string
180
-	 */
181
-	private function isUsedTlsLibOutdated() {
182
-		// Don't run check when:
183
-		// 1. Server has `has_internet_connection` set to false
184
-		// 2. AppStore AND S2S is disabled
185
-		if(!$this->config->getSystemValue('has_internet_connection', true)) {
186
-			return '';
187
-		}
188
-		if(!$this->config->getSystemValue('appstoreenabled', true)
189
-			&& $this->config->getAppValue('files_sharing', 'outgoing_server2server_share_enabled', 'yes') === 'no'
190
-			&& $this->config->getAppValue('files_sharing', 'incoming_server2server_share_enabled', 'yes') === 'no') {
191
-			return '';
192
-		}
193
-
194
-		$versionString = $this->getCurlVersion();
195
-		if(isset($versionString['ssl_version'])) {
196
-			$versionString = $versionString['ssl_version'];
197
-		} else {
198
-			return '';
199
-		}
200
-
201
-		$features = (string)$this->l10n->t('installing and updating apps via the app store or Federated Cloud Sharing');
202
-		if(!$this->config->getSystemValue('appstoreenabled', true)) {
203
-			$features = (string)$this->l10n->t('Federated Cloud Sharing');
204
-		}
205
-
206
-		// Check if at least OpenSSL after 1.01d or 1.0.2b
207
-		if(strpos($versionString, 'OpenSSL/') === 0) {
208
-			$majorVersion = substr($versionString, 8, 5);
209
-			$patchRelease = substr($versionString, 13, 6);
210
-
211
-			if(($majorVersion === '1.0.1' && ord($patchRelease) < ord('d')) ||
212
-				($majorVersion === '1.0.2' && ord($patchRelease) < ord('b'))) {
213
-				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]);
214
-			}
215
-		}
216
-
217
-		// Check if NSS and perform heuristic check
218
-		if(strpos($versionString, 'NSS/') === 0) {
219
-			try {
220
-				$firstClient = $this->clientService->newClient();
221
-				$firstClient->get('https://nextcloud.com/');
222
-
223
-				$secondClient = $this->clientService->newClient();
224
-				$secondClient->get('https://nextcloud.com/');
225
-			} catch (ClientException $e) {
226
-				if($e->getResponse()->getStatusCode() === 400) {
227
-					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]);
228
-				}
229
-			}
230
-		}
231
-
232
-		return '';
233
-	}
234
-
235
-	/**
236
-	 * Whether the version is outdated
237
-	 *
238
-	 * @return bool
239
-	 */
240
-	protected function isPhpOutdated() {
241
-		if (version_compare(PHP_VERSION, '7.0.0', '<')) {
242
-			return true;
243
-		}
244
-
245
-		return false;
246
-	}
247
-
248
-	/**
249
-	 * Whether the php version is still supported (at time of release)
250
-	 * according to: https://secure.php.net/supported-versions.php
251
-	 *
252
-	 * @return array
253
-	 */
254
-	private function isPhpSupported() {
255
-		return ['eol' => $this->isPhpOutdated(), 'version' => PHP_VERSION];
256
-	}
257
-
258
-	/**
259
-	 * Check if the reverse proxy configuration is working as expected
260
-	 *
261
-	 * @return bool
262
-	 */
263
-	private function forwardedForHeadersWorking() {
264
-		$trustedProxies = $this->config->getSystemValue('trusted_proxies', []);
265
-		$remoteAddress = $this->request->getRemoteAddress();
266
-
267
-		if (is_array($trustedProxies) && in_array($remoteAddress, $trustedProxies)) {
268
-			return false;
269
-		}
270
-
271
-		// either not enabled or working correctly
272
-		return true;
273
-	}
274
-
275
-	/**
276
-	 * Checks if the correct memcache module for PHP is installed. Only
277
-	 * fails if memcached is configured and the working module is not installed.
278
-	 *
279
-	 * @return bool
280
-	 */
281
-	private function isCorrectMemcachedPHPModuleInstalled() {
282
-		if ($this->config->getSystemValue('memcache.distributed', null) !== '\OC\Memcache\Memcached') {
283
-			return true;
284
-		}
285
-
286
-		// there are two different memcached modules for PHP
287
-		// we only support memcached and not memcache
288
-		// https://code.google.com/p/memcached/wiki/PHPClientComparison
289
-		return !(!extension_loaded('memcached') && extension_loaded('memcache'));
290
-	}
291
-
292
-	/**
293
-	 * Checks if set_time_limit is not disabled.
294
-	 *
295
-	 * @return bool
296
-	 */
297
-	private function isSettimelimitAvailable() {
298
-		if (function_exists('set_time_limit')
299
-			&& strpos(@ini_get('disable_functions'), 'set_time_limit') === false) {
300
-			return true;
301
-		}
302
-
303
-		return false;
304
-	}
305
-
306
-	/**
307
-	 * @return RedirectResponse
308
-	 */
309
-	public function rescanFailedIntegrityCheck() {
310
-		$this->checker->runInstanceVerification();
311
-		return new RedirectResponse(
312
-			$this->urlGenerator->linkToRoute('settings.AdminSettings.index')
313
-		);
314
-	}
315
-
316
-	/**
317
-	 * @NoCSRFRequired
318
-	 * @return DataResponse
319
-	 */
320
-	public function getFailedIntegrityCheckFiles() {
321
-		if(!$this->checker->isCodeCheckEnforced()) {
322
-			return new DataDisplayResponse('Integrity checker has been disabled. Integrity cannot be verified.');
323
-		}
324
-
325
-		$completeResults = $this->checker->getResults();
326
-
327
-		if(!empty($completeResults)) {
328
-			$formattedTextResponse = 'Technical information
53
+    /** @var IConfig */
54
+    private $config;
55
+    /** @var IClientService */
56
+    private $clientService;
57
+    /** @var \OC_Util */
58
+    private $util;
59
+    /** @var IURLGenerator */
60
+    private $urlGenerator;
61
+    /** @var IL10N */
62
+    private $l10n;
63
+    /** @var Checker */
64
+    private $checker;
65
+    /** @var ILogger */
66
+    private $logger;
67
+
68
+    /**
69
+     * @param string $AppName
70
+     * @param IRequest $request
71
+     * @param IConfig $config
72
+     * @param IClientService $clientService
73
+     * @param IURLGenerator $urlGenerator
74
+     * @param \OC_Util $util
75
+     * @param IL10N $l10n
76
+     * @param Checker $checker
77
+     * @param ILogger $logger
78
+     */
79
+    public function __construct($AppName,
80
+                                IRequest $request,
81
+                                IConfig $config,
82
+                                IClientService $clientService,
83
+                                IURLGenerator $urlGenerator,
84
+                                \OC_Util $util,
85
+                                IL10N $l10n,
86
+                                Checker $checker,
87
+                                ILogger $logger) {
88
+        parent::__construct($AppName, $request);
89
+        $this->config = $config;
90
+        $this->clientService = $clientService;
91
+        $this->util = $util;
92
+        $this->urlGenerator = $urlGenerator;
93
+        $this->l10n = $l10n;
94
+        $this->checker = $checker;
95
+        $this->logger = $logger;
96
+    }
97
+
98
+    /**
99
+     * Checks if the ownCloud server can connect to the internet using HTTPS and HTTP
100
+     * @return bool
101
+     */
102
+    private function isInternetConnectionWorking() {
103
+        if ($this->config->getSystemValue('has_internet_connection', true) === false) {
104
+            return false;
105
+        }
106
+
107
+        $siteArray = ['www.nextcloud.com',
108
+                        'www.google.com',
109
+                        'www.github.com'];
110
+
111
+        foreach($siteArray as $site) {
112
+            if ($this->isSiteReachable($site)) {
113
+                return true;
114
+            }
115
+        }
116
+        return false;
117
+    }
118
+
119
+    /**
120
+     * Chceks if the ownCloud server can connect to a specific URL using both HTTPS and HTTP
121
+     * @return bool
122
+     */
123
+    private function isSiteReachable($sitename) {
124
+        $httpSiteName = 'http://' . $sitename . '/';
125
+        $httpsSiteName = 'https://' . $sitename . '/';
126
+
127
+        try {
128
+            $client = $this->clientService->newClient();
129
+            $client->get($httpSiteName);
130
+            $client->get($httpsSiteName);
131
+        } catch (\Exception $e) {
132
+            $this->logger->logException($e, ['app' => 'internet_connection_check']);
133
+            return false;
134
+        }
135
+        return true;
136
+    }
137
+
138
+    /**
139
+     * Checks whether a local memcache is installed or not
140
+     * @return bool
141
+     */
142
+    private function isMemcacheConfigured() {
143
+        return $this->config->getSystemValue('memcache.local', null) !== null;
144
+    }
145
+
146
+    /**
147
+     * Whether /dev/urandom is available to the PHP controller
148
+     *
149
+     * @return bool
150
+     */
151
+    private function isUrandomAvailable() {
152
+        if(@file_exists('/dev/urandom')) {
153
+            $file = fopen('/dev/urandom', 'rb');
154
+            if($file) {
155
+                fclose($file);
156
+                return true;
157
+            }
158
+        }
159
+
160
+        return false;
161
+    }
162
+
163
+    /**
164
+     * Public for the sake of unit-testing
165
+     *
166
+     * @return array
167
+     */
168
+    protected function getCurlVersion() {
169
+        return curl_version();
170
+    }
171
+
172
+    /**
173
+     * Check if the used  SSL lib is outdated. Older OpenSSL and NSS versions do
174
+     * have multiple bugs which likely lead to problems in combination with
175
+     * functionality required by ownCloud such as SNI.
176
+     *
177
+     * @link https://github.com/owncloud/core/issues/17446#issuecomment-122877546
178
+     * @link https://bugzilla.redhat.com/show_bug.cgi?id=1241172
179
+     * @return string
180
+     */
181
+    private function isUsedTlsLibOutdated() {
182
+        // Don't run check when:
183
+        // 1. Server has `has_internet_connection` set to false
184
+        // 2. AppStore AND S2S is disabled
185
+        if(!$this->config->getSystemValue('has_internet_connection', true)) {
186
+            return '';
187
+        }
188
+        if(!$this->config->getSystemValue('appstoreenabled', true)
189
+            && $this->config->getAppValue('files_sharing', 'outgoing_server2server_share_enabled', 'yes') === 'no'
190
+            && $this->config->getAppValue('files_sharing', 'incoming_server2server_share_enabled', 'yes') === 'no') {
191
+            return '';
192
+        }
193
+
194
+        $versionString = $this->getCurlVersion();
195
+        if(isset($versionString['ssl_version'])) {
196
+            $versionString = $versionString['ssl_version'];
197
+        } else {
198
+            return '';
199
+        }
200
+
201
+        $features = (string)$this->l10n->t('installing and updating apps via the app store or Federated Cloud Sharing');
202
+        if(!$this->config->getSystemValue('appstoreenabled', true)) {
203
+            $features = (string)$this->l10n->t('Federated Cloud Sharing');
204
+        }
205
+
206
+        // Check if at least OpenSSL after 1.01d or 1.0.2b
207
+        if(strpos($versionString, 'OpenSSL/') === 0) {
208
+            $majorVersion = substr($versionString, 8, 5);
209
+            $patchRelease = substr($versionString, 13, 6);
210
+
211
+            if(($majorVersion === '1.0.1' && ord($patchRelease) < ord('d')) ||
212
+                ($majorVersion === '1.0.2' && ord($patchRelease) < ord('b'))) {
213
+                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]);
214
+            }
215
+        }
216
+
217
+        // Check if NSS and perform heuristic check
218
+        if(strpos($versionString, 'NSS/') === 0) {
219
+            try {
220
+                $firstClient = $this->clientService->newClient();
221
+                $firstClient->get('https://nextcloud.com/');
222
+
223
+                $secondClient = $this->clientService->newClient();
224
+                $secondClient->get('https://nextcloud.com/');
225
+            } catch (ClientException $e) {
226
+                if($e->getResponse()->getStatusCode() === 400) {
227
+                    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]);
228
+                }
229
+            }
230
+        }
231
+
232
+        return '';
233
+    }
234
+
235
+    /**
236
+     * Whether the version is outdated
237
+     *
238
+     * @return bool
239
+     */
240
+    protected function isPhpOutdated() {
241
+        if (version_compare(PHP_VERSION, '7.0.0', '<')) {
242
+            return true;
243
+        }
244
+
245
+        return false;
246
+    }
247
+
248
+    /**
249
+     * Whether the php version is still supported (at time of release)
250
+     * according to: https://secure.php.net/supported-versions.php
251
+     *
252
+     * @return array
253
+     */
254
+    private function isPhpSupported() {
255
+        return ['eol' => $this->isPhpOutdated(), 'version' => PHP_VERSION];
256
+    }
257
+
258
+    /**
259
+     * Check if the reverse proxy configuration is working as expected
260
+     *
261
+     * @return bool
262
+     */
263
+    private function forwardedForHeadersWorking() {
264
+        $trustedProxies = $this->config->getSystemValue('trusted_proxies', []);
265
+        $remoteAddress = $this->request->getRemoteAddress();
266
+
267
+        if (is_array($trustedProxies) && in_array($remoteAddress, $trustedProxies)) {
268
+            return false;
269
+        }
270
+
271
+        // either not enabled or working correctly
272
+        return true;
273
+    }
274
+
275
+    /**
276
+     * Checks if the correct memcache module for PHP is installed. Only
277
+     * fails if memcached is configured and the working module is not installed.
278
+     *
279
+     * @return bool
280
+     */
281
+    private function isCorrectMemcachedPHPModuleInstalled() {
282
+        if ($this->config->getSystemValue('memcache.distributed', null) !== '\OC\Memcache\Memcached') {
283
+            return true;
284
+        }
285
+
286
+        // there are two different memcached modules for PHP
287
+        // we only support memcached and not memcache
288
+        // https://code.google.com/p/memcached/wiki/PHPClientComparison
289
+        return !(!extension_loaded('memcached') && extension_loaded('memcache'));
290
+    }
291
+
292
+    /**
293
+     * Checks if set_time_limit is not disabled.
294
+     *
295
+     * @return bool
296
+     */
297
+    private function isSettimelimitAvailable() {
298
+        if (function_exists('set_time_limit')
299
+            && strpos(@ini_get('disable_functions'), 'set_time_limit') === false) {
300
+            return true;
301
+        }
302
+
303
+        return false;
304
+    }
305
+
306
+    /**
307
+     * @return RedirectResponse
308
+     */
309
+    public function rescanFailedIntegrityCheck() {
310
+        $this->checker->runInstanceVerification();
311
+        return new RedirectResponse(
312
+            $this->urlGenerator->linkToRoute('settings.AdminSettings.index')
313
+        );
314
+    }
315
+
316
+    /**
317
+     * @NoCSRFRequired
318
+     * @return DataResponse
319
+     */
320
+    public function getFailedIntegrityCheckFiles() {
321
+        if(!$this->checker->isCodeCheckEnforced()) {
322
+            return new DataDisplayResponse('Integrity checker has been disabled. Integrity cannot be verified.');
323
+        }
324
+
325
+        $completeResults = $this->checker->getResults();
326
+
327
+        if(!empty($completeResults)) {
328
+            $formattedTextResponse = 'Technical information
329 329
 =====================
330 330
 The following list covers which files have failed the integrity check. Please read
331 331
 the previous linked documentation to learn more about the errors and how to fix
@@ -334,103 +334,103 @@  discard block
 block discarded – undo
334 334
 Results
335 335
 =======
336 336
 ';
337
-			foreach($completeResults as $context => $contextResult) {
338
-				$formattedTextResponse .= "- $context\n";
339
-
340
-				foreach($contextResult as $category => $result) {
341
-					$formattedTextResponse .= "\t- $category\n";
342
-					if($category !== 'EXCEPTION') {
343
-						foreach ($result as $key => $results) {
344
-							$formattedTextResponse .= "\t\t- $key\n";
345
-						}
346
-					} else {
347
-						foreach ($result as $key => $results) {
348
-							$formattedTextResponse .= "\t\t- $results\n";
349
-						}
350
-					}
351
-
352
-				}
353
-			}
354
-
355
-			$formattedTextResponse .= '
337
+            foreach($completeResults as $context => $contextResult) {
338
+                $formattedTextResponse .= "- $context\n";
339
+
340
+                foreach($contextResult as $category => $result) {
341
+                    $formattedTextResponse .= "\t- $category\n";
342
+                    if($category !== 'EXCEPTION') {
343
+                        foreach ($result as $key => $results) {
344
+                            $formattedTextResponse .= "\t\t- $key\n";
345
+                        }
346
+                    } else {
347
+                        foreach ($result as $key => $results) {
348
+                            $formattedTextResponse .= "\t\t- $results\n";
349
+                        }
350
+                    }
351
+
352
+                }
353
+            }
354
+
355
+            $formattedTextResponse .= '
356 356
 Raw output
357 357
 ==========
358 358
 ';
359
-			$formattedTextResponse .= print_r($completeResults, true);
360
-		} else {
361
-			$formattedTextResponse = 'No errors have been found.';
362
-		}
363
-
364
-
365
-		$response = new DataDisplayResponse(
366
-			$formattedTextResponse,
367
-			Http::STATUS_OK,
368
-			[
369
-				'Content-Type' => 'text/plain',
370
-			]
371
-		);
372
-
373
-		return $response;
374
-	}
375
-
376
-	/**
377
-	 * Checks whether a PHP opcache is properly set up
378
-	 * @return bool
379
-	 */
380
-	protected function isOpcacheProperlySetup() {
381
-		$iniWrapper = new IniGetWrapper();
382
-
383
-		$isOpcacheProperlySetUp = true;
384
-
385
-		if(!$iniWrapper->getBool('opcache.enable')) {
386
-			$isOpcacheProperlySetUp = false;
387
-		}
388
-
389
-		if(!$iniWrapper->getBool('opcache.save_comments')) {
390
-			$isOpcacheProperlySetUp = false;
391
-		}
392
-
393
-		if(!$iniWrapper->getBool('opcache.enable_cli')) {
394
-			$isOpcacheProperlySetUp = false;
395
-		}
396
-
397
-		if($iniWrapper->getNumeric('opcache.max_accelerated_files') < 10000) {
398
-			$isOpcacheProperlySetUp = false;
399
-		}
400
-
401
-		if($iniWrapper->getNumeric('opcache.memory_consumption') < 128) {
402
-			$isOpcacheProperlySetUp = false;
403
-		}
404
-
405
-		if($iniWrapper->getNumeric('opcache.interned_strings_buffer') < 8) {
406
-			$isOpcacheProperlySetUp = false;
407
-		}
408
-
409
-		return $isOpcacheProperlySetUp;
410
-	}
411
-
412
-	/**
413
-	 * @return DataResponse
414
-	 */
415
-	public function check() {
416
-		return new DataResponse(
417
-			[
418
-				'serverHasInternetConnection' => $this->isInternetConnectionWorking(),
419
-				'isMemcacheConfigured' => $this->isMemcacheConfigured(),
420
-				'memcacheDocs' => $this->urlGenerator->linkToDocs('admin-performance'),
421
-				'isUrandomAvailable' => $this->isUrandomAvailable(),
422
-				'securityDocs' => $this->urlGenerator->linkToDocs('admin-security'),
423
-				'isUsedTlsLibOutdated' => $this->isUsedTlsLibOutdated(),
424
-				'phpSupported' => $this->isPhpSupported(),
425
-				'forwardedForHeadersWorking' => $this->forwardedForHeadersWorking(),
426
-				'reverseProxyDocs' => $this->urlGenerator->linkToDocs('admin-reverse-proxy'),
427
-				'isCorrectMemcachedPHPModuleInstalled' => $this->isCorrectMemcachedPHPModuleInstalled(),
428
-				'hasPassedCodeIntegrityCheck' => $this->checker->hasPassedCheck(),
429
-				'codeIntegrityCheckerDocumentation' => $this->urlGenerator->linkToDocs('admin-code-integrity'),
430
-				'isOpcacheProperlySetup' => $this->isOpcacheProperlySetup(),
431
-				'phpOpcacheDocumentation' => $this->urlGenerator->linkToDocs('admin-php-opcache'),
432
-				'isSettimelimitAvailable' => $this->isSettimelimitAvailable(),
433
-			]
434
-		);
435
-	}
359
+            $formattedTextResponse .= print_r($completeResults, true);
360
+        } else {
361
+            $formattedTextResponse = 'No errors have been found.';
362
+        }
363
+
364
+
365
+        $response = new DataDisplayResponse(
366
+            $formattedTextResponse,
367
+            Http::STATUS_OK,
368
+            [
369
+                'Content-Type' => 'text/plain',
370
+            ]
371
+        );
372
+
373
+        return $response;
374
+    }
375
+
376
+    /**
377
+     * Checks whether a PHP opcache is properly set up
378
+     * @return bool
379
+     */
380
+    protected function isOpcacheProperlySetup() {
381
+        $iniWrapper = new IniGetWrapper();
382
+
383
+        $isOpcacheProperlySetUp = true;
384
+
385
+        if(!$iniWrapper->getBool('opcache.enable')) {
386
+            $isOpcacheProperlySetUp = false;
387
+        }
388
+
389
+        if(!$iniWrapper->getBool('opcache.save_comments')) {
390
+            $isOpcacheProperlySetUp = false;
391
+        }
392
+
393
+        if(!$iniWrapper->getBool('opcache.enable_cli')) {
394
+            $isOpcacheProperlySetUp = false;
395
+        }
396
+
397
+        if($iniWrapper->getNumeric('opcache.max_accelerated_files') < 10000) {
398
+            $isOpcacheProperlySetUp = false;
399
+        }
400
+
401
+        if($iniWrapper->getNumeric('opcache.memory_consumption') < 128) {
402
+            $isOpcacheProperlySetUp = false;
403
+        }
404
+
405
+        if($iniWrapper->getNumeric('opcache.interned_strings_buffer') < 8) {
406
+            $isOpcacheProperlySetUp = false;
407
+        }
408
+
409
+        return $isOpcacheProperlySetUp;
410
+    }
411
+
412
+    /**
413
+     * @return DataResponse
414
+     */
415
+    public function check() {
416
+        return new DataResponse(
417
+            [
418
+                'serverHasInternetConnection' => $this->isInternetConnectionWorking(),
419
+                'isMemcacheConfigured' => $this->isMemcacheConfigured(),
420
+                'memcacheDocs' => $this->urlGenerator->linkToDocs('admin-performance'),
421
+                'isUrandomAvailable' => $this->isUrandomAvailable(),
422
+                'securityDocs' => $this->urlGenerator->linkToDocs('admin-security'),
423
+                'isUsedTlsLibOutdated' => $this->isUsedTlsLibOutdated(),
424
+                'phpSupported' => $this->isPhpSupported(),
425
+                'forwardedForHeadersWorking' => $this->forwardedForHeadersWorking(),
426
+                'reverseProxyDocs' => $this->urlGenerator->linkToDocs('admin-reverse-proxy'),
427
+                'isCorrectMemcachedPHPModuleInstalled' => $this->isCorrectMemcachedPHPModuleInstalled(),
428
+                'hasPassedCodeIntegrityCheck' => $this->checker->hasPassedCheck(),
429
+                'codeIntegrityCheckerDocumentation' => $this->urlGenerator->linkToDocs('admin-code-integrity'),
430
+                'isOpcacheProperlySetup' => $this->isOpcacheProperlySetup(),
431
+                'phpOpcacheDocumentation' => $this->urlGenerator->linkToDocs('admin-php-opcache'),
432
+                'isSettimelimitAvailable' => $this->isSettimelimitAvailable(),
433
+            ]
434
+        );
435
+    }
436 436
 }
Please login to merge, or discard this patch.