Completed
Branch master (e379bd)
by Pierre-Henry
33:06
created

InstallController::_sendWelcomeEmail()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 7
nc 1
nop 0
dl 0
loc 12
rs 9.4285
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 18 and the first side effect is on line 13.

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
 * @title            InstallController Class
4
 *
5
 * @author           Pierre-Henry Soria <[email protected]>
6
 * @copyright        (c) 2012-2017, Pierre-Henry Soria. All Rights Reserved.
7
 * @license          GNU General Public License; See PH7.LICENSE.txt and PH7.COPYRIGHT.txt in the root directory.
8
 * @package          PH7 / Install / Controller
9
 */
10
11
namespace PH7;
12
13
defined('PH7') or exit('Restricted access');
14
15
// Reset the time limit
16
@set_time_limit(0);
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...
17
18
class InstallController extends Controller
19
{
20
    /**
21
     * Enable/Disable Modules according to the chosen niche
22
     */
23
    const SOCIAL_MODS = [
24
        'connect' => '0',
25
        'affiliate' => '0',
26
        'game' => '1',
27
        'chat' => '0',
28
        'chatroulette' => '0',
29
        'picture' => '1',
30
        'video' => '1',
31
        'hotornot' => '0',
32
        'forum' => '1',
33
        'note' => '1',
34
        'blog' => '1',
35
        'newsletter' => '0',
36
        'invite' => '1',
37
        'webcam' => '1',
38
        'love-calculator' => '0',
39
        'mail' => '1',
40
        'im' => '1',
41
        'user-dashboard' => '0',
42
        'related-profile' => '1',
43
        'friend' => '1'
44
    ];
45
46
    const DATING_MODS = [
47
        'connect' => '0',
48
        'affiliate' => '1',
49
        'game' => '0',
50
        'chat' => '1',
51
        'chatroulette' => '1',
52
        'picture' => '1',
53
        'video' => '0',
54
        'hotornot' => '1',
55
        'forum' => '0',
56
        'note' => '0',
57
        'blog' => '1',
58
        'newsletter' => '1',
59
        'invite' => '0',
60
        'webcam' => '0',
61
        'love-calculator' => '1',
62
        'mail' => '1',
63
        'im' => '1',
64
        'user-dashboard' => '1',
65
        'related-profile' => '1',
66
        'friend' => '0'
67
    ];
68
69
    /**
70
     * Enable/Disable Site Settings according to the chosen niche
71
     */
72
    const SOCIAL_SETTINGS = [
73
        'social_media_widgets' => '1'
74
    ];
75
76
    const DATING_SETTINGS = [
77
        'social_media_widgets' => '0'
78
    ];
79
80
81
    /********************* STEP 1 *********************/
82
    public function index()
83
    {
84
        $aLangs = get_dir_list(PH7_ROOT_INSTALL . 'langs/');
85
        $aLangsList = include PH7_ROOT_INSTALL . 'inc/lang_list.inc.php';
86
        $sLangSelect = '';
87
88
        foreach ($aLangs as $sLang)
89
        {
90
            $sSel = (empty($_REQUEST['l']) ? $sLang == $this->sCurrentLang ? '" selected="selected' : '' : ($sLang == $_REQUEST['l']) ? '" selected="selected' : '');
91
            $sLangSelect .= '<option value="?l=' . $sLang . $sSel . '">' . $aLangsList[$sLang] . '</option>';
92
        }
93
94
        $this->oView->assign('lang_select', $sLangSelect);
95
        $this->oView->assign('sept_number', 1);
96
        $this->oView->display('index.tpl');
97
    }
98
99
    /********************* STEP 2 *********************/
100
    public function config_path()
101
    {
102
        global $LANG;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
103
104
        if (empty($_SESSION['val']['path_protected']))
105
            $_SESSION['val']['path_protected'] = PH7_ROOT_PUBLIC . '_protected' . PH7_DS;
106
107
        if ($_SERVER['REQUEST_METHOD'] == 'POST' && !empty($_POST['path_protected']))
108
        {
109
            $_SESSION['val']['path_protected'] = check_ext_start(check_ext_end(trim($_POST['path_protected'])));
110
111
            if (is_dir($_SESSION['val']['path_protected']))
112
            {
113
                if (is_readable($_SESSION['val']['path_protected']))
114
                {
115
                    $sConstantContent = file_get_contents(PH7_ROOT_INSTALL . 'data/configs/constants.php');
116
117
                    $sConstantContent = str_replace('%path_protected%', addslashes($_SESSION['val']['path_protected']), $sConstantContent);
118
119
                    if (!@file_put_contents(PH7_ROOT_PUBLIC . '_constants.php', $sConstantContent))
120
                    {
121
                        $aErrors[] = $LANG['no_public_writable'];
0 ignored issues
show
Coding Style Comprehensibility introduced by
$aErrors was never initialized. Although not strictly required by PHP, it is generally a good practice to add $aErrors = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
122
                    }
123
                    else
124
                    {
125
                        $_SESSION['step2'] = 1;
126
                        unset($_SESSION['val']);
127
128
                        redirect(PH7_URL_SLUG_INSTALL . 'config_system');
129
                    }
130
                }
131
                else
132
                {
133
                    $aErrors[] = $LANG['no_protected_readable'];
0 ignored issues
show
Coding Style Comprehensibility introduced by
$aErrors was never initialized. Although not strictly required by PHP, it is generally a good practice to add $aErrors = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
134
                }
135
            }
136
            else
137
            {
138
                $aErrors[] = $LANG['no_protected_exist'];
0 ignored issues
show
Coding Style Comprehensibility introduced by
$aErrors was never initialized. Although not strictly required by PHP, it is generally a good practice to add $aErrors = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
139
            }
140
        }
141
142
        $this->oView->assign('sept_number', 2);
143
        $this->oView->assign('errors', @$aErrors);
0 ignored issues
show
Bug introduced by
The variable $aErrors does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
144
        unset($aErrors);
145
        $this->oView->display('config_path.tpl');
146
    }
147
148
    /********************* STEP 3 *********************/
149
    public function config_system()
150
    {
151
        global $LANG;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
152
153
        if (!empty($_SESSION['step2']) && is_file(PH7_ROOT_PUBLIC . '_constants.php'))
154
        {
155
            session_regenerate_id(true);
156
157
            if (empty($_SESSION['val']))
158
            {
159
                $_SESSION['db']['type_name'] = 'MySQL';
160
                $_SESSION['db']['type'] = 'mysql';
161
                $_SESSION['db']['hostname'] = 'localhost';
162
                $_SESSION['db']['username'] = 'root';
163
                $_SESSION['db']['name'] = 'ph7cms';
164
                $_SESSION['db']['prefix'] = 'PH7_';
165
                $_SESSION['db']['port'] = '3306';
166
                $_SESSION['db']['charset'] = 'UTF8';
167
168
                $_SESSION['val']['bug_report_email'] = '';
169
                $_SESSION['val']['ffmpeg_path'] = ffmpeg_path();
170
            }
171
172
            if ($_SERVER['REQUEST_METHOD'] == 'POST' && !empty($_POST['config_system_submit']))
173
            {
174
                if (filled_out($_POST))
175
                {
176
                    foreach ($_POST as $sKey => $sVal)
177
                        $_SESSION['db'][str_replace('db_', '', $sKey)] = trim($sVal);
178
179
                    $_SESSION['val']['bug_report_email'] = trim($_POST['bug_report_email']);
180
                    $_SESSION['val']['ffmpeg_path'] = trim($_POST['ffmpeg_path']);
181
182
                    if (validate_email($_SESSION['val']['bug_report_email']))
183
                    {
184
                        try
185
                        {
186
                            require_once PH7_ROOT_INSTALL . 'inc/_db_connect.inc.php';
187
                            @require_once PH7_ROOT_PUBLIC . '_constants.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...
188
                            @require_once PH7_PATH_APP . 'configs/constants.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...
189
190
                            // Config File
191
                            @chmod(PH7_PATH_APP_CONFIG, 0777);
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...
192
                            $sConfigContent = file_get_contents(PH7_ROOT_INSTALL . 'data/configs/config.ini');
193
194
                            $sConfigContent = str_replace('%bug_report_email%', $_SESSION['val']['bug_report_email'], $sConfigContent);
195
                            $sConfigContent = str_replace('%ffmpeg_path%', clean_string($_SESSION['val']['ffmpeg_path']), $sConfigContent);
196
197
                            $sConfigContent = str_replace('%db_type_name%', $_SESSION['db']['type_name'], $sConfigContent);
198
                            $sConfigContent = str_replace('%db_type%', $_SESSION['db']['type'], $sConfigContent);
199
                            $sConfigContent = str_replace('%db_hostname%', $_SESSION['db']['hostname'], $sConfigContent);
200
                            $sConfigContent = str_replace('%db_username%', clean_string($_SESSION['db']['username']), $sConfigContent);
201
                            $sConfigContent = str_replace('%db_password%', clean_string($_SESSION['db']['password']), $sConfigContent);
202
                            $sConfigContent = str_replace('%db_name%', clean_string($_SESSION['db']['name']), $sConfigContent);
203
                            $sConfigContent = str_replace('%db_prefix%', clean_string($_SESSION['db']['prefix']), $sConfigContent);
204
                            $sConfigContent = str_replace('%db_charset%', $_SESSION['db']['charset'], $sConfigContent);
205
                            $sConfigContent = str_replace('%db_port%', $_SESSION['db']['port'], $sConfigContent);
206
207
                            $sConfigContent = str_replace('%private_key%', generate_hash(40), $sConfigContent);
208
                            $sConfigContent = str_replace('%rand_id%', generate_hash(5), $sConfigContent);
209
210
                            if (!@file_put_contents(PH7_PATH_APP_CONFIG . 'config.ini', $sConfigContent))
211
                            {
212
                                $aErrors[] = $LANG['no_app_config_writable'];
0 ignored issues
show
Coding Style Comprehensibility introduced by
$aErrors was never initialized. Although not strictly required by PHP, it is generally a good practice to add $aErrors = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
213
                            }
214
                            else
215
                            {
216
                                if (!($DB->getAttribute(\PDO::ATTR_DRIVER_NAME) == 'mysql' && version_compare($DB->getAttribute(\PDO::ATTR_SERVER_VERSION), PH7_REQUIRE_SQL_VERSION, '>=')))
217
                                {
218
                                    $aErrors[] = $LANG['require_mysql_version'];
0 ignored issues
show
Coding Style Comprehensibility introduced by
$aErrors was never initialized. Although not strictly required by PHP, it is generally a good practice to add $aErrors = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
219
                                }
220
                                else
221
                                {
222
                                    $aDumps = [
223
                                        /*** Game ***/
224
                                        // We need to install the Game before the Core SQL for "foreign keys" that work are correct.
225
                                        'pH7_SchemaGame',
226
                                        'pH7_DataGame',
227
                                        /*** Core ***/
228
                                        'pH7_Core',
229
                                        // --- GeoIp (exec_query_file() function executes these files only if they existens otherwise it does nothing) --- //
230
                                        'pH7_GeoCountry',
231
                                        'pH7_GeoCity',
232
                                        'pH7_GeoCity2',
233
                                        'pH7_GeoCity3',
234
                                        'pH7_GeoCity4',
235
                                        'pH7_GeoCity5',
236
                                        'pH7_GeoCity6',
237
                                        'pH7_GeoCity7',
238
                                        'pH7_GeoCity8',
239
                                        'pH7_GeoState',
240
                                        // --- Execute this file if there is something --- //
241
                                        'pH7_SampleData'
242
                                    ];
243
244
                                    for ($i = 0, $iCount = count($aDumps); $i < $iCount; $i++)
245
                                        exec_query_file($DB, PH7_ROOT_INSTALL . 'data/sql/' . $_SESSION['db']['type_name'] . '/' . $aDumps[$i] . '.sql');
0 ignored issues
show
Bug introduced by
The variable $DB does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
246
247
                                    unset($DB);
248
249
                                    $_SESSION['step3'] = 1;
250
                                    unset($_SESSION['val']);
251
252
                                    redirect(PH7_URL_SLUG_INSTALL . 'config_site');
253
                                }
254
                            }
255
                        }
256
                        catch (\PDOException $oE)
257
                        {
258
                            $aErrors[] = $LANG['database_error'] . escape($oE->getMessage());
0 ignored issues
show
Bug introduced by
The variable $aErrors does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
259
                        }
260
                    }
261
                    else
262
                    {
263
                        $aErrors[] = $LANG['bad_email'];
264
                    }
265
                }
266
                else
267
                {
268
                    $aErrors[] = $LANG['all_fields_mandatory'];
269
                }
270
            }
271
        }
272
        else
273
        {
274
            redirect(PH7_URL_SLUG_INSTALL . 'config_path');
275
        }
276
277
        $this->oView->assign('sept_number', 3);
278
        $this->oView->assign('errors', @$aErrors);
279
        unset($aErrors);
280
        $this->oView->display('config_system.tpl');
281
    }
282
283
    /********************* STEP 4 *********************/
284
    public function config_site()
285
    {
286
        global $LANG;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
287
288
        if (empty($_SESSION['step4']))
289
        {
290
            if (!empty($_SESSION['step3']) && is_file(PH7_ROOT_PUBLIC . '_constants.php'))
291
            {
292
                session_regenerate_id(true);
293
294
                if (empty($_SESSION['val']))
295
                {
296
                    $_SESSION['val']['site_name'] = 'My Social Dating Site';
297
                    $_SESSION['val']['admin_login_email'] = '';
298
                    $_SESSION['val']['admin_email'] = '';
299
                    $_SESSION['val']['admin_feedback_email'] = '';
300
                    $_SESSION['val']['admin_return_email'] = '';
301
                    $_SESSION['val']['admin_username'] = 'administrator';
302
                    $_SESSION['val']['admin_first_name'] = '';
303
                    $_SESSION['val']['admin_last_name'] = '';
304
                }
305
306
                if ($_SERVER['REQUEST_METHOD'] == 'POST' && !empty($_POST['config_site_submit']))
307
                {
308
                    if (filled_out($_POST))
309
                    {
310
                        foreach ($_POST as $sKey => $sVal)
311
                            $_SESSION['val'][$sKey] = trim($sVal);
312
313
                        if (validate_email($_SESSION['val']['admin_login_email']) && validate_email($_SESSION['val']['admin_email']) && validate_email($_SESSION['val']['admin_feedback_email']) && validate_email($_SESSION['val']['admin_return_email']))
314
                        {
315
                            if (validate_username($_SESSION['val']['admin_username']) == 0)
316
                            {
317
                                if (validate_password($_SESSION['val']['admin_password']) == 0)
318
                                {
319
                                    if (validate_identical($_SESSION['val']['admin_password'], $_SESSION['val']['admin_passwords']))
320
                                    {
321
                                        if (!find($_SESSION['val']['admin_password'], $_SESSION['val']['admin_username']) && !find($_SESSION['val']['admin_password'], $_SESSION['val']['admin_first_name']) && !find($_SESSION['val']['admin_password'], $_SESSION['val']['admin_last_name']))
322
                                        {
323
                                            if (validate_name($_SESSION['val']['admin_first_name']))
324
                                            {
325
                                                if (validate_name($_SESSION['val']['admin_last_name']))
326
                                                {
327
                                                    @require_once PH7_ROOT_PUBLIC . '_constants.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...
328
                                                    @require_once PH7_PATH_APP . 'configs/constants.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...
329
330
                                                    require PH7_PATH_APP . 'includes/helpers/misc.php';
331
                                                    require PH7_PATH_FRAMEWORK . 'Loader/Autoloader.php';
332
                                                    // To load "\PH7\Framework\Security\Security" class
333
                                                    Framework\Loader\Autoloader::getInstance()->init();
334
335
                                                    try
336
                                                    {
337
                                                        require_once PH7_ROOT_INSTALL . 'inc/_db_connect.inc.php';
338
339
                                                        // SQL EXECUTE
340
                                                        $rStmt = $DB->prepare('INSERT INTO ' . $_SESSION['db']['prefix'] . 'Admins
0 ignored issues
show
Bug introduced by
The variable $DB does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
341
                                                        (profileId , username, password, email, firstName, lastName, joinDate, lastActivity, ip)
342
                                                        VALUES (1, :username, :password, :email, :firstName, :lastName, :joinDate, :lastActivity, :ip)');
343
344
                                                        $sCurrentDate = date('Y-m-d H:i:s');
345
                                                        $rStmt->execute([
346
                                                            'username' => $_SESSION['val']['admin_username'],
347
                                                            'password' => Framework\Security\Security::hashPwd($_SESSION['val']['admin_password']),
348
                                                            'email' => $_SESSION['val']['admin_login_email'],
349
                                                            'firstName'=> $_SESSION['val']['admin_first_name'],
350
                                                            'lastName'=> $_SESSION['val']['admin_last_name'],
351
                                                            'joinDate'=> $sCurrentDate,
352
                                                            'lastActivity' => $sCurrentDate,
353
                                                            'ip' => client_ip()
354
                                                        ]);
355
356
                                                        $rStmt = $DB->prepare('UPDATE ' . $_SESSION['db']['prefix'] . 'Settings SET value = :siteName WHERE name = \'siteName\' LIMIT 1');
357
                                                        $rStmt->execute(['siteName' => $_SESSION['val']['site_name']]);
358
359
                                                        $rStmt = $DB->prepare('UPDATE ' . $_SESSION['db']['prefix'] . 'Settings SET value = :adminEmail WHERE name = \'adminEmail\'  LIMIT 1');
360
                                                        $rStmt->execute(['adminEmail' => $_SESSION['val']['admin_email']]);
361
362
                                                        $rStmt = $DB->prepare('UPDATE ' . $_SESSION['db']['prefix'] . 'Settings SET value = :feedbackEmail WHERE name = \'feedbackEmail\'  LIMIT 1');
363
                                                        $rStmt->execute(['feedbackEmail' => $_SESSION['val']['admin_feedback_email']]);
364
365
                                                        $rStmt = $DB->prepare('UPDATE ' . $_SESSION['db']['prefix'] . 'Settings SET value = :returnEmail WHERE name = \'returnEmail\'  LIMIT 1');
366
                                                        $rStmt->execute(['returnEmail' => $_SESSION['val']['admin_return_email']]);
367
368
                                                        // We finalise by putting the correct permission to the config files
369
                                                        $this->_chmodConfigFiles();
370
371
                                                        $_SESSION['step4'] = 1;
372
373
                                                        redirect(PH7_URL_SLUG_INSTALL . 'niche');
374
                                                    }
375
                                                    catch (\PDOException $oE)
376
                                                    {
377
                                                        $aErrors[] = $LANG['database_error'] . escape($oE->getMessage());
0 ignored issues
show
Coding Style Comprehensibility introduced by
$aErrors was never initialized. Although not strictly required by PHP, it is generally a good practice to add $aErrors = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
378
                                                    }
379
                                                }
380
                                                else
381
                                                {
382
                                                    $aErrors[] = $LANG['bad_last_name'];
0 ignored issues
show
Coding Style Comprehensibility introduced by
$aErrors was never initialized. Although not strictly required by PHP, it is generally a good practice to add $aErrors = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
383
                                                }
384
                                            }
385
                                            else
386
                                            {
387
                                                $aErrors[] = $LANG['bad_first_name'];
0 ignored issues
show
Coding Style Comprehensibility introduced by
$aErrors was never initialized. Although not strictly required by PHP, it is generally a good practice to add $aErrors = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
388
                                            }
389
                                        }
390
                                        else
391
                                        {
392
                                            $aErrors[] = $LANG['insecure_password'];
0 ignored issues
show
Coding Style Comprehensibility introduced by
$aErrors was never initialized. Although not strictly required by PHP, it is generally a good practice to add $aErrors = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
393
                                        }
394
                                    }
395
                                    else
396
                                    {
397
                                        $aErrors[] = $LANG['passwords_different'];
0 ignored issues
show
Coding Style Comprehensibility introduced by
$aErrors was never initialized. Although not strictly required by PHP, it is generally a good practice to add $aErrors = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
398
                                    }
399
                                }
400
                                elseif (validate_password($_SESSION['val']['admin_password']) == 1)
401
                                {
402
                                    $aErrors[] = $LANG['password_too_short'];
0 ignored issues
show
Coding Style Comprehensibility introduced by
$aErrors was never initialized. Although not strictly required by PHP, it is generally a good practice to add $aErrors = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
403
                                }
404
                                elseif (validate_password($_SESSION['val']['admin_password']) == 2)
405
                                {
406
                                    $aErrors[] = $LANG['password_too_long'];
0 ignored issues
show
Coding Style Comprehensibility introduced by
$aErrors was never initialized. Although not strictly required by PHP, it is generally a good practice to add $aErrors = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
407
                                }
408
                                elseif (validate_password($_SESSION['val']['admin_password']) ==  3)
409
                                {
410
                                    $aErrors[] = $LANG['password_no_number'];
0 ignored issues
show
Coding Style Comprehensibility introduced by
$aErrors was never initialized. Although not strictly required by PHP, it is generally a good practice to add $aErrors = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
411
                                }
412
                                elseif (validate_password($_SESSION['val']['admin_password']) ==  4)
413
                                {
414
                                    $aErrors[] = $LANG['password_no_upper'];
0 ignored issues
show
Coding Style Comprehensibility introduced by
$aErrors was never initialized. Although not strictly required by PHP, it is generally a good practice to add $aErrors = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
415
                                }
416
                            }
417
                            elseif (validate_username($_SESSION['val']['admin_username']) == 1)
418
                            {
419
                                $aErrors[] = $LANG['username_too_short'];
0 ignored issues
show
Coding Style Comprehensibility introduced by
$aErrors was never initialized. Although not strictly required by PHP, it is generally a good practice to add $aErrors = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
420
                            }
421
                            elseif (validate_username($_SESSION['val']['admin_username']) == 2)
422
                            {
423
                                $aErrors[] = $LANG['username_too_long'];
0 ignored issues
show
Coding Style Comprehensibility introduced by
$aErrors was never initialized. Although not strictly required by PHP, it is generally a good practice to add $aErrors = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
424
                            }
425
                            elseif (validate_username($_SESSION['val']['admin_username']) == 3)
426
                            {
427
                                $aErrors[] = $LANG['bad_username'];
0 ignored issues
show
Coding Style Comprehensibility introduced by
$aErrors was never initialized. Although not strictly required by PHP, it is generally a good practice to add $aErrors = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
428
                            }
429
                        }
430
                        else
431
                        {
432
                            $aErrors[] = $LANG['bad_email'];
0 ignored issues
show
Coding Style Comprehensibility introduced by
$aErrors was never initialized. Although not strictly required by PHP, it is generally a good practice to add $aErrors = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
433
                        }
434
                    }
435
                    else
436
                    {
437
                        $aErrors[] = $LANG['all_fields_mandatory'];
0 ignored issues
show
Coding Style Comprehensibility introduced by
$aErrors was never initialized. Although not strictly required by PHP, it is generally a good practice to add $aErrors = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
438
                    }
439
                }
440
            }
441
            else
442
            {
443
                redirect(PH7_URL_SLUG_INSTALL . 'config_system');
444
            }
445
        }
446
        else
447
        {
448
            redirect(PH7_URL_SLUG_INSTALL . 'niche');
449
        }
450
451
        $this->oView->assign('sept_number', 4);
452
        $this->oView->assign('errors', @$aErrors);
0 ignored issues
show
Bug introduced by
The variable $aErrors does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
453
        unset($aErrors);
454
        $this->oView->display('config_site.tpl');
455
    }
456
457
    /********************* STEP 5 *********************/
458
    public function niche()
459
    {
460
        global $LANG;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
461
462
        if (empty($_SESSION['step5']))
463
        {
464
            if (!empty($_SESSION['step4']) && is_file(PH7_ROOT_PUBLIC . '_constants.php'))
465
            {
466
                session_regenerate_id(true);
467
468
                if ($_SERVER['REQUEST_METHOD'] == 'POST' && !empty($_POST['niche_submit']))
469
                {
470
                    $bUpdateNeeded = false; // Value by default. Don't need to update the DB for the Social/Dating Niche
471
472
                    switch ($_POST['niche_submit'])
473
                    {
474
                        case 'zendate':
475
                            $bUpdateNeeded = true;
476
                            $sTheme = 'zendate';
477
                            $aModUpdate = self::SOCIAL_MODS;
478
                            $aSettingUpdate = self::SOCIAL_SETTINGS;
479
                        break;
480
481
                        case 'datelove':
482
                            $bUpdateNeeded = true;
483
                            $sTheme = 'datelove';
484
                            $aModUpdate = self::DATING_MODS;
485
                            $aSettingUpdate = self::DATING_SETTINGS;
486
                        break;
487
488
                        // Or for 'base', don't do anything. Just use the default settings already setup in the database
489
                    }
490
491
                    if ($bUpdateNeeded)
492
                    {
493
                        @require_once PH7_ROOT_PUBLIC . '_constants.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...
494
                        @require_once PH7_PATH_APP . 'configs/constants.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...
495
496
                        require PH7_PATH_APP . 'includes/helpers/misc.php';
497
                        require PH7_PATH_FRAMEWORK . 'Loader/Autoloader.php';
498
                        // To load "PH7\Framework\Mvc\Model\DbConfig" class
499
                        Framework\Loader\Autoloader::getInstance()->init();
500
501
                        try
502
                        {
503
                            require_once PH7_ROOT_INSTALL . 'inc/_db_connect.inc.php';
504
505
                            // Enable/Disable the modules according to the chosen niche
506
                            foreach ($aModUpdate as $sModName => $sStatus)
0 ignored issues
show
Bug introduced by
The variable $aModUpdate does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
507
                                $this->_updateMods($DB, $sModName, $sStatus);
0 ignored issues
show
Bug introduced by
The variable $DB does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
508
509
                            $this->_updateSettings($aSettingUpdate);
0 ignored issues
show
Bug introduced by
The variable $aSettingUpdate does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
510
511
                            // Set the theme for the chosen niche
512
                            $sSql = 'UPDATE ' . $_SESSION['db']['prefix'] . 'Settings SET value = :theme WHERE name = \'defaultTemplate\' LIMIT 1';
513
                            $rStmt = $DB->prepare($sSql);
514
                            $rStmt->execute(['theme' => $sTheme]);
0 ignored issues
show
Bug introduced by
The variable $sTheme does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
515
                        }
516
                        catch (\PDOException $oE)
517
                        {
518
                            $aErrors[] = $LANG['database_error'] . escape($oE->getMessage());
0 ignored issues
show
Coding Style Comprehensibility introduced by
$aErrors was never initialized. Although not strictly required by PHP, it is generally a good practice to add $aErrors = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
519
                        }
520
                    }
521
                    $_SESSION['step5'] = 1;
522
523
                    redirect(PH7_URL_SLUG_INSTALL . 'service');
524
                }
525
            }
526
            else
527
            {
528
                redirect(PH7_URL_SLUG_INSTALL . 'config_site');
529
            }
530
        }
531
        else
532
        {
533
            redirect(PH7_URL_SLUG_INSTALL . 'service');
534
        }
535
536
        $this->oView->assign('sept_number', 5);
537
        $this->oView->assign('errors', @$aErrors);
0 ignored issues
show
Bug introduced by
The variable $aErrors does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
538
        unset($aErrors);
539
        $this->oView->display('niche.tpl');
540
    }
541
542
    /********************* STEP 6 *********************/
543
    public function service()
544
    {
545
        $this->oView->assign('sept_number', 6);
546
        $this->oView->display('service.tpl');
547
    }
548
549
    /********************* STEP 7 *********************/
550
    public function license()
551
    {
552
        global $LANG;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
553
554
        if (!empty($_SESSION['step5']) && is_file(PH7_ROOT_PUBLIC . '_constants.php'))
555
        {
556
            if (empty($_SESSION['val']['license']))
557
                $_SESSION['val']['license'] = '';
558
559
            if ($_SERVER['REQUEST_METHOD'] == 'POST' && !empty($_POST['license']))
560
            {
561
                $sKey = trim($_POST['license']);
562
                if (check_license($sKey))
563
                {
564
                    @require_once PH7_ROOT_PUBLIC . '_constants.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...
565
                    @require_once PH7_PATH_APP . 'configs/constants.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...
566
567
                    try
568
                    {
569
                        require_once PH7_ROOT_INSTALL . 'inc/_db_connect.inc.php';
570
571
                        $rStmt = $DB->prepare('UPDATE ' . $_SESSION['db']['prefix'] . 'License SET licenseKey = :key WHERE licenseId = 1');
0 ignored issues
show
Bug introduced by
The variable $DB does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
572
                        $rStmt->execute(['key' => $sKey]);
573
574
                        redirect(PH7_URL_SLUG_INSTALL . 'finish');
575
                    }
576
                    catch (\PDOException $oE)
577
                    {
578
                        $aErrors[] = $LANG['database_error'] . escape($oE->getMessage());
0 ignored issues
show
Coding Style Comprehensibility introduced by
$aErrors was never initialized. Although not strictly required by PHP, it is generally a good practice to add $aErrors = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
579
                    }
580
                }
581
                else
582
                {
583
                    $aErrors[] = $LANG['failure_license'];
0 ignored issues
show
Coding Style Comprehensibility introduced by
$aErrors was never initialized. Although not strictly required by PHP, it is generally a good practice to add $aErrors = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
584
                }
585
            }
586
        }
587
        else
588
        {
589
            redirect(PH7_URL_SLUG_INSTALL . 'niche');
590
        }
591
592
        $this->oView->assign('sept_number', 7);
593
        $this->oView->assign('errors', @$aErrors);
0 ignored issues
show
Bug introduced by
The variable $aErrors does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
594
        unset($aErrors);
595
        $this->oView->display('license.tpl');
596
    }
597
598
    /********************* STEP 8 *********************/
599
    public function finish()
600
    {
601
        @require_once PH7_ROOT_PUBLIC . '_constants.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...
602
603
        if (!empty($_SESSION['val']['admin_login_email']) && !empty($_SESSION['val']['admin_username']))
604
        {
605
            $this->_sendWelcomeEmail();
606
607
            $this->oView->assign('admin_login_email', $_SESSION['val']['admin_login_email']);
608
            $this->oView->assign('admin_username', $_SESSION['val']['admin_username']);
609
        }
610
611
        $this->_removeSessions();
612
        $this->_removeCookies();
613
614
        if ($_SERVER['REQUEST_METHOD'] == 'POST' && !empty($_POST['confirm_remove_install']))
615
        {
616
            remove_install_dir();
617
            clearstatcache(); // We remove the files status cache as the "_install" folder doesn't exist anymore by now.
618
            exit(header('Location: ' . PH7_URL_ROOT));
619
        }
620
621
        $this->oView->assign('sept_number', 8);
622
        $this->oView->display('finish.tpl');
623
    }
624
625
    /**
626
     * Update module status (enabled/disabled).
627
     *
628
     * @param Db $oDb
629
     * @param string $sModName Module Name.
630
     * @param string $sStatus '1' = Enabled | '0' = Disabled (need to be string because in DB it is an "enum").
631
     *
632
     * @return mixed (integer | boolean) Returns the number of rows on success or FALSE on failure.
633
     */
634
    private function _updateMods(Db $oDb, $sModName, $sStatus)
635
    {
636
        $sSql = 'UPDATE ' . $_SESSION['db']['prefix'] . 'SysModsEnabled SET enabled = :status WHERE folderName = :modName LIMIT 1';
637
        $rStmt = $oDb->prepare($sSql);
638
        return $rStmt->execute(['modName' => $sModName, 'status' => $sStatus]);
639
    }
640
641
    /**
642
     * Update Settings.
643
     *
644
     * @param array $aParams
645
     * @return void
646
     */
647
    private function _updateSettings(array $aParams)
648
    {
649
        // Initialize the site's database to get "\PH7\Framework\Mvc\Model\Engine\Db" class working (as it uses that DB and not the installer one)
650
        Framework\Mvc\Router\FrontController::getInstance()->_databaseInitialize();
651
652
        // Enable/Disable Social Media Widgets according to the chosen niche
653
        Framework\Mvc\Model\DbConfig::setSocialWidgets($aParams['social_media_widgets']);
654
    }
655
656
    /***** Get the loading image *****/
657
    private function _loadImg()
0 ignored issues
show
Unused Code introduced by
This method is not used, and could be removed.
Loading history...
658
    {
659
        global $LANG;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
660
661
        return '<div style="text-align:center"><p>' . $LANG['wait_importing_database'] . '</p>
662
        <p><img src="data:image/gif;base64,R0lGODlhHwAfAPUAAP///wAAAOjo6NLS0ry8vK6urqKiotzc3Li4uJqamuTk5NjY2KqqqqCgoLCwsMzMzPb29qioqNTU1Obm5jY2NiYmJlBQUMTExHBwcJKSklZWVvr6+mhoaEZGRsbGxvj4+EhISDIyMgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh/hpDcmVhdGVkIHdpdGggYWpheGxvYWQuaW5mbwAh+QQJCgAAACwAAAAAHwAfAAAG/0CAcEgUDAgFA4BiwSQexKh0eEAkrldAZbvlOD5TqYKALWu5XIwnPFwwymY0GsRgAxrwuJwbCi8aAHlYZ3sVdwtRCm8JgVgODwoQAAIXGRpojQwKRGSDCRESYRsGHYZlBFR5AJt2a3kHQlZlERN2QxMRcAiTeaG2QxJ5RnAOv1EOcEdwUMZDD3BIcKzNq3BJcJLUABBwStrNBtjf3GUGBdLfCtadWMzUz6cDxN/IZQMCvdTBcAIAsli0jOHSJeSAqmlhNr0awo7RJ19TJORqdAXVEEVZyjyKtE3Bg3oZE2iK8oeiKkFZGiCaggelSTiA2LhxiZLBSjZjBL2siNBOFQ84LxHA+mYEiRJzBO7ZCQIAIfkECQoAAAAsAAAAAB8AHwAABv9AgHBIFAwIBQPAUCAMBMSodHhAJK5XAPaKOEynCsIWqx0nCIrvcMEwZ90JxkINaMATZXfju9jf82YAIQxRCm14Ww4PChAAEAoPDlsAFRUgHkRiZAkREmoSEXiVlRgfQgeBaXRpo6MOQlZbERN0Qx4drRUcAAJmnrVDBrkVDwNjr8BDGxq5Z2MPyUQZuRgFY6rRABe5FgZjjdm8uRTh2d5b4NkQY0zX5QpjTc/lD2NOx+WSW0++2RJmUGJhmZVsQqgtCE6lqpXGjBchmt50+hQKEAEiht5gUcTIESR9GhlgE9IH0BiTkxrMmWIHDkose9SwcQlHDsOIk9ygiVbl5JgMLuV4HUmypMkTOkEAACH5BAkKAAAALAAAAAAfAB8AAAb/QIBwSBQMCAUDwFAgDATEqHR4QCSuVwD2ijhMpwrCFqsdJwiK73DBMGfdCcZCDWjAE2V347vY3/NmdXNECm14Ww4PChAAEAoPDltlDGlDYmQJERJqEhGHWARUgZVqaWZeAFZbERN0QxOeWwgAAmabrkMSZkZjDrhRkVtHYw+/RA9jSGOkxgpjSWOMxkIQY0rT0wbR2LQV3t4UBcvcF9/eFpdYxdgZ5hUYA73YGxruCbVjt78G7hXFqlhY/fLQwR0HIQdGuUrTz5eQdIc0cfIEwByGD0MKvcGSaFGjR8GyeAPhIUofQGNQSgrB4IsdOCqx7FHDBiYcOQshYjKDxliVDpRjunCjdSTJkiZP6AQBACH5BAkKAAAALAAAAAAfAB8AAAb/QIBwSBQMCAUDwFAgDATEqHR4QCSuVwD2ijhMpwrCFqsdJwiK73DBMGfdCcZCDWjAE2V347vY3/NmdXNECm14Ww4PChAAEAoPDltlDGlDYmQJERJqEhGHWARUgZVqaWZeAFZbERN0QxOeWwgAAmabrkMSZkZjDrhRkVtHYw+/RA9jSGOkxgpjSWOMxkIQY0rT0wbR2I3WBcvczltNxNzIW0693MFYT7bTumNQqlisv7BjswAHo64egFdQAbj0RtOXDQY6VAAUakihN1gSLaJ1IYOGChgXXqEUpQ9ASRlDYhT0xQ4cACJDhqDD5mRKjCAYuArjBmVKDP9+VRljMyMHDwcfuBlBooSCBQwJiqkJAgAh+QQJCgAAACwAAAAAHwAfAAAG/0CAcEgUDAgFA8BQIAwExKh0eEAkrlcA9oo4TKcKwharHScIiu9wwTBn3QnGQg1owBNld+O72N/zZnVzRApteFsODwoQABAKDw5bZQxpQ2JkCRESahIRh1gEVIGVamlmXgBWWxETdEMTnlsIAAJmm65DEmZGYw64UZFbR2MPv0QPY0hjpMYKY0ljjMZCEGNK09MG0diN1gXL3M5bTcTcyFtOvdzBWE+207pjUKpYrL+wY7MAB4EerqZjUAG4lKVCBwMbvnT6dCXUkEIFK0jUkOECFEeQJF2hFKUPAIkgQwIaI+hLiJAoR27Zo4YBCJQgVW4cpMYDBpgVZKL59cEBhw+U+QROQ4bBAoUlTZ7QCQIAIfkECQoAAAAsAAAAAB8AHwAABv9AgHBIFAwIBQPAUCAMBMSodHhAJK5XAPaKOEynCsIWqx0nCIrvcMEwZ90JxkINaMATZXfju9jf82Z1c0QKbXhbDg8KEAAQCg8OW2UMaUNiZAkREmoSEYdYBFSBlWppZl4AVlsRE3RDE55bCAACZpuuQxJmRmMOuFGRW0djD79ED2NIY6TGCmNJY4zGQhBjStPTFBXb21DY1VsGFtzbF9gAzlsFGOQVGefIW2LtGhvYwVgDD+0V17+6Y6BwaNfBwy9YY2YBcMAPnStTY1B9YMdNiyZOngCFGuIBxDZAiRY1eoTvE6UoDEIAGrNSUoNBUuzAaYlljxo2M+HIeXiJpRsRNMaq+JSFCpsRJEqYOPH2JQgAIfkECQoAAAAsAAAAAB8AHwAABv9AgHBIFAwIBQPAUCAMBMSodHhAJK5XAPaKOEynCsIWqx0nCIrvcMEwZ90JxkINaMATZXfjywjlzX9jdXNEHiAVFX8ODwoQABAKDw5bZQxpQh8YiIhaERJqEhF4WwRDDpubAJdqaWZeAByoFR0edEMTolsIAA+yFUq2QxJmAgmyGhvBRJNbA5qoGcpED2MEFrIX0kMKYwUUslDaj2PA4soGY47iEOQFY6vS3FtNYw/m1KQDYw7mzFhPZj5JGzYGipUtESYowzVmF4ADgOCBCZTgFQAxZBJ4AiXqT6ltbUZhWdToUSR/Ii1FWbDnDkUyDQhJsQPn5ZU9atjUhCPHVhgTNy/RSKsiqKFFbUaQKGHiJNyXIAAh+QQJCgAAACwAAAAAHwAfAAAG/0CAcEh8JDAWCsBQIAwExKhU+HFwKlgsIMHlIg7TqQeTLW+7XYIiPGSAymY0mrFgA0LwuLzbCC/6eVlnewkADXVECgxcAGUaGRdQEAoPDmhnDGtDBJcVHQYbYRIRhWgEQwd7AB52AGt7YAAIchETrUITpGgIAAJ7ErdDEnsCA3IOwUSWaAOcaA/JQ0amBXKa0QpyBQZyENFCEHIG39HcaN7f4WhM1uTZaE1y0N/TacZoyN/LXU+/0cNyoMxCUytYLjm8AKSS46rVKzmxADhjlCACMFGkBiU4NUQRxS4OHijwNqnSJS6ZovzRyJAQo0NhGrgs5bIPmwWLCLHsQsfhxBWTe9QkOzCwC8sv5Ho127akyRM7QQAAOwAAAAAAAAAAAA==" alt="' . $LANG['loading'] . '" /></p>
663
        </div>';
664
    }
665
666
    /**
667
     * Send an email to say the installation is now done, and give some information...
668
     */
669
    private function _sendWelcomeEmail()
670
    {
671
        global $LANG;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
672
673
        $aParams = [
674
            'to' => $_SESSION['val']['admin_login_email'],
675
            'subject' => $LANG['title_email_finish_install'],
676
            'body' => $LANG['content_email_finish_install']
677
        ];
678
679
        send_mail($aParams);
680
    }
681
682
    /***** Set the correct permission to the config files *****/
683
    private function _chmodConfigFiles()
684
    {
685
        @chmod(PH7_PATH_APP_CONFIG . 'config.ini', 0644);
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...
686
        @chmod(PH7_ROOT_PUBLIC . '_constants.php', 0644);
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...
687
    }
688
689
    private function _removeSessions()
690
    {
691
        $_SESSION = [];
692
        session_unset();
693
        session_destroy();
694
    }
695
696
    private function _removeCookies()
697
    {
698
        $sCookieName = Controller::SOFTWARE_PREFIX_COOKIE_NAME . '_install_lang';
699
        // We are asking the browser to delete the cookie.
700
        setcookie($sCookieName, 0, 0);
701
        // and then, we delete the cookie value locally to avoid using it by mistake in following our script.
702
        unset($_COOKIE[$sCookieName]);
703
    }
704
}
705