1b1a54200SGreg Roach<?php 2b1a54200SGreg Roach 3b1a54200SGreg Roach/** 4b1a54200SGreg Roach * webtrees: online genealogy 5*d11be702SGreg Roach * Copyright (C) 2023 webtrees development team 6b1a54200SGreg Roach * This program is free software: you can redistribute it and/or modify 7b1a54200SGreg Roach * it under the terms of the GNU General Public License as published by 8b1a54200SGreg Roach * the Free Software Foundation, either version 3 of the License, or 9b1a54200SGreg Roach * (at your option) any later version. 10b1a54200SGreg Roach * This program is distributed in the hope that it will be useful, 11b1a54200SGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of 12b1a54200SGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13b1a54200SGreg Roach * GNU General Public License for more details. 14b1a54200SGreg Roach * You should have received a copy of the GNU General Public License 1589f7189bSGreg Roach * along with this program. If not, see <https://www.gnu.org/licenses/>. 16b1a54200SGreg Roach */ 17fcfa147eSGreg Roach 18b1a54200SGreg Roachdeclare(strict_types=1); 19b1a54200SGreg Roach 20b1a54200SGreg Roachnamespace Fisharebest\Webtrees\Http\RequestHandlers; 21b1a54200SGreg Roach 22b1a54200SGreg Roachuse Fisharebest\Webtrees\Http\ViewResponseTrait; 23b1a54200SGreg Roachuse Fisharebest\Webtrees\I18N; 24b1a54200SGreg Roachuse Psr\Http\Message\ResponseInterface; 25b1a54200SGreg Roachuse Psr\Http\Message\ServerRequestInterface; 26b1a54200SGreg Roachuse Psr\Http\Server\RequestHandlerInterface; 27b1a54200SGreg Roach 28b1a54200SGreg Roachuse function ob_get_clean; 29b1a54200SGreg Roachuse function ob_start; 30b1a54200SGreg Roachuse function phpinfo; 31b1a54200SGreg Roachuse function preg_match; 32b1a54200SGreg Roach 33b1a54200SGreg Roachuse const INFO_ALL; 34b1a54200SGreg Roachuse const INFO_CREDITS; 35b1a54200SGreg Roachuse const INFO_LICENSE; 36b1a54200SGreg Roach 37b1a54200SGreg Roach/** 38b1a54200SGreg Roach * Show PHP information. 39b1a54200SGreg Roach */ 40b1a54200SGreg Roachclass PhpInformation implements RequestHandlerInterface 41b1a54200SGreg Roach{ 42b1a54200SGreg Roach use ViewResponseTrait; 43b1a54200SGreg Roach 44b1a54200SGreg Roach /** 45b1a54200SGreg Roach * @param ServerRequestInterface $request 46b1a54200SGreg Roach * 47b1a54200SGreg Roach * @return ResponseInterface 48b1a54200SGreg Roach */ 49b1a54200SGreg Roach public function handle(ServerRequestInterface $request): ResponseInterface 50b1a54200SGreg Roach { 51b1a54200SGreg Roach $this->layout = 'layouts/administration'; 52b1a54200SGreg Roach 53b1a54200SGreg Roach ob_start(); 54b1a54200SGreg Roach phpinfo(INFO_ALL & ~INFO_CREDITS & ~INFO_LICENSE); 55b1a54200SGreg Roach $phpinfo = ob_get_clean(); 56b1a54200SGreg Roach preg_match('%<body>(.*)</body>%s', $phpinfo, $matches); 57b1a54200SGreg Roach $phpinfo = $matches[1]; 58b1a54200SGreg Roach 59b1a54200SGreg Roach return $this->viewResponse('admin/server-information', [ 60b1a54200SGreg Roach 'title' => I18N::translate('Server information'), 61b1a54200SGreg Roach 'phpinfo' => $phpinfo, 62b1a54200SGreg Roach ]); 63b1a54200SGreg Roach } 64b1a54200SGreg Roach} 65