fisharebest /
webtrees
| 1 | <?php |
||
| 2 | |||
| 3 | /** |
||
| 4 | * webtrees: online genealogy |
||
| 5 | * Copyright (C) 2025 webtrees development team |
||
| 6 | * This program is free software: you can redistribute it and/or modify |
||
| 7 | * it under the terms of the GNU General Public License as published by |
||
| 8 | * the Free Software Foundation, either version 3 of the License, or |
||
| 9 | * (at your option) any later version. |
||
| 10 | * This program is distributed in the hope that it will be useful, |
||
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
| 13 | * GNU General Public License for more details. |
||
| 14 | * You should have received a copy of the GNU General Public License |
||
| 15 | * along with this program. If not, see <https://www.gnu.org/licenses/>. |
||
| 16 | */ |
||
| 17 | |||
| 18 | declare(strict_types=1); |
||
| 19 | |||
| 20 | namespace Fisharebest\Webtrees\Http\RequestHandlers; |
||
| 21 | |||
| 22 | use DateTimeImmutable; |
||
| 23 | use DateTimeZone; |
||
| 24 | use Fisharebest\Webtrees\Auth; |
||
|
0 ignored issues
–
show
|
|||
| 25 | use Fisharebest\Webtrees\Contracts\UserInterface; |
||
|
0 ignored issues
–
show
The type
Fisharebest\Webtrees\Contracts\UserInterface was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 26 | use Fisharebest\Webtrees\DB; |
||
|
0 ignored issues
–
show
The type
Fisharebest\Webtrees\DB was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 27 | use Fisharebest\Webtrees\Http\ViewResponseTrait; |
||
| 28 | use Fisharebest\Webtrees\I18N; |
||
|
0 ignored issues
–
show
The type
Fisharebest\Webtrees\I18N was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 29 | use Fisharebest\Webtrees\Services\TreeService; |
||
|
0 ignored issues
–
show
The type
Fisharebest\Webtrees\Services\TreeService was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 30 | use Fisharebest\Webtrees\Services\UserService; |
||
| 31 | use Fisharebest\Webtrees\Tree; |
||
| 32 | use Fisharebest\Webtrees\User; |
||
| 33 | use Fisharebest\Webtrees\Validator; |
||
| 34 | use Psr\Http\Message\ResponseInterface; |
||
| 35 | use Psr\Http\Message\ServerRequestInterface; |
||
| 36 | use Psr\Http\Server\RequestHandlerInterface; |
||
| 37 | |||
| 38 | use function date; |
||
| 39 | use function max; |
||
| 40 | use function min; |
||
| 41 | |||
| 42 | final class SiteLogsPage implements RequestHandlerInterface |
||
| 43 | { |
||
| 44 | use ViewResponseTrait; |
||
| 45 | |||
| 46 | public function __construct( |
||
| 47 | private readonly TreeService $tree_service, |
||
| 48 | private readonly UserService $user_service, |
||
| 49 | ) { |
||
| 50 | } |
||
| 51 | |||
| 52 | public function handle(ServerRequestInterface $request): ResponseInterface |
||
| 53 | { |
||
| 54 | $this->layout = 'layouts/administration'; |
||
| 55 | |||
| 56 | // First and last change in the database |
||
| 57 | $earliest = DB::table('log')->min('log_time') ?? date('Y-m-d H:i:s'); |
||
| 58 | $latest = DB::table('log')->max('log_time') ?? date('Y-m-d H:i:s'); |
||
| 59 | |||
| 60 | $earliest = DateTimeImmutable::createFromFormat('Y-m-d H:i:s', $earliest, new DateTimeZone('UTC')) |
||
| 61 | ->setTimezone(new DateTimeZone(Auth::user()->getPreference(UserInterface::PREF_TIME_ZONE, 'UTC'))) |
||
| 62 | ->format('Y-m-d'); |
||
| 63 | |||
| 64 | $latest = DateTimeImmutable::createFromFormat('Y-m-d H:i:s', $latest, new DateTimeZone('UTC')) |
||
| 65 | ->setTimezone(new DateTimeZone(Auth::user()->getPreference(UserInterface::PREF_TIME_ZONE, 'UTC'))) |
||
| 66 | ->format('Y-m-d'); |
||
| 67 | |||
| 68 | $action = Validator::queryParams($request)->string('action', ''); |
||
| 69 | $from = Validator::queryParams($request)->string('from', $earliest); |
||
| 70 | $to = Validator::queryParams($request)->string('to', $latest); |
||
| 71 | $type = Validator::queryParams($request)->string('type', ''); |
||
| 72 | $text = Validator::queryParams($request)->string('text', ''); |
||
| 73 | $ip = Validator::queryParams($request)->string('ip', ''); |
||
| 74 | $username = Validator::queryParams($request)->string('username', ''); |
||
| 75 | $tree = Validator::queryParams($request)->string('tree', ''); |
||
| 76 | |||
| 77 | $from = max($from, $earliest); |
||
| 78 | $to = min(max($from, $to), $latest); |
||
| 79 | |||
| 80 | $user_options = $this->user_service->all()->mapWithKeys(static fn (User $user): array => [$user->userName() => $user->userName()]); |
||
| 81 | $user_options->prepend('', ''); |
||
| 82 | |||
| 83 | $tree_options = $this->tree_service->all()->mapWithKeys(static fn (Tree $tree): array => [$tree->name() => $tree->title()]); |
||
| 84 | $tree_options->prepend('', ''); |
||
| 85 | |||
| 86 | $title = I18N::translate('Website logs'); |
||
| 87 | |||
| 88 | return $this->viewResponse('admin/site-logs', [ |
||
| 89 | 'action' => $action, |
||
| 90 | 'earliest' => $earliest, |
||
| 91 | 'from' => $from, |
||
| 92 | 'tree' => $tree, |
||
| 93 | 'ip' => $ip, |
||
| 94 | 'latest' => $latest, |
||
| 95 | 'tree_options' => $tree_options, |
||
| 96 | 'title' => $title, |
||
| 97 | 'to' => $to, |
||
| 98 | 'text' => $text, |
||
| 99 | 'type' => $type, |
||
| 100 | 'username' => $username, |
||
| 101 | 'user_options' => $user_options, |
||
| 102 | ]); |
||
| 103 | } |
||
| 104 | } |
||
| 105 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths