Completed
Pull Request — master (#404)
by Richard
11:08
created

common.inc.php ➔ fatalPhpErrorHandler()   B

Complexity

Conditions 5
Paths 4

Size

Total Lines 15
Code Lines 10

Duplication

Lines 15
Ratio 100 %

Importance

Changes 0
Metric Value
cc 5
eloc 10
nc 4
nop 1
dl 15
loc 15
rs 8.8571
c 0
b 0
f 0
1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 31 and the first side effect is on line 51.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
/*
3
 You may not change or alter any portion of this comment or credits
4
 of supporting developers from this source code or any supporting source code
5
 which is considered copyrighted (c) material of the original comment or credit authors.
6
7
 This program is distributed in the hope that it will be useful,
8
 but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10
*/
11
/**
12
 * Installer common include file
13
 *
14
 * See the enclosed file license.txt for licensing information.
15
 * If you did not receive this file, get it at http://www.gnu.org/licenses/gpl-2.0.html
16
 *
17
 * @copyright    (c) 2000-2016 XOOPS Project (www.xoops.org)
18
 * @license          GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
19
 * @package          installer
20
 * @since            2.3.0
21
 * @author           Haruki Setoyama  <[email protected]>
22
 * @author           Kazumi Ono <[email protected]>
23
 * @author           Skalpa Keo <[email protected]>
24
 * @author           Taiwen Jiang <[email protected]>
25
 * @author           DuGris (aka L. JEN) <[email protected]>
26
 **/
27
28
/**
29
 * If non-empty, only this user can access this installer
30
 */
31
define('INSTALL_USER', '');
32
define('INSTALL_PASSWORD', '');
33
34
define('XOOPS_INSTALL', 1);
35
36 View Code Duplication
function fatalPhpErrorHandler($e = null) {
0 ignored issues
show
Duplication introduced by
This function seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
37
    $messageFormat = '<br><div>Fatal %s %s file: %s : %d </div>';
38
    $exceptionClass = '\Exception';
39
    $throwableClass = '\Throwable';
40
    if ($e === null) {
41
        $lastError = error_get_last();
42
        if ($lastError['type'] === E_ERROR) {
43
            // fatal error
44
            printf($messageFormat, 'Error', $lastError['message'], $lastError['file'], $lastError['line']);
45
        }
46
    } elseif ($e instanceof $exceptionClass || $e instanceof $throwableClass) {
47
        /** @var $e \Exception */
48
        printf($messageFormat, get_class($e), $e->getMessage(), $e->getFile(), $e->getLine());
49
    }
50
}
51
register_shutdown_function('fatalPhpErrorHandler');
52
set_exception_handler('fatalPhpErrorHandler');
53
54
// options for mainfile.php
55
if (empty($xoopsOption['hascommon'])) {
56
    $xoopsOption['nocommon'] = true;
57
    session_start();
58
}
59
@include '../mainfile.php';
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
60
if (!defined('XOOPS_ROOT_PATH')) {
61
    define('XOOPS_ROOT_PATH', str_replace("\\", '/', realpath('../')));
62
}
63
64
/*
65
error_reporting( 0 );
66
if (isset($xoopsLogger)) {
67
    $xoopsLogger->activated = false;
68
}
69
error_reporting(E_ALL);
70
$xoopsLogger->activated = true;
71
*/
72
73
date_default_timezone_set(@date_default_timezone_get());
74
include './class/installwizard.php';
75
include_once '../include/version.php';
76
include_once './include/functions.php';
77
include_once '../class/module.textsanitizer.php';
78
include_once '../class/libraries/vendor/autoload.php';
79
80
$pageHasHelp = false;
81
$pageHasForm = false;
82
83
$wizard = new XoopsInstallWizard();
84
if (!$wizard->xoInit()) {
85
    exit();
86
}
87
88
if (!@is_array($_SESSION['settings'])) {
89
    $_SESSION['settings'] = array();
90
}
91