Passed
Pull Request — develop (#92)
by Felipe
04:47
created

UsersController::doSaveEdit()   B

Complexity

Conditions 6
Paths 6

Size

Total Lines 23
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 6
eloc 16
nc 6
nop 0
dl 0
loc 23
rs 8.5906
c 0
b 0
f 0
1
<?php
2
0 ignored issues
show
Coding Style introduced by
You must use "/**" style comments for a file comment
Loading history...
3
/*
4
 * PHPPgAdmin v6.0.0-beta.30
5
 */
6
7
namespace PHPPgAdmin\Controller;
8
9
use PHPPgAdmin\Decorators\Decorator;
10
11
/**
12
 * Base controller class.
13
 */
5 ignored issues
show
Coding Style introduced by
Missing @category tag in class comment
Loading history...
Coding Style introduced by
Missing @package tag in class comment
Loading history...
Coding Style introduced by
Missing @author tag in class comment
Loading history...
Coding Style introduced by
Missing @license tag in class comment
Loading history...
Coding Style introduced by
Missing @link tag in class comment
Loading history...
14
class UsersController extends BaseController
15
{
16
    public $controller_name = 'UsersController';
17
18
    /**
19
     * Default method to render the controller according to the action parameter.
20
     */
21
    public function render()
22
    {
23
        $this->printHeader($lang['strusers']);
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $lang seems to be never defined.
Loading history...
24
        $this->printBody();
25
26
        switch ($action) {
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $action seems to be never defined.
Loading history...
27
            case 'changepassword':
28
                if (isset($_REQUEST['ok'])) {
29
                    $this->doChangePassword(false);
30
                } else {
31
                    $this->doAccount();
32
                }
33
34
                break;
35
            case 'confchangepassword':
36
                $this->doChangePassword(true);
37
38
                break;
39
            case 'account':
40
                $this->doAccount();
41
42
                break;
43
            case 'save_create':
44
                if (isset($_REQUEST['cancel'])) {
45
                    $this->doDefault();
46
                } else {
47
                    $this->doSaveCreate();
48
                }
49
50
                break;
51
            case 'create':
52
                $this->doCreate();
53
54
                break;
55
            case 'drop':
56
                if (isset($_REQUEST['cancel'])) {
57
                    $this->doDefault();
58
                } else {
59
                    $this->doDrop(false);
60
                }
61
62
                break;
63
            case 'confirm_drop':
64
                $this->doDrop(true);
65
66
                break;
67
            case 'save_edit':
68
                if (isset($_REQUEST['cancel'])) {
69
                    $this->doDefault();
70
                } else {
71
                    $this->doSaveEdit();
72
                }
73
74
                break;
75
            case 'edit':
76
                $this->doEdit();
77
78
                break;
79
            default:
80
                $this->doDefault();
81
82
                break;
83
        }
84
85
        $this->printFooter();
86
    }
87
88
    /**
89
     * Show default list of users in the database.
90
     *
91
     * @param mixed $msg
1 ignored issue
show
Coding Style introduced by
Missing parameter comment
Loading history...
92
     */
93
    public function doDefault($msg = '')
94
    {
95
        $conf = $this->conf;
96
97
        $lang = $this->lang;
98
        $data = $this->misc->getDatabaseAccessor();
99
100
        $renderUseExpires = function ($val) use ($lang) {
101
            return 'infinity' == $val ? $lang['strnever'] : htmlspecialchars($val);
102
        };
103
104
        $this->printTrail('server');
105
        $this->printTabs('server', 'users');
106
        $this->printMsg($msg);
107
108
        $users = $data->getUsers();
109
110
        $columns = [
111
            'user' => [
112
                'title' => $lang['strusername'],
113
                'field' => Decorator::field('usename'),
114
            ],
115
            'superuser' => [
116
                'title' => $lang['strsuper'],
117
                'field' => Decorator::field('usesuper'),
118
                'type'  => 'yesno',
119
            ],
120
            'createdb' => [
121
                'title' => $lang['strcreatedb'],
122
                'field' => Decorator::field('usecreatedb'),
123
                'type'  => 'yesno',
124
            ],
125
            'expires' => [
126
                'title'  => $lang['strexpires'],
127
                'field'  => Decorator::field('useexpires'),
128
                'type'   => 'callback',
129
                'params' => ['function' => $renderUseExpires, 'null' => $lang['strnever']],
130
            ],
131
            'defaults' => [
132
                'title' => $lang['strsessiondefaults'],
133
                'field' => Decorator::field('useconfig'),
134
            ],
135
            'actions' => [
136
                'title' => $lang['stractions'],
137
            ],
138
        ];
139
140
        $actions = [
141
            'alter' => [
142
                'content' => $lang['stralter'],
143
                'attr'    => [
144
                    'href' => [
145
                        'url'     => 'users.php',
146
                        'urlvars' => [
147
                            'action'   => 'edit',
148
                            'username' => Decorator::field('usename'),
149
                        ],
150
                    ],
151
                ],
152
            ],
153
            'drop' => [
154
                'content' => $lang['strdrop'],
155
                'attr'    => [
156
                    'href' => [
157
                        'url'     => 'users.php',
158
                        'urlvars' => [
159
                            'action'   => 'confirm_drop',
160
                            'username' => Decorator::field('usename'),
161
                        ],
162
                    ],
163
                ],
164
            ],
165
        ];
166
167
        echo $this->printTable($users, $columns, $actions, 'users-users', $lang['strnousers']);
168
169
        $this->printNavLinks(['create' => [
1 ignored issue
show
Coding Style introduced by
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
170
            'attr' => [
171
                'href' => [
172
                    'url'     => 'users.php',
173
                    'urlvars' => [
174
                        'action' => 'create',
175
                        'server' => $_REQUEST['server'],
176
                    ],
177
                ],
178
            ],
179
            'content' => $lang['strcreateuser'],
180
        ]], 'users-users', get_defined_vars());
1 ignored issue
show
Coding Style introduced by
For multi-line function calls, the closing parenthesis should be on a new line.

If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
); // Closing parenthesis on a new line.
Loading history...
181
    }
182
183
    /**
184
     * If a user is not a superuser, then we have an 'account management' page
185
     * where they can change their password, etc.  We don't prevent them from
186
     * messing with the URL to gain access to other user admin stuff, because
187
     * the PostgreSQL permissions will prevent them changing anything anyway.
188
     *
189
     * @param mixed $msg
1 ignored issue
show
Coding Style introduced by
Missing parameter comment
Loading history...
190
     */
191
    public function doAccount($msg = '')
192
    {
193
        $conf = $this->conf;
194
195
        $lang = $this->lang;
196
        $data = $this->misc->getDatabaseAccessor();
197
198
        $server_info = $this->misc->getServerInfo();
199
200
        $userdata         = $data->getUser($server_info['username']);
201
        $_REQUEST['user'] = $server_info['username'];
202
203
        $this->printTrail('user');
204
        $this->printTabs('server', 'account');
205
        $this->printMsg($msg);
206
207
        if ($userdata->recordCount() > 0) {
208
            $userdata->fields['usesuper']    = $data->phpBool($userdata->fields['usesuper']);
209
            $userdata->fields['usecreatedb'] = $data->phpBool($userdata->fields['usecreatedb']);
210
            echo "<table>\n";
211
            echo "<tr><th class=\"data\">{$lang['strusername']}</th><th class=\"data\">{$lang['strsuper']}</th><th class=\"data\">{$lang['strcreatedb']}</th><th class=\"data\">{$lang['strexpires']}</th>";
212
            echo "<th class=\"data\">{$lang['strsessiondefaults']}</th>";
213
            echo "</tr>\n";
214
            echo "<tr>\n\t<td class=\"data1\">", $this->misc->printVal($userdata->fields['usename']), "</td>\n";
215
            echo "\t<td class=\"data1\">", $this->misc->printVal($userdata->fields['usesuper'], 'yesno'), "</td>\n";
216
            echo "\t<td class=\"data1\">", $this->misc->printVal($userdata->fields['usecreatedb'], 'yesno'), "</td>\n";
217
            echo "\t<td class=\"data1\">", ('infinity' == $userdata->fields['useexpires'] || is_null($userdata->fields['useexpires']) ? $lang['strnever'] : $this->misc->printVal($userdata->fields['useexpires'])), "</td>\n";
218
            echo "\t<td class=\"data1\">", $this->misc->printVal($userdata->fields['useconfig']), "</td>\n";
219
            echo "</tr>\n</table>\n";
220
        } else {
221
            echo "<p>{$lang['strnodata']}</p>\n";
222
        }
223
224
        $this->printNavLinks(['changepassword' => [
1 ignored issue
show
Coding Style introduced by
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
225
            'attr' => [
226
                'href' => [
227
                    'url'     => 'users.php',
228
                    'urlvars' => [
229
                        'action' => 'confchangepassword',
230
                        'server' => $_REQUEST['server'],
231
                    ],
232
                ],
233
            ],
234
            'content' => $lang['strchangepassword'],
235
        ]], 'users-account', get_defined_vars());
1 ignored issue
show
Coding Style introduced by
For multi-line function calls, the closing parenthesis should be on a new line.

If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
); // Closing parenthesis on a new line.
Loading history...
236
    }
237
238
    /**
239
     * Show confirmation of change password and actually change password.
240
     *
241
     * @param mixed $confirm
1 ignored issue
show
Coding Style introduced by
Missing parameter comment
Loading history...
242
     * @param mixed $msg
1 ignored issue
show
Coding Style introduced by
Missing parameter comment
Loading history...
243
     */
244
    public function doChangePassword($confirm, $msg = '')
245
    {
246
        $conf = $this->conf;
247
248
        $lang = $this->lang;
249
        $data = $this->misc->getDatabaseAccessor();
250
251
        $server_info = $this->misc->getServerInfo();
252
253
        if ($confirm) {
254
            $_REQUEST['user'] = $server_info['username'];
255
            $this->printTrail('user');
256
            $this->printTitle($lang['strchangepassword'], 'pg.user.alter');
257
            $this->printMsg($msg);
258
259
            if (!isset($_POST['password'])) {
260
                $_POST['password'] = '';
261
            }
262
263
            if (!isset($_POST['confirm'])) {
264
                $_POST['confirm'] = '';
265
            }
266
267
            echo '<form action="'.\SUBFOLDER."/src/views/users.php\" method=\"post\">\n";
268
            echo "<table>\n";
269
            echo "\t<tr>\n\t\t<th class=\"data left required\">{$lang['strpassword']}</th>\n";
270
            echo "\t\t<td><input type=\"password\" name=\"password\" size=\"32\" value=\"",
271
            htmlspecialchars($_POST['password']), "\" /></td>\n\t</tr>\n";
272
            echo "\t<tr>\n\t\t<th class=\"data left required\">{$lang['strconfirm']}</th>\n";
273
            echo "\t\t<td><input type=\"password\" name=\"confirm\" size=\"32\" value=\"\" /></td>\n\t</tr>\n";
274
            echo "</table>\n";
275
            echo "<p><input type=\"hidden\" name=\"action\" value=\"changepassword\" />\n";
276
            echo $this->misc->form;
277
            echo "<input type=\"submit\" name=\"ok\" value=\"{$lang['strok']}\" />\n";
278
            echo "<input type=\"submit\" name=\"cancel\" value=\"{$lang['strcancel']}\" />\n";
279
            echo "</p></form>\n";
280
        } else {
281
            // Check that password is minimum length
282
            if (strlen($_POST['password']) < $conf['min_password_length']) {
283
                $this->doChangePassword(true, $lang['strpasswordshort']);
284
            }
285
286
            // Check that password matches confirmation password
287
            elseif ($_POST['password'] != $_POST['confirm']) {
0 ignored issues
show
Coding Style introduced by
Expected "} elseif (...) \n"; found "\n\n // Check that password matches confirmation password\n elseif (...) {\n"
Loading history...
288
                $this->doChangePassword(true, $lang['strpasswordconfirm']);
289
            } else {
290
                $status = $data->changePassword(
291
                    $server_info['username'],
292
                    $_POST['password']
293
                );
294
                if (0 == $status) {
295
                    $this->doAccount($lang['strpasswordchanged']);
296
                } else {
297
                    $this->doAccount($lang['strpasswordchangedbad']);
298
                }
299
            }
300
        }
301
    }
