1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the core-bundle package. |
5
|
|
|
* |
6
|
|
|
* (c) 2022 WEBEWEB |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace WBW\Bundle\CoreBundle\Controller; |
13
|
|
|
|
14
|
|
|
use Doctrine\DBAL\Connection; |
15
|
|
|
use Symfony\Component\HttpFoundation\JsonResponse; |
16
|
|
|
use Symfony\Component\HttpFoundation\Request; |
17
|
|
|
use Symfony\Component\HttpFoundation\Response; |
18
|
|
|
use WBW\Library\System\System; |
19
|
|
|
use WBW\Library\Types\Helper\ArrayHelper; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* Host controller. |
23
|
|
|
* |
24
|
|
|
* @author webeweb <https://github.com/webeweb> |
25
|
|
|
* @package WBW\Bundle\CoreBundle\Controller |
26
|
|
|
*/ |
27
|
|
|
class HostController extends AbstractController { |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* Service name. |
31
|
|
|
* |
32
|
|
|
* @var string |
33
|
|
|
*/ |
34
|
|
|
const SERVICE_NAME = "wbw.core.controller.host"; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* CPU. |
38
|
|
|
* |
39
|
|
|
* @return Response Returns the response. |
40
|
|
|
*/ |
41
|
|
|
public function cpuAction(): Response { |
42
|
|
|
|
43
|
|
|
$info = System::getCpu(); |
44
|
|
|
$data = $this->newDefaultJsonResponseData(true, $info->jsonSerialize()); |
45
|
|
|
|
46
|
|
|
return new JsonResponse($data); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* Hard disks. |
51
|
|
|
* |
52
|
|
|
* @return Response Returns the response. |
53
|
|
|
*/ |
54
|
|
|
public function hardDisksAction(): Response { |
55
|
|
|
|
56
|
|
|
$info = System::getHardDisks(); |
57
|
|
|
$data = $this->newDefaultJsonResponseData(true, $info); |
58
|
|
|
|
59
|
|
|
return new JsonResponse($data); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* Memory. |
64
|
|
|
* |
65
|
|
|
* @return Response Returns the response. |
66
|
|
|
*/ |
67
|
|
|
public function memoryAction(): Response { |
68
|
|
|
|
69
|
|
|
$info = System::getMemory(); |
70
|
|
|
$data = $this->newDefaultJsonResponseData(true, $info->jsonSerialize()); |
71
|
|
|
|
72
|
|
|
return new JsonResponse($data); |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* Retrieve the information "database". |
77
|
|
|
* |
78
|
|
|
* @return array Returns the information "database". |
79
|
|
|
*/ |
80
|
|
|
public function retrieveInformationDatabase(): array { |
81
|
|
|
|
82
|
|
|
/** @var Connection $connection */ |
83
|
|
|
$connection = $this->getDoctrine()->getConnection(); |
|
|
|
|
84
|
|
|
$parameters = $connection->getParams(); |
85
|
|
|
|
86
|
|
|
return [ |
87
|
|
|
"driver" => $parameters["driver"], |
88
|
|
|
"dbname" => ArrayHelper::get($parameters, "dbname"), |
89
|
|
|
"host" => $parameters["host"], |
90
|
|
|
"port" => $parameters["port"], |
91
|
|
|
"user" => $parameters["user"], |
92
|
|
|
"serverVersion" => ArrayHelper::get($parameters, "serverVersion"), |
93
|
|
|
]; |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* Retrieve the information "server". |
98
|
|
|
* |
99
|
|
|
* @param Request $request The request. |
100
|
|
|
* @return array Returns the information "server". |
101
|
|
|
*/ |
102
|
|
|
public function retrieveInformationServer(Request $request): array { |
103
|
|
|
|
104
|
|
|
return [ |
105
|
|
|
"maxExecutionTime" => ini_get("max_execution_time"), |
106
|
|
|
"memoryLimit" => ini_get("memory_limit"), |
107
|
|
|
"phpUname" => implode(" ", [ |
108
|
|
|
php_uname('s'), |
109
|
|
|
php_uname('v'), |
110
|
|
|
php_uname('m'), |
111
|
|
|
]), |
112
|
|
|
"phpVersion" => phpversion(), |
113
|
|
|
"serverSoftware" => $request->server->get("SERVER_SOFTWARE"), |
114
|
|
|
]; |
115
|
|
|
} |
116
|
|
|
} |
117
|
|
|
|
This function has been deprecated. The supplier of the function has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.