config = $config; $this->cache = $cache; $this->lock = $lock; } private function isAllowed(array $request): bool { return empty(!$request['key']) && $request['key'] == $this->config->get('system', 'stats_key'); } protected function content(array $request = []): string { if (!$this->isAllowed($request)) { throw new HTTPException\NotFoundException($this->l10n->t('Page not found.')); } return ''; } protected function rawContent(array $request = []) { if (!$this->isAllowed($request)) { return; } $data = []; // OPcache if (function_exists('opcache_get_status')) { $status = opcache_get_status(false); $data['opcache'] = [ 'enabled' => $status['opcache_enabled'] ?? false, 'hit_rate' => $status['opcache_statistics']['opcache_hit_rate'] ?? null, 'used_memory' => $status['memory_usage']['used_memory'] ?? null, 'free_memory' => $status['memory_usage']['free_memory'] ?? null, 'num_cached_scripts' => $status['opcache_statistics']['num_cached_scripts'] ?? null, ]; } else { $data['opcache'] = [ 'enabled' => false, ]; } if ($this->cache instanceof ICanCacheInMemory) { $data['cache'] = [ 'type' => $this->cache->getName(), 'stats' => $this->cache->getStats(), ]; } else { $data['cache'] = [ 'type' => $this->cache->getName(), ]; } if ($this->lock instanceof CacheLock) { $data['lock'] = [ 'type' => $this->lock->getName(), 'stats' => $this->lock->getCacheStats(), ]; } else { $data['lock'] = [ 'type' => $this->lock->getName(), ]; } $this->jsonExit($data); } }