302
303
    /**
304
     * Function to allow editing of a user.
305
     *
306
     * @param mixed $msg
1 ignored issue
show
Coding Style introduced by
Missing parameter comment
Loading history...
307
     */
308
    public function doEdit($msg = '')
309
    {
310
        $conf = $this->conf;
0 ignored issues
show
Unused Code introduced by
The assignment to $conf is dead and can be removed.
Loading history...
311
312
        $lang = $this->lang;
313
        $data = $this->misc->getDatabaseAccessor();
314
315
        $this->printTrail('user');
316
        $this->printTitle($lang['stralter'], 'pg.user.alter');
317
        $this->printMsg($msg);
318
319
        $userdata = $data->getUser($_REQUEST['username']);
320
321
        if ($userdata->recordCount() > 0) {
322
            $server_info                     = $this->misc->getServerInfo();
323
            $canRename                       = $data->hasUserRename() && ($_REQUEST['username'] != $server_info['username']);
324
            $userdata->fields['usesuper']    = $data->phpBool($userdata->fields['usesuper']);
325
            $userdata->fields['usecreatedb'] = $data->phpBool($userdata->fields['usecreatedb']);
326
327
            if (!isset($_POST['formExpires'])) {
328
                if ($canRename) {
329
                    $_POST['newname'] = $userdata->fields['usename'];
330
                }
331
332
                if ($userdata->fields['usesuper']) {
333
                    $_POST['formSuper'] = '';
334
                }
335
336
                if ($userdata->fields['usecreatedb']) {
337
                    $_POST['formCreateDB'] = '';
338
                }
339
340
                $_POST['formExpires']  = 'infinity' == $userdata->fields['useexpires'] ? '' : $userdata->fields['useexpires'];
341
                $_POST['formPassword'] = '';
342
            }
343
344
            echo '<form action="'.\SUBFOLDER."/src/views/users.php\" method=\"post\">\n";
345
            echo "<table>\n";
346
            echo "\t<tr>\n\t\t<th class=\"data left\">{$lang['strusername']}</th>\n";
347
            echo "\t\t<td class=\"data1\">", ($canRename ? "<input name=\"newname\" size=\"15\" maxlength=\"{$data->_maxNameLen}\" value=\"".htmlspecialchars($_POST['newname']).'" />' : $this->misc->printVal($userdata->fields['usename'])), "</td>\n\t</tr>\n";
348
            echo "\t<tr>\n\t\t<th class=\"data left\"><label for=\"formSuper\">{$lang['strsuper']}</label></th>\n";
349
            echo "\t\t<td class=\"data1\"><input type=\"checkbox\" id=\"formSuper\" name=\"formSuper\"",
350
            (isset($_POST['formSuper'])) ? ' checked="checked"' : '', " /></td>\n\t</tr>\n";
351
            echo "\t<tr>\n\t\t<th class=\"data left\"><label for=\"formCreateDB\">{$lang['strcreatedb']}</label></th>\n";
352
            echo "\t\t<td class=\"data1\"><input type=\"checkbox\" id=\"formCreateDB\" name=\"formCreateDB\"",
353
            (isset($_POST['formCreateDB'])) ? ' checked="checked"' : '', " /></td>\n\t</tr>\n";
354
            echo "\t<tr>\n\t\t<th class=\"data left\">{$lang['strexpires']}</th>\n";
355
            echo "\t\t<td class=\"data1\"><input size=\"16\" name=\"formExpires\" value=\"", htmlspecialchars($_POST['formExpires']), "\" /></td>\n\t</tr>\n";
356
            echo "\t<tr>\n\t\t<th class=\"data left\">{$lang['strpassword']}</th>\n";
357
            echo "\t\t<td class=\"data1\"><input type=\"password\" size=\"16\" name=\"formPassword\" value=\"", htmlspecialchars($_POST['formPassword']), "\" /></td>\n\t</tr>\n";
358
            echo "\t<tr>\n\t\t<th class=\"data left\">{$lang['strconfirm']}</th>\n";
359
            echo "\t\t<td class=\"data1\"><input type=\"password\" size=\"16\" name=\"formConfirm\" value=\"\" /></td>\n\t</tr>\n";
360
            echo "</table>\n";
361
            echo "<p><input type=\"hidden\" name=\"action\" value=\"save_edit\" />\n";
362
            echo '<input type="hidden" name="username" value="', htmlspecialchars($_REQUEST['username']), "\" />\n";
363
            echo $this->misc->form;
364
            echo "<input type=\"submit\" name=\"alter\" value=\"{$lang['stralter']}\" />\n";
365
            echo "<input type=\"submit\" name=\"cancel\" value=\"{$lang['strcancel']}\" /></p>\n";
366
            echo "</form>\n";
367
        } else {
368
            echo "<p>{$lang['strnodata']}</p>\n";
369
        }
370
    }
