Passed
Push — master ( 76dca6...1e403f )
by William
08:14
created

db_routines.php (1 issue)

1
<?php
2
/* vim: set expandtab sw=4 ts=4 sts=4: */
3
/**
4
 * Routines management.
5
 *
6
 * @package PhpMyAdmin
7
 */
8
declare(strict_types=1);
9
10
use PhpMyAdmin\CheckUserPrivileges;
11
use PhpMyAdmin\Controllers\Database\RoutinesController;
12
use PhpMyAdmin\Response;
13
use PhpMyAdmin\Url;
14
use PhpMyAdmin\Util;
15
16
if (! defined('ROOT_PATH')) {
17
    define('ROOT_PATH', __DIR__ . DIRECTORY_SEPARATOR);
18
}
19
20
require_once ROOT_PATH . 'libraries/common.inc.php';
21
22
$checkUserPrivileges = new CheckUserPrivileges($GLOBALS['dbi']);
23
$checkUserPrivileges->getPrivileges();
24
25
$response = Response::getInstance();
26
27
$_PMA_RTE = 'RTN';
28
29
$controller = new RoutinesController(
30
    $response,
31
    $GLOBALS['dbi'],
32
    $db
33
);
34
35
if (! $response->isAjax()) {
36
    /**
37
     * Displays the header and tabs
38
     */
39
    if (! empty($table) && in_array($table, $GLOBALS['dbi']->getTables($db))) {
40
        include_once ROOT_PATH . 'libraries/tbl_common.inc.php';
41
    } else {
42
        $table = '';
43
        include_once ROOT_PATH . 'libraries/db_common.inc.php';
44
45
        list(
0 ignored issues
show
Comprehensibility Best Practice introduced by
This list assign is not used and could be removed.
Loading history...
46
            $tables,
47
            $num_tables,
48
            $total_num_tables,
49
            $sub_part,
50
            $is_show_stats,
51
            $db_is_system_schema,
52
            $tooltip_truename,
53
            $tooltip_aliasname,
54
            $pos
55
            ) = Util::getDbInfo($db, isset($sub_part) ? $sub_part : '');
56
    }
57
} else {
58
    /**
59
     * Since we did not include some libraries, we need
60
     * to manually select the required database and
61
     * create the missing $url_query variable
62
     */
63
    if (strlen($db) > 0) {
64
        $GLOBALS['dbi']->selectDb($db);
65
        if (! isset($url_query)) {
66
            $url_query = Url::getCommon(
67
                [
68
                    'db' => $db,
69
                    'table' => $table,
70
                ]
71
            );
72
        }
73
    }
74
}
75
76
$controller->index([
77
    'type' => $_REQUEST['type'] ?? null,
78
]);
79