|
1
|
|
|
<?php |
|
2
|
|
|
/* |
|
3
|
|
|
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony). |
|
4
|
|
|
* |
|
5
|
|
|
* Copyright (C) 2019 - 2022 Jan Böhmer (https://github.com/jbtronics) |
|
6
|
|
|
* |
|
7
|
|
|
* This program is free software: you can redistribute it and/or modify |
|
8
|
|
|
* it under the terms of the GNU Affero General Public License as published |
|
9
|
|
|
* by the Free Software Foundation, either version 3 of the License, or |
|
10
|
|
|
* (at your option) any later version. |
|
11
|
|
|
* |
|
12
|
|
|
* This program is distributed in the hope that it will be useful, |
|
13
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
14
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
15
|
|
|
* GNU Affero General Public License for more details. |
|
16
|
|
|
* |
|
17
|
|
|
* You should have received a copy of the GNU Affero General Public License |
|
18
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>. |
|
19
|
|
|
*/ |
|
20
|
|
|
|
|
21
|
|
|
namespace App\Controller; |
|
22
|
|
|
|
|
23
|
|
|
use App\Services\Attachments\AttachmentPathResolver; |
|
24
|
|
|
use App\Services\Attachments\AttachmentURLGenerator; |
|
25
|
|
|
use App\Services\Attachments\BuiltinAttachmentsFinder; |
|
26
|
|
|
use App\Services\Misc\GitVersionInfo; |
|
27
|
|
|
use App\Services\Misc\DBInfoHelper; |
|
28
|
|
|
use Doctrine\ORM\EntityManagerInterface; |
|
29
|
|
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; |
|
30
|
|
|
use Symfony\Component\HttpFoundation\Response; |
|
31
|
|
|
use Symfony\Component\Routing\Annotation\Route; |
|
32
|
|
|
use Symfony\Component\Routing\Generator\UrlGenerator; |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* @Route("/tools") |
|
36
|
|
|
*/ |
|
37
|
|
|
class ToolsController extends AbstractController |
|
38
|
|
|
{ |
|
39
|
|
|
/** |
|
40
|
|
|
* @Route("/reel_calc", name="tools_reel_calculator") |
|
41
|
|
|
*/ |
|
42
|
|
|
public function reelCalculator(): Response |
|
43
|
|
|
{ |
|
44
|
|
|
$this->denyAccessUnlessGranted('@tools.reel_calculator'); |
|
45
|
|
|
|
|
46
|
|
|
return $this->render('Tools/ReelCalculator/main.html.twig'); |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* @Route("/server_infos", name="tools_server_infos") |
|
51
|
|
|
*/ |
|
52
|
|
|
public function systemInfos(GitVersionInfo $versionInfo, DBInfoHelper $DBInfoHelper): Response |
|
53
|
|
|
{ |
|
54
|
|
|
$this->denyAccessUnlessGranted('@system.server_infos'); |
|
55
|
|
|
|
|
56
|
|
|
return $this->render('Tools/ServerInfos/main.html.twig', [ |
|
57
|
|
|
//Part-DB section |
|
58
|
|
|
'git_branch' => $versionInfo->getGitBranchName(), |
|
59
|
|
|
'git_commit' => $versionInfo->getGitCommitHash(), |
|
60
|
|
|
'default_locale' => $this->getParameter('partdb.locale'), |
|
61
|
|
|
'default_timezone' => $this->getParameter('partdb.timezone'), |
|
62
|
|
|
'default_currency' => $this->getParameter('partdb.default_currency'), |
|
63
|
|
|
'default_theme' => $this->getParameter('partdb.global_theme'), |
|
64
|
|
|
'enabled_locales' => $this->getParameter('partdb.locale_menu'), |
|
65
|
|
|
'demo_mode' => $this->getParameter('partdb.demo_mode'), |
|
66
|
|
|
'gpdr_compliance' => $this->getParameter('partdb.gpdr_compliance'), |
|
67
|
|
|
'use_gravatar' => $this->getParameter('partdb.users.use_gravatar'), |
|
68
|
|
|
'email_password_reset' => $this->getParameter('partdb.users.email_pw_reset'), |
|
69
|
|
|
'enviroment' => $this->getParameter('kernel.environment'), |
|
70
|
|
|
'is_debug' => $this->getParameter('kernel.debug'), |
|
71
|
|
|
'email_sender' => $this->getParameter('partdb.mail.sender_email'), |
|
72
|
|
|
'email_sender_name' => $this->getParameter('partdb.mail.sender_name'), |
|
73
|
|
|
'allow_attachments_downloads' => $this->getParameter('partdb.attachments.allow_downloads'), |
|
74
|
|
|
'detailed_error_pages' => $this->getParameter('partdb.error_pages.show_help'), |
|
75
|
|
|
'error_page_admin_email' => $this->getParameter('partdb.error_pages.admin_email'), |
|
76
|
|
|
|
|
77
|
|
|
//PHP section |
|
78
|
|
|
'php_version' => PHP_VERSION, |
|
79
|
|
|
'php_uname' => php_uname('a'), |
|
80
|
|
|
'php_sapi' => PHP_SAPI, |
|
81
|
|
|
'php_extensions' => array_merge(get_loaded_extensions()), |
|
82
|
|
|
'php_opcache_enabled' => ini_get('opcache.enable'), |
|
83
|
|
|
'php_upload_max_filesize' => ini_get('upload_max_filesize'), |
|
84
|
|
|
'php_post_max_size' => ini_get('post_max_size'), |
|
85
|
|
|
|
|
86
|
|
|
//DB section |
|
87
|
|
|
'db_type' => $DBInfoHelper->getDatabaseType() ?? 'Unknown', |
|
88
|
|
|
'db_version' => $DBInfoHelper->getDatabaseVersion() ?? 'Unknown', |
|
89
|
|
|
]); |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
/** |
|
93
|
|
|
* @Route("/builtin_footprints", name="tools_builtin_footprints_viewer") |
|
94
|
|
|
* @return Response |
|
95
|
|
|
*/ |
|
96
|
|
|
public function builtInFootprintsViewer(BuiltinAttachmentsFinder $builtinAttachmentsFinder, AttachmentURLGenerator $urlGenerator): Response |
|
97
|
|
|
{ |
|
98
|
|
|
$this->denyAccessUnlessGranted('@tools.builtin_footprints_viewer'); |
|
99
|
|
|
|
|
100
|
|
|
$grouped_footprints = $builtinAttachmentsFinder->getListOfFootprintsGroupedByFolder(); |
|
101
|
|
|
$grouped_footprints = array_map(function($group) use ($urlGenerator) { |
|
102
|
|
|
return array_map(function($placeholder_filepath) use ($urlGenerator) { |
|
103
|
|
|
return [ |
|
104
|
|
|
'filename' => basename($placeholder_filepath), |
|
105
|
|
|
'assets_path' => $urlGenerator->placeholderPathToAssetPath($placeholder_filepath), |
|
106
|
|
|
]; |
|
107
|
|
|
}, $group); |
|
108
|
|
|
}, $grouped_footprints); |
|
109
|
|
|
|
|
110
|
|
|
return $this->render('Tools/BuiltInFootprintsViewer/main.html.twig', [ |
|
111
|
|
|
'grouped_footprints' => $grouped_footprints, |
|
112
|
|
|
]); |
|
113
|
|
|
} |
|
114
|
|
|
|
|
115
|
|
|
/** |
|
116
|
|
|
* @Route("/ic_logos", name="tools_ic_logos") |
|
117
|
|
|
* @return Response |
|
118
|
|
|
*/ |
|
119
|
|
|
public function icLogos(): Response |
|
120
|
|
|
{ |
|
121
|
|
|
$this->denyAccessUnlessGranted('@tools.ic_logos'); |
|
122
|
|
|
|
|
123
|
|
|
return $this->render('Tools/ICLogos/ic_logos.html.twig'); |
|
124
|
|
|
} |
|
125
|
|
|
} |
|
126
|
|
|
|