371
372
    /**
373
     * Function to save after editing a user.
374
     */
375
    public function doSaveEdit()
376
    {
377
        $conf = $this->conf;
0 ignored issues
show
Unused Code introduced by
The assignment to $conf is dead and can be removed.
Loading history...
378
379
        $lang = $this->lang;
380
        $data = $this->misc->getDatabaseAccessor();
381
382
        // Check name and password
383
        if (isset($_POST['newname']) && '' == $_POST['newname']) {
384
            $this->doEdit($lang['struserneedsname']);
385
        } elseif ($_POST['formPassword'] != $_POST['formConfirm']) {
386
            $this->doEdit($lang['strpasswordconfirm']);
387
        } else {
388
            if (isset($_POST['newname'])) {
389
                $status = $data->setRenameUser($_POST['username'], $_POST['formPassword'], isset($_POST['formCreateDB']), isset($_POST['formSuper']), $_POST['formExpires'], $_POST['newname']);
390
            } else {
391
                $status = $data->setUser($_POST['username'], $_POST['formPassword'], isset($_POST['formCreateDB']), isset($_POST['formSuper']), $_POST['formExpires']);
392
            }
393
394
            if (0 == $status) {
395
                $this->doDefault($lang['struserupdated']);
396
            } else {
397
                $this->doEdit($lang['struserupdatedbad']);
398
            }
399
        }
400
    }
