Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 25 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
ManagementEnvironmentLogic | |
0.00% |
0 / 25 |
|
0.00% |
0 / 3 |
12 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
validateImpl | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
executeImpl | |
0.00% |
0 / 23 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | |
3 | declare(strict_types=1); |
4 | |
5 | namespace PeServer\App\Models\Domain\Page\Management; |
6 | |
7 | use DOMXPath; |
8 | use DOMElement; |
9 | use DOMDocument; |
10 | use PeServer\Core\Regex; |
11 | use PeServer\Core\OutputBuffer; |
12 | use PeServer\Core\Html\HtmlTagElement; |
13 | use PeServer\Core\Html\HtmlDocument; |
14 | use PeServer\Core\Mvc\LogicCallMode; |
15 | use PeServer\Core\Mvc\LogicParameter; |
16 | use PeServer\App\Models\Domain\Page\PageLogicBase; |
17 | |
18 | class ManagementEnvironmentLogic extends PageLogicBase |
19 | { |
20 | public function __construct(LogicParameter $parameter) |
21 | { |
22 | parent::__construct($parameter); |
23 | } |
24 | |
25 | protected function validateImpl(LogicCallMode $callMode): void |
26 | { |
27 | //NOP |
28 | } |
29 | |
30 | protected function executeImpl(LogicCallMode $callMode): void |
31 | { |
32 | // phpinfo() 内容を無理やり出力するのです |
33 | |
34 | $rawPhpinfo = OutputBuffer::get(function () { |
35 | phpinfo(); |
36 | }); |
37 | |
38 | $phpDoc = new HtmlDocument($rawPhpinfo->raw); |
39 | |
40 | $xpath = $phpDoc->path(); |
41 | /** @var HtmlTagElement */ |
42 | $srcStyle = $xpath->query('//html/head/style')[0]; |
43 | /** @var HtmlTagElement */ |
44 | $srcContent = $xpath->query('//html/body/div')[0]; |
45 | |
46 | $dom = new HtmlDocument(); |
47 | $content = $dom->addTagElement('div'); |
48 | $content->addClass('phpinfo'); |
49 | |
50 | $dstStyle = $dom->importNode($srcStyle); |
51 | $dstContent = $dom->importNode($srcContent); |
52 | |
53 | $css = $dstStyle->raw->textContent; |
54 | $regex = new Regex(); |
55 | $newCss = $regex->replace( |
56 | $css, |
57 | '/^(.*)$/m', |
58 | '.phpinfo $1' |
59 | ); |
60 | $dstStyle->raw->textContent = $newCss; |
61 | |
62 | $content->appendChild($dstStyle); |
63 | $content->appendChild($dstContent); |
64 | |
65 | $this->setValue('phpinfo', $dom->build()); |
66 | } |
67 | } |