Welcome to mirror list, hosted at ThFree Co, Russian Federation.

Import.php « Display « classes « libraries - github.com/phpmyadmin/phpmyadmin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 5ca08aa3919649e0a074499127a39f3e460c2b1d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
 * functions for displaying import for: server, database and table
 *
 * @package PhpMyAdmin
 */
declare(strict_types=1);

namespace PhpMyAdmin\Display;

use PhpMyAdmin\Core;
use PhpMyAdmin\Display\ImportAjax;
use PhpMyAdmin\Encoding;
use PhpMyAdmin\Message;
use PhpMyAdmin\Plugins;
use PhpMyAdmin\Template;

/**
 * PhpMyAdmin\Display\Import class
 *
 * @package PhpMyAdmin
 */
class Import
{
    /**
     * Gets HTML to display import dialogs
     *
     * @param string $importType    Import type: server|database|table
     * @param string $db            Selected DB
     * @param string $table         Selected Table
     * @param int    $maxUploadSize Max upload size
     *
     * @return string HTML
     */
    public static function get($importType, $db, $table, $maxUploadSize)
    {
        global $cfg;
        global $SESSION_KEY;

        $template = new Template();

        list(
            $SESSION_KEY,
            $uploadId,
        ) = ImportAjax::uploadProgressSetup();

        /* Scan for plugins */
        /* @var $importList \PhpMyAdmin\Plugins\ImportPlugin[] */
        $importList = Plugins::getPlugins(
            "import",
            'libraries/classes/Plugins/Import/',
            $importType
        );

        /* Fail if we didn't find any plugin */
        if (empty($importList)) {
            Message::error(
                __(
                    'Could not load import plugins, please check your installation!'
                )
            )->display();
            exit;
        }

        if (Core::isValid($_REQUEST['offset'], 'numeric')) {
            $offset = intval($_REQUEST['offset']);
        }
        if (isset($_REQUEST['timeout_passed'])) {
            $timeoutPassed = $_REQUEST['timeout_passed'];
        }

        $localImportFile = '';
        if (isset($_REQUEST['local_import_file'])) {
            $localImportFile = $_REQUEST['local_import_file'];
        }

        // zip, gzip and bzip2 encode features
        $compressions = [];
        if ($cfg['GZipDump'] && function_exists('gzopen')) {
            $compressions[] = 'gzip';
        }
        if ($cfg['BZipDump'] && function_exists('bzopen')) {
            $compressions[] = 'bzip2';
        }
        if ($cfg['ZipDump'] && function_exists('zip_open')) {
            $compressions[] = 'zip';
        }

        return $template->render('display/import/import', [
            'upload_id' => $uploadId,
            'handler' => $_SESSION[$SESSION_KEY]["handler"],
            'id_key' => $_SESSION[$SESSION_KEY]['handler']::getIdKey(),
            'pma_theme_image' => $GLOBALS['pmaThemeImage'],
            'import_type' => $importType,
            'db' => $db,
            'table' => $table,
            'max_upload_size' => $maxUploadSize,
            'import_list' => $importList,
            'local_import_file' => $localImportFile,
            'is_upload' => $GLOBALS['is_upload'],
            'upload_dir' => isset($cfg['UploadDir']) ? $cfg['UploadDir'] : null,
            'timeout_passed_global' => isset($GLOBALS['timeout_passed']) ? $GLOBALS['timeout_passed'] : null,
            'compressions' => $compressions,
            'is_encoding_supported' => Encoding::isSupported(),
            'encodings' => Encoding::listEncodings(),
            'import_charset' => isset($cfg['Import']['charset']) ? $cfg['Import']['charset'] : null,
            'dbi' => $GLOBALS['dbi'],
            'disable_is' => $cfg['Server']['DisableIS'],
            'timeout_passed' => isset($timeoutPassed) ? $timeoutPassed : null,
            'offset' => isset($offset) ? $offset : null,
            'can_convert_kanji' => Encoding::canConvertKanji(),
        ]);
    }
}