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