PhpinfoController::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 13
rs 9.8333
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Alpha\Controller;
4
5
use Alpha\Util\Logging\Logger;
6
use Alpha\Util\Http\Request;
7
use Alpha\Util\Http\Response;
8
use Alpha\View\View;
9
use Alpha\Controller\Front\FrontController;
10
11
/**
12
 * Login controller that adds the current user object to the session.
13
 *
14
 * @since 2.0.3
15
 *
16
 * @author John Collins <[email protected]>
17
 * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
18
 * @copyright Copyright (c) 2018, John Collins (founder of Alpha Framework).
19
 * All rights reserved.
20
 *
21
 * <pre>
22
 * Redistribution and use in source and binary forms, with or
23
 * without modification, are permitted provided that the
24
 * following conditions are met:
25
 *
26
 * * Redistributions of source code must retain the above
27
 *   copyright notice, this list of conditions and the
28
 *   following disclaimer.
29
 * * Redistributions in binary form must reproduce the above
30
 *   copyright notice, this list of conditions and the
31
 *   following disclaimer in the documentation and/or other
32
 *   materials provided with the distribution.
33
 * * Neither the name of the Alpha Framework nor the names
34
 *   of its contributors may be used to endorse or promote
35
 *   products derived from this software without specific
36
 *   prior written permission.
37
 *
38
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
39
 * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
40
 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
41
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
42
 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
43
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
48
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
49
 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
50
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
51
 * </pre>
52
 */
53
class PhpinfoController extends Controller implements ControllerInterface
54
{
55
    /**
56
     * Trace logger.
57
     *
58
     * @var \Alpha\Util\Logging\Logger
59
     *
60
     * @since 2.0.3
61
     */
62
    private static $logger = null;
0 ignored issues
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
63
64
    /**
65
     * constructor to set up the object.
66
     *
67
     * @since 2.0.3
68
     */
69
    public function __construct()
70
    {
71
        self::$logger = new Logger('PhpinfoController');
72
        self::$logger->debug('>>__construct()');
73
74
        // ensure that the super class constructor is called, indicating the rights group
75
        parent::__construct('Admin');
76
77
        // set up the title and meta details
78
        $this->setTitle('Information about the PHP installation');
79
80
        self::$logger->debug('<<__construct');
81
    }
82
83
    /**
84
     * Handle GET requests.
85
     *
86
     * @param \Alpha\Util\Http\Request $request
87
     *
88
     * @return \Alpha\Util\Http\Response
89
     *
90
     * @since 2.0.3
91
     */
92
    public function doGET($request)
93
    {
94
        self::$logger->debug('>>doGET($request=['.var_export($request, true).'])');
95
96
        if ($request->getParam('displayphpinfo') != null) {
97
            ob_start();
98
            phpinfo();
99
            $body = ob_get_contents();
100
        } else {
101
            $body = View::displayPageHead($this);
102
103
            $url = FrontController::generateSecureURL('act=Alpha\Controller\PhpinfoController&displayphpinfo=true');
104
105
            $body .= '<iframe src="'.$url.'" style="border:none; overflow-x: scroll; overflow-y: scroll; width:100%; height:100vh;"></iframe>';
106
107
            $body .= View::displayPageFoot($this);
108
        }
109
110
        self::$logger->debug('<<doGET');
111
112
        return new Response(200, $body, array('Content-Type' => 'text/html', 'X-Frame-Options' => 'SAMEORIGIN'));
113
    }
114
}
115