401
402
    /**
403
     * Show confirmation of drop and perform actual drop.
404
     *
405
     * @param mixed $confirm
1 ignored issue
show
Coding Style introduced by
Missing parameter comment
Loading history...
406
     */
407
    public function doDrop($confirm)
408
    {
409
        $conf = $this->conf;
0 ignored issues
show
Unused Code introduced by
The assignment to $conf is dead and can be removed.
Loading history...
410
411
        $lang = $this->lang;
412
        $data = $this->misc->getDatabaseAccessor();
413
414
        if ($confirm) {
415
            $this->printTrail('user');
416
            $this->printTitle($lang['strdrop'], 'pg.user.drop');
417
418
            echo '<p>', sprintf($lang['strconfdropuser'], $this->misc->printVal($_REQUEST['username'])), "</p>\n";
419
420
            echo '<form action="'.\SUBFOLDER."/src/views/users.php\" method=\"post\">\n";
421
            echo "<p><input type=\"hidden\" name=\"action\" value=\"drop\" />\n";
422
            echo '<input type="hidden" name="username" value="', htmlspecialchars($_REQUEST['username']), "\" />\n";
423
            echo $this->misc->form;
424
            echo "<input type=\"submit\" name=\"drop\" value=\"{$lang['strdrop']}\" />\n";
425
            echo "<input type=\"submit\" name=\"cancel\" value=\"{$lang['strcancel']}\" /></p>\n";
426
            echo "</form>\n";
427
        } else {
428
            $status = $data->dropUser($_REQUEST['username']);
429
            if (0 == $status) {
430
                $this->doDefault($lang['struserdropped']);
431
            } else {
432
                $this->doDefault($lang['struserdroppedbad']);
433
            }
434
        }
435
    }
436
437
    /**
438
     * Displays a screen where they can enter a new user.
439
     *
440
     * @param mixed $msg
1 ignored issue
show
Coding Style introduced by
Missing parameter comment
Loading history...
441
     */
442
    public function doCreate($msg = '')
