pageSettings->init('Import'); $pageSettingsErrorHtml = $this->pageSettings->getErrorHTML(); $pageSettingsHtml = $this->pageSettings->getHTML(); $this->response->addScriptFiles(['import.js']); if (Current::$database === '') { return $this->response->missingParameterError('db'); } if (Current::$table === '') { return $this->response->missingParameterError('table'); } UrlParams::$params = ['db' => Current::$database, 'table' => Current::$table]; $databaseName = DatabaseName::tryFrom($request->getParam('db')); if ($databaseName === null || ! $this->dbTableExists->selectDatabase($databaseName)) { return $this->response->respondWithErrorMessage(__('No database selected.')); } $tableName = TableName::tryFrom($request->getParam('table')); if ($tableName === null || ! $this->dbTableExists->hasTable($databaseName, $tableName)) { return $this->response->respondWithErrorMessage(__('No table selected.')); } UrlParams::$params['goto'] = Url::getFromRoute('/table/import'); UrlParams::$params['back'] = Url::getFromRoute('/table/import'); $uploadId = $this->ajax->uploadProgressSetup(); ImportSettings::$importType = 'table'; $importList = Plugins::getImport(); if ($importList === []) { $this->response->addHTML(Message::error(__( 'Could not load import plugins, please check your installation!', ))); return $this->response->response(); } $offset = null; if (is_numeric($request->getParam('offset'))) { $offset = (int) $request->getParam('offset'); } $timeoutPassed = $request->getParam('timeout_passed'); $localImportFile = $request->getParam('local_import_file'); $compressions = Import::getCompressions($this->config); $charsets = Charsets::getCharsets($this->dbi, $this->config->selectedServer['DisableIS']); $idKey = $_SESSION[Ajax::SESSION_KEY]['handler']::getIdKey(); $hiddenInputs = [ $idKey => $uploadId, 'import_type' => 'table', 'db' => Current::$database, 'table' => Current::$table, ]; $pluginName = $this->getFormat($request->getParam('format')); $pluginName = Plugins::validatePluginNameOrUseDefault($importList, $pluginName); $choice = Plugins::getChoice($importList, $pluginName); $options = Plugins::getOptions(PluginType::Import, $importList); $skipQueriesDefault = $this->getSkipQueries($request->getParam('skip_queries')); $isAllowInterruptChecked = Plugins::checkboxCheck(PluginType::Import, 'allow_interrupt'); $maxUploadSize = Util::getUploadSizeInBytes(); $this->response->render('table/import/index', [ 'page_settings_error_html' => $pageSettingsErrorHtml, 'page_settings_html' => $pageSettingsHtml, 'upload_id' => $uploadId, 'handler' => $_SESSION[Ajax::SESSION_KEY]['handler'], 'hidden_inputs' => $hiddenInputs, 'db' => Current::$database, 'table' => Current::$table, 'max_upload_size' => $maxUploadSize, 'formatted_maximum_upload_size' => Util::getFormattedMaximumUploadSize($maxUploadSize), 'plugins_choice' => $choice, 'options' => $options, 'skip_queries_default' => $skipQueriesDefault, 'is_allow_interrupt_checked' => $isAllowInterruptChecked, 'local_import_file' => $localImportFile, 'is_upload' => $this->config->isUploadEnabled(), 'upload_dir' => $this->config->config->UploadDir , 'timeout_passed_global' => ImportSettings::$timeoutPassed, 'compressions' => $compressions, 'is_encoding_supported' => Encoding::isSupported(), 'encodings' => Encoding::listEncodings(), 'import_charset' => $this->config->config->Import->charset, 'timeout_passed' => $timeoutPassed, 'offset' => $offset, 'can_convert_kanji' => Encoding::canConvertKanji(), 'charsets' => $charsets, 'is_foreign_key_check' => ForeignKey::isCheckEnabled(), 'user_upload_dir' => Util::userDir($this->config->selectedServer['user'], $this->config->config->UploadDir), 'local_files' => Import::getLocalFiles($this->config, $importList), ]); return $this->response->response(); } private function getFormat(mixed $formatParam): string { if (is_string($formatParam) && $formatParam !== '') { return $formatParam; } return $this->config->settings['Import']['format']; } private function getSkipQueries(mixed $skipQueriesParam): int { if (is_numeric($skipQueriesParam) && $skipQueriesParam >= 0) { return (int) $skipQueriesParam; } return $this->config->settings['Import']['skip_queries']; } }