Completed
Push — master ( 66baab...a58902 )
by Alexey
13:14 queued 04:19
created

Main::init()   B

Complexity

Conditions 7
Paths 6

Size

Total Lines 15
Code Lines 9

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 15
rs 8.2222
cc 7
eloc 9
nc 6
nop 0
1
<?php
2
3
/**
4
 * Main module
5
 *
6
 * @author Alexey Krupskiy <[email protected]>
7
 * @link http://inji.ru/
8
 * @copyright 2015 Alexey Krupskiy
9
 * @license https://github.com/injitools/cms-Inji/blob/master/LICENSE
10
 */
11
class Main extends Module
12
{
13
    public function init()
1 ignored issue
show
Coding Style introduced by
init uses the super-global variable $_SESSION which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
14
    {
15
        $config = Config::share();
16
        if (!empty($config['failTry']) && $config['failTry'] > 3) {
17
            exit('Превышен лимит неправильного ввода пароля. Для разблокировки отредактируйте файл %INJI_PROGRAM_DIR%/config/config.php');
18
        }
19
        if (empty(App::$cur->params[0]) || App::$cur->params[0] != 'enter') {
20
            if (empty($config['systemPass'])) {
21
                Tools::redirect('/setup/enter', 'Придумайте системный пароль');
22
            }
23
            if (empty($_SESSION['systemLogin'])) {
24
                Tools::redirect('/setup/enter', 'Введите системный пароль');
25
            }
26
        }
27
    }
28
29
}
30