443
    {
444
        $conf = $this->conf;
0 ignored issues
show
Unused Code introduced by
The assignment to $conf is dead and can be removed.
Loading history...
445
446
        $lang = $this->lang;
447
        $data = $this->misc->getDatabaseAccessor();
448
449
        if (!isset($_POST['formUsername'])) {
450
            $_POST['formUsername'] = '';
451
        }
452
453
        if (!isset($_POST['formPassword'])) {
454
            $_POST['formPassword'] = '';
455
        }
456
457
        if (!isset($_POST['formConfirm'])) {
458
            $_POST['formConfirm'] = '';
459
        }
460
461
        if (!isset($_POST['formExpires'])) {
462
            $_POST['formExpires'] = '';
463
        }
464
465
        $this->printTrail('server');
466
        $this->printTitle($lang['strcreateuser'], 'pg.user.create');
467
        $this->printMsg($msg);
468
469
        echo '<form action="'.\SUBFOLDER."/src/views/users.php\" method=\"post\">\n";
470
        echo "<table>\n";
471
        echo "\t<tr>\n\t\t<th class=\"data left required\">{$lang['strusername']}</th>\n";
472
        echo "\t\t<td class=\"data1\"><input size=\"15\" maxlength=\"{$data->_maxNameLen}\" name=\"formUsername\" value=\"", htmlspecialchars($_POST['formUsername']), "\" /></td>\n\t</tr>\n";
473
        echo "\t<tr>\n\t\t<th class=\"data left\">{$lang['strpassword']}</th>\n";
474
        echo "\t\t<td class=\"data1\"><input size=\"15\" type=\"password\" name=\"formPassword\" value=\"", htmlspecialchars($_POST['formPassword']), "\" /></td>\n\t</tr>\n";
475
        echo "\t<tr>\n\t\t<th class=\"data left\">{$lang['strconfirm']}</th>\n";
476
        echo "\t\t<td class=\"data1\"><input size=\"15\" type=\"password\" name=\"formConfirm\" value=\"", htmlspecialchars($_POST['formConfirm']), "\" /></td>\n\t</tr>\n";
477
        echo "\t<tr>\n\t\t<th class=\"data left\"><label for=\"formSuper\">{$lang['strsuper']}</label></th>\n";
478
        echo "\t\t<td class=\"data1\"><input type=\"checkbox\" id=\"formSuper\" name=\"formSuper\"",
479
        (isset($_POST['formSuper'])) ? ' checked="checked"' : '', " /></td>\n\t</tr>\n";
480
        echo "\t<tr>\n\t\t<th class=\"data left\"><label for=\"formCreateDB\">{$lang['strcreatedb']}</label></th>\n";
481
        echo "\t\t<td class=\"data1\"><input type=\"checkbox\" id=\"formCreateDB\" name=\"formCreateDB\"",
482
        (isset($_POST['formCreateDB'])) ? ' checked="checked"' : '', " /></td>\n\t</tr>\n";
483
        echo "\t<tr>\n\t\t<th class=\"data left\">{$lang['strexpires']}</th>\n";
484
        echo "\t\t<td class=\"data1\"><input size=\"30\" name=\"formExpires\" value=\"", htmlspecialchars($_POST['formExpires']), "\" /></td>\n\t</tr>\n";
485
        echo "</table>\n";
486
        echo "<p><input type=\"hidden\" name=\"action\" value=\"save_create\" />\n";
487
        echo $this->misc->form;
488
        echo "<input type=\"submit\" name=\"create\" value=\"{$lang['strcreate']}\" />\n";
489
        echo "<input type=\"submit\" name=\"cancel\" value=\"{$lang['strcancel']}\" /></p>\n";
490
        echo "</form>\n";
491
    }
492
493
    /**
494
     * Actually creates the new user in the database.
495
     */
496
    public function doSaveCreate()
497
    {
498
        $conf = $this->conf;
0 ignored issues
show
Unused Code introduced by
The assignment to $conf is dead and can be removed.
Loading history...
499
500
        $lang = $this->lang;
501
        $data = $this->misc->getDatabaseAccessor();
502
503
        // Check data
504
        if ('' == $_POST['formUsername']) {
505
            $this->doCreate($lang['struserneedsname']);
506
        } elseif ($_POST['formPassword'] != $_POST['formConfirm']) {
507
            $this->doCreate($lang['strpasswordconfirm']);
508
        } else {
509
            $status = $data->createUser(
510
                $_POST['formUsername'],
511
                $_POST['formPassword'],
512
                isset($_POST['formCreateDB']),
513
                isset($_POST['formSuper']),
514
                $_POST['formExpires'],
515
                []
516
            );
517
            if (0 == $status) {
518
                $this->doDefault($lang['strusercreated']);
519
            } else {
520
                $this->doCreate($lang['strusercreatedbad']);
521
            }
522
        }
523
    }
524